mp_aframe_create:
   53|   971k|{
   54|   971k|    struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe);
  ------------------
  |  |   27|   971k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   971k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   971k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|   971k|    frame->av_frame = av_frame_alloc();
   56|   971k|    MP_HANDLE_OOM(frame->av_frame);
  ------------------
  |  |  206|   971k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   971k|        void *oom_p_ = (x);     \
  |  |  208|   971k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 971k]
  |  |  ------------------
  |  |  209|   971k|            abort();            \
  |  |  210|   971k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 971k]
  |  |  ------------------
  ------------------
   57|   971k|    talloc_set_destructor(frame, free_frame);
  ------------------
  |  |   41|   971k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   58|   971k|    mp_aframe_reset(frame);
   59|   971k|    return frame;
   60|   971k|}
mp_aframe_new_ref:
   63|  11.9k|{
   64|  11.9k|    if (!frame)
  ------------------
  |  Branch (64:9): [True: 0, False: 11.9k]
  ------------------
   65|      0|        return NULL;
   66|       |
   67|  11.9k|    struct mp_aframe *dst = mp_aframe_create();
   68|       |
   69|  11.9k|    dst->chmap = frame->chmap;
   70|  11.9k|    dst->format = frame->format;
   71|  11.9k|    dst->pts = frame->pts;
   72|  11.9k|    dst->speed = frame->speed;
   73|       |
   74|  11.9k|    if (mp_aframe_is_allocated(frame)) {
  ------------------
  |  Branch (74:9): [True: 0, False: 11.9k]
  ------------------
   75|      0|        if (av_frame_ref(dst->av_frame, frame->av_frame) < 0)
  ------------------
  |  Branch (75:13): [True: 0, False: 0]
  ------------------
   76|      0|            abort();
   77|  11.9k|    } else {
   78|       |        // av_frame_ref() would fail.
   79|  11.9k|        mp_aframe_config_copy(dst, frame);
   80|  11.9k|    }
   81|       |
   82|  11.9k|    return dst;
   83|  11.9k|}
mp_aframe_reset:
   87|  1.04M|{
   88|  1.04M|    av_frame_unref(frame->av_frame);
   89|  1.04M|    frame->chmap.num = 0;
   90|  1.04M|    frame->format = 0;
   91|  1.04M|    frame->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.04M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   92|  1.04M|    frame->speed = 1.0;
   93|  1.04M|}
mp_aframe_alloc_data:
  110|  7.80k|{
  111|  7.80k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (111:9): [True: 0, False: 7.80k]
  ------------------
  112|      0|        return false;
  113|  7.80k|    struct mp_aframe_pool *p = mp_aframe_pool_create(NULL);
  114|  7.80k|    int r = mp_aframe_pool_allocate(p, frame, samples);
  115|  7.80k|    talloc_free(p);
  ------------------
  |  |   47|  7.80k|#define talloc_free                     ta_free
  ------------------
  116|  7.80k|    return r >= 0;
  117|  7.80k|}
mp_aframe_from_avframe:
  123|   802k|{
  124|   802k|    if (!av_frame || av_frame->width > 0 || av_frame->height > 0)
  ------------------
  |  Branch (124:9): [True: 0, False: 802k]
  |  Branch (124:22): [True: 0, False: 802k]
  |  Branch (124:45): [True: 0, False: 802k]
  ------------------
  125|      0|        return NULL;
  126|       |
  127|   802k|    if (!av_channel_layout_check(&av_frame->ch_layout))
  ------------------
  |  Branch (127:9): [True: 0, False: 802k]
  ------------------
  128|      0|        return NULL;
  129|       |
  130|   802k|    struct mp_chmap converted_map = { 0 };
  131|   802k|    if (!mp_chmap_from_av_layout(&converted_map, &av_frame->ch_layout)) {
  ------------------
  |  Branch (131:9): [True: 1.97k, False: 800k]
  ------------------
  132|  1.97k|        return NULL;
  133|  1.97k|    }
  134|       |
  135|   800k|    int format = af_from_avformat(av_frame->format);
  136|   800k|    if (!format && av_frame->format != AV_SAMPLE_FMT_NONE)
  ------------------
  |  Branch (136:9): [True: 0, False: 800k]
  |  Branch (136:20): [True: 0, False: 0]
  ------------------
  137|      0|        return NULL;
  138|       |
  139|   800k|    struct mp_aframe *frame = mp_aframe_create();
  140|       |
  141|       |    // This also takes care of forcing refcounting.
  142|   800k|    if (av_frame_ref(frame->av_frame, av_frame) < 0)
  ------------------
  |  Branch (142:9): [True: 0, False: 800k]
  ------------------
  143|      0|        abort();
  144|       |
  145|   800k|    frame->format = format;
  146|   800k|    frame->chmap = converted_map;
  147|       |
  148|   800k|    if (av_frame->opaque_ref) {
  ------------------
  |  Branch (148:9): [True: 0, False: 800k]
  ------------------
  149|      0|        struct avframe_opaque *op = (void *)av_frame->opaque_ref->data;
  150|      0|        frame->speed = op->speed;
  151|      0|    }
  152|       |
  153|   800k|    return frame;
  154|   800k|}
mp_aframe_is_allocated:
  198|  2.72M|{
  199|  2.72M|    return frame->av_frame->buf[0] || frame->av_frame->extended_data[0];
  ------------------
  |  Branch (199:12): [True: 2.67M, False: 46.3k]
  |  Branch (199:39): [True: 0, False: 46.3k]
  ------------------
  200|  2.72M|}
mp_aframe_config_copy:
  204|  68.0k|{
  205|  68.0k|    mp_aframe_reset(dst);
  206|       |
  207|  68.0k|    dst->chmap = src->chmap;
  208|  68.0k|    dst->format = src->format;
  209|       |
  210|  68.0k|    mp_aframe_copy_attributes(dst, src);
  211|       |
  212|  68.0k|    dst->av_frame->sample_rate = src->av_frame->sample_rate;
  213|  68.0k|    dst->av_frame->format = src->av_frame->format;
  214|       |
  215|  68.0k|    if (av_channel_layout_copy(&dst->av_frame->ch_layout, &src->av_frame->ch_layout) < 0)
  ------------------
  |  Branch (215:9): [True: 0, False: 68.0k]
  ------------------
  216|      0|        abort();
  217|  68.0k|}
mp_aframe_copy_attributes:
  222|  68.0k|{
  223|  68.0k|    dst->pts = src->pts;
  224|  68.0k|    dst->speed = src->speed;
  225|       |
  226|  68.0k|    int rate = dst->av_frame->sample_rate;
  227|       |
  228|  68.0k|    if (av_frame_copy_props(dst->av_frame, src->av_frame) < 0)
  ------------------
  |  Branch (228:9): [True: 0, False: 68.0k]
  ------------------
  229|      0|        abort();
  230|       |
  231|  68.0k|    dst->av_frame->sample_rate = rate;
  232|  68.0k|}
mp_aframe_config_equals:
  237|  3.20M|{
  238|  3.20M|    struct mp_chmap ca = {0}, cb = {0};
  239|  3.20M|    mp_aframe_get_chmap(a, &ca);
  240|  3.20M|    mp_aframe_get_chmap(b, &cb);
  241|  3.20M|    return mp_chmap_equals(&ca, &cb) &&
  ------------------
  |  Branch (241:12): [True: 3.17M, False: 29.4k]
  ------------------
  242|  3.17M|           mp_aframe_get_rate(a) == mp_aframe_get_rate(b) &&
  ------------------
  |  Branch (242:12): [True: 3.17M, False: 5.57k]
  ------------------
  243|  3.17M|           mp_aframe_get_format(a) == mp_aframe_get_format(b);
  ------------------
  |  Branch (243:12): [True: 3.17M, False: 0]
  ------------------
  244|  3.20M|}
mp_aframe_config_is_valid:
  248|  9.04k|{
  249|  9.04k|    return frame->format && frame->chmap.num && frame->av_frame->sample_rate;
  ------------------
  |  Branch (249:12): [True: 9.04k, False: 0]
  |  Branch (249:29): [True: 9.04k, False: 0]
  |  Branch (249:49): [True: 9.04k, False: 0]
  ------------------
  250|  9.04k|}
mp_aframe_get_data_ro:
  256|   805k|{
  257|   805k|    return mp_aframe_is_allocated(frame) ? frame->av_frame->extended_data : NULL;
  ------------------
  |  Branch (257:12): [True: 805k, False: 0]
  ------------------
  258|   805k|}
mp_aframe_get_data_rw:
  263|  1.87M|{
  264|  1.87M|    if (!mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (264:9): [True: 0, False: 1.87M]
  ------------------
  265|      0|        return NULL;
  266|  1.87M|    if (av_frame_make_writable(frame->av_frame) < 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 1.87M]
  ------------------
  267|      0|        return NULL;
  268|  1.87M|    return frame->av_frame->extended_data;
  269|  1.87M|}
mp_aframe_get_format:
  272|  13.8M|{
  273|  13.8M|    return frame->format;
  274|  13.8M|}
mp_aframe_get_chmap:
  277|  7.22M|{
  278|  7.22M|    if (!mp_chmap_is_valid(&frame->chmap))
  ------------------
  |  Branch (278:9): [True: 24.5k, False: 7.20M]
  ------------------
  279|  24.5k|        return false;
  280|  7.20M|    *out = frame->chmap;
  281|       |    return true;
  282|  7.22M|}
mp_aframe_get_channels:
  285|  2.93M|{
  286|  2.93M|    return frame->chmap.num;
  287|  2.93M|}
mp_aframe_get_rate:
  290|  14.3M|{
  291|  14.3M|    return frame->av_frame->sample_rate;
  292|  14.3M|}
mp_aframe_get_size:
  295|  9.35M|{
  296|  9.35M|    return frame->av_frame->nb_samples;
  297|  9.35M|}
mp_aframe_get_pts:
  300|  8.00M|{
  301|  8.00M|    return frame->pts;
  302|  8.00M|}
mp_aframe_set_format:
  305|  10.8k|{
  306|  10.8k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (306:9): [True: 0, False: 10.8k]
  ------------------
  307|      0|        return false;
  308|  10.8k|    enum AVSampleFormat av_format = af_to_avformat(format);
  309|  10.8k|    if (av_format == AV_SAMPLE_FMT_NONE && format) {
  ------------------
  |  Branch (309:9): [True: 0, False: 10.8k]
  |  Branch (309:44): [True: 0, False: 0]
  ------------------
  310|      0|        if (af_fmt_is_pcm(format))
  ------------------
  |  Branch (310:13): [True: 0, False: 0]
  ------------------
  311|      0|            return false;
  312|      0|        av_format = af_fmt_to_bytes(format) == 4 ? AV_SAMPLE_FMT_S32
  ------------------
  |  Branch (312:21): [True: 0, False: 0]
  ------------------
  313|      0|                                                 : AV_SAMPLE_FMT_S16;
  314|      0|    }
  315|  10.8k|    frame->format = format;
  316|  10.8k|    frame->av_frame->format = av_format;
  317|       |    return true;
  318|  10.8k|}
mp_aframe_set_chmap:
  321|  7.92k|{
  322|  7.92k|    if (!mp_chmap_is_valid(in) && !mp_chmap_is_empty(in))
  ------------------
  |  Branch (322:9): [True: 0, False: 7.92k]
  |  Branch (322:35): [True: 0, False: 0]
  ------------------
  323|      0|        return false;
  324|  7.92k|    if (mp_aframe_is_allocated(frame) && in->num != frame->chmap.num)
  ------------------
  |  Branch (324:9): [True: 0, False: 7.92k]
  |  Branch (324:42): [True: 0, False: 0]
  ------------------
  325|      0|        return false;
  326|       |
  327|  7.92k|    frame->chmap = *in;
  328|  7.92k|    mp_chmap_to_av_layout(&frame->av_frame->ch_layout, in);
  329|       |
  330|       |    return true;
  331|  7.92k|}
mp_aframe_set_rate:
  334|  7.92k|{
  335|  7.92k|    if (rate < 1 || rate > 10000000)
  ------------------
  |  Branch (335:9): [True: 0, False: 7.92k]
  |  Branch (335:21): [True: 113, False: 7.80k]
  ------------------
  336|    113|        return false;
  337|  7.80k|    frame->av_frame->sample_rate = rate;
  338|       |    return true;
  339|  7.92k|}
mp_aframe_set_pts:
  350|  1.60M|{
  351|  1.60M|    frame->pts = pts;
  352|  1.60M|}
mp_aframe_get_effective_rate:
  381|  6.40M|{
  382|  6.40M|    return mp_aframe_get_rate(frame) / frame->speed;
  383|  6.40M|}
mp_aframe_get_planes:
  387|  2.93M|{
  388|  2.93M|    return af_fmt_is_planar(mp_aframe_get_format(frame))
  ------------------
  |  Branch (388:12): [True: 2.80M, False: 134k]
  ------------------
  389|  2.93M|           ? mp_aframe_get_channels(frame) : 1;
  390|  2.93M|}
mp_aframe_get_sstride:
  394|  2.41M|{
  395|  2.41M|    int format = mp_aframe_get_format(frame);
  396|  2.41M|    return af_fmt_to_bytes(format) *
  397|  2.41M|           (af_fmt_is_planar(format) ? 1 : mp_aframe_get_channels(frame));
  ------------------
  |  Branch (397:13): [True: 2.27M, False: 134k]
  ------------------
  398|  2.41M|}
mp_aframe_get_total_plane_samples:
  402|   564k|{
  403|   564k|    return frame->av_frame->nb_samples *
  404|   564k|           (af_fmt_is_planar(mp_aframe_get_format(frame))
  ------------------
  |  Branch (404:13): [True: 564k, False: 0]
  ------------------
  405|   564k|            ? 1 : mp_aframe_get_channels(frame));
  406|   564k|}
mp_aframe_format_str_buf:
  409|  32.0k|{
  410|  32.0k|    char ch[128];
  411|  32.0k|    mp_chmap_to_str_buf(ch, sizeof(ch), &fmt->chmap);
  412|  32.0k|    char *hr_ch = mp_chmap_to_str_hr(&fmt->chmap);
  ------------------
  |  |  153|  32.0k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  32.0k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  413|  32.0k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (413:9): [True: 1.18k, False: 30.8k]
  ------------------
  414|  1.18k|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  415|  32.0k|    snprintf(buf, buf_size, "%dHz %s %dch %s", fmt->av_frame->sample_rate,
  416|  32.0k|             ch, fmt->chmap.num, af_fmt_to_str(fmt->format));
  417|  32.0k|    return buf;
  418|  32.0k|}
mp_aframe_skip_samples:
  422|   805k|{
  423|   805k|    mp_assert(samples >= 0 && samples <= mp_aframe_get_size(f));
  ------------------
  |  |   41|   805k|#define mp_assert assert
  ------------------
  |  Branch (423:5): [True: 805k, False: 0]
  |  Branch (423:5): [True: 805k, False: 0]
  ------------------
  424|       |
  425|   805k|    if (av_frame_make_writable(f->av_frame) < 0)
  ------------------
  |  Branch (425:9): [True: 0, False: 805k]
  ------------------
  426|      0|        return; // go complain to ffmpeg
  427|       |
  428|   805k|    int num_planes = mp_aframe_get_planes(f);
  429|   805k|    size_t sstride = mp_aframe_get_sstride(f);
  430|  1.66M|    for (int n = 0; n < num_planes; n++) {
  ------------------
  |  Branch (430:21): [True: 862k, False: 805k]
  ------------------
  431|   862k|        memmove(f->av_frame->extended_data[n],
  432|   862k|                f->av_frame->extended_data[n] + samples * sstride,
  433|   862k|                (f->av_frame->nb_samples - samples) * sstride);
  434|   862k|    }
  435|       |
  436|   805k|    f->av_frame->nb_samples -= samples;
  437|       |
  438|   805k|    if (f->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   805k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (438:9): [True: 805k, False: 115]
  ------------------
  439|   805k|        f->pts += samples / mp_aframe_get_effective_rate(f);
  440|   805k|}
mp_aframe_sanitize_float:
  449|   800k|{
  450|   800k|    int format = af_fmt_from_planar(mp_aframe_get_format(mpa));
  451|   800k|    if (format != AF_FORMAT_FLOAT && format != AF_FORMAT_DOUBLE)
  ------------------
  |  Branch (451:9): [True: 277k, False: 523k]
  |  Branch (451:38): [True: 277k, False: 0]
  ------------------
  452|   277k|        return;
  453|   523k|    int num_planes = mp_aframe_get_planes(mpa);
  454|   523k|    uint8_t **planes = mp_aframe_get_data_rw(mpa);
  455|   523k|    if (!planes)
  ------------------
  |  Branch (455:9): [True: 0, False: 523k]
  ------------------
  456|      0|        return;
  457|  1.08M|    for (int p = 0; p < num_planes; p++) {
  ------------------
  |  Branch (457:21): [True: 564k, False: 523k]
  ------------------
  458|   564k|        void *ptr = planes[p];
  459|   564k|        int total = mp_aframe_get_total_plane_samples(mpa);
  460|   564k|        switch (format) {
  ------------------
  |  Branch (460:17): [True: 564k, False: 0]
  ------------------
  461|   564k|        case AF_FORMAT_FLOAT:
  ------------------
  |  Branch (461:9): [True: 564k, False: 0]
  ------------------
  462|   187M|            for (int s = 0; s < total; s++)
  ------------------
  |  Branch (462:29): [True: 186M, False: 564k]
  ------------------
  463|   186M|                sanitizef(((float *)ptr)[s]);
  ------------------
  |  |  443|   187M|#define sanitizef(f) do {       \
  |  |  444|   186M|    if (!isnormal(f))           \
  |  |  ------------------
  |  |  |  Branch (444:9): [True: 113M, False: 73.4M]
  |  |  ------------------
  |  |  445|   186M|        (f) = 0;                \
  |  |  446|   186M|} while (0)
  |  |  ------------------
  |  |  |  Branch (446:10): [Folded, False: 186M]
  |  |  ------------------
  ------------------
  464|   564k|            break;
  465|      0|        case AF_FORMAT_DOUBLE:
  ------------------
  |  Branch (465:9): [True: 0, False: 564k]
  ------------------
  466|      0|            for (int s = 0; s < total; s++)
  ------------------
  |  Branch (466:29): [True: 0, False: 0]
  ------------------
  467|       |                sanitizef(((double *)ptr)[s]);
  ------------------
  |  |  443|      0|#define sanitizef(f) do {       \
  |  |  444|      0|    if (!isnormal(f))           \
  |  |  ------------------
  |  |  |  Branch (444:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  445|      0|        (f) = 0;                \
  |  |  446|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (446:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  468|      0|            break;
  469|   564k|        }
  470|   564k|    }
  471|   523k|}
mp_aframe_end_pts:
  475|  3.20M|{
  476|  3.20M|    double rate = mp_aframe_get_effective_rate(f);
  477|  3.20M|    if (f->pts == MP_NOPTS_VALUE || rate <= 0)
  ------------------
  |  |   39|  6.40M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (477:9): [True: 506, False: 3.20M]
  |  Branch (477:37): [True: 0, False: 3.20M]
  ------------------
  478|    506|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|    506|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  479|  3.20M|    return f->pts + f->av_frame->nb_samples / rate;
  480|  3.20M|}
mp_aframe_duration:
  484|   800k|{
  485|   800k|    double rate = mp_aframe_get_effective_rate(f);
  486|   800k|    if (rate <= 0)
  ------------------
  |  Branch (486:9): [True: 0, False: 800k]
  ------------------
  487|      0|        return 0;
  488|   800k|    return f->av_frame->nb_samples / rate;
  489|   800k|}
mp_aframe_clip_timestamps:
  495|  1.60M|{
  496|  1.60M|    double f_end = mp_aframe_end_pts(f);
  497|  1.60M|    double rate = mp_aframe_get_effective_rate(f);
  498|  1.60M|    if (f_end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (498:9): [True: 253, False: 1.60M]
  ------------------
  499|    253|        return;
  500|  1.60M|    if (end != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (500:9): [True: 0, False: 1.60M]
  ------------------
  501|      0|        if (f_end >= end) {
  ------------------
  |  Branch (501:13): [True: 0, False: 0]
  ------------------
  502|      0|            if (f->pts >= end) {
  ------------------
  |  Branch (502:17): [True: 0, False: 0]
  ------------------
  503|      0|                f->av_frame->nb_samples = 0;
  504|      0|            } else {
  505|      0|                if (!af_fmt_is_pcm(mp_aframe_get_format(f)))
  ------------------
  |  Branch (505:21): [True: 0, False: 0]
  ------------------
  506|      0|                    return;
  507|      0|                int new = (end - f->pts) * rate;
  508|      0|                f->av_frame->nb_samples = MPCLAMP(new, 0, f->av_frame->nb_samples);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  509|      0|            }
  510|      0|        }
  511|      0|    }
  512|  1.60M|    if (start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (512:9): [True: 0, False: 1.60M]
  ------------------
  513|      0|        if (f->pts < start) {
  ------------------
  |  Branch (513:13): [True: 0, False: 0]
  ------------------
  514|      0|            if (f_end <= start) {
  ------------------
  |  Branch (514:17): [True: 0, False: 0]
  ------------------
  515|      0|                f->av_frame->nb_samples = 0;
  516|      0|                f->pts = f_end;
  517|      0|            } else {
  518|      0|                if (!af_fmt_is_pcm(mp_aframe_get_format(f)))
  ------------------
  |  Branch (518:21): [True: 0, False: 0]
  ------------------
  519|      0|                    return;
  520|      0|                int skip = (start - f->pts) * rate;
  521|      0|                skip = MPCLAMP(skip, 0, f->av_frame->nb_samples);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  522|      0|                mp_aframe_skip_samples(f, skip);
  523|      0|            }
  524|      0|        }
  525|      0|    }
  526|  1.60M|}
mp_aframe_approx_byte_size:
  614|  1.60M|{
  615|       |    // God damn, AVFrame is too fucking annoying. Just go with the size that
  616|       |    // allocating a new frame would use.
  617|  1.60M|    int planes = mp_aframe_get_planes(frame);
  618|  1.60M|    size_t sstride = mp_aframe_get_sstride(frame);
  619|  1.60M|    int samples = frame->av_frame->nb_samples;
  620|  1.60M|    int plane_size = MP_ALIGN_UP(sstride * MPMAX(samples, 1), 32);
  ------------------
  |  |   53|  3.20M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 1.60M, False: 23]
  |  |  ------------------
  ------------------
  621|  1.60M|    return plane_size * planes + sizeof(*frame);
  622|  1.60M|}
mp_aframe_pool_create:
  630|  7.80k|{
  631|  7.80k|    return talloc_zero(ta_parent, struct mp_aframe_pool);
  ------------------
  |  |   27|  7.80k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  7.80k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  7.80k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|  7.80k|}
mp_aframe_pool_allocate:
  643|  7.80k|{
  644|  7.80k|    int planes = mp_aframe_get_planes(frame);
  645|  7.80k|    size_t sstride = mp_aframe_get_sstride(frame);
  646|       |    // FFmpeg hardcodes similar hidden possibly-requirements in a number of
  647|       |    // places: av_frame_get_buffer(), libavcodec's get_buffer(), mem.c,
  648|       |    // probably more.
  649|  7.80k|    int align_samples = MP_ALIGN_UP(MPMAX(samples, 1), 32);
  ------------------
  |  |   53|  15.6k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 7.80k, False: 0]
  |  |  ------------------
  ------------------
  650|  7.80k|    int plane_size = MP_ALIGN_UP(sstride * align_samples, 64);
  ------------------
  |  |   53|  7.80k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  651|  7.80k|    int size = plane_size * planes;
  652|       |
  653|  7.80k|    if (size <= 0 || mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (653:9): [True: 0, False: 7.80k]
  |  Branch (653:22): [True: 0, False: 7.80k]
  ------------------
  654|      0|        return -1;
  655|       |
  656|  7.80k|    if (!pool->avpool || size > pool->element_size) {
  ------------------
  |  Branch (656:9): [True: 7.80k, False: 0]
  |  Branch (656:26): [True: 0, False: 0]
  ------------------
  657|  7.80k|        size_t alloc = ta_calc_prealloc_elems(size);
  658|  7.80k|        if (alloc >= INT_MAX)
  ------------------
  |  Branch (658:13): [True: 0, False: 7.80k]
  ------------------
  659|      0|            return -1;
  660|  7.80k|        av_buffer_pool_uninit(&pool->avpool);
  661|  7.80k|        pool->element_size = alloc;
  662|  7.80k|        pool->avpool = av_buffer_pool_init(pool->element_size, NULL);
  663|  7.80k|        if (!pool->avpool)
  ------------------
  |  Branch (663:13): [True: 0, False: 7.80k]
  ------------------
  664|      0|            return -1;
  665|  7.80k|        talloc_set_destructor(pool, mp_aframe_pool_destructor);
  ------------------
  |  |   41|  7.80k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  666|  7.80k|    }
  667|       |
  668|       |    // Yes, you have to do all this shit manually.
  669|       |    // At least it's less stupid than av_frame_get_buffer(), which just wipes
  670|       |    // the entire frame struct on error for no reason.
  671|  7.80k|    AVFrame *av_frame = frame->av_frame;
  672|  7.80k|    if (av_frame->extended_data != av_frame->data)
  ------------------
  |  Branch (672:9): [True: 0, False: 7.80k]
  ------------------
  673|      0|        av_freep(&av_frame->extended_data); // sigh
  674|  7.80k|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (674:9): [True: 292, False: 7.51k]
  ------------------
  675|    292|        av_frame->extended_data =
  676|    292|            av_calloc(planes, sizeof(av_frame->extended_data[0]));
  677|    292|        MP_HANDLE_OOM(av_frame->extended_data);
  ------------------
  |  |  206|    292|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    292|        void *oom_p_ = (x);     \
  |  |  208|    292|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 292]
  |  |  ------------------
  |  |  209|    292|            abort();            \
  |  |  210|    292|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 292]
  |  |  ------------------
  ------------------
  678|  7.51k|    } else {
  679|  7.51k|        av_frame->extended_data = av_frame->data;
  680|  7.51k|    }
  681|  7.80k|    av_frame->buf[0] = av_buffer_pool_get(pool->avpool);
  682|  7.80k|    if (!av_frame->buf[0])
  ------------------
  |  Branch (682:9): [True: 0, False: 7.80k]
  ------------------
  683|      0|        return -1;
  684|  7.80k|    av_frame->linesize[0] = samples * sstride;
  685|  36.3k|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (685:21): [True: 28.5k, False: 7.80k]
  ------------------
  686|  28.5k|        av_frame->extended_data[n] = av_frame->buf[0]->data + n * plane_size;
  687|  7.80k|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (687:9): [True: 292, False: 7.51k]
  ------------------
  688|  2.62k|        for (int n = 0; n < AV_NUM_DATA_POINTERS; n++)
  ------------------
  |  Branch (688:25): [True: 2.33k, False: 292]
  ------------------
  689|  2.33k|            av_frame->data[n] = av_frame->extended_data[n];
  690|    292|    }
  691|  7.80k|    av_frame->nb_samples = samples;
  692|       |
  693|  7.80k|    return 0;
  694|  7.80k|}
aframe.c:free_frame:
   47|   971k|{
   48|   971k|    struct mp_aframe *frame = ptr;
   49|   971k|    av_frame_free(&frame->av_frame);
   50|   971k|}
aframe.c:mp_aframe_pool_destructor:
  635|  7.80k|{
  636|  7.80k|    struct mp_aframe_pool *pool = p;
  637|  7.80k|    av_buffer_pool_uninit(&pool->avpool);
  638|  7.80k|}

mp_chmap_is_valid:
  126|  7.27M|{
  127|  7.27M|    bool mapped[MP_SPEAKER_ID_COUNT] = {0};
  128|  15.1M|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (128:21): [True: 7.92M, False: 7.27M]
  ------------------
  129|  7.92M|        int sp = src->speaker[n];
  130|  7.92M|        if (sp >= MP_SPEAKER_ID_COUNT || mapped[sp])
  ------------------
  |  Branch (130:13): [True: 0, False: 7.92M]
  |  Branch (130:42): [True: 0, False: 7.92M]
  ------------------
  131|      0|            return false;
  132|  7.92M|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (132:13): [True: 7.60M, False: 319k]
  ------------------
  133|  7.60M|            mapped[sp] = true;
  134|  7.92M|    }
  135|  7.27M|    return src->num > 0;
  136|  7.27M|}
mp_chmap_is_unknown:
  146|   120k|{
  147|   215k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (147:21): [True: 211k, False: 4.87k]
  ------------------
  148|   211k|        if (src->speaker[n] != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (148:13): [True: 115k, False: 95.7k]
  ------------------
  149|   115k|            return false;
  150|   211k|    }
  151|  4.87k|    return mp_chmap_is_valid(src);
  152|   120k|}
mp_chmap_equals:
  156|  4.24M|{
  157|  4.24M|    if (a->num != b->num)
  ------------------
  |  Branch (157:9): [True: 221k, False: 4.02M]
  ------------------
  158|   221k|        return false;
  159|  8.30M|    for (int n = 0; n < a->num; n++) {
  ------------------
  |  Branch (159:21): [True: 4.28M, False: 4.02M]
  ------------------
  160|  4.28M|        if (a->speaker[n] != b->speaker[n])
  ------------------
  |  Branch (160:13): [True: 2.46k, False: 4.27M]
  ------------------
  161|  2.46k|            return false;
  162|  4.28M|    }
  163|  4.02M|    return true;
  164|  4.02M|}
mp_chmap_equals_reordered:
  168|   241k|{
  169|   241k|    struct mp_chmap t1 = *a, t2 = *b;
  170|   241k|    mp_chmap_reorder_norm(&t1);
  171|   241k|    mp_chmap_reorder_norm(&t2);
  172|   241k|    return mp_chmap_equals(&t1, &t2);
  173|   241k|}
mp_chmap_reorder_norm:
  189|   483k|{
  190|   483k|    uint8_t *arr = &map->speaker[0];
  191|   483k|    qsort(arr, map->num, 1, comp_uint8);
  192|   483k|}
mp_chmap_remove_na:
  196|  39.9k|{
  197|  39.9k|    struct mp_chmap new = {0};
  198|   185k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (198:21): [True: 145k, False: 39.9k]
  ------------------
  199|   145k|        int sp = map->speaker[n];
  200|   145k|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (200:13): [True: 85.6k, False: 60.0k]
  ------------------
  201|  85.6k|            new.speaker[new.num++] = map->speaker[n];
  202|   145k|    }
  203|  39.9k|    *map = new;
  204|  39.9k|}
mp_chmap_from_channels:
  218|  15.7k|{
  219|  15.7k|    *dst = (struct mp_chmap) {0};
  220|  15.7k|    if (num_channels >= 0 && num_channels < MP_ARRAY_SIZE(default_layouts))
  ------------------
  |  |   49|  15.7k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (220:9): [True: 15.7k, False: 0]
  |  Branch (220:30): [True: 9.02k, False: 6.72k]
  ------------------
  221|  9.02k|        *dst = default_layouts[num_channels];
  222|  15.7k|    if (!dst->num)
  ------------------
  |  Branch (222:9): [True: 7.67k, False: 8.07k]
  ------------------
  223|  7.67k|        mp_chmap_set_unknown(dst, num_channels);
  224|  15.7k|}
mp_chmap_set_unknown:
  232|  7.67k|{
  233|  7.67k|    if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  7.67k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (233:9): [True: 0, False: 7.67k]
  |  Branch (233:29): [True: 5.03k, False: 2.63k]
  ------------------
  234|  5.03k|        *dst = (struct mp_chmap) {0};
  235|  5.03k|    } else {
  236|  2.63k|        dst->num = num_channels;
  237|  52.6k|        for (int n = 0; n < dst->num; n++)
  ------------------
  |  Branch (237:25): [True: 50.0k, False: 2.63k]
  ------------------
  238|  50.0k|            dst->speaker[n] = MP_SPEAKER_ID_NA;
  239|  2.63k|    }
  240|  7.67k|}
mp_chmap_to_lavc_unchecked:
  249|  7.63k|{
  250|  7.63k|    struct mp_chmap t = *src;
  251|  7.63k|    if (t.num > 64)
  ------------------
  |  Branch (251:9): [True: 0, False: 7.63k]
  ------------------
  252|      0|        return 0;
  253|       |    // lavc has no concept for unknown layouts yet, so pick something that does
  254|       |    // the job of signaling the number of channels, even if it makes no sense
  255|       |    // as a proper layout.
  256|  7.63k|    if (mp_chmap_is_unknown(&t))
  ------------------
  |  Branch (256:9): [True: 0, False: 7.63k]
  ------------------
  257|      0|        return t.num == 64 ? (uint64_t)-1 : (1ULL << t.num) - 1;
  ------------------
  |  Branch (257:16): [True: 0, False: 0]
  ------------------
  258|  7.63k|    uint64_t mask = 0;
  259|  24.6k|    for (int n = 0; n < t.num; n++) {
  ------------------
  |  Branch (259:21): [True: 17.0k, False: 7.63k]
  ------------------
  260|  17.0k|        if (t.speaker[n] < 64) // ignore MP_SPEAKER_ID_NA etc.
  ------------------
  |  Branch (260:13): [True: 17.0k, False: 0]
  ------------------
  261|  17.0k|            mask |= 1ULL << t.speaker[n];
  262|  17.0k|    }
  263|  7.63k|    return mask;
  264|  7.63k|}
mp_chmap_to_lavc:
  269|  8.67k|{
  270|  8.67k|    if (!mp_chmap_is_lavc(src))
  ------------------
  |  Branch (270:9): [True: 1.04k, False: 7.63k]
  ------------------
  271|  1.04k|        return 0;
  272|  7.63k|    return mp_chmap_to_lavc_unchecked(src);
  273|  8.67k|}
mp_chmap_from_lavc:
  279|  1.61M|{
  280|  1.61M|    dst->num = 0;
  281|   104M|    for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (281:21): [True: 103M, False: 1.61M]
  ------------------
  282|   103M|        if (src & (1ULL << n)) {
  ------------------
  |  Branch (282:13): [True: 1.70M, False: 101M]
  ------------------
  283|  1.70M|            if (dst->num >= MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  1.70M|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (283:17): [True: 0, False: 1.70M]
  ------------------
  284|      0|                dst->num = 0;
  285|      0|                return;
  286|      0|            }
  287|  1.70M|            dst->speaker[dst->num] = n;
  288|  1.70M|            dst->num++;
  289|  1.70M|        }
  290|   103M|    }
  291|  1.61M|}
mp_chmap_is_lavc:
  294|  8.67k|{
  295|  8.67k|    if (!mp_chmap_is_valid(src))
  ------------------
  |  Branch (295:9): [True: 1.04k, False: 7.63k]
  ------------------
  296|  1.04k|        return false;
  297|  7.63k|    if (mp_chmap_is_unknown(src))
  ------------------
  |  Branch (297:9): [True: 0, False: 7.63k]
  ------------------
  298|      0|        return true;
  299|       |    // lavc's channel layout is a bit mask, and channels are always ordered
  300|       |    // from LSB to MSB speaker bits, so speaker IDs have to increase.
  301|  7.63k|    mp_assert(src->num > 0);
  ------------------
  |  |   41|  7.63k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 7.63k, False: 0]
  ------------------
  302|  17.0k|    for (int n = 1; n < src->num; n++) {
  ------------------
  |  Branch (302:21): [True: 9.37k, False: 7.63k]
  ------------------
  303|  9.37k|        if (src->speaker[n - 1] >= src->speaker[n])
  ------------------
  |  Branch (303:13): [True: 0, False: 9.37k]
  ------------------
  304|      0|            return false;
  305|  9.37k|    }
  306|  24.6k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (306:21): [True: 17.0k, False: 7.63k]
  ------------------
  307|  17.0k|        if (src->speaker[n] >= 64)
  ------------------
  |  Branch (307:13): [True: 0, False: 17.0k]
  ------------------
  308|      0|            return false;
  309|  17.0k|    }
  310|  7.63k|    return true;
  311|  7.63k|}
mp_chmap_to_str_buf:
  368|  95.9k|{
  369|  95.9k|    buf[0] = '\0';
  370|       |
  371|  95.9k|    if (mp_chmap_is_unknown(src)) {
  ------------------
  |  Branch (371:9): [True: 2.05k, False: 93.9k]
  ------------------
  372|  2.05k|        snprintf(buf, buf_size, "unknown%d", src->num);
  373|  2.05k|        return buf;
  374|  2.05k|    }
  375|       |
  376|   299k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (376:21): [True: 205k, False: 93.9k]
  ------------------
  377|   205k|        int sp = src->speaker[n];
  378|   205k|        const char *s = sp < MP_SPEAKER_ID_COUNT ? speaker_names[sp][0] : NULL;
  ------------------
  |  Branch (378:25): [True: 205k, False: 0]
  ------------------
  379|   205k|        char sp_buf[10];
  380|   205k|        if (!s) {
  ------------------
  |  Branch (380:13): [True: 0, False: 205k]
  ------------------
  381|      0|            snprintf(sp_buf, sizeof(sp_buf), "sp%d", sp);
  382|      0|            s = sp_buf;
  383|      0|        }
  384|   205k|        mp_snprintf_cat(buf, buf_size, "%s%s", n > 0 ? "-" : "", s);
  ------------------
  |  Branch (384:48): [True: 112k, False: 92.4k]
  ------------------
  385|   205k|    }
  386|       |
  387|       |    // To standard layout name
  388|   560k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (388:21): [True: 559k, False: 1.20k]
  ------------------
  389|   559k|        if (strcmp(buf, std_layout_names[n][1]) == 0) {
  ------------------
  |  Branch (389:13): [True: 92.7k, False: 466k]
  ------------------
  390|  92.7k|            snprintf(buf, buf_size, "%s", std_layout_names[n][0]);
  391|  92.7k|            break;
  392|  92.7k|        }
  393|   559k|    }
  394|       |
  395|  93.9k|    return buf;
  396|  95.9k|}
mp_chmap_from_str:
  403|   233k|{
  404|       |    // Single number corresponds to mp_chmap_from_channels()
  405|   233k|    if (src.len > 0) {
  ------------------
  |  Branch (405:9): [True: 233k, False: 0]
  ------------------
  406|   233k|        bstr t = src;
  407|   233k|        bool unknown = bstr_eatstart0(&t, "unknown");
  408|   233k|        bstr rest;
  409|   233k|        long long count = bstrtoll(t, &rest, 10);
  410|   233k|        if (rest.len == 0) {
  ------------------
  |  Branch (410:13): [True: 0, False: 233k]
  ------------------
  411|      0|            struct mp_chmap res;
  412|      0|            if (unknown) {
  ------------------
  |  Branch (412:17): [True: 0, False: 0]
  ------------------
  413|      0|                mp_chmap_set_unknown(&res, count);
  414|      0|            } else {
  415|      0|                mp_chmap_from_channels(&res, count);
  416|      0|            }
  417|      0|            if (mp_chmap_is_valid(&res)) {
  ------------------
  |  Branch (417:17): [True: 0, False: 0]
  ------------------
  418|      0|                *dst = res;
  419|      0|                return true;
  420|      0|            }
  421|      0|        }
  422|   233k|    }
  423|       |
  424|       |    // From standard layout name
  425|  1.84M|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (425:21): [True: 1.84M, False: 0]
  ------------------
  426|  1.84M|        if (bstr_equals0(src, std_layout_names[n][0])) {
  ------------------
  |  Branch (426:13): [True: 233k, False: 1.61M]
  ------------------
  427|   233k|            src = bstr0(std_layout_names[n][1]);
  428|   233k|            break;
  429|   233k|        }
  430|  1.84M|    }
  431|       |
  432|       |    // Explicit speaker list (separated by "-")
  433|   233k|    struct mp_chmap res = {0};
  434|   844k|    while (src.len) {
  ------------------
  |  Branch (434:12): [True: 610k, False: 233k]
  ------------------
  435|   610k|        bstr s;
  436|   610k|        bstr_split_tok(src, "-", &s, &src);
  437|   610k|        int speaker = -1;
  438|  2.52M|        for (int n = 0; n < MP_SPEAKER_ID_COUNT; n++) {
  ------------------
  |  Branch (438:25): [True: 2.52M, False: 0]
  ------------------
  439|  2.52M|            const char *name = speaker_names[n][0];
  440|  2.52M|            if (name && bstr_equals0(s, name)) {
  ------------------
  |  Branch (440:17): [True: 2.45M, False: 68.8k]
  |  Branch (440:25): [True: 610k, False: 1.84M]
  ------------------
  441|   610k|                speaker = n;
  442|   610k|                break;
  443|   610k|            }
  444|  2.52M|        }
  445|   610k|        if (speaker < 0) {
  ------------------
  |  Branch (445:13): [True: 0, False: 610k]
  ------------------
  446|      0|            if (bstr_eatstart0(&s, "sp")) {
  ------------------
  |  Branch (446:17): [True: 0, False: 0]
  ------------------
  447|      0|                long long sp = bstrtoll(s, &s, 0);
  448|      0|                if (s.len == 0 && sp >= 0 && sp < MP_SPEAKER_ID_COUNT)
  ------------------
  |  Branch (448:21): [True: 0, False: 0]
  |  Branch (448:35): [True: 0, False: 0]
  |  Branch (448:46): [True: 0, False: 0]
  ------------------
  449|      0|                    speaker = sp;
  450|      0|            }
  451|      0|            if (speaker < 0)
  ------------------
  |  Branch (451:17): [True: 0, False: 0]
  ------------------
  452|      0|                return false;
  453|      0|        }
  454|   610k|        if (res.num >= MP_NUM_CHANNELS)
  ------------------
  |  |   25|   610k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (454:13): [True: 0, False: 610k]
  ------------------
  455|      0|            return false;
  456|   610k|        res.speaker[res.num] = speaker;
  457|   610k|        res.num++;
  458|   610k|    }
  459|       |
  460|   233k|    *dst = res;
  461|       |    return true;
  462|   233k|}
mp_chmap_to_str_hr_buf:
  468|  39.9k|{
  469|  39.9k|    struct mp_chmap map = *src;
  470|  39.9k|    mp_chmap_remove_na(&map);
  471|   234k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (471:21): [True: 233k, False: 500]
  ------------------
  472|   233k|        struct mp_chmap s;
  473|   233k|        if (mp_chmap_from_str(&s, bstr0(std_layout_names[n][0])) &&
  ------------------
  |  Branch (473:13): [True: 233k, False: 0]
  ------------------
  474|   233k|            mp_chmap_equals_reordered(&s, &map))
  ------------------
  |  Branch (474:13): [True: 39.4k, False: 194k]
  ------------------
  475|  39.4k|        {
  476|  39.4k|            map = s;
  477|  39.4k|            break;
  478|  39.4k|        }
  479|   233k|    }
  480|  39.9k|    return mp_chmap_to_str_buf(buf, buf_size, &map);
  481|  39.9k|}
chmap.c:comp_uint8:
  182|  1.61M|{
  183|  1.61M|    return *(const uint8_t *)a - *(const uint8_t *)b;
  184|  1.61M|}

mp_chmap_from_av_layout:
   24|  1.62M|{
   25|  1.62M|    *dst = (struct mp_chmap) {0};
   26|       |
   27|  1.62M|    switch (src->order) {
   28|  15.7k|    case AV_CHANNEL_ORDER_UNSPEC:
  ------------------
  |  Branch (28:5): [True: 15.7k, False: 1.61M]
  ------------------
   29|  15.7k|        mp_chmap_from_channels(dst, src->nb_channels);
   30|  15.7k|        return dst->num == src->nb_channels;
   31|  1.61M|    case AV_CHANNEL_ORDER_NATIVE:
  ------------------
  |  Branch (31:5): [True: 1.61M, False: 15.7k]
  ------------------
   32|  1.61M|        mp_chmap_from_lavc(dst, src->u.mask);
   33|  1.61M|        return dst->num == src->nb_channels;
   34|      0|    default:
  ------------------
  |  Branch (34:5): [True: 0, False: 1.62M]
  ------------------
   35|       |        // TODO: handle custom layouts
   36|       |        return false;
   37|  1.62M|    }
   38|  1.62M|}
mp_chmap_to_av_layout:
   41|  8.97k|{
   42|  8.97k|    *dst = (AVChannelLayout){
   43|  8.97k|        .order = AV_CHANNEL_ORDER_UNSPEC,
   44|  8.97k|        .nb_channels = src->num,
   45|  8.97k|    };
   46|       |
   47|       |    // TODO: handle custom layouts
   48|  8.97k|    if (!mp_chmap_is_unknown(src)) {
  ------------------
  |  Branch (48:9): [True: 8.67k, False: 292]
  ------------------
   49|  8.67k|        av_channel_layout_from_mask(dst, mp_chmap_to_lavc(src));
   50|  8.67k|    }
   51|  8.97k|}

mp_chmap_sel_add_any:
   88|  7.98k|{
   89|       |    s->allow_any = true;
   90|  7.98k|}
mp_chmap_sel_add_map:
  100|  7.95k|{
  101|  7.95k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (101:9): [True: 0, False: 7.95k]
  ------------------
  102|      0|        return;
  103|  7.95k|    if (!s->chmaps)
  ------------------
  |  Branch (103:9): [True: 7.95k, False: 0]
  ------------------
  104|  7.95k|        s->chmaps = s->chmaps_storage;
  105|  7.95k|    if (s->num_chmaps == MP_ARRAY_SIZE(s->chmaps_storage)) {
  ------------------
  |  |   49|  7.95k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (105:9): [True: 0, False: 7.95k]
  ------------------
  106|      0|        if (!s->tmp)
  ------------------
  |  Branch (106:13): [True: 0, False: 0]
  ------------------
  107|      0|            return;
  108|      0|        s->chmaps = talloc_memdup(s->tmp, s->chmaps, sizeof(s->chmaps_storage));
  ------------------
  |  |   49|      0|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|      0|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|      0|    }
  110|  7.95k|    if (s->chmaps != s->chmaps_storage)
  ------------------
  |  Branch (110:9): [True: 0, False: 7.95k]
  ------------------
  111|      0|        MP_TARRAY_GROW(s->tmp, s->chmaps, s->num_chmaps);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  112|  7.95k|    s->chmaps[s->num_chmaps++] = *map;
  113|  7.95k|}
mp_chmap_sel_adjust:
  182|  15.9k|{
  183|  15.9k|    if (test_layout(s, map))
  ------------------
  |  Branch (183:9): [True: 15.9k, False: 0]
  ------------------
  184|  15.9k|        return true;
  185|      0|    if (mp_chmap_is_unknown(map)) {
  ------------------
  |  Branch (185:9): [True: 0, False: 0]
  ------------------
  186|      0|        struct mp_chmap t = {0};
  187|      0|        if (mp_chmap_sel_get_def(s, &t, map->num) && test_layout(s, &t)) {
  ------------------
  |  Branch (187:13): [True: 0, False: 0]
  |  Branch (187:54): [True: 0, False: 0]
  ------------------
  188|      0|            *map = t;
  189|      0|            return true;
  190|      0|        }
  191|      0|    }
  192|       |
  193|      0|    if (mp_chmap_sel_fallback(s, map))
  ------------------
  |  Branch (193:9): [True: 0, False: 0]
  ------------------
  194|      0|        return true;
  195|       |
  196|      0|    for (int i = 0; i < MP_ARRAY_SIZE(speaker_replacements); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (196:21): [True: 0, False: 0]
  ------------------
  197|      0|        struct mp_chmap  t = *map;
  198|      0|        struct mp_chmap *r = (struct mp_chmap *)speaker_replacements[i];
  199|      0|        if (replace_speakers(&t, r) && test_layout(s, &t)) {
  ------------------
  |  Branch (199:13): [True: 0, False: 0]
  |  Branch (199:40): [True: 0, False: 0]
  ------------------
  200|      0|            *map = t;
  201|      0|            return true;
  202|      0|        }
  203|      0|    }
  204|       |
  205|       |    // Fallback to mono/stereo as last resort
  206|      0|    *map = (struct mp_chmap) MP_CHMAP_INIT_STEREO;
  ------------------
  |  |  119|      0|#define MP_CHMAP_INIT_STEREO MP_CHMAP2(FL, FR)
  |  |  ------------------
  |  |  |  |   88|      0|    {2, {MP_SP(a), MP_SP(b)}}
  |  |  |  |  ------------------
  |  |  |  |  |  |   85|      0|#define MP_SP(speaker) MP_SPEAKER_ID_ ## speaker
  |  |  |  |  ------------------
  |  |  |  |                   {2, {MP_SP(a), MP_SP(b)}}
  |  |  |  |  ------------------
  |  |  |  |  |  |   85|      0|#define MP_SP(speaker) MP_SPEAKER_ID_ ## speaker
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|      0|    if (test_layout(s, map))
  ------------------
  |  Branch (207:9): [True: 0, False: 0]
  ------------------
  208|      0|        return true;
  209|      0|    *map = (struct mp_chmap) MP_CHMAP_INIT_MONO;
  ------------------
  |  |  118|      0|#define MP_CHMAP_INIT_MONO {1, {MP_SPEAKER_ID_FC}}
  ------------------
  210|      0|    if (test_layout(s, map))
  ------------------
  |  Branch (210:9): [True: 0, False: 0]
  ------------------
  211|      0|        return true;
  212|      0|    *map = (struct mp_chmap) {0};
  213|       |    return false;
  214|      0|}
mp_chmap_sel_fallback:
  309|  7.98k|{
  310|  7.98k|    struct mp_chmap best = {0};
  311|       |
  312|  7.98k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (312:21): [True: 0, False: 7.98k]
  ------------------
  313|      0|        struct mp_chmap e = s->chmaps[n];
  314|       |
  315|      0|        if (mp_chmap_is_unknown(&e))
  ------------------
  |  Branch (315:13): [True: 0, False: 0]
  ------------------
  316|      0|            continue;
  317|       |
  318|      0|        if (mp_chmap_is_better(map, &best, &e))
  ------------------
  |  Branch (318:13): [True: 0, False: 0]
  ------------------
  319|      0|            best = e;
  320|      0|    }
  321|       |
  322|  7.98k|    if (best.num) {
  ------------------
  |  Branch (322:9): [True: 0, False: 7.98k]
  ------------------
  323|      0|        *map = best;
  324|      0|        return true;
  325|      0|    }
  326|       |
  327|  7.98k|    return false;
  328|  7.98k|}
mp_chmal_sel_log:
  359|  7.98k|{
  360|  7.98k|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (360:9): [True: 0, False: 7.98k]
  ------------------
  361|      0|        return;
  362|       |
  363|  7.98k|    for (int i = 0; i < s->num_chmaps; i++)
  ------------------
  |  Branch (363:21): [True: 0, False: 7.98k]
  ------------------
  364|      0|        mp_msg(log, lev, " - %s\n", mp_chmap_to_str(&s->chmaps[i]));
  ------------------
  |  |  149|      0|#define mp_chmap_to_str(m) mp_chmap_to_str_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  148|      0|#define mp_chmap_to_str_(m, sz) mp_chmap_to_str_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  365|   527k|    for (int i = 0; i < MP_SPEAKER_ID_COUNT; i++) {
  ------------------
  |  Branch (365:21): [True: 519k, False: 7.98k]
  ------------------
  366|   519k|        if (!s->speakers[i])
  ------------------
  |  Branch (366:13): [True: 519k, False: 0]
  ------------------
  367|   519k|            continue;
  368|      0|        struct mp_chmap l = {.num = 1, .speaker = { i }};
  369|      0|        mp_msg(log, lev, " - #%s\n",
  370|      0|                    i == MP_SPEAKER_ID_FC ? "fc" : mp_chmap_to_str_hr(&l));
  ------------------
  |  |  153|      0|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|      0|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  |  Branch (370:21): [True: 0, False: 0]
  ------------------
  371|      0|    }
  372|  7.98k|    if (s->allow_waveext)
  ------------------
  |  Branch (372:9): [True: 0, False: 7.98k]
  ------------------
  373|      0|        mp_msg(log, lev, " - waveext\n");
  374|  7.98k|    if (s->allow_any)
  ------------------
  |  Branch (374:9): [True: 7.98k, False: 0]
  ------------------
  375|  7.98k|        mp_msg(log, lev, " - anything\n");
  376|  7.98k|}
mp_chmap_sel_list:
  381|  7.98k|{
  382|       |    // This is a separate function to keep messing with mp_chmap_sel internals
  383|       |    // within this source file.
  384|  7.98k|    struct mp_chmap_sel sel = {
  385|  7.98k|        .chmaps = maps,
  386|  7.98k|        .num_chmaps = num_maps,
  387|  7.98k|    };
  388|  7.98k|    mp_chmap_sel_fallback(&sel, c);
  389|  7.98k|}
chmap_sel.c:test_layout:
  167|  15.9k|{
  168|  15.9k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (168:9): [True: 0, False: 15.9k]
  ------------------
  169|      0|        return false;
  170|       |
  171|  15.9k|    return s->allow_any || test_waveext(s, map) || test_speakers(s, map) ||
  ------------------
  |  Branch (171:12): [True: 7.98k, False: 7.95k]
  |  Branch (171:28): [True: 0, False: 7.95k]
  |  Branch (171:52): [True: 0, False: 7.95k]
  ------------------
  172|  7.95k|           test_maps(s, map);
  ------------------
  |  Branch (172:12): [True: 7.95k, False: 0]
  ------------------
  173|  15.9k|}
chmap_sel.c:test_waveext:
  154|  7.95k|{
  155|  7.95k|    if (s->allow_waveext) {
  ------------------
  |  Branch (155:9): [True: 0, False: 7.95k]
  ------------------
  156|      0|        struct mp_chmap t = *map;
  157|      0|        mp_chmap_reorder_to_waveext(&t);
  ------------------
  |  |  177|      0|#define mp_chmap_reorder_to_waveext mp_chmap_reorder_to_lavc
  ------------------
  158|      0|        if (mp_chmap_is_waveext(&t)) {
  ------------------
  |  |  176|      0|#define mp_chmap_is_waveext mp_chmap_is_lavc
  ------------------
  |  Branch (158:13): [True: 0, False: 0]
  ------------------
  159|      0|            *map = t;
  160|      0|            return true;
  161|      0|        }
  162|      0|    }
  163|  7.95k|    return false;
  164|  7.95k|}
chmap_sel.c:test_speakers:
  134|  7.95k|{
  135|  7.95k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (135:21): [True: 7.95k, False: 0]
  ------------------
  136|  7.95k|        if (!s->speakers[map->speaker[n]])
  ------------------
  |  Branch (136:13): [True: 7.95k, False: 0]
  ------------------
  137|  7.95k|            return false;
  138|  7.95k|    }
  139|      0|    return true;
  140|  7.95k|}
chmap_sel.c:test_maps:
  143|  7.95k|{
  144|  7.95k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (144:21): [True: 7.95k, False: 0]
  ------------------
  145|  7.95k|        if (mp_chmap_equals_reordered(&s->chmaps[n], map)) {
  ------------------
  |  Branch (145:13): [True: 7.95k, False: 0]
  ------------------
  146|  7.95k|            *map = s->chmaps[n];
  147|  7.95k|            return true;
  148|  7.95k|        }
  149|  7.95k|    }
  150|      0|    return false;
  151|  7.95k|}

select_dsd_codec:
  260|  12.1k|{
  261|  12.1k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  12.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  12.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  12.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|  12.1k|    if (!codec)
  ------------------
  |  Branch (263:9): [True: 0, False: 12.1k]
  ------------------
  264|      0|        return list;
  265|       |
  266|  12.1k|    bool found = false;
  267|  73.1k|    for (int n = 0; n < MP_ARRAY_SIZE(dsd_codecs); n++)
  ------------------
  |  |   49|  73.1k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (267:21): [True: 60.9k, False: 12.1k]
  ------------------
  268|  60.9k|        found |= strcmp(dsd_codecs[n].codec, codec) == 0;
  269|  12.1k|    if (!found)
  ------------------
  |  Branch (269:9): [True: 12.0k, False: 127]
  ------------------
  270|  12.0k|        return list;
  271|       |
  272|    127|    bstr sel = bstr0(pref);
  273|    127|    while (sel.len) {
  ------------------
  |  Branch (273:12): [True: 0, False: 127]
  ------------------
  274|      0|        bstr entry;
  275|      0|        bstr_split_tok(sel, ",", &entry, &sel);
  276|      0|        if (bstr_equals0(entry, "dsd")) {
  ------------------
  |  Branch (276:13): [True: 0, False: 0]
  ------------------
  277|      0|            mp_add_decoder(list, codec, "dop",
  278|      0|                           "DSD to DSD-over-PCM (DoP) pass-through decoder");
  279|      0|            break;
  280|      0|        }
  281|      0|    }
  282|    127|    return list;
  283|  12.1k|}

ad_lavc.c:create:
  303|  12.2k|{
  304|  12.2k|    struct mp_filter *da = mp_filter_create(parent, &ad_lavc_filter);
  305|  12.2k|    if (!da)
  ------------------
  |  Branch (305:9): [True: 0, False: 12.2k]
  ------------------
  306|      0|        return NULL;
  307|       |
  308|  12.2k|    mp_filter_add_pin(da, MP_PIN_IN, "in");
  309|  12.2k|    mp_filter_add_pin(da, MP_PIN_OUT, "out");
  310|       |
  311|  12.2k|    da->log = mp_log_new(da, parent->log, NULL);
  312|       |
  313|  12.2k|    struct priv *priv = da->priv;
  314|  12.2k|    priv->codec = codec;
  315|  12.2k|    priv->public.f = da;
  316|       |
  317|  12.2k|    if (!init(da, codec, decoder)) {
  ------------------
  |  Branch (317:9): [True: 434, False: 11.7k]
  ------------------
  318|    434|        talloc_free(da);
  ------------------
  |  |   47|    434|#define talloc_free                     ta_free
  ------------------
  319|    434|        return NULL;
  320|    434|    }
  321|       |
  322|  11.7k|    codec->codec_desc = priv->avctx->codec_descriptor->long_name;
  323|  11.7k|    mp_chmap_from_av_layout(&priv->codec->channels, &priv->avctx->ch_layout);
  324|       |
  325|  11.7k|    return &priv->public;
  326|  12.2k|}
ad_lavc.c:ad_lavc_destroy:
  163|  12.2k|{
  164|  12.2k|    struct priv *ctx = da->priv;
  165|       |
  166|  12.2k|    avcodec_free_context(&ctx->avctx);
  167|  12.2k|    av_frame_free(&ctx->avframe);
  168|  12.2k|    mp_free_av_packet(&ctx->avpkt);
  169|  12.2k|}
ad_lavc.c:ad_lavc_process:
  286|  3.31M|{
  287|  3.31M|    struct priv *priv = ad->priv;
  288|       |
  289|  3.31M|    lavc_process(ad, &priv->state, send_packet, receive_frame);
  290|  3.31M|}
ad_lavc.c:send_packet:
  184|  1.23M|{
  185|  1.23M|    struct priv *priv = da->priv;
  186|  1.23M|    AVCodecContext *avctx = priv->avctx;
  187|       |
  188|       |    // If the decoder discards the timestamp for some reason, we use the
  189|       |    // interpolated PTS. Initialize it so that it works for the initial
  190|       |    // packet as well.
  191|  1.23M|    if (mpkt && priv->next_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.22M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (191:9): [True: 1.22M, False: 7.45k]
  |  Branch (191:17): [True: 10.5k, False: 1.21M]
  ------------------
  192|  10.5k|        priv->next_pts = mpkt->pts;
  193|       |
  194|  1.23M|    mp_set_av_packet(priv->avpkt, mpkt, &priv->codec_timebase);
  195|       |
  196|  1.23M|    int ret = avcodec_send_packet(avctx, mpkt ? priv->avpkt : NULL);
  ------------------
  |  Branch (196:42): [True: 1.22M, False: 7.45k]
  ------------------
  197|  1.23M|    if (ret < 0)
  ------------------
  |  Branch (197:9): [True: 426k, False: 808k]
  ------------------
  198|  1.23M|        MP_ERR(da, "Error decoding audio.\n");
  ------------------
  |  |   89|   426k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   426k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  199|  1.23M|    return ret;
  200|  1.23M|}
ad_lavc.c:receive_frame:
  203|  3.30M|{
  204|  3.30M|    struct priv *priv = da->priv;
  205|  3.30M|    AVCodecContext *avctx = priv->avctx;
  206|       |
  207|  3.30M|    int ret = avcodec_receive_frame(avctx, priv->avframe);
  208|       |
  209|  3.30M|    if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (209:9): [True: 7.45k, False: 3.29M]
  ------------------
  210|       |        // If flushing was initialized earlier and has ended now, make it start
  211|       |        // over in case we get new packets at some point in the future.
  212|       |        // (Don't reset the filter itself, we want to keep other state.)
  213|  7.45k|        avcodec_flush_buffers(priv->avctx);
  214|  7.45k|        return ret;
  215|  3.29M|    } else if (ret < 0 && ret != AVERROR(EAGAIN)) {
  ------------------
  |  Branch (215:16): [True: 2.49M, False: 802k]
  |  Branch (215:27): [True: 12.2k, False: 2.47M]
  ------------------
  216|  12.2k|        MP_ERR(da, "Error decoding audio.\n");
  ------------------
  |  |   89|  12.2k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  217|  12.2k|    }
  218|       |
  219|  3.29M|    if (priv->avframe->flags & AV_FRAME_FLAG_DISCARD)
  ------------------
  |  Branch (219:9): [True: 0, False: 3.29M]
  ------------------
  220|      0|        av_frame_unref(priv->avframe);
  221|       |
  222|  3.29M|    if (!priv->avframe->buf[0])
  ------------------
  |  Branch (222:9): [True: 2.49M, False: 802k]
  ------------------
  223|  2.49M|        return ret;
  224|       |
  225|   802k|    mp_codec_info_from_av(avctx, priv->codec);
  226|   802k|    mp_chmap_from_av_layout(&priv->codec->channels, &avctx->ch_layout);
  227|       |
  228|   802k|    double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase);
  229|       |
  230|   802k|    struct mp_aframe *mpframe = mp_aframe_from_avframe(priv->avframe);
  231|   802k|    if (!mpframe) {
  ------------------
  |  Branch (231:9): [True: 1.97k, False: 800k]
  ------------------
  232|  1.97k|        MP_ERR(da, "Converting libavcodec frame to mpv frame failed.\n");
  ------------------
  |  |   89|  1.97k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.97k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  233|  1.97k|        return ret;
  234|  1.97k|    }
  235|       |
  236|   800k|    if (priv->force_channel_map.num)
  ------------------
  |  Branch (236:9): [True: 0, False: 800k]
  ------------------
  237|      0|        mp_aframe_set_chmap(mpframe, &priv->force_channel_map);
  238|       |
  239|   800k|    if (out_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (239:9): [True: 1.39k, False: 799k]
  ------------------
  240|  1.39k|        out_pts = priv->next_pts;
  241|   800k|    mp_aframe_set_pts(mpframe, out_pts);
  242|       |
  243|   800k|    priv->next_pts = mp_aframe_end_pts(mpframe);
  244|       |
  245|   800k|    AVFrameSideData *sd =
  246|   800k|        av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
  247|   800k|    if (sd && sd->size >= 10) {
  ------------------
  |  Branch (247:9): [True: 0, False: 800k]
  |  Branch (247:15): [True: 0, False: 0]
  ------------------
  248|      0|        char *d = sd->data;
  249|      0|        priv->skip_samples += AV_RL32(d + 0);
  250|      0|        priv->trim_samples += AV_RL32(d + 4);
  251|      0|    }
  252|       |
  253|   800k|    if (!priv->preroll_done) {
  ------------------
  |  Branch (253:9): [True: 6.14k, False: 794k]
  ------------------
  254|       |        // Skip only if this isn't already handled by AV_FRAME_DATA_SKIP_SAMPLES.
  255|  6.14k|        if (!priv->skip_samples)
  ------------------
  |  Branch (255:13): [True: 6.14k, False: 0]
  ------------------
  256|  6.14k|            priv->skip_samples = avctx->delay;
  257|  6.14k|        priv->preroll_done = true;
  258|  6.14k|    }
  259|       |
  260|   800k|    uint32_t skip = MPMIN(priv->skip_samples, mp_aframe_get_size(mpframe));
  ------------------
  |  |   45|   800k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 800k]
  |  |  ------------------
  ------------------
  261|   800k|    if (skip) {
  ------------------
  |  Branch (261:9): [True: 0, False: 800k]
  ------------------
  262|      0|        mp_aframe_skip_samples(mpframe, skip);
  263|      0|        priv->skip_samples -= skip;
  264|      0|    }
  265|   800k|    uint32_t trim = MPMIN(priv->trim_samples, mp_aframe_get_size(mpframe));
  ------------------
  |  |   45|   800k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 800k]
  |  |  ------------------
  ------------------
  266|   800k|    if (trim) {
  ------------------
  |  Branch (266:9): [True: 0, False: 800k]
  ------------------
  267|      0|        mp_aframe_set_size(mpframe, mp_aframe_get_size(mpframe) - trim);
  268|      0|        priv->trim_samples -= trim;
  269|      0|    }
  270|       |
  271|       |    // Strip possibly bogus float values like Infinity, NaN, denormalized
  272|   800k|    mp_aframe_sanitize_float(mpframe);
  273|       |
  274|   800k|    if (mp_aframe_get_size(mpframe) > 0) {
  ------------------
  |  Branch (274:9): [True: 800k, False: 3]
  ------------------
  275|   800k|        *out = MAKE_FRAME(MP_FRAME_AUDIO, mpframe);
  ------------------
  |  |   57|   800k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
  276|   800k|    } else {
  277|      3|        talloc_free(mpframe);
  ------------------
  |  |   47|      3|#define talloc_free                     ta_free
  ------------------
  278|      3|    }
  279|       |
  280|   800k|    av_frame_unref(priv->avframe);
  281|       |
  282|   800k|    return ret;
  283|   802k|}
ad_lavc.c:init:
   85|  12.2k|{
   86|  12.2k|    struct priv *ctx = da->priv;
   87|  12.2k|    struct MPOpts *mpopts = mp_get_config_group(ctx, da->global, &mp_opt_root);
   88|  12.2k|    struct ad_lavc_params *opts =
   89|  12.2k|        mp_get_config_group(ctx, da->global, &ad_lavc_conf);
   90|  12.2k|    const AVCodec *lavc_codec;
   91|       |
   92|  12.2k|    ctx->codec_timebase = mp_get_codec_timebase(codec);
   93|       |
   94|  12.2k|    if (codec->force_channels)
  ------------------
  |  Branch (94:9): [True: 0, False: 12.2k]
  ------------------
   95|      0|        ctx->force_channel_map = codec->channels;
   96|       |
   97|  12.2k|    lavc_codec = avcodec_find_decoder_by_name(decoder);
   98|  12.2k|    if (!lavc_codec) {
  ------------------
  |  Branch (98:9): [True: 0, False: 12.2k]
  ------------------
   99|      0|        MP_ERR(da, "Cannot find codec '%s' in libavcodec...\n", decoder);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  100|      0|        return false;
  101|      0|    }
  102|       |
  103|  12.2k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  104|  12.2k|    MP_HANDLE_OOM(ctx->avctx);
  ------------------
  |  |  206|  12.2k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  12.2k|        void *oom_p_ = (x);     \
  |  |  208|  12.2k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 12.2k]
  |  |  ------------------
  |  |  209|  12.2k|            abort();            \
  |  |  210|  12.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 12.2k]
  |  |  ------------------
  ------------------
  105|  12.2k|    ctx->avframe = av_frame_alloc();
  106|  12.2k|    MP_HANDLE_OOM(ctx->avframe);
  ------------------
  |  |  206|  12.2k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  12.2k|        void *oom_p_ = (x);     \
  |  |  208|  12.2k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 12.2k]
  |  |  ------------------
  |  |  209|  12.2k|            abort();            \
  |  |  210|  12.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 12.2k]
  |  |  ------------------
  ------------------
  107|  12.2k|    ctx->avpkt = av_packet_alloc();
  108|  12.2k|    MP_HANDLE_OOM(ctx->avpkt);
  ------------------
  |  |  206|  12.2k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  12.2k|        void *oom_p_ = (x);     \
  |  |  208|  12.2k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 12.2k]
  |  |  ------------------
  |  |  209|  12.2k|            abort();            \
  |  |  210|  12.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 12.2k]
  |  |  ------------------
  ------------------
  109|  12.2k|    ctx->avctx->codec_type = AVMEDIA_TYPE_AUDIO;
  110|  12.2k|    ctx->avctx->codec_id = lavc_codec->id;
  111|  12.2k|    ctx->avctx->pkt_timebase = ctx->codec_timebase;
  112|       |
  113|  12.2k|    if (opts->downmix && mpopts->audio_output_channels.num_chmaps == 1) {
  ------------------
  |  Branch (113:9): [True: 0, False: 12.2k]
  |  Branch (113:26): [True: 0, False: 0]
  ------------------
  114|      0|        const struct mp_chmap *requested_layout =
  115|      0|            &mpopts->audio_output_channels.chmaps[0];
  116|      0|        AVChannelLayout av_layout = { 0 };
  117|      0|        mp_chmap_to_av_layout(&av_layout, requested_layout);
  118|       |
  119|       |        // Always try to set requested output layout - currently only something
  120|       |        // supported by AC3, MLP/TrueHD, DTS and the fdk-aac wrapper.
  121|      0|        av_opt_set_chlayout(ctx->avctx, "downmix", &av_layout,
  122|      0|                            AV_OPT_SEARCH_CHILDREN);
  123|       |
  124|      0|        av_channel_layout_uninit(&av_layout);
  125|      0|    }
  126|       |
  127|       |    // Always try to set - option only exists for AC3 at the moment
  128|  12.2k|    av_opt_set_double(ctx->avctx, "drc_scale", opts->ac3drc,
  129|  12.2k|                      AV_OPT_SEARCH_CHILDREN);
  130|       |
  131|       |    // Let decoder add AV_FRAME_DATA_SKIP_SAMPLES.
  132|  12.2k|    av_opt_set(ctx->avctx, "flags2", "+skip_manual", AV_OPT_SEARCH_CHILDREN);
  133|       |
  134|  12.2k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(61, 7, 100)
  135|       |    // Request the raw bitstream from DSD decoders, decoder built-in conversion
  136|       |    // to PCM is deprecated. It's still default in lavc for backwards
  137|       |    // compatibility, but will be removed.
  138|  12.2k|    if (codec->lav_codecpar && codec->lav_codecpar->format == AV_SAMPLE_FMT_DSD)
  ------------------
  |  Branch (138:9): [True: 12.2k, False: 0]
  |  Branch (138:32): [True: 0, False: 12.2k]
  ------------------
  139|      0|        ctx->avctx->request_sample_fmt = AV_SAMPLE_FMT_DSD;
  140|  12.2k|#endif
  141|       |
  142|  12.2k|    mp_set_avopts(da->log, ctx->avctx, opts->avopts);
  143|       |
  144|  12.2k|    if (mp_set_avctx_codec_headers(ctx->avctx, codec) < 0) {
  ------------------
  |  Branch (144:9): [True: 0, False: 12.2k]
  ------------------
  145|      0|        MP_ERR(da, "Could not set decoder parameters.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  146|      0|        return false;
  147|      0|    }
  148|       |
  149|  12.2k|    mp_set_avcodec_threads(da->log, ctx->avctx, opts->threads);
  150|       |
  151|       |    /* open it */
  152|  12.2k|    if (avcodec_open2(ctx->avctx, lavc_codec, NULL) < 0) {
  ------------------
  |  Branch (152:9): [True: 434, False: 11.7k]
  ------------------
  153|    434|        MP_ERR(da, "Could not open codec.\n");
  ------------------
  |  |   89|    434|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    434|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  154|    434|        return false;
  155|    434|    }
  156|       |
  157|  11.7k|    ctx->next_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  11.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  158|       |
  159|       |    return true;
  160|  12.2k|}
ad_lavc.c:add_decoders:
  329|  12.1k|{
  330|  12.1k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_AUDIO);
  331|  12.1k|}

select_spdif_codec:
  471|  12.1k|{
  472|  12.1k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  12.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  12.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  12.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|       |
  474|  12.1k|    if (!find_codec(codec))
  ------------------
  |  Branch (474:9): [True: 8.84k, False: 3.35k]
  ------------------
  475|  8.84k|        return list;
  476|       |
  477|  12.1k|    bool spdif_allowed = false, dts_hd_allowed = false;
  478|  3.35k|    bstr sel = bstr0(pref);
  479|  3.35k|    while (sel.len) {
  ------------------
  |  Branch (479:12): [True: 0, False: 3.35k]
  ------------------
  480|      0|        bstr decoder;
  481|      0|        bstr_split_tok(sel, ",", &decoder, &sel);
  482|      0|        if (decoder.len) {
  ------------------
  |  Branch (482:13): [True: 0, False: 0]
  ------------------
  483|      0|            if (bstr_equals0(decoder, codec))
  ------------------
  |  Branch (483:17): [True: 0, False: 0]
  ------------------
  484|      0|                spdif_allowed = true;
  485|      0|            if (bstr_equals0(decoder, "dts-hd") && strcmp(codec, "dts") == 0)
  ------------------
  |  Branch (485:17): [True: 0, False: 0]
  |  Branch (485:52): [True: 0, False: 0]
  ------------------
  486|      0|                spdif_allowed = dts_hd_allowed = true;
  487|      0|        }
  488|      0|    }
  489|       |
  490|  3.35k|    if (!spdif_allowed)
  ------------------
  |  Branch (490:9): [True: 3.35k, False: 0]
  ------------------
  491|  3.35k|        return list;
  492|       |
  493|      0|    const char *suffix_name = dts_hd_allowed ? "dts_hd" : codec;
  ------------------
  |  Branch (493:31): [True: 0, False: 0]
  ------------------
  494|      0|    char name[80];
  495|      0|    snprintf(name, sizeof(name), "spdif_%s", suffix_name);
  496|      0|    mp_add_decoder(list, codec, name,
  497|      0|                   "libavformat/spdifenc audio pass-through decoder");
  498|      0|    return list;
  499|  3.35k|}
ad_spdif.c:find_codec:
  458|  12.1k|{
  459|  67.2k|    for (int n = 0; codecs[n] != AV_CODEC_ID_NONE; n++) {
  ------------------
  |  Branch (459:21): [True: 58.3k, False: 8.84k]
  ------------------
  460|  58.3k|        const char *format = mp_codec_from_av_codec_id(codecs[n]);
  461|  58.3k|        if (format && name && strcmp(format, name) == 0)
  ------------------
  |  Branch (461:13): [True: 58.3k, False: 0]
  |  Branch (461:23): [True: 58.3k, False: 0]
  |  Branch (461:31): [True: 3.35k, False: 55.0k]
  ------------------
  462|  3.35k|            return true;
  463|  58.3k|    }
  464|  8.84k|    return false;
  465|  12.1k|}

af_to_avformat:
   49|  10.8k|{
   50|  99.4k|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (50:21): [True: 99.4k, False: 0]
  ------------------
   51|  99.4k|        if (audio_conversion_map[i].fmt == fmt)
  ------------------
  |  Branch (51:13): [True: 10.8k, False: 88.5k]
  ------------------
   52|  10.8k|            return audio_conversion_map[i].sample_fmt;
   53|  99.4k|    }
   54|      0|    return AV_SAMPLE_FMT_NONE;
   55|  10.8k|}
af_from_avformat:
   58|   800k|{
   59|  7.71M|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (59:21): [True: 7.71M, False: 0]
  ------------------
   60|  7.71M|        if (audio_conversion_map[i].sample_fmt == sample_fmt)
  ------------------
  |  Branch (60:13): [True: 800k, False: 6.90M]
  ------------------
   61|   800k|            return audio_conversion_map[i].fmt;
   62|  7.71M|    }
   63|      0|    return 0;
   64|   800k|}

af_fmt_to_bytes:
   27|  2.42M|{
   28|  2.42M|    switch (af_fmt_from_planar(format)) {
  ------------------
  |  Branch (28:13): [True: 2.42M, False: 31]
  ------------------
   29|    422|    case AF_FORMAT_U8:      return 1;
  ------------------
  |  Branch (29:5): [True: 422, False: 2.42M]
  ------------------
   30|   839k|    case AF_FORMAT_S16:     return 2;
  ------------------
  |  Branch (30:5): [True: 839k, False: 1.58M]
  ------------------
   31|     35|    case AF_FORMAT_S32:     return 4;
  ------------------
  |  Branch (31:5): [True: 35, False: 2.42M]
  ------------------
   32|      0|    case AF_FORMAT_S64:     return 8;
  ------------------
  |  Branch (32:5): [True: 0, False: 2.42M]
  ------------------
   33|  1.58M|    case AF_FORMAT_FLOAT:   return 4;
  ------------------
  |  Branch (33:5): [True: 1.58M, False: 839k]
  ------------------
   34|      0|    case AF_FORMAT_DOUBLE:  return 8;
  ------------------
  |  Branch (34:5): [True: 0, False: 2.42M]
  ------------------
   35|  2.42M|    }
   36|      0|    if (format == AF_FORMAT_S_DOP)
  ------------------
  |  Branch (36:9): [True: 0, False: 0]
  ------------------
   37|      0|        return 4;
   38|      0|    if (format == AF_FORMAT_DSD)
  ------------------
  |  Branch (38:9): [True: 0, False: 0]
  ------------------
   39|      0|        return 1;
   40|      0|    if (af_fmt_is_spdif(format))
  ------------------
  |  Branch (40:9): [True: 0, False: 0]
  ------------------
   41|      0|        return 2;
   42|      0|    return 0;
   43|      0|}
af_fmt_is_unsigned:
   47|  1.43M|{
   48|  1.43M|    return format == AF_FORMAT_U8 || format == AF_FORMAT_U8P;
  ------------------
  |  Branch (48:12): [True: 149, False: 1.43M]
  |  Branch (48:38): [True: 0, False: 1.43M]
  ------------------
   49|  1.43M|}
af_fmt_is_spdif:
   66|  32.9k|{
   67|  32.9k|    return af_format_sample_alignment(format) > 1;
   68|  32.9k|}
af_fmt_is_pcm:
   71|  32.9k|{
   72|  32.9k|    return af_fmt_is_valid(format) && !af_fmt_is_spdif(format) &&
  ------------------
  |  Branch (72:12): [True: 32.9k, False: 0]
  |  Branch (72:39): [True: 32.9k, False: 0]
  ------------------
   73|  32.9k|           format != AF_FORMAT_S_DOP;
  ------------------
  |  Branch (73:12): [True: 32.9k, False: 0]
  ------------------
   74|  32.9k|}
af_fmt_is_planar:
   86|  7.27M|{
   87|  31.5M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  31.5M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (87:21): [True: 31.1M, False: 340k]
  ------------------
   88|  31.1M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (88:13): [True: 6.92M, False: 24.2M]
  ------------------
   89|  6.92M|            return true;
   90|  31.1M|    }
   91|   340k|    return false;
   92|  7.27M|}
af_fmt_from_planar:
  110|  3.22M|{
  111|  13.6M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  13.6M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (111:21): [True: 13.4M, False: 179k]
  ------------------
  112|  13.4M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (112:13): [True: 3.04M, False: 10.4M]
  ------------------
  113|  3.04M|            return planar_formats[n][1];
  114|  13.4M|    }
  115|   179k|    return format;
  116|  3.22M|}
af_fmt_is_valid:
  119|  32.9k|{
  120|  32.9k|    return format > 0 && format < AF_FORMAT_COUNT;
  ------------------
  |  Branch (120:12): [True: 32.9k, False: 0]
  |  Branch (120:26): [True: 32.9k, False: 0]
  ------------------
  121|  32.9k|}
af_fmt_to_str:
  124|  47.9k|{
  125|  47.9k|    switch (format) {
  ------------------
  |  Branch (125:13): [True: 47.9k, False: 0]
  ------------------
  126|    156|    case AF_FORMAT_U8:          return "u8";
  ------------------
  |  Branch (126:5): [True: 156, False: 47.8k]
  ------------------
  127|  5.58k|    case AF_FORMAT_S16:         return "s16";
  ------------------
  |  Branch (127:5): [True: 5.58k, False: 42.3k]
  ------------------
  128|      0|    case AF_FORMAT_S32:         return "s32";
  ------------------
  |  Branch (128:5): [True: 0, False: 47.9k]
  ------------------
  129|      0|    case AF_FORMAT_S64:         return "s64";
  ------------------
  |  Branch (129:5): [True: 0, False: 47.9k]
  ------------------
  130|      0|    case AF_FORMAT_FLOAT:       return "float";
  ------------------
  |  Branch (130:5): [True: 0, False: 47.9k]
  ------------------
  131|      0|    case AF_FORMAT_DOUBLE:      return "double";
  ------------------
  |  Branch (131:5): [True: 0, False: 47.9k]
  ------------------
  132|      0|    case AF_FORMAT_U8P:         return "u8p";
  ------------------
  |  Branch (132:5): [True: 0, False: 47.9k]
  ------------------
  133|  14.4k|    case AF_FORMAT_S16P:        return "s16p";
  ------------------
  |  Branch (133:5): [True: 14.4k, False: 33.4k]
  ------------------
  134|     42|    case AF_FORMAT_S32P:        return "s32p";
  ------------------
  |  Branch (134:5): [True: 42, False: 47.9k]
  ------------------
  135|      0|    case AF_FORMAT_S64P:        return "s64p";
  ------------------
  |  Branch (135:5): [True: 0, False: 47.9k]
  ------------------
  136|  27.7k|    case AF_FORMAT_FLOATP:      return "floatp";
  ------------------
  |  Branch (136:5): [True: 27.7k, False: 20.2k]
  ------------------
  137|      0|    case AF_FORMAT_DOUBLEP:     return "doublep";
  ------------------
  |  Branch (137:5): [True: 0, False: 47.9k]
  ------------------
  138|      0|    case AF_FORMAT_S_AAC:       return "spdif-aac";
  ------------------
  |  Branch (138:5): [True: 0, False: 47.9k]
  ------------------
  139|      0|    case AF_FORMAT_S_AC3:       return "spdif-ac3";
  ------------------
  |  Branch (139:5): [True: 0, False: 47.9k]
  ------------------
  140|      0|    case AF_FORMAT_S_DTS:       return "spdif-dts";
  ------------------
  |  Branch (140:5): [True: 0, False: 47.9k]
  ------------------
  141|      0|    case AF_FORMAT_S_DTSHD:     return "spdif-dtshd";
  ------------------
  |  Branch (141:5): [True: 0, False: 47.9k]
  ------------------
  142|      0|    case AF_FORMAT_S_EAC3:      return "spdif-eac3";
  ------------------
  |  Branch (142:5): [True: 0, False: 47.9k]
  ------------------
  143|      0|    case AF_FORMAT_S_MP3:       return "spdif-mp3";
  ------------------
  |  Branch (143:5): [True: 0, False: 47.9k]
  ------------------
  144|      0|    case AF_FORMAT_S_TRUEHD:    return "spdif-truehd";
  ------------------
  |  Branch (144:5): [True: 0, False: 47.9k]
  ------------------
  145|      0|    case AF_FORMAT_S_DOP:       return "dop";
  ------------------
  |  Branch (145:5): [True: 0, False: 47.9k]
  ------------------
  146|      0|    case AF_FORMAT_DSD:         return "dsd";
  ------------------
  |  Branch (146:5): [True: 0, False: 47.9k]
  ------------------
  147|  47.9k|    }
  148|      0|    return "??";
  149|  47.9k|}
af_fill_silence:
  152|  1.43M|{
  153|  1.43M|    int fill = 0;
  154|  1.43M|    if (af_fmt_is_unsigned(format))
  ------------------
  |  Branch (154:9): [True: 149, False: 1.43M]
  ------------------
  155|    149|        fill = 0x80;
  156|  1.43M|    if (format == AF_FORMAT_DSD)
  ------------------
  |  Branch (156:9): [True: 0, False: 1.43M]
  ------------------
  157|      0|        fill = 0x69; // only ultrasonic tones, filtered out on playback
  158|  1.43M|    memset(dst, fill, bytes);
  159|  1.43M|}
af_format_conversion_score:
  166|  10.8k|{
  167|  10.8k|    if (dst_format == AF_FORMAT_UNKNOWN || src_format == AF_FORMAT_UNKNOWN)
  ------------------
  |  Branch (167:9): [True: 0, False: 10.8k]
  |  Branch (167:44): [True: 0, False: 10.8k]
  ------------------
  168|      0|        return INT_MIN;
  169|  10.8k|    if (dst_format == src_format)
  ------------------
  |  Branch (169:9): [True: 10.8k, False: 0]
  ------------------
  170|  10.8k|        return 1024;
  171|      0|    if (src_format == AF_FORMAT_DSD) {
  ------------------
  |  Branch (171:9): [True: 0, False: 0]
  ------------------
  172|      0|        return af_fmt_is_pcm(dst_format) && dst_format != AF_FORMAT_DSD
  ------------------
  |  Branch (172:16): [True: 0, False: 0]
  |  Branch (172:45): [True: 0, False: 0]
  ------------------
  173|      0|               ? af_format_conversion_score(dst_format, AF_FORMAT_FLOAT) - 1
  174|      0|               : INT_MIN;
  175|      0|    }
  176|      0|    if (dst_format == AF_FORMAT_DSD)
  ------------------
  |  Branch (176:9): [True: 0, False: 0]
  ------------------
  177|      0|        return INT_MIN;
  178|       |    // Can't be normally converted
  179|      0|    if (!af_fmt_is_pcm(dst_format) || !af_fmt_is_pcm(src_format))
  ------------------
  |  Branch (179:9): [True: 0, False: 0]
  |  Branch (179:39): [True: 0, False: 0]
  ------------------
  180|      0|        return INT_MIN;
  181|      0|    int score = 1024;
  182|      0|    if (af_fmt_is_planar(dst_format) != af_fmt_is_planar(src_format))
  ------------------
  |  Branch (182:9): [True: 0, False: 0]
  ------------------
  183|      0|        score -= 1;     // has to (de-)planarize
  184|      0|    if (af_fmt_is_float(dst_format) != af_fmt_is_float(src_format)) {
  ------------------
  |  Branch (184:9): [True: 0, False: 0]
  ------------------
  185|      0|        int dst_bytes = af_fmt_to_bytes(dst_format);
  186|      0|        if (af_fmt_is_float(dst_format)) {
  ------------------
  |  Branch (186:13): [True: 0, False: 0]
  ------------------
  187|       |            // For int->float, consider a lower bound on the precision difference.
  188|      0|            int bytes = (dst_bytes == 4 ? 3 : 6) - af_fmt_to_bytes(src_format);
  ------------------
  |  Branch (188:26): [True: 0, False: 0]
  ------------------
  189|      0|            if (bytes >= 0) {
  ------------------
  |  Branch (189:17): [True: 0, False: 0]
  ------------------
  190|      0|                score -= 8 * bytes;          // excess precision
  191|      0|            } else {
  192|      0|                score += 1024 * (bytes - 1); // precision is lost (i.e. s32 -> float)
  193|      0|            }
  194|      0|        } else {
  195|       |            // float->int is the worst case. Penalize heavily and
  196|       |            // prefer highest bit depth int.
  197|      0|            score -= 1048576 * (8 - dst_bytes);
  198|      0|        }
  199|      0|        score -= 512; // penalty for any float <-> int conversion
  200|      0|    } else {
  201|      0|        int bytes = af_fmt_to_bytes(dst_format) - af_fmt_to_bytes(src_format);
  202|      0|        if (bytes > 0) {
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  ------------------
  203|      0|            score -= 8 * bytes;          // has to add padding
  204|      0|        } else if (bytes < 0) {
  ------------------
  |  Branch (204:20): [True: 0, False: 0]
  ------------------
  205|      0|            score += 1024 * (bytes - 1); // has to reduce bit depth
  206|      0|        }
  207|      0|    }
  208|      0|    return score;
  209|      0|}
af_select_best_samplerate:
  249|  7.95k|{
  250|  7.95k|    if (!available)
  ------------------
  |  Branch (250:9): [True: 0, False: 7.95k]
  ------------------
  251|      0|        return -1;
  252|       |
  253|  7.95k|    int min_mult_rate = INT_MAX;
  254|  7.95k|    int max_rate      = INT_MIN;
  255|  7.95k|    for (int i = 0; available[i]; i++) {
  ------------------
  |  Branch (255:21): [True: 7.95k, False: 0]
  ------------------
  256|  7.95k|        if (available[i] == src_samplerate)
  ------------------
  |  Branch (256:13): [True: 7.95k, False: 0]
  ------------------
  257|  7.95k|            return available[i];
  258|       |
  259|      0|        if (!(available[i] % src_samplerate))
  ------------------
  |  Branch (259:13): [True: 0, False: 0]
  ------------------
  260|      0|            min_mult_rate = MPMIN(min_mult_rate, available[i]);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  261|       |
  262|      0|        max_rate = MPMAX(max_rate, available[i]);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  263|      0|    }
  264|       |
  265|      0|    if (min_mult_rate < INT_MAX)
  ------------------
  |  Branch (265:9): [True: 0, False: 0]
  ------------------
  266|      0|        return min_mult_rate;
  267|       |
  268|      0|    if (max_rate > INT_MIN)
  ------------------
  |  Branch (268:9): [True: 0, False: 0]
  ------------------
  269|      0|        return max_rate;
  270|       |
  271|      0|    return -1;
  272|      0|}
af_format_sample_alignment:
  277|  40.8k|{
  278|  40.8k|    switch (format) {
  279|      0|    case AF_FORMAT_S_AAC:       return 16384 / 4;
  ------------------
  |  Branch (279:5): [True: 0, False: 40.8k]
  ------------------
  280|      0|    case AF_FORMAT_S_AC3:       return 6144 / 4;
  ------------------
  |  Branch (280:5): [True: 0, False: 40.8k]
  ------------------
  281|      0|    case AF_FORMAT_S_DTSHD:     return 32768 / 16;
  ------------------
  |  Branch (281:5): [True: 0, False: 40.8k]
  ------------------
  282|      0|    case AF_FORMAT_S_DTS:       return 2048 / 4;
  ------------------
  |  Branch (282:5): [True: 0, False: 40.8k]
  ------------------
  283|      0|    case AF_FORMAT_S_EAC3:      return 24576 / 4;
  ------------------
  |  Branch (283:5): [True: 0, False: 40.8k]
  ------------------
  284|      0|    case AF_FORMAT_S_MP3:       return 4608 / 4;
  ------------------
  |  Branch (284:5): [True: 0, False: 40.8k]
  ------------------
  285|      0|    case AF_FORMAT_S_TRUEHD:    return 61440 / 16;
  ------------------
  |  Branch (285:5): [True: 0, False: 40.8k]
  ------------------
  286|  40.8k|    default:                    return 1;
  ------------------
  |  Branch (286:5): [True: 40.8k, False: 0]
  ------------------
  287|  40.8k|    }
  288|  40.8k|}

ao_init_best:
  296|  7.98k|{
  297|  7.98k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  7.98k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  7.98k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  298|  7.98k|    struct ao_opts *opts = mp_get_config_group(tmp, global, &ao_conf);
  299|  7.98k|    struct mp_log *log = mp_log_new(tmp, global->log, "ao");
  300|  7.98k|    struct ao *ao = NULL;
  301|  7.98k|    struct m_obj_settings *ao_list = NULL;
  302|  7.98k|    int ao_num = 0;
  303|       |
  304|  15.9k|    for (int n = 0; opts->audio_driver_list && opts->audio_driver_list[n].name; n++)
  ------------------
  |  Branch (304:21): [True: 15.9k, False: 0]
  |  Branch (304:48): [True: 7.98k, False: 7.98k]
  ------------------
  305|  7.98k|        MP_TARRAY_APPEND(tmp, ao_list, ao_num, opts->audio_driver_list[n]);
  ------------------
  |  |  105|  7.98k|    do {                                            \
  |  |  106|  7.98k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  7.98k|    do {                                            \
  |  |  |  |   97|  7.98k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  7.98k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  7.98k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  7.98k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 7.98k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  7.98k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  7.98k|    do {                                                        \
  |  |  |  |  |  |   89|  7.98k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  7.98k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  7.98k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  7.98k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  7.98k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  7.98k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  7.98k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 7.98k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  7.98k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 7.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  7.98k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  7.98k|        (idxvar)++;                                 \
  |  |  109|  7.98k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.98k]
  |  |  ------------------
  ------------------
  306|       |
  307|  7.98k|    bool forced_dev = false;
  308|  7.98k|    char *pref_ao, *pref_dev;
  309|  7.98k|    split_ao_device(tmp, opts->audio_device, &pref_ao, &pref_dev);
  310|  7.98k|    if (!ao_num && pref_ao) {
  ------------------
  |  Branch (310:9): [True: 0, False: 7.98k]
  |  Branch (310:20): [True: 0, False: 0]
  ------------------
  311|       |        // Reuse the autoselection code
  312|      0|        MP_TARRAY_APPEND(tmp, ao_list, ao_num,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  313|      0|            (struct m_obj_settings){.name = pref_ao});
  314|      0|        forced_dev = true;
  315|      0|    }
  316|       |
  317|  7.98k|    bool autoprobe = ao_num == 0;
  318|       |
  319|       |    // Something like "--ao=a,b," means do autoprobing after a and b fail.
  320|  7.98k|    if (ao_num && strlen(ao_list[ao_num - 1].name) == 0) {
  ------------------
  |  Branch (320:9): [True: 7.98k, False: 0]
  |  Branch (320:19): [True: 0, False: 7.98k]
  ------------------
  321|      0|        ao_num -= 1;
  322|      0|        autoprobe = true;
  323|      0|    }
  324|       |
  325|  7.98k|    if (autoprobe) {
  ------------------
  |  Branch (325:9): [True: 0, False: 7.98k]
  ------------------
  326|      0|        for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (326:25): [True: 0, False: 0]
  ------------------
  327|      0|            const struct ao_driver *driver = audio_out_drivers[n];
  328|      0|            if (driver == &audio_out_null)
  ------------------
  |  Branch (328:17): [True: 0, False: 0]
  ------------------
  329|      0|                break;
  330|      0|            MP_TARRAY_APPEND(tmp, ao_list, ao_num,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  331|      0|                (struct m_obj_settings){.name = (char *)driver->name});
  332|      0|        }
  333|      0|    }
  334|       |
  335|  7.98k|    if (init_flags & AO_INIT_NULL_FALLBACK) {
  ------------------
  |  Branch (335:9): [True: 0, False: 7.98k]
  ------------------
  336|      0|        MP_TARRAY_APPEND(tmp, ao_list, ao_num,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  337|      0|            (struct m_obj_settings){.name = "null"});
  338|      0|    }
  339|       |
  340|  8.04k|    for (int n = 0; n < ao_num; n++) {
  ------------------
  |  Branch (340:21): [True: 7.98k, False: 64]
  ------------------
  341|  7.98k|        struct m_obj_settings *entry = &ao_list[n];
  342|  7.98k|        bool probing = n + 1 != ao_num;
  343|  7.98k|        mp_verbose(log, "Trying audio driver '%s'\n", entry->name);
  ------------------
  |  |   79|  7.98k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  344|  7.98k|        char *dev = NULL;
  345|  7.98k|        if (pref_ao && pref_dev && strcmp(entry->name, pref_ao) == 0) {
  ------------------
  |  Branch (345:13): [True: 0, False: 7.98k]
  |  Branch (345:24): [True: 0, False: 0]
  |  Branch (345:36): [True: 0, False: 0]
  ------------------
  346|      0|            dev = pref_dev;
  347|      0|            mp_verbose(log, "Using preferred device '%s'\n", dev);
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  348|      0|        }
  349|  7.98k|        ao = ao_init(probing, global, wakeup_cb, wakeup_ctx, encode_lavc_ctx,
  350|  7.98k|                     init_flags, samplerate, format, channels, dev, entry->name);
  351|  7.98k|        if (ao)
  ------------------
  |  Branch (351:13): [True: 7.92k, False: 64]
  ------------------
  352|  7.92k|            break;
  353|     64|        if (!probing)
  ------------------
  |  Branch (353:13): [True: 64, False: 0]
  ------------------
  354|     64|            mp_err(log, "Failed to initialize audio driver '%s'\n", entry->name);
  ------------------
  |  |   76|     64|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  355|     64|        if (dev && forced_dev) {
  ------------------
  |  Branch (355:13): [True: 0, False: 64]
  |  Branch (355:20): [True: 0, False: 0]
  ------------------
  356|      0|            mp_err(log, "This audio driver/device was forced with the "
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  357|      0|                        "--audio-device option.\nTry unsetting it.\n");
  358|      0|        }
  359|     64|    }
  360|       |
  361|  7.98k|    talloc_free(tmp);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  362|  7.98k|    return ao;
  363|  7.98k|}
ao_query_and_reset_events:
  367|  21.7k|{
  368|       |    return atomic_fetch_and(&ao->events_, ~(unsigned)events) & events;
  369|  21.7k|}
ao_chmap_sel_adjust:
  395|  7.98k|{
  396|  7.98k|    MP_VERBOSE(ao, "Channel layouts:\n");
  ------------------
  |  |   92|  7.98k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  397|  7.98k|    mp_chmal_sel_log(s, ao->log, MSGL_V);
  398|  7.98k|    bool r = mp_chmap_sel_adjust(s, map);
  399|  7.98k|    if (r)
  ------------------
  |  Branch (399:9): [True: 7.98k, False: 0]
  ------------------
  400|  7.98k|        MP_VERBOSE(ao, "result: %s\n", mp_chmap_to_str(map));
  ------------------
  |  |   92|  7.98k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  401|  7.98k|    return r;
  402|  7.98k|}
ao_get_format:
  437|  15.8k|{
  438|  15.8k|    *samplerate = ao->samplerate;
  439|  15.8k|    *format = ao->format;
  440|  15.8k|    *channels = ao->channels;
  441|  15.8k|}
ao_get_name:
  444|  7.92k|{
  445|  7.92k|    return ao->driver->name;
  446|  7.92k|}
ao_get_description:
  449|  7.92k|{
  450|  7.92k|    return ao->driver->description;
  451|  7.92k|}
ao_hotplug_destroy:
  587|  28.9k|{
  588|  28.9k|    if (!hp)
  ------------------
  |  Branch (588:9): [True: 28.9k, False: 0]
  ------------------
  589|  28.9k|        return;
  590|      0|    if (hp->ao && hp->ao->driver->hotplug_uninit)
  ------------------
  |  Branch (590:9): [True: 0, False: 0]
  |  Branch (590:19): [True: 0, False: 0]
  ------------------
  591|      0|        hp->ao->driver->hotplug_uninit(hp->ao);
  592|      0|    talloc_free(hp->ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  593|      0|    talloc_free(hp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  594|      0|}
ao_set_gain:
  614|  23.8k|{
  615|       |    atomic_store(&ao->gain, gain);
  616|  23.8k|}
ao_post_process_data:
  656|  1.34M|{
  657|  1.34M|    bool planar = af_fmt_is_planar(ao->format);
  658|  1.34M|    int planes = planar ? ao->channels.num : 1;
  ------------------
  |  Branch (658:18): [True: 1.27M, False: 70.8k]
  ------------------
  659|  1.34M|    int plane_samples = num_samples * (planar ? 1: ao->channels.num);
  ------------------
  |  Branch (659:40): [True: 1.27M, False: 70.8k]
  ------------------
  660|  2.78M|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (660:21): [True: 1.43M, False: 1.34M]
  ------------------
  661|  1.43M|        process_plane(ao, data[n], plane_samples);
  662|  1.34M|}
ao.c:get_desc:
  116|   239k|{
  117|   239k|    if (index >= MP_ARRAY_SIZE(audio_out_drivers))
  ------------------
  |  |   49|   239k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (117:9): [True: 28.9k, False: 210k]
  ------------------
  118|  28.9k|        return false;
  119|   210k|    const struct ao_driver *ao = audio_out_drivers[index];
  120|   210k|    *dst = (struct m_obj_desc) {
  121|   210k|        .name = ao->name,
  122|   210k|        .description = ao->description,
  123|   210k|        .priv_size = ao->priv_size,
  124|   210k|        .priv_defaults = ao->priv_defaults,
  125|   210k|        .options = ao->options,
  126|   210k|        .options_prefix = ao->options_prefix,
  127|   210k|        .global_opts = ao->global_opts,
  128|   210k|        .hidden = ao->encode,
  129|   210k|        .p = ao,
  130|   210k|    };
  131|       |    return true;
  132|   239k|}
ao.c:split_ao_device:
  276|  7.98k|{
  277|  7.98k|    *out_ao = NULL;
  278|  7.98k|    *out_dev = NULL;
  279|  7.98k|    if (!opt)
  ------------------
  |  Branch (279:9): [True: 0, False: 7.98k]
  ------------------
  280|      0|        return;
  281|  7.98k|    if (!opt[0] || strcmp(opt, "auto") == 0)
  ------------------
  |  Branch (281:9): [True: 0, False: 7.98k]
  |  Branch (281:20): [True: 7.98k, False: 0]
  ------------------
  282|  7.98k|        return;
  283|       |    // Split on "/". If "/" is the final character, or absent, out_dev is NULL.
  284|      0|    bstr b_dev, b_ao;
  285|      0|    bstr_split_tok(bstr0(opt), "/", &b_ao, &b_dev);
  286|      0|    if (b_dev.len > 0)
  ------------------
  |  Branch (286:9): [True: 0, False: 0]
  ------------------
  287|      0|        *out_dev = bstrto0(tmp, b_dev);
  288|      0|    *out_ao = bstrto0(tmp, b_ao);
  289|      0|}
ao.c:ao_init:
  207|  7.98k|{
  208|  7.98k|    struct ao *ao = ao_alloc(probing, global, wakeup_cb, wakeup_ctx, name);
  209|  7.98k|    if (!ao)
  ------------------
  |  Branch (209:9): [True: 0, False: 7.98k]
  ------------------
  210|      0|        return NULL;
  211|  7.98k|    ao->samplerate = samplerate;
  212|  7.98k|    ao->channels = channels;
  213|  7.98k|    ao->format = format;
  214|  7.98k|    ao->encode_lavc_ctx = encode_lavc_ctx;
  215|  7.98k|    ao->init_flags = flags;
  216|  7.98k|    if (ao->driver->encode != !!ao->encode_lavc_ctx)
  ------------------
  |  Branch (216:9): [True: 0, False: 7.98k]
  ------------------
  217|      0|        goto fail;
  218|       |
  219|  7.98k|    MP_VERBOSE(ao, "requested format: %d Hz, %s channels, %s\n",
  ------------------
  |  |   92|  7.98k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  220|  7.98k|               ao->samplerate, mp_chmap_to_str(&ao->channels),
  221|  7.98k|               af_fmt_to_str(ao->format));
  222|       |
  223|  7.98k|    ao->device = talloc_strdup(ao, dev);
  ------------------
  |  |   50|  7.98k|#define talloc_strdup                   ta_xstrdup
  ------------------
  224|  7.98k|    ao->stream_silence = flags & AO_INIT_STREAM_SILENCE;
  225|       |
  226|  7.98k|    init_buffer_pre(ao);
  227|       |
  228|  7.98k|    int r = ao->driver->init(ao);
  229|  7.98k|    if (r < 0) {
  ------------------
  |  Branch (229:9): [True: 0, False: 7.98k]
  ------------------
  230|       |        // Silly exception for coreaudio spdif redirection
  231|      0|        if (ao->redirect) {
  ------------------
  |  Branch (231:13): [True: 0, False: 0]
  ------------------
  232|      0|            char redirect[80], rdevice[80];
  233|      0|            snprintf(redirect, sizeof(redirect), "%s", ao->redirect);
  234|      0|            snprintf(rdevice, sizeof(rdevice), "%s", ao->device ? ao->device : "");
  ------------------
  |  Branch (234:54): [True: 0, False: 0]
  ------------------
  235|      0|            ao_uninit(ao);
  236|      0|            return ao_init(probing, global, wakeup_cb, wakeup_ctx,
  237|      0|                           encode_lavc_ctx, flags, samplerate, format, channels,
  238|      0|                           rdevice, redirect);
  239|      0|        }
  240|      0|        goto fail;
  241|      0|    }
  242|  7.98k|    ao->driver_initialized = true;
  243|       |
  244|  7.98k|    ao->sstride = af_fmt_to_bytes(ao->format);
  245|  7.98k|    ao->num_planes = 1;
  246|  7.98k|    if (af_fmt_is_planar(ao->format)) {
  ------------------
  |  Branch (246:9): [True: 7.02k, False: 957]
  ------------------
  247|  7.02k|        ao->num_planes = ao->channels.num;
  248|  7.02k|    } else {
  249|    957|        ao->sstride *= ao->channels.num;
  250|    957|    }
  251|  7.98k|    ao->bps = (int64_t)ao->samplerate * ao->sstride;
  252|       |
  253|  7.98k|    if (ao->device_buffer <= 0 && ao->driver->write) {
  ------------------
  |  Branch (253:9): [True: 64, False: 7.92k]
  |  Branch (253:35): [True: 64, False: 0]
  ------------------
  254|     64|        MP_ERR(ao, "Device buffer size not set.\n");
  ------------------
  |  |   89|     64|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     64|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  255|     64|        goto fail;
  256|     64|    }
  257|  7.92k|    if (ao->device_buffer)
  ------------------
  |  Branch (257:9): [True: 7.92k, False: 0]
  ------------------
  258|  7.92k|        MP_VERBOSE(ao, "device buffer: %d samples.\n", ao->device_buffer);
  ------------------
  |  |   92|  7.92k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.92k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  259|  7.92k|    ao->buffer = MPMAX(ao->device_buffer, ao->def_buffer * ao->samplerate);
  ------------------
  |  |   44|  7.92k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 7, False: 7.91k]
  |  |  ------------------
  ------------------
  260|  7.92k|    ao->buffer = MPMAX(ao->buffer, 1);
  ------------------
  |  |   44|  7.92k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 7.92k, False: 0]
  |  |  ------------------
  ------------------
  261|       |
  262|  7.92k|    int align = af_format_sample_alignment(ao->format);
  263|  7.92k|    ao->buffer = (ao->buffer + align - 1) / align * align;
  264|  7.92k|    MP_VERBOSE(ao, "using soft-buffer of %d samples.\n", ao->buffer);
  ------------------
  |  |   92|  7.92k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.92k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  265|       |
  266|  7.92k|    if (!init_buffer_post(ao))
  ------------------
  |  Branch (266:9): [True: 0, False: 7.92k]
  ------------------
  267|      0|        goto fail;
  268|  7.92k|    return ao;
  269|       |
  270|     64|fail:
  271|     64|    ao_uninit(ao);
  272|       |    return NULL;
  273|  7.92k|}
ao.c:ao_alloc:
  167|  7.98k|{
  168|  7.98k|    mp_assert(wakeup_cb);
  ------------------
  |  |   41|  7.98k|#define mp_assert assert
  ------------------
  |  Branch (168:5): [True: 7.98k, False: 0]
  ------------------
  169|       |
  170|  7.98k|    struct mp_log *log = mp_log_new(NULL, global->log, "ao");
  171|  7.98k|    struct m_obj_desc desc;
  172|  7.98k|    if (!m_obj_list_find(&desc, &ao_obj_list, bstr0(name))) {
  ------------------
  |  Branch (172:9): [True: 0, False: 7.98k]
  ------------------
  173|      0|        mp_msg(log, MSGL_ERR, "Audio output %s not found!\n", name);
  174|      0|        talloc_free(log);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  175|      0|        return NULL;
  176|  7.98k|    };
  177|  7.98k|    struct ao_opts *opts = mp_get_config_group(NULL, global, &ao_conf);
  178|  7.98k|    struct ao *ao = talloc_ptrtype(NULL, ao);
  ------------------
  |  |   34|  7.98k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  7.98k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  7.98k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|  7.98k|    talloc_steal(ao, log);
  ------------------
  |  |   38|  7.98k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  7.98k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  180|  7.98k|    *ao = (struct ao) {
  181|  7.98k|        .driver = desc.p,
  182|  7.98k|        .probing = probing,
  183|  7.98k|        .global = global,
  184|  7.98k|        .wakeup_cb = wakeup_cb,
  185|  7.98k|        .wakeup_ctx = wakeup_ctx,
  186|  7.98k|        .log = mp_log_new(ao, log, name),
  187|  7.98k|        .def_buffer = opts->audio_buffer,
  188|  7.98k|        .client_name = talloc_strdup(ao, opts->audio_client_name),
  ------------------
  |  |   50|  7.98k|#define talloc_strdup                   ta_xstrdup
  ------------------
  189|  7.98k|        .set_media_role = opts->audio_set_media_role
  190|  7.98k|    };
  191|  7.98k|    talloc_free(opts);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  192|  7.98k|    ao->priv = m_config_group_from_desc(ao, ao->log, global, &desc, name);
  193|  7.98k|    if (!ao->priv)
  ------------------
  |  Branch (193:9): [True: 0, False: 7.98k]
  ------------------
  194|      0|        goto error;
  195|  7.98k|    ao_set_gain(ao, 1.0f);
  196|  7.98k|    return ao;
  197|      0|error:
  198|      0|    talloc_free(ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  199|       |    return NULL;
  200|  7.98k|}
ao.c:process_plane:
  629|  1.43M|{
  630|  1.43M|    float gain = atomic_load_explicit(&ao->gain, memory_order_relaxed);
  631|  1.43M|    int gi = lrint(256.0 * gain);
  632|  1.43M|    if (gi == 256)
  ------------------
  |  Branch (632:9): [True: 1.43M, False: 0]
  ------------------
  633|  1.43M|        return;
  634|      0|    switch (af_fmt_from_planar(ao->format)) {
  635|      0|    case AF_FORMAT_U8:
  ------------------
  |  Branch (635:5): [True: 0, False: 0]
  ------------------
  636|      0|        MUL_GAIN_i((uint8_t *)data, num_samples, gi, 0, 128, 255);
  ------------------
  |  |  619|      0|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (619:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  620|      0|        (d)[n] = MPCLAMP(                                                       \
  |  |  ------------------
  |  |  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  621|      0|            ((((int64_t)((d)[n]) - (center)) * (gain) + 128) >> 8) + (center),  \
  |  |  622|      0|            (low), (high))
  ------------------
  637|      0|        break;
  638|      0|    case AF_FORMAT_S16:
  ------------------
  |  Branch (638:5): [True: 0, False: 0]
  ------------------
  639|      0|        MUL_GAIN_i((int16_t *)data, num_samples, gi, INT16_MIN, 0, INT16_MAX);
  ------------------
  |  |  619|      0|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (619:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  620|      0|        (d)[n] = MPCLAMP(                                                       \
  |  |  ------------------
  |  |  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  621|      0|            ((((int64_t)((d)[n]) - (center)) * (gain) + 128) >> 8) + (center),  \
  |  |  622|      0|            (low), (high))
  ------------------
  640|      0|        break;
  641|      0|    case AF_FORMAT_S32:
  ------------------
  |  Branch (641:5): [True: 0, False: 0]
  ------------------
  642|      0|        MUL_GAIN_i((int32_t *)data, num_samples, gi, INT32_MIN, 0, INT32_MAX);
  ------------------
  |  |  619|      0|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (619:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  620|      0|        (d)[n] = MPCLAMP(                                                       \
  |  |  ------------------
  |  |  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  621|      0|            ((((int64_t)((d)[n]) - (center)) * (gain) + 128) >> 8) + (center),  \
  |  |  622|      0|            (low), (high))
  ------------------
  643|      0|        break;
  644|      0|    case AF_FORMAT_FLOAT:
  ------------------
  |  Branch (644:5): [True: 0, False: 0]
  ------------------
  645|      0|        MUL_GAIN_f((float *)data, num_samples, gain);
  ------------------
  |  |  625|      0|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (625:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  626|      0|        (d)[n] = (d)[n] * (gain)
  ------------------
  646|      0|        break;
  647|      0|    case AF_FORMAT_DOUBLE:
  ------------------
  |  Branch (647:5): [True: 0, False: 0]
  ------------------
  648|      0|        MUL_GAIN_f((double *)data, num_samples, gain);
  ------------------
  |  |  625|      0|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (625:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  626|      0|        (d)[n] = (d)[n] * (gain)
  ------------------
  649|      0|        break;
  650|      0|    default:;
  ------------------
  |  Branch (650:5): [True: 0, False: 0]
  ------------------
  651|       |        // all other sample formats are simply not supported
  652|      0|    }
  653|      0|}

ao_null.c:init:
   85|  7.98k|{
   86|  7.98k|    struct priv *priv = ao->priv;
   87|       |
   88|  7.98k|    if (priv->format)
  ------------------
  |  Branch (88:9): [True: 0, False: 7.98k]
  ------------------
   89|      0|        ao->format = priv->format;
   90|       |
   91|  7.98k|    ao->untimed = priv->untimed;
   92|       |
   93|  7.98k|    struct mp_chmap_sel sel = {.tmp = ao};
   94|  7.98k|    if (priv->channel_layouts.num_chmaps) {
  ------------------
  |  Branch (94:9): [True: 0, False: 7.98k]
  ------------------
   95|      0|        for (int n = 0; n < priv->channel_layouts.num_chmaps; n++)
  ------------------
  |  Branch (95:25): [True: 0, False: 0]
  ------------------
   96|      0|            mp_chmap_sel_add_map(&sel, &priv->channel_layouts.chmaps[n]);
   97|  7.98k|    } else {
   98|  7.98k|        mp_chmap_sel_add_any(&sel);
   99|  7.98k|    }
  100|  7.98k|    if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
  ------------------
  |  Branch (100:9): [True: 0, False: 7.98k]
  ------------------
  101|      0|        mp_chmap_from_channels(&ao->channels, 2);
  102|       |
  103|  7.98k|    priv->latency = priv->latency_sec * ao->samplerate;
  104|       |
  105|       |    // A "buffer" for this many seconds of audio
  106|  7.98k|    int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
  107|  7.98k|    ao->device_buffer = priv->outburst * bursts + priv->latency;
  108|       |
  109|  7.98k|    priv->last_time = mp_time_sec();
  110|       |
  111|  7.98k|    return 0;
  112|  7.98k|}
ao_null.c:uninit:
  116|  7.98k|{
  117|  7.98k|}
ao_null.c:reset:
  121|  4.29k|{
  122|  4.29k|    struct priv *priv = ao->priv;
  123|  4.29k|    priv->paused = false;
  124|  4.29k|    priv->buffered = 0;
  125|       |    priv->playing = false;
  126|  4.29k|}
ao_null.c:drain:
   64|  1.39M|{
   65|  1.39M|    struct priv *priv = ao->priv;
   66|       |
   67|  1.39M|    if (ao->untimed) {
  ------------------
  |  Branch (67:9): [True: 1.39M, False: 0]
  ------------------
   68|  1.39M|        priv->buffered = 0;
   69|  1.39M|        return;
   70|  1.39M|    }
   71|       |
   72|      0|    if (priv->paused)
  ------------------
  |  Branch (72:9): [True: 0, False: 0]
  ------------------
   73|      0|        return;
   74|       |
   75|      0|    double now = mp_time_sec();
   76|      0|    if (priv->buffered > 0) {
  ------------------
  |  Branch (76:9): [True: 0, False: 0]
  ------------------
   77|      0|        priv->buffered -= (now - priv->last_time) * ao->samplerate * priv->speed;
   78|      0|        if (priv->buffered < 0)
  ------------------
  |  Branch (78:13): [True: 0, False: 0]
  ------------------
   79|      0|            priv->buffered = 0;
   80|      0|    }
   81|      0|    priv->last_time = now;
   82|      0|}
ao_null.c:start:
  129|  7.83k|{
  130|  7.83k|    struct priv *priv = ao->priv;
  131|       |
  132|  7.83k|    if (priv->paused)
  ------------------
  |  Branch (132:9): [True: 0, False: 7.83k]
  ------------------
  133|  7.83k|        MP_ERR(ao, "illegal state: start() while paused\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  134|       |
  135|  7.83k|    drain(ao);
  136|  7.83k|    priv->paused = false;
  137|  7.83k|    priv->last_time = mp_time_sec();
  138|       |    priv->playing = true;
  139|  7.83k|}
ao_null.c:audio_write:
  160|   689k|{
  161|   689k|    struct priv *priv = ao->priv;
  162|       |
  163|   689k|    if (priv->buffered <= 0)
  ------------------
  |  Branch (163:9): [True: 689k, False: 0]
  ------------------
  164|   689k|        priv->buffered = priv->latency; // emulate fixed latency
  165|       |
  166|   689k|    priv->buffered += samples;
  167|       |    return true;
  168|   689k|}
ao_null.c:get_state:
  171|  1.38M|{
  172|  1.38M|    struct priv *priv = ao->priv;
  173|       |
  174|  1.38M|    drain(ao);
  175|       |
  176|  1.38M|    state->free_samples = ao->device_buffer - priv->latency - priv->buffered;
  177|  1.38M|    state->free_samples = state->free_samples / priv->outburst * priv->outburst;
  178|  1.38M|    state->queued_samples = priv->buffered;
  179|       |
  180|       |    // Note how get_state returns the delay in audio device time (instead of
  181|       |    // adjusting for speed), since most AOs seem to also do that.
  182|  1.38M|    state->delay = priv->buffered;
  183|       |
  184|       |    // Drivers with broken EOF handling usually always report the same device-
  185|       |    // level delay that is additional to the buffer time.
  186|  1.38M|    if (priv->broken_eof && priv->buffered < priv->latency)
  ------------------
  |  Branch (186:9): [True: 0, False: 1.38M]
  |  Branch (186:29): [True: 0, False: 0]
  ------------------
  187|      0|        state->delay = priv->latency;
  188|       |
  189|  1.38M|    state->delay /= ao->samplerate;
  190|       |
  191|  1.38M|    if (priv->broken_delay) { // Report only multiples of outburst
  ------------------
  |  Branch (191:9): [True: 0, False: 1.38M]
  ------------------
  192|      0|        double q = priv->outburst / (double)ao->samplerate;
  193|      0|        if (state->delay > 0)
  ------------------
  |  Branch (193:13): [True: 0, False: 0]
  ------------------
  194|      0|            state->delay = (int)(state->delay / q) * q;
  195|      0|    }
  196|       |
  197|  1.38M|    state->playing = priv->playing && priv->buffered > 0;
  ------------------
  |  Branch (197:22): [True: 1.34M, False: 34.7k]
  |  Branch (197:39): [True: 0, False: 1.34M]
  ------------------
  198|  1.38M|}

ao_wakeup:
   86|   728k|{
   87|   728k|    struct buffer_state *p = ao->buffer_state;
   88|   728k|    mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|   728k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   89|   728k|    p->need_wakeup = true;
   90|   728k|    mp_cond_broadcast(&p->pt_wakeup);
   91|   728k|    mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|   728k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   92|   728k|}
ao_get_queue:
  113|  7.95k|{
  114|  7.95k|    struct buffer_state *p = ao->buffer_state;
  115|  7.95k|    return p->queue;
  116|  7.95k|}
ao_control:
  279|  7.93k|{
  280|  7.93k|    struct buffer_state *p = ao->buffer_state;
  281|  7.93k|    int r = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  7.93k|#define CONTROL_UNKNOWN -1
  ------------------
  282|  7.93k|    if (ao->driver->control) {
  ------------------
  |  Branch (282:9): [True: 0, False: 7.93k]
  ------------------
  283|       |        // Only need to lock in push mode.
  284|      0|        if (ao->driver->write)
  ------------------
  |  Branch (284:13): [True: 0, False: 0]
  ------------------
  285|      0|            mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  286|       |
  287|      0|        r = ao->driver->control(ao, cmd, arg);
  288|       |
  289|      0|        if (ao->driver->write)
  ------------------
  |  Branch (289:13): [True: 0, False: 0]
  ------------------
  290|      0|            mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  291|      0|    }
  292|  7.93k|    return r;
  293|  7.93k|}
ao_get_delay:
  296|  34.4k|{
  297|  34.4k|    struct buffer_state *p = ao->buffer_state;
  298|       |
  299|  34.4k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  34.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|       |
  301|  34.4k|    double driver_delay;
  302|  34.4k|    if (ao->driver->write) {
  ------------------
  |  Branch (302:9): [True: 34.4k, False: 0]
  ------------------
  303|  34.4k|        struct mp_pcm_state state;
  304|  34.4k|        get_dev_state(ao, &state);
  305|  34.4k|        driver_delay = state.delay;
  306|  34.4k|    } else {
  307|      0|        int64_t end = p->end_time_ns;
  308|      0|        int64_t now = mp_time_ns();
  309|      0|        driver_delay = MPMAX(0, MP_TIME_NS_TO_S(end - now));
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  310|      0|    }
  311|       |
  312|  34.4k|    int64_t pending = mp_async_queue_get_samples(p->queue);
  313|  34.4k|    if (p->pending)
  ------------------
  |  Branch (313:9): [True: 21, False: 34.3k]
  ------------------
  314|     21|        pending += mp_aframe_get_size(p->pending);
  315|       |
  316|  34.4k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  34.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  317|  34.4k|    return driver_delay + pending / (double)ao->samplerate;
  318|  34.4k|}
ao_reset:
  322|  4.29k|{
  323|  4.29k|    struct buffer_state *p = ao->buffer_state;
  324|  4.29k|    bool wakeup = false;
  325|  4.29k|    bool do_reset = false;
  326|       |
  327|  4.29k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  4.29k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  328|       |
  329|  4.29k|    TA_FREEP(&p->pending);
  ------------------
  |  |   81|  4.29k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  4.29k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  330|  4.29k|    mp_async_queue_reset(p->queue);
  331|  4.29k|    mp_filter_reset(p->filter_root);
  332|  4.29k|    mp_async_queue_resume_reading(p->queue);
  333|       |
  334|  4.29k|    if (!ao->stream_silence && ao->driver->reset) {
  ------------------
  |  Branch (334:9): [True: 4.29k, False: 0]
  |  Branch (334:32): [True: 4.29k, False: 0]
  ------------------
  335|  4.29k|        if (ao->driver->write) {
  ------------------
  |  Branch (335:13): [True: 4.29k, False: 0]
  ------------------
  336|  4.29k|            ao->driver->reset(ao);
  337|  4.29k|        } else {
  338|       |            // Pull AOs may wait for ao_read_data() to return.
  339|       |            // That would deadlock if called from within the lock.
  340|      0|            do_reset = true;
  341|      0|        }
  342|  4.29k|        p->streaming = false;
  343|  4.29k|    }
  344|  4.29k|    wakeup = p->playing;
  345|  4.29k|    p->playing = false;
  346|  4.29k|    p->recover_pause = false;
  347|  4.29k|    p->hw_paused = false;
  348|  4.29k|    p->end_time_ns = 0;
  349|       |
  350|  4.29k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  4.29k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  351|       |
  352|  4.29k|    if (do_reset)
  ------------------
  |  Branch (352:9): [True: 0, False: 4.29k]
  ------------------
  353|      0|        ao->driver->reset(ao);
  354|       |
  355|  4.29k|    if (wakeup)
  ------------------
  |  Branch (355:9): [True: 2.01k, False: 2.27k]
  ------------------
  356|  2.01k|        ao_wakeup(ao);
  357|  4.29k|}
ao_start:
  364|  7.95k|{
  365|  7.95k|    struct buffer_state *p = ao->buffer_state;
  366|  7.95k|    bool do_start = false;
  367|       |
  368|  7.95k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  7.95k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  369|       |
  370|  7.95k|    p->playing = true;
  371|       |
  372|  7.95k|    if (!ao->driver->write && !p->paused && !p->streaming) {
  ------------------
  |  Branch (372:9): [True: 0, False: 7.95k]
  |  Branch (372:31): [True: 0, False: 0]
  |  Branch (372:45): [True: 0, False: 0]
  ------------------
  373|      0|        p->streaming = true;
  374|      0|        do_start = true;
  375|      0|    }
  376|       |
  377|  7.95k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  7.95k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  378|       |
  379|       |    // Pull AOs might call ao_read_data() so do this outside the lock.
  380|  7.95k|    if (do_start)
  ------------------
  |  Branch (380:9): [True: 0, False: 7.95k]
  ------------------
  381|      0|        ao->driver->start(ao);
  382|       |
  383|  7.95k|    ao_wakeup(ao);
  384|  7.95k|}
ao_set_paused:
  387|  7.92k|{
  388|  7.92k|    struct buffer_state *p = ao->buffer_state;
  389|  7.92k|    bool wakeup = false;
  390|  7.92k|    bool do_change_state = false;
  391|  7.92k|    bool is_hw_paused;
  392|       |
  393|       |    // If we are going to pause on eof and ao is still playing,
  394|       |    // be sure to drain the ao first for gapless.
  395|  7.92k|    if (eof && paused && ao_is_playing(ao))
  ------------------
  |  Branch (395:9): [True: 0, False: 7.92k]
  |  Branch (395:16): [True: 0, False: 0]
  |  Branch (395:26): [True: 0, False: 0]
  ------------------
  396|      0|        ao_drain(ao);
  397|       |
  398|  7.92k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  7.92k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  399|       |
  400|  7.92k|    if ((p->playing || !ao->driver->write) && !p->paused && paused) {
  ------------------
  |  Branch (400:10): [True: 0, False: 7.92k]
  |  Branch (400:24): [True: 0, False: 7.92k]
  |  Branch (400:47): [True: 0, False: 0]
  |  Branch (400:61): [True: 0, False: 0]
  ------------------
  401|      0|        if (p->streaming && !ao->stream_silence) {
  ------------------
  |  Branch (401:13): [True: 0, False: 0]
  |  Branch (401:29): [True: 0, False: 0]
  ------------------
  402|      0|            if (ao->driver->write) {
  ------------------
  |  Branch (402:17): [True: 0, False: 0]
  ------------------
  403|      0|                if (!p->recover_pause)
  ------------------
  |  Branch (403:21): [True: 0, False: 0]
  ------------------
  404|      0|                    get_dev_state(ao, &p->prepause_state);
  405|      0|                if (ao->driver->set_pause && ao->driver->set_pause(ao, true)) {
  ------------------
  |  Branch (405:21): [True: 0, False: 0]
  |  Branch (405:46): [True: 0, False: 0]
  ------------------
  406|      0|                    p->hw_paused = true;
  407|      0|                } else {
  408|      0|                    ao->driver->reset(ao);
  409|      0|                    p->streaming = false;
  410|      0|                    p->recover_pause = !ao->untimed;
  411|      0|                }
  412|      0|            } else if (ao->driver->reset || ao->driver->set_pause) {
  ------------------
  |  Branch (412:24): [True: 0, False: 0]
  |  Branch (412:45): [True: 0, False: 0]
  ------------------
  413|       |                // See ao_reset() why this is done outside of the lock.
  414|      0|                do_change_state = true;
  415|      0|                p->streaming = false;
  416|      0|                is_hw_paused = p->hw_paused = !!ao->driver->set_pause;
  417|      0|            }
  418|      0|        }
  419|      0|        wakeup = true;
  420|  7.92k|    } else if (p->playing && p->paused && !paused) {
  ------------------
  |  Branch (420:16): [True: 0, False: 7.92k]
  |  Branch (420:30): [True: 0, False: 0]
  |  Branch (420:43): [True: 0, False: 0]
  ------------------
  421|      0|        if (ao->driver->write) {
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|      0|            if (p->hw_paused)
  ------------------
  |  Branch (422:17): [True: 0, False: 0]
  ------------------
  423|      0|                ao->driver->set_pause(ao, false);
  424|      0|            p->hw_paused = false;
  425|      0|        } else {
  426|      0|            if (!p->streaming)
  ------------------
  |  Branch (426:17): [True: 0, False: 0]
  ------------------
  427|      0|                do_change_state = true;
  428|      0|            p->streaming = true;
  429|      0|            is_hw_paused = p->hw_paused;
  430|      0|            p->hw_paused = false;
  431|      0|        }
  432|      0|        wakeup = true;
  433|      0|    }
  434|  7.92k|    p->paused = paused;
  435|       |
  436|  7.92k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  7.92k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  437|       |
  438|  7.92k|    if (do_change_state) {
  ------------------
  |  Branch (438:9): [True: 0, False: 7.92k]
  ------------------
  439|      0|        if (is_hw_paused) {
  ------------------
  |  Branch (439:13): [True: 0, False: 0]
  ------------------
  440|      0|            if (paused) {
  ------------------
  |  Branch (440:17): [True: 0, False: 0]
  ------------------
  441|      0|                ao->driver->set_pause(ao, true);
  442|      0|                p->queued_time_ns = p->end_time_ns - mp_time_ns();
  443|      0|            } else {
  444|      0|                p->end_time_ns = p->queued_time_ns + mp_time_ns();
  445|      0|                ao->driver->set_pause(ao, false);
  446|      0|            }
  447|      0|        } else {
  448|      0|            if (paused)
  ------------------
  |  Branch (448:17): [True: 0, False: 0]
  ------------------
  449|      0|                ao->driver->reset(ao);
  450|      0|            else
  451|      0|                ao->driver->start(ao);
  452|      0|        }
  453|      0|    }
  454|       |
  455|  7.92k|    if (wakeup)
  ------------------
  |  Branch (455:9): [True: 0, False: 7.92k]
  ------------------
  456|      0|        ao_wakeup(ao);
  457|  7.92k|}
ao_is_playing:
  464|  83.3k|{
  465|  83.3k|    struct buffer_state *p = ao->buffer_state;
  466|       |
  467|  83.3k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  83.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  468|  83.3k|    bool playing = p->playing;
  469|  83.3k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  83.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  470|       |
  471|  83.3k|    return playing;
  472|  83.3k|}
ao_drain:
  476|  1.99k|{
  477|  1.99k|    struct buffer_state *p = ao->buffer_state;
  478|       |
  479|  1.99k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  1.99k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  480|  2.82k|    while (!p->paused && p->playing) {
  ------------------
  |  Branch (480:12): [True: 2.82k, False: 0]
  |  Branch (480:26): [True: 2.82k, False: 5]
  ------------------
  481|       |        // Untimed AOs never signal an underrun, they are done once they took
  482|       |        // everything.
  483|  2.82k|        if (ao->untimed && !p->pending && !mp_async_queue_get_samples(p->queue))
  ------------------
  |  Branch (483:13): [True: 2.82k, False: 0]
  |  Branch (483:28): [True: 2.82k, False: 0]
  |  Branch (483:43): [True: 1.87k, False: 950]
  ------------------
  484|  1.87k|            break;
  485|    950|        mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|    950|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  486|    950|        double delay = ao_get_delay(ao);
  487|    950|        mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|    950|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  488|       |
  489|       |        // Wait for buffer + arbitrary ~250ms for EOF signal from AO.
  490|    950|        if (mp_cond_timedwait(&p->wakeup, &p->lock,
  ------------------
  |  Branch (490:13): [True: 113, False: 837]
  ------------------
  491|    950|                              MP_TIME_S_TO_NS(MPMAX(delay, 0) + 0.25)))
  ------------------
  |  |   71|  1.90k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 950, False: 0]
  |  |  ------------------
  ------------------
  492|    113|        {
  493|    113|            MP_VERBOSE(ao, "drain timeout\n");
  ------------------
  |  |   92|    113|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    113|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  494|    113|            break;
  495|    113|        }
  496|       |
  497|    837|        if (!p->playing && mp_async_queue_get_samples(p->queue)) {
  ------------------
  |  Branch (497:13): [True: 5, False: 832]
  |  Branch (497:28): [True: 0, False: 5]
  ------------------
  498|      0|            MP_WARN(ao, "underrun during draining\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  499|      0|            mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  500|      0|            ao_start(ao);
  501|      0|            mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  502|      0|        }
  503|    837|    }
  504|  1.99k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  1.99k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|       |
  506|  1.99k|    ao_reset(ao);
  507|  1.99k|}
ao_uninit:
  516|  7.98k|{
  517|  7.98k|    struct buffer_state *p = ao->buffer_state;
  518|       |
  519|  7.98k|    if (p && p->thread_valid) {
  ------------------
  |  Branch (519:9): [True: 7.98k, False: 0]
  |  Branch (519:14): [True: 7.92k, False: 64]
  ------------------
  520|  7.92k|        mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|  7.92k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  521|  7.92k|        p->terminate = true;
  522|  7.92k|        mp_cond_broadcast(&p->pt_wakeup);
  523|  7.92k|        mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|  7.92k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  524|       |
  525|  7.92k|        mp_thread_join(p->thread);
  ------------------
  |  |  215|  7.92k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  526|  7.92k|        p->thread_valid = false;
  527|  7.92k|    }
  528|       |
  529|  7.98k|    if (ao->driver_initialized)
  ------------------
  |  Branch (529:9): [True: 7.98k, False: 0]
  ------------------
  530|  7.98k|        ao->driver->uninit(ao);
  531|       |
  532|  7.98k|    if (p) {
  ------------------
  |  Branch (532:9): [True: 7.98k, False: 0]
  ------------------
  533|  7.98k|        talloc_free(p->filter_root);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  534|  7.98k|        talloc_free(p->queue);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  535|  7.98k|        talloc_free(p->pending);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  536|  7.98k|        talloc_free(p->convert_buffer);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  537|  7.98k|        talloc_free(p->temp_buf);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  538|       |
  539|  7.98k|        mp_cond_destroy(&p->wakeup);
  540|  7.98k|        mp_mutex_destroy(&p->lock);
  ------------------
  |  |  133|  7.98k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  541|       |
  542|  7.98k|        mp_cond_destroy(&p->pt_wakeup);
  543|  7.98k|        mp_mutex_destroy(&p->pt_lock);
  ------------------
  |  |  133|  7.98k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  544|  7.98k|    }
  545|       |
  546|  7.98k|    talloc_free(ao);
  ------------------
  |  |   47|  7.98k|#define talloc_free                     ta_free
  ------------------
  547|  7.98k|}
init_buffer_pre:
  550|  7.98k|{
  551|  7.98k|    ao->buffer_state = talloc_zero(ao, struct buffer_state);
  ------------------
  |  |   27|  7.98k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  7.98k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  7.98k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  552|  7.98k|}
init_buffer_post:
  555|  7.92k|{
  556|  7.92k|    struct buffer_state *p = ao->buffer_state;
  557|       |
  558|  7.92k|    mp_assert(ao->driver->start);
  ------------------
  |  |   41|  7.92k|#define mp_assert assert
  ------------------
  |  Branch (558:5): [True: 7.92k, False: 0]
  ------------------
  559|  7.92k|    if (ao->driver->write) {
  ------------------
  |  Branch (559:9): [True: 7.92k, False: 0]
  ------------------
  560|  7.92k|        mp_assert(ao->driver->reset);
  ------------------
  |  |   41|  7.92k|#define mp_assert assert
  ------------------
  |  Branch (560:9): [True: 7.92k, False: 0]
  ------------------
  561|  7.92k|        mp_assert(ao->driver->get_state);
  ------------------
  |  |   41|  7.92k|#define mp_assert assert
  ------------------
  |  Branch (561:9): [True: 7.92k, False: 0]
  ------------------
  562|  7.92k|    }
  563|       |
  564|  7.92k|    mp_mutex_init(&p->lock);
  565|  7.92k|    mp_cond_init(&p->wakeup);
  566|       |
  567|  7.92k|    mp_mutex_init(&p->pt_lock);
  568|  7.92k|    mp_cond_init(&p->pt_wakeup);
  569|       |
  570|  7.92k|    p->queue = mp_async_queue_create();
  571|  7.92k|    p->filter_root = mp_filter_create_root(ao->global);
  572|  7.92k|    p->input = mp_async_queue_create_filter(p->filter_root, MP_PIN_OUT, p->queue);
  573|       |
  574|  7.92k|    mp_async_queue_resume_reading(p->queue);
  575|       |
  576|  7.92k|    struct mp_async_queue_config cfg = {
  577|  7.92k|        .sample_unit = AQUEUE_UNIT_SAMPLES,
  578|  7.92k|        .max_samples = ao->buffer,
  579|  7.92k|        .max_bytes = INT64_MAX,
  580|  7.92k|    };
  581|  7.92k|    mp_async_queue_set_config(p->queue, cfg);
  582|       |
  583|  7.92k|    if (ao->driver->write) {
  ------------------
  |  Branch (583:9): [True: 7.92k, False: 0]
  ------------------
  584|  7.92k|        mp_filter_graph_set_wakeup_cb(p->filter_root, wakeup_filters, ao);
  585|       |
  586|  7.92k|        p->thread_valid = true;
  587|  7.92k|        if (mp_thread_create(&p->thread, ao_thread, ao)) {
  ------------------
  |  |  214|  7.92k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 7.92k]
  |  |  ------------------
  ------------------
  588|      0|            p->thread_valid = false;
  589|      0|            return false;
  590|      0|        }
  591|  7.92k|    } else {
  592|      0|        if (ao->stream_silence) {
  ------------------
  |  Branch (592:13): [True: 0, False: 0]
  ------------------
  593|      0|            ao->driver->start(ao);
  594|      0|            p->streaming = true;
  595|      0|        }
  596|      0|    }
  597|       |
  598|  7.92k|    if (ao->stream_silence) {
  ------------------
  |  Branch (598:9): [True: 0, False: 7.92k]
  ------------------
  599|      0|        MP_WARN(ao, "The --audio-stream-silence option is set. This will break "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  600|      0|                "certain player behavior.\n");
  601|      0|    }
  602|       |
  603|       |    return true;
  604|  7.92k|}
buffer.c:read_buffer:
  121|  1.34M|{
  122|  1.34M|    struct buffer_state *p = ao->buffer_state;
  123|  1.34M|    int pos = 0;
  124|  1.34M|    *eof = false;
  125|       |
  126|  2.16M|    while (p->playing && !p->paused && pos < samples) {
  ------------------
  |  Branch (126:12): [True: 2.16M, False: 0]
  |  Branch (126:26): [True: 2.16M, False: 0]
  |  Branch (126:40): [True: 2.15M, False: 5.42k]
  ------------------
  127|  2.15M|        if (!p->pending || !mp_aframe_get_size(p->pending)) {
  ------------------
  |  Branch (127:13): [True: 1.34M, False: 805k]
  |  Branch (127:28): [True: 800k, False: 5.01k]
  ------------------
  128|  2.15M|            TA_FREEP(&p->pending);
  ------------------
  |  |   81|  2.15M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  2.15M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 2.15M]
  |  |  ------------------
  ------------------
  129|  2.15M|            struct mp_frame frame = mp_pin_out_read(p->input->pins[0]);
  130|  2.15M|            if (!frame.type)
  ------------------
  |  Branch (130:17): [True: 1.34M, False: 806k]
  ------------------
  131|  1.34M|                break; // we can't/don't want to block
  132|   806k|            if (frame.type != MP_FRAME_AUDIO) {
  ------------------
  |  Branch (132:17): [True: 5.93k, False: 800k]
  ------------------
  133|  5.93k|                if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (133:21): [True: 5.93k, False: 0]
  ------------------
  134|  5.93k|                    *eof = true;
  135|  5.93k|                mp_frame_unref(&frame);
  136|  5.93k|                continue;
  137|  5.93k|            }
  138|   800k|            p->pending = frame.data;
  139|   800k|        }
  140|       |
  141|   805k|        if (!data)
  ------------------
  |  Branch (141:13): [True: 0, False: 805k]
  ------------------
  142|      0|            break;
  143|       |
  144|   805k|        int copy = mp_aframe_get_size(p->pending);
  145|   805k|        uint8_t **fdata = mp_aframe_get_data_ro(p->pending);
  146|   805k|        copy = MPMIN(copy, samples - pos);
  ------------------
  |  |   45|   805k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 5.01k, False: 800k]
  |  |  ------------------
  ------------------
  147|  1.66M|        for (int n = 0; n < ao->num_planes; n++) {
  ------------------
  |  Branch (147:25): [True: 862k, False: 805k]
  ------------------
  148|   862k|            memcpy((char *)data[n] + pos * ao->sstride,
  149|   862k|                   fdata[n], copy * ao->sstride);
  150|   862k|        }
  151|   805k|        mp_aframe_skip_samples(p->pending, copy);
  152|   805k|        pos += copy;
  153|   805k|        *eof = false;
  154|   805k|    }
  155|       |
  156|  1.34M|    if (!data) {
  ------------------
  |  Branch (156:9): [True: 0, False: 1.34M]
  ------------------
  157|      0|        if (!p->pending)
  ------------------
  |  Branch (157:13): [True: 0, False: 0]
  ------------------
  158|      0|            return 0;
  159|      0|        void **pd = (void *)mp_aframe_get_data_rw(p->pending);
  160|      0|        if (pd)
  ------------------
  |  Branch (160:13): [True: 0, False: 0]
  ------------------
  161|      0|            ao_post_process_data(ao, pd, mp_aframe_get_size(p->pending));
  162|      0|        return 1;
  163|      0|    }
  164|       |
  165|       |    // pad with silence (underflow/paused/eof)
  166|  1.34M|    if (pad_silence) {
  ------------------
  |  Branch (166:9): [True: 1.34M, False: 0]
  ------------------
  167|  2.78M|        for (int n = 0; n < ao->num_planes; n++) {
  ------------------
  |  Branch (167:25): [True: 1.43M, False: 1.34M]
  ------------------
  168|  1.43M|            af_fill_silence((char *)data[n] + pos * ao->sstride,
  169|  1.43M|                    (samples - pos) * ao->sstride,
  170|  1.43M|                    ao->format);
  171|  1.43M|        }
  172|  1.34M|    }
  173|       |
  174|  1.34M|    ao_post_process_data(ao, data, pos);
  175|  1.34M|    return pos;
  176|  1.34M|}
buffer.c:get_dev_state:
   96|  1.38M|{
   97|  1.38M|    struct buffer_state *p = ao->buffer_state;
   98|       |
   99|  1.38M|    if (p->paused && p->playing && !ao->stream_silence) {
  ------------------
  |  Branch (99:9): [True: 0, False: 1.38M]
  |  Branch (99:22): [True: 0, False: 0]
  |  Branch (99:36): [True: 0, False: 0]
  ------------------
  100|      0|        *state = p->prepause_state;
  101|      0|        return;
  102|      0|    }
  103|       |
  104|  1.38M|    *state = (struct mp_pcm_state){
  105|  1.38M|        .free_samples = -1,
  106|  1.38M|        .queued_samples = -1,
  107|  1.38M|        .delay = -1,
  108|  1.38M|    };
  109|  1.38M|    ao->driver->get_state(ao, state);
  110|  1.38M|}
buffer.c:wakeup_filters:
  510|   718k|{
  511|   718k|    struct ao *ao = ctx;
  512|   718k|    ao_wakeup(ao);
  513|   718k|}
buffer.c:ao_thread:
  715|  7.92k|{
  716|  7.92k|    struct ao *ao = arg;
  717|  7.92k|    struct buffer_state *p = ao->buffer_state;
  718|  7.92k|    mp_thread_set_name("ao");
  719|  1.37M|    while (1) {
  ------------------
  |  Branch (719:12): [True: 1.37M, Folded]
  ------------------
  720|  1.37M|        mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  1.37M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  721|       |
  722|  1.37M|        bool retry = ao_play_data(ao);
  723|       |
  724|       |        // Wait until the device wants us to write more data to it.
  725|       |        // Fallback to guessing.
  726|  1.37M|        int64_t timeout = INT64_MAX;
  727|  1.37M|        if (p->streaming && !retry && (!p->paused || ao->stream_silence)) {
  ------------------
  |  Branch (727:13): [True: 1.34M, False: 30.5k]
  |  Branch (727:29): [True: 656k, False: 686k]
  |  Branch (727:40): [True: 656k, False: 0]
  |  Branch (727:54): [True: 0, False: 0]
  ------------------
  728|       |            // Wake up again if half of the audio buffer has been played.
  729|       |            // Since audio could play at a faster or slower pace, wake up twice
  730|       |            // as often as ideally needed.
  731|   656k|            timeout = MP_TIME_S_TO_NS(ao->device_buffer / (double)ao->samplerate * 0.25);
  ------------------
  |  |   71|   656k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  732|   656k|        }
  733|       |
  734|  1.37M|        mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  1.37M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  735|       |
  736|  1.37M|        mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|  1.37M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  737|  1.37M|        if (p->terminate) {
  ------------------
  |  Branch (737:13): [True: 7.92k, False: 1.36M]
  ------------------
  738|  7.92k|            mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|  7.92k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  739|  7.92k|            break;
  740|  7.92k|        }
  741|  1.36M|        if (!p->need_wakeup && !retry) {
  ------------------
  |  Branch (741:13): [True: 1.30M, False: 65.4k]
  |  Branch (741:32): [True: 658k, False: 641k]
  ------------------
  742|   658k|            MP_STATS(ao, "start audio wait");
  ------------------
  |  |   99|   658k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   658k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  743|   658k|            mp_cond_timedwait(&p->pt_wakeup, &p->pt_lock, timeout);
  744|   658k|            MP_STATS(ao, "end audio wait");
  ------------------
  |  |   99|   658k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   658k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  745|   658k|        }
  746|  1.36M|        p->need_wakeup = false;
  747|  1.36M|        mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|  1.36M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  748|  1.36M|    }
  749|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  7.92k|#define MP_THREAD_RETURN() return NULL
  ------------------
  750|  7.92k|}
buffer.c:ao_play_data:
  630|  1.37M|{
  631|  1.37M|    struct buffer_state *p = ao->buffer_state;
  632|       |
  633|  1.37M|    if ((!p->playing || p->paused) && !ao->stream_silence)
  ------------------
  |  Branch (633:10): [True: 23.8k, False: 1.34M]
  |  Branch (633:25): [True: 0, False: 1.34M]
  |  Branch (633:39): [True: 23.8k, False: 0]
  ------------------
  634|  23.8k|        return false;
  635|       |
  636|  1.34M|    struct mp_pcm_state state;
  637|  1.34M|    get_dev_state(ao, &state);
  638|       |
  639|  1.34M|    if (p->streaming && !state.playing && !ao->untimed)
  ------------------
  |  Branch (639:9): [True: 1.34M, False: 8.55k]
  |  Branch (639:25): [True: 1.34M, False: 0]
  |  Branch (639:43): [True: 0, False: 1.34M]
  ------------------
  640|      0|        goto eof;
  641|       |
  642|  1.34M|    void **planes = NULL;
  643|  1.34M|    int space = state.free_samples;
  644|  1.34M|    if (!space)
  ------------------
  |  Branch (644:9): [True: 0, False: 1.34M]
  ------------------
  645|      0|        return false;
  646|  1.34M|    mp_assert(space >= 0);
  ------------------
  |  |   41|  1.34M|#define mp_assert assert
  ------------------
  |  Branch (646:5): [True: 1.34M, False: 0]
  ------------------
  647|       |
  648|  1.34M|    int samples = 0;
  649|  1.34M|    bool got_eof = false;
  650|  1.34M|    if (ao->driver->write_frames) {
  ------------------
  |  Branch (650:9): [True: 0, False: 1.34M]
  ------------------
  651|      0|        TA_FREEP(&p->pending);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  652|      0|        samples = read_buffer(ao, NULL, 1, &got_eof, false);
  653|      0|        planes = (void **)&p->pending;
  654|  1.34M|    } else {
  655|  1.34M|        if (!realloc_buf(ao, space)) {
  ------------------
  |  Branch (655:13): [True: 113, False: 1.34M]
  ------------------
  656|    113|            MP_ERR(ao, "Failed to allocate buffer.\n");
  ------------------
  |  |   89|    113|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    113|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  657|    113|            return false;
  658|    113|        }
  659|  1.34M|        planes = (void **)mp_aframe_get_data_rw(p->temp_buf);
  660|  1.34M|        mp_assert(planes);
  ------------------
  |  |   41|  1.34M|#define mp_assert assert
  ------------------
  |  Branch (660:9): [True: 1.34M, False: 0]
  ------------------
  661|       |
  662|  1.34M|        if (p->recover_pause) {
  ------------------
  |  Branch (662:13): [True: 0, False: 1.34M]
  ------------------
  663|      0|            samples = MPCLAMP(p->prepause_state.delay * ao->samplerate, 0, space);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  664|      0|            p->recover_pause = false;
  665|      0|            mp_aframe_set_silence(p->temp_buf, 0, space);
  666|      0|        }
  667|       |
  668|  1.34M|        if (!samples) {
  ------------------
  |  Branch (668:13): [True: 1.34M, False: 0]
  ------------------
  669|  1.34M|            samples = read_buffer(ao, planes, space, &got_eof, true);
  670|  1.34M|            if (p->paused || (ao->stream_silence && !p->playing))
  ------------------
  |  Branch (670:17): [True: 0, False: 1.34M]
  |  Branch (670:31): [True: 0, False: 1.34M]
  |  Branch (670:53): [True: 0, False: 0]
  ------------------
  671|      0|                samples = space; // read_buffer() sets remainder to silent
  672|  1.34M|        }
  673|  1.34M|    }
  674|       |
  675|  1.34M|    if (samples) {
  ------------------
  |  Branch (675:9): [True: 689k, False: 659k]
  ------------------
  676|   689k|        MP_STATS(ao, "start ao fill");
  ------------------
  |  |   99|   689k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   689k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  677|   689k|        if (!ao->driver->write(ao, planes, samples))
  ------------------
  |  Branch (677:13): [True: 0, False: 689k]
  ------------------
  678|   689k|            MP_ERR(ao, "Error writing audio to device.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  679|   689k|        MP_STATS(ao, "end ao fill");
  ------------------
  |  |   99|   689k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   689k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  680|       |
  681|   689k|        if (!p->streaming) {
  ------------------
  |  Branch (681:13): [True: 7.83k, False: 681k]
  ------------------
  682|  7.83k|            MP_VERBOSE(ao, "starting AO\n");
  ------------------
  |  |   92|  7.83k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.83k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  683|  7.83k|            ao->driver->start(ao);
  684|  7.83k|            p->streaming = true;
  685|  7.83k|            state.playing = true;
  686|  7.83k|        }
  687|   689k|    }
  688|       |
  689|  1.34M|    MP_TRACE(ao, "in=%d space=%d(%d) pl=%d, eof=%d\n",
  ------------------
  |  |   94|  1.34M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.34M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  690|  1.34M|             samples, space, state.free_samples, p->playing, got_eof);
  691|       |
  692|  1.34M|    if (got_eof)
  ------------------
  |  Branch (692:9): [True: 5.93k, False: 1.34M]
  ------------------
  693|  5.93k|        goto eof;
  694|       |
  695|       |    // For ao_drain(), an untimed AO took everything.
  696|  1.34M|    if (ao->untimed && !samples)
  ------------------
  |  Branch (696:9): [True: 1.34M, False: 0]
  |  Branch (696:24): [True: 657k, False: 686k]
  ------------------
  697|   657k|        mp_cond_broadcast(&p->wakeup);
  698|       |
  699|  1.34M|    return samples > 0 && (samples < space || ao->untimed);
  ------------------
  |  Branch (699:12): [True: 686k, False: 657k]
  |  Branch (699:28): [True: 680k, False: 5.42k]
  |  Branch (699:47): [True: 5.42k, False: 0]
  ------------------
  700|       |
  701|  5.93k|eof:
  702|  5.93k|    MP_VERBOSE(ao, "audio end or underrun\n");
  ------------------
  |  |   92|  5.93k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.93k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  703|       |    // Normal AOs signal EOF on underrun, untimed AOs never signal underruns.
  704|  5.93k|    if (ao->untimed || !state.playing || ao->stream_silence) {
  ------------------
  |  Branch (704:9): [True: 5.93k, False: 0]
  |  Branch (704:24): [True: 0, False: 0]
  |  Branch (704:42): [True: 0, False: 0]
  ------------------
  705|  5.93k|        p->streaming = state.playing && !ao->untimed;
  ------------------
  |  Branch (705:24): [True: 2.66k, False: 3.26k]
  |  Branch (705:41): [True: 0, False: 2.66k]
  ------------------
  706|  5.93k|        p->playing = false;
  707|  5.93k|    }
  708|  5.93k|    ao->wakeup_cb(ao->wakeup_ctx);
  709|       |    // For ao_drain().
  710|  5.93k|    mp_cond_broadcast(&p->wakeup);
  711|       |    return true;
  712|  1.34M|}
buffer.c:realloc_buf:
  607|  1.34M|{
  608|  1.34M|    struct buffer_state *p = ao->buffer_state;
  609|       |
  610|  1.34M|    samples = MPMAX(1, samples);
  ------------------
  |  |   44|  1.34M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 1.34M]
  |  |  ------------------
  ------------------
  611|       |
  612|  1.34M|    if (!p->temp_buf || samples > mp_aframe_get_size(p->temp_buf)) {
  ------------------
  |  Branch (612:9): [True: 7.92k, False: 1.34M]
  |  Branch (612:25): [True: 0, False: 1.34M]
  ------------------
  613|  7.92k|        TA_FREEP(&p->temp_buf);
  ------------------
  |  |   81|  7.92k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  7.92k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 7.92k]
  |  |  ------------------
  ------------------
  614|  7.92k|        p->temp_buf = mp_aframe_create();
  615|  7.92k|        if (!mp_aframe_set_format(p->temp_buf, ao->format) ||
  ------------------
  |  Branch (615:13): [True: 0, False: 7.92k]
  ------------------
  616|  7.92k|            !mp_aframe_set_chmap(p->temp_buf, &ao->channels) ||
  ------------------
  |  Branch (616:13): [True: 0, False: 7.92k]
  ------------------
  617|  7.92k|            !mp_aframe_set_rate(p->temp_buf, ao->samplerate) ||
  ------------------
  |  Branch (617:13): [True: 113, False: 7.80k]
  ------------------
  618|  7.80k|            !mp_aframe_alloc_data(p->temp_buf, samples))
  ------------------
  |  Branch (618:13): [True: 0, False: 7.80k]
  ------------------
  619|    113|        {
  620|    113|            TA_FREEP(&p->temp_buf);
  ------------------
  |  |   81|    113|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    113|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 113]
  |  |  ------------------
  ------------------
  621|    113|            return false;
  622|    113|        }
  623|  7.92k|    }
  624|       |
  625|  1.34M|    return true;
  626|  1.34M|}

mp_to_av_stream_type:
   44|  1.04k|{
   45|  1.04k|    switch (type) {
   46|  1.04k|    case STREAM_VIDEO: return AVMEDIA_TYPE_VIDEO;
  ------------------
  |  Branch (46:5): [True: 1.04k, False: 0]
  ------------------
   47|      0|    case STREAM_AUDIO: return AVMEDIA_TYPE_AUDIO;
  ------------------
  |  Branch (47:5): [True: 0, False: 1.04k]
  ------------------
   48|      0|    case STREAM_SUB:   return AVMEDIA_TYPE_SUBTITLE;
  ------------------
  |  Branch (48:5): [True: 0, False: 1.04k]
  ------------------
   49|      0|    default:           return AVMEDIA_TYPE_UNKNOWN;
  ------------------
  |  Branch (49:5): [True: 0, False: 1.04k]
  ------------------
   50|  1.04k|    }
   51|  1.04k|}
mp_codec_params_to_av:
   54|  20.0k|{
   55|  20.0k|    AVCodecParameters *avp = avcodec_parameters_alloc();
   56|  20.0k|    if (!avp)
  ------------------
  |  Branch (56:9): [True: 0, False: 20.0k]
  ------------------
   57|      0|        return NULL;
   58|       |
   59|       |    // If we have lavf demuxer params, they overwrite by definition any others.
   60|  20.0k|    if (c->lav_codecpar) {
  ------------------
  |  Branch (60:9): [True: 18.9k, False: 1.04k]
  ------------------
   61|  18.9k|        if (avcodec_parameters_copy(avp, c->lav_codecpar) < 0)
  ------------------
  |  Branch (61:13): [True: 0, False: 18.9k]
  ------------------
   62|      0|            goto error;
   63|  18.9k|        return avp;
   64|  18.9k|    }
   65|       |
   66|  1.04k|    avp->codec_type = mp_to_av_stream_type(c->type);
   67|  1.04k|    avp->codec_id = mp_codec_to_av_codec_id(c->codec);
   68|  1.04k|    avp->codec_tag = c->codec_tag;
   69|  1.04k|    if (c->extradata_size) {
  ------------------
  |  Branch (69:9): [True: 0, False: 1.04k]
  ------------------
   70|      0|        uint8_t *extradata = c->extradata;
   71|      0|        int size = c->extradata_size;
   72|       |
   73|      0|        if (avp->codec_id == AV_CODEC_ID_FLAC) {
  ------------------
  |  Branch (73:13): [True: 0, False: 0]
  ------------------
   74|       |            // ffmpeg expects FLAC extradata to be just the STREAMINFO,
   75|       |            // so grab only that (and assume it'll be the first block)
   76|      0|            if (size >= 8 && !memcmp(c->extradata, "fLaC", 4)) {
  ------------------
  |  Branch (76:17): [True: 0, False: 0]
  |  Branch (76:30): [True: 0, False: 0]
  ------------------
   77|      0|                extradata += 8;
   78|      0|                size = MPMIN(34, size - 8); // FLAC_STREAMINFO_SIZE
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   79|      0|            }
   80|      0|        }
   81|       |
   82|      0|        avp->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
   83|      0|        if (!avp->extradata)
  ------------------
  |  Branch (83:13): [True: 0, False: 0]
  ------------------
   84|      0|            goto error;
   85|      0|        avp->extradata_size = size;
   86|      0|        memcpy(avp->extradata, extradata, size);
   87|      0|    }
   88|  1.04k|    avp->bits_per_coded_sample = c->bits_per_coded_sample;
   89|       |
   90|       |    // Video only
   91|  1.04k|    avp->width = c->disp_w;
   92|  1.04k|    avp->height = c->disp_h;
   93|       |
   94|       |    // Audio only
   95|  1.04k|    avp->sample_rate = c->samplerate;
   96|  1.04k|    avp->bit_rate = c->bitrate;
   97|  1.04k|    avp->block_align = c->block_align;
   98|       |
   99|  1.04k|    mp_chmap_to_av_layout(&avp->ch_layout, &c->channels);
  100|       |
  101|  1.04k|    return avp;
  102|      0|error:
  103|      0|    avcodec_parameters_free(&avp);
  104|       |    return NULL;
  105|  1.04k|}
mp_set_avctx_codec_headers:
  109|  20.0k|{
  110|  20.0k|    enum AVMediaType codec_type = avctx->codec_type;
  111|  20.0k|    enum AVCodecID codec_id = avctx->codec_id;
  112|  20.0k|    AVCodecParameters *avp = mp_codec_params_to_av(c);
  113|  20.0k|    if (!avp)
  ------------------
  |  Branch (113:9): [True: 0, False: 20.0k]
  ------------------
  114|      0|        return -1;
  115|       |
  116|  20.0k|    int r = avcodec_parameters_to_context(avctx, avp) < 0 ? -1 : 0;
  ------------------
  |  Branch (116:13): [True: 0, False: 20.0k]
  ------------------
  117|  20.0k|    avcodec_parameters_free(&avp);
  118|       |
  119|  20.0k|    if (avctx->codec_type != AVMEDIA_TYPE_UNKNOWN)
  ------------------
  |  Branch (119:9): [True: 20.0k, False: 0]
  ------------------
  120|  20.0k|        avctx->codec_type = codec_type;
  121|  20.0k|    if (avctx->codec_id != AV_CODEC_ID_NONE)
  ------------------
  |  Branch (121:9): [True: 20.0k, False: 0]
  ------------------
  122|  20.0k|        avctx->codec_id = codec_id;
  123|  20.0k|    return r;
  124|  20.0k|}
mp_get_codec_timebase:
  129|  20.0k|{
  130|  20.0k|    AVRational tb = {c->native_tb_num, c->native_tb_den};
  131|  20.0k|    if (tb.num < 1 || tb.den < 1) {
  ------------------
  |  Branch (131:9): [True: 1.04k, False: 18.9k]
  |  Branch (131:23): [True: 0, False: 18.9k]
  ------------------
  132|  1.04k|        if (c->reliable_fps)
  ------------------
  |  Branch (132:13): [True: 1.04k, False: 0]
  ------------------
  133|  1.04k|            tb = av_inv_q(av_d2q(c->fps, 1000000));
  134|  1.04k|        if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (134:13): [True: 0, False: 1.04k]
  |  Branch (134:27): [True: 0, False: 1.04k]
  ------------------
  135|      0|            tb = AV_TIME_BASE_Q;
  136|  1.04k|    }
  137|       |
  138|       |    // If the timebase is too coarse, raise its precision, or small adjustments
  139|       |    // to timestamps done between decoder and demuxer could be lost.
  140|  20.0k|    int64_t den = tb.den;
  141|  20.0k|    if (av_q2d(tb) > 0.001) {
  ------------------
  |  Branch (141:9): [True: 4.19k, False: 15.8k]
  ------------------
  142|  4.19k|        int64_t scaling_num = tb.num * INT64_C(1000);
  143|  4.19k|        int64_t scaling_den = tb.den;
  144|  4.19k|        den *= (scaling_num + scaling_den - 1) / scaling_den;
  145|  4.19k|    }
  146|       |
  147|  20.0k|    av_reduce(&tb.num, &tb.den, tb.num, den, INT_MAX);
  148|       |
  149|  20.0k|    if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (149:9): [True: 0, False: 20.0k]
  |  Branch (149:23): [True: 0, False: 20.0k]
  ------------------
  150|      0|        tb = AV_TIME_BASE_Q;
  151|       |
  152|  20.0k|    return tb;
  153|  20.0k|}
mp_pts_to_av:
  163|  2.78M|{
  164|  2.78M|    AVRational b = get_def_tb(tb);
  165|  2.78M|    return mp_pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : llrint(mp_pts / av_q2d(b));
  ------------------
  |  |   39|  2.78M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (165:12): [True: 44.0k, False: 2.73M]
  ------------------
  166|  2.78M|}
mp_pts_from_av:
  170|  3.87M|{
  171|  3.87M|    AVRational b = get_def_tb(tb);
  172|  3.87M|    return av_pts == AV_NOPTS_VALUE ? MP_NOPTS_VALUE : av_pts * av_q2d(b);
  ------------------
  |  |   39|  20.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (172:12): [True: 20.3k, False: 3.85M]
  ------------------
  173|  3.87M|}
mp_set_av_packet:
  180|  1.39M|{
  181|  1.39M|    dst->side_data = NULL;
  182|  1.39M|    dst->side_data_elems = 0;
  183|  1.39M|    dst->buf = NULL;
  184|  1.39M|    av_packet_unref(dst);
  185|       |
  186|  1.39M|    dst->data = mpkt ? mpkt->buffer : NULL;
  ------------------
  |  Branch (186:17): [True: 1.37M, False: 13.5k]
  ------------------
  187|  1.39M|    dst->size = mpkt ? mpkt->len : 0;
  ------------------
  |  Branch (187:17): [True: 1.37M, False: 13.5k]
  ------------------
  188|       |    /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
  189|       |     * from demuxer. */
  190|  1.39M|    if (mpkt && mpkt->keyframe)
  ------------------
  |  Branch (190:9): [True: 1.37M, False: 13.5k]
  |  Branch (190:17): [True: 1.29M, False: 87.0k]
  ------------------
  191|  1.29M|        dst->flags |= AV_PKT_FLAG_KEY;
  192|  1.39M|    if (mpkt && mpkt->avpacket) {
  ------------------
  |  Branch (192:9): [True: 1.37M, False: 13.5k]
  |  Branch (192:17): [True: 1.37M, False: 0]
  ------------------
  193|  1.37M|        dst->side_data = mpkt->avpacket->side_data;
  194|  1.37M|        dst->side_data_elems = mpkt->avpacket->side_data_elems;
  195|  1.37M|        if (dst->data == mpkt->avpacket->data)
  ------------------
  |  Branch (195:13): [True: 1.37M, False: 0]
  ------------------
  196|  1.37M|            dst->buf = mpkt->avpacket->buf;
  197|  1.37M|        dst->flags |= mpkt->avpacket->flags;
  198|  1.37M|    }
  199|  1.39M|    if (mpkt && tb && tb->num > 0 && tb->den > 0)
  ------------------
  |  Branch (199:9): [True: 1.37M, False: 13.5k]
  |  Branch (199:17): [True: 1.37M, False: 0]
  |  Branch (199:23): [True: 1.37M, False: 0]
  |  Branch (199:38): [True: 1.37M, False: 0]
  ------------------
  200|  1.37M|        dst->duration = mpkt->duration / av_q2d(*tb);
  201|  1.39M|    dst->pts = mp_pts_to_av(mpkt ? mpkt->pts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  13.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (201:29): [True: 1.37M, False: 13.5k]
  ------------------
  202|  1.39M|    dst->dts = mp_pts_to_av(mpkt ? mpkt->dts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  13.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (202:29): [True: 1.37M, False: 13.5k]
  ------------------
  203|  1.39M|}
mp_set_avcodec_threads:
  206|  20.0k|{
  207|  20.0k|    if (threads == 0) {
  ------------------
  |  Branch (207:9): [True: 7.79k, False: 12.2k]
  ------------------
  208|  7.79k|        threads = av_cpu_count();
  209|  7.79k|        if (threads < 1) {
  ------------------
  |  Branch (209:13): [True: 0, False: 7.79k]
  ------------------
  210|      0|            mp_warn(l, "Could not determine thread count to use, defaulting to 1.\n");
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  211|      0|            threads = 1;
  212|  7.79k|        } else {
  213|  7.79k|            mp_verbose(l, "Detected %d logical cores.\n", threads);
  ------------------
  |  |   79|  7.79k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  214|  7.79k|            if (threads > 1)
  ------------------
  |  Branch (214:17): [True: 7.79k, False: 0]
  ------------------
  215|  7.79k|                threads += 1; // extra thread for better load balancing
  216|  7.79k|        }
  217|       |        // Apparently some libavcodec versions have or had trouble with more
  218|       |        // than 16 threads, and/or print a warning when using > 16.
  219|  7.79k|        threads = MPMIN(threads, 16);
  ------------------
  |  |   45|  7.79k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 7.79k, False: 0]
  |  |  ------------------
  ------------------
  220|  7.79k|    }
  221|  20.0k|    mp_verbose(l, "Requesting %d threads for decoding.\n", threads);
  ------------------
  |  |   79|  20.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  222|  20.0k|    avctx->thread_count = threads;
  223|  20.0k|}
mp_add_lavc_decoders:
  243|  21.8k|{
  244|       |    add_codecs(list, type, true);
  245|  21.8k|}
mp_get_lavf_demuxers:
  254|  60.9k|{
  255|  60.9k|    char **list = NULL;
  256|  60.9k|    void *iter = NULL;
  257|  60.9k|    int num = 0;
  258|  22.2M|    for (;;) {
  259|  22.2M|        const AVInputFormat *cur = av_demuxer_iterate(&iter);
  260|  22.2M|        if (!cur)
  ------------------
  |  Branch (260:13): [True: 60.9k, False: 22.2M]
  ------------------
  261|  60.9k|            break;
  262|  22.2M|        MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(list, cur->name));
  ------------------
  |  |  105|  22.2M|    do {                                            \
  |  |  106|  22.2M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  22.2M|    do {                                            \
  |  |  |  |   97|  22.2M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  22.2M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  22.2M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  22.2M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 487k, False: 21.7M]
  |  |  |  |  ------------------
  |  |  |  |   99|  22.2M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   487k|    do {                                                        \
  |  |  |  |  |  |   89|   487k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   487k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   487k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   487k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   487k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   487k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   487k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 487k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  22.2M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 22.2M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  22.2M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  22.2M|        (idxvar)++;                                 \
  |  |  109|  22.2M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 22.2M]
  |  |  ------------------
  ------------------
  263|  22.2M|    }
  264|  60.9k|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|  60.9k|    do {                                            \
  |  |  106|  60.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.9k|    do {                                            \
  |  |  |  |   97|  60.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 60.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.9k|        (idxvar)++;                                 \
  |  |  109|  60.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.9k]
  |  |  ------------------
  ------------------
  265|  60.9k|    return list;
  266|  60.9k|}
mp_get_lavf_protocols:
  269|  90.6k|{
  270|  90.6k|    char **list = NULL;
  271|  90.6k|    int num = 0;
  272|  90.6k|    void *opaque = NULL;
  273|  90.6k|    const char *name;
  274|  1.08M|    while ((name = avio_enum_protocols(&opaque, 0)))
  ------------------
  |  Branch (274:12): [True: 997k, False: 90.6k]
  ------------------
  275|   997k|        MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(list, name));
  ------------------
  |  |  105|   997k|    do {                                            \
  |  |  106|   997k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   997k|    do {                                            \
  |  |  |  |   97|   997k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   997k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   997k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   997k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 271k, False: 725k]
  |  |  |  |  ------------------
  |  |  |  |   99|   997k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   271k|    do {                                                        \
  |  |  |  |  |  |   89|   271k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   271k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   271k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   271k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   271k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   271k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   271k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 271k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   997k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 997k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   997k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   997k|        (idxvar)++;                                 \
  |  |  109|   997k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 997k]
  |  |  ------------------
  ------------------
  276|  90.6k|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|  90.6k|    do {                                            \
  |  |  106|  90.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  90.6k|    do {                                            \
  |  |  |  |   97|  90.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  90.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  90.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  90.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 90.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  90.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  90.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 90.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  90.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  90.6k|        (idxvar)++;                                 \
  |  |  109|  90.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 90.6k]
  |  |  ------------------
  ------------------
  277|  90.6k|    return list;
  278|  90.6k|}
mp_codec_to_av_codec_id:
  281|  13.4k|{
  282|  13.4k|    int id = AV_CODEC_ID_NONE;
  283|  13.4k|    if (codec) {
  ------------------
  |  Branch (283:9): [True: 13.4k, False: 0]
  ------------------
  284|  13.4k|        const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
  285|  13.4k|        if (desc)
  ------------------
  |  Branch (285:13): [True: 13.3k, False: 56]
  ------------------
  286|  13.3k|            id = desc->id;
  287|  13.4k|        if (id == AV_CODEC_ID_NONE) {
  ------------------
  |  Branch (287:13): [True: 56, False: 13.3k]
  ------------------
  288|     56|            const AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
  289|     56|            if (avcodec)
  ------------------
  |  Branch (289:17): [True: 0, False: 56]
  ------------------
  290|      0|                id = avcodec->id;
  291|     56|        }
  292|  13.4k|    }
  293|  13.4k|    return id;
  294|  13.4k|}
mp_codec_from_av_codec_id:
  297|  5.28M|{
  298|  5.28M|    const char *name = NULL;
  299|  5.28M|    const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
  300|  5.28M|    if (desc)
  ------------------
  |  Branch (300:9): [True: 5.28M, False: 216]
  ------------------
  301|  5.28M|        name = desc->name;
  302|  5.28M|    if (!name) {
  ------------------
  |  Branch (302:9): [True: 216, False: 5.28M]
  ------------------
  303|    216|        const AVCodec *avcodec = avcodec_find_decoder(codec_id);
  304|    216|        if (avcodec)
  ------------------
  |  Branch (304:13): [True: 0, False: 216]
  ------------------
  305|      0|            name = avcodec->name;
  306|    216|    }
  307|  5.28M|    return name;
  308|  5.28M|}
mp_codec_is_lossless:
  311|  12.3k|{
  312|  12.3k|    const AVCodecDescriptor *desc =
  313|  12.3k|        avcodec_descriptor_get(mp_codec_to_av_codec_id(codec));
  314|  12.3k|    return desc && (desc->props & AV_CODEC_PROP_LOSSLESS);
  ------------------
  |  Branch (314:12): [True: 12.3k, False: 56]
  |  Branch (314:20): [True: 3.30k, False: 9.01k]
  ------------------
  315|  12.3k|}
mp_set_avdict:
  320|  56.3k|{
  321|  56.3k|    for (int n = 0; kv && kv[n * 2]; n++)
  ------------------
  |  Branch (321:21): [True: 0, False: 56.3k]
  |  Branch (321:27): [True: 0, False: 0]
  ------------------
  322|      0|        av_dict_set(dict, kv[n * 2 + 0], kv[n * 2 + 1], 0);
  323|  56.3k|}
mp_avdict_print_unset:
  328|  51.7k|{
  329|  51.7k|    AVDictionaryEntry *t = NULL;
  330|   234k|    while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX)))
  ------------------
  |  Branch (330:12): [True: 182k, False: 51.7k]
  ------------------
  331|   182k|        mp_msg(log, msgl, "Could not set AVOption %s='%s'\n", t->key, t->value);
  332|  51.7k|}
mp_set_avopts:
  369|  20.0k|{
  370|  20.0k|    return mp_set_avopts_pos(log, avobj, avobj, kv);
  371|  20.0k|}
mp_set_avopts_pos:
  376|  20.0k|{
  377|  20.0k|    int success = 0;
  378|  20.0k|    for (int n = 0; kv && kv[n * 2]; n++) {
  ------------------
  |  Branch (378:21): [True: 0, False: 20.0k]
  |  Branch (378:27): [True: 0, False: 0]
  ------------------
  379|      0|        char *k = kv[n * 2 + 0];
  380|      0|        char *v = kv[n * 2 + 1];
  381|      0|        resolve_positional_arg(posargs, &k);
  382|      0|        int r = av_opt_set(avobj, k, v, AV_OPT_SEARCH_CHILDREN);
  383|      0|        if (r == AVERROR_OPTION_NOT_FOUND) {
  ------------------
  |  Branch (383:13): [True: 0, False: 0]
  ------------------
  384|      0|            mp_err(log, "AVOption '%s' not found.\n", k);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  385|      0|            success = -1;
  386|      0|        } else if (r < 0) {
  ------------------
  |  Branch (386:20): [True: 0, False: 0]
  ------------------
  387|      0|            char errstr[80];
  388|      0|            av_strerror(r, errstr, sizeof(errstr));
  389|      0|            mp_err(log, "Could not set AVOption %s='%s' (%s)\n", k, v, errstr);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  390|      0|            success = -1;
  391|      0|        }
  392|      0|    }
  393|  20.0k|    return success;
  394|  20.0k|}
mp_free_av_packet:
  405|  27.9k|{
  406|  27.9k|    if (*pkt) {
  ------------------
  |  Branch (406:9): [True: 20.0k, False: 7.92k]
  ------------------
  407|  20.0k|        (*pkt)->side_data = NULL;
  408|  20.0k|        (*pkt)->side_data_elems = 0;
  409|       |        (*pkt)->buf = NULL;
  410|  20.0k|    }
  411|  27.9k|    av_packet_free(pkt);
  412|  27.9k|}
mp_codec_info_from_av:
  415|   846k|{
  416|   846k|    c->codec_profile = av_get_profile_name(avctx->codec, avctx->profile);
  417|   846k|    if (!c->codec_profile)
  ------------------
  |  Branch (417:9): [True: 842k, False: 4.30k]
  ------------------
  418|   842k|        c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile);
  419|   846k|    c->codec = avctx->codec_descriptor->name;
  420|   846k|    c->codec_desc = avctx->codec_descriptor->long_name;
  421|   846k|    c->decoder = avctx->codec->name;
  422|   846k|    c->decoder_desc = avctx->codec->long_name;
  423|   846k|}
mp_codec_info_from_avcodecpar:
  426|  22.9k|{
  427|  22.9k|    const AVCodec *codec = avcodec_find_decoder(avcodecpar->codec_id);
  428|  22.9k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(avcodecpar->codec_id);
  429|  22.9k|    c->codec = mp_codec_from_av_codec_id(avcodecpar->codec_id);
  430|  22.9k|    if (desc)
  ------------------
  |  Branch (430:9): [True: 22.7k, False: 216]
  ------------------
  431|  22.7k|        c->codec_desc = desc->long_name;
  432|  22.9k|    if (codec) {
  ------------------
  |  Branch (432:9): [True: 21.0k, False: 1.94k]
  ------------------
  433|  21.0k|        c->decoder = codec->name;
  434|  21.0k|        c->decoder_desc = codec->long_name;
  435|  21.0k|        c->codec_profile = av_get_profile_name(codec, avcodecpar->profile);
  436|  21.0k|    }
  437|  22.9k|    if (!c->codec_profile)
  ------------------
  |  Branch (437:9): [True: 18.6k, False: 4.30k]
  ------------------
  438|  18.6k|        c->codec_profile = avcodec_profile_name(avcodecpar->codec_id, avcodecpar->profile);
  439|  22.9k|}
av_common.c:get_def_tb:
  156|  6.65M|{
  157|  6.65M|    return tb && tb->num > 0 && tb->den > 0 ? *tb : AV_TIME_BASE_Q;
  ------------------
  |  Branch (157:12): [True: 6.65M, False: 10]
  |  Branch (157:18): [True: 6.65M, False: 18.4E]
  |  Branch (157:33): [True: 6.65M, False: 18.4E]
  ------------------
  158|  6.65M|}
av_common.c:add_codecs:
  227|  21.8k|{
  228|  21.8k|    void *iter = NULL;
  229|  10.9M|    for (;;) {
  230|  10.9M|        const AVCodec *cur = av_codec_iterate(&iter);
  231|  10.9M|        if (!cur)
  ------------------
  |  Branch (231:13): [True: 21.8k, False: 10.9M]
  ------------------
  232|  21.8k|            break;
  233|  10.9M|        if (av_codec_is_decoder(cur) == decoders &&
  ------------------
  |  Branch (233:13): [True: 10.9M, False: 0]
  ------------------
  234|  10.9M|            (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type))
  ------------------
  |  Branch (234:14): [True: 0, False: 10.9M]
  |  Branch (234:46): [True: 5.20M, False: 5.76M]
  ------------------
  235|  5.20M|        {
  236|  5.20M|            mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id),
  237|  5.20M|                           cur->name, cur->long_name);
  238|  5.20M|        }
  239|  10.9M|    }
  240|  21.8k|}

init_libav:
  154|  28.9k|{
  155|  28.9k|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  156|  28.9k|    if (!log_mpv_instance) {
  ------------------
  |  Branch (156:9): [True: 28.9k, False: 0]
  ------------------
  157|  28.9k|        log_mpv_instance = global;
  158|  28.9k|        log_root = mp_log_new(NULL, global->log, "ffmpeg");
  159|  28.9k|        log_decaudio = mp_log_new(log_root, log_root, "audio");
  160|  28.9k|        log_decvideo = mp_log_new(log_root, log_root, "video");
  161|  28.9k|        log_demuxer = mp_log_new(log_root, log_root, "demuxer");
  162|  28.9k|        log_buffer = (bstr){0};
  163|  28.9k|        av_log_set_callback(mp_msg_av_log_callback);
  164|  28.9k|    }
  165|  28.9k|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  166|       |
  167|  28.9k|    avformat_network_init();
  168|       |
  169|  28.9k|#if HAVE_LIBAVDEVICE
  170|  28.9k|    avdevice_register_all();
  171|  28.9k|#endif
  172|  28.9k|}
uninit_libav:
  175|  28.9k|{
  176|  28.9k|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  177|  28.9k|    if (log_mpv_instance == global) {
  ------------------
  |  Branch (177:9): [True: 28.9k, False: 0]
  ------------------
  178|  28.9k|        av_log_set_callback(av_log_default_callback);
  179|  28.9k|        log_mpv_instance = NULL;
  180|  28.9k|        talloc_free(log_root);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  181|  28.9k|    }
  182|  28.9k|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  183|  28.9k|}
check_library_versions:
  196|  57.9k|{
  197|  57.9k|    const struct lib libs[] = {
  198|  57.9k|        {"libavcodec",    LIBAVCODEC_VERSION_INT,    avcodec_version()},
  199|  57.9k|#if HAVE_LIBAVDEVICE
  200|  57.9k|        {"libavdevice",   LIBAVDEVICE_VERSION_INT,   avdevice_version()},
  201|  57.9k|#endif
  202|  57.9k|        {"libavfilter",   LIBAVFILTER_VERSION_INT,   avfilter_version()},
  203|  57.9k|        {"libavformat",   LIBAVFORMAT_VERSION_INT,   avformat_version()},
  204|  57.9k|        {"libavutil",     LIBAVUTIL_VERSION_INT,     avutil_version()},
  205|  57.9k|        {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()},
  206|  57.9k|        {"libswscale",    LIBSWSCALE_VERSION_INT,    swscale_version()},
  207|  57.9k|    };
  208|       |
  209|  57.9k|    const char *runtime_version = av_version_info();
  210|  57.9k|    mp_msg(log, v, "FFmpeg version: %s", FFMPEG_VERSION);
  211|  57.9k|    if (strcmp(runtime_version, FFMPEG_VERSION))
  ------------------
  |  Branch (211:9): [True: 0, False: 57.9k]
  ------------------
  212|      0|        mp_msg(log, v, " (runtime %s)", runtime_version);
  213|  57.9k|    mp_msg(log, v, "\n");
  214|  57.9k|    mp_msg(log, v, "FFmpeg library versions:\n");
  215|       |
  216|   463k|    for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) {
  ------------------
  |  |   49|   463k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (216:21): [True: 405k, False: 57.9k]
  ------------------
  217|   405k|        const struct lib *l = &libs[n];
  218|   405k|        mp_msg(log, v, "   %-15s %d.%d.%d", l->name, V(l->buildv));
  ------------------
  |  |  185|   405k|#define V(x) AV_VERSION_MAJOR(x), \
  |  |  186|   405k|             AV_VERSION_MINOR(x), \
  |  |  187|   405k|             AV_VERSION_MICRO(x)
  ------------------
  219|   405k|        if (l->buildv != l->runv)
  ------------------
  |  Branch (219:13): [True: 0, False: 405k]
  ------------------
  220|      0|            mp_msg(log, v, " (runtime %d.%d.%d)", V(l->runv));
  ------------------
  |  |  185|      0|#define V(x) AV_VERSION_MAJOR(x), \
  |  |  186|      0|             AV_VERSION_MINOR(x), \
  |  |  187|      0|             AV_VERSION_MICRO(x)
  ------------------
  221|   405k|        mp_msg(log, v, "\n");
  222|   405k|        if (l->buildv > l->runv ||
  ------------------
  |  Branch (222:13): [True: 0, False: 405k]
  ------------------
  223|   405k|            AV_VERSION_MAJOR(l->buildv) != AV_VERSION_MAJOR(l->runv))
  ------------------
  |  Branch (223:13): [True: 0, False: 405k]
  ------------------
  224|      0|        {
  225|      0|            mp_fatal(log, "%s: build version %d.%d.%d incompatible with runtime version %d.%d.%d\n",
  ------------------
  |  |   75|      0|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  ------------------
  226|      0|                     l->name, V(l->buildv), V(l->runv));
  227|      0|            exit(1);
  228|      0|        }
  229|   405k|    }
  230|  57.9k|}
av_log.c:mp_msg_av_log_callback:
  119|  12.7M|{
  120|  12.7M|    AVClass *avc = ptr ? *(AVClass **)ptr : NULL;
  ------------------
  |  Branch (120:20): [True: 9.87M, False: 2.83M]
  ------------------
  121|  12.7M|    int mp_level = av_log_level_to_mp_level(level);
  122|       |
  123|       |    // Note: mp_log is thread-safe, but destruction of the log instances is not.
  124|  12.7M|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  12.7M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  125|       |
  126|  12.7M|    if (!log_mpv_instance) {
  ------------------
  |  Branch (126:9): [True: 0, False: 12.7M]
  ------------------
  127|      0|        mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  128|       |        // Fallback to stderr
  129|      0|        vfprintf(stderr, fmt, vl);
  130|      0|        return;
  131|      0|    }
  132|       |
  133|  12.7M|    struct mp_log *log = get_av_log(ptr);
  134|       |
  135|  12.7M|    if (mp_msg_test(log, mp_level)) {
  ------------------
  |  Branch (135:9): [True: 12.7M, False: 18.4E]
  ------------------
  136|  12.7M|        log_buffer.len = 0;
  137|  12.7M|        bstr_xappend_vasprintf(log_root, &log_buffer, fmt, vl);
  138|  12.7M|        if (!log_buffer.len)
  ------------------
  |  Branch (138:13): [True: 0, False: 12.7M]
  ------------------
  139|      0|            goto done;
  140|  12.7M|        const char *prefix = avc ? avclass_item_name(ptr, avc) : NULL;
  ------------------
  |  Branch (140:30): [True: 9.87M, False: 2.83M]
  ------------------
  141|  12.7M|        if (log_print_prefix && prefix) {
  ------------------
  |  Branch (141:13): [True: 11.4M, False: 1.24M]
  |  Branch (141:33): [True: 9.84M, False: 1.62M]
  ------------------
  142|  9.84M|            mp_msg(log, mp_level, "%s: %.*s", prefix, BSTR_P(log_buffer));
  ------------------
  |  |  307|  9.84M|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 9.84M, False: 0]
  |  |  ------------------
  ------------------
  143|  9.84M|        } else {
  144|  2.86M|            mp_msg(log, mp_level, "%.*s", BSTR_P(log_buffer));
  ------------------
  |  |  307|  2.86M|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 2.86M, False: 0]
  |  |  ------------------
  ------------------
  145|  2.86M|        }
  146|  12.7M|        log_print_prefix = log_buffer.start[log_buffer.len - 1] == '\n';
  147|  12.7M|    }
  148|       |
  149|  12.7M|done:
  150|  12.7M|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  12.7M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  151|  12.7M|}
av_log.c:av_log_level_to_mp_level:
   63|  12.7M|{
   64|  12.7M|    if (av_level > AV_LOG_VERBOSE)
  ------------------
  |  Branch (64:9): [True: 4.50M, False: 8.21M]
  ------------------
   65|  4.50M|        return MSGL_TRACE;
   66|  8.21M|    if (av_level > AV_LOG_INFO)
  ------------------
  |  Branch (66:9): [True: 6.93M, False: 1.27M]
  ------------------
   67|  6.93M|        return MSGL_DEBUG;
   68|  1.27M|    if (av_level > AV_LOG_WARNING)
  ------------------
  |  Branch (68:9): [True: 6.92k, False: 1.27M]
  ------------------
   69|  6.92k|        return MSGL_V;
   70|  1.27M|    if (av_level > AV_LOG_ERROR)
  ------------------
  |  Branch (70:9): [True: 229k, False: 1.04M]
  ------------------
   71|   229k|        return MSGL_WARN;
   72|  1.04M|    if (av_level > AV_LOG_FATAL)
  ------------------
  |  Branch (72:9): [True: 1.04M, False: 506]
  ------------------
   73|  1.04M|        return MSGL_ERR;
   74|    506|    return MSGL_FATAL;
   75|  1.04M|}
av_log.c:get_av_log:
   78|  12.7M|{
   79|  12.7M|    if (!ptr)
  ------------------
  |  Branch (79:9): [True: 2.83M, False: 9.87M]
  ------------------
   80|  2.83M|        return log_root;
   81|       |
   82|  9.87M|    AVClass *avc = *(AVClass **)ptr;
   83|  9.87M|    if (!avc) {
  ------------------
  |  Branch (83:9): [True: 0, False: 9.87M]
  ------------------
   84|      0|        mp_warn(log_root,
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
   85|      0|               "av_log callback called with bad parameters (NULL AVClass).\n"
   86|      0|               "This is a bug in one of FFmpeg libraries used.\n");
   87|      0|        return log_root;
   88|      0|    }
   89|       |
   90|  9.87M|    if (!strcmp(avc->class_name, "AVCodecContext")) {
  ------------------
  |  Branch (90:9): [True: 7.82M, False: 2.04M]
  ------------------
   91|  7.82M|        AVCodecContext *s = ptr;
   92|  7.82M|        if (s->codec) {
  ------------------
  |  Branch (92:13): [True: 7.81M, False: 18.2k]
  ------------------
   93|  7.81M|            if (s->codec->type == AVMEDIA_TYPE_AUDIO) {
  ------------------
  |  Branch (93:17): [True: 7.66M, False: 143k]
  ------------------
   94|  7.66M|                if (av_codec_is_decoder(s->codec))
  ------------------
  |  Branch (94:21): [True: 7.66M, False: 0]
  ------------------
   95|  7.66M|                    return log_decaudio;
   96|  7.66M|            } else if (s->codec->type == AVMEDIA_TYPE_VIDEO) {
  ------------------
  |  Branch (96:24): [True: 143k, False: 0]
  ------------------
   97|   143k|                if (av_codec_is_decoder(s->codec))
  ------------------
  |  Branch (97:21): [True: 143k, False: 0]
  ------------------
   98|   143k|                    return log_decvideo;
   99|   143k|            }
  100|  7.81M|        }
  101|  7.82M|    }
  102|       |
  103|  2.06M|    if (!strcmp(avc->class_name, "AVFormatContext")) {
  ------------------
  |  Branch (103:9): [True: 1.79M, False: 270k]
  ------------------
  104|  1.79M|        AVFormatContext *s = ptr;
  105|  1.79M|        if (s->iformat)
  ------------------
  |  Branch (105:13): [True: 1.79M, False: 0]
  ------------------
  106|  1.79M|            return log_demuxer;
  107|  1.79M|    }
  108|       |
  109|   270k|    return log_root;
  110|  2.06M|}
av_log.c:avclass_item_name:
  113|  9.87M|{
  114|  9.87M|    return (avc->item_name ? avc->item_name : av_default_item_name)(obj);
  ------------------
  |  Branch (114:13): [True: 9.87M, False: 0]
  ------------------
  115|  9.87M|}

mp_add_decoder:
   26|  5.22M|{
   27|  5.22M|    struct mp_decoder_entry entry = {
   28|  5.22M|        .codec = talloc_strdup(list, codec),
  ------------------
  |  |   50|  5.22M|#define talloc_strdup                   ta_xstrdup
  ------------------
   29|  5.22M|        .decoder = talloc_strdup(list, decoder),
  ------------------
  |  |   50|  5.22M|#define talloc_strdup                   ta_xstrdup
  ------------------
   30|  5.22M|        .desc = talloc_strdup(list, desc),
  ------------------
  |  |   50|  5.22M|#define talloc_strdup                   ta_xstrdup
  ------------------
   31|  5.22M|    };
   32|  5.22M|    MP_TARRAY_APPEND(list, list->entries, list->num_entries, entry);
  ------------------
  |  |  105|  5.22M|    do {                                            \
  |  |  106|  5.22M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  5.22M|    do {                                            \
  |  |  |  |   97|  5.22M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  5.22M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  5.22M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  5.22M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 182k, False: 5.04M]
  |  |  |  |  ------------------
  |  |  |  |   99|  5.22M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   182k|    do {                                                        \
  |  |  |  |  |  |   89|   182k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   182k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   182k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   182k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   182k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   182k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   182k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 182k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  5.22M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 5.22M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  5.22M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  5.22M|        (idxvar)++;                                 \
  |  |  109|  5.22M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.22M]
  |  |  ------------------
  ------------------
   33|  5.22M|}
mp_select_decoders:
   60|  21.8k|{
   61|  21.8k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  21.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  21.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  21.8k|    if (!codec)
  ------------------
  |  Branch (62:9): [True: 0, False: 21.8k]
  ------------------
   63|      0|        codec = "unknown";
   64|  21.8k|    bool stop = false;
   65|  21.8k|    bstr sel = bstr0(selection);
   66|  21.8k|    while (sel.len) {
  ------------------
  |  Branch (66:12): [True: 0, False: 21.8k]
  ------------------
   67|      0|        bstr entry;
   68|      0|        bstr_split_tok(sel, ",", &entry, &sel);
   69|      0|        if (bstr_equals0(entry, "-")) {
  ------------------
  |  Branch (69:13): [True: 0, False: 0]
  ------------------
   70|      0|            mp_warn(log, "Excluding codecs is deprecated.\n");
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
   71|      0|            stop = true;
   72|      0|            break;
   73|      0|        }
   74|      0|        for (int n = 0; n < all->num_entries; n++) {
  ------------------
  |  Branch (74:25): [True: 0, False: 0]
  ------------------
   75|      0|            struct mp_decoder_entry *cur = &all->entries[n];
   76|      0|            if (bstr_equals0(entry, cur->decoder))
  ------------------
  |  Branch (76:17): [True: 0, False: 0]
  ------------------
   77|      0|                add_new(list, cur, codec);
   78|      0|        }
   79|      0|    }
   80|  21.8k|    if (!stop) {
  ------------------
  |  Branch (80:9): [True: 21.8k, False: 0]
  ------------------
   81|       |        // Add the remaining codecs which haven't been added yet
   82|  5.22M|        for (int n = 0; n < all->num_entries; n++)
  ------------------
  |  Branch (82:25): [True: 5.20M, False: 21.8k]
  ------------------
   83|  5.20M|            add_new(list, &all->entries[n], codec);
   84|  21.8k|    }
   85|  21.8k|    return list;
   86|  21.8k|}
mp_print_decoders:
   96|  21.8k|{
   97|  21.8k|    mp_msg(log, msgl, "%s\n", header);
   98|  48.6k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (98:21): [True: 26.7k, False: 21.8k]
  ------------------
   99|  26.7k|        struct mp_decoder_entry *entry = &list->entries[n];
  100|  26.7k|        mp_msg(log, msgl, "    %s", entry->decoder);
  101|  26.7k|        if (strcmp(entry->decoder, entry->codec) != 0)
  ------------------
  |  Branch (101:13): [True: 8.23k, False: 18.5k]
  ------------------
  102|  8.23k|            mp_msg(log, msgl, " (%s)", entry->codec);
  103|  26.7k|        mp_msg(log, msgl, " - %s\n", entry->desc);
  104|  26.7k|    }
  105|  21.8k|    if (list->num_entries == 0)
  ------------------
  |  Branch (105:9): [True: 1.95k, False: 19.9k]
  ------------------
  106|  1.95k|        mp_msg(log, msgl, "    (no decoders)\n");
  107|  21.8k|}
codecs.c:add_new:
   39|  5.20M|{
   40|  5.20M|    if (!entry || (codec && strcmp(entry->codec, codec) != 0))
  ------------------
  |  Branch (40:9): [True: 0, False: 5.20M]
  |  Branch (40:20): [True: 5.20M, False: 0]
  |  Branch (40:29): [True: 5.17M, False: 26.7k]
  ------------------
   41|  5.17M|        return;
   42|  26.7k|    mp_add_decoder(to, entry->codec, entry->decoder, entry->desc);
   43|  26.7k|}

mp_format_double:
   99|  1.73k|{
  100|  1.73k|    bstr str = {0};
  101|  1.73k|    const char *fmt = plus_sign ? "%+.*f" : "%.*f";
  ------------------
  |  Branch (101:23): [True: 0, False: 1.73k]
  ------------------
  102|  1.73k|    bstr_xappend_asprintf(talloc_ctx, &str, fmt, precision, val);
  103|  1.73k|    size_t pos = str.len;
  104|  1.73k|    if (trim) {
  ------------------
  |  Branch (104:9): [True: 1.73k, False: 0]
  ------------------
  105|  8.49k|        while (--pos && str.start[pos] == '0')
  ------------------
  |  Branch (105:16): [True: 8.49k, False: 0]
  |  Branch (105:25): [True: 6.76k, False: 1.73k]
  ------------------
  106|  6.76k|            str.len--;
  107|  1.73k|        if (str.start[pos] == '.')
  ------------------
  |  Branch (107:13): [True: 1.68k, False: 54]
  ------------------
  108|  1.68k|            str.len--;
  109|  1.73k|    }
  110|  1.73k|    if (percent_sign)
  ------------------
  |  Branch (110:9): [True: 0, False: 1.73k]
  ------------------
  111|      0|        bstr_xappend(talloc_ctx, &str, bstr0("%"));
  112|  1.73k|    str.start[str.len] = '\0';
  113|  1.73k|    return str.start;
  114|  1.73k|}
mp_rect_equals:
  144|   337k|{
  145|   337k|    return rc1->x0 == rc2->x0 && rc1->y0 == rc2->y0 &&
  ------------------
  |  Branch (145:12): [True: 337k, False: 0]
  |  Branch (145:34): [True: 337k, False: 0]
  ------------------
  146|   337k|           rc1->x1 == rc2->x1 && rc1->y1 == rc2->y1;
  ------------------
  |  Branch (146:12): [True: 337k, False: 0]
  |  Branch (146:34): [True: 337k, False: 0]
  ------------------
  147|   337k|}
mp_snprintf_cat:
  214|   398k|{
  215|   398k|    size_t len = strnlen(str, size);
  216|   398k|    mp_assert(!size || len < size); // str with no 0-termination is not allowed
  ------------------
  |  |   41|   398k|#define mp_assert assert
  ------------------
  |  Branch (216:5): [True: 0, False: 398k]
  |  Branch (216:5): [True: 398k, False: 0]
  ------------------
  217|   398k|    int r;
  218|   398k|    va_list ap;
  219|   398k|    va_start(ap, format);
  220|   398k|    r = vsnprintf(str + len, size - len, format, ap);
  221|       |    va_end(ap);
  222|   398k|    return r;
  223|   398k|}
mp_append_utf8_bstr:
  229|  2.23M|{
  230|  2.23M|    char data[8];
  231|  2.23M|    uint8_t tmp;
  232|  2.23M|    char *output = data;
  233|       |    PUT_UTF8(codepoint, tmp, *output++ = tmp;);
  ------------------
  |  Branch (233:5): [True: 2.23M, False: 2.23M]
  |  Branch (233:5): [True: 0, False: 2.23M]
  ------------------
  234|  2.23M|    bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
  235|  2.23M|}
mp_strerror_buf:
  353|    409|{
  354|       |    // This handles the nasty details of calling the right function for us.
  355|       |    av_strerror(AVERROR(errnum), buf, buf_size);
  356|    409|    return buf;
  357|    409|}
mp_tprintf_buf:
  376|  16.0k|{
  377|  16.0k|    va_list ap;
  378|  16.0k|    va_start(ap, format);
  379|  16.0k|    vsnprintf(buf, buf_size, format, ap);
  380|       |    va_end(ap);
  381|  16.0k|    return buf;
  382|  16.0k|}
mp_dup_str_array:
  385|  87.2k|{
  386|  87.2k|    char **r = NULL;
  387|  87.2k|    int num_r = 0;
  388|  87.2k|    for (int n = 0; s && s[n]; n++)
  ------------------
  |  Branch (388:21): [True: 0, False: 87.2k]
  |  Branch (388:26): [True: 0, False: 0]
  ------------------
  389|      0|        MP_TARRAY_APPEND(tctx, r, num_r, talloc_strdup(tctx, s[n]));
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  390|  87.2k|    if (r)
  ------------------
  |  Branch (390:9): [True: 0, False: 87.2k]
  ------------------
  391|      0|        MP_TARRAY_APPEND(tctx, r, num_r, NULL);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  392|  87.2k|    return r;
  393|  87.2k|}
mp_log2:
  401|   228M|{
  402|   228M|#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
  403|   228M|    return v ? 31 - __builtin_clz(v) : 0;
  ------------------
  |  Branch (403:12): [True: 174M, False: 54.2M]
  ------------------
  404|       |#else
  405|       |    for (int x = 31; x >= 0; x--) {
  406|       |        if (v & (((uint32_t)1) << x))
  407|       |            return x;
  408|       |    }
  409|       |    return 0;
  410|       |#endif
  411|   228M|}
mp_round_next_power_of_2:
  419|   695k|{
  420|   695k|    if (!v)
  ------------------
  |  Branch (420:9): [True: 0, False: 695k]
  ------------------
  421|      0|        return 1;
  422|   695k|    if (!(v & (v - 1)))
  ------------------
  |  Branch (422:9): [True: 694k, False: 241]
  ------------------
  423|   694k|        return v;
  424|    241|    int l = mp_log2(v) + 1;
  425|    241|    return l == 32 ? 0 : (uint32_t)1 << l;
  ------------------
  |  Branch (425:12): [True: 0, False: 241]
  ------------------
  426|   695k|}
mp_lcm:
  429|  78.5k|{
  430|  78.5k|    mp_assert(x && y);
  ------------------
  |  |   41|  78.5k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 78.5k, False: 0]
  |  Branch (430:5): [True: 78.5k, False: 0]
  ------------------
  431|  78.5k|    return x * (y / av_gcd(x, y));
  432|  78.5k|}

encode_lavc_free:
  189|  28.9k|{
  190|  28.9k|    bool res = true;
  191|  28.9k|    if (!ctx)
  ------------------
  |  Branch (191:9): [True: 28.9k, False: 0]
  ------------------
  192|  28.9k|        return res;
  193|       |
  194|      0|    struct encode_priv *p = ctx->priv;
  195|       |
  196|      0|    if (!p->failed && !p->header_written) {
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  |  Branch (196:23): [True: 0, False: 0]
  ------------------
  197|      0|        MP_FATAL(p, "no data written to target file\n");
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  198|      0|        p->failed = true;
  199|      0|    }
  200|       |
  201|      0|    if (!p->failed && p->header_written) {
  ------------------
  |  Branch (201:9): [True: 0, False: 0]
  |  Branch (201:23): [True: 0, False: 0]
  ------------------
  202|      0|        if (av_write_trailer(p->muxer) < 0)
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  ------------------
  203|      0|            MP_ERR(p, "error writing trailer\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  204|       |
  205|      0|        MP_INFO(p, "video: encoded %lld bytes\n", p->vbytes);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  206|      0|        MP_INFO(p, "audio: encoded %lld bytes\n", p->abytes);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  207|       |
  208|      0|        MP_INFO(p, "muxing overhead %lld bytes\n",
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  209|      0|                (long long)(avio_size(p->muxer->pb) - p->vbytes - p->abytes));
  210|      0|    }
  211|       |
  212|      0|    if (avio_closep(&p->muxer->pb) < 0 && !p->failed) {
  ------------------
  |  Branch (212:9): [True: 0, False: 0]
  |  Branch (212:43): [True: 0, False: 0]
  ------------------
  213|      0|        MP_ERR(p, "Closing file failed\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  214|      0|        p->failed = true;
  215|      0|    }
  216|       |
  217|      0|    avformat_free_context(p->muxer);
  218|       |
  219|      0|    res = !p->failed;
  220|       |
  221|      0|    mp_mutex_destroy(&ctx->lock);
  ------------------
  |  |  133|      0|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  222|      0|    talloc_free(ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  223|       |
  224|      0|    return res;
  225|  28.9k|}
encode_lavc_discontinuity:
  436|   133k|{
  437|   133k|    if (!ctx)
  ------------------
  |  Branch (437:9): [True: 133k, False: 0]
  ------------------
  438|   133k|        return;
  439|       |
  440|      0|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  441|      0|    ctx->discontinuity_pts_offset = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  442|      0|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  443|      0|}
encode_lavc_showhelp:
  520|  28.9k|{
  521|  28.9k|    bool help_output = false;
  522|  28.9k|#define CHECKS(str) ((str) && \
  523|  28.9k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  524|  28.9k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  525|  28.9k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  526|  28.9k|    if (CHECKS(opts->format)) {
  ------------------
  |  |  522|  28.9k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 28.9k]
  |  |  |  Branch (522:22): [True: 0, False: 28.9k]
  |  |  ------------------
  |  |  523|  28.9k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (523:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  527|      0|        const AVOutputFormat *c = NULL;
  528|      0|        void *iter = NULL;
  529|      0|        mp_info(log, "Available output formats:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  530|      0|        while ((c = av_muxer_iterate(&iter))) {
  ------------------
  |  Branch (530:16): [True: 0, False: 0]
  ------------------
  531|      0|            mp_info(log, "  --of=%-13s %s\n", c->name,
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  532|      0|                   c->long_name ? c->long_name : "");
  533|      0|        }
  534|      0|    }
  535|  28.9k|    if (CHECKV(opts->fopts)) {
  ------------------
  |  |  524|  28.9k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 28.9k]
  |  |  |  Branch (524:23): [True: 0, False: 28.9k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  28.9k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (525:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  536|      0|        AVFormatContext *c = avformat_alloc_context();
  537|      0|        const AVOutputFormat *format = NULL;
  538|      0|        mp_info(log, "Available output format ctx->options:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  539|      0|        encode_lavc_printoptions(log, c, "  --ofopts=", "           ", NULL,
  540|      0|                                 AV_OPT_FLAG_ENCODING_PARAM,
  541|      0|                                 AV_OPT_FLAG_ENCODING_PARAM);
  542|      0|        avformat_free_context(c);
  543|      0|        void *iter = NULL;
  544|      0|        while ((format = av_muxer_iterate(&iter))) {
  ------------------
  |  Branch (544:16): [True: 0, False: 0]
  ------------------
  545|      0|            if (format->priv_class) {
  ------------------
  |  Branch (545:17): [True: 0, False: 0]
  ------------------
  546|      0|                mp_info(log, "Additionally, for --of=%s:\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  547|      0|                       format->name);
  548|      0|                encode_lavc_printoptions(log, &format->priv_class, "  --ofopts=",
  549|      0|                                         "           ", NULL,
  550|      0|                                         AV_OPT_FLAG_ENCODING_PARAM,
  551|      0|                                         AV_OPT_FLAG_ENCODING_PARAM);
  552|      0|            }
  553|      0|        }
  554|      0|    }
  555|  28.9k|    if (CHECKV(opts->vopts)) {
  ------------------
  |  |  524|  28.9k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 28.9k]
  |  |  |  Branch (524:23): [True: 0, False: 28.9k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  28.9k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (525:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  556|      0|        AVCodecContext *c = avcodec_alloc_context3(NULL);
  557|      0|        const AVCodec *codec = NULL;
  558|      0|        mp_info(log, "Available output video codec ctx->options:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  559|      0|        encode_lavc_printoptions(log,
  560|      0|            c, "  --ovcopts=", "            ", NULL,
  561|      0|            AV_OPT_FLAG_ENCODING_PARAM |
  562|      0|            AV_OPT_FLAG_VIDEO_PARAM,
  563|      0|            AV_OPT_FLAG_ENCODING_PARAM |
  564|      0|            AV_OPT_FLAG_VIDEO_PARAM);
  565|      0|        av_free(c);
  566|      0|        void *iter = NULL;
  567|      0|        while ((codec = av_codec_iterate(&iter))) {
  ------------------
  |  Branch (567:16): [True: 0, False: 0]
  ------------------
  568|      0|            if (!av_codec_is_encoder(codec))
  ------------------
  |  Branch (568:17): [True: 0, False: 0]
  ------------------
  569|      0|                continue;
  570|      0|            if (codec->type != AVMEDIA_TYPE_VIDEO)
  ------------------
  |  Branch (570:17): [True: 0, False: 0]
  ------------------
  571|      0|                continue;
  572|      0|            if (opts->vcodec && opts->vcodec[0] &&
  ------------------
  |  Branch (572:17): [True: 0, False: 0]
  |  Branch (572:33): [True: 0, False: 0]
  ------------------
  573|      0|                strcmp(opts->vcodec, codec->name) != 0)
  ------------------
  |  Branch (573:17): [True: 0, False: 0]
  ------------------
  574|      0|                continue;
  575|      0|            if (codec->priv_class) {
  ------------------
  |  Branch (575:17): [True: 0, False: 0]
  ------------------
  576|      0|                mp_info(log, "Additionally, for --ovc=%s:\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  577|      0|                       codec->name);
  578|      0|                encode_lavc_printoptions(log,
  579|      0|                    &codec->priv_class, "  --ovcopts=",
  580|      0|                    "            ", NULL,
  581|      0|                    AV_OPT_FLAG_ENCODING_PARAM |
  582|      0|                    AV_OPT_FLAG_VIDEO_PARAM,
  583|      0|                    AV_OPT_FLAG_ENCODING_PARAM |
  584|      0|                    AV_OPT_FLAG_VIDEO_PARAM);
  585|      0|            }
  586|      0|        }
  587|      0|    }
  588|  28.9k|    if (CHECKV(opts->aopts)) {
  ------------------
  |  |  524|  28.9k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 28.9k]
  |  |  |  Branch (524:23): [True: 0, False: 28.9k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  28.9k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (525:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  589|      0|        AVCodecContext *c = avcodec_alloc_context3(NULL);
  590|      0|        const AVCodec *codec = NULL;
  591|      0|        mp_info(log, "Available output audio codec ctx->options:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  592|      0|        encode_lavc_printoptions(log,
  593|      0|            c, "  --oacopts=", "            ", NULL,
  594|      0|            AV_OPT_FLAG_ENCODING_PARAM |
  595|      0|            AV_OPT_FLAG_AUDIO_PARAM,
  596|      0|            AV_OPT_FLAG_ENCODING_PARAM |
  597|      0|            AV_OPT_FLAG_AUDIO_PARAM);
  598|      0|        av_free(c);
  599|      0|        void *iter = NULL;
  600|      0|        while ((codec = av_codec_iterate(&iter))) {
  ------------------
  |  Branch (600:16): [True: 0, False: 0]
  ------------------
  601|      0|            if (!av_codec_is_encoder(codec))
  ------------------
  |  Branch (601:17): [True: 0, False: 0]
  ------------------
  602|      0|                continue;
  603|      0|            if (codec->type != AVMEDIA_TYPE_AUDIO)
  ------------------
  |  Branch (603:17): [True: 0, False: 0]
  ------------------
  604|      0|                continue;
  605|      0|            if (opts->acodec && opts->acodec[0] &&
  ------------------
  |  Branch (605:17): [True: 0, False: 0]
  |  Branch (605:33): [True: 0, False: 0]
  ------------------
  606|      0|                strcmp(opts->acodec, codec->name) != 0)
  ------------------
  |  Branch (606:17): [True: 0, False: 0]
  ------------------
  607|      0|                continue;
  608|      0|            if (codec->priv_class) {
  ------------------
  |  Branch (608:17): [True: 0, False: 0]
  ------------------
  609|      0|                mp_info(log, "Additionally, for --oac=%s:\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  610|      0|                       codec->name);
  611|      0|                encode_lavc_printoptions(log,
  612|      0|                    &codec->priv_class, "  --oacopts=",
  613|      0|                    "           ", NULL,
  614|      0|                    AV_OPT_FLAG_ENCODING_PARAM |
  615|      0|                    AV_OPT_FLAG_AUDIO_PARAM,
  616|      0|                    AV_OPT_FLAG_ENCODING_PARAM |
  617|      0|                    AV_OPT_FLAG_AUDIO_PARAM);
  618|      0|            }
  619|      0|        }
  620|      0|    }
  621|  28.9k|    if (CHECKS(opts->vcodec)) {
  ------------------
  |  |  522|  28.9k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 28.9k]
  |  |  |  Branch (522:22): [True: 0, False: 28.9k]
  |  |  ------------------
  |  |  523|  28.9k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (523:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  622|      0|        const AVCodec *c = NULL;
  623|      0|        void *iter = NULL;
  624|      0|        mp_info(log, "Available output video codecs:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  625|      0|        while ((c = av_codec_iterate(&iter))) {
  ------------------
  |  Branch (625:16): [True: 0, False: 0]
  ------------------
  626|      0|            if (!av_codec_is_encoder(c))
  ------------------
  |  Branch (626:17): [True: 0, False: 0]
  ------------------
  627|      0|                continue;
  628|      0|            if (c->type != AVMEDIA_TYPE_VIDEO)
  ------------------
  |  Branch (628:17): [True: 0, False: 0]
  ------------------
  629|      0|                continue;
  630|      0|            mp_info(log, "  --ovc=%-12s %s\n", c->name,
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  631|      0|                   c->long_name ? c->long_name : "");
  632|      0|        }
  633|      0|    }
  634|  28.9k|    if (CHECKS(opts->acodec)) {
  ------------------
  |  |  522|  28.9k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 28.9k]
  |  |  |  Branch (522:22): [True: 0, False: 28.9k]
  |  |  ------------------
  |  |  523|  28.9k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  |  |  ------------------
  |  |  |  Branch (523:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  635|      0|        const AVCodec *c = NULL;
  636|      0|        void *iter = NULL;
  637|      0|        mp_info(log, "Available output audio codecs:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  638|      0|        while ((c = av_codec_iterate(&iter))) {
  ------------------
  |  Branch (638:16): [True: 0, False: 0]
  ------------------
  639|      0|            if (!av_codec_is_encoder(c))
  ------------------
  |  Branch (639:17): [True: 0, False: 0]
  ------------------
  640|      0|                continue;
  641|      0|            if (c->type != AVMEDIA_TYPE_AUDIO)
  ------------------
  |  Branch (641:17): [True: 0, False: 0]
  ------------------
  642|      0|                continue;
  643|      0|            mp_info(log, "  --oac=%-12s %s\n", c->name,
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  644|      0|                   c->long_name ? c->long_name : "");
  645|      0|        }
  646|      0|    }
  647|  28.9k|    return help_output;
  648|  28.9k|}
encode_lavc_didfail:
  692|   265k|{
  693|   265k|    if (!ctx)
  ------------------
  |  Branch (693:9): [True: 265k, False: 0]
  ------------------
  694|   265k|        return false;
  695|      0|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  696|      0|    bool fail = ctx->priv->failed;
  697|      0|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  698|      0|    return fail;
  699|   265k|}

mp_msg_level:
  184|  48.7M|{
  185|  48.7M|    struct mp_log_root *root = log->root;
  186|  48.7M|    if (!root)
  ------------------
  |  Branch (186:9): [True: 938k, False: 47.7M]
  ------------------
  187|   938k|        return -1;
  188|  47.7M|    if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) !=
  ------------------
  |  Branch (188:9): [True: 594k, False: 47.1M]
  ------------------
  189|  47.7M|        atomic_load_explicit(&root->reload_counter, memory_order_relaxed))
  190|   594k|    {
  191|   594k|        update_loglevel(log);
  192|   594k|    }
  193|       |    return atomic_load_explicit(&log->level, memory_order_relaxed);
  194|  48.7M|}
mp_msg_flush_status_line:
  295|   162k|{
  296|   162k|    if (!log->root)
  ------------------
  |  Branch (296:9): [True: 0, False: 162k]
  ------------------
  297|      0|        return;
  298|       |
  299|   162k|    mp_mutex_lock(&log->root->lock);
  ------------------
  |  |  134|   162k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|   162k|    msg_flush_status_line(log->root, clear);
  301|   162k|    mp_mutex_unlock(&log->root->lock);
  ------------------
  |  |  136|   162k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  302|   162k|}
mp_msg_sanitize:
  576|  29.6M|{
  577|  2.35G|    for (size_t i = 0; i < text->len; i++) {
  ------------------
  |  Branch (577:24): [True: 2.32G, False: 29.6M]
  ------------------
  578|  2.32G|        unsigned char ch = text->start[i];
  579|       |
  580|       |        // Allow SGR escape sequences only, filter anything else.
  581|  2.32G|        if (allow_sgr && ch == 0x1B && i + 2 < text->len && text->start[i + 1] == '[') {
  ------------------
  |  Branch (581:13): [True: 2.32G, False: 0]
  |  Branch (581:26): [True: 357k, False: 2.32G]
  |  Branch (581:40): [True: 357k, False: 88]
  |  Branch (581:61): [True: 960, False: 356k]
  ------------------
  582|    960|            size_t j = i + 2;
  583|    960|            bool sgr = false;
  584|       |
  585|  3.54k|            while (j < text->len) {
  ------------------
  |  Branch (585:20): [True: 3.54k, False: 0]
  ------------------
  586|  3.54k|                unsigned char c = text->start[j];
  587|  3.54k|                if (c == 'm') {
  ------------------
  |  Branch (587:21): [True: 244, False: 3.30k]
  ------------------
  588|    244|                    sgr = true;
  589|    244|                    i = j;
  590|    244|                    break;
  591|  3.30k|                } else if ((c >= '0' && c <= '9') || c == ';' || c == ':') {
  ------------------
  |  Branch (591:29): [True: 3.20k, False: 100]
  |  Branch (591:41): [True: 1.61k, False: 1.58k]
  |  Branch (591:54): [True: 639, False: 1.04k]
  |  Branch (591:66): [True: 333, False: 716]
  ------------------
  592|  2.58k|                    j++;
  593|  2.58k|                } else {
  594|    716|                    break;
  595|    716|                }
  596|  3.54k|            }
  597|       |
  598|       |            // Nuke everything that is not an SGR sequence
  599|    960|            if (!sgr)
  ------------------
  |  Branch (599:17): [True: 716, False: 244]
  ------------------
  600|    716|                text->start[i] = '?';
  601|    960|            continue;
  602|    960|        }
  603|       |
  604|  2.32G|        int len = bstr_parse_utf8_code_length(ch);
  605|       |
  606|       |        // ASCII: allow only printable plus HT, LF, CR.
  607|  2.32G|        if (len == 1) {
  ------------------
  |  Branch (607:13): [True: 2.10G, False: 218M]
  ------------------
  608|  2.10G|            if (ch == 0x7F || (ch < 0x20 && ch != '\t' && ch != '\n' && ch != '\r'))
  ------------------
  |  Branch (608:17): [True: 660k, False: 2.10G]
  |  Branch (608:32): [True: 140M, False: 1.96G]
  |  Branch (608:45): [True: 135M, False: 4.54M]
  |  Branch (608:59): [True: 90.9M, False: 44.7M]
  |  Branch (608:73): [True: 85.8M, False: 5.10M]
  ------------------
  609|  86.5M|                text->start[i] = '?';
  610|  2.10G|            continue;
  611|  2.10G|        }
  612|       |
  613|       |        // Block UTF-8 C1 controls (C2 80..C2 9F), except PU1/PU2 used internally.
  614|   218M|        if (ch == 0xC2 && i + 1 < text->len && (text->start[i + 1] & 0xC0) == 0x80) {
  ------------------
  |  Branch (614:13): [True: 1.79M, False: 216M]
  |  Branch (614:27): [True: 1.79M, False: 0]
  |  Branch (614:48): [True: 1.35M, False: 435k]
  ------------------
  615|  1.35M|            unsigned char c1 = text->start[i + 1];
  616|  1.35M|            if (c1 >= 0x80 && c1 <= 0x9F && c1 != 0x91 && c1 != 0x92) {
  ------------------
  |  Branch (616:17): [True: 1.35M, False: 0]
  |  Branch (616:31): [True: 86.7k, False: 1.26M]
  |  Branch (616:45): [True: 85.5k, False: 1.11k]
  |  Branch (616:59): [True: 72.9k, False: 12.6k]
  ------------------
  617|  72.9k|                text->start[i] = '?';
  618|  72.9k|                text->start[i + 1] = '?';
  619|  72.9k|            }
  620|  1.35M|            i++;
  621|  1.35M|            continue;
  622|  1.35M|        }
  623|       |
  624|       |        // Skip valid multi-byte sequences so continuation bytes aren't seen as
  625|       |        // raw C1. Reject overlong 0xC0/0xC1 and verify the bytes before skipping.
  626|   216M|        if (len >= 2 && ch >= 0xC2 && i + len <= text->len) {
  ------------------
  |  Branch (626:13): [True: 80.4M, False: 136M]
  |  Branch (626:25): [True: 79.4M, False: 999k]
  |  Branch (626:39): [True: 79.4M, False: 2.06k]
  ------------------
  627|  79.4M|            bool valid = true;
  628|   189M|            for (int n = 1; n < len; n++)
  ------------------
  |  Branch (628:29): [True: 110M, False: 79.4M]
  ------------------
  629|   110M|                valid &= (text->start[i + n] & 0xC0) == 0x80;
  630|  79.4M|            if (valid) {
  ------------------
  |  Branch (630:17): [True: 9.82M, False: 69.5M]
  ------------------
  631|  9.82M|                i += len - 1;
  632|  9.82M|                continue;
  633|  9.82M|            }
  634|  79.4M|        }
  635|       |
  636|       |        // Block raw 8-bit C1 (0x80-0x9F); leave other invalid bytes alone.
  637|   207M|        if (ch <= 0x9F)
  ------------------
  |  Branch (637:13): [True: 21.7M, False: 185M]
  ------------------
  638|  21.7M|            text->start[i] = '?';
  639|   207M|    }
  640|  29.6M|}
mp_msg_va:
  654|  35.6M|{
  655|  35.6M|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (655:9): [True: 6.04M, False: 29.5M]
  ------------------
  656|  6.04M|        return; // do not display
  657|       |
  658|  29.5M|    struct mp_log_root *root = log->root;
  659|       |
  660|  29.5M|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  29.5M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  661|       |
  662|  29.5M|    root->buffer.len = 0;
  663|       |
  664|       |    // The partial line is sanitized already, except for a UTF-8 sequence at
  665|       |    // its end that the new text may complete.
  666|  29.5M|    size_t sanitized = utf8_tail_start(log->partial[lev]);
  667|  29.5M|    if (log->partial[lev].len)
  ------------------
  |  Branch (667:9): [True: 2.01M, False: 27.5M]
  ------------------
  668|  2.01M|        bstr_xappend(root, &root->buffer, log->partial[lev]);
  669|  29.5M|    log->partial[lev].len = 0;
  670|       |
  671|  29.5M|    if (bstr_xappend_vasprintf(root, &root->buffer, format, va) < 0) {
  ------------------
  |  Branch (671:9): [True: 0, False: 29.5M]
  ------------------
  672|      0|        bstr_xappend(root, &root->buffer, bstr0("format error: "));
  673|      0|        bstr_xappend(root, &root->buffer, bstr0(format));
  674|      0|    }
  675|       |
  676|  29.5M|    bstr text = {root->buffer.start + sanitized, root->buffer.len - sanitized};
  677|  29.5M|    mp_msg_sanitize(&text, true);
  678|       |
  679|       |    // Remember last status message and restore it to ensure that it is
  680|       |    // always displayed
  681|  29.5M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (681:9): [True: 0, False: 29.5M]
  ------------------
  682|      0|        root->status_log = log;
  683|      0|        root->status_line.len = 0;
  684|       |        // Use bstr_xappend instead bstrdup to reuse allocated memory
  685|      0|        if (root->buffer.len)
  ------------------
  |  Branch (685:13): [True: 0, False: 0]
  ------------------
  686|      0|            bstr_xappend(root, &root->status_line, root->buffer);
  687|      0|    }
  688|       |
  689|  29.5M|    if (lev == MSGL_STATS) {
  ------------------
  |  Branch (689:9): [True: 0, False: 29.5M]
  ------------------
  690|      0|        dump_stats(log, lev, root->buffer);
  691|  29.5M|    } else if (lev == MSGL_STATUS && !test_terminal_level(log, lev)) {
  ------------------
  |  Branch (691:16): [True: 0, False: 29.5M]
  |  Branch (691:38): [True: 0, False: 0]
  ------------------
  692|       |        /* discard */
  693|  29.5M|    } else {
  694|  29.5M|        write_term_msg(log, lev, root->buffer, &root->term_msg);
  695|       |
  696|  29.5M|        FILE *stream = term_msg_fp(root, lev);
  697|  29.5M|        if (root->term_msg.len) {
  ------------------
  |  Branch (697:13): [True: 0, False: 29.5M]
  ------------------
  698|      0|            root->term_status_msg.len = 0;
  699|      0|            if (lev != MSGL_STATUS && root->status_line.len && root->status_log &&
  ------------------
  |  Branch (699:17): [True: 0, False: 0]
  |  Branch (699:39): [True: 0, False: 0]
  |  Branch (699:64): [True: 0, False: 0]
  ------------------
  700|      0|                is_status_output(root, lev) && test_terminal_level(root->status_log, MSGL_STATUS))
  ------------------
  |  Branch (700:17): [True: 0, False: 0]
  |  Branch (700:48): [True: 0, False: 0]
  ------------------
  701|      0|            {
  702|      0|                write_term_msg(root->status_log, MSGL_STATUS, root->status_line,
  703|      0|                               &root->term_status_msg);
  704|      0|            }
  705|      0|            terminal_lock_output();
  706|      0|            fwrite(root->term_msg.start, root->term_msg.len, 1, stream);
  707|      0|            if (root->term_status_msg.len)
  ------------------
  |  Branch (707:17): [True: 0, False: 0]
  ------------------
  708|      0|                fwrite(root->term_status_msg.start, root->term_status_msg.len, 1, stream);
  709|      0|            fflush(stream);
  710|      0|            terminal_unlock_output();
  711|      0|        }
  712|  29.5M|    }
  713|       |
  714|  29.5M|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  29.5M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  715|  29.5M|}
mp_log_new:
  737|  1.54M|{
  738|  1.54M|    mp_assert(parent);
  ------------------
  |  |   41|  1.54M|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 1.54M, False: 0]
  ------------------
  739|  1.54M|    struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
  ------------------
  |  |   27|  1.54M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.54M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.54M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  1.54M|    if (!parent->root)
  ------------------
  |  Branch (740:9): [True: 0, False: 1.54M]
  ------------------
  741|      0|        return log; // same as null_log
  742|  1.54M|    talloc_set_destructor(log, destroy_log);
  ------------------
  |  |   41|  1.54M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  743|  1.54M|    log->root = parent->root;
  744|  1.54M|    log->max_level = MSGL_MAX;
  745|  1.54M|    if (name) {
  ------------------
  |  Branch (745:9): [True: 1.52M, False: 20.0k]
  ------------------
  746|  1.52M|        if (name[0] == '!') {
  ------------------
  |  Branch (746:13): [True: 276k, False: 1.24M]
  ------------------
  747|   276k|            name = &name[1];
  748|  1.24M|        } else if (name[0] == '/') {
  ------------------
  |  Branch (748:20): [True: 0, False: 1.24M]
  ------------------
  749|      0|            name = &name[1];
  750|      0|            log->prefix = talloc_strdup(log, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  751|  1.24M|        } else {
  752|  1.24M|            log->prefix = parent->prefix
  ------------------
  |  Branch (752:27): [True: 133k, False: 1.11M]
  ------------------
  753|  1.24M|                    ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   133k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   133k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  754|  1.24M|                    : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.11M|#define talloc_strdup                   ta_xstrdup
  ------------------
  755|  1.24M|        }
  756|  1.52M|        log->verbose_prefix = parent->prefix
  ------------------
  |  Branch (756:31): [True: 133k, False: 1.38M]
  ------------------
  757|  1.52M|                ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   133k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   133k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  758|  1.52M|                : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.38M|#define talloc_strdup                   ta_xstrdup
  ------------------
  759|  1.52M|        if (log->prefix && !log->prefix[0])
  ------------------
  |  Branch (759:13): [True: 1.24M, False: 276k]
  |  Branch (759:28): [True: 28.9k, False: 1.21M]
  ------------------
  760|  28.9k|            log->prefix = NULL;
  761|  1.52M|        if (!log->verbose_prefix[0])
  ------------------
  |  Branch (761:13): [True: 28.9k, False: 1.49M]
  ------------------
  762|  28.9k|            log->verbose_prefix = "global";
  763|  1.52M|    } else {
  764|  20.0k|        log->prefix = talloc_strdup(log, parent->prefix);
  ------------------
  |  |   50|  20.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|  20.0k|        log->verbose_prefix = talloc_strdup(log, parent->verbose_prefix);
  ------------------
  |  |   50|  20.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  766|  20.0k|    }
  767|  1.54M|    return log;
  768|  1.54M|}
mp_msg_init:
  771|  28.9k|{
  772|  28.9k|    mp_assert(!global->log);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (772:5): [True: 28.9k, False: 0]
  ------------------
  773|       |
  774|  28.9k|    struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  775|  28.9k|    *root = (struct mp_log_root){
  776|  28.9k|        .global = global,
  777|  28.9k|        .reload_counter = 1,
  778|  28.9k|    };
  779|       |
  780|  28.9k|    mp_mutex_init(&root->lock);
  781|  28.9k|    mp_mutex_init(&root->log_file_lock);
  782|  28.9k|    mp_cond_init(&root->log_file_wakeup);
  783|       |
  784|  28.9k|    struct mp_log dummy = { .root = root };
  785|  28.9k|    struct mp_log *log = mp_log_new(root, &dummy, "");
  786|       |
  787|  28.9k|    global->log = log;
  788|  28.9k|}
mp_msg_update_msglevels:
  881|  57.9k|{
  882|  57.9k|    struct mp_log_root *root = global->log->root;
  883|       |
  884|  57.9k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  885|       |
  886|  57.9k|    root->verbose = opts->verbose;
  887|  57.9k|    root->really_quiet = opts->msg_really_quiet;
  888|  57.9k|    root->module = opts->msg_module;
  889|  57.9k|    root->use_terminal = opts->use_terminal;
  890|  57.9k|    root->show_time = opts->msg_time;
  891|       |
  892|  57.9k|    if (root->really_quiet)
  ------------------
  |  Branch (892:9): [True: 0, False: 57.9k]
  ------------------
  893|      0|        root->status_lines = 0;
  894|       |
  895|  57.9k|    for (int i = STDOUT_FILENO; i <= STDERR_FILENO && root->use_terminal; ++i) {
  ------------------
  |  Branch (895:33): [True: 57.9k, False: 0]
  |  Branch (895:55): [True: 0, False: 57.9k]
  ------------------
  896|      0|        root->isatty[i] = isatty(i);
  897|      0|        root->color[i] = opts->msg_color && root->isatty[i];
  ------------------
  |  Branch (897:26): [True: 0, False: 0]
  |  Branch (897:45): [True: 0, False: 0]
  ------------------
  898|      0|    }
  899|       |
  900|  57.9k|    m_option_type_msglevels.free(&root->msg_levels);
  901|  57.9k|    m_option_type_msglevels.copy(NULL, &root->msg_levels, &opts->msg_levels);
  902|       |
  903|  57.9k|    atomic_fetch_add(&root->reload_counter, 1);
  904|  57.9k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  905|       |
  906|  57.9k|    if (check_new_path(global, opts->log_file, &root->log_path)) {
  ------------------
  |  Branch (906:9): [True: 0, False: 57.9k]
  ------------------
  907|      0|        terminate_log_file_thread(root);
  908|      0|        if (root->log_path) {
  ------------------
  |  Branch (908:13): [True: 0, False: 0]
  ------------------
  909|      0|            root->log_file = fopen(root->log_path, "wb");
  ------------------
  |  |   84|      0|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
  910|      0|            if (root->log_file) {
  ------------------
  |  Branch (910:17): [True: 0, False: 0]
  ------------------
  911|       |
  912|       |                // if a logfile is created and the early filebuf still exists,
  913|       |                // flush and destroy the early buffer
  914|      0|                mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  915|      0|                struct mp_log_buffer *earlybuf = root->early_filebuffer;
  916|      0|                if (earlybuf)
  ------------------
  |  Branch (916:21): [True: 0, False: 0]
  ------------------
  917|      0|                    root->early_filebuffer = NULL;  // but it still logs msgs
  918|      0|                mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  919|       |
  920|      0|                if (earlybuf) {
  ------------------
  |  Branch (920:21): [True: 0, False: 0]
  ------------------
  921|       |                    // flush, destroy before creating the normal logfile buf,
  922|       |                    // as once the new one is created (specifically, its write
  923|       |                    // thread), then MSGL_LOGFILE messages become blocking, but
  924|       |                    // the early logfile buf is without dequeue - can deadlock.
  925|       |                    // note: timestamp is unknown, we use 0.000 as indication.
  926|       |                    // note: new messages while iterating are still flushed.
  927|      0|                    struct mp_log_buffer_entry *e;
  928|      0|                    while ((e = mp_msg_log_buffer_read(earlybuf))) {
  ------------------
  |  Branch (928:28): [True: 0, False: 0]
  ------------------
  929|      0|                        fprintf(root->log_file, "[%8.3f][%c][%s] %s", 0.0,
  930|      0|                                mp_log_levels[e->level][0], e->prefix, e->text);
  931|      0|                        talloc_free(e);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  932|      0|                    }
  933|      0|                    mp_msg_log_buffer_destroy(earlybuf);  // + remove from root
  934|      0|                }
  935|       |
  936|      0|                root->log_file_buffer =
  937|      0|                    mp_msg_log_buffer_new(global, FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE,
  ------------------
  |  |   45|      0|#define FILE_BUF 100
  ------------------
                                  mp_msg_log_buffer_new(global, FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE,
  ------------------
  |  |   29|      0|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  938|      0|                                          wakeup_log_file, root);
  939|      0|                root->log_file_thread_active = true;
  940|      0|                if (mp_thread_create(&root->log_file_thread, log_file_thread,
  ------------------
  |  |  214|      0|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  941|      0|                                   root))
  942|      0|                {
  943|      0|                    root->log_file_thread_active = false;
  944|      0|                    terminate_log_file_thread(root);
  945|      0|                }
  946|      0|            } else {
  947|      0|                mp_err(global->log, "Failed to open log file '%s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  948|      0|                       root->log_path);
  949|      0|            }
  950|      0|        }
  951|      0|    }
  952|       |
  953|  57.9k|    if (check_new_path(global, opts->dump_stats, &root->stats_path)) {
  ------------------
  |  Branch (953:9): [True: 0, False: 57.9k]
  ------------------
  954|      0|        bool open_error = false;
  955|       |
  956|      0|        mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  957|      0|        if (root->stats_file)
  ------------------
  |  Branch (957:13): [True: 0, False: 0]
  ------------------
  958|      0|            fclose(root->stats_file);
  959|      0|        root->stats_file = NULL;
  960|      0|        if (root->stats_path) {
  ------------------
  |  Branch (960:13): [True: 0, False: 0]
  ------------------
  961|      0|            root->stats_file = fopen(root->stats_path, "wb");
  ------------------
  |  |   84|      0|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
  962|      0|            open_error = !root->stats_file;
  963|      0|        }
  964|      0|        mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  965|       |
  966|      0|        if (open_error) {
  ------------------
  |  Branch (966:13): [True: 0, False: 0]
  ------------------
  967|      0|            mp_err(global->log, "Failed to open stats file '%s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  968|      0|                   root->stats_path);
  969|      0|        }
  970|      0|    }
  971|  57.9k|}
mp_msg_has_log_file:
  984|   115k|{
  985|   115k|    struct mp_log_root *root = global->log->root;
  986|       |
  987|   115k|    return !!root->log_file;
  988|   115k|}
mp_msg_uninit:
  991|  28.9k|{
  992|  28.9k|    struct mp_log_root *root = global->log->root;
  993|  28.9k|    mp_msg_flush_status_line(global->log, true);
  994|  28.9k|    if (root->really_quiet && root->isatty[term_msg_fileno(root, MSGL_STATUS)]) {
  ------------------
  |  Branch (994:9): [True: 0, False: 28.9k]
  |  Branch (994:31): [True: 0, False: 0]
  ------------------
  995|      0|        terminal_lock_output();
  996|      0|        fprintf(term_msg_fp(root, MSGL_STATUS), TERM_ESC_RESTORE_CURSOR);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  997|      0|        terminal_unlock_output();
  998|      0|    }
  999|  28.9k|    terminate_log_file_thread(root);
 1000|  28.9k|    mp_msg_log_buffer_destroy(root->early_buffer);
 1001|  28.9k|    mp_msg_log_buffer_destroy(root->early_filebuffer);
 1002|  28.9k|    mp_assert(root->num_buffers == 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (1002:5): [True: 28.9k, False: 0]
  ------------------
 1003|  28.9k|    if (root->stats_file)
  ------------------
  |  Branch (1003:9): [True: 0, False: 28.9k]
  ------------------
 1004|      0|        fclose(root->stats_file);
 1005|  28.9k|    talloc_free(root->stats_path);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1006|  28.9k|    talloc_free(root->log_path);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1007|  28.9k|    m_option_type_msglevels.free(&root->msg_levels);
 1008|  28.9k|    mp_mutex_destroy(&root->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1009|  28.9k|    mp_mutex_destroy(&root->log_file_lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1010|  28.9k|    mp_cond_destroy(&root->log_file_wakeup);
 1011|  28.9k|    talloc_free(root);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1012|       |    global->log = NULL;
 1013|  28.9k|}
mp_msg_set_early_logging:
 1061|  57.9k|{
 1062|  57.9k|    struct mp_log_root *root = global->log->root;
 1063|       |
 1064|  57.9k|    mp_msg_set_early_logging_raw(global, enable, &root->early_buffer,
 1065|  57.9k|                                 EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   48|  57.9k|#define EARLY_TERM_BUF 100
  ------------------
                                               EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   27|  57.9k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
 1066|       |
 1067|       |    // normally MSGL_LOGFILE buffer gets a write thread, but not the early buf
 1068|  57.9k|    mp_msg_set_early_logging_raw(global, enable, &root->early_filebuffer,
 1069|  57.9k|                                 EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   54|  57.9k|#define EARLY_FILE_BUF 5000
  ------------------
                                               EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   29|  57.9k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
 1070|  57.9k|}
mp_msg_log_buffer_new:
 1076|  57.9k|{
 1077|  57.9k|    struct mp_log_root *root = global->log->root;
 1078|       |
 1079|  57.9k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1080|       |
 1081|  57.9k|    if (level == MP_LOG_BUFFER_MSGL_TERM) {
  ------------------
  |  |   27|  57.9k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (1081:9): [True: 28.9k, False: 28.9k]
  ------------------
 1082|       |        // The first thing which creates a terminal-level log buffer gets the
 1083|       |        // early log buffer, if it exists. This is supposed to enable a script
 1084|       |        // to grab log messages from before it was initialized. It's OK that
 1085|       |        // this works only for 1 script and only once.
 1086|  28.9k|        if (root->early_buffer) {
  ------------------
  |  Branch (1086:13): [True: 0, False: 28.9k]
  ------------------
 1087|      0|            struct mp_log_buffer *buffer = root->early_buffer;
 1088|      0|            root->early_buffer = NULL;
 1089|      0|            mp_msg_log_buffer_resize(buffer, size);
 1090|      0|            buffer->wakeup_cb = wakeup_cb;
 1091|      0|            buffer->wakeup_cb_ctx = wakeup_cb_ctx;
 1092|      0|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1093|      0|            return buffer;
 1094|      0|        }
 1095|  28.9k|    }
 1096|       |
 1097|  57.9k|    mp_assert(size > 0);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (1097:5): [True: 57.9k, False: 0]
  ------------------
 1098|       |
 1099|  57.9k|    struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer);
  ------------------
  |  |   34|  57.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  57.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|  57.9k|    *buffer = (struct mp_log_buffer) {
 1101|  57.9k|        .root = root,
 1102|  57.9k|        .level = level,
 1103|  57.9k|        .entries = talloc_array(buffer, struct mp_log_buffer_entry *, size),
  ------------------
  |  |   29|  57.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  57.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|  57.9k|        .capacity = size,
 1105|  57.9k|        .wakeup_cb = wakeup_cb,
 1106|  57.9k|        .wakeup_cb_ctx = wakeup_cb_ctx,
 1107|  57.9k|    };
 1108|       |
 1109|  57.9k|    mp_mutex_init(&buffer->lock);
 1110|       |
 1111|  57.9k|    MP_TARRAY_APPEND(root, root->buffers, root->num_buffers, buffer);
  ------------------
  |  |  105|  57.9k|    do {                                            \
  |  |  106|  57.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.9k|    do {                                            \
  |  |  |  |   97|  57.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  57.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.9k|        (idxvar)++;                                 \
  |  |  109|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
 1112|       |
 1113|  57.9k|    atomic_fetch_add(&root->reload_counter, 1);
 1114|  57.9k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|       |
 1116|  57.9k|    return buffer;
 1117|  57.9k|}
mp_msg_log_buffer_destroy:
 1161|   202k|{
 1162|   202k|    if (!buffer)
  ------------------
  |  Branch (1162:9): [True: 144k, False: 57.9k]
  ------------------
 1163|   144k|        return;
 1164|       |
 1165|  57.9k|    struct mp_log_root *root = buffer->root;
 1166|       |
 1167|  57.9k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1168|       |
 1169|  57.9k|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (1169:21): [True: 57.9k, False: 0]
  ------------------
 1170|  57.9k|        if (root->buffers[n] == buffer) {
  ------------------
  |  Branch (1170:13): [True: 57.9k, False: 0]
  ------------------
 1171|  57.9k|            MP_TARRAY_REMOVE_AT(root->buffers, root->num_buffers, n);
  ------------------
  |  |  143|  57.9k|    do {                                            \
  |  |  144|  57.9k|        size_t at_ = (at);                          \
  |  |  145|  57.9k|        assert(at_ < (idxvar));                     \
  |  |  146|  57.9k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  57.9k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  57.9k|        (idxvar)--;                                 \
  |  |  149|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
  |  Branch (1171:13): [True: 57.9k, False: 0]
  ------------------
 1172|  57.9k|            goto found;
 1173|  57.9k|        }
 1174|  57.9k|    }
 1175|       |
 1176|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (1176:5): [Folded, False: 0]
  ------------------
 1177|       |
 1178|  57.9k|found:
 1179|       |
 1180|  1.15M|    while (buffer->num_entries)
  ------------------
  |  Branch (1180:12): [True: 1.10M, False: 57.9k]
  ------------------
 1181|  1.10M|        talloc_free(log_buffer_read(buffer));
  ------------------
  |  |   47|  1.10M|#define talloc_free                     ta_free
  ------------------
 1182|       |
 1183|  57.9k|    mp_mutex_destroy(&buffer->lock);
  ------------------
  |  |  133|  57.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1184|  57.9k|    talloc_free(buffer);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
 1185|       |
 1186|  57.9k|    atomic_fetch_add(&root->reload_counter, 1);
 1187|  57.9k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1188|  57.9k|}
mp_msg:
 1223|  35.6M|{
 1224|  35.6M|    va_list va;
 1225|  35.6M|    va_start(va, format);
 1226|  35.6M|    mp_msg_va(log, lev, format, va);
 1227|       |    va_end(va);
 1228|  35.6M|}
mp_msg_find_level:
 1255|   565k|{
 1256|  4.52M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) {
  ------------------
  |  |   49|  4.52M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (1256:21): [True: 4.52M, False: 0]
  ------------------
 1257|  4.52M|        if (mp_log_levels[n] && !strcasecmp(s, mp_log_levels[n]))
  ------------------
  |  Branch (1257:13): [True: 4.52M, False: 0]
  |  Branch (1257:33): [True: 565k, False: 3.95M]
  ------------------
 1258|   565k|            return n;
 1259|  4.52M|    }
 1260|      0|    return -1;
 1261|   565k|}
msg.c:update_loglevel:
  141|   594k|{
  142|   594k|    struct mp_log_root *root = log->root;
  143|   594k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   594k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  144|   594k|    int level = MSGL_STATUS + root->verbose; // default log level
  145|   594k|    if (root->really_quiet)
  ------------------
  |  Branch (145:9): [True: 0, False: 594k]
  ------------------
  146|      0|        level = -1;
  147|  1.13M|    for (int n = 0; root->msg_levels && root->msg_levels[n * 2 + 0]; n++) {
  ------------------
  |  Branch (147:21): [True: 1.07M, False: 57.9k]
  |  Branch (147:41): [True: 536k, False: 536k]
  ------------------
  148|   536k|        if (match_mod(log->verbose_prefix, root->msg_levels[n * 2 + 0]))
  ------------------
  |  Branch (148:13): [True: 536k, False: 0]
  ------------------
  149|   536k|            level = mp_msg_find_level(root->msg_levels[n * 2 + 1]);
  150|   536k|    }
  151|   594k|    log->terminal_level = level;
  152|   883k|    for (int n = 0; n < log->root->num_buffers; n++) {
  ------------------
  |  Branch (152:21): [True: 289k, False: 594k]
  ------------------
  153|   289k|        int buffer_level = log->root->buffers[n]->level;
  154|   289k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   289k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (154:13): [True: 144k, False: 144k]
  ------------------
  155|   144k|            buffer_level = MSGL_DEBUG;
  156|   289k|        if (buffer_level != MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   289k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (156:13): [True: 144k, False: 144k]
  ------------------
  157|   144k|            level = MPMAX(level, buffer_level);
  ------------------
  |  |   44|   144k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 144k, False: 0]
  |  |  ------------------
  ------------------
  158|   289k|    }
  159|   594k|    if (log->root->log_file)
  ------------------
  |  Branch (159:9): [True: 0, False: 594k]
  ------------------
  160|      0|        level = MPMAX(level, MSGL_DEBUG);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  161|   594k|    if (log->root->stats_file)
  ------------------
  |  Branch (161:9): [True: 0, False: 594k]
  ------------------
  162|      0|        level = MPMAX(level, MSGL_STATS);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  163|   594k|    level = MPMIN(level, log->max_level);
  ------------------
  |  |   45|   594k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 594k]
  |  |  ------------------
  ------------------
  164|   594k|    atomic_store_explicit(&log->level, level, memory_order_relaxed);
  165|   594k|    atomic_store(&log->reload_counter, atomic_load(&log->root->reload_counter));
  166|   594k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|   594k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  167|   594k|}
msg.c:match_mod:
  132|   536k|{
  133|   536k|    if (!strcmp(mod, "all"))
  ------------------
  |  Branch (133:9): [True: 536k, False: 0]
  ------------------
  134|   536k|        return true;
  135|       |    // Path prefix matches
  136|      0|    bstr b = bstr0(name);
  137|      0|    return bstr_eatstart0(&b, mod) && (bstr_eatstart0(&b, "/") || !b.len);
  ------------------
  |  Branch (137:12): [True: 0, False: 0]
  |  Branch (137:40): [True: 0, False: 0]
  |  Branch (137:67): [True: 0, False: 0]
  ------------------
  138|   536k|}
msg.c:msg_flush_status_line:
  265|   162k|{
  266|   162k|    if (!root->status_lines)
  ------------------
  |  Branch (266:9): [True: 162k, False: 0]
  ------------------
  267|   162k|        goto done;
  268|       |
  269|      0|    FILE *fp = term_msg_fp(root, MSGL_STATUS);
  270|      0|    if (!clear) {
  ------------------
  |  Branch (270:9): [True: 0, False: 0]
  ------------------
  271|      0|        terminal_lock_output();
  272|      0|        if (root->isatty[term_msg_fileno(root, MSGL_STATUS)])
  ------------------
  |  Branch (272:13): [True: 0, False: 0]
  ------------------
  273|      0|            fprintf(fp, TERM_ESC_RESTORE_CURSOR);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  274|      0|        fprintf(fp, "\n");
  275|      0|        terminal_unlock_output();
  276|      0|        root->blank_lines = 0;
  277|      0|        root->status_lines = 0;
  278|      0|        goto done;
  279|      0|    }
  280|       |
  281|      0|    bstr term_msg = {0};
  282|      0|    prepare_prefix(root, &term_msg, MSGL_STATUS, 0);
  283|      0|    if (term_msg.len) {
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|        terminal_lock_output();
  285|      0|        fprintf(fp, "%.*s", BSTR_P(term_msg));
  ------------------
  |  |  307|      0|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  286|      0|        terminal_unlock_output();
  287|      0|        talloc_free(term_msg.start);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  288|      0|    }
  289|       |
  290|   162k|done:
  291|   162k|    root->status_line.len = 0;
  292|   162k|}
msg.c:term_msg_fp:
  202|  29.6M|{
  203|  29.6M|    return term_msg_fileno(root, lev) == STDERR_FILENO ? stderr : stdout;
  ------------------
  |  Branch (203:12): [True: 0, False: 29.6M]
  ------------------
  204|  29.6M|}
msg.c:utf8_tail_start:
  644|  29.6M|{
  645|  29.6M|    for (size_t n = 1; n <= 4 && n <= str.len; n++) {
  ------------------
  |  Branch (645:24): [True: 29.6M, False: 23]
  |  Branch (645:34): [True: 2.01M, False: 27.5M]
  ------------------
  646|  2.01M|        unsigned char ch = str.start[str.len - n];
  647|  2.01M|        if ((ch & 0xC0) != 0x80)
  ------------------
  |  Branch (647:13): [True: 2.01M, False: 2.98k]
  ------------------
  648|  2.01M|            return ch >= 0xC0 ? str.len - n : str.len;
  ------------------
  |  Branch (648:20): [True: 2.17k, False: 2.00M]
  ------------------
  649|  2.01M|    }
  650|  27.5M|    return str.len;
  651|  29.6M|}
msg.c:test_terminal_level:
  379|  29.6M|{
  380|  29.6M|    return lev <= log->terminal_level && log->root->use_terminal &&
  ------------------
  |  Branch (380:12): [True: 29.6M, False: 0]
  |  Branch (380:42): [True: 0, False: 29.6M]
  ------------------
  381|      0|           !(lev == MSGL_STATUS && terminal_in_background());
  ------------------
  |  Branch (381:14): [True: 0, False: 0]
  |  Branch (381:36): [True: 0, False: 0]
  ------------------
  382|  29.6M|}
msg.c:write_term_msg:
  518|  29.6M|{
  519|  29.6M|    struct mp_log_root *root = log->root;
  520|  29.6M|    bool print_term = test_terminal_level(log, lev);
  521|  29.6M|    int fileno = term_msg_fileno(root, lev);
  522|  29.6M|    int term_w = 0, term_h = 0;
  523|  29.6M|    if (print_term && root->isatty[fileno])
  ------------------
  |  Branch (523:9): [True: 0, False: 29.6M]
  |  Branch (523:23): [True: 0, False: 0]
  ------------------
  524|      0|        terminal_get_size(&term_w, &term_h);
  525|       |
  526|  29.6M|    out->len = 0;
  527|       |
  528|       |    // Split away each line. Normally we require full lines; buffer partial
  529|       |    // lines if they happen.
  530|  29.6M|    root->term_msg_tmp.len = 0;
  531|  29.6M|    int term_msg_lines = 0;
  532|       |
  533|  29.6M|    bstr str = text;
  534|  74.3M|    while (str.len) {
  ------------------
  |  Branch (534:12): [True: 46.7M, False: 27.5M]
  ------------------
  535|  46.7M|        bstr line = bstr_getline(str, &str);
  536|  46.7M|        if (line.start[line.len - 1] != '\n') {
  ------------------
  |  Branch (536:13): [True: 2.01M, False: 44.7M]
  ------------------
  537|  2.01M|            mp_assert(str.len == 0);
  ------------------
  |  |   41|  2.01M|#define mp_assert assert
  ------------------
  |  Branch (537:13): [True: 2.01M, False: 0]
  ------------------
  538|  2.01M|            str = line;
  539|  2.01M|            break;
  540|  2.01M|        }
  541|       |
  542|  46.7M|        bool clip = bstr_eatstart0(&line, TERM_MSG_0);
  ------------------
  |  |   30|  44.7M|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  44.7M|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  543|  44.7M|        if (print_term) {
  ------------------
  |  Branch (543:13): [True: 0, False: 44.7M]
  ------------------
  544|      0|            int line_w;
  545|      0|            append_terminal_line(log, lev, line, &root->term_msg_tmp, &line_w,
  546|      0|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (546:34): [True: 0, False: 0]
  |  Branch (546:42): [True: 0, False: 0]
  ------------------
  547|      0|            term_msg_lines += (!line_w || !term_w)
  ------------------
  |  Branch (547:32): [True: 0, False: 0]
  |  Branch (547:43): [True: 0, False: 0]
  ------------------
  548|      0|                                ? 1 : (line_w + term_w - 1) / term_w;
  549|      0|        }
  550|  44.7M|        write_msg_to_buffers(log, lev, line);
  551|  44.7M|    }
  552|       |
  553|  29.6M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (553:9): [True: 0, False: 29.6M]
  ------------------
  554|      0|        int line_w = 0;
  555|      0|        bool clip = bstr_eatstart0(&str, TERM_MSG_0);
  ------------------
  |  |   30|      0|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|      0|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  556|      0|        if (str.len && print_term)
  ------------------
  |  Branch (556:13): [True: 0, False: 0]
  |  Branch (556:24): [True: 0, False: 0]
  ------------------
  557|      0|            append_terminal_line(log, lev, str, &root->term_msg_tmp, &line_w,
  558|      0|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (558:34): [True: 0, False: 0]
  |  Branch (558:42): [True: 0, False: 0]
  ------------------
  559|      0|        term_msg_lines += !term_w ? (str.len ? 1 : 0)
  ------------------
  |  Branch (559:27): [True: 0, False: 0]
  |  Branch (559:38): [True: 0, False: 0]
  ------------------
  560|      0|                                  : (line_w + term_w - 1) / term_w;
  561|  29.6M|    } else if (str.len) {
  ------------------
  |  Branch (561:16): [True: 2.01M, False: 27.5M]
  ------------------
  562|  2.01M|        bstr_xappend(NULL, &log->partial[lev], str);
  563|  2.01M|    }
  564|       |
  565|  29.6M|    if (print_term && (root->term_msg_tmp.len || lev == MSGL_STATUS)) {
  ------------------
  |  Branch (565:9): [True: 0, False: 29.6M]
  |  Branch (565:24): [True: 0, False: 0]
  |  Branch (565:50): [True: 0, False: 0]
  ------------------
  566|      0|        prepare_prefix(root, out, lev, term_msg_lines);
  567|      0|        if (root->color[fileno] && root->term_msg_tmp.len) {
  ------------------
  |  Branch (567:13): [True: 0, False: 0]
  |  Branch (567:36): [True: 0, False: 0]
  ------------------
  568|      0|            set_msg_color(root, out, lev);
  569|      0|            set_term_color(root, &root->term_msg_tmp, -1);
  570|      0|        }
  571|      0|        bstr_xappend(root, out, root->term_msg_tmp);
  572|      0|    }
  573|  29.6M|}
msg.c:write_msg_to_buffers:
  459|  44.7M|{
  460|  44.7M|    struct mp_log_root *root = log->root;
  461|  45.8M|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (461:21): [True: 1.10M, False: 44.7M]
  ------------------
  462|  1.10M|        struct mp_log_buffer *buffer = root->buffers[n];
  463|  1.10M|        bool wakeup = false;
  464|  1.10M|        mp_mutex_lock(&buffer->lock);
  ------------------
  |  |  134|  1.10M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  465|  1.10M|        int buffer_level = buffer->level;
  466|  1.10M|        if (buffer_level == MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|  1.10M|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (466:13): [True: 550k, False: 550k]
  ------------------
  467|   550k|            buffer_level = log->terminal_level;
  468|  1.10M|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|  1.10M|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (468:13): [True: 550k, False: 550k]
  ------------------
  469|   550k|            buffer_level = MPMAX(log->terminal_level, MSGL_DEBUG);
  ------------------
  |  |   44|   550k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 550k, False: 0]
  |  |  ------------------
  ------------------
  470|  1.10M|        if (lev <= buffer_level && lev != MSGL_STATUS) {
  ------------------
  |  Branch (470:13): [True: 1.10M, False: 0]
  |  Branch (470:36): [True: 1.10M, False: 0]
  ------------------
  471|  1.10M|            if (buffer->level == MP_LOG_BUFFER_MSGL_LOGFILE) {
  ------------------
  |  |   29|  1.10M|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (471:17): [True: 550k, False: 550k]
  ------------------
  472|       |                // If the buffer is full, block until we can write again,
  473|       |                // unless there's no write thread (died, or early filebuffer)
  474|   550k|                if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (474:21): [True: 0, False: 550k]
  ------------------
  475|       |                    // Temporary unlock is OK; buffer->level is immutable, and
  476|       |                    // buffer can't go away because the global log lock is held.
  477|      0|                    mp_mutex_unlock(&buffer->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  478|      0|                    mp_mutex_lock(&root->log_file_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  479|      0|                    while (root->log_file_thread_active && log_buffer_full(buffer)) {
  ------------------
  |  Branch (479:28): [True: 0, False: 0]
  |  Branch (479:60): [True: 0, False: 0]
  ------------------
  480|      0|                        mp_cond_wait(&root->log_file_wakeup,
  481|      0|                                          &root->log_file_lock);
  482|      0|                    }
  483|      0|                    mp_mutex_unlock(&root->log_file_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  484|      0|                    mp_mutex_lock(&buffer->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  485|      0|                }
  486|   550k|            }
  487|  1.10M|            if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (487:17): [True: 0, False: 1.10M]
  ------------------
  488|      0|                struct mp_log_buffer_entry *skip = log_buffer_read(buffer);
  489|      0|                talloc_free(skip);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  490|      0|                buffer->dropped += 1;
  491|      0|            }
  492|  1.10M|            struct mp_log_buffer_entry *entry = talloc_ptrtype(NULL, entry);
  ------------------
  |  |   34|  1.10M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.10M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.10M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|  1.10M|            *entry = (struct mp_log_buffer_entry) {
  494|  1.10M|                .prefix = talloc_strdup(entry, log->verbose_prefix),
  ------------------
  |  |   50|  1.10M|#define talloc_strdup                   ta_xstrdup
  ------------------
  495|  1.10M|                .level = lev,
  496|  1.10M|                .text = bstrdup0(entry, text),
  497|  1.10M|            };
  498|  1.10M|            int pos = (buffer->entry0 + buffer->num_entries) % buffer->capacity;
  499|  1.10M|            buffer->entries[pos] = entry;
  500|  1.10M|            buffer->num_entries += 1;
  501|  1.10M|            if (buffer->wakeup_cb && !buffer->silent)
  ------------------
  |  Branch (501:17): [True: 0, False: 1.10M]
  |  Branch (501:38): [True: 0, False: 0]
  ------------------
  502|      0|                wakeup = true;
  503|  1.10M|        }
  504|  1.10M|        mp_mutex_unlock(&buffer->lock);
  ------------------
  |  |  136|  1.10M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|  1.10M|        if (wakeup)
  ------------------
  |  Branch (505:13): [True: 0, False: 1.10M]
  ------------------
  506|      0|            buffer->wakeup_cb(buffer->wakeup_cb_ctx);
  507|  1.10M|    }
  508|  44.7M|}
msg.c:destroy_log:
  718|  1.54M|{
  719|  1.54M|    struct mp_log *log = ptr;
  720|       |    // This is not managed via talloc itself, because mp_msg calls must be
  721|       |    // thread-safe, while talloc is not thread-safe.
  722|  15.4M|    for (int lvl = 0; lvl <= MSGL_MAX; ++lvl)
  ------------------
  |  Branch (722:23): [True: 13.8M, False: 1.54M]
  ------------------
  723|  13.8M|        talloc_free(log->partial[lvl].start);
  ------------------
  |  |   47|  13.8M|#define talloc_free                     ta_free
  ------------------
  724|  1.54M|}
msg.c:check_new_path:
  858|   115k|{
  859|   115k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   115k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   115k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  860|   115k|    bool res = false;
  861|       |
  862|   115k|    char *new_path = mp_get_user_path(tmp, global, opt);
  863|   115k|    if (!new_path)
  ------------------
  |  Branch (863:9): [True: 115k, False: 0]
  ------------------
  864|   115k|        new_path = "";
  865|       |
  866|   115k|    char *old_path = *current_path ? *current_path : "";
  ------------------
  |  Branch (866:22): [True: 0, False: 115k]
  ------------------
  867|   115k|    if (strcmp(old_path, new_path) != 0) {
  ------------------
  |  Branch (867:9): [True: 0, False: 115k]
  ------------------
  868|      0|        talloc_free(*current_path);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  869|      0|        *current_path = NULL;
  870|      0|        if (new_path[0])
  ------------------
  |  Branch (870:13): [True: 0, False: 0]
  ------------------
  871|      0|            *current_path = talloc_strdup(NULL, new_path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  872|      0|        res = true;
  873|      0|    }
  874|       |
  875|   115k|    talloc_free(tmp);
  ------------------
  |  |   47|   115k|#define talloc_free                     ta_free
  ------------------
  876|       |
  877|   115k|    return res;
  878|   115k|}
msg.c:terminate_log_file_thread:
  832|  28.9k|{
  833|  28.9k|    bool wait_terminate = false;
  834|       |
  835|  28.9k|    mp_mutex_lock(&root->log_file_lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  836|  28.9k|    if (root->log_file_thread_active) {
  ------------------
  |  Branch (836:9): [True: 0, False: 28.9k]
  ------------------
  837|      0|        root->log_file_thread_active = false;
  838|      0|        mp_cond_broadcast(&root->log_file_wakeup);
  839|      0|        wait_terminate = true;
  840|      0|    }
  841|  28.9k|    mp_mutex_unlock(&root->log_file_lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|       |
  843|  28.9k|    if (wait_terminate)
  ------------------
  |  Branch (843:9): [True: 0, False: 28.9k]
  ------------------
  844|      0|        mp_thread_join(root->log_file_thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  845|       |
  846|  28.9k|    mp_msg_log_buffer_destroy(root->log_file_buffer);
  847|  28.9k|    root->log_file_buffer = NULL;
  848|       |
  849|  28.9k|    if (root->log_file)
  ------------------
  |  Branch (849:9): [True: 0, False: 28.9k]
  ------------------
  850|      0|        fclose(root->log_file);
  851|       |    root->log_file = NULL;
  852|  28.9k|}
msg.c:term_msg_fileno:
  197|  59.2M|{
  198|  59.2M|    return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
  ------------------
  |  Branch (198:12): [True: 0, False: 59.2M]
  ------------------
  199|  59.2M|}
msg.c:mp_msg_set_early_logging_raw:
 1036|   115k|{
 1037|   115k|    struct mp_log_root *root = global->log->root;
 1038|   115k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   115k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1039|       |
 1040|   115k|    if (enable != !!*root_logbuf) {
  ------------------
  |  Branch (1040:9): [True: 115k, False: 0]
  ------------------
 1041|   115k|        if (enable) {
  ------------------
  |  Branch (1041:13): [True: 57.9k, False: 57.9k]
  ------------------
 1042|  57.9k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1043|  57.9k|            struct mp_log_buffer *buf =
 1044|  57.9k|                mp_msg_log_buffer_new(global, size, level, NULL, NULL);
 1045|  57.9k|            mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1046|  57.9k|            mp_assert(!*root_logbuf); // no concurrent calls to this function
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (1046:13): [True: 57.9k, False: 0]
  ------------------
 1047|  57.9k|            *root_logbuf = buf;
 1048|  57.9k|        } else {
 1049|  57.9k|            struct mp_log_buffer *buf = *root_logbuf;
 1050|  57.9k|            *root_logbuf = NULL;
 1051|  57.9k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1052|  57.9k|            mp_msg_log_buffer_destroy(buf);
 1053|  57.9k|            return;
 1054|  57.9k|        }
 1055|   115k|    }
 1056|       |
 1057|  57.9k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1058|  57.9k|}
msg.c:log_buffer_read:
  442|  1.10M|{
  443|  1.10M|    mp_assert(buffer->num_entries);
  ------------------
  |  |   41|  1.10M|#define mp_assert assert
  ------------------
  |  Branch (443:5): [True: 1.10M, False: 0]
  ------------------
  444|  1.10M|    struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0];
  445|  1.10M|    buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity;
  446|  1.10M|    buffer->num_entries -= 1;
  447|  1.10M|    return res;
  448|  1.10M|}

av_log.c:mp_msg_test:
   64|  12.7M|{
   65|  12.7M|    return lev <= mp_msg_level(log);
   66|  12.7M|}
msg.c:mp_msg_test:
   64|  35.6M|{
   65|  35.6M|    return lev <= mp_msg_level(log);
   66|  35.6M|}
cmd.c:mp_msg_test:
   64|  86.8k|{
   65|  86.8k|    return lev <= mp_msg_level(log);
   66|  86.8k|}
m_config_frontend.c:mp_msg_test:
   64|   260k|{
   65|   260k|    return lev <= mp_msg_level(log);
   66|   260k|}
chmap_sel.c:mp_msg_test:
   64|  7.98k|{
   65|  7.98k|    return lev <= mp_msg_level(log);
   66|  7.98k|}

playlist_entry_new:
   31|   133k|{
   32|   133k|    struct playlist_entry *e = talloc_zero(NULL, struct playlist_entry);
  ------------------
  |  |   27|   133k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   133k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   133k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   33|   133k|    char *local_filename = mp_file_url_to_filename(e, bstr0(filename));
   34|   133k|    e->filename = mp_normalize_path(e, local_filename ? local_filename : filename);
  ------------------
  |  Branch (34:40): [True: 863, False: 133k]
  ------------------
   35|   133k|    talloc_free(local_filename);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
   36|   133k|    e->stream_flags = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|   133k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
   37|   133k|    e->original_index = -1;
   38|   133k|    return e;
   39|   133k|}
playlist_insert_at:
   77|   133k|{
   78|   133k|    mp_assert(add->filename);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (78:5): [True: 133k, False: 0]
  ------------------
   79|   133k|    mp_assert(!at || at->pl == pl);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (79:5): [True: 133k, False: 0]
  |  Branch (79:5): [True: 0, False: 0]
  ------------------
   80|       |
   81|   133k|    int index = at ? at->pl_index : pl->num_entries;
  ------------------
  |  Branch (81:17): [True: 0, False: 133k]
  ------------------
   82|   133k|    MP_TARRAY_INSERT_AT(pl, pl->entries, pl->num_entries, index, add);
  ------------------
  |  |  115|   133k|    do {                                            \
  |  |  116|   133k|        size_t at_ = (at);                          \
  |  |  117|   133k|        assert(at_ <= (idxvar));                    \
  |  |  118|   133k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   133k|    do {                                            \
  |  |  |  |   97|   133k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   133k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   133k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   133k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 34.6k, False: 99.2k]
  |  |  |  |  ------------------
  |  |  |  |   99|   133k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  34.6k|    do {                                                        \
  |  |  |  |  |  |   89|  34.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  34.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  34.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  34.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  34.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  34.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  34.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 34.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   133k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 133k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   133k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   133k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   133k|        (idxvar)++;                                 \
  |  |  122|   133k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   133k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 133k]
  |  |  ------------------
  ------------------
  |  Branch (82:5): [True: 133k, False: 0]
  ------------------
   83|       |
   84|   133k|    add->pl = pl;
   85|   133k|    add->pl_index = index;
   86|   133k|    add->id = ++pl->id_alloc;
   87|       |
   88|   133k|    playlist_update_indexes(pl, index, pl->num_entries);
   89|       |
   90|   133k|    talloc_steal(pl, add);
  ------------------
  |  |   38|   133k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   133k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
   91|   133k|}
playlist_entry_unref:
   94|  34.5k|{
   95|  34.5k|    e->reserved--;
   96|  34.5k|    if (e->reserved < 0) {
  ------------------
  |  Branch (96:9): [True: 2.79k, False: 31.7k]
  ------------------
   97|  2.79k|        mp_assert(!e->pl);
  ------------------
  |  |   41|  2.79k|#define mp_assert assert
  ------------------
  |  Branch (97:9): [True: 2.79k, False: 0]
  ------------------
   98|  2.79k|        talloc_free(e);
  ------------------
  |  |   47|  2.79k|#define talloc_free                     ta_free
  ------------------
   99|  2.79k|    }
  100|  34.5k|}
playlist_remove:
  103|  2.79k|{
  104|  2.79k|    mp_assert(pl && entry->pl == pl);
  ------------------
  |  |   41|  2.79k|#define mp_assert assert
  ------------------
  |  Branch (104:5): [True: 2.79k, False: 0]
  |  Branch (104:5): [True: 2.79k, False: 0]
  ------------------
  105|       |
  106|  2.79k|    if (pl->current == entry) {
  ------------------
  |  Branch (106:9): [True: 2.66k, False: 124]
  ------------------
  107|  2.66k|        pl->current = playlist_entry_get_rel(entry, 1);
  108|  2.66k|        pl->current_was_replaced = true;
  109|  2.66k|    }
  110|       |
  111|  2.79k|    MP_TARRAY_REMOVE_AT(pl->entries, pl->num_entries, entry->pl_index);
  ------------------
  |  |  143|  2.79k|    do {                                            \
  |  |  144|  2.79k|        size_t at_ = (at);                          \
  |  |  145|  2.79k|        assert(at_ < (idxvar));                     \
  |  |  146|  2.79k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  2.79k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  2.79k|        (idxvar)--;                                 \
  |  |  149|  2.79k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 2.79k]
  |  |  ------------------
  ------------------
  |  Branch (111:5): [True: 2.79k, False: 0]
  ------------------
  112|  2.79k|    playlist_update_indexes(pl, entry->pl_index, -1);
  113|       |
  114|  2.79k|    entry->pl = NULL;
  115|  2.79k|    entry->pl_index = -1;
  116|  2.79k|    ta_set_parent(entry, NULL);
  117|       |
  118|       |    entry->removed = true;
  119|  2.79k|    playlist_entry_unref(entry);
  120|  2.79k|}
playlist_clear:
  123|  87.8k|{
  124|  87.9k|    for (int n = pl->num_entries - 1; n >= 0; n--)
  ------------------
  |  Branch (124:39): [True: 124, False: 87.8k]
  ------------------
  125|    124|        playlist_remove(pl, pl->entries[n]);
  126|  87.8k|    mp_assert(!pl->current);
  ------------------
  |  |   41|  87.8k|#define mp_assert assert
  ------------------
  |  Branch (126:5): [True: 87.8k, False: 0]
  ------------------
  127|  87.8k|    pl->current_was_replaced = false;
  128|  87.8k|    pl->playlist_completed = false;
  129|  87.8k|    pl->playlist_started = false;
  130|       |    TA_FREEP(&pl->playlist_dir);
  ------------------
  |  |   81|  87.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  87.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 87.8k]
  |  |  ------------------
  ------------------
  131|  87.8k|}
playlist_append_file:
  166|   104k|{
  167|       |    playlist_insert_at(pl, playlist_entry_new(filename), NULL);
  168|   104k|}
playlist_populate_playlist_path:
  171|  2.79k|{
  172|  2.79k|    char *playlist_path = talloc_strdup(pl, path);
  ------------------
  |  |   50|  2.79k|#define talloc_strdup                   ta_xstrdup
  ------------------
  173|   107k|    for (int n = 0; n < pl->num_entries; n++) {
  ------------------
  |  Branch (173:21): [True: 104k, False: 2.79k]
  ------------------
  174|   104k|        struct playlist_entry *e = pl->entries[n];
  175|   104k|        e->playlist_path = playlist_path;
  176|   104k|    }
  177|  2.79k|}
playlist_get_first:
  212|  34.2k|{
  213|  34.2k|    return pl->num_entries ? pl->entries[0] : NULL;
  ------------------
  |  Branch (213:12): [True: 5.33k, False: 28.9k]
  ------------------
  214|  34.2k|}
playlist_get_last:
  218|   103k|{
  219|   103k|    return pl->num_entries ? pl->entries[pl->num_entries - 1] : NULL;
  ------------------
  |  Branch (219:12): [True: 103k, False: 0]
  ------------------
  220|   103k|}
playlist_get_next:
  223|   133k|{
  224|   133k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (224:5): [True: 0, False: 133k]
  |  Branch (224:5): [True: 133k, False: 0]
  ------------------
  225|   133k|    if (!pl->current && pl->playlist_completed && direction < 0) {
  ------------------
  |  Branch (225:9): [True: 0, False: 133k]
  |  Branch (225:25): [True: 0, False: 0]
  |  Branch (225:51): [True: 0, False: 0]
  ------------------
  226|      0|        return playlist_entry_from_index(pl, pl->num_entries - 1);
  227|   133k|    } else if (!pl->current && !pl->playlist_started && direction > 0) {
  ------------------
  |  Branch (227:16): [True: 0, False: 133k]
  |  Branch (227:32): [True: 0, False: 0]
  |  Branch (227:57): [True: 0, False: 0]
  ------------------
  228|      0|        return playlist_entry_from_index(pl, 0);
  229|   133k|    } else if (!pl->current) {
  ------------------
  |  Branch (229:16): [True: 0, False: 133k]
  ------------------
  230|      0|        return NULL;
  231|      0|    }
  232|   133k|    mp_assert(pl->current->pl == pl);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (232:5): [True: 133k, False: 0]
  ------------------
  233|   133k|    if (direction < 0)
  ------------------
  |  Branch (233:9): [True: 0, False: 133k]
  ------------------
  234|      0|        return playlist_entry_get_rel(pl->current, -1);
  235|   133k|    return pl->current_was_replaced ? pl->current :
  ------------------
  |  Branch (235:12): [True: 2.66k, False: 130k]
  ------------------
  236|   133k|           playlist_entry_get_rel(pl->current, 1);
  237|   133k|}
playlist_entry_get_rel:
  242|   133k|{
  243|   133k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 0, False: 133k]
  |  Branch (243:5): [True: 133k, False: 0]
  ------------------
  244|   133k|    if (!e->pl)
  ------------------
  |  Branch (244:9): [True: 0, False: 133k]
  ------------------
  245|      0|        return NULL;
  246|   133k|    return playlist_entry_from_index(e->pl, e->pl_index + direction);
  247|   133k|}
playlist_set_stream_flags:
  318|  2.79k|{
  319|   107k|    for (int n = 0; n < pl->num_entries; n++)
  ------------------
  |  Branch (319:21): [True: 104k, False: 2.79k]
  ------------------
  320|   104k|        pl->entries[n]->stream_flags = flags;
  321|  2.79k|}
playlist_transfer_entries_to:
  325|  2.66k|{
  326|  2.66k|    mp_assert(pl != source_pl);
  ------------------
  |  |   41|  2.66k|#define mp_assert assert
  ------------------
  |  Branch (326:5): [True: 2.66k, False: 0]
  ------------------
  327|  2.66k|    struct playlist_entry *first = playlist_get_first(source_pl);
  328|       |
  329|  2.66k|    int count = source_pl->num_entries;
  330|  2.66k|    MP_TARRAY_INSERT_N_AT(pl, pl->entries, pl->num_entries, dst_index, count);
  ------------------
  |  |  130|  2.66k|    do {                                            \
  |  |  131|  2.66k|        size_t at_ = (at);                          \
  |  |  132|  2.66k|        assert(at_ <= (idxvar));                    \
  |  |  133|  2.66k|        size_t c_ = (c);                            \
  |  |  134|  2.66k|        MP_TARRAY_GROW(ctx, p, (idxvar) + c_);      \
  |  |  ------------------
  |  |  |  |   96|  2.66k|    do {                                            \
  |  |  |  |   97|  2.66k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.66k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.66k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.66k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.39k, False: 1.27k]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.66k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.39k|    do {                                                        \
  |  |  |  |  |  |   89|  1.39k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.39k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.39k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.39k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.39k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.39k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.39k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.39k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  2.66k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|  2.66k|        memmove((p) + at_ + c_, (p) + at_,          \
  |  |  136|  2.66k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  137|  2.66k|        (idxvar) += c_;                             \
  |  |  138|  2.66k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (138:14): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
  |  Branch (330:5): [True: 2.66k, False: 0]
  ------------------
  331|       |
  332|   107k|    for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (332:21): [True: 104k, False: 2.66k]
  ------------------
  333|   104k|        struct playlist_entry *e = source_pl->entries[n];
  334|   104k|        e->pl = pl;
  335|   104k|        e->pl_index = dst_index + n;
  336|   104k|        e->id = ++pl->id_alloc;
  337|   104k|        pl->entries[e->pl_index] = e;
  338|   104k|        talloc_steal(pl, e);
  ------------------
  |  |   38|   104k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   104k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  339|   104k|        talloc_steal(pl, e->playlist_path);
  ------------------
  |  |   38|   104k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   104k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  340|   104k|    }
  341|       |
  342|  2.66k|    playlist_update_indexes(pl, dst_index + count, -1);
  343|  2.66k|    source_pl->num_entries = 0;
  344|       |
  345|  2.66k|    pl->playlist_completed = source_pl->playlist_completed;
  346|  2.66k|    pl->playlist_started = source_pl->playlist_started;
  347|       |
  348|  2.66k|    return first ? first->id : 0;
  ------------------
  |  Branch (348:12): [True: 2.66k, False: 0]
  ------------------
  349|  2.66k|}
playlist_transfer_entries:
  357|  2.66k|{
  358|       |
  359|  2.66k|    int add_at = pl->num_entries;
  360|  2.66k|    if (pl->current) {
  ------------------
  |  Branch (360:9): [True: 2.66k, False: 0]
  ------------------
  361|  2.66k|        add_at = pl->current->pl_index + 1;
  362|  2.66k|        if (pl->current_was_replaced)
  ------------------
  |  Branch (362:13): [True: 0, False: 2.66k]
  ------------------
  363|      0|            add_at += 1;
  364|  2.66k|    }
  365|  2.66k|    mp_assert(add_at >= 0);
  ------------------
  |  |   41|  2.66k|#define mp_assert assert
  ------------------
  |  Branch (365:5): [True: 2.66k, False: 0]
  ------------------
  366|  2.66k|    mp_assert(add_at <= pl->num_entries);
  ------------------
  |  |   41|  2.66k|#define mp_assert assert
  ------------------
  |  Branch (366:5): [True: 2.66k, False: 0]
  ------------------
  367|       |
  368|  2.66k|    return playlist_transfer_entries_to(pl, add_at, source_pl);
  369|  2.66k|}
playlist_entry_to_index:
  379|  28.9k|{
  380|  28.9k|    if (!e || e->pl != pl)
  ------------------
  |  Branch (380:9): [True: 0, False: 28.9k]
  |  Branch (380:15): [True: 0, False: 28.9k]
  ------------------
  381|      0|        return -1;
  382|  28.9k|    return e->pl_index;
  383|  28.9k|}
playlist_entry_from_index:
  393|   133k|{
  394|   133k|    return index >= 0 && index < pl->num_entries ? pl->entries[index] : NULL;
  ------------------
  |  Branch (394:12): [True: 133k, False: 0]
  |  Branch (394:26): [True: 104k, False: 28.7k]
  ------------------
  395|   133k|}
playlist.c:playlist_update_indexes:
   65|   139k|{
   66|   139k|    start = MPMAX(start, 0);
  ------------------
  |  |   44|   139k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 105k, False: 34.2k]
  |  |  ------------------
  ------------------
   67|   139k|    end = end < 0 ? pl->num_entries : MPMIN(end, pl->num_entries);
  ------------------
  |  |   45|   273k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 133k]
  |  |  ------------------
  ------------------
  |  Branch (67:11): [True: 5.45k, False: 133k]
  ------------------
   68|       |
   69|   378k|    for (int n = start; n < end; n++)
  ------------------
  |  Branch (69:25): [True: 238k, False: 139k]
  ------------------
   70|   238k|        pl->entries[n]->pl_index = n;
   71|   139k|}

stats_global_init:
   81|  28.9k|{
   82|  28.9k|    mp_assert(!global->stats);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (82:5): [True: 28.9k, False: 0]
  ------------------
   83|  28.9k|    struct stats_base *stats = talloc_zero(global, struct stats_base);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  28.9k|    ta_set_destructor(stats, stats_destroy);
   85|  28.9k|    mp_mutex_init(&stats->lock);
   86|       |
   87|  28.9k|    global->stats = stats;
   88|  28.9k|    stats->global = global;
   89|  28.9k|}
stats_ctx_create:
  224|   458k|{
  225|   458k|    struct stats_base *base = global->stats;
  226|   458k|    mp_assert(base);
  ------------------
  |  |   41|   458k|#define mp_assert assert
  ------------------
  |  Branch (226:5): [True: 458k, False: 0]
  ------------------
  227|       |
  228|   458k|    struct stats_ctx *ctx = talloc_zero(ta_parent, struct stats_ctx);
  ------------------
  |  |   27|   458k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   458k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   458k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|   458k|    ctx->base = base;
  230|   458k|    ctx->prefix = talloc_strdup(ctx, prefix);
  ------------------
  |  |   50|   458k|#define talloc_strdup                   ta_xstrdup
  ------------------
  231|   458k|    ta_set_destructor(ctx, stats_ctx_destroy);
  232|       |
  233|   458k|    mp_mutex_lock(&base->lock);
  ------------------
  |  |  134|   458k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  234|   458k|    LL_APPEND(list, &base->list, ctx);
  ------------------
  |  |   44|   458k|#define LL_APPEND(field, list, item)  do {                              \
  |  |   45|   458k|    (item)->field.prev = (list)->tail;                                  \
  |  |   46|   458k|    (item)->field.next = NULL;                                          \
  |  |   47|   458k|    LL_RELINK_(field, list, item)                                       \
  |  |  ------------------
  |  |  |  |   98|   458k|    if ((item)->field.prev) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:9): [True: 429k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|   429k|        (item)->field.prev->field.next = (item);                        \
  |  |  |  |  100|   429k|    } else {                                                            \
  |  |  |  |  101|  28.9k|        (list)->head = (item);                                          \
  |  |  |  |  102|  28.9k|    }                                                                   \
  |  |  |  |  103|   458k|    if ((item)->field.next) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:9): [True: 0, False: 458k]
  |  |  |  |  ------------------
  |  |  |  |  104|      0|        (item)->field.next->field.prev = (item);                        \
  |  |  |  |  105|   458k|    } else {                                                            \
  |  |  |  |  106|   458k|        (list)->tail = (item);                                          \
  |  |  |  |  107|   458k|    }
  |  |  ------------------
  |  |   48|   458k|} while (0)
  |  |  ------------------
  |  |  |  Branch (48:10): [Folded, False: 458k]
  |  |  ------------------
  ------------------
  235|   458k|    base->num_entries = 0; // invalidate
  236|   458k|    mp_mutex_unlock(&base->lock);
  ------------------
  |  |  136|   458k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  237|       |
  238|   458k|    return ctx;
  239|   458k|}
stats_time_start:
  283|  87.5k|{
  284|  87.5k|    MP_STATS(ctx->base->global, "start %s", name);
  ------------------
  |  |   99|  87.5k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  87.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  285|  87.5k|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|  87.5k|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (285:9): [True: 87.5k, False: 0]
  ------------------
  286|  87.5k|        return;
  287|      0|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  288|      0|    struct stat_entry *e = find_entry(ctx, name);
  289|      0|    e->type = VAL_TIME;
  290|      0|    e->thread_id = mp_thread_current_id();
  ------------------
  |  |  217|      0|#define mp_thread_current_id      pthread_self
  ------------------
  291|      0|    e->cpu_start_ns = mp_thread_cpu_time_ns(e->thread_id);
  292|      0|    e->time_start_ns = mp_time_ns();
  293|      0|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  294|      0|}
stats_time_end:
  297|  87.5k|{
  298|  87.5k|    MP_STATS(ctx->base->global, "end %s", name);
  ------------------
  |  |   99|  87.5k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  87.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  299|  87.5k|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|  87.5k|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (299:9): [True: 87.5k, False: 0]
  ------------------
  300|  87.5k|        return;
  301|      0|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  302|      0|    struct stat_entry *e = find_entry(ctx, name);
  303|      0|    if (e->type == VAL_TIME && e->time_start_ns) {
  ------------------
  |  Branch (303:9): [True: 0, False: 0]
  |  Branch (303:32): [True: 0, False: 0]
  ------------------
  304|      0|        e->val_th += mp_thread_cpu_time_ns(e->thread_id) - e->cpu_start_ns;
  305|      0|        e->val_rt += mp_time_ns() - e->time_start_ns;
  306|      0|        e->time_start_ns = 0;
  307|      0|    }
  308|      0|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  309|      0|}
stats_event:
  312|   612k|{
  313|   612k|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|   612k|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (313:9): [True: 612k, False: 0]
  ------------------
  314|   612k|        return;
  315|      0|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  316|      0|    struct stat_entry *e = find_entry(ctx, name);
  317|      0|    e->val_d += 1;
  318|      0|    e->type = VAL_INC;
  319|      0|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  320|      0|}
stats_register_thread_cputime:
  333|  48.8k|{
  334|  48.8k|    register_thread(ctx, name, VAL_THREAD_CPU_TIME);
  335|  48.8k|}
stats_unregister_thread:
  338|  19.9k|{
  339|  19.9k|    register_thread(ctx, name, 0);
  340|  19.9k|}
stats.c:stats_destroy:
   71|  28.9k|{
   72|  28.9k|    struct stats_base *stats = p;
   73|       |
   74|       |    // All entries must have been destroyed before this.
   75|  28.9k|    mp_assert(!stats->list.head);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (75:5): [True: 28.9k, False: 0]
  ------------------
   76|       |
   77|  28.9k|    mp_mutex_destroy(&stats->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   78|  28.9k|}
stats.c:stats_ctx_destroy:
  213|   458k|{
  214|   458k|    struct stats_ctx *ctx = p;
  215|       |
  216|   458k|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|   458k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  217|   458k|    LL_REMOVE(list, &ctx->base->list, ctx);
  ------------------
  |  |   78|   458k|#define LL_REMOVE(field, list, item) do {                               \
  |  |   79|   458k|    if ((item)->field.prev) {                                           \
  |  |  ------------------
  |  |  |  Branch (79:9): [True: 429k, False: 28.9k]
  |  |  ------------------
  |  |   80|   429k|        (item)->field.prev->field.next = (item)->field.next;            \
  |  |   81|   429k|    } else {                                                            \
  |  |   82|  28.9k|        (list)->head = (item)->field.next;                              \
  |  |   83|  28.9k|    }                                                                   \
  |  |   84|   458k|    if ((item)->field.next) {                                           \
  |  |  ------------------
  |  |  |  Branch (84:9): [True: 7.60k, False: 451k]
  |  |  ------------------
  |  |   85|  7.60k|        (item)->field.next->field.prev = (item)->field.prev;            \
  |  |   86|   451k|    } else {                                                            \
  |  |   87|   451k|        (list)->tail = (item)->field.prev;                              \
  |  |   88|   451k|    }                                                                   \
  |  |   89|   458k|} while (0)
  |  |  ------------------
  |  |  |  Branch (89:10): [Folded, False: 458k]
  |  |  ------------------
  ------------------
  218|   458k|    ctx->base->num_entries = 0; // invalidate
  219|   458k|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|   458k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  220|   458k|}
stats.c:find_entry:
  242|  68.8k|{
  243|  68.8k|    for (int n = 0; n < ctx->num_entries; n++) {
  ------------------
  |  Branch (243:21): [True: 19.9k, False: 48.8k]
  ------------------
  244|  19.9k|        if (strcmp(ctx->entries[n]->name, name) == 0)
  ------------------
  |  Branch (244:13): [True: 19.9k, False: 0]
  ------------------
  245|  19.9k|            return ctx->entries[n];
  246|  19.9k|    }
  247|       |
  248|  48.8k|    struct stat_entry *e = talloc_zero(ctx, struct stat_entry);
  ------------------
  |  |   27|  48.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  48.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  48.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|  48.8k|    snprintf(e->name, sizeof(e->name), "%s", name);
  250|  48.8k|    mp_assert(strcmp(e->name, name) == 0); // make e->name larger and don't complain
  ------------------
  |  |   41|  48.8k|#define mp_assert assert
  ------------------
  |  Branch (250:5): [True: 48.8k, False: 0]
  ------------------
  251|       |
  252|  48.8k|    e->full_name = talloc_asprintf(e, "%s/%s", ctx->prefix, e->name);
  ------------------
  |  |   52|  48.8k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  48.8k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  253|       |
  254|  48.8k|    MP_TARRAY_APPEND(ctx, ctx->entries, ctx->num_entries, e);
  ------------------
  |  |  105|  48.8k|    do {                                            \
  |  |  106|  48.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  48.8k|    do {                                            \
  |  |  |  |   97|  48.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  48.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  48.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  48.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 48.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  48.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  48.8k|    do {                                                        \
  |  |  |  |  |  |   89|  48.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  48.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  48.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  48.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  48.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  48.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  48.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 48.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  48.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 48.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  48.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  48.8k|        (idxvar)++;                                 \
  |  |  109|  48.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 48.8k]
  |  |  ------------------
  ------------------
  255|  48.8k|    ctx->base->num_entries = 0; // invalidate
  256|       |
  257|  48.8k|    return e;
  258|  48.8k|}
stats.c:register_thread:
  324|  68.8k|{
  325|  68.8k|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|  68.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  326|  68.8k|    struct stat_entry *e = find_entry(ctx, name);
  327|  68.8k|    e->type = type;
  328|  68.8k|    e->thread_id = mp_thread_current_id();
  ------------------
  |  |  217|  68.8k|#define mp_thread_current_id      pthread_self
  ------------------
  329|  68.8k|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|  68.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  330|  68.8k|}

mp_tags_set_str:
   27|  26.5k|{
   28|  26.5k|    mp_tags_set_bstr(tags, bstr0(key), bstr0(value));
   29|  26.5k|}
mp_tags_set_bstr:
   32|  26.6k|{
   33|  64.2k|    for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (33:21): [True: 40.0k, False: 24.1k]
  ------------------
   34|  40.0k|        if (bstrcasecmp0(key, tags->keys[n]) == 0) {
  ------------------
  |  Branch (34:13): [True: 2.56k, False: 37.5k]
  ------------------
   35|  2.56k|            talloc_free(tags->values[n]);
  ------------------
  |  |   47|  2.56k|#define talloc_free                     ta_free
  ------------------
   36|  2.56k|            tags->values[n] = bstrto0(tags, value);
   37|  2.56k|            return;
   38|  2.56k|        }
   39|  40.0k|    }
   40|       |
   41|  24.1k|    MP_RESIZE_ARRAY(tags, tags->keys,   tags->num_keys + 1);
  ------------------
  |  |   88|  24.1k|    do {                                                        \
  |  |   89|  24.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  24.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  24.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  24.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  24.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  24.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  24.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 24.1k]
  |  |  ------------------
  ------------------
   42|  24.1k|    MP_RESIZE_ARRAY(tags, tags->values, tags->num_keys + 1);
  ------------------
  |  |   88|  24.1k|    do {                                                        \
  |  |   89|  24.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  24.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  24.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  24.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  24.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  24.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  24.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 24.1k]
  |  |  ------------------
  ------------------
   43|  24.1k|    tags->keys[tags->num_keys]   = bstrto0(tags, key);
   44|  24.1k|    tags->values[tags->num_keys] = bstrto0(tags, value);
   45|  24.1k|    tags->num_keys++;
   46|  24.1k|}
mp_tags_get_str:
   67|  2.10M|{
   68|  2.10M|    return mp_tags_get_bstr(tags, bstr0(key));
   69|  2.10M|}
mp_tags_get_bstr:
   72|  2.10M|{
   73|  2.13M|    for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (73:21): [True: 29.5k, False: 2.10M]
  ------------------
   74|  29.5k|        if (bstrcasecmp0(key, tags->keys[n]) == 0)
  ------------------
  |  Branch (74:13): [True: 1.00k, False: 28.5k]
  ------------------
   75|  1.00k|            return tags->values[n];
   76|  29.5k|    }
   77|  2.10M|    return NULL;
   78|  2.10M|}
mp_tags_clear:
   81|  37.8k|{
   82|  37.8k|    *tags = (struct mp_tags){0};
   83|  37.8k|    talloc_free_children(tags);
  ------------------
  |  |   46|  37.8k|#define talloc_free_children            ta_free_children
  ------------------
   84|  37.8k|}
mp_tags_dup:
   89|  37.8k|{
   90|  37.8k|    struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
  ------------------
  |  |   27|  37.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  37.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  37.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|  37.8k|    mp_tags_replace(new, tags);
   92|  37.8k|    return new;
   93|  37.8k|}
mp_tags_replace:
   96|  37.8k|{
   97|  37.8k|    mp_tags_clear(dst);
   98|  37.8k|    MP_RESIZE_ARRAY(dst, dst->keys,   src->num_keys);
  ------------------
  |  |   88|  37.8k|    do {                                                        \
  |  |   89|  37.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  37.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  37.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  37.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  37.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  37.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  37.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 37.8k]
  |  |  ------------------
  ------------------
   99|  37.8k|    MP_RESIZE_ARRAY(dst, dst->values, src->num_keys);
  ------------------
  |  |   88|  37.8k|    do {                                                        \
  |  |   89|  37.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  37.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  37.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  37.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  37.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  37.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  37.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 37.8k]
  |  |  ------------------
  ------------------
  100|  37.8k|    dst->num_keys = src->num_keys;
  101|  60.9k|    for (int n = 0; n < src->num_keys; n++) {
  ------------------
  |  Branch (101:21): [True: 23.1k, False: 37.8k]
  ------------------
  102|  23.1k|        dst->keys[n] = talloc_strdup(dst, src->keys[n]);
  ------------------
  |  |   50|  23.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
  103|  23.1k|        dst->values[n] = talloc_strdup(dst, src->values[n]);
  ------------------
  |  |   50|  23.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
  104|  23.1k|    }
  105|  37.8k|}
mp_tags_filtered:
  111|  21.8k|{
  112|  21.8k|    struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
  ------------------
  |  |   27|  21.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  21.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|   392k|    for (int n = 0; list && list[n]; n++) {
  ------------------
  |  Branch (113:21): [True: 392k, False: 0]
  |  Branch (113:29): [True: 370k, False: 21.8k]
  ------------------
  114|   370k|        char *key = list[n];
  115|   370k|        size_t keylen = strlen(key);
  116|   370k|        if (keylen >= INT_MAX)
  ------------------
  |  Branch (116:13): [True: 0, False: 370k]
  ------------------
  117|      0|            continue;
  118|   370k|        bool prefix = keylen && key[keylen - 1] == '*';
  ------------------
  |  Branch (118:23): [True: 370k, False: 0]
  |  Branch (118:33): [True: 0, False: 370k]
  ------------------
  119|   370k|        int matchlen = prefix ? keylen - 1 : keylen + 1;
  ------------------
  |  Branch (119:24): [True: 0, False: 370k]
  ------------------
  120|   420k|        for (int x = 0; x < tags->num_keys; x++) {
  ------------------
  |  Branch (120:25): [True: 49.3k, False: 370k]
  ------------------
  121|  49.3k|            if (strncasecmp(tags->keys[x], key, matchlen) == 0) {
  ------------------
  |  Branch (121:17): [True: 903, False: 48.4k]
  ------------------
  122|    903|                char skey[320];
  123|    903|                snprintf(skey, sizeof(skey), "%.*s%s", matchlen, key,
  124|    903|                         prefix ? tags->keys[x] + keylen - 1 : "");
  ------------------
  |  Branch (124:26): [True: 0, False: 903]
  ------------------
  125|    903|                mp_tags_set_str(new, skey, tags->values[x]);
  126|    903|            }
  127|  49.3k|        }
  128|   370k|    }
  129|  21.8k|    return new;
  130|  21.8k|}
mp_tags_merge:
  133|  9.30k|{
  134|  9.32k|    for (int n = 0; n < src->num_keys; n++)
  ------------------
  |  Branch (134:21): [True: 17, False: 9.30k]
  ------------------
  135|     17|        mp_tags_set_str(tags, src->keys[n], src->values[n]);
  136|  9.30k|}
mp_tags_copy_from_av_dictionary:
  140|  56.7k|{
  141|  56.7k|    AVDictionaryEntry *entry = NULL;
  142|  69.1k|    while ((entry = av_dict_get(av_dict, "", entry, AV_DICT_IGNORE_SUFFIX)))
  ------------------
  |  Branch (142:12): [True: 12.3k, False: 56.7k]
  ------------------
  143|  12.3k|        mp_tags_set_str(tags, entry->key, entry->value);
  144|  56.7k|}
mp_tags_move_from_av_dictionary:
  148|  56.7k|{
  149|  56.7k|    mp_tags_copy_from_av_dictionary(tags, *av_dict_ptr);
  150|  56.7k|    av_dict_free(av_dict_ptr);
  151|  56.7k|}

mp_map_mimetype_to_video_codec:
  200|  19.6k|{
  201|  19.6k|    if (mimetype) {
  ------------------
  |  Branch (201:9): [True: 0, False: 19.6k]
  ------------------
  202|      0|        for (int n = 0; mimetype_to_codec[n][0]; n++) {
  ------------------
  |  Branch (202:25): [True: 0, False: 0]
  ------------------
  203|      0|            if (strcasecmp(mimetype_to_codec[n][0], mimetype) == 0)
  ------------------
  |  Branch (203:17): [True: 0, False: 0]
  ------------------
  204|      0|                return mimetype_to_codec[n][1];
  205|      0|        }
  206|      0|    }
  207|  19.6k|    return NULL;
  208|  19.6k|}

mp_probe_cue:
  181|  40.1k|{
  182|  40.1k|    bool valid = false;
  183|  40.1k|    data = skip_utf8_bom(data);
  184|  46.0k|    for (;;) {
  185|  46.0k|        enum cue_command cmd = read_cmd(&data, NULL);
  186|       |        // End reached. Since the line was most likely cut off, don't use the
  187|       |        // result of the last parsing call.
  188|  46.0k|        if (data.len == 0)
  ------------------
  |  Branch (188:13): [True: 13.1k, False: 32.9k]
  ------------------
  189|  13.1k|            break;
  190|  32.9k|        if (cmd == CUE_ERROR)
  ------------------
  |  Branch (190:13): [True: 27.0k, False: 5.94k]
  ------------------
  191|  27.0k|            return false;
  192|  5.94k|        if (cmd != CUE_EMPTY)
  ------------------
  |  Branch (192:13): [True: 1.71k, False: 4.23k]
  ------------------
  193|  1.71k|            valid = true;
  194|  5.94k|    }
  195|  13.1k|    return valid;
  196|  40.1k|}
mp_parse_cue:
  199|    260|{
  200|    260|    struct cue_file *f = talloc_zero(NULL, struct cue_file);
  ------------------
  |  |   27|    260|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    260|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    260|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|    260|    f->tags = talloc_zero(f, struct mp_tags);
  ------------------
  |  |   27|    260|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    260|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    260|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|       |
  203|    260|    data = skip_utf8_bom(data);
  204|       |
  205|    260|    char *filename = NULL;
  206|       |    // Global metadata, and copied into new tracks.
  207|    260|    struct cue_track proto_track = {0};
  208|    260|    struct cue_track *cur_track = NULL;
  209|       |
  210|  10.6k|    while (data.len) {
  ------------------
  |  Branch (210:12): [True: 10.6k, False: 34]
  ------------------
  211|  10.6k|        struct bstr param;
  212|  10.6k|        int cmd = read_cmd(&data, &param);
  213|  10.6k|        switch (cmd) {
  ------------------
  |  Branch (213:17): [True: 5.45k, False: 5.14k]
  ------------------
  214|    226|        case CUE_ERROR:
  ------------------
  |  Branch (214:9): [True: 226, False: 10.3k]
  ------------------
  215|    226|            talloc_free(f);
  ------------------
  |  |   47|    226|#define talloc_free                     ta_free
  ------------------
  216|    226|            return NULL;
  217|    225|        case CUE_TRACK: {
  ------------------
  |  Branch (217:9): [True: 225, False: 10.3k]
  ------------------
  218|    225|            if (bstr_find0(param, "AUDIO") == -1)
  ------------------
  |  Branch (218:17): [True: 225, False: 0]
  ------------------
  219|    225|                break;
  220|      0|            MP_TARRAY_GROW(f, f->tracks, f->num_tracks);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  221|      0|            f->num_tracks += 1;
  222|      0|            cur_track = &f->tracks[f->num_tracks - 1];
  223|      0|            *cur_track = proto_track;
  224|      0|            cur_track->tags = talloc_zero(f, struct mp_tags);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|      0|            break;
  226|    225|        }
  227|    174|        case CUE_TITLE:
  ------------------
  |  Branch (227:9): [True: 174, False: 10.4k]
  ------------------
  228|    174|        case CUE_PERFORMER: {
  ------------------
  |  Branch (228:9): [True: 0, False: 10.6k]
  ------------------
  229|    174|            static const char *metanames[] = {
  230|    174|                [CUE_TITLE] = "title",
  231|    174|                [CUE_PERFORMER] = "performer",
  232|    174|            };
  233|    174|            struct mp_tags *tags = cur_track ? cur_track->tags : f->tags;
  ------------------
  |  Branch (233:36): [True: 0, False: 174]
  ------------------
  234|    174|            mp_tags_set_bstr(tags, bstr0(metanames[cmd]), strip_quotes(param));
  235|    174|            break;
  236|    174|        }
  237|     52|        case CUE_INDEX: {
  ------------------
  |  Branch (237:9): [True: 52, False: 10.5k]
  ------------------
  238|     52|            int type = read_int(&param, true);
  239|     52|            double time = read_time(&param);
  240|     52|            if (cur_track) {
  ------------------
  |  Branch (240:17): [True: 0, False: 52]
  ------------------
  241|      0|                if (type == 1) {
  ------------------
  |  Branch (241:21): [True: 0, False: 0]
  ------------------
  242|      0|                    cur_track->start = time;
  243|      0|                    cur_track->filename = filename;
  244|      0|                } else if (type == 0) {
  ------------------
  |  Branch (244:28): [True: 0, False: 0]
  ------------------
  245|      0|                    cur_track->pregap_start = time;
  246|      0|                }
  247|      0|            }
  248|     52|            break;
  249|    174|        }
  250|  4.77k|        case CUE_FILE:
  ------------------
  |  Branch (250:9): [True: 4.77k, False: 5.82k]
  ------------------
  251|       |            // NOTE: FILE comes before TRACK, so don't use cur_track->filename
  252|  4.77k|            filename = read_quoted(f, &param);
  253|  4.77k|            break;
  254|  10.6k|        }
  255|  10.6k|    }
  256|       |
  257|     34|    return f;
  258|    260|}
cue.c:skip_utf8_bom:
  173|  40.4k|{
  174|  40.4k|    return bstr_startswith0(data, "\xEF\xBB\xBF") ? bstr_cut(data, 3) : data;
  ------------------
  |  Branch (174:12): [True: 102, False: 40.3k]
  ------------------
  175|  40.4k|}
cue.c:read_cmd:
   92|  56.6k|{
   93|  56.6k|    struct bstr line = bstr_strip_linebreaks(bstr_getline(*data, data));
   94|  56.6k|    line = lstrip_whitespace(line);
   95|  56.6k|    if (line.len == 0)
  ------------------
  |  Branch (95:9): [True: 9.32k, False: 47.3k]
  ------------------
   96|  9.32k|        return CUE_EMPTY;
   97|   653k|    for (int n = 0; cue_command_strings[n].command != -1; n++) {
  ------------------
  |  Branch (97:21): [True: 613k, False: 40.2k]
  ------------------
   98|   613k|        struct bstr name = bstr0(cue_command_strings[n].text);
   99|   613k|        if (bstr_case_startswith(line, name)) {
  ------------------
  |  Branch (99:13): [True: 7.17k, False: 605k]
  ------------------
  100|  7.17k|            struct bstr rest = bstr_cut(line, name.len);
  101|  7.17k|            struct bstr par = lstrip_whitespace(rest);
  102|  7.17k|            if (rest.len && par.len == rest.len)
  ------------------
  |  Branch (102:17): [True: 7.14k, False: 34]
  |  Branch (102:29): [True: 39, False: 7.10k]
  ------------------
  103|     39|                continue;
  104|  7.13k|            if (out_params)
  ------------------
  |  Branch (104:17): [True: 5.31k, False: 1.82k]
  ------------------
  105|  5.31k|                *out_params = par;
  106|  7.13k|            return cue_command_strings[n].command;
  107|  7.17k|        }
  108|   613k|    }
  109|  40.2k|    return CUE_ERROR;
  110|  47.3k|}
cue.c:lstrip_whitespace:
   69|  68.8k|{
   70|  91.7k|    while (data.len) {
  ------------------
  |  Branch (70:12): [True: 82.2k, False: 9.46k]
  ------------------
   71|  82.2k|        bstr rest = data;
   72|  82.2k|        int code = bstr_decode_utf8(data, &rest);
   73|  82.2k|        if (code < 0) {
  ------------------
  |  Branch (73:13): [True: 11.1k, False: 71.1k]
  ------------------
   74|       |            // Tolerate Latin1 => probing works (which doesn't convert charsets).
   75|  11.1k|            code = data.start[0];
   76|  11.1k|            rest.start += 1;
   77|  11.1k|            rest.len -= 1;
   78|  11.1k|        }
   79|   538k|        for (size_t n = 0; n < MP_ARRAY_SIZE(spaces); n++) {
  ------------------
  |  |   49|   538k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (79:28): [True: 479k, False: 59.3k]
  ------------------
   80|   479k|            if (spaces[n] == code) {
  ------------------
  |  Branch (80:17): [True: 22.9k, False: 456k]
  ------------------
   81|  22.9k|                data = rest;
   82|  22.9k|                goto next;
   83|  22.9k|            }
   84|   479k|        }
   85|  59.3k|        break;
   86|  59.3k|    next: ;
   87|  22.9k|    }
   88|  68.8k|    return data;
   89|  68.8k|}
cue.c:strip_quotes:
  136|    174|{
  137|    174|    bstr s = data;
  138|    174|    if (bstr_eatstart0(&s, "\"") && bstr_eatend0(&s, "\""))
  ------------------
  |  Branch (138:9): [True: 125, False: 49]
  |  Branch (138:37): [True: 22, False: 103]
  ------------------
  139|     22|        return s;
  140|    152|    return data;
  141|    174|}
cue.c:read_int:
  147|    208|{
  148|    208|    *data = lstrip_whitespace(*data);
  149|    208|    if (data->len && data->start[0] == '-')
  ------------------
  |  Branch (149:9): [True: 171, False: 37]
  |  Branch (149:22): [True: 14, False: 157]
  ------------------
  150|     14|        return -1;
  151|    194|    struct bstr s = *data;
  152|    194|    int res = (int)bstrtoll(s, &s, 10);
  153|    194|    if (data->len == s.len || (two_digit && data->len - s.len > 2))
  ------------------
  |  Branch (153:9): [True: 118, False: 76]
  |  Branch (153:32): [True: 52, False: 24]
  |  Branch (153:45): [True: 24, False: 28]
  ------------------
  154|    142|        return -1;
  155|     52|    *data = s;
  156|     52|    return res;
  157|    194|}
cue.c:read_time:
  160|     52|{
  161|     52|    struct bstr s = *data;
  162|     52|    bool ok = true;
  163|     52|    double t1 = read_int(&s, false);
  164|     52|    ok = eat_char(&s, ':') && ok;
  ------------------
  |  Branch (164:10): [True: 3, False: 49]
  |  Branch (164:31): [True: 3, False: 0]
  ------------------
  165|     52|    double t2 = read_int(&s, true);
  166|     52|    ok = eat_char(&s, ':') && ok;
  ------------------
  |  Branch (166:10): [True: 2, False: 50]
  |  Branch (166:31): [True: 2, False: 0]
  ------------------
  167|     52|    double t3 = read_int(&s, true);
  168|     52|    ok = ok && t1 >= 0 && t2 >= 0 && t3 >= 0;
  ------------------
  |  Branch (168:10): [True: 2, False: 50]
  |  Branch (168:16): [True: 0, False: 2]
  |  Branch (168:27): [True: 0, False: 0]
  |  Branch (168:38): [True: 0, False: 0]
  ------------------
  169|     52|    return ok ? t1 * 60.0 + t2 + t3 * SECS_PER_CUE_FRAME : 0;
  ------------------
  |  |   31|      0|#define SECS_PER_CUE_FRAME (1.0/75.0)
  ------------------
  |  Branch (169:12): [True: 0, False: 52]
  ------------------
  170|     52|}
cue.c:eat_char:
  113|  4.87k|{
  114|  4.87k|    if (data->len && data->start[0] == ch) {
  ------------------
  |  Branch (114:9): [True: 4.84k, False: 39]
  |  Branch (114:22): [True: 3.63k, False: 1.20k]
  ------------------
  115|  3.63k|        *data = bstr_cut(*data, 1);
  116|  3.63k|        return true;
  117|  3.63k|    } else {
  118|       |        return false;
  119|  1.24k|    }
  120|  4.87k|}
cue.c:read_quoted:
  123|  4.77k|{
  124|  4.77k|    *data = lstrip_whitespace(*data);
  125|  4.77k|    if (!eat_char(data, '"'))
  ------------------
  |  Branch (125:9): [True: 1.14k, False: 3.63k]
  ------------------
  126|  1.14k|        return NULL;
  127|  3.63k|    int end = bstrchr(*data, '"');
  128|  3.63k|    if (end < 0)
  ------------------
  |  Branch (128:9): [True: 2.60k, False: 1.02k]
  ------------------
  129|  2.60k|        return NULL;
  130|  1.02k|    struct bstr res = bstr_splice(*data, 0, end);
  131|  1.02k|    *data = bstr_cut(*data, end + 1);
  132|  1.02k|    return bstrto0(talloc_ctx, res);
  133|  3.63k|}

demux_set_ts_offset:
  975|  21.8k|{
  976|  21.8k|    struct demux_internal *in = demuxer->in;
  977|  21.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  21.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  978|  21.8k|    in->ts_offset = offset;
  979|  21.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  21.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  980|  21.8k|}
demux_alloc_sh_stream:
 1004|  24.0k|{
 1005|  24.0k|    struct sh_stream *sh = talloc_ptrtype(NULL, sh);
  ------------------
  |  |   34|  24.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1006|  24.0k|    *sh = (struct sh_stream) {
 1007|  24.0k|        .type = type,
 1008|  24.0k|        .index = -1,
 1009|  24.0k|        .ff_index = -1,     // may be overwritten by demuxer
 1010|  24.0k|        .demuxer_id = -1,   // ... same
 1011|  24.0k|        .codec = talloc_zero(sh, struct mp_codec_params),
  ------------------
  |  |   27|  24.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|  24.0k|        .tags = talloc_zero(sh, struct mp_tags),
  ------------------
  |  |   27|  24.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  24.0k|    };
 1014|  24.0k|    sh->codec->type = type;
 1015|  24.0k|    return sh;
 1016|  24.0k|}
demux_add_sh_stream:
 1086|  24.0k|{
 1087|  24.0k|    struct demux_internal *in = demuxer->in;
 1088|  24.0k|    mp_assert(demuxer == in->d_thread);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (1088:5): [True: 24.0k, False: 0]
  ------------------
 1089|  24.0k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1090|  24.0k|    demux_add_sh_stream_locked(in, sh);
 1091|  24.0k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1092|  24.0k|}
demux_get_stream:
 1099|  48.0k|{
 1100|  48.0k|    struct demux_internal *in = demuxer->in;
 1101|  48.0k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  48.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1102|  48.0k|    mp_assert(index >= 0 && index < in->num_streams);
  ------------------
  |  |   41|  48.0k|#define mp_assert assert
  ------------------
  |  Branch (1102:5): [True: 48.0k, False: 0]
  |  Branch (1102:5): [True: 48.0k, False: 0]
  ------------------
 1103|  48.0k|    struct sh_stream *r = in->streams[index];
 1104|  48.0k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  48.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1105|  48.0k|    return r;
 1106|  48.0k|}
demux_get_num_stream:
 1110|  91.6k|{
 1111|  91.6k|    struct demux_internal *in = demuxer->in;
 1112|  91.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  91.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1113|  91.6k|    int r = in->num_streams;
 1114|  91.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  91.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|  91.6k|    return r;
 1116|  91.6k|}
demux_free:
 1159|   411k|{
 1160|   411k|    if (!demuxer)
  ------------------
  |  Branch (1160:9): [True: 40.3k, False: 371k]
  ------------------
 1161|  40.3k|        return;
 1162|   371k|    struct demux_internal *in = demuxer->in;
 1163|   371k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   371k|#define mp_assert assert
  ------------------
  |  Branch (1163:5): [True: 371k, False: 0]
  ------------------
 1164|       |
 1165|   371k|    demux_stop_thread(demuxer);
 1166|   371k|    demux_shutdown(in);
 1167|   371k|    demux_dealloc(in);
 1168|   371k|}
demux_free_async:
 1178|  24.6k|{
 1179|  24.6k|    struct demux_internal *in = demuxer->in;
 1180|  24.6k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (1180:5): [True: 24.6k, False: 0]
  ------------------
 1181|       |
 1182|  24.6k|    if (!in->threading)
  ------------------
  |  Branch (1182:9): [True: 4.66k, False: 19.9k]
  ------------------
 1183|  4.66k|        return NULL;
 1184|       |
 1185|  19.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1186|  19.9k|    in->thread_terminate = true;
 1187|  19.9k|    in->shutdown_async = true;
 1188|  19.9k|    mp_cond_signal(&in->wakeup);
 1189|  19.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1190|       |
 1191|  19.9k|    return (struct demux_free_async_state *)demuxer->in; // lies
 1192|  24.6k|}
demux_free_async_finish:
 1210|  59.8k|{
 1211|  59.8k|    struct demux_internal *in = (struct demux_internal *)state; // reverse lies
 1212|       |
 1213|  59.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  59.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1214|  59.8k|    bool busy = in->shutdown_async;
 1215|  59.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  59.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1216|       |
 1217|  59.8k|    if (busy)
  ------------------
  |  Branch (1217:9): [True: 39.9k, False: 19.9k]
  ------------------
 1218|  39.9k|        return false;
 1219|       |
 1220|  19.9k|    demux_stop_thread(in->d_user);
 1221|  19.9k|    demux_dealloc(in);
 1222|       |    return true;
 1223|  59.8k|}
demux_cancel_and_free:
 1229|  24.6k|{
 1230|  24.6k|    if (!demuxer)
  ------------------
  |  Branch (1230:9): [True: 19.9k, False: 4.66k]
  ------------------
 1231|  19.9k|        return;
 1232|  4.66k|    mp_cancel_trigger(demuxer->cancel);
 1233|  4.66k|    demux_free(demuxer);
 1234|  4.66k|}
demux_start_thread:
 1238|  19.9k|{
 1239|  19.9k|    struct demux_internal *in = demuxer->in;
 1240|  19.9k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  19.9k|#define mp_assert assert
  ------------------
  |  Branch (1240:5): [True: 19.9k, False: 0]
  ------------------
 1241|       |
 1242|  19.9k|    if (!in->threading) {
  ------------------
  |  Branch (1242:9): [True: 19.9k, False: 0]
  ------------------
 1243|  19.9k|        in->threading = true;
 1244|  19.9k|        if (mp_thread_create(&in->thread, demux_thread, in))
  ------------------
  |  |  214|  19.9k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 19.9k]
  |  |  ------------------
  ------------------
 1245|      0|            in->threading = false;
 1246|  19.9k|    }
 1247|  19.9k|}
demux_stop_thread:
 1250|   391k|{
 1251|   391k|    struct demux_internal *in = demuxer->in;
 1252|   391k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (1252:5): [True: 391k, False: 0]
  ------------------
 1253|       |
 1254|   391k|    if (in->threading) {
  ------------------
  |  Branch (1254:9): [True: 19.9k, False: 371k]
  ------------------
 1255|  19.9k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1256|  19.9k|        in->thread_terminate = true;
 1257|  19.9k|        mp_cond_signal(&in->wakeup);
 1258|  19.9k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1259|  19.9k|        mp_thread_join(in->thread);
  ------------------
  |  |  215|  19.9k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1260|  19.9k|        in->threading = false;
 1261|       |        in->thread_terminate = false;
 1262|  19.9k|    }
 1263|   391k|}
demux_set_wakeup_cb:
 1267|  44.5k|{
 1268|  44.5k|    struct demux_internal *in = demuxer->in;
 1269|  44.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  44.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1270|  44.5k|    in->wakeup_cb = cb;
 1271|  44.5k|    in->wakeup_cb_ctx = ctx;
 1272|  44.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  44.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1273|  44.5k|}
stream_type_name:
 1314|  1.40M|{
 1315|  1.40M|    switch (type) {
 1316|   150k|    case STREAM_VIDEO:  return "video";
  ------------------
  |  Branch (1316:5): [True: 150k, False: 1.25M]
  ------------------
 1317|  1.25M|    case STREAM_AUDIO:  return "audio";
  ------------------
  |  Branch (1317:5): [True: 1.25M, False: 150k]
  ------------------
 1318|      0|    case STREAM_SUB:    return "sub";
  ------------------
  |  Branch (1318:5): [True: 0, False: 1.40M]
  ------------------
 1319|      0|    default:            return "unknown";
  ------------------
  |  Branch (1319:5): [True: 0, False: 1.40M]
  ------------------
 1320|  1.40M|    }
 1321|  1.40M|}
demux_append_codec_desc:
 1333|  24.0k|{
 1334|  24.0k|    struct mp_codec_params *c = sh->codec;
 1335|       |
 1336|  24.0k|    bstr_xappend0(ta_ctx, dst, c->codec ? c->codec : "<unknown>");
  ------------------
  |  Branch (1336:32): [True: 24.0k, False: 0]
  ------------------
 1337|       |
 1338|  24.0k|    if (c->codec_profile)
  ------------------
  |  Branch (1338:9): [True: 4.30k, False: 19.7k]
  ------------------
 1339|  4.30k|        bstr_xappend_asprintf(ta_ctx, dst, " [%s]", c->codec_profile);
 1340|  24.0k|    if (c->disp_w)
  ------------------
  |  Branch (1340:9): [True: 5.45k, False: 18.5k]
  ------------------
 1341|  5.45k|        append_field(ta_ctx, dst, skip_dup,
 1342|  5.45k|                     mp_tprintf(32, "%dx%d", c->disp_w, c->disp_h));
  ------------------
  |  |  195|  5.45k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1343|  24.0k|    if (c->fps && !sh->image) {
  ------------------
  |  Branch (1343:9): [True: 6.50k, False: 17.5k]
  |  Branch (1343:19): [True: 1.73k, False: 4.76k]
  ------------------
 1344|  1.73k|        char *fps = mp_format_double(ta_ctx, c->fps, 4, false, false, true);
 1345|  1.73k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%s fps", fps));
  ------------------
  |  |  195|  1.73k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1346|  1.73k|    }
 1347|  24.0k|    if (c->channels.num)
  ------------------
  |  Branch (1347:9): [True: 11.2k, False: 12.8k]
  ------------------
 1348|  11.2k|        bstr_xappend_asprintf(ta_ctx, dst, " %dch", c->channels.num);
 1349|  24.0k|    if (c->samplerate)
  ------------------
  |  Branch (1349:9): [True: 10.4k, False: 13.6k]
  ------------------
 1350|  10.4k|        bstr_xappend_asprintf(ta_ctx, dst, " %d Hz", c->samplerate);
 1351|  24.0k|    int bitrate = 0;
 1352|  24.0k|    if (c->bitrate > 0 && c->bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1352:9): [True: 9.12k, False: 14.9k]
  |  Branch (1352:27): [True: 9.12k, False: 2]
  ------------------
 1353|  9.12k|        bitrate = (c->bitrate + 500) / 1000;
 1354|  14.9k|    } else if (sh->hls_bitrate > 0 && sh->hls_bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1354:16): [True: 0, False: 14.9k]
  |  Branch (1354:39): [True: 0, False: 0]
  ------------------
 1355|      0|        bitrate = (sh->hls_bitrate + 500) / 1000;
 1356|      0|    }
 1357|  24.0k|    if (bitrate)
  ------------------
  |  Branch (1357:9): [True: 8.82k, False: 15.2k]
  ------------------
 1358|  8.82k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%d kbps", bitrate));
  ------------------
  |  |  195|  8.82k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1359|  24.0k|}
demux_read_packet_async:
 2974|  1.42M|{
 2975|  1.42M|    return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt);
  ------------------
  |  |   39|  1.42M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2976|  1.42M|}
demux_read_packet_async_until:
 2984|  1.42M|{
 2985|  1.42M|    struct demux_stream *ds = sh ? sh->ds : NULL;
  ------------------
  |  Branch (2985:31): [True: 1.42M, False: 0]
  ------------------
 2986|  1.42M|    *out_pkt = NULL;
 2987|  1.42M|    if (!ds)
  ------------------
  |  Branch (2987:9): [True: 0, False: 1.42M]
  ------------------
 2988|      0|        return -1;
 2989|  1.42M|    struct demux_internal *in = ds->in;
 2990|       |
 2991|  1.42M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.42M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2992|  1.42M|    int r = -1;
 2993|  1.42M|    while (1) {
  ------------------
  |  Branch (2993:12): [True: 1.42M, Folded]
  ------------------
 2994|  1.42M|        r = dequeue_packet(ds, min_pts, out_pkt);
 2995|  1.42M|        if (in->threading || in->blocked || r != 0)
  ------------------
  |  Branch (2995:13): [True: 1.42M, False: 0]
  |  Branch (2995:30): [True: 0, False: 0]
  |  Branch (2995:45): [True: 0, False: 0]
  ------------------
 2996|  1.42M|            break;
 2997|       |        // Needs to actually read packets until we got a packet or EOF.
 2998|      0|        thread_work(in);
 2999|      0|    }
 3000|  1.42M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.42M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3001|  1.42M|    return r;
 3002|  1.42M|}
demux_update:
 3400|   177k|{
 3401|   177k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|   177k|#define mp_assert assert
  ------------------
  |  Branch (3401:5): [True: 177k, False: 0]
  ------------------
 3402|   177k|    struct demux_internal *in = demuxer->in;
 3403|       |
 3404|   177k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   177k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3405|       |
 3406|   177k|    if (!in->threading)
  ------------------
  |  Branch (3406:9): [True: 26.4k, False: 151k]
  ------------------
 3407|  26.4k|        update_cache(in);
 3408|       |
 3409|       |    // This implies this function is actually called from "the" user thread.
 3410|   177k|    in->d_user->filesize = in->stream_size;
 3411|       |
 3412|   177k|    pts = MP_ADD_PTS(pts, -in->ts_offset);
  ------------------
  |  |   67|   177k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   177k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 24.6k, False: 153k]
  |  |  ------------------
  ------------------
 3413|       |
 3414|   177k|    struct timed_metadata *prev = lookup_timed_metadata(in, in->last_playback_pts);
 3415|   177k|    struct timed_metadata *cur = lookup_timed_metadata(in, pts);
 3416|   177k|    if (prev != cur || in->force_metadata_update) {
  ------------------
  |  Branch (3416:9): [True: 0, False: 177k]
  |  Branch (3416:24): [True: 24.6k, False: 153k]
  ------------------
 3417|  24.6k|        in->force_metadata_update = false;
 3418|  24.6k|        update_final_metadata(demuxer, cur);
 3419|  24.6k|        demuxer->events |= DEMUX_EVENT_METADATA;
 3420|  24.6k|    }
 3421|       |
 3422|   177k|    in->last_playback_pts = pts;
 3423|       |
 3424|   177k|    demuxer->events |= in->events;
 3425|   177k|    in->events = 0;
 3426|   177k|    if (in->lists_changed) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 177k]
  ------------------
 3427|      0|        in->lists_changed = false;
 3428|      0|        demuxer->chapters = in->staged_chapters;
 3429|      0|        demuxer->num_chapters = in->num_staged_chapters;
 3430|      0|        demuxer->editions = in->staged_editions;
 3431|      0|        demuxer->num_editions = in->num_staged_editions;
 3432|      0|        demuxer->edition = in->staged_edition;
 3433|      0|    }
 3434|   369k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3434:21): [True: 192k, False: 177k]
  ------------------
 3435|   192k|        struct demux_stream *ds = in->streams[n]->ds;
 3436|   192k|        if (ds->staged_codec) {
  ------------------
  |  Branch (3436:13): [True: 0, False: 192k]
  ------------------
 3437|      0|            in->streams[n]->codec = ds->staged_codec;
 3438|      0|            ds->staged_codec = NULL;
 3439|      0|        }
 3440|   192k|    }
 3441|   177k|    if (demuxer->events & (DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS | DEMUX_EVENT_CODEC))
  ------------------
  |  Branch (3441:9): [True: 46.4k, False: 131k]
  ------------------
 3442|  46.4k|        demux_update_replaygain(demuxer);
 3443|   177k|    if (demuxer->events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (3443:9): [True: 65.1k, False: 112k]
  ------------------
 3444|  65.1k|        demuxer->duration = in->duration;
 3445|       |
 3446|   177k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   177k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3447|   177k|}
demux_close_stream:
 3484|  4.66k|{
 3485|  4.66k|    struct demux_internal *in = demuxer->in;
 3486|  4.66k|    mp_assert(!in->threading && demuxer == in->d_thread);
  ------------------
  |  |   41|  4.66k|#define mp_assert assert
  ------------------
  |  Branch (3486:5): [True: 4.66k, False: 0]
  |  Branch (3486:5): [True: 4.66k, False: 0]
  ------------------
 3487|       |
 3488|  4.66k|    if (!demuxer->stream || !in->owns_stream)
  ------------------
  |  Branch (3488:9): [True: 0, False: 4.66k]
  |  Branch (3488:29): [True: 0, False: 4.66k]
  ------------------
 3489|      0|        return;
 3490|       |
 3491|  4.66k|    MP_VERBOSE(demuxer, "demuxer read all data; closing stream\n");
  ------------------
  |  |   92|  4.66k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.66k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3492|  4.66k|    free_stream(demuxer->stream);
 3493|  4.66k|    demuxer->stream = NULL;
 3494|       |    in->d_user->stream = NULL;
 3495|  4.66k|}
demux_open_url:
 3766|  31.7k|{
 3767|  31.7k|    if (!params)
  ------------------
  |  Branch (3767:9): [True: 0, False: 31.7k]
  ------------------
 3768|      0|        return NULL;
 3769|  31.7k|    struct mp_cancel *priv_cancel = mp_cancel_new(NULL);
 3770|  31.7k|    if (cancel)
  ------------------
  |  Branch (3770:9): [True: 31.7k, False: 0]
  ------------------
 3771|  31.7k|        mp_cancel_set_parent(priv_cancel, cancel);
 3772|  31.7k|    struct stream *s = params->external_stream;
 3773|  31.7k|    if (!s) {
  ------------------
  |  Branch (3773:9): [True: 31.7k, False: 0]
  ------------------
 3774|  31.7k|        s = stream_create(url, STREAM_READ | params->stream_flags,
  ------------------
  |  |   41|  31.7k|#define STREAM_READ               0
  ------------------
 3775|  31.7k|                          priv_cancel, global);
 3776|  31.7k|        if (s && params->init_fragment.len) {
  ------------------
  |  Branch (3776:13): [True: 30.5k, False: 1.16k]
  |  Branch (3776:18): [True: 0, False: 30.5k]
  ------------------
 3777|      0|            s = create_webshit_concat_stream(global, priv_cancel,
 3778|      0|                                             params->init_fragment, s);
 3779|      0|        }
 3780|  31.7k|    }
 3781|  31.7k|    if (!s) {
  ------------------
  |  Branch (3781:9): [True: 1.16k, False: 30.5k]
  ------------------
 3782|  1.16k|        talloc_free(priv_cancel);
  ------------------
  |  |   47|  1.16k|#define talloc_free                     ta_free
  ------------------
 3783|  1.16k|        return NULL;
 3784|  1.16k|    }
 3785|  30.5k|    struct demuxer *d = demux_open(s, priv_cancel, params, global);
 3786|  30.5k|    if (d) {
  ------------------
  |  Branch (3786:9): [True: 24.6k, False: 5.98k]
  ------------------
 3787|  24.6k|        talloc_steal(d->in, priv_cancel);
  ------------------
  |  |   38|  24.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3788|  24.6k|        mp_assert(d->cancel);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (3788:9): [True: 24.6k, False: 0]
  ------------------
 3789|  24.6k|    } else {
 3790|  5.98k|        params->demuxer_failed = true;
 3791|  5.98k|        if (!params->external_stream)
  ------------------
  |  Branch (3791:13): [True: 5.98k, False: 0]
  ------------------
 3792|  5.98k|            free_stream(s);
 3793|  5.98k|        talloc_free(priv_cancel);
  ------------------
  |  |   47|  5.98k|#define talloc_free                     ta_free
  ------------------
 3794|  5.98k|    }
 3795|  30.5k|    return d;
 3796|  30.5k|}
demux_flush:
 3800|   391k|{
 3801|   391k|    struct demux_internal *in = demuxer->in;
 3802|   391k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (3802:5): [True: 391k, False: 0]
  ------------------
 3803|       |
 3804|   391k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   391k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3805|   391k|    clear_reader_state(in, true);
 3806|   416k|    for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (3806:21): [True: 24.6k, False: 391k]
  ------------------
 3807|  24.6k|        clear_cached_range(in, in->ranges[n]);
 3808|   391k|    free_empty_cached_ranges(in);
 3809|   415k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3809:21): [True: 24.0k, False: 391k]
  ------------------
 3810|  24.0k|        struct demux_stream *ds = in->streams[n]->ds;
 3811|  24.0k|        ds->refreshing = false;
 3812|  24.0k|        ds->eof = false;
 3813|  24.0k|    }
 3814|   391k|    in->eof = false;
 3815|   391k|    in->seeking = false;
 3816|   391k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   391k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3817|   391k|}
demuxer_select_track:
 4325|  26.5k|{
 4326|  26.5k|    struct demux_internal *in = demuxer->in;
 4327|  26.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  26.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4328|  26.5k|    bool changed = select_track(in, stream, ref_pts, selected);
 4329|  26.5k|    changed |= select_dependent_tracks(in, stream, ref_pts, selected);
 4330|  26.5k|    if (changed) {
  ------------------
  |  Branch (4330:9): [True: 24.4k, False: 2.12k]
  ------------------
 4331|  24.4k|        if (in->threading) {
  ------------------
  |  Branch (4331:13): [True: 24.4k, False: 0]
  ------------------
 4332|  24.4k|            mp_cond_signal(&in->wakeup);
 4333|  24.4k|        } else {
 4334|      0|            execute_trackswitch(in);
 4335|      0|        }
 4336|  24.4k|    }
 4337|  26.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  26.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4338|  26.5k|}
demux_stream_is_selected:
 4390|  1.51M|{
 4391|  1.51M|    if (!stream)
  ------------------
  |  Branch (4391:9): [True: 20, False: 1.51M]
  ------------------
 4392|     20|        return false;
 4393|  1.51M|    bool r = false;
 4394|  1.51M|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|  1.51M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4395|  1.51M|    r = stream->ds->selected;
 4396|  1.51M|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|  1.51M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4397|  1.51M|    return r;
 4398|  1.51M|}
demux_stream_eof_is_lazy:
 4405|   142k|{
 4406|   142k|    if (!stream)
  ------------------
  |  Branch (4406:9): [True: 0, False: 142k]
  ------------------
 4407|      0|        return false;
 4408|   142k|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|   142k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4409|   142k|    bool r = stream->ds->lazy_eof;
 4410|   142k|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|   142k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4411|   142k|    return r;
 4412|   142k|}
demux_set_stream_wakeup_cb:
 4427|  43.7k|{
 4428|  43.7k|    mp_mutex_lock(&sh->ds->in->lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4429|  43.7k|    sh->ds->wakeup_cb = cb;
 4430|  43.7k|    sh->ds->wakeup_cb_ctx = ctx;
 4431|  43.7k|    sh->ds->need_wakeup = true;
 4432|  43.7k|    mp_mutex_unlock(&sh->ds->in->lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4433|  43.7k|}
demuxer_add_chapter:
 4474|  13.2k|{
 4475|  13.2k|    struct demux_chapter new = {
 4476|  13.2k|        .original_index = demuxer->num_chapters,
 4477|  13.2k|        .pts = pts,
 4478|  13.2k|        .metadata = talloc_zero(demuxer, struct mp_tags),
  ------------------
  |  |   27|  13.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  13.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  13.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4479|  13.2k|        .demuxer_id = demuxer_id,
 4480|  13.2k|    };
 4481|  13.2k|    mp_tags_set_str(new.metadata, "TITLE", name);
 4482|  13.2k|    MP_TARRAY_APPEND(demuxer, demuxer->chapters, demuxer->num_chapters, new);
  ------------------
  |  |  105|  13.2k|    do {                                            \
  |  |  106|  13.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  13.2k|    do {                                            \
  |  |  |  |   97|  13.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  13.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  13.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  13.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 731, False: 12.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  13.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    731|    do {                                                        \
  |  |  |  |  |  |   89|    731|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    731|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    731|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    731|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    731|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    731|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    731|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 731]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  13.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 13.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  13.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  13.2k|        (idxvar)++;                                 \
  |  |  109|  13.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 13.2k]
  |  |  ------------------
  ------------------
 4483|  13.2k|    talloc_steal(demuxer->chapters, new.metadata);
  ------------------
  |  |   38|  13.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  13.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4484|  13.2k|    return demuxer->num_chapters - 1;
 4485|  13.2k|}
demux_get_reader_state:
 4874|   214k|{
 4875|   214k|    struct demux_internal *in = demuxer->in;
 4876|   214k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   214k|#define mp_assert assert
  ------------------
  |  Branch (4876:5): [True: 214k, False: 0]
  ------------------
 4877|       |
 4878|   214k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   214k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4879|       |
 4880|   214k|    *r = (struct demux_reader_state){
 4881|   214k|        .eof = in->eof,
 4882|   214k|        .ts_info = {
 4883|   214k|            .reader = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   214k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4884|   214k|            .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   214k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4885|   214k|            .duration = -1,
 4886|   214k|        },
 4887|   214k|        .total_bytes = in->total_bytes,
 4888|   214k|        .seeking = in->seeking_in_progress,
 4889|   214k|        .low_level_seeks = in->low_level_seeks,
 4890|   214k|        .ts_last = in->demux_ts,
 4891|   214k|        .bytes_per_second = in->bytes_per_second,
 4892|   214k|        .byte_level_seeks = in->byte_level_seeks,
 4893|   214k|        .file_cache_bytes = in->cache ? demux_cache_get_size(in->cache) : -1,
  ------------------
  |  Branch (4893:29): [True: 0, False: 214k]
  ------------------
 4894|   214k|    };
 4895|   214k|    bool any_packets = false;
 4896|   859k|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4896:21): [True: 644k, False: 214k]
  ------------------
 4897|   644k|        r->ts_per_stream[n] = r->ts_info;
 4898|   644k|    }
 4899|   446k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4899:21): [True: 231k, False: 214k]
  ------------------
 4900|   231k|        struct demux_stream *ds = in->streams[n]->ds;
 4901|   231k|        if (ds->eager && !(!ds->queue->head && ds->eof) && !ds->ignore_eof) {
  ------------------
  |  Branch (4901:13): [True: 206k, False: 25.6k]
  |  Branch (4901:28): [True: 37.5k, False: 168k]
  |  Branch (4901:48): [True: 16.9k, False: 20.6k]
  |  Branch (4901:60): [True: 189k, False: 0]
  ------------------
 4902|   189k|            r->underrun |= !ds->reader_head && !ds->eof && !ds->still_image;
  ------------------
  |  Branch (4902:28): [True: 58.6k, False: 130k]
  |  Branch (4902:48): [True: 21.1k, False: 37.4k]
  |  Branch (4902:60): [True: 21.1k, False: 0]
  ------------------
 4903|   189k|            any_packets |= !!ds->reader_head;
 4904|       |
 4905|   189k|            double ts_reader = ds->base_ts;
 4906|   189k|            double ts_end = ds->queue->last_ts;
 4907|   189k|            double ts_duration = -1;
 4908|   189k|            if (ts_reader != MP_NOPTS_VALUE && ts_reader <= ts_end)
  ------------------
  |  |   39|   378k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4908:17): [True: 153k, False: 35.6k]
  |  Branch (4908:48): [True: 153k, False: 4]
  ------------------
 4909|   153k|                ts_duration = ts_end - ts_reader;
 4910|       |
 4911|   189k|            struct demux_ctrl_ts_info *i = &r->ts_per_stream[ds->type];
 4912|   189k|            i->reader = MP_PTS_MIN(i->reader, ts_reader);
  ------------------
  |  |   64|   189k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   378k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 189k]
  |  |  |  |  |  Branch (45:23): [True: 189k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 35.6k, False: 153k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 189k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4913|   189k|            i->end = MP_PTS_MIN(i->end, ts_end);
  ------------------
  |  |   64|   189k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   378k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 189k]
  |  |  |  |  |  Branch (45:23): [True: 189k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 35.6k, False: 153k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 189k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4914|   189k|            i->duration = ts_duration;
 4915|   189k|        }
 4916|   231k|        r->fw_bytes += get_forward_buffered_bytes(ds);
 4917|   231k|    }
 4918|   214k|    struct demux_ctrl_ts_info *ots = &r->ts_info;
 4919|       |    // find stream type with lowest duration and use its state
 4920|   859k|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4920:21): [True: 644k, False: 214k]
  ------------------
 4921|   644k|        struct demux_ctrl_ts_info *ts = &r->ts_per_stream[n];
 4922|   644k|        if (r->ts_info.duration != -1) {
  ------------------
  |  Branch (4922:13): [True: 250k, False: 394k]
  ------------------
 4923|       |            // skip if timestamps unknown
 4924|   250k|            if (ts->duration == -1)
  ------------------
  |  Branch (4924:17): [True: 250k, False: 132]
  ------------------
 4925|   250k|                continue;
 4926|       |            // skip if we already know of a smaller cached stream
 4927|    132|            if (ts->duration > ots->duration)
  ------------------
  |  Branch (4927:17): [True: 13, False: 119]
  ------------------
 4928|     13|                continue;
 4929|       |            // skip empty subtitle streams when other streams exist
 4930|    119|            if (n == STREAM_SUB && ts->duration == 0.0)
  ------------------
  |  Branch (4930:17): [True: 0, False: 119]
  |  Branch (4930:36): [True: 0, False: 0]
  ------------------
 4931|      0|                continue;
 4932|    119|        }
 4933|   394k|        ots->duration = ts->duration;
 4934|   394k|        ots->reader = ts->reader;
 4935|   394k|        ots->end = ts->end;
 4936|   394k|    }
 4937|   214k|    r->idle = (!in->reading && !r->underrun) || r->eof;
  ------------------
  |  Branch (4937:16): [True: 182k, False: 32.5k]
  |  Branch (4937:32): [True: 182k, False: 0]
  |  Branch (4937:49): [True: 0, False: 32.5k]
  ------------------
 4938|   214k|    r->underrun &= !r->idle && in->threading;
  ------------------
  |  Branch (4938:20): [True: 32.5k, False: 182k]
  |  Branch (4938:32): [True: 32.5k, False: 0]
  ------------------
 4939|   214k|    ots->reader = MP_ADD_PTS(ots->reader, in->ts_offset);
  ------------------
  |  |   67|   214k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   214k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 61.2k, False: 153k]
  |  |  ------------------
  ------------------
 4940|   214k|    ots->end = MP_ADD_PTS(ots->end, in->ts_offset);
  ------------------
  |  |   67|   214k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   214k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 61.2k, False: 153k]
  |  |  ------------------
  ------------------
 4941|   214k|    if (ots->reader != MP_NOPTS_VALUE && ots->reader <= ots->end)
  ------------------
  |  |   39|   429k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4941:9): [True: 153k, False: 61.2k]
  |  Branch (4941:42): [True: 153k, False: 0]
  ------------------
 4942|   153k|        ots->duration = ots->end - ots->reader;
 4943|   214k|    if (in->seeking || !any_packets)
  ------------------
  |  Branch (4943:9): [True: 18, False: 214k]
  |  Branch (4943:24): [True: 84.1k, False: 130k]
  ------------------
 4944|  84.1k|        ots->duration = 0;
 4945|   429k|    for (int n = 0; n < MPMIN(in->num_ranges, MAX_SEEK_RANGES); n++) {
  ------------------
  |  |   45|   429k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 429k]
  |  |  ------------------
  ------------------
  |  Branch (4945:21): [True: 214k, False: 214k]
  ------------------
 4946|   214k|        struct demux_cached_range *range = in->ranges[n];
 4947|   214k|        if (range->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   214k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4947:13): [True: 148k, False: 66.6k]
  ------------------
 4948|   148k|            r->seek_ranges[r->num_seek_ranges++] =
 4949|   148k|                (struct demux_seek_range){
 4950|   148k|                    .start = MP_ADD_PTS(range->seek_start, in->ts_offset),
  ------------------
  |  |   67|   148k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   148k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 148k]
  |  |  ------------------
  ------------------
 4951|   148k|                    .end = MP_ADD_PTS(range->seek_end, in->ts_offset),
  ------------------
  |  |   67|   148k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   148k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 148k]
  |  |  ------------------
  ------------------
 4952|   148k|                };
 4953|   148k|            r->bof_cached |= range->is_bof;
 4954|   148k|            r->eof_cached |= range->is_eof;
 4955|   148k|        }
 4956|   214k|    }
 4957|       |
 4958|   214k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   214k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4959|   214k|}
demux_cancel_test:
 4962|  4.88M|{
 4963|  4.88M|    return mp_cancel_test(demuxer->cancel);
 4964|  4.88M|}
demux_read_interrupted:
 4969|  1.92M|{
 4970|  1.92M|    struct demux_internal *in = demuxer->in;
 4971|  1.92M|    return atomic_load_explicit(&in->seeking, memory_order_relaxed) ||
  ------------------
  |  Branch (4971:12): [True: 0, False: 1.92M]
  ------------------
 4972|  1.92M|           atomic_load_explicit(&in->thread_terminate, memory_order_relaxed) ||
  ------------------
  |  Branch (4972:12): [True: 0, False: 1.92M]
  ------------------
 4973|  1.92M|           demux_cancel_test(demuxer);
  ------------------
  |  Branch (4973:12): [True: 0, False: 1.92M]
  ------------------
 4974|  1.92M|}
demux_copy_chapter_data:
 4977|  21.8k|{
 4978|  21.8k|    struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num);
  ------------------
  |  |   29|  21.8k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  21.8k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4979|  35.0k|    for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (4979:21): [True: 13.2k, False: 21.8k]
  ------------------
 4980|  13.2k|        new[n] = c[n];
 4981|  13.2k|        new[n].metadata = mp_tags_dup(new, new[n].metadata);
 4982|  13.2k|    }
 4983|  21.8k|    return new;
 4984|  21.8k|}
demux.c:update_stream_eager_state:
  900|  48.4k|{
  901|  48.4k|    bool any_av_streams = false;
  902|  48.4k|    bool any_streams = false;
  903|       |
  904|   106k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (904:21): [True: 57.9k, False: 48.4k]
  ------------------
  905|  57.9k|        struct demux_stream *s = in->streams[n]->ds;
  906|       |
  907|  57.9k|        s->still_image = s->sh->still_image;
  908|  57.9k|        s->eager = s->selected && !s->sh->absent && !s->sh->attached_picture;
  ------------------
  |  Branch (908:20): [True: 24.9k, False: 32.9k]
  |  Branch (908:35): [True: 24.9k, False: 0]
  |  Branch (908:53): [True: 24.9k, False: 0]
  ------------------
  909|  57.9k|        if (s->eager && !s->still_image)
  ------------------
  |  Branch (909:13): [True: 24.9k, False: 32.9k]
  |  Branch (909:25): [True: 24.9k, False: 0]
  ------------------
  910|  24.9k|            any_av_streams |= s->type != STREAM_SUB;
  911|  57.9k|        any_streams |= s->selected;
  912|  57.9k|    }
  913|       |
  914|       |    // Subtitles and sparse still-image video are only eagerly read if there are
  915|       |    // no other eagerly read streams.
  916|  48.4k|    if (any_av_streams) {
  ------------------
  |  Branch (916:9): [True: 22.0k, False: 26.3k]
  ------------------
  917|  50.3k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (917:25): [True: 28.3k, False: 22.0k]
  ------------------
  918|  28.3k|            struct demux_stream *s = in->streams[n]->ds;
  919|       |
  920|  28.3k|            if (s->type == STREAM_SUB || s->still_image)
  ------------------
  |  Branch (920:17): [True: 0, False: 28.3k]
  |  Branch (920:42): [True: 0, False: 28.3k]
  ------------------
  921|      0|                s->eager = false;
  922|  28.3k|        }
  923|  22.0k|    }
  924|       |
  925|  48.4k|    if (!any_streams)
  ------------------
  |  Branch (925:9): [True: 26.3k, False: 22.0k]
  ------------------
  926|  26.3k|        in->blocked = false;
  927|  48.4k|}
demux.c:demux_add_sh_stream_locked:
 1023|  24.0k|{
 1024|  24.0k|    mp_assert(!sh->ds); // must not be added yet
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (1024:5): [True: 24.0k, False: 0]
  ------------------
 1025|       |
 1026|  24.0k|    sh->index = in->num_streams;
 1027|       |
 1028|  24.0k|    sh->ds = talloc(sh, struct demux_stream);
  ------------------
  |  |   26|  24.0k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.0k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1029|  24.0k|    *sh->ds = (struct demux_stream) {
 1030|  24.0k|        .in = in,
 1031|  24.0k|        .sh = sh,
 1032|  24.0k|        .type = sh->type,
 1033|  24.0k|        .index = sh->index,
 1034|  24.0k|        .global_correct_dts = true,
 1035|  24.0k|        .global_correct_pos = true,
 1036|  24.0k|    };
 1037|       |
 1038|  24.0k|    struct demux_stream *ds = sh->ds;
 1039|       |
 1040|  24.0k|    if (!sh->codec->codec)
  ------------------
  |  Branch (1040:9): [True: 216, False: 23.7k]
  ------------------
 1041|    216|        sh->codec->codec = "";
 1042|       |
 1043|  24.0k|    MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
  ------------------
  |  |  105|  24.0k|    do {                                            \
  |  |  106|  24.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.0k|    do {                                            \
  |  |  |  |   97|  24.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.0k, False: 2.93k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.0k|    do {                                                        \
  |  |  |  |  |  |   89|  21.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.0k|        (idxvar)++;                                 \
  |  |  109|  24.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.0k]
  |  |  ------------------
  ------------------
 1044|  24.0k|    mp_assert(in->streams[sh->index] == sh);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (1044:5): [True: 24.0k, False: 0]
  ------------------
 1045|       |
 1046|  24.0k|    if (in->current_range) {
  ------------------
  |  Branch (1046:9): [True: 9, False: 24.0k]
  ------------------
 1047|     18|        for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (1047:25): [True: 9, False: 9]
  ------------------
 1048|      9|            add_missing_streams(in, in->ranges[n]);
 1049|       |
 1050|      9|        sh->ds->queue = in->current_range->streams[sh->ds->index];
 1051|      9|    }
 1052|       |
 1053|  24.0k|    update_stream_selection_state(in, sh->ds);
 1054|       |
 1055|  24.0k|    switch (ds->type) {
  ------------------
  |  Branch (1055:13): [True: 22.0k, False: 1.94k]
  ------------------
 1056|  12.3k|    case STREAM_AUDIO:
  ------------------
  |  Branch (1056:5): [True: 12.3k, False: 11.6k]
  ------------------
 1057|  12.3k|        ds->back_preroll = in->d_user->opts->audio_back_preroll;
 1058|  12.3k|        if (ds->back_preroll < 0) { // auto
  ------------------
  |  Branch (1058:13): [True: 12.3k, False: 0]
  ------------------
 1059|  12.3k|            ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1;
  ------------------
  |  Branch (1059:32): [True: 3.30k, False: 9.07k]
  ------------------
 1060|  12.3k|            if (sh->codec->codec && (strcmp(sh->codec->codec, "opus") == 0 ||
  ------------------
  |  Branch (1060:17): [True: 12.3k, False: 0]
  |  Branch (1060:38): [True: 0, False: 12.3k]
  ------------------
 1061|  12.3k|                                     strcmp(sh->codec->codec, "vorbis") == 0 ||
  ------------------
  |  Branch (1061:38): [True: 2, False: 12.3k]
  ------------------
 1062|  12.3k|                                     strcmp(sh->codec->codec, "mp3") == 0))
  ------------------
  |  Branch (1062:38): [True: 389, False: 11.9k]
  ------------------
 1063|    391|                ds->back_preroll = 2;
 1064|  12.3k|        }
 1065|  12.3k|        break;
 1066|  9.69k|    case STREAM_VIDEO:
  ------------------
  |  Branch (1066:5): [True: 9.69k, False: 14.3k]
  ------------------
 1067|  9.69k|        ds->back_preroll = in->d_user->opts->video_back_preroll;
 1068|  9.69k|        if (ds->back_preroll < 0)
  ------------------
  |  Branch (1068:13): [True: 9.69k, False: 0]
  ------------------
 1069|  9.69k|            ds->back_preroll = 0; // auto
 1070|  9.69k|        break;
 1071|  24.0k|    }
 1072|       |
 1073|  24.0k|    if (!ds->sh->attached_picture) {
  ------------------
  |  Branch (1073:9): [True: 24.0k, False: 0]
  ------------------
 1074|       |        // Typically this is used for webradio, so any stream will do.
 1075|  24.0k|        if (!in->metadata_stream)
  ------------------
  |  Branch (1075:13): [True: 20.9k, False: 3.05k]
  ------------------
 1076|  20.9k|            in->metadata_stream = sh;
 1077|  24.0k|    }
 1078|       |
 1079|  24.0k|    in->events |= DEMUX_EVENT_STREAMS;
 1080|  24.0k|    if (in->wakeup_cb)
  ------------------
  |  Branch (1080:9): [True: 9, False: 24.0k]
  ------------------
 1081|      9|        in->wakeup_cb(in->wakeup_cb_ctx);
 1082|  24.0k|}
demux.c:add_missing_streams:
  984|  24.6k|{
  985|  48.6k|    for (int n = range->num_streams; n < in->num_streams; n++) {
  ------------------
  |  Branch (985:38): [True: 24.0k, False: 24.6k]
  ------------------
  986|  24.0k|        struct demux_stream *ds = in->streams[n]->ds;
  987|       |
  988|  24.0k|        struct demux_queue *queue = talloc_ptrtype(NULL, queue);
  ------------------
  |  |   34|  24.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|  24.0k|        *queue = (struct demux_queue){
  990|  24.0k|            .ds = ds,
  991|  24.0k|            .range = range,
  992|  24.0k|        };
  993|  24.0k|        clear_queue(queue);
  994|  24.0k|        MP_TARRAY_APPEND(range, range->streams, range->num_streams, queue);
  ------------------
  |  |  105|  24.0k|    do {                                            \
  |  |  106|  24.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.0k|    do {                                            \
  |  |  |  |   97|  24.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.0k, False: 2.93k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.0k|    do {                                                        \
  |  |  |  |  |  |   89|  21.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.0k|        (idxvar)++;                                 \
  |  |  109|  24.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.0k]
  |  |  ------------------
  ------------------
  995|       |        mp_assert(range->streams[ds->index] == queue);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (995:9): [True: 24.0k, False: 0]
  ------------------
  996|  24.0k|    }
  997|  24.6k|}
demux.c:clear_queue:
  758|  74.5k|{
  759|  74.5k|    struct demux_stream *ds = queue->ds;
  760|  74.5k|    struct demux_internal *in = ds->in;
  761|       |
  762|  74.5k|    if (queue->head)
  ------------------
  |  Branch (762:9): [True: 13.7k, False: 60.8k]
  ------------------
  763|  13.7k|        in->total_bytes -= queue->tail_cum_pos - queue->head->cum_pos;
  764|       |
  765|  74.5k|    free_index(queue);
  766|       |
  767|  74.5k|    demux_packet_pool_prepend(in->packet_pool, queue->head, queue->tail);
  768|  74.5k|    queue->head = queue->tail = NULL;
  769|  74.5k|    queue->keyframe_first = NULL;
  770|  74.5k|    queue->keyframe_latest = NULL;
  771|  74.5k|    queue->seek_start = queue->seek_end = queue->last_pruned = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  74.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  772|       |
  773|  74.5k|    queue->correct_dts = queue->correct_pos = true;
  774|  74.5k|    queue->last_pos = -1;
  775|  74.5k|    queue->last_ts = queue->last_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  74.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  776|  74.5k|    queue->last_pos_fixup = -1;
  777|       |
  778|  74.5k|    queue->is_eof = false;
  779|       |    queue->is_bof = false;
  780|  74.5k|}
demux.c:free_index:
  746|  74.5k|{
  747|  74.5k|    struct demux_stream *ds = queue->ds;
  748|  74.5k|    struct demux_internal *in = ds->in;
  749|       |
  750|  74.5k|    in->total_bytes -= queue->index_size * sizeof(queue->index[0]);
  751|  74.5k|    queue->index_size = 0;
  752|  74.5k|    queue->index0 = 0;
  753|  74.5k|    queue->num_index = 0;
  754|       |    TA_FREEP(&queue->index);
  ------------------
  |  |   81|  74.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  74.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 74.5k]
  |  |  ------------------
  ------------------
  755|  74.5k|}
demux.c:demux_shutdown:
 1120|   391k|{
 1121|   391k|    struct demuxer *demuxer = in->d_user;
 1122|       |
 1123|   391k|    if (in->recorder) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 391k]
  ------------------
 1124|      0|        mp_recorder_destroy(in->recorder);
 1125|      0|        in->recorder = NULL;
 1126|      0|    }
 1127|       |
 1128|   391k|    dumper_close(in);
 1129|       |
 1130|   391k|    if (demuxer->desc->close)
  ------------------
  |  Branch (1130:9): [True: 140k, False: 251k]
  ------------------
 1131|   140k|        demuxer->desc->close(in->d_thread);
 1132|   391k|    demuxer->priv = NULL;
 1133|   391k|    in->d_thread->priv = NULL;
 1134|       |
 1135|   391k|    demux_flush(demuxer);
 1136|   391k|    mp_assert(in->total_bytes == 0);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (1136:5): [True: 391k, False: 0]
  ------------------
 1137|       |
 1138|   391k|    in->current_range = NULL;
 1139|   391k|    free_empty_cached_ranges(in);
 1140|       |
 1141|   391k|    talloc_free(in->cache);
  ------------------
  |  |   47|   391k|#define talloc_free                     ta_free
  ------------------
 1142|   391k|    in->cache = NULL;
 1143|       |
 1144|   391k|    if (in->owns_stream)
  ------------------
  |  Branch (1144:9): [True: 391k, False: 0]
  ------------------
 1145|   391k|        free_stream(demuxer->stream);
 1146|       |    demuxer->stream = NULL;
 1147|   391k|}
demux.c:demux_dealloc:
 1150|   391k|{
 1151|   415k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1151:21): [True: 24.0k, False: 391k]
  ------------------
 1152|  24.0k|        talloc_free(in->streams[n]);
  ------------------
  |  |   47|  24.0k|#define talloc_free                     ta_free
  ------------------
 1153|   391k|    mp_mutex_destroy(&in->lock);
  ------------------
  |  |  133|   391k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1154|   391k|    mp_cond_destroy(&in->wakeup);
 1155|   391k|    talloc_free(in->d_user);
  ------------------
  |  |   47|   391k|#define talloc_free                     ta_free
  ------------------
 1156|   391k|}
demux.c:append_field:
 1325|  16.0k|{
 1326|  16.0k|    if (skip_dup && skip_dup[0] && strstr(skip_dup, value))
  ------------------
  |  Branch (1326:9): [True: 0, False: 16.0k]
  |  Branch (1326:21): [True: 0, False: 0]
  |  Branch (1326:36): [True: 0, False: 0]
  ------------------
 1327|      0|        return;
 1328|  16.0k|    bstr_xappend_asprintf(ta_ctx, dst, " %s", value);
 1329|  16.0k|}
demux.c:add_packet_locked:
 2153|  1.47M|{
 2154|  1.47M|    struct demux_stream *ds = stream ? stream->ds : NULL;
  ------------------
  |  Branch (2154:31): [True: 1.47M, False: 0]
  ------------------
 2155|  1.47M|    mp_assert(ds && ds->in);
  ------------------
  |  |   41|  1.47M|#define mp_assert assert
  ------------------
  |  Branch (2155:5): [True: 1.47M, False: 0]
  |  Branch (2155:5): [True: 1.47M, False: 0]
  ------------------
 2156|  1.47M|    if (!dp->len || demux_cancel_test(ds->in->d_thread)) {
  ------------------
  |  Branch (2156:9): [True: 71.3k, False: 1.40M]
  |  Branch (2156:21): [True: 0, False: 1.40M]
  ------------------
 2157|  71.3k|        talloc_free(dp);
  ------------------
  |  |   47|  71.3k|#define talloc_free                     ta_free
  ------------------
 2158|  71.3k|        return;
 2159|  71.3k|    }
 2160|       |
 2161|  1.40M|    mp_assert(dp->stream == stream->index);
  ------------------
  |  |   41|  1.40M|#define mp_assert assert
  ------------------
  |  Branch (2161:5): [True: 1.40M, False: 0]
  ------------------
 2162|  1.40M|    mp_assert(!dp->next);
  ------------------
  |  |   41|  1.40M|#define mp_assert assert
  ------------------
  |  Branch (2162:5): [True: 1.40M, False: 0]
  ------------------
 2163|       |
 2164|  1.40M|    struct demux_internal *in = ds->in;
 2165|       |
 2166|  1.40M|    in->after_seek = false;
 2167|  1.40M|    in->after_seek_to_start = false;
 2168|       |
 2169|  1.40M|    double ts = dp->dts == MP_NOPTS_VALUE ? dp->pts : dp->dts;
  ------------------
  |  |   39|  1.40M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2169:17): [True: 9.47k, False: 1.39M]
  ------------------
 2170|  1.40M|    if (dp->segmented)
  ------------------
  |  Branch (2170:9): [True: 0, False: 1.40M]
  ------------------
 2171|      0|        ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|      0|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2172|       |
 2173|  1.40M|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.40M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2173:9): [True: 1.39M, False: 8.42k]
  ------------------
 2174|  1.39M|        in->demux_ts = ts;
 2175|       |
 2176|  1.40M|    struct demux_queue *queue = ds->queue;
 2177|       |
 2178|  1.40M|    bool drop = !ds->selected || in->seeking || ds->sh->attached_picture;
  ------------------
  |  Branch (2178:17): [True: 0, False: 1.40M]
  |  Branch (2178:34): [True: 0, False: 1.40M]
  |  Branch (2178:49): [True: 0, False: 1.40M]
  ------------------
 2179|       |
 2180|  1.40M|    if (!drop) {
  ------------------
  |  Branch (2180:9): [True: 1.40M, False: 0]
  ------------------
 2181|       |        // If libavformat splits packets, some packets will have pos unset, so
 2182|       |        // make up one based on the first packet => makes refresh seeks work.
 2183|  1.40M|        if ((dp->pos < 0 || dp->pos == queue->last_pos_fixup) &&
  ------------------
  |  Branch (2183:14): [True: 295k, False: 1.10M]
  |  Branch (2183:29): [True: 8.82k, False: 1.09M]
  ------------------
 2184|   304k|            !dp->keyframe && queue->last_pos_fixup >= 0)
  ------------------
  |  Branch (2184:13): [True: 2.85k, False: 301k]
  |  Branch (2184:30): [True: 611, False: 2.24k]
  ------------------
 2185|    611|            dp->pos = queue->last_pos_fixup + 1;
 2186|  1.40M|        queue->last_pos_fixup = dp->pos;
 2187|  1.40M|    }
 2188|       |
 2189|  1.40M|    if (!drop && ds->refreshing) {
  ------------------
  |  Branch (2189:9): [True: 1.40M, False: 0]
  |  Branch (2189:18): [True: 0, False: 1.40M]
  ------------------
 2190|       |        // Resume reading once the old position was reached (i.e. we start
 2191|       |        // returning packets where we left off before the refresh).
 2192|       |        // If it's the same position, drop, but continue normally next time.
 2193|      0|        if (queue->correct_dts) {
  ------------------
  |  Branch (2193:13): [True: 0, False: 0]
  ------------------
 2194|      0|            ds->refreshing = dp->dts < queue->last_dts;
 2195|      0|        } else if (queue->correct_pos) {
  ------------------
  |  Branch (2195:20): [True: 0, False: 0]
  ------------------
 2196|      0|            ds->refreshing = dp->pos < queue->last_pos;
 2197|      0|        } else {
 2198|      0|            ds->refreshing = false; // should not happen
 2199|      0|            MP_WARN(in, "stream %d: demux refreshing failed\n", ds->index);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2200|      0|        }
 2201|      0|        drop = true;
 2202|      0|    }
 2203|       |
 2204|  1.40M|    if (drop) {
  ------------------
  |  Branch (2204:9): [True: 0, False: 1.40M]
  ------------------
 2205|      0|        demux_packet_pool_push(in->packet_pool, dp);
 2206|      0|        return;
 2207|      0|    }
 2208|       |
 2209|  1.40M|    record_packet(in, dp);
 2210|       |
 2211|  1.40M|    if (in->cache && in->d_user->opts->disk_cache && !dp->is_wrapped_avframe) {
  ------------------
  |  Branch (2211:9): [True: 0, False: 1.40M]
  |  Branch (2211:22): [True: 0, False: 0]
  |  Branch (2211:54): [True: 0, False: 0]
  ------------------
 2212|      0|        int64_t pos = demux_cache_write(in->cache, dp);
 2213|      0|        if (pos >= 0) {
  ------------------
  |  Branch (2213:13): [True: 0, False: 0]
  ------------------
 2214|      0|            demux_packet_unref_contents(dp);
 2215|      0|            dp->is_cached = true;
 2216|      0|            dp->cached_data.pos = pos;
 2217|      0|        }
 2218|      0|    }
 2219|       |
 2220|  1.40M|    queue->correct_pos &= dp->pos >= 0 && dp->pos > queue->last_pos;
  ------------------
  |  Branch (2220:27): [True: 1.10M, False: 295k]
  |  Branch (2220:43): [True: 1.09M, False: 8.75k]
  ------------------
 2221|  1.40M|    queue->correct_dts &= dp->dts != MP_NOPTS_VALUE && dp->dts > queue->last_dts;
  ------------------
  |  |   39|  2.80M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2221:27): [True: 1.39M, False: 9.47k]
  |  Branch (2221:56): [True: 1.25M, False: 132k]
  ------------------
 2222|  1.40M|    queue->last_pos = dp->pos;
 2223|  1.40M|    queue->last_dts = dp->dts;
 2224|  1.40M|    ds->global_correct_pos &= queue->correct_pos;
 2225|  1.40M|    ds->global_correct_dts &= queue->correct_dts;
 2226|       |
 2227|       |    // (keep in mind that even if the reader went out of data, the queue is not
 2228|       |    // necessarily empty due to the backbuffer)
 2229|  1.40M|    if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
  ------------------
  |  Branch (2229:9): [True: 18.2k, False: 1.38M]
  |  Branch (2229:30): [True: 18.2k, False: 0]
  |  Branch (2229:55): [True: 0, False: 0]
  ------------------
 2230|  18.2k|        ds->reader_head = dp;
 2231|  18.2k|        ds->skip_to_keyframe = false;
 2232|  18.2k|    }
 2233|       |
 2234|  1.40M|    size_t bytes = demux_packet_estimate_total_size(dp);
 2235|  1.40M|    in->total_bytes += bytes;
 2236|  1.40M|    dp->cum_pos = queue->tail_cum_pos;
 2237|  1.40M|    queue->tail_cum_pos += bytes;
 2238|       |
 2239|  1.40M|    if (queue->tail) {
  ------------------
  |  Branch (2239:9): [True: 1.38M, False: 13.7k]
  ------------------
 2240|       |        // next packet in stream
 2241|  1.38M|        queue->tail->next = dp;
 2242|  1.38M|        queue->tail = dp;
 2243|  1.38M|    } else {
 2244|       |        // first packet in stream
 2245|  13.7k|        queue->head = queue->tail = dp;
 2246|  13.7k|    }
 2247|       |
 2248|  1.40M|    if (!ds->ignore_eof) {
  ------------------
  |  Branch (2248:9): [True: 1.40M, False: 0]
  ------------------
 2249|       |        // obviously not true anymore
 2250|  1.40M|        ds->eof = false;
 2251|  1.40M|        in->eof = false;
 2252|  1.40M|    }
 2253|       |
 2254|       |    // For video, PTS determination is not trivial, but for other media types
 2255|       |    // distinguishing PTS and DTS is not useful.
 2256|  1.40M|    if (stream->type != STREAM_VIDEO && dp->pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.24M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2256:9): [True: 1.24M, False: 150k]
  |  Branch (2256:41): [True: 3.92k, False: 1.24M]
  ------------------
 2257|  3.92k|        dp->pts = dp->dts;
 2258|       |
 2259|  1.40M|    if (ts != MP_NOPTS_VALUE && (ts > queue->last_ts || ts + 10 < queue->last_ts))
  ------------------
  |  |   39|  2.80M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2259:9): [True: 1.39M, False: 8.42k]
  |  Branch (2259:34): [True: 1.25M, False: 132k]
  |  Branch (2259:57): [True: 0, False: 132k]
  ------------------
 2260|  1.25M|        queue->last_ts = ts;
 2261|  1.40M|    if (ds->base_ts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.40M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2261:9): [True: 18.9k, False: 1.38M]
  ------------------
 2262|  18.9k|        ds->base_ts = queue->last_ts;
 2263|       |
 2264|  1.40M|    const char *num_pkts = queue->head == queue->tail ? "1" : ">1";
  ------------------
  |  Branch (2264:28): [True: 13.7k, False: 1.38M]
  ------------------
 2265|  1.40M|    uint64_t fw_bytes = get_forward_buffered_bytes(ds);
 2266|  1.40M|    MP_TRACE(in, "append packet to %s: size=%zu pts=%f dts=%f pos=%"PRIi64" "
  ------------------
  |  |   94|  1.40M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.40M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2267|  1.40M|             "[num=%s size=%zd]\n", stream_type_name(stream->type),
 2268|  1.40M|             dp->len, dp->pts, dp->dts, dp->pos, num_pkts, (size_t)fw_bytes);
 2269|       |
 2270|  1.40M|    adjust_seek_range_on_packet(ds, dp);
 2271|       |
 2272|       |    // May need to reduce backward cache.
 2273|  1.40M|    prune_old_packets(in);
 2274|       |
 2275|       |    // Possibly update duration based on highest TS demuxed (but ignore subs).
 2276|  1.40M|    if (stream->type != STREAM_SUB) {
  ------------------
  |  Branch (2276:9): [True: 1.40M, False: 0]
  ------------------
 2277|  1.40M|        if (dp->segmented)
  ------------------
  |  Branch (2277:13): [True: 0, False: 1.40M]
  ------------------
 2278|      0|            ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|      0|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2279|  1.40M|        if (ts > in->highest_av_pts) {
  ------------------
  |  Branch (2279:13): [True: 1.25M, False: 140k]
  ------------------
 2280|  1.25M|            in->highest_av_pts = ts;
 2281|  1.25M|            double duration = in->highest_av_pts - in->d_thread->start_time;
 2282|  1.25M|            if (duration > in->d_thread->duration) {
  ------------------
  |  Branch (2282:17): [True: 1.25M, False: 3.60k]
  ------------------
 2283|  1.25M|                in->d_thread->duration = duration;
 2284|       |                // (Don't wakeup user thread, would be too noisy.)
 2285|  1.25M|                in->events |= DEMUX_EVENT_DURATION;
 2286|  1.25M|                in->duration = duration;
 2287|  1.25M|            }
 2288|  1.25M|        }
 2289|  1.40M|    }
 2290|       |
 2291|       |    // Don't process the packet further if it's skipped by the previous seek
 2292|       |    // (see reader_head check/assignment above).
 2293|  1.40M|    if (!ds->reader_head)
  ------------------
  |  Branch (2293:9): [True: 0, False: 1.40M]
  ------------------
 2294|      0|        return;
 2295|       |
 2296|  1.40M|    back_demux_see_packets(ds);
 2297|       |
 2298|  1.40M|    wakeup_ds(ds);
 2299|  1.40M|}
demux.c:record_packet:
 2122|  1.40M|{
 2123|       |    // (should preferably be outside of the lock)
 2124|  1.40M|    if (in->enable_recording && !in->recorder &&
  ------------------
  |  Branch (2124:9): [True: 0, False: 1.40M]
  |  Branch (2124:33): [True: 0, False: 0]
  ------------------
 2125|      0|        in->d_user->opts->record_file && in->d_user->opts->record_file[0])
  ------------------
  |  Branch (2125:9): [True: 0, False: 0]
  |  Branch (2125:42): [True: 0, False: 0]
  ------------------
 2126|      0|    {
 2127|       |        // Later failures shouldn't make it retry and overwrite the previously
 2128|       |        // recorded file.
 2129|      0|        in->enable_recording = false;
 2130|       |
 2131|      0|        in->recorder = recorder_create(in, in->d_user->opts->record_file);
 2132|      0|        if (!in->recorder)
  ------------------
  |  Branch (2132:13): [True: 0, False: 0]
  ------------------
 2133|      0|            MP_ERR(in, "Disabling recording.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2134|      0|    }
 2135|       |
 2136|  1.40M|    if (in->recorder) {
  ------------------
  |  Branch (2136:9): [True: 0, False: 1.40M]
  ------------------
 2137|      0|        struct mp_recorder_sink *sink =
 2138|      0|            mp_recorder_get_sink(in->recorder, in->streams[dp->stream]);
 2139|      0|        if (sink) {
  ------------------
  |  Branch (2139:13): [True: 0, False: 0]
  ------------------
 2140|      0|            mp_recorder_feed_packet(sink, dp);
 2141|      0|        } else {
 2142|      0|            MP_ERR(in, "New stream appeared; stopping recording.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2143|      0|            mp_recorder_destroy(in->recorder);
 2144|      0|            in->recorder = NULL;
 2145|      0|        }
 2146|      0|    }
 2147|       |
 2148|  1.40M|    if (in->dumper_status == CONTROL_OK)
  ------------------
  |  |   95|  1.40M|#define CONTROL_OK 1
  ------------------
  |  Branch (2148:9): [True: 0, False: 1.40M]
  ------------------
 2149|      0|        write_dump_packet(in, dp);
 2150|  1.40M|}
demux.c:adjust_seek_range_on_packet:
 2015|  1.41M|{
 2016|  1.41M|    struct demux_queue *queue = ds->queue;
 2017|       |
 2018|  1.41M|    if (!ds->in->seekable_cache)
  ------------------
  |  Branch (2018:9): [True: 0, False: 1.41M]
  ------------------
 2019|      0|        return;
 2020|       |
 2021|  1.41M|    bool new_eof = !dp;
 2022|  1.41M|    bool update_ranges = queue->is_eof != new_eof;
 2023|  1.41M|    queue->is_eof = new_eof;
 2024|       |
 2025|  1.41M|    if (!dp || dp->keyframe) {
  ------------------
  |  Branch (2025:9): [True: 19.7k, False: 1.40M]
  |  Branch (2025:16): [True: 1.31M, False: 87.0k]
  ------------------
 2026|  1.33M|        if (queue->keyframe_latest) {
  ------------------
  |  Branch (2026:13): [True: 1.31M, False: 19.7k]
  ------------------
 2027|  1.31M|            double kf_min, kf_max;
 2028|  1.31M|            compute_keyframe_times(queue->keyframe_latest, &kf_min, &kf_max);
 2029|       |
 2030|  1.31M|            if (kf_min != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.31M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2030:17): [True: 1.30M, False: 3.98k]
  ------------------
 2031|  1.30M|                add_index_entry(queue, queue->keyframe_latest, kf_min);
 2032|       |
 2033|       |                // Initialize the queue's start if it's unset.
 2034|  1.30M|                if (queue->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.30M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2034:21): [True: 10.0k, False: 1.29M]
  ------------------
 2035|  10.0k|                    update_ranges = true;
 2036|  10.0k|                    queue->seek_start = kf_min + ds->sh->seek_preroll;
 2037|       |
 2038|       |                    // queue->is_bof is set optimistically after a seek to start,
 2039|       |                    // assuming demuxing began at the start of the file. That is
 2040|       |                    // wrong for streams opened mid-content, which can happen in
 2041|       |                    // unfinished event HLS playlists, which starts at live-edge,
 2042|       |                    // but the seekable range in the past is still valid.
 2043|  10.0k|                    double start_time = ds->in->d_thread->start_time;
 2044|  10.0k|                    if (queue->is_bof && ds->in->d_thread->seekable &&
  ------------------
  |  Branch (2044:25): [True: 10.0k, False: 0]
  |  Branch (2044:42): [True: 10.0k, False: 0]
  ------------------
 2045|  10.0k|                        start_time != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  20.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2045:25): [True: 10.0k, False: 0]
  ------------------
 2046|  10.0k|                        queue->seek_start > start_time + BOF_START_TOLERANCE)
  ------------------
  |  |  348|  10.0k|#define BOF_START_TOLERANCE 1.0
  ------------------
  |  Branch (2046:25): [True: 23, False: 10.0k]
  ------------------
 2047|     23|                    {
 2048|     23|                        queue->is_bof = false;
 2049|     23|                    }
 2050|  10.0k|                }
 2051|  1.30M|            }
 2052|       |
 2053|  1.31M|            if (kf_max != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  2.62M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2053:17): [True: 1.30M, False: 3.98k]
  ------------------
 2054|  1.30M|                (queue->seek_end == MP_NOPTS_VALUE || kf_max > queue->seek_end))
  ------------------
  |  |   39|  2.61M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2054:18): [True: 10.0k, False: 1.29M]
  |  Branch (2054:55): [True: 1.16M, False: 132k]
  ------------------
 2055|  1.17M|            {
 2056|       |                // If the queue was past the current range's end even before
 2057|       |                // this update, it means _other_ streams are not there yet,
 2058|       |                // and the seek range doesn't need to be updated. This means
 2059|       |                // if the _old_ queue->seek_end was already after the range end,
 2060|       |                // then the new seek_end won't extend the range either.
 2061|  1.17M|                if (queue->range->seek_end == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  2.35M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2061:21): [True: 16.7k, False: 1.16M]
  ------------------
 2062|  1.16M|                    queue->seek_end <= queue->range->seek_end)
  ------------------
  |  Branch (2062:21): [True: 1.16M, False: 0]
  ------------------
 2063|  1.17M|                {
 2064|  1.17M|                    update_ranges = true;
 2065|  1.17M|                }
 2066|       |
 2067|  1.17M|                queue->seek_end = kf_max;
 2068|  1.17M|            }
 2069|  1.31M|        }
 2070|       |
 2071|  1.33M|        queue->keyframe_latest = dp;
 2072|  1.33M|    }
 2073|       |
 2074|       |    // Adding a sparse packet never changes the seek range.
 2075|  1.41M|    if (update_ranges && ds->eager) {
  ------------------
  |  Branch (2075:9): [True: 1.18M, False: 233k]
  |  Branch (2075:26): [True: 1.18M, False: 316]
  ------------------
 2076|  1.18M|        update_seek_ranges(queue->range);
 2077|  1.18M|        attempt_range_joining(ds->in);
 2078|  1.18M|    }
 2079|  1.41M|}
demux.c:add_index_entry:
 1747|  1.30M|{
 1748|  1.30M|    struct demux_internal *in = queue->ds->in;
 1749|       |
 1750|  1.30M|    mp_assert(dp->keyframe && pts != MP_NOPTS_VALUE);
  ------------------
  |  |   41|  1.30M|#define mp_assert assert
  ------------------
  |  Branch (1750:5): [True: 1.30M, False: 0]
  |  Branch (1750:5): [True: 1.30M, False: 0]
  ------------------
 1751|       |
 1752|  1.30M|    if (queue->num_index > 0) {
  ------------------
  |  Branch (1752:9): [True: 1.29M, False: 10.0k]
  ------------------
 1753|  1.29M|        struct index_entry *last = &QUEUE_INDEX_ENTRY(queue, queue->num_index - 1);
  ------------------
  |  |  340|  1.29M|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|  1.29M|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1754|  1.29M|        if (pts - last->pts < INDEX_STEP_SIZE)
  ------------------
  |  |  344|  1.29M|#define INDEX_STEP_SIZE 1.0
  ------------------
  |  Branch (1754:13): [True: 1.27M, False: 26.3k]
  ------------------
 1755|  1.27M|            return;
 1756|  1.29M|    }
 1757|       |
 1758|  36.4k|    if (queue->num_index == queue->index_size) {
  ------------------
  |  Branch (1758:9): [True: 10.1k, False: 26.3k]
  ------------------
 1759|       |        // Needs to honor power-of-2 requirement.
 1760|  10.1k|        size_t new_size = MPMAX(128, queue->index_size * 2);
  ------------------
  |  |   44|  10.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 10.0k, False: 30]
  |  |  ------------------
  ------------------
 1761|  10.1k|        mp_assert(!(new_size & (new_size - 1)));
  ------------------
  |  |   41|  10.1k|#define mp_assert assert
  ------------------
  |  Branch (1761:9): [True: 10.1k, False: 0]
  ------------------
 1762|  10.1k|        MP_DBG(in, "stream %d: resize index to %zu\n", queue->ds->index,
  ------------------
  |  |   93|  10.1k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1763|  10.1k|               new_size);
 1764|       |        // Note: we could tolerate allocation failure, and just discard the
 1765|       |        // entire index (and prevent the index from being recreated).
 1766|  10.1k|        MP_RESIZE_ARRAY(NULL, queue->index, new_size);
  ------------------
  |  |   88|  10.1k|    do {                                                        \
  |  |   89|  10.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  10.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  10.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  10.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  10.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  10.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  10.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 10.1k]
  |  |  ------------------
  ------------------
 1767|  10.1k|        size_t highest_index = queue->index0 + queue->num_index;
 1768|  10.1k|        for (size_t n = queue->index_size; n < highest_index; n++)
  ------------------
  |  Branch (1768:44): [True: 0, False: 10.1k]
  ------------------
 1769|      0|            queue->index[n] = queue->index[n - queue->index_size];
 1770|  10.1k|        in->total_bytes +=
 1771|  10.1k|            (new_size - queue->index_size) * sizeof(queue->index[0]);
 1772|  10.1k|        queue->index_size = new_size;
 1773|  10.1k|    }
 1774|       |
 1775|  36.4k|    mp_assert(queue->num_index < queue->index_size);
  ------------------
  |  |   41|  36.4k|#define mp_assert assert
  ------------------
  |  Branch (1775:5): [True: 36.4k, False: 0]
  ------------------
 1776|       |
 1777|  36.4k|    queue->num_index += 1;
 1778|       |
 1779|  36.4k|    QUEUE_INDEX_ENTRY(queue, queue->num_index - 1) = (struct index_entry){
  ------------------
  |  |  340|  36.4k|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|  36.4k|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1780|  36.4k|        .pts = pts,
 1781|  36.4k|        .pkt = dp,
 1782|  36.4k|    };
 1783|  36.4k|}
demux.c:update_seek_ranges:
  629|  1.25M|{
  630|  1.25M|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  631|  1.25M|    range->is_bof = true;
  632|  1.25M|    range->is_eof = true;
  633|       |
  634|  1.25M|    double min_start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  635|  1.25M|    double max_end_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  636|       |
  637|  2.45M|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (637:21): [True: 1.26M, False: 1.19M]
  ------------------
  638|  1.26M|        struct demux_queue *queue = range->streams[n];
  639|       |
  640|  1.26M|        if (queue->ds->selected && queue->ds->eager) {
  ------------------
  |  Branch (640:13): [True: 1.24M, False: 14.1k]
  |  Branch (640:36): [True: 1.24M, False: 0]
  ------------------
  641|  1.24M|            if (queue->is_bof) {
  ------------------
  |  Branch (641:17): [True: 1.19M, False: 55.7k]
  ------------------
  642|  1.19M|                min_start_pts = MP_PTS_MIN(min_start_pts, queue->seek_start);
  ------------------
  |  |   64|  1.19M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  2.38M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 3, False: 1.19M]
  |  |  |  |  |  Branch (45:23): [True: 1.19M, False: 6]
  |  |  |  |  |  Branch (45:29): [True: 14.5k, False: 1.17M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 3]
  |  |  |  |  |  Branch (45:41): [True: 1.19M, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|  1.19M|            } else {
  644|  55.7k|                range->seek_start =
  645|  55.7k|                    MP_PTS_MAX(range->seek_start, queue->seek_start);
  ------------------
  |  |   65|  55.7k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|   111k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 55.7k]
  |  |  |  |  |  Branch (44:23): [True: 55.7k, False: 1]
  |  |  |  |  |  Branch (44:29): [True: 55.4k, False: 240]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 55.4k, False: 240]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|  55.7k|            }
  647|       |
  648|  1.24M|            if (queue->is_eof) {
  ------------------
  |  Branch (648:17): [True: 21.9k, False: 1.22M]
  ------------------
  649|  21.9k|                max_end_pts = MP_PTS_MAX(max_end_pts, queue->seek_end);
  ------------------
  |  |   65|  21.9k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  43.9k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 1, False: 21.9k]
  |  |  |  |  |  Branch (44:23): [True: 21.9k, False: 5]
  |  |  |  |  |  Branch (44:29): [True: 11.9k, False: 10.0k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 1]
  |  |  |  |  |  Branch (44:41): [True: 11.9k, False: 10.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|  1.22M|            } else {
  651|  1.22M|                range->seek_end = MP_PTS_MIN(range->seek_end, queue->seek_end);
  ------------------
  |  |   64|  1.22M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  2.44M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 1.22M]
  |  |  |  |  |  Branch (45:23): [True: 1.22M, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 58.0k, False: 1.16M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 1.22M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|  1.22M|            }
  653|       |
  654|  1.24M|            range->is_eof &= queue->is_eof;
  655|  1.24M|            range->is_bof &= queue->is_bof;
  656|       |
  657|  1.24M|            bool empty = queue->is_eof && !queue->head;
  ------------------
  |  Branch (657:26): [True: 21.9k, False: 1.22M]
  |  Branch (657:43): [True: 8.15k, False: 13.8k]
  ------------------
  658|  1.24M|            if (queue->seek_start >= queue->seek_end && !empty &&
  ------------------
  |  Branch (658:17): [True: 79.8k, False: 1.16M]
  |  Branch (658:57): [True: 71.6k, False: 8.15k]
  ------------------
  659|  71.6k|                !(queue->seek_start == queue->seek_end &&
  ------------------
  |  Branch (659:19): [True: 71.6k, False: 0]
  ------------------
  660|  71.6k|                  queue->seek_start != MP_NOPTS_VALUE))
  ------------------
  |  |   39|  71.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (660:19): [True: 9.81k, False: 61.8k]
  ------------------
  661|  61.8k|                goto broken;
  662|  1.24M|        }
  663|  1.26M|    }
  664|       |
  665|  1.19M|    if (range->is_eof)
  ------------------
  |  Branch (665:9): [True: 31.2k, False: 1.16M]
  ------------------
  666|  31.2k|        range->seek_end = max_end_pts;
  667|  1.19M|    if (range->is_bof)
  ------------------
  |  Branch (667:9): [True: 1.19M, False: 241]
  ------------------
  668|  1.19M|        range->seek_start = min_start_pts;
  669|       |
  670|       |    // Sparse (subtitle) stream behavior is not very clearly defined, but
  671|       |    // usually we don't want it to restrict the range of other streams. For
  672|       |    // example, if there are subtitle packets at position 5 and 10 seconds, and
  673|       |    // the demuxer demuxed the other streams until position 7 seconds, the seek
  674|       |    // range end position is 7.
  675|       |    // Assume that reading a non-sparse (audio/video) packet gets all sparse
  676|       |    // packets that are needed before that non-sparse packet.
  677|       |    // This is incorrect in any of these cases:
  678|       |    //  - sparse streams only (it's unknown how to determine an accurate range)
  679|       |    //  - if sparse streams have non-keyframe packets (we set queue->last_pruned
  680|       |    //    to the start of the pruned keyframe range - we'd need the end or so)
  681|       |    // We also assume that ds->eager equals to a stream not being sparse
  682|       |    // (usually true, except if only sparse streams are selected).
  683|       |    // We also rely on the fact that the demuxer position will always be ahead
  684|       |    // of the seek_end for audio/video, because they need to prefetch at least
  685|       |    // 1 packet to detect the end of a keyframe range. This means that there's
  686|       |    // a relatively high guarantee to have all sparse (subtitle) packets within
  687|       |    // the seekable range.
  688|       |    // As a consequence, the code _never_ checks queue->seek_end for a sparse
  689|       |    // queue, as the end of it is implied by the highest PTS of a non-sparse
  690|       |    // stream (i.e. the latest demuxer position).
  691|       |    // On the other hand, if a sparse packet was pruned, and that packet has
  692|       |    // a higher PTS than seek_start for non-sparse queues, that packet is
  693|       |    // missing. So the range's seek_start needs to be adjusted accordingly.
  694|  2.38M|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (694:21): [True: 1.19M, False: 1.19M]
  ------------------
  695|  1.19M|        struct demux_queue *queue = range->streams[n];
  696|  1.19M|        if (queue->ds->selected && !queue->ds->eager &&
  ------------------
  |  Branch (696:13): [True: 1.18M, False: 11.5k]
  |  Branch (696:36): [True: 0, False: 1.18M]
  ------------------
  697|      0|            queue->last_pruned != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  1.19M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (697:13): [True: 0, False: 0]
  ------------------
  698|      0|            range->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (698:13): [True: 0, False: 0]
  ------------------
  699|      0|        {
  700|       |            // (last_pruned is _exclusive_ to the seekable range, so add a small
  701|       |            // value to exclude it from the valid range.)
  702|      0|            range->seek_start =
  703|      0|                MP_PTS_MAX(range->seek_start, queue->last_pruned + 0.1);
  ------------------
  |  |   65|      0|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  704|      0|        }
  705|  1.19M|    }
  706|       |
  707|  1.19M|    if (range->seek_start >= range->seek_end && !(range->is_bof && range->is_eof))
  ------------------
  |  Branch (707:9): [True: 31.0k, False: 1.16M]
  |  Branch (707:51): [True: 30.9k, False: 24]
  |  Branch (707:68): [True: 24.3k, False: 6.64k]
  ------------------
  708|  6.66k|        goto broken;
  709|       |
  710|  1.19M|    prune_metadata(range);
  711|  1.19M|    return;
  712|       |
  713|  68.5k|broken:
  714|  68.5k|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  68.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  715|  68.5k|    prune_metadata(range);
  716|  68.5k|}
demux.c:prune_metadata:
  603|  1.25M|{
  604|  1.25M|    int first_needed = 0;
  605|       |
  606|  1.25M|    if (range->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (606:9): [True: 89.7k, False: 1.17M]
  ------------------
  607|  89.7k|        first_needed = range->num_metadata;
  608|  1.17M|    } else {
  609|  1.17M|        for (int n = 0; n < range->num_metadata ; n++) {
  ------------------
  |  Branch (609:25): [True: 0, False: 1.17M]
  ------------------
  610|      0|            if (range->metadata[n]->pts > range->seek_start)
  ------------------
  |  Branch (610:17): [True: 0, False: 0]
  ------------------
  611|      0|                break;
  612|      0|            first_needed = n;
  613|      0|        }
  614|  1.17M|    }
  615|       |
  616|       |    // Always preserve the last entry.
  617|  1.25M|    first_needed = MPMIN(first_needed, range->num_metadata - 1);
  ------------------
  |  |   45|  1.25M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 1.25M, False: 0]
  |  |  ------------------
  ------------------
  618|       |
  619|       |    // (Could make this significantly more efficient for large first_needed,
  620|       |    // however that might be very rare and even then it might not matter.)
  621|  1.25M|    for (int n = 0; n < first_needed; n++) {
  ------------------
  |  Branch (621:21): [True: 0, False: 1.25M]
  ------------------
  622|      0|        talloc_free(range->metadata[0]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  623|       |        MP_TARRAY_REMOVE_AT(range->metadata, range->num_metadata, 0);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (623:9): [True: 0, False: 0]
  ------------------
  624|      0|    }
  625|  1.25M|}
demux.c:attempt_range_joining:
 1788|  1.18M|{
 1789|  1.18M|    struct demux_cached_range *current = in->current_range;
 1790|  1.18M|    struct demux_cached_range *next = NULL;
 1791|  1.18M|    double next_dist = INFINITY;
 1792|       |
 1793|  1.18M|    mp_assert(current && in->num_ranges > 0);
  ------------------
  |  |   41|  1.18M|#define mp_assert assert
  ------------------
  |  Branch (1793:5): [True: 1.18M, False: 0]
  |  Branch (1793:5): [True: 1.18M, False: 0]
  ------------------
 1794|  1.18M|    mp_assert(current == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|  1.18M|#define mp_assert assert
  ------------------
  |  Branch (1794:5): [True: 1.18M, False: 0]
  ------------------
 1795|       |
 1796|  1.18M|    for (int n = 0; n < in->num_ranges - 1; n++) {
  ------------------
  |  Branch (1796:21): [True: 0, False: 1.18M]
  ------------------
 1797|      0|        struct demux_cached_range *range = in->ranges[n];
 1798|       |
 1799|      0|        if (current->seek_start <= range->seek_start) {
  ------------------
  |  Branch (1799:13): [True: 0, False: 0]
  ------------------
 1800|       |            // This uses ">" to get some non-0 overlap.
 1801|      0|            double dist = current->seek_end - range->seek_start;
 1802|      0|            if (dist > 0 && dist < next_dist) {
  ------------------
  |  Branch (1802:17): [True: 0, False: 0]
  |  Branch (1802:29): [True: 0, False: 0]
  ------------------
 1803|      0|                next = range;
 1804|      0|                next_dist = dist;
 1805|      0|            }
 1806|      0|        }
 1807|      0|    }
 1808|       |
 1809|  1.18M|    if (!next)
  ------------------
  |  Branch (1809:9): [True: 1.18M, False: 0]
  ------------------
 1810|  1.18M|        return;
 1811|       |
 1812|      0|    MP_VERBOSE(in, "going to join ranges %f-%f + %f-%f\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1813|      0|               current->seek_start, current->seek_end,
 1814|      0|               next->seek_start, next->seek_end);
 1815|       |
 1816|       |    // Try to find a join point, where packets obviously overlap. (It would be
 1817|       |    // better and faster to do this incrementally, but probably too complex.)
 1818|       |    // The current range can overlap arbitrarily with the next one, not only by
 1819|       |    // the seek overlap, but for arbitrary packet readahead as well.
 1820|       |    // We also drop the overlapping packets (if joining fails, we discard the
 1821|       |    // entire next range anyway, so this does no harm).
 1822|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1822:21): [True: 0, False: 0]
  ------------------
 1823|      0|        struct demux_stream *ds = in->streams[n]->ds;
 1824|       |
 1825|      0|        struct demux_queue *q1 = current->streams[n];
 1826|      0|        struct demux_queue *q2 = next->streams[n];
 1827|       |
 1828|      0|        if (!ds->global_correct_pos && !ds->global_correct_dts) {
  ------------------
  |  Branch (1828:13): [True: 0, False: 0]
  |  Branch (1828:40): [True: 0, False: 0]
  ------------------
 1829|      0|            MP_WARN(in, "stream %d: ranges unjoinable\n", n);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1830|      0|            goto failed;
 1831|      0|        }
 1832|       |
 1833|      0|        struct demux_packet *end = q1->tail;
 1834|      0|        bool join_point_found = !end; // no packets yet -> joining will work
 1835|      0|        if (end) {
  ------------------
  |  Branch (1835:13): [True: 0, False: 0]
  ------------------
 1836|      0|            while (q2->head) {
  ------------------
  |  Branch (1836:20): [True: 0, False: 0]
  ------------------
 1837|      0|                struct demux_packet *dp = q2->head;
 1838|       |
 1839|       |                // Some weird corner-case. We'd have to search the equivalent
 1840|       |                // packet in q1 to update it correctly. Better just give up.
 1841|      0|                if (dp == q2->keyframe_latest) {
  ------------------
  |  Branch (1841:21): [True: 0, False: 0]
  ------------------
 1842|      0|                    MP_VERBOSE(in, "stream %d: not enough keyframes for join\n", n);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1843|      0|                    goto failed;
 1844|      0|                }
 1845|       |
 1846|      0|                if ((ds->global_correct_dts && dp->dts == end->dts) ||
  ------------------
  |  Branch (1846:22): [True: 0, False: 0]
  |  Branch (1846:48): [True: 0, False: 0]
  ------------------
 1847|      0|                    (ds->global_correct_pos && dp->pos == end->pos))
  ------------------
  |  Branch (1847:22): [True: 0, False: 0]
  |  Branch (1847:48): [True: 0, False: 0]
  ------------------
 1848|      0|                {
 1849|       |                    // Do some additional checks as a (imperfect) sanity check
 1850|       |                    // in case pos/dts are not "correct" across the ranges (we
 1851|       |                    // never actually check that).
 1852|      0|                    if (dp->dts != end->dts || dp->pos != end->pos ||
  ------------------
  |  Branch (1852:25): [True: 0, False: 0]
  |  Branch (1852:48): [True: 0, False: 0]
  ------------------
 1853|      0|                        dp->pts != end->pts)
  ------------------
  |  Branch (1853:25): [True: 0, False: 0]
  ------------------
 1854|      0|                    {
 1855|      0|                        MP_WARN(in,
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1856|      0|                            "stream %d: non-repeatable demuxer behavior\n", n);
 1857|      0|                        goto failed;
 1858|      0|                    }
 1859|       |
 1860|      0|                    remove_head_packet(q2);
 1861|      0|                    join_point_found = true;
 1862|      0|                    break;
 1863|      0|                }
 1864|       |
 1865|       |                // This happens if the next range misses the end packet. For
 1866|       |                // normal streams (ds->eager==true), this is a failure to find
 1867|       |                // an overlap. For subtitles, this can mean the current_range
 1868|       |                // has a subtitle somewhere before the end of its range, and
 1869|       |                // next has another subtitle somewhere after the start of its
 1870|       |                // range.
 1871|      0|                if ((ds->global_correct_dts && dp->dts > end->dts) ||
  ------------------
  |  Branch (1871:22): [True: 0, False: 0]
  |  Branch (1871:48): [True: 0, False: 0]
  ------------------
 1872|      0|                    (ds->global_correct_pos && dp->pos > end->pos))
  ------------------
  |  Branch (1872:22): [True: 0, False: 0]
  |  Branch (1872:48): [True: 0, False: 0]
  ------------------
 1873|      0|                    break;
 1874|       |
 1875|      0|                remove_head_packet(q2);
 1876|      0|            }
 1877|      0|        }
 1878|       |
 1879|       |        // For enabled non-sparse streams, always require an overlap packet.
 1880|      0|        if (ds->eager && !join_point_found) {
  ------------------
  |  Branch (1880:13): [True: 0, False: 0]
  |  Branch (1880:26): [True: 0, False: 0]
  ------------------
 1881|      0|            MP_WARN(in, "stream %d: no join point found\n", n);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1882|      0|            goto failed;
 1883|      0|        }
 1884|      0|    }
 1885|       |
 1886|       |    // Actually join the ranges. Now that we think it will work, mutate the
 1887|       |    // data associated with the current range.
 1888|       |
 1889|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1889:21): [True: 0, False: 0]
  ------------------
 1890|      0|        struct demux_queue *q1 = current->streams[n];
 1891|      0|        struct demux_queue *q2 = next->streams[n];
 1892|       |
 1893|      0|        struct demux_stream *ds = in->streams[n]->ds;
 1894|      0|        mp_assert(ds->queue == q1);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1894:9): [True: 0, False: 0]
  ------------------
 1895|       |
 1896|       |        // First new packet that is appended to the current range.
 1897|      0|        struct demux_packet *join_point = q2->head;
 1898|       |
 1899|      0|        if (q2->head) {
  ------------------
  |  Branch (1899:13): [True: 0, False: 0]
  ------------------
 1900|      0|            if (q1->head) {
  ------------------
  |  Branch (1900:17): [True: 0, False: 0]
  ------------------
 1901|      0|                q1->tail->next = q2->head;
 1902|      0|            } else {
 1903|      0|                q1->head = q2->head;
 1904|      0|            }
 1905|      0|            q1->tail = q2->tail;
 1906|      0|        }
 1907|       |
 1908|      0|        q1->seek_end = q2->seek_end;
 1909|      0|        q1->correct_dts &= q2->correct_dts;
 1910|      0|        q1->correct_pos &= q2->correct_pos;
 1911|      0|        q1->last_pos = q2->last_pos;
 1912|      0|        q1->last_dts = q2->last_dts;
 1913|      0|        q1->last_ts = q2->last_ts;
 1914|      0|        q1->keyframe_latest = q2->keyframe_latest;
 1915|      0|        q1->is_eof = q2->is_eof;
 1916|       |
 1917|      0|        q1->last_pos_fixup = -1;
 1918|       |
 1919|      0|        q2->head = q2->tail = NULL;
 1920|      0|        q2->keyframe_first = NULL;
 1921|      0|        q2->keyframe_latest = NULL;
 1922|       |
 1923|      0|        if (ds->selected && !ds->reader_head)
  ------------------
  |  Branch (1923:13): [True: 0, False: 0]
  |  Branch (1923:29): [True: 0, False: 0]
  ------------------
 1924|      0|            ds->reader_head = join_point;
 1925|      0|        ds->skip_to_keyframe = false;
 1926|       |
 1927|       |        // Make the cum_pos values in all q2 packets continuous.
 1928|      0|        for (struct demux_packet *dp = join_point; dp; dp = dp->next) {
  ------------------
  |  Branch (1928:52): [True: 0, False: 0]
  ------------------
 1929|      0|            uint64_t next_pos = dp->next ? dp->next->cum_pos : q2->tail_cum_pos;
  ------------------
  |  Branch (1929:33): [True: 0, False: 0]
  ------------------
 1930|      0|            uint64_t size = next_pos - dp->cum_pos;
 1931|      0|            dp->cum_pos = q1->tail_cum_pos;
 1932|      0|            q1->tail_cum_pos += size;
 1933|      0|        }
 1934|       |
 1935|       |        // And update the index with packets from q2.
 1936|      0|        for (size_t i = 0; i < q2->num_index; i++) {
  ------------------
  |  Branch (1936:28): [True: 0, False: 0]
  ------------------
 1937|      0|            struct index_entry *e = &QUEUE_INDEX_ENTRY(q2, i);
  ------------------
  |  |  340|      0|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|      0|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1938|      0|            add_index_entry(q1, e->pkt, e->pts);
 1939|      0|        }
 1940|      0|        free_index(q2);
 1941|       |
 1942|       |        // For moving demuxer position.
 1943|      0|        ds->refreshing = ds->selected;
 1944|      0|    }
 1945|       |
 1946|      0|    for (int n = 0; n < next->num_metadata; n++) {
  ------------------
  |  Branch (1946:21): [True: 0, False: 0]
  ------------------
 1947|      0|        MP_TARRAY_APPEND(current, current->metadata, current->num_metadata,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1948|      0|                         next->metadata[n]);
 1949|      0|    }
 1950|      0|    next->num_metadata = 0;
 1951|       |
 1952|      0|    update_seek_ranges(current);
 1953|       |
 1954|       |    // Move demuxing position to after the current range.
 1955|      0|    in->seeking = true;
 1956|      0|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|      0|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 1957|      0|    in->seek_pts = next->seek_end - 1.0;
 1958|       |
 1959|      0|    MP_VERBOSE(in, "ranges joined!\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1960|       |
 1961|      0|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1961:21): [True: 0, False: 0]
  ------------------
 1962|      0|        back_demux_see_packets(in->streams[n]->ds);
 1963|       |
 1964|      0|failed:
 1965|      0|    clear_cached_range(in, next);
 1966|      0|    free_empty_cached_ranges(in);
 1967|      0|}
demux.c:prune_old_packets:
 2465|  2.80M|{
 2466|  2.80M|    mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|  2.80M|#define mp_assert assert
  ------------------
  |  Branch (2466:5): [True: 2.80M, False: 0]
  ------------------
 2467|       |
 2468|       |    // It's not clear what the ideal way to prune old packets is. For now, we
 2469|       |    // prune the oldest packet runs, as long as the total cache amount is too
 2470|       |    // big.
 2471|  2.80M|    while (1) {
  ------------------
  |  Branch (2471:12): [True: 2.80M, Folded]
  ------------------
 2472|  2.80M|        uint64_t fw_bytes = 0;
 2473|  5.61M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2473:25): [True: 2.81M, False: 2.80M]
  ------------------
 2474|  2.81M|            struct demux_stream *ds = in->streams[n]->ds;
 2475|  2.81M|            fw_bytes += get_forward_buffered_bytes(ds);
 2476|  2.81M|        }
 2477|  2.80M|        uint64_t max_avail = in->max_bytes_bw;
 2478|       |        // Backward cache (if enabled at all) can use unused forward cache.
 2479|       |        // Still leave 1 byte free, so the read_packet logic doesn't get stuck.
 2480|  2.80M|        if (max_avail && in->max_bytes > (fw_bytes + 1) && in->d_user->opts->donate_fw)
  ------------------
  |  Branch (2480:13): [True: 2.80M, False: 16]
  |  Branch (2480:26): [True: 2.80M, False: 0]
  |  Branch (2480:60): [True: 2.80M, False: 0]
  ------------------
 2481|  2.80M|            max_avail += in->max_bytes - (fw_bytes + 1);
 2482|  2.80M|        if (in->total_bytes - fw_bytes <= max_avail)
  ------------------
  |  Branch (2482:13): [True: 2.80M, False: 0]
  ------------------
 2483|  2.80M|            break;
 2484|       |
 2485|       |        // (Start from least recently used range.)
 2486|      0|        struct demux_cached_range *range = in->ranges[0];
 2487|      0|        double earliest_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2488|      0|        struct demux_stream *earliest_stream = NULL;
 2489|       |
 2490|      0|        for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (2490:25): [True: 0, False: 0]
  ------------------
 2491|      0|            struct demux_queue *queue = range->streams[n];
 2492|      0|            struct demux_stream *ds = queue->ds;
 2493|       |
 2494|      0|            if (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2494:17): [True: 0, False: 0]
  |  Branch (2494:32): [True: 0, False: 0]
  ------------------
 2495|      0|                struct demux_packet *dp = queue->head;
 2496|      0|                double ts = queue->seek_start;
 2497|       |                // If the ts is NOPTS, the queue has no retainable packets, so
 2498|       |                // delete them all. This code is not run when there's enough
 2499|       |                // free space, so normally the queue gets the chance to build up.
 2500|      0|                bool prune_always =
 2501|      0|                    !in->seekable_cache || ts == MP_NOPTS_VALUE || !dp->keyframe;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2501:21): [True: 0, False: 0]
  |  Branch (2501:44): [True: 0, False: 0]
  |  Branch (2501:68): [True: 0, False: 0]
  ------------------
 2502|      0|                if (prune_always || !earliest_stream || ts < earliest_ts) {
  ------------------
  |  Branch (2502:21): [True: 0, False: 0]
  |  Branch (2502:37): [True: 0, False: 0]
  |  Branch (2502:57): [True: 0, False: 0]
  ------------------
 2503|      0|                    earliest_ts = ts;
 2504|      0|                    earliest_stream = ds;
 2505|      0|                    if (prune_always)
  ------------------
  |  Branch (2505:25): [True: 0, False: 0]
  ------------------
 2506|      0|                        break;
 2507|      0|                }
 2508|      0|            }
 2509|      0|        }
 2510|       |
 2511|       |        // In some cases (like when the seek index became huge), there aren't
 2512|       |        // any backwards packets, even if the total cache size is exceeded.
 2513|      0|        if (!earliest_stream)
  ------------------
  |  Branch (2513:13): [True: 0, False: 0]
  ------------------
 2514|      0|            break;
 2515|       |
 2516|      0|        struct demux_stream *ds = earliest_stream;
 2517|      0|        struct demux_queue *queue = range->streams[ds->index];
 2518|       |
 2519|      0|        bool non_kf_prune = queue->head && !queue->head->keyframe;
  ------------------
  |  Branch (2519:29): [True: 0, False: 0]
  |  Branch (2519:44): [True: 0, False: 0]
  ------------------
 2520|      0|        bool kf_was_pruned = false;
 2521|       |
 2522|      0|        while (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2522:16): [True: 0, False: 0]
  |  Branch (2522:31): [True: 0, False: 0]
  ------------------
 2523|      0|            if (queue->head->keyframe) {
  ------------------
  |  Branch (2523:17): [True: 0, False: 0]
  ------------------
 2524|       |                // If the cache is seekable, only delete until up the next
 2525|       |                // keyframe. This is not always efficient, but ensures we
 2526|       |                // prune all streams fairly.
 2527|       |                // Also, if the first packet was _not_ a keyframe, we want it
 2528|       |                // to remove all preceding non-keyframe packets first, before
 2529|       |                // re-evaluating what to prune next.
 2530|      0|                if ((kf_was_pruned || non_kf_prune) && in->seekable_cache)
  ------------------
  |  Branch (2530:22): [True: 0, False: 0]
  |  Branch (2530:39): [True: 0, False: 0]
  |  Branch (2530:56): [True: 0, False: 0]
  ------------------
 2531|      0|                    break;
 2532|      0|                kf_was_pruned = true;
 2533|      0|            }
 2534|       |
 2535|      0|            remove_head_packet(queue);
 2536|      0|        }
 2537|       |
 2538|       |        // Need to update the seekable time range.
 2539|      0|        if (kf_was_pruned) {
  ------------------
  |  Branch (2539:13): [True: 0, False: 0]
  ------------------
 2540|      0|            mp_assert(!queue->keyframe_first); // it was just deleted, supposedly
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2540:13): [True: 0, False: 0]
  ------------------
 2541|       |
 2542|      0|            queue->keyframe_first = queue->head;
 2543|       |            // (May happen if reader_head stopped pruning the range, and there's
 2544|       |            // no next range.)
 2545|      0|            while (queue->keyframe_first && !queue->keyframe_first->keyframe)
  ------------------
  |  Branch (2545:20): [True: 0, False: 0]
  |  Branch (2545:45): [True: 0, False: 0]
  ------------------
 2546|      0|                queue->keyframe_first = queue->keyframe_first->next;
 2547|       |
 2548|      0|            if (queue->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2548:17): [True: 0, False: 0]
  ------------------
 2549|      0|                queue->last_pruned = queue->seek_start;
 2550|       |
 2551|      0|            double kf_min;
 2552|      0|            compute_keyframe_times(queue->keyframe_first, &kf_min, NULL);
 2553|       |
 2554|      0|            bool update_range = true;
 2555|       |
 2556|      0|            queue->seek_start = kf_min;
 2557|       |
 2558|      0|            if (queue->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2558:17): [True: 0, False: 0]
  ------------------
 2559|      0|                queue->seek_start += ds->sh->seek_preroll;
 2560|       |
 2561|       |                // Don't need to update if the new start is still before the
 2562|       |                // range's start (or if the range was undefined anyway).
 2563|      0|                if (range->seek_start == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2563:21): [True: 0, False: 0]
  ------------------
 2564|      0|                    queue->seek_start <= range->seek_start)
  ------------------
  |  Branch (2564:21): [True: 0, False: 0]
  ------------------
 2565|      0|                {
 2566|      0|                    update_range = false;
 2567|      0|                }
 2568|      0|            }
 2569|       |
 2570|      0|            if (update_range)
  ------------------
  |  Branch (2570:17): [True: 0, False: 0]
  ------------------
 2571|      0|                update_seek_ranges(range);
 2572|      0|        }
 2573|       |
 2574|      0|        if (range != in->current_range && range->seek_start == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2574:13): [True: 0, False: 0]
  |  Branch (2574:43): [True: 0, False: 0]
  ------------------
 2575|      0|            free_empty_cached_ranges(in);
 2576|      0|    }
 2577|  2.80M|}
demux.c:back_demux_see_packets:
 1713|  1.41M|{
 1714|  1.41M|    struct demux_internal *in = ds->in;
 1715|       |
 1716|  1.41M|    if (!ds->selected || !in->back_demuxing || !ds->eager)
  ------------------
  |  Branch (1716:9): [True: 316, False: 1.41M]
  |  Branch (1716:26): [True: 1.41M, False: 0]
  |  Branch (1716:48): [True: 0, False: 0]
  ------------------
 1717|  1.41M|        return;
 1718|       |
 1719|      0|    mp_assert(!(ds->back_resuming && ds->back_restarting));
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1719:5): [True: 0, False: 0]
  |  Branch (1719:5): [True: 0, False: 0]
  ------------------
 1720|       |
 1721|      0|    if (!ds->global_correct_dts && !ds->global_correct_pos) {
  ------------------
  |  Branch (1721:9): [True: 0, False: 0]
  |  Branch (1721:36): [True: 0, False: 0]
  ------------------
 1722|      0|        MP_ERR(in, "Can't demux backward due to demuxer problems.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1723|      0|        error_on_backward_demuxing(in);
 1724|      0|        return;
 1725|      0|    }
 1726|       |
 1727|      0|    while (ds->back_resuming && ds->reader_head) {
  ------------------
  |  Branch (1727:12): [True: 0, False: 0]
  |  Branch (1727:33): [True: 0, False: 0]
  ------------------
 1728|      0|        struct demux_packet *head = ds->reader_head;
 1729|      0|        if ((ds->global_correct_dts && head->dts == ds->back_resume_dts) ||
  ------------------
  |  Branch (1729:14): [True: 0, False: 0]
  |  Branch (1729:40): [True: 0, False: 0]
  ------------------
 1730|      0|            (ds->global_correct_pos && head->pos == ds->back_resume_pos))
  ------------------
  |  Branch (1730:14): [True: 0, False: 0]
  |  Branch (1730:40): [True: 0, False: 0]
  ------------------
 1731|      0|        {
 1732|      0|            ds->back_resuming = false;
 1733|      0|            ds->need_wakeup = true;
 1734|      0|            wakeup_ds(ds); // probably
 1735|      0|            break;
 1736|      0|        }
 1737|      0|        advance_reader_head(ds);
 1738|      0|    }
 1739|       |
 1740|      0|    if (ds->back_restarting)
  ------------------
  |  Branch (1740:9): [True: 0, False: 0]
  ------------------
 1741|      0|        find_backward_restart_pos(ds);
 1742|      0|}
demux.c:advance_reader_head:
 2778|  1.37M|{
 2779|  1.37M|    struct demux_packet *pkt = ds->reader_head;
 2780|  1.37M|    if (!pkt)
  ------------------
  |  Branch (2780:9): [True: 0, False: 1.37M]
  ------------------
 2781|      0|        return NULL;
 2782|       |
 2783|  1.37M|    ds->reader_head = pkt->next;
 2784|       |
 2785|  1.37M|    ds->last_ret_pos = pkt->pos;
 2786|  1.37M|    ds->last_ret_dts = pkt->dts;
 2787|       |
 2788|  1.37M|    return pkt;
 2789|  1.37M|}
demux.c:ds_clear_reader_state:
  842|  72.4k|{
  843|  72.4k|    ds_clear_reader_queue_state(ds);
  844|       |
  845|  72.4k|    ds->base_ts = ds->last_br_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  846|  72.4k|    ds->last_br_bytes = 0;
  847|  72.4k|    ds->bitrate = -1;
  848|  72.4k|    ds->skip_to_keyframe = false;
  849|  72.4k|    ds->attached_picture_added = false;
  850|  72.4k|    ds->lazy_eof = false;
  851|  72.4k|    ds->last_ret_pos = -1;
  852|  72.4k|    ds->last_ret_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  853|  72.4k|    ds->force_read_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  854|       |
  855|  72.4k|    if (clear_back_state) {
  ------------------
  |  Branch (855:9): [True: 72.4k, False: 0]
  ------------------
  856|  72.4k|        ds->back_restart_pos = -1;
  857|  72.4k|        ds->back_restart_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  858|  72.4k|        ds->back_restart_eof = false;
  859|  72.4k|        ds->back_restart_next = ds->in->back_demuxing;
  860|  72.4k|        ds->back_restarting = ds->in->back_demuxing && ds->eager;
  ------------------
  |  Branch (860:31): [True: 0, False: 72.4k]
  |  Branch (860:56): [True: 0, False: 0]
  ------------------
  861|  72.4k|        ds->back_seek_pos = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  862|  72.4k|        ds->back_resume_pos = -1;
  863|  72.4k|        ds->back_resume_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  72.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  864|  72.4k|        ds->back_resuming = false;
  865|       |        ds->back_range_started = false;
  866|  72.4k|        ds->back_range_count = 0;
  867|  72.4k|        ds->back_range_preroll = 0;
  868|  72.4k|    }
  869|  72.4k|}
demux.c:ds_clear_reader_queue_state:
  834|  72.4k|{
  835|  72.4k|    ds->reader_head = NULL;
  836|  72.4k|    ds->eof = false;
  837|       |    ds->need_wakeup = true;
  838|  72.4k|}
demux.c:demux_thread:
 2747|  19.9k|{
 2748|  19.9k|    struct demux_internal *in = pctx;
 2749|  19.9k|    mp_thread_set_name("demux");
 2750|  19.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2751|       |
 2752|  19.9k|    stats_register_thread_cputime(in->stats, "thread");
 2753|       |
 2754|  1.64M|    while (!in->thread_terminate) {
  ------------------
  |  Branch (2754:12): [True: 1.62M, False: 19.9k]
  ------------------
 2755|  1.62M|        if (thread_work(in))
  ------------------
  |  Branch (2755:13): [True: 1.56M, False: 59.8k]
  ------------------
 2756|  1.56M|            continue;
 2757|  59.8k|        mp_cond_signal(&in->wakeup);
 2758|  59.8k|        mp_cond_timedwait_until(&in->wakeup, &in->lock, in->next_cache_update);
 2759|  59.8k|    }
 2760|       |
 2761|  19.9k|    if (in->shutdown_async) {
  ------------------
  |  Branch (2761:9): [True: 19.9k, False: 0]
  ------------------
 2762|  19.9k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2763|  19.9k|        demux_shutdown(in);
 2764|  19.9k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2765|  19.9k|        in->shutdown_async = false;
 2766|  19.9k|        if (in->wakeup_cb)
  ------------------
  |  Branch (2766:13): [True: 19.9k, False: 0]
  ------------------
 2767|  19.9k|            in->wakeup_cb(in->wakeup_cb_ctx);
 2768|  19.9k|    }
 2769|       |
 2770|  19.9k|    stats_unregister_thread(in->stats, "thread");
 2771|       |
 2772|  19.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2773|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  19.9k|#define MP_THREAD_RETURN() return NULL
  ------------------
 2774|  19.9k|}
demux.c:dequeue_packet:
 2823|  1.42M|{
 2824|  1.42M|    struct demux_internal *in = ds->in;
 2825|       |
 2826|  1.42M|    if (!ds->selected)
  ------------------
  |  Branch (2826:9): [True: 0, False: 1.42M]
  ------------------
 2827|      0|        return -1;
 2828|  1.42M|    if (in->blocked)
  ------------------
  |  Branch (2828:9): [True: 0, False: 1.42M]
  ------------------
 2829|      0|        return 0;
 2830|       |
 2831|  1.42M|    if (ds->sh->attached_picture) {
  ------------------
  |  Branch (2831:9): [True: 0, False: 1.42M]
  ------------------
 2832|      0|        ds->eof = true;
 2833|      0|        if (ds->attached_picture_added)
  ------------------
  |  Branch (2833:13): [True: 0, False: 0]
  ------------------
 2834|      0|            return -1;
 2835|      0|        ds->attached_picture_added = true;
 2836|      0|        struct demux_packet *pkt = demux_copy_packet(in->packet_pool,
 2837|      0|                                                     ds->sh->attached_picture);
 2838|      0|        MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2839|      0|        pkt->stream = ds->sh->index;
 2840|      0|        *res = pkt;
 2841|      0|        return 1;
 2842|      0|    }
 2843|       |
 2844|  1.42M|    if (!in->reading && !in->eof) {
  ------------------
  |  Branch (2844:9): [True: 1.11M, False: 307k]
  |  Branch (2844:25): [True: 20.6k, False: 1.09M]
  ------------------
 2845|  20.6k|        in->reading = true; // enable demuxer thread prefetching
 2846|  20.6k|        mp_cond_signal(&in->wakeup);
 2847|  20.6k|    }
 2848|       |
 2849|  1.42M|    ds->force_read_until = min_pts;
 2850|       |
 2851|  1.42M|    if (ds->back_resuming || ds->back_restarting) {
  ------------------
  |  Branch (2851:9): [True: 0, False: 1.42M]
  |  Branch (2851:30): [True: 0, False: 1.42M]
  ------------------
 2852|      0|        mp_assert(in->back_demuxing);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2852:9): [True: 0, False: 0]
  ------------------
 2853|      0|        return 0;
 2854|      0|    }
 2855|       |
 2856|  1.42M|    bool eof = !ds->reader_head && ds->eof;
  ------------------
  |  Branch (2856:16): [True: 43.7k, False: 1.37M]
  |  Branch (2856:36): [True: 19.2k, False: 24.4k]
  ------------------
 2857|       |
 2858|  1.42M|    if (in->back_demuxing) {
  ------------------
  |  Branch (2858:9): [True: 0, False: 1.42M]
  ------------------
 2859|       |        // Subtitles not supported => EOF.
 2860|      0|        if (!ds->eager)
  ------------------
  |  Branch (2860:13): [True: 0, False: 0]
  ------------------
 2861|      0|            return -1;
 2862|       |
 2863|       |        // Next keyframe (or EOF) was reached => step back.
 2864|      0|        if (ds->back_range_started && !ds->back_range_count &&
  ------------------
  |  Branch (2864:13): [True: 0, False: 0]
  |  Branch (2864:39): [True: 0, False: 0]
  ------------------
 2865|      0|            ((ds->reader_head && ds->reader_head->keyframe) || eof))
  ------------------
  |  Branch (2865:15): [True: 0, False: 0]
  |  Branch (2865:34): [True: 0, False: 0]
  |  Branch (2865:64): [True: 0, False: 0]
  ------------------
 2866|      0|        {
 2867|      0|            ds->back_restarting = true;
 2868|      0|            ds->back_restart_eof = false;
 2869|      0|            ds->back_restart_next = false;
 2870|       |
 2871|      0|            find_backward_restart_pos(ds);
 2872|       |
 2873|      0|            if (ds->back_restarting)
  ------------------
  |  Branch (2873:17): [True: 0, False: 0]
  ------------------
 2874|      0|                return 0;
 2875|      0|        }
 2876|       |
 2877|      0|        eof = ds->back_range_count < 0;
 2878|      0|    }
 2879|       |
 2880|  1.42M|    ds->need_wakeup = !ds->reader_head;
 2881|  1.42M|    if (!ds->reader_head || eof) {
  ------------------
  |  Branch (2881:9): [True: 43.7k, False: 1.37M]
  |  Branch (2881:29): [True: 0, False: 1.37M]
  ------------------
 2882|  43.7k|        if (!ds->eager) {
  ------------------
  |  Branch (2882:13): [True: 0, False: 43.7k]
  ------------------
 2883|       |            // Non-eager streams temporarily return EOF. If they returned 0,
 2884|       |            // the reader would have to wait for new packets, which does not
 2885|       |            // make sense due to the sparseness and passiveness of non-eager
 2886|       |            // streams.
 2887|       |            // Unless the min_pts feature is used: then EOF is only signaled
 2888|       |            // if read-ahead went above min_pts.
 2889|      0|            if (!lazy_stream_needs_wait(ds))
  ------------------
  |  Branch (2889:17): [True: 0, False: 0]
  ------------------
 2890|      0|                ds->eof = eof = true;
 2891|      0|        }
 2892|       |        // Non-eager streams and streams starved by a queue overflow get EOF
 2893|       |        // while the demuxer can still read. Backward demuxing signals BOF
 2894|       |        // this way, which is final.
 2895|  43.7k|        if (eof)
  ------------------
  |  Branch (2895:13): [True: 19.2k, False: 24.4k]
  ------------------
 2896|  19.2k|            ds->lazy_eof = !in->eof && !in->back_demuxing;
  ------------------
  |  Branch (2896:28): [True: 0, False: 19.2k]
  |  Branch (2896:40): [True: 0, False: 0]
  ------------------
 2897|  43.7k|        return eof ? -1 : 0;
  ------------------
  |  Branch (2897:16): [True: 19.2k, False: 24.4k]
  ------------------
 2898|  43.7k|    }
 2899|       |
 2900|  1.37M|    struct demux_packet *pkt = advance_reader_head(ds);
 2901|  1.37M|    mp_assert(pkt);
  ------------------
  |  |   41|  1.37M|#define mp_assert assert
  ------------------
  |  Branch (2901:5): [True: 1.37M, False: 0]
  ------------------
 2902|  1.37M|    pkt = read_packet_from_cache(in, pkt);
 2903|  1.37M|    if (!pkt)
  ------------------
  |  Branch (2903:9): [True: 0, False: 1.37M]
  ------------------
 2904|      0|        return 0;
 2905|  1.37M|    ds->lazy_eof = false;
 2906|       |
 2907|  1.37M|    if (in->back_demuxing) {
  ------------------
  |  Branch (2907:9): [True: 0, False: 1.37M]
  ------------------
 2908|      0|        if (pkt->keyframe) {
  ------------------
  |  Branch (2908:13): [True: 0, False: 0]
  ------------------
 2909|      0|            mp_assert(ds->back_range_count > 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2909:13): [True: 0, False: 0]
  ------------------
 2910|      0|            ds->back_range_count -= 1;
 2911|      0|            if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2911:17): [True: 0, False: 0]
  ------------------
 2912|      0|                ds->back_range_preroll -= 1;
 2913|      0|        }
 2914|       |
 2915|      0|        if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2915:13): [True: 0, False: 0]
  ------------------
 2916|      0|            pkt->back_preroll = true;
 2917|       |
 2918|      0|        if (!ds->back_range_started) {
  ------------------
  |  Branch (2918:13): [True: 0, False: 0]
  ------------------
 2919|      0|            pkt->back_restart = true;
 2920|      0|            ds->back_range_started = true;
 2921|      0|        }
 2922|      0|    }
 2923|       |
 2924|  1.37M|    double ts = MP_PTS_OR_DEF(pkt->dts, pkt->pts);
  ------------------
  |  |   62|  1.37M|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|  1.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 9.47k, False: 1.36M]
  |  |  ------------------
  ------------------
 2925|  1.37M|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2925:9): [True: 1.36M, False: 8.42k]
  ------------------
 2926|  1.36M|        ds->base_ts = ts;
 2927|       |
 2928|  1.37M|    if (pkt->keyframe && ts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.29M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2928:9): [True: 1.29M, False: 87.0k]
  |  Branch (2928:26): [True: 1.28M, False: 3.98k]
  ------------------
 2929|       |        // Update bitrate - only at keyframe points, because we use the
 2930|       |        // (possibly) reordered packet timestamps instead of realtime.
 2931|  1.28M|        double d = ts - ds->last_br_ts;
 2932|  1.28M|        if (ds->last_br_ts == MP_NOPTS_VALUE || d < 0) {
  ------------------
  |  |   39|  2.57M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2932:13): [True: 10.0k, False: 1.27M]
  |  Branch (2932:49): [True: 0, False: 1.27M]
  ------------------
 2933|  10.0k|            ds->bitrate = -1;
 2934|  10.0k|            ds->last_br_ts = ts;
 2935|  10.0k|            ds->last_br_bytes = 0;
 2936|  1.27M|        } else if (d >= 0.5) { // a window of least 500ms for UI purposes
  ------------------
  |  Branch (2936:20): [True: 52.4k, False: 1.22M]
  ------------------
 2937|  52.4k|            ds->bitrate = ds->last_br_bytes / d;
 2938|  52.4k|            ds->last_br_ts = ts;
 2939|  52.4k|            ds->last_br_bytes = 0;
 2940|  52.4k|        }
 2941|  1.28M|    }
 2942|  1.37M|    ds->last_br_bytes += pkt->len;
 2943|       |
 2944|       |    // This implies this function is actually called from "the" user thread.
 2945|  1.37M|    if (pkt->pos >= in->d_user->filepos)
  ------------------
  |  Branch (2945:9): [True: 1.32M, False: 49.4k]
  ------------------
 2946|  1.32M|        in->d_user->filepos = pkt->pos;
 2947|  1.37M|    in->d_user->filesize = in->stream_size;
 2948|       |
 2949|  1.37M|    pkt->pts = MP_ADD_PTS(pkt->pts, in->ts_offset);
  ------------------
  |  |   67|  1.37M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  1.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 8.42k, False: 1.36M]
  |  |  ------------------
  ------------------
 2950|  1.37M|    pkt->dts = MP_ADD_PTS(pkt->dts, in->ts_offset);
  ------------------
  |  |   67|  1.37M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  1.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 9.47k, False: 1.36M]
  |  |  ------------------
  ------------------
 2951|       |
 2952|  1.37M|    if (pkt->segmented) {
  ------------------
  |  Branch (2952:9): [True: 0, False: 1.37M]
  ------------------
 2953|      0|        pkt->start = MP_ADD_PTS(pkt->start, in->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2954|      0|        pkt->end = MP_ADD_PTS(pkt->end, in->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2955|      0|    }
 2956|       |
 2957|  1.37M|    prune_old_packets(in);
 2958|  1.37M|    *res = pkt;
 2959|  1.37M|    return 1;
 2960|  1.37M|}
demux.c:lazy_stream_needs_wait:
 2312|  3.47k|{
 2313|  3.47k|    struct demux_internal *in = ds->in;
 2314|       |    // Attempt to read until force_read_until was reached, or reading has
 2315|       |    // stopped for some reason (true EOF, queue overflow).
 2316|  3.47k|    return !ds->eager && !in->back_demuxing &&
  ------------------
  |  Branch (2316:12): [True: 3.47k, False: 0]
  |  Branch (2316:26): [True: 3.47k, False: 0]
  ------------------
 2317|  3.47k|           !in->eof && ds->force_read_until != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  6.94k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2317:12): [True: 3.47k, False: 0]
  |  Branch (2317:24): [True: 0, False: 3.47k]
  ------------------
 2318|      0|           (in->demux_ts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2318:13): [True: 0, False: 0]
  ------------------
 2319|      0|            in->demux_ts <= ds->force_read_until);
  ------------------
  |  Branch (2319:13): [True: 0, False: 0]
  ------------------
 2320|  3.47k|}
demux.c:read_packet_from_cache:
 2796|  1.37M|{
 2797|  1.37M|    if (!pkt)
  ------------------
  |  Branch (2797:9): [True: 0, False: 1.37M]
  ------------------
 2798|      0|        return NULL;
 2799|       |
 2800|  1.37M|    if (pkt->is_cached) {
  ------------------
  |  Branch (2800:9): [True: 0, False: 1.37M]
  ------------------
 2801|      0|        mp_assert(in->cache);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2801:9): [True: 0, False: 0]
  ------------------
 2802|      0|        struct demux_packet *meta = pkt;
 2803|      0|        pkt = demux_cache_read(in->cache, pkt->cached_data.pos);
 2804|      0|        if (pkt) {
  ------------------
  |  Branch (2804:13): [True: 0, False: 0]
  ------------------
 2805|      0|            demux_packet_copy_attribs(pkt, meta);
 2806|      0|        } else {
 2807|      0|            MP_ERR(in, "Failed to retrieve packet from cache.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2808|      0|        }
 2809|  1.37M|    } else {
 2810|       |        // The returned packet is mutated etc. and will be owned by the user.
 2811|  1.37M|        pkt = demux_copy_packet(in->packet_pool, pkt);
 2812|  1.37M|    }
 2813|       |
 2814|  1.37M|    return pkt;
 2815|  1.37M|}
demux.c:thread_work:
 2708|  1.62M|{
 2709|  1.62M|    struct demux_opts *opts = in->d_user->opts;
 2710|  1.62M|    size_t old_max_bytes = opts->max_bytes;
 2711|  1.62M|    size_t old_max_bytes_bw = opts->max_bytes_bw;
 2712|  1.62M|    if (m_config_cache_update(in->d_user->opts_cache)) {
  ------------------
  |  Branch (2712:9): [True: 0, False: 1.62M]
  ------------------
 2713|      0|        update_opts(in->d_user);
 2714|      0|        if (opts->max_bytes + opts->max_bytes_bw < old_max_bytes + old_max_bytes_bw)
  ------------------
  |  Branch (2714:13): [True: 0, False: 0]
  ------------------
 2715|      0|            demux_packet_pool_clear(in->packet_pool);
 2716|      0|    }
 2717|  1.62M|    if (in->tracks_switched) {
  ------------------
  |  Branch (2717:9): [True: 19.7k, False: 1.60M]
  ------------------
 2718|  19.7k|        execute_trackswitch(in);
 2719|  19.7k|        return true;
 2720|  19.7k|    }
 2721|  1.60M|    if (in->nav_refresh) {
  ------------------
  |  Branch (2721:9): [True: 0, False: 1.60M]
  ------------------
 2722|      0|        execute_nav_refresh(in);
 2723|      0|        return true;
 2724|      0|    }
 2725|  1.60M|    if (in->need_back_seek) {
  ------------------
  |  Branch (2725:9): [True: 0, False: 1.60M]
  ------------------
 2726|      0|        perform_backward_seek(in);
 2727|      0|        return true;
 2728|      0|    }
 2729|  1.60M|    if (in->back_any_need_recheck) {
  ------------------
  |  Branch (2729:9): [True: 0, False: 1.60M]
  ------------------
 2730|      0|        check_backward_seek(in);
 2731|      0|        return true;
 2732|      0|    }
 2733|  1.60M|    if (in->seeking) {
  ------------------
  |  Branch (2733:9): [True: 9.33k, False: 1.59M]
  ------------------
 2734|  9.33k|        execute_seek(in);
 2735|  9.33k|        return true;
 2736|  9.33k|    }
 2737|  1.59M|    if (read_packet(in))
  ------------------
  |  Branch (2737:9): [True: 1.53M, False: 59.8k]
  ------------------
 2738|  1.53M|        return true; // read_packet unlocked, so recheck conditions
 2739|  59.8k|    if (mp_time_ns() >= in->next_cache_update) {
  ------------------
  |  Branch (2739:9): [True: 0, False: 59.8k]
  ------------------
 2740|      0|        update_cache(in);
 2741|      0|        return true;
 2742|      0|    }
 2743|  59.8k|    return false;
 2744|  59.8k|}
demux.c:update_opts:
 2638|  24.6k|{
 2639|  24.6k|    struct demux_opts *opts = demuxer->opts;
 2640|  24.6k|    struct demux_internal *in = demuxer->in;
 2641|       |
 2642|  24.6k|    in->min_secs = opts->min_secs;
 2643|  24.6k|    in->hyst_secs = opts->hyst_secs;
 2644|  24.6k|    in->hyst_bytes = opts->hyst_bytes;
 2645|  24.6k|    in->max_bytes = opts->max_bytes;
 2646|  24.6k|    in->max_bytes_bw = opts->max_bytes_bw;
 2647|       |
 2648|  24.6k|    int seekable = opts->seekable_cache;
 2649|  24.6k|    bool is_streaming = in->d_thread->is_streaming;
 2650|  24.6k|    bool use_cache = is_streaming;
 2651|  24.6k|    if (opts->enable_cache >= 0)
  ------------------
  |  Branch (2651:9): [True: 0, False: 24.6k]
  ------------------
 2652|      0|        use_cache = opts->enable_cache == 1;
 2653|       |
 2654|  24.6k|    if (use_cache) {
  ------------------
  |  Branch (2654:9): [True: 24.5k, False: 16]
  ------------------
 2655|  24.5k|        in->min_secs = MPMAX(in->min_secs, opts->min_secs_cache);
  ------------------
  |  |   44|  24.5k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 24.5k]
  |  |  ------------------
  ------------------
 2656|  24.5k|        if (seekable < 0)
  ------------------
  |  Branch (2656:13): [True: 24.5k, False: 0]
  ------------------
 2657|  24.5k|            seekable = 1;
 2658|  24.5k|    }
 2659|  24.6k|    in->seekable_cache = seekable == 1;
 2660|  24.6k|    if (in->d_thread->no_cache_seeking)
  ------------------
  |  Branch (2660:9): [True: 0, False: 24.6k]
  ------------------
 2661|      0|        in->seekable_cache = false;
 2662|  24.6k|    in->using_network_cache_opts = is_streaming && use_cache;
  ------------------
  |  Branch (2662:36): [True: 24.5k, False: 16]
  |  Branch (2662:52): [True: 24.5k, False: 0]
  ------------------
 2663|       |
 2664|  24.6k|    if (!in->seekable_cache)
  ------------------
  |  Branch (2664:9): [True: 16, False: 24.5k]
  ------------------
 2665|     16|        in->max_bytes_bw = 0;
 2666|       |
 2667|  24.6k|    if (!in->can_cache) {
  ------------------
  |  Branch (2667:9): [True: 0, False: 24.6k]
  ------------------
 2668|      0|        in->seekable_cache = false;
 2669|      0|        in->min_secs = 0;
 2670|      0|        in->max_bytes = 1;
 2671|      0|        in->max_bytes_bw = 0;
 2672|      0|        in->using_network_cache_opts = false;
 2673|      0|    }
 2674|       |
 2675|  24.6k|    if (in->seekable_cache && opts->disk_cache && !in->cache) {
  ------------------
  |  Branch (2675:9): [True: 24.5k, False: 16]
  |  Branch (2675:31): [True: 0, False: 24.5k]
  |  Branch (2675:51): [True: 0, False: 0]
  ------------------
 2676|      0|        in->cache = demux_cache_create(in->global, in->log);
 2677|      0|        if (!in->cache)
  ------------------
  |  Branch (2677:13): [True: 0, False: 0]
  ------------------
 2678|      0|            MP_ERR(in, "Failed to create file cache.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2679|      0|    }
 2680|       |
 2681|       |    // The filename option really decides whether recording should be active.
 2682|       |    // So if the filename changes, act upon it.
 2683|  24.6k|    char *old = in->record_filename ? in->record_filename : "";
  ------------------
  |  Branch (2683:17): [True: 0, False: 24.6k]
  ------------------
 2684|  24.6k|    char *new = opts->record_file ? opts->record_file : "";
  ------------------
  |  Branch (2684:17): [True: 0, False: 24.6k]
  ------------------
 2685|  24.6k|    if (strcmp(old, new) != 0) {
  ------------------
  |  Branch (2685:9): [True: 0, False: 24.6k]
  ------------------
 2686|      0|        if (in->recorder) {
  ------------------
  |  Branch (2686:13): [True: 0, False: 0]
  ------------------
 2687|      0|            MP_WARN(in, "Stopping recording.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2688|      0|            mp_recorder_destroy(in->recorder);
 2689|      0|            in->recorder = NULL;
 2690|      0|        }
 2691|      0|        talloc_free(in->record_filename);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2692|      0|        in->record_filename = talloc_strdup(in, opts->record_file);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2693|       |        // Note: actual recording only starts once packets are read. It may be
 2694|       |        // important to delay creating in->recorder to that point, because the
 2695|       |        // demuxer might detect more streams until finding the first packet.
 2696|      0|        in->enable_recording = in->can_record;
 2697|      0|    }
 2698|       |
 2699|       |    // In case the cache was reduced in size.
 2700|  24.6k|    prune_old_packets(in);
 2701|       |
 2702|       |    // In case the seekable cache was disabled.
 2703|  24.6k|    free_empty_cached_ranges(in);
 2704|  24.6k|}
demux.c:execute_seek:
 2604|  9.33k|{
 2605|  9.33k|    int flags = in->seek_flags;
 2606|  9.33k|    double pts = in->seek_pts;
 2607|  9.33k|    in->eof = false;
 2608|  9.33k|    in->seeking = false;
 2609|  9.33k|    in->seeking_in_progress = pts;
 2610|  9.33k|    in->demux_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.33k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2611|  9.33k|    in->low_level_seeks += 1;
 2612|  9.33k|    in->after_seek = true;
 2613|  9.33k|    in->after_seek_to_start =
 2614|  9.33k|        !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   95|  9.33k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
                      !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   94|  9.33k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (2614:9): [True: 9.33k, False: 0]
  ------------------
 2615|  9.33k|        pts <= in->d_thread->start_time;
  ------------------
  |  Branch (2615:9): [True: 9.33k, False: 0]
  ------------------
 2616|       |
 2617|  18.7k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2617:21): [True: 9.45k, False: 9.33k]
  ------------------
 2618|  9.45k|        in->streams[n]->ds->queue->last_pos_fixup = -1;
 2619|       |
 2620|  9.33k|    if (in->recorder)
  ------------------
  |  Branch (2620:9): [True: 0, False: 9.33k]
  ------------------
 2621|      0|        mp_recorder_mark_discontinuity(in->recorder);
 2622|       |
 2623|  9.33k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  9.33k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2624|       |
 2625|  9.33k|    MP_VERBOSE(in, "execute seek (to %f flags %d)\n", pts, flags);
  ------------------
  |  |   92|  9.33k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.33k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2626|       |
 2627|  9.33k|    if (in->d_thread->desc->seek)
  ------------------
  |  Branch (2627:9): [True: 9.33k, False: 0]
  ------------------
 2628|  9.33k|        in->d_thread->desc->seek(in->d_thread, pts, flags);
 2629|       |
 2630|  9.33k|    MP_VERBOSE(in, "seek done\n");
  ------------------
  |  |   92|  9.33k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.33k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2631|       |
 2632|  9.33k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  9.33k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2633|       |
 2634|  9.33k|    in->seeking_in_progress = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.33k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2635|  9.33k|}
demux.c:read_packet:
 2324|  1.59M|{
 2325|  1.59M|    bool was_reading = in->reading;
 2326|  1.59M|    in->reading = false;
 2327|       |
 2328|  1.59M|    if (!was_reading || in->blocked || demux_cancel_test(in->d_thread))
  ------------------
  |  Branch (2328:9): [True: 55.9k, False: 1.54M]
  |  Branch (2328:25): [True: 0, False: 1.54M]
  |  Branch (2328:40): [True: 0, False: 1.54M]
  ------------------
 2329|  55.9k|        return false;
 2330|       |
 2331|       |    // Check if we need to read a new packet. We do this if all queues are below
 2332|       |    // the minimum, or if a stream explicitly needs new packets. Also includes
 2333|       |    // safe-guards against packet queue overflow.
 2334|  1.59M|    bool read_more = false, prefetch_more = false, refresh_more = false;
 2335|  1.54M|    uint64_t total_fw_bytes = 0;
 2336|  3.11M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2336:21): [True: 1.57M, False: 1.54M]
  ------------------
 2337|  1.57M|        total_fw_bytes += get_forward_buffered_bytes(in->streams[n]->ds);
 2338|  1.54M|    if (in->hyst_bytes > 0 && total_fw_bytes <= in->hyst_bytes)
  ------------------
  |  Branch (2338:9): [True: 0, False: 1.54M]
  |  Branch (2338:31): [True: 0, False: 0]
  ------------------
 2339|      0|        in->hyst_active = false;
 2340|  3.11M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2340:21): [True: 1.57M, False: 1.54M]
  ------------------
 2341|  1.57M|        struct demux_stream *ds = in->streams[n]->ds;
 2342|  1.57M|        if (ds->eager) {
  ------------------
  |  Branch (2342:13): [True: 1.57M, False: 3.47k]
  ------------------
 2343|  1.57M|            read_more |= !ds->reader_head;
 2344|  1.57M|            if (in->back_demuxing)
  ------------------
  |  Branch (2344:17): [True: 0, False: 1.57M]
  ------------------
 2345|      0|                read_more |= ds->back_restarting || ds->back_resuming;
  ------------------
  |  Branch (2345:30): [True: 0, False: 0]
  |  Branch (2345:53): [True: 0, False: 0]
  ------------------
 2346|  1.57M|        } else {
 2347|  3.47k|            if (lazy_stream_needs_wait(ds)) {
  ------------------
  |  Branch (2347:17): [True: 0, False: 3.47k]
  ------------------
 2348|      0|                read_more = true;
 2349|  3.47k|            } else {
 2350|  3.47k|                mark_stream_eof(ds); // let playback continue
 2351|  3.47k|            }
 2352|  3.47k|        }
 2353|  1.57M|        refresh_more |= ds->refreshing;
 2354|  1.57M|        if (ds->eager && ds->queue->last_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  3.14M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2354:13): [True: 1.57M, False: 3.47k]
  |  Branch (2354:26): [True: 1.40M, False: 168k]
  ------------------
 2355|  1.40M|            in->min_secs > 0 && ds->base_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  2.98M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2355:13): [True: 1.40M, False: 0]
  |  Branch (2355:33): [True: 1.40M, False: 0]
  ------------------
 2356|  1.40M|            ds->queue->last_ts >= ds->base_ts &&
  ------------------
  |  Branch (2356:13): [True: 1.40M, False: 1]
  ------------------
 2357|  1.40M|            !in->back_demuxing)
  ------------------
  |  Branch (2357:13): [True: 1.40M, False: 0]
  ------------------
 2358|  1.40M|        {
 2359|  1.40M|            if (ds->queue->last_ts - ds->base_ts <= in->hyst_secs)
  ------------------
  |  Branch (2359:17): [True: 18.1k, False: 1.38M]
  ------------------
 2360|  18.1k|                in->hyst_active = false;
 2361|  1.40M|            if (!in->hyst_active)
  ------------------
  |  Branch (2361:17): [True: 1.40M, False: 0]
  ------------------
 2362|  1.40M|                prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
 2363|  1.40M|        }
 2364|  1.57M|    }
 2365|       |
 2366|       |    // While interactive disc navigation is active, never read ahead. It would
 2367|       |    // advance the disc VM past what the user is watching. Reads still happen
 2368|       |    // whenever a selected stream demands data.
 2369|  1.54M|    if (in->nav_active)
  ------------------
  |  Branch (2369:9): [True: 0, False: 1.54M]
  ------------------
 2370|      0|        prefetch_more = false;
 2371|  1.54M|    prefetch_more |= in->nav_pump;
 2372|       |
 2373|  1.54M|    MP_TRACE(in, "bytes=%zd, read_more=%d prefetch_more=%d, refresh_more=%d\n",
  ------------------
  |  |   94|  1.54M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.54M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2374|  1.54M|             (size_t)total_fw_bytes, read_more, prefetch_more, refresh_more);
 2375|  1.54M|    if (total_fw_bytes >= in->max_bytes) {
  ------------------
  |  Branch (2375:9): [True: 0, False: 1.54M]
  ------------------
 2376|       |        // if we hit the limit just by prefetching, simply stop prefetching
 2377|      0|        if (!read_more) {
  ------------------
  |  Branch (2377:13): [True: 0, False: 0]
  ------------------
 2378|      0|            in->hyst_active = in->hyst_secs > 0 || in->hyst_bytes > 0;
  ------------------
  |  Branch (2378:31): [True: 0, False: 0]
  |  Branch (2378:52): [True: 0, False: 0]
  ------------------
 2379|      0|            return false;
 2380|      0|        }
 2381|      0|        if (!in->warned_queue_overflow) {
  ------------------
  |  Branch (2381:13): [True: 0, False: 0]
  ------------------
 2382|      0|            in->warned_queue_overflow = true;
 2383|      0|            MP_WARN(in, "Too many packets in the demuxer packet queues:\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2384|      0|            for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2384:29): [True: 0, False: 0]
  ------------------
 2385|      0|                struct demux_stream *ds = in->streams[n]->ds;
 2386|      0|                if (ds->selected) {
  ------------------
  |  Branch (2386:21): [True: 0, False: 0]
  ------------------
 2387|      0|                    size_t num_pkts = 0;
 2388|      0|                    for (struct demux_packet *dp = ds->reader_head;
 2389|      0|                         dp; dp = dp->next)
  ------------------
  |  Branch (2389:26): [True: 0, False: 0]
  ------------------
 2390|      0|                        num_pkts++;
 2391|      0|                    uint64_t fw_bytes = get_forward_buffered_bytes(ds);
 2392|      0|                    MP_WARN(in, "  %s/%d: %zd packets, %zd bytes%s%s\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2393|      0|                            stream_type_name(ds->type), n,
 2394|      0|                            num_pkts, (size_t)fw_bytes,
 2395|      0|                            ds->eager ? "" : " (lazy)",
 2396|      0|                            ds->refreshing ? " (refreshing)" : "");
 2397|      0|                }
 2398|      0|            }
 2399|      0|            if (in->back_demuxing)
  ------------------
  |  Branch (2399:17): [True: 0, False: 0]
  ------------------
 2400|      0|                MP_ERR(in, "Backward playback is likely stuck/broken now.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2401|      0|        }
 2402|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2402:25): [True: 0, False: 0]
  ------------------
 2403|      0|            struct demux_stream *ds = in->streams[n]->ds;
 2404|      0|            if (!ds->reader_head)
  ------------------
  |  Branch (2404:17): [True: 0, False: 0]
  ------------------
 2405|      0|                mark_stream_eof(ds);
 2406|      0|        }
 2407|      0|        return false;
 2408|      0|    }
 2409|       |
 2410|  1.54M|    if (!read_more && !prefetch_more && !refresh_more) {
  ------------------
  |  Branch (2410:9): [True: 1.40M, False: 138k]
  |  Branch (2410:23): [True: 3.87k, False: 1.39M]
  |  Branch (2410:41): [True: 3.87k, False: 0]
  ------------------
 2411|  3.87k|        in->hyst_active = in->hyst_secs > 0 || in->hyst_bytes > 0;
  ------------------
  |  Branch (2411:27): [True: 0, False: 3.87k]
  |  Branch (2411:48): [True: 0, False: 3.87k]
  ------------------
 2412|  3.87k|        return false;
 2413|  3.87k|    }
 2414|       |
 2415|  1.53M|    if (in->after_seek_to_start) {
  ------------------
  |  Branch (2415:9): [True: 16.7k, False: 1.51M]
  ------------------
 2416|  36.5k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2416:25): [True: 19.7k, False: 16.7k]
  ------------------
 2417|  19.7k|            struct demux_stream *ds = in->streams[n]->ds;
 2418|  19.7k|            in->current_range->streams[n]->is_bof =
 2419|  19.7k|                ds->selected && !ds->refreshing;
  ------------------
  |  Branch (2419:17): [True: 19.4k, False: 307]
  |  Branch (2419:33): [True: 19.4k, False: 0]
  ------------------
 2420|  19.7k|        }
 2421|  16.7k|    }
 2422|       |
 2423|       |    // Actually read a packet. Drop the lock while doing so, because waiting
 2424|       |    // for disk or network I/O can take time.
 2425|  1.53M|    in->reading = true;
 2426|  1.53M|    in->nav_pump = false;
 2427|  1.53M|    in->after_seek = false;
 2428|  1.53M|    in->after_seek_to_start = false;
 2429|  1.53M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.53M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2430|       |
 2431|  1.53M|    struct demuxer *demux = in->d_thread;
 2432|  1.53M|    struct demux_packet *pkt = NULL;
 2433|       |
 2434|  1.53M|    bool eof = true;
 2435|  1.53M|    if (demux->desc->read_packet && !demux_read_interrupted(demux))
  ------------------
  |  Branch (2435:9): [True: 1.53M, False: 0]
  |  Branch (2435:37): [True: 1.53M, False: 0]
  ------------------
 2436|  1.53M|        eof = !demux->desc->read_packet(demux, &pkt);
 2437|       |
 2438|  1.53M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.53M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2439|  1.53M|    update_cache(in);
 2440|       |
 2441|  1.53M|    if (pkt) {
  ------------------
  |  Branch (2441:9): [True: 1.47M, False: 64.9k]
  ------------------
 2442|  1.47M|        mp_assert(pkt->stream >= 0 && pkt->stream < in->num_streams);
  ------------------
  |  |   41|  1.47M|#define mp_assert assert
  ------------------
  |  Branch (2442:9): [True: 1.47M, False: 0]
  |  Branch (2442:9): [True: 1.47M, False: 0]
  ------------------
 2443|  1.47M|        add_packet_locked(in->streams[pkt->stream], pkt);
 2444|  1.47M|    }
 2445|       |
 2446|  1.53M|    if (!in->seeking) {
  ------------------
  |  Branch (2446:9): [True: 1.53M, False: 0]
  ------------------
 2447|  1.53M|        if (eof) {
  ------------------
  |  Branch (2447:13): [True: 16.7k, False: 1.51M]
  ------------------
 2448|  36.5k|            for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2448:29): [True: 19.7k, False: 16.7k]
  ------------------
 2449|  19.7k|                mark_stream_eof(in->streams[n]->ds);
 2450|       |            // If we had EOF previously, then don't wakeup (avoids wakeup loop)
 2451|  16.7k|            if (!in->eof) {
  ------------------
  |  Branch (2451:17): [True: 16.7k, False: 0]
  ------------------
 2452|  16.7k|                if (in->wakeup_cb)
  ------------------
  |  Branch (2452:21): [True: 16.7k, False: 0]
  ------------------
 2453|  16.7k|                    in->wakeup_cb(in->wakeup_cb_ctx);
 2454|  16.7k|                mp_cond_signal(&in->wakeup);
 2455|  16.7k|                MP_VERBOSE(in, "EOF reached.\n");
  ------------------
  |  |   92|  16.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  16.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2456|  16.7k|            }
 2457|  16.7k|        }
 2458|  1.53M|        in->eof = eof;
 2459|  1.53M|        in->reading = !eof;
 2460|  1.53M|    }
 2461|       |    return true;
 2462|  1.53M|}
demux.c:mark_stream_eof:
 2302|  23.2k|{
 2303|  23.2k|    if (!ds->eof) {
  ------------------
  |  Branch (2303:9): [True: 19.7k, False: 3.47k]
  ------------------
 2304|  19.7k|        ds->eof = true;
 2305|       |        adjust_seek_range_on_packet(ds, NULL);
 2306|  19.7k|        back_demux_see_packets(ds);
 2307|  19.7k|        wakeup_ds(ds);
 2308|  19.7k|    }
 2309|  23.2k|}
demux.c:lookup_timed_metadata:
 3374|   355k|{
 3375|   355k|    struct demux_cached_range *r = in->current_range;
 3376|       |
 3377|   355k|    if (!r || !r->num_metadata || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3377:9): [True: 0, False: 355k]
  |  Branch (3377:15): [True: 355k, False: 0]
  |  Branch (3377:35): [True: 0, False: 0]
  ------------------
 3378|   355k|        return NULL;
 3379|       |
 3380|      0|    int start = 1;
 3381|      0|    int i = in->cached_metadata_index;
 3382|      0|    if (i >= 0 &&  i < r->num_metadata && r->metadata[i]->pts <= pts)
  ------------------
  |  Branch (3382:9): [True: 0, False: 0]
  |  Branch (3382:20): [True: 0, False: 0]
  |  Branch (3382:43): [True: 0, False: 0]
  ------------------
 3383|      0|        start = i + 1;
 3384|       |
 3385|      0|    in->cached_metadata_index = r->num_metadata - 1;
 3386|      0|    for (int n = start; n < r->num_metadata; n++) {
  ------------------
  |  Branch (3386:25): [True: 0, False: 0]
  ------------------
 3387|      0|        if (r->metadata[n]->pts >= pts) {
  ------------------
  |  Branch (3387:13): [True: 0, False: 0]
  ------------------
 3388|      0|            in->cached_metadata_index = n - 1;
 3389|      0|            break;
 3390|      0|        }
 3391|      0|    }
 3392|       |
 3393|      0|    return r->metadata[in->cached_metadata_index];
 3394|   355k|}
demux.c:update_final_metadata:
 3331|  24.6k|{
 3332|  24.6k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (3332:5): [True: 24.6k, False: 0]
  ------------------
 3333|  24.6k|    struct demux_internal *in = demuxer->in;
 3334|       |
 3335|  24.6k|    struct mp_tags *dyn_tags = NULL;
 3336|       |
 3337|       |    // Often useful for audio-only files, which have metadata in the audio track
 3338|       |    // metadata instead of the main metadata, but can also have cover art
 3339|       |    // metadata (which libavformat likes to treat as video streams).
 3340|  24.6k|    int astreams = 0;
 3341|  24.6k|    int astream_id = -1;
 3342|  24.6k|    int vstreams = 0;
 3343|  48.6k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3343:21): [True: 24.0k, False: 24.6k]
  ------------------
 3344|  24.0k|        struct sh_stream *sh = in->streams[n];
 3345|  24.0k|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3345:13): [True: 9.69k, False: 14.3k]
  |  Branch (3345:41): [True: 9.69k, False: 0]
  ------------------
 3346|  9.69k|            vstreams += 1;
 3347|  24.0k|        if (sh->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3347:13): [True: 12.3k, False: 11.6k]
  ------------------
 3348|  12.3k|            astreams += 1;
 3349|  12.3k|            astream_id = n;
 3350|  12.3k|        }
 3351|  24.0k|    }
 3352|       |
 3353|       |    // Use the metadata_stream tags only if this really seems to be an audio-
 3354|       |    // only stream. Otherwise it will happen too often that "uninteresting"
 3355|       |    // stream metadata will trash the actual file tags.
 3356|  24.6k|    if (vstreams == 0 && astreams == 1 &&
  ------------------
  |  Branch (3356:9): [True: 14.9k, False: 9.69k]
  |  Branch (3356:26): [True: 9.27k, False: 5.64k]
  ------------------
 3357|  9.27k|        in->streams[astream_id] == in->metadata_stream)
  ------------------
  |  Branch (3357:9): [True: 9.27k, False: 0]
  ------------------
 3358|  9.27k|    {
 3359|  9.27k|        dyn_tags = in->metadata_stream->tags;
 3360|  9.27k|        if (tm && tm->from_stream)
  ------------------
  |  Branch (3360:13): [True: 0, False: 9.27k]
  |  Branch (3360:19): [True: 0, False: 0]
  ------------------
 3361|      0|            dyn_tags = tm->tags;
 3362|  9.27k|    }
 3363|       |
 3364|       |    // Global metadata updates.
 3365|  24.6k|    if (tm && !tm->from_stream)
  ------------------
  |  Branch (3365:9): [True: 0, False: 24.6k]
  |  Branch (3365:15): [True: 0, False: 0]
  ------------------
 3366|      0|        dyn_tags = tm->tags;
 3367|       |
 3368|  24.6k|    if (dyn_tags)
  ------------------
  |  Branch (3368:9): [True: 9.27k, False: 15.3k]
  ------------------
 3369|  9.27k|        mp_tags_merge(demuxer->metadata, dyn_tags);
 3370|  24.6k|}
demux.c:demux_update_replaygain:
 3167|  46.4k|{
 3168|  46.4k|    struct demux_internal *in = demuxer->in;
 3169|  94.4k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3169:21): [True: 48.0k, False: 46.4k]
  ------------------
 3170|  48.0k|        struct sh_stream *sh = in->streams[n];
 3171|  48.0k|        if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
  ------------------
  |  Branch (3171:13): [True: 24.7k, False: 23.2k]
  |  Branch (3171:41): [True: 24.7k, False: 0]
  ------------------
 3172|  24.7k|            struct replaygain_data *rg = decode_rgain(demuxer->log, sh->tags);
 3173|  24.7k|            if (!rg)
  ------------------
  |  Branch (3173:17): [True: 24.7k, False: 0]
  ------------------
 3174|  24.7k|                rg = decode_rgain(demuxer->log, demuxer->metadata);
 3175|  24.7k|            if (rg)
  ------------------
  |  Branch (3175:17): [True: 0, False: 24.7k]
  ------------------
 3176|      0|                sh->codec->replaygain_data = talloc_steal(sh->codec, rg);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3177|  24.7k|        }
 3178|  48.0k|    }
 3179|  46.4k|}
demux.c:decode_rgain:
 3117|  49.5k|{
 3118|  49.5k|    struct replaygain_data rg = {0};
 3119|       |
 3120|       |    // Set values in *rg, using track gain as a fallback for album gain if the
 3121|       |    // latter is not present. This behavior matches that in demux/demux_lavf.c's
 3122|       |    // export_replaygain; if you change this, please make equivalent changes
 3123|       |    // there too.
 3124|  49.5k|    if (decode_gain(log, tags, "REPLAYGAIN_TRACK_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3124:9): [True: 0, False: 49.5k]
  ------------------
 3125|      0|        decode_peak(log, tags, "REPLAYGAIN_TRACK_PEAK", &rg.track_peak) >= 0)
  ------------------
  |  Branch (3125:9): [True: 0, False: 0]
  ------------------
 3126|      0|    {
 3127|      0|        if (decode_gain(log, tags, "REPLAYGAIN_ALBUM_GAIN", &rg.album_gain) < 0 ||
  ------------------
  |  Branch (3127:13): [True: 0, False: 0]
  ------------------
 3128|      0|            decode_peak(log, tags, "REPLAYGAIN_ALBUM_PEAK", &rg.album_peak) < 0)
  ------------------
  |  Branch (3128:13): [True: 0, False: 0]
  ------------------
 3129|      0|        {
 3130|       |            // Album gain is undefined; fall back to track gain.
 3131|      0|            rg.album_gain = rg.track_gain;
 3132|      0|            rg.album_peak = rg.track_peak;
 3133|      0|        }
 3134|      0|        return talloc_dup(NULL, &rg);
  ------------------
  |  |   48|      0|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|      0|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3135|      0|    }
 3136|       |
 3137|  49.5k|    if (decode_gain(log, tags, "REPLAYGAIN_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3137:9): [True: 0, False: 49.5k]
  ------------------
 3138|      0|        decode_peak(log, tags, "REPLAYGAIN_PEAK", &rg.track_peak) >= 0)
  ------------------
  |  Branch (3138:9): [True: 0, False: 0]
  ------------------
 3139|      0|    {
 3140|      0|        rg.album_gain = rg.track_gain;
 3141|      0|        rg.album_peak = rg.track_peak;
 3142|      0|        return talloc_dup(NULL, &rg);
  ------------------
  |  |   48|      0|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|      0|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3143|      0|    }
 3144|       |
 3145|       |    // The r128 replaygain tags declared in RFC 7845 for opus files. The tags
 3146|       |    // are generated with EBU-R128, which does not use peak meters. And the
 3147|       |    // values are stored as a Q7.8 fixed point number in dB.
 3148|  49.5k|    if (decode_gain(log, tags, "R128_TRACK_GAIN", &rg.track_gain) >= 0) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 49.5k]
  ------------------
 3149|      0|        if (decode_gain(log, tags, "R128_ALBUM_GAIN", &rg.album_gain) < 0) {
  ------------------
  |  Branch (3149:13): [True: 0, False: 0]
  ------------------
 3150|       |            // Album gain is undefined; fall back to track gain.
 3151|      0|            rg.album_gain = rg.track_gain;
 3152|      0|        }
 3153|      0|        rg.track_gain /= 256.;
 3154|      0|        rg.album_gain /= 256.;
 3155|       |
 3156|       |        // Add 5dB to compensate for the different reference levels between
 3157|       |        // our reference of ReplayGain 2 (-18 LUFS) and EBU R128 (-23 LUFS).
 3158|      0|        rg.track_gain += 5.;
 3159|      0|        rg.album_gain += 5.;
 3160|      0|        return talloc_dup(NULL, &rg);
  ------------------
  |  |   48|      0|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|      0|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3161|      0|    }
 3162|       |
 3163|  49.5k|    return NULL;
 3164|  49.5k|}
demux.c:decode_gain:
 3079|   148k|{
 3080|   148k|    char *tag_val = NULL;
 3081|   148k|    float dec_val;
 3082|       |
 3083|   148k|    tag_val = mp_tags_get_str(tags, tag);
 3084|   148k|    if (!tag_val)
  ------------------
  |  Branch (3084:9): [True: 148k, False: 0]
  ------------------
 3085|   148k|        return -1;
 3086|       |
 3087|      0|    if (decode_float(tag_val, &dec_val) < 0) {
  ------------------
  |  Branch (3087:9): [True: 0, False: 0]
  ------------------
 3088|      0|        mp_msg(log, MSGL_ERR, "Invalid replaygain value\n");
 3089|      0|        return -1;
 3090|      0|    }
 3091|       |
 3092|      0|    *out = dec_val;
 3093|      0|    return 0;
 3094|      0|}
demux.c:demux_open:
 3678|  30.5k|{
 3679|  30.5k|    const int *check_levels = d_normal;
 3680|  30.5k|    const struct demuxer_desc *check_desc = NULL;
 3681|  30.5k|    struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
 3682|  30.5k|    struct demuxer *demuxer = NULL;
 3683|  30.5k|    char *force_format = params->force_format;
 3684|       |
 3685|  30.5k|    struct parent_stream_info sinfo = {
 3686|  30.5k|        .seekable = stream->seekable,
 3687|  30.5k|        .is_network = stream->is_network,
 3688|  30.5k|        .is_streaming = stream->streaming,
 3689|  30.5k|        .stream_origin = stream->stream_origin,
 3690|  30.5k|        .cancel = cancel,
 3691|  30.5k|        .filename = talloc_strdup(NULL, stream->url),
  ------------------
  |  |   50|  30.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3692|  30.5k|        .server_filename = stream->server_filename,
 3693|  30.5k|    };
 3694|       |
 3695|  30.5k|    if (!force_format)
  ------------------
  |  Branch (3695:9): [True: 30.5k, False: 0]
  ------------------
 3696|  30.5k|        force_format = stream->demuxer;
 3697|       |
 3698|  30.5k|    if (force_format && force_format[0] && !stream->is_directory) {
  ------------------
  |  Branch (3698:9): [True: 112, False: 30.4k]
  |  Branch (3698:25): [True: 112, False: 0]
  |  Branch (3698:44): [True: 112, False: 0]
  ------------------
 3699|    112|        check_levels = d_request;
 3700|    112|        if (force_format[0] == '+') {
  ------------------
  |  Branch (3700:13): [True: 0, False: 112]
  ------------------
 3701|      0|            force_format += 1;
 3702|      0|            check_levels = d_force;
 3703|      0|        }
 3704|    992|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3704:25): [True: 992, False: 0]
  ------------------
 3705|    992|            if (strcmp(demuxer_list[n]->name, force_format) == 0) {
  ------------------
  |  Branch (3705:17): [True: 112, False: 880]
  ------------------
 3706|    112|                check_desc = demuxer_list[n];
 3707|    112|                break;
 3708|    112|            }
 3709|    992|        }
 3710|    112|        if (!check_desc) {
  ------------------
  |  Branch (3710:13): [True: 0, False: 112]
  ------------------
 3711|      0|            mp_err(log, "Demuxer %s does not exist.\n", force_format);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3712|      0|            goto done;
 3713|      0|        }
 3714|    112|    }
 3715|       |
 3716|       |    // Test demuxers from first to last, one pass for each check_levels[] entry
 3717|  46.4k|    for (int pass = 0; check_levels[pass] != -1; pass++) {
  ------------------
  |  Branch (3717:24): [True: 40.4k, False: 5.98k]
  ------------------
 3718|  40.4k|        enum demux_check level = check_levels[pass];
 3719|  40.4k|        mp_verbose(log, "Trying demuxers for level=%s.\n", d_level(level));
  ------------------
  |  |   79|  40.4k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3720|   408k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3720:25): [True: 392k, False: 15.8k]
  ------------------
 3721|   392k|            const struct demuxer_desc *desc = demuxer_list[n];
 3722|   392k|            if (!check_desc || desc == check_desc) {
  ------------------
  |  Branch (3722:17): [True: 391k, False: 1.34k]
  |  Branch (3722:32): [True: 112, False: 1.23k]
  ------------------
 3723|   391k|                demuxer = open_given_type(global, log, desc, stream, &sinfo,
 3724|   391k|                                          params, level);
 3725|   391k|                if (demuxer) {
  ------------------
  |  Branch (3725:21): [True: 24.6k, False: 366k]
  ------------------
 3726|  24.6k|                    talloc_steal(demuxer, log);
  ------------------
  |  |   38|  24.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3727|  24.6k|                    log = NULL;
 3728|  24.6k|                    goto done;
 3729|  24.6k|                }
 3730|   391k|            }
 3731|   392k|        }
 3732|  40.4k|    }
 3733|       |
 3734|  30.5k|done:
 3735|  30.5k|    talloc_free(sinfo.filename);
  ------------------
  |  |   47|  30.5k|#define talloc_free                     ta_free
  ------------------
 3736|  30.5k|    talloc_free(log);
  ------------------
  |  |   47|  30.5k|#define talloc_free                     ta_free
  ------------------
 3737|  30.5k|    return demuxer;
 3738|  30.5k|}
demux.c:d_level:
 3054|   431k|{
 3055|   431k|    switch (level) {
  ------------------
  |  Branch (3055:13): [True: 431k, False: 0]
  ------------------
 3056|      0|    case DEMUX_CHECK_FORCE:  return "force";
  ------------------
  |  Branch (3056:5): [True: 0, False: 431k]
  ------------------
 3057|   116k|    case DEMUX_CHECK_UNSAFE: return "unsafe";
  ------------------
  |  Branch (3057:5): [True: 116k, False: 315k]
  ------------------
 3058|    224|    case DEMUX_CHECK_REQUEST:return "request";
  ------------------
  |  Branch (3058:5): [True: 224, False: 431k]
  ------------------
 3059|   315k|    case DEMUX_CHECK_NORMAL: return "normal";
  ------------------
  |  Branch (3059:5): [True: 315k, False: 116k]
  ------------------
 3060|   431k|    }
 3061|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (3061:5): [Folded, False: 0]
  ------------------
 3062|      0|}
demux.c:open_given_type:
 3541|   391k|{
 3542|   391k|    if (mp_cancel_test(sinfo->cancel))
  ------------------
  |  Branch (3542:9): [True: 0, False: 391k]
  ------------------
 3543|      0|        return NULL;
 3544|       |
 3545|   391k|    if (params->depth > 10) {
  ------------------
  |  Branch (3545:9): [True: 0, False: 391k]
  ------------------
 3546|      0|        mp_err(log, "Demuxer recursion depth exceeded.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3547|      0|        return NULL;
 3548|      0|    }
 3549|       |
 3550|   391k|    mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
  ------------------
  |  |   80|   391k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
 3551|   391k|           desc->name, d_level(check));
 3552|       |
 3553|   391k|    if (stream && !stream_seek(stream, 0)) {
  ------------------
  |  Branch (3553:9): [True: 391k, False: 0]
  |  Branch (3553:19): [True: 65, False: 391k]
  ------------------
 3554|     65|        mp_err(log, "Failed to rewind stream to the start.\n");
  ------------------
  |  |   76|     65|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3555|     65|        return NULL;
 3556|     65|    }
 3557|       |
 3558|   391k|    struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
  ------------------
  |  |   34|   391k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   391k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   391k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3559|   391k|    struct m_config_cache *opts_cache =
 3560|   391k|        m_config_cache_alloc(demuxer, global, &demux_conf);
 3561|   391k|    struct demux_opts *opts = opts_cache->opts;
 3562|   391k|    *demuxer = (struct demuxer) {
 3563|   391k|        .desc = desc,
 3564|   391k|        .stream = stream,
 3565|   391k|        .cancel = sinfo->cancel,
 3566|   391k|        .seekable = sinfo->seekable,
 3567|   391k|        .filepos = -1,
 3568|   391k|        .global = global,
 3569|   391k|        .log = mp_log_new(demuxer, log, desc->name),
 3570|   391k|        .packet_pool = demux_packet_pool_get(global),
 3571|   391k|        .glog = log,
 3572|   391k|        .filename = talloc_strdup(demuxer, sinfo->filename),
  ------------------
  |  |   50|   391k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3573|   391k|        .server_filename = talloc_strdup(demuxer, sinfo->server_filename),
  ------------------
  |  |   50|   391k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3574|   391k|        .is_network = sinfo->is_network,
 3575|   391k|        .is_streaming = sinfo->is_streaming,
 3576|   391k|        .stream_origin = sinfo->stream_origin,
 3577|   391k|        .access_references = opts->access_references,
 3578|   391k|        .opts = opts,
 3579|   391k|        .opts_cache = opts_cache,
 3580|   391k|        .events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS,
 3581|   391k|        .duration = -1,
 3582|   391k|        .depth = params->depth,
 3583|   391k|    };
 3584|       |
 3585|   391k|    struct demux_internal *in = demuxer->in = talloc_ptrtype(demuxer, in);
  ------------------
  |  |   34|   391k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   391k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   391k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3586|   391k|    *in = (struct demux_internal){
 3587|   391k|        .global = global,
 3588|   391k|        .log = demuxer->log,
 3589|   391k|        .packet_pool = demux_packet_pool_get(global),
 3590|   391k|        .stats = stats_ctx_create(in, global, "demuxer"),
 3591|   391k|        .can_cache = params->is_top_level,
 3592|   391k|        .can_record = params->stream_record,
 3593|   391k|        .d_thread = talloc(demuxer, struct demuxer),
  ------------------
  |  |   26|   391k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   391k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   391k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3594|   391k|        .d_user = demuxer,
 3595|   391k|        .after_seek = true, // (assumed identical to initial demuxer state)
 3596|   391k|        .after_seek_to_start = true,
 3597|   391k|        .highest_av_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   391k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3598|   391k|        .seeking_in_progress = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   391k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3599|   391k|        .demux_ts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   391k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3600|   391k|        .owns_stream = !params->external_stream,
 3601|   391k|    };
 3602|   391k|    mp_mutex_init(&in->lock);
 3603|   391k|    mp_cond_init(&in->wakeup);
 3604|       |
 3605|   391k|    *in->d_thread = *demuxer;
 3606|       |
 3607|   391k|    in->d_thread->metadata = talloc_zero(in->d_thread, struct mp_tags);
  ------------------
  |  |   27|   391k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   391k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   391k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3608|       |
 3609|   391k|    in->d_thread->params = params; // temporary during open()
 3610|   391k|    int ret = demuxer->desc->open(in->d_thread, check);
 3611|   391k|    if (ret >= 0) {
  ------------------
  |  Branch (3611:9): [True: 24.6k, False: 366k]
  ------------------
 3612|  24.6k|        in->d_thread->params = NULL;
 3613|  24.6k|        if (in->d_thread->filetype)
  ------------------
  |  Branch (3613:13): [True: 23.3k, False: 1.24k]
  ------------------
 3614|  23.3k|            mp_verbose(log, "Detected file format: %s (%s)\n",
  ------------------
  |  |   79|  23.3k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3615|  24.6k|                       in->d_thread->filetype, desc->desc);
 3616|  1.24k|        else
 3617|  1.24k|            mp_verbose(log, "Detected file format: %s\n", desc->desc);
  ------------------
  |  |   79|  1.24k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3618|  24.6k|        if (!in->d_thread->seekable)
  ------------------
  |  Branch (3618:13): [True: 0, False: 24.6k]
  ------------------
 3619|      0|            mp_verbose(log, "Stream is not seekable.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3620|  24.6k|        if (!in->d_thread->seekable && opts->force_seekable) {
  ------------------
  |  Branch (3620:13): [True: 0, False: 24.6k]
  |  Branch (3620:40): [True: 0, False: 0]
  ------------------
 3621|      0|            mp_warn(log, "Not seekable, but enabling seeking on user request.\n");
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
 3622|      0|            in->d_thread->seekable = true;
 3623|      0|            in->d_thread->partially_seekable = true;
 3624|      0|        }
 3625|  24.6k|        demux_init_cuesheet(in->d_thread);
 3626|  24.6k|        demux_init_ccs(demuxer, opts);
 3627|  24.6k|        demux_convert_tags_charset(in->d_thread);
 3628|  24.6k|        demux_copy(in->d_user, in->d_thread);
 3629|  24.6k|        in->duration = in->d_thread->duration;
 3630|  24.6k|        demuxer_sort_chapters(demuxer);
 3631|  24.6k|        in->events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS;
 3632|       |
 3633|  24.6k|        struct demuxer *sub = NULL;
 3634|  24.6k|        if (!params->disable_timeline) {
  ------------------
  |  Branch (3634:13): [True: 24.6k, False: 0]
  ------------------
 3635|  24.6k|            struct timeline *tl = timeline_load(global, log, demuxer);
 3636|  24.6k|            if (tl) {
  ------------------
  |  Branch (3636:17): [True: 0, False: 24.6k]
  ------------------
 3637|      0|                struct demuxer_params params2 = {0};
 3638|      0|                params2.timeline = tl;
 3639|      0|                params2.is_top_level = params->is_top_level;
 3640|      0|                params2.stream_record = params->stream_record;
 3641|      0|                params2.depth = params->depth + 1;
 3642|      0|                sub =
 3643|      0|                    open_given_type(global, log, &demuxer_desc_timeline,
 3644|      0|                                    NULL, sinfo, &params2, DEMUX_CHECK_FORCE);
 3645|      0|                if (sub) {
  ------------------
  |  Branch (3645:21): [True: 0, False: 0]
  ------------------
 3646|      0|                    in->can_cache = false;
 3647|      0|                    in->can_record = false;
 3648|      0|                } else {
 3649|      0|                    timeline_destroy(tl);
 3650|      0|                }
 3651|      0|            }
 3652|  24.6k|        }
 3653|       |
 3654|  24.6k|        switch_to_fresh_cache_range(in);
 3655|       |
 3656|  24.6k|        update_opts(demuxer);
 3657|       |
 3658|  24.6k|        demux_update(demuxer, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  24.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3659|       |
 3660|  24.6k|        demuxer = sub ? sub : demuxer;
  ------------------
  |  Branch (3660:19): [True: 0, False: 24.6k]
  ------------------
 3661|  24.6k|        return demuxer;
 3662|  24.6k|    }
 3663|       |
 3664|   366k|    demuxer->stream = NULL;
 3665|   366k|    demux_free(demuxer);
 3666|       |    return NULL;
 3667|   391k|}
demux.c:demux_init_cuesheet:
 3450|  24.6k|{
 3451|  24.6k|    if (demuxer->num_chapters)
  ------------------
  |  Branch (3451:9): [True: 168, False: 24.4k]
  ------------------
 3452|    168|        return;
 3453|       |
 3454|  24.4k|    struct sh_stream *sh = demuxer->in->metadata_stream;
 3455|  24.4k|    char *cue = mp_tags_get_str(demuxer->metadata, "cuesheet");
 3456|  24.4k|    if (!cue && sh)
  ------------------
  |  Branch (3456:9): [True: 24.4k, False: 0]
  |  Branch (3456:17): [True: 20.9k, False: 3.47k]
  ------------------
 3457|  20.9k|        cue = mp_tags_get_str(sh->tags, "cuesheet");
 3458|  24.4k|    if (!cue)
  ------------------
  |  Branch (3458:9): [True: 24.4k, False: 0]
  ------------------
 3459|  24.4k|        return;
 3460|       |
 3461|      0|    struct cue_file *f = mp_parse_cue(bstr0(cue));
 3462|      0|    if (f) {
  ------------------
  |  Branch (3462:9): [True: 0, False: 0]
  ------------------
 3463|      0|        if (mp_check_embedded_cue(f) < 0) {
  ------------------
  |  Branch (3463:13): [True: 0, False: 0]
  ------------------
 3464|      0|            MP_WARN(demuxer, "Embedded cue sheet references zero or multiple files. "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3465|      0|                    "Ignoring it.\n");
 3466|      0|        } else {
 3467|      0|            for (int n = 0; n < f->num_tracks; n++) {
  ------------------
  |  Branch (3467:29): [True: 0, False: 0]
  ------------------
 3468|      0|                struct cue_track *t = &f->tracks[n];
 3469|      0|                int idx = demuxer_add_chapter(demuxer, "", t->start, -1);
 3470|      0|                mp_tags_merge(demuxer->chapters[idx].metadata, t->tags);
 3471|      0|            }
 3472|      0|        }
 3473|      0|        talloc_free(f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3474|      0|    }
 3475|      0|}
demux.c:demux_init_ccs:
 3498|  24.6k|{
 3499|  24.6k|    struct demux_internal *in = demuxer->in;
 3500|  24.6k|    if (!opts->create_ccs)
  ------------------
  |  Branch (3500:9): [True: 24.6k, False: 0]
  ------------------
 3501|  24.6k|        return;
 3502|      0|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3503|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3503:21): [True: 0, False: 0]
  ------------------
 3504|      0|        struct sh_stream *sh = in->streams[n];
 3505|      0|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3505:13): [True: 0, False: 0]
  |  Branch (3505:41): [True: 0, False: 0]
  ------------------
 3506|      0|            demuxer_get_cc_track_locked(sh);
 3507|      0|    }
 3508|      0|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3509|      0|}
demux.c:demux_convert_tags_charset:
 5041|  24.6k|{
 5042|  24.6k|    struct demux_internal *in = demuxer->in;
 5043|       |
 5044|  24.6k|    char *cp = demuxer->opts->meta_cp;
 5045|  24.6k|    if (!cp || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (5045:9): [True: 0, False: 24.6k]
  |  Branch (5045:16): [True: 0, False: 24.6k]
  ------------------
 5046|      0|        return;
 5047|       |
 5048|  24.6k|    char *data = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  24.6k|#define talloc_strdup                   ta_xstrdup
  ------------------
 5049|  24.6k|    visit_meta(demuxer, &data, visit_detect);
 5050|       |
 5051|  24.6k|    in->meta_charset = (char *)mp_charset_guess(in, in->log, bstr0(data), cp, 0);
 5052|  24.6k|    if (in->meta_charset && !mp_charset_is_utf8(in->meta_charset)) {
  ------------------
  |  Branch (5052:9): [True: 24.6k, False: 0]
  |  Branch (5052:29): [True: 517, False: 24.0k]
  ------------------
 5053|    517|        MP_INFO(demuxer, "Using tag charset: %s\n", in->meta_charset);
  ------------------
  |  |   91|    517|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    517|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 5054|    517|        visit_meta(demuxer, demuxer, visit_convert);
 5055|    517|    }
 5056|       |
 5057|  24.6k|    talloc_free(data);
  ------------------
  |  |   47|  24.6k|#define talloc_free                     ta_free
  ------------------
 5058|  24.6k|}
demux.c:visit_meta:
 4995|  25.1k|{
 4996|  25.1k|    struct demux_internal *in = demuxer->in;
 4997|       |
 4998|  49.4k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4998:21): [True: 24.3k, False: 25.1k]
  ------------------
 4999|  24.3k|        struct sh_stream *sh = in->streams[n];
 5000|       |
 5001|  24.3k|        visit(ctx, sh, &sh->title);
 5002|  24.3k|        visit_tags(ctx, visit, sh->tags);
 5003|  24.3k|    }
 5004|       |
 5005|  46.4k|    for (int n = 0; n < demuxer->num_chapters; n++)
  ------------------
  |  Branch (5005:21): [True: 21.3k, False: 25.1k]
  ------------------
 5006|  21.3k|        visit_tags(ctx, visit, demuxer->chapters[n].metadata);
 5007|       |
 5008|  25.1k|    visit_tags(ctx, visit, demuxer->metadata);
 5009|  25.1k|}
demux.c:visit_tags:
 4988|  70.7k|{
 4989|   111k|    for (int n = 0; n < (tags ? tags->num_keys : 0); n++)
  ------------------
  |  Branch (4989:21): [True: 40.6k, False: 70.7k]
  |  Branch (4989:26): [True: 111k, False: 0]
  ------------------
 4990|  40.6k|        visit(ctx, tags, &tags->values[n]);
 4991|  70.7k|}
demux.c:visit_detect:
 5013|  47.1k|{
 5014|  47.1k|    char **all = ctx;
 5015|       |
 5016|  47.1k|    if (*s)
  ------------------
  |  Branch (5016:9): [True: 23.1k, False: 24.0k]
  ------------------
 5017|  23.1k|        *all = talloc_asprintf_append_buffer(*all, "%s\n", *s);
  ------------------
  |  |   64|  23.1k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
 5018|  47.1k|}
demux.c:visit_convert:
 5021|  17.8k|{
 5022|  17.8k|    struct demuxer *demuxer = ctx;
 5023|  17.8k|    struct demux_internal *in = demuxer->in;
 5024|       |
 5025|  17.8k|    if (!*s)
  ------------------
  |  Branch (5025:9): [True: 335, False: 17.5k]
  ------------------
 5026|    335|        return;
 5027|       |
 5028|  17.5k|    bstr data = bstr0(*s);
 5029|  17.5k|    bstr conv = mp_iconv_to_utf8(in->log, data, in->meta_charset,
 5030|  17.5k|                                 MP_ICONV_VERBOSE);
 5031|  17.5k|    if (conv.start && conv.start != data.start) {
  ------------------
  |  Branch (5031:9): [True: 17.5k, False: 0]
  |  Branch (5031:23): [True: 8.15k, False: 9.37k]
  ------------------
 5032|  8.15k|        char *ns = conv.start; // 0-termination is guaranteed
 5033|       |        // (The old string might not be an alloc, but if it is, it's a talloc
 5034|       |        // child, and will not leak, even if it stays allocated uselessly.)
 5035|  8.15k|        *s = ns;
 5036|  8.15k|        talloc_steal(ta, *s);
  ------------------
  |  |   38|  8.15k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  8.15k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5037|  8.15k|    }
 5038|  17.5k|}
demux.c:demux_copy:
 3183|  24.6k|{
 3184|       |    // Note that we do as shallow copies as possible. We expect the data
 3185|       |    // that is not-copied (only referenced) to be immutable.
 3186|       |    // This implies e.g. that no chapters are added after initialization.
 3187|  24.6k|    dst->chapters = src->chapters;
 3188|  24.6k|    dst->num_chapters = src->num_chapters;
 3189|  24.6k|    dst->editions = src->editions;
 3190|  24.6k|    dst->num_editions = src->num_editions;
 3191|  24.6k|    dst->edition = src->edition;
 3192|  24.6k|    dst->edition_is_track_mapping = src->edition_is_track_mapping;
 3193|  24.6k|    dst->attachments = src->attachments;
 3194|  24.6k|    dst->num_attachments = src->num_attachments;
 3195|  24.6k|    dst->matroska_data = src->matroska_data;
 3196|  24.6k|    dst->playlist = src->playlist;
 3197|  24.6k|    dst->seekable = src->seekable;
 3198|  24.6k|    dst->partially_seekable = src->partially_seekable;
 3199|  24.6k|    dst->filetype = src->filetype;
 3200|  24.6k|    dst->ts_resets_possible = src->ts_resets_possible;
 3201|  24.6k|    dst->fully_read = src->fully_read;
 3202|  24.6k|    dst->start_time = src->start_time;
 3203|  24.6k|    dst->duration = src->duration;
 3204|  24.6k|    dst->is_network = src->is_network;
 3205|  24.6k|    dst->is_streaming = src->is_streaming;
 3206|  24.6k|    dst->stream_origin = src->stream_origin;
 3207|  24.6k|    dst->priv = src->priv;
 3208|  24.6k|    dst->metadata = mp_tags_dup(dst, src->metadata);
 3209|  24.6k|}
demux.c:demuxer_sort_chapters:
 4465|  24.6k|{
 4466|  24.6k|    if (demuxer->num_chapters) {
  ------------------
  |  Branch (4466:9): [True: 168, False: 24.4k]
  ------------------
 4467|    168|        qsort(demuxer->chapters, demuxer->num_chapters,
 4468|    168|            sizeof(struct demux_chapter), chapter_compare);
 4469|    168|    }
 4470|  24.6k|}
demux.c:chapter_compare:
 4453|  52.3k|{
 4454|  52.3k|    struct demux_chapter *c1 = (void *)p1;
 4455|  52.3k|    struct demux_chapter *c2 = (void *)p2;
 4456|       |
 4457|  52.3k|    if (c1->pts > c2->pts)
  ------------------
  |  Branch (4457:9): [True: 6.22k, False: 46.0k]
  ------------------
 4458|  6.22k|        return 1;
 4459|  46.0k|    else if (c1->pts < c2->pts)
  ------------------
  |  Branch (4459:14): [True: 3.75k, False: 42.3k]
  ------------------
 4460|  3.75k|        return -1;
 4461|  42.3k|    return c1->original_index > c2->original_index ? 1 :-1; // never equal
  ------------------
  |  Branch (4461:12): [True: 0, False: 42.3k]
  ------------------
 4462|  52.3k|}
demux.c:switch_to_fresh_cache_range:
 4058|  24.6k|{
 4059|  24.6k|    if (!in->seekable_cache && in->current_range) {
  ------------------
  |  Branch (4059:9): [True: 24.6k, False: 0]
  |  Branch (4059:32): [True: 0, False: 24.6k]
  ------------------
 4060|      0|        clear_cached_range(in, in->current_range);
 4061|      0|        return;
 4062|      0|    }
 4063|       |
 4064|  24.6k|    struct demux_cached_range *range = talloc_ptrtype(NULL, range);
  ------------------
  |  |   34|  24.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4065|  24.6k|    *range = (struct demux_cached_range){
 4066|  24.6k|        .seek_start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4067|  24.6k|        .seek_end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4068|  24.6k|    };
 4069|  24.6k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  24.6k|    do {                                            \
  |  |  106|  24.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.6k|    do {                                            \
  |  |  |  |   97|  24.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.6k|    do {                                                        \
  |  |  |  |  |  |   89|  24.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.6k|        (idxvar)++;                                 \
  |  |  109|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
 4070|  24.6k|    add_missing_streams(in, range);
 4071|       |
 4072|  24.6k|    switch_current_range(in, range);
 4073|  24.6k|}
demux.c:switch_current_range:
 3822|  24.6k|{
 3823|  24.6k|    struct demux_cached_range *old = in->current_range;
 3824|  24.6k|    mp_assert(old != range);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (3824:5): [True: 24.6k, False: 0]
  ------------------
 3825|       |
 3826|  24.6k|    set_current_range(in, range);
 3827|       |
 3828|  24.6k|    if (old) {
  ------------------
  |  Branch (3828:9): [True: 0, False: 24.6k]
  ------------------
 3829|       |        // Remove packets which can't be used when seeking back to the range.
 3830|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3830:25): [True: 0, False: 0]
  ------------------
 3831|      0|            struct demux_queue *queue = old->streams[n];
 3832|       |
 3833|       |            // Remove all packets which cannot be involved in seeking.
 3834|      0|            while (queue->head && !queue->head->keyframe)
  ------------------
  |  Branch (3834:20): [True: 0, False: 0]
  |  Branch (3834:35): [True: 0, False: 0]
  ------------------
 3835|      0|                remove_head_packet(queue);
 3836|      0|        }
 3837|       |
 3838|       |        // Exclude weird corner cases that break resuming.
 3839|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3839:25): [True: 0, False: 0]
  ------------------
 3840|      0|            struct demux_stream *ds = in->streams[n]->ds;
 3841|       |            // This is needed to resume or join the range at all.
 3842|      0|            if (ds->selected && !(ds->global_correct_dts ||
  ------------------
  |  Branch (3842:17): [True: 0, False: 0]
  |  Branch (3842:35): [True: 0, False: 0]
  ------------------
 3843|      0|                                  ds->global_correct_pos))
  ------------------
  |  Branch (3843:35): [True: 0, False: 0]
  ------------------
 3844|      0|            {
 3845|      0|                MP_VERBOSE(in, "discarding unseekable range due to stream %d\n", n);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3846|      0|                clear_cached_range(in, old);
 3847|      0|                break;
 3848|      0|            }
 3849|      0|        }
 3850|      0|    }
 3851|       |
 3852|       |    // Set up reading from new range (as well as writing to it).
 3853|  48.6k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3853:21): [True: 24.0k, False: 24.6k]
  ------------------
 3854|  24.0k|        struct demux_stream *ds = in->streams[n]->ds;
 3855|       |
 3856|  24.0k|        ds->queue = range->streams[n];
 3857|  24.0k|        ds->refreshing = false;
 3858|  24.0k|        ds->eof = false;
 3859|  24.0k|    }
 3860|       |
 3861|       |    // No point in keeping any junk (especially if old current_range is empty).
 3862|  24.6k|    free_empty_cached_ranges(in);
 3863|       |
 3864|       |    // The change detection doesn't work across ranges.
 3865|       |    in->force_metadata_update = true;
 3866|  24.6k|}
demux.c:set_current_range:
  589|  24.6k|{
  590|  24.6k|    in->current_range = range;
  591|       |
  592|       |    // Move to in->ranges[in->num_ranges-1] (for LRU sorting/invariant)
  593|  24.6k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (593:21): [True: 24.6k, False: 0]
  ------------------
  594|  24.6k|        if (in->ranges[n] == range) {
  ------------------
  |  Branch (594:13): [True: 24.6k, False: 0]
  ------------------
  595|  24.6k|            MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  24.6k|    do {                                            \
  |  |  144|  24.6k|        size_t at_ = (at);                          \
  |  |  145|  24.6k|        assert(at_ < (idxvar));                     \
  |  |  146|  24.6k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  24.6k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  24.6k|        (idxvar)--;                                 \
  |  |  149|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
  |  Branch (595:13): [True: 24.6k, False: 0]
  ------------------
  596|  24.6k|            break;
  597|  24.6k|        }
  598|  24.6k|    }
  599|  24.6k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  24.6k|    do {                                            \
  |  |  106|  24.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.6k|    do {                                            \
  |  |  |  |   97|  24.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 24.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.6k|        (idxvar)++;                                 \
  |  |  109|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
  600|  24.6k|}
demux.c:clear_reader_state:
  874|   391k|{
  875|   415k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (875:21): [True: 24.0k, False: 391k]
  ------------------
  876|  24.0k|        ds_clear_reader_state(in->streams[n]->ds, clear_back_state);
  877|   391k|    in->warned_queue_overflow = false;
  878|   391k|    in->d_user->filepos = -1; // implicitly synchronized
  879|   391k|    in->blocked = false;
  880|       |    in->need_back_seek = false;
  881|   391k|}
demux.c:clear_cached_range:
  784|  49.2k|{
  785|  97.2k|    for (int n = 0; n < range->num_streams; n++)
  ------------------
  |  Branch (785:21): [True: 48.0k, False: 49.2k]
  ------------------
  786|  48.0k|        clear_queue(range->streams[n]);
  787|       |
  788|  49.2k|    for (int n = 0; n < range->num_metadata; n++)
  ------------------
  |  Branch (788:21): [True: 0, False: 49.2k]
  ------------------
  789|      0|        talloc_free(range->metadata[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  790|  49.2k|    range->num_metadata = 0;
  791|       |
  792|  49.2k|    update_seek_ranges(range);
  793|  49.2k|}
demux.c:free_empty_cached_ranges:
  798|   880k|{
  799|   880k|    while (1) {
  ------------------
  |  Branch (799:12): [True: 880k, Folded]
  ------------------
  800|   880k|        struct demux_cached_range *worst = NULL;
  801|       |
  802|   880k|        int end = in->num_ranges - 1;
  803|       |
  804|       |        // (Not set during early init or late destruction.)
  805|   880k|        if (in->current_range) {
  ------------------
  |  Branch (805:13): [True: 98.2k, False: 782k]
  ------------------
  806|  98.2k|            mp_assert(in->current_range && in->num_ranges > 0);
  ------------------
  |  |   41|  98.2k|#define mp_assert assert
  ------------------
  |  Branch (806:13): [True: 98.2k, False: 0]
  |  Branch (806:13): [True: 98.2k, False: 0]
  ------------------
  807|  98.2k|            mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|  98.2k|#define mp_assert assert
  ------------------
  |  Branch (807:13): [True: 98.2k, False: 0]
  ------------------
  808|  98.2k|            end -= 1;
  809|  98.2k|        }
  810|       |
  811|   905k|        for (int n = end; n >= 0; n--) {
  ------------------
  |  Branch (811:27): [True: 24.6k, False: 880k]
  ------------------
  812|  24.6k|            struct demux_cached_range *range = in->ranges[n];
  813|  24.6k|            if (range->seek_start == MP_NOPTS_VALUE || !in->seekable_cache) {
  ------------------
  |  |   39|  49.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (813:17): [True: 24.6k, False: 0]
  |  Branch (813:56): [True: 0, False: 0]
  ------------------
  814|  24.6k|                clear_cached_range(in, range);
  815|  24.6k|                MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  24.6k|    do {                                            \
  |  |  144|  24.6k|        size_t at_ = (at);                          \
  |  |  145|  24.6k|        assert(at_ < (idxvar));                     \
  |  |  146|  24.6k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  24.6k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  24.6k|        (idxvar)--;                                 \
  |  |  149|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
  |  Branch (815:17): [True: 24.6k, False: 0]
  ------------------
  816|  48.6k|                for (int i = 0; i < range->num_streams; i++)
  ------------------
  |  Branch (816:33): [True: 24.0k, False: 24.6k]
  ------------------
  817|  24.0k|                    talloc_free(range->streams[i]);
  ------------------
  |  |   47|  24.0k|#define talloc_free                     ta_free
  ------------------
  818|  24.6k|                talloc_free(range);
  ------------------
  |  |   47|  24.6k|#define talloc_free                     ta_free
  ------------------
  819|  24.6k|            } else {
  820|      0|                if (!worst || (range->seek_end - range->seek_start <
  ------------------
  |  Branch (820:21): [True: 0, False: 0]
  |  Branch (820:31): [True: 0, False: 0]
  ------------------
  821|      0|                               worst->seek_end - worst->seek_start))
  822|      0|                    worst = range;
  823|      0|            }
  824|  24.6k|        }
  825|       |
  826|   880k|        if (in->num_ranges <= MAX_SEEK_RANGES || !worst)
  ------------------
  |  |   33|  1.76M|#define MAX_SEEK_RANGES 10
  ------------------
  |  Branch (826:13): [True: 880k, False: 0]
  |  Branch (826:50): [True: 0, False: 0]
  ------------------
  827|   880k|            break;
  828|       |
  829|      0|        clear_cached_range(in, worst);
  830|      0|    }
  831|   880k|}
demux.c:select_track:
 4290|  26.5k|{
 4291|  26.5k|    struct demux_stream *ds = stream->ds;
 4292|  26.5k|    if (ds->selected == selected)
  ------------------
  |  Branch (4292:9): [True: 2.12k, False: 24.4k]
  ------------------
 4293|  2.12k|        return false;
 4294|  24.4k|    MP_VERBOSE(in, "%sselect track %d\n", selected ? "" : "de", stream->index);
  ------------------
  |  |   92|  24.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  48.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 21.8k, False: 2.51k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4295|  24.4k|    ds->selected = selected;
 4296|  24.4k|    update_stream_selection_state(in, ds);
 4297|  24.4k|    in->tracks_switched = true;
 4298|  24.4k|    if (ds->selected)
  ------------------
  |  Branch (4298:9): [True: 21.8k, False: 2.51k]
  ------------------
 4299|  21.8k|        refresh_track(in, stream, ref_pts);
 4300|       |    return true;
 4301|  26.5k|}
demux.c:select_dependent_tracks:
 4307|  26.5k|{
 4308|  26.5k|    bool changed = false;
 4309|  26.5k|    if (stream->group && !stream->dependent_track) {
  ------------------
  |  Branch (4309:9): [True: 0, False: 26.5k]
  |  Branch (4309:26): [True: 0, False: 0]
  ------------------
 4310|      0|        for (int i = 0; i < stream->group->num_members; i++) {
  ------------------
  |  Branch (4310:25): [True: 0, False: 0]
  ------------------
 4311|      0|            struct sh_stream *m = stream->group->members[i];
 4312|      0|            mp_assert(m);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (4312:13): [True: 0, False: 0]
  ------------------
 4313|      0|            if (m != stream && m->dependent_track)
  ------------------
  |  Branch (4313:17): [True: 0, False: 0]
  |  Branch (4313:32): [True: 0, False: 0]
  ------------------
 4314|      0|                changed |= select_track(in, m, ref_pts, selected);
 4315|      0|        }
 4316|      0|    }
 4317|  26.5k|    return changed;
 4318|  26.5k|}
demux.c:execute_trackswitch:
 2580|  19.7k|{
 2581|  19.7k|    in->tracks_switched = false;
 2582|       |
 2583|  19.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2584|       |
 2585|  19.7k|    if (in->d_thread->desc->switched_tracks)
  ------------------
  |  Branch (2585:9): [True: 18.6k, False: 1.05k]
  ------------------
 2586|  18.6k|        in->d_thread->desc->switched_tracks(in->d_thread);
 2587|       |
 2588|  19.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2589|  19.7k|}
demux.c:update_stream_selection_state:
  948|  48.4k|{
  949|  48.4k|    ds->eof = false;
  950|  48.4k|    ds->refreshing = false;
  951|       |
  952|  48.4k|    update_stream_eager_state(in);
  953|       |
  954|  48.4k|    ds_clear_reader_state(ds, true);
  955|       |
  956|       |    // Make sure any stream reselection or addition is reflected in the seek
  957|       |    // ranges, and also get rid of data that is not needed anymore (or
  958|       |    // rather, which can't be kept consistent). This has to happen after we've
  959|       |    // updated all the subtle state (like s->eager).
  960|  72.8k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (960:21): [True: 24.4k, False: 48.4k]
  ------------------
  961|  24.4k|        struct demux_cached_range *range = in->ranges[n];
  962|       |
  963|  24.4k|        if (!ds->selected)
  ------------------
  |  Branch (963:13): [True: 2.52k, False: 21.8k]
  ------------------
  964|  2.52k|            clear_queue(range->streams[ds->index]);
  965|       |
  966|  24.4k|        update_seek_ranges(range);
  967|  24.4k|    }
  968|       |
  969|  48.4k|    free_empty_cached_ranges(in);
  970|       |
  971|  48.4k|    wakeup_ds(ds);
  972|  48.4k|}
demux.c:refresh_track:
 4256|  21.8k|{
 4257|  21.8k|    struct demux_stream *ds = stream->ds;
 4258|  21.8k|    ref_pts = MP_ADD_PTS(ref_pts, -in->ts_offset);
  ------------------
  |  |   67|  21.8k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  21.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 21.8k]
  |  |  ------------------
  ------------------
 4259|       |
 4260|  21.8k|    if (in->back_demuxing)
  ------------------
  |  Branch (4260:9): [True: 0, False: 21.8k]
  ------------------
 4261|      0|        ds->back_seek_pos = ref_pts;
 4262|       |    // Avoid refresh seek for video streams except when immediately after a seek
 4263|       |    // to ensure a correct seek position.
 4264|  21.8k|    bool avoid_refresh = false;
 4265|  36.3k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4265:21): [True: 26.9k, False: 9.33k]
  ------------------
 4266|  26.9k|        struct demux_stream *ds_n = in->streams[n]->ds;
 4267|  26.9k|        if (ds_n->type == STREAM_VIDEO && ds_n->selected) {
  ------------------
  |  Branch (4267:13): [True: 12.5k, False: 14.4k]
  |  Branch (4267:43): [True: 12.5k, False: 4]
  ------------------
 4268|  12.5k|            avoid_refresh = true;
 4269|  12.5k|            break;
 4270|  12.5k|        }
 4271|  26.9k|    }
 4272|  21.8k|    avoid_refresh = avoid_refresh && !(in->after_seek && !in->after_seek_to_start);
  ------------------
  |  Branch (4272:21): [True: 12.5k, False: 9.33k]
  |  Branch (4272:40): [True: 12.5k, False: 2]
  |  Branch (4272:58): [True: 0, False: 12.5k]
  ------------------
 4273|       |    // Allow refresh seek for non-video streams, even if no packets have
 4274|       |    // ever been read yet or after seeking. This is necessary because:
 4275|       |    // - A-V sync targets may come from different demuxers, so enabling an external
 4276|       |    //   audio track for the first time can cause desync since a seek is not performed.
 4277|       |    // - If cache is enabled and a seek causes some new data to be cached, the demuxer
 4278|       |    //   is sought to the end of cache after cache joining. Switching track immediately
 4279|       |    //   after this also causes the same problem.
 4280|  21.8k|    if (!in->after_seek || (ds->type != STREAM_VIDEO && !avoid_refresh)) {
  ------------------
  |  Branch (4280:9): [True: 2, False: 21.8k]
  |  Branch (4280:29): [True: 12.1k, False: 9.69k]
  |  Branch (4280:57): [True: 9.33k, False: 2.86k]
  ------------------
 4281|  9.33k|        MP_VERBOSE(in, "refresh track %d (%s)\n", stream->index,
  ------------------
  |  |   92|  9.33k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.33k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4282|  9.33k|                   stream_type_name(ds->type));
 4283|  9.33k|        initiate_refresh_seek(in, ds, ref_pts);
 4284|  9.33k|    }
 4285|  21.8k|}
demux.c:initiate_refresh_seek:
 4184|  9.33k|{
 4185|  9.33k|    struct demuxer *demux = in->d_thread;
 4186|  9.33k|    bool seekable = demux->desc->seek && demux->seekable &&
  ------------------
  |  Branch (4186:21): [True: 9.33k, False: 0]
  |  Branch (4186:42): [True: 9.33k, False: 0]
  ------------------
 4187|  9.33k|                    !demux->partially_seekable;
  ------------------
  |  Branch (4187:21): [True: 9.33k, False: 0]
  ------------------
 4188|       |
 4189|  9.33k|    bool normal_seek = true;
 4190|  9.33k|    bool refresh_possible = true;
 4191|  18.7k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4191:21): [True: 9.45k, False: 9.33k]
  ------------------
 4192|  9.45k|        struct demux_stream *ds = in->streams[n]->ds;
 4193|       |
 4194|  9.45k|        if (!ds->selected)
  ------------------
  |  Branch (4194:13): [True: 117, False: 9.33k]
  ------------------
 4195|    117|            continue;
 4196|       |
 4197|  9.33k|        if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
  ------------------
  |  Branch (4197:13): [True: 2, False: 9.33k]
  |  Branch (4197:41): [True: 9.33k, False: 0]
  ------------------
 4198|  9.33k|            start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
  ------------------
  |  |   64|  9.33k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  18.6k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 2, False: 9.33k]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 9.33k]
  |  |  |  |  |  Branch (45:29): [True: 9.33k, False: 2]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 2]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 9.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|       |
 4200|       |        // If there were no other streams selected, we can use a normal seek.
 4201|  9.33k|        normal_seek &= stream == ds;
 4202|       |
 4203|  9.33k|        refresh_possible &= ds->queue->correct_dts || ds->queue->correct_pos;
  ------------------
  |  Branch (4203:29): [True: 9.33k, False: 0]
  |  Branch (4203:55): [True: 0, False: 0]
  ------------------
 4204|  9.33k|    }
 4205|       |
 4206|  9.33k|    if (start_ts == MP_NOPTS_VALUE || !seekable)
  ------------------
  |  |   39|  18.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4206:9): [True: 0, False: 9.33k]
  |  Branch (4206:39): [True: 0, False: 9.33k]
  ------------------
 4207|      0|        return;
 4208|       |
 4209|  9.33k|    if (!normal_seek) {
  ------------------
  |  Branch (4209:9): [True: 2, False: 9.33k]
  ------------------
 4210|      2|        if (!refresh_possible) {
  ------------------
  |  Branch (4210:13): [True: 0, False: 2]
  ------------------
 4211|      0|            MP_VERBOSE(in, "can't issue refresh seek\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4212|      0|            return;
 4213|      0|        }
 4214|       |
 4215|      7|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4215:25): [True: 5, False: 2]
  ------------------
 4216|      5|            struct demux_stream *ds = in->streams[n]->ds;
 4217|       |
 4218|      5|            bool correct_pos = ds->queue->correct_pos;
 4219|      5|            bool correct_dts = ds->queue->correct_dts;
 4220|       |
 4221|       |            // We need to re-read all packets anyway, so discard the buffered
 4222|       |            // data. (In theory, we could keep the packets, and be able to use
 4223|       |            // it for seeking if partially read streams are deselected again,
 4224|       |            // but this causes other problems like queue overflows when
 4225|       |            // selecting a new stream.)
 4226|      5|            ds_clear_reader_queue_state(ds);
 4227|      5|            clear_queue(ds->queue);
 4228|       |
 4229|       |            // Streams which didn't have any packets yet will return all packets,
 4230|       |            // other streams return packets only starting from the last position.
 4231|      5|            if (ds->selected && (ds->last_ret_pos != -1 ||
  ------------------
  |  Branch (4231:17): [True: 4, False: 1]
  |  Branch (4231:34): [True: 0, False: 4]
  ------------------
 4232|      4|                                 ds->last_ret_dts != MP_NOPTS_VALUE))
  ------------------
  |  |   39|      4|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4232:34): [True: 0, False: 4]
  ------------------
 4233|      0|            {
 4234|      0|                ds->refreshing = true;
 4235|      0|                ds->queue->correct_dts = correct_dts;
 4236|      0|                ds->queue->correct_pos = correct_pos;
 4237|      0|                ds->queue->last_pos = ds->last_ret_pos;
 4238|      0|                ds->queue->last_dts = ds->last_ret_dts;
 4239|      0|            }
 4240|       |
 4241|      5|            update_seek_ranges(in->current_range);
 4242|      5|        }
 4243|       |
 4244|      2|        start_ts -= 1.0; // small offset to get correct overlap
 4245|      2|    }
 4246|       |
 4247|  9.33k|    MP_VERBOSE(in, "refresh seek to %f\n", start_ts);
  ------------------
  |  |   92|  9.33k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.33k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4248|  9.33k|    in->seeking = true;
 4249|  9.33k|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|  9.33k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 4250|  9.33k|    in->seek_pts = start_ts;
 4251|  9.33k|}
demux.c:wakeup_ds:
  887|  1.46M|{
  888|  1.46M|    if (ds->need_wakeup) {
  ------------------
  |  Branch (888:9): [True: 72.8k, False: 1.39M]
  ------------------
  889|  72.8k|        if (ds->wakeup_cb) {
  ------------------
  |  Branch (889:13): [True: 24.4k, False: 48.4k]
  ------------------
  890|  24.4k|            ds->wakeup_cb(ds->wakeup_cb_ctx);
  891|  48.4k|        } else if (ds->in->wakeup_cb) {
  ------------------
  |  Branch (891:20): [True: 24.4k, False: 24.0k]
  ------------------
  892|  24.4k|            ds->in->wakeup_cb(ds->in->wakeup_cb_ctx);
  893|  24.4k|        }
  894|       |        ds->need_wakeup = false;
  895|  72.8k|        mp_cond_signal(&ds->in->wakeup);
  896|  72.8k|    }
  897|  1.46M|}
demux.c:update_cache:
 4528|  1.56M|{
 4529|  1.56M|    struct demuxer *demuxer = in->d_thread;
 4530|  1.56M|    struct stream *stream = demuxer->stream;
 4531|       |
 4532|  1.56M|    int64_t now = mp_time_ns();
 4533|  1.56M|    int64_t diff = now - in->last_speed_query;
 4534|  1.56M|    bool do_update = diff >= MP_TIME_S_TO_NS(1) || !in->last_speed_query;
  ------------------
  |  |   71|  3.12M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (4534:22): [True: 24.6k, False: 1.53M]
  |  Branch (4534:52): [True: 2, False: 1.53M]
  ------------------
 4535|       |
 4536|       |    // Don't lock while querying the stream.
 4537|  1.56M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.56M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4538|       |
 4539|  1.56M|    int64_t stream_size = -1;
 4540|  1.56M|    struct mp_tags *stream_metadata = NULL;
 4541|  1.56M|    if (stream) {
  ------------------
  |  Branch (4541:9): [True: 1.55M, False: 6.53k]
  ------------------
 4542|  1.55M|        if (do_update)
  ------------------
  |  Branch (4542:13): [True: 19.9k, False: 1.53M]
  ------------------
 4543|  19.9k|            stream_size = stream_get_size(stream);
 4544|  1.55M|        stream_control(stream, STREAM_CTRL_GET_METADATA, &stream_metadata);
 4545|  1.55M|    }
 4546|       |
 4547|  1.56M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.56M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4548|       |
 4549|  1.56M|    update_bytes_read(in);
 4550|       |
 4551|  1.56M|    if (do_update)
  ------------------
  |  Branch (4551:9): [True: 24.6k, False: 1.53M]
  ------------------
 4552|  24.6k|        in->stream_size = stream_size;
 4553|  1.56M|    if (stream_metadata) {
  ------------------
  |  Branch (4553:9): [True: 0, False: 1.56M]
  ------------------
 4554|      0|        add_timed_metadata(in, stream_metadata, NULL, MP_NOPTS_VALUE);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4555|      0|        talloc_free(stream_metadata);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4556|      0|    }
 4557|       |
 4558|  1.56M|    in->next_cache_update = INT64_MAX;
 4559|       |
 4560|  1.56M|    if (do_update) {
  ------------------
  |  Branch (4560:9): [True: 24.6k, False: 1.53M]
  ------------------
 4561|  24.6k|        uint64_t bytes = in->cache_unbuffered_read_bytes;
 4562|  24.6k|        in->cache_unbuffered_read_bytes = 0;
 4563|  24.6k|        in->last_speed_query = now;
 4564|  24.6k|        double speed = bytes / (diff / (double)MP_TIME_S_TO_NS(1));
  ------------------
  |  |   71|  24.6k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
 4565|  24.6k|        in->bytes_per_second = 0.5 * in->speed_query_prev_sample +
 4566|  24.6k|                               0.5 * speed;
 4567|  24.6k|        in->speed_query_prev_sample = speed;
 4568|  24.6k|    }
 4569|       |    // The idea is to update as long as there is "activity".
 4570|  1.56M|    if (in->bytes_per_second)
  ------------------
  |  Branch (4570:9): [True: 1.52M, False: 36.9k]
  ------------------
 4571|  1.52M|        in->next_cache_update = now + MP_TIME_S_TO_NS(1) + MP_TIME_US_TO_NS(1);
  ------------------
  |  |   71|  1.52M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
                      in->next_cache_update = now + MP_TIME_S_TO_NS(1) + MP_TIME_US_TO_NS(1);
  ------------------
  |  |   73|  1.52M|#define MP_TIME_US_TO_NS(us) ((us) * INT64_C(1000))
  ------------------
 4572|  1.56M|}
demux.c:dumper_close:
 4575|   391k|{
 4576|   391k|    if (in->dumper)
  ------------------
  |  Branch (4576:9): [True: 0, False: 391k]
  ------------------
 4577|      0|        mp_recorder_destroy(in->dumper);
 4578|   391k|    in->dumper = NULL;
 4579|   391k|    if (in->dumper_status == CONTROL_TRUE)
  ------------------
  |  |   96|   391k|#define CONTROL_TRUE 1
  ------------------
  |  Branch (4579:9): [True: 0, False: 391k]
  ------------------
 4580|      0|        in->dumper_status = CONTROL_FALSE; // make abort equal to success
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 4581|   391k|}
demux.c:compute_keyframe_times:
 1981|  1.31M|{
 1982|  1.31M|    struct demux_packet *start = pkt;
 1983|  1.31M|    double min = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.31M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1984|  1.31M|    double max = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.31M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1985|       |
 1986|  2.70M|    while (pkt) {
  ------------------
  |  Branch (1986:12): [True: 2.69M, False: 10.9k]
  ------------------
 1987|  2.69M|        if (pkt->keyframe && pkt != start)
  ------------------
  |  Branch (1987:13): [True: 2.61M, False: 81.1k]
  |  Branch (1987:30): [True: 1.30M, False: 1.31M]
  ------------------
 1988|  1.30M|            break;
 1989|       |
 1990|  1.39M|        double ts = MP_PTS_OR_DEF(pkt->pts, pkt->dts);
  ------------------
  |  |   62|  1.39M|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|  1.39M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 3.98k, False: 1.39M]
  |  |  ------------------
  ------------------
 1991|  1.39M|        if (pkt->segmented && ((pkt->start != MP_NOPTS_VALUE && ts < pkt->start) ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1991:13): [True: 0, False: 1.39M]
  |  Branch (1991:33): [True: 0, False: 0]
  |  Branch (1991:65): [True: 0, False: 0]
  ------------------
 1992|      0|                               (pkt->end != MP_NOPTS_VALUE && ts > pkt->end)))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1992:33): [True: 0, False: 0]
  |  Branch (1992:63): [True: 0, False: 0]
  ------------------
 1993|      0|            ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1994|       |
 1995|  1.39M|        min = MP_PTS_MIN(min, ts);
  ------------------
  |  |   64|  1.39M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  2.78M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 1.39M]
  |  |  |  |  |  Branch (45:23): [True: 1.31M, False: 81.1k]
  |  |  |  |  |  Branch (45:29): [True: 3.98k, False: 1.39M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 1.31M, False: 81.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1996|  1.39M|        max = MP_PTS_MAX(max, ts);
  ------------------
  |  |   65|  1.39M|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  2.78M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 1.39M]
  |  |  |  |  |  Branch (44:23): [True: 1.31M, False: 81.1k]
  |  |  |  |  |  Branch (44:29): [True: 3.98k, False: 1.39M]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 3.98k, False: 1.39M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|  1.39M|        pkt = pkt->next;
 1999|  1.39M|    }
 2000|       |
 2001|  1.31M|    if (out_kf_min)
  ------------------
  |  Branch (2001:9): [True: 1.31M, False: 0]
  ------------------
 2002|  1.31M|        *out_kf_min = min;
 2003|  1.31M|    if (out_kf_max)
  ------------------
  |  Branch (2003:9): [True: 1.31M, False: 0]
  ------------------
 2004|  1.31M|        *out_kf_max = max;
 2005|  1.31M|    return pkt;
 2006|  1.31M|}
demux.c:update_bytes_read:
 4505|  1.56M|{
 4506|  1.56M|    struct demuxer *demuxer = in->d_thread;
 4507|       |
 4508|  1.56M|    int64_t new = in->slave_unbuffered_read_bytes;
 4509|  1.56M|    in->slave_unbuffered_read_bytes = 0;
 4510|       |
 4511|  1.56M|    int64_t new_seeks = 0;
 4512|       |
 4513|  1.56M|    struct stream *stream = demuxer->stream;
 4514|  1.56M|    if (stream) {
  ------------------
  |  Branch (4514:9): [True: 1.55M, False: 6.53k]
  ------------------
 4515|  1.55M|        new += stream->total_unbuffered_read_bytes;
 4516|  1.55M|        stream->total_unbuffered_read_bytes = 0;
 4517|  1.55M|        new_seeks += stream->total_stream_seeks;
 4518|  1.55M|        stream->total_stream_seeks = 0;
 4519|  1.55M|    }
 4520|       |
 4521|  1.56M|    in->cache_unbuffered_read_bytes += new;
 4522|  1.56M|    in->hack_unbuffered_read_bytes += new;
 4523|  1.56M|    in->byte_level_seeks += new_seeks;
 4524|  1.56M|}
demux.c:get_forward_buffered_bytes:
  491|  6.02M|{
  492|  6.02M|    if (!ds->reader_head)
  ------------------
  |  Branch (492:9): [True: 311k, False: 5.70M]
  ------------------
  493|   311k|        return 0;
  494|  5.70M|    return ds->queue->tail_cum_pos - ds->reader_head->cum_pos;
  495|  6.02M|}
demux.c:get_demux_sub_opts:
 5061|   376k|{
 5062|   376k|    if (!demuxer_list[index])
  ------------------
  |  Branch (5062:9): [True: 28.9k, False: 347k]
  ------------------
 5063|  28.9k|        return false;
 5064|   347k|    *sub = demuxer_list[index]->options;
 5065|       |    return true;
 5066|   376k|}

demux_cue.c:try_open_file:
  248|  40.1k|{
  249|  40.1k|    if (!demuxer->access_references)
  ------------------
  |  Branch (249:9): [True: 0, False: 40.1k]
  ------------------
  250|      0|        return -1;
  251|       |
  252|  40.1k|    struct stream *s = demuxer->stream;
  253|  40.1k|    if (check >= DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (253:9): [True: 40.1k, False: 0]
  ------------------
  254|  40.1k|        char probe[PROBE_SIZE];
  255|  40.1k|        int len = stream_read_peek(s, probe, sizeof(probe));
  256|  40.1k|        if (len < 1 || !mp_probe_cue((bstr){probe, len}))
  ------------------
  |  Branch (256:13): [True: 42, False: 40.1k]
  |  Branch (256:24): [True: 39.8k, False: 260]
  ------------------
  257|  39.9k|            return -1;
  258|  40.1k|    }
  259|    260|    struct priv *p = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|    260|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    260|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    260|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|    260|    demuxer->priv = p;
  261|    260|    demuxer->fully_read = true;
  262|    260|    bstr data = stream_read_complete(s, p, 1000000);
  263|    260|    if (data.start == NULL)
  ------------------
  |  Branch (263:9): [True: 0, False: 260]
  ------------------
  264|      0|        return -1;
  265|       |
  266|    260|    struct demux_opts *opts = mp_get_config_group(p, demuxer->global, &demux_conf);
  267|    260|    const char *charset = mp_charset_guess(p, demuxer->log, data, opts->meta_cp, 0);
  268|    260|    if (charset && !mp_charset_is_utf8(charset)) {
  ------------------
  |  Branch (268:9): [True: 260, False: 0]
  |  Branch (268:20): [True: 220, False: 40]
  ------------------
  269|    220|        MP_INFO(demuxer, "Using CUE charset: %s\n", charset);
  ------------------
  |  |   91|    220|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    220|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  270|    220|        bstr utf8 = mp_iconv_to_utf8(demuxer->log, data, charset, MP_ICONV_VERBOSE);
  271|    220|        if (utf8.start && utf8.start != data.start) {
  ------------------
  |  Branch (271:13): [True: 220, False: 0]
  |  Branch (271:27): [True: 220, False: 0]
  ------------------
  272|    220|            ta_steal(data.start, utf8.start);
  ------------------
  |  |  100|    220|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  ------------------
  273|    220|            data = utf8;
  274|    220|        }
  275|    220|    }
  276|    260|    talloc_free(opts);
  ------------------
  |  |   47|    260|#define talloc_free                     ta_free
  ------------------
  277|       |
  278|    260|    p->f = mp_parse_cue(data);
  279|    260|    talloc_steal(p, p->f);
  ------------------
  |  |   38|    260|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    260|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  280|    260|    if (!p->f) {
  ------------------
  |  Branch (280:9): [True: 226, False: 34]
  ------------------
  281|    226|        MP_ERR(demuxer, "error parsing input file!\n");
  ------------------
  |  |   89|    226|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    226|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  282|    226|        return -1;
  283|    226|    }
  284|       |
  285|     34|    demux_close_stream(demuxer);
  286|       |
  287|     34|    mp_tags_merge(demuxer->metadata, p->f->tags);
  288|     34|    return 0;
  289|    260|}
demux_cue.c:build_timeline:
  140|     34|{
  141|     34|    struct priv *p = tl->demuxer->priv;
  142|       |
  143|     34|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|     34|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|     34|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  144|       |
  145|     34|    add_source(tl, tl->demuxer);
  146|       |
  147|     34|    struct cue_track *tracks = NULL;
  148|     34|    size_t track_count = 0;
  149|       |
  150|     34|    for (size_t n = 0; n < p->f->num_tracks; n++) {
  ------------------
  |  Branch (150:24): [True: 0, False: 34]
  ------------------
  151|      0|        struct cue_track *track = &p->f->tracks[n];
  152|      0|        if (track->filename) {
  ------------------
  |  Branch (152:13): [True: 0, False: 0]
  ------------------
  153|      0|            MP_TARRAY_APPEND(ctx, tracks, track_count, *track);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  154|      0|        } else {
  155|      0|            MP_WARN(tl->demuxer, "No file specified for track entry %zd. "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  156|      0|                    "It will be removed\n", n + 1);
  157|      0|        }
  158|      0|    }
  159|       |
  160|     34|    if (track_count == 0) {
  ------------------
  |  Branch (160:9): [True: 34, False: 0]
  ------------------
  161|     34|        MP_ERR(tl, "CUE: no tracks found!\n");
  ------------------
  |  |   89|     34|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     34|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  162|     34|        goto out;
  163|     34|    }
  164|       |
  165|       |    // Remove duplicate file entries. This might be too sophisticated, since
  166|       |    // CUE files usually use either separate files for every single track, or
  167|       |    // only one file for all tracks.
  168|       |
  169|      0|    char **files = 0;
  170|      0|    size_t file_count = 0;
  171|       |
  172|      0|    for (size_t n = 0; n < track_count; n++) {
  ------------------
  |  Branch (172:24): [True: 0, False: 0]
  ------------------
  173|      0|        struct cue_track *track = &tracks[n];
  174|      0|        track->source = -1;
  175|      0|        for (size_t file = 0; file < file_count; file++) {
  ------------------
  |  Branch (175:31): [True: 0, False: 0]
  ------------------
  176|      0|            if (strcmp(files[file], track->filename) == 0) {
  ------------------
  |  Branch (176:17): [True: 0, False: 0]
  ------------------
  177|      0|                track->source = file;
  178|      0|                break;
  179|      0|            }
  180|      0|        }
  181|      0|        if (track->source == -1) {
  ------------------
  |  Branch (181:13): [True: 0, False: 0]
  ------------------
  182|      0|            file_count++;
  183|      0|            files = talloc_realloc(ctx, files, char *, file_count);
  ------------------
  |  |   33|      0|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|      0|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|      0|            files[file_count - 1] = track->filename;
  185|      0|            track->source = file_count - 1;
  186|      0|        }
  187|      0|    }
  188|       |
  189|      0|    for (size_t i = 0; i < file_count; i++) {
  ------------------
  |  Branch (189:24): [True: 0, False: 0]
  ------------------
  190|      0|        if (!open_source(tl, files[i]))
  ------------------
  |  Branch (190:13): [True: 0, False: 0]
  ------------------
  191|      0|            goto out;
  192|      0|    }
  193|       |
  194|      0|    struct timeline_part *timeline = talloc_array_ptrtype(tl, timeline,
  ------------------
  |  |   36|      0|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|      0|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|      0|                                                          track_count + 1);
  196|      0|    struct demux_chapter *chapters = talloc_array_ptrtype(tl, chapters,
  ------------------
  |  |   36|      0|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|      0|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  197|      0|                                                          track_count);
  198|      0|    double starttime = 0;
  199|      0|    for (int i = 0; i < track_count; i++) {
  ------------------
  |  Branch (199:21): [True: 0, False: 0]
  ------------------
  200|      0|        struct demuxer *source = tl->sources[1 + tracks[i].source];
  201|      0|        double duration;
  202|      0|        if (i + 1 < track_count && tracks[i].source == tracks[i + 1].source) {
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  |  Branch (202:36): [True: 0, False: 0]
  ------------------
  203|      0|            duration = tracks[i + 1].start - tracks[i].start;
  204|      0|        } else {
  205|      0|            duration = source->duration;
  206|       |            // Two cases: 1) last track of a single-file cue, or 2) any track of
  207|       |            // a multi-file cue. We need to do this for 1) only because the
  208|       |            // timeline needs to be terminated with the length of the last
  209|       |            // track.
  210|      0|            duration -= tracks[i].start;
  211|      0|        }
  212|      0|        if (duration < 0) {
  ------------------
  |  Branch (212:13): [True: 0, False: 0]
  ------------------
  213|      0|            MP_WARN(tl, "CUE: Can't get duration of source file!\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  214|       |            // xxx: do something more reasonable
  215|      0|            duration = 0.0;
  216|      0|        }
  217|      0|        timeline[i] = (struct timeline_part) {
  218|      0|            .start = starttime,
  219|      0|            .end = starttime + duration,
  220|      0|            .source_start = tracks[i].start,
  221|      0|            .source = source,
  222|      0|        };
  223|      0|        chapters[i] = (struct demux_chapter) {
  224|      0|            .pts = timeline[i].start,
  225|      0|            .metadata = mp_tags_dup(tl, tracks[i].tags),
  226|      0|        };
  227|      0|        starttime = timeline[i].end;
  228|      0|    }
  229|       |
  230|      0|    struct timeline_par *par = talloc_ptrtype(tl, par);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|      0|    *par = (struct timeline_par){
  232|      0|        .parts = timeline,
  233|      0|        .num_parts = track_count,
  234|      0|        .track_layout = timeline[0].source,
  235|      0|    };
  236|       |
  237|      0|    tl->chapters = chapters;
  238|      0|    tl->num_chapters = track_count;
  239|      0|    MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  240|      0|    tl->meta = par->track_layout;
  241|      0|    tl->format = "cue";
  242|       |
  243|     34|out:
  244|     34|    talloc_free(ctx);
  ------------------
  |  |   47|     34|#define talloc_free                     ta_free
  ------------------
  245|     34|}
demux_cue.c:add_source:
   49|     34|{
   50|     34|    MP_TARRAY_APPEND(tl, tl->sources, tl->num_sources, d);
  ------------------
  |  |  105|     34|    do {                                            \
  |  |  106|     34|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     34|    do {                                            \
  |  |  |  |   97|     34|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     34|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     34|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     34|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 34, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     34|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     34|    do {                                                        \
  |  |  |  |  |  |   89|     34|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     34|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     34|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     34|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     34|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     34|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     34|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 34]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     34|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     34|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     34|        (idxvar)++;                                 \
  |  |  109|     34|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 34]
  |  |  ------------------
  ------------------
   51|     34|}

demux_disc.c:d_open:
 1133|  40.3k|{
 1134|  40.3k|    struct priv *p = demuxer->priv = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|  40.3k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.3k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1135|  40.3k|    p->disc_audio_id = -1;
 1136|  40.3k|    p->applied_seg = -1;
 1137|  40.3k|    p->skip_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  40.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1138|       |
 1139|  40.3k|    if (check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (1139:9): [True: 40.3k, False: 0]
  ------------------
 1140|  40.3k|        return -1;
 1141|       |
 1142|      0|    struct demuxer_params params = {
 1143|      0|        .force_format = "+lavf",
 1144|      0|        .external_stream = demuxer->stream,
 1145|      0|        .stream_flags = demuxer->stream_origin,
 1146|      0|        .depth = demuxer->depth + 1,
 1147|      0|    };
 1148|       |
 1149|      0|    struct stream *cur = demuxer->stream;
 1150|      0|    const char *sname = "";
 1151|      0|    if (cur->info)
  ------------------
  |  Branch (1151:9): [True: 0, False: 0]
  ------------------
 1152|      0|        sname = cur->info->name;
 1153|       |
 1154|      0|    p->is_cdda = strcmp(sname, "cdda") == 0;
 1155|      0|    p->is_dvd = strcmp(sname, "dvdnav") == 0 ||
  ------------------
  |  Branch (1155:17): [True: 0, False: 0]
  ------------------
 1156|      0|                strcmp(sname, "ifo_dvdnav") == 0;
  ------------------
  |  Branch (1156:17): [True: 0, False: 0]
  ------------------
 1157|      0|    p->is_dvda = strcmp(sname, "dvda") == 0 ||
  ------------------
  |  Branch (1157:18): [True: 0, False: 0]
  ------------------
 1158|      0|                 strcmp(sname, "ifo_dvda") == 0;
  ------------------
  |  Branch (1158:18): [True: 0, False: 0]
  ------------------
 1159|      0|    p->is_bd = strcmp(sname, "bd") == 0 ||
  ------------------
  |  Branch (1159:16): [True: 0, False: 0]
  ------------------
 1160|      0|               strcmp(sname, "bdmv/bluray") == 0;
  ------------------
  |  Branch (1160:16): [True: 0, False: 0]
  ------------------
 1161|       |
 1162|      0|    if (p->is_cdda)
  ------------------
  |  Branch (1162:9): [True: 0, False: 0]
  ------------------
 1163|      0|        params.force_format = "+rawaudio";
 1164|       |
 1165|      0|    char *t = NULL;
 1166|      0|    stream_control(demuxer->stream, STREAM_CTRL_GET_DISC_NAME, &t);
 1167|      0|    if (t) {
  ------------------
  |  Branch (1167:9): [True: 0, False: 0]
  ------------------
 1168|      0|        mp_tags_set_str(demuxer->metadata, "TITLE", t);
 1169|      0|        talloc_free(t);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1170|      0|    }
 1171|       |
 1172|       |    // The disc VM settles at its starting position only when data is read
 1173|       |    // (at least with libdvdnav), and what it plays there is what the stream
 1174|       |    // declares below.
 1175|      0|    stream_read_peek(demuxer->stream, &(char){0}, 1);
 1176|       |
 1177|       |    // Boundaries settled before the first slave open predate any player
 1178|       |    // state to resync, release them so the probe can read.
 1179|      0|    if (!p->is_dvd)
  ------------------
  |  Branch (1179:9): [True: 0, False: 0]
  ------------------
 1180|      0|        stream_control(demuxer->stream, STREAM_CTRL_NAV_DRAIN_ACK, NULL);
 1181|       |
 1182|      0|    register_declared_streams(demuxer);
 1183|       |
 1184|      0|    p->slave = demux_open_url("-", &params, demuxer->cancel, demuxer->global);
 1185|      0|    if (!p->slave)
  ------------------
  |  Branch (1185:9): [True: 0, False: 0]
  ------------------
 1186|      0|        return -1;
 1187|       |
 1188|       |    // Jumps during open/probe predate the slave and must not be handled by
 1189|       |    // dropping the data it just buffered. Hold at boundaries from here on.
 1190|      0|    struct stream_nav_state nav = {0};
 1191|      0|    if (stream_control(demuxer->stream, STREAM_CTRL_GET_NAV_STATE, &nav) >= 1)
  ------------------
  |  Branch (1191:9): [True: 0, False: 0]
  ------------------
 1192|      0|        p->last_discontinuity_id = nav.discontinuity_id;
 1193|      0|    if (p->is_dvd)
  ------------------
  |  Branch (1193:9): [True: 0, False: 0]
  ------------------
 1194|      0|        stream_control(demuxer->stream, STREAM_CTRL_NAV_DRAIN_ENABLE, NULL);
 1195|       |
 1196|       |    // Can be seekable even if the stream isn't.
 1197|      0|    demuxer->seekable = true;
 1198|      0|    demuxer->partially_seekable = !p->is_cdda;
 1199|      0|    demuxer->no_cache_seeking = !p->is_cdda;
 1200|       |
 1201|      0|    sync_streams(demuxer);
 1202|      0|    add_still_stream(demuxer);
 1203|      0|    add_stream_chapters(demuxer);
 1204|      0|    add_stream_editions(demuxer);
 1205|       |
 1206|      0|    double len;
 1207|      0|    if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) >= 1)
  ------------------
  |  Branch (1207:9): [True: 0, False: 0]
  ------------------
 1208|      0|        demuxer->duration = len;
 1209|       |
 1210|      0|    sync_initial_edition(demuxer);
 1211|       |
 1212|      0|    return 0;
 1213|      0|}
demux_disc.c:clear_dvd_sub_holds:
   99|  40.3k|{
  100|  1.33M|    for (int i = 0; i < MAX_DVD_SPU_STREAMS; i++) {
  ------------------
  |  |   32|  1.33M|#define MAX_DVD_SPU_STREAMS 32
  ------------------
  |  Branch (100:21): [True: 1.29M, False: 40.3k]
  ------------------
  101|  1.29M|        talloc_free(p->dvd_sub_hold[i].pkt);
  ------------------
  |  |   47|  1.29M|#define talloc_free                     ta_free
  ------------------
  102|  1.29M|        p->dvd_sub_hold[i] = (struct dvd_sub_hold){0};
  103|  1.29M|    }
  104|  40.3k|}
demux_disc.c:d_close:
 1216|  40.3k|{
 1217|  40.3k|    struct priv *p = demuxer->priv;
 1218|  40.3k|    clear_dvd_sub_holds(p);
 1219|       |    TA_FREEP(&p->pending_pkt);
  ------------------
  |  |   81|  40.3k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  40.3k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 40.3k]
  |  |  ------------------
  ------------------
 1220|  40.3k|    demux_free(p->slave);
 1221|  40.3k|}

demux_edl.c:try_open_file:
  648|  40.3k|{
  649|  40.3k|    if (!demuxer->access_references)
  ------------------
  |  Branch (649:9): [True: 0, False: 40.3k]
  ------------------
  650|      0|        return -1;
  651|       |
  652|  40.3k|    struct priv *p = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|  40.3k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.3k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  40.3k|    demuxer->priv = p;
  654|  40.3k|    demuxer->fully_read = true;
  655|       |
  656|  40.3k|    struct stream *s = demuxer->stream;
  657|  40.3k|    if (s->info && strcmp(s->info->name, "edl") == 0) {
  ------------------
  |  Branch (657:9): [True: 40.3k, False: 0]
  |  Branch (657:20): [True: 0, False: 40.3k]
  ------------------
  658|      0|        p->data = bstr0(s->path);
  659|      0|        return 0;
  660|      0|    }
  661|  40.3k|    if (check >= DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (661:9): [True: 40.3k, False: 0]
  ------------------
  662|  40.3k|        char header[sizeof(HEADER) - 1];
  663|  40.3k|        int len = stream_read_peek(s, header, sizeof(header));
  664|  40.3k|        if (len != strlen(HEADER) || memcmp(header, HEADER, len) != 0)
  ------------------
  |  |   39|  40.3k|#define HEADER "# mpv EDL v0\n"
  ------------------
                      if (len != strlen(HEADER) || memcmp(header, HEADER, len) != 0)
  ------------------
  |  |   39|  38.7k|#define HEADER "# mpv EDL v0\n"
  ------------------
  |  Branch (664:13): [True: 1.61k, False: 38.7k]
  |  Branch (664:38): [True: 38.5k, False: 139]
  ------------------
  665|  40.1k|            return -1;
  666|  40.3k|    }
  667|    139|    p->data = stream_read_complete(s, demuxer, 1000000);
  668|    139|    if (p->data.start == NULL)
  ------------------
  |  Branch (668:9): [True: 0, False: 139]
  ------------------
  669|      0|        return -1;
  670|    139|    bstr_eatstart0(&p->data, HEADER);
  ------------------
  |  |   39|    139|#define HEADER "# mpv EDL v0\n"
  ------------------
  671|    139|    demux_close_stream(demuxer);
  672|    139|    return 0;
  673|    139|}
demux_edl.c:build_mpv_edl_timeline:
  612|    139|{
  613|    139|    struct priv *p = tl->demuxer->priv;
  614|       |
  615|    139|    struct tl_root *root = parse_edl(p->data, tl->log);
  616|    139|    if (!root) {
  ------------------
  |  Branch (616:9): [True: 124, False: 15]
  ------------------
  617|    124|        MP_ERR(tl, "Error in EDL.\n");
  ------------------
  |  |   89|    124|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    124|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  618|    124|        return;
  619|    124|    }
  620|       |
  621|    139|    bool all_dash = true;
  622|     15|    bool all_no_clip = true;
  623|     15|    bool all_single = true;
  624|       |
  625|     15|    for (int n = 0; n < root->num_pars; n++) {
  ------------------
  |  Branch (625:21): [True: 15, False: 0]
  ------------------
  626|     15|        struct tl_parts *parts = root->pars[n];
  627|     15|        fix_filenames(parts, tl->demuxer->filename);
  628|     15|        struct timeline_par *par = build_timeline(tl, root, parts);
  629|     15|        if (!par)
  ------------------
  |  Branch (629:13): [True: 15, False: 0]
  ------------------
  630|     15|            break;
  631|      0|        all_dash &= par->dash;
  632|      0|        all_no_clip &= par->no_clip;
  633|      0|        all_single &= par->num_parts == 1;
  634|      0|    }
  635|       |
  636|     15|    if (all_dash) {
  ------------------
  |  Branch (636:9): [True: 15, False: 0]
  ------------------
  637|     15|        tl->format = "dash";
  638|     15|    } else if (all_no_clip && all_single) {
  ------------------
  |  Branch (638:16): [True: 0, False: 0]
  |  Branch (638:31): [True: 0, False: 0]
  ------------------
  639|      0|        tl->format = "multi";
  640|      0|    } else {
  641|      0|        tl->format = "edl";
  642|      0|    }
  643|       |
  644|     15|    talloc_free(root);
  ------------------
  |  |   47|     15|#define talloc_free                     ta_free
  ------------------
  645|     15|}
demux_edl.c:parse_edl:
  175|    139|{
  176|    139|    struct tl_root *root = talloc_zero(NULL, struct tl_root);
  ------------------
  |  |   27|    139|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    139|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    139|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|    139|    root->tags = talloc_zero(root, struct mp_tags);
  ------------------
  |  |   27|    139|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    139|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    139|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|    139|    struct tl_parts *tl = add_part(root);
  179|  25.3k|    while (str.len) {
  ------------------
  |  Branch (179:12): [True: 25.2k, False: 37]
  ------------------
  180|  25.2k|        if (bstr_eatstart0(&str, "#")) {
  ------------------
  |  Branch (180:13): [True: 518, False: 24.7k]
  ------------------
  181|    518|            bstr_split_tok(str, "\n", &(bstr){0}, &str);
  182|    518|            continue;
  183|    518|        }
  184|  24.7k|        if (bstr_eatstart0(&str, "\n") || bstr_eatstart0(&str, ";"))
  ------------------
  |  Branch (184:13): [True: 11.7k, False: 13.0k]
  |  Branch (184:43): [True: 5.67k, False: 7.35k]
  ------------------
  185|  17.4k|            continue;
  186|  24.7k|        bool is_header = bstr_eatstart0(&str, "!");
  187|  7.35k|        struct parse_ctx ctx = { .log = log };
  188|  7.35k|        int nparam = 0;
  189|  10.4k|        while (1) {
  ------------------
  |  Branch (189:16): [True: 10.4k, Folded]
  ------------------
  190|  10.4k|            bstr name, val;
  191|       |            // Check if it's of the form "name=..."
  192|  10.4k|            int next = bstrcspn(str, "=%,;\n");
  193|  10.4k|            if (next > 0 && next < str.len && str.start[next] == '=') {
  ------------------
  |  Branch (193:17): [True: 9.34k, False: 1.14k]
  |  Branch (193:29): [True: 9.29k, False: 56]
  |  Branch (193:47): [True: 807, False: 8.48k]
  ------------------
  194|    807|                name = bstr_splice(str, 0, next);
  195|    807|                str = bstr_cut(str, next + 1);
  196|  9.68k|            } else if (is_header) {
  ------------------
  |  Branch (196:24): [True: 53, False: 9.63k]
  ------------------
  197|     53|                const char *names[] = {"type"}; // implied name
  198|     53|                name = bstr0(nparam < 1 ? names[nparam] : "-");
  ------------------
  |  Branch (198:30): [True: 9, False: 44]
  ------------------
  199|  9.63k|            } else {
  200|  9.63k|                const char *names[] = {"file", "start", "length"}; // implied name
  201|  9.63k|                name = bstr0(nparam < 3 ? names[nparam] : "-");
  ------------------
  |  Branch (201:30): [True: 7.97k, False: 1.66k]
  ------------------
  202|  9.63k|            }
  203|  10.4k|            if (bstr_eatstart0(&str, "%")) {
  ------------------
  |  Branch (203:17): [True: 23, False: 10.4k]
  ------------------
  204|     23|                int len = bstrtoll(str, &str, 0);
  205|     23|                if (!bstr_startswith0(str, "%") || (len > str.len - 1))
  ------------------
  |  Branch (205:21): [True: 21, False: 2]
  |  Branch (205:52): [True: 0, False: 2]
  ------------------
  206|     21|                    goto error;
  207|      2|                val = bstr_splice(str, 1, len + 1);
  208|      2|                str = bstr_cut(str, len + 1);
  209|  10.4k|            } else {
  210|  10.4k|                next = bstrcspn(str, ",;\n");
  211|  10.4k|                val = bstr_splice(str, 0, next);
  212|  10.4k|                str = bstr_cut(str, next);
  213|  10.4k|            }
  214|  10.4k|            if (ctx.num_params >= NUM_MAX_PARAMS) {
  ------------------
  |  |   73|  10.4k|#define NUM_MAX_PARAMS 20
  ------------------
  |  Branch (214:17): [True: 943, False: 9.53k]
  ------------------
  215|    943|                mp_err(log, "Too many parameters, ignoring '%.*s'.\n",
  ------------------
  |  |   76|  1.88k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 943, False: 0]
  |  |  ------------------
  ------------------
  216|    943|                       BSTR_P(name));
  217|  9.53k|            } else {
  218|  9.53k|                ctx.param_names[ctx.num_params] = name;
  219|  9.53k|                ctx.param_vals[ctx.num_params] = val;
  220|  9.53k|                ctx.num_params += 1;
  221|  9.53k|            }
  222|  10.4k|            nparam++;
  223|  10.4k|            if (!bstr_eatstart0(&str, ","))
  ------------------
  |  Branch (223:17): [True: 7.33k, False: 3.13k]
  ------------------
  224|  7.33k|                break;
  225|  10.4k|        }
  226|  7.33k|        if (is_header) {
  ------------------
  |  Branch (226:13): [True: 11, False: 7.32k]
  ------------------
  227|     11|            bstr f_type = get_param(&ctx, "type");
  228|     11|            if (bstr_equals0(f_type, "mp4_dash")) {
  ------------------
  |  Branch (228:17): [True: 0, False: 11]
  ------------------
  229|      0|                tl->dash = true;
  230|      0|                tl->init_fragment_url = get_param0(&ctx, tl, "init");
  231|     11|            } else if (bstr_equals0(f_type, "no_clip")) {
  ------------------
  |  Branch (231:24): [True: 0, False: 11]
  ------------------
  232|      0|                tl->no_clip = true;
  233|     11|            } else if (bstr_equals0(f_type, "new_stream")) {
  ------------------
  |  Branch (233:24): [True: 0, False: 11]
  ------------------
  234|       |                // (Special case: ignore "redundant" headers at the start for
  235|       |                // general symmetry.)
  236|      0|                if (root->num_pars > 1 || tl->num_parts)
  ------------------
  |  Branch (236:21): [True: 0, False: 0]
  |  Branch (236:43): [True: 0, False: 0]
  ------------------
  237|      0|                    tl = add_part(root);
  238|     11|            } else if (bstr_equals0(f_type, "no_chapters")) {
  ------------------
  |  Branch (238:24): [True: 0, False: 11]
  ------------------
  239|      0|                tl->disable_chapters = true;
  240|     11|            } else if (bstr_equals0(f_type, "track_meta")) {
  ------------------
  |  Branch (240:24): [True: 0, False: 11]
  ------------------
  241|      0|                int index = get_param_int(&ctx, "index", -1);
  242|      0|                struct sh_stream *sh = index < 0 && tl->num_sh_meta
  ------------------
  |  Branch (242:40): [True: 0, False: 0]
  |  Branch (242:53): [True: 0, False: 0]
  ------------------
  243|      0|                    ? tl->sh_meta[tl->num_sh_meta - 1]
  244|      0|                    : get_meta(tl, index);
  245|      0|                sh->lang = get_param0(&ctx, sh, "lang");
  246|      0|                sh->title = get_param0(&ctx, sh, "title");
  247|      0|                MP_SATURATE_MUL(&sh->hls_bitrate, get_param_int(&ctx, "byterate", 0), 8);
  ------------------
  |  |   89|      0|#define MP_SATURATE_MUL(result, a, b) (         \
  |  |   90|      0|    MP_CKD_MUL(result, a, b) ?                  \
  |  |  ------------------
  |  |  |  |   85|      0|#define MP_CKD_MUL(result, a, b) __builtin_mul_overflow(a, b, result)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   91|      0|        *result = MP_MAX_VAL(*result), true :   \
  |  |  ------------------
  |  |  |  |   75|      0|#define MP_MAX_VAL(a) _Generic((a),                             \
  |  |  |  |   76|      0|                               char: SCHAR_MAX,                 \
  |  |  |  |   77|      0|                               unsigned char: UCHAR_MAX,        \
  |  |  |  |   78|      0|                               short: SHRT_MAX,                 \
  |  |  |  |   79|      0|                               unsigned short: USHRT_MAX,       \
  |  |  |  |   80|      0|                               int: INT_MAX,                    \
  |  |  |  |   81|      0|                               unsigned int: UINT_MAX,          \
  |  |  |  |   82|      0|                               long: LONG_MAX,                  \
  |  |  |  |   83|      0|                               unsigned long: ULONG_MAX,        \
  |  |  |  |   84|      0|                               long long: LLONG_MAX,            \
  |  |  |  |   85|      0|                               unsigned long long: ULLONG_MAX)
  |  |  ------------------
  |  |   92|      0|        false                                   \
  |  |   93|      0|)
  ------------------
  248|      0|                int pid = get_param_int(&ctx, "program_id", -1);
  249|      0|                if (pid >= 0)
  ------------------
  |  Branch (249:21): [True: 0, False: 0]
  ------------------
  250|      0|                    MP_TARRAY_APPEND(sh, sh->program_ids, sh->num_program_ids, pid);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  251|      0|                bstr flags = get_param(&ctx, "flags");
  252|      0|                bstr flag;
  253|      0|                while (bstr_split_tok(flags, "+", &flag, &flags) || flag.len) {
  ------------------
  |  Branch (253:24): [True: 0, False: 0]
  |  Branch (253:69): [True: 0, False: 0]
  ------------------
  254|      0|                    if (bstr_equals0(flag, "default")) {
  ------------------
  |  Branch (254:25): [True: 0, False: 0]
  ------------------
  255|      0|                        sh->default_track = true;
  256|      0|                    } else if (bstr_equals0(flag, "forced")) {
  ------------------
  |  Branch (256:32): [True: 0, False: 0]
  ------------------
  257|      0|                        sh->forced_track = true;
  258|      0|                    } else {
  259|      0|                        mp_warn(log, "Unknown flag: '%.*s'\n", BSTR_P(flag));
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  260|      0|                    }
  261|      0|                }
  262|     11|            } else if (bstr_equals0(f_type, "delay_open")) {
  ------------------
  |  Branch (262:24): [True: 0, False: 11]
  ------------------
  263|      0|                struct sh_stream *sh = get_meta(tl, tl->num_sh_meta);
  264|      0|                bstr mt = get_param(&ctx, "media_type");
  265|      0|                if (bstr_equals0(mt, "video")) {
  ------------------
  |  Branch (265:21): [True: 0, False: 0]
  ------------------
  266|      0|                    sh->type = sh->codec->type = STREAM_VIDEO;
  267|      0|                } else if (bstr_equals0(mt, "audio")) {
  ------------------
  |  Branch (267:28): [True: 0, False: 0]
  ------------------
  268|      0|                    sh->type = sh->codec->type = STREAM_AUDIO;
  269|      0|                } else if (bstr_equals0(mt, "sub")) {
  ------------------
  |  Branch (269:28): [True: 0, False: 0]
  ------------------
  270|      0|                    sh->type = sh->codec->type = STREAM_SUB;
  271|      0|                } else {
  272|      0|                    mp_err(log, "Invalid or missing !delay_open media type.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  273|      0|                    goto error;
  274|      0|                }
  275|      0|                const char *codec = get_param0(&ctx, sh, "codec");
  276|      0|                if (codec) {
  ------------------
  |  Branch (276:21): [True: 0, False: 0]
  ------------------
  277|      0|                    const char *mapped = mp_map_rfc6381_to_codec(sh->type, codec);
  278|      0|                    if (mapped) {
  ------------------
  |  Branch (278:25): [True: 0, False: 0]
  ------------------
  279|      0|                        codec = mapped;
  280|      0|                    } else if (sh->type != STREAM_SUB &&
  ------------------
  |  Branch (280:32): [True: 0, False: 0]
  ------------------
  281|      0|                               strcmp(codec, "null") != 0)
  ------------------
  |  Branch (281:32): [True: 0, False: 0]
  ------------------
  282|      0|                    {
  283|      0|                        mp_verbose(log, "Ignoring unknown codec '%s'.\n", codec);
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  284|      0|                        codec = NULL;
  285|      0|                    }
  286|      0|                }
  287|      0|                sh->codec->codec = codec ? codec : "null";
  ------------------
  |  Branch (287:36): [True: 0, False: 0]
  ------------------
  288|      0|                sh->codec->disp_w = get_param_int(&ctx, "w", 0);
  289|      0|                sh->codec->disp_h = get_param_int(&ctx, "h", 0);
  290|      0|                sh->codec->fps = get_param_int(&ctx, "fps", 0);
  291|      0|                sh->codec->samplerate = get_param_int(&ctx, "samplerate", 0);
  292|      0|                tl->delay_open = true;
  293|     11|            } else if (bstr_equals0(f_type, "global_tags")) {
  ------------------
  |  Branch (293:24): [True: 0, False: 11]
  ------------------
  294|      0|                for (int n = 0; n < ctx.num_params; n++) {
  ------------------
  |  Branch (294:33): [True: 0, False: 0]
  ------------------
  295|      0|                    mp_tags_set_bstr(root->tags, ctx.param_names[n],
  296|      0|                                     ctx.param_vals[n]);
  297|      0|                }
  298|      0|                ctx.num_params = 0;
  299|     11|            } else {
  300|     11|                mp_err(log, "Unknown header: '%.*s'\n", BSTR_P(f_type));
  ------------------
  |  |   76|     22|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 9, False: 2]
  |  |  ------------------
  ------------------
  301|     11|                goto error;
  302|     11|            }
  303|  7.32k|        } else {
  304|  7.32k|            struct tl_part p = { .length = -1 };
  305|  7.32k|            p.filename = get_param0(&ctx, tl, "file");
  306|  7.32k|            if (!p.filename || !p.filename[0]) {
  ------------------
  |  Branch (306:17): [True: 5, False: 7.32k]
  |  Branch (306:32): [True: 2, False: 7.31k]
  ------------------
  307|      7|                mp_err(log, "Missing filename in segment.\n");
  ------------------
  |  |   76|      7|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  308|      7|                goto error;
  309|      7|            }
  310|  7.31k|            p.offset_set = get_param_time(&ctx, "start", &p.offset);
  311|  7.31k|            get_param_time(&ctx, "length", &p.length);
  312|  7.31k|            bstr ts = get_param(&ctx, "timestamps");
  313|  7.31k|            if (bstr_equals0(ts, "chapters")) {
  ------------------
  |  Branch (313:17): [True: 0, False: 7.31k]
  ------------------
  314|      0|                p.chapter_ts = true;
  315|  7.31k|            } else if (ts.start && !bstr_equals0(ts, "seconds")) {
  ------------------
  |  Branch (315:24): [True: 0, False: 7.31k]
  |  Branch (315:36): [True: 0, False: 0]
  ------------------
  316|      0|                mp_warn(log, "Unknown timestamp type: '%.*s'\n", BSTR_P(ts));
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  317|      0|            }
  318|  7.31k|            p.title = get_param0(&ctx, tl, "title");
  319|  7.31k|            bstr layout = get_param(&ctx, "layout");
  320|  7.31k|            if (layout.start) {
  ------------------
  |  Branch (320:17): [True: 172, False: 7.14k]
  ------------------
  321|    172|                if (bstr_equals0(layout, "this")) {
  ------------------
  |  Branch (321:21): [True: 0, False: 172]
  ------------------
  322|      0|                    p.is_layout = true;
  323|    172|                } else {
  324|    172|                    mp_warn(log, "Unknown layout param: '%.*s'\n", BSTR_P(layout));
  ------------------
  |  |   77|    344|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 172, False: 0]
  |  |  ------------------
  ------------------
  325|    172|                }
  326|    172|            }
  327|  7.31k|            MP_TARRAY_APPEND(tl, tl->parts, tl->num_parts, p);
  ------------------
  |  |  105|  7.31k|    do {                                            \
  |  |  106|  7.31k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  7.31k|    do {                                            \
  |  |  |  |   97|  7.31k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  7.31k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  7.31k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  7.31k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 341, False: 6.97k]
  |  |  |  |  ------------------
  |  |  |  |   99|  7.31k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    341|    do {                                                        \
  |  |  |  |  |  |   89|    341|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    341|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    341|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    341|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    341|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    341|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    341|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 341]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  7.31k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 7.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  7.31k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  7.31k|        (idxvar)++;                                 \
  |  |  109|  7.31k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.31k]
  |  |  ------------------
  ------------------
  328|  7.31k|        }
  329|  7.31k|        if (ctx.error)
  ------------------
  |  Branch (329:13): [True: 63, False: 7.25k]
  ------------------
  330|     63|            goto error;
  331|  8.35k|        for (int n = 0; n < ctx.num_params; n++) {
  ------------------
  |  Branch (331:25): [True: 1.10k, False: 7.25k]
  ------------------
  332|  1.10k|            mp_warn(log, "Unknown or duplicate parameter: '%.*s'\n",
  ------------------
  |  |   77|  2.20k|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 1.10k, False: 0]
  |  |  ------------------
  ------------------
  333|  1.10k|                    BSTR_P(ctx.param_names[n]));
  334|  1.10k|        }
  335|  7.25k|    }
  336|     37|    mp_assert(root->num_pars);
  ------------------
  |  |   41|     37|#define mp_assert assert
  ------------------
  |  Branch (336:5): [True: 37, False: 0]
  ------------------
  337|     37|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  338|     37|    if (root->num_pars > 3)
  ------------------
  |  Branch (338:9): [True: 0, False: 37]
  ------------------
  339|      0|        goto error;
  340|     37|#endif
  341|     52|    for (int n = 0; n < root->num_pars; n++) {
  ------------------
  |  Branch (341:21): [True: 37, False: 15]
  ------------------
  342|     37|        if (root->pars[n]->num_parts < 1) {
  ------------------
  |  Branch (342:13): [True: 1, False: 36]
  ------------------
  343|      1|            mp_err(log, "EDL specifies no segments.\n");
  ------------------
  |  |   76|      1|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  344|      1|            goto error;
  345|      1|        }
  346|     36|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  347|     36|        if (root->pars[n]->num_parts > 3)
  ------------------
  |  Branch (347:13): [True: 21, False: 15]
  ------------------
  348|     21|            goto error;
  349|     36|#endif
  350|     36|    }
  351|     15|    return root;
  352|    124|error:
  353|    124|    mp_err(log, "EDL parsing failed.\n");
  ------------------
  |  |   76|    124|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  354|    124|    talloc_free(root);
  ------------------
  |  |   47|    124|#define talloc_free                     ta_free
  ------------------
  355|       |    return NULL;
  356|     37|}
demux_edl.c:add_part:
  150|    139|{
  151|    139|    struct tl_parts *tl = talloc_zero(root, struct tl_parts);
  ------------------
  |  |   27|    139|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    139|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    139|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|    139|    MP_TARRAY_APPEND(root, root->pars, root->num_pars, tl);
  ------------------
  |  |  105|    139|    do {                                            \
  |  |  106|    139|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    139|    do {                                            \
  |  |  |  |   97|    139|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    139|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    139|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    139|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 139, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|    139|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    139|    do {                                                        \
  |  |  |  |  |  |   89|    139|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    139|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    139|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    139|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    139|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    139|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    139|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 139]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    139|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 139]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    139|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    139|        (idxvar)++;                                 \
  |  |  109|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  153|    139|    return tl;
  154|    139|}
demux_edl.c:get_param:
   87|  43.9k|{
   88|  43.9k|    bstr bname = bstr0(name);
   89|  50.1k|    for (int n = 0; n < ctx->num_params; n++) {
  ------------------
  |  Branch (89:21): [True: 14.2k, False: 35.8k]
  ------------------
   90|  14.2k|        if (bstr_equals(ctx->param_names[n], bname)) {
  ------------------
  |  Branch (90:13): [True: 8.12k, False: 6.17k]
  ------------------
   91|  8.12k|            bstr res = ctx->param_vals[n];
   92|  8.12k|            int count = ctx->num_params;
   93|  8.12k|            MP_TARRAY_REMOVE_AT(ctx->param_names, count, n);
  ------------------
  |  |  143|  8.12k|    do {                                            \
  |  |  144|  8.12k|        size_t at_ = (at);                          \
  |  |  145|  8.12k|        assert(at_ < (idxvar));                     \
  |  |  146|  8.12k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  8.12k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  8.12k|        (idxvar)--;                                 \
  |  |  149|  8.12k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 8.12k]
  |  |  ------------------
  ------------------
  |  Branch (93:13): [True: 8.12k, False: 0]
  ------------------
   94|  8.12k|            count = ctx->num_params;
   95|  8.12k|            MP_TARRAY_REMOVE_AT(ctx->param_vals, count, n);
  ------------------
  |  |  143|  8.12k|    do {                                            \
  |  |  144|  8.12k|        size_t at_ = (at);                          \
  |  |  145|  8.12k|        assert(at_ < (idxvar));                     \
  |  |  146|  8.12k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  8.12k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  8.12k|        (idxvar)--;                                 \
  |  |  149|  8.12k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 8.12k]
  |  |  ------------------
  ------------------
  |  Branch (95:13): [True: 8.12k, False: 0]
  ------------------
   96|  8.12k|            ctx->num_params -= 1;
   97|  8.12k|            if (!res.start)
  ------------------
  |  Branch (97:17): [True: 0, False: 8.12k]
  ------------------
   98|      0|                res = bstr0("");  // keep guarantees
   99|  8.12k|            return res;
  100|  8.12k|        }
  101|  14.2k|    }
  102|  35.8k|    return (bstr){0};
  103|  43.9k|}
demux_edl.c:get_param0:
  107|  14.6k|{
  108|  14.6k|    return bstrdup0(ta_ctx, get_param(ctx, name));
  109|  14.6k|}
demux_edl.c:get_param_time:
  133|  14.6k|{
  134|  14.6k|    bstr val = get_param(ctx, name);
  135|  14.6k|    if (val.start) {
  ------------------
  |  Branch (135:9): [True: 622, False: 14.0k]
  ------------------
  136|    622|        bstr rest;
  137|    622|        double time = bstrtod(val, &rest);
  138|    622|        if (!val.len || rest.len || !isfinite(time)) {
  ------------------
  |  Branch (138:13): [True: 35, False: 587]
  |  Branch (138:25): [True: 55, False: 532]
  |  Branch (138:37): [True: 0, False: 532]
  ------------------
  139|     90|            MP_ERR(ctx, "Invalid time string: '%.*s'\n", BSTR_P(val));
  ------------------
  |  |   89|     90|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    180|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 90, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  140|     90|            ctx->error = true;
  141|     90|            return false;
  142|     90|        }
  143|    532|        *t = time;
  144|    532|        return true;
  145|    622|    }
  146|  14.0k|    return false;
  147|  14.6k|}
demux_edl.c:fix_filenames:
  592|     15|{
  593|     15|    bstr proto = mp_split_proto(bstr0(source_path), NULL);
  594|       |    // Don't adjust self-expanding protocols
  595|     15|    if (!bstrcasecmp0(proto, "memory") || !bstrcasecmp0(proto, "lavf") ||
  ------------------
  |  Branch (595:9): [True: 0, False: 15]
  |  Branch (595:43): [True: 15, False: 0]
  ------------------
  596|      0|        !bstrcasecmp0(proto, "hex") || !bstrcasecmp0(proto, "edl") ||
  ------------------
  |  Branch (596:9): [True: 0, False: 0]
  |  Branch (596:40): [True: 0, False: 0]
  ------------------
  597|      0|        !bstrcasecmp0(proto, "ffmpeg") || !bstrcasecmp0(proto, "data"))
  ------------------
  |  Branch (597:9): [True: 0, False: 0]
  |  Branch (597:43): [True: 0, False: 0]
  ------------------
  598|     15|    {
  599|     15|        return;
  600|     15|    }
  601|      0|    struct bstr dirname = mp_dirname(source_path);
  602|      0|    for (int n = 0; n < parts->num_parts; n++) {
  ------------------
  |  Branch (602:21): [True: 0, False: 0]
  ------------------
  603|      0|        struct tl_part *part = &parts->parts[n];
  604|      0|        if (!mp_is_url(bstr0(part->filename))) {
  ------------------
  |  Branch (604:13): [True: 0, False: 0]
  ------------------
  605|      0|            part->filename =
  606|      0|                mp_path_join_bstr(parts, dirname, bstr0(part->filename));
  607|      0|        }
  608|      0|    }
  609|      0|}
demux_edl.c:build_timeline:
  426|     15|{
  427|     15|    struct timeline_par *tl = talloc_zero(root, struct timeline_par);
  ------------------
  |  |   27|     15|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     15|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     15|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|     15|    MP_TARRAY_APPEND(root, root->pars, root->num_pars, tl);
  ------------------
  |  |  105|     15|    do {                                            \
  |  |  106|     15|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     15|    do {                                            \
  |  |  |  |   97|     15|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     15|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     15|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     15|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     15|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     15|    do {                                                        \
  |  |  |  |  |  |   89|     15|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     15|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     15|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     15|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     15|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     15|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     15|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 15]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     15|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     15|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     15|        (idxvar)++;                                 \
  |  |  109|     15|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15]
  |  |  ------------------
  ------------------
  429|       |
  430|     15|    tl->track_layout = NULL;
  431|     15|    tl->dash = parts->dash;
  432|     15|    tl->no_clip = parts->no_clip;
  433|     15|    tl->delay_open = parts->delay_open;
  434|       |
  435|       |    // There is no copy function for sh_stream, so just steal it.
  436|     15|    for (int n = 0; n < parts->num_sh_meta; n++) {
  ------------------
  |  Branch (436:21): [True: 0, False: 15]
  ------------------
  437|      0|        MP_TARRAY_APPEND(tl, tl->sh_meta, tl->num_sh_meta,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  438|      0|                         talloc_steal(tl, parts->sh_meta[n]));
  439|      0|        parts->sh_meta[n] = NULL;
  440|      0|    }
  441|     15|    parts->num_sh_meta = 0;
  442|       |
  443|     15|    if (parts->init_fragment_url && parts->init_fragment_url[0]) {
  ------------------
  |  Branch (443:9): [True: 0, False: 15]
  |  Branch (443:37): [True: 0, False: 0]
  ------------------
  444|      0|        MP_VERBOSE(root, "Opening init fragment...\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  445|      0|        stream_t *s = stream_create(parts->init_fragment_url,
  446|      0|                                    STREAM_READ | root->stream_origin,
  ------------------
  |  |   41|      0|#define STREAM_READ               0
  ------------------
  447|      0|                                    root->cancel, root->global);
  448|      0|        if (s) {
  ------------------
  |  Branch (448:13): [True: 0, False: 0]
  ------------------
  449|      0|            root->is_network |= s->is_network;
  450|      0|            root->is_streaming |= s->streaming;
  451|      0|            tl->init_fragment = stream_read_complete(s, tl, 1000000);
  452|      0|        }
  453|      0|        free_stream(s);
  454|      0|        if (!tl->init_fragment.len) {
  ------------------
  |  Branch (454:13): [True: 0, False: 0]
  ------------------
  455|      0|            MP_ERR(root, "Could not read init fragment.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  456|      0|            goto error;
  457|      0|        }
  458|      0|        struct demuxer_params params = {
  459|      0|            .init_fragment = tl->init_fragment,
  460|      0|            .stream_flags = root->stream_origin,
  461|      0|            .depth = root->demuxer->depth + 1,
  462|      0|        };
  463|      0|        tl->track_layout = demux_open_url("memory://", &params, root->cancel,
  464|      0|                                          root->global);
  465|      0|        if (!tl->track_layout) {
  ------------------
  |  Branch (465:13): [True: 0, False: 0]
  ------------------
  466|      0|            MP_ERR(root, "Could not demux init fragment.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  467|      0|            goto error;
  468|      0|        }
  469|      0|        MP_TARRAY_APPEND(root, root->sources, root->num_sources, tl->track_layout);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  470|      0|    }
  471|       |
  472|     15|    tl->parts = talloc_array_ptrtype(tl, tl->parts, parts->num_parts);
  ------------------
  |  |   36|     15|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|     15|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     15|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|     15|    double starttime = 0;
  474|     15|    for (int n = 0; n < parts->num_parts; n++) {
  ------------------
  |  Branch (474:21): [True: 15, False: 0]
  ------------------
  475|     15|        struct tl_part *part = &parts->parts[n];
  476|     15|        struct demuxer *source = NULL;
  477|       |
  478|     15|        if (tl->dash) {
  ------------------
  |  Branch (478:13): [True: 0, False: 15]
  ------------------
  479|      0|            part->offset = starttime;
  480|      0|            if (part->length <= 0)
  ------------------
  |  Branch (480:17): [True: 0, False: 0]
  ------------------
  481|      0|                MP_WARN(root, "Segment %d has unknown duration.\n", n);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  482|      0|            if (part->offset_set)
  ------------------
  |  Branch (482:17): [True: 0, False: 0]
  ------------------
  483|      0|                MP_WARN(root, "Offsets are ignored.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|       |
  485|      0|            if (!tl->track_layout)
  ------------------
  |  Branch (485:17): [True: 0, False: 0]
  ------------------
  486|      0|                tl->track_layout = open_source(root, tl, part->filename);
  487|     15|        } else if (tl->delay_open) {
  ------------------
  |  Branch (487:20): [True: 0, False: 15]
  ------------------
  488|      0|            if (n == 0 && !part->offset_set) {
  ------------------
  |  Branch (488:17): [True: 0, False: 0]
  |  Branch (488:27): [True: 0, False: 0]
  ------------------
  489|      0|                part->offset = starttime;
  490|      0|                part->offset_set = true;
  491|      0|            }
  492|      0|            if (part->chapter_ts || (part->length < 0 && !tl->no_clip)) {
  ------------------
  |  Branch (492:17): [True: 0, False: 0]
  |  Branch (492:38): [True: 0, False: 0]
  |  Branch (492:58): [True: 0, False: 0]
  ------------------
  493|      0|                MP_ERR(root, "Invalid specification for delay_open stream.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  494|      0|                goto error;
  495|      0|            }
  496|     15|        } else {
  497|     15|            MP_VERBOSE(root, "Opening segment %d...\n", n);
  ------------------
  |  |   92|     15|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     15|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  498|       |
  499|     15|            source = open_source(root, tl, part->filename);
  500|     15|            if (!source)
  ------------------
  |  Branch (500:17): [True: 15, False: 0]
  ------------------
  501|     15|                goto error;
  502|       |
  503|      0|            resolve_timestamps(part, source);
  504|       |
  505|      0|            double end_time = source->duration;
  506|      0|            if (end_time >= 0)
  ------------------
  |  Branch (506:17): [True: 0, False: 0]
  ------------------
  507|      0|                end_time += source->start_time;
  508|       |
  509|       |            // Unknown length => use rest of the file. If duration is unknown, make
  510|       |            // something up.
  511|      0|            if (part->length < 0) {
  ------------------
  |  Branch (511:17): [True: 0, False: 0]
  ------------------
  512|      0|                if (end_time < 0) {
  ------------------
  |  Branch (512:21): [True: 0, False: 0]
  ------------------
  513|      0|                    MP_WARN(root, "EDL: source file '%s' has unknown duration.\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  514|      0|                            part->filename);
  515|      0|                    end_time = 1;
  516|      0|                }
  517|      0|                part->length = end_time - part->offset;
  518|      0|            } else if (end_time >= 0) {
  ------------------
  |  Branch (518:24): [True: 0, False: 0]
  ------------------
  519|      0|                double end_part = part->offset + part->length;
  520|      0|                if (end_part > end_time) {
  ------------------
  |  Branch (520:21): [True: 0, False: 0]
  ------------------
  521|      0|                    MP_WARN(root, "EDL: entry %d uses %f "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  522|      0|                            "seconds, but file has only %f seconds.\n",
  523|      0|                            n, end_part, end_time);
  524|      0|                }
  525|      0|            }
  526|       |
  527|      0|            if (!parts->disable_chapters) {
  ------------------
  |  Branch (527:17): [True: 0, False: 0]
  ------------------
  528|       |                // Add a chapter between each file.
  529|      0|                struct demux_chapter ch = {
  530|      0|                    .pts = starttime,
  531|      0|                    .metadata = talloc_zero(tl, struct mp_tags),
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  532|      0|                };
  533|      0|                mp_tags_set_str(ch.metadata, "title",
  534|      0|                                part->title ? part->title : part->filename);
  ------------------
  |  Branch (534:33): [True: 0, False: 0]
  ------------------
  535|      0|                MP_TARRAY_APPEND(root, root->chapters, root->num_chapters, ch);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  536|       |
  537|       |                // Also copy the source file's chapters for the relevant parts
  538|      0|                copy_chapters(&root->chapters, &root->num_chapters, source,
  539|      0|                              part->offset, part->length, starttime);
  540|      0|            }
  541|      0|        }
  542|       |
  543|      0|        tl->parts[n] = (struct timeline_part) {
  544|      0|            .start = starttime,
  545|      0|            .end = starttime + part->length,
  546|      0|            .source_start = part->offset,
  547|      0|            .source = source,
  548|      0|            .url = talloc_strdup(tl, part->filename),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  549|      0|        };
  550|       |
  551|      0|        starttime = tl->parts[n].end;
  552|       |
  553|      0|        if (source && !tl->track_layout && part->is_layout)
  ------------------
  |  Branch (553:13): [True: 0, False: 0]
  |  Branch (553:23): [True: 0, False: 0]
  |  Branch (553:44): [True: 0, False: 0]
  ------------------
  554|      0|            tl->track_layout = source;
  555|       |
  556|      0|        tl->num_parts++;
  557|      0|    }
  558|       |
  559|      0|    if (tl->no_clip && tl->num_parts > 1)
  ------------------
  |  Branch (559:9): [True: 0, False: 0]
  |  Branch (559:24): [True: 0, False: 0]
  ------------------
  560|      0|        MP_WARN(root, "Multiple parts with no_clip. Undefined behavior ahead.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  561|       |
  562|      0|    if (!tl->track_layout) {
  ------------------
  |  Branch (562:9): [True: 0, False: 0]
  ------------------
  563|       |        // Use a heuristic to select the "broadest" part as layout.
  564|      0|        for (int n = 0; n < parts->num_parts; n++) {
  ------------------
  |  Branch (564:25): [True: 0, False: 0]
  ------------------
  565|      0|            struct demuxer *s = tl->parts[n].source;
  566|      0|            if (!s)
  ------------------
  |  Branch (566:17): [True: 0, False: 0]
  ------------------
  567|      0|                continue;
  568|      0|            if (!tl->track_layout ||
  ------------------
  |  Branch (568:17): [True: 0, False: 0]
  ------------------
  569|      0|                demux_get_num_stream(s) > demux_get_num_stream(tl->track_layout))
  ------------------
  |  Branch (569:17): [True: 0, False: 0]
  ------------------
  570|      0|                tl->track_layout = s;
  571|      0|        }
  572|      0|    }
  573|       |
  574|      0|    if (!tl->track_layout && !tl->delay_open)
  ------------------
  |  Branch (574:9): [True: 0, False: 0]
  |  Branch (574:30): [True: 0, False: 0]
  ------------------
  575|      0|        goto error;
  576|      0|    if (!root->meta)
  ------------------
  |  Branch (576:9): [True: 0, False: 0]
  ------------------
  577|      0|        root->meta = tl->track_layout ? tl->track_layout : root->demuxer;
  ------------------
  |  Branch (577:22): [True: 0, False: 0]
  ------------------
  578|       |
  579|       |    // Not very sane, since demuxer fields are supposed to be treated read-only
  580|       |    // from outside, but happens to work in this case, so who cares.
  581|      0|    mp_tags_merge(root->meta->metadata, edl_root->tags);
  582|       |
  583|      0|    mp_assert(tl->num_parts == parts->num_parts);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (583:5): [True: 0, False: 0]
  ------------------
  584|      0|    return tl;
  585|       |
  586|     15|error:
  587|     15|    root->num_pars = 0;
  588|       |    return NULL;
  589|      0|}
demux_edl.c:open_source:
  360|     15|{
  361|     15|    for (int n = 0; n < tl->num_parts; n++) {
  ------------------
  |  Branch (361:21): [True: 0, False: 15]
  ------------------
  362|      0|        struct demuxer *d = tl->parts[n].source;
  363|      0|        if (d && d->filename && strcmp(d->filename, filename) == 0)
  ------------------
  |  Branch (363:13): [True: 0, False: 0]
  |  Branch (363:18): [True: 0, False: 0]
  |  Branch (363:33): [True: 0, False: 0]
  ------------------
  364|      0|            return d;
  365|      0|    }
  366|     15|    struct demuxer_params params = {
  367|     15|        .init_fragment = tl->init_fragment,
  368|     15|        .stream_flags = root->stream_origin,
  369|     15|        .depth = root->demuxer->depth + 1,
  370|     15|    };
  371|     15|    struct demuxer *d = demux_open_url(filename, &params, root->cancel,
  372|     15|                                       root->global);
  373|     15|    if (d) {
  ------------------
  |  Branch (373:9): [True: 0, False: 15]
  ------------------
  374|      0|        MP_TARRAY_APPEND(root, root->sources, root->num_sources, d);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  375|     15|    } else {
  376|     15|        MP_ERR(root, "EDL: Could not open source file '%s'.\n", filename);
  ------------------
  |  |   89|     15|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     15|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  377|     15|    }
  378|     15|    return d;
  379|     15|}

demux_lavf.c:demux_open_lavf:
 1461|  40.1k|{
 1462|  40.1k|    AVFormatContext *avfc = NULL;
 1463|  40.1k|    AVDictionaryEntry *t = NULL;
 1464|  40.1k|    float analyze_duration = 0;
 1465|  40.1k|    lavf_priv_t *priv = talloc_zero(NULL, lavf_priv_t);
  ------------------
  |  |   27|  40.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1466|  40.1k|    AVDictionary *dopts = NULL;
 1467|       |
 1468|  40.1k|    demuxer->priv = priv;
 1469|  40.1k|    priv->stream = demuxer->stream;
 1470|       |
 1471|  40.1k|    priv->opts = mp_get_config_group(priv, demuxer->global, &demux_lavf_conf);
 1472|  40.1k|    struct demux_lavf_opts *lavfdopts = priv->opts;
 1473|       |
 1474|  40.1k|    if (lavf_check_file(demuxer, check) < 0)
  ------------------
  |  Branch (1474:9): [True: 14.8k, False: 25.2k]
  ------------------
 1475|  14.8k|        goto fail;
 1476|       |
 1477|  25.2k|    avfc = avformat_alloc_context();
 1478|  25.2k|    if (!avfc)
  ------------------
  |  Branch (1478:9): [True: 0, False: 25.2k]
  ------------------
 1479|      0|        goto fail;
 1480|       |
 1481|  25.2k|    if (demuxer->opts->index_mode != 1)
  ------------------
  |  Branch (1481:9): [True: 0, False: 25.2k]
  ------------------
 1482|      0|        avfc->flags |= AVFMT_FLAG_IGNIDX;
 1483|       |
 1484|  25.2k|    if (lavfdopts->probesize) {
  ------------------
  |  Branch (1484:9): [True: 0, False: 25.2k]
  ------------------
 1485|      0|        if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0)
  ------------------
  |  Branch (1485:13): [True: 0, False: 0]
  ------------------
 1486|      0|            MP_ERR(demuxer, "couldn't set option probesize to %"PRId64"\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1487|      0|                   lavfdopts->probesize);
 1488|      0|    }
 1489|       |
 1490|  25.2k|    if (priv->format_hack.analyzeduration)
  ------------------
  |  Branch (1490:9): [True: 0, False: 25.2k]
  ------------------
 1491|      0|        analyze_duration = priv->format_hack.analyzeduration;
 1492|  25.2k|    if (lavfdopts->analyzeduration)
  ------------------
  |  Branch (1492:9): [True: 0, False: 25.2k]
  ------------------
 1493|      0|        analyze_duration = lavfdopts->analyzeduration;
 1494|  25.2k|    if (analyze_duration > 0) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 25.2k]
  ------------------
 1495|      0|        if (av_opt_set_int(avfc, "analyzeduration",
  ------------------
  |  Branch (1495:13): [True: 0, False: 0]
  ------------------
 1496|      0|                           analyze_duration * AV_TIME_BASE, 0) < 0)
 1497|      0|            MP_ERR(demuxer, "demux_lavf, couldn't set option "
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1498|      0|                   "analyzeduration to %f\n", analyze_duration);
 1499|      0|    }
 1500|       |
 1501|  25.2k|    if (priv->format_hack.no_ext_picky) {
  ------------------
  |  Branch (1501:9): [True: 0, False: 25.2k]
  ------------------
 1502|      0|        bool user_set_ext_picky = false;
 1503|      0|        for (int i = 0; lavfdopts->avopts && lavfdopts->avopts[i * 2]; i++) {
  ------------------
  |  Branch (1503:25): [True: 0, False: 0]
  |  Branch (1503:46): [True: 0, False: 0]
  ------------------
 1504|      0|            if (bstr_startswith0(bstr0(lavfdopts->avopts[i * 2]), "extension_picky")) {
  ------------------
  |  Branch (1504:17): [True: 0, False: 0]
  ------------------
 1505|      0|                user_set_ext_picky = true;
 1506|      0|                break;
 1507|      0|            }
 1508|      0|        }
 1509|      0|        if (!user_set_ext_picky && av_dict_set(&dopts, "extension_picky", "0", 0) >= 0)
  ------------------
  |  Branch (1509:13): [True: 0, False: 0]
  |  Branch (1509:36): [True: 0, False: 0]
  ------------------
 1510|      0|            MP_VERBOSE(demuxer, "Option extension_picky=0 was set due to known FFmpeg bugs\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1511|      0|    }
 1512|       |
 1513|  25.2k|    if ((priv->avif_flags & AVFMT_NOFILE) || priv->format_hack.nested_network) {
  ------------------
  |  Branch (1513:9): [True: 0, False: 25.2k]
  |  Branch (1513:46): [True: 0, False: 25.2k]
  ------------------
 1514|      0|        mp_setup_av_network_options(&dopts, priv->avif->name,
 1515|      0|                                    demuxer->global, demuxer->log);
 1516|       |        // This might be incorrect.
 1517|      0|        demuxer->seekable = true;
 1518|      0|    }
 1519|       |
 1520|  25.2k|    if (!(priv->avif_flags & AVFMT_NOFILE)) {
  ------------------
  |  Branch (1520:9): [True: 25.2k, False: 0]
  ------------------
 1521|  25.2k|        void *buffer = av_malloc(lavfdopts->buffersize);
 1522|  25.2k|        if (!buffer)
  ------------------
  |  Branch (1522:13): [True: 0, False: 25.2k]
  ------------------
 1523|      0|            goto fail;
 1524|  25.2k|        const char *location = priv->stream->effective_url;
 1525|  25.2k|        priv->avio_cookie = (struct avio_cookie){
 1526|  25.2k|            .av_class = &avio_cookie_class,
 1527|  25.2k|            .demuxer = demuxer,
 1528|  25.2k|            .location = location ? location : priv->filename,
  ------------------
  |  Branch (1528:25): [True: 0, False: 25.2k]
  ------------------
 1529|  25.2k|        };
 1530|  25.2k|        priv->pb = avio_alloc_context(buffer, lavfdopts->buffersize, 0,
 1531|  25.2k|                                      &priv->avio_cookie, mp_read, NULL,
 1532|  25.2k|                                      mp_seek);
 1533|  25.2k|        if (!priv->pb) {
  ------------------
  |  Branch (1533:13): [True: 0, False: 25.2k]
  ------------------
 1534|      0|            av_free(buffer);
 1535|      0|            goto fail;
 1536|      0|        }
 1537|  25.2k|        priv->pb->av_class = &avio_class;
 1538|  25.2k|        priv->pb->read_seek = mp_read_seek;
 1539|  25.2k|        priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0;
  ------------------
  |  Branch (1539:30): [True: 25.2k, False: 0]
  ------------------
 1540|  25.2k|        avfc->pb = priv->pb;
 1541|  25.2k|        if (stream_control(priv->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
  ------------------
  |  Branch (1541:13): [True: 0, False: 25.2k]
  ------------------
 1542|      0|            demuxer->seekable = true;
 1543|  25.2k|        demuxer->seekable |= priv->format_hack.fully_read;
 1544|  25.2k|    }
 1545|       |
 1546|  25.2k|    if (matches_avinputformat_name(priv, "rtsp")) {
  ------------------
  |  Branch (1546:9): [True: 0, False: 25.2k]
  ------------------
 1547|      0|        const char *transport = NULL;
 1548|      0|        switch (lavfdopts->rtsp_transport) {
  ------------------
  |  Branch (1548:17): [True: 0, False: 0]
  ------------------
 1549|      0|        case 1: transport = "udp";  break;
  ------------------
  |  Branch (1549:9): [True: 0, False: 0]
  ------------------
 1550|      0|        case 2: transport = "tcp";  break;
  ------------------
  |  Branch (1550:9): [True: 0, False: 0]
  ------------------
 1551|      0|        case 3: transport = "http"; break;
  ------------------
  |  Branch (1551:9): [True: 0, False: 0]
  ------------------
 1552|      0|        case 4: transport = "udp_multicast"; break;
  ------------------
  |  Branch (1552:9): [True: 0, False: 0]
  ------------------
 1553|      0|        }
 1554|      0|        if (transport)
  ------------------
  |  Branch (1554:13): [True: 0, False: 0]
  ------------------
 1555|      0|            av_dict_set(&dopts, "rtsp_transport", transport, 0);
 1556|      0|    }
 1557|       |
 1558|  25.2k|    guess_and_set_vobsub_name(demuxer, &dopts);
 1559|       |
 1560|  25.2k|    avfc->interrupt_callback = (AVIOInterruptCB){
 1561|  25.2k|        .callback = interrupt_cb,
 1562|  25.2k|        .opaque = demuxer,
 1563|  25.2k|    };
 1564|       |
 1565|  25.2k|    avfc->opaque = demuxer;
 1566|  25.2k|    if (demuxer->access_references) {
  ------------------
  |  Branch (1566:9): [True: 25.2k, False: 0]
  ------------------
 1567|  25.2k|        priv->default_io_open = avfc->io_open;
 1568|  25.2k|        avfc->io_open = nested_io_open;
 1569|  25.2k|        priv->default_io_close2 = avfc->io_close2;
 1570|  25.2k|        avfc->io_close2 = nested_io_close2;
 1571|  25.2k|    } else {
 1572|      0|        avfc->io_open = block_io_open;
 1573|      0|    }
 1574|       |
 1575|       |#if HAVE_LIBCURL
 1576|       |    // When nested HTTP requests are routed through our libcurl backend,
 1577|       |    // Lavf's HLS demuxer must not try to reuse the URLContext of the previous
 1578|       |    // request via ff_http_do_new_request2(). Our AVIOContext is not backed by a
 1579|       |    // URLContext, so ffio_geturlcontext() returns NULL and av_assert0() trips.
 1580|       |    // Note that our implementation will reuse and multiplex connections.
 1581|       |    // This will be fixed upstream, but keep compatibility with older versions.
 1582|       |    if (demuxer->access_references) {
 1583|       |        av_dict_set(&dopts, "http_persistent", "0", 0);
 1584|       |        // Actually enable http_multiple, this is basic prefetching logic in
 1585|       |        // HLS demuxer. We just need to avoid autodetection (-1) which would
 1586|       |        // be incorrect as our backed is handling everything.
 1587|       |        av_dict_set(&dopts, "http_multiple", "1", 0);
 1588|       |    }
 1589|       |#endif
 1590|       |
 1591|  25.2k|    mp_set_avdict(&dopts, lavfdopts->avopts);
 1592|       |
 1593|  25.2k|    if (av_dict_copy(&priv->av_opts, dopts, 0) < 0) {
  ------------------
  |  Branch (1593:9): [True: 0, False: 25.2k]
  ------------------
 1594|      0|        MP_ERR(demuxer, "av_dict_copy() failed\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1595|      0|        goto fail;
 1596|      0|    }
 1597|       |
 1598|  25.2k|    if (priv->format_hack.readall_on_no_streamseek && priv->pb &&
  ------------------
  |  Branch (1598:9): [True: 328, False: 24.9k]
  |  Branch (1598:55): [True: 328, False: 0]
  ------------------
 1599|    328|        !priv->pb->seekable)
  ------------------
  |  Branch (1599:9): [True: 0, False: 328]
  ------------------
 1600|      0|    {
 1601|      0|        MP_VERBOSE(demuxer, "Non-seekable demuxer pre-read hack...\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1602|       |        // Read incremental to avoid unnecessary large buffer sizes.
 1603|      0|        int r = 0;
 1604|      0|        for (int n = 16; n < 29; n++) {
  ------------------
  |  Branch (1604:26): [True: 0, False: 0]
  ------------------
 1605|      0|            r = stream_peek(priv->stream, 1 << n);
 1606|      0|            if (r < (1 << n))
  ------------------
  |  Branch (1606:17): [True: 0, False: 0]
  ------------------
 1607|      0|                break;
 1608|      0|        }
 1609|      0|        MP_VERBOSE(demuxer, "...did read %d bytes.\n", r);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1610|      0|    }
 1611|       |
 1612|  25.2k|    if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) {
  ------------------
  |  Branch (1612:9): [True: 4.01k, False: 21.2k]
  ------------------
 1613|  4.01k|        MP_ERR(demuxer, "avformat_open_input() failed\n");
  ------------------
  |  |   89|  4.01k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.01k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1614|  4.01k|        goto fail;
 1615|  4.01k|    }
 1616|       |
 1617|  21.2k|    mp_avdict_print_unset(demuxer->log, MSGL_V, dopts);
 1618|  21.2k|    av_dict_free(&dopts);
 1619|       |
 1620|  21.2k|    priv->avfc = avfc;
 1621|       |
 1622|  21.2k|    bool probeinfo = lavfdopts->probeinfo != 0;
 1623|  21.2k|    switch (lavfdopts->probeinfo) {
  ------------------
  |  Branch (1623:13): [True: 21.2k, False: 0]
  ------------------
 1624|      0|    case -2: probeinfo = priv->avfc->nb_streams == 0; break;
  ------------------
  |  Branch (1624:5): [True: 0, False: 21.2k]
  ------------------
 1625|  21.2k|    case -1: probeinfo = !priv->format_hack.skipinfo; break;
  ------------------
  |  Branch (1625:5): [True: 21.2k, False: 0]
  ------------------
 1626|  21.2k|    }
 1627|  21.2k|    if (demuxer->params && demuxer->params->skip_lavf_probing)
  ------------------
  |  Branch (1627:9): [True: 21.2k, False: 0]
  |  Branch (1627:28): [True: 0, False: 21.2k]
  ------------------
 1628|      0|        probeinfo = false;
 1629|  21.2k|    if (probeinfo) {
  ------------------
  |  Branch (1629:9): [True: 20.9k, False: 318]
  ------------------
 1630|  20.9k|        int nb_streams = avfc->nb_streams;
 1631|  20.9k|        AVDictionary **opts = talloc_zero_array(NULL, AVDictionary *, nb_streams);
  ------------------
  |  |   30|  20.9k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  20.9k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  20.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|  20.9k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(61, 7, 100)
 1633|  45.5k|        for (int i = 0; i < nb_streams; i++) {
  ------------------
  |  Branch (1633:25): [True: 24.6k, False: 20.9k]
  ------------------
 1634|  24.6k|            AVCodecParameters *par = avfc->streams[i]->codecpar;
 1635|  24.6k|            if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->format == AV_SAMPLE_FMT_DSD)
  ------------------
  |  Branch (1635:17): [True: 10.9k, False: 13.6k]
  |  Branch (1635:58): [True: 0, False: 10.9k]
  ------------------
 1636|      0|                av_dict_set(&opts[i], "request_sample_fmt", "dsd", 0);
 1637|  24.6k|        }
 1638|  20.9k|#endif
 1639|  20.9k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1640|  45.5k|        for (int i = 0; i < nb_streams; i++)
  ------------------
  |  Branch (1640:25): [True: 24.6k, False: 20.9k]
  ------------------
 1641|  24.6k|            av_dict_set_int(&opts[i], "max_pixels", 2048 * 2048, 0);
 1642|  20.9k|#endif
 1643|  20.9k|        int r = avformat_find_stream_info(avfc, opts);
 1644|  45.5k|        for (int i = 0; i < nb_streams; i++)
  ------------------
  |  Branch (1644:25): [True: 24.6k, False: 20.9k]
  ------------------
 1645|  24.6k|            av_dict_free(&opts[i]);
 1646|  20.9k|        talloc_free(opts);
  ------------------
  |  |   47|  20.9k|#define talloc_free                     ta_free
  ------------------
 1647|  20.9k|        if (r < 0) {
  ------------------
  |  Branch (1647:13): [True: 690, False: 20.2k]
  ------------------
 1648|    690|            MP_ERR(demuxer, "av_find_stream_info() failed\n");
  ------------------
  |  |   89|    690|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    690|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1649|    690|            goto fail;
 1650|    690|        }
 1651|       |
 1652|  20.2k|        MP_VERBOSE(demuxer, "avformat_find_stream_info() finished after %"PRId64
  ------------------
  |  |   92|  20.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  20.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1653|  20.2k|                   " bytes.\n", stream_tell(priv->stream));
 1654|  20.2k|    }
 1655|       |
 1656|  33.8k|    for (int i = 0; i < avfc->nb_chapters; i++) {
  ------------------
  |  Branch (1656:21): [True: 13.2k, False: 20.5k]
  ------------------
 1657|  13.2k|        AVChapter *c = avfc->chapters[i];
 1658|  13.2k|        t = av_dict_get(c->metadata, "title", NULL, 0);
 1659|  13.2k|        int index = demuxer_add_chapter(demuxer, t ? t->value : "",
  ------------------
  |  Branch (1659:50): [True: 2.43k, False: 10.8k]
  ------------------
 1660|  13.2k|                                        c->start * av_q2d(c->time_base), i);
 1661|  13.2k|        mp_tags_move_from_av_dictionary(demuxer->chapters[index].metadata, &c->metadata);
 1662|  13.2k|    }
 1663|       |
 1664|  20.5k|    add_new_streams(demuxer);
 1665|  20.5k|    build_editions(demuxer);
 1666|  20.5k|#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 19, 100)
 1667|  20.5k|    handle_stream_groups(demuxer);
 1668|  20.5k|#endif
 1669|  20.5k|    detect_dovi_split_streams(demuxer);
 1670|       |
 1671|  20.5k|    mp_tags_move_from_av_dictionary(demuxer->metadata, &avfc->metadata);
 1672|       |
 1673|  20.5k|    demuxer->ts_resets_possible =
 1674|  20.5k|        priv->avif_flags & (AVFMT_TS_DISCONT | AVFMT_NOTIMESTAMPS);
 1675|       |
 1676|  20.5k|    if (avfc->start_time != AV_NOPTS_VALUE)
  ------------------
  |  Branch (1676:9): [True: 5.38k, False: 15.1k]
  ------------------
 1677|  5.38k|        demuxer->start_time = avfc->start_time / (double)AV_TIME_BASE;
 1678|       |
 1679|  20.5k|    demuxer->fully_read = priv->format_hack.fully_read;
 1680|       |
 1681|  20.5k|#ifdef AVFMTCTX_UNSEEKABLE
 1682|  20.5k|    if (avfc->ctx_flags & AVFMTCTX_UNSEEKABLE)
  ------------------
  |  Branch (1682:9): [True: 0, False: 20.5k]
  ------------------
 1683|      0|        demuxer->seekable = false;
 1684|  20.5k|#endif
 1685|       |
 1686|  20.5k|    demuxer->is_network |= priv->format_hack.is_network;
 1687|  20.5k|    demuxer->seekable &= !priv->format_hack.no_seek;
 1688|       |
 1689|       |    // We initially prefer track durations over container durations because they
 1690|       |    // have a higher degree of precision over the container duration which are
 1691|       |    // only accurate to the 6th decimal place. This is probably a lavf bug.
 1692|  20.5k|    double total_duration = -1;
 1693|  20.5k|    double av_duration = -1;
 1694|  50.2k|    for (int n = 0; n < priv->avfc->nb_streams; n++) {
  ------------------
  |  Branch (1694:21): [True: 29.7k, False: 20.5k]
  ------------------
 1695|  29.7k|        AVStream *st = priv->avfc->streams[n];
 1696|  29.7k|        if (st->duration <= 0)
  ------------------
  |  Branch (1696:13): [True: 28.1k, False: 1.56k]
  ------------------
 1697|  28.1k|            continue;
 1698|  1.56k|        double f_duration = st->duration * av_q2d(st->time_base);
 1699|  1.56k|        total_duration = MPMAX(total_duration, f_duration);
  ------------------
  |  |   44|  1.56k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 30, False: 1.53k]
  |  |  ------------------
  ------------------
 1700|  1.56k|        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ||
  ------------------
  |  Branch (1700:13): [True: 1.27k, False: 291]
  ------------------
 1701|    291|            st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
  ------------------
  |  Branch (1701:13): [True: 291, False: 0]
  ------------------
 1702|  1.56k|            av_duration = MPMAX(av_duration, f_duration);
  ------------------
  |  |   44|  1.56k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 30, False: 1.53k]
  |  |  ------------------
  ------------------
 1703|  1.56k|    }
 1704|  20.5k|    double duration = av_duration > 0 ? av_duration : total_duration;
  ------------------
  |  Branch (1704:23): [True: 1.51k, False: 19.0k]
  ------------------
 1705|  20.5k|    if (duration <= 0 && priv->avfc->duration > 0)
  ------------------
  |  Branch (1705:9): [True: 19.0k, False: 1.51k]
  |  Branch (1705:26): [True: 0, False: 19.0k]
  ------------------
 1706|      0|        duration = (double)priv->avfc->duration / AV_TIME_BASE;
 1707|  20.5k|    demuxer->duration = duration;
 1708|       |
 1709|  20.5k|    if (demuxer->duration < 0 && priv->format_hack.no_seek_on_no_duration)
  ------------------
  |  Branch (1709:9): [True: 19.0k, False: 1.51k]
  |  Branch (1709:34): [True: 0, False: 19.0k]
  ------------------
 1710|      0|        demuxer->seekable = false;
 1711|       |
 1712|       |    // In some cases, libavformat will export bogus bullshit timestamps anyway,
 1713|       |    // such as with mjpeg.
 1714|  20.5k|    if (priv->avif_flags & AVFMT_NOTIMESTAMPS) {
  ------------------
  |  Branch (1714:9): [True: 2.23k, False: 18.3k]
  ------------------
 1715|  2.23k|        MP_WARN(demuxer,
  ------------------
  |  |   90|  2.23k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.23k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1716|  2.23k|                "This format is marked by FFmpeg as having no timestamps!\n"
 1717|  2.23k|                "FFmpeg will likely make up its own broken timestamps. For\n"
 1718|  2.23k|                "video streams you can correct this with:\n"
 1719|  2.23k|                "    --no-correct-pts --container-fps-override=VALUE\n"
 1720|  2.23k|                "with VALUE being the real framerate of the stream. You can\n"
 1721|  2.23k|                "expect seeking and buffering estimation to be generally\n"
 1722|  2.23k|                "broken as well.\n");
 1723|  2.23k|    }
 1724|       |
 1725|  20.5k|    if (demuxer->fully_read) {
  ------------------
  |  Branch (1725:9): [True: 1.69k, False: 18.8k]
  ------------------
 1726|  1.69k|        demux_close_stream(demuxer);
 1727|  1.69k|        if (priv->own_stream)
  ------------------
  |  Branch (1727:13): [True: 1.66k, False: 31]
  ------------------
 1728|  1.66k|            free_stream(priv->stream);
 1729|  1.69k|        priv->own_stream = false;
 1730|  1.69k|        priv->stream = NULL;
 1731|  1.69k|    }
 1732|       |
 1733|  20.5k|    if (priv->stream) {
  ------------------
  |  Branch (1733:9): [True: 18.8k, False: 1.69k]
  ------------------
 1734|  18.8k|        const char *sname = priv->stream->info->name;
 1735|  18.8k|        priv->is_dvd = strcmp(sname, "dvdnav") == 0 ||
  ------------------
  |  Branch (1735:24): [True: 0, False: 18.8k]
  ------------------
 1736|  18.8k|                       strcmp(sname, "ifo_dvdnav") == 0;
  ------------------
  |  Branch (1736:24): [True: 0, False: 18.8k]
  ------------------
 1737|  18.8k|        priv->is_dvd_bd = priv->is_dvd ||
  ------------------
  |  Branch (1737:27): [True: 0, False: 18.8k]
  ------------------
 1738|  18.8k|                          strcmp(sname, "bd") == 0 ||
  ------------------
  |  Branch (1738:27): [True: 0, False: 18.8k]
  ------------------
 1739|  18.8k|                          strcmp(sname, "bdnav") == 0 ||
  ------------------
  |  Branch (1739:27): [True: 0, False: 18.8k]
  ------------------
 1740|  18.8k|                          strcmp(sname, "bdmv/bluray") == 0;
  ------------------
  |  Branch (1740:27): [True: 0, False: 18.8k]
  ------------------
 1741|  18.8k|    }
 1742|       |
 1743|  20.5k|    return 0;
 1744|       |
 1745|  19.6k|fail:
 1746|  19.6k|    if (!priv->avfc)
  ------------------
  |  Branch (1746:9): [True: 18.9k, False: 690]
  ------------------
 1747|  18.9k|        avformat_free_context(avfc);
 1748|  19.6k|    av_dict_free(&dopts);
 1749|       |
 1750|  19.6k|    return -1;
 1751|  21.2k|}
demux_lavf.c:lavf_check_file:
  471|  40.1k|{
  472|  40.1k|    lavf_priv_t *priv = demuxer->priv;
  473|  40.1k|    struct demux_lavf_opts *lavfdopts = priv->opts;
  474|  40.1k|    struct stream *s = priv->stream;
  475|       |
  476|  40.1k|    priv->filename = remove_prefix(s->url, prefixes);
  477|       |
  478|  40.1k|    char *avdevice_format = NULL;
  479|  40.1k|    if (s->info && strcmp(s->info->name, "avdevice") == 0) {
  ------------------
  |  Branch (479:9): [True: 40.1k, False: 0]
  |  Branch (479:20): [True: 5, False: 40.1k]
  ------------------
  480|       |        // always require filename in the form "format:filename"
  481|      5|        char *sep = strchr(priv->filename, ':');
  482|      5|        if (!sep) {
  ------------------
  |  Branch (482:13): [True: 2, False: 3]
  ------------------
  483|      2|            MP_FATAL(demuxer, "Must specify filename in 'format:filename' form\n");
  ------------------
  |  |   88|      2|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|      2|            return -1;
  485|      2|        }
  486|      3|        avdevice_format = talloc_strndup(priv, priv->filename,
  ------------------
  |  |   51|      3|#define talloc_strndup                  ta_xstrndup
  ------------------
  487|      3|                                         sep - priv->filename);
  488|      3|        priv->filename = sep + 1;
  489|      3|    }
  490|       |
  491|  40.1k|    char *mime_type = s->mime_type;
  492|  40.1k|    if (!lavfdopts->allow_mimetype || !mime_type)
  ------------------
  |  Branch (492:9): [True: 0, False: 40.1k]
  |  Branch (492:39): [True: 40.1k, False: 0]
  ------------------
  493|  40.1k|        mime_type = "";
  494|       |
  495|  40.1k|    const AVInputFormat *forced_format = NULL;
  496|  40.1k|    const char *format = lavfdopts->format;
  497|  40.1k|    if (!format || !format[0])
  ------------------
  |  Branch (497:9): [True: 40.1k, False: 0]
  |  Branch (497:20): [True: 0, False: 0]
  ------------------
  498|  40.1k|        format = s->lavf_type;
  499|  40.1k|    if (!format)
  ------------------
  |  Branch (499:9): [True: 40.1k, False: 11]
  ------------------
  500|  40.1k|        format = avdevice_format;
  501|  40.1k|    if (format) {
  ------------------
  |  Branch (501:9): [True: 14, False: 40.1k]
  ------------------
  502|     14|        if (strcmp(format, "help") == 0) {
  ------------------
  |  Branch (502:13): [True: 0, False: 14]
  ------------------
  503|      0|            list_formats(demuxer);
  504|      0|            return -1;
  505|      0|        }
  506|     14|        forced_format = av_find_input_format(format);
  507|     14|        if (!forced_format) {
  ------------------
  |  Branch (507:13): [True: 14, False: 0]
  ------------------
  508|     14|            MP_FATAL(demuxer, "Unknown lavf format %s\n", format);
  ------------------
  |  |   88|     14|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     14|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  509|     14|            return -1;
  510|     14|        }
  511|     14|    }
  512|       |
  513|       |    // HLS streams seems to be not well tagged, so matching mime type is not
  514|       |    // enough. Strip URL parameters and match extension.
  515|  40.1k|    bstr ext = mp_get_ext(bstr_split(bstr0(priv->filename), "?#", NULL));
  516|  40.1k|    AVProbeData avpd = {
  517|       |        // Disable file-extension matching with normal checks, except for HLS
  518|  40.1k|        .filename = !bstrcasecmp0(ext, "m3u8") || !bstrcasecmp0(ext, "m3u") ||
  ------------------
  |  Branch (518:21): [True: 166, False: 39.9k]
  |  Branch (518:51): [True: 93, False: 39.8k]
  ------------------
  519|  39.8k|                    check <= DEMUX_CHECK_REQUEST ? priv->filename : "",
  ------------------
  |  Branch (519:21): [True: 9.72k, False: 30.1k]
  ------------------
  520|  40.1k|        .buf_size = 0,
  521|  40.1k|        .buf = av_malloc(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE),
  ------------------
  |  |   65|  40.1k|#define PROBE_BUF_SIZE (10 * 1024 * 1024)
  ------------------
  522|  40.1k|        .mime_type = lavfdopts->allow_mimetype ? mime_type : NULL,
  ------------------
  |  Branch (522:22): [True: 40.1k, False: 0]
  ------------------
  523|  40.1k|    };
  524|  40.1k|    if (!avpd.buf)
  ------------------
  |  Branch (524:9): [True: 0, False: 40.1k]
  ------------------
  525|      0|        return -1;
  526|       |
  527|  40.1k|    bool final_probe = false;
  528|  70.0k|    do {
  529|  70.0k|        int score = 0;
  530|       |
  531|  70.0k|        if (forced_format) {
  ------------------
  |  Branch (531:13): [True: 0, False: 70.0k]
  ------------------
  532|      0|            priv->avif = forced_format;
  533|      0|            score = AVPROBE_SCORE_MAX;
  534|  70.0k|        } else {
  535|  70.0k|            int nsize = av_clip(avpd.buf_size * 2, INITIAL_PROBE_SIZE,
  ------------------
  |  |   64|  70.0k|#define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   33|  70.0k|#define STREAM_BUFFER_SIZE 2048
  |  |  ------------------
  ------------------
  536|  70.0k|                                PROBE_BUF_SIZE);
  ------------------
  |  |   65|  70.0k|#define PROBE_BUF_SIZE (10 * 1024 * 1024)
  ------------------
  537|  70.0k|            nsize = stream_read_peek(s, avpd.buf, nsize);
  538|  70.0k|            memset(avpd.buf + nsize, 0, AV_INPUT_BUFFER_PADDING_SIZE);
  539|  70.0k|            if (nsize <= avpd.buf_size)
  ------------------
  |  Branch (539:17): [True: 15.3k, False: 54.6k]
  ------------------
  540|  15.3k|                final_probe = true;
  541|  70.0k|            avpd.buf_size = nsize;
  542|       |
  543|  70.0k|            priv->avif = av_probe_input_format2(&avpd, avpd.buf_size > 0, &score);
  544|  70.0k|        }
  545|       |
  546|  70.0k|        if (priv->avif) {
  ------------------
  |  Branch (546:13): [True: 44.3k, False: 25.6k]
  ------------------
  547|  44.3k|            MP_VERBOSE(demuxer, "Found '%s' at score=%d size=%d%s.\n",
  ------------------
  |  |   92|  44.3k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  88.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 44.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|  44.3k|                       priv->avif->name, score, avpd.buf_size,
  549|  44.3k|                       forced_format ? " (forced)" : "");
  550|       |
  551|  1.23M|            for (int n = 0; lavfdopts->hacks && format_hacks[n].ff_name; n++) {
  ------------------
  |  Branch (551:29): [True: 1.23M, False: 0]
  |  Branch (551:49): [True: 1.20M, False: 24.9k]
  ------------------
  552|  1.20M|                const struct format_hack *entry = &format_hacks[n];
  553|  1.20M|                if (!matches_avinputformat_name(priv, entry->ff_name))
  ------------------
  |  Branch (553:21): [True: 1.17M, False: 36.2k]
  ------------------
  554|  1.17M|                    continue;
  555|  36.2k|                if (entry->mime_type && strcasecmp(entry->mime_type, mime_type) != 0)
  ------------------
  |  Branch (555:21): [True: 16.8k, False: 19.3k]
  |  Branch (555:41): [True: 16.8k, False: 0]
  ------------------
  556|  16.8k|                    continue;
  557|  19.3k|                priv->format_hack = *entry;
  558|  19.3k|                break;
  559|  36.2k|            }
  560|       |
  561|       |            // AVIF always needs to find stream info
  562|  44.3k|            if (bstrcasecmp0(ext, "avif") == 0)
  ------------------
  |  Branch (562:17): [True: 8, False: 44.3k]
  ------------------
  563|      8|                priv->format_hack.skipinfo = false;
  564|       |
  565|  44.3k|            if (score >= lavfdopts->probescore)
  ------------------
  |  Branch (565:17): [True: 24.8k, False: 19.5k]
  ------------------
  566|  24.8k|                break;
  567|       |
  568|  19.5k|            if (priv->format_hack.probescore &&
  ------------------
  |  Branch (568:17): [True: 12.3k, False: 7.18k]
  ------------------
  569|  12.3k|                score >= priv->format_hack.probescore &&
  ------------------
  |  Branch (569:17): [True: 2.84k, False: 9.48k]
  ------------------
  570|  2.84k|                (!priv->format_hack.max_probe || final_probe))
  ------------------
  |  Branch (570:18): [True: 0, False: 2.84k]
  |  Branch (570:50): [True: 1.27k, False: 1.56k]
  ------------------
  571|  1.27k|                break;
  572|  19.5k|        }
  573|       |
  574|  43.9k|        priv->avif = NULL;
  575|  43.9k|        priv->format_hack = (struct format_hack){0};
  576|  43.9k|    } while (!final_probe);
  ------------------
  |  Branch (576:14): [True: 29.8k, False: 14.0k]
  ------------------
  577|       |
  578|  40.1k|    av_free(avpd.buf);
  579|       |
  580|  40.1k|    if (priv->avif && !forced_format && priv->format_hack.ignore) {
  ------------------
  |  Branch (580:9): [True: 26.0k, False: 14.0k]
  |  Branch (580:23): [True: 26.0k, False: 0]
  |  Branch (580:41): [True: 817, False: 25.2k]
  ------------------
  581|    817|        MP_VERBOSE(demuxer, "Format blacklisted.\n");
  ------------------
  |  |   92|    817|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    817|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  582|    817|        priv->avif = NULL;
  583|    817|    }
  584|       |
  585|  40.1k|    if (!priv->avif) {
  ------------------
  |  Branch (585:9): [True: 14.8k, False: 25.2k]
  ------------------
  586|  14.8k|        MP_VERBOSE(demuxer, "No format found, try lowering probescore or forcing the format.\n");
  ------------------
  |  |   92|  14.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  587|  14.8k|        return -1;
  588|  14.8k|    }
  589|       |
  590|  25.2k|    if (lavfdopts->hacks)
  ------------------
  |  Branch (590:9): [True: 25.2k, False: 0]
  ------------------
  591|  25.2k|        priv->avif_flags = priv->avif->flags | priv->format_hack.if_flags;
  592|       |
  593|  25.2k|    priv->linearize_ts = lavfdopts->linearize_ts;
  594|  25.2k|    if (priv->linearize_ts < 0 && !priv->format_hack.linearize_audio_ts)
  ------------------
  |  Branch (594:9): [True: 25.2k, False: 0]
  |  Branch (594:35): [True: 25.2k, False: 0]
  ------------------
  595|  25.2k|        priv->linearize_ts = 0;
  596|       |
  597|  25.2k|    demuxer->filetype = priv->avif->name;
  598|       |
  599|  25.2k|    if (priv->format_hack.detect_charset)
  ------------------
  |  Branch (599:9): [True: 2.00k, False: 23.2k]
  ------------------
  600|  2.00k|        convert_charset(demuxer);
  601|       |
  602|  25.2k|    return 0;
  603|  40.1k|}
demux_lavf.c:remove_prefix:
  458|  40.1k|{
  459|  88.7k|    for (int n = 0; prefixes[n]; n++) {
  ------------------
  |  Branch (459:21): [True: 85.9k, False: 2.79k]
  ------------------
  460|  85.9k|        int len = strlen(prefixes[n]);
  461|  85.9k|        if (strncmp(s, prefixes[n], len) == 0)
  ------------------
  |  Branch (461:13): [True: 37.3k, False: 48.5k]
  ------------------
  462|  37.3k|            return s + len;
  463|  85.9k|    }
  464|  2.79k|    return s;
  465|  40.1k|}
demux_lavf.c:convert_charset:
  428|  2.00k|{
  429|  2.00k|    lavf_priv_t *priv = demuxer->priv;
  430|  2.00k|    char *cp = priv->opts->sub_cp;
  431|  2.00k|    if (!cp || !cp[0] || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (431:9): [True: 0, False: 2.00k]
  |  Branch (431:16): [True: 0, False: 2.00k]
  |  Branch (431:26): [True: 0, False: 2.00k]
  ------------------
  432|      0|        return;
  433|  2.00k|    bstr data = stream_read_complete(priv->stream, NULL, 128 * 1024 * 1024);
  434|  2.00k|    if (!data.start) {
  ------------------
  |  Branch (434:9): [True: 0, False: 2.00k]
  ------------------
  435|      0|        MP_WARN(demuxer, "File too big (or error reading) - skip charset probing.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  436|      0|        return;
  437|      0|    }
  438|  2.00k|    void *alloc = data.start;
  439|  2.00k|    cp = (char *)mp_charset_guess(priv, demuxer->log, data, cp, 0);
  440|  2.00k|    if (cp && !mp_charset_is_utf8(cp))
  ------------------
  |  Branch (440:9): [True: 2.00k, False: 0]
  |  Branch (440:15): [True: 1.87k, False: 131]
  ------------------
  441|  2.00k|        MP_INFO(demuxer, "Using subtitle charset: %s\n", cp);
  ------------------
  |  |   91|  1.87k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.87k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  442|       |    // libavformat transparently converts UTF-16 to UTF-8
  443|  2.00k|    if (!mp_charset_is_utf16(cp) && !mp_charset_is_utf8(cp)) {
  ------------------
  |  Branch (443:9): [True: 1.96k, False: 38]
  |  Branch (443:37): [True: 1.83k, False: 131]
  ------------------
  444|  1.83k|        bstr conv = mp_iconv_to_utf8(demuxer->log, data, cp, MP_ICONV_VERBOSE);
  445|  1.83k|        if (conv.start && conv.start != data.start)
  ------------------
  |  Branch (445:13): [True: 1.83k, False: 0]
  |  Branch (445:27): [True: 1.83k, False: 0]
  ------------------
  446|  1.83k|            talloc_steal(alloc, conv.start);
  ------------------
  |  |   38|  1.83k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  1.83k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  447|  1.83k|        if (conv.start)
  ------------------
  |  Branch (447:13): [True: 1.83k, False: 0]
  ------------------
  448|  1.83k|            data = conv;
  449|  1.83k|    }
  450|  2.00k|    if (data.start) {
  ------------------
  |  Branch (450:9): [True: 2.00k, False: 0]
  ------------------
  451|  2.00k|        priv->stream = stream_memory_open(demuxer->global, data.start, data.len);
  452|  2.00k|        priv->own_stream = true;
  453|  2.00k|    }
  454|  2.00k|    talloc_free(alloc);
  ------------------
  |  |   47|  2.00k|#define talloc_free                     ta_free
  ------------------
  455|  2.00k|}
demux_lavf.c:mp_read:
  343|   137k|{
  344|   137k|    struct demuxer *demuxer = ((struct avio_cookie *)opaque)->demuxer;
  345|   137k|    lavf_priv_t *priv = demuxer->priv;
  346|   137k|    struct stream *stream = priv->stream;
  347|   137k|    if (!stream)
  ------------------
  |  Branch (347:9): [True: 0, False: 137k]
  ------------------
  348|      0|        return 0;
  349|       |
  350|   137k|    int ret = stream_read_partial(stream, buf, size);
  351|       |
  352|   137k|    MP_TRACE(demuxer, "%d=mp_read(%p, %p, %d), pos: %"PRId64", eof:%d\n",
  ------------------
  |  |   94|   137k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   137k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  353|   137k|             ret, stream, buf, size, stream_tell(stream), stream->eof);
  354|   137k|    return ret ? ret : AVERROR_EOF;
  ------------------
  |  Branch (354:12): [True: 29.7k, False: 108k]
  ------------------
  355|   137k|}
demux_lavf.c:mp_seek:
  358|  1.54M|{
  359|  1.54M|    struct demuxer *demuxer = ((struct avio_cookie *)opaque)->demuxer;
  360|  1.54M|    lavf_priv_t *priv = demuxer->priv;
  361|  1.54M|    struct stream *stream = priv->stream;
  362|  1.54M|    if (!stream)
  ------------------
  |  Branch (362:9): [True: 0, False: 1.54M]
  ------------------
  363|      0|        return -1;
  364|       |
  365|  1.54M|    MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %s)\n", stream, pos,
  ------------------
  |  |   94|  1.54M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.03M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 1.41M, False: 66.0k]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 1.48M]
  |  |  |  |  |  Branch (86:57): [True: 62.0k, False: 1.48M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|  1.54M|             whence == SEEK_END ? "end" :
  367|  1.54M|             whence == SEEK_CUR ? "cur" :
  368|  1.54M|             whence == SEEK_SET ? "set" : "size");
  369|  1.54M|    if (whence == SEEK_END || whence == AVSEEK_SIZE) {
  ------------------
  |  Branch (369:9): [True: 62.0k, False: 1.48M]
  |  Branch (369:31): [True: 66.0k, False: 1.41M]
  ------------------
  370|   128k|        int64_t end = stream_get_size(stream);
  371|   128k|        if (end < 0)
  ------------------
  |  Branch (371:13): [True: 124k, False: 3.98k]
  ------------------
  372|   124k|            return -1;
  373|  3.98k|        if (whence == AVSEEK_SIZE)
  ------------------
  |  Branch (373:13): [True: 3.98k, False: 0]
  ------------------
  374|  3.98k|            return end;
  375|      0|        pos += end;
  376|  1.41M|    } else if (whence == SEEK_CUR) {
  ------------------
  |  Branch (376:16): [True: 0, False: 1.41M]
  ------------------
  377|      0|        pos += stream_tell(stream);
  378|  1.41M|    } else if (whence != SEEK_SET) {
  ------------------
  |  Branch (378:16): [True: 0, False: 1.41M]
  ------------------
  379|      0|        return -1;
  380|      0|    }
  381|       |
  382|  1.41M|    if (pos < 0)
  ------------------
  |  Branch (382:9): [True: 0, False: 1.41M]
  ------------------
  383|      0|        return -1;
  384|       |
  385|  1.41M|    int64_t current_pos = stream_tell(stream);
  386|  1.41M|    if (!priv->is_dvd_bd) {
  ------------------
  |  Branch (386:9): [True: 1.41M, False: 0]
  ------------------
  387|  1.41M|        if (stream_seek(stream, pos) == 0) {
  ------------------
  |  Branch (387:13): [True: 1.41M, False: 1.18k]
  ------------------
  388|  1.41M|            stream_seek(stream, current_pos);
  389|  1.41M|            return -1;
  390|  1.41M|        }
  391|  1.41M|    } else {
  392|      0|        stream_drop_buffers(stream);
  393|      0|        stream->pos = current_pos;
  394|      0|    }
  395|       |
  396|  1.18k|    return pos;
  397|  1.41M|}
demux_lavf.c:avio_child_next:
  330|   119k|{
  331|   119k|    AVIOContext *pb = obj;
  332|   119k|    return prev ? NULL : pb->opaque;
  ------------------
  |  Branch (332:12): [True: 59.9k, False: 59.9k]
  ------------------
  333|   119k|}
demux_lavf.c:matches_avinputformat_name:
  304|  1.26M|{
  305|  1.26M|    const char *avifname = priv->avif->name;
  306|  1.35M|    while (1) {
  ------------------
  |  Branch (306:12): [True: 1.35M, Folded]
  ------------------
  307|  1.35M|        const char *next = strchr(avifname, ',');
  308|  1.35M|        if (!next)
  ------------------
  |  Branch (308:13): [True: 1.26M, False: 84.8k]
  ------------------
  309|  1.26M|            return !strcmp(avifname, name);
  310|  84.8k|        int len = next - avifname;
  311|  84.8k|        if (len == strlen(name) && !memcmp(avifname, name, len))
  ------------------
  |  Branch (311:13): [True: 54.0k, False: 30.7k]
  |  Branch (311:36): [True: 1.34k, False: 52.7k]
  ------------------
  312|  1.34k|            return true;
  313|  83.4k|        avifname = next + 1;
  314|  83.4k|    }
  315|  1.26M|}
demux_lavf.c:guess_and_set_vobsub_name:
  614|  25.2k|{
  615|  25.2k|    lavf_priv_t *priv = demuxer->priv;
  616|  25.2k|    if (!matches_avinputformat_name(priv, "vobsub"))
  ------------------
  |  Branch (616:9): [True: 25.1k, False: 92]
  ------------------
  617|  25.1k|        return;
  618|       |
  619|     92|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|     92|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|     92|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  620|     92|    bstr bfilename = bstr0(priv->filename);
  621|     92|    char *subname = NULL;
  622|     92|    if (mp_is_url(bfilename)) {
  ------------------
  |  Branch (622:9): [True: 37, False: 55]
  ------------------
  623|       |        // It might be a http URL, which has additional parameters after the
  624|       |        // end of the actual file path.
  625|     37|        bstr start, end;
  626|     37|        if (bstr_split_tok(bfilename, "?", &start, &end)) {
  ------------------
  |  Branch (626:13): [True: 24, False: 13]
  ------------------
  627|     24|            subname = replace_idx_ext(tmp, start);
  628|     24|            if (subname)
  ------------------
  |  Branch (628:17): [True: 3, False: 21]
  ------------------
  629|      3|                subname = talloc_asprintf(tmp, "%s?%.*s", subname, BSTR_P(end));
  ------------------
  |  |   52|      3|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      6|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|     24|        }
  631|     37|    }
  632|     92|    if (!subname)
  ------------------
  |  Branch (632:9): [True: 89, False: 3]
  ------------------
  633|     89|        subname = replace_idx_ext(tmp, bfilename);
  634|     92|    if (!subname)
  ------------------
  |  Branch (634:9): [True: 84, False: 8]
  ------------------
  635|     84|        subname = talloc_asprintf(tmp, "%.*s.sub", BSTR_P(bfilename));
  ------------------
  |  |   52|     84|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|    168|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 84, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|     92|    MP_VERBOSE(demuxer, "Assuming associated .sub file: %s\n", subname);
  ------------------
  |  |   92|     92|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     92|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  638|     92|    av_dict_set(d, "sub_name", subname, 0);
  639|     92|    talloc_free(tmp);
  ------------------
  |  |   47|     92|#define talloc_free                     ta_free
  ------------------
  640|     92|}
demux_lavf.c:replace_idx_ext:
  606|    113|{
  607|    113|    if (f.len < 4 || f.start[f.len - 4] != '.')
  ------------------
  |  Branch (607:9): [True: 0, False: 113]
  |  Branch (607:22): [True: 105, False: 8]
  ------------------
  608|    105|        return NULL;
  609|      8|    char *ext = bstr_endswith0(f, "IDX") ? "SUB" : "sub"; // match case
  ------------------
  |  Branch (609:17): [True: 0, False: 8]
  ------------------
  610|      8|    return talloc_asprintf(ta_ctx, "%.*s.%s", BSTR_P(bstr_splice(f, 0, -4)), ext);
  ------------------
  |  |   52|      8|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     16|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  611|    113|}
demux_lavf.c:interrupt_cb:
  979|   332k|{
  980|   332k|    return demux_read_interrupted(ctx);
  981|   332k|}
demux_lavf.c:add_new_streams:
  962|  1.49M|{
  963|  1.49M|    lavf_priv_t *priv = demuxer->priv;
  964|  1.52M|    while (priv->num_streams < priv->avfc->nb_streams)
  ------------------
  |  Branch (964:12): [True: 29.7k, False: 1.49M]
  ------------------
  965|  29.7k|        handle_new_stream(demuxer, priv->num_streams);
  966|  1.49M|}
demux_lavf.c:handle_new_stream:
  742|  29.7k|{
  743|  29.7k|    lavf_priv_t *priv = demuxer->priv;
  744|  29.7k|    AVFormatContext *avfc = priv->avfc;
  745|  29.7k|    AVStream *st = avfc->streams[i];
  746|  29.7k|    struct sh_stream *sh = NULL;
  747|  29.7k|    AVCodecParameters *codec = st->codecpar;
  748|  29.7k|    int lavc_delay = codec->initial_padding;
  749|       |
  750|  29.7k|    switch (codec->codec_type) {
  751|  12.3k|    case AVMEDIA_TYPE_AUDIO: {
  ------------------
  |  Branch (751:5): [True: 12.3k, False: 17.3k]
  ------------------
  752|  12.3k|        sh = demux_alloc_sh_stream(STREAM_AUDIO);
  753|  12.3k|        if (!mp_chmap_from_av_layout(&sh->codec->channels, &codec->ch_layout)) {
  ------------------
  |  Branch (753:13): [True: 564, False: 11.8k]
  ------------------
  754|    564|            char layout[128] = {0};
  755|    564|            MP_WARN(demuxer,
  ------------------
  |  |   90|    564|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.12k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 564]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  756|    564|                    "Failed to convert channel layout %s to mpv one!\n",
  757|    564|                    av_channel_layout_describe(&codec->ch_layout,
  758|    564|                                               layout, 128) < 0 ?
  759|    564|                    "undefined" : layout);
  760|    564|        }
  761|       |
  762|  12.3k|        sh->codec->samplerate = codec->sample_rate;
  763|  12.3k|        sh->codec->bitrate = codec->bit_rate;
  764|  12.3k|        sh->codec->format_name = talloc_strdup(sh->codec, av_get_sample_fmt_name(codec->format));
  ------------------
  |  |   50|  12.3k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|       |
  766|  12.3k|        double delay = 0;
  767|  12.3k|        if (codec->sample_rate > 0)
  ------------------
  |  Branch (767:13): [True: 10.3k, False: 2.03k]
  ------------------
  768|  10.3k|            delay = lavc_delay / (double)codec->sample_rate;
  769|  12.3k|        priv->seek_delay = MPMAX(priv->seek_delay, delay);
  ------------------
  |  |   44|  12.3k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 12.3k]
  |  |  ------------------
  ------------------
  770|       |
  771|  12.3k|        export_replaygain(demuxer, sh, st);
  772|       |
  773|  12.3k|        sh->seek_preroll = delay;
  774|       |
  775|  12.3k|        break;
  776|      0|    }
  777|  8.64k|    case AVMEDIA_TYPE_VIDEO: {
  ------------------
  |  Branch (777:5): [True: 8.64k, False: 21.0k]
  ------------------
  778|  8.64k|        sh = demux_alloc_sh_stream(STREAM_VIDEO);
  779|       |
  780|  8.64k|        if ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) &&
  ------------------
  |  Branch (780:13): [True: 0, False: 8.64k]
  ------------------
  781|      0|            !(st->disposition & AV_DISPOSITION_TIMED_THUMBNAILS))
  ------------------
  |  Branch (781:13): [True: 0, False: 0]
  ------------------
  782|      0|        {
  783|      0|            sh->attached_picture =
  784|      0|                new_demux_packet_from_avpacket(demuxer->packet_pool, &st->attached_pic);
  785|      0|            if (sh->attached_picture) {
  ------------------
  |  Branch (785:17): [True: 0, False: 0]
  ------------------
  786|      0|                sh->attached_picture->pts = 0;
  787|      0|                talloc_steal(sh, sh->attached_picture);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  788|      0|                sh->attached_picture->keyframe = true;
  789|      0|            }
  790|      0|        }
  791|       |
  792|  8.64k|        if (!sh->attached_picture) {
  ------------------
  |  Branch (792:13): [True: 8.64k, False: 0]
  ------------------
  793|       |            // A real video stream probably means it's a packet based format.
  794|  8.64k|            priv->pcm_seek_hack_disabled = true;
  795|  8.64k|            priv->pcm_seek_hack = NULL;
  796|       |            // Also, we don't want to do this shit for ogv videos.
  797|  8.64k|            if (priv->linearize_ts < 0)
  ------------------
  |  Branch (797:17): [True: 0, False: 8.64k]
  ------------------
  798|      0|                priv->linearize_ts = 0;
  799|  8.64k|        }
  800|       |
  801|  8.64k|        sh->codec->disp_w = codec->width;
  802|  8.64k|        sh->codec->disp_h = codec->height;
  803|  8.64k|        sh->codec->bitrate = codec->bit_rate;
  804|  8.64k|        sh->codec->format_name = talloc_strdup(sh->codec, av_get_pix_fmt_name(codec->format));
  ------------------
  |  |   50|  8.64k|#define talloc_strdup                   ta_xstrdup
  ------------------
  805|  8.64k|        if (st->avg_frame_rate.num)
  ------------------
  |  Branch (805:13): [True: 5.11k, False: 3.52k]
  ------------------
  806|  5.11k|            sh->codec->fps = av_q2d(st->avg_frame_rate);
  807|  8.64k|        if (is_image(st, sh->attached_picture, priv->avif)) {
  ------------------
  |  Branch (807:13): [True: 3.70k, False: 4.93k]
  ------------------
  808|  3.70k|            MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
  ------------------
  |  |   92|  3.70k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.70k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  809|  3.70k|            sh->image = true;
  810|  3.70k|            sh->codec->fps = demuxer->opts->mf_fps;
  811|  3.70k|        }
  812|  8.64k|        sh->codec->par_w = st->sample_aspect_ratio.num;
  813|  8.64k|        sh->codec->par_h = st->sample_aspect_ratio.den;
  814|       |
  815|  8.64k|        const uint8_t *sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX);
  816|  8.64k|        if (sd) {
  ------------------
  |  Branch (816:13): [True: 0, False: 8.64k]
  ------------------
  817|      0|            double r = av_display_rotation_get((int32_t *)sd);
  818|      0|            if (!isnan(r))
  ------------------
  |  Branch (818:17): [True: 0, False: 0]
  ------------------
  819|      0|                sh->codec->rotate = (((int)(-r) % 360) + 360) % 360;
  820|      0|        }
  821|       |
  822|  8.64k|        if ((sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D)))
  ------------------
  |  Branch (822:13): [True: 0, False: 8.64k]
  ------------------
  823|      0|            sh->codec->stereo_mode = mp_stereo3d_from_av((const AVStereo3D *)sd);
  824|       |
  825|  8.64k|        if ((sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF))) {
  ------------------
  |  Branch (825:13): [True: 0, False: 8.64k]
  ------------------
  826|      0|            const AVDOVIDecoderConfigurationRecord *cfg = (void *) sd;
  827|      0|            MP_VERBOSE(demuxer, "Found Dolby Vision config record: profile "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  828|      0|                       "%d level %d\n", cfg->dv_profile, cfg->dv_level);
  829|      0|            sh->codec->dovi = true;
  830|      0|            sh->codec->dv_profile = cfg->dv_profile;
  831|      0|            sh->codec->dv_level = cfg->dv_level;
  832|      0|            sh->codec->dv_el_present = cfg->bl_present_flag && cfg->el_present_flag;
  ------------------
  |  Branch (832:40): [True: 0, False: 0]
  |  Branch (832:64): [True: 0, False: 0]
  ------------------
  833|      0|        }
  834|       |
  835|       |        // AVI uses decode-order indices as DTS and needs the compensation.
  836|  8.64k|        sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");
  837|       |
  838|  8.64k|        break;
  839|      0|    }
  840|  1.94k|    case AVMEDIA_TYPE_SUBTITLE: {
  ------------------
  |  Branch (840:5): [True: 1.94k, False: 27.7k]
  ------------------
  841|  1.94k|        sh = demux_alloc_sh_stream(STREAM_SUB);
  842|       |
  843|  1.94k|        if (codec->extradata_size) {
  ------------------
  |  Branch (843:13): [True: 209, False: 1.73k]
  ------------------
  844|    209|            sh->codec->extradata = talloc_size(sh->codec, codec->extradata_size);
  ------------------
  |  |   43|    209|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|    209|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    209|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    209|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    209|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    209|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|    209|            memcpy(sh->codec->extradata, codec->extradata, codec->extradata_size);
  846|    209|            sh->codec->extradata_size = codec->extradata_size;
  847|    209|        }
  848|       |
  849|  1.94k|        if (matches_avinputformat_name(priv, "microdvd")) {
  ------------------
  |  Branch (849:13): [True: 0, False: 1.94k]
  ------------------
  850|      0|            AVRational r;
  851|      0|            if (av_opt_get_q(avfc, "subfps", AV_OPT_SEARCH_CHILDREN, &r) >= 0) {
  ------------------
  |  Branch (851:17): [True: 0, False: 0]
  ------------------
  852|       |                // File headers don't have a FPS set.
  853|      0|                if (r.num < 1 || r.den < 1)
  ------------------
  |  Branch (853:21): [True: 0, False: 0]
  |  Branch (853:34): [True: 0, False: 0]
  ------------------
  854|      0|                    sh->codec->frame_based = 23.976; // default timebase
  855|      0|            }
  856|      0|        }
  857|  1.94k|        break;
  858|      0|    }
  859|      0|    case AVMEDIA_TYPE_ATTACHMENT: {
  ------------------
  |  Branch (859:5): [True: 0, False: 29.7k]
  ------------------
  860|      0|        AVDictionaryEntry *ftag = av_dict_get(st->metadata, "filename", NULL, 0);
  861|      0|        char *filename = ftag ? ftag->value : NULL;
  ------------------
  |  Branch (861:26): [True: 0, False: 0]
  ------------------
  862|      0|        AVDictionaryEntry *mt = av_dict_get(st->metadata, "mimetype", NULL, 0);
  863|      0|        char *mimetype = mt ? mt->value : NULL;
  ------------------
  |  Branch (863:26): [True: 0, False: 0]
  ------------------
  864|      0|        if (mimetype) {
  ------------------
  |  Branch (864:13): [True: 0, False: 0]
  ------------------
  865|      0|            demuxer_add_attachment(demuxer, filename, mimetype,
  866|      0|                                   codec->extradata, codec->extradata_size);
  867|      0|        }
  868|      0|        break;
  869|      0|    }
  870|  6.77k|    default: ;
  ------------------
  |  Branch (870:5): [True: 6.77k, False: 22.9k]
  ------------------
  871|  29.7k|    }
  872|       |
  873|  29.7k|    struct stream_info *info = talloc_zero(priv, struct stream_info);
  ------------------
  |  |   27|  29.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  29.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  29.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|  29.7k|    *info = (struct stream_info){
  875|  29.7k|        .sh = sh,
  876|  29.7k|        .last_key_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  29.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  877|  29.7k|        .highest_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  29.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  878|  29.7k|    };
  879|  29.7k|    mp_assert(priv->num_streams == i); // directly mapped
  ------------------
  |  |   41|  29.7k|#define mp_assert assert
  ------------------
  |  Branch (879:5): [True: 29.7k, False: 0]
  ------------------
  880|  29.7k|    MP_TARRAY_APPEND(priv, priv->streams, priv->num_streams, info);
  ------------------
  |  |  105|  29.7k|    do {                                            \
  |  |  106|  29.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.7k|    do {                                            \
  |  |  |  |   97|  29.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 20.7k, False: 9.01k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  20.7k|    do {                                                        \
  |  |  |  |  |  |   89|  20.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  20.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  20.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  20.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  20.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  20.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  20.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 20.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.7k|        (idxvar)++;                                 \
  |  |  109|  29.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.7k]
  |  |  ------------------
  ------------------
  881|       |
  882|  29.7k|    if (sh) {
  ------------------
  |  Branch (882:9): [True: 22.9k, False: 6.77k]
  ------------------
  883|  22.9k|        sh->ff_index = st->index;
  884|  22.9k|        mp_codec_info_from_avcodecpar(codec, sh->codec);
  885|  22.9k|        sh->codec->codec_tag = codec->codec_tag;
  886|  22.9k|        AVCodecParameters **lavp = talloc_ptrtype(sh->codec, lavp);
  ------------------
  |  |   34|  22.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  22.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  22.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|  22.9k|        talloc_set_destructor(lavp, avcodec_par_destructor);
  ------------------
  |  |   41|  22.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  888|  22.9k|        *lavp = avcodec_parameters_alloc();
  889|  22.9k|        if (*lavp && avcodec_parameters_copy(*lavp, codec) >= 0)
  ------------------
  |  Branch (889:13): [True: 22.9k, False: 0]
  |  Branch (889:22): [True: 22.9k, False: 0]
  ------------------
  890|  22.9k|            sh->codec->lav_codecpar = *lavp;
  891|  22.9k|        sh->codec->native_tb_num = st->time_base.num;
  892|  22.9k|        sh->codec->native_tb_den = st->time_base.den;
  893|  22.9k|        sh->codec->duration = st->duration * av_q2d(st->time_base);
  894|       |
  895|  22.9k|        if (st->disposition & AV_DISPOSITION_DEFAULT)
  ------------------
  |  Branch (895:13): [True: 0, False: 22.9k]
  ------------------
  896|      0|            sh->default_track = true;
  897|  22.9k|        if (st->disposition & AV_DISPOSITION_FORCED)
  ------------------
  |  Branch (897:13): [True: 0, False: 22.9k]
  ------------------
  898|      0|            sh->forced_track = true;
  899|  22.9k|        if (st->disposition & AV_DISPOSITION_DEPENDENT)
  ------------------
  |  Branch (899:13): [True: 0, False: 22.9k]
  ------------------
  900|      0|            sh->dependent_track = true;
  901|  22.9k|        if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
  ------------------
  |  Branch (901:13): [True: 1, False: 22.9k]
  ------------------
  902|      1|            sh->visual_impaired_track = true;
  903|  22.9k|        if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
  ------------------
  |  Branch (903:13): [True: 1, False: 22.9k]
  ------------------
  904|      1|            sh->hearing_impaired_track = true;
  905|  22.9k|        if (st->disposition & AV_DISPOSITION_ORIGINAL)
  ------------------
  |  Branch (905:13): [True: 0, False: 22.9k]
  ------------------
  906|      0|            sh->original_track = true;
  907|  22.9k|        if (st->disposition & AV_DISPOSITION_COMMENT)
  ------------------
  |  Branch (907:13): [True: 2, False: 22.9k]
  ------------------
  908|      2|            sh->commentary_track = true;
  909|  22.9k|        if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
  ------------------
  |  Branch (909:13): [True: 0, False: 22.9k]
  ------------------
  910|      0|            sh->still_image = true;
  911|  22.9k|        if (priv->format_hack.use_stream_ids)
  ------------------
  |  Branch (911:13): [True: 227, False: 22.7k]
  ------------------
  912|    227|            sh->demuxer_id = st->id;
  913|  22.9k|        AVDictionaryEntry *title = av_dict_get(st->metadata, "title", NULL, 0);
  914|  22.9k|        if (title && title->value)
  ------------------
  |  Branch (914:13): [True: 0, False: 22.9k]
  |  Branch (914:22): [True: 0, False: 0]
  ------------------
  915|      0|            sh->title = talloc_strdup(sh, title->value);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  916|  22.9k|        AVDictionaryEntry *comment = av_dict_get(st->metadata, "comment", NULL, 0);
  917|  22.9k|        if (!sh->title && comment && comment->value)
  ------------------
  |  Branch (917:13): [True: 22.9k, False: 0]
  |  Branch (917:27): [True: 0, False: 22.9k]
  |  Branch (917:38): [True: 0, False: 0]
  ------------------
  918|      0|            sh->title = talloc_strdup(sh, comment->value);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  919|  22.9k|        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
  920|  22.9k|        if (lang && lang->value && strcmp(lang->value, "und") != 0)
  ------------------
  |  Branch (920:13): [True: 0, False: 22.9k]
  |  Branch (920:21): [True: 0, False: 0]
  |  Branch (920:36): [True: 0, False: 0]
  ------------------
  921|      0|            sh->lang = talloc_strdup(sh, lang->value);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  922|  22.9k|        sh->hls_bitrate = dict_get_decimal(st->metadata, "variant_bitrate", 0);
  923|  22.9k|        AVProgram *prog = NULL;
  924|       |        // In the order as reported by lavf
  925|  22.9k|        while ((prog = av_find_program_from_stream(avfc, prog, i)))
  ------------------
  |  Branch (925:16): [True: 0, False: 22.9k]
  ------------------
  926|      0|            MP_TARRAY_APPEND(sh, sh->program_ids, sh->num_program_ids, prog->id);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  927|  22.9k|        sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS);
  928|  22.9k|        mp_tags_move_from_av_dictionary(sh->tags, &st->metadata);
  929|  22.9k|        demux_add_sh_stream(demuxer, sh);
  930|       |
  931|       |        // DVD routes the menu's button-graphics through an SPU
  932|       |        // substream lavf only discovers once the first SPU PES arrives
  933|       |        // mid-playback. Select it immediately to avoid missing menu highlights.
  934|  22.9k|        if (priv->is_dvd && sh->type == STREAM_SUB)
  ------------------
  |  Branch (934:13): [True: 0, False: 22.9k]
  |  Branch (934:29): [True: 0, False: 0]
  ------------------
  935|      0|            demuxer_select_track(demuxer, sh, MP_NOPTS_VALUE, true);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  936|       |
  937|       |        // Unfortunately, there is no better way to detect PCM codecs, other
  938|       |        // than listing them all manually. (Or other "frameless" codecs. Or
  939|       |        // rather, codecs with frames so small libavformat will put multiple of
  940|       |        // them into a single packet, but not preserve these artificial packet
  941|       |        // boundaries on seeking.)
  942|  22.9k|        if (sh->codec->codec && strncmp(sh->codec->codec, "pcm_", 4) == 0 &&
  ------------------
  |  Branch (942:13): [True: 22.9k, False: 0]
  |  Branch (942:33): [True: 2.93k, False: 20.0k]
  ------------------
  943|  2.93k|            codec->block_align && !priv->pcm_seek_hack_disabled &&
  ------------------
  |  Branch (943:13): [True: 323, False: 2.61k]
  |  Branch (943:35): [True: 200, False: 123]
  ------------------
  944|    200|            priv->opts->hacks && !priv->format_hack.no_pcm_seek &&
  ------------------
  |  Branch (944:13): [True: 200, False: 0]
  |  Branch (944:34): [True: 200, False: 0]
  ------------------
  945|    200|            st->time_base.num == 1 && st->time_base.den == codec->sample_rate)
  ------------------
  |  Branch (945:13): [True: 200, False: 0]
  |  Branch (945:39): [True: 200, False: 0]
  ------------------
  946|    200|        {
  947|    200|            if (priv->pcm_seek_hack) {
  ------------------
  |  Branch (947:17): [True: 0, False: 200]
  ------------------
  948|       |                // More than 1 audio stream => usually doesn't apply.
  949|      0|                priv->pcm_seek_hack_disabled = true;
  950|      0|                priv->pcm_seek_hack = NULL;
  951|    200|            } else {
  952|    200|                priv->pcm_seek_hack = st;
  953|    200|            }
  954|    200|        }
  955|  22.9k|    }
  956|       |
  957|  29.7k|    select_tracks(demuxer, i);
  958|  29.7k|}
demux_lavf.c:export_replaygain:
  672|  12.3k|{
  673|  12.3k|    const AVReplayGain *av_rgain =
  674|  12.3k|        (const AVReplayGain *)mp_av_stream_get_side_data(st, AV_PKT_DATA_REPLAYGAIN);
  675|  12.3k|    if (!av_rgain)
  ------------------
  |  Branch (675:9): [True: 12.3k, False: 0]
  ------------------
  676|  12.3k|        return;
  677|       |
  678|  12.3k|    bool track_data_available =
  679|      0|        av_rgain->track_gain != INT32_MIN && av_rgain->track_peak != 0;
  ------------------
  |  Branch (679:9): [True: 0, False: 0]
  |  Branch (679:46): [True: 0, False: 0]
  ------------------
  680|      0|    bool album_data_available =
  681|      0|        av_rgain->album_gain != INT32_MIN && av_rgain->album_peak != 0;
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  |  Branch (681:46): [True: 0, False: 0]
  ------------------
  682|       |
  683|      0|    if (!track_data_available && !album_data_available)
  ------------------
  |  Branch (683:9): [True: 0, False: 0]
  |  Branch (683:34): [True: 0, False: 0]
  ------------------
  684|      0|        return;
  685|       |
  686|      0|    struct replaygain_data *rgain = talloc_ptrtype(sh->codec, rgain);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  687|      0|    rgain->track_gain = rgain->album_gain = 0;
  688|      0|    rgain->track_peak = rgain->album_peak = 1;
  689|       |
  690|       |    // Set values in *rgain, using track gain as a fallback for album gain
  691|       |    // if the latter is not present. This behavior matches that in
  692|       |    // demux/demux.c's decode_rgain; if you change this, please make
  693|       |    // equivalent changes there too.
  694|      0|    if (track_data_available) {
  ------------------
  |  Branch (694:9): [True: 0, False: 0]
  ------------------
  695|      0|        rgain->track_gain = rgain->album_gain =
  696|      0|            av_rgain->track_gain / 100000.0f;
  697|      0|        rgain->track_peak = rgain->album_peak =
  698|      0|            av_rgain->track_peak / 100000.0f;
  699|      0|    }
  700|       |
  701|       |    // If album data is actually available, fill it in with proper values.
  702|      0|    if (album_data_available) {
  ------------------
  |  Branch (702:9): [True: 0, False: 0]
  ------------------
  703|      0|        rgain->album_gain = av_rgain->album_gain / 100000.0f;
  704|      0|        rgain->album_peak = av_rgain->album_peak / 100000.0f;
  705|      0|    }
  706|       |
  707|       |    // This must be run only before the stream was added, otherwise there
  708|       |    // will be race conditions with accesses from the user thread.
  709|      0|    mp_assert(!sh->ds);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (709:5): [True: 0, False: 0]
  ------------------
  710|      0|    sh->codec->replaygain_data = rgain;
  711|      0|}
demux_lavf.c:is_image:
  727|  8.64k|{
  728|  8.64k|    return st->nb_frames <= 1 && (
  ------------------
  |  Branch (728:12): [True: 8.38k, False: 255]
  ------------------
  729|  8.38k|        attached_picture ||
  ------------------
  |  Branch (729:9): [True: 0, False: 8.38k]
  ------------------
  730|  8.38k|        bstr_endswith0(bstr0(avif->name), "_pipe") ||
  ------------------
  |  Branch (730:9): [True: 3.37k, False: 5.00k]
  ------------------
  731|  5.00k|        strcmp(avif->name, "alias_pix") == 0 ||
  ------------------
  |  Branch (731:9): [True: 0, False: 5.00k]
  ------------------
  732|  5.00k|        strcmp(avif->name, "gif") == 0 ||
  ------------------
  |  Branch (732:9): [True: 328, False: 4.68k]
  ------------------
  733|  4.68k|        strcmp(avif->name, "ico") == 0 ||
  ------------------
  |  Branch (733:9): [True: 0, False: 4.68k]
  ------------------
  734|  4.68k|        strcmp(avif->name, "image2pipe") == 0 ||
  ------------------
  |  Branch (734:9): [True: 0, False: 4.68k]
  ------------------
  735|  4.68k|        ((st->codecpar->codec_id == AV_CODEC_ID_HEVC ||
  ------------------
  |  Branch (735:11): [True: 0, False: 4.68k]
  ------------------
  736|  4.68k|          st->codecpar->codec_id == AV_CODEC_ID_AV1)
  ------------------
  |  Branch (736:11): [True: 1.21k, False: 3.46k]
  ------------------
  737|  1.21k|         && st->nb_frames == 1)
  ------------------
  |  Branch (737:13): [True: 0, False: 1.21k]
  ------------------
  738|  8.38k|    );
  739|  8.64k|}
demux_lavf.c:mp_av_stream_get_side_data:
  662|  38.3k|{
  663|  38.3k|    const AVPacketSideData *sd;
  664|  38.3k|    sd = av_packet_side_data_get(st->codecpar->coded_side_data,
  665|  38.3k|                                 st->codecpar->nb_coded_side_data,
  666|  38.3k|                                 type);
  667|  38.3k|    return sd ? sd->data : NULL;
  ------------------
  |  Branch (667:12): [True: 0, False: 38.3k]
  ------------------
  668|  38.3k|}
demux_lavf.c:avcodec_par_destructor:
   73|  22.9k|{
   74|  22.9k|    avcodec_parameters_free(p);
   75|  22.9k|}
demux_lavf.c:dict_get_decimal:
  715|  22.9k|{
  716|  22.9k|    AVDictionaryEntry *e = av_dict_get(dict, entry, NULL, 0);
  717|  22.9k|    if (e && e->value) {
  ------------------
  |  Branch (717:9): [True: 0, False: 22.9k]
  |  Branch (717:14): [True: 0, False: 0]
  ------------------
  718|      0|        char *end = NULL;
  719|      0|        long int r = strtol(e->value, &end, 10);
  720|      0|        if (!end[0] && r >= INT_MIN && r <= INT_MAX)
  ------------------
  |  Branch (720:13): [True: 0, False: 0]
  |  Branch (720:24): [True: 0, False: 0]
  |  Branch (720:40): [True: 0, False: 0]
  ------------------
  721|      0|            return r;
  722|      0|    }
  723|  22.9k|    return def;
  724|  22.9k|}
demux_lavf.c:select_tracks:
  643|  48.3k|{
  644|  48.3k|    lavf_priv_t *priv = demuxer->priv;
  645|   100k|    for (int n = start; n < priv->num_streams; n++) {
  ------------------
  |  Branch (645:25): [True: 51.7k, False: 48.3k]
  ------------------
  646|  51.7k|        struct sh_stream *stream = priv->streams[n]->sh;
  647|  51.7k|        AVStream *st = priv->avfc->streams[n];
  648|  51.7k|        bool selected = stream && demux_stream_is_selected(stream) &&
  ------------------
  |  Branch (648:25): [True: 44.8k, False: 6.86k]
  |  Branch (648:35): [True: 21.0k, False: 23.8k]
  ------------------
  649|  21.0k|                        !stream->attached_picture;
  ------------------
  |  Branch (649:25): [True: 21.0k, False: 0]
  ------------------
  650|  51.7k|        if (!selected && priv->streams[n]->dovi_split) {
  ------------------
  |  Branch (650:13): [True: 30.7k, False: 21.0k]
  |  Branch (650:26): [True: 0, False: 30.7k]
  ------------------
  651|      0|            struct sh_stream *el =
  652|      0|                mp_dovi_split_el_stream(priv->streams[n]->dovi_split);
  653|      0|            if (el && demux_stream_is_selected(el))
  ------------------
  |  Branch (653:17): [True: 0, False: 0]
  |  Branch (653:23): [True: 0, False: 0]
  ------------------
  654|      0|                selected = true;
  655|      0|        }
  656|  51.7k|        st->discard = selected ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
  ------------------
  |  Branch (656:23): [True: 21.0k, False: 30.7k]
  ------------------
  657|  51.7k|    }
  658|  48.3k|}
demux_lavf.c:build_editions:
 1073|  20.5k|{
 1074|  20.5k|    lavf_priv_t *priv = demuxer->priv;
 1075|  20.5k|    AVFormatContext *avfc = priv->avfc;
 1076|       |
 1077|  20.5k|    if (avfc->nb_programs <= 1)
  ------------------
  |  Branch (1077:9): [True: 20.5k, False: 0]
  ------------------
 1078|  20.5k|        return;
 1079|       |
 1080|      0|    struct MPOpts *mp_opts = mp_get_config_group(NULL, demuxer->global, &mp_opt_root);
 1081|      0|    int hls_bitrate = mp_opts->hls_bitrate;
 1082|      0|    int edition_id = mp_opts->edition_id;
 1083|      0|    bool flatten_editions = mp_opts->flatten_editions;
 1084|      0|    TA_FREEP(&mp_opts);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1085|      0|    if (flatten_editions) {
  ------------------
  |  Branch (1085:9): [True: 0, False: 0]
  ------------------
 1086|      0|        MP_VERBOSE(demuxer, "Flattening track-based editions.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1087|      0|        return;
 1088|      0|    }
 1089|       |
 1090|       |    // Order programs by their id so the list is stable regardless of the order
 1091|       |    // lavf happened to discover them.
 1092|      0|    AVProgram **progs = talloc_memdup(NULL, avfc->programs, avfc->nb_programs * sizeof(progs[0]));
  ------------------
  |  |   49|      0|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|      0|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1093|      0|    qsort(progs, avfc->nb_programs, sizeof(progs[0]), cmp_avprogram);
 1094|      0|    bool *nonempty = talloc_zero_array(progs, bool, avfc->nb_programs);
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1095|       |
 1096|      0|    int first_nonempty = -1;
 1097|      0|    for (unsigned i = 0; i < avfc->nb_programs; i++) {
  ------------------
  |  Branch (1097:26): [True: 0, False: 0]
  ------------------
 1098|      0|        AVProgram *prog = progs[i];
 1099|       |
 1100|      0|        struct demux_edition ed = {
 1101|      0|            .demuxer_id = prog->id,
 1102|      0|            .metadata = talloc_zero(demuxer, struct mp_tags),
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1103|      0|        };
 1104|      0|        mp_tags_copy_from_av_dictionary(ed.metadata, prog->metadata);
 1105|       |
 1106|      0|        int video_count = 0, audio_count = 0, track_count = 0;
 1107|      0|        int video_idx = -1, audio_idx = -1;
 1108|      0|        for (unsigned j = 0; j < prog->nb_stream_indexes; j++) {
  ------------------
  |  Branch (1108:30): [True: 0, False: 0]
  ------------------
 1109|      0|            unsigned idx = prog->stream_index[j];
 1110|      0|            if (idx >= priv->num_streams || !priv->streams[idx]->sh)
  ------------------
  |  Branch (1110:17): [True: 0, False: 0]
  |  Branch (1110:45): [True: 0, False: 0]
  ------------------
 1111|      0|                continue;
 1112|      0|            track_count++;
 1113|      0|            struct sh_stream *sh = priv->streams[idx]->sh;
 1114|      0|            if (sh->type == STREAM_VIDEO) {
  ------------------
  |  Branch (1114:17): [True: 0, False: 0]
  ------------------
 1115|      0|                video_count++;
 1116|      0|                video_idx = idx;
 1117|      0|            } else if (sh->type == STREAM_AUDIO) {
  ------------------
  |  Branch (1117:24): [True: 0, False: 0]
  ------------------
 1118|      0|                audio_count++;
 1119|      0|                audio_idx = idx;
 1120|      0|            }
 1121|      0|        }
 1122|       |
 1123|      0|        const char *prefix = mp_tags_get_str(ed.metadata, "title");
 1124|      0|        if (!prefix)
  ------------------
  |  Branch (1124:13): [True: 0, False: 0]
  ------------------
 1125|      0|            prefix = mp_tags_get_str(ed.metadata, "service_name");
 1126|      0|        if (!prefix) {
  ------------------
  |  Branch (1126:13): [True: 0, False: 0]
  ------------------
 1127|      0|            int name_idx = video_count == 1 ? video_idx
  ------------------
  |  Branch (1127:28): [True: 0, False: 0]
  ------------------
 1128|      0|                         : audio_count == 1 ? audio_idx : -1;
  ------------------
  |  Branch (1128:28): [True: 0, False: 0]
  ------------------
 1129|      0|            if (name_idx >= 0)
  ------------------
  |  Branch (1129:17): [True: 0, False: 0]
  ------------------
 1130|      0|                prefix = mp_tags_get_str(priv->streams[name_idx]->sh->tags, "comment");
 1131|      0|        }
 1132|      0|        char buf[42];
 1133|      0|        if (!prefix) {
  ------------------
  |  Branch (1133:13): [True: 0, False: 0]
  ------------------
 1134|      0|            char *vb = mp_tags_get_str(ed.metadata, "variant_bitrate");
 1135|      0|            char *end;
 1136|      0|            double rate = vb ? strtoll(vb, &end, 10) : 0;
  ------------------
  |  Branch (1136:27): [True: 0, False: 0]
  ------------------
 1137|      0|            if (rate > 0 && *end == '\0') {
  ------------------
  |  Branch (1137:17): [True: 0, False: 0]
  |  Branch (1137:29): [True: 0, False: 0]
  ------------------
 1138|      0|                rate /= 1000.0;
 1139|      0|                prefix = rate < 1000
  ------------------
  |  Branch (1139:26): [True: 0, False: 0]
  ------------------
 1140|      0|                    ? mp_tprintf_buf(buf, sizeof(buf), "Bitrate: %.f kbps", rate)
 1141|      0|                    : mp_tprintf_buf(buf, sizeof(buf), "Bitrate: %.3f Mbps", rate / 1000.0);
 1142|      0|            }
 1143|      0|        }
 1144|       |
 1145|      0|        char *title = demux_compose_edition_title(demuxer, demuxer,
 1146|      0|                                                  prog->id, prefix);
 1147|      0|        if (title)
  ------------------
  |  Branch (1147:13): [True: 0, False: 0]
  ------------------
 1148|      0|            mp_tags_set_str(ed.metadata, "title", title);
 1149|       |
 1150|      0|        nonempty[i] = track_count > 0;
 1151|      0|        if (track_count > 0 && first_nonempty < 0)
  ------------------
  |  Branch (1151:13): [True: 0, False: 0]
  |  Branch (1151:32): [True: 0, False: 0]
  ------------------
 1152|      0|            first_nonempty = demuxer->num_editions;
 1153|       |
 1154|      0|        MP_TARRAY_APPEND(demuxer, demuxer->editions, demuxer->num_editions, ed);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1155|      0|    }
 1156|       |
 1157|      0|    demuxer->edition_is_track_mapping = true;
 1158|       |
 1159|      0|    int selected = -1;
 1160|      0|    if (edition_id >= 0 && edition_id < demuxer->num_editions)
  ------------------
  |  Branch (1160:9): [True: 0, False: 0]
  |  Branch (1160:28): [True: 0, False: 0]
  ------------------
 1161|      0|        selected = edition_id;
 1162|       |
 1163|       |    // Select initial edition by best variant bitrate from the program's
 1164|       |    // metadata (HLS variant BANDWIDTH).
 1165|      0|    if (selected < 0 && hls_bitrate >= 0) {
  ------------------
  |  Branch (1165:9): [True: 0, False: 0]
  |  Branch (1165:25): [True: 0, False: 0]
  ------------------
 1166|      0|        int best = -1;
 1167|      0|        int best_bitrate = 0;
 1168|      0|        bool best_ok = false;
 1169|      0|        for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (1169:25): [True: 0, False: 0]
  ------------------
 1170|      0|            AVProgram *prog = progs[n];
 1171|      0|            int bitrate = dict_get_decimal(prog->metadata, "variant_bitrate", 0);
 1172|      0|            if (bitrate <= 0 || !nonempty[n])
  ------------------
  |  Branch (1172:17): [True: 0, False: 0]
  |  Branch (1172:33): [True: 0, False: 0]
  ------------------
 1173|      0|                continue;
 1174|      0|            bool ok = bitrate <= hls_bitrate;
 1175|      0|            if (best < 0 || (ok && !best_ok) ||
  ------------------
  |  Branch (1175:17): [True: 0, False: 0]
  |  Branch (1175:30): [True: 0, False: 0]
  |  Branch (1175:36): [True: 0, False: 0]
  ------------------
 1176|      0|                (ok && best_ok && bitrate > best_bitrate) ||
  ------------------
  |  Branch (1176:18): [True: 0, False: 0]
  |  Branch (1176:24): [True: 0, False: 0]
  |  Branch (1176:35): [True: 0, False: 0]
  ------------------
 1177|      0|                (!ok && !best_ok && bitrate < best_bitrate))
  ------------------
  |  Branch (1177:18): [True: 0, False: 0]
  |  Branch (1177:25): [True: 0, False: 0]
  |  Branch (1177:37): [True: 0, False: 0]
  ------------------
 1178|      0|            {
 1179|      0|                best = n;
 1180|      0|                best_bitrate = bitrate;
 1181|      0|                best_ok = ok;
 1182|      0|            }
 1183|      0|        }
 1184|      0|        if (best >= 0)
  ------------------
  |  Branch (1184:13): [True: 0, False: 0]
  ------------------
 1185|      0|            selected = best;
 1186|      0|    }
 1187|       |
 1188|      0|    demuxer->edition = selected >= 0 ? selected : first_nonempty >= 0 ? first_nonempty : 0;
  ------------------
  |  Branch (1188:24): [True: 0, False: 0]
  |  Branch (1188:51): [True: 0, False: 0]
  ------------------
 1189|       |
 1190|      0|    talloc_free(progs);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1191|      0|}
demux_lavf.c:handle_stream_groups:
 1399|  20.5k|{
 1400|  20.5k|    lavf_priv_t *priv = demuxer->priv;
 1401|  20.5k|    AVFormatContext *avfc = priv->avfc;
 1402|       |
 1403|  20.5k|    for (unsigned i = 0; i < avfc->nb_stream_groups; i++) {
  ------------------
  |  Branch (1403:26): [True: 0, False: 20.5k]
  ------------------
 1404|      0|        AVStreamGroup *stg = avfc->stream_groups[i];
 1405|      0|        switch (stg->type) {
 1406|      0|#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 22, 100)
 1407|      0|        case AV_STREAM_GROUP_PARAMS_TILE_GRID:
  ------------------
  |  Branch (1407:9): [True: 0, False: 0]
  ------------------
 1408|      0|            handle_tile_grid_group(demuxer, stg);
 1409|      0|            break;
 1410|      0|#endif
 1411|      0|        case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:
  ------------------
  |  Branch (1411:9): [True: 0, False: 0]
  ------------------
 1412|      0|            handle_iamf_audio_element_group(demuxer, stg);
 1413|      0|            break;
 1414|      0|        case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: {
  ------------------
  |  Branch (1414:9): [True: 0, False: 0]
  ------------------
 1415|       |            // Full playback requires routing sub-streams through an IAMF
 1416|       |            // decoder context; log for now and let element streams handle
 1417|       |            // suppression.
 1418|      0|            AVDictionaryEntry *t =
 1419|      0|                stg->metadata
  ------------------
  |  Branch (1419:17): [True: 0, False: 0]
  ------------------
 1420|      0|                ? av_dict_get(stg->metadata, "title", NULL, 0) : NULL;
 1421|      0|            MP_VERBOSE(demuxer, "IAMF mix presentation group %u: \"%s\"\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1422|      0|                       stg->index, t ? t->value : "(untitled)");
 1423|      0|            break;
 1424|      0|        }
 1425|      0|#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(61, 6, 100)
 1426|      0|        case AV_STREAM_GROUP_PARAMS_LCEVC:
  ------------------
  |  Branch (1426:9): [True: 0, False: 0]
  ------------------
 1427|      0|            handle_lcevc_group(demuxer, stg);
 1428|      0|            break;
 1429|      0|#endif
 1430|      0|#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(62, 19, 100)
 1431|      0|        case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
  ------------------
  |  Branch (1431:9): [True: 0, False: 0]
  ------------------
 1432|      0|            handle_layered_video_group(demuxer, stg);
 1433|      0|            break;
 1434|      0|#endif
 1435|      0|        default:
  ------------------
  |  Branch (1435:9): [True: 0, False: 0]
  ------------------
 1436|      0|            MP_VERBOSE(demuxer, "Unhandled stream group type %d (index %u)\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1437|      0|                       (int)stg->type, stg->index);
 1438|      0|            break;
 1439|      0|        }
 1440|      0|    }
 1441|  20.5k|}
demux_lavf.c:detect_dovi_split_streams:
 1445|  20.5k|{
 1446|  20.5k|    lavf_priv_t *priv = demuxer->priv;
 1447|  20.5k|    int snapshot_count = priv->num_streams;
 1448|  50.2k|    for (int n = 0; n < snapshot_count; n++) {
  ------------------
  |  Branch (1448:21): [True: 29.7k, False: 20.5k]
  ------------------
 1449|  29.7k|        struct stream_info *info = priv->streams[n];
 1450|  29.7k|        struct sh_stream *sh = info ? info->sh : NULL;
  ------------------
  |  Branch (1450:32): [True: 29.7k, False: 0]
  ------------------
 1451|  29.7k|        if (!sh || sh->type != STREAM_VIDEO || !sh->codec ||
  ------------------
  |  Branch (1451:13): [True: 6.76k, False: 22.9k]
  |  Branch (1451:20): [True: 14.3k, False: 8.64k]
  |  Branch (1451:48): [True: 0, False: 8.64k]
  ------------------
 1452|  8.64k|            !sh->codec->dv_el_present || sh->group)
  ------------------
  |  Branch (1452:13): [True: 8.64k, False: 0]
  |  Branch (1452:42): [True: 0, False: 0]
  ------------------
 1453|  29.7k|        {
 1454|  29.7k|            continue;
 1455|  29.7k|        }
 1456|      0|        info->dovi_split = mp_dovi_split_create(demuxer, sh);
 1457|      0|    }
 1458|  20.5k|}
demux_lavf.c:demux_lavf_read_packet:
 1755|  1.53M|{
 1756|  1.53M|    lavf_priv_t *priv = demux->priv;
 1757|       |
 1758|       |    // Companion EL packet queued by the Dolby Vision splitter on a prior call.
 1759|  1.53M|    if (priv->pending_pkt) {
  ------------------
  |  Branch (1759:9): [True: 0, False: 1.53M]
  ------------------
 1760|      0|        *mp_pkt = priv->pending_pkt;
 1761|      0|        priv->pending_pkt = NULL;
 1762|      0|        return true;
 1763|      0|    }
 1764|       |
 1765|  1.53M|    AVPacket *pkt = av_packet_alloc();
 1766|  1.53M|    MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|  1.53M|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.53M|        void *oom_p_ = (x);     \
  |  |  208|  1.53M|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.53M]
  |  |  ------------------
  |  |  209|  1.53M|            abort();            \
  |  |  210|  1.53M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.53M]
  |  |  ------------------
  ------------------
 1767|  1.53M|    int r = av_read_frame(priv->avfc, pkt);
 1768|  1.53M|    update_read_stats(demux);
 1769|  1.53M|    if (r < 0) {
  ------------------
  |  Branch (1769:9): [True: 63.7k, False: 1.47M]
  ------------------
 1770|  63.7k|        av_packet_free(&pkt);
 1771|  63.7k|        if (r == AVERROR_EOF)
  ------------------
  |  Branch (1771:13): [True: 11.9k, False: 51.7k]
  ------------------
 1772|  11.9k|            return false;
 1773|  51.7k|        if (demux_read_interrupted(demux)) {
  ------------------
  |  Branch (1773:13): [True: 0, False: 51.7k]
  ------------------
 1774|      0|            MP_VERBOSE(demux, "read interrupted: %s.\n", av_err2str(r));
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1775|      0|            return false;
 1776|      0|        }
 1777|  51.7k|        MP_WARN(demux, "error reading packet: %s.\n", av_err2str(r));
  ------------------
  |  |   90|  51.7k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  51.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1778|  51.7k|        if (priv->retry_counter >= 10) {
  ------------------
  |  Branch (1778:13): [True: 3.72k, False: 48.0k]
  ------------------
 1779|  3.72k|            MP_ERR(demux, "...treating it as fatal error.\n");
  ------------------
  |  |   89|  3.72k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.72k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1780|  3.72k|            return false;
 1781|  3.72k|        }
 1782|  48.0k|        priv->retry_counter += 1;
 1783|  48.0k|        return true;
 1784|  51.7k|    }
 1785|  1.47M|    priv->retry_counter = 0;
 1786|       |
 1787|  1.47M|    add_new_streams(demux);
 1788|  1.47M|    update_metadata(demux);
 1789|       |
 1790|  1.47M|    mp_assert(pkt->stream_index >= 0 && pkt->stream_index < priv->num_streams);
  ------------------
  |  |   41|  1.47M|#define mp_assert assert
  ------------------
  |  Branch (1790:5): [True: 1.47M, False: 0]
  |  Branch (1790:5): [True: 1.47M, False: 0]
  ------------------
 1791|  1.47M|    struct stream_info *info = priv->streams[pkt->stream_index];
 1792|  1.47M|    struct sh_stream *stream = info->sh;
 1793|  1.47M|    AVStream *st = priv->avfc->streams[pkt->stream_index];
 1794|       |
 1795|       |    // Keep BL packets flowing to feed the Dolby Vision splitter when its
 1796|       |    // virtual EL is selected, even if the BL itself isn't selected. The
 1797|       |    // unselected BL dp gets discarded by the demuxer queue downstream.
 1798|  1.47M|    struct sh_stream *split_el = info->dovi_split
  ------------------
  |  Branch (1798:34): [True: 0, False: 1.47M]
  ------------------
 1799|  1.47M|                                    ? mp_dovi_split_el_stream(info->dovi_split)
 1800|  1.47M|                                    : NULL;
 1801|  1.47M|    bool need_for_split = split_el && demux_stream_is_selected(split_el);
  ------------------
  |  Branch (1801:27): [True: 0, False: 1.47M]
  |  Branch (1801:39): [True: 0, False: 0]
  ------------------
 1802|  1.47M|    if (!demux_stream_is_selected(stream) && !need_for_split) {
  ------------------
  |  Branch (1802:9): [True: 189, False: 1.47M]
  |  Branch (1802:46): [True: 189, False: 0]
  ------------------
 1803|    189|        av_packet_free(&pkt);
 1804|    189|        return true; // don't signal EOF if skipping a packet
 1805|    189|    }
 1806|       |
 1807|       |    // Never send additional frames for streams that are a single frame.
 1808|  1.47M|    if (stream->image && priv->format_hack.first_frame_only && pkt->pos != 0) {
  ------------------
  |  Branch (1808:9): [True: 62.1k, False: 1.40M]
  |  Branch (1808:26): [True: 0, False: 62.1k]
  |  Branch (1808:64): [True: 0, False: 0]
  ------------------
 1809|      0|        av_packet_free(&pkt);
 1810|      0|        return true;
 1811|      0|    }
 1812|       |
 1813|  1.47M|    struct demux_packet *dp = new_demux_packet_from_avpacket(demux->packet_pool, pkt);
 1814|  1.47M|    if (!dp) {
  ------------------
  |  Branch (1814:9): [True: 0, False: 1.47M]
  ------------------
 1815|      0|        av_packet_free(&pkt);
 1816|      0|        return true;
 1817|      0|    }
 1818|       |
 1819|  1.47M|    if (priv->pcm_seek_hack == st && !priv->pcm_seek_hack_packet_size)
  ------------------
  |  Branch (1819:9): [True: 596, False: 1.46M]
  |  Branch (1819:38): [True: 0, False: 596]
  ------------------
 1820|      0|        priv->pcm_seek_hack_packet_size = pkt->size;
 1821|       |
 1822|  1.47M|    dp->pts = mp_pts_from_av(pkt->pts, &st->time_base);
 1823|  1.47M|    dp->dts = mp_pts_from_av(pkt->dts, &st->time_base);
 1824|  1.47M|    dp->duration = pkt->duration * av_q2d(st->time_base);
 1825|  1.47M|    dp->pos = pkt->pos;
 1826|  1.47M|    dp->keyframe = pkt->flags & AV_PKT_FLAG_KEY;
 1827|  1.47M|    dp->is_wrapped_avframe = st->codecpar->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME;
 1828|  1.47M|    if (dp->is_wrapped_avframe) {
  ------------------
  |  Branch (1828:9): [True: 0, False: 1.47M]
  ------------------
 1829|      0|        mp_require(dp->buffer);
  ------------------
  |  |   42|      0|#define mp_require assert
  ------------------
  |  Branch (1829:9): [True: 0, False: 0]
  ------------------
 1830|      0|        const AVFrame *frame = (AVFrame *)dp->buffer;
 1831|      0|        dp->keyframe |= frame->flags & AV_FRAME_FLAG_KEY;
 1832|      0|    }
 1833|  1.47M|    av_packet_free(&pkt);
 1834|       |
 1835|  1.47M|    if (priv->format_hack.clear_filepos)
  ------------------
  |  Branch (1835:9): [True: 0, False: 1.47M]
  ------------------
 1836|      0|        dp->pos = -1;
 1837|       |
 1838|  1.47M|    dp->stream = stream->index;
 1839|       |
 1840|  1.47M|    if (priv->linearize_ts) {
  ------------------
  |  Branch (1840:9): [True: 0, False: 1.47M]
  ------------------
 1841|      0|        dp->pts = MP_ADD_PTS(dp->pts, info->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1842|      0|        dp->dts = MP_ADD_PTS(dp->dts, info->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1843|       |
 1844|      0|        double pts = MP_PTS_OR_DEF(dp->pts, dp->dts);
  ------------------
  |  |   62|      0|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1845|      0|        if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1845:13): [True: 0, False: 0]
  ------------------
 1846|      0|            if (dp->keyframe) {
  ------------------
  |  Branch (1846:17): [True: 0, False: 0]
  ------------------
 1847|      0|                if (pts < info->highest_pts) {
  ------------------
  |  Branch (1847:21): [True: 0, False: 0]
  ------------------
 1848|      0|                    MP_WARN(demux, "Linearizing discontinuity: %f -> %f\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1849|      0|                            pts, info->highest_pts);
 1850|       |                    // Note: introduces a small discontinuity by a frame size.
 1851|      0|                    double diff = info->highest_pts - pts;
 1852|      0|                    dp->pts = MP_ADD_PTS(dp->pts, diff);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1853|      0|                    dp->dts = MP_ADD_PTS(dp->dts, diff);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1854|      0|                    pts += diff;
 1855|      0|                    info->ts_offset += diff;
 1856|      0|                    priv->any_ts_fixed = true;
 1857|      0|                }
 1858|      0|                info->last_key_pts = pts;
 1859|      0|            }
 1860|      0|            info->highest_pts = MP_PTS_MAX(info->highest_pts, pts);
  ------------------
  |  |   65|      0|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1861|      0|        }
 1862|      0|    }
 1863|       |
 1864|       |    // Dispatch the EL view of this packet via the splitter.
 1865|  1.47M|    if (info->dovi_split) {
  ------------------
  |  Branch (1865:9): [True: 0, False: 1.47M]
  ------------------
 1866|      0|        struct sh_stream *el = mp_dovi_split_el_stream(info->dovi_split);
 1867|      0|        if (el && demux_stream_is_selected(el))
  ------------------
  |  Branch (1867:13): [True: 0, False: 0]
  |  Branch (1867:19): [True: 0, False: 0]
  ------------------
 1868|      0|            priv->pending_pkt = mp_dovi_split_dispatch(info->dovi_split, dp);
 1869|      0|    }
 1870|       |
 1871|  1.47M|    if (st->event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
  ------------------
  |  Branch (1871:9): [True: 0, False: 1.47M]
  ------------------
 1872|      0|        st->event_flags = 0;
 1873|      0|        struct mp_tags *tags = talloc_zero(NULL, struct mp_tags);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1874|      0|        mp_tags_move_from_av_dictionary(tags, &st->metadata);
 1875|      0|        double pts = MP_PTS_OR_DEF(dp->pts, dp->dts);
  ------------------
  |  |   62|      0|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1876|      0|        demux_stream_tags_changed(demux, stream, tags, pts);
 1877|      0|    }
 1878|       |
 1879|  1.47M|    *mp_pkt = dp;
 1880|       |    return true;
 1881|  1.47M|}
demux_lavf.c:update_read_stats:
  287|  1.54M|{
  288|  1.54M|    lavf_priv_t *priv = demuxer->priv;
  289|       |
  290|  1.54M|    for (int n = 0; n < priv->num_nested; n++) {
  ------------------
  |  Branch (290:21): [True: 0, False: 1.54M]
  ------------------
  291|      0|        struct nested_stream *nest = &priv->nested[n];
  292|       |
  293|      0|        int64_t cur = nest->id->bytes_read;
  294|      0|        int64_t new = cur - nest->last_bytes;
  295|      0|        nest->last_bytes = cur;
  296|      0|        demux_report_unbuffered_read_bytes(demuxer, new);
  297|      0|    }
  298|  1.54M|}
demux_lavf.c:update_metadata:
  969|  1.47M|{
  970|  1.47M|    lavf_priv_t *priv = demuxer->priv;
  971|  1.47M|    if (priv->avfc->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
  ------------------
  |  Branch (971:9): [True: 0, False: 1.47M]
  ------------------
  972|      0|        mp_tags_move_from_av_dictionary(demuxer->metadata, &priv->avfc->metadata);
  973|      0|        priv->avfc->event_flags = 0;
  974|      0|        demux_metadata_changed(demuxer);
  975|      0|    }
  976|  1.47M|}
demux_lavf.c:reset_dovi_split_state:
 1884|  9.33k|{
 1885|  9.33k|    lavf_priv_t *priv = demuxer->priv;
 1886|  9.33k|    TA_FREEP(&priv->pending_pkt);
  ------------------
  |  |   81|  9.33k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.33k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.33k]
  |  |  ------------------
  ------------------
 1887|  18.8k|    for (int n = 0; n < priv->num_streams; n++) {
  ------------------
  |  Branch (1887:21): [True: 9.48k, False: 9.33k]
  ------------------
 1888|  9.48k|        if (priv->streams[n] && priv->streams[n]->dovi_split)
  ------------------
  |  Branch (1888:13): [True: 9.48k, False: 0]
  |  Branch (1888:33): [True: 0, False: 9.48k]
  ------------------
 1889|      0|            mp_dovi_split_reset(priv->streams[n]->dovi_split);
 1890|  9.48k|    }
 1891|  9.33k|}
demux_lavf.c:demux_close_lavf:
 2008|  40.1k|{
 2009|  40.1k|    lavf_priv_t *priv = demuxer->priv;
 2010|  40.1k|    if (priv) {
  ------------------
  |  Branch (2010:9): [True: 40.1k, False: 0]
  ------------------
 2011|       |        // This will be a dangling pointer; but see below.
 2012|  40.1k|        AVIOContext *leaking = priv->avfc ? priv->avfc->pb : NULL;
  ------------------
  |  Branch (2012:32): [True: 21.2k, False: 18.9k]
  ------------------
 2013|  40.1k|        avformat_close_input(&priv->avfc);
 2014|       |        // The ffmpeg garbage breaks its own API yet again: hls.c will call
 2015|       |        // io_open on the main playlist, but never calls io_close. This happens
 2016|       |        // to work out for us (since we don't really use custom I/O), but it's
 2017|       |        // still weird. Compensate.
 2018|  40.1k|        if (priv->num_nested == 1 && priv->nested[0].id == leaking)
  ------------------
  |  Branch (2018:13): [True: 0, False: 40.1k]
  |  Branch (2018:38): [True: 0, False: 0]
  ------------------
 2019|      0|            priv->num_nested = 0;
 2020|  40.1k|        if (priv->num_nested) {
  ------------------
  |  Branch (2020:13): [True: 0, False: 40.1k]
  ------------------
 2021|      0|            MP_WARN(demuxer, "Leaking %d nested connections (FFmpeg bug).\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2022|      0|                    priv->num_nested);
 2023|      0|        }
 2024|  40.1k|        if (priv->pb)
  ------------------
  |  Branch (2024:13): [True: 25.2k, False: 14.8k]
  ------------------
 2025|  25.2k|            av_freep(&priv->pb->buffer);
 2026|  40.1k|        av_freep(&priv->pb);
 2027|  69.8k|        for (int n = 0; n < priv->num_streams; n++) {
  ------------------
  |  Branch (2027:25): [True: 29.7k, False: 40.1k]
  ------------------
 2028|  29.7k|            struct stream_info *info = priv->streams[n];
 2029|  29.7k|            TA_FREEP(&info->dovi_split);
  ------------------
  |  |   81|  29.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  29.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 29.7k]
  |  |  ------------------
  ------------------
 2030|  29.7k|        }
 2031|  40.1k|        TA_FREEP(&priv->pending_pkt);
  ------------------
  |  |   81|  40.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  40.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 40.1k]
  |  |  ------------------
  ------------------
 2032|  40.1k|        if (priv->own_stream)
  ------------------
  |  Branch (2032:13): [True: 339, False: 39.8k]
  ------------------
 2033|    339|            free_stream(priv->stream);
 2034|  40.1k|        if (priv->av_opts)
  ------------------
  |  Branch (2034:13): [True: 92, False: 40.0k]
  ------------------
 2035|     92|            av_dict_free(&priv->av_opts);
 2036|  40.1k|        talloc_free(priv);
  ------------------
  |  |   47|  40.1k|#define talloc_free                     ta_free
  ------------------
 2037|       |        demuxer->priv = NULL;
 2038|  40.1k|    }
 2039|  40.1k|}
demux_lavf.c:demux_seek_lavf:
 1916|  9.33k|{
 1917|  9.33k|    lavf_priv_t *priv = demuxer->priv;
 1918|  9.33k|    int avsflags = 0;
 1919|  9.33k|    int64_t seek_pts_av = 0;
 1920|  9.33k|    int seek_stream = -1;
 1921|       |
 1922|  9.33k|    if (priv->any_ts_fixed)  {
  ------------------
  |  Branch (1922:9): [True: 0, False: 9.33k]
  ------------------
 1923|       |        // helpful message to piss of users
 1924|      0|        MP_WARN(demuxer, "Some timestamps returned by the demuxer were linearized. "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1925|      0|                         "A low level seek was requested; this won't work due to "
 1926|      0|                         "restrictions in libavformat's API. You may have more "
 1927|      0|                         "luck by enabling or enlarging the mpv cache.\n");
 1928|      0|    }
 1929|       |
 1930|  9.33k|    if (priv->linearize_ts < 0)
  ------------------
  |  Branch (1930:9): [True: 0, False: 9.33k]
  ------------------
 1931|      0|        priv->linearize_ts = 0;
 1932|       |
 1933|  9.33k|    if (!(flags & SEEK_FORWARD))
  ------------------
  |  |   95|  9.33k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (1933:9): [True: 9.33k, False: 0]
  ------------------
 1934|  9.33k|        avsflags = AVSEEK_FLAG_BACKWARD;
 1935|       |
 1936|  9.33k|    if (flags & SEEK_FACTOR) {
  ------------------
  |  |   94|  9.33k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (1936:9): [True: 0, False: 9.33k]
  ------------------
 1937|      0|        struct stream *s = priv->stream;
 1938|      0|        int64_t end = s ? stream_get_size(s) : -1;
  ------------------
  |  Branch (1938:23): [True: 0, False: 0]
  ------------------
 1939|      0|        if (end > 0 && demuxer->ts_resets_possible &&
  ------------------
  |  Branch (1939:13): [True: 0, False: 0]
  |  Branch (1939:24): [True: 0, False: 0]
  ------------------
 1940|      0|            !(priv->avif_flags & AVFMT_NO_BYTE_SEEK))
  ------------------
  |  Branch (1940:13): [True: 0, False: 0]
  ------------------
 1941|      0|        {
 1942|      0|            avsflags |= AVSEEK_FLAG_BYTE;
 1943|      0|            seek_pts_av = end * seek_pts;
 1944|      0|        } else if (priv->avfc->duration != 0 &&
  ------------------
  |  Branch (1944:20): [True: 0, False: 0]
  ------------------
 1945|      0|                   priv->avfc->duration != AV_NOPTS_VALUE)
  ------------------
  |  Branch (1945:20): [True: 0, False: 0]
  ------------------
 1946|      0|        {
 1947|      0|            seek_pts_av = seek_pts * priv->avfc->duration;
 1948|      0|        }
 1949|  9.33k|    } else {
 1950|  9.33k|        if (!(flags & SEEK_FORWARD))
  ------------------
  |  |   95|  9.33k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (1950:13): [True: 9.33k, False: 0]
  ------------------
 1951|  9.33k|            seek_pts -= priv->seek_delay;
 1952|  9.33k|        seek_pts_av = MPCLAMP(seek_pts, INT64_MIN / AV_TIME_BASE,
  ------------------
  |  |   46|  9.33k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 9.33k]
  |  |  |  Branch (46:56): [True: 0, False: 9.33k]
  |  |  ------------------
  ------------------
 1953|  9.33k|                              INT64_MAX / AV_TIME_BASE) * AV_TIME_BASE;
 1954|  9.33k|    }
 1955|       |
 1956|       |    // Hack to make wav seeking "deterministic". Without this, features like
 1957|       |    // backward playback won't work.
 1958|  9.33k|    if (priv->pcm_seek_hack && !priv->pcm_seek_hack_packet_size) {
  ------------------
  |  Branch (1958:9): [True: 200, False: 9.13k]
  |  Branch (1958:32): [True: 200, False: 0]
  ------------------
 1959|       |        // This might for example be the initial seek. Fuck it up like the
 1960|       |        // bullshit it is.
 1961|    200|        AVPacket *pkt = av_packet_alloc();
 1962|    200|        MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|    200|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    200|        void *oom_p_ = (x);     \
  |  |  208|    200|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 200]
  |  |  ------------------
  |  |  209|    200|            abort();            \
  |  |  210|    200|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 200]
  |  |  ------------------
  ------------------
 1963|    200|        if (av_read_frame(priv->avfc, pkt) >= 0)
  ------------------
  |  Branch (1963:13): [True: 200, False: 0]
  ------------------
 1964|    200|            priv->pcm_seek_hack_packet_size = pkt->size;
 1965|    200|        av_packet_free(&pkt);
 1966|    200|        add_new_streams(demuxer);
 1967|    200|    }
 1968|  9.33k|    if (priv->pcm_seek_hack && priv->pcm_seek_hack_packet_size &&
  ------------------
  |  Branch (1968:9): [True: 200, False: 9.13k]
  |  Branch (1968:32): [True: 200, False: 0]
  ------------------
 1969|    200|        !(avsflags & AVSEEK_FLAG_BYTE))
  ------------------
  |  Branch (1969:9): [True: 200, False: 0]
  ------------------
 1970|    200|    {
 1971|    200|        int samples = priv->pcm_seek_hack_packet_size /
 1972|    200|                      priv->pcm_seek_hack->codecpar->block_align;
 1973|    200|        if (samples > 0) {
  ------------------
  |  Branch (1973:13): [True: 200, False: 0]
  ------------------
 1974|    200|            MP_VERBOSE(demuxer, "using bullshit libavformat PCM seek hack\n");
  ------------------
  |  |   92|    200|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    200|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1975|    200|            seek_pts_av = av_rescale_q(seek_pts_av, AV_TIME_BASE_Q,
 1976|    200|                                       priv->pcm_seek_hack->time_base);
 1977|    200|            int64_t align = seek_pts_av % samples;
 1978|    200|            seek_pts_av -= align;
 1979|    200|            seek_stream = priv->pcm_seek_hack->index;
 1980|    200|        }
 1981|    200|    }
 1982|       |
 1983|  9.33k|    int r = av_seek_frame(priv->avfc, seek_stream, seek_pts_av, avsflags);
 1984|  9.33k|    if (r < 0 && (avsflags & AVSEEK_FLAG_BACKWARD)) {
  ------------------
  |  Branch (1984:9): [True: 3.46k, False: 5.87k]
  |  Branch (1984:18): [True: 3.46k, False: 0]
  ------------------
 1985|       |        // When seeking before the beginning of the file, and seeking fails,
 1986|       |        // try again without the backwards flag to make it seek to the
 1987|       |        // beginning.
 1988|  3.46k|        avsflags &= ~AVSEEK_FLAG_BACKWARD;
 1989|  3.46k|        r = av_seek_frame(priv->avfc, seek_stream, seek_pts_av, avsflags);
 1990|  3.46k|    }
 1991|       |
 1992|  9.33k|    if (r < 0) {
  ------------------
  |  Branch (1992:9): [True: 3.46k, False: 5.87k]
  ------------------
 1993|  3.46k|        char buf[180];
 1994|  3.46k|        av_strerror(r, buf, sizeof(buf));
 1995|  3.46k|        MP_VERBOSE(demuxer, "Seek failed (%s)\n", buf);
  ------------------
  |  |   92|  3.46k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.46k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1996|  3.46k|    }
 1997|  9.33k|    reset_dovi_split_state(demuxer);
 1998|       |
 1999|  9.33k|    update_read_stats(demuxer);
 2000|  9.33k|}
demux_lavf.c:demux_lavf_switched_tracks:
 2003|  18.6k|{
 2004|  18.6k|    select_tracks(demuxer, 0);
 2005|  18.6k|}

demux_mf.c:demux_open_mf:
  372|  19.6k|{
  373|  19.6k|    mf_t *mf;
  374|       |
  375|  19.6k|    if (strncmp(demuxer->stream->url, "mf://", 5) == 0 &&
  ------------------
  |  Branch (375:9): [True: 96, False: 19.5k]
  ------------------
  376|     96|        demuxer->stream->info && strcmp(demuxer->stream->info->name, "mf") == 0)
  ------------------
  |  Branch (376:9): [True: 96, False: 0]
  |  Branch (376:34): [True: 96, False: 0]
  ------------------
  377|     96|    {
  378|     96|        mf = open_mf_pattern(demuxer, demuxer, demuxer->stream->url + 5);
  379|  19.5k|    } else {
  380|  19.5k|        mf = open_mf_single(demuxer, demuxer->log, demuxer->stream->url);
  381|  19.5k|        int bog = 0;
  382|  19.5k|        MP_TARRAY_APPEND(mf, mf->streams, bog, demuxer->stream);
  ------------------
  |  |  105|  19.5k|    do {                                            \
  |  |  106|  19.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.5k|    do {                                            \
  |  |  |  |   97|  19.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  19.5k|    do {                                                        \
  |  |  |  |  |  |   89|  19.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  19.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  19.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  19.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  19.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  19.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  19.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 19.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  19.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.5k|        (idxvar)++;                                 \
  |  |  109|  19.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.5k]
  |  |  ------------------
  ------------------
  383|  19.5k|    }
  384|       |
  385|  19.6k|    if (!mf || mf->nr_of_files < 1)
  ------------------
  |  Branch (385:9): [True: 0, False: 19.6k]
  |  Branch (385:16): [True: 65, False: 19.6k]
  ------------------
  386|     65|        goto error;
  387|       |
  388|  19.6k|    const char *codec = mp_map_mimetype_to_video_codec(demuxer->stream->mime_type);
  389|  19.6k|    if (!codec || (demuxer->opts->mf_type && demuxer->opts->mf_type[0]))
  ------------------
  |  Branch (389:9): [True: 19.6k, False: 0]
  |  Branch (389:20): [True: 0, False: 0]
  |  Branch (389:46): [True: 0, False: 0]
  ------------------
  390|  19.6k|        codec = probe_format(mf, demuxer->opts->mf_type, check);
  391|  19.6k|    if (!codec)
  ------------------
  |  Branch (391:9): [True: 18.5k, False: 1.05k]
  ------------------
  392|  18.5k|        goto error;
  393|       |
  394|  1.05k|    mf->curr_frame = 0;
  395|       |
  396|       |    // create a new video stream header
  397|  1.05k|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
  398|  1.05k|    if (mf->nr_of_files == 1) {
  ------------------
  |  Branch (398:9): [True: 1.05k, False: 0]
  ------------------
  399|  1.05k|        MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
  ------------------
  |  |   92|  1.05k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.05k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  400|  1.05k|        sh->image = true;
  401|  1.05k|    }
  402|       |
  403|  1.05k|    struct mp_codec_params *c = sh->codec;
  404|  1.05k|    c->codec = codec;
  405|  1.05k|    c->disp_w = 0;
  406|  1.05k|    c->disp_h = 0;
  407|  1.05k|    c->fps = demuxer->opts->mf_fps;
  408|  1.05k|    c->reliable_fps = true;
  409|       |
  410|  1.05k|    demux_add_sh_stream(demuxer, sh);
  411|       |
  412|  1.05k|    mf->sh = sh;
  413|  1.05k|    demuxer->priv = (void *)mf;
  414|  1.05k|    demuxer->seekable = true;
  415|  1.05k|    demuxer->duration = mf->nr_of_files / mf->sh->codec->fps;
  416|       |
  417|  1.05k|    return 0;
  418|       |
  419|  18.6k|error:
  420|  18.6k|    return -1;
  421|  19.6k|}
demux_mf.c:open_mf_pattern:
   59|     96|{
   60|     96|    struct mp_log *log = d->log;
   61|     96|    int error_count = 0;
   62|     96|    int count = 0;
   63|       |
   64|     96|    mf_t *mf = talloc_zero(talloc_ctx, mf_t);
  ------------------
  |  |   27|     96|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     96|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     96|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   65|     96|    mf->log = log;
   66|       |
   67|     96|    if (filename[0] == '@') {
  ------------------
  |  Branch (67:9): [True: 30, False: 66]
  ------------------
   68|     30|        struct stream *s = stream_create(filename + 1,
   69|     30|                            d->stream_origin | STREAM_READ, d->cancel, d->global);
  ------------------
  |  |   41|     30|#define STREAM_READ               0
  ------------------
   70|     30|        if (s && !s->is_directory) {
  ------------------
  |  Branch (70:13): [True: 10, False: 20]
  |  Branch (70:18): [True: 10, False: 0]
  ------------------
   71|     84|            while (1) {
  ------------------
  |  Branch (71:20): [True: 84, Folded]
  ------------------
   72|     84|                char buf[512];
   73|     84|                int len = stream_read_peek(s, buf, sizeof(buf));
   74|     84|                if (!len)
  ------------------
  |  Branch (74:21): [True: 10, False: 74]
  ------------------
   75|     10|                    break;
   76|     74|                bstr data = (bstr){buf, len};
   77|     74|                int pos = bstrchr(data, '\n');
   78|     74|                data = bstr_splice(data, 0, pos < 0 ? data.len : pos + 1);
  ------------------
  |  Branch (78:45): [True: 74, False: 0]
  ------------------
   79|     74|                bstr fname = bstr_strip(data);
   80|     74|                if (fname.len) {
  ------------------
  |  Branch (80:21): [True: 74, False: 0]
  ------------------
   81|     74|                    if (bstrchr(fname, '\0') >= 0) {
  ------------------
  |  Branch (81:25): [True: 0, False: 74]
  ------------------
   82|      0|                        mp_err(log, "invalid filename\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
   83|      0|                        break;
   84|      0|                    }
   85|     74|                    char *entry = bstrto0(mf, fname);
   86|     74|                    if (!mp_path_exists(entry) && !mp_is_url(fname)) {
  ------------------
  |  Branch (86:25): [True: 74, False: 0]
  |  Branch (86:51): [True: 71, False: 3]
  ------------------
   87|     71|                        mp_verbose(log, "file not found: '%s'\n", entry);
  ------------------
  |  |   79|     71|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   88|     71|                    } else {
   89|      3|                        MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry);
  ------------------
  |  |  105|      3|    do {                                            \
  |  |  106|      3|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      3|    do {                                            \
  |  |  |  |   97|      3|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      3|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      3|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      3|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      3|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      3|    do {                                                        \
  |  |  |  |  |  |   89|      3|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      3|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      3|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      3|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      3|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      3|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      3|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      3|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      3|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      3|        (idxvar)++;                                 \
  |  |  109|      3|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3]
  |  |  ------------------
  ------------------
   90|      3|                    }
   91|     74|                }
   92|     74|                stream_seek_skip(s, stream_tell(s) + data.len);
   93|     74|            }
   94|     10|            free_stream(s);
   95|       |
   96|     10|            goto exit_mf;
   97|     10|        }
   98|     20|        free_stream(s);
   99|     20|        mp_info(log, "%s is not indirect filelist\n", filename + 1);
  ------------------
  |  |   78|     20|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  100|     20|    }
  101|       |
  102|     86|    if (strchr(filename, ',')) {
  ------------------
  |  Branch (102:9): [True: 41, False: 45]
  ------------------
  103|     41|        bstr bfilename = bstr0(filename);
  104|     41|        mp_info(log, "filelist: %.*s\n", BSTR_P(bfilename));
  ------------------
  |  |   78|     82|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 41, False: 0]
  |  |  ------------------
  ------------------
  105|       |
  106|  3.19k|        while (bfilename.len) {
  ------------------
  |  Branch (106:16): [True: 3.15k, False: 41]
  ------------------
  107|  3.15k|            bstr bfname;
  108|  3.15k|            bstr_split_tok(bfilename, ",", &bfname, &bfilename);
  109|  3.15k|            char *fname2 = bstrdup0(mf, bfname);
  110|       |
  111|  3.15k|            if (!mp_path_exists(fname2) && !mp_is_url(bfname))
  ------------------
  |  Branch (111:17): [True: 3.10k, False: 51]
  |  Branch (111:44): [True: 2.96k, False: 133]
  ------------------
  112|  2.96k|                mp_verbose(log, "file not found: '%s'\n", fname2);
  ------------------
  |  |   79|  2.96k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  113|    184|            else {
  114|    184|                mf_add(mf, fname2);
  115|    184|            }
  116|  3.15k|            talloc_free(fname2);
  ------------------
  |  |   47|  3.15k|#define talloc_free                     ta_free
  ------------------
  117|  3.15k|        }
  118|       |
  119|     41|        goto exit_mf;
  120|     41|    }
  121|       |
  122|     45|    bstr bfilename = bstr0(filename);
  123|     45|    if (mp_is_url(bfilename))
  ------------------
  |  Branch (123:9): [True: 3, False: 42]
  ------------------
  124|      3|        goto exit_mf;
  125|       |
  126|     42|    size_t fname_avail = bfilename.len + 32;
  127|     42|    char *fname = talloc_size(mf, fname_avail);
  ------------------
  |  |   43|     42|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|     42|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|     42|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     42|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     42|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     42|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|       |#if HAVE_GLOB && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
  130|       |    if (!strchr(filename, '%')) {
  131|       |        // append * if none present
  132|       |        snprintf(fname, fname_avail, "%s%c", filename,
  133|       |            strchr(filename, '*') ? 0 : '*');
  134|       |        mp_info(log, "search expr: %s\n", fname);
  135|       |
  136|       |        glob_t gg;
  137|       |        if (glob(fname, 0, NULL, &gg)) {
  138|       |            talloc_free(mf);
  139|       |            return NULL;
  140|       |        }
  141|       |
  142|       |        for (int i = 0; i < gg.gl_pathc; i++) {
  143|       |            if (mp_path_isdir(gg.gl_pathv[i]))
  144|       |                continue;
  145|       |            mf_add(mf, gg.gl_pathv[i]);
  146|       |        }
  147|       |        globfree(&gg);
  148|       |        goto exit_mf;
  149|       |    }
  150|       |#endif
  151|       |
  152|       |    // We're using arbitrary user input as printf format with 1 int argument.
  153|       |    // Any format which uses exactly 1 int argument would be valid, but for
  154|       |    // simplicity we reject all conversion specifiers except %% and simple
  155|       |    // integer specifier: %[.][NUM]d where NUM is 1-3 digits (%.d is valid)
  156|     42|    const char *f = filename;
  157|     42|    int MAXDIGS = 3, nspec = 0, c;
  158|     42|    bool bad_spec = false;
  159|       |
  160|  1.58k|    while (nspec < 2 && (c = *f++)) {
  ------------------
  |  Branch (160:12): [True: 1.58k, False: 2]
  |  Branch (160:25): [True: 1.56k, False: 25]
  ------------------
  161|  1.56k|        if (c != '%')
  ------------------
  |  Branch (161:13): [True: 1.30k, False: 254]
  ------------------
  162|  1.30k|            continue;
  163|       |
  164|    254|        if (*f == '%') {
  ------------------
  |  Branch (164:13): [True: 223, False: 31]
  ------------------
  165|       |            // '%%', which ends up as an explicit % in the output.
  166|       |            // Skipping forwards as it doesn't require further attention.
  167|    223|            f++;
  168|    223|            continue;
  169|    223|        }
  170|       |
  171|       |        // Now c == '%' and *f != '%', thus we have entered territory of format
  172|       |        // specifiers which we are interested in.
  173|     31|        nspec++;
  174|       |
  175|     31|        if (*f == '.')
  ------------------
  |  Branch (175:13): [True: 1, False: 30]
  ------------------
  176|      1|            f++;
  177|       |
  178|     59|        for (int ndig = 0; mp_isdigit(*f) && ndig < MAXDIGS; ndig++, f++)
  ------------------
  |  Branch (178:28): [True: 28, False: 31]
  |  Branch (178:46): [True: 28, False: 0]
  ------------------
  179|     28|            /* no-op */;
  180|       |
  181|     31|        if (*f != 'd') {
  ------------------
  |  Branch (181:13): [True: 15, False: 16]
  ------------------
  182|     15|            bad_spec = true; // not int, or beyond our validation capacity
  183|     15|            break;
  184|     15|        }
  185|       |
  186|       |        // *f is 'd'
  187|     16|        f++;
  188|     16|    }
  189|       |
  190|       |    // nspec==0 (zero specifiers) is rejected because fname wouldn't advance.
  191|     42|    if (bad_spec || nspec != 1) {
  ------------------
  |  Branch (191:9): [True: 15, False: 27]
  |  Branch (191:21): [True: 20, False: 7]
  ------------------
  192|     35|        mp_err(log,
  ------------------
  |  |   76|     35|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  193|     35|               "unsupported expr format: '%s' - exactly one format specifier of the form %%[.][NUM]d is expected\n",
  194|     35|               filename);
  195|     35|        goto exit_mf;
  196|     35|    }
  197|       |
  198|      7|    mp_info(log, "search expr: %s\n", filename);
  ------------------
  |  |   78|      7|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  199|       |
  200|     27|    while (error_count < 5) {
  ------------------
  |  Branch (200:12): [True: 23, False: 4]
  ------------------
  201|     23|        if (snprintf(fname, fname_avail, filename, count++) >= fname_avail) {
  ------------------
  |  Branch (201:13): [True: 3, False: 20]
  ------------------
  202|      3|            mp_err(log, "format result too long: '%s'\n", filename);
  ------------------
  |  |   76|      3|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  203|      3|            goto exit_mf;
  204|      3|        }
  205|     20|        if (!mp_path_exists(fname)) {
  ------------------
  |  Branch (205:13): [True: 20, False: 0]
  ------------------
  206|     20|            error_count++;
  207|     20|            mp_verbose(log, "file not found: '%s'\n", fname);
  ------------------
  |  |   79|     20|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  208|     20|        } else {
  209|      0|            mf_add(mf, fname);
  210|      0|        }
  211|     20|    }
  212|       |
  213|     96|exit_mf:
  214|     96|    mp_info(log, "number of files: %d\n", mf->nr_of_files);
  ------------------
  |  |   78|     96|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  215|     96|    return mf;
  216|      7|}
demux_mf.c:mf_add:
   53|  19.7k|{
   54|  19.7k|    char *entry = talloc_strdup(mf, fname);
  ------------------
  |  |   50|  19.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
   55|  19.7k|    MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry);
  ------------------
  |  |  105|  19.7k|    do {                                            \
  |  |  106|  19.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.7k|    do {                                            \
  |  |  |  |   97|  19.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.6k, False: 129]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  19.6k|    do {                                                        \
  |  |  |  |  |  |   89|  19.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  19.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  19.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  19.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  19.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  19.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  19.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 19.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  19.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.7k|        (idxvar)++;                                 \
  |  |  109|  19.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.7k]
  |  |  ------------------
  ------------------
   56|  19.7k|}
demux_mf.c:open_mf_single:
  219|  19.5k|{
  220|  19.5k|    mf_t *mf = talloc_zero(talloc_ctx, mf_t);
  ------------------
  |  |   27|  19.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  19.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|  19.5k|    mf->log = log;
  222|  19.5k|    mf_add(mf, filename);
  223|  19.5k|    return mf;
  224|  19.5k|}
demux_mf.c:probe_format:
  348|  19.6k|{
  349|  19.6k|    if (check > DEMUX_CHECK_REQUEST)
  ------------------
  |  Branch (349:9): [True: 11.0k, False: 8.55k]
  ------------------
  350|  11.0k|        return NULL;
  351|  8.55k|    char *org_type = type;
  352|  8.55k|    if (!type || !type[0]) {
  ------------------
  |  Branch (352:9): [True: 8.55k, False: 0]
  |  Branch (352:18): [True: 0, False: 0]
  ------------------
  353|  8.55k|        char *p = strrchr(mf->names[0], '.');
  354|  8.55k|        if (p)
  ------------------
  |  Branch (354:13): [True: 4.69k, False: 3.86k]
  ------------------
  355|  4.69k|            type = p + 1;
  356|  8.55k|    }
  357|   411k|    for (int i = 0; type2format[i].type; i++) {
  ------------------
  |  Branch (357:21): [True: 403k, False: 7.50k]
  ------------------
  358|   403k|        if (type && strcasecmp(type, type2format[i].type) == 0)
  ------------------
  |  Branch (358:13): [True: 210k, False: 193k]
  |  Branch (358:21): [True: 1.05k, False: 209k]
  ------------------
  359|  1.05k|            return type2format[i].codec;
  360|   403k|    }
  361|  7.50k|    if (check == DEMUX_CHECK_REQUEST) {
  ------------------
  |  Branch (361:9): [True: 31, False: 7.47k]
  ------------------
  362|     31|        if (!org_type) {
  ------------------
  |  Branch (362:13): [True: 31, False: 0]
  ------------------
  363|     31|            MP_ERR(mf, "file type was not set! (try --mf-type=ext)\n");
  ------------------
  |  |   89|     31|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     31|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  364|     31|        } else {
  365|      0|            MP_ERR(mf, "--mf-type set to an unknown codec!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  366|      0|        }
  367|     31|    }
  368|       |    return NULL;
  369|  8.55k|}
demux_mf.c:demux_mf_read_packet:
  242|  2.09k|{
  243|  2.09k|    mf_t *mf = demuxer->priv;
  244|  2.09k|    if (mf->curr_frame >= mf->nr_of_files)
  ------------------
  |  Branch (244:9): [True: 1.04k, False: 1.04k]
  ------------------
  245|  1.04k|        return false;
  246|  2.09k|    bool ok = false;
  247|       |
  248|  1.04k|    struct stream *entry_stream = NULL;
  249|  1.04k|    if (mf->streams)
  ------------------
  |  Branch (249:9): [True: 1.04k, False: 0]
  ------------------
  250|  1.04k|        entry_stream = mf->streams[mf->curr_frame];
  251|  1.04k|    struct stream *stream = entry_stream;
  252|  1.04k|    if (!stream) {
  ------------------
  |  Branch (252:9): [True: 0, False: 1.04k]
  ------------------
  253|      0|        char *filename = mf->names[mf->curr_frame];
  254|      0|        if (filename) {
  ------------------
  |  Branch (254:13): [True: 0, False: 0]
  ------------------
  255|      0|            stream = stream_create(filename, demuxer->stream_origin | STREAM_READ,
  ------------------
  |  |   41|      0|#define STREAM_READ               0
  ------------------
  256|      0|                                   demuxer->cancel, demuxer->global);
  257|      0|        }
  258|      0|    }
  259|       |
  260|  1.04k|    if (stream) {
  ------------------
  |  Branch (260:9): [True: 1.04k, False: 0]
  ------------------
  261|  1.04k|        stream_seek(stream, 0);
  262|  1.04k|        bstr data = stream_read_complete(stream, NULL, MF_MAX_FILE_SIZE);
  ------------------
  |  |   39|  1.04k|#define MF_MAX_FILE_SIZE (1024 * 1024 * 256)
  ------------------
  263|  1.04k|        if (data.len) {
  ------------------
  |  Branch (263:13): [True: 1.04k, False: 0]
  ------------------
  264|  1.04k|            demux_packet_t *dp = new_demux_packet(demuxer->packet_pool, data.len);
  265|  1.04k|            if (dp) {
  ------------------
  |  Branch (265:17): [True: 1.04k, False: 0]
  ------------------
  266|  1.04k|                memcpy(dp->buffer, data.start, data.len);
  267|  1.04k|                dp->pts = mf->curr_frame / mf->sh->codec->fps;
  268|  1.04k|                dp->keyframe = true;
  269|  1.04k|                dp->stream = mf->sh->index;
  270|  1.04k|                *pkt = dp;
  271|  1.04k|                ok = true;
  272|  1.04k|            }
  273|  1.04k|        }
  274|  1.04k|        talloc_free(data.start);
  ------------------
  |  |   47|  1.04k|#define talloc_free                     ta_free
  ------------------
  275|  1.04k|    }
  276|       |
  277|  1.04k|    if (stream && stream != entry_stream)
  ------------------
  |  Branch (277:9): [True: 1.04k, False: 0]
  |  Branch (277:19): [True: 0, False: 1.04k]
  ------------------
  278|      0|        free_stream(stream);
  279|       |
  280|  1.04k|    mf->curr_frame++;
  281|       |
  282|  1.04k|    if (!ok)
  ------------------
  |  Branch (282:9): [True: 0, False: 1.04k]
  ------------------
  283|  1.04k|        MP_ERR(demuxer, "error reading image file\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  284|       |
  285|       |    return true;
  286|  2.09k|}
demux_mf.c:demux_close_mf:
  424|  19.6k|{
  425|  19.6k|}

demux_mkv.c:demux_mkv_open:
 2510|  40.1k|{
 2511|  40.1k|    stream_t *s = demuxer->stream;
 2512|  40.1k|    mkv_demuxer_t *mkv_d;
 2513|  40.1k|    int64_t start_pos;
 2514|  40.1k|    int64_t end_pos;
 2515|       |
 2516|  40.1k|    mkv_d = talloc_zero(demuxer, struct mkv_demuxer);
  ------------------
  |  |   27|  40.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2517|  40.1k|    demuxer->priv = mkv_d;
 2518|  40.1k|    mkv_d->tc_scale = 1000000;
 2519|  40.1k|    mkv_d->a_skip_preroll = 1;
 2520|  40.1k|    mkv_d->skip_to_timecode = INT64_MIN;
 2521|       |
 2522|  40.1k|    if (demuxer->params)
  ------------------
  |  Branch (2522:9): [True: 40.1k, False: 0]
  ------------------
 2523|  40.1k|        mkv_d->probably_webm_dash_init = demuxer->params->init_fragment.len > 0;
 2524|       |
 2525|       |    // Make sure you can seek back after read_ebml_header() if no EBML ID.
 2526|  40.1k|    if (stream_read_peek(s, &(char[4]){0}, 4) != 4)
  ------------------
  |  Branch (2526:9): [True: 190, False: 39.9k]
  ------------------
 2527|    190|        return -1;
 2528|  39.9k|    if (!read_ebml_header(demuxer))
  ------------------
  |  Branch (2528:9): [True: 39.5k, False: 419]
  ------------------
 2529|  39.5k|        return -1;
 2530|    419|    MP_DBG(demuxer, "Found the head...\n");
  ------------------
  |  |   93|    419|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    419|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2531|       |
 2532|    419|    if (!read_mkv_segment_header(demuxer, &end_pos))
  ------------------
  |  Branch (2532:9): [True: 419, False: 0]
  ------------------
 2533|    419|        return -1;
 2534|       |
 2535|      0|    mkv_d->segment_start = stream_tell(s);
 2536|      0|    mkv_d->segment_end = end_pos;
 2537|       |
 2538|      0|    struct MPOpts *mp_opts = mp_get_config_group(mkv_d, demuxer->global, &mp_opt_root);
 2539|      0|    mkv_d->edition_id = mp_opts->edition_id;
 2540|      0|    talloc_free(mp_opts);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2541|       |
 2542|      0|    mkv_d->opts = mp_get_config_group(mkv_d, demuxer->global, &demux_mkv_conf);
 2543|       |
 2544|      0|    if (demuxer->params && demuxer->params->matroska_was_valid)
  ------------------
  |  Branch (2544:9): [True: 0, False: 0]
  |  Branch (2544:28): [True: 0, False: 0]
  ------------------
 2545|      0|        *demuxer->params->matroska_was_valid = true;
 2546|       |
 2547|      0|    while (1) {
  ------------------
  |  Branch (2547:12): [True: 0, Folded]
  ------------------
 2548|      0|        start_pos = stream_tell(s);
 2549|      0|        uint32_t id = ebml_read_id(s);
 2550|      0|        if (s->eof) {
  ------------------
  |  Branch (2550:13): [True: 0, False: 0]
  ------------------
 2551|      0|            if (!mkv_d->probably_webm_dash_init)
  ------------------
  |  Branch (2551:17): [True: 0, False: 0]
  ------------------
 2552|      0|                MP_WARN(demuxer, "Unexpected end of file (no clusters found)\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2553|      0|            break;
 2554|      0|        }
 2555|      0|        if (id == MATROSKA_ID_CLUSTER) {
  ------------------
  |  |   28|      0|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (2555:13): [True: 0, False: 0]
  ------------------
 2556|      0|            MP_DBG(demuxer, "|+ found cluster\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2557|      0|            mkv_d->first_cluster = start_pos;
 2558|      0|            mkv_d->cluster_start = start_pos;
 2559|      0|            break;
 2560|      0|        }
 2561|      0|        int res = read_header_element(demuxer, id, start_pos);
 2562|      0|        if (res < 0)
  ------------------
  |  Branch (2562:13): [True: 0, False: 0]
  ------------------
 2563|      0|            return -1;
 2564|      0|    }
 2565|       |
 2566|      0|    int64_t end = stream_get_size(s);
 2567|       |
 2568|       |    // Read headers that come after the first cluster (i.e. require seeking).
 2569|       |    // Note: reading might increase ->num_headers.
 2570|       |    //       Likewise, ->headers might be reallocated.
 2571|      0|    int only_cue = -1;
 2572|      0|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2572:21): [True: 0, False: 0]
  ------------------
 2573|      0|        struct header_elem *elem = &mkv_d->headers[n];
 2574|      0|        if (elem->parsed)
  ------------------
  |  Branch (2574:13): [True: 0, False: 0]
  ------------------
 2575|      0|            continue;
 2576|       |        // Warn against incomplete files and skip headers outside of range.
 2577|      0|        if (elem->pos >= end || !s->seekable) {
  ------------------
  |  Branch (2577:13): [True: 0, False: 0]
  |  Branch (2577:33): [True: 0, False: 0]
  ------------------
 2578|      0|            elem->parsed = true; // don't bother if file is incomplete
 2579|      0|            if (end < 0 || !s->seekable) {
  ------------------
  |  Branch (2579:17): [True: 0, False: 0]
  |  Branch (2579:28): [True: 0, False: 0]
  ------------------
 2580|      0|                MP_WARN(demuxer, "Stream is not seekable or unknown size, "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2581|      0|                        "not reading mkv metadata at end of file.\n");
 2582|      0|            } else if (!mkv_d->eof_warning &&
  ------------------
  |  Branch (2582:24): [True: 0, False: 0]
  ------------------
 2583|      0|                       !(mkv_d->probably_webm_dash_init &&  elem->pos == end))
  ------------------
  |  Branch (2583:26): [True: 0, False: 0]
  |  Branch (2583:61): [True: 0, False: 0]
  ------------------
 2584|      0|            {
 2585|      0|                MP_WARN(demuxer, "mkv metadata beyond end of file - incomplete "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2586|      0|                        "file?\n");
 2587|      0|                mkv_d->eof_warning = true;
 2588|      0|            }
 2589|      0|            continue;
 2590|      0|        }
 2591|      0|        only_cue = only_cue < 0 && elem->id == MATROSKA_ID_CUES;
  ------------------
  |  |  130|      0|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (2591:20): [True: 0, False: 0]
  |  Branch (2591:36): [True: 0, False: 0]
  ------------------
 2592|      0|    }
 2593|       |
 2594|       |    // If there's only 1 needed element, and it's the cues, defer reading.
 2595|      0|    if (only_cue == 1) {
  ------------------
  |  Branch (2595:9): [True: 0, False: 0]
  ------------------
 2596|       |        // Read cues when they are needed, to avoid seeking on opening.
 2597|      0|        MP_VERBOSE(demuxer, "Deferring reading cues.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2598|      0|    } else {
 2599|       |        // Read them by ascending position to reduce unneeded seeks.
 2600|       |        // O(n^2) because the number of elements is very low.
 2601|      0|        while (1) {
  ------------------
  |  Branch (2601:16): [True: 0, Folded]
  ------------------
 2602|      0|            struct header_elem *lowest = NULL;
 2603|      0|            for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2603:29): [True: 0, False: 0]
  ------------------
 2604|      0|                struct header_elem *elem = &mkv_d->headers[n];
 2605|      0|                if (elem->parsed)
  ------------------
  |  Branch (2605:21): [True: 0, False: 0]
  ------------------
 2606|      0|                    continue;
 2607|      0|                if (!lowest || elem->pos < lowest->pos)
  ------------------
  |  Branch (2607:21): [True: 0, False: 0]
  |  Branch (2607:32): [True: 0, False: 0]
  ------------------
 2608|      0|                    lowest = elem;
 2609|      0|            }
 2610|       |
 2611|      0|            if (!lowest)
  ------------------
  |  Branch (2611:17): [True: 0, False: 0]
  ------------------
 2612|      0|                break;
 2613|       |
 2614|      0|            if (read_deferred_element(demuxer, lowest) < 0)
  ------------------
  |  Branch (2614:17): [True: 0, False: 0]
  ------------------
 2615|      0|                return -1;
 2616|      0|        }
 2617|      0|    }
 2618|       |
 2619|      0|    if (!stream_seek(s, start_pos)) {
  ------------------
  |  Branch (2619:9): [True: 0, False: 0]
  ------------------
 2620|      0|        MP_ERR(demuxer, "Couldn't seek back after reading headers?\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2621|      0|        return -1;
 2622|      0|    }
 2623|       |
 2624|      0|    MP_VERBOSE(demuxer, "All headers are parsed!\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2625|       |
 2626|      0|    display_create_tracks(demuxer);
 2627|      0|    pair_dovi_tracks(demuxer);
 2628|      0|    add_coverart(demuxer);
 2629|      0|    process_tags(demuxer);
 2630|       |
 2631|      0|    probe_first_timestamp(demuxer);
 2632|      0|    if (mkv_d->opts->probe_duration)
  ------------------
  |  Branch (2632:9): [True: 0, False: 0]
  ------------------
 2633|      0|        probe_last_timestamp(demuxer, start_pos);
 2634|      0|    probe_x264_garbage(demuxer);
 2635|      0|    probe_if_image(demuxer);
 2636|       |
 2637|      0|    return 0;
 2638|      0|}
demux_mkv.c:read_ebml_header:
 2423|  39.9k|{
 2424|  39.9k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2425|  39.9k|    stream_t *s = demuxer->stream;
 2426|       |
 2427|  39.9k|    if (ebml_read_id(s) != EBML_ID_EBML)
  ------------------
  |  |    3|  39.9k|#define EBML_ID_EBML                             0x1a45dfa3
  ------------------
  |  Branch (2427:9): [True: 39.4k, False: 484]
  ------------------
 2428|  39.4k|        return 0;
 2429|    484|    struct ebml_ebml ebml_master = {0};
 2430|    484|    struct ebml_parse_ctx parse_ctx = { demuxer->log, .no_error_messages = true };
 2431|    484|    if (ebml_read_element(s, &parse_ctx, &ebml_master, &ebml_ebml_desc) < 0)
  ------------------
  |  Branch (2431:9): [True: 65, False: 419]
  ------------------
 2432|     65|        return 0;
 2433|    484|    bool is_matroska = false, is_webm = false;
 2434|    419|    if (!ebml_master.doc_type) {
  ------------------
  |  Branch (2434:9): [True: 419, False: 0]
  ------------------
 2435|    419|        MP_VERBOSE(demuxer, "File has EBML header but no doctype. "
  ------------------
  |  |   92|    419|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    419|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2436|    419|                   "Assuming \"matroska\".\n");
 2437|    419|        is_matroska = true;
 2438|    419|    } else if (strcmp(ebml_master.doc_type, "matroska") == 0) {
  ------------------
  |  Branch (2438:16): [True: 0, False: 0]
  ------------------
 2439|      0|        is_matroska = true;
 2440|      0|    } else if (strcmp(ebml_master.doc_type, "webm") == 0) {
  ------------------
  |  Branch (2440:16): [True: 0, False: 0]
  ------------------
 2441|      0|        is_webm = true;
 2442|      0|    }
 2443|    419|    if (!is_matroska && !is_webm) {
  ------------------
  |  Branch (2443:9): [True: 0, False: 419]
  |  Branch (2443:25): [True: 0, False: 0]
  ------------------
 2444|      0|        MP_TRACE(demuxer, "no head found\n");
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2445|      0|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2446|      0|        return 0;
 2447|      0|    }
 2448|    419|    mkv_d->probably_webm_dash_init &= is_webm;
 2449|    419|    if (ebml_master.doc_type_read_version > 2) {
  ------------------
  |  Branch (2449:9): [True: 0, False: 419]
  ------------------
 2450|      0|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2451|      0|                "but we don't support format version %"PRIu64"\n",
 2452|      0|                ebml_master.doc_type_read_version);
 2453|      0|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2454|      0|        return 0;
 2455|      0|    }
 2456|    419|    if ((ebml_master.n_ebml_read_version
  ------------------
  |  Branch (2456:10): [True: 0, False: 419]
  ------------------
 2457|      0|         && ebml_master.ebml_read_version != EBML_VERSION)
  ------------------
  |  |   31|      0|#define EBML_VERSION 1
  ------------------
  |  Branch (2457:13): [True: 0, False: 0]
  ------------------
 2458|    419|        || (ebml_master.n_ebml_max_size_length
  ------------------
  |  Branch (2458:13): [True: 0, False: 419]
  ------------------
 2459|      0|            && ebml_master.ebml_max_size_length > 8)
  ------------------
  |  Branch (2459:16): [True: 0, False: 0]
  ------------------
 2460|    419|        || (ebml_master.n_ebml_max_id_length
  ------------------
  |  Branch (2460:13): [True: 0, False: 419]
  ------------------
 2461|      0|            && ebml_master.ebml_max_id_length != 4))
  ------------------
  |  Branch (2461:16): [True: 0, False: 0]
  ------------------
 2462|      0|    {
 2463|      0|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2464|      0|                "but the header has bad parameters\n");
 2465|      0|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2466|      0|        return 0;
 2467|      0|    }
 2468|    419|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    419|#define talloc_free                     ta_free
  ------------------
 2469|       |
 2470|    419|    return 1;
 2471|    419|}
demux_mkv.c:read_mkv_segment_header:
 2474|    419|{
 2475|    419|    stream_t *s = demuxer->stream;
 2476|    419|    int num_skip = 0;
 2477|    419|    if (demuxer->params)
  ------------------
  |  Branch (2477:9): [True: 419, False: 0]
  ------------------
 2478|    419|        num_skip = demuxer->params->matroska_wanted_segment;
 2479|       |
 2480|    419|    while (stream_read_peek(s, &(char){0}, 1)) {
  ------------------
  |  Branch (2480:12): [True: 207, False: 212]
  ------------------
 2481|    207|        if (ebml_read_id(s) != MATROSKA_ID_SEGMENT) {
  ------------------
  |  |   13|    207|#define MATROSKA_ID_SEGMENT                      0x18538067
  ------------------
  |  Branch (2481:13): [True: 207, False: 0]
  ------------------
 2482|    207|            MP_VERBOSE(demuxer, "segment not found\n");
  ------------------
  |  |   92|    207|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    207|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2483|    207|            return 0;
 2484|    207|        }
 2485|      0|        MP_DBG(demuxer, "+ a segment...\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2486|      0|        uint64_t len = ebml_read_length(s);
 2487|      0|        *segment_end = (len == EBML_UINT_INVALID) ? 0 : stream_tell(s) + len;
  ------------------
  |  |   85|      0|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (2487:24): [True: 0, False: 0]
  ------------------
 2488|      0|        if (num_skip <= 0)
  ------------------
  |  Branch (2488:13): [True: 0, False: 0]
  ------------------
 2489|      0|            return 1;
 2490|      0|        num_skip--;
 2491|      0|        MP_DBG(demuxer, "  (skipping)\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2492|      0|        if (*segment_end <= 0)
  ------------------
  |  Branch (2492:13): [True: 0, False: 0]
  ------------------
 2493|      0|            break;
 2494|      0|        if (*segment_end >= stream_get_size(s))
  ------------------
  |  Branch (2494:13): [True: 0, False: 0]
  ------------------
 2495|      0|            return 0;
 2496|      0|        if (!stream_seek(s, *segment_end)) {
  ------------------
  |  Branch (2496:13): [True: 0, False: 0]
  ------------------
 2497|      0|            MP_WARN(demuxer, "Failed to seek in file\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2498|      0|            return 0;
 2499|      0|        }
 2500|       |        // Segments are like concatenated Matroska files
 2501|      0|        if (!read_ebml_header(demuxer))
  ------------------
  |  Branch (2501:13): [True: 0, False: 0]
  ------------------
 2502|      0|            return 0;
 2503|      0|    }
 2504|       |
 2505|    212|    MP_VERBOSE(demuxer, "End of file, no further segments.\n");
  ------------------
  |  |   92|    212|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    212|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2506|    212|    return 0;
 2507|    419|}
demux_mkv.c:mkv_seek_reset:
 2837|  40.1k|{
 2838|  40.1k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2839|       |
 2840|  40.1k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (2840:21): [True: 0, False: 40.1k]
  ------------------
 2841|      0|        mkv_track_t *track = mkv_d->tracks[i];
 2842|      0|        if (track->av_parser)
  ------------------
  |  Branch (2842:13): [True: 0, False: 0]
  ------------------
 2843|      0|            av_parser_close(track->av_parser);
 2844|      0|        track->av_parser = NULL;
 2845|      0|        avcodec_free_context(&track->av_parser_codec);
 2846|      0|        mp_dovi_split_reset(track->dovi_split);
 2847|      0|    }
 2848|       |
 2849|  40.1k|    for (int n = 0; n < mkv_d->num_blocks; n++)
  ------------------
  |  Branch (2849:21): [True: 0, False: 40.1k]
  ------------------
 2850|      0|        free_block(&mkv_d->blocks[n]);
 2851|  40.1k|    mkv_d->num_blocks = 0;
 2852|       |
 2853|  40.1k|    for (int n = 0; n < mkv_d->num_packets; n++)
  ------------------
  |  Branch (2853:21): [True: 0, False: 40.1k]
  ------------------
 2854|      0|        talloc_free(mkv_d->packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2855|  40.1k|    mkv_d->num_packets = 0;
 2856|       |
 2857|       |    mkv_d->skip_to_timecode = INT64_MIN;
 2858|  40.1k|}
demux_mkv.c:mkv_free:
 3790|  40.1k|{
 3791|  40.1k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3792|  40.1k|    if (!mkv_d)
  ------------------
  |  Branch (3792:9): [True: 0, False: 40.1k]
  ------------------
 3793|      0|        return;
 3794|  40.1k|    mkv_seek_reset(demuxer);
 3795|  40.1k|    for (int i = 0; i < mkv_d->num_tracks; i++)
  ------------------
  |  Branch (3795:21): [True: 0, False: 40.1k]
  ------------------
 3796|      0|        demux_mkv_free_trackentry(mkv_d->tracks[i]);
 3797|  40.1k|}

demux_mpv.c:open_mpv:
   24|  15.7k|{
   25|  15.7k|    if (check != DEMUX_CHECK_REQUEST)
  ------------------
  |  Branch (25:9): [True: 15.7k, False: 0]
  ------------------
   26|  15.7k|        return -1;
   27|       |
   28|      0|    struct stream *s = demuxer->stream;
   29|      0|    if (!s->info || strcmp(s->info->name, "mpv"))
  ------------------
  |  Branch (29:9): [True: 0, False: 0]
  |  Branch (29:21): [True: 0, False: 0]
  ------------------
   30|      0|        return -1;
   31|       |
   32|      0|    demuxer->playlist = talloc_zero(demuxer, struct playlist);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   33|      0|    mp_url_unescape_inplace(s->path);
   34|      0|    playlist_append_file(demuxer->playlist, s->path);
   35|      0|    playlist_set_stream_flags(demuxer->playlist, demuxer->stream_origin);
   36|      0|    demuxer->fully_read = true;
   37|      0|    demux_close_stream(demuxer);
   38|       |
   39|      0|    return 0;
   40|      0|}

demux_null.c:try_open_file:
   23|  15.7k|{
   24|  15.7k|    if (!bstr_startswith0(bstr0(demux->filename), "null://") &&
  ------------------
  |  Branch (24:9): [True: 15.7k, False: 14]
  ------------------
   25|  15.7k|        check != DEMUX_CHECK_REQUEST)
  ------------------
  |  Branch (25:9): [True: 15.7k, False: 0]
  ------------------
   26|  15.7k|        return -1;
   27|     14|    demux->seekable = true;
   28|     14|    return 0;
   29|  15.7k|}

demux_playlist.c:open_file:
  646|  58.8k|{
  647|  58.8k|    if (!demuxer->access_references)
  ------------------
  |  Branch (647:9): [True: 0, False: 58.8k]
  ------------------
  648|      0|        return -1;
  649|       |
  650|  58.8k|    bool force = check < DEMUX_CHECK_UNSAFE || check == DEMUX_CHECK_REQUEST;
  ------------------
  |  Branch (650:18): [True: 0, False: 58.8k]
  |  Branch (650:48): [True: 0, False: 58.8k]
  ------------------
  651|       |
  652|  58.8k|    struct pl_parser *p = talloc_zero(NULL, struct pl_parser);
  ------------------
  |  |   27|  58.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  58.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  58.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  58.8k|    p->global = demuxer->global;
  654|  58.8k|    p->log = demuxer->log;
  655|  58.8k|    p->pl = talloc_zero(p, struct playlist);
  ------------------
  |  |   27|  58.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  58.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  58.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|  58.8k|    p->real_stream = demuxer->stream;
  657|       |
  658|  58.8k|    struct demux_opts *opts = mp_get_config_group(p, p->global, &demux_conf);
  659|  58.8k|    p->codepage = opts->meta_cp;
  660|       |
  661|  58.8k|    char probe[PROBE_SIZE];
  662|  58.8k|    int probe_len = stream_read_peek(p->real_stream, probe, sizeof(probe));
  663|  58.8k|    p->s = stream_memory_open(demuxer->global, probe, probe_len);
  664|  58.8k|    p->s->mime_type = demuxer->stream->mime_type;
  665|  58.8k|    p->utf16 = stream_skip_bom(p->s);
  666|  58.8k|    p->force = force;
  667|  58.8k|    p->check_level = check;
  668|  58.8k|    p->probing = true;
  669|  58.8k|    p->autocreate_playlist = demuxer->params->allow_playlist_create ? opts->autocreate_playlist : 0;
  ------------------
  |  Branch (669:30): [True: 56.9k, False: 1.91k]
  ------------------
  670|  58.8k|    p->directory_filter = opts->directory_filter;
  671|  58.8k|    p->mp_opts = mp_get_config_group(demuxer, demuxer->global, &mp_opt_root);
  672|  58.8k|    p->opts = mp_get_config_group(demuxer, demuxer->global, &demux_playlist_conf);
  673|       |
  674|  58.8k|    const struct pl_format *fmts = playlist_formats;
  675|  58.8k|    if (demuxer->desc == &demuxer_desc_directory)
  ------------------
  |  Branch (675:9): [True: 40.3k, False: 18.5k]
  ------------------
  676|  40.3k|        fmts = dir_formats;
  677|       |
  678|  58.8k|    const struct pl_format *fmt = probe_pl(p, fmts);
  679|  58.8k|    free_stream(p->s);
  680|  58.8k|    playlist_clear(p->pl);
  681|  58.8k|    if (!fmt) {
  ------------------
  |  Branch (681:9): [True: 56.0k, False: 2.79k]
  ------------------
  682|  56.0k|        talloc_free(p);
  ------------------
  |  |   47|  56.0k|#define talloc_free                     ta_free
  ------------------
  683|  56.0k|        return -1;
  684|  56.0k|    }
  685|       |
  686|  2.79k|    p->probing = false;
  687|  2.79k|    p->error = false;
  688|  2.79k|    p->s = demuxer->stream;
  689|  2.79k|    p->utf16 = stream_skip_bom(p->s);
  690|  2.79k|    bool ok = fmt->parse(p) >= 0 && !p->error;
  ------------------
  |  Branch (690:15): [True: 2.79k, False: 0]
  |  Branch (690:37): [True: 2.79k, False: 0]
  ------------------
  691|  2.79k|    playlist_set_stream_flags(p->pl, demuxer->stream_origin);
  692|  2.79k|    demuxer->playlist = talloc_steal(demuxer, p->pl);
  ------------------
  |  |   38|  2.79k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.79k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  693|  2.79k|    demuxer->filetype = p->format ? p->format : fmt->name;
  ------------------
  |  Branch (693:25): [True: 69, False: 2.73k]
  ------------------
  694|  2.79k|    demuxer->fully_read = true;
  695|  2.79k|    talloc_free(p);
  ------------------
  |  |   47|  2.79k|#define talloc_free                     ta_free
  ------------------
  696|  2.79k|    if (ok)
  ------------------
  |  Branch (696:9): [True: 2.79k, False: 0]
  ------------------
  697|  2.79k|        demux_close_stream(demuxer);
  698|  2.79k|    return ok ? 0 : -1;
  ------------------
  |  Branch (698:12): [True: 2.79k, False: 0]
  ------------------
  699|  58.8k|}
demux_playlist.c:parse_m3u:
  248|  37.0k|{
  249|  37.0k|    bstr line = pl_get_line(p);
  250|  37.0k|    if (p->probing && !bstr_equals0(line, "#EXTM3U")) {
  ------------------
  |  Branch (250:9): [True: 34.3k, False: 2.69k]
  |  Branch (250:23): [True: 33.2k, False: 1.08k]
  ------------------
  251|       |        // Last resort: if the file extension is m3u, it might be headerless.
  252|  33.2k|        if (p->check_level == DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (252:13): [True: 13.3k, False: 19.9k]
  ------------------
  253|  13.3k|            bstr ext = mp_get_ext(bstr0(p->real_stream->url));
  254|  13.3k|            char probe[PROBE_SIZE];
  255|  13.3k|            int len = stream_read_peek(p->real_stream, probe, sizeof(probe));
  256|  13.3k|            bstr data = {probe, len};
  257|  13.3k|            if (ext.len && data.len >= 2 && maybe_text(data)) {
  ------------------
  |  Branch (257:17): [True: 3.60k, False: 9.73k]
  |  Branch (257:28): [True: 3.60k, False: 6]
  |  Branch (257:45): [True: 1.89k, False: 1.71k]
  ------------------
  258|  1.89k|                const char *exts[] = {"m3u", "m3u8", "strm", NULL};
  259|  4.30k|                for (int n = 0; exts[n]; n++) {
  ------------------
  |  Branch (259:33): [True: 4.01k, False: 284]
  ------------------
  260|  4.01k|                    if (bstrcasecmp(ext, bstr0(exts[n])) == 0)
  ------------------
  |  Branch (260:25): [True: 1.60k, False: 2.41k]
  ------------------
  261|  1.60k|                        goto ok;
  262|  4.01k|                }
  263|  1.89k|            }
  264|  13.3k|        }
  265|  31.6k|        pl_free_line(p, line);
  266|  31.6k|        return -1;
  267|  33.2k|    }
  268|       |
  269|  5.39k|ok:
  270|  5.39k|    if (p->probing) {
  ------------------
  |  Branch (270:9): [True: 2.69k, False: 2.69k]
  ------------------
  271|  2.69k|        pl_free_line(p, line);
  272|  2.69k|        return 0;
  273|  2.69k|    }
  274|       |
  275|  2.69k|    char *title = NULL;
  276|   240k|    while (line.len || !pl_eof(p)) {
  ------------------
  |  Branch (276:12): [True: 109k, False: 131k]
  |  Branch (276:24): [True: 128k, False: 2.69k]
  ------------------
  277|   237k|        bstr line_dup = line;
  278|   237k|        if (bstr_eatstart0(&line_dup, "#EXTINF:")) {
  ------------------
  |  Branch (278:13): [True: 315, False: 237k]
  ------------------
  279|    315|            bstr duration, btitle;
  280|    315|            if (bstr_split_tok(line_dup, ",", &duration, &btitle) && btitle.len) {
  ------------------
  |  Branch (280:17): [True: 195, False: 120]
  |  Branch (280:70): [True: 152, False: 43]
  ------------------
  281|    152|                talloc_free(title);
  ------------------
  |  |   47|    152|#define talloc_free                     ta_free
  ------------------
  282|    152|                title = bstrto0(NULL, btitle);
  283|    152|            }
  284|   237k|        } else if (bstr_startswith0(line_dup, "#EXT-X-")) {
  ------------------
  |  Branch (284:20): [True: 1.00k, False: 236k]
  ------------------
  285|       |            // Note that this is only used for user advice. Actual HLS demuxing
  286|       |            // must happen through demux_lavf.
  287|  1.00k|            p->format = "hls";
  288|   236k|        } else if (line_dup.len > 0 && !bstr_startswith0(line_dup, "#")) {
  ------------------
  |  Branch (288:20): [True: 108k, False: 128k]
  |  Branch (288:40): [True: 103k, False: 4.38k]
  ------------------
  289|   103k|            pl_add(p, line);
  290|   103k|            struct playlist_entry *e = playlist_get_last(p->pl);
  291|   103k|            e->title = talloc_steal(e, title);
  ------------------
  |  |   38|   103k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   103k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  292|   103k|            title = NULL;
  293|   103k|        }
  294|   237k|        pl_free_line(p, line);
  295|   237k|        line = pl_get_line(p);
  296|   237k|    }
  297|  2.69k|    pl_free_line(p, line);
  298|  2.69k|    talloc_free(title);
  ------------------
  |  |   47|  2.69k|#define talloc_free                     ta_free
  ------------------
  299|  2.69k|    return 0;
  300|  5.39k|}
demux_playlist.c:pl_get_line:
  192|   357k|{
  193|   357k|    bstr line = bstr_strip(bstr0(pl_get_line0(p)));
  194|   357k|    const char *charset = mp_charset_guess(p, p->log, line, p->codepage, 0);
  195|   357k|    if (charset && !mp_charset_is_utf8(charset)) {
  ------------------
  |  Branch (195:9): [True: 357k, False: 0]
  |  Branch (195:20): [True: 141k, False: 215k]
  ------------------
  196|   141k|        bstr utf8 = mp_iconv_to_utf8(p->log, line, charset, 0);
  197|   141k|        if (utf8.start && utf8.start != line.start) {
  ------------------
  |  Branch (197:13): [True: 141k, False: 0]
  |  Branch (197:27): [True: 141k, False: 0]
  ------------------
  198|   141k|            line = utf8;
  199|       |            p->line_allocated = true;
  200|   141k|        }
  201|   141k|    }
  202|   357k|    return line;
  203|   357k|}
demux_playlist.c:pl_get_line0:
  179|   357k|{
  180|   357k|    char *res = read_line(p->s, p->buffer, sizeof(p->buffer), p->utf16);
  181|   357k|    if (res) {
  ------------------
  |  Branch (181:9): [True: 351k, False: 5.78k]
  ------------------
  182|   351k|        int len = strlen(res);
  183|   351k|        if (len > 0 && res[len - 1] == '\n')
  ------------------
  |  Branch (183:13): [True: 351k, False: 0]
  |  Branch (183:24): [True: 317k, False: 34.8k]
  ------------------
  184|   317k|            res[len - 1] = '\0';
  185|   351k|    } else {
  186|  5.78k|        p->error |= !p->s->eof;
  187|  5.78k|    }
  188|   357k|    return res;
  189|   357k|}
demux_playlist.c:read_line:
  157|   357k|{
  158|   357k|    if (max < 1)
  ------------------
  |  Branch (158:9): [True: 0, False: 357k]
  ------------------
  159|      0|        return NULL;
  160|   357k|    int read = 0;
  161|   433k|    while (1) {
  ------------------
  |  Branch (161:12): [True: 433k, Folded]
  ------------------
  162|       |        // Reserve 1 byte of ptr for terminating \0.
  163|   433k|        int l = read_characters(s, &mem[read], max - read - 1, utf16);
  164|   433k|        if (l < 0 || memchr(&mem[read], '\0', l)) {
  ------------------
  |  Branch (164:13): [True: 393, False: 432k]
  |  Branch (164:22): [True: 2.43k, False: 430k]
  ------------------
  165|  2.83k|            MP_WARN(s, "error reading line\n");
  ------------------
  |  |   90|  2.83k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.83k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  166|  2.83k|            return NULL;
  167|  2.83k|        }
  168|   430k|        read += l;
  169|   430k|        if (l == 0 || (read > 0 && mem[read - 1] == '\n'))
  ------------------
  |  Branch (169:13): [True: 37.7k, False: 392k]
  |  Branch (169:24): [True: 392k, False: 0]
  |  Branch (169:36): [True: 317k, False: 75.6k]
  ------------------
  170|   354k|            break;
  171|   430k|    }
  172|   354k|    mem[read] = '\0';
  173|   354k|    if (!stream_read_peek(s, &(char){0}, 1) && read == 0) // legitimate EOF
  ------------------
  |  Branch (173:9): [True: 38.3k, False: 316k]
  |  Branch (173:48): [True: 2.94k, False: 35.4k]
  ------------------
  174|  2.94k|        return NULL;
  175|   351k|    return mem;
  176|   354k|}
demux_playlist.c:read_characters:
  122|   433k|{
  123|   433k|    if (utf16 == 1 || utf16 == 2) {
  ------------------
  |  Branch (123:9): [True: 839, False: 432k]
  |  Branch (123:23): [True: 594, False: 431k]
  ------------------
  124|  1.43k|        uint8_t *cur = dst;
  125|  96.8k|        while (1) {
  ------------------
  |  Branch (125:16): [True: 96.8k, Folded]
  ------------------
  126|  96.8k|            if ((cur - dst) + 8 >= dstsize) // PUT_UTF8 writes max. 8 bytes
  ------------------
  |  Branch (126:17): [True: 0, False: 96.8k]
  ------------------
  127|      0|                return -1; // line too long
  128|  96.8k|            uint32_t c;
  129|  96.8k|            uint8_t tmp;
  130|  96.8k|            GET_UTF16(c, stream_read_word_endian(s, utf16 == 2), return -1;)
  ------------------
  |  Branch (130:13): [True: 303, False: 305]
  |  Branch (130:13): [True: 90, False: 215]
  |  Branch (130:13): [True: 608, False: 96.2k]
  ------------------
  131|  96.4k|            if (s->eof)
  ------------------
  |  Branch (131:17): [True: 1.04k, False: 95.4k]
  ------------------
  132|  1.04k|                break; // legitimate EOF; ignore the case of partial reads
  133|  96.4k|            PUT_UTF8(c, tmp, *cur++ = tmp;)
  ------------------
  |  Branch (133:13): [True: 189k, False: 95.4k]
  |  Branch (133:13): [True: 0, False: 95.4k]
  ------------------
  134|  95.4k|            if (c == '\n')
  ------------------
  |  Branch (134:17): [True: 0, False: 95.4k]
  ------------------
  135|      0|                break;
  136|  95.4k|        }
  137|  1.04k|        return cur - dst;
  138|   431k|    } else {
  139|   431k|        uint8_t buf[1024];
  140|   431k|        int buf_len = stream_read_peek(s, buf, sizeof(buf));
  141|   431k|        uint8_t *end = memchr(buf, '\n', buf_len);
  142|   431k|        int len = end ? end - buf + 1 : buf_len;
  ------------------
  |  Branch (142:19): [True: 317k, False: 114k]
  ------------------
  143|   431k|        if (len > dstsize)
  ------------------
  |  Branch (143:13): [True: 0, False: 431k]
  ------------------
  144|      0|            return -1; // line too long
  145|   431k|        memcpy(dst, buf, len);
  146|   431k|        stream_seek_skip(s, stream_tell(s) + len);
  147|   431k|        return len;
  148|   431k|    }
  149|   433k|}
demux_playlist.c:stream_read_word_endian:
  111|  97.4k|{
  112|  97.4k|    unsigned int y = stream_read_char(s);
  113|  97.4k|    y = (y << 8) | stream_read_char(s);
  114|  97.4k|    if (!big_endian)
  ------------------
  |  Branch (114:9): [True: 29.8k, False: 67.5k]
  ------------------
  115|  29.8k|        y = ((y >> 8) & 0xFF) | (y << 8);
  116|  97.4k|    return y;
  117|  97.4k|}
demux_playlist.c:maybe_text:
  238|  3.60k|{
  239|  4.05M|    for (int n = 0; n < d.len; n++) {
  ------------------
  |  Branch (239:21): [True: 4.04M, False: 1.89k]
  ------------------
  240|  4.04M|        unsigned char c = d.start[n];
  241|  4.04M|        if (c < 32 && c != '\n' && c != '\r' && c != '\t')
  ------------------
  |  Branch (241:13): [True: 60.8k, False: 3.98M]
  |  Branch (241:23): [True: 51.1k, False: 9.66k]
  |  Branch (241:36): [True: 50.3k, False: 803]
  |  Branch (241:49): [True: 1.71k, False: 48.6k]
  ------------------
  242|  1.71k|            return false;
  243|  4.04M|    }
  244|  1.89k|    return true;
  245|  3.60k|}
demux_playlist.c:pl_free_line:
  207|   354k|{
  208|   354k|    if (p->line_allocated) {
  ------------------
  |  Branch (208:9): [True: 141k, False: 213k]
  ------------------
  209|   141k|        talloc_free(line.start);
  ------------------
  |  |   47|   141k|#define talloc_free                     ta_free
  ------------------
  210|       |        p->line_allocated = false;
  211|   141k|    }
  212|   354k|}
demux_playlist.c:pl_eof:
  233|   200k|{
  234|   200k|    return p->error || p->s->eof;
  ------------------
  |  Branch (234:12): [True: 1.82k, False: 198k]
  |  Branch (234:24): [True: 3.01k, False: 195k]
  ------------------
  235|   200k|}
demux_playlist.c:pl_add:
  215|   104k|{
  216|   104k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|   104k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   104k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  217|   104k|    char *path = mp_get_user_path(ctx, p->global, bstrto0(ctx, entry));
  218|       |
  219|   104k|    bstr proto = mp_split_proto(bstr0(p->s->url), NULL);
  220|       |    // Don't add base path to self-expanding protocols
  221|   104k|    if (!mp_is_url(entry) && bstrcasecmp0(proto, "memory") &&
  ------------------
  |  Branch (221:9): [True: 95.8k, False: 9.13k]
  |  Branch (221:30): [True: 95.7k, False: 124]
  ------------------
  222|  95.7k|        bstrcasecmp0(proto, "lavf") && bstrcasecmp0(proto, "hex") &&
  ------------------
  |  Branch (222:9): [True: 76, False: 95.6k]
  |  Branch (222:40): [True: 76, False: 0]
  ------------------
  223|     76|        bstrcasecmp0(proto, "data") && bstrcasecmp0(proto, "fd")) {
  ------------------
  |  Branch (223:9): [True: 0, False: 76]
  |  Branch (223:40): [True: 0, False: 0]
  ------------------
  224|      0|        const char *base = p->s->effective_url ? p->s->effective_url : p->s->url;
  ------------------
  |  Branch (224:28): [True: 0, False: 0]
  ------------------
  225|      0|        path = mp_path_join_bstr(ctx, mp_dirname(base), bstr0(path));
  226|      0|    }
  227|       |
  228|   104k|    playlist_append_file(p->pl, path);
  229|   104k|    talloc_free(ctx);
  ------------------
  |  |   47|   104k|#define talloc_free                     ta_free
  ------------------
  230|   104k|}
demux_playlist.c:parse_ref_init:
  303|  15.8k|{
  304|  15.8k|    bstr line = pl_get_line(p);
  305|  15.8k|    if (!bstr_equals0(line, "[Reference]")) {
  ------------------
  |  Branch (305:9): [True: 15.7k, False: 94]
  ------------------
  306|  15.7k|        pl_free_line(p, line);
  307|  15.7k|        return -1;
  308|  15.7k|    }
  309|     94|    pl_free_line(p, line);
  310|       |
  311|       |    // ASF http streaming redirection - this is needed because ffmpeg http://
  312|       |    // and mmsh:// can not automatically switch automatically between each
  313|       |    // others. Both protocols use http - MMSH requires special http headers
  314|       |    // to "activate" it, and will in other cases return this playlist.
  315|     94|    static const char *const mmsh_types[] = {"audio/x-ms-wax",
  316|     94|        "audio/x-ms-wma", "video/x-ms-asf", "video/x-ms-afs", "video/x-ms-wmv",
  317|     94|        "video/x-ms-wma", "application/x-mms-framed",
  318|     94|        "application/vnd.ms.wms-hdr.asfv1", NULL};
  319|     94|    bstr burl = bstr0(p->s->url);
  320|     94|    if (bstr_eatstart0(&burl, "http://") && check_mimetype(p->s, mmsh_types)) {
  ------------------
  |  Branch (320:9): [True: 0, False: 94]
  |  Branch (320:45): [True: 0, False: 0]
  ------------------
  321|      0|        MP_INFO(p, "Redirecting to mmsh://\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  322|      0|        playlist_append_file(p->pl, talloc_asprintf(p, "mmsh://%.*s", BSTR_P(burl)));
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|      0|        return 0;
  324|      0|    }
  325|       |
  326|  18.3k|    while (!pl_eof(p)) {
  ------------------
  |  Branch (326:12): [True: 18.3k, False: 94]
  ------------------
  327|  18.3k|        line = pl_get_line(p);
  328|  18.3k|        bstr value;
  329|  18.3k|        if (bstr_case_startswith(line, bstr0("Ref"))) {
  ------------------
  |  Branch (329:13): [True: 344, False: 17.9k]
  ------------------
  330|    344|            bstr_split_tok(line, "=", &(bstr){0}, &value);
  331|    344|            if (value.len)
  ------------------
  |  Branch (331:17): [True: 266, False: 78]
  ------------------
  332|    266|                pl_add(p, value);
  333|    344|        }
  334|  18.3k|        pl_free_line(p, line);
  335|  18.3k|    }
  336|     94|    return 0;
  337|     94|}
demux_playlist.c:check_mimetype:
   78|   137k|{
   79|   137k|    if (s->mime_type) {
  ------------------
  |  Branch (79:9): [True: 0, False: 137k]
  ------------------
   80|      0|        for (int n = 0; list && list[n]; n++) {
  ------------------
  |  Branch (80:25): [True: 0, False: 0]
  |  Branch (80:33): [True: 0, False: 0]
  ------------------
   81|      0|            if (strcasecmp(s->mime_type, list[n]) == 0)
  ------------------
  |  Branch (81:17): [True: 0, False: 0]
  ------------------
   82|      0|                return true;
   83|      0|        }
   84|      0|    }
   85|   137k|    return false;
   86|   137k|}
demux_playlist.c:parse_pls:
  371|  15.7k|{
  372|  15.7k|    return parse_ini_thing(p, "[playlist]", "File");
  373|  15.7k|}
demux_playlist.c:parse_ini_thing:
  341|  31.6k|{
  342|  31.6k|    bstr line = {0};
  343|  66.0k|    while (!line.len && !pl_eof(p))
  ------------------
  |  Branch (343:12): [True: 36.3k, False: 29.6k]
  |  Branch (343:25): [True: 34.4k, False: 1.99k]
  ------------------
  344|  34.4k|        line = pl_get_line(p);
  345|  31.6k|    if (bstrcasecmp0(line, header) != 0) {
  ------------------
  |  Branch (345:9): [True: 31.5k, False: 112]
  ------------------
  346|  31.5k|        pl_free_line(p, line);
  347|  31.5k|        return -1;
  348|  31.5k|    }
  349|    112|    if (p->probing) {
  ------------------
  |  Branch (349:9): [True: 56, False: 56]
  ------------------
  350|     56|        pl_free_line(p, line);
  351|     56|        return 0;
  352|     56|    }
  353|     56|    pl_free_line(p, line);
  354|  14.3k|    while (!pl_eof(p)) {
  ------------------
  |  Branch (354:12): [True: 14.2k, False: 56]
  ------------------
  355|  14.2k|        line = pl_get_line(p);
  356|  14.2k|        bstr key, value;
  357|  14.2k|        if (bstr_split_tok(line, "=", &key, &value) &&
  ------------------
  |  Branch (357:13): [True: 1.37k, False: 12.9k]
  ------------------
  358|  1.37k|            bstr_case_startswith(key, bstr0(entry)))
  ------------------
  |  Branch (358:13): [True: 1.05k, False: 322]
  ------------------
  359|  1.05k|        {
  360|  1.05k|            value = bstr_strip(value);
  361|  1.05k|            if (bstr_startswith0(value, "\"") && bstr_endswith0(value, "\""))
  ------------------
  |  Branch (361:17): [True: 152, False: 905]
  |  Branch (361:50): [True: 70, False: 82]
  ------------------
  362|     70|                value = bstr_splice(value, 1, -1);
  363|  1.05k|            pl_add(p, value);
  364|  1.05k|        }
  365|  14.2k|        pl_free_line(p, line);
  366|  14.2k|    }
  367|     56|    return 0;
  368|    112|}
demux_playlist.c:parse_url:
  376|  15.8k|{
  377|  15.8k|    return parse_ini_thing(p, "[InternetShortcut]", "URL");
  378|  15.8k|}
demux_playlist.c:parse_txt:
  381|  15.7k|{
  382|  15.7k|    if (!p->force)
  ------------------
  |  Branch (382:9): [True: 15.7k, False: 0]
  ------------------
  383|  15.7k|        return -1;
  384|      0|    if (p->probing)
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        return 0;
  386|      0|    MP_WARN(p, "Reading plaintext playlist.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  387|      0|    while (!pl_eof(p)) {
  ------------------
  |  Branch (387:12): [True: 0, False: 0]
  ------------------
  388|      0|        bstr line = pl_get_line(p);
  389|      0|        if (line.len == 0)
  ------------------
  |  Branch (389:13): [True: 0, False: 0]
  ------------------
  390|      0|            continue;
  391|      0|        pl_add(p, line);
  392|      0|        pl_free_line(p, line);
  393|      0|    }
  394|      0|    return 0;
  395|      0|}
demux_playlist.c:parse_dir:
  532|  40.3k|{
  533|  40.3k|    int ret = -1;
  534|  40.3k|    struct stream *stream = p->real_stream;
  535|  40.3k|    enum autocreate_mode autocreate = AUTO_NONE;
  536|  40.3k|    p->pl->playlist_dir = NULL;
  537|  40.3k|    if (p->autocreate_playlist && p->real_stream->is_local_fs && p->real_stream->is_regular &&
  ------------------
  |  Branch (537:9): [True: 0, False: 40.3k]
  |  Branch (537:35): [True: 0, False: 0]
  |  Branch (537:66): [True: 0, False: 0]
  ------------------
  538|      0|        !p->real_stream->is_directory) {
  ------------------
  |  Branch (538:9): [True: 0, False: 0]
  ------------------
  539|      0|        bstr ext = mp_get_ext(bstr0(p->real_stream->url));
  540|      0|        switch (p->autocreate_playlist) {
  ------------------
  |  Branch (540:17): [True: 0, False: 0]
  ------------------
  541|      0|        case 1: // filter
  ------------------
  |  Branch (541:9): [True: 0, False: 0]
  ------------------
  542|      0|            autocreate = get_directory_filter(p);
  543|      0|            break;
  544|      0|        case 2: // same
  ------------------
  |  Branch (544:9): [True: 0, False: 0]
  ------------------
  545|      0|            if (bstr_in_list0(ext, p->mp_opts->video_exts)) {
  ------------------
  |  Branch (545:17): [True: 0, False: 0]
  ------------------
  546|      0|                autocreate = AUTO_VIDEO;
  547|      0|            } else if (bstr_in_list0(ext, p->mp_opts->audio_exts)) {
  ------------------
  |  Branch (547:24): [True: 0, False: 0]
  ------------------
  548|      0|                autocreate = AUTO_AUDIO;
  549|      0|            } else if (bstr_in_list0(ext, p->mp_opts->image_exts)) {
  ------------------
  |  Branch (549:24): [True: 0, False: 0]
  ------------------
  550|      0|                autocreate = AUTO_IMAGE;
  551|      0|            } else if (bstr_in_list0(ext, p->mp_opts->archive_exts)) {
  ------------------
  |  Branch (551:24): [True: 0, False: 0]
  ------------------
  552|      0|                autocreate = AUTO_ARCHIVE;
  553|      0|            } else if (bstr_in_list0(ext, p->mp_opts->playlist_exts)) {
  ------------------
  |  Branch (553:24): [True: 0, False: 0]
  ------------------
  554|      0|                autocreate = AUTO_PLAYLIST;
  555|      0|            }
  556|      0|            break;
  557|      0|        }
  558|      0|        int flags = STREAM_READ_FILE_FLAGS_DEFAULT;
  ------------------
  |  |   60|      0|    (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   47|      0|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   41|      0|#define STREAM_READ               0
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   54|      0|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   55|      0|#define STREAM_LESS_NOISE         (1 << 6) // try to log errors only
  |  |  ------------------
  ------------------
  559|      0|        bstr dir = mp_dirname(p->real_stream->url);
  560|      0|        if (!dir.len)
  ------------------
  |  Branch (560:13): [True: 0, False: 0]
  ------------------
  561|      0|            autocreate = AUTO_NONE;
  562|      0|        if (autocreate != AUTO_NONE) {
  ------------------
  |  Branch (562:13): [True: 0, False: 0]
  ------------------
  563|      0|            stream = stream_create(bstrdup0(p, dir), flags, NULL, p->global);
  564|      0|            p->pl->playlist_dir = bstrdup0(p->pl, dir);
  565|      0|        }
  566|  40.3k|    } else {
  567|  40.3k|        autocreate = get_directory_filter(p);
  568|  40.3k|    }
  569|  40.3k|    if (!stream->is_directory)
  ------------------
  |  Branch (569:9): [True: 40.3k, False: 0]
  ------------------
  570|  40.3k|        goto done;
  571|      0|    if (p->probing) {
  ------------------
  |  Branch (571:9): [True: 0, False: 0]
  ------------------
  572|      0|        ret = 0;
  573|      0|        goto done;
  574|      0|    }
  575|       |
  576|      0|    char *path = mp_file_get_path(p, bstr0(stream->url));
  577|      0|    if (!path)
  ------------------
  |  Branch (577:9): [True: 0, False: 0]
  ------------------
  578|      0|        goto done;
  579|       |
  580|      0|    if (autocreate == AUTO_NONE)
  ------------------
  |  Branch (580:9): [True: 0, False: 0]
  ------------------
  581|      0|        goto done;
  582|       |
  583|      0|    struct stat dir_stack[MAX_DIR_STACK];
  584|       |
  585|      0|    if (p->opts->dir_mode == DIR_AUTO)
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|        p->opts->dir_mode = p->mp_opts->shuffle ? DIR_RECURSIVE : DIR_LAZY;
  ------------------
  |  Branch (586:29): [True: 0, False: 0]
  ------------------
  587|       |
  588|      0|    scan_dir(p, path, dir_stack, 0, autocreate);
  589|       |
  590|      0|    ret = p->pl->num_entries > 0 ? 0 : -1;
  ------------------
  |  Branch (590:11): [True: 0, False: 0]
  ------------------
  591|       |
  592|  40.3k|done:
  593|  40.3k|    if (stream != p->real_stream)
  ------------------
  |  Branch (593:9): [True: 0, False: 40.3k]
  ------------------
  594|      0|        free_stream(stream);
  595|  40.3k|    return ret;
  596|      0|}
demux_playlist.c:get_directory_filter:
  514|  40.3k|{
  515|  40.3k|    enum autocreate_mode autocreate = AUTO_NONE;
  516|  40.3k|    if (!p->directory_filter || !p->directory_filter[0])
  ------------------
  |  Branch (516:9): [True: 0, False: 40.3k]
  |  Branch (516:33): [True: 0, False: 40.3k]
  ------------------
  517|      0|        autocreate = AUTO_ANY;
  518|  40.3k|    if (bstr_in_list0(bstr0("video"), p->directory_filter))
  ------------------
  |  Branch (518:9): [True: 40.3k, False: 0]
  ------------------
  519|  40.3k|        autocreate |= AUTO_VIDEO;
  520|  40.3k|    if (bstr_in_list0(bstr0("audio"), p->directory_filter))
  ------------------
  |  Branch (520:9): [True: 40.3k, False: 0]
  ------------------
  521|  40.3k|        autocreate |= AUTO_AUDIO;
  522|  40.3k|    if (bstr_in_list0(bstr0("image"), p->directory_filter))
  ------------------
  |  Branch (522:9): [True: 40.3k, False: 0]
  ------------------
  523|  40.3k|        autocreate |= AUTO_IMAGE;
  524|  40.3k|    if (bstr_in_list0(bstr0("archive"), p->directory_filter))
  ------------------
  |  Branch (524:9): [True: 40.3k, False: 0]
  ------------------
  525|  40.3k|        autocreate |= AUTO_ARCHIVE;
  526|  40.3k|    if (bstr_in_list0(bstr0("playlist"), p->directory_filter))
  ------------------
  |  Branch (526:9): [True: 40.3k, False: 0]
  ------------------
  527|  40.3k|        autocreate |= AUTO_PLAYLIST;
  528|  40.3k|    return autocreate;
  529|  40.3k|}
demux_playlist.c:probe_pl:
  625|  58.8k|{
  626|  58.8k|    int64_t start = stream_tell(p->s);
  627|  58.8k|    const struct pl_format *fmt = fmts;
  628|   193k|    while (fmt->name) {
  ------------------
  |  Branch (628:12): [True: 137k, False: 56.0k]
  ------------------
  629|   137k|        stream_seek(p->s, start);
  630|   137k|        if (check_mimetype(p->s, fmt->mime_types)) {
  ------------------
  |  Branch (630:13): [True: 0, False: 137k]
  ------------------
  631|      0|            MP_VERBOSE(p, "forcing format by mime-type.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  632|      0|            p->force = true;
  633|      0|            return fmt;
  634|      0|        }
  635|   137k|        if (fmt->parse(p) >= 0)
  ------------------
  |  Branch (635:13): [True: 2.79k, False: 135k]
  ------------------
  636|  2.79k|            return fmt;
  637|   135k|        fmt++;
  638|   135k|    }
  639|  56.0k|    return NULL;
  640|  58.8k|}

demux_raw.c:demux_rawaudio_open:
  146|  40.1k|{
  147|  40.1k|    struct demux_rawaudio_opts *opts =
  148|  40.1k|        mp_get_config_group(demuxer, demuxer->global, &demux_rawaudio_conf);
  149|       |
  150|  40.1k|    if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (150:9): [True: 40.1k, False: 0]
  |  Branch (150:41): [True: 40.1k, False: 0]
  ------------------
  151|  40.1k|        return -1;
  152|       |
  153|      0|    if (opts->channels.num_chmaps != 1) {
  ------------------
  |  Branch (153:9): [True: 0, False: 0]
  ------------------
  154|      0|        MP_ERR(demuxer, "Invalid channels option given.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  155|      0|        return -1;
  156|      0|    }
  157|       |
  158|      0|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO);
  159|      0|    struct mp_codec_params *c = sh->codec;
  160|      0|    c->channels = opts->channels.chmaps[0];
  161|      0|    c->force_channels = true;
  162|      0|    c->samplerate = opts->samplerate;
  163|       |
  164|      0|    c->native_tb_num = 1;
  165|      0|    c->native_tb_den = c->samplerate;
  166|       |
  167|      0|    int f = opts->aformat;
  168|       |    // See PCM():               sign   float  bits    endian
  169|      0|    mp_set_pcm_codec(sh->codec, f & 1, f & 2, f >> 3, f & 4);
  170|      0|    int samplesize = ((f >> 3) + 7) / 8;
  171|       |
  172|      0|    demux_add_sh_stream(demuxer, sh);
  173|       |
  174|      0|    struct priv *p = talloc_ptrtype(demuxer, p);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|      0|    demuxer->priv = p;
  176|      0|    *p = (struct priv) {
  177|      0|        .sh = sh,
  178|      0|        .frame_size = samplesize * c->channels.num,
  179|      0|        .frame_rate = c->samplerate,
  180|      0|        .read_frames = c->samplerate / 8,
  181|      0|    };
  182|       |
  183|      0|    return generic_open(demuxer);
  184|      0|}
demux_raw.c:demux_rawvideo_open:
  187|  40.1k|{
  188|  40.1k|    struct demux_rawvideo_opts *opts =
  189|  40.1k|        mp_get_config_group(demuxer, demuxer->global, &demux_rawvideo_conf);
  190|       |
  191|  40.1k|    if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (191:9): [True: 40.1k, False: 0]
  |  Branch (191:41): [True: 40.1k, False: 0]
  ------------------
  192|  40.1k|        return -1;
  193|       |
  194|      0|    int width = opts->width;
  195|      0|    int height = opts->height;
  196|       |
  197|      0|    if (!width || !height) {
  ------------------
  |  Branch (197:9): [True: 0, False: 0]
  |  Branch (197:19): [True: 0, False: 0]
  ------------------
  198|      0|        MP_ERR(demuxer, "rawvideo: width or height not specified!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  199|      0|        return -1;
  200|      0|    }
  201|       |
  202|      0|    const char *decoder = "rawvideo";
  203|      0|    int imgfmt = opts->vformat;
  204|      0|    int imgsize = opts->imgsize;
  205|      0|    int mp_imgfmt = 0;
  206|      0|    if (opts->mp_format && !IMGFMT_IS_HWACCEL(opts->mp_format)) {
  ------------------
  |  |  329|      0|#define IMGFMT_IS_HWACCEL(fmt) (!!(mp_imgfmt_get_desc(fmt).flags & MP_IMGFLAG_HWACCEL))
  |  |  ------------------
  |  |  |  |   70|      0|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  |  |  ------------------
  |  |  |  |  |  |   65|      0|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (206:9): [True: 0, False: 0]
  |  Branch (206:9): [True: 0, False: 0]
  |  Branch (206:28): [True: 0, False: 0]
  ------------------
  207|      0|        mp_imgfmt = opts->mp_format;
  208|      0|        if (!imgsize) {
  ------------------
  |  Branch (208:13): [True: 0, False: 0]
  ------------------
  209|      0|            struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(opts->mp_format);
  210|      0|            for (int p = 0; p < desc.num_planes; p++) {
  ------------------
  |  Branch (210:29): [True: 0, False: 0]
  ------------------
  211|      0|                imgsize += ((width >> desc.xs[p]) * (height >> desc.ys[p]) *
  212|      0|                            desc.bpp[p] + 7) / 8;
  213|      0|            }
  214|      0|        }
  215|      0|    } else if (opts->codec && opts->codec[0])
  ------------------
  |  Branch (215:16): [True: 0, False: 0]
  |  Branch (215:31): [True: 0, False: 0]
  ------------------
  216|      0|        decoder = talloc_strdup(demuxer, opts->codec);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  217|       |
  218|      0|    if (!imgsize) {
  ------------------
  |  Branch (218:9): [True: 0, False: 0]
  ------------------
  219|      0|        int bpp = 0;
  220|      0|        switch (imgfmt) {
  ------------------
  |  Branch (220:17): [True: 0, False: 0]
  ------------------
  221|      0|        case MKTAG('Y', 'V', '1', '2'):
  ------------------
  |  Branch (221:9): [True: 0, False: 0]
  ------------------
  222|      0|        case MKTAG('I', '4', '2', '0'):
  ------------------
  |  Branch (222:9): [True: 0, False: 0]
  ------------------
  223|      0|        case MKTAG('I', 'Y', 'U', 'V'):
  ------------------
  |  Branch (223:9): [True: 0, False: 0]
  ------------------
  224|      0|            bpp = 12;
  225|      0|            break;
  226|      0|        case MKTAG('U', 'Y', 'V', 'Y'):
  ------------------
  |  Branch (226:9): [True: 0, False: 0]
  ------------------
  227|      0|        case MKTAG('Y', 'U', 'Y', '2'):
  ------------------
  |  Branch (227:9): [True: 0, False: 0]
  ------------------
  228|      0|            bpp = 16;
  229|      0|            break;
  230|      0|        }
  231|      0|        if (!bpp) {
  ------------------
  |  Branch (231:13): [True: 0, False: 0]
  ------------------
  232|      0|            MP_ERR(demuxer, "rawvideo: img size not specified and unknown format!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  233|      0|            return -1;
  234|      0|        }
  235|      0|        imgsize = width * height * bpp / 8;
  236|      0|    }
  237|       |
  238|      0|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
  239|      0|    struct mp_codec_params *c = sh->codec;
  240|      0|    c->codec = decoder;
  241|      0|    c->codec_tag = imgfmt;
  242|      0|    c->fps = opts->fps;
  243|      0|    c->reliable_fps = true;
  244|      0|    c->disp_w = width;
  245|      0|    c->disp_h = height;
  246|      0|    if (mp_imgfmt) {
  ------------------
  |  Branch (246:9): [True: 0, False: 0]
  ------------------
  247|      0|        c->lav_codecpar = avcodec_parameters_alloc();
  248|      0|        MP_HANDLE_OOM(c->lav_codecpar);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  249|      0|        c->lav_codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
  250|      0|        c->lav_codecpar->codec_id = mp_codec_to_av_codec_id(decoder);
  251|      0|        c->lav_codecpar->format = imgfmt2pixfmt(mp_imgfmt);
  252|      0|        c->lav_codecpar->width = width;
  253|      0|        c->lav_codecpar->height = height;
  254|      0|    }
  255|      0|    demux_add_sh_stream(demuxer, sh);
  256|       |
  257|      0|    struct priv *p = talloc_ptrtype(demuxer, p);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      0|    demuxer->priv = p;
  259|      0|    *p = (struct priv) {
  260|      0|        .sh = sh,
  261|      0|        .frame_size = imgsize,
  262|      0|        .frame_rate = c->fps,
  263|      0|        .read_frames = 1,
  264|      0|    };
  265|       |
  266|      0|    return generic_open(demuxer);
  267|      0|}

ebml_read_id:
   62|  40.1k|{
   63|  40.1k|    int i, len_mask = 0x80;
   64|  40.1k|    uint32_t id;
   65|       |
   66|  84.9k|    for (i = 0, id = stream_read_char(s); i < 4 && !(id & len_mask); i++)
  ------------------
  |  Branch (66:43): [True: 83.2k, False: 1.78k]
  |  Branch (66:52): [True: 44.8k, False: 38.3k]
  ------------------
   67|  44.8k|        len_mask >>= 1;
   68|  40.1k|    if (i >= 4)
  ------------------
  |  Branch (68:9): [True: 1.78k, False: 38.3k]
  ------------------
   69|  1.78k|        return EBML_ID_INVALID;
  ------------------
  |  |   75|  1.78k|#define EBML_ID_INVALID 0xffffffff
  ------------------
   70|  76.0k|    while (i--)
  ------------------
  |  Branch (70:12): [True: 37.6k, False: 38.3k]
  ------------------
   71|  37.6k|        id = (id << 8) | stream_read_char(s);
   72|  38.3k|    return id;
   73|  40.1k|}
ebml_read_length:
   79|    484|{
   80|    484|    int byte = stream_read_char(s);
   81|    484|    if (byte == STREAM_EOF || byte < 1)
  ------------------
  |  |   71|    968|#define STREAM_EOF (-256)
  ------------------
  |  Branch (81:9): [True: 2, False: 482]
  |  Branch (81:31): [True: 0, False: 482]
  ------------------
   82|      2|        return EBML_UINT_INVALID;
  ------------------
  |  |   85|      2|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   83|       |
   84|    482|    uint8_t leading_zeros = 7 - mp_log2((uint8_t)byte);
   85|    482|    uint64_t len = (uint8_t)byte & ((1 << (8 - leading_zeros - 1)) - 1);
   86|    979|    for (uint8_t i = 0; i < leading_zeros; ++i) {
  ------------------
  |  Branch (86:25): [True: 497, False: 482]
  ------------------
   87|    497|        byte = stream_read_char(s);
   88|    497|        if (byte == STREAM_EOF)
  ------------------
  |  |   71|    497|#define STREAM_EOF (-256)
  ------------------
  |  Branch (88:13): [True: 0, False: 497]
  ------------------
   89|      0|            return EBML_UINT_INVALID;
  ------------------
  |  |   85|      0|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   90|    497|        len = (len << 8) | (uint8_t)byte;
   91|    497|    }
   92|       |
   93|    482|    return len;
   94|    482|}
ebml_read_element:
  613|    484|{
  614|    484|    ctx->has_errors = false;
  615|    484|    int msglevel = ctx->no_error_messages ? MSGL_DEBUG : MSGL_WARN;
  ------------------
  |  Branch (615:20): [True: 484, False: 0]
  ------------------
  616|    484|    uint64_t length = ebml_read_length(s);
  617|    484|    if (s->eof) {
  ------------------
  |  Branch (617:9): [True: 2, False: 482]
  ------------------
  618|      2|        MP_MSG(ctx, msglevel, "Unexpected end of file "
  ------------------
  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  619|      2|                   "- partial or corrupt file?\n");
  620|      2|        return -1;
  621|      2|    }
  622|    482|    if (length == EBML_UINT_INVALID) {
  ------------------
  |  |   85|    482|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (622:9): [True: 0, False: 482]
  ------------------
  623|      0|        MP_MSG(ctx, msglevel, "EBML element with unknown length - unsupported\n");
  ------------------
  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  624|      0|        return -1;
  625|      0|    }
  626|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  627|       |    if (length > (512 << 20)) {
  628|       |#else
  629|    482|    if (length > (64 << 20)) {
  ------------------
  |  Branch (629:9): [True: 63, False: 419]
  ------------------
  630|     63|#endif
  631|     63|        MP_MSG(ctx, msglevel, "Element too big (%" PRIu64 " MiB) - skipping\n", length >> 20);
  ------------------
  |  |   86|     63|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  632|     63|        return -1;
  633|     63|    }
  634|    419|    ctx->talloc_ctx = talloc_size(NULL, length);
  ------------------
  |  |   43|    419|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|    419|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    419|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    419|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    419|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    419|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|    419|    int read_len = stream_read(s, ctx->talloc_ctx, length);
  636|    419|    if (read_len < length)
  ------------------
  |  Branch (636:9): [True: 208, False: 211]
  ------------------
  637|    208|        MP_MSG(ctx, msglevel, "Unexpected end of file - partial or corrupt file?\n");
  ------------------
  |  |   86|    208|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  638|    419|    ebml_parse_element(ctx, target, ctx->talloc_ctx, read_len, desc, 0);
  639|    419|    if (ctx->has_errors)
  ------------------
  |  Branch (639:9): [True: 380, False: 39]
  ------------------
  640|    380|        MP_MSG(ctx, msglevel, "Error parsing element %s\n", desc->name);
  ------------------
  |  |   86|    380|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  641|    419|    return 0;
  642|    482|}
ebml.c:ebml_parse_element:
  327|    419|{
  328|    419|    mp_assert(type->type == EBML_TYPE_SUBELEMENTS);
  ------------------
  |  |   41|    419|#define mp_assert assert
  ------------------
  |  Branch (328:5): [True: 419, False: 0]
  ------------------
  329|    419|    mp_assert(level < 8);
  ------------------
  |  |   41|    419|#define mp_assert assert
  ------------------
  |  Branch (329:5): [True: 419, False: 0]
  ------------------
  330|    419|    MP_TRACE(ctx, "%.*sParsing element %s\n", level, "       ", type->name);
  ------------------
  |  |   94|    419|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    419|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  331|       |
  332|    419|    char *s = target;
  333|    419|    uint8_t *end = data + size;
  334|    419|    uint8_t *p = data;
  335|    419|    int num_elems[MAX_EBML_SUBELEMENTS] = {0};
  336|  2.03k|    while (p < end) {
  ------------------
  |  Branch (336:12): [True: 1.68k, False: 353]
  ------------------
  337|  1.68k|        uint8_t *startp = p;
  338|  1.68k|        int len;
  339|  1.68k|        uint32_t id = ebml_parse_id(p, end - p, &len);
  340|  1.68k|        if (len > end - p)
  ------------------
  |  Branch (340:13): [True: 5, False: 1.68k]
  ------------------
  341|      5|            goto past_end_error;
  342|  1.68k|        if (len < 0) {
  ------------------
  |  Branch (342:13): [True: 11, False: 1.66k]
  ------------------
  343|     11|            MP_ERR(ctx, "Error parsing subelement id\n");
  ------------------
  |  |   89|     11|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  344|     11|            goto other_error;
  345|     11|        }
  346|  1.66k|        p += len;
  347|  1.66k|        uint64_t length = ebml_parse_length(p, end - p, &len);
  348|  1.66k|        if (len > end - p)
  ------------------
  |  Branch (348:13): [True: 0, False: 1.66k]
  ------------------
  349|      0|            goto past_end_error;
  350|  1.66k|        if (len < 0) {
  ------------------
  |  Branch (350:13): [True: 50, False: 1.61k]
  ------------------
  351|     50|            MP_ERR(ctx, "Error parsing subelement length\n");
  ------------------
  |  |   89|     50|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     50|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  352|     50|            goto other_error;
  353|     50|        }
  354|  1.61k|        p += len;
  355|       |
  356|  1.61k|        int field_idx = -1;
  357|  12.9k|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (357:25): [True: 11.3k, False: 1.61k]
  ------------------
  358|  11.3k|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (358:17): [True: 0, False: 11.3k]
  ------------------
  359|      0|                field_idx = i;
  360|      0|                num_elems[i]++;
  361|      0|                if (num_elems[i] >= 0x70000000) {
  ------------------
  |  Branch (361:21): [True: 0, False: 0]
  ------------------
  362|      0|                    MP_ERR(ctx, "Too many EBML subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  363|      0|                    goto other_error;
  364|      0|                }
  365|      0|                break;
  366|      0|            }
  367|       |
  368|  1.61k|        if (length > end - p) {
  ------------------
  |  Branch (368:13): [True: 314, False: 1.30k]
  ------------------
  369|    314|            if (field_idx >= 0 && type->fields[field_idx].desc->type
  ------------------
  |  Branch (369:17): [True: 0, False: 314]
  |  Branch (369:35): [True: 0, False: 0]
  ------------------
  370|      0|                != EBML_TYPE_SUBELEMENTS) {
  371|      0|                MP_ERR(ctx, "Subelement content goes "
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  372|      0|                       "past end of containing element\n");
  373|      0|                goto other_error;
  374|      0|            }
  375|       |            // Try to parse what is possible from inside this partial element
  376|    314|            ctx->has_errors = true;
  377|    314|            length = end - p;
  378|    314|        }
  379|  1.61k|        p += length;
  380|       |
  381|  1.61k|        continue;
  382|       |
  383|      5|    past_end_error:
  384|      5|        MP_ERR(ctx, "Subelement headers go past end of containing element\n");
  ------------------
  |  |   89|      5|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  385|     66|    other_error:
  386|     66|        ctx->has_errors = true;
  387|     66|        end = startp;
  388|     66|        break;
  389|      5|    }
  390|       |
  391|  3.35k|    for (int i = 0; i < type->field_count; i++) {
  ------------------
  |  Branch (391:21): [True: 2.93k, False: 419]
  ------------------
  392|  2.93k|        if (num_elems[i] && type->fields[i].multiple) {
  ------------------
  |  Branch (392:13): [True: 0, False: 2.93k]
  |  Branch (392:29): [True: 0, False: 0]
  ------------------
  393|      0|            char *ptr = s + type->fields[i].offset;
  394|      0|            switch (type->fields[i].desc->type) {
  395|      0|            case EBML_TYPE_SUBELEMENTS: {
  ------------------
  |  Branch (395:13): [True: 0, False: 0]
  ------------------
  396|      0|                size_t max = 1000000000 / type->fields[i].desc->size;
  397|      0|                if (num_elems[i] > max) {
  ------------------
  |  Branch (397:21): [True: 0, False: 0]
  ------------------
  398|      0|                    MP_ERR(ctx, "Too many subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  399|      0|                    num_elems[i] = max;
  400|      0|                }
  401|      0|                int sz = num_elems[i] * type->fields[i].desc->size;
  402|      0|                *(generic_struct **) ptr = talloc_zero_size(ctx->talloc_ctx, sz);
  ------------------
  |  |   44|      0|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|      0|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|      0|                break;
  404|      0|            }
  405|      0|            case EBML_TYPE_UINT:
  ------------------
  |  Branch (405:13): [True: 0, False: 0]
  ------------------
  406|      0|                *(uint64_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  407|      0|                                                       uint64_t, num_elems[i]);
  408|      0|                break;
  409|      0|            case EBML_TYPE_SINT:
  ------------------
  |  Branch (409:13): [True: 0, False: 0]
  ------------------
  410|      0|                *(int64_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|      0|                                                      int64_t, num_elems[i]);
  412|      0|                break;
  413|      0|            case EBML_TYPE_FLOAT:
  ------------------
  |  Branch (413:13): [True: 0, False: 0]
  ------------------
  414|      0|                *(double **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|      0|                                                     double, num_elems[i]);
  416|      0|                break;
  417|      0|            case EBML_TYPE_STR:
  ------------------
  |  Branch (417:13): [True: 0, False: 0]
  ------------------
  418|      0|                *(char ***) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|      0|                                                    char *, num_elems[i]);
  420|      0|                break;
  421|      0|            case EBML_TYPE_BINARY:
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|      0|                *(struct bstr **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|      0|                                                          struct bstr,
  424|      0|                                                          num_elems[i]);
  425|      0|                break;
  426|      0|            case EBML_TYPE_EBML_ID:
  ------------------
  |  Branch (426:13): [True: 0, False: 0]
  ------------------
  427|      0|                *(int32_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|      0|                                                      uint32_t, num_elems[i]);
  429|      0|                break;
  430|      0|            default:
  ------------------
  |  Branch (430:13): [True: 0, False: 0]
  ------------------
  431|      0|                MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (431:17): [Folded, False: 0]
  ------------------
  432|      0|            }
  433|      0|        }
  434|  2.93k|    }
  435|       |
  436|  2.03k|    while (data < end) {
  ------------------
  |  Branch (436:12): [True: 1.61k, False: 419]
  ------------------
  437|  1.61k|        int len;
  438|  1.61k|        uint32_t id = ebml_parse_id(data, end - data, &len);
  439|  1.61k|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (439:13): [True: 0, False: 1.61k]
  |  Branch (439:24): [True: 0, False: 1.61k]
  ------------------
  440|      0|            MP_ERR(ctx, "Error parsing subelement\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  441|      0|            break;
  442|      0|        }
  443|  1.61k|        data += len;
  444|  1.61k|        uint64_t length = ebml_parse_length(data, end - data, &len);
  445|  1.61k|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (445:13): [True: 0, False: 1.61k]
  |  Branch (445:24): [True: 0, False: 1.61k]
  ------------------
  446|      0|            MP_ERR(ctx, "Error parsing subelement length\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  447|      0|            break;
  448|      0|        }
  449|  1.61k|        data += len;
  450|  1.61k|        if (length > end - data) {
  ------------------
  |  Branch (450:13): [True: 314, False: 1.30k]
  ------------------
  451|       |            // Try to parse what is possible from inside this partial element
  452|    314|            length = end - data;
  453|    314|            MP_ERR(ctx, "Next subelement content goes "
  ------------------
  |  |   89|    314|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    314|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  454|    314|                   "past end of containing element, will be truncated\n");
  455|    314|        }
  456|  1.61k|        int field_idx = -1;
  457|  12.9k|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (457:25): [True: 11.3k, False: 1.61k]
  ------------------
  458|  11.3k|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (458:17): [True: 0, False: 11.3k]
  ------------------
  459|      0|                field_idx = i;
  460|      0|                break;
  461|      0|            }
  462|  1.61k|        if (field_idx < 0) {
  ------------------
  |  Branch (462:13): [True: 1.61k, False: 0]
  ------------------
  463|  1.61k|            if (id == 0xec) {
  ------------------
  |  Branch (463:17): [True: 17, False: 1.60k]
  ------------------
  464|     17|                MP_TRACE(ctx, "%.*sIgnoring Void element "
  ------------------
  |  |   94|     17|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     17|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  465|     17|                         "size: %"PRIu64"\n", level+1, "        ", length);
  466|  1.60k|            } else if (id == 0xbf) {
  ------------------
  |  Branch (466:24): [True: 104, False: 1.49k]
  ------------------
  467|    104|                MP_TRACE(ctx, "%.*sIgnoring CRC-32 "
  ------------------
  |  |   94|    104|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    104|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  468|    104|                         "element size: %"PRIu64"\n", level+1, "        ",
  469|    104|                         length);
  470|  1.49k|            } else {
  471|  1.49k|                MP_DBG(ctx, "Ignoring unrecognized "
  ------------------
  |  |   93|  1.49k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.49k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  472|  1.49k|                       "subelement. ID: %x size: %"PRIu64"\n", id, length);
  473|  1.49k|            }
  474|  1.61k|            data += length;
  475|  1.61k|            continue;
  476|  1.61k|        }
  477|      0|        const struct ebml_field_desc *fd = &type->fields[field_idx];
  478|      0|        const struct ebml_elem_desc *ed = fd->desc;
  479|      0|        bool multiple = fd->multiple;
  480|      0|        int *countptr = (int *) (s + fd->count_offset);
  481|      0|        if (*countptr >= num_elems[field_idx]) {
  ------------------
  |  Branch (481:13): [True: 0, False: 0]
  ------------------
  482|       |            // Shouldn't happen on any sane file without bugs
  483|      0|            MP_ERR(ctx, "Too many subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|      0|            ctx->has_errors = true;
  485|      0|            data += length;
  486|      0|            continue;
  487|      0|        }
  488|      0|        if (*countptr > 0 && !multiple) {
  ------------------
  |  Branch (488:13): [True: 0, False: 0]
  |  Branch (488:30): [True: 0, False: 0]
  ------------------
  489|      0|            MP_WARN(ctx, "Another subelement of type "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|      0|                    "%x %s (size: %"PRIu64"). Only one allowed. Ignoring.\n",
  491|      0|                    id, ed->name, length);
  492|      0|            ctx->has_errors = true;
  493|      0|            data += length;
  494|      0|            continue;
  495|      0|        }
  496|      0|        MP_TRACE(ctx, "%.*sParsing %x %s size: %"PRIu64
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|      0|                 " value: ", level+1, "        ", id, ed->name, length);
  498|       |
  499|      0|        char *fieldptr = s + fd->offset;
  500|      0|        switch (ed->type) {
  501|      0|        case EBML_TYPE_SUBELEMENTS:
  ------------------
  |  Branch (501:9): [True: 0, False: 0]
  ------------------
  502|      0|            MP_TRACE(ctx, "subelements\n");
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  503|      0|            char *subelptr;
  504|      0|            if (multiple) {
  ------------------
  |  Branch (504:17): [True: 0, False: 0]
  ------------------
  505|      0|                char *array_start = (char *) *(generic_struct **) fieldptr;
  506|      0|                subelptr = array_start + *countptr * ed->size;
  507|      0|            } else
  508|      0|                subelptr = fieldptr;
  509|      0|            ebml_parse_element(ctx, subelptr, data, length, ed, level + 1);
  510|      0|            break;
  511|       |
  512|      0|        case EBML_TYPE_UINT:;
  ------------------
  |  Branch (512:9): [True: 0, False: 0]
  ------------------
  513|      0|            uint64_t *uintptr;
  514|      0|#define GETPTR(subelptr, fieldtype)                                     \
  515|      0|            if (multiple)                                               \
  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  517|      0|            else                                                        \
  518|      0|                subelptr = (fieldtype *) fieldptr
  519|      0|            GETPTR(uintptr, uint64_t);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  520|      0|            if (length > 8) {
  ------------------
  |  Branch (520:17): [True: 0, False: 0]
  ------------------
  521|      0|                MP_ERR(ctx, "uint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  522|      0|                goto error;
  523|      0|            }
  524|      0|            if (!length && ed->context_default)
  ------------------
  |  Branch (524:17): [True: 0, False: 0]
  |  Branch (524:28): [True: 0, False: 0]
  ------------------
  525|      0|                goto skip;
  526|      0|            *uintptr = length ? ebml_parse_uint(data, length) : ed->defval.u;
  ------------------
  |  Branch (526:24): [True: 0, False: 0]
  ------------------
  527|      0|            MP_TRACE(ctx, "uint %"PRIu64"\n", *uintptr);
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  528|      0|            break;
  529|       |
  530|      0|        case EBML_TYPE_SINT:;
  ------------------
  |  Branch (530:9): [True: 0, False: 0]
  ------------------
  531|      0|            int64_t *sintptr;
  532|      0|            GETPTR(sintptr, int64_t);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  533|      0|            if (length > 8) {
  ------------------
  |  Branch (533:17): [True: 0, False: 0]
  ------------------
  534|      0|                MP_ERR(ctx, "sint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  535|      0|                goto error;
  536|      0|            }
  537|      0|            if (!length && ed->context_default)
  ------------------
  |  Branch (537:17): [True: 0, False: 0]
  |  Branch (537:28): [True: 0, False: 0]
  ------------------
  538|      0|                goto skip;
  539|      0|            *sintptr = length ? ebml_parse_sint(data, length) : ed->defval.i;
  ------------------
  |  Branch (539:24): [True: 0, False: 0]
  ------------------
  540|      0|            MP_TRACE(ctx, "sint %"PRId64"\n", *sintptr);
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  541|      0|            break;
  542|       |
  543|      0|        case EBML_TYPE_FLOAT:;
  ------------------
  |  Branch (543:9): [True: 0, False: 0]
  ------------------
  544|      0|            double *floatptr;
  545|      0|            GETPTR(floatptr, double);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  546|      0|            if (length != 0 && length != 4 && length != 8) {
  ------------------
  |  Branch (546:17): [True: 0, False: 0]
  |  Branch (546:32): [True: 0, False: 0]
  |  Branch (546:47): [True: 0, False: 0]
  ------------------
  547|      0|                MP_ERR(ctx, "float invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  548|      0|                goto error;
  549|      0|            }
  550|      0|            if (!length && ed->context_default)
  ------------------
  |  Branch (550:17): [True: 0, False: 0]
  |  Branch (550:28): [True: 0, False: 0]
  ------------------
  551|      0|                goto skip;
  552|      0|            *floatptr = length ? ebml_parse_float(data, length) : ed->defval.f;
  ------------------
  |  Branch (552:25): [True: 0, False: 0]
  ------------------
  553|      0|            MP_DBG(ctx, "float %f\n", *floatptr);
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  554|      0|            break;
  555|       |
  556|      0|        case EBML_TYPE_STR:
  ------------------
  |  Branch (556:9): [True: 0, False: 0]
  ------------------
  557|      0|            if (length > 1024 * 1024) {
  ------------------
  |  Branch (557:17): [True: 0, False: 0]
  ------------------
  558|      0|                MP_ERR(ctx, "Not reading overly long string element.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  559|      0|                goto error;
  560|      0|            }
  561|      0|            char **strptr;
  562|      0|            GETPTR(strptr, char *);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  563|      0|            if (!length && ed->context_default)
  ------------------
  |  Branch (563:17): [True: 0, False: 0]
  |  Branch (563:28): [True: 0, False: 0]
  ------------------
  564|      0|                goto skip;
  565|      0|            if (!length && ed->defval.s) {
  ------------------
  |  Branch (565:17): [True: 0, False: 0]
  |  Branch (565:28): [True: 0, False: 0]
  ------------------
  566|      0|                *strptr = talloc_strdup(ctx->talloc_ctx, ed->defval.s);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  567|      0|            } else {
  568|      0|                *strptr = talloc_strndup(ctx->talloc_ctx, data, length);
  ------------------
  |  |   51|      0|#define talloc_strndup                  ta_xstrndup
  ------------------
  569|      0|            }
  570|      0|            MP_TRACE(ctx, "string \"%s\"\n", *strptr);
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  571|      0|            break;
  572|       |
  573|      0|        case EBML_TYPE_BINARY:;
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  ------------------
  574|      0|            if (length > 0x80000000) {
  ------------------
  |  Branch (574:17): [True: 0, False: 0]
  ------------------
  575|      0|                MP_ERR(ctx, "Not reading overly long EBML element.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  576|      0|                goto error;
  577|      0|            }
  578|      0|            if (ed->size && length != ed->size) {
  ------------------
  |  Branch (578:17): [True: 0, False: 0]
  |  Branch (578:29): [True: 0, False: 0]
  ------------------
  579|      0|                MP_WARN(ctx, "%s invalid length %"PRIu64", ignoring\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  580|      0|                        ed->name, length);
  581|      0|                goto error;
  582|      0|            }
  583|      0|            struct bstr *binptr;
  584|      0|            GETPTR(binptr, struct bstr);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  585|      0|            binptr->start = data;
  586|      0|            binptr->len = length;
  587|      0|            MP_TRACE(ctx, "binary %zd bytes\n", binptr->len);
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  588|      0|            break;
  589|       |
  590|      0|        case EBML_TYPE_EBML_ID:;
  ------------------
  |  Branch (590:9): [True: 0, False: 0]
  ------------------
  591|      0|            uint32_t *idptr;
  592|      0|            GETPTR(idptr, uint32_t);
  ------------------
  |  |  515|      0|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  516|      0|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|      0|            else                                                        \
  |  |  518|      0|                subelptr = (fieldtype *) fieldptr
  ------------------
  593|      0|            *idptr = ebml_parse_id(data, end - data, &len);
  594|      0|            if (len != length) {
  ------------------
  |  Branch (594:17): [True: 0, False: 0]
  ------------------
  595|      0|                MP_ERR(ctx, "ebml_id broken value\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  596|      0|                goto error;
  597|      0|            }
  598|      0|            MP_TRACE(ctx, "ebml_id %x\n", (unsigned)*idptr);
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  599|      0|            break;
  600|      0|        default:
  ------------------
  |  Branch (600:9): [True: 0, False: 0]
  ------------------
  601|      0|            MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (601:13): [Folded, False: 0]
  ------------------
  602|      0|        }
  603|      0|        *countptr += 1;
  604|      0|    error:
  605|      0|    skip:
  606|      0|        data += length;
  607|      0|    }
  608|    419|}
ebml.c:ebml_parse_id:
  238|  3.30k|{
  239|  3.30k|    *length = -1;
  240|  3.30k|    uint8_t *end = data + data_len;
  241|  3.30k|    if (data == end)
  ------------------
  |  Branch (241:9): [True: 0, False: 3.30k]
  ------------------
  242|      0|        return EBML_ID_INVALID;
  ------------------
  |  |   75|      0|#define EBML_ID_INVALID 0xffffffff
  ------------------
  243|  3.30k|    int len = 1;
  244|  3.30k|    uint32_t id = *data++;
  245|  4.59k|    for (int len_mask = 0x80; !(id & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (245:31): [True: 1.29k, False: 3.29k]
  ------------------
  246|  1.29k|        len++;
  247|  1.29k|        if (len > 4)
  ------------------
  |  Branch (247:13): [True: 11, False: 1.28k]
  ------------------
  248|     11|            return EBML_ID_INVALID;
  ------------------
  |  |   75|     11|#define EBML_ID_INVALID 0xffffffff
  ------------------
  249|  1.29k|    }
  250|  3.29k|    *length = len;
  251|  4.54k|    while (--len && data < end)
  ------------------
  |  Branch (251:12): [True: 1.25k, False: 3.28k]
  |  Branch (251:21): [True: 1.24k, False: 5]
  ------------------
  252|  1.24k|        id = (id << 8) | *data++;
  253|  3.29k|    return id;
  254|  3.30k|}
ebml.c:ebml_parse_length:
  257|  3.28k|{
  258|  3.28k|    *length = -1;
  259|  3.28k|    uint8_t *end = data + data_len;
  260|  3.28k|    if (data == end)
  ------------------
  |  Branch (260:9): [True: 11, False: 3.27k]
  ------------------
  261|     11|        return -1;
  262|  3.27k|    uint64_t r = *data++;
  263|  3.27k|    int len = 1;
  264|  3.27k|    int len_mask;
  265|  5.12k|    for (len_mask = 0x80; !(r & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (265:27): [True: 1.85k, False: 3.27k]
  ------------------
  266|  1.85k|        len++;
  267|  1.85k|        if (len > 8)
  ------------------
  |  Branch (267:13): [True: 0, False: 1.85k]
  ------------------
  268|      0|            return -1;
  269|  1.85k|    }
  270|  3.27k|    r &= len_mask - 1;
  271|       |
  272|  3.27k|    int num_allones = 0;
  273|  3.27k|    if (r == len_mask - 1)
  ------------------
  |  Branch (273:9): [True: 176, False: 3.10k]
  ------------------
  274|    176|        num_allones++;
  275|  5.12k|    for (int i = 1; i < len; i++) {
  ------------------
  |  Branch (275:21): [True: 1.84k, False: 3.27k]
  ------------------
  276|  1.84k|        if (data == end)
  ------------------
  |  Branch (276:13): [True: 5, False: 1.84k]
  ------------------
  277|      5|            return -1;
  278|  1.84k|        if (*data == 255)
  ------------------
  |  Branch (278:13): [True: 624, False: 1.22k]
  ------------------
  279|    624|            num_allones++;
  280|  1.84k|        r = (r << 8) | *data++;
  281|  1.84k|    }
  282|       |    // According to Matroska specs this means "unknown length"
  283|       |    // Could be supported if there are any actual files using it
  284|  3.27k|    if (num_allones == len)
  ------------------
  |  Branch (284:9): [True: 34, False: 3.23k]
  ------------------
  285|     34|        return -1;
  286|  3.23k|    *length = len;
  287|  3.23k|    return r;
  288|  3.27k|}

demux_packet_unref_contents:
   48|  1.48M|{
   49|  1.48M|    if (dp->avpacket) {
  ------------------
  |  Branch (49:9): [True: 1.48M, False: 18.4E]
  ------------------
   50|  1.48M|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|  1.48M|#define mp_assert assert
  ------------------
  |  Branch (50:9): [True: 1.48M, False: 1]
  ------------------
   51|  1.48M|        av_packet_free(&dp->avpacket);
   52|  1.48M|        dp->buffer = NULL;
   53|  1.48M|        dp->len = 0;
   54|       |        dp->is_wrapped_avframe = false;
   55|  1.48M|    }
   56|  1.48M|}
demux_packet_unref:
   81|  4.22M|{
   82|  4.22M|    if (!dp)
  ------------------
  |  Branch (82:9): [True: 1.48M, False: 2.74M]
  ------------------
   83|  1.48M|        return;
   84|  2.74M|    struct AVPacket *avpkt = dp->avpacket;
   85|  2.74M|    if (avpkt)
  ------------------
  |  Branch (85:9): [True: 2.74M, False: 18.4E]
  ------------------
   86|  2.74M|        av_packet_unref(avpkt);
   87|  2.74M|    ta_free_children(dp);
   88|  2.74M|    set_packet_defaults(dp);
   89|  2.74M|    dp->avpacket = avpkt;
   90|  2.74M|}
new_demux_packet_from_avpacket:
  111|  2.84M|{
  112|  2.84M|    if (avpkt->size > 1000000000)
  ------------------
  |  Branch (112:9): [True: 0, False: 2.84M]
  ------------------
  113|      0|        return NULL;
  114|  2.84M|    struct demux_packet *dp = packet_create(pool);
  115|  2.84M|    int r = -1;
  116|  2.84M|    if (avpkt->data) {
  ------------------
  |  Branch (116:9): [True: 2.84M, False: 18.4E]
  ------------------
  117|       |        // We hope that this function won't need/access AVPacket input padding,
  118|       |        // because otherwise new_demux_packet_from() wouldn't work.
  119|  2.84M|        r = av_packet_ref(dp->avpacket, avpkt);
  120|  18.4E|    } else {
  121|  18.4E|        r = av_new_packet(dp->avpacket, avpkt->size);
  122|  18.4E|    }
  123|  2.84M|    if (r < 0) {
  ------------------
  |  Branch (123:9): [True: 0, False: 2.84M]
  ------------------
  124|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  125|      0|        return NULL;
  126|      0|    }
  127|  2.84M|    dp->buffer = dp->avpacket->data;
  128|  2.84M|    dp->len = dp->avpacket->size;
  129|  2.84M|    return dp;
  130|  2.84M|}
new_demux_packet_from_buf:
  135|  43.7k|{
  136|  43.7k|    if (!buf)
  ------------------
  |  Branch (136:9): [True: 43.7k, False: 0]
  ------------------
  137|  43.7k|        return NULL;
  138|      0|    if (buf->size > 1000000000)
  ------------------
  |  Branch (138:9): [True: 0, False: 0]
  ------------------
  139|      0|        return NULL;
  140|       |
  141|      0|    struct demux_packet *dp = packet_create(pool);
  142|      0|    dp->avpacket->buf = av_buffer_ref(buf);
  143|      0|    if (!dp->avpacket->buf) {
  ------------------
  |  Branch (143:9): [True: 0, False: 0]
  ------------------
  144|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        return NULL;
  146|      0|    }
  147|      0|    dp->avpacket->data = dp->buffer = buf->data;
  148|      0|    dp->avpacket->size = dp->len = buf->size;
  149|      0|    return dp;
  150|      0|}
new_demux_packet:
  163|  1.04k|{
  164|  1.04k|    if (len > INT_MAX)
  ------------------
  |  Branch (164:9): [True: 0, False: 1.04k]
  ------------------
  165|      0|        return NULL;
  166|       |
  167|  1.04k|    struct demux_packet *dp = packet_create(pool);
  168|  1.04k|    int r = av_new_packet(dp->avpacket, len);
  169|  1.04k|    if (r < 0) {
  ------------------
  |  Branch (169:9): [True: 0, False: 1.04k]
  ------------------
  170|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  171|      0|        return NULL;
  172|      0|    }
  173|  1.04k|    dp->buffer = dp->avpacket->data;
  174|  1.04k|    dp->len = len;
  175|  1.04k|    return dp;
  176|  1.04k|}
free_demux_packet:
  188|  1.41M|{
  189|  1.41M|    talloc_free(dp);
  ------------------
  |  |   47|  1.41M|#define talloc_free                     ta_free
  ------------------
  190|  1.41M|}
demux_packet_copy_attribs:
  193|  1.37M|{
  194|  1.37M|    dst->pts = src->pts;
  195|  1.37M|    dst->dts = src->dts;
  196|  1.37M|    dst->duration = src->duration;
  197|  1.37M|    dst->pos = src->pos;
  198|  1.37M|    dst->is_wrapped_avframe = src->is_wrapped_avframe;
  199|  1.37M|    dst->segmented = src->segmented;
  200|  1.37M|    dst->start = src->start;
  201|  1.37M|    dst->end = src->end;
  202|  1.37M|    dst->codec = src->codec;
  203|  1.37M|    dst->back_restart = src->back_restart;
  204|  1.37M|    dst->back_preroll = src->back_preroll;
  205|  1.37M|    dst->keyframe = src->keyframe;
  206|  1.37M|    dst->stream = src->stream;
  207|  1.37M|}
demux_copy_packet:
  210|  1.37M|{
  211|  1.37M|    struct demux_packet *new = NULL;
  212|  1.37M|    if (dp->avpacket) {
  ------------------
  |  Branch (212:9): [True: 1.37M, False: 0]
  ------------------
  213|  1.37M|        new = new_demux_packet_from_avpacket(pool, dp->avpacket);
  214|  1.37M|    } else {
  215|       |        // Some packets might be not created by new_demux_packet*().
  216|      0|        new = new_demux_packet_from(pool, dp->buffer, dp->len);
  217|      0|    }
  218|  1.37M|    if (!new)
  ------------------
  |  Branch (218:9): [True: 0, False: 1.37M]
  ------------------
  219|      0|        return NULL;
  220|  1.37M|    demux_packet_copy_attribs(new, dp);
  221|  1.37M|    return new;
  222|  1.37M|}
demux_packet_estimate_total_size:
  235|  1.40M|{
  236|  1.40M|    size_t size = ROUND_ALLOC(sizeof(struct demux_packet));
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  237|  1.40M|    size += 8 * sizeof(void *); // ta  overhead
  238|  1.40M|    size += 10 * sizeof(void *); // additional estimate for ta_ext_header
  239|  1.40M|    if (dp->avpacket) {
  ------------------
  |  Branch (239:9): [True: 1.40M, False: 0]
  ------------------
  240|  1.40M|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|  1.40M|#define mp_assert assert
  ------------------
  |  Branch (240:9): [True: 1.40M, False: 0]
  ------------------
  241|  1.40M|        size += ROUND_ALLOC(dp->len);
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  242|  1.40M|        if (dp->is_wrapped_avframe) {
  ------------------
  |  Branch (242:13): [True: 0, False: 1.40M]
  ------------------
  243|      0|            mp_require(dp->buffer);
  ------------------
  |  |   42|      0|#define mp_require assert
  ------------------
  |  Branch (243:13): [True: 0, False: 0]
  ------------------
  244|       |
  245|      0|            const AVFrame *frame = (AVFrame *)dp->buffer;
  246|      0|            if (frame->hw_frames_ctx) {
  ------------------
  |  Branch (246:17): [True: 0, False: 0]
  ------------------
  247|      0|                const AVHWFramesContext *hwctx = (AVHWFramesContext *)frame->hw_frames_ctx->data;
  248|      0|                int r = av_image_get_buffer_size(hwctx->sw_format, hwctx->width, hwctx->height, 16);
  249|      0|                mp_require(r >= 0);
  ------------------
  |  |   42|      0|#define mp_require assert
  ------------------
  |  Branch (249:17): [True: 0, False: 0]
  ------------------
  250|      0|                size += ROUND_ALLOC(r);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  251|      0|            }
  252|      0|            for (int i = 0; i < MP_ARRAY_SIZE(frame->buf) && frame->buf[i]; ++i)
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (252:29): [True: 0, False: 0]
  |  Branch (252:62): [True: 0, False: 0]
  ------------------
  253|      0|                size += ROUND_ALLOC(frame->buf[i]->size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  254|       |
  255|      0|            size += ROUND_ALLOC(frame->nb_extended_buf * sizeof(frame->extended_buf[0]));
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  256|      0|            for (int i = 0; i < frame->nb_extended_buf; ++i) {
  ------------------
  |  Branch (256:29): [True: 0, False: 0]
  ------------------
  257|      0|                size += ROUND_ALLOC(sizeof(*frame->extended_buf[i]));
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  258|      0|                size += ROUND_ALLOC(frame->extended_buf[i]->size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  259|      0|            }
  260|       |
  261|      0|            size += ROUND_ALLOC(frame->nb_side_data * sizeof(frame->side_data[0]));
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  262|      0|            for (int i = 0; i < frame->nb_side_data; ++i) {
  ------------------
  |  Branch (262:29): [True: 0, False: 0]
  ------------------
  263|      0|                size += ROUND_ALLOC(sizeof(*frame->side_data[i]));
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  264|      0|                size += ROUND_ALLOC(frame->side_data[i]->size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|      0|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  265|      0|            }
  266|      0|        }
  267|  1.40M|        size += ROUND_ALLOC(sizeof(AVPacket));
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  268|  1.40M|        size += 8 * sizeof(void *); // ta  overhead
  269|  1.40M|        size += ROUND_ALLOC(sizeof(AVBufferRef));
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  270|  1.40M|        size += ROUND_ALLOC(64); // upper bound estimate on sizeof(AVBuffer)
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  271|  1.40M|        size += ROUND_ALLOC(dp->avpacket->side_data_elems *
  ------------------
  |  |  224|  1.40M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  272|  1.40M|                            sizeof(dp->avpacket->side_data[0]));
  273|  1.40M|        for (int n = 0; n < dp->avpacket->side_data_elems; n++)
  ------------------
  |  Branch (273:25): [True: 0, False: 1.40M]
  ------------------
  274|  1.40M|            size += ROUND_ALLOC(dp->avpacket->side_data[n].size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.40M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  275|  1.40M|    }
  276|  1.40M|    return size;
  277|  1.40M|}
packet.c:set_packet_defaults:
   65|  4.22M|{
   66|  4.22M|    *dp = (struct demux_packet) {
   67|  4.22M|        .pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.22M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   68|  4.22M|        .dts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.22M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   69|  4.22M|        .duration = -1,
   70|  4.22M|        .pos = -1,
   71|  4.22M|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.22M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   72|  4.22M|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.22M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   73|  4.22M|        .stream = -1,
   74|  4.22M|        .animated = -1,
   75|  4.22M|    };
   76|  4.22M|}
packet.c:packet_create:
   93|  2.84M|{
   94|  2.84M|    struct demux_packet *dp = pool ? demux_packet_pool_pop(pool) : NULL;
  ------------------
  |  Branch (94:31): [True: 2.84M, False: 18.4E]
  ------------------
   95|  2.84M|    if (!dp) {
  ------------------
  |  Branch (95:9): [True: 1.48M, False: 1.36M]
  ------------------
   96|  1.48M|        dp = talloc(NULL, struct demux_packet);
  ------------------
  |  |   26|  1.48M|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  1.48M|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.48M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   97|  1.48M|        talloc_set_destructor(dp, packet_destroy);
  ------------------
  |  |   41|  1.48M|#define talloc_set_destructor           ta_set_destructor
  ------------------
   98|  1.48M|        set_packet_defaults(dp);
   99|  1.48M|    }
  100|  2.84M|    if (!dp->avpacket)
  ------------------
  |  Branch (100:9): [True: 1.48M, False: 1.36M]
  ------------------
  101|  1.48M|        dp->avpacket = av_packet_alloc();
  102|  2.84M|    MP_HANDLE_OOM(dp->avpacket);
  ------------------
  |  |  206|  2.84M|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  2.84M|        void *oom_p_ = (x);     \
  |  |  208|  2.84M|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 2.84M]
  |  |  ------------------
  |  |  209|  2.84M|            abort();            \
  |  |  210|  2.84M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 2.84M]
  |  |  ------------------
  ------------------
  103|  2.84M|    return dp;
  104|  2.84M|}
packet.c:packet_destroy:
   59|  1.48M|{
   60|  1.48M|    struct demux_packet *dp = ptr;
   61|  1.48M|    demux_packet_unref_contents(dp);
   62|  1.48M|}

demux_packet_pool_init:
   50|  28.9k|{
   51|  28.9k|    struct demux_packet_pool *pool = talloc(global, struct demux_packet_pool);
  ------------------
  |  |   26|  28.9k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  28.9k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   52|  28.9k|    talloc_set_destructor(pool, uninit);
  ------------------
  |  |   41|  28.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   53|  28.9k|    mp_mutex_init(&pool->lock);
   54|  28.9k|    pool->packets = NULL;
   55|       |
   56|  28.9k|    mp_assert(!global->packet_pool);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 28.9k, False: 0]
  ------------------
   57|  28.9k|    global->packet_pool = pool;
   58|  28.9k|}
demux_packet_pool_get:
   61|  1.33M|{
   62|       |    // Currently all clients use the same packet pool. There is no additional
   63|       |    // state for each client, may be extended in the future.
   64|  1.33M|    return global->packet_pool;
   65|  1.33M|}
demux_packet_pool_clear:
   68|  86.7k|{
   69|  86.7k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  86.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   70|  86.7k|    struct demux_packet *dp = pool->packets;
   71|  86.7k|    pool->packets = NULL;
   72|  86.7k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  86.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   73|  86.7k|    free_demux_packets(dp);
   74|  86.7k|}
demux_packet_pool_push:
   78|  1.39M|{
   79|  1.39M|    if (!dp)
  ------------------
  |  Branch (79:9): [True: 13.5k, False: 1.37M]
  ------------------
   80|  13.5k|        return;
   81|  1.37M|    dp->next = NULL;
   82|       |    // On single packet push, clear instantly. Unlike prepend, where multiple
   83|       |    // packets may be prepended at once, there is no performance issue with
   84|       |    // clearing a single packet here.
   85|  1.37M|    demux_packet_unref(dp);
   86|  1.37M|    demux_packet_pool_prepend(pool, dp, dp);
   87|  1.37M|}
demux_packet_pool_prepend:
   91|  1.45M|{
   92|  1.45M|    if (!head)
  ------------------
  |  Branch (92:9): [True: 60.8k, False: 1.39M]
  ------------------
   93|  60.8k|        return;
   94|  1.39M|    mp_assert(tail);
  ------------------
  |  |   41|  1.39M|#define mp_assert assert
  ------------------
  |  Branch (94:5): [True: 1.39M, False: 0]
  ------------------
   95|  1.39M|    mp_assert(head != tail ? !!head->next : !head->next);
  ------------------
  |  |   41|  1.39M|#define mp_assert assert
  ------------------
  |  Branch (95:5): [True: 7.38k, False: 1.38M]
  |  Branch (95:5): [True: 1.39M, False: 0]
  ------------------
   96|       |
   97|  1.39M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  1.39M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   98|  1.39M|    tail->next = pool->packets;
   99|  1.39M|    pool->packets = head;
  100|       |#if HAVE_DISABLE_PACKET_POOL
  101|       |    struct demux_packet *dp = pool->packets;
  102|       |    pool->packets = NULL;
  103|       |#endif
  104|  1.39M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  1.39M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  105|       |
  106|       |#if HAVE_DISABLE_PACKET_POOL
  107|       |    free_demux_packets(dp);
  108|       |#endif
  109|  1.39M|}
demux_packet_pool_pop:
  145|  2.84M|{
  146|  2.84M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  2.84M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  147|  2.84M|    struct demux_packet *dp = pool->packets;
  148|  2.84M|    if (dp) {
  ------------------
  |  Branch (148:9): [True: 1.36M, False: 1.48M]
  ------------------
  149|  1.36M|        pool->packets = dp->next;
  150|  1.36M|        dp->next = NULL;
  151|  1.36M|    }
  152|  2.84M|    struct demux_packet *gc = pool_gc_detach(pool);
  153|  2.84M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  2.84M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  154|       |
  155|       |    // Clear the popped packet's external references and drain a small batch
  156|       |    // of old pooled packets. Both costs are amortized across packet_create()
  157|       |    // calls so EOF / cache reset never has to free a huge list at once.
  158|  2.84M|    demux_packet_unref(dp);
  159|       |    // GC is done unlocked, this makes packets be iterated again, but that's
  160|       |    // should be fine, with POOL_GC_BATCH elements only.
  161|  2.84M|    free_demux_packets(gc);
  162|       |
  163|  2.84M|    return dp;
  164|  2.84M|}
packet_pool.c:uninit:
   34|  28.9k|{
   35|  28.9k|    struct demux_packet_pool *pool = p;
   36|  28.9k|    demux_packet_pool_clear(pool);
   37|  28.9k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   38|  28.9k|}
packet_pool.c:free_demux_packets:
   41|  2.93M|{
   42|  4.34M|    while (dp) {
  ------------------
  |  Branch (42:12): [True: 1.41M, False: 2.93M]
  ------------------
   43|  1.41M|        struct demux_packet *next = dp->next;
   44|  1.41M|        free_demux_packet(dp);
   45|  1.41M|        dp = next;
   46|  1.41M|    }
   47|  2.93M|}
packet_pool.c:pool_gc_detach:
  126|  2.84M|{
  127|  2.84M|    struct demux_packet *cat_reserve = pool->packets;
  128|  2.85M|    for (int i = 1; cat_reserve && i < POOL_HOT_RESERVE; i++)
  ------------------
  |  |  114|  6.20k|#define POOL_HOT_RESERVE 16
  ------------------
  |  Branch (128:21): [True: 6.20k, False: 2.84M]
  |  Branch (128:36): [True: 6.04k, False: 153]
  ------------------
  129|  6.04k|        cat_reserve = cat_reserve->next;
  130|       |
  131|  2.84M|    if (!cat_reserve || !cat_reserve->next)
  ------------------
  |  Branch (131:9): [True: 2.84M, False: 153]
  |  Branch (131:25): [True: 7, False: 146]
  ------------------
  132|  2.84M|        return NULL;
  133|       |
  134|    146|    struct demux_packet *gc = cat_reserve->next;
  135|    146|    struct demux_packet *cut_rest = gc;
  136|  8.22k|    for (int i = 1; cut_rest->next && i < POOL_GC_BATCH; i++)
  ------------------
  |  |  121|  8.19k|#define POOL_GC_BATCH 64
  ------------------
  |  Branch (136:21): [True: 8.19k, False: 29]
  |  Branch (136:39): [True: 8.07k, False: 117]
  ------------------
  137|  8.07k|        cut_rest = cut_rest->next;
  138|       |
  139|    146|    cat_reserve->next = cut_rest->next;
  140|       |    cut_rest->next = NULL;
  141|    146|    return gc;
  142|  2.84M|}

loadfile.c:sh_stream_dependent_sibling:
  107|  86.2k|{
  108|  86.2k|    if (!bl || !bl->group || bl->dependent_track)
  ------------------
  |  Branch (108:9): [True: 0, False: 86.2k]
  |  Branch (108:16): [True: 86.2k, False: 0]
  |  Branch (108:30): [True: 0, False: 0]
  ------------------
  109|  86.2k|        return NULL;
  110|      0|    if (bl->group->num_members != 2)
  ------------------
  |  Branch (110:9): [True: 0, False: 0]
  ------------------
  111|      0|        return NULL;
  112|      0|    for (int i = 0; i < bl->group->num_members; i++) {
  ------------------
  |  Branch (112:21): [True: 0, False: 0]
  ------------------
  113|      0|        struct sh_stream *m = bl->group->members[i];
  114|      0|        if (m && m != bl && m->dependent_track && m->type == bl->type)
  ------------------
  |  Branch (114:13): [True: 0, False: 0]
  |  Branch (114:18): [True: 0, False: 0]
  |  Branch (114:29): [True: 0, False: 0]
  |  Branch (114:51): [True: 0, False: 0]
  ------------------
  115|      0|            return m->absent ? NULL : m;
  ------------------
  |  Branch (115:20): [True: 0, False: 0]
  ------------------
  116|      0|    }
  117|      0|    return NULL;
  118|      0|}
video.c:sh_stream_dependent_sibling:
  107|  9.69k|{
  108|  9.69k|    if (!bl || !bl->group || bl->dependent_track)
  ------------------
  |  Branch (108:9): [True: 0, False: 9.69k]
  |  Branch (108:16): [True: 9.69k, False: 0]
  |  Branch (108:30): [True: 0, False: 0]
  ------------------
  109|  9.69k|        return NULL;
  110|      0|    if (bl->group->num_members != 2)
  ------------------
  |  Branch (110:9): [True: 0, False: 0]
  ------------------
  111|      0|        return NULL;
  112|      0|    for (int i = 0; i < bl->group->num_members; i++) {
  ------------------
  |  Branch (112:21): [True: 0, False: 0]
  ------------------
  113|      0|        struct sh_stream *m = bl->group->members[i];
  114|      0|        if (m && m != bl && m->dependent_track && m->type == bl->type)
  ------------------
  |  Branch (114:13): [True: 0, False: 0]
  |  Branch (114:18): [True: 0, False: 0]
  |  Branch (114:29): [True: 0, False: 0]
  |  Branch (114:51): [True: 0, False: 0]
  ------------------
  115|      0|            return m->absent ? NULL : m;
  ------------------
  |  Branch (115:20): [True: 0, False: 0]
  ------------------
  116|      0|    }
  117|      0|    return NULL;
  118|      0|}

timeline_load:
    9|  24.6k|{
   10|  24.6k|    if (!demuxer->desc->load_timeline)
  ------------------
  |  Branch (10:9): [True: 24.4k, False: 173]
  ------------------
   11|  24.4k|        return NULL;
   12|       |
   13|    173|    struct timeline *tl = talloc_ptrtype(NULL, tl);
  ------------------
  |  |   34|    173|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    173|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    173|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   14|    173|    *tl = (struct timeline){
   15|    173|        .global = global,
   16|    173|        .log = log,
   17|    173|        .cancel = demuxer->cancel,
   18|    173|        .demuxer = demuxer,
   19|    173|        .format = "unknown",
   20|    173|        .stream_origin = demuxer->stream_origin,
   21|    173|    };
   22|       |
   23|    173|    demuxer->desc->load_timeline(tl);
   24|       |
   25|    173|    if (tl->num_pars)
  ------------------
  |  Branch (25:9): [True: 0, False: 173]
  ------------------
   26|      0|        return tl;
   27|    173|    timeline_destroy(tl);
   28|       |    return NULL;
   29|    173|}
timeline_destroy:
   32|    173|{
   33|    173|    if (!tl)
  ------------------
  |  Branch (33:9): [True: 0, False: 173]
  ------------------
   34|      0|        return;
   35|    207|    for (int n = 0; n < tl->num_sources; n++) {
  ------------------
  |  Branch (35:21): [True: 34, False: 173]
  ------------------
   36|     34|        struct demuxer *d = tl->sources[n];
   37|     34|        if (d != tl->demuxer)
  ------------------
  |  Branch (37:13): [True: 0, False: 34]
  ------------------
   38|      0|            demux_free(d);
   39|     34|    }
   40|    173|    talloc_free(tl);
  ------------------
  |  |   47|    173|#define talloc_free                     ta_free
  ------------------
   41|    173|}

mp_async_queue_create:
   72|  7.92k|{
   73|  7.92k|    struct mp_async_queue *r = talloc_zero(NULL, struct mp_async_queue);
  ------------------
  |  |   27|  7.92k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  7.92k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  7.92k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   74|  7.92k|    r->q = talloc_zero(NULL, struct async_queue);
  ------------------
  |  |   27|  7.92k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  7.92k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  7.92k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|  7.92k|    *r->q = (struct async_queue){
   76|  7.92k|        .refcount = 1,
   77|  7.92k|    };
   78|  7.92k|    mp_mutex_init(&r->q->lock);
   79|  7.92k|    talloc_set_destructor(r, on_free_queue);
  ------------------
  |  |   41|  7.92k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   80|  7.92k|    mp_async_queue_set_config(r, (struct mp_async_queue_config){0});
   81|  7.92k|    return r;
   82|  7.92k|}
mp_async_queue_set_config:
  135|  15.8k|{
  136|  15.8k|    struct async_queue *q = queue->q;
  137|       |
  138|  15.8k|    cfg.max_bytes = MPCLAMP(cfg.max_bytes, 1, (size_t)-1 / 2);
  ------------------
  |  |   46|  15.8k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 7.92k, False: 7.92k]
  |  |  |  Branch (46:56): [True: 0, False: 7.92k]
  |  |  ------------------
  ------------------
  139|       |
  140|  15.8k|    mp_assert(cfg.sample_unit == AQUEUE_UNIT_FRAME ||
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 7.92k, False: 7.92k]
  |  Branch (140:5): [True: 7.92k, False: 0]
  ------------------
  141|  15.8k|           cfg.sample_unit == AQUEUE_UNIT_SAMPLES);
  142|       |
  143|  15.8k|    cfg.max_samples = MPMAX(cfg.max_samples, 1);
  ------------------
  |  |   44|  15.8k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 7.92k, False: 7.92k]
  |  |  ------------------
  ------------------
  144|       |
  145|  15.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  15.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  146|  15.8k|    bool recompute = q->cfg.sample_unit != cfg.sample_unit;
  147|  15.8k|    q->cfg = cfg;
  148|  15.8k|    if (recompute)
  ------------------
  |  Branch (148:9): [True: 7.92k, False: 7.92k]
  ------------------
  149|  7.92k|        recompute_sizes(q);
  150|  15.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  15.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  151|  15.8k|}
mp_async_queue_reset:
  154|  4.29k|{
  155|  4.29k|    reset_queue(queue->q);
  156|  4.29k|}
mp_async_queue_is_full:
  168|  80.0k|{
  169|  80.0k|    struct async_queue *q = queue->q;
  170|  80.0k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  80.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  171|  80.0k|    bool res = is_full(q);
  172|  80.0k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  80.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  173|  80.0k|    return res;
  174|  80.0k|}
mp_async_queue_resume_reading:
  191|  12.2k|{
  192|  12.2k|    struct async_queue *q = queue->q;
  193|       |
  194|  12.2k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  12.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  195|  12.2k|    if (!q->active || !q->reading) {
  ------------------
  |  Branch (195:9): [True: 12.2k, False: 0]
  |  Branch (195:23): [True: 0, False: 0]
  ------------------
  196|  12.2k|        q->active = true;
  197|  12.2k|        q->reading = true;
  198|       |        // Possibly start producer/consumer.
  199|  36.6k|        for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (199:25): [True: 24.4k, False: 12.2k]
  ------------------
  200|  24.4k|            if (q->conn[n])
  ------------------
  |  Branch (200:17): [True: 14.5k, False: 9.91k]
  ------------------
  201|  14.5k|                mp_filter_wakeup(q->conn[n]);
  202|  24.4k|        }
  203|  12.2k|    }
  204|  12.2k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  12.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  205|  12.2k|}
mp_async_queue_get_samples:
  208|  37.2k|{
  209|  37.2k|    struct async_queue *q = queue->q;
  210|  37.2k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  37.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  211|  37.2k|    int64_t res = q->samples_size;
  212|  37.2k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  37.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  213|  37.2k|    return res;
  214|  37.2k|}
mp_async_queue_get_frames:
  217|  5.15k|{
  218|  5.15k|    struct async_queue *q = queue->q;
  219|  5.15k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  5.15k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  220|  5.15k|    int res = q->num_frames;
  221|  5.15k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  5.15k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  222|  5.15k|    return res;
  223|  5.15k|}
mp_async_queue_set_notifier:
  338|  7.95k|{
  339|  7.95k|    mp_assert(mp_filter_get_info(f) == &info_in);
  ------------------
  |  |   41|  7.95k|#define mp_assert assert
  ------------------
  |  Branch (339:5): [True: 7.95k, False: 0]
  ------------------
  340|  7.95k|    struct priv *p = f->priv;
  341|  7.95k|    if (p->notify != notify) {
  ------------------
  |  Branch (341:9): [True: 7.95k, False: 0]
  ------------------
  342|  7.95k|        p->notify = notify;
  343|  7.95k|        if (notify)
  ------------------
  |  Branch (343:13): [True: 7.95k, False: 0]
  ------------------
  344|  7.95k|            mp_filter_wakeup(notify);
  345|  7.95k|    }
  346|  7.95k|}
mp_async_queue_create_filter:
  351|  15.8k|{
  352|  15.8k|    bool is_in = dir == MP_PIN_IN;
  353|  15.8k|    mp_assert(queue);
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (353:5): [True: 15.8k, False: 0]
  ------------------
  354|       |
  355|  15.8k|    struct mp_filter *f = mp_filter_create(parent, is_in ? &info_in : &info_out);
  ------------------
  |  Branch (355:52): [True: 7.95k, False: 7.92k]
  ------------------
  356|  15.8k|    if (!f)
  ------------------
  |  Branch (356:9): [True: 0, False: 15.8k]
  ------------------
  357|      0|        return NULL;
  358|       |
  359|  15.8k|    struct priv *p = f->priv;
  360|       |
  361|  15.8k|    struct async_queue *q = queue->q;
  362|       |
  363|  15.8k|    mp_filter_add_pin(f, dir, is_in ? "in" : "out");
  ------------------
  |  Branch (363:31): [True: 7.95k, False: 7.92k]
  ------------------
  364|       |
  365|  15.8k|    atomic_fetch_add(&q->refcount, 1);
  366|  15.8k|    p->q = q;
  367|       |
  368|  15.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  15.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  369|  15.8k|    int slot = is_in ? 0 : 1;
  ------------------
  |  Branch (369:16): [True: 7.95k, False: 7.92k]
  ------------------
  370|  15.8k|    mp_assert(!q->conn[slot]); // fails if already connected on this end
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (370:5): [True: 15.8k, False: 0]
  ------------------
  371|  15.8k|    q->conn[slot] = f;
  372|  15.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  15.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  373|       |
  374|  15.8k|    return f;
  375|  15.8k|}
f_async_queue.c:on_free_queue:
   66|  7.92k|{
   67|  7.92k|    struct mp_async_queue *q = p;
   68|  7.92k|    unref_queue(q->q);
   69|  7.92k|}
f_async_queue.c:unref_queue:
   53|  23.7k|{
   54|  23.7k|    if (!q)
  ------------------
  |  Branch (54:9): [True: 0, False: 23.7k]
  ------------------
   55|      0|        return;
   56|  23.7k|    int count = atomic_fetch_add(&q->refcount, -1) - 1;
   57|  23.7k|    mp_assert(count >= 0);
  ------------------
  |  |   41|  23.7k|#define mp_assert assert
  ------------------
  |  Branch (57:5): [True: 23.7k, False: 0]
  ------------------
   58|  23.7k|    if (count == 0) {
  ------------------
  |  Branch (58:9): [True: 7.92k, False: 15.8k]
  ------------------
   59|  7.92k|        reset_queue(q);
   60|  7.92k|        mp_mutex_destroy(&q->lock);
  ------------------
  |  |  133|  7.92k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   61|  7.92k|        talloc_free(q);
  ------------------
  |  |   47|  7.92k|#define talloc_free                     ta_free
  ------------------
   62|  7.92k|    }
   63|  23.7k|}
f_async_queue.c:recompute_sizes:
  125|  7.92k|{
  126|  7.92k|    q->eof_count = 0;
  127|  7.92k|    q->samples_size = 0;
  128|  7.92k|    q->byte_size = 0;
  129|  7.92k|    for (int n = 0; n < q->num_frames; n++)
  ------------------
  |  Branch (129:21): [True: 0, False: 7.92k]
  ------------------
  130|      0|        account_frame(q, q->frames[n], 1);
  131|  7.92k|}
f_async_queue.c:account_frame:
  114|  1.61M|{
  115|  1.61M|    mp_assert(dir == 1 || dir == -1);
  ------------------
  |  |   41|  1.61M|#define mp_assert assert
  ------------------
  |  Branch (115:5): [True: 806k, False: 806k]
  |  Branch (115:5): [True: 806k, False: 0]
  ------------------
  116|       |
  117|  1.61M|    q->samples_size += dir * frame_get_samples(q, frame);
  118|  1.61M|    q->byte_size += dir * mp_frame_approx_size(frame);
  119|       |
  120|  1.61M|    if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (120:9): [True: 11.9k, False: 1.60M]
  ------------------
  121|  11.9k|        q->eof_count += dir;
  122|  1.61M|}
f_async_queue.c:frame_get_samples:
   85|  1.61M|{
   86|  1.61M|    int64_t res = 1;
   87|  1.61M|    if (frame.type == MP_FRAME_AUDIO && q->cfg.sample_unit == AQUEUE_UNIT_SAMPLES) {
  ------------------
  |  Branch (87:9): [True: 1.60M, False: 11.9k]
  |  Branch (87:41): [True: 1.60M, False: 0]
  ------------------
   88|  1.60M|        struct mp_aframe *aframe = frame.data;
   89|  1.60M|        res = mp_aframe_get_size(aframe);
   90|  1.60M|    }
   91|  1.61M|    if (mp_frame_is_signaling(frame))
  ------------------
  |  Branch (91:9): [True: 11.9k, False: 1.60M]
  ------------------
   92|  11.9k|        return 0;
   93|  1.60M|    return res;
   94|  1.61M|}
f_async_queue.c:reset_queue:
   36|  12.2k|{
   37|  12.2k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  12.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   38|  12.2k|    q->active = q->reading = false;
   39|  12.8k|    for (int n = 0; n < q->num_frames; n++)
  ------------------
  |  Branch (39:21): [True: 664, False: 12.2k]
  ------------------
   40|    664|        mp_frame_unref(&q->frames[n]);
   41|  12.2k|    q->num_frames = 0;
   42|  12.2k|    q->eof_count = 0;
   43|  12.2k|    q->samples_size = 0;
   44|  12.2k|    q->byte_size = 0;
   45|  36.6k|    for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (45:21): [True: 24.4k, False: 12.2k]
  ------------------
   46|  24.4k|        if (q->conn[n])
  ------------------
  |  Branch (46:13): [True: 6.58k, False: 17.8k]
  ------------------
   47|  6.58k|            mp_filter_wakeup(q->conn[n]);
   48|  24.4k|    }
   49|  12.2k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  12.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   50|  12.2k|}
f_async_queue.c:is_full:
   97|  1.71M|{
   98|  1.71M|    if (q->samples_size >= q->cfg.max_samples || q->byte_size >= q->cfg.max_bytes)
  ------------------
  |  Branch (98:9): [True: 10.4k, False: 1.70M]
  |  Branch (98:50): [True: 0, False: 1.70M]
  ------------------
   99|  10.4k|        return true;
  100|  1.70M|    if (q->num_frames >= 2 && q->cfg.max_duration > 0) {
  ------------------
  |  Branch (100:9): [True: 192k, False: 1.50M]
  |  Branch (100:31): [True: 0, False: 192k]
  ------------------
  101|      0|        double pts1 = mp_frame_get_pts(q->frames[q->num_frames - 1]);
  102|      0|        double pts2 = mp_frame_get_pts(q->frames[0]);
  103|      0|        if (pts1 != MP_NOPTS_VALUE && pts2 != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts1 != MP_NOPTS_VALUE && pts2 != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (103:13): [True: 0, False: 0]
  |  Branch (103:39): [True: 0, False: 0]
  ------------------
  104|      0|            pts2 - pts1 >= q->cfg.max_duration)
  ------------------
  |  Branch (104:13): [True: 0, False: 0]
  ------------------
  105|      0|            return true;
  106|      0|    }
  107|  1.70M|    return false;
  108|  1.70M|}
f_async_queue.c:destroy:
  231|  15.8k|{
  232|  15.8k|    struct priv *p = f->priv;
  233|  15.8k|    struct async_queue *q = p->q;
  234|       |
  235|  15.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  15.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  236|  47.6k|    for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (236:21): [True: 31.7k, False: 15.8k]
  ------------------
  237|  31.7k|        if (q->conn[n] == f)
  ------------------
  |  Branch (237:13): [True: 15.8k, False: 15.8k]
  ------------------
  238|  15.8k|            q->conn[n] = NULL;
  239|  31.7k|    }
  240|  15.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  15.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  241|       |
  242|  15.8k|    unref_queue(q);
  243|  15.8k|}
f_async_queue.c:process_in:
  246|   824k|{
  247|   824k|    struct priv *p = f->priv;
  248|   824k|    struct async_queue *q = p->q;
  249|   824k|    mp_assert(q->conn[0] == f);
  ------------------
  |  |   41|   824k|#define mp_assert assert
  ------------------
  |  Branch (249:5): [True: 824k, False: 0]
  ------------------
  250|       |
  251|   824k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|   824k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  252|   824k|    if (!q->reading) {
  ------------------
  |  Branch (252:9): [True: 0, False: 824k]
  ------------------
  253|       |        // mp_async_queue_reset()/reset_queue() is usually called asynchronously,
  254|       |        // so we might have requested a frame earlier, and now can't use it.
  255|       |        // Discard it; the expectation is that this is a benign logical race
  256|       |        // condition, and the filter graph will be reset anyway.
  257|      0|        if (mp_pin_out_has_data(f->ppins[0])) {
  ------------------
  |  Branch (257:13): [True: 0, False: 0]
  ------------------
  258|      0|            struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  259|      0|            mp_frame_unref(&frame);
  260|      0|            MP_DBG(f, "discarding frame due to async reset\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  261|      0|        }
  262|   824k|    } else if (!is_full(q) && mp_pin_out_request_data(f->ppins[0])) {
  ------------------
  |  Branch (262:16): [True: 823k, False: 732]
  |  Branch (262:31): [True: 806k, False: 16.9k]
  ------------------
  263|   806k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  264|   806k|        account_frame(q, frame, 1);
  265|   806k|        MP_TARRAY_INSERT_AT(q, q->frames, q->num_frames, 0, frame);
  ------------------
  |  |  115|   806k|    do {                                            \
  |  |  116|   806k|        size_t at_ = (at);                          \
  |  |  117|   806k|        assert(at_ <= (idxvar));                    \
  |  |  118|   806k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   806k|    do {                                            \
  |  |  |  |   97|   806k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   806k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   806k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   806k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14.9k, False: 791k]
  |  |  |  |  ------------------
  |  |  |  |   99|   806k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  14.9k|    do {                                                        \
  |  |  |  |  |  |   89|  14.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  14.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  14.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  14.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  14.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  14.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  14.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   806k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 806k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   806k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   806k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   806k|        (idxvar)++;                                 \
  |  |  122|   806k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   806k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 806k]
  |  |  ------------------
  ------------------
  |  Branch (265:9): [True: 806k, False: 0]
  ------------------
  266|       |        // Notify reader that we have new frames.
  267|   806k|        if (q->conn[1])
  ------------------
  |  Branch (267:13): [True: 806k, False: 0]
  ------------------
  268|   806k|            mp_filter_wakeup(q->conn[1]);
  269|   806k|        bool full = is_full(q);
  270|   806k|        if (!full)
  ------------------
  |  Branch (270:13): [True: 802k, False: 4.55k]
  ------------------
  271|   802k|            mp_pin_out_request_data_next(f->ppins[0]);
  272|   806k|        if (p->notify && full)
  ------------------
  |  Branch (272:13): [True: 806k, False: 0]
  |  Branch (272:26): [True: 4.55k, False: 802k]
  ------------------
  273|  4.55k|            mp_filter_wakeup(p->notify);
  274|   806k|    }
  275|   824k|    if (p->notify && !q->num_frames)
  ------------------
  |  Branch (275:9): [True: 824k, False: 0]
  |  Branch (275:22): [True: 14.0k, False: 810k]
  ------------------
  276|  14.0k|        mp_filter_wakeup(p->notify);
  277|   824k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|   824k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  278|   824k|}
f_async_queue.c:process_out:
  281|  1.50M|{
  282|  1.50M|    struct priv *p = f->priv;
  283|  1.50M|    struct async_queue *q = p->q;
  284|  1.50M|    mp_assert(q->conn[1] == f);
  ------------------
  |  |   41|  1.50M|#define mp_assert assert
  ------------------
  |  Branch (284:5): [True: 1.50M, False: 0]
  ------------------
  285|       |
  286|  1.50M|    if (!mp_pin_in_needs_data(f->ppins[0]))
  ------------------
  |  Branch (286:9): [True: 8.66k, False: 1.49M]
  ------------------
  287|  8.66k|        return;
  288|       |
  289|  1.49M|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  1.49M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  290|  1.49M|    if (q->active && !q->reading) {
  ------------------
  |  Branch (290:9): [True: 1.49M, False: 0]
  |  Branch (290:22): [True: 0, False: 1.49M]
  ------------------
  291|      0|        q->reading = true;
  292|      0|        mp_filter_wakeup(q->conn[0]);
  293|      0|    }
  294|  1.49M|    if (q->active && q->num_frames) {
  ------------------
  |  Branch (294:9): [True: 1.49M, False: 0]
  |  Branch (294:22): [True: 806k, False: 687k]
  ------------------
  295|   806k|        struct mp_frame frame = q->frames[q->num_frames - 1];
  296|   806k|        q->num_frames -= 1;
  297|   806k|        account_frame(q, frame, -1);
  298|   806k|        mp_assert(q->samples_size >= 0);
  ------------------
  |  |   41|   806k|#define mp_assert assert
  ------------------
  |  Branch (298:9): [True: 806k, False: 0]
  ------------------
  299|   806k|        mp_pin_in_write(f->ppins[0], frame);
  300|       |        // Notify writer that we need new frames.
  301|   806k|        if (q->conn[0])
  ------------------
  |  Branch (301:13): [True: 801k, False: 4.58k]
  ------------------
  302|   801k|            mp_filter_wakeup(q->conn[0]);
  303|   806k|    }
  304|  1.49M|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  1.49M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  305|  1.49M|}

mp_deint_create:
  211|  9.69k|{
  212|  9.69k|    struct mp_filter *f = mp_filter_create(parent, &deint_filter);
  213|  9.69k|    if (!f)
  ------------------
  |  Branch (213:9): [True: 0, False: 9.69k]
  ------------------
  214|      0|        return NULL;
  215|       |
  216|  9.69k|    struct deint_priv *p = f->priv;
  217|       |
  218|  9.69k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  219|  9.69k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  220|       |
  221|  9.69k|    p->opts = m_config_cache_alloc(f, f->global, &filter_conf);
  222|       |
  223|  9.69k|    return f;
  224|  9.69k|}
mp_autorotate_create:
  337|  9.69k|{
  338|  9.69k|    struct mp_filter *f = mp_filter_create(parent, &rotate_filter);
  339|  9.69k|    if (!f)
  ------------------
  |  Branch (339:9): [True: 0, False: 9.69k]
  ------------------
  340|      0|        return NULL;
  341|       |
  342|  9.69k|    struct rotate_priv *p = f->priv;
  343|  9.69k|    p->prev_rotate = -1;
  344|       |
  345|  9.69k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  346|  9.69k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  347|       |
  348|  9.69k|    return f;
  349|  9.69k|}
mp_autovflip_create:
  458|  9.69k|{
  459|  9.69k|    struct mp_filter *f = mp_filter_create(parent, &vflip_filter);
  460|  9.69k|    if (!f)
  ------------------
  |  Branch (460:9): [True: 0, False: 9.69k]
  ------------------
  461|      0|        return NULL;
  462|       |
  463|  9.69k|    struct vflip_priv *p = f->priv;
  464|  9.69k|    p->prev_vflip = -1;
  465|       |
  466|  9.69k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  467|  9.69k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  468|       |
  469|  9.69k|    return f;
  470|  9.69k|}
mp_autoaspeed_create:
  581|  12.1k|{
  582|  12.1k|    struct mp_filter *f = mp_filter_create(parent, &aspeed_filter);
  583|  12.1k|    if (!f)
  ------------------
  |  Branch (583:9): [True: 0, False: 12.1k]
  ------------------
  584|      0|        return NULL;
  585|       |
  586|  12.1k|    struct aspeed_priv *p = f->priv;
  587|  12.1k|    p->cur_speed = 1.0;
  588|  12.1k|    p->cur_speed_drop = 1.0;
  589|       |
  590|  12.1k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  591|  12.1k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  592|       |
  593|  12.1k|    return f;
  594|  12.1k|}
f_auto_filters.c:deint_destroy:
  176|  9.69k|{
  177|  9.69k|    struct deint_priv *p = f->priv;
  178|       |
  179|  9.69k|    mp_subfilter_reset(&p->sub);
  180|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  9.69k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.69k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  181|  9.69k|}
f_auto_filters.c:deint_process:
   30|   110k|{
   31|   110k|    struct deint_priv *p = f->priv;
   32|       |
   33|   110k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (33:9): [True: 59.0k, False: 51.3k]
  ------------------
   34|  59.0k|        return;
   35|       |
   36|  51.3k|    struct mp_frame frame = p->sub.frame;
   37|       |
   38|  51.3k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (38:9): [True: 7.61k, False: 43.7k]
  ------------------
   39|  7.61k|        mp_subfilter_continue(&p->sub);
   40|  7.61k|        return;
   41|  7.61k|    }
   42|       |
   43|  43.7k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (43:9): [True: 0, False: 43.7k]
  ------------------
   44|      0|        MP_ERR(f, "video input required!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   45|      0|        mp_filter_internal_mark_failed(f);
   46|      0|        return;
   47|      0|    }
   48|       |
   49|  43.7k|    struct mp_image *img = frame.data;
   50|  43.7k|    p->interlaced_frame = img->fields & MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|  43.7k|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
   51|       |
   52|  43.7k|    m_config_cache_update(p->opts);
   53|  43.7k|    struct filter_opts *opts = p->opts->opts;
   54|       |
   55|       |    // Handle deinterlace=0 case by destroying any existing filter immediately.
   56|  43.7k|    if (!opts->deinterlace)
  ------------------
  |  Branch (56:9): [True: 43.7k, False: 0]
  ------------------
   57|  43.7k|        mp_subfilter_destroy(&p->sub);
   58|       |
   59|       |    // Insert a deinterlace filter in the chain if:
   60|       |    //   1) deinterlace=1 (always), or
   61|       |    //   2) deinterlace=-1 (auto) and the frame is interlaced.
   62|       |    // We check also if a filter is already present, to avoid removing it
   63|  43.7k|    bool filter_needed = opts->deinterlace == 1 ||
  ------------------
  |  Branch (63:26): [True: 0, False: 43.7k]
  ------------------
   64|  43.7k|                         (opts->deinterlace == -1 && (p->interlaced_frame || p->sub.filter));
  ------------------
  |  Branch (64:27): [True: 0, False: 43.7k]
  |  Branch (64:55): [True: 0, False: 0]
  |  Branch (64:78): [True: 0, False: 0]
  ------------------
   65|       |
   66|       |    // If the image format changed, destroy any existing filter immediately since
   67|       |    // it may not support the new format. If we no longer need a filter, drain
   68|       |    // and destroy it gracefully.
   69|  43.7k|    if (img->imgfmt != p->prev_imgfmt) {
  ------------------
  |  Branch (69:9): [True: 1.37k, False: 42.3k]
  ------------------
   70|  1.37k|        mp_subfilter_destroy(&p->sub);
   71|  1.37k|        p->prev_imgfmt = img->imgfmt;
   72|  42.3k|    } else if (p->sub.filter && !filter_needed) {
  ------------------
  |  Branch (72:16): [True: 0, False: 42.3k]
  |  Branch (72:33): [True: 0, False: 0]
  ------------------
   73|      0|        if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (73:13): [True: 0, False: 0]
  ------------------
   74|      0|            return;
   75|      0|    }
   76|       |
   77|       |    // If no filter is needed or if the filter is already inserted and we reach
   78|       |    // this point, just continue. Otherwise, create and insert the filter.
   79|  43.7k|    if (!filter_needed || p->sub.filter) {
  ------------------
  |  Branch (79:9): [True: 43.7k, False: 0]
  |  Branch (79:27): [True: 0, False: 0]
  ------------------
   80|  43.7k|        mp_subfilter_continue(&p->sub);
   81|  43.7k|        return;
   82|  43.7k|    }
   83|       |
   84|      0|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (84:5): [True: 0, False: 0]
  ------------------
   85|       |
   86|      0|    char *field_parity;
   87|      0|    switch (opts->field_parity) {
   88|      0|    case MP_FIELD_PARITY_TFF:
  ------------------
  |  |   33|      0|#define MP_FIELD_PARITY_TFF 0
  ------------------
  |  Branch (88:5): [True: 0, False: 0]
  ------------------
   89|      0|        field_parity = "tff";
   90|      0|        break;
   91|      0|    case MP_FIELD_PARITY_BFF:
  ------------------
  |  |   34|      0|#define MP_FIELD_PARITY_BFF 1
  ------------------
  |  Branch (91:5): [True: 0, False: 0]
  ------------------
   92|      0|        field_parity = "bff";
   93|      0|        break;
   94|      0|    default:
  ------------------
  |  Branch (94:5): [True: 0, False: 0]
  ------------------
   95|      0|        field_parity = "auto";
   96|      0|    }
   97|       |
   98|      0|    bool has_filter = true;
   99|      0|    if (img->imgfmt == IMGFMT_VDPAU) {
  ------------------
  |  Branch (99:9): [True: 0, False: 0]
  ------------------
  100|      0|        char *args[] = {"deint", "yes",
  101|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (101:44): [True: 0, False: 0]
  ------------------
  102|      0|                        "parity", field_parity, NULL};
  103|      0|        p->sub.filter =
  104|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vdpaupp", args);
  105|      0|    } else if (img->imgfmt == IMGFMT_D3D11) {
  ------------------
  |  Branch (105:16): [True: 0, False: 0]
  ------------------
  106|      0|        char *args[] = {"deint", "yes",
  107|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (107:44): [True: 0, False: 0]
  ------------------
  108|      0|                        "parity", field_parity, NULL};
  109|      0|        p->sub.filter =
  110|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "d3d11vpp", args);
  111|      0|    } else if (img->imgfmt == IMGFMT_CUDA) {
  ------------------
  |  Branch (111:16): [True: 0, False: 0]
  ------------------
  112|      0|        char *args[] = {"mode", "send_field",
  113|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (113:34): [True: 0, False: 0]
  ------------------
  114|      0|                        "parity", field_parity, NULL};
  115|      0|        p->sub.filter =
  116|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "bwdif_cuda", args);
  117|      0|    } else if (img->imgfmt == IMGFMT_VULKAN) {
  ------------------
  |  Branch (117:16): [True: 0, False: 0]
  ------------------
  118|      0|        char *args[] = {"mode", "send_field",
  119|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (119:34): [True: 0, False: 0]
  ------------------
  120|      0|                        "parity", field_parity, NULL};
  121|      0|        p->sub.filter =
  122|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "bwdif_vulkan", args);
  123|      0|    } else if (img->imgfmt == IMGFMT_VAAPI) {
  ------------------
  |  Branch (123:16): [True: 0, False: 0]
  ------------------
  124|      0|        char *args[] = {"deint", "motion-adaptive",
  125|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (125:44): [True: 0, False: 0]
  ------------------
  126|      0|                        "parity", field_parity, NULL};
  127|      0|        p->sub.filter =
  128|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vavpp", args);
  129|      0|    } else {
  130|      0|        has_filter = false;
  131|      0|    }
  132|       |
  133|      0|    if (!p->sub.filter) {
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  ------------------
  134|      0|        if (has_filter)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            MP_ERR(f, "creating deinterlacer failed\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  136|       |
  137|      0|        struct mp_filter *subf = mp_bidir_dummy_filter_create(f);
  138|      0|        struct mp_filter *filters[2] = {0};
  139|       |
  140|      0|        struct mp_autoconvert *ac = mp_autoconvert_create(subf);
  141|      0|        if (ac) {
  ------------------
  |  Branch (141:13): [True: 0, False: 0]
  ------------------
  142|      0|            filters[0] = ac->f;
  143|       |            // We know vf_bwdif does not support hw inputs.
  144|      0|            mp_autoconvert_add_all_sw_imgfmts(ac);
  145|       |
  146|      0|            if (!mp_autoconvert_probe_input_video(ac, img)) {
  ------------------
  |  Branch (146:17): [True: 0, False: 0]
  ------------------
  147|      0|                MP_ERR(f, "no deinterlace filter available for format %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  148|      0|                       mp_imgfmt_to_name(img->imgfmt));
  149|      0|                talloc_free(subf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  150|      0|                mp_subfilter_continue(&p->sub);
  151|      0|                return;
  152|      0|            }
  153|      0|        }
  154|       |
  155|      0|        char *args[] = {"mode", "send_field",
  156|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (156:34): [True: 0, False: 0]
  ------------------
  157|      0|                        "parity", field_parity, NULL};
  158|      0|        filters[1] =
  159|      0|            mp_create_user_filter(subf, MP_OUTPUT_CHAIN_VIDEO, "bwdif", args);
  160|       |
  161|      0|        mp_chain_filters(subf->ppins[0], subf->ppins[1], filters, 2);
  162|      0|        p->sub.filter = subf;
  163|      0|    }
  164|       |
  165|      0|    mp_subfilter_continue(&p->sub);
  166|      0|}
f_auto_filters.c:deint_command:
  184|  51.3k|{
  185|  51.3k|    struct deint_priv *p = f->priv;
  186|       |
  187|  51.3k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (187:9): [True: 51.3k, False: 0]
  ------------------
  188|  51.3k|        cmd->is_active = !!p->sub.filter;
  189|  51.3k|        return true;
  190|  51.3k|    }
  191|      0|    return false;
  192|  51.3k|}
f_auto_filters.c:rotate_destroy:
  309|  9.69k|{
  310|  9.69k|    struct rotate_priv *p = f->priv;
  311|       |
  312|  9.69k|    mp_subfilter_reset(&p->sub);
  313|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  9.69k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.69k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  314|  9.69k|}
f_auto_filters.c:rotate_process:
  234|   110k|{
  235|   110k|    struct rotate_priv *p = f->priv;
  236|       |
  237|   110k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (237:9): [True: 59.0k, False: 51.3k]
  ------------------
  238|  59.0k|        return;
  239|       |
  240|  51.3k|    struct mp_frame frame = p->sub.frame;
  241|       |
  242|  51.3k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (242:9): [True: 7.61k, False: 43.7k]
  ------------------
  243|  7.61k|        mp_subfilter_continue(&p->sub);
  244|  7.61k|        return;
  245|  7.61k|    }
  246|       |
  247|  43.7k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (247:9): [True: 0, False: 43.7k]
  ------------------
  248|      0|        MP_ERR(f, "video input required!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  249|      0|        return;
  250|      0|    }
  251|       |
  252|  43.7k|    struct mp_image *img = frame.data;
  253|       |
  254|  43.7k|    if (img->params.rotate == p->prev_rotate &&
  ------------------
  |  Branch (254:9): [True: 42.7k, False: 1.00k]
  ------------------
  255|  42.7k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (255:9): [True: 42.3k, False: 373]
  ------------------
  256|  42.3k|    {
  257|  42.3k|        img->params.rotate = p->target_rotate;
  258|  42.3k|        mp_subfilter_continue(&p->sub);
  259|  42.3k|        return;
  260|  42.3k|    }
  261|       |
  262|  1.37k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (262:9): [True: 0, False: 1.37k]
  ------------------
  263|      0|        return;
  264|       |
  265|  1.37k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  1.37k|#define mp_assert assert
  ------------------
  |  Branch (265:5): [True: 1.37k, False: 0]
  ------------------
  266|       |
  267|  1.37k|    int rotate = p->prev_rotate = img->params.rotate;
  268|  1.37k|    p->target_rotate = rotate;
  269|  1.37k|    p->prev_imgfmt = img->imgfmt;
  270|       |
  271|  1.37k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  272|  1.37k|    if (rotate == 0 || (info && info->rotate90 && !(rotate % 90))) {
  ------------------
  |  Branch (272:9): [True: 1.37k, False: 0]
  |  Branch (272:25): [True: 0, False: 0]
  |  Branch (272:33): [True: 0, False: 0]
  |  Branch (272:51): [True: 0, False: 0]
  ------------------
  273|  1.37k|        mp_subfilter_continue(&p->sub);
  274|  1.37k|        return;
  275|  1.37k|    }
  276|       |
  277|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|        MP_ERR(f, "Video rotation with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  279|      0|        mp_subfilter_continue(&p->sub);
  280|      0|        return;
  281|      0|    }
  282|       |
  283|      0|    double angle = rotate / 360.0 * M_PI * 2;
  284|      0|    char *args[] = {"angle", mp_tprintf(30, "%f", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  285|      0|                    "ow", mp_tprintf(30, "rotw(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  286|      0|                    "oh", mp_tprintf(30, "roth(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  287|      0|                    NULL};
  288|      0|    p->sub.filter =
  289|      0|        mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "rotate", args);
  290|       |
  291|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|        MP_INFO(f, "Inserting rotation filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  293|      0|        p->target_rotate = 0;
  294|      0|    } else {
  295|      0|        MP_ERR(f, "could not create rotation filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  296|      0|    }
  297|       |
  298|      0|    mp_subfilter_continue(&p->sub);
  299|      0|}
f_auto_filters.c:rotate_command:
  317|  51.3k|{
  318|  51.3k|    struct rotate_priv *p = f->priv;
  319|       |
  320|  51.3k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (320:9): [True: 51.3k, False: 0]
  ------------------
  321|  51.3k|        cmd->is_active = !!p->sub.filter;
  322|  51.3k|        return true;
  323|  51.3k|    }
  324|      0|    return false;
  325|  51.3k|}
f_auto_filters.c:vflip_destroy:
  430|  9.69k|{
  431|  9.69k|    struct vflip_priv *p = f->priv;
  432|       |
  433|  9.69k|    mp_subfilter_reset(&p->sub);
  434|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  9.69k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.69k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  435|  9.69k|}
f_auto_filters.c:vflip_process:
  359|   110k|{
  360|   110k|    struct vflip_priv *p = f->priv;
  361|       |
  362|   110k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (362:9): [True: 59.0k, False: 51.3k]
  ------------------
  363|  59.0k|        return;
  364|       |
  365|  51.3k|    struct mp_frame frame = p->sub.frame;
  366|       |
  367|  51.3k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (367:9): [True: 7.61k, False: 43.7k]
  ------------------
  368|  7.61k|        mp_subfilter_continue(&p->sub);
  369|  7.61k|        return;
  370|  7.61k|    }
  371|       |
  372|  43.7k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (372:9): [True: 0, False: 43.7k]
  ------------------
  373|      0|        MP_ERR(f, "video input required!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  374|      0|        return;
  375|      0|    }
  376|       |
  377|  43.7k|    struct mp_image *img = frame.data;
  378|       |
  379|  43.7k|    if (img->params.vflip == p->prev_vflip &&
  ------------------
  |  Branch (379:9): [True: 42.7k, False: 1.00k]
  ------------------
  380|  42.7k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (380:9): [True: 42.3k, False: 373]
  ------------------
  381|  42.3k|    {
  382|  42.3k|        img->params.vflip = p->target_vflip;
  383|  42.3k|        mp_subfilter_continue(&p->sub);
  384|  42.3k|        return;
  385|  42.3k|    }
  386|       |
  387|  1.37k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (387:9): [True: 0, False: 1.37k]
  ------------------
  388|      0|        return;
  389|       |
  390|  1.37k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  1.37k|#define mp_assert assert
  ------------------
  |  Branch (390:5): [True: 1.37k, False: 0]
  ------------------
  391|       |
  392|  1.37k|    int vflip = p->prev_vflip = img->params.vflip;
  393|  1.37k|    p->target_vflip = vflip;
  394|  1.37k|    p->prev_imgfmt = img->imgfmt;
  395|       |
  396|  1.37k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  397|  1.37k|    if (!vflip || (info && info->vflip)) {
  ------------------
  |  Branch (397:9): [True: 1.37k, False: 0]
  |  Branch (397:20): [True: 0, False: 0]
  |  Branch (397:28): [True: 0, False: 0]
  ------------------
  398|  1.37k|        mp_subfilter_continue(&p->sub);
  399|  1.37k|        return;
  400|  1.37k|    }
  401|       |
  402|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (402:9): [True: 0, False: 0]
  ------------------
  403|      0|        MP_ERR(f, "Video vflip with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  404|      0|        mp_subfilter_continue(&p->sub);
  405|      0|        return;
  406|      0|    }
  407|       |
  408|      0|    char *args[] = {NULL};
  409|       |
  410|      0|    p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vflip", args);
  411|       |
  412|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (412:9): [True: 0, False: 0]
  ------------------
  413|      0|        MP_INFO(f, "Inserting vflip filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  414|      0|        p->target_vflip = 0;
  415|      0|    } else {
  416|      0|        MP_ERR(f, "could not create vflip filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  417|      0|    }
  418|       |
  419|      0|    mp_subfilter_continue(&p->sub);
  420|      0|}
f_auto_filters.c:vflip_command:
  438|  51.3k|{
  439|  51.3k|    struct vflip_priv *p = f->priv;
  440|       |
  441|  51.3k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (441:9): [True: 51.3k, False: 0]
  ------------------
  442|  51.3k|        cmd->is_active = !!p->sub.filter;
  443|  51.3k|        return true;
  444|  51.3k|    }
  445|      0|    return false;
  446|  51.3k|}
f_auto_filters.c:aspeed_destroy:
  564|  12.1k|{
  565|  12.1k|    struct aspeed_priv *p = f->priv;
  566|       |
  567|  12.1k|    mp_subfilter_reset(&p->sub);
  568|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  12.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  12.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 12.1k]
  |  |  ------------------
  ------------------
  569|  12.1k|}
f_auto_filters.c:aspeed_process:
  479|  1.63M|{
  480|  1.63M|    struct aspeed_priv *p = f->priv;
  481|       |
  482|  1.63M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (482:9): [True: 824k, False: 812k]
  ------------------
  483|   824k|        return;
  484|       |
  485|   812k|    if (!p->sub.filter)
  ------------------
  |  Branch (485:9): [True: 812k, False: 0]
  ------------------
  486|   812k|        p->current_filter = 0;
  487|       |
  488|   812k|    double speed = p->cur_speed * p->cur_speed_drop;
  489|       |
  490|   812k|    int req_filter = 0;
  491|   812k|    if (fabs(speed - 1.0) >= 1e-8) {
  ------------------
  |  Branch (491:9): [True: 0, False: 812k]
  ------------------
  492|      0|        req_filter = p->cur_speed_drop == 1.0 ? 1 : 2;
  ------------------
  |  Branch (492:22): [True: 0, False: 0]
  ------------------
  493|      0|        if (p->sub.frame.type == MP_FRAME_AUDIO &&
  ------------------
  |  Branch (493:13): [True: 0, False: 0]
  ------------------
  494|      0|            !af_fmt_is_pcm(mp_aframe_get_format(p->sub.frame.data)))
  ------------------
  |  Branch (494:13): [True: 0, False: 0]
  ------------------
  495|      0|            req_filter = 2;
  496|      0|    }
  497|       |
  498|   812k|    if (req_filter != p->current_filter) {
  ------------------
  |  Branch (498:9): [True: 0, False: 812k]
  ------------------
  499|      0|        if (p->sub.filter)
  ------------------
  |  Branch (499:13): [True: 0, False: 0]
  ------------------
  500|      0|            MP_VERBOSE(f, "removing audio speed filter\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  501|      0|        if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (501:13): [True: 0, False: 0]
  ------------------
  502|      0|            return;
  503|       |
  504|      0|        if (req_filter) {
  ------------------
  |  Branch (504:13): [True: 0, False: 0]
  ------------------
  505|      0|            if (req_filter == 1) {
  ------------------
  |  Branch (505:17): [True: 0, False: 0]
  ------------------
  506|      0|                MP_VERBOSE(f, "adding scaletempo2\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  507|      0|                p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_AUDIO,
  508|      0|                                                      "scaletempo2", NULL);
  509|      0|            } else if (req_filter == 2) {
  ------------------
  |  Branch (509:24): [True: 0, False: 0]
  ------------------
  510|      0|                MP_VERBOSE(f, "adding drop\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  511|      0|                p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_AUDIO,
  512|      0|                                                      "drop", NULL);
  513|      0|            }
  514|      0|            if (!p->sub.filter) {
  ------------------
  |  Branch (514:17): [True: 0, False: 0]
  ------------------
  515|      0|                MP_ERR(f, "could not create filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  516|      0|                mp_subfilter_continue(&p->sub);
  517|      0|                return;
  518|      0|            }
  519|      0|            p->current_filter = req_filter;
  520|      0|        }
  521|      0|    }
  522|       |
  523|   812k|    if (p->sub.filter) {
  ------------------
  |  Branch (523:9): [True: 0, False: 812k]
  ------------------
  524|      0|        struct mp_filter_command cmd = {
  525|      0|            .type = MP_FILTER_COMMAND_SET_SPEED,
  526|      0|            .speed = speed,
  527|      0|        };
  528|      0|        mp_filter_command(p->sub.filter, &cmd);
  529|      0|    }
  530|       |
  531|   812k|    mp_subfilter_continue(&p->sub);
  532|   812k|}
f_auto_filters.c:aspeed_command:
  535|   847k|{
  536|   847k|    struct aspeed_priv *p = f->priv;
  537|       |
  538|   847k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED) {
  ------------------
  |  Branch (538:9): [True: 11.7k, False: 836k]
  ------------------
  539|  11.7k|        p->cur_speed = cmd->speed;
  540|  11.7k|        return true;
  541|  11.7k|    }
  542|       |
  543|   836k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_DROP) {
  ------------------
  |  Branch (543:9): [True: 11.7k, False: 824k]
  ------------------
  544|  11.7k|        p->cur_speed_drop = cmd->speed;
  545|  11.7k|        return true;
  546|  11.7k|    }
  547|       |
  548|   824k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (548:9): [True: 812k, False: 11.7k]
  ------------------
  549|   812k|        cmd->is_active = !!p->sub.filter;
  550|   812k|        return true;
  551|   812k|    }
  552|       |
  553|  11.7k|    return false;
  554|   824k|}

mp_autoconvert_clear:
   61|  27.1k|{
   62|  27.1k|    struct priv *p = c->f->priv;
   63|       |
   64|  27.1k|    p->num_imgfmts = 0;
   65|  27.1k|    p->imgparams_set = false;
   66|  27.1k|    p->num_afmts = 0;
   67|  27.1k|    p->num_srates = 0;
   68|  27.1k|    p->chmaps = (struct mp_chmap_sel){0};
   69|       |    p->force_update = true;
   70|  27.1k|}
mp_autoconvert_add_imgfmt:
   73|  10.7M|{
   74|  10.7M|    struct priv *p = c->f->priv;
   75|       |
   76|  10.7M|    MP_TARRAY_GROW(p, p->imgfmts, p->num_imgfmts);
  ------------------
  |  |   96|  10.7M|    do {                                            \
  |  |   97|  10.7M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  10.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  10.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  10.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 87.2k, False: 10.6M]
  |  |  ------------------
  |  |   99|  10.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  87.2k|    do {                                                        \
  |  |  |  |   89|  87.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  87.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  87.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  87.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  87.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  87.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  87.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 87.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  10.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 10.7M]
  |  |  ------------------
  ------------------
   77|  10.7M|    MP_TARRAY_GROW(p, p->subfmts, p->num_imgfmts);
  ------------------
  |  |   96|  10.7M|    do {                                            \
  |  |   97|  10.7M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  10.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  10.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  10.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 87.2k, False: 10.6M]
  |  |  ------------------
  |  |   99|  10.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  87.2k|    do {                                                        \
  |  |  |  |   89|  87.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  87.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  87.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  87.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  87.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  87.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  87.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 87.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  10.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 10.7M]
  |  |  ------------------
  ------------------
   78|       |
   79|  10.7M|    p->imgfmts[p->num_imgfmts] = imgfmt;
   80|  10.7M|    p->subfmts[p->num_imgfmts] = subfmt;
   81|       |
   82|  10.7M|    p->num_imgfmts += 1;
   83|       |    p->force_update = true;
   84|  10.7M|}
mp_autoconvert_add_afmt:
  112|  7.95k|{
  113|  7.95k|    struct priv *p = c->f->priv;
  114|       |
  115|  7.95k|    MP_TARRAY_APPEND(p, p->afmts, p->num_afmts, afmt);
  ------------------
  |  |  105|  7.95k|    do {                                            \
  |  |  106|  7.95k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  7.95k|    do {                                            \
  |  |  |  |   97|  7.95k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  7.95k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  7.95k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  7.95k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.07k, False: 1.87k]
  |  |  |  |  ------------------
  |  |  |  |   99|  7.95k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.07k|    do {                                                        \
  |  |  |  |  |  |   89|  6.07k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.07k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.07k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.07k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.07k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.07k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.07k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.07k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  7.95k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 7.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  7.95k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  7.95k|        (idxvar)++;                                 \
  |  |  109|  7.95k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.95k]
  |  |  ------------------
  ------------------
  116|       |    p->force_update = true;
  117|  7.95k|}
mp_autoconvert_add_chmap:
  120|  7.95k|{
  121|  7.95k|    struct priv *p = c->f->priv;
  122|       |
  123|  7.95k|    mp_chmap_sel_add_map(&p->chmaps, chmap);
  124|       |    p->force_update = true;
  125|  7.95k|}
mp_autoconvert_add_srate:
  128|  7.95k|{
  129|  7.95k|    struct priv *p = c->f->priv;
  130|       |
  131|  7.95k|    MP_TARRAY_APPEND(p, p->srates, p->num_srates, rate);
  ------------------
  |  |  105|  7.95k|    do {                                            \
  |  |  106|  7.95k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  7.95k|    do {                                            \
  |  |  |  |   97|  7.95k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  7.95k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  7.95k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  7.95k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.07k, False: 1.87k]
  |  |  |  |  ------------------
  |  |  |  |   99|  7.95k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.07k|    do {                                                        \
  |  |  |  |  |  |   89|  6.07k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.07k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.07k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.07k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.07k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.07k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.07k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.07k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  7.95k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 7.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  7.95k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  7.95k|        (idxvar)++;                                 \
  |  |  109|  7.95k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.95k]
  |  |  ------------------
  ------------------
  132|       |    // Some other API we call expects a 0-terminated sample rates array.
  133|  7.95k|    MP_TARRAY_GROW(p, p->srates, p->num_srates);
  ------------------
  |  |   96|  7.95k|    do {                                            \
  |  |   97|  7.95k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  7.95k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  7.95k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  7.95k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 7.95k]
  |  |  ------------------
  |  |   99|  7.95k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  7.95k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 7.95k]
  |  |  ------------------
  ------------------
  134|  7.95k|    p->srates[p->num_srates] = 0;
  135|       |    p->force_update = true;
  136|  7.95k|}
mp_autoconvert_format_change_continue:
  507|  7.95k|{
  508|  7.95k|    struct priv *p = c->f->priv;
  509|       |
  510|  7.95k|    if (p->format_change_blocked) {
  ------------------
  |  Branch (510:9): [True: 7.95k, False: 0]
  ------------------
  511|  7.95k|        p->format_change_cont = true;
  512|       |        p->format_change_blocked = false;
  513|  7.95k|        mp_filter_wakeup(c->f);
  514|  7.95k|    }
  515|  7.95k|}
mp_autoconvert_create:
  566|  21.8k|{
  567|  21.8k|    struct mp_filter *f = mp_filter_create(parent, &autoconvert_filter);
  568|  21.8k|    if (!f)
  ------------------
  |  Branch (568:9): [True: 0, False: 21.8k]
  ------------------
  569|      0|        return NULL;
  570|       |
  571|  21.8k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  572|  21.8k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  573|       |
  574|  21.8k|    struct priv *p = f->priv;
  575|  21.8k|    p->public.f = f;
  576|  21.8k|    p->log = f->log;
  577|  21.8k|    p->audio_speed = 1.0;
  578|  21.8k|    p->sub.in = f->ppins[0];
  579|  21.8k|    p->sub.out = f->ppins[1];
  580|       |
  581|  21.8k|    return &p->public;
  582|  21.8k|}
f_autoconvert.c:build_image_converter:
  141|  1.84k|{
  142|  1.84k|    struct mp_filter *f = c->f;
  143|  1.84k|    struct priv *p = f->priv;
  144|       |
  145|  1.84k|    *f_out = NULL;
  146|       |
  147|  1.84k|    if (!p->num_imgfmts)
  ------------------
  |  Branch (147:9): [True: 0, False: 1.84k]
  ------------------
  148|      0|        return true;
  149|       |
  150|   130k|    for (int n = 0; n < p->num_imgfmts; n++) {
  ------------------
  |  Branch (150:21): [True: 130k, False: 0]
  ------------------
  151|   130k|        bool samefmt = img->params.imgfmt == p->imgfmts[n];
  152|   130k|        bool samesubffmt = img->params.hw_subfmt == p->subfmts[n];
  153|       |        /*
  154|       |         * In practice, `p->subfmts` is not usually populated today, in which
  155|       |         * case we must actively probe formats below to establish if the VO can
  156|       |         * accept the subfmt being used by the hwdec.
  157|       |         */
  158|   130k|        if (samefmt && samesubffmt) {
  ------------------
  |  Branch (158:13): [True: 1.84k, False: 128k]
  |  Branch (158:24): [True: 1.84k, False: 0]
  ------------------
  159|  1.84k|            if (p->imgparams_set) {
  ------------------
  |  Branch (159:17): [True: 0, False: 1.84k]
  ------------------
  160|      0|                if (!mp_image_params_static_equal(&p->imgparams, &img->params))
  ------------------
  |  Branch (160:21): [True: 0, False: 0]
  ------------------
  161|      0|                    break;
  162|      0|            }
  163|  1.84k|            return true;
  164|  1.84k|        }
  165|   130k|    }
  166|       |
  167|      0|    struct mp_filter *conv = mp_filter_create(f, &convert_filter);
  168|      0|    if (!conv)
  ------------------
  |  Branch (168:9): [True: 0, False: 0]
  ------------------
  169|      0|        return false;
  170|       |
  171|      0|    mp_filter_add_pin(conv, MP_PIN_IN, "in");
  172|      0|    mp_filter_add_pin(conv, MP_PIN_OUT, "out");
  173|       |
  174|       |    // 0: hw->sw download
  175|       |    // 1: swscale
  176|       |    // 2: sw->hw upload
  177|      0|    struct mp_filter *filters[3] = {0};
  178|      0|    bool need_sws = true;
  179|      0|    bool force_sws_params = false;
  180|      0|    struct mp_image_params imgpar = img->params;
  181|       |
  182|      0|    int *fmts = p->imgfmts;
  183|      0|    int num_fmts = p->num_imgfmts;
  184|      0|    int hwupload_fmt = 0;
  185|       |
  186|      0|    bool imgfmt_is_sw = !IMGFMT_IS_HWACCEL(img->imgfmt);
  ------------------
  |  |  329|      0|#define IMGFMT_IS_HWACCEL(fmt) (!!(mp_imgfmt_get_desc(fmt).flags & MP_IMGFLAG_HWACCEL))
  |  |  ------------------
  |  |  |  |   70|      0|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  |  |  ------------------
  |  |  |  |  |  |   65|      0|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  187|       |
  188|       |    // This should not happen. But not enough guarantee to make it an assert().
  189|      0|    if (imgfmt_is_sw != !img->hwctx)
  ------------------
  |  Branch (189:9): [True: 0, False: 0]
  ------------------
  190|      0|        mp_warn(log, "Unexpected AVFrame/imgfmt hardware context mismatch.\n");
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  191|       |
  192|      0|    bool dst_all_hw = true;
  193|      0|    bool dst_have_sw = false;
  194|      0|    bool has_src_hw_fmt = false;
  195|      0|    for (int n = 0; n < num_fmts; n++) {
  ------------------
  |  Branch (195:21): [True: 0, False: 0]
  ------------------
  196|      0|        bool is_hw = IMGFMT_IS_HWACCEL(fmts[n]);
  ------------------
  |  |  329|      0|#define IMGFMT_IS_HWACCEL(fmt) (!!(mp_imgfmt_get_desc(fmt).flags & MP_IMGFLAG_HWACCEL))
  |  |  ------------------
  |  |  |  |   70|      0|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  |  |  ------------------
  |  |  |  |  |  |   65|      0|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  197|      0|        dst_all_hw &= is_hw;
  198|      0|        dst_have_sw |= !is_hw;
  199|      0|        has_src_hw_fmt |= is_hw && fmts[n] == imgpar.imgfmt;
  ------------------
  |  Branch (199:27): [True: 0, False: 0]
  |  Branch (199:36): [True: 0, False: 0]
  ------------------
  200|      0|    }
  201|       |
  202|       |    // Source is hw, some targets are sw -> try to download.
  203|      0|    bool hw_to_sw = !imgfmt_is_sw && dst_have_sw;
  ------------------
  |  Branch (203:21): [True: 0, False: 0]
  |  Branch (203:38): [True: 0, False: 0]
  ------------------
  204|       |
  205|      0|    if (has_src_hw_fmt) {
  ------------------
  |  Branch (205:9): [True: 0, False: 0]
  ------------------
  206|      0|        int src_fmt = img->params.hw_subfmt;
  207|       |        /*
  208|       |         * If the source format is a hardware format, and our output supports
  209|       |         * that hardware format, we prioritize preserving the use of that
  210|       |         * hardware format. In most cases, the sub format will also be supported
  211|       |         * and no conversion will be required, but in some cases, the hwdec
  212|       |         * may be able to output formats that the VO cannot display, and
  213|       |         * hardware format conversion becomes necessary.
  214|       |         */
  215|      0|        struct mp_hwupload upload = mp_hwupload_create(conv, imgpar.imgfmt,
  216|      0|                                                       src_fmt,
  217|      0|                                                       true);
  218|      0|        if (upload.successful_init) {
  ------------------
  |  Branch (218:13): [True: 0, False: 0]
  ------------------
  219|      0|            if (upload.f) {
  ------------------
  |  Branch (219:17): [True: 0, False: 0]
  ------------------
  220|      0|                mp_info(log, "Converting %s[%s] -> %s[%s]\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  221|      0|                        mp_imgfmt_to_name(imgpar.imgfmt),
  222|      0|                        mp_imgfmt_to_name(src_fmt),
  223|      0|                        mp_imgfmt_to_name(imgpar.imgfmt),
  224|      0|                        mp_imgfmt_to_name(upload.selected_sw_imgfmt));
  225|      0|                filters[2] = upload.f;
  226|      0|            }
  227|      0|            hw_to_sw = false;
  228|      0|            need_sws = false;
  229|      0|        } else {
  230|      0|            mp_err(log, "Failed to create HW uploader for format %s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  231|      0|                   mp_imgfmt_to_name(src_fmt));
  232|      0|        }
  233|      0|    } else if (dst_all_hw && num_fmts > 0) {
  ------------------
  |  Branch (233:16): [True: 0, False: 0]
  |  Branch (233:30): [True: 0, False: 0]
  ------------------
  234|      0|        bool upload_created = false;
  235|      0|        int sw_fmt = imgfmt_is_sw ? img->imgfmt : img->params.hw_subfmt;
  ------------------
  |  Branch (235:22): [True: 0, False: 0]
  ------------------
  236|       |
  237|      0|        for (int i = 0; i < num_fmts; i++) {
  ------------------
  |  Branch (237:25): [True: 0, False: 0]
  ------------------
  238|       |            // We can probably use this! Very lazy and very approximate.
  239|      0|            struct mp_hwupload upload = mp_hwupload_create(conv, fmts[i],
  240|      0|                                                           sw_fmt, false);
  241|      0|            if (upload.successful_init) {
  ------------------
  |  Branch (241:17): [True: 0, False: 0]
  ------------------
  242|      0|                mp_info(log, "HW-uploading to %s\n", mp_imgfmt_to_name(fmts[i]));
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  243|      0|                filters[2] = upload.f;
  244|      0|                hwupload_fmt = upload.selected_sw_imgfmt;
  245|      0|                fmts = &hwupload_fmt;
  246|      0|                num_fmts = hwupload_fmt ? 1 : 0;
  ------------------
  |  Branch (246:28): [True: 0, False: 0]
  ------------------
  247|      0|                hw_to_sw = false;
  248|       |
  249|       |                // We cannot do format conversions when transferring between
  250|       |                // two hardware devices, so reject this format if that would be
  251|       |                // required.
  252|      0|                if (!imgfmt_is_sw && hwupload_fmt != sw_fmt) {
  ------------------
  |  Branch (252:21): [True: 0, False: 0]
  |  Branch (252:38): [True: 0, False: 0]
  ------------------
  253|      0|                    mp_err(log, "Format %s is not supported by %s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  254|      0|                           mp_imgfmt_to_name(sw_fmt),
  255|      0|                           mp_imgfmt_to_name(p->imgfmts[i]));
  256|      0|                    continue;
  257|      0|                }
  258|      0|                upload_created = true;
  259|      0|                break;
  260|      0|            }
  261|      0|        }
  262|      0|        if (!upload_created) {
  ------------------
  |  Branch (262:13): [True: 0, False: 0]
  ------------------
  263|      0|            mp_err(log, "Failed to create HW uploader for format %s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  264|      0|                   mp_imgfmt_to_name(sw_fmt));
  265|      0|        }
  266|      0|    }
  267|       |
  268|      0|    int src_fmt = img->imgfmt;
  269|      0|    if (hw_to_sw) {
  ------------------
  |  Branch (269:9): [True: 0, False: 0]
  ------------------
  270|      0|        mp_info(log, "HW-downloading from %s\n", mp_imgfmt_to_name(img->imgfmt));
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  271|      0|        int res_fmt = mp_image_hw_download_get_sw_format(img);
  272|      0|        if (!res_fmt) {
  ------------------
  |  Branch (272:13): [True: 0, False: 0]
  ------------------
  273|      0|            mp_err(log, "cannot copy surface of this format to CPU memory\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  274|      0|            goto fail;
  275|      0|        }
  276|      0|        struct mp_hwdownload *hwd = mp_hwdownload_create(conv);
  277|      0|        if (hwd) {
  ------------------
  |  Branch (277:13): [True: 0, False: 0]
  ------------------
  278|      0|            filters[0] = hwd->f;
  279|      0|            src_fmt = res_fmt;
  280|       |            // Downloading from hw will obviously change the parameters. We
  281|       |            // stupidly don't know the result parameters, but if it's
  282|       |            // sufficiently sane, it will only do the following.
  283|      0|            imgpar.imgfmt = src_fmt;
  284|      0|            imgpar.hw_subfmt = 0;
  285|       |            // Try to compensate for in-sane cases.
  286|      0|            mp_image_params_guess_csp(&imgpar);
  287|      0|        }
  288|      0|    }
  289|       |
  290|      0|    if (p->imgparams_set) {
  ------------------
  |  Branch (290:9): [True: 0, False: 0]
  ------------------
  291|      0|        force_sws_params |= !mp_image_params_equal(&imgpar, &p->imgparams);
  292|      0|        need_sws |= force_sws_params;
  293|      0|    }
  294|      0|    if (!imgfmt_is_sw && dst_all_hw) {
  ------------------
  |  Branch (294:9): [True: 0, False: 0]
  |  Branch (294:26): [True: 0, False: 0]
  ------------------
  295|       |        // This is a hw -> hw upload, so the sw format must already be
  296|       |        // mutually understood. No conversion can be done.
  297|      0|        need_sws = false;
  298|      0|    }
  299|       |
  300|      0|    if (need_sws) {
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|       |        // Create a new conversion filter.
  302|      0|        struct mp_sws_filter *sws = mp_sws_filter_create(conv);
  303|      0|        if (!sws) {
  ------------------
  |  Branch (303:13): [True: 0, False: 0]
  ------------------
  304|      0|            mp_err(log, "error creating conversion filter\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  305|      0|            goto fail;
  306|      0|        }
  307|       |
  308|      0|        sws->force_scaler = c->force_scaler;
  309|       |
  310|      0|        int out = mp_sws_find_best_out_format(sws, src_fmt, fmts, num_fmts);
  311|      0|        if (!out) {
  ------------------
  |  Branch (311:13): [True: 0, False: 0]
  ------------------
  312|      0|            mp_err(log, "can't find video conversion for %s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  313|      0|                   mp_imgfmt_to_name(src_fmt));
  314|      0|            goto fail;
  315|      0|        }
  316|       |
  317|      0|        if (out == src_fmt && !force_sws_params) {
  ------------------
  |  Branch (317:13): [True: 0, False: 0]
  |  Branch (317:31): [True: 0, False: 0]
  ------------------
  318|       |            // Can happen if hwupload goes to same format.
  319|      0|            talloc_free(sws->f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  320|      0|        } else {
  321|      0|            sws->out_format = out;
  322|      0|            sws->out_params = p->imgparams;
  323|      0|            sws->use_out_params = force_sws_params;
  324|      0|            mp_info(log, "Converting %s -> %s\n", mp_imgfmt_to_name(src_fmt),
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  325|      0|                    mp_imgfmt_to_name(sws->out_format));
  326|      0|            filters[1] = sws->f;
  327|      0|        }
  328|      0|    }
  329|       |
  330|      0|    mp_chain_filters(conv->ppins[0], conv->ppins[1], filters, 3);
  331|       |
  332|      0|    *f_out = conv;
  333|      0|    return true;
  334|       |
  335|      0|fail:
  336|      0|    talloc_free(conv);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  337|       |    return false;
  338|      0|}
f_autoconvert.c:autoconvert_destroy:
  549|  21.8k|{
  550|  21.8k|    struct priv *p = f->priv;
  551|       |
  552|  21.8k|    mp_subfilter_reset(&p->sub);
  553|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  21.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  21.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  554|  21.8k|}
f_autoconvert.c:autoconvert_process:
  487|  1.75M|{
  488|  1.75M|    struct priv *p = f->priv;
  489|       |
  490|  1.75M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (490:9): [True: 883k, False: 871k]
  ------------------
  491|   883k|        return;
  492|       |
  493|   871k|    if (p->sub.frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (493:9): [True: 43.7k, False: 828k]
  ------------------
  494|  43.7k|        handle_video_frame(f);
  495|  43.7k|        return;
  496|  43.7k|    }
  497|       |
  498|   828k|    if (p->sub.frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (498:9): [True: 808k, False: 19.2k]
  ------------------
  499|   808k|        handle_audio_frame(f);
  500|   808k|        return;
  501|   808k|    }
  502|       |
  503|  19.2k|    mp_subfilter_continue(&p->sub);
  504|  19.2k|}
f_autoconvert.c:handle_video_frame:
  350|  43.7k|{
  351|  43.7k|    struct priv *p = f->priv;
  352|       |
  353|  43.7k|    struct mp_image *img = p->sub.frame.data;
  354|       |
  355|  43.7k|    if (p->force_update)
  ------------------
  |  Branch (355:9): [True: 1.84k, False: 41.9k]
  ------------------
  356|  1.84k|        p->in_imgfmt = p->in_subfmt = 0;
  357|       |
  358|  43.7k|    if (img->imgfmt == p->in_imgfmt && img->params.hw_subfmt == p->in_subfmt) {
  ------------------
  |  Branch (358:9): [True: 41.9k, False: 1.84k]
  |  Branch (358:40): [True: 41.9k, False: 0]
  ------------------
  359|  41.9k|        mp_subfilter_continue(&p->sub);
  360|  41.9k|        return;
  361|  41.9k|    }
  362|       |
  363|  1.84k|    if (!mp_subfilter_drain_destroy(&p->sub)) {
  ------------------
  |  Branch (363:9): [True: 0, False: 1.84k]
  ------------------
  364|      0|        MP_VERBOSE(f, "Sub-filter requires draining but we must destroy it now.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  365|      0|        mp_subfilter_destroy(&p->sub);
  366|      0|    }
  367|       |
  368|  1.84k|    p->in_imgfmt = img->params.imgfmt;
  369|  1.84k|    p->in_subfmt = img->params.hw_subfmt;
  370|  1.84k|    p->force_update = false;
  371|       |
  372|  1.84k|    struct mp_filter *conv = NULL;
  373|  1.84k|    if (build_image_converter(&p->public, p->log, img, &conv)) {
  ------------------
  |  Branch (373:9): [True: 1.84k, False: 0]
  ------------------
  374|  1.84k|        p->sub.filter = conv;
  375|  1.84k|        mp_subfilter_continue(&p->sub);
  376|  1.84k|    } else {
  377|      0|        mp_filter_internal_mark_failed(f);
  378|      0|    }
  379|  1.84k|}
f_autoconvert.c:handle_audio_frame:
  382|   808k|{
  383|   808k|    struct priv *p = f->priv;
  384|       |
  385|   808k|    struct mp_aframe *aframe = p->sub.frame.data;
  386|       |
  387|   808k|    int afmt = mp_aframe_get_format(aframe);
  388|   808k|    int srate = mp_aframe_get_rate(aframe);
  389|   808k|    struct mp_chmap chmap = {0};
  390|   808k|    mp_aframe_get_chmap(aframe, &chmap);
  391|       |
  392|   808k|    if (p->resampling_forced && !af_fmt_is_pcm(afmt)) {
  ------------------
  |  Branch (392:9): [True: 0, False: 808k]
  |  Branch (392:33): [True: 0, False: 0]
  ------------------
  393|      0|        MP_WARN(p, "ignoring request to resample non-PCM audio for speed change\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  394|      0|        p->resampling_forced = false;
  395|      0|    }
  396|       |
  397|   808k|    bool format_change = afmt != p->in_afmt ||
  ------------------
  |  Branch (397:26): [True: 12.2k, False: 796k]
  ------------------
  398|   796k|                         srate != p->in_srate ||
  ------------------
  |  Branch (398:26): [True: 3.18k, False: 793k]
  ------------------
  399|   793k|                         !mp_chmap_equals(&chmap, &p->in_chmap) ||
  ------------------
  |  Branch (399:26): [True: 585, False: 792k]
  ------------------
  400|   792k|                         p->force_update;
  ------------------
  |  Branch (400:26): [True: 0, False: 792k]
  ------------------
  401|       |
  402|   808k|    if (!format_change && (!p->resampling_forced || p->sub.filter))
  ------------------
  |  Branch (402:9): [True: 792k, False: 15.9k]
  |  Branch (402:28): [True: 792k, False: 0]
  |  Branch (402:53): [True: 0, False: 0]
  ------------------
  403|   792k|        goto cont;
  404|       |
  405|  15.9k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (405:9): [True: 0, False: 15.9k]
  ------------------
  406|      0|        return;
  407|       |
  408|  15.9k|    if (format_change && p->public.on_audio_format_change) {
  ------------------
  |  Branch (408:9): [True: 15.9k, False: 0]
  |  Branch (408:26): [True: 15.9k, False: 0]
  ------------------
  409|  15.9k|        if (p->format_change_blocked)
  ------------------
  |  Branch (409:13): [True: 0, False: 15.9k]
  ------------------
  410|      0|            return;
  411|       |
  412|  15.9k|        if (!p->format_change_cont) {
  ------------------
  |  Branch (412:13): [True: 8.04k, False: 7.95k]
  ------------------
  413|  8.04k|            p->format_change_blocked = true;
  414|  8.04k|            p->public.
  415|  8.04k|                on_audio_format_change(p->public.on_audio_format_change_opaque);
  416|  8.04k|            return;
  417|  8.04k|        }
  418|  7.95k|        p->format_change_cont = false;
  419|  7.95k|    }
  420|       |
  421|  7.95k|    p->in_afmt = afmt;
  422|  7.95k|    p->in_srate = srate;
  423|  7.95k|    p->in_chmap = chmap;
  424|  7.95k|    p->force_update = false;
  425|       |
  426|  7.95k|    int out_afmt = 0;
  427|  7.95k|    int best_score = 0;
  428|  15.9k|    for (int n = 0; n < p->num_afmts; n++) {
  ------------------
  |  Branch (428:21): [True: 7.95k, False: 7.95k]
  ------------------
  429|  7.95k|        int score = af_format_conversion_score(p->afmts[n], afmt);
  430|  7.95k|        if (!out_afmt || score > best_score) {
  ------------------
  |  Branch (430:13): [True: 7.95k, False: 0]
  |  Branch (430:26): [True: 0, False: 0]
  ------------------
  431|  7.95k|            best_score = score;
  432|  7.95k|            out_afmt = p->afmts[n];
  433|  7.95k|        }
  434|  7.95k|    }
  435|  7.95k|    if (!out_afmt)
  ------------------
  |  Branch (435:9): [True: 0, False: 7.95k]
  ------------------
  436|      0|        out_afmt = afmt;
  437|       |
  438|       |    // Raw DSD can only be converted to PCM, not resampled.
  439|  7.95k|    if (p->resampling_forced && out_afmt == AF_FORMAT_DSD) {
  ------------------
  |  Branch (439:9): [True: 0, False: 7.95k]
  |  Branch (439:33): [True: 0, False: 0]
  ------------------
  440|      0|        MP_WARN(p, "ignoring request to resample DSD audio\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  441|      0|        p->resampling_forced = false;
  442|      0|    }
  443|       |
  444|       |    // (The p->srates array is 0-terminated already.)
  445|  7.95k|    int out_srate = af_select_best_samplerate(srate, p->srates);
  446|  7.95k|    if (out_srate <= 0)
  ------------------
  |  Branch (446:9): [True: 0, False: 7.95k]
  ------------------
  447|      0|        out_srate = p->num_srates ? p->srates[0] : srate;
  ------------------
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|       |
  449|  7.95k|    struct mp_chmap out_chmap = chmap;
  450|  7.95k|    if (p->chmaps.num_chmaps) {
  ------------------
  |  Branch (450:9): [True: 7.95k, False: 0]
  ------------------
  451|  7.95k|        if (!mp_chmap_sel_adjust(&p->chmaps, &out_chmap))
  ------------------
  |  Branch (451:13): [True: 0, False: 7.95k]
  ------------------
  452|      0|            out_chmap = p->chmaps.chmaps[0]; // violently force fallback
  453|  7.95k|    }
  454|       |
  455|  7.95k|    if (out_afmt == p->in_afmt && out_srate == p->in_srate &&
  ------------------
  |  Branch (455:9): [True: 7.95k, False: 0]
  |  Branch (455:35): [True: 7.95k, False: 0]
  ------------------
  456|  7.95k|        mp_chmap_equals(&out_chmap, &p->in_chmap) && !p->resampling_forced)
  ------------------
  |  Branch (456:9): [True: 7.95k, False: 0]
  |  Branch (456:54): [True: 7.95k, False: 0]
  ------------------
  457|  7.95k|    {
  458|  7.95k|        goto cont;
  459|  7.95k|    }
  460|       |
  461|      0|    MP_VERBOSE(p, "inserting resampler\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  462|       |
  463|      0|    struct mp_swresample *s = mp_swresample_create(f, NULL);
  464|      0|    if (!s)
  ------------------
  |  Branch (464:9): [True: 0, False: 0]
  ------------------
  465|      0|        abort();
  466|       |
  467|      0|    s->out_format = out_afmt;
  468|      0|    s->out_rate = out_srate;
  469|      0|    s->out_channels = out_chmap;
  470|       |
  471|      0|    p->sub.filter = s->f;
  472|       |
  473|   800k|cont:
  474|       |
  475|   800k|    if (p->sub.filter) {
  ------------------
  |  Branch (475:9): [True: 0, False: 800k]
  ------------------
  476|      0|        struct mp_filter_command cmd = {
  477|      0|            .type = MP_FILTER_COMMAND_SET_SPEED_RESAMPLE,
  478|      0|            .speed = p->audio_speed,
  479|      0|        };
  480|      0|        mp_filter_command(p->sub.filter, &cmd);
  481|      0|    }
  482|       |
  483|   800k|    mp_subfilter_continue(&p->sub);
  484|   800k|}
f_autoconvert.c:autoconvert_command:
  518|   899k|{
  519|   899k|    struct priv *p = f->priv;
  520|       |
  521|   899k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_RESAMPLE) {
  ------------------
  |  Branch (521:9): [True: 11.7k, False: 887k]
  ------------------
  522|  11.7k|        p->audio_speed = cmd->speed;
  523|       |        // If we needed resampling once, keep forcing resampling, as it might be
  524|       |        // quickly changing between 1.0 and other values for A/V compensation.
  525|  11.7k|        if (p->audio_speed != 1.0)
  ------------------
  |  Branch (525:13): [True: 0, False: 11.7k]
  ------------------
  526|      0|            p->resampling_forced = true;
  527|  11.7k|        return true;
  528|  11.7k|    }
  529|       |
  530|   887k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (530:9): [True: 863k, False: 23.5k]
  ------------------
  531|   863k|        cmd->is_active = !!p->sub.filter;
  532|   863k|        return true;
  533|   863k|    }
  534|       |
  535|  23.5k|    return false;
  536|   887k|}

mp_decoder_wrapper_control:
  363|  9.72k|{
  364|  9.72k|    struct priv *p = d->f->priv;
  365|  9.72k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  9.72k|#define CONTROL_UNKNOWN -1
  ------------------
  366|  9.72k|    if (p->is_group) {
  ------------------
  |  Branch (366:9): [True: 0, False: 9.72k]
  ------------------
  367|      0|        mp_assert(p->num_children);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      0|        for (int i = 0; i < p->num_children; i++) {
  ------------------
  |  Branch (368:25): [True: 0, False: 0]
  ------------------
  369|       |            // Forward control to all children, but get the result from the last
  370|       |            // one. Currently it is used only for same decoders, so we care only
  371|       |            // about the control, and the result for GET can be whatever.
  372|      0|            res = mp_decoder_wrapper_control(p->children[i], cmd, arg);
  373|      0|            if (i == p->num_children - 1)
  ------------------
  |  Branch (373:17): [True: 0, False: 0]
  ------------------
  374|      0|                return res;
  375|      0|        }
  376|      0|        return res;
  377|      0|    }
  378|  9.72k|    thread_lock(p);
  379|  9.72k|    if (cmd == VDCTRL_GET_HWDEC) {
  ------------------
  |  Branch (379:9): [True: 0, False: 9.72k]
  ------------------
  380|      0|        res = update_cached_values(p);
  381|      0|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  382|      0|        *(char **)arg = p->cur_hwdec;
  383|      0|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  384|  9.72k|    } else {
  385|  9.72k|        if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (385:13): [True: 9.72k, False: 0]
  |  Branch (385:27): [True: 9.72k, False: 0]
  ------------------
  386|  9.72k|            res = p->decoder->control(p->decoder->f, cmd, arg);
  387|  9.72k|        update_cached_values(p);
  388|  9.72k|    }
  389|  9.72k|    thread_unlock(p);
  390|  9.72k|    return res;
  391|  9.72k|}
mp_decoder_wrapper_reinit:
  532|  21.8k|{
  533|  21.8k|    struct priv *p = d->f->priv;
  534|  21.8k|    if (p->is_group) {
  ------------------
  |  Branch (534:9): [True: 0, False: 21.8k]
  ------------------
  535|      0|        for (int i = 0; i < p->num_children; i++) {
  ------------------
  |  Branch (535:25): [True: 0, False: 0]
  ------------------
  536|      0|            if (!mp_decoder_wrapper_reinit(p->children[i]))
  ------------------
  |  Branch (536:17): [True: 0, False: 0]
  ------------------
  537|      0|                return false;
  538|      0|        }
  539|      0|        return true;
  540|      0|    }
  541|  21.8k|    thread_lock(p);
  542|       |    bool res = reinit_decoder(p);
  543|  21.8k|    thread_unlock(p);
  544|  21.8k|    return res;
  545|  21.8k|}
mp_decoder_wrapper_get_container_fps:
  578|  7.67k|{
  579|  7.67k|    struct priv *p = d->f->priv;
  580|  7.67k|    thread_lock(p);
  581|  7.67k|    double res = p->fps;
  582|  7.67k|    thread_unlock(p);
  583|  7.67k|    return res;
  584|  7.67k|}
mp_decoder_wrapper_set_spdif_flag:
  587|  12.1k|{
  588|  12.1k|    struct priv *p = d->f->priv;
  589|  12.1k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  12.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  590|  12.1k|    p->try_spdif = spdif;
  591|  12.1k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  12.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  592|  12.1k|}
mp_decoder_wrapper_get_pts_reset:
  603|  11.1k|{
  604|  11.1k|    struct priv *p = d->f->priv;
  605|  11.1k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  11.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  606|  11.1k|    bool res = p->pts_reset;
  607|  11.1k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  11.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  608|  11.1k|    return res;
  609|  11.1k|}
mp_decoder_wrapper_set_play_dir:
  612|  29.1k|{
  613|  29.1k|    struct priv *p = d->f->priv;
  614|  29.1k|    if (p->is_group) {
  ------------------
  |  Branch (614:9): [True: 0, False: 29.1k]
  ------------------
  615|      0|        for (int i = 0; i < p->num_children; i++)
  ------------------
  |  Branch (615:25): [True: 0, False: 0]
  ------------------
  616|      0|            mp_decoder_wrapper_set_play_dir(p->children[i], dir);
  617|      0|        p->play_dir = dir;
  618|      0|        return;
  619|      0|    }
  620|  29.1k|    thread_lock(p);
  621|  29.1k|    p->play_dir = dir;
  622|  29.1k|    thread_unlock(p);
  623|  29.1k|}
mp_decoder_wrapper_create:
 1378|  21.8k|{
 1379|  21.8k|    struct mp_filter *public_f = mp_filter_create(parent, &decode_wrapper_filter);
 1380|  21.8k|    if (!public_f)
  ------------------
  |  Branch (1380:9): [True: 0, False: 21.8k]
  ------------------
 1381|      0|        return NULL;
 1382|       |
 1383|  21.8k|    struct priv *p = public_f->priv;
 1384|  21.8k|    p->public.f = public_f;
 1385|       |
 1386|  21.8k|    mp_mutex_init(&p->cache_lock);
 1387|  21.8k|    p->opt_cache = m_config_cache_alloc(p, public_f->global, &dec_wrapper_conf);
 1388|  21.8k|    p->opts = p->opt_cache->opts;
 1389|  21.8k|    p->header = src;
 1390|  21.8k|    p->codec = p->header->codec;
 1391|  21.8k|    p->play_dir = 1;
 1392|  21.8k|    mp_filter_add_pin(public_f, MP_PIN_OUT, "out");
 1393|       |
 1394|  21.8k|    if (src->group && src->group->lavfi_graph) {
  ------------------
  |  Branch (1394:9): [True: 0, False: 21.8k]
  |  Branch (1394:23): [True: 0, False: 0]
  ------------------
 1395|      0|        const char *tag = src->type == STREAM_AUDIO ? "!ad" : "!vd";
  ------------------
  |  Branch (1395:27): [True: 0, False: 0]
  ------------------
 1396|      0|        p->log = mp_log_new(p, parent->global->log, tag);
 1397|      0|        public_f->log = p->log;
 1398|      0|        if (!init_group_decoder(p, public_f))
  ------------------
  |  Branch (1398:13): [True: 0, False: 0]
  ------------------
 1399|      0|            goto error;
 1400|      0|        public_f_reset(public_f);
 1401|      0|        return &p->public;
 1402|      0|    }
 1403|       |
 1404|  21.8k|    if (p->header->type == STREAM_VIDEO) {
  ------------------
  |  Branch (1404:9): [True: 9.69k, False: 12.1k]
  ------------------
 1405|  9.69k|        p->log = mp_log_new(p, parent->global->log, "!vd");
 1406|       |
 1407|  9.69k|        p->fps = src->codec->fps;
 1408|       |
 1409|  9.69k|        MP_VERBOSE(p, "Container reported FPS: %f\n", p->fps);
  ------------------
  |  |   92|  9.69k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.69k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1410|       |
 1411|  9.69k|        if (p->opts->fps_override) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 9.69k]
  ------------------
 1412|      0|            p->fps = p->opts->fps_override;
 1413|      0|            MP_INFO(p, "Container FPS forced to %5.3f.\n", p->fps);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1414|      0|            MP_INFO(p, "Use --no-correct-pts to force FPS based timing.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1415|      0|        }
 1416|       |
 1417|  9.69k|        p->queue_opts = p->opts->vdec_queue_opts;
 1418|  12.1k|    } else if (p->header->type == STREAM_AUDIO) {
  ------------------
  |  Branch (1418:16): [True: 12.1k, False: 0]
  ------------------
 1419|  12.1k|        p->log = mp_log_new(p, parent->global->log, "!ad");
 1420|  12.1k|        p->queue_opts = p->opts->adec_queue_opts;
 1421|  12.1k|    } else {
 1422|      0|        goto error;
 1423|      0|    }
 1424|       |
 1425|  21.8k|    if (p->queue_opts && p->queue_opts->use_queue) {
  ------------------
  |  Branch (1425:9): [True: 21.8k, False: 0]
  |  Branch (1425:26): [True: 0, False: 21.8k]
  ------------------
 1426|      0|        p->queue = mp_async_queue_create();
 1427|      0|        p->dec_dispatch = mp_dispatch_create(p);
 1428|      0|        p->dec_root_filter = mp_filter_create_root(public_f->global);
 1429|      0|        mp_filter_graph_set_wakeup_cb(p->dec_root_filter, wakeup_dec_thread, p);
 1430|      0|        mp_dispatch_set_onlock_fn(p->dec_dispatch, onlock_dec_thread, p);
 1431|       |
 1432|      0|        struct mp_stream_info *sinfo = mp_filter_find_stream_info(parent);
 1433|      0|        if (sinfo) {
  ------------------
  |  Branch (1433:13): [True: 0, False: 0]
  ------------------
 1434|      0|            p->dec_root_filter->stream_info = &p->stream_info;
 1435|      0|            p->stream_info = (struct mp_stream_info){
 1436|      0|                .dr_vo = sinfo->dr_vo,
 1437|      0|                .hwdec_devs = sinfo->hwdec_devs,
 1438|      0|            };
 1439|      0|        }
 1440|       |
 1441|      0|        update_queue_config(p);
 1442|      0|    }
 1443|       |
 1444|  21.8k|    p->decf = mp_filter_create(p->dec_root_filter ? p->dec_root_filter : public_f,
  ------------------
  |  Branch (1444:32): [True: 0, False: 21.8k]
  ------------------
 1445|  21.8k|                               &decf_filter);
 1446|  21.8k|    if (!p->decf)
  ------------------
  |  Branch (1446:9): [True: 0, False: 21.8k]
  ------------------
 1447|      0|        goto error;
 1448|  21.8k|    p->decf->priv = p;
 1449|  21.8k|    p->decf->log = public_f->log = p->log;
 1450|  21.8k|    mp_filter_add_pin(p->decf, MP_PIN_OUT, "out");
 1451|       |
 1452|  21.8k|    struct mp_filter *demux = mp_demux_in_create(p->decf, p->header);
 1453|  21.8k|    if (!demux)
  ------------------
  |  Branch (1453:9): [True: 0, False: 21.8k]
  ------------------
 1454|      0|        goto error;
 1455|  21.8k|    p->demux = demux->pins[0];
 1456|       |
 1457|  21.8k|    decf_reset(p->decf);
 1458|       |
 1459|  21.8k|    struct mp_pin *out_pin;
 1460|  21.8k|    if (p->queue) {
  ------------------
  |  Branch (1460:9): [True: 0, False: 21.8k]
  ------------------
 1461|      0|        struct mp_filter *f_in =
 1462|      0|            mp_async_queue_create_filter(public_f, MP_PIN_OUT, p->queue);
 1463|      0|        struct mp_filter *f_out =
 1464|      0|            mp_async_queue_create_filter(p->decf, MP_PIN_IN, p->queue);
 1465|      0|        mp_pin_connect(f_out->pins[0], p->decf->pins[0]);
 1466|      0|        out_pin = f_in->pins[0];
 1467|       |
 1468|      0|        p->dec_thread_valid = true;
 1469|      0|        if (mp_thread_create(&p->dec_thread, dec_thread, p)) {
  ------------------
  |  |  214|      0|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1470|      0|            p->dec_thread_valid = false;
 1471|      0|            goto error;
 1472|      0|        }
 1473|  21.8k|    } else {
 1474|  21.8k|        out_pin = p->decf->pins[0];
 1475|  21.8k|    }
 1476|       |
 1477|  21.8k|    mp_pin_connect(public_f->ppins[0], out_pin);
 1478|       |
 1479|  21.8k|    public_f_reset(public_f);
 1480|       |
 1481|  21.8k|    return &p->public;
 1482|      0|error:
 1483|      0|    talloc_free(public_f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1484|       |    return NULL;
 1485|  21.8k|}
lavc_process:
 1490|  3.68M|{
 1491|  3.68M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (1491:9): [True: 19.4k, False: 3.66M]
  ------------------
 1492|  19.4k|        return;
 1493|       |
 1494|  3.66M|    struct mp_frame frame = {0};
 1495|  3.66M|    int ret_recv = receive(f, &frame);
 1496|  3.66M|    if (frame.type) {
  ------------------
  |  Branch (1496:9): [True: 844k, False: 2.82M]
  ------------------
 1497|   844k|        state->eof_returned = false;
 1498|   844k|        mp_pin_in_write(f->ppins[1], frame);
 1499|  2.82M|    } else if (ret_recv == AVERROR_EOF) {
  ------------------
  |  Branch (1499:16): [True: 13.5k, False: 2.80M]
  ------------------
 1500|  13.5k|        if (!state->eof_returned)
  ------------------
  |  Branch (1500:13): [True: 13.5k, False: 0]
  ------------------
 1501|  13.5k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  13.5k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  13.5k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1502|  13.5k|        state->eof_returned = true;
 1503|  13.5k|        state->packets_sent = false;
 1504|  2.80M|    } else if (ret_recv == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1504:16): [True: 2.79M, False: 16.0k]
  ------------------
 1505|       |        // Need to feed a packet.
 1506|  2.79M|        frame = mp_pin_out_read(f->ppins[0]);
 1507|  2.79M|        struct demux_packet *pkt = NULL;
 1508|  2.79M|        if (frame.type == MP_FRAME_PACKET) {
  ------------------
  |  Branch (1508:13): [True: 1.37M, False: 1.41M]
  ------------------
 1509|  1.37M|            pkt = frame.data;
 1510|  1.41M|        } else if (frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1510:20): [True: 1.39M, False: 19.2k]
  ------------------
 1511|  1.39M|            if (frame.type) {
  ------------------
  |  Branch (1511:17): [True: 0, False: 1.39M]
  ------------------
 1512|      0|                MP_ERR(f, "unexpected frame type\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1513|      0|                mp_frame_unref(&frame);
 1514|      0|                mp_filter_internal_mark_failed(f);
 1515|      0|            }
 1516|  1.39M|            return;
 1517|  1.39M|        } else if (!state->packets_sent) {
  ------------------
  |  Branch (1517:20): [True: 5.71k, False: 13.5k]
  ------------------
 1518|       |            // EOF only; just return it, without requiring send/receive to
 1519|       |            // pass it through properly.
 1520|  5.71k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  5.71k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  5.71k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1521|  5.71k|            return;
 1522|  5.71k|        }
 1523|  1.39M|        int ret_send = send(f, pkt);
 1524|  1.39M|        if (ret_send == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1524:13): [True: 0, False: 1.39M]
  ------------------
 1525|       |            // Should never happen, but can happen with broken decoders.
 1526|      0|            MP_WARN(f, "could not consume packet\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1527|      0|            mp_pin_out_unread(f->ppins[0], frame);
 1528|      0|            mp_filter_wakeup(f);
 1529|      0|            return;
 1530|      0|        }
 1531|  1.39M|        state->packets_sent = true;
 1532|  1.39M|        demux_packet_pool_push(f->packet_pool, pkt);
 1533|  1.39M|        mp_filter_internal_mark_progress(f);
 1534|  1.39M|    } else {
 1535|       |        // Decoding error, or hwdec fallback recovery. Just try again.
 1536|  16.0k|        mp_filter_internal_mark_progress(f);
 1537|  16.0k|    }
 1538|  3.66M|}
f_decoder_wrapper.c:thread_lock:
  292|  68.4k|{
  293|  68.4k|    if (p->dec_dispatch)
  ------------------
  |  Branch (293:9): [True: 0, False: 68.4k]
  ------------------
  294|      0|        mp_dispatch_lock(p->dec_dispatch);
  295|       |
  296|  68.4k|    mp_assert(!p->dec_thread_lock);
  ------------------
  |  |   41|  68.4k|#define mp_assert assert
  ------------------
  |  Branch (296:5): [True: 68.4k, False: 0]
  ------------------
  297|  68.4k|    p->dec_thread_lock = true;
  298|  68.4k|}
f_decoder_wrapper.c:update_cached_values:
  275|  31.6k|{
  276|  31.6k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  31.6k|#define CONTROL_UNKNOWN -1
  ------------------
  277|  31.6k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  31.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  278|       |
  279|  31.6k|    p->cur_hwdec = NULL;
  280|  31.6k|    if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (280:9): [True: 29.1k, False: 2.45k]
  |  Branch (280:23): [True: 17.3k, False: 11.7k]
  ------------------
  281|  17.3k|        res = p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
  282|       |
  283|  31.6k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  31.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  284|  31.6k|    return res;
  285|  31.6k|}
f_decoder_wrapper.c:thread_unlock:
  302|  68.4k|{
  303|  68.4k|    mp_assert(p->dec_thread_lock);
  ------------------
  |  |   41|  68.4k|#define mp_assert assert
  ------------------
  |  Branch (303:5): [True: 68.4k, False: 0]
  ------------------
  304|  68.4k|    p->dec_thread_lock = false;
  305|       |
  306|  68.4k|    if (p->dec_dispatch)
  ------------------
  |  Branch (306:9): [True: 0, False: 68.4k]
  ------------------
  307|      0|        mp_dispatch_unlock(p->dec_dispatch);
  308|  68.4k|}
f_decoder_wrapper.c:reinit_decoder:
  425|  21.8k|{
  426|  21.8k|    if (p->decoder)
  ------------------
  |  Branch (426:9): [True: 0, False: 21.8k]
  ------------------
  427|      0|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  428|  21.8k|    p->decoder = NULL;
  429|       |
  430|  21.8k|    reset_decoder(p);
  431|  21.8k|    p->has_broken_packet_pts = -10; // needs 10 packets to reach decision
  432|       |
  433|  21.8k|    const struct mp_decoder_fns *driver = NULL;
  434|  21.8k|    struct mp_decoder_list *list = NULL;
  435|  21.8k|    char *user_list = NULL;
  436|  21.8k|    char *fallback = NULL;
  437|       |
  438|  21.8k|    if (p->codec->type == STREAM_VIDEO) {
  ------------------
  |  Branch (438:9): [True: 9.69k, False: 12.1k]
  ------------------
  439|  9.69k|        driver = &vd_lavc;
  440|  9.69k|        user_list = p->opts->video_decoders;
  441|  9.69k|        fallback = "h264";
  442|  12.1k|    } else if (p->codec->type == STREAM_AUDIO) {
  ------------------
  |  Branch (442:16): [True: 12.1k, False: 0]
  ------------------
  443|  12.1k|        driver = &ad_lavc;
  444|  12.1k|        user_list = p->opts->audio_decoders;
  445|  12.1k|        fallback = "aac";
  446|       |
  447|  12.1k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  12.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  448|  12.1k|        bool try_spdif = p->try_spdif;
  449|  12.1k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  12.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  450|       |
  451|  12.1k|        if (try_spdif && p->codec->codec) {
  ------------------
  |  Branch (451:13): [True: 12.1k, False: 0]
  |  Branch (451:26): [True: 12.1k, False: 0]
  ------------------
  452|  12.1k|            struct mp_decoder_list *spdif =
  453|  12.1k|                select_spdif_codec(p->codec->codec, p->opts->audio_spdif);
  454|  12.1k|            if (spdif->num_entries) {
  ------------------
  |  Branch (454:17): [True: 0, False: 12.1k]
  ------------------
  455|      0|                driver = &ad_spdif;
  456|      0|                list = spdif;
  457|  12.1k|            } else {
  458|  12.1k|                talloc_free(spdif);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  459|  12.1k|                struct mp_decoder_list *dsd =
  460|  12.1k|                    select_dsd_codec(p->codec->codec, p->opts->audio_spdif);
  461|  12.1k|                if (dsd->num_entries) {
  ------------------
  |  Branch (461:21): [True: 0, False: 12.1k]
  ------------------
  462|      0|                    driver = &ad_dsd;
  463|      0|                    list = dsd;
  464|  12.1k|                } else {
  465|  12.1k|                    talloc_free(dsd);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  466|  12.1k|                }
  467|  12.1k|            }
  468|  12.1k|        }
  469|  12.1k|    }
  470|       |
  471|  21.8k|    if (!driver)
  ------------------
  |  Branch (471:9): [True: 0, False: 21.8k]
  ------------------
  472|      0|        return false;
  473|       |
  474|  21.8k|    if (!list) {
  ------------------
  |  Branch (474:9): [True: 21.8k, False: 0]
  ------------------
  475|  21.8k|        struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  21.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  21.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|  21.8k|        driver->add_decoders(full);
  477|  21.8k|        const char *codec = p->codec->codec;
  478|  21.8k|        if (codec && strcmp(codec, "null") == 0)
  ------------------
  |  Branch (478:13): [True: 21.8k, False: 0]
  |  Branch (478:22): [True: 0, False: 21.8k]
  ------------------
  479|      0|            codec = fallback;
  480|  21.8k|        list = mp_select_decoders(p->log, full, codec, user_list);
  481|  21.8k|        talloc_free(full);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  482|  21.8k|    }
  483|       |
  484|  21.8k|    mp_print_decoders(p->log, MSGL_V, "Codec list:", list);
  485|       |
  486|  22.4k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (486:21): [True: 20.0k, False: 2.45k]
  ------------------
  487|  20.0k|        struct mp_decoder_entry *sel = &list->entries[n];
  488|  20.0k|        MP_VERBOSE(p, "Opening decoder %s\n", sel->decoder);
  ------------------
  |  |   92|  20.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  20.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|       |
  490|  20.0k|        p->decoder = driver->create(p->decf, p->codec, sel->decoder);
  491|  20.0k|        if (p->decoder) {
  ------------------
  |  Branch (491:13): [True: 19.4k, False: 559]
  ------------------
  492|  19.4k|            p->codec->decoder = talloc_strdup(p->codec, sel->decoder);
  ------------------
  |  |   50|  19.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  493|  19.4k|            p->codec->decoder_desc = talloc_strdup(p->codec, sel->desc && sel->desc[0] ? sel->desc : NULL);
  ------------------
  |  |   50|  19.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (493:62): [True: 19.4k, False: 0]
  |  Branch (493:75): [True: 19.4k, False: 0]
  ------------------
  494|  19.4k|            MP_VERBOSE(p, "Selected decoder: %s", sel->decoder);
  ------------------
  |  |   92|  19.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  495|  19.4k|            if (p->codec->decoder_desc)
  ------------------
  |  Branch (495:17): [True: 19.4k, False: 0]
  ------------------
  496|  19.4k|                MP_VERBOSE(p, " - %s", p->codec->decoder_desc);
  ------------------
  |  |   92|  19.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|  19.4k|            MP_VERBOSE(p, "\n");
  ------------------
  |  |   92|  19.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  498|  19.4k|            break;
  499|  19.4k|        }
  500|       |
  501|    559|        MP_WARN(p, "Decoder init failed for %s\n", sel->decoder);
  ------------------
  |  |   90|    559|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    559|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  502|    559|    }
  503|       |
  504|  21.8k|    if (!p->decoder) {
  ------------------
  |  Branch (504:9): [True: 2.45k, False: 19.4k]
  ------------------
  505|  2.45k|        MP_ERR(p, "Failed to initialize a decoder for codec '%s'.\n",
  ------------------
  |  |   89|  2.45k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.90k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 2.45k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|  2.45k|               p->codec->codec ? p->codec->codec : "<?>");
  507|  2.45k|    }
  508|       |
  509|  21.8k|    if (p->decoder && p->decoder->control) {
  ------------------
  |  Branch (509:9): [True: 19.4k, False: 2.45k]
  |  Branch (509:23): [True: 7.67k, False: 11.7k]
  ------------------
  510|  7.67k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  7.67k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  511|  7.67k|        int extra_hw_frames = p->extra_hw_frames;
  512|  7.67k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  7.67k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  513|  7.67k|        if (extra_hw_frames > 0) {
  ------------------
  |  Branch (513:13): [True: 0, False: 7.67k]
  ------------------
  514|      0|            p->decoder->control(p->decoder->f, VDCTRL_SET_EXTRA_HW_FRAMES,
  515|      0|                                &extra_hw_frames);
  516|      0|        }
  517|  7.67k|    }
  518|       |
  519|  21.8k|    update_cached_values(p);
  520|       |
  521|  21.8k|    talloc_free(list);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  522|  21.8k|    return !!p->decoder;
  523|  21.8k|}
f_decoder_wrapper.c:reset_decoder:
  315|  65.6k|{
  316|  65.6k|    p->first_packet_pdts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  317|  65.6k|    p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  318|  65.6k|    p->codec_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  319|  65.6k|    p->codec_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  320|  65.6k|    p->num_codec_pts_problems = 0;
  321|  65.6k|    p->num_codec_dts_problems = 0;
  322|  65.6k|    p->has_broken_decoded_pts = 0;
  323|  65.6k|    p->packets_without_output = 0;
  324|  65.6k|    mp_frame_unref(&p->packet);
  325|  65.6k|    p->packet_fed = false;
  326|  65.6k|    p->preroll_discard = false;
  327|  65.6k|    talloc_free(p->new_segment);
  ------------------
  |  |   47|  65.6k|#define talloc_free                     ta_free
  ------------------
  328|  65.6k|    p->new_segment = NULL;
  329|  65.6k|    p->start = p->end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  330|       |
  331|  65.6k|    if (p->decoder)
  ------------------
  |  Branch (331:9): [True: 0, False: 65.6k]
  ------------------
  332|      0|        mp_filter_reset(p->decoder->f);
  333|  65.6k|}
f_decoder_wrapper.c:public_f_destroy:
 1252|  21.8k|{
 1253|  21.8k|    struct priv *p = f->priv;
 1254|  21.8k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (1254:5): [True: 21.8k, False: 0]
  ------------------
 1255|       |
 1256|  21.8k|    if (p->dec_thread_valid) {
  ------------------
  |  Branch (1256:9): [True: 0, False: 21.8k]
  ------------------
 1257|      0|        mp_assert(p->dec_dispatch);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1257:9): [True: 0, False: 0]
  ------------------
 1258|      0|        thread_lock(p);
 1259|      0|        p->request_terminate_dec_thread = 1;
 1260|      0|        mp_dispatch_interrupt(p->dec_dispatch);
 1261|      0|        thread_unlock(p);
 1262|      0|        mp_thread_join(p->dec_thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1263|      0|        p->dec_thread_valid = false;
 1264|      0|    }
 1265|       |
 1266|  21.8k|    mp_filter_free_children(f);
 1267|       |
 1268|  21.8k|    talloc_free(p->dec_root_filter);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
 1269|  21.8k|    talloc_free(p->queue);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
 1270|  21.8k|    mp_mutex_destroy(&p->cache_lock);
  ------------------
  |  |  133|  21.8k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1271|  21.8k|}
f_decoder_wrapper.c:public_f_reset:
 1237|  21.8k|{
 1238|  21.8k|    struct priv *p = f->priv;
 1239|  21.8k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (1239:5): [True: 21.8k, False: 0]
  ------------------
 1240|       |
 1241|  21.8k|    if (p->queue) {
  ------------------
  |  Branch (1241:9): [True: 0, False: 21.8k]
  ------------------
 1242|      0|        mp_async_queue_reset(p->queue);
 1243|      0|        thread_lock(p);
 1244|      0|        mp_filter_reset(p->dec_root_filter);
 1245|      0|        mp_dispatch_interrupt(p->dec_dispatch);
 1246|      0|        thread_unlock(p);
 1247|      0|        mp_async_queue_resume(p->queue);
 1248|      0|    }
 1249|  21.8k|}
f_decoder_wrapper.c:decf_destroy:
  394|  21.8k|{
  395|  21.8k|    struct priv *p = f->priv;
  396|  21.8k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 21.8k, False: 0]
  ------------------
  397|       |
  398|  21.8k|    if (p->decoder) {
  ------------------
  |  Branch (398:9): [True: 19.4k, False: 2.45k]
  ------------------
  399|  19.4k|        MP_DBG(f, "Uninit decoder.\n");
  ------------------
  |  |   93|  19.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  400|  19.4k|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|  19.4k|#define talloc_free                     ta_free
  ------------------
  401|  19.4k|        p->decoder = NULL;
  402|  19.4k|        p->codec->decoder = NULL;
  403|  19.4k|        p->codec->decoder_desc = NULL;
  404|  19.4k|    }
  405|       |
  406|  21.8k|    decf_reset(f);
  407|  21.8k|    mp_frame_unref(&p->decoded_coverart);
  408|  21.8k|}
f_decoder_wrapper.c:decf_process:
 1205|  4.54M|{
 1206|  4.54M|    struct priv *p = f->priv;
 1207|  4.54M|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  4.54M|#define mp_assert assert
  ------------------
  |  Branch (1207:5): [True: 4.54M, False: 0]
  ------------------
 1208|       |
 1209|  4.54M|    if (m_config_cache_update(p->opt_cache))
  ------------------
  |  Branch (1209:9): [True: 0, False: 4.54M]
  ------------------
 1210|      0|        update_queue_config(p);
 1211|       |
 1212|  4.54M|    feed_packet(p);
 1213|  4.54M|    read_frame(p);
 1214|  4.54M|}
f_decoder_wrapper.c:feed_packet:
  967|  4.54M|{
  968|  4.54M|    if (!p->decoder || !mp_pin_in_needs_data(p->decoder->f->pins[0]))
  ------------------
  |  Branch (968:9): [True: 0, False: 4.54M]
  |  Branch (968:24): [True: 1.74M, False: 2.79M]
  ------------------
  969|  1.74M|        return;
  970|       |
  971|  2.79M|    if (p->decoded_coverart.type)
  ------------------
  |  Branch (971:9): [True: 0, False: 2.79M]
  ------------------
  972|      0|        return;
  973|       |
  974|       |    // Don't read after EOF was output. If the stream continues, the player
  975|       |    // creates a new decoder.
  976|  2.79M|    if (p->eof_output)
  ------------------
  |  Branch (976:9): [True: 0, False: 2.79M]
  ------------------
  977|      0|        return;
  978|       |
  979|  2.79M|    if (!p->packet.type && !p->new_segment) {
  ------------------
  |  Branch (979:9): [True: 2.79M, False: 0]
  |  Branch (979:28): [True: 2.79M, False: 0]
  ------------------
  980|  2.79M|        p->packet = mp_pin_out_read(p->demux);
  981|  2.79M|        if (!p->packet.type)
  ------------------
  |  Branch (981:13): [True: 1.39M, False: 1.39M]
  ------------------
  982|  1.39M|            return;
  983|  1.39M|        if (p->packet.type != MP_FRAME_EOF && p->packet.type != MP_FRAME_PACKET) {
  ------------------
  |  Branch (983:13): [True: 1.37M, False: 19.2k]
  |  Branch (983:47): [True: 0, False: 1.37M]
  ------------------
  984|      0|            MP_ERR(p, "invalid frame type from demuxer\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  985|      0|            mp_frame_unref(&p->packet);
  986|      0|            mp_filter_internal_mark_failed(p->decf);
  987|      0|            return;
  988|      0|        }
  989|  1.39M|    }
  990|       |
  991|  1.39M|    if (!p->packet.type)
  ------------------
  |  Branch (991:9): [True: 0, False: 1.39M]
  ------------------
  992|      0|        return;
  993|       |
  994|       |    // Flush current data if the packet is a new segment.
  995|  1.39M|    if (is_new_segment(p, p->packet)) {
  ------------------
  |  Branch (995:9): [True: 0, False: 1.39M]
  ------------------
  996|      0|        mp_assert(!p->new_segment);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (996:9): [True: 0, False: 0]
  ------------------
  997|      0|        p->new_segment = p->packet.data;
  998|      0|        p->packet = MP_EOF_FRAME;
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  999|      0|    }
 1000|       |
 1001|  1.39M|    mp_assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF);
  ------------------
  |  |   41|  1.39M|#define mp_assert assert
  ------------------
  |  Branch (1001:5): [True: 1.37M, False: 19.2k]
  |  Branch (1001:5): [True: 19.2k, False: 0]
  ------------------
 1002|  1.39M|    struct demux_packet *packet =
 1003|  1.39M|        p->packet.type == MP_FRAME_PACKET ? p->packet.data : NULL;
  ------------------
  |  Branch (1003:9): [True: 1.37M, False: 19.2k]
  ------------------
 1004|       |
 1005|       |    // For video framedropping, including parts of the hr-seek logic.
 1006|  1.39M|    if (p->decoder->control) {
  ------------------
  |  Branch (1006:9): [True: 156k, False: 1.23M]
  ------------------
 1007|   156k|        double start_pts = p->start_pts;
 1008|   156k|        if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|   313k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1008:13): [True: 0, False: 156k]
  |  Branch (1008:44): [True: 0, False: 0]
  ------------------
 1009|      0|                                           p->start > start_pts))
  ------------------
  |  Branch (1009:44): [True: 0, False: 0]
  ------------------
 1010|      0|            start_pts = p->start;
 1011|       |
 1012|   156k|        int framedrop_type = 0;
 1013|       |
 1014|   156k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   156k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1015|   156k|        if (p->attempt_framedrops)
  ------------------
  |  Branch (1015:13): [True: 0, False: 156k]
  ------------------
 1016|      0|            framedrop_type = 1;
 1017|   156k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   156k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1018|       |
 1019|   156k|        if (start_pts != MP_NOPTS_VALUE && packet && p->play_dir > 0 &&
  ------------------
  |  |   39|   313k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1019:13): [True: 0, False: 156k]
  |  Branch (1019:44): [True: 0, False: 0]
  |  Branch (1019:54): [True: 0, False: 0]
  ------------------
 1020|      0|            packet->pts < start_pts - .005 && !p->has_broken_packet_pts)
  ------------------
  |  Branch (1020:13): [True: 0, False: 0]
  |  Branch (1020:47): [True: 0, False: 0]
  ------------------
 1021|      0|            framedrop_type = 2;
 1022|       |
 1023|   156k|        p->decoder->control(p->decoder->f, VDCTRL_SET_FRAMEDROP, &framedrop_type);
 1024|   156k|    }
 1025|       |
 1026|  1.39M|    if (!p->dec_dispatch && p->public.recorder_sink)
  ------------------
  |  Branch (1026:9): [True: 1.39M, False: 0]
  |  Branch (1026:29): [True: 0, False: 1.39M]
  ------------------
 1027|      0|        mp_recorder_feed_packet(p->public.recorder_sink, packet);
 1028|       |
 1029|  1.39M|    double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  19.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1029:22): [True: 1.37M, False: 19.2k]
  ------------------
 1030|  1.39M|    double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  19.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1030:22): [True: 1.37M, False: 19.2k]
  ------------------
 1031|       |
 1032|  1.39M|    if (pkt_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.39M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1032:9): [True: 27.7k, False: 1.36M]
  ------------------
 1033|  27.7k|        p->has_broken_packet_pts = 1;
 1034|       |
 1035|  1.39M|    if (packet && packet->dts == MP_NOPTS_VALUE && !p->codec->avi_dts)
  ------------------
  |  |   39|  2.77M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1035:9): [True: 1.37M, False: 19.2k]
  |  Branch (1035:19): [True: 9.47k, False: 1.36M]
  |  Branch (1035:52): [True: 9.47k, False: 0]
  ------------------
 1036|  9.47k|        packet->dts = packet->pts;
 1037|       |
 1038|  1.39M|    double pkt_pdts = pkt_pts == MP_NOPTS_VALUE ? pkt_dts : pkt_pts;
  ------------------
  |  |   39|  1.39M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1038:23): [True: 27.7k, False: 1.36M]
  ------------------
 1039|  1.39M|    if (p->first_packet_pdts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.39M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1039:9): [True: 27.8k, False: 1.36M]
  ------------------
 1040|  27.8k|        p->first_packet_pdts = pkt_pdts;
 1041|       |
 1042|  1.39M|    if (packet && packet->back_preroll) {
  ------------------
  |  Branch (1042:9): [True: 1.37M, False: 19.2k]
  |  Branch (1042:19): [True: 0, False: 1.37M]
  ------------------
 1043|      0|        p->preroll_discard = true;
 1044|      0|        packet->pts = packet->dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1045|      0|    }
 1046|       |
 1047|  1.39M|    mp_pin_in_write(p->decoder->f->pins[0], p->packet);
 1048|  1.39M|    p->packet_fed = true;
 1049|  1.39M|    p->packet = MP_NO_FRAME;
  ------------------
  |  |   58|  1.39M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  1.39M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1050|       |
 1051|  1.39M|    p->packets_without_output += 1;
 1052|  1.39M|}
f_decoder_wrapper.c:is_new_segment:
  957|  1.39M|{
  958|  1.39M|    if (frame.type != MP_FRAME_PACKET)
  ------------------
  |  Branch (958:9): [True: 19.2k, False: 1.37M]
  ------------------
  959|  19.2k|        return false;
  960|  1.37M|    struct demux_packet *pkt = frame.data;
  961|  1.37M|    return (pkt->segmented && (pkt->start != p->start || pkt->end != p->end ||
  ------------------
  |  Branch (961:13): [True: 0, False: 1.37M]
  |  Branch (961:32): [True: 0, False: 0]
  |  Branch (961:58): [True: 0, False: 0]
  ------------------
  962|      0|                               pkt->codec != p->codec)) ||
  ------------------
  |  Branch (962:32): [True: 0, False: 0]
  ------------------
  963|  1.37M|           (p->play_dir < 0 && pkt->back_restart && p->packet_fed);
  ------------------
  |  Branch (963:13): [True: 0, False: 1.37M]
  |  Branch (963:32): [True: 0, False: 0]
  |  Branch (963:53): [True: 0, False: 0]
  ------------------
  964|  1.39M|}
f_decoder_wrapper.c:read_frame:
 1084|  4.54M|{
 1085|  4.54M|    struct mp_pin *pin = p->decf->ppins[0];
 1086|  4.54M|    struct mp_frame frame = {0};
 1087|       |
 1088|  4.54M|    if (!p->decoder) {
  ------------------
  |  Branch (1088:9): [True: 0, False: 4.54M]
  ------------------
 1089|      0|        if (mp_pin_in_needs_data(pin))
  ------------------
  |  Branch (1089:13): [True: 0, False: 0]
  ------------------
 1090|      0|            mp_pin_in_write(pin, MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1091|      0|        return;
 1092|      0|    }
 1093|  4.54M|    if (!mp_pin_in_needs_data(pin))
  ------------------
  |  Branch (1093:9): [True: 19.4k, False: 4.52M]
  ------------------
 1094|  19.4k|        return;
 1095|       |
 1096|  4.52M|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1096:9): [True: 0, False: 4.52M]
  ------------------
 1097|      0|        if (p->coverart_returned == 0) {
  ------------------
  |  Branch (1097:13): [True: 0, False: 0]
  ------------------
 1098|      0|            frame = mp_frame_ref(p->decoded_coverart);
 1099|      0|            p->coverart_returned = 1;
 1100|      0|            goto output_frame;
 1101|      0|        } else if (p->coverart_returned == 1) {
  ------------------
  |  Branch (1101:20): [True: 0, False: 0]
  ------------------
 1102|      0|            frame = MP_EOF_FRAME;
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1103|      0|            p->coverart_returned = 2;
 1104|      0|            goto output_frame;
 1105|      0|        }
 1106|      0|        return;
 1107|      0|    }
 1108|       |
 1109|  4.52M|    if (p->reverse_queue_complete && p->num_reverse_queue) {
  ------------------
  |  Branch (1109:9): [True: 0, False: 4.52M]
  |  Branch (1109:38): [True: 0, False: 0]
  ------------------
 1110|      0|        frame = p->reverse_queue[p->num_reverse_queue - 1];
 1111|      0|        p->num_reverse_queue -= 1;
 1112|      0|        goto output_frame;
 1113|      0|    }
 1114|  4.52M|    p->reverse_queue_complete = false;
 1115|       |
 1116|  4.52M|    frame = mp_pin_out_read(p->decoder->f->pins[1]);
 1117|  4.52M|    if (!frame.type)
  ------------------
  |  Branch (1117:9): [True: 3.65M, False: 863k]
  ------------------
 1118|  3.65M|        return;
 1119|       |
 1120|   863k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   863k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1121|   863k|    if (p->attached_picture && frame.type == MP_FRAME_VIDEO)
  ------------------
  |  Branch (1121:9): [True: 0, False: 863k]
  |  Branch (1121:32): [True: 0, False: 0]
  ------------------
 1122|      0|        p->decoded_coverart = frame;
 1123|   863k|    if (p->attempt_framedrops) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 863k]
  ------------------
 1124|      0|        int dropped = MPMAX(0, p->packets_without_output - 1);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1125|      0|        p->attempt_framedrops = MPMAX(0, p->attempt_framedrops - dropped);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1126|      0|        p->dropped_frames += dropped;
 1127|      0|    }
 1128|   863k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   863k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1129|       |
 1130|   863k|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1130:9): [True: 0, False: 863k]
  ------------------
 1131|      0|        mp_filter_internal_mark_progress(p->decf);
 1132|      0|        return;
 1133|      0|    }
 1134|       |
 1135|   863k|    p->packets_without_output = 0;
 1136|       |
 1137|   863k|    if (p->preroll_discard && frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 863k]
  |  Branch (1137:31): [True: 0, False: 0]
  ------------------
 1138|      0|        double ts = mp_frame_get_pts(frame);
 1139|      0|        if (ts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1139:13): [True: 0, False: 0]
  ------------------
 1140|      0|            mp_frame_unref(&frame);
 1141|      0|            mp_filter_internal_mark_progress(p->decf);
 1142|      0|            return;
 1143|      0|        }
 1144|      0|        p->preroll_discard = false;
 1145|      0|    }
 1146|       |
 1147|   863k|    bool segment_ended = process_decoded_frame(p, &frame);
 1148|       |
 1149|   863k|    if (p->play_dir < 0 && frame.type) {
  ------------------
  |  Branch (1149:9): [True: 0, False: 863k]
  |  Branch (1149:28): [True: 0, False: 0]
  ------------------
 1150|      0|        enqueue_backward_frame(p, frame);
 1151|      0|        frame = MP_NO_FRAME;
  ------------------
  |  |   58|      0|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1152|      0|    }
 1153|       |
 1154|       |    // If there's a new segment, start it as soon as we're drained/finished.
 1155|   863k|    if (segment_ended && p->new_segment) {
  ------------------
  |  Branch (1155:9): [True: 19.2k, False: 844k]
  |  Branch (1155:26): [True: 0, False: 19.2k]
  ------------------
 1156|      0|        struct demux_packet *new_segment = p->new_segment;
 1157|      0|        p->new_segment = NULL;
 1158|       |
 1159|      0|        reset_decoder(p);
 1160|       |
 1161|      0|        if (new_segment->segmented) {
  ------------------
  |  Branch (1161:13): [True: 0, False: 0]
  ------------------
 1162|      0|            if (p->codec != new_segment->codec) {
  ------------------
  |  Branch (1162:17): [True: 0, False: 0]
  ------------------
 1163|      0|                p->codec = new_segment->codec;
 1164|      0|                if (!decoder_wrapper_reinit(&p->public))
  ------------------
  |  Branch (1164:21): [True: 0, False: 0]
  ------------------
 1165|      0|                    mp_filter_internal_mark_failed(p->decf);
 1166|      0|            }
 1167|       |
 1168|      0|            p->start = new_segment->start;
 1169|      0|            p->end = new_segment->end;
 1170|      0|        }
 1171|       |
 1172|      0|        p->reverse_queue_byte_size = 0;
 1173|      0|        p->reverse_queue_complete = p->num_reverse_queue > 0;
 1174|       |
 1175|      0|        p->packet = MAKE_FRAME(MP_FRAME_PACKET, new_segment);
  ------------------
  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1176|      0|        mp_filter_internal_mark_progress(p->decf);
 1177|      0|    }
 1178|       |
 1179|   863k|    if (!frame.type) {
  ------------------
  |  Branch (1179:9): [True: 0, False: 863k]
  ------------------
 1180|      0|        mp_filter_internal_mark_progress(p->decf); // make it retry
 1181|      0|        return;
 1182|      0|    }
 1183|       |
 1184|   863k|output_frame:
 1185|   863k|    process_output_frame(p, frame);
 1186|   863k|    p->eof_output = frame.type == MP_FRAME_EOF;
 1187|   863k|    mp_pin_in_write(pin, frame);
 1188|   863k|}
f_decoder_wrapper.c:process_decoded_frame:
  786|   863k|{
  787|   863k|    if (frame->type == MP_FRAME_EOF) {
  ------------------
  |  Branch (787:9): [True: 19.2k, False: 844k]
  ------------------
  788|       |        // if we were just draining current segment, don't propagate EOF
  789|  19.2k|        if (p->new_segment)
  ------------------
  |  Branch (789:13): [True: 0, False: 19.2k]
  ------------------
  790|      0|            mp_frame_unref(frame);
  791|  19.2k|        return true;
  792|  19.2k|    }
  793|       |
  794|   863k|    bool segment_ended = false;
  795|       |
  796|   844k|    if (frame->type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (796:9): [True: 43.7k, False: 800k]
  ------------------
  797|  43.7k|        struct mp_image *mpi = frame->data;
  798|       |
  799|  43.7k|        crazy_video_pts_stuff(p, mpi);
  800|       |
  801|  43.7k|        struct demux_packet *ccpkt = new_demux_packet_from_buf(p->public.f->packet_pool,
  802|  43.7k|                                                               mpi->a53_cc);
  803|  43.7k|        if (ccpkt) {
  ------------------
  |  Branch (803:13): [True: 0, False: 43.7k]
  ------------------
  804|      0|            av_buffer_unref(&mpi->a53_cc);
  805|      0|            ccpkt->pts = mpi->pts;
  806|      0|            ccpkt->dts = mpi->dts;
  807|      0|            demuxer_feed_caption(p->header, ccpkt);
  808|      0|        }
  809|       |
  810|       |        // Stop hr-seek logic.
  811|  43.7k|        if (mpi->pts == MP_NOPTS_VALUE || mpi->pts >= p->start_pts)
  ------------------
  |  |   39|  87.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (811:13): [True: 64, False: 43.6k]
  |  Branch (811:43): [True: 43.6k, False: 0]
  ------------------
  812|  43.7k|            p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  813|       |
  814|  43.7k|        if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (814:13): [True: 43.6k, False: 64]
  ------------------
  815|  43.6k|            segment_ended = p->end != MP_NOPTS_VALUE && mpi->pts >= p->end;
  ------------------
  |  |   39|  87.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (815:29): [True: 0, False: 43.6k]
  |  Branch (815:57): [True: 0, False: 0]
  ------------------
  816|  43.6k|            if ((p->start != MP_NOPTS_VALUE && mpi->pts < p->start) ||
  ------------------
  |  |   39|  87.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (816:18): [True: 0, False: 43.6k]
  |  Branch (816:48): [True: 0, False: 0]
  ------------------
  817|  43.6k|                segment_ended)
  ------------------
  |  Branch (817:17): [True: 0, False: 43.6k]
  ------------------
  818|      0|            {
  819|      0|                mp_frame_unref(frame);
  820|      0|                goto done;
  821|      0|            }
  822|  43.6k|        }
  823|   800k|    } else if (frame->type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (823:16): [True: 800k, False: 0]
  ------------------
  824|   800k|        struct mp_aframe *aframe = frame->data;
  825|       |
  826|   800k|        mp_aframe_clip_timestamps(aframe, p->start, p->end);
  827|   800k|        double pts = mp_aframe_get_pts(aframe);
  828|   800k|        if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (828:13): [True: 800k, False: 127]
  |  Branch (828:38): [True: 0, False: 800k]
  ------------------
  829|      0|            segment_ended = pts >= p->end;
  830|       |
  831|   800k|        if (mp_aframe_get_size(aframe) == 0) {
  ------------------
  |  Branch (831:13): [True: 0, False: 800k]
  ------------------
  832|      0|            mp_frame_unref(frame);
  833|      0|            goto done;
  834|      0|        }
  835|   800k|    } else {
  836|      0|        MP_ERR(p, "unknown frame type from decoder\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  837|      0|    }
  838|       |
  839|   844k|done:
  840|   844k|    return segment_ended;
  841|   844k|}
f_decoder_wrapper.c:crazy_video_pts_stuff:
  749|  43.7k|{
  750|       |    // Note: the PTS is reordered, but the DTS is not. Both must be monotonic.
  751|       |
  752|  43.7k|    if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (752:9): [True: 43.6k, False: 64]
  ------------------
  753|  43.6k|        if (mpi->pts < p->codec_pts)
  ------------------
  |  Branch (753:13): [True: 0, False: 43.6k]
  ------------------
  754|      0|            p->num_codec_pts_problems++;
  755|  43.6k|        p->codec_pts = mpi->pts;
  756|  43.6k|    }
  757|       |
  758|  43.7k|    if (mpi->dts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (758:9): [True: 43.6k, False: 64]
  ------------------
  759|  43.6k|        if (mpi->dts <= p->codec_dts)
  ------------------
  |  Branch (759:13): [True: 0, False: 43.6k]
  ------------------
  760|      0|            p->num_codec_dts_problems++;
  761|  43.6k|        p->codec_dts = mpi->dts;
  762|  43.6k|    }
  763|       |
  764|  43.7k|    if (p->has_broken_packet_pts < 0)
  ------------------
  |  Branch (764:9): [True: 4.96k, False: 38.7k]
  ------------------
  765|  4.96k|        p->has_broken_packet_pts++;
  766|  43.7k|    if (p->num_codec_pts_problems)
  ------------------
  |  Branch (766:9): [True: 0, False: 43.7k]
  ------------------
  767|      0|        p->has_broken_packet_pts = 1;
  768|       |
  769|       |    // If PTS is unset, or non-monotonic, fall back to DTS.
  770|  43.7k|    if ((p->num_codec_pts_problems > p->num_codec_dts_problems ||
  ------------------
  |  Branch (770:10): [True: 0, False: 43.7k]
  ------------------
  771|  43.7k|        mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|     64|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (771:9): [True: 64, False: 43.6k]
  |  Branch (771:40): [True: 0, False: 64]
  ------------------
  772|      0|        mpi->pts = mpi->dts;
  773|       |
  774|       |    // Compensate for incorrectly using mpeg-style DTS for avi timestamps.
  775|  43.7k|    if (p->decoder && p->decoder->control && p->codec->avi_dts &&
  ------------------
  |  Branch (775:9): [True: 43.7k, False: 0]
  |  Branch (775:23): [True: 43.7k, False: 0]
  |  Branch (775:46): [True: 0, False: 43.7k]
  ------------------
  776|      0|        mpi->pts != MP_NOPTS_VALUE && p->fps > 0)
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (776:9): [True: 0, False: 0]
  |  Branch (776:39): [True: 0, False: 0]
  ------------------
  777|      0|    {
  778|      0|        int delay = -1;
  779|      0|        p->decoder->control(p->decoder->f, VDCTRL_GET_BFRAMES, &delay);
  780|      0|        mpi->pts -= MPMAX(delay, 0) / p->fps;
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  781|      0|    }
  782|  43.7k|}
f_decoder_wrapper.c:process_output_frame:
  922|   863k|{
  923|   863k|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (923:9): [True: 43.7k, False: 820k]
  ------------------
  924|  43.7k|        struct mp_image *mpi = frame.data;
  925|       |
  926|  43.7k|        correct_video_pts(p, mpi);
  927|       |
  928|  43.7k|        if (!mp_image_params_equal(&p->last_format, &mpi->params)) {
  ------------------
  |  Branch (928:13): [True: 1.84k, False: 41.9k]
  ------------------
  929|  1.84k|            fix_image_params(p, &mpi->params,
  930|  1.84k|                mp_image_params_static_equal(&p->last_format, &mpi->params));
  931|  1.84k|        }
  932|       |
  933|  43.7k|        mpi->params = p->fixed_format;
  934|  43.7k|        mpi->nominal_fps = p->fps;
  935|   820k|    } else if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (935:16): [True: 800k, False: 19.2k]
  ------------------
  936|   800k|        struct mp_aframe *aframe = frame.data;
  937|       |
  938|   800k|        if (p->play_dir < 0 && !mp_aframe_reverse(aframe))
  ------------------
  |  Branch (938:13): [True: 0, False: 800k]
  |  Branch (938:32): [True: 0, False: 0]
  ------------------
  939|   800k|            MP_ERR(p, "Couldn't reverse audio frame.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  940|       |
  941|   800k|        correct_audio_pts(p, aframe);
  942|   800k|    }
  943|   863k|}
f_decoder_wrapper.c:correct_video_pts:
  844|  43.7k|{
  845|  43.7k|    mpi->pts *= p->play_dir;
  846|       |
  847|  43.7k|    if (!p->opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (847:9): [True: 0, False: 43.7k]
  |  Branch (847:34): [True: 64, False: 43.6k]
  ------------------
  848|     64|        double fps = p->fps > 0 ? p->fps : 25;
  ------------------
  |  Branch (848:22): [True: 0, False: 64]
  ------------------
  849|       |
  850|     64|        if (p->opts->correct_pts) {
  ------------------
  |  Branch (850:13): [True: 64, False: 0]
  ------------------
  851|     64|            if (p->has_broken_decoded_pts <= 1) {
  ------------------
  |  Branch (851:17): [True: 64, False: 0]
  ------------------
  852|     64|                MP_WARN(p, "No video PTS! Making something up. Using "
  ------------------
  |  |   90|     64|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     64|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  853|     64|                        "%f FPS.\n", fps);
  854|     64|                if (p->has_broken_decoded_pts == 1)
  ------------------
  |  Branch (854:21): [True: 0, False: 64]
  ------------------
  855|     64|                    MP_WARN(p, "Ignoring further missing PTS warnings.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  856|     64|                p->has_broken_decoded_pts++;
  857|     64|            }
  858|     64|        }
  859|       |
  860|     64|        double frame_time = 1.0f / fps;
  861|     64|        double base = p->first_packet_pdts;
  862|     64|        mpi->pts = p->pts;
  863|     64|        if (mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|     64|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (863:13): [True: 64, False: 0]
  ------------------
  864|     64|            mpi->pts = base == MP_NOPTS_VALUE ? 0 : base;
  ------------------
  |  |   39|     64|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:24): [True: 64, False: 0]
  ------------------
  865|     64|        } else {
  866|      0|            mpi->pts += frame_time;
  867|      0|        }
  868|     64|    }
  869|       |
  870|  43.7k|    p->pts = mpi->pts;
  871|  43.7k|}
f_decoder_wrapper.c:fix_image_params:
  628|  1.84k|{
  629|  1.84k|    struct mp_image_params m = *params;
  630|  1.84k|    struct mp_codec_params *c = p->codec;
  631|  1.84k|    struct dec_wrapper_opts *opts = p->opts;
  632|       |
  633|  1.84k|    if (!quiet)
  ------------------
  |  Branch (633:9): [True: 1.84k, False: 0]
  ------------------
  634|  1.84k|        MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  1.84k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.84k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  635|  1.84k|    p->dec_format = *params;
  636|       |
  637|  1.84k|    if (!quiet && opts->movie_aspect == 0)
  ------------------
  |  Branch (637:9): [True: 1.84k, False: 0]
  |  Branch (637:19): [True: 0, False: 1.84k]
  ------------------
  638|  1.84k|        MP_WARN(p, "Setting video-aspect-override to 0 is deprecated.\n"
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  639|  1.84k|                   "Use --video-aspect-override=no --video-aspect-mode=ignore instead.\n");
  640|  1.84k|    if (!quiet && opts->movie_aspect == -1)
  ------------------
  |  Branch (640:9): [True: 1.84k, False: 0]
  |  Branch (640:19): [True: 0, False: 1.84k]
  ------------------
  641|  1.84k|        MP_WARN(p, "Setting video-aspect-override to -1 is deprecated.\n"
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  642|  1.84k|                   "Use --video-aspect-override=no --video-aspect-mode=container instead.\n");
  643|       |
  644|       |    // While mp_image_params normally always have to have d_w/d_h set, the
  645|       |    // decoder signals unknown bitstream aspect ratio with both set to 0.
  646|  1.84k|    bool use_container = true;
  647|  1.84k|    if (opts->aspect_method == 1 && m.p_w > 0 && m.p_h > 0 &&
  ------------------
  |  Branch (647:9): [True: 0, False: 1.84k]
  |  Branch (647:37): [True: 0, False: 0]
  |  Branch (647:50): [True: 0, False: 0]
  ------------------
  648|      0|        opts->movie_aspect != -1) {
  ------------------
  |  Branch (648:9): [True: 0, False: 0]
  ------------------
  649|      0|        if (!quiet)
  ------------------
  |  Branch (649:13): [True: 0, False: 0]
  ------------------
  650|      0|            MP_VERBOSE(p, "Using bitstream aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  651|      0|        use_container = false;
  652|      0|    }
  653|       |
  654|  1.84k|    if (opts->aspect_method == 3 && opts->movie_aspect != -1) {
  ------------------
  |  Branch (654:9): [True: 0, False: 1.84k]
  |  Branch (654:37): [True: 0, False: 0]
  ------------------
  655|      0|        if (!quiet)
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            MP_VERBOSE(p, "Ignoring aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  657|      0|        use_container = false;
  658|      0|        m.p_w = m.p_h = 1;
  659|      0|    }
  660|       |
  661|  1.84k|    if (use_container && c->dar_w > 0 && c->dar_h > 0) {
  ------------------
  |  Branch (661:9): [True: 1.84k, False: 0]
  |  Branch (661:26): [True: 0, False: 1.84k]
  |  Branch (661:42): [True: 0, False: 0]
  ------------------
  662|      0|        if (!quiet)
  ------------------
  |  Branch (662:13): [True: 0, False: 0]
  ------------------
  663|      0|            MP_VERBOSE(p, "Using container display aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  664|      0|        mp_image_params_set_dsize(&m, c->dar_w, c->dar_h);
  665|  1.84k|    } else if (use_container && c->par_w > 0 && c->par_h) {
  ------------------
  |  Branch (665:16): [True: 1.84k, False: 0]
  |  Branch (665:33): [True: 0, False: 1.84k]
  |  Branch (665:49): [True: 0, False: 0]
  ------------------
  666|      0|        if (!quiet)
  ------------------
  |  Branch (666:13): [True: 0, False: 0]
  ------------------
  667|      0|            MP_VERBOSE(p, "Using container aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  668|      0|        m.p_w = c->par_w;
  669|      0|        m.p_h = c->par_h;
  670|      0|    }
  671|       |
  672|  1.84k|    if (opts->movie_aspect >= 0) {
  ------------------
  |  Branch (672:9): [True: 0, False: 1.84k]
  ------------------
  673|      0|        if (!quiet)
  ------------------
  |  Branch (673:13): [True: 0, False: 0]
  ------------------
  674|      0|            MP_VERBOSE(p, "Forcing user-set aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  675|      0|        if (opts->movie_aspect == 0) {
  ------------------
  |  Branch (675:13): [True: 0, False: 0]
  ------------------
  676|      0|            m.p_w = m.p_h = 1;
  677|      0|        } else {
  678|      0|            AVRational a = av_d2q(opts->movie_aspect, INT_MAX);
  679|      0|            mp_image_params_set_dsize(&m, a.num, a.den);
  680|      0|        }
  681|      0|    }
  682|       |
  683|       |    // Assume square pixels if no aspect ratio is set at all.
  684|  1.84k|    if (m.p_w <= 0 || m.p_h <= 0)
  ------------------
  |  Branch (684:9): [True: 1.79k, False: 46]
  |  Branch (684:23): [True: 0, False: 46]
  ------------------
  685|  1.79k|        m.p_w = m.p_h = 1;
  686|       |
  687|  1.84k|    if (!m.stereo3d)
  ------------------
  |  Branch (687:9): [True: 1.84k, False: 0]
  ------------------
  688|  1.84k|        m.stereo3d = p->codec->stereo_mode;
  689|       |
  690|  1.84k|    if (!mp_rect_equals(&p->codec->crop, &(struct mp_rect){0})) {
  ------------------
  |  Branch (690:9): [True: 0, False: 1.84k]
  ------------------
  691|      0|        struct mp_rect crop = p->codec->crop;
  692|       |        // Offset to respect existing decoder crop.
  693|      0|        crop.x0 += m.crop.x0;
  694|      0|        crop.x1 += m.crop.x0;
  695|      0|        crop.y0 += m.crop.y0;
  696|      0|        crop.y1 += m.crop.y0;
  697|       |        // Crop has to be inside existing image bounds.
  698|      0|        if (mp_image_crop_valid(&(struct mp_image_params) {
  ------------------
  |  Branch (698:13): [True: 0, False: 0]
  ------------------
  699|      0|            .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  157|      0|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                          .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  158|      0|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  700|      0|        {
  701|      0|            m.crop = crop;
  702|      0|        } else {
  703|      0|            MP_WARN(p, "Invalid container crop %dx%d+%d+%d for %dx%d image\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  704|      0|            mp_rect_w(crop), mp_rect_h(crop), crop.x0, crop.y0,
  705|      0|            mp_rect_w(m.crop), mp_rect_h(m.crop));
  706|      0|        }
  707|      0|    }
  708|       |
  709|  1.84k|    if (opts->video_rotate < 0) {
  ------------------
  |  Branch (709:9): [True: 0, False: 1.84k]
  ------------------
  710|      0|        m.rotate = 0;
  711|  1.84k|    } else {
  712|       |        // ffmpeg commit 535a835e51 says that frame rotate takes priority
  713|  1.84k|        if (!m.rotate)
  ------------------
  |  Branch (713:13): [True: 1.84k, False: 0]
  ------------------
  714|  1.84k|            m.rotate = p->codec->rotate;
  715|  1.84k|        m.rotate = (m.rotate + opts->video_rotate) % 360;
  716|  1.84k|    }
  717|       |
  718|  1.84k|    pl_color_space_merge(&m.color, &c->color);
  719|  1.84k|    pl_color_repr_merge(&m.repr, &c->repr);
  720|       |
  721|  1.84k|    if (m.chroma_location == PL_CHROMA_UNKNOWN)
  ------------------
  |  Branch (721:9): [True: 1.84k, False: 0]
  ------------------
  722|  1.84k|        m.chroma_location = c->chroma_location;
  723|       |
  724|       |    // Guess missing colorspace fields from metadata. This guarantees all
  725|       |    // fields are at least set to legal values afterwards.
  726|  1.84k|    mp_image_params_guess_csp(&m);
  727|       |
  728|  1.84k|    p->last_format = *params;
  729|  1.84k|    p->fixed_format = m;
  730|  1.84k|}
f_decoder_wrapper.c:correct_audio_pts:
  874|   800k|{
  875|   800k|    double dir = p->play_dir;
  876|       |
  877|   800k|    double frame_pts = mp_aframe_get_pts(aframe);
  878|   800k|    double frame_len = mp_aframe_duration(aframe);
  879|       |
  880|   800k|    if (frame_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (880:9): [True: 800k, False: 127]
  ------------------
  881|   800k|        if (dir < 0)
  ------------------
  |  Branch (881:13): [True: 0, False: 800k]
  ------------------
  882|      0|            frame_pts = -(frame_pts + frame_len);
  883|       |
  884|   800k|        if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (884:13): [True: 794k, False: 6.09k]
  ------------------
  885|   800k|            MP_STATS(p, "value %f audio-pts-err", p->pts - frame_pts);
  ------------------
  |  |   99|   794k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   794k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  886|       |
  887|   800k|        double diff = fabs(p->pts - frame_pts);
  888|       |
  889|       |        // Attempt to detect jumps in PTS. Even for the lowest sample rates and
  890|       |        // with worst container rounded timestamp, this should be a margin more
  891|       |        // than enough.
  892|   800k|        if (p->pts != MP_NOPTS_VALUE && diff > 0.1) {
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (892:13): [True: 794k, False: 6.09k]
  |  Branch (892:41): [True: 1.98k, False: 792k]
  ------------------
  893|  1.98k|            MP_WARN(p, "Invalid audio PTS: %f -> %f\n", p->pts, frame_pts);
  ------------------
  |  |   90|  1.98k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  894|  1.98k|            if (diff >= 5) {
  ------------------
  |  Branch (894:17): [True: 113, False: 1.87k]
  ------------------
  895|    113|                mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|    113|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  896|    113|                p->pts_reset = true;
  897|    113|                mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|    113|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  898|    113|            }
  899|  1.98k|        }
  900|       |
  901|       |        // The timestamps of the file are rounded, and can be off by more
  902|       |        // than that for a few packets. The pts continues by the samples and
  903|       |        // moves to the timestamp by their distance per second, which follows
  904|       |        // timestamps that run faster or slower than the samples. Further
  905|       |        // apart than the rounding tolerance they are a jump in the file.
  906|   800k|        if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|   794k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (906:13): [True: 6.09k, False: 794k]
  |  Branch (906:41): [True: 5.30k, False: 789k]
  ------------------
  907|  11.3k|            p->pts = frame_pts;
  908|   789k|        else
  909|   789k|            p->pts += (frame_pts - p->pts) * frame_len;
  910|   800k|    }
  911|       |
  912|   800k|    if (p->pts == MP_NOPTS_VALUE && p->header->missing_timestamps)
  ------------------
  |  |   39|  1.60M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (912:9): [True: 127, False: 800k]
  |  Branch (912:37): [True: 0, False: 127]
  ------------------
  913|      0|        p->pts = 0;
  914|       |
  915|   800k|    mp_aframe_set_pts(aframe, p->pts);
  916|       |
  917|   800k|    if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (917:9): [True: 800k, False: 127]
  ------------------
  918|   800k|        p->pts += frame_len;
  919|   800k|}
f_decoder_wrapper.c:decf_reset:
  336|  43.7k|{
  337|  43.7k|    struct priv *p = f->priv;
  338|  43.7k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (338:5): [True: 43.7k, False: 0]
  ------------------
  339|       |
  340|  43.7k|    p->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  341|  43.7k|    p->last_format = p->fixed_format = (struct mp_image_params){0};
  342|       |
  343|  43.7k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  344|  43.7k|    p->pts_reset = false;
  345|  43.7k|    p->attempt_framedrops = 0;
  346|  43.7k|    p->dropped_frames = 0;
  347|  43.7k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  348|       |
  349|  43.7k|    p->coverart_returned = 0;
  350|  43.7k|    p->eof_output = false;
  351|       |
  352|  43.7k|    for (int n = 0; n < p->num_reverse_queue; n++)
  ------------------
  |  Branch (352:21): [True: 0, False: 43.7k]
  ------------------
  353|      0|        mp_frame_unref(&p->reverse_queue[n]);
  354|  43.7k|    p->num_reverse_queue = 0;
  355|  43.7k|    p->reverse_queue_byte_size = 0;
  356|  43.7k|    p->reverse_queue_complete = false;
  357|       |
  358|  43.7k|    reset_decoder(p);
  359|  43.7k|}

mp_demux_in_create:
   72|  21.8k|{
   73|  21.8k|    struct mp_filter *f = mp_filter_create(parent, &demux_filter);
   74|  21.8k|    if (!f)
  ------------------
  |  Branch (74:9): [True: 0, False: 21.8k]
  ------------------
   75|      0|        return NULL;
   76|       |
   77|  21.8k|    struct priv *p = f->priv;
   78|  21.8k|    p->src = src;
   79|       |
   80|  21.8k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
   81|       |
   82|  21.8k|    demux_set_stream_wakeup_cb(p->src, wakeup, f);
   83|       |
   84|  21.8k|    return f;
   85|  21.8k|}
f_demux_in.c:demux_destroy:
   56|  21.8k|{
   57|  21.8k|    struct priv *p = f->priv;
   58|       |
   59|  21.8k|    demux_set_stream_wakeup_cb(p->src, NULL, NULL);
   60|  21.8k|}
f_demux_in.c:demux_process:
   21|  1.44M|{
   22|  1.44M|    struct priv *p = f->priv;
   23|       |
   24|  1.44M|    if (!mp_pin_in_needs_data(f->ppins[0]))
  ------------------
  |  Branch (24:9): [True: 19.4k, False: 1.42M]
  ------------------
   25|  19.4k|        return;
   26|       |
   27|  1.42M|    struct demux_packet *pkt = NULL;
   28|  1.42M|    if (demux_read_packet_async(p->src, &pkt) == 0)
  ------------------
  |  Branch (28:9): [True: 24.4k, False: 1.39M]
  ------------------
   29|  24.4k|        return; // wait
   30|       |
   31|  1.39M|    struct mp_frame frame = {MP_FRAME_PACKET, pkt};
   32|  1.39M|    if (pkt) {
  ------------------
  |  Branch (32:9): [True: 1.37M, False: 19.2k]
  ------------------
   33|  1.37M|        if (p->eof_returned)
  ------------------
  |  Branch (33:13): [True: 0, False: 1.37M]
  ------------------
   34|  1.37M|            MP_VERBOSE(f, "unset EOF on stream %d\n", p->src->index);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   35|  1.37M|        p->eof_returned = false;
   36|  1.37M|    } else {
   37|  19.2k|        frame.type = MP_FRAME_EOF;
   38|       |
   39|       |        // While the demuxer will repeat EOFs, filters never do that.
   40|  19.2k|        if (p->eof_returned)
  ------------------
  |  Branch (40:13): [True: 0, False: 19.2k]
  ------------------
   41|      0|            return;
   42|  19.2k|        p->eof_returned = true;
   43|  19.2k|    }
   44|       |
   45|  1.39M|    mp_pin_in_write(f->ppins[0], frame);
   46|  1.39M|}
f_demux_in.c:wakeup:
   14|  24.4k|{
   15|  24.4k|    struct mp_filter *f = ctx;
   16|       |
   17|  24.4k|    mp_filter_wakeup(f);
   18|  24.4k|}

mp_output_chain_set_vo:
  393|  9.69k|{
  394|  9.69k|    struct chain *p = c->f->priv;
  395|       |
  396|  9.69k|    p->stream_info.hwdec_devs = vo ? vo->hwdec_devs : NULL;
  ------------------
  |  Branch (396:33): [True: 9.69k, False: 0]
  ------------------
  397|  9.69k|    p->stream_info.osd = vo ? vo->osd : NULL;
  ------------------
  |  Branch (397:26): [True: 9.69k, False: 0]
  ------------------
  398|  9.69k|    p->stream_info.vflip = vo ? vo->driver->caps & VO_CAP_VFLIP : false;
  ------------------
  |  Branch (398:28): [True: 9.69k, False: 0]
  ------------------
  399|  9.69k|    p->stream_info.rotate90 = vo ? vo->driver->caps & VO_CAP_ROTATE90 : false;
  ------------------
  |  Branch (399:31): [True: 9.69k, False: 0]
  ------------------
  400|  9.69k|    p->stream_info.dr_vo = vo;
  401|  9.69k|    p->vo = vo;
  402|  9.69k|    update_output_caps(p);
  403|  9.69k|}
mp_output_chain_set_el_stream:
  407|  86.2k|{
  408|  86.2k|    struct chain *p = c->f->priv;
  409|       |
  410|  86.2k|    mp_assert(p->type == MP_OUTPUT_CHAIN_VIDEO);
  ------------------
  |  |   41|  86.2k|#define mp_assert assert
  ------------------
  |  Branch (410:5): [True: 86.2k, False: 0]
  ------------------
  411|       |
  412|  86.2k|    if (p->el_sh == el_sh && (!el_sh || p->el_pair))
  ------------------
  |  Branch (412:9): [True: 86.2k, False: 0]
  |  Branch (412:31): [True: 86.2k, False: 0]
  |  Branch (412:41): [True: 0, False: 0]
  ------------------
  413|  86.2k|        return;
  414|       |
  415|      0|    if (p->el_pair) {
  ------------------
  |  Branch (415:9): [True: 0, False: 0]
  ------------------
  416|      0|        for (int n = 0; n < p->num_post_filters; n++) {
  ------------------
  |  Branch (416:25): [True: 0, False: 0]
  ------------------
  417|      0|            if (p->post_filters[n] == p->el_pair) {
  ------------------
  |  Branch (417:17): [True: 0, False: 0]
  ------------------
  418|      0|                MP_TARRAY_REMOVE_AT(p->post_filters, p->num_post_filters, n);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (418:17): [True: 0, False: 0]
  ------------------
  419|      0|                break;
  420|      0|            }
  421|      0|        }
  422|      0|        talloc_free(p->el_pair->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  423|      0|        p->el_pair = NULL;
  424|      0|        p->el_sh = NULL;
  425|      0|    }
  426|       |
  427|      0|    if (el_sh) {
  ------------------
  |  Branch (427:9): [True: 0, False: 0]
  ------------------
  428|      0|        struct mp_user_filter *u = create_wrapper_filter(p);
  429|      0|        u->name = "el_pair";
  430|      0|        u->f = mp_enhancement_pair_create(u->wrapper, el_sh);
  431|      0|        if (!u->f) {
  ------------------
  |  Branch (431:13): [True: 0, False: 0]
  ------------------
  432|      0|            MP_WARN(p, "Failed to set up enhancement-layer pairing.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  433|      0|            talloc_free(u->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  434|      0|        } else {
  435|      0|            MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, u);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  436|      0|            p->el_pair = u;
  437|      0|            p->el_sh = el_sh;
  438|      0|        }
  439|      0|    }
  440|       |
  441|      0|    relink_filter_list(p);
  442|      0|}
mp_output_chain_set_ao:
  445|  7.95k|{
  446|  7.95k|    struct chain *p = c->f->priv;
  447|       |
  448|  7.95k|    mp_assert(p->public.ao_needs_update); // can't just call it any time
  ------------------
  |  |   41|  7.95k|#define mp_assert assert
  ------------------
  |  Branch (448:5): [True: 7.95k, False: 0]
  ------------------
  449|  7.95k|    mp_assert(!p->ao);
  ------------------
  |  |   41|  7.95k|#define mp_assert assert
  ------------------
  |  Branch (449:5): [True: 7.95k, False: 0]
  ------------------
  450|       |
  451|  7.95k|    p->public.ao_needs_update = false;
  452|       |
  453|  7.95k|    p->ao = ao;
  454|       |
  455|  7.95k|    int out_format = 0;
  456|  7.95k|    int out_rate = 0;
  457|  7.95k|    struct mp_chmap out_channels = {0};
  458|  7.95k|    ao_get_format(p->ao, &out_rate, &out_format, &out_channels);
  459|       |
  460|  7.95k|    mp_autoconvert_clear(p->convert);
  461|  7.95k|    mp_autoconvert_add_afmt(p->convert, out_format);
  462|  7.95k|    mp_autoconvert_add_srate(p->convert, out_rate);
  463|  7.95k|    mp_autoconvert_add_chmap(p->convert, &out_channels);
  464|       |
  465|  7.95k|    mp_autoconvert_format_change_continue(p->convert);
  466|       |
  467|       |    // Just to get the format change logged again.
  468|  7.95k|    mp_aframe_reset(p->public.output_aformat);
  469|  7.95k|}
mp_output_chain_set_audio_speed:
  544|  11.7k|{
  545|  11.7k|    struct chain *p = c->f->priv;
  546|       |
  547|       |    // We always resample with the final libavresample instance.
  548|  11.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  549|  11.7k|                  MP_FILTER_COMMAND_SET_SPEED_RESAMPLE, &resample);
  550|       |
  551|       |    // If users have filters like "scaletempo" insert anywhere, use that,
  552|       |    // otherwise use the builtin ones.
  553|  11.7k|    set_speed_any(p->user_filters, p->num_user_filters,
  554|  11.7k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  555|  11.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  556|  11.7k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  557|  11.7k|    set_speed_any(p->user_filters, p->num_user_filters,
  558|  11.7k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  559|  11.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  560|  11.7k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  561|  11.7k|}
mp_output_chain_update_filters:
  595|  19.4k|{
  596|  19.4k|    struct chain *p = c->f->priv;
  597|       |
  598|  19.4k|    struct mp_user_filter **add = NULL;      // new filters
  599|  19.4k|    int num_add = 0;
  600|  19.4k|    struct mp_user_filter **res = NULL;      // new final list
  601|  19.4k|    int num_res = 0;
  602|  19.4k|    bool *used = talloc_zero_array(NULL, bool, p->num_user_filters);
  ------------------
  |  |   30|  19.4k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  19.4k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|       |
  604|  19.4k|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (604:21): [True: 0, False: 19.4k]
  |  Branch (604:29): [True: 0, False: 0]
  ------------------
  605|      0|        struct m_obj_settings *entry = &list[n];
  606|       |
  607|      0|        if (!entry->enabled)
  ------------------
  |  Branch (607:13): [True: 0, False: 0]
  ------------------
  608|      0|            continue;
  609|       |
  610|      0|        struct mp_user_filter *u = NULL;
  611|       |
  612|      0|        for (int i = 0; i < p->num_user_filters; i++) {
  ------------------
  |  Branch (612:25): [True: 0, False: 0]
  ------------------
  613|      0|            if (!used[i] && m_obj_settings_equal(entry, p->user_filters[i]->args))
  ------------------
  |  Branch (613:17): [True: 0, False: 0]
  |  Branch (613:29): [True: 0, False: 0]
  ------------------
  614|      0|            {
  615|      0|                u = p->user_filters[i];
  616|      0|                used[i] = true;
  617|      0|                break;
  618|      0|            }
  619|      0|        }
  620|       |
  621|      0|        if (!u) {
  ------------------
  |  Branch (621:13): [True: 0, False: 0]
  ------------------
  622|      0|            u = create_wrapper_filter(p);
  623|      0|            u->name = talloc_strdup(u, entry->name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  624|      0|            u->label = talloc_strdup(u, entry->label);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  625|      0|            u->f = mp_create_user_filter(u->wrapper, p->type, entry->name,
  626|      0|                                         entry->attribs);
  627|      0|            if (!u->f) {
  ------------------
  |  Branch (627:17): [True: 0, False: 0]
  ------------------
  628|      0|                talloc_free(u->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  629|      0|                goto error;
  630|      0|            }
  631|       |
  632|      0|            struct m_obj_settings *args = (struct m_obj_settings[2]){*entry, {0}};
  633|       |
  634|      0|            struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  635|      0|            m_option_copy(&dummy, &u->args, &args);
  636|       |
  637|      0|            MP_TARRAY_APPEND(NULL, add, num_add, u);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  638|      0|        }
  639|       |
  640|      0|        MP_TARRAY_APPEND(p, res, num_res, u);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  641|      0|    }
  642|       |
  643|       |    // At this point we definitely know we'll use the new list, so clean up.
  644|       |
  645|  19.4k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (645:21): [True: 0, False: 19.4k]
  ------------------
  646|      0|        if (!used[n])
  ------------------
  |  Branch (646:13): [True: 0, False: 0]
  ------------------
  647|      0|            talloc_free(p->user_filters[n]->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  648|      0|    }
  649|       |
  650|  19.4k|    talloc_free(p->user_filters);
  ------------------
  |  |   47|  19.4k|#define talloc_free                     ta_free
  ------------------
  651|  19.4k|    p->user_filters = res;
  652|  19.4k|    p->num_user_filters = num_res;
  653|       |
  654|  19.4k|    relink_filter_list(p);
  655|       |
  656|  19.4k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (656:21): [True: 0, False: 19.4k]
  ------------------
  657|      0|        struct mp_user_filter *u = p->user_filters[n];
  658|      0|        if (u->generated_label)
  ------------------
  |  Branch (658:13): [True: 0, False: 0]
  ------------------
  659|      0|            TA_FREEP(&u->label);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  660|      0|        if (!u->label) {
  ------------------
  |  Branch (660:13): [True: 0, False: 0]
  ------------------
  661|      0|            for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (661:29): [True: 0, False: 0]
  ------------------
  662|      0|                char *label = mp_tprintf(80, "%s.%02d", u->name, i);
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  663|      0|                if (!find_by_label(p, label)) {
  ------------------
  |  Branch (663:21): [True: 0, False: 0]
  ------------------
  664|      0|                    u->label = talloc_strdup(u, label);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  665|      0|                    u->generated_label = true;
  666|      0|                    break;
  667|      0|                }
  668|      0|            }
  669|      0|        }
  670|      0|    }
  671|       |
  672|  19.4k|    MP_VERBOSE(p, "User filter list:\n");
  ------------------
  |  |   92|  19.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  673|  19.4k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (673:21): [True: 0, False: 19.4k]
  ------------------
  674|      0|        struct mp_user_filter *u = p->user_filters[n];
  675|      0|        MP_VERBOSE(p, "  %s (%s)\n", u->name, u->label ? u->label : "-");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|      0|    }
  677|  19.4k|    if (!p->num_user_filters)
  ------------------
  |  Branch (677:9): [True: 19.4k, False: 0]
  ------------------
  678|  19.4k|        MP_VERBOSE(p, "  (empty)\n");
  ------------------
  |  |   92|  19.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  679|       |
  680|       |    // Filters can load hwdec interops, which might add new formats.
  681|  19.4k|    update_output_caps(p);
  682|       |
  683|  19.4k|    mp_filter_wakeup(p->f);
  684|       |
  685|  19.4k|    talloc_free(add);
  ------------------
  |  |   47|  19.4k|#define talloc_free                     ta_free
  ------------------
  686|  19.4k|    talloc_free(used);
  ------------------
  |  |   47|  19.4k|#define talloc_free                     ta_free
  ------------------
  687|  19.4k|    return true;
  688|       |
  689|      0|error:
  690|      0|    for (int n = 0; n < num_add; n++)
  ------------------
  |  Branch (690:21): [True: 0, False: 0]
  ------------------
  691|      0|        talloc_free(add[n]->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  692|      0|    talloc_free(add);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  693|      0|    talloc_free(used);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  694|       |    return false;
  695|  19.4k|}
mp_output_chain_create:
  743|  21.8k|{
  744|  21.8k|    struct mp_filter *f = mp_filter_create(parent, &output_chain_filter);
  745|  21.8k|    if (!f)
  ------------------
  |  Branch (745:9): [True: 0, False: 21.8k]
  ------------------
  746|      0|        return NULL;
  747|       |
  748|  21.8k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  749|  21.8k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  750|       |
  751|  21.8k|    const char *log_name = NULL;
  752|  21.8k|    switch (type) {
  ------------------
  |  Branch (752:13): [True: 21.8k, False: 0]
  ------------------
  753|  9.69k|    case MP_OUTPUT_CHAIN_VIDEO: log_name = "!vf"; break;
  ------------------
  |  Branch (753:5): [True: 9.69k, False: 12.1k]
  ------------------
  754|  12.1k|    case MP_OUTPUT_CHAIN_AUDIO: log_name = "!af"; break;
  ------------------
  |  Branch (754:5): [True: 12.1k, False: 9.69k]
  ------------------
  755|  21.8k|    }
  756|  21.8k|    if (log_name)
  ------------------
  |  Branch (756:9): [True: 21.8k, False: 0]
  ------------------
  757|  21.8k|        f->log = mp_log_new(f, parent->global->log, log_name);
  758|       |
  759|  21.8k|    struct chain *p = f->priv;
  760|  21.8k|    p->f = f;
  761|  21.8k|    p->log = f->log;
  762|  21.8k|    p->type = type;
  763|       |
  764|  21.8k|    struct mp_output_chain *c = &p->public;
  765|  21.8k|    c->f = f;
  766|  21.8k|    c->input_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  21.8k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  21.8k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  767|  21.8k|    c->output_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  21.8k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  21.8k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  768|       |
  769|       |    // Dummy filter for reporting and logging the input format.
  770|  21.8k|    p->input = create_wrapper_filter(p);
  771|  21.8k|    p->input->f = mp_bidir_nop_filter_create(p->input->wrapper);
  772|  21.8k|    if (!p->input->f)
  ------------------
  |  Branch (772:9): [True: 0, False: 21.8k]
  ------------------
  773|      0|        abort();
  774|  21.8k|    p->input->name = "in";
  775|  21.8k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, p->input);
  ------------------
  |  |  105|  21.8k|    do {                                            \
  |  |  106|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.8k|    do {                                                        \
  |  |  |  |  |  |   89|  21.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.8k|        (idxvar)++;                                 \
  |  |  109|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  776|       |
  777|  21.8k|    switch (type) {
  ------------------
  |  Branch (777:13): [True: 21.8k, False: 0]
  ------------------
  778|  9.69k|    case MP_OUTPUT_CHAIN_VIDEO: create_video_things(p); break;
  ------------------
  |  Branch (778:5): [True: 9.69k, False: 12.1k]
  ------------------
  779|  12.1k|    case MP_OUTPUT_CHAIN_AUDIO: create_audio_things(p); break;
  ------------------
  |  Branch (779:5): [True: 12.1k, False: 9.69k]
  ------------------
  780|  21.8k|    }
  781|       |
  782|  21.8k|    p->convert_wrapper = create_wrapper_filter(p);
  783|  21.8k|    p->convert = mp_autoconvert_create(p->convert_wrapper->wrapper);
  784|  21.8k|    if (!p->convert)
  ------------------
  |  Branch (784:9): [True: 0, False: 21.8k]
  ------------------
  785|      0|        abort();
  786|  21.8k|    p->convert_wrapper->name = "convert";
  787|  21.8k|    p->convert_wrapper->f = p->convert->f;
  788|  21.8k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->convert_wrapper);
  ------------------
  |  |  105|  21.8k|    do {                                            \
  |  |  106|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 9.69k, False: 12.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  9.69k|    do {                                                        \
  |  |  |  |  |  |   89|  9.69k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  9.69k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  9.69k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  9.69k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  9.69k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  9.69k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  9.69k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 9.69k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.8k|        (idxvar)++;                                 \
  |  |  109|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  789|       |
  790|  21.8k|    if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (790:9): [True: 12.1k, False: 9.69k]
  ------------------
  791|  12.1k|        p->convert->on_audio_format_change = on_audio_format_change;
  792|  12.1k|        p->convert->on_audio_format_change_opaque = p;
  793|  12.1k|    }
  794|       |
  795|       |    // Dummy filter for reporting and logging the output format.
  796|  21.8k|    p->output = create_wrapper_filter(p);
  797|  21.8k|    p->output->f = mp_bidir_nop_filter_create(p->output->wrapper);
  798|  21.8k|    if (!p->output->f)
  ------------------
  |  Branch (798:9): [True: 0, False: 21.8k]
  ------------------
  799|      0|        abort();
  800|  21.8k|    p->output->name = "out";
  801|  21.8k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->output);
  ------------------
  |  |  105|  21.8k|    do {                                            \
  |  |  106|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 12.1k, False: 9.69k]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  12.1k|    do {                                                        \
  |  |  |  |  |  |   89|  12.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  12.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  12.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  12.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  12.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  12.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  12.1k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 12.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.8k|        (idxvar)++;                                 \
  |  |  109|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  802|       |
  803|  21.8k|    relink_filter_list(p);
  804|       |
  805|  21.8k|    output_chain_reset(f);
  806|       |
  807|  21.8k|    return c;
  808|  21.8k|}
f_output_chain.c:update_output_caps:
   85|  30.9k|{
   86|  30.9k|    if (p->type != MP_OUTPUT_CHAIN_VIDEO)
  ------------------
  |  Branch (86:9): [True: 11.7k, False: 19.2k]
  ------------------
   87|  11.7k|        return;
   88|       |
   89|  19.2k|    mp_autoconvert_clear(p->convert);
   90|       |
   91|  19.2k|    if (p->vo) {
  ------------------
  |  Branch (91:9): [True: 19.2k, False: 0]
  ------------------
   92|  19.2k|        uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START] = {0};
   93|  19.2k|        vo_query_formats(p->vo, allowed_output_formats);
   94|       |
   95|  10.7M|        for (int n = 0; n < MP_ARRAY_SIZE(allowed_output_formats); n++) {
  ------------------
  |  |   49|  10.7M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (95:25): [True: 10.7M, False: 19.2k]
  ------------------
   96|  10.7M|            if (allowed_output_formats[n])
  ------------------
  |  Branch (96:17): [True: 10.7M, False: 0]
  ------------------
   97|  10.7M|                mp_autoconvert_add_imgfmt(p->convert, IMGFMT_START + n, 0);
   98|  10.7M|        }
   99|  19.2k|    }
  100|  19.2k|}
f_output_chain.c:create_wrapper_filter:
  258|   106k|{
  259|   106k|    struct mp_filter *f = mp_filter_create(p->f, &user_wrapper_filter);
  260|   106k|    if (!f)
  ------------------
  |  Branch (260:9): [True: 0, False: 106k]
  ------------------
  261|      0|        abort();
  262|   106k|    struct mp_user_filter *wrapper = f->priv;
  263|   106k|    wrapper->wrapper = f;
  264|   106k|    wrapper->p = p;
  265|   106k|    wrapper->last_in_aformat = talloc_steal(wrapper, mp_aframe_create());
  ------------------
  |  |   38|   106k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   106k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  266|       |    wrapper->last_is_active = true;
  267|   106k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  268|   106k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  269|   106k|    return wrapper;
  270|   106k|}
f_output_chain.c:user_wrapper_destroy:
  240|   106k|{
  241|   106k|    struct mp_user_filter *u = f->priv;
  242|       |
  243|   106k|    struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  244|   106k|    m_option_free(&dummy, &u->args);
  245|       |
  246|   106k|    mp_filter_free_children(f);
  247|   106k|}
f_output_chain.c:user_wrapper_process:
  157|  12.7M|{
  158|  12.7M|    struct mp_user_filter *u = f->priv;
  159|  12.7M|    struct chain *p = u->p;
  160|       |
  161|  12.7M|    mp_filter_set_error_handler(u->f, f);
  162|  12.7M|    const char *name = u->label ? u->label : u->name;
  ------------------
  |  Branch (162:24): [True: 0, False: 12.7M]
  ------------------
  163|  12.7M|    mp_assert(u->name);
  ------------------
  |  |   41|  12.7M|#define mp_assert assert
  ------------------
  |  Branch (163:5): [True: 12.7M, False: 0]
  ------------------
  164|       |
  165|  12.7M|    if (!u->failed && mp_filter_has_failed(u->f)) {
  ------------------
  |  Branch (165:9): [True: 12.7M, False: 0]
  |  Branch (165:23): [True: 0, False: 12.7M]
  ------------------
  166|      0|        if (u == p->convert_wrapper) {
  ------------------
  |  Branch (166:13): [True: 0, False: 0]
  ------------------
  167|       |            // This is a fuckup we can't ignore.
  168|      0|            MP_FATAL(p, "Cannot convert decoder/filter output to any format "
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  169|      0|                     "supported by the output.\n");
  170|      0|            p->public.failed_output_conversion = true;
  171|      0|            mp_filter_wakeup(p->f);
  172|      0|        } else {
  173|      0|            MP_ERR(p, "Disabling filter %s because it has failed.\n", name);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  174|      0|            mp_filter_reset(u->f); // clear out staled buffered data
  175|      0|        }
  176|      0|        u->failed = true;
  177|      0|    }
  178|       |
  179|  12.7M|    if (u->failed) {
  ------------------
  |  Branch (179:9): [True: 0, False: 12.7M]
  ------------------
  180|       |        // The convert_wrapper failure is fatal so we must signal EOF. Similarly,
  181|       |        // if this wrapper forwarded EOF into the inner filter, that EOF may
  182|       |        // be lost. Reset filter may have discarded this frame from failed filter.
  183|       |        // Synthesize EOF so downstream doesn't stall indefinitely.
  184|      0|        if (u == p->convert_wrapper || u->in_eof) {
  ------------------
  |  Branch (184:13): [True: 0, False: 0]
  |  Branch (184:40): [True: 0, False: 0]
  ------------------
  185|      0|            if (mp_pin_in_needs_data(f->ppins[1])) {
  ------------------
  |  Branch (185:17): [True: 0, False: 0]
  ------------------
  186|      0|                if (!u->error_eof_sent)
  ------------------
  |  Branch (186:21): [True: 0, False: 0]
  ------------------
  187|      0|                    mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  188|      0|                u->error_eof_sent = true;
  189|      0|            }
  190|      0|            return;
  191|      0|        }
  192|       |
  193|      0|        mp_pin_transfer_data(f->ppins[1], f->ppins[0]);
  194|      0|        return;
  195|      0|    }
  196|       |
  197|  12.7M|    if (mp_pin_can_transfer_data(u->f->pins[0], f->ppins[0])) {
  ------------------
  |  Branch (197:9): [True: 3.55M, False: 9.19M]
  ------------------
  198|  3.55M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  199|       |
  200|  3.55M|        check_in_format_change(u, frame);
  201|       |
  202|  3.55M|        double pts = mp_frame_get_pts(frame);
  203|  3.55M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  3.55M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (203:13): [True: 3.46M, False: 92.8k]
  ------------------
  204|  3.46M|            u->last_in_pts = pts;
  205|       |
  206|  3.55M|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (206:13): [True: 92.3k, False: 3.46M]
  ------------------
  207|  92.3k|            u->in_eof = true;
  208|       |
  209|  3.55M|        mp_pin_in_write(u->f->pins[0], frame);
  210|  3.55M|    }
  211|       |
  212|  12.7M|    if (mp_pin_can_transfer_data(f->ppins[1], u->f->pins[1])) {
  ------------------
  |  Branch (212:9): [True: 3.55M, False: 9.19M]
  ------------------
  213|  3.55M|        struct mp_frame frame = mp_pin_out_read(u->f->pins[1]);
  214|       |
  215|  3.55M|        double pts = mp_frame_get_pts(frame);
  216|  3.55M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  3.55M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (216:13): [True: 3.46M, False: 92.8k]
  ------------------
  217|  3.46M|            u->last_out_pts = pts;
  218|       |
  219|  3.55M|        mp_pin_in_write(f->ppins[1], frame);
  220|       |
  221|  3.55M|        struct mp_filter_command cmd = {.type = MP_FILTER_COMMAND_IS_ACTIVE};
  222|  3.55M|        if (mp_filter_command(u->f, &cmd) && u->last_is_active != cmd.is_active) {
  ------------------
  |  Branch (222:13): [True: 1.83M, False: 1.72M]
  |  Branch (222:46): [True: 54.1k, False: 1.77M]
  ------------------
  223|  54.1k|            u->last_is_active = cmd.is_active;
  224|  54.1k|            MP_VERBOSE(p, "[%s] (%sabled)\n", u->name,
  ------------------
  |  |   92|  54.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   108k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 54.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|  54.1k|                       u->last_is_active ? "en" : "dis");
  226|  54.1k|        }
  227|  3.55M|    }
  228|  12.7M|}
f_output_chain.c:check_in_format_change:
  104|  3.55M|{
  105|  3.55M|    struct chain *p = u->p;
  106|       |
  107|  3.55M|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (107:9): [True: 262k, False: 3.29M]
  ------------------
  108|   262k|        struct mp_image *img = frame.data;
  109|       |
  110|   262k|        if (!mp_image_params_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (110:13): [True: 11.0k, False: 251k]
  ------------------
  111|  11.0k|            if (u == p->input) {
  ------------------
  |  Branch (111:17): [True: 1.84k, False: 9.21k]
  ------------------
  112|  1.84k|                p->public.input_params = img->params;
  113|  9.21k|            } else if (u == p->output) {
  ------------------
  |  Branch (113:24): [True: 1.84k, False: 7.36k]
  ------------------
  114|  1.84k|                p->public.output_params = img->params;
  115|  1.84k|            }
  116|       |
  117|  11.0k|            if (!mp_image_params_static_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (117:17): [True: 11.0k, False: 0]
  ------------------
  118|  11.0k|                MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  11.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  119|  11.0k|                           mp_image_params_to_str(&img->params));
  120|       |
  121|       |                // Unfortunately there's no good place to update these.
  122|       |                // But a common case is enabling HW decoding, which
  123|       |                // might init some support of them in the VO, and update
  124|       |                // the VO's format list.
  125|       |                //
  126|       |                // But as this is only relevant to the "convert" filter, don't
  127|       |                // do this for the other filters as it is wasted work.
  128|  11.0k|                if (strcmp(u->name, "convert") == 0)
  ------------------
  |  Branch (128:21): [True: 1.84k, False: 9.21k]
  ------------------
  129|  1.84k|                    update_output_caps(p);
  130|       |
  131|  11.0k|                p->public.reconfig_happened = true;
  132|  11.0k|            }
  133|  11.0k|            u->last_in_vformat = img->params;
  134|  11.0k|        }
  135|   262k|    }
  136|       |
  137|  3.55M|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (137:9): [True: 3.20M, False: 354k]
  ------------------
  138|  3.20M|        struct mp_aframe *aframe = frame.data;
  139|       |
  140|  3.20M|        if (!mp_aframe_config_equals(aframe, u->last_in_aformat)) {
  ------------------
  |  Branch (140:13): [True: 32.0k, False: 3.17M]
  ------------------
  141|  32.0k|            MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  32.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  142|  32.0k|                       mp_aframe_format_str(aframe));
  143|  32.0k|            mp_aframe_config_copy(u->last_in_aformat, aframe);
  144|       |
  145|  32.0k|            if (u == p->input) {
  ------------------
  |  Branch (145:17): [True: 8.04k, False: 24.0k]
  ------------------
  146|  8.04k|                mp_aframe_config_copy(p->public.input_aformat, aframe);
  147|  24.0k|            } else if (u == p->output) {
  ------------------
  |  Branch (147:24): [True: 7.95k, False: 16.0k]
  ------------------
  148|  7.95k|                mp_aframe_config_copy(p->public.output_aformat, aframe);
  149|  7.95k|            }
  150|       |
  151|       |            p->public.reconfig_happened = true;
  152|  32.0k|        }
  153|  3.20M|    }
  154|  3.55M|}
f_output_chain.c:relink_filter_list:
  274|  41.3k|{
  275|  41.3k|    struct mp_user_filter **all_filters[3] =
  276|  41.3k|        {p->pre_filters, p->user_filters, p->post_filters};
  277|  41.3k|    int all_filters_num[3] =
  278|  41.3k|        {p->num_pre_filters, p->num_user_filters, p->num_post_filters};
  279|  41.3k|    p->num_all_filters = 0;
  280|   165k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (280:21): [True: 124k, False: 41.3k]
  ------------------
  281|   124k|        struct mp_user_filter **filters = all_filters[n];
  282|   124k|        int filters_num = all_filters_num[n];
  283|   324k|        for (int i = 0; i < filters_num; i++)
  ------------------
  |  Branch (283:25): [True: 200k, False: 124k]
  ------------------
  284|   200k|            MP_TARRAY_APPEND(p, p->all_filters, p->num_all_filters, filters[i]);
  ------------------
  |  |  105|   200k|    do {                                            \
  |  |  106|   200k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   200k|    do {                                            \
  |  |  |  |   97|   200k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   200k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   200k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   200k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 43.7k, False: 156k]
  |  |  |  |  ------------------
  |  |  |  |   99|   200k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  43.7k|    do {                                                        \
  |  |  |  |  |  |   89|  43.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  43.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  43.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  43.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  43.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  43.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  43.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 43.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   200k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 200k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   200k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   200k|        (idxvar)++;                                 \
  |  |  109|   200k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 200k]
  |  |  ------------------
  ------------------
  285|   124k|    }
  286|       |
  287|  41.3k|    mp_assert(p->num_all_filters > 0);
  ------------------
  |  |   41|  41.3k|#define mp_assert assert
  ------------------
  |  Branch (287:5): [True: 41.3k, False: 0]
  ------------------
  288|       |
  289|  41.3k|    p->filters_in = NULL;
  290|  41.3k|    p->filters_out = NULL;
  291|   241k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (291:21): [True: 200k, False: 41.3k]
  ------------------
  292|   200k|        struct mp_filter *f = p->all_filters[n]->wrapper;
  293|   200k|        if (n == 0)
  ------------------
  |  Branch (293:13): [True: 41.3k, False: 158k]
  ------------------
  294|  41.3k|            p->filters_in = f->pins[0];
  295|   200k|        if (p->filters_out)
  ------------------
  |  Branch (295:13): [True: 158k, False: 41.3k]
  ------------------
  296|   158k|            mp_pin_connect(f->pins[0], p->filters_out);
  297|   200k|        p->filters_out = f->pins[1];
  298|   200k|    }
  299|       |
  300|  41.3k|    mp_pin_set_manual_connection_for(p->filters_in, p->f);
  301|  41.3k|    mp_pin_set_manual_connection_for(p->filters_out, p->f);
  302|  41.3k|}
f_output_chain.c:set_speed_any:
  530|  58.8k|{
  531|   164k|    for (int n = num_filters - 1; n >= 0; n--) {
  ------------------
  |  Branch (531:35): [True: 105k, False: 58.8k]
  ------------------
  532|   105k|        mp_assert(*speed);
  ------------------
  |  |   41|   105k|#define mp_assert assert
  ------------------
  |  Branch (532:9): [True: 105k, False: 0]
  ------------------
  533|   105k|        struct mp_filter_command cmd = {
  534|   105k|            .type = command,
  535|   105k|            .speed = *speed,
  536|   105k|        };
  537|   105k|        if (mp_filter_command(filters[n]->f, &cmd))
  ------------------
  |  Branch (537:13): [True: 35.3k, False: 70.6k]
  ------------------
  538|  35.3k|            *speed = 1.0;
  539|   105k|    }
  540|  58.8k|}
f_output_chain.c:output_chain_destroy:
  364|  21.8k|{
  365|  21.8k|    output_chain_reset(f);
  366|  21.8k|}
f_output_chain.c:output_chain_process:
  305|  3.46M|{
  306|  3.46M|    struct chain *p = f->priv;
  307|       |
  308|  3.46M|    if (mp_pin_can_transfer_data(p->filters_in, f->ppins[0])) {
  ------------------
  |  Branch (308:9): [True: 863k, False: 2.59M]
  ------------------
  309|   863k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  310|       |
  311|   863k|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (311:13): [True: 19.2k, False: 844k]
  ------------------
  312|   863k|            MP_VERBOSE(p, "filter input EOF\n");
  ------------------
  |  |   92|  19.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  313|       |
  314|   863k|        if (frame.type == MP_FRAME_VIDEO && p->public.update_subtitles) {
  ------------------
  |  Branch (314:13): [True: 43.7k, False: 820k]
  |  Branch (314:45): [True: 43.7k, False: 0]
  ------------------
  315|  43.7k|            p->public.update_subtitles(p->public.update_subtitles_ctx,
  316|  43.7k|                                       mp_frame_get_pts(frame));
  317|  43.7k|        }
  318|       |
  319|   863k|        mp_pin_in_write(p->filters_in, frame);
  320|   863k|    }
  321|       |
  322|  3.46M|    if (mp_pin_can_transfer_data(f->ppins[1], p->filters_out)) {
  ------------------
  |  Branch (322:9): [True: 863k, False: 2.59M]
  ------------------
  323|   863k|        struct mp_frame frame = mp_pin_out_read(p->filters_out);
  324|       |
  325|   863k|        p->public.got_output_eof = frame.type == MP_FRAME_EOF;
  326|   863k|        if (p->public.got_output_eof)
  ------------------
  |  Branch (326:13): [True: 19.2k, False: 844k]
  ------------------
  327|   863k|            MP_VERBOSE(p, "filter output EOF\n");
  ------------------
  |  |   92|  19.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  328|       |
  329|   863k|        mp_pin_in_write(f->ppins[1], frame);
  330|   863k|    }
  331|  3.46M|}
f_output_chain.c:create_video_things:
  698|  9.69k|{
  699|  9.69k|    p->frame_type = MP_FRAME_VIDEO;
  700|       |
  701|  9.69k|    p->stream_info.priv = p;
  702|  9.69k|    p->stream_info.get_display_fps = get_display_fps;
  703|  9.69k|    p->stream_info.get_display_res = get_display_res;
  704|       |
  705|  9.69k|    p->f->stream_info = &p->stream_info;
  706|       |
  707|  9.69k|    struct mp_user_filter *f = create_wrapper_filter(p);
  708|  9.69k|    f->name = "userdeint";
  709|  9.69k|    f->f = mp_deint_create(f->wrapper);
  710|  9.69k|    if (!f->f)
  ------------------
  |  Branch (710:9): [True: 0, False: 9.69k]
  ------------------
  711|      0|        abort();
  712|  9.69k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, f);
  ------------------
  |  |  105|  9.69k|    do {                                            \
  |  |  106|  9.69k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  9.69k|    do {                                            \
  |  |  |  |   97|  9.69k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  9.69k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  9.69k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  9.69k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 9.69k]
  |  |  |  |  ------------------
  |  |  |  |   99|  9.69k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  9.69k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 9.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  9.69k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  9.69k|        (idxvar)++;                                 \
  |  |  109|  9.69k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  713|       |
  714|  9.69k|    f = create_wrapper_filter(p);
  715|  9.69k|    f->name = "autovflip";
  716|  9.69k|    f->f = mp_autovflip_create(f->wrapper);
  717|  9.69k|    if (!f->f)
  ------------------
  |  Branch (717:9): [True: 0, False: 9.69k]
  ------------------
  718|      0|        abort();
  719|  9.69k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  9.69k|    do {                                            \
  |  |  106|  9.69k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  9.69k|    do {                                            \
  |  |  |  |   97|  9.69k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  9.69k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  9.69k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  9.69k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 9.69k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  9.69k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  9.69k|    do {                                                        \
  |  |  |  |  |  |   89|  9.69k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  9.69k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  9.69k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  9.69k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  9.69k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  9.69k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  9.69k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 9.69k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  9.69k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 9.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  9.69k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  9.69k|        (idxvar)++;                                 \
  |  |  109|  9.69k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  720|       |
  721|  9.69k|    f = create_wrapper_filter(p);
  722|  9.69k|    f->name = "autorotate";
  723|  9.69k|    f->f = mp_autorotate_create(f->wrapper);
  724|  9.69k|    if (!f->f)
  ------------------
  |  Branch (724:9): [True: 0, False: 9.69k]
  ------------------
  725|      0|        abort();
  726|  9.69k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  9.69k|    do {                                            \
  |  |  106|  9.69k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  9.69k|    do {                                            \
  |  |  |  |   97|  9.69k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  9.69k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  9.69k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  9.69k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 9.69k]
  |  |  |  |  ------------------
  |  |  |  |   99|  9.69k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  9.69k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 9.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  9.69k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  9.69k|        (idxvar)++;                                 \
  |  |  109|  9.69k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.69k]
  |  |  ------------------
  ------------------
  727|  9.69k|}
f_output_chain.c:create_audio_things:
  730|  12.1k|{
  731|  12.1k|    p->frame_type = MP_FRAME_AUDIO;
  732|       |
  733|  12.1k|    struct mp_user_filter *f = create_wrapper_filter(p);
  734|  12.1k|    f->name = "userspeed";
  735|  12.1k|    f->f = mp_autoaspeed_create(f->wrapper);
  736|  12.1k|    if (!f->f)
  ------------------
  |  Branch (736:9): [True: 0, False: 12.1k]
  ------------------
  737|      0|        abort();
  738|  12.1k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  12.1k|    do {                                            \
  |  |  106|  12.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  12.1k|    do {                                            \
  |  |  |  |   97|  12.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  12.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  12.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  12.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  12.1k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  12.1k|    do {                                                        \
  |  |  |  |  |  |   89|  12.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  12.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  12.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  12.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  12.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  12.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  12.1k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 12.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  12.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 12.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  12.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  12.1k|        (idxvar)++;                                 \
  |  |  109|  12.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 12.1k]
  |  |  ------------------
  ------------------
  739|  12.1k|}
f_output_chain.c:on_audio_format_change:
  472|  8.04k|{
  473|  8.04k|    struct chain *p = opaque;
  474|       |
  475|       |    // Let the f_output_chain user know what format to use. (Not quite proper,
  476|       |    // since we overwrite what some other code normally automatically sets.
  477|       |    // The main issue is that this callback is called before output_aformat can
  478|       |    // be set, because we "block" the converter until the AO is reconfigured,
  479|       |    // and mp_autoconvert_format_change_continue() is called.)
  480|  8.04k|    mp_aframe_config_copy(p->public.output_aformat,
  481|  8.04k|                          p->convert_wrapper->last_in_aformat);
  482|       |
  483|       |    // Ask for calling mp_output_chain_set_ao().
  484|  8.04k|    p->public.ao_needs_update = true;
  485|  8.04k|    p->ao = NULL;
  486|       |
  487|       |    // Do something silly to notify the f_output_chain user. (Not quite proper,
  488|       |    // it's merely that this will cause the core to run again, and check the
  489|       |    // flag set above.)
  490|  8.04k|    mp_filter_wakeup(p->f);
  491|  8.04k|}
f_output_chain.c:output_chain_reset:
  334|  43.7k|{
  335|  43.7k|    struct chain *p = f->priv;
  336|       |
  337|  43.7k|    p->public.ao_needs_update = false;
  338|       |
  339|       |    p->public.got_output_eof = false;
  340|  43.7k|}

mp_subfilter_read:
   94|  3.72M|{
   95|  3.72M|    if (sub->filter) {
  ------------------
  |  Branch (95:9): [True: 0, False: 3.72M]
  ------------------
   96|      0|        if (mp_pin_can_transfer_data(sub->out, sub->filter->pins[1])) {
  ------------------
  |  Branch (96:13): [True: 0, False: 0]
  ------------------
   97|      0|            struct mp_frame frame = mp_pin_out_read(sub->filter->pins[1]);
   98|      0|            if (sub->draining && frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (98:17): [True: 0, False: 0]
  |  Branch (98:34): [True: 0, False: 0]
  ------------------
   99|      0|                sub->draining = false;
  100|      0|                TA_FREEP(&sub->filter);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  101|      0|                mark_progress(sub);
  102|      0|                return false;
  103|      0|            }
  104|      0|            mp_pin_in_write(sub->out, frame);
  105|      0|            return false;
  106|      0|        }
  107|      0|        if (sub->draining)
  ------------------
  |  Branch (107:13): [True: 0, False: 0]
  ------------------
  108|      0|            return false;
  109|      0|    }
  110|       |
  111|  3.72M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (111:26): [True: 0, False: 3.72M]
  ------------------
  112|       |
  113|  3.72M|    if (sub->frame.type)
  ------------------
  |  Branch (113:9): [True: 7.95k, False: 3.71M]
  ------------------
  114|  7.95k|        return mp_pin_in_needs_data(out);
  115|       |
  116|  3.71M|    if (!mp_pin_can_transfer_data(out, sub->in))
  ------------------
  |  Branch (116:9): [True: 1.88M, False: 1.83M]
  ------------------
  117|  1.88M|        return false;
  118|       |
  119|  1.83M|    sub->frame = mp_pin_out_read(sub->in);
  120|       |    return true;
  121|  3.71M|}
mp_subfilter_reset:
  124|  63.1k|{
  125|  63.1k|    if (sub->filter && sub->draining)
  ------------------
  |  Branch (125:9): [True: 0, False: 63.1k]
  |  Branch (125:24): [True: 0, False: 0]
  ------------------
  126|      0|        TA_FREEP(&sub->filter);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  127|       |    sub->draining = false;
  128|  63.1k|    mp_frame_unref(&sub->frame);
  129|  63.1k|}
mp_subfilter_continue:
  132|  1.83M|{
  133|  1.83M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (133:26): [True: 0, False: 1.83M]
  ------------------
  134|       |    // It was made sure earlier that the pin is writable, unless the filter
  135|       |    // was newly created, or a previously existing filter (which was going to
  136|       |    // accept input) was destroyed. In those cases, essentially restart
  137|       |    // data flow.
  138|  1.83M|    if (!mp_pin_in_needs_data(out)) {
  ------------------
  |  Branch (138:9): [True: 0, False: 1.83M]
  ------------------
  139|      0|        mark_progress(sub);
  140|      0|        return;
  141|      0|    }
  142|  1.83M|    mp_pin_in_write(out, sub->frame);
  143|  1.83M|    sub->frame = MP_NO_FRAME;
  ------------------
  |  |   58|  1.83M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  1.83M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  144|  1.83M|}
mp_subfilter_destroy:
  147|  45.1k|{
  148|  45.1k|    TA_FREEP(&sub->filter);
  ------------------
  |  |   81|  45.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  45.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 45.1k]
  |  |  ------------------
  ------------------
  149|       |    sub->draining = false;
  150|  45.1k|}
mp_subfilter_drain_destroy:
  153|  20.5k|{
  154|  20.5k|    if (!sub->draining && sub->filter) {
  ------------------
  |  Branch (154:9): [True: 20.5k, False: 0]
  |  Branch (154:27): [True: 0, False: 20.5k]
  ------------------
  155|       |        // We know the filter is writable (unless the user created a new filter
  156|       |        // and immediately called this function, which is invalid).
  157|      0|        mp_pin_in_write(sub->filter->pins[0], MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  158|       |        sub->draining = true;
  159|      0|    }
  160|  20.5k|    return !sub->filter;
  161|  20.5k|}
mp_bidir_nop_filter_create:
  168|  43.7k|{
  169|  43.7k|    struct mp_filter *f = mp_filter_create(parent, &bidir_nop_filter);
  170|  43.7k|    if (!f)
  ------------------
  |  Branch (170:9): [True: 0, False: 43.7k]
  ------------------
  171|      0|        return NULL;
  172|       |
  173|  43.7k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  174|  43.7k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  175|       |
  176|  43.7k|    mp_pin_connect(f->ppins[1], f->ppins[0]);
  177|       |
  178|  43.7k|    return f;
  179|  43.7k|}

mp_filter_internal_mark_progress:
  190|  1.41M|{
  191|  1.41M|    struct filter_runner *r = f->in->runner;
  192|  1.41M|    mp_assert(r->filtering); // only call from f's process()
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (192:5): [True: 1.41M, False: 0]
  ------------------
  193|  1.41M|    add_pending(f);
  194|  1.41M|}
mp_filter_graph_run:
  212|  2.33M|{
  213|  2.33M|    struct filter_runner *r = filter->in->runner;
  214|  2.33M|    mp_assert(filter == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  2.33M|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 2.33M, False: 0]
  ------------------
  215|       |
  216|  2.33M|    int64_t end_time = 0;
  217|  2.33M|    if (isfinite(r->max_run_time))
  ------------------
  |  Branch (217:9): [True: 182k, False: 2.15M]
  ------------------
  218|   182k|        end_time = mp_time_ns_add(mp_time_ns(), MPMAX(r->max_run_time, 0));
  ------------------
  |  |   44|   182k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 182k, False: 0]
  |  |  ------------------
  ------------------
  219|       |
  220|       |    // (could happen with separate filter graphs calling each other, for now
  221|       |    // ignore this issue as we don't use such a setup anywhere)
  222|  2.33M|    mp_assert(!r->filtering);
  ------------------
  |  |   41|  2.33M|#define mp_assert assert
  ------------------
  |  Branch (222:5): [True: 2.33M, False: 0]
  ------------------
  223|       |
  224|  2.33M|    r->filtering = true;
  225|       |
  226|  2.33M|    flush_async_notifications(r);
  227|       |
  228|  2.33M|    bool exit_req = false;
  229|       |
  230|  36.8M|    while (1) {
  ------------------
  |  Branch (230:12): [True: 36.8M, Folded]
  ------------------
  231|  36.8M|        if (atomic_exchange_explicit(&r->interrupt_flag, false,
  ------------------
  |  Branch (231:13): [True: 71, False: 36.8M]
  ------------------
  232|  36.8M|                                     memory_order_acq_rel))
  233|     71|        {
  234|     71|            mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|     71|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  235|     71|            if (!r->async_wakeup_sent && r->wakeup_cb)
  ------------------
  |  Branch (235:17): [True: 35, False: 36]
  |  Branch (235:42): [True: 35, False: 0]
  ------------------
  236|     35|                r->wakeup_cb(r->wakeup_ctx);
  237|     71|            r->async_wakeup_sent = true;
  238|     71|            mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|     71|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  239|     71|            exit_req = true;
  240|     71|        }
  241|       |
  242|  36.8M|        if (!r->num_pending) {
  ------------------
  |  Branch (242:13): [True: 2.36M, False: 34.4M]
  ------------------
  243|  2.36M|            flush_async_notifications(r);
  244|  2.36M|            if (!r->num_pending)
  ------------------
  |  Branch (244:17): [True: 2.33M, False: 30.5k]
  ------------------
  245|  2.33M|                break;
  246|  2.36M|        }
  247|       |
  248|  34.5M|        struct mp_filter *next = NULL;
  249|       |
  250|  34.5M|        if (r->pending[0]->in->high_priority) {
  ------------------
  |  Branch (250:13): [True: 816k, False: 33.6M]
  ------------------
  251|   816k|            next = r->pending[0];
  252|   816k|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, 0);
  ------------------
  |  |  143|   816k|    do {                                            \
  |  |  144|   816k|        size_t at_ = (at);                          \
  |  |  145|   816k|        assert(at_ < (idxvar));                     \
  |  |  146|   816k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   816k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   816k|        (idxvar)--;                                 \
  |  |  149|   816k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 816k]
  |  |  ------------------
  ------------------
  |  Branch (252:13): [True: 816k, False: 0]
  ------------------
  253|  33.6M|        } else if (!exit_req) {
  ------------------
  |  Branch (253:20): [True: 33.6M, False: 18.4E]
  ------------------
  254|  33.6M|            next = r->pending[r->num_pending - 1];
  255|  33.6M|            r->num_pending -= 1;
  256|  33.6M|        }
  257|       |
  258|  34.5M|        if (!next)
  ------------------
  |  Branch (258:13): [True: 71, False: 34.5M]
  ------------------
  259|     71|            break;
  260|       |
  261|  34.5M|        next->in->pending = false;
  262|  34.5M|        if (next->in->info->process)
  ------------------
  |  Branch (262:13): [True: 33.5M, False: 927k]
  ------------------
  263|  33.5M|            next->in->info->process(next);
  264|       |
  265|  34.5M|        if (end_time && mp_time_ns() >= end_time)
  ------------------
  |  Branch (265:13): [True: 32.1M, False: 2.30M]
  |  Branch (265:25): [True: 71, False: 32.1M]
  ------------------
  266|     71|            mp_filter_graph_interrupt(r->root_filter);
  267|  34.5M|    }
  268|       |
  269|  2.33M|    r->filtering = false;
  270|       |
  271|  2.33M|    bool externals = r->external_pending;
  272|       |    r->external_pending = false;
  273|  2.33M|    return externals;
  274|  2.33M|}
mp_pin_can_transfer_data:
  277|  37.7M|{
  278|  37.7M|    return mp_pin_in_needs_data(dst) && mp_pin_out_request_data(src);
  ------------------
  |  Branch (278:12): [True: 30.0M, False: 7.67M]
  |  Branch (278:41): [True: 11.4M, False: 18.6M]
  ------------------
  279|  37.7M|}
mp_pin_in_needs_data:
  290|  72.0M|{
  291|  72.0M|    mp_assert(p->dir == MP_PIN_IN);
  ------------------
  |  |   41|  72.0M|#define mp_assert assert
  ------------------
  |  Branch (291:5): [True: 72.0M, False: 18.4E]
  ------------------
  292|  72.0M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  72.0M|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 72.0M, False: 18.4E]
  ------------------
  293|  72.0M|    return p->conn && p->conn->manual_connection && p->conn->data_requested;
  ------------------
  |  Branch (293:12): [True: 72.0M, False: 1.35k]
  |  Branch (293:23): [True: 72.0M, False: 18.4E]
  |  Branch (293:53): [True: 62.6M, False: 9.48M]
  ------------------
  294|  72.0M|}
mp_pin_in_write:
  297|  16.8M|{
  298|  16.8M|    if (!mp_pin_in_needs_data(p) || frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (298:9): [True: 18.4E, False: 16.8M]
  |  Branch (298:37): [True: 18.4E, False: 16.8M]
  ------------------
  299|      0|        if (frame.type)
  ------------------
  |  Branch (299:13): [True: 0, False: 0]
  ------------------
  300|      0|            MP_ERR(p->owner, "losing frame on %s\n", p->name);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  301|      0|        mp_frame_unref(&frame);
  302|      0|        return false;
  303|      0|    }
  304|  16.8M|    mp_assert(p->conn->data.type == MP_FRAME_NONE);
  ------------------
  |  |   41|  16.8M|#define mp_assert assert
  ------------------
  |  Branch (304:5): [True: 16.8M, False: 18.4E]
  ------------------
  305|  16.8M|    p->conn->data = frame;
  306|  16.8M|    p->conn->data_requested = false;
  307|  16.8M|    add_pending_pin(p->conn);
  308|  16.8M|    filter_recursive(p);
  309|       |    return true;
  310|  16.8M|}
mp_pin_out_has_data:
  313|  84.4M|{
  314|  84.4M|    mp_assert(p->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  84.4M|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 84.4M, False: 18.4E]
  ------------------
  315|  84.4M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  84.4M|#define mp_assert assert
  ------------------
  |  Branch (315:5): [True: 84.4M, False: 4.54k]
  ------------------
  316|  84.4M|    return p->conn && p->conn->manual_connection && p->data.type != MP_FRAME_NONE;
  ------------------
  |  Branch (316:12): [True: 84.4M, False: 18.4E]
  |  Branch (316:23): [True: 84.4M, False: 18.4E]
  |  Branch (316:53): [True: 29.1M, False: 55.3M]
  ------------------
  317|  84.4M|}
mp_pin_out_request_data:
  320|  56.3M|{
  321|  56.3M|    if (mp_pin_out_has_data(p))
  ------------------
  |  Branch (321:9): [True: 28.2M, False: 28.1M]
  ------------------
  322|  28.2M|        return true;
  323|  28.1M|    if (p->conn && p->conn->manual_connection) {
  ------------------
  |  Branch (323:9): [True: 28.1M, False: 18.4E]
  |  Branch (323:20): [True: 28.1M, False: 18.4E]
  ------------------
  324|  28.1M|        if (!p->data_requested) {
  ------------------
  |  Branch (324:13): [True: 16.8M, False: 11.2M]
  ------------------
  325|       |            p->data_requested = true;
  326|  16.8M|            add_pending_pin(p->conn);
  327|  16.8M|        }
  328|  28.1M|        filter_recursive(p);
  329|  28.1M|    }
  330|  28.1M|    return mp_pin_out_has_data(p);
  331|  56.3M|}
mp_pin_out_request_data_next:
  334|   802k|{
  335|   802k|    if (mp_pin_out_request_data(p))
  ------------------
  |  Branch (335:9): [True: 0, False: 802k]
  ------------------
  336|      0|        add_pending_pin(p->conn);
  337|   802k|}
mp_pin_out_read:
  340|  24.6M|{
  341|  24.6M|    if (!mp_pin_out_request_data(p))
  ------------------
  |  Branch (341:9): [True: 7.82M, False: 16.8M]
  ------------------
  342|  7.82M|        return MP_NO_FRAME;
  ------------------
  |  |   58|  7.82M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  7.82M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  343|  16.8M|    struct mp_frame res = p->data;
  344|  16.8M|    p->data = MP_NO_FRAME;
  ------------------
  |  |   58|  16.8M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  16.8M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  345|  16.8M|    return res;
  346|  24.6M|}
mp_pin_connect:
  438|   256k|{
  439|   256k|    mp_assert(src->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   256k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 256k, False: 0]
  ------------------
  440|   256k|    mp_assert(dst->dir == MP_PIN_IN);
  ------------------
  |  |   41|   256k|#define mp_assert assert
  ------------------
  |  Branch (440:5): [True: 256k, False: 0]
  ------------------
  441|       |
  442|   256k|    if (dst->user_conn == src) {
  ------------------
  |  Branch (442:9): [True: 73.6k, False: 182k]
  ------------------
  443|  73.6k|        mp_assert(src->user_conn == dst);
  ------------------
  |  |   41|  73.6k|#define mp_assert assert
  ------------------
  |  Branch (443:9): [True: 73.6k, False: 0]
  ------------------
  444|  73.6k|        return;
  445|  73.6k|    }
  446|       |
  447|   182k|    mp_pin_disconnect(src);
  448|   182k|    mp_pin_disconnect(dst);
  449|       |
  450|   182k|    src->user_conn = dst;
  451|   182k|    dst->user_conn = src;
  452|       |
  453|   182k|    init_connection(src);
  454|   182k|}
mp_pin_set_manual_connection_for:
  462|  82.6k|{
  463|  82.6k|    if (p->manual_connection == f)
  ------------------
  |  Branch (463:9): [True: 82.6k, False: 0]
  ------------------
  464|  82.6k|        return;
  465|      0|    if (p->within_conn)
  ------------------
  |  Branch (465:9): [True: 0, False: 0]
  ------------------
  466|      0|        mp_pin_disconnect(p);
  467|      0|    p->manual_connection = f;
  468|      0|    init_connection(p);
  469|      0|}
mp_pin_disconnect:
  499|  1.57M|{
  500|  1.57M|    if (!mp_pin_is_connected(p))
  ------------------
  |  Branch (500:9): [True: 182k, False: 1.39M]
  ------------------
  501|   182k|        return;
  502|       |
  503|  1.39M|    p->manual_connection = NULL;
  504|       |
  505|  1.39M|    struct mp_pin *conn = p->user_conn;
  506|  1.39M|    if (conn) {
  ------------------
  |  Branch (506:9): [True: 182k, False: 1.21M]
  ------------------
  507|   182k|        p->user_conn = NULL;
  508|   182k|        conn->user_conn = NULL;
  509|   182k|        deinit_connection(conn);
  510|   182k|    }
  511|       |
  512|  1.39M|    deinit_connection(p);
  513|  1.39M|}
mp_pin_is_connected:
  516|  1.57M|{
  517|  1.57M|    return p->user_conn || p->manual_connection;
  ------------------
  |  Branch (517:12): [True: 182k, False: 1.39M]
  |  Branch (517:28): [True: 1.21M, False: 182k]
  ------------------
  518|  1.57M|}
mp_filter_get_info:
  536|  7.95k|{
  537|  7.95k|    return f->in->info;
  538|  7.95k|}
mp_filter_set_high_priority:
  541|  7.95k|{
  542|  7.95k|    f->in->high_priority = pri;
  543|  7.95k|}
mp_filter_get_named_pin:
  552|   605k|{
  553|   861k|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (553:21): [True: 255k, False: 605k]
  ------------------
  554|   255k|        if (name && strcmp(f->pins[n]->name, name) == 0)
  ------------------
  |  Branch (554:13): [True: 255k, False: 0]
  |  Branch (554:21): [True: 0, False: 255k]
  ------------------
  555|      0|            return f->pins[n];
  556|   255k|    }
  557|   605k|    return NULL;
  558|   605k|}
mp_filter_set_error_handler:
  561|  12.7M|{
  562|  12.7M|    f->in->error_handler = handler;
  563|  12.7M|}
mp_filter_has_failed:
  578|  12.7M|{
  579|  12.7M|    bool failed = filter->in->failed;
  580|       |    filter->in->failed = false;
  581|  12.7M|    return failed;
  582|  12.7M|}
mp_filter_reset:
  595|   142k|{
  596|   142k|    if (!filter)
  ------------------
  |  Branch (596:9): [True: 0, False: 142k]
  ------------------
  597|      0|        return;
  598|       |
  599|   146k|    for (int n = 0; n < filter->in->num_children; n++)
  ------------------
  |  Branch (599:21): [True: 4.29k, False: 142k]
  ------------------
  600|  4.29k|        mp_filter_reset(filter->in->children[n]);
  601|       |
  602|   146k|    for (int n = 0; n < filter->num_pins; n++) {
  ------------------
  |  Branch (602:21): [True: 4.29k, False: 142k]
  ------------------
  603|  4.29k|        struct mp_pin *p = filter->ppins[n];
  604|  4.29k|        reset_pin(p);
  605|  4.29k|        reset_pin(p->other);
  606|  4.29k|    }
  607|       |
  608|   142k|    if (filter->in->info->reset)
  ------------------
  |  Branch (608:9): [True: 0, False: 142k]
  ------------------
  609|      0|        filter->in->info->reset(filter);
  610|   142k|}
mp_filter_add_pin:
  614|   605k|{
  615|   605k|    mp_assert(dir == MP_PIN_IN || dir == MP_PIN_OUT);
  ------------------
  |  |   41|   605k|#define mp_assert assert
  ------------------
  |  Branch (615:5): [True: 275k, False: 329k]
  |  Branch (615:5): [True: 329k, False: 0]
  ------------------
  616|   605k|    mp_assert(name && name[0]);
  ------------------
  |  |   41|   605k|#define mp_assert assert
  ------------------
  |  Branch (616:5): [True: 605k, False: 0]
  |  Branch (616:5): [True: 605k, False: 0]
  ------------------
  617|   605k|    mp_assert(!mp_filter_get_named_pin(f, name));
  ------------------
  |  |   41|   605k|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 605k, False: 0]
  ------------------
  618|       |
  619|       |    // "Public" pin
  620|   605k|    struct mp_pin *p = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|   605k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   605k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   605k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|   605k|    *p = (struct mp_pin){
  622|   605k|        .name = talloc_strdup(p, name),
  ------------------
  |  |   50|   605k|#define talloc_strdup                   ta_xstrdup
  ------------------
  623|   605k|        .dir = dir,
  624|   605k|        .owner = f,
  625|   605k|        .manual_connection = f->in->parent,
  626|   605k|    };
  627|       |
  628|       |    // "Private" paired pin
  629|   605k|    p->other = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|   605k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   605k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   605k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|   605k|    *p->other = (struct mp_pin){
  631|   605k|        .name = p->name,
  632|   605k|        .dir = p->dir == MP_PIN_IN ? MP_PIN_OUT : MP_PIN_IN,
  ------------------
  |  Branch (632:16): [True: 275k, False: 329k]
  ------------------
  633|   605k|        .owner = f,
  634|   605k|        .other = p,
  635|   605k|        .manual_connection = f,
  636|   605k|    };
  637|       |
  638|   605k|    MP_TARRAY_GROW(f, f->pins, f->num_pins);
  ------------------
  |  |   96|   605k|    do {                                            \
  |  |   97|   605k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   605k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   605k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   605k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 349k, False: 255k]
  |  |  ------------------
  |  |   99|   605k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   349k|    do {                                                        \
  |  |  |  |   89|   349k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   349k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   349k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   349k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   349k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   349k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   349k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 349k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   605k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 605k]
  |  |  ------------------
  ------------------
  639|   605k|    MP_TARRAY_GROW(f, f->ppins, f->num_pins);
  ------------------
  |  |   96|   605k|    do {                                            \
  |  |   97|   605k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   605k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   605k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   605k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 349k, False: 255k]
  |  |  ------------------
  |  |   99|   605k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   349k|    do {                                                        \
  |  |  |  |   89|   349k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   349k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   349k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   349k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   349k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   349k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   349k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 349k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   605k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 605k]
  |  |  ------------------
  ------------------
  640|   605k|    f->pins[f->num_pins] = p;
  641|   605k|    f->ppins[f->num_pins] = p->other;
  642|   605k|    f->num_pins += 1;
  643|       |
  644|   605k|    init_connection(p);
  645|       |
  646|   605k|    return p->other;
  647|   605k|}
mp_filter_remove_pin:
  650|   605k|{
  651|   605k|    if (!p)
  ------------------
  |  Branch (651:9): [True: 0, False: 605k]
  ------------------
  652|      0|        return;
  653|       |
  654|   605k|    mp_assert(p->owner == f);
  ------------------
  |  |   41|   605k|#define mp_assert assert
  ------------------
  |  Branch (654:5): [True: 605k, False: 0]
  ------------------
  655|   605k|    mp_pin_disconnect(p);
  656|   605k|    mp_pin_disconnect(p->other);
  657|       |
  658|   605k|    int index = -1;
  659|   605k|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (659:21): [True: 605k, False: 0]
  ------------------
  660|   605k|        if (f->ppins[n] == p) {
  ------------------
  |  Branch (660:13): [True: 605k, False: 0]
  ------------------
  661|   605k|            index = n;
  662|   605k|            break;
  663|   605k|        }
  664|   605k|    }
  665|   605k|    mp_assert(index >= 0);
  ------------------
  |  |   41|   605k|#define mp_assert assert
  ------------------
  |  Branch (665:5): [True: 605k, False: 0]
  ------------------
  666|       |
  667|   605k|    talloc_free(f->pins[index]);
  ------------------
  |  |   47|   605k|#define talloc_free                     ta_free
  ------------------
  668|   605k|    talloc_free(f->ppins[index]);
  ------------------
  |  |   47|   605k|#define talloc_free                     ta_free
  ------------------
  669|       |
  670|   605k|    int count = f->num_pins;
  671|   605k|    MP_TARRAY_REMOVE_AT(f->pins, count, index);
  ------------------
  |  |  143|   605k|    do {                                            \
  |  |  144|   605k|        size_t at_ = (at);                          \
  |  |  145|   605k|        assert(at_ < (idxvar));                     \
  |  |  146|   605k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   605k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   605k|        (idxvar)--;                                 \
  |  |  149|   605k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 605k]
  |  |  ------------------
  ------------------
  |  Branch (671:5): [True: 605k, False: 0]
  ------------------
  672|   605k|    count = f->num_pins;
  673|   605k|    MP_TARRAY_REMOVE_AT(f->ppins, count, index);
  ------------------
  |  |  143|   605k|    do {                                            \
  |  |  144|   605k|        size_t at_ = (at);                          \
  |  |  145|   605k|        assert(at_ < (idxvar));                     \
  |  |  146|   605k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   605k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   605k|        (idxvar)--;                                 \
  |  |  149|   605k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 605k]
  |  |  ------------------
  ------------------
  |  Branch (673:5): [True: 605k, False: 0]
  ------------------
  674|   605k|    f->num_pins -= 1;
  675|   605k|}
mp_filter_command:
  678|  3.66M|{
  679|  3.66M|    return f->in->info->command ? f->in->info->command(f, cmd) : false;
  ------------------
  |  Branch (679:12): [True: 1.90M, False: 1.76M]
  ------------------
  680|  3.66M|}
mp_filter_find_stream_info:
  683|  10.5k|{
  684|  39.4k|    while (f) {
  ------------------
  |  Branch (684:12): [True: 39.4k, False: 0]
  ------------------
  685|  39.4k|        if (f->stream_info)
  ------------------
  |  Branch (685:13): [True: 10.5k, False: 28.8k]
  ------------------
  686|  10.5k|            return f->stream_info;
  687|  28.8k|        f = f->in->parent;
  688|  28.8k|    }
  689|      0|    return NULL;
  690|  10.5k|}
mp_filter_wakeup:
  726|  1.73M|{
  727|       |    filter_wakeup(f, false);
  728|  1.73M|}
mp_filter_graph_set_max_run_time:
  736|   133k|{
  737|   133k|    struct filter_runner *r = f->in->runner;
  738|   133k|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 133k, False: 0]
  ------------------
  739|   133k|    r->max_run_time = seconds;
  740|   133k|}
mp_filter_graph_interrupt:
  743|     71|{
  744|     71|    struct filter_runner *r = f->in->runner;
  745|     71|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|     71|#define mp_assert assert
  ------------------
  |  Branch (745:5): [True: 71, False: 0]
  ------------------
  746|     71|    atomic_store(&r->interrupt_flag, true);
  747|     71|}
mp_filter_free_children:
  750|   620k|{
  751|   891k|    while(f->in->num_children)
  ------------------
  |  Branch (751:11): [True: 271k, False: 620k]
  ------------------
  752|   271k|        talloc_free(f->in->children[0]);
  ------------------
  |  |   47|   271k|#define talloc_free                     ta_free
  ------------------
  753|   620k|}
mp_filter_create_with_params:
  800|   491k|{
  801|   491k|    struct mp_filter *f = talloc(NULL, struct mp_filter);
  ------------------
  |  |   26|   491k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   491k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   491k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|   491k|    talloc_set_destructor(f, filter_destructor);
  ------------------
  |  |   41|   491k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  803|   491k|    *f = (struct mp_filter){
  804|   491k|        .priv = params->info->priv_size ?
  ------------------
  |  Branch (804:17): [True: 271k, False: 219k]
  ------------------
  805|   491k|                    talloc_zero_size(f, params->info->priv_size) : NULL,
  ------------------
  |  |   44|   271k|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|   271k|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   271k|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   271k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   271k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   271k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|   491k|        .global = params->global,
  807|   491k|        .packet_pool = demux_packet_pool_get(params->parent ? params->parent->global : params->global),
  ------------------
  |  Branch (807:46): [True: 349k, False: 141k]
  ------------------
  808|   491k|        .in = talloc(f, struct mp_filter_internal),
  ------------------
  |  |   26|   491k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   491k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   491k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|   491k|    };
  810|   491k|    *f->in = (struct mp_filter_internal){
  811|   491k|        .info = params->info,
  812|   491k|        .parent = params->parent,
  813|   491k|        .runner = params->parent ? params->parent->in->runner : NULL,
  ------------------
  |  Branch (813:19): [True: 349k, False: 141k]
  ------------------
  814|   491k|    };
  815|       |
  816|   491k|    if (!f->in->runner) {
  ------------------
  |  Branch (816:9): [True: 141k, False: 349k]
  ------------------
  817|   141k|        mp_assert(params->global);
  ------------------
  |  |   41|   141k|#define mp_assert assert
  ------------------
  |  Branch (817:9): [True: 141k, False: 0]
  ------------------
  818|       |
  819|   141k|        f->in->runner = talloc(NULL, struct filter_runner);
  ------------------
  |  |   26|   141k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   141k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   141k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|   141k|        *f->in->runner = (struct filter_runner){
  821|   141k|            .global = params->global,
  822|   141k|            .root_filter = f,
  823|   141k|            .max_run_time = INFINITY,
  824|   141k|        };
  825|   141k|        mp_mutex_init(&f->in->runner->async_lock);
  826|   141k|    }
  827|       |
  828|   491k|    if (!f->global)
  ------------------
  |  Branch (828:9): [True: 349k, False: 141k]
  ------------------
  829|   349k|        f->global = f->in->runner->global;
  830|       |
  831|   491k|    if (f->in->parent) {
  ------------------
  |  Branch (831:9): [True: 349k, False: 141k]
  ------------------
  832|   349k|        struct mp_filter_internal *parent = f->in->parent->in;
  833|   349k|        MP_TARRAY_APPEND(parent, parent->children, parent->num_children, f);
  ------------------
  |  |  105|   349k|    do {                                            \
  |  |  106|   349k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   349k|    do {                                            \
  |  |  |  |   97|   349k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   349k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   349k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   349k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 249k, False: 100k]
  |  |  |  |  ------------------
  |  |  |  |   99|   349k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   249k|    do {                                                        \
  |  |  |  |  |  |   89|   249k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   249k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   249k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   249k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   249k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   249k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   249k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 249k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   349k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 349k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   349k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   349k|        (idxvar)++;                                 \
  |  |  109|   349k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 349k]
  |  |  ------------------
  ------------------
  834|   349k|        f->log = mp_log_new(f, f->global->log, params->info->name);
  835|   349k|    } else {
  836|   141k|        f->log = mp_log_new(f, f->global->log, "!root");
  837|   141k|    }
  838|       |
  839|   491k|    if (f->in->info->init) {
  ------------------
  |  Branch (839:9): [True: 0, False: 491k]
  ------------------
  840|      0|        if (!f->in->info->init(f, params)) {
  ------------------
  |  Branch (840:13): [True: 0, False: 0]
  ------------------
  841|      0|            talloc_free(f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  842|      0|            return NULL;
  843|      0|        }
  844|      0|    }
  845|       |
  846|   491k|    return f;
  847|   491k|}
mp_filter_create:
  851|   349k|{
  852|   349k|    mp_assert(parent);
  ------------------
  |  |   41|   349k|#define mp_assert assert
  ------------------
  |  Branch (852:5): [True: 349k, False: 0]
  ------------------
  853|   349k|    mp_assert(info);
  ------------------
  |  |   41|   349k|#define mp_assert assert
  ------------------
  |  Branch (853:5): [True: 349k, False: 0]
  ------------------
  854|   349k|    struct mp_filter_params params = {
  855|   349k|        .info = info,
  856|   349k|        .parent = parent,
  857|   349k|    };
  858|   349k|    return mp_filter_create_with_params(&params);
  859|   349k|}
mp_filter_create_root:
  868|   141k|{
  869|   141k|    struct mp_filter_params params = {
  870|   141k|        .info = &filter_root,
  871|   141k|        .global = global,
  872|   141k|    };
  873|   141k|    return mp_filter_create_with_params(&params);
  874|   141k|}
mp_filter_graph_set_wakeup_cb:
  878|   141k|{
  879|   141k|    struct filter_runner *r = root->in->runner;
  880|   141k|    mp_assert(root == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|   141k|#define mp_assert assert
  ------------------
  |  Branch (880:5): [True: 141k, False: 0]
  ------------------
  881|   141k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|   141k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  882|   141k|    r->wakeup_cb = wakeup_cb;
  883|   141k|    r->wakeup_ctx = ctx;
  884|   141k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|   141k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  885|   141k|}
filter.c:add_pending:
  131|  35.8M|{
  132|  35.8M|    struct filter_runner *r = f->in->runner;
  133|       |
  134|  35.8M|    if (f->in->pending)
  ------------------
  |  Branch (134:9): [True: 1.26M, False: 34.5M]
  ------------------
  135|  1.26M|        return;
  136|       |
  137|       |    // This should probably really be some sort of priority queue, but for now
  138|       |    // something naive and dumb does the job too.
  139|  34.5M|    f->in->pending = true;
  140|  34.5M|    if (f->in->high_priority) {
  ------------------
  |  Branch (140:9): [True: 822k, False: 33.7M]
  ------------------
  141|   822k|        MP_TARRAY_INSERT_AT(r, r->pending, r->num_pending, 0, f);
  ------------------
  |  |  115|   822k|    do {                                            \
  |  |  116|   822k|        size_t at_ = (at);                          \
  |  |  117|   822k|        assert(at_ <= (idxvar));                    \
  |  |  118|   822k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   822k|    do {                                            \
  |  |  |  |   97|   822k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   822k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   822k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   822k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 822k]
  |  |  |  |  ------------------
  |  |  |  |   99|   822k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   822k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 822k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   822k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   822k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   822k|        (idxvar)++;                                 \
  |  |  122|   822k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   822k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 822k]
  |  |  ------------------
  ------------------
  |  Branch (141:9): [True: 822k, False: 0]
  ------------------
  142|  33.7M|    } else {
  143|  33.7M|        MP_TARRAY_APPEND(r, r->pending, r->num_pending, f);
  ------------------
  |  |  105|  33.7M|    do {                                            \
  |  |  106|  33.7M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  33.7M|    do {                                            \
  |  |  |  |   97|  33.7M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  33.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  33.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  33.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 86.6k, False: 33.6M]
  |  |  |  |  ------------------
  |  |  |  |   99|  33.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  86.6k|    do {                                                        \
  |  |  |  |  |  |   89|  86.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  86.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  86.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  86.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  86.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  86.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  86.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 86.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  33.7M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 33.7M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  33.7M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  33.7M|        (idxvar)++;                                 \
  |  |  109|  33.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 33.7M]
  |  |  ------------------
  ------------------
  144|  33.7M|    }
  145|  34.5M|}
filter.c:flush_async_notifications:
  199|  5.18M|{
  200|  5.18M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  5.18M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  201|  6.02M|    for (int n = 0; n < r->num_async_pending; n++) {
  ------------------
  |  Branch (201:21): [True: 833k, False: 5.18M]
  ------------------
  202|   833k|        struct mp_filter *f = r->async_pending[n];
  203|   833k|        add_pending(f);
  204|   833k|        f->in->async_pending = false;
  205|   833k|    }
  206|  5.18M|    r->num_async_pending = 0;
  207|  5.18M|    r->async_wakeup_sent = false;
  208|  5.18M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  5.18M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  209|  5.18M|}
filter.c:add_pending_pin:
  148|  33.6M|{
  149|  33.6M|    struct mp_filter *f = p->manual_connection;
  150|  33.6M|    mp_assert(f);
  ------------------
  |  |   41|  33.6M|#define mp_assert assert
  ------------------
  |  Branch (150:5): [True: 33.6M, False: 18.4E]
  ------------------
  151|       |
  152|  33.6M|    if (f->in->pending)
  ------------------
  |  Branch (152:9): [True: 1.62M, False: 32.0M]
  ------------------
  153|  1.62M|        return;
  154|       |
  155|  32.0M|    add_pending(f);
  156|       |
  157|       |    // Need to tell user that something changed.
  158|  32.0M|    if (f == f->in->runner->root_filter && p != f->in->runner->recursive)
  ------------------
  |  Branch (158:9): [True: 857k, False: 31.1M]
  |  Branch (158:44): [True: 693, False: 856k]
  ------------------
  159|    693|        f->in->runner->external_pending = true;
  160|  32.0M|}
filter.c:filter_recursive:
  169|  44.8M|{
  170|  44.8M|    struct mp_filter *f = p->conn->manual_connection;
  171|  44.8M|    mp_assert(f);
  ------------------
  |  |   41|  44.8M|#define mp_assert assert
  ------------------
  |  Branch (171:5): [True: 44.8M, False: 18.4E]
  ------------------
  172|  44.8M|    struct filter_runner *r = f->in->runner;
  173|       |
  174|       |    // Never do internal filtering recursively.
  175|  44.8M|    if (r->filtering)
  ------------------
  |  Branch (175:9): [True: 42.6M, False: 2.20M]
  ------------------
  176|  42.6M|        return;
  177|       |
  178|  2.20M|    mp_assert(!r->recursive);
  ------------------
  |  |   41|  2.20M|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 2.21M, False: 18.4E]
  ------------------
  179|  2.21M|    r->recursive = p;
  180|       |
  181|       |    // Also don't lose the pending state, which the user may or may not
  182|       |    // care about.
  183|  2.21M|    r->external_pending |= mp_filter_graph_run(r->root_filter);
  184|       |
  185|  2.21M|    mp_assert(r->recursive == p);
  ------------------
  |  |   41|  2.21M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 2.21M, False: 0]
  ------------------
  186|  2.21M|    r->recursive = NULL;
  187|  2.21M|}
filter.c:init_connection:
  385|   787k|{
  386|   787k|    struct filter_runner *runner = p->owner->in->runner;
  387|       |
  388|   787k|    if (p->dir == MP_PIN_IN)
  ------------------
  |  Branch (388:9): [True: 275k, False: 511k]
  ------------------
  389|   275k|        p = p->other;
  390|       |
  391|   787k|    struct mp_pin *in = find_connected_end(p);
  392|   787k|    struct mp_pin *out = find_connected_end(p->other);
  393|       |
  394|       |    // These are the "outer" pins by definition, they have no user connections.
  395|   787k|    mp_assert(!in->user_conn);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (395:5): [True: 787k, False: 0]
  ------------------
  396|   787k|    mp_assert(!out->user_conn);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 787k, False: 0]
  ------------------
  397|       |
  398|       |    // This and similar checks enforce the same root filter requirement.
  399|   787k|    if (in->manual_connection)
  ------------------
  |  Branch (399:9): [True: 787k, False: 0]
  ------------------
  400|   787k|        mp_assert(in->manual_connection->in->runner == runner);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (400:9): [True: 787k, False: 0]
  ------------------
  401|   787k|    if (out->manual_connection)
  ------------------
  |  Branch (401:9): [True: 787k, False: 0]
  ------------------
  402|   787k|        mp_assert(out->manual_connection->in->runner == runner);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (402:9): [True: 787k, False: 0]
  ------------------
  403|       |
  404|       |    // Logically, the ends are always manual connections. A pin chain without
  405|       |    // manual connections at the ends is still disconnected (or if this
  406|       |    // attempted to extend an existing connection, becomes dangling and gets
  407|       |    // disconnected).
  408|   787k|    if (!in->manual_connection || !out->manual_connection)
  ------------------
  |  Branch (408:9): [True: 0, False: 787k]
  |  Branch (408:35): [True: 0, False: 787k]
  ------------------
  409|      0|        return;
  410|       |
  411|   787k|    mp_assert(in->dir == MP_PIN_IN);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (411:5): [True: 787k, False: 0]
  ------------------
  412|   787k|    mp_assert(out->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 787k, False: 0]
  ------------------
  413|       |
  414|   787k|    struct mp_pin *cur = in;
  415|  1.77M|    while (cur) {
  ------------------
  |  Branch (415:12): [True: 989k, False: 787k]
  ------------------
  416|   989k|        mp_assert(!cur->within_conn && !cur->other->within_conn);
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (416:9): [True: 989k, False: 0]
  |  Branch (416:9): [True: 989k, False: 0]
  ------------------
  417|   989k|        mp_assert(!cur->conn && !cur->other->conn);
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (417:9): [True: 989k, False: 0]
  |  Branch (417:9): [True: 989k, False: 0]
  ------------------
  418|   989k|        mp_assert(!cur->data_requested); // unused for in pins
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (418:9): [True: 989k, False: 0]
  ------------------
  419|   989k|        mp_assert(!cur->data.type); // unused for in pins
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (419:9): [True: 989k, False: 0]
  ------------------
  420|   989k|        mp_assert(!cur->other->data_requested); // unset for unconnected out pins
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (420:9): [True: 989k, False: 0]
  ------------------
  421|   989k|        mp_assert(!cur->other->data.type); // unset for unconnected out pins
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (421:9): [True: 989k, False: 0]
  ------------------
  422|   989k|        mp_assert(cur->owner->in->runner == runner);
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (422:9): [True: 989k, False: 0]
  ------------------
  423|   989k|        cur->within_conn = cur->other->within_conn = true;
  424|   989k|        cur = cur->other->user_conn;
  425|   989k|    }
  426|       |
  427|   787k|    in->conn = out;
  428|   787k|    in->within_conn = false;
  429|   787k|    out->conn = in;
  430|   787k|    out->within_conn = false;
  431|       |
  432|       |    // Scheduling so far will be messed up.
  433|   787k|    add_pending(in->manual_connection);
  434|   787k|    add_pending(out->manual_connection);
  435|   787k|}
filter.c:find_connected_end:
  372|  3.15M|{
  373|  3.51M|    while (1) {
  ------------------
  |  Branch (373:12): [True: 3.51M, Folded]
  ------------------
  374|  3.51M|        struct mp_pin *other = p->other;
  375|  3.51M|        if (!other->user_conn)
  ------------------
  |  Branch (375:13): [True: 3.15M, False: 359k]
  ------------------
  376|  3.15M|            return other;
  377|   359k|        p = other->user_conn;
  378|   359k|    }
  379|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (379:5): [Folded, False: 0]
  ------------------
  380|      0|}
filter.c:deinit_connection:
  477|  1.57M|{
  478|  1.57M|    if (p->dir == MP_PIN_OUT)
  ------------------
  |  Branch (478:9): [True: 787k, False: 787k]
  ------------------
  479|   787k|        p = p->other;
  480|       |
  481|  1.57M|    p = find_connected_end(p);
  482|       |
  483|  3.32M|    while (p) {
  ------------------
  |  Branch (483:12): [True: 1.75M, False: 1.57M]
  ------------------
  484|  1.75M|        p->conn = p->other->conn = NULL;
  485|  1.75M|        p->within_conn = p->other->within_conn = false;
  486|  1.75M|        mp_assert(!p->other->data_requested); // unused for in pins
  ------------------
  |  |   41|  1.75M|#define mp_assert assert
  ------------------
  |  Branch (486:9): [True: 1.75M, False: 0]
  ------------------
  487|  1.75M|        mp_assert(!p->other->data.type); // unused for in pins
  ------------------
  |  |   41|  1.75M|#define mp_assert assert
  ------------------
  |  Branch (487:9): [True: 1.75M, False: 0]
  ------------------
  488|  1.75M|        if (p->data.type)
  ------------------
  |  Branch (488:13): [True: 0, False: 1.75M]
  ------------------
  489|  1.75M|            MP_VERBOSE(p->owner, "dropping frame due to pin disconnect\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  1.75M|        if (p->data_requested)
  ------------------
  |  Branch (490:13): [True: 12.0k, False: 1.74M]
  ------------------
  491|  1.75M|            MP_VERBOSE(p->owner, "dropping request due to pin disconnect\n");
  ------------------
  |  |   92|  12.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  492|       |        p->data_requested = false;
  493|  1.75M|        mp_frame_unref(&p->data);
  494|  1.75M|        p = p->other->user_conn;
  495|  1.75M|    }
  496|  1.57M|}
filter.c:reset_pin:
  585|  8.58k|{
  586|  8.58k|    if (!p->conn || p->dir != MP_PIN_OUT) {
  ------------------
  |  Branch (586:9): [True: 0, False: 8.58k]
  |  Branch (586:21): [True: 4.29k, False: 4.29k]
  ------------------
  587|  4.29k|        mp_assert(!p->data.type);
  ------------------
  |  |   41|  4.29k|#define mp_assert assert
  ------------------
  |  Branch (587:9): [True: 4.29k, False: 0]
  ------------------
  588|  4.29k|        mp_assert(!p->data_requested);
  ------------------
  |  |   41|  4.29k|#define mp_assert assert
  ------------------
  |  Branch (588:9): [True: 4.29k, False: 0]
  ------------------
  589|  4.29k|    }
  590|  8.58k|    mp_frame_unref(&p->data);
  591|       |    p->data_requested = false;
  592|  8.58k|}
filter.c:filter_wakeup:
  709|  1.73M|{
  710|  1.73M|    struct filter_runner *r = f->in->runner;
  711|  1.73M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  1.73M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  712|  1.73M|    if (!f->in->async_pending) {
  ------------------
  |  Branch (712:9): [True: 833k, False: 898k]
  ------------------
  713|   833k|        f->in->async_pending = true;
  714|       |        // (not using a talloc parent for thread safety reasons)
  715|   833k|        MP_TARRAY_APPEND(NULL, r->async_pending, r->num_async_pending, f);
  ------------------
  |  |  105|   833k|    do {                                            \
  |  |  106|   833k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   833k|    do {                                            \
  |  |  |  |   97|   833k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   833k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   833k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   833k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 25.0k, False: 808k]
  |  |  |  |  ------------------
  |  |  |  |   99|   833k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  25.0k|    do {                                                        \
  |  |  |  |  |  |   89|  25.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  25.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  25.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  25.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  25.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  25.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  25.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 25.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   833k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 833k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   833k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   833k|        (idxvar)++;                                 \
  |  |  109|   833k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 833k]
  |  |  ------------------
  ------------------
  716|   833k|    }
  717|  1.73M|    if (!mark_only && !r->async_wakeup_sent) {
  ------------------
  |  Branch (717:9): [True: 1.73M, False: 0]
  |  Branch (717:23): [True: 805k, False: 927k]
  ------------------
  718|   805k|        if (r->wakeup_cb)
  ------------------
  |  Branch (718:13): [True: 797k, False: 7.92k]
  ------------------
  719|   797k|            r->wakeup_cb(r->wakeup_ctx);
  720|   805k|        r->async_wakeup_sent = true;
  721|   805k|    }
  722|  1.73M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  1.73M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  723|  1.73M|}
filter.c:filter_destructor:
  756|   491k|{
  757|   491k|    struct mp_filter *f = p;
  758|   491k|    struct filter_runner *r = f->in->runner;
  759|       |
  760|   491k|    if (f->in->info->destroy)
  ------------------
  |  Branch (760:9): [True: 293k, False: 197k]
  ------------------
  761|   293k|        f->in->info->destroy(f);
  762|       |
  763|       |    // For convenience, free child filters.
  764|   491k|    mp_filter_free_children(f);
  765|       |
  766|  1.09M|    while (f->num_pins)
  ------------------
  |  Branch (766:12): [True: 605k, False: 491k]
  ------------------
  767|   605k|        mp_filter_remove_pin(f, f->ppins[0]);
  768|       |
  769|       |    // Just make sure the filter is not still in the async notifications set.
  770|       |    // There will be no more new notifications at this point (due to destroy()).
  771|   491k|    flush_async_notifications(r);
  772|       |
  773|   750k|    for (int n = 0; n < r->num_pending; n++) {
  ------------------
  |  Branch (773:21): [True: 309k, False: 440k]
  ------------------
  774|   309k|        if (r->pending[n] == f) {
  ------------------
  |  Branch (774:13): [True: 50.8k, False: 259k]
  ------------------
  775|  50.8k|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, n);
  ------------------
  |  |  143|  50.8k|    do {                                            \
  |  |  144|  50.8k|        size_t at_ = (at);                          \
  |  |  145|  50.8k|        assert(at_ < (idxvar));                     \
  |  |  146|  50.8k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  50.8k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  50.8k|        (idxvar)--;                                 \
  |  |  149|  50.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 50.8k]
  |  |  ------------------
  ------------------
  |  Branch (775:13): [True: 50.8k, False: 0]
  ------------------
  776|  50.8k|            break;
  777|  50.8k|        }
  778|   309k|    }
  779|       |
  780|   491k|    if (f->in->parent) {
  ------------------
  |  Branch (780:9): [True: 349k, False: 141k]
  ------------------
  781|   349k|        struct mp_filter_internal *p_in = f->in->parent->in;
  782|   460k|        for (int n = 0; n < p_in->num_children; n++) {
  ------------------
  |  Branch (782:25): [True: 460k, False: 0]
  ------------------
  783|   460k|            if (p_in->children[n] == f) {
  ------------------
  |  Branch (783:17): [True: 349k, False: 110k]
  ------------------
  784|   349k|                MP_TARRAY_REMOVE_AT(p_in->children, p_in->num_children, n);
  ------------------
  |  |  143|   349k|    do {                                            \
  |  |  144|   349k|        size_t at_ = (at);                          \
  |  |  145|   349k|        assert(at_ < (idxvar));                     \
  |  |  146|   349k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   349k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   349k|        (idxvar)--;                                 \
  |  |  149|   349k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 349k]
  |  |  ------------------
  ------------------
  |  Branch (784:17): [True: 349k, False: 0]
  ------------------
  785|   349k|                break;
  786|   349k|            }
  787|   460k|        }
  788|   349k|    }
  789|       |
  790|   491k|    if (r->root_filter == f) {
  ------------------
  |  Branch (790:9): [True: 141k, False: 349k]
  ------------------
  791|   141k|        mp_assert(!f->in->parent);
  ------------------
  |  |   41|   141k|#define mp_assert assert
  ------------------
  |  Branch (791:9): [True: 141k, False: 0]
  ------------------
  792|   141k|        mp_mutex_destroy(&r->async_lock);
  ------------------
  |  |  133|   141k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  793|   141k|        talloc_free(r->async_pending);
  ------------------
  |  |   47|   141k|#define talloc_free                     ta_free
  ------------------
  794|   141k|        talloc_free(r);
  ------------------
  |  |   47|   141k|#define talloc_free                     ta_free
  ------------------
  795|   141k|    }
  796|   491k|}

mp_frame_is_signaling:
  137|  1.76M|{
  138|  1.76M|    return frame_handlers[frame.type].is_signaling;
  139|  1.76M|}
mp_frame_unref:
  142|  1.91M|{
  143|  1.91M|    if (!frame)
  ------------------
  |  Branch (143:9): [True: 0, False: 1.91M]
  ------------------
  144|      0|        return;
  145|       |
  146|  1.91M|    if (frame_handlers[frame->type].free)
  ------------------
  |  Branch (146:9): [True: 641, False: 1.91M]
  ------------------
  147|    641|        frame_handlers[frame->type].free(frame->data);
  148|       |
  149|  1.91M|    *frame = (struct mp_frame){0};
  150|  1.91M|}
mp_frame_get_pts:
  164|  7.15M|{
  165|  7.15M|    if (frame_handlers[frame.type].get_pts)
  ------------------
  |  Branch (165:9): [True: 6.97M, False: 184k]
  ------------------
  166|  6.97M|        return frame_handlers[frame.type].get_pts(frame.data);
  167|   184k|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|   184k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  7.15M|}
mp_frame_approx_size:
  177|  1.61M|{
  178|  1.61M|    if (frame_handlers[frame.type].approx_size)
  ------------------
  |  Branch (178:9): [True: 1.60M, False: 11.9k]
  ------------------
  179|  1.60M|        return frame_handlers[frame.type].approx_size(frame.data);
  180|  11.9k|    return 0;
  181|  1.61M|}
frame.c:video_get_pts:
   29|   568k|{
   30|   568k|    return ((struct mp_image *)data)->pts;
   31|   568k|}
frame.c:audio_get_pts:
   59|  6.40M|{
   60|  6.40M|    return mp_aframe_get_pts(data);
   61|  6.40M|}
frame.c:audio_approx_size:
   69|  1.60M|{
   70|  1.60M|    return mp_aframe_approx_byte_size(data);
   71|  1.60M|}

user_filters.c:get_af_desc:
   48|   260k|{
   49|   260k|    return get_desc_from(af_list, MP_ARRAY_SIZE(af_list), dst, index);
  ------------------
  |  |   49|   260k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
   50|   260k|}
user_filters.c:get_desc_from:
   14|   405k|{
   15|   405k|    if (index >= num)
  ------------------
  |  Branch (15:9): [True: 57.9k, False: 347k]
  ------------------
   16|  57.9k|        return false;
   17|   347k|    const struct mp_user_filter_entry *entry = list[index];
   18|   347k|    *dst = entry->desc;
   19|   347k|    dst->p = entry;
   20|       |    return true;
   21|   405k|}
user_filters.c:get_vf_desc:
  113|   144k|{
  114|   144k|    return get_desc_from(vf_list, MP_ARRAY_SIZE(vf_list), dst, index);
  ------------------
  |  |   49|   144k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  115|   144k|}

fuzzer_loadfile_direct.c:str_startswith:
   47|  28.9k|{
   48|  28.9k|    if (str_len < prefix_len)
  ------------------
  |  Branch (48:9): [True: 3, False: 28.9k]
  ------------------
   49|      3|        return false;
   50|  28.9k|    return !memcmp(str, prefix, prefix_len);
   51|  28.9k|}
fuzzer_loadfile_direct.c:set_fontconfig_sysroot:
   54|  28.9k|{
   55|  28.9k|#ifdef MPV_FONTCONFIG_SYSROOT
   56|  28.9k|    const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT);
  ------------------
  |  |   35|  28.9k|#define MPV_STRINGIFY(X) MPV_STRINGIFY_(X)
  |  |  ------------------
  |  |  |  |   34|  28.9k|#define MPV_STRINGIFY_(X) #X
  |  |  ------------------
  ------------------
   57|  28.9k|    char path[PATH_MAX];
   58|  28.9k|    if (sysroot[0] != '/') {
  ------------------
  |  Branch (58:9): [True: 28.9k, False: 0]
  ------------------
   59|  28.9k|        ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);
   60|  28.9k|        if (len < 0)
  ------------------
  |  Branch (60:13): [True: 0, False: 28.9k]
  ------------------
   61|      0|            exit(1);
   62|  28.9k|        path[len] = '\0';
   63|  28.9k|        char *name = strrchr(path, '/') + 1;
   64|  28.9k|        snprintf(name, path + sizeof(path) - name, "%s", sysroot);
   65|  28.9k|        sysroot = path;
   66|  28.9k|    }
   67|  28.9k|    setenv("FONTCONFIG_SYSROOT", sysroot, 1);
   68|  28.9k|#endif
   69|  28.9k|}
fuzzer_loadfile_direct.c:check_error:
   38|   318k|{
   39|   318k|    if (status < 0) {
  ------------------
  |  Branch (39:9): [True: 0, False: 318k]
  ------------------
   40|       |        fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status));
   41|      0|        exit(1);
   42|      0|    }
   43|   318k|}
fuzzer_loadfile_direct.c:initialize:
  100|  28.9k|{
  101|  28.9k|    check_error(mpv_initialize(ctx));
  102|  28.9k|    if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx))
  ------------------
  |  Branch (102:9): [True: 0, False: 28.9k]
  |  Branch (102:45): [True: 0, False: 28.9k]
  ------------------
  103|      0|        exit(1);
  104|  28.9k|}
fuzzer_loadfile_direct.c:wait_event:
   72|  28.9k|{
   73|  28.9k|    while (1) {
  ------------------
  |  Branch (73:12): [True: 28.9k, Folded]
  ------------------
   74|  28.9k|        mpv_event *event = mpv_wait_event(ctx, -1);
   75|  28.9k|        if (event->event_id == id)
  ------------------
  |  Branch (75:13): [True: 28.9k, False: 0]
  ------------------
   76|  28.9k|            return true;
   77|      0|        if (event->event_id == MPV_EVENT_SHUTDOWN)
  ------------------
  |  Branch (77:13): [True: 0, False: 0]
  ------------------
   78|      0|            return false;
   79|      0|    }
   80|  28.9k|}
fuzzer_loadfile_direct.c:sync_core:
   84|  57.9k|{
   85|  57.9k|    uint64_t sync_id = 1;
   86|  57.9k|    mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE);
   87|  57.9k|    bool ok;
   88|  58.0k|    while (1) {
  ------------------
  |  Branch (88:12): [True: 58.0k, Folded]
  ------------------
   89|  58.0k|        mpv_event *event = mpv_wait_event(ctx, -1);
   90|  58.0k|        ok = event->event_id != MPV_EVENT_SHUTDOWN;
   91|  58.0k|        if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE &&
  ------------------
  |  Branch (91:13): [True: 28.8k, False: 29.2k]
  |  Branch (91:21): [True: 29.0k, False: 178]
  ------------------
   92|  29.0k|                    event->reply_userdata == sync_id))
  ------------------
  |  Branch (92:21): [True: 29.0k, False: 0]
  ------------------
   93|  57.9k|            break;
   94|  58.0k|    }
   95|  57.9k|    mpv_unobserve_property(ctx, sync_id);
   96|  57.9k|    return ok;
   97|  57.9k|}
fuzzer_loadfile_direct.c:player_loop:
  122|  28.9k|{
  123|  28.9k|    bool playing = false;
  124|  28.9k|    bool loaded = false;
  125|  28.9k|    int timeout = -1;
  126|  28.9k|    int events_limit_after_restart = EVENTS_LIMIT;
  ------------------
  |  |  118|  28.9k|#define EVENTS_LIMIT 10
  ------------------
  127|   404k|    while (1) {
  ------------------
  |  Branch (127:12): [True: 404k, Folded]
  ------------------
  128|   404k|        mpv_event *event = mpv_wait_event(ctx, timeout);
  129|       |        // If some events are spamming, like audio-reconfig preventing our
  130|       |        // timeout to trigger stop after N events.
  131|   404k|        if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0)
  ------------------
  |  |  114|   808k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  |  Branch (131:13): [True: 42.2k, False: 362k]
  |  Branch (131:47): [True: 160, False: 42.0k]
  ------------------
  132|    160|            break;
  133|   404k|        if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE)
  ------------------
  |  |  114|   808k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  |  Branch (133:13): [True: 42.0k, False: 362k]
  |  Branch (133:47): [True: 1, False: 42.0k]
  ------------------
  134|      1|            break;
  135|   404k|        if (event->event_id == MPV_EVENT_START_FILE)
  ------------------
  |  Branch (135:13): [True: 133k, False: 270k]
  ------------------
  136|   133k|            loaded = playing = true;
  137|   404k|        if (event->event_id == MPV_EVENT_END_FILE) {
  ------------------
  |  Branch (137:13): [True: 133k, False: 270k]
  ------------------
  138|   133k|            playing = false;
  139|   133k|            events_limit_after_restart = EVENTS_LIMIT;
  ------------------
  |  |  118|   133k|#define EVENTS_LIMIT 10
  ------------------
  140|   133k|            timeout = -1;
  141|   133k|        }
  142|   404k|        if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART)
  ------------------
  |  Branch (142:13): [True: 228k, False: 175k]
  |  Branch (142:24): [True: 16.7k, False: 211k]
  ------------------
  143|  16.7k|            timeout = PLAYBACK_TIME_LIMIT;
  ------------------
  |  |  114|  16.7k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  144|   404k|        if (loaded && event->event_id == MPV_EVENT_IDLE)
  ------------------
  |  Branch (144:13): [True: 404k, False: 0]
  |  Branch (144:23): [True: 28.7k, False: 375k]
  ------------------
  145|  28.7k|            break;
  146|   404k|    }
  147|  28.9k|}
fuzzer_loadfile_direct.c:destroy:
  107|  28.9k|{
  108|  28.9k|    if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED)
  ------------------
  |  Branch (108:9): [True: 28.9k, False: 0]
  ------------------
  109|  28.9k|        sync_core(ctx);
  110|  28.9k|    mpv_terminate_destroy(ctx);
  111|  28.9k|}

LLVMFuzzerTestOneInput:
   26|  28.9k|{
   27|  28.9k|    if (size > MAX_FUZZ_SIZE)
  ------------------
  |  |   30|  28.9k|#define MAX_FUZZ_SIZE (100 << 10) // 100 KiB
  ------------------
  |  Branch (27:9): [True: 1, False: 28.9k]
  ------------------
   28|      1|        return 0;
   29|       |
   30|  28.9k|    if (size <= 1 || data[size - 1] != '\0')
  ------------------
  |  Branch (30:9): [True: 1, False: 28.9k]
  |  Branch (30:22): [True: 7, False: 28.9k]
  ------------------
   31|      8|        return 0;
   32|       |
   33|       |    // Exclude data with null bytes inside
   34|  28.9k|    if (strlen(data) != size - 1)
  ------------------
  |  Branch (34:9): [True: 3, False: 28.9k]
  ------------------
   35|      3|        return 0;
   36|       |
   37|  28.9k|#ifdef MPV_PROTO
   38|  28.9k|    if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
  ------------------
  |  |   35|  28.9k|#define MPV_STRINGIFY(X) MPV_STRINGIFY_(X)
  |  |  ------------------
  |  |  |  |   34|  28.9k|#define MPV_STRINGIFY_(X) #X
  |  |  ------------------
  ------------------
                  if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
  ------------------
  |  |   35|  28.9k|#define MPV_STRINGIFY(X) MPV_STRINGIFY_(X)
  |  |  ------------------
  |  |  |  |   34|  28.9k|#define MPV_STRINGIFY_(X) #X
  |  |  ------------------
  ------------------
  |  Branch (38:9): [True: 13, False: 28.9k]
  ------------------
   39|     13|        return 0;
   40|  28.9k|#endif
   41|       |
   42|  28.9k|    set_fontconfig_sysroot();
   43|       |
   44|  28.9k|    mpv_handle *ctx = mpv_create();
   45|  28.9k|    if (!ctx)
  ------------------
  |  Branch (45:9): [True: 0, False: 28.9k]
  ------------------
   46|      0|        exit(1);
   47|       |
   48|  28.9k|    check_error(mpv_set_option_string(ctx, "vo", "null"));
   49|  28.9k|    check_error(mpv_set_option_string(ctx, "ao", "null"));
   50|  28.9k|    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
   51|  28.9k|    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
   52|  28.9k|    check_error(mpv_set_option_string(ctx, "image-display-duration", "0"));
   53|  28.9k|    check_error(mpv_set_option_string(ctx, "video-osd", "no"));
   54|  28.9k|    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
   55|  28.9k|    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
   56|  28.9k|    check_error(mpv_set_option_string(ctx, "input-builtin-bindings", "no"));
   57|       |
   58|  28.9k|    initialize(ctx);
   59|       |
   60|  28.9k|    const char *cmd[] = {"loadfile", data, NULL};
   61|  28.9k|    check_error(mpv_command(ctx, cmd));
   62|       |
   63|  28.9k|    player_loop(ctx);
   64|       |
   65|  28.9k|    destroy(ctx);
   66|       |
   67|  28.9k|    return 0;
   68|  28.9k|}

mp_input_parse_cmd_node:
  293|  86.8k|{
  294|  86.8k|    struct mp_cmd *cmd = talloc_ptrtype(NULL, cmd);
  ------------------
  |  |   34|  86.8k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  86.8k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  86.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  86.8k|    talloc_set_destructor(cmd, destroy_cmd);
  ------------------
  |  |   41|  86.8k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  296|  86.8k|    *cmd = (struct mp_cmd) { .scale = 1, .scale_units = 1 };
  297|       |
  298|  86.8k|    bool res = false;
  299|  86.8k|    if (node->format == MPV_FORMAT_NODE_ARRAY) {
  ------------------
  |  Branch (299:9): [True: 86.8k, False: 0]
  ------------------
  300|  86.8k|        res = cmd_node_array(log, cmd, node);
  301|  86.8k|    } else if (node->format == MPV_FORMAT_NODE_MAP) {
  ------------------
  |  Branch (301:16): [True: 0, False: 0]
  ------------------
  302|      0|        res = cmd_node_map(log, cmd, node);
  303|      0|    }
  304|       |
  305|  86.8k|    res = res && finish_cmd(log, cmd);
  ------------------
  |  Branch (305:11): [True: 86.8k, False: 0]
  |  Branch (305:18): [True: 86.8k, False: 0]
  ------------------
  306|       |
  307|  86.8k|    if (!res)
  ------------------
  |  Branch (307:9): [True: 0, False: 86.8k]
  ------------------
  308|      0|        TA_FREEP(&cmd);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  309|       |
  310|  86.8k|    return cmd;
  311|  86.8k|}
mp_input_parse_cmd_strv:
  513|  86.8k|{
  514|  86.8k|    int count = 0;
  515|   202k|    while (argv[count])
  ------------------
  |  Branch (515:12): [True: 115k, False: 86.8k]
  ------------------
  516|   115k|        count++;
  517|  86.8k|    mpv_node *items = talloc_zero_array(NULL, mpv_node, count);
  ------------------
  |  |   30|  86.8k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  86.8k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  86.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|  86.8k|    mpv_node_list list = {.values = items, .num = count};
  519|  86.8k|    mpv_node node = {.format = MPV_FORMAT_NODE_ARRAY, .u = {.list = &list}};
  520|   202k|    for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (520:21): [True: 115k, False: 86.8k]
  ------------------
  521|   115k|        items[n] = (mpv_node){.format = MPV_FORMAT_STRING,
  522|   115k|                              .u = {.string = (char *)argv[n]}};
  523|   115k|    }
  524|  86.8k|    struct mp_cmd *res = mp_input_parse_cmd_node(log, &node);
  525|  86.8k|    talloc_free(items);
  ------------------
  |  |   47|  86.8k|#define talloc_free                     ta_free
  ------------------
  526|  86.8k|    return res;
  527|  86.8k|}
mp_cmd_dump:
  582|  86.8k|{
  583|  86.8k|    if (!mp_msg_test(log, msgl))
  ------------------
  |  Branch (583:9): [True: 0, False: 86.8k]
  ------------------
  584|      0|        return;
  585|  86.8k|    if (header)
  ------------------
  |  Branch (585:9): [True: 86.8k, False: 0]
  ------------------
  586|  86.8k|        mp_msg(log, msgl, "%s ", header);
  587|  86.8k|    if (!cmd) {
  ------------------
  |  Branch (587:9): [True: 0, False: 86.8k]
  ------------------
  588|      0|        mp_msg(log, msgl, "(NULL)\n");
  589|      0|        return;
  590|      0|    }
  591|  86.8k|    mp_msg(log, msgl, "%s, flags=%d, args=[", cmd->name, cmd->flags);
  592|  86.8k|    int argc = get_arg_count(cmd->def);
  593|   260k|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (593:21): [True: 173k, False: 86.8k]
  ------------------
  594|   173k|        const char *argname = cmd->def->args[MPMIN(n, argc - 1)].name;
  ------------------
  |  |   45|   173k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 173k]
  |  |  ------------------
  ------------------
  595|   173k|        char *s = m_option_print(cmd->args[n].type, &cmd->args[n].v);
  596|   173k|        if (n)
  ------------------
  |  Branch (596:13): [True: 86.8k, False: 86.8k]
  ------------------
  597|  86.8k|            mp_msg(log, msgl, ", ");
  598|   173k|        struct mpv_node node = {
  599|   173k|            .format = MPV_FORMAT_STRING,
  600|   173k|            .u.string = s ? s : "(NULL)",
  ------------------
  |  Branch (600:25): [True: 173k, False: 0]
  ------------------
  601|   173k|        };
  602|   173k|        char *esc = NULL;
  603|   173k|        json_write(&esc, &node);
  604|   173k|        mp_msg(log, msgl, "%s=%s", argname, esc ? esc : "<error>");
  ------------------
  |  Branch (604:45): [True: 173k, False: 0]
  ------------------
  605|   173k|        talloc_free(esc);
  ------------------
  |  |   47|   173k|#define talloc_free                     ta_free
  ------------------
  606|   173k|        talloc_free(s);
  ------------------
  |  |   47|   173k|#define talloc_free                     ta_free
  ------------------
  607|   173k|    }
  608|  86.8k|    mp_msg(log, msgl, "]\n");
  609|  86.8k|}
cmd.c:destroy_cmd:
   33|  86.8k|{
   34|  86.8k|    struct mp_cmd *cmd = ptr;
   35|   260k|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (35:21): [True: 173k, False: 86.8k]
  ------------------
   36|   173k|        if (cmd->args[n].type)
  ------------------
  |  Branch (36:13): [True: 173k, False: 0]
  ------------------
   37|   173k|            m_option_free(cmd->args[n].type, &cmd->args[n].v);
   38|   173k|    }
   39|  86.8k|}
cmd.c:cmd_node_array:
  200|  86.8k|{
  201|  86.8k|    mp_assert(node->format == MPV_FORMAT_NODE_ARRAY);
  ------------------
  |  |   41|  86.8k|#define mp_assert assert
  ------------------
  |  Branch (201:5): [True: 86.8k, False: 0]
  ------------------
  202|  86.8k|    mpv_node_list *args = node->u.list;
  203|  86.8k|    int cur = 0;
  204|       |
  205|  86.8k|    while (cur < args->num) {
  ------------------
  |  Branch (205:12): [True: 86.8k, False: 0]
  ------------------
  206|  86.8k|        if (args->values[cur].format != MPV_FORMAT_STRING)
  ------------------
  |  Branch (206:13): [True: 0, False: 86.8k]
  ------------------
  207|      0|            break;
  208|  86.8k|        if (!apply_flag(cmd, bstr0(args->values[cur].u.string)))
  ------------------
  |  Branch (208:13): [True: 86.8k, False: 0]
  ------------------
  209|  86.8k|            break;
  210|      0|        cur++;
  211|      0|    }
  212|       |
  213|  86.8k|    bstr cmd_name = {0};
  214|  86.8k|    if (cur < args->num && args->values[cur].format == MPV_FORMAT_STRING)
  ------------------
  |  Branch (214:9): [True: 86.8k, False: 0]
  |  Branch (214:28): [True: 86.8k, False: 0]
  ------------------
  215|  86.8k|        cmd_name = bstr0(args->values[cur++].u.string);
  216|  86.8k|    if (!find_cmd(log, cmd, cmd_name))
  ------------------
  |  Branch (216:9): [True: 0, False: 86.8k]
  ------------------
  217|      0|        return false;
  218|       |
  219|  86.8k|    int first = cur;
  220|   115k|    for (int i = 0; i < args->num - first; i++) {
  ------------------
  |  Branch (220:21): [True: 28.9k, False: 86.8k]
  ------------------
  221|  28.9k|        if (!set_node_arg(log, cmd, cmd->nargs, &args->values[cur++]))
  ------------------
  |  Branch (221:13): [True: 0, False: 28.9k]
  ------------------
  222|      0|            return false;
  223|  28.9k|    }
  224|       |
  225|  86.8k|    return true;
  226|  86.8k|}
cmd.c:apply_flag:
   63|  86.8k|{
   64|  1.12M|    for (int n = 0; cmd_flags[n].name; n++) {
  ------------------
  |  Branch (64:21): [True: 1.04M, False: 86.8k]
  ------------------
   65|  1.04M|        if (bstr_equals0(str, cmd_flags[n].name)) {
  ------------------
  |  Branch (65:13): [True: 0, False: 1.04M]
  ------------------
   66|      0|            cmd->flags = (cmd->flags & ~cmd_flags[n].remove) | cmd_flags[n].add;
   67|      0|            return true;
   68|      0|        }
   69|  1.04M|    }
   70|  86.8k|    return false;
   71|  86.8k|}
cmd.c:find_cmd:
   74|  86.8k|{
   75|  86.8k|    if (name.len == 0) {
  ------------------
  |  Branch (75:9): [True: 0, False: 86.8k]
  ------------------
   76|      0|        mp_err(log, "Command name missing.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
   77|      0|        return false;
   78|      0|    }
   79|       |
   80|  86.8k|    char nname[80];
   81|  86.8k|    snprintf(nname, sizeof(nname), "%.*s", BSTR_P(name));
  ------------------
  |  |  307|  86.8k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 86.8k, False: 0]
  |  |  ------------------
  ------------------
   82|   550k|    for (int n = 0; nname[n]; n++) {
  ------------------
  |  Branch (82:21): [True: 463k, False: 86.8k]
  ------------------
   83|   463k|        if (nname[n] == '_')
  ------------------
  |  Branch (83:13): [True: 0, False: 463k]
  ------------------
   84|      0|            nname[n] = '-';
   85|   463k|    }
   86|       |
   87|  1.33M|    for (int n = 0; mp_cmds[n].name; n++) {
  ------------------
  |  Branch (87:21): [True: 1.33M, False: 0]
  ------------------
   88|  1.33M|        if (strcmp(nname, mp_cmds[n].name) == 0) {
  ------------------
  |  Branch (88:13): [True: 86.8k, False: 1.24M]
  ------------------
   89|  86.8k|            cmd->def = &mp_cmds[n];
   90|  86.8k|            cmd->name = (char *)cmd->def->name;
   91|  86.8k|            return true;
   92|  86.8k|        }
   93|  1.33M|    }
   94|      0|    mp_err(log, "Command '%.*s' not found.\n", BSTR_P(name));
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   95|       |    return false;
   96|  86.8k|}
cmd.c:set_node_arg:
  161|  28.9k|{
  162|  28.9k|    const char *name = get_arg_name(cmd->def, i);
  ------------------
  |  |  123|  28.9k|    ((i) < MP_CMD_DEF_MAX_ARGS && (cmd)->args[(i)].name &&      \
  |  |  ------------------
  |  |  |  |   26|  57.9k|#define MP_CMD_DEF_MAX_ARGS 15
  |  |  ------------------
  |  |  |  Branch (123:6): [True: 28.9k, False: 0]
  |  |  |  Branch (123:35): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |  124|  28.9k|     (cmd)->args[(i)].name[0]                                   \
  |  |  ------------------
  |  |  |  Branch (124:6): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |  125|  28.9k|     ? (cmd)->args[(i)].name : mp_tprintf(10, "%d", (i) + 1))
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  163|       |
  164|  28.9k|    const struct m_option *opt = get_arg_type(cmd->def, i);
  165|  28.9k|    if (!opt) {
  ------------------
  |  Branch (165:9): [True: 0, False: 28.9k]
  ------------------
  166|      0|        mp_err(log, "Command %s: has only %d arguments.\n", cmd->name, i);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  167|      0|        return false;
  168|      0|    }
  169|       |
  170|  28.9k|    if (i < cmd->nargs && cmd->args[i].type) {
  ------------------
  |  Branch (170:9): [True: 0, False: 28.9k]
  |  Branch (170:27): [True: 0, False: 0]
  ------------------
  171|      0|        mp_err(log, "Command %s: argument %s was already set.\n", cmd->name, name);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  172|      0|        return false;
  173|      0|    }
  174|       |
  175|  28.9k|    struct mp_cmd_arg arg = {.type = opt};
  176|  28.9k|    void *dst = &arg.v;
  177|  28.9k|    int r = m_option_set_node_or_string(log, opt, bstr0(cmd->name), dst, val);
  178|  28.9k|    if (r < 0) {
  ------------------
  |  Branch (178:9): [True: 0, False: 28.9k]
  ------------------
  179|      0|        if (val->format == MPV_FORMAT_STRING) {
  ------------------
  |  Branch (179:13): [True: 0, False: 0]
  ------------------
  180|      0|            mp_err(log, "Command %s: argument %s can't be parsed: %s.\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  181|      0|                   cmd->name, name, m_option_strerror(r));
  182|      0|        } else {
  183|      0|            mp_err(log, "Command %s: argument %s has incompatible type.\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  184|      0|                   cmd->name, name);
  185|      0|        }
  186|      0|        return false;
  187|      0|    }
  188|       |
  189|       |    // (leave unset arguments blank, to be set later or checked by finish_cmd())
  190|  57.9k|    while (i >= cmd->nargs) {
  ------------------
  |  Branch (190:12): [True: 28.9k, False: 28.9k]
  ------------------
  191|  28.9k|        struct mp_cmd_arg t = {0};
  192|  28.9k|        MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, t);
  ------------------
  |  |  105|  28.9k|    do {                                            \
  |  |  106|  28.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  28.9k|    do {                                            \
  |  |  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  28.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  28.9k|        (idxvar)++;                                 \
  |  |  109|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
  193|  28.9k|    }
  194|       |
  195|  28.9k|    cmd->args[i] = arg;
  196|       |    return true;
  197|  28.9k|}
cmd.c:get_arg_type:
  104|   260k|{
  105|   260k|    const struct m_option *opt = NULL;
  106|   260k|    if (is_vararg(cmd, i)) {
  ------------------
  |  Branch (106:9): [True: 0, False: 260k]
  ------------------
  107|       |        // The last arg in a vararg command sets all vararg types.
  108|      0|        for (int n = MPMIN(i, MP_CMD_DEF_MAX_ARGS - 1); n >= 0; n--) {
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (108:57): [True: 0, False: 0]
  ------------------
  109|      0|            if (cmd->args[n].type) {
  ------------------
  |  Branch (109:17): [True: 0, False: 0]
  ------------------
  110|      0|                opt = &cmd->args[n];
  111|      0|                break;
  112|      0|            }
  113|      0|        }
  114|   260k|    } else if (i < MP_CMD_DEF_MAX_ARGS) {
  ------------------
  |  |   26|   260k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (114:16): [True: 260k, False: 0]
  ------------------
  115|   260k|        opt = &cmd->args[i];
  116|   260k|    }
  117|   260k|    return opt && opt->type ? opt : NULL;
  ------------------
  |  Branch (117:12): [True: 260k, False: 0]
  |  Branch (117:19): [True: 173k, False: 86.8k]
  ------------------
  118|   260k|}
cmd.c:is_vararg:
   99|   405k|{
  100|   405k|    return m->vararg && (i + 1 >= MP_CMD_DEF_MAX_ARGS || !m->args[i + 1].type);
  ------------------
  |  |   26|      0|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (100:12): [True: 0, False: 405k]
  |  Branch (100:26): [True: 0, False: 0]
  |  Branch (100:58): [True: 0, False: 0]
  ------------------
  101|   405k|}
cmd.c:finish_cmd:
  129|  86.8k|{
  130|   260k|    for (int i = 0; i < MP_CMD_DEF_MAX_ARGS; i++) {
  ------------------
  |  |   26|   260k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (130:21): [True: 260k, False: 0]
  ------------------
  131|       |        // (type==NULL is used for yet unset arguments)
  132|   260k|        if (i < cmd->nargs && cmd->args[i].type)
  ------------------
  |  Branch (132:13): [True: 28.9k, False: 231k]
  |  Branch (132:31): [True: 28.9k, False: 0]
  ------------------
  133|  28.9k|            continue;
  134|   231k|        const struct m_option *opt = get_arg_type(cmd->def, i);
  135|   231k|        if (i >= cmd->nargs && (!opt || is_vararg(cmd->def, i)))
  ------------------
  |  Branch (135:13): [True: 231k, False: 0]
  |  Branch (135:33): [True: 86.8k, False: 144k]
  |  Branch (135:41): [True: 0, False: 144k]
  ------------------
  136|  86.8k|            break;
  137|   144k|        if (!opt->defval && !(opt->flags & MP_CMD_OPT_ARG)) {
  ------------------
  |  |   27|   115k|#define MP_CMD_OPT_ARG M_OPT_OPTIONAL_PARAM
  |  |  ------------------
  |  |  |  |  497|   115k|#define M_OPT_OPTIONAL_PARAM    (UINT64_C(1) << 54)
  |  |  ------------------
  ------------------
  |  Branch (137:13): [True: 115k, False: 28.9k]
  |  Branch (137:29): [True: 0, False: 115k]
  ------------------
  138|      0|            mp_err(log, "Command %s: required argument %s not set.\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  139|      0|                   cmd->name, get_arg_name(cmd->def, i));
  140|      0|            return false;
  141|      0|        }
  142|   144k|        struct mp_cmd_arg arg = {.type = opt};
  143|   144k|        if (opt->defval)
  ------------------
  |  Branch (143:13): [True: 28.9k, False: 115k]
  ------------------
  144|  28.9k|            m_option_copy(opt, &arg.v, opt->defval);
  145|   144k|        mp_assert(i <= cmd->nargs);
  ------------------
  |  |   41|   144k|#define mp_assert assert
  ------------------
  |  Branch (145:9): [True: 144k, False: 0]
  ------------------
  146|   144k|        if (i == cmd->nargs) {
  ------------------
  |  Branch (146:13): [True: 144k, False: 0]
  ------------------
  147|   144k|            MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, arg);
  ------------------
  |  |  105|   144k|    do {                                            \
  |  |  106|   144k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   144k|    do {                                            \
  |  |  |  |   97|   144k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   144k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   144k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   144k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 86.8k, False: 57.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|   144k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  86.8k|    do {                                                        \
  |  |  |  |  |  |   89|  86.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  86.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  86.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  86.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  86.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  86.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  86.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 86.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   144k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 144k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   144k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   144k|        (idxvar)++;                                 \
  |  |  109|   144k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 144k]
  |  |  ------------------
  ------------------
  148|   144k|        } else {
  149|      0|            cmd->args[i] = arg;
  150|      0|        }
  151|   144k|    }
  152|       |
  153|  86.8k|    if (!(cmd->flags & (MP_ASYNC_CMD | MP_SYNC_CMD)))
  ------------------
  |  Branch (153:9): [True: 86.8k, False: 0]
  ------------------
  154|  86.8k|        cmd->flags |= cmd->def->default_async ? MP_ASYNC_CMD : MP_SYNC_CMD;
  ------------------
  |  Branch (154:23): [True: 0, False: 86.8k]
  ------------------
  155|       |
  156|       |    return true;
  157|  86.8k|}
cmd.c:get_arg_count:
  573|  86.8k|{
  574|  1.21M|    for (int i = MP_CMD_DEF_MAX_ARGS - 1; i >= 0; i--) {
  ------------------
  |  |   26|  86.8k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (574:43): [True: 1.21M, False: 0]
  ------------------
  575|  1.21M|        if (cmd->args[i].type)
  ------------------
  |  Branch (575:13): [True: 86.8k, False: 1.12M]
  ------------------
  576|  86.8k|            return i + 1;
  577|  1.21M|    }
  578|      0|    return 0;
  579|  86.8k|}

mp_dnd_init:
  148|  28.9k|{
  149|  28.9k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  150|       |    // Nothing drops files here, the thread only makes coverage timing dependent.
  151|  28.9k|    mpv_destroy(mpv);
  152|  28.9k|    return;
  153|      0|#endif
  154|      0|    mp_thread mpv_event_loop;
  155|      0|    if (!mp_thread_create(&mpv_event_loop, mpv_event_loop_fn, mpv))
  ------------------
  |  |  214|      0|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (155:9): [True: 0, False: 0]
  ------------------
  156|      0|        mp_thread_detach(mpv_event_loop);
  ------------------
  |  |  216|      0|#define mp_thread_detach          pthread_detach
  ------------------
  157|      0|    else
  158|      0|        mpv_destroy(mpv);
  159|      0|}

mp_input_set_mouse_transform:
  886|  9.61k|{
  887|  9.61k|    input_lock(ictx);
  ------------------
  |  |   58|  9.61k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  9.61k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  888|  9.61k|    ictx->mouse_mangle = dst || src;
  ------------------
  |  Branch (888:26): [True: 0, False: 9.61k]
  |  Branch (888:33): [True: 0, False: 9.61k]
  ------------------
  889|  9.61k|    if (ictx->mouse_mangle) {
  ------------------
  |  Branch (889:9): [True: 0, False: 9.61k]
  ------------------
  890|      0|        ictx->mouse_dst = *dst;
  891|      0|        ictx->mouse_src_mangle = !!src;
  892|      0|        if (ictx->mouse_src_mangle)
  ------------------
  |  Branch (892:13): [True: 0, False: 0]
  ------------------
  893|      0|            ictx->mouse_src = *src;
  894|      0|    }
  895|  9.61k|    input_unlock(ictx);
  ------------------
  |  |   59|  9.61k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  9.61k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  896|  9.61k|}
mp_input_get_mouse_event_counter:
 1321|  86.5k|{
 1322|       |    // Make the frontend always display the mouse cursor (as long as it's not
 1323|       |    // forced invisible) if mouse input is desired.
 1324|  86.5k|    input_lock(ictx);
  ------------------
  |  |   58|  86.5k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  86.5k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1325|  86.5k|    if (test_mouse_active(ictx, ictx->mouse_x, ictx->mouse_y))
  ------------------
  |  Branch (1325:9): [True: 0, False: 86.5k]
  ------------------
 1326|      0|        ictx->mouse_event_counter++;
 1327|  86.5k|    int ret = ictx->mouse_event_counter;
 1328|  86.5k|    input_unlock(ictx);
  ------------------
  |  |   59|  86.5k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  86.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1329|  86.5k|    return ret;
 1330|  86.5k|}
mp_input_get_delay:
 1387|   415k|{
 1388|   415k|    input_lock(ictx);
  ------------------
  |  |   58|   415k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|   415k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1389|   415k|    double seconds = INFINITY;
 1390|   415k|    adjust_max_wait_time(ictx, &seconds);
 1391|   415k|    input_unlock(ictx);
  ------------------
  |  |   59|   415k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|   415k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1392|   415k|    return seconds;
 1393|   415k|}
mp_input_read_cmd:
 1401|   415k|{
 1402|   415k|    input_lock(ictx);
  ------------------
  |  |   58|   415k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|   415k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1403|   415k|    struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue);
 1404|   415k|    if (!ret)
  ------------------
  |  Branch (1404:9): [True: 415k, False: 0]
  ------------------
 1405|   415k|        ret = check_autorepeat(ictx);
 1406|   415k|    if (ret && ret->mouse_move) {
  ------------------
  |  Branch (1406:9): [True: 0, False: 415k]
  |  Branch (1406:16): [True: 0, False: 0]
  ------------------
 1407|      0|        ictx->mouse_x = ret->mouse_x;
 1408|      0|        ictx->mouse_y = ret->mouse_y;
 1409|      0|    }
 1410|   415k|    input_unlock(ictx);
  ------------------
  |  |   59|   415k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|   415k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1411|   415k|    return ret;
 1412|   415k|}
mp_input_enable_section:
 1453|  28.9k|{
 1454|  28.9k|    bstr bname = bstr0(name);
 1455|  28.9k|    input_lock(ictx);
  ------------------
  |  |   58|  28.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1456|  28.9k|    bname = normalize_section(ictx, bname);
 1457|       |
 1458|  28.9k|    disable_section(ictx, bname);
 1459|       |
 1460|  28.9k|    MP_TRACE(ictx, "enable section '%.*s'\n", BSTR_P(bname));
  ------------------
  |  |   94|  28.9k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  57.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1461|       |
 1462|  28.9k|    int top = ictx->num_active_sections;
 1463|  28.9k|    if (!(flags & MP_INPUT_ON_TOP)) {
  ------------------
  |  Branch (1463:9): [True: 28.9k, False: 0]
  ------------------
 1464|       |        // insert before the first top entry
 1465|  28.9k|        for (top = 0; top < ictx->num_active_sections; top++) {
  ------------------
  |  Branch (1465:23): [True: 0, False: 28.9k]
  ------------------
 1466|      0|            if (ictx->active_sections[top].flags & MP_INPUT_ON_TOP)
  ------------------
  |  Branch (1466:17): [True: 0, False: 0]
  ------------------
 1467|      0|                break;
 1468|      0|        }
 1469|  28.9k|    }
 1470|  28.9k|    MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,
  ------------------
  |  |  115|  28.9k|    do {                                            \
  |  |  116|  28.9k|        size_t at_ = (at);                          \
  |  |  117|  28.9k|        assert(at_ <= (idxvar));                    \
  |  |  118|  28.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  28.9k|    do {                                            \
  |  |  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  28.9k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  28.9k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  28.9k|        (idxvar)++;                                 \
  |  |  122|  28.9k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
  |  Branch (1470:5): [True: 28.9k, False: 0]
  ------------------
 1471|  28.9k|                        top, (struct active_section){bname, flags});
 1472|       |
 1473|  28.9k|    MP_TRACE(ictx, "active section stack:\n");
  ------------------
  |  |   94|  28.9k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1474|  57.9k|    for (int n = 0; n < ictx->num_active_sections; n++) {
  ------------------
  |  Branch (1474:21): [True: 28.9k, False: 28.9k]
  ------------------
 1475|  28.9k|        MP_TRACE(ictx, " %.*s %d\n", BSTR_P(ictx->active_sections[n].name),
  ------------------
  |  |   94|  28.9k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  57.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|  28.9k|                 ictx->active_sections[n].flags);
 1477|  28.9k|    }
 1478|       |
 1479|  28.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  28.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1480|  28.9k|}
mp_input_remove_sections_by_owner:
 1545|  57.9k|{
 1546|  57.9k|    input_lock(ictx);
  ------------------
  |  |   58|  57.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1547|   115k|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (1547:21): [True: 57.9k, False: 57.9k]
  ------------------
 1548|  57.9k|        struct cmd_bind_section *bs = ictx->sections[n];
 1549|  57.9k|        if (bs->owner && owner && strcmp(bs->owner, owner) == 0) {
  ------------------
  |  Branch (1549:13): [True: 0, False: 57.9k]
  |  Branch (1549:26): [True: 0, False: 0]
  |  Branch (1549:35): [True: 0, False: 0]
  ------------------
 1550|      0|            disable_section(ictx, bs->section);
 1551|      0|            remove_binds(bs, false);
 1552|      0|            remove_binds(bs, true);
 1553|      0|        }
 1554|  57.9k|    }
 1555|  57.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  57.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1556|  57.9k|}
mp_input_init:
 1717|  28.9k|{
 1718|       |
 1719|  28.9k|    struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
  ------------------
  |  |   34|  28.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  28.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1720|  28.9k|    *ictx = (struct input_ctx){
 1721|  28.9k|        .global = global,
 1722|  28.9k|        .ar_state = -1,
 1723|  28.9k|        .log = mp_log_new(ictx, global->log, "input"),
 1724|  28.9k|        .mouse_section = bstr0("default"),
 1725|  28.9k|        .opts_cache = m_config_cache_alloc(ictx, global, &input_config),
 1726|  28.9k|        .wakeup_cb = wakeup_cb,
 1727|  28.9k|        .wakeup_ctx = wakeup_ctx,
 1728|  28.9k|        .active_sections = talloc_array(ictx, struct active_section, 0),
  ------------------
  |  |   29|  28.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  28.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1729|  28.9k|        .touch_points = talloc_array(ictx, struct touch_point, 0),
  ------------------
  |  |   29|  28.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  28.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|  28.9k|        .dnd_action = DND_NONE,
 1731|  28.9k|    };
 1732|       |
 1733|  28.9k|    ictx->opts = ictx->opts_cache->opts;
 1734|       |
 1735|  28.9k|    mp_mutex_init(&ictx->mutex);
 1736|       |
 1737|       |    // Setup default section, so that it does nothing.
 1738|  28.9k|    mp_input_enable_section(ictx, NULL, MP_INPUT_ALLOW_VO_DRAGGING |
 1739|  28.9k|                                        MP_INPUT_ALLOW_HIDE_CURSOR);
 1740|       |
 1741|  28.9k|    return ictx;
 1742|  28.9k|}
mp_input_update_opts:
 1763|  28.9k|{
 1764|  28.9k|    input_lock(ictx);
  ------------------
  |  |   58|  28.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1765|  28.9k|    reload_opts(ictx, false);
 1766|  28.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  28.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1767|  28.9k|}
mp_input_load_config:
 1770|  28.9k|{
 1771|  28.9k|    input_lock(ictx);
  ------------------
  |  |   58|  28.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1772|       |
 1773|  28.9k|    reload_opts(ictx, false);
 1774|       |
 1775|       |    // "Uncomment" the default key bindings in etc/input.conf and add them.
 1776|       |    // All lines that do not start with '# ' are parsed.
 1777|  28.9k|    bstr builtin = bstr0(builtin_input_conf);
 1778|  28.9k|    while (ictx->opts->builtin_bindings && builtin.len) {
  ------------------
  |  Branch (1778:12): [True: 0, False: 28.9k]
  |  Branch (1778:44): [True: 0, False: 0]
  ------------------
 1779|      0|        bstr line = bstr_getline(builtin, &builtin);
 1780|      0|        bstr_eatstart0(&line, "#");
 1781|      0|        if (!bstr_startswith0(line, " "))
  ------------------
  |  Branch (1781:13): [True: 0, False: 0]
  ------------------
 1782|      0|            parse_config(ictx, true, line, "<builtin>", (bstr){0});
 1783|      0|    }
 1784|       |
 1785|  28.9k|    bool config_ok = false;
 1786|  28.9k|    if (ictx->opts->config_file && ictx->opts->config_file[0])
  ------------------
  |  Branch (1786:9): [True: 0, False: 28.9k]
  |  Branch (1786:36): [True: 0, False: 0]
  ------------------
 1787|      0|        config_ok = parse_config_file(ictx, ictx->opts->config_file);
 1788|  28.9k|    if (!config_ok) {
  ------------------
  |  Branch (1788:9): [True: 28.9k, False: 0]
  ------------------
 1789|       |        // Try global conf dir
 1790|  28.9k|        void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  28.9k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  28.9k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1791|  28.9k|        char **files = mp_find_all_config_files(tmp, ictx->global, "input.conf");
 1792|  28.9k|        for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1792:25): [True: 28.9k, False: 0]
  |  Branch (1792:34): [True: 0, False: 28.9k]
  ------------------
 1793|      0|            parse_config_file(ictx, files[n]);
 1794|  28.9k|        talloc_free(tmp);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1795|  28.9k|    }
 1796|       |
 1797|  28.9k|    bool use_gamepad = ictx->opts->use_gamepad;
 1798|  28.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  28.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1799|       |
 1800|       |#if HAVE_SDL2_GAMEPAD
 1801|       |    if (use_gamepad)
 1802|       |        mp_input_sdl_gamepad_add(ictx);
 1803|       |#else
 1804|  28.9k|    (void)use_gamepad;
 1805|  28.9k|#endif
 1806|  28.9k|}
mp_input_uninit:
 1826|  28.9k|{
 1827|  28.9k|    if (!ictx)
  ------------------
  |  Branch (1827:9): [True: 0, False: 28.9k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  28.9k|    input_lock(ictx);
  ------------------
  |  |   58|  28.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1831|  28.9k|    reload_opts(ictx, true);
 1832|  28.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  28.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1833|       |
 1834|  28.9k|    close_input_sources(ictx);
 1835|  28.9k|    clear_queue(&ictx->cmd_queue);
 1836|  28.9k|    talloc_free(ictx->current_down_cmd);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1837|  28.9k|    mp_mutex_destroy(&ictx->mutex);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1838|  28.9k|    talloc_free(ictx);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 1839|  28.9k|}
input.c:test_mouse_active:
 1266|  86.5k|{
 1267|  86.5k|    return test_mouse(ictx, x, y, MP_INPUT_ALLOW_HIDE_CURSOR);
 1268|  86.5k|}
input.c:test_mouse:
 1250|  86.5k|{
 1251|  86.5k|    bool res = false;
 1252|   173k|    for (int i = 0; i < ictx->num_active_sections; i++) {
  ------------------
  |  Branch (1252:21): [True: 86.5k, False: 86.5k]
  ------------------
 1253|  86.5k|        struct active_section *as = &ictx->active_sections[i];
 1254|  86.5k|        if (as->flags & rej_flags)
  ------------------
  |  Branch (1254:13): [True: 86.5k, False: 0]
  ------------------
 1255|  86.5k|            continue;
 1256|      0|        struct cmd_bind_section *s = get_bind_section(ictx, as->name);
 1257|      0|        if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {
  ------------------
  |  Branch (1257:13): [True: 0, False: 0]
  |  Branch (1257:34): [True: 0, False: 0]
  ------------------
 1258|       |            res = true;
 1259|      0|            break;
 1260|      0|        }
 1261|      0|    }
 1262|  86.5k|    return res;
 1263|  86.5k|}
input.c:adjust_max_wait_time:
 1334|   415k|{
 1335|   415k|    struct input_opts *opts = ictx->opts;
 1336|   415k|    if (ictx->last_key_down && opts->ar_rate > 0 && ictx->ar_state >= 0) {
  ------------------
  |  Branch (1336:9): [True: 0, False: 415k]
  |  Branch (1336:32): [True: 0, False: 0]
  |  Branch (1336:53): [True: 0, False: 0]
  ------------------
 1337|      0|        *time = MPMIN(*time, 1.0 / opts->ar_rate);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1338|      0|        *time = MPMIN(*time, opts->ar_delay / 1000.0);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1339|      0|    }
 1340|   415k|}
input.c:queue_remove_head:
  301|   415k|{
  302|   415k|    struct mp_cmd *ret = queue->first;
  303|   415k|    if (ret)
  ------------------
  |  Branch (303:9): [True: 0, False: 415k]
  ------------------
  304|      0|        queue_remove(queue, ret);
  305|   415k|    return ret;
  306|   415k|}
input.c:check_autorepeat:
 1353|   415k|{
 1354|   415k|    struct input_opts *opts = ictx->opts;
 1355|       |
 1356|       |    // No input : autorepeat ?
 1357|   415k|    if (opts->ar_rate <= 0 || !ictx->current_down_cmd || !ictx->last_key_down ||
  ------------------
  |  Branch (1357:9): [True: 0, False: 415k]
  |  Branch (1357:31): [True: 415k, False: 0]
  |  Branch (1357:58): [True: 0, False: 0]
  ------------------
 1358|      0|        (ictx->last_key_down & MP_NO_REPEAT_KEY) ||
  ------------------
  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  ------------------
  |  Branch (1358:9): [True: 0, False: 0]
  ------------------
 1359|      0|        !mp_input_is_repeatable_cmd(ictx->current_down_cmd))
  ------------------
  |  Branch (1359:9): [True: 0, False: 0]
  ------------------
 1360|   415k|        ictx->ar_state = -1; // disable
 1361|       |
 1362|   415k|    if (ictx->ar_state >= 0) {
  ------------------
  |  Branch (1362:9): [True: 0, False: 415k]
  ------------------
 1363|      0|        int64_t t = mp_time_ns();
 1364|      0|        if (ictx->last_ar + MP_TIME_S_TO_NS(2) < t)
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (1364:13): [True: 0, False: 0]
  ------------------
 1365|      0|            ictx->last_ar = t;
 1366|       |        // First time : wait delay
 1367|      0|        if (ictx->ar_state == 0
  ------------------
  |  Branch (1367:13): [True: 0, False: 0]
  ------------------
 1368|      0|            && (t - ictx->last_key_down_time) >= MP_TIME_MS_TO_NS(opts->ar_delay))
  ------------------
  |  |   72|      0|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  |  Branch (1368:16): [True: 0, False: 0]
  ------------------
 1369|      0|        {
 1370|      0|            ictx->ar_state = 1;
 1371|      0|            ictx->last_ar = ictx->last_key_down_time + MP_TIME_MS_TO_NS(opts->ar_delay);
  ------------------
  |  |   72|      0|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
 1372|       |            // Then send rate / sec event
 1373|      0|        } else if (ictx->ar_state == 1
  ------------------
  |  Branch (1373:20): [True: 0, False: 0]
  ------------------
 1374|      0|                   && (t - ictx->last_ar) >= 1e9 / opts->ar_rate) {
  ------------------
  |  Branch (1374:23): [True: 0, False: 0]
  ------------------
 1375|      0|            ictx->last_ar += 1e9 / opts->ar_rate;
 1376|      0|        } else {
 1377|      0|            return NULL;
 1378|      0|        }
 1379|      0|        struct mp_cmd *ret = mp_cmd_clone(ictx->current_down_cmd);
 1380|      0|        ret->repeated = true;
 1381|      0|        return ret;
 1382|      0|    }
 1383|   415k|    return NULL;
 1384|   415k|}
input.c:disable_section:
 1432|  28.9k|{
 1433|  28.9k|    name = normalize_section(ictx, name);
 1434|       |
 1435|       |    // Remove old section, or make sure it's on top if re-enabled
 1436|  28.9k|    for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
  ------------------
  |  Branch (1436:49): [True: 0, False: 28.9k]
  ------------------
 1437|      0|        struct active_section *as = &ictx->active_sections[i];
 1438|      0|        if (bstr_equals(as->name, name)) {
  ------------------
  |  Branch (1438:13): [True: 0, False: 0]
  ------------------
 1439|       |            MP_TARRAY_REMOVE_AT(ictx->active_sections,
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1439:13): [True: 0, False: 0]
  ------------------
 1440|      0|                                ictx->num_active_sections, i);
 1441|      0|        }
 1442|      0|    }
 1443|  28.9k|}
input.c:normalize_section:
 1427|  57.9k|{
 1428|  57.9k|    return get_bind_section(ictx, name)->section;
 1429|  57.9k|}
input.c:get_bind_section:
  406|  57.9k|{
  407|  57.9k|    if (section.len == 0)
  ------------------
  |  Branch (407:9): [True: 28.9k, False: 28.9k]
  ------------------
  408|  28.9k|        section = bstr0("default");
  409|  57.9k|    struct cmd_bind_section *bind_section = find_section(ictx, section);
  410|  57.9k|    if (bind_section)
  ------------------
  |  Branch (410:9): [True: 28.9k, False: 28.9k]
  ------------------
  411|  28.9k|        return bind_section;
  412|  28.9k|    bind_section = talloc_ptrtype(ictx, bind_section);
  ------------------
  |  |   34|  28.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  28.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|  28.9k|    *bind_section = (struct cmd_bind_section) {
  414|  28.9k|        .section = bstrdup(bind_section, section),
  415|  28.9k|        .mouse_area = {INT_MIN, INT_MIN, INT_MAX, INT_MAX},
  416|  28.9k|        .mouse_area_set = true,
  417|  28.9k|    };
  418|  28.9k|    MP_TARRAY_APPEND(ictx, ictx->sections, ictx->num_sections, bind_section);
  ------------------
  |  |  105|  28.9k|    do {                                            \
  |  |  106|  28.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  28.9k|    do {                                            \
  |  |  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  28.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  28.9k|        (idxvar)++;                                 \
  |  |  109|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
  419|  28.9k|    return bind_section;
  420|  57.9k|}
input.c:find_section:
  395|  57.9k|{
  396|  57.9k|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (396:21): [True: 28.9k, False: 28.9k]
  ------------------
  397|  28.9k|        struct cmd_bind_section *bs = ictx->sections[n];
  398|  28.9k|        if (bstr_equals(section, bs->section))
  ------------------
  |  Branch (398:13): [True: 28.9k, False: 0]
  ------------------
  399|  28.9k|            return bs;
  400|  28.9k|    }
  401|  28.9k|    return NULL;
  402|  57.9k|}
input.c:reload_opts:
 1745|  86.8k|{
 1746|  86.8k|    m_config_cache_update(ictx->opts_cache);
 1747|       |
 1748|       |#if HAVE_COCOA
 1749|       |    struct input_opts *opts = ictx->opts;
 1750|       |
 1751|       |    if (ictx->using_cocoa_media_keys != (opts->use_media_keys && !shutdown)) {
 1752|       |        ictx->using_cocoa_media_keys = !ictx->using_cocoa_media_keys;
 1753|       |        if (ictx->using_cocoa_media_keys) {
 1754|       |            cocoa_init_media_keys();
 1755|       |        } else {
 1756|       |            cocoa_uninit_media_keys();
 1757|       |        }
 1758|       |    }
 1759|       |#endif
 1760|  86.8k|}
input.c:clear_queue:
 1817|  28.9k|{
 1818|  28.9k|    while (queue->first) {
  ------------------
  |  Branch (1818:12): [True: 0, False: 28.9k]
  ------------------
 1819|      0|        struct mp_cmd *item = queue->first;
 1820|      0|        queue_remove(queue, item);
 1821|      0|        talloc_free(item);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1822|      0|    }
 1823|  28.9k|}
input.c:close_input_sources:
 1976|  28.9k|{
 1977|       |    // To avoid lock-order issues, we first remove each source from the context,
 1978|       |    // and then destroy it.
 1979|  28.9k|    while (1) {
  ------------------
  |  Branch (1979:12): [True: 28.9k, Folded]
  ------------------
 1980|  28.9k|        input_lock(ictx);
  ------------------
  |  |   58|  28.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1981|  28.9k|        struct mp_input_src *src = ictx->num_sources ? ictx->sources[0] : NULL;
  ------------------
  |  Branch (1981:36): [True: 0, False: 28.9k]
  ------------------
 1982|  28.9k|        input_unlock(ictx);
  ------------------
  |  |   59|  28.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1983|  28.9k|        if (!src)
  ------------------
  |  Branch (1983:13): [True: 28.9k, False: 0]
  ------------------
 1984|  28.9k|            break;
 1985|      0|        input_src_kill(src);
 1986|      0|    }
 1987|  28.9k|}

mp_init_ipc:
  408|  28.9k|{
  409|  28.9k|    struct MPOpts *opts = mp_get_config_group(NULL, global, &mp_opt_root);
  410|       |
  411|  28.9k|    struct mp_ipc_ctx *arg = talloc_ptrtype(NULL, arg);
  ------------------
  |  |   34|  28.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  28.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|  28.9k|    *arg = (struct mp_ipc_ctx){
  413|  28.9k|        .log        = mp_log_new(arg, global->log, "ipc"),
  414|  28.9k|        .client_api = client_api,
  415|  28.9k|        .path       = mp_get_user_path(arg, global, opts->ipc_path),
  416|  28.9k|        .death_pipe = {-1, -1},
  417|  28.9k|    };
  418|       |
  419|  28.9k|    if (opts->ipc_client && opts->ipc_client[0]) {
  ------------------
  |  Branch (419:9): [True: 0, False: 28.9k]
  |  Branch (419:29): [True: 0, False: 0]
  ------------------
  420|      0|        int fd = -1;
  421|      0|        bstr str = bstr0(opts->ipc_client);
  422|      0|        if (bstr_eatstart0(&str, "fd://") && str.len) {
  ------------------
  |  Branch (422:13): [True: 0, False: 0]
  |  Branch (422:46): [True: 0, False: 0]
  ------------------
  423|      0|            long long ll = bstrtoll(str, &str, 0);
  424|      0|            if (!str.len && ll >= 0 && ll <= INT_MAX)
  ------------------
  |  Branch (424:17): [True: 0, False: 0]
  |  Branch (424:29): [True: 0, False: 0]
  |  Branch (424:40): [True: 0, False: 0]
  ------------------
  425|      0|                fd = ll;
  426|      0|        }
  427|      0|        if (fd < 0) {
  ------------------
  |  Branch (427:13): [True: 0, False: 0]
  ------------------
  428|      0|            MP_ERR(arg, "Invalid IPC client argument: '%s'\n", opts->ipc_client);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  429|      0|        } else {
  430|      0|            mp_set_cloexec(fd);
  431|      0|            ipc_start_client_json(arg, -1, fd);
  432|      0|        }
  433|      0|    }
  434|       |
  435|  28.9k|    talloc_free(opts);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  436|       |
  437|  28.9k|    if (!arg->path || !arg->path[0])
  ------------------
  |  Branch (437:9): [True: 28.9k, False: 0]
  |  Branch (437:23): [True: 0, False: 0]
  ------------------
  438|  28.9k|        goto out;
  439|       |
  440|      0|    if (mp_make_wakeup_pipe(arg->death_pipe) < 0)
  ------------------
  |  Branch (440:9): [True: 0, False: 0]
  ------------------
  441|      0|        goto out;
  442|       |
  443|      0|    if (mp_thread_create(&arg->thread, ipc_thread, arg))
  ------------------
  |  |  214|      0|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  444|      0|        goto out;
  445|       |
  446|      0|    return arg;
  447|       |
  448|  28.9k|out:
  449|  28.9k|    if (arg->death_pipe[0] >= 0) {
  ------------------
  |  Branch (449:9): [True: 0, False: 28.9k]
  ------------------
  450|      0|        close(arg->death_pipe[0]);
  451|      0|        close(arg->death_pipe[1]);
  452|      0|    }
  453|  28.9k|    talloc_free(arg);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  454|       |    return NULL;
  455|      0|}
mp_uninit_ipc:
  458|  28.9k|{
  459|  28.9k|    if (!arg)
  ------------------
  |  Branch (459:9): [True: 28.9k, False: 0]
  ------------------
  460|  28.9k|        return;
  461|       |
  462|      0|    (void)write(arg->death_pipe[1], &(char){0}, 1);
  463|      0|    mp_thread_join(arg->thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  464|       |
  465|      0|    close(arg->death_pipe[0]);
  466|      0|    close(arg->death_pipe[1]);
  467|      0|    talloc_free(arg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  468|      0|}

bstrcmp:
   31|  38.2M|{
   32|  38.2M|    int ret = 0;
   33|  38.2M|    if (str1.len && str2.len)
  ------------------
  |  Branch (33:9): [True: 38.2M, False: 118]
  |  Branch (33:21): [True: 38.2M, False: 28.9k]
  ------------------
   34|  38.2M|        ret = memcmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  38.2M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 11.4M, False: 26.7M]
  |  |  ------------------
  ------------------
   35|       |
   36|  38.2M|    if (!ret) {
  ------------------
  |  Branch (36:9): [True: 6.55M, False: 31.7M]
  ------------------
   37|  6.55M|        if (str1.len == str2.len)
  ------------------
  |  Branch (37:13): [True: 5.19M, False: 1.36M]
  ------------------
   38|  5.19M|            return 0;
   39|  1.36M|        else if (str1.len > str2.len)
  ------------------
  |  Branch (39:18): [True: 144k, False: 1.21M]
  ------------------
   40|   144k|            return 1;
   41|  1.21M|        else
   42|  1.21M|            return -1;
   43|  6.55M|    }
   44|  31.7M|    return ret;
   45|  38.2M|}
bstrcasecmp:
   48|  1.76M|{
   49|  1.76M|    int ret = 0;
   50|  1.76M|    if (str1.len && str2.len)
  ------------------
  |  Branch (50:9): [True: 1.55M, False: 210k]
  |  Branch (50:21): [True: 1.55M, False: 460]
  ------------------
   51|  1.55M|        ret = strncasecmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  1.55M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 350k, False: 1.20M]
  |  |  ------------------
  ------------------
   52|       |
   53|  1.76M|    if (!ret) {
  ------------------
  |  Branch (53:9): [True: 583k, False: 1.18M]
  ------------------
   54|   583k|        if (str1.len == str2.len)
  ------------------
  |  Branch (54:13): [True: 341k, False: 241k]
  ------------------
   55|   341k|            return 0;
   56|   241k|        else if (str1.len > str2.len)
  ------------------
  |  Branch (56:18): [True: 2.17k, False: 239k]
  ------------------
   57|  2.17k|            return 1;
   58|   239k|        else
   59|   239k|            return -1;
   60|   583k|    }
   61|  1.18M|    return ret;
   62|  1.76M|}
bstrchr:
   65|  51.7M|{
   66|  51.7M|    if (!str.len)
  ------------------
  |  Branch (66:9): [True: 14, False: 51.7M]
  ------------------
   67|     14|        return -1;
   68|  51.7M|    unsigned char *pos = memchr(str.start, c, str.len);
   69|  51.7M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (69:12): [True: 47.9M, False: 3.76M]
  ------------------
   70|  51.7M|}
bstrrchr:
   73|   934k|{
   74|   934k|    if (!str.len)
  ------------------
  |  Branch (74:9): [True: 3.93k, False: 930k]
  ------------------
   75|  3.93k|        return -1;
   76|   930k|#if HAVE_MEMRCHR
   77|   930k|    unsigned char *pos = memrchr(str.start, c, str.len);
   78|   930k|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (78:12): [True: 829k, False: 101k]
  ------------------
   79|       |#else
   80|       |    for (int i = str.len - 1; i >= 0; i--)
   81|       |        if (str.start[i] == c)
   82|       |            return i;
   83|       |    return -1;
   84|       |#endif
   85|   934k|}
bstrcspn:
   88|   506k|{
   89|   506k|    int i;
   90|  54.3M|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (90:17): [True: 54.3M, False: 42.7k]
  ------------------
   91|  54.3M|        if (strchr(reject, str.start[i]))
  ------------------
  |  Branch (91:13): [True: 463k, False: 53.8M]
  ------------------
   92|   463k|            break;
   93|   506k|    return i;
   94|   506k|}
bstrspn:
   97|   222k|{
   98|   222k|    int i;
   99|   690k|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (99:17): [True: 571k, False: 119k]
  ------------------
  100|   571k|        if (!strchr(accept, str.start[i]))
  ------------------
  |  Branch (100:13): [True: 103k, False: 467k]
  ------------------
  101|   103k|            break;
  102|   222k|    return i;
  103|   222k|}
bstr_find:
  106|  2.61M|{
  107|  47.3M|    for (int i = 0; i < haystack.len; i++)
  ------------------
  |  Branch (107:21): [True: 46.7M, False: 611k]
  ------------------
  108|  46.7M|        if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle))
  ------------------
  |  Branch (108:13): [True: 2.00M, False: 44.6M]
  ------------------
  109|  2.00M|            return i;
  110|   611k|    return -1;
  111|  2.61M|}
bstr_lstrip:
  114|  11.6M|{
  115|  11.7M|    while (str.len && mp_isspace(*str.start)) {
  ------------------
  |  Branch (115:12): [True: 8.99M, False: 2.73M]
  |  Branch (115:23): [True: 55.5k, False: 8.94M]
  ------------------
  116|  55.5k|        str.start++;
  117|  55.5k|        str.len--;
  118|  55.5k|    }
  119|  11.6M|    return str;
  120|  11.6M|}
bstr_strip:
  123|  2.23M|{
  124|  2.23M|    str = bstr_lstrip(str);
  125|  3.87M|    while (str.len && mp_isspace(str.start[str.len - 1]))
  ------------------
  |  Branch (125:12): [True: 3.71M, False: 158k]
  |  Branch (125:23): [True: 1.64M, False: 2.07M]
  ------------------
  126|  1.64M|        str.len--;
  127|  2.23M|    return str;
  128|  2.23M|}
bstr_split:
  131|  40.1k|{
  132|  40.1k|    int start;
  133|  40.1k|    for (start = 0; start < str.len; start++)
  ------------------
  |  Branch (133:21): [True: 40.1k, False: 0]
  ------------------
  134|  40.1k|        if (!strchr(sep, str.start[start]))
  ------------------
  |  Branch (134:13): [True: 40.1k, False: 0]
  ------------------
  135|  40.1k|            break;
  136|  40.1k|    str = bstr_cut(str, start);
  137|  40.1k|    int end = bstrcspn(str, sep);
  138|  40.1k|    if (rest) {
  ------------------
  |  Branch (138:9): [True: 0, False: 40.1k]
  ------------------
  139|      0|        *rest = bstr_cut(str, end);
  140|      0|    }
  141|  40.1k|    return bstr_splice(str, 0, end);
  142|  40.1k|}
bstr_split_tok:
  148|  1.37M|{
  149|  1.37M|    bstr bsep = bstr0(tok);
  150|  1.37M|    int pos = bstr_find(str, bsep);
  151|  1.37M|    if (pos < 0)
  ------------------
  |  Branch (151:9): [True: 330k, False: 1.04M]
  ------------------
  152|   330k|        pos = str.len;
  153|  1.37M|    *out_left = bstr_splice(str, 0, pos);
  154|  1.37M|    *out_right = bstr_cut(str, pos + bsep.len);
  155|  1.37M|    return pos != str.len;
  156|  1.37M|}
bstr_splice:
  159|   103M|{
  160|   103M|    if (!str.len)
  ------------------
  |  Branch (160:9): [True: 21.7k, False: 103M]
  ------------------
  161|  21.7k|        return str;
  162|       |
  163|   103M|    if (start < 0)
  ------------------
  |  Branch (163:9): [True: 0, False: 103M]
  ------------------
  164|      0|        start += str.len;
  165|   103M|    if (end < 0)
  ------------------
  |  Branch (165:9): [True: 94, False: 103M]
  ------------------
  166|     94|        end += str.len;
  167|   103M|    end = MPMIN(end, str.len);
  ------------------
  |  |   45|   103M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 2.13M, False: 101M]
  |  |  ------------------
  ------------------
  168|   103M|    start = MPMAX(start, 0);
  ------------------
  |  |   44|   103M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 44.8M, False: 58.4M]
  |  |  ------------------
  ------------------
  169|   103M|    end = MPMAX(end, start);
  ------------------
  |  |   44|   103M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 102M, False: 396k]
  |  |  ------------------
  ------------------
  170|   103M|    str.start += start;
  171|   103M|    str.len = end - start;
  172|   103M|    return str;
  173|   103M|}
bstrtoll:
  176|   291k|{
  177|   291k|    str = bstr_lstrip(str);
  178|   291k|    char buf[51];
  179|   291k|    int len = MPMIN(str.len, 50);
  ------------------
  |  |   45|   291k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 60, False: 291k]
  |  |  ------------------
  ------------------
  180|   291k|    memcpy(buf, str.start, len);
  181|   291k|    buf[len] = 0;
  182|   291k|    char *endptr;
  183|   291k|    long long r = strtoll(buf, &endptr, base);
  184|   291k|    if (rest)
  ------------------
  |  Branch (184:9): [True: 291k, False: 0]
  ------------------
  185|   291k|        *rest = bstr_cut(str, endptr - buf);
  186|   291k|    return r;
  187|   291k|}
bstrtod:
  190|   319k|{
  191|   319k|    str = bstr_lstrip(str);
  192|   319k|    char buf[101];
  193|   319k|    int len = MPMIN(str.len, 100);
  ------------------
  |  |   45|   319k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 3, False: 319k]
  |  |  ------------------
  ------------------
  194|   319k|    memcpy(buf, str.start, len);
  195|   319k|    buf[len] = 0;
  196|   319k|    char *endptr;
  197|   319k|    double r = strtod(buf, &endptr);
  198|   319k|    if (rest)
  ------------------
  |  Branch (198:9): [True: 319k, False: 0]
  ------------------
  199|   319k|        *rest = bstr_cut(str, endptr - buf);
  200|   319k|    return r;
  201|   319k|}
bstr_splitchar:
  204|  49.7M|{
  205|  49.7M|    int pos = bstrchr(str, c);
  206|  49.7M|    if (pos < 0)
  ------------------
  |  Branch (206:9): [True: 2.02M, False: 47.6M]
  ------------------
  207|  2.02M|        pos = str.len;
  208|  49.7M|    if (rest)
  ------------------
  |  Branch (208:9): [True: 49.7M, False: 0]
  ------------------
  209|  49.7M|        *rest = bstr_cut(str, pos + 1);
  210|  49.7M|    return bstr_splice(str, 0, pos + 1);
  211|  49.7M|}
bstr_strip_linebreaks:
  214|  2.98M|{
  215|  2.98M|    if (bstr_endswith0(str, "\r\n")) {
  ------------------
  |  Branch (215:9): [True: 392, False: 2.98M]
  ------------------
  216|    392|        str = bstr_splice(str, 0, str.len - 2);
  217|  2.98M|    } else if (bstr_endswith0(str, "\n")) {
  ------------------
  |  Branch (217:16): [True: 2.96M, False: 13.0k]
  ------------------
  218|  2.96M|        str = bstr_splice(str, 0, str.len - 1);
  219|  2.96M|    }
  220|  2.98M|    return str;
  221|  2.98M|}
bstr_eatstart:
  224|  59.9M|{
  225|  59.9M|    if (!bstr_startswith(*s, prefix))
  ------------------
  |  Branch (225:9): [True: 56.9M, False: 3.06M]
  ------------------
  226|  56.9M|        return false;
  227|  3.06M|    *s = bstr_cut(*s, prefix.len);
  228|       |    return true;
  229|  59.9M|}
bstr_eatend:
  232|    125|{
  233|    125|    if (!bstr_endswith(*s, prefix))
  ------------------
  |  Branch (233:9): [True: 103, False: 22]
  ------------------
  234|    103|        return false;
  235|     22|    s->len -= prefix.len;
  236|       |    return true;
  237|    125|}
bstr_parse_utf8_code_length:
  257|  2.33G|{
  258|  2.33G|    if (b < 128)
  ------------------
  |  Branch (258:9): [True: 2.10G, False: 228M]
  ------------------
  259|  2.10G|        return 1;
  260|   228M|    int bytes = 7 - mp_log2(b ^ 255);
  261|   228M|    return (bytes >= 2 && bytes <= 4) ? bytes : -1;
  ------------------
  |  Branch (261:13): [True: 160M, False: 68.1M]
  |  Branch (261:27): [True: 90.2M, False: 70.0M]
  ------------------
  262|  2.33G|}
bstr_decode_partial_utf8:
  265|  29.1M|{
  266|  29.1M|    if (s->len == 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 29.1M]
  ------------------
  267|      0|        return -1;
  268|  29.1M|    unsigned int codepoint = s->start[0];
  269|  29.1M|    s->start++; s->len--;
  270|  29.1M|    if (codepoint >= 128) {
  ------------------
  |  Branch (270:9): [True: 9.94M, False: 19.1M]
  ------------------
  271|  9.94M|        int bytes = bstr_parse_utf8_code_length(codepoint);
  272|  9.94M|        if (bytes < 1)
  ------------------
  |  Branch (272:13): [True: 1.49M, False: 8.45M]
  ------------------
  273|  1.49M|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|  1.49M|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  274|  8.45M|        codepoint &= 127 >> bytes;
  275|  19.8M|        for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (275:25): [True: 12.3M, False: 7.56M]
  ------------------
  276|  12.3M|            if (!s->len)
  ------------------
  |  Branch (276:17): [True: 3.99k, False: 12.3M]
  ------------------
  277|  3.99k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|  3.99k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  278|  12.3M|            int tmp = (unsigned char)s->start[0];
  279|  12.3M|            if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (279:17): [True: 892k, False: 11.4M]
  ------------------
  280|   892k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|   892k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  281|  11.4M|            codepoint = (codepoint << 6) | (tmp & ~0xC0);
  282|  11.4M|            s->start++; s->len--;
  283|  11.4M|        }
  284|  7.56M|        if (codepoint > 0x10FFFF || (codepoint >= 0xD800 && codepoint <= 0xDFFF))
  ------------------
  |  Branch (284:13): [True: 1.43k, False: 7.56M]
  |  Branch (284:38): [True: 12.8k, False: 7.54M]
  |  Branch (284:61): [True: 86, False: 12.7k]
  ------------------
  285|  1.51k|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|  1.51k|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  286|       |
  287|       |        // Overlong sequences - check taken from libavcodec.
  288|  7.55M|        unsigned int min = bytes == 2 ? 0x80 : 1 << (5 * bytes - 4);
  ------------------
  |  Branch (288:28): [True: 3.71M, False: 3.84M]
  ------------------
  289|  7.55M|        if (codepoint < min)
  ------------------
  |  Branch (289:13): [True: 1.70k, False: 7.55M]
  ------------------
  290|  1.70k|            return BSTR_DECODE_OVERLONG_ENCODING;
  ------------------
  |  |   93|  1.70k|#define BSTR_DECODE_OVERLONG_ENCODING -3
  ------------------
  291|  7.55M|    }
  292|  26.7M|    return codepoint;
  293|  29.1M|}
bstr_decode_utf8:
  296|  29.1M|{
  297|  29.1M|    int res = bstr_decode_partial_utf8(&s);
  298|  29.1M|    if (res >= 0 && out_next)
  ------------------
  |  Branch (298:9): [True: 26.7M, False: 2.39M]
  |  Branch (298:21): [True: 26.7M, False: 0]
  ------------------
  299|  26.7M|        *out_next = s;
  300|  29.1M|    return res;
  301|  29.1M|}
bstr_validate_utf8:
  315|   380k|{
  316|  23.8M|    while (s.len) {
  ------------------
  |  Branch (316:12): [True: 23.6M, False: 235k]
  ------------------
  317|  23.6M|        if (bstr_decode_utf8(s, &s) < 0) {
  ------------------
  |  Branch (317:13): [True: 144k, False: 23.4M]
  ------------------
  318|       |            // Try to guess whether the sequence was just cut-off.
  319|   144k|            unsigned int codepoint = (unsigned char)s.start[0];
  320|   144k|            int bytes = bstr_parse_utf8_code_length(codepoint);
  321|   144k|            if (bytes > 1 && s.len < 6) {
  ------------------
  |  Branch (321:17): [True: 33.3k, False: 110k]
  |  Branch (321:30): [True: 10.7k, False: 22.5k]
  ------------------
  322|       |                // Manually check validity of left bytes
  323|  11.3k|                for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (323:33): [True: 11.2k, False: 87]
  ------------------
  324|  11.2k|                    if (n >= s.len) {
  ------------------
  |  Branch (324:25): [True: 2.30k, False: 8.97k]
  ------------------
  325|       |                        // Everything valid until now - just cut off.
  326|  2.30k|                        return -(bytes - s.len);
  327|  2.30k|                    }
  328|  8.97k|                    int tmp = (unsigned char)s.start[n];
  329|  8.97k|                    if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (329:25): [True: 8.38k, False: 587]
  ------------------
  330|  8.38k|                        break;
  331|  8.97k|                }
  332|  10.7k|            }
  333|   141k|            return -8;
  334|   144k|        }
  335|  23.6M|    }
  336|   235k|    return 0;
  337|   380k|}
bstr_sanitize_utf8_latin1:
  340|  22.4k|{
  341|  22.4k|    bstr new = {0};
  342|  22.4k|    bstr left = s;
  343|  22.4k|    unsigned char *first_ok = s.start;
  344|  5.43M|    while (left.len) {
  ------------------
  |  Branch (344:12): [True: 5.41M, False: 22.4k]
  ------------------
  345|  5.41M|        int r = bstr_decode_utf8(left, &left);
  346|  5.41M|        if (r < 0) {
  ------------------
  |  Branch (346:13): [True: 2.23M, False: 3.17M]
  ------------------
  347|  2.23M|            bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  348|  2.23M|            mp_append_utf8_bstr(talloc_ctx, &new, (unsigned char)left.start[0]);
  349|  2.23M|            left.start += 1;
  350|  2.23M|            left.len -= 1;
  351|  2.23M|            first_ok = left.start;
  352|  2.23M|        }
  353|  5.41M|    }
  354|  22.4k|    if (!new.start)
  ------------------
  |  Branch (354:9): [True: 711, False: 21.7k]
  ------------------
  355|    711|        return s;
  356|  21.7k|    if (first_ok != left.start)
  ------------------
  |  Branch (356:9): [True: 12.8k, False: 8.87k]
  ------------------
  357|  12.8k|        bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  358|  21.7k|    return new;
  359|  22.4k|}
bstr_xappend:
  375|  47.2M|{
  376|  47.2M|    if (!append.len)
  ------------------
  |  Branch (376:9): [True: 31.6M, False: 15.6M]
  ------------------
  377|  31.6M|        return;
  378|  15.6M|    resize_append(talloc_ctx, s, append.len + 1);
  379|  15.6M|    memmove(s->start + s->len, append.start, append.len);
  380|  15.6M|    s->len += append.len;
  381|  15.6M|    s->start[s->len] = '\0';
  382|  15.6M|}
bstr_xappend_asprintf:
  385|  39.3M|{
  386|  39.3M|    va_list ap;
  387|  39.3M|    va_start(ap, fmt);
  388|  39.3M|    int ret = bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap);
  389|       |    va_end(ap);
  390|  39.3M|    return ret;
  391|  39.3M|}
bstr_xappend_vasprintf:
  395|  81.6M|{
  396|  81.6M|    int size;
  397|  81.6M|    va_list copy;
  398|  81.6M|    va_copy(copy, ap);
  399|  81.6M|    size_t avail = talloc_get_size(s->start) - s->len;
  ------------------
  |  |   45|  81.6M|#define talloc_get_size                 ta_get_size
  ------------------
  400|  81.6M|    char *dest = s->start ? s->start + s->len : NULL;
  ------------------
  |  Branch (400:18): [True: 81.4M, False: 196k]
  ------------------
  401|  81.6M|    size = vsnprintf(dest, avail, fmt, copy);
  402|  81.6M|    va_end(copy);
  403|       |
  404|  81.6M|    if (size < 0)
  ------------------
  |  Branch (404:9): [True: 0, False: 81.6M]
  ------------------
  405|      0|        return size;
  406|       |
  407|  81.6M|    if (avail < 1 || size + 1 > avail) {
  ------------------
  |  Branch (407:9): [True: 196k, False: 81.4M]
  |  Branch (407:22): [True: 779k, False: 80.6M]
  ------------------
  408|   975k|        resize_append(talloc_ctx, s, size + 1);
  409|   975k|        vsnprintf(s->start + s->len, size + 1, fmt, ap);
  410|   975k|    }
  411|  81.6M|    s->len += size;
  412|  81.6M|    return size;
  413|  81.6M|}
bstr_case_startswith:
  416|   636k|{
  417|   636k|    struct bstr start = bstr_splice(s, 0, prefix.len);
  418|   636k|    return start.len == prefix.len && bstrcasecmp(start, prefix) == 0;
  ------------------
  |  Branch (418:12): [True: 519k, False: 117k]
  |  Branch (418:39): [True: 8.61k, False: 510k]
  ------------------
  419|   636k|}
bstr_decode_hex:
  440|     32|{
  441|     32|    if (!out)
  ------------------
  |  Branch (441:9): [True: 0, False: 32]
  ------------------
  442|      0|        return false;
  443|       |
  444|     32|    char *arr = talloc_array(talloc_ctx, char, hex.len / 2);
  ------------------
  |  |   29|     32|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|     32|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     32|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|     32|    int len = 0;
  446|       |
  447|    919|    while (hex.len >= 2) {
  ------------------
  |  Branch (447:12): [True: 918, False: 1]
  ------------------
  448|    918|        int a = h_to_i(hex.start[0]);
  449|    918|        int b = h_to_i(hex.start[1]);
  450|    918|        hex = bstr_splice(hex, 2, hex.len);
  451|       |
  452|    918|        if (a < 0 || b < 0) {
  ------------------
  |  Branch (452:13): [True: 16, False: 902]
  |  Branch (452:22): [True: 15, False: 887]
  ------------------
  453|     31|            talloc_free(arr);
  ------------------
  |  |   47|     31|#define talloc_free                     ta_free
  ------------------
  454|     31|            return false;
  455|     31|        }
  456|       |
  457|    887|        arr[len++] = (a << 4) | b;
  458|    887|    }
  459|       |
  460|      1|    *out = (struct bstr){ .start = arr, .len = len };
  461|       |    return true;
  462|     32|}
bstr_find_in_list0:
  465|   201k|{
  466|   604k|    for (int n = 0; list && list[n]; n++)
  ------------------
  |  Branch (466:21): [True: 604k, False: 0]
  |  Branch (466:29): [True: 604k, False: 0]
  ------------------
  467|   604k|        if (case_sensitive ? !bstrcmp0(str, list[n]) : !bstrcasecmp0(str, list[n]))
  ------------------
  |  Branch (467:13): [True: 0, False: 604k]
  |  Branch (467:13): [True: 201k, False: 403k]
  ------------------
  468|   201k|            return n;
  469|       |
  470|      0|    return -1;
  471|   201k|}
bstr_in_list0:
  474|   201k|{
  475|       |    return bstr_find_in_list0(str, list, false) != -1;
  476|   201k|}
bstr.c:resize_append:
  362|  16.6M|{
  363|  16.6M|    size_t size = talloc_get_size(s->start);
  ------------------
  |  |   45|  16.6M|#define talloc_get_size                 ta_get_size
  ------------------
  364|  16.6M|    mp_assert(s->len <= size);
  ------------------
  |  |   41|  16.6M|#define mp_assert assert
  ------------------
  |  Branch (364:5): [True: 16.6M, False: 0]
  ------------------
  365|  16.6M|    if (append_min > size - s->len) {
  ------------------
  |  Branch (365:9): [True: 1.73M, False: 14.9M]
  ------------------
  366|  1.73M|        if (append_min < size)
  ------------------
  |  Branch (366:13): [True: 645k, False: 1.08M]
  ------------------
  367|   645k|            append_min = size; // preallocate in power of 2s
  368|  1.73M|        if (size >= SIZE_MAX / 2 || append_min >= SIZE_MAX / 2)
  ------------------
  |  Branch (368:13): [True: 0, False: 1.73M]
  |  Branch (368:37): [True: 0, False: 1.73M]
  ------------------
  369|      0|            abort(); // oom
  370|  1.73M|        s->start = talloc_realloc_size(talloc_ctx, s->start, size + append_min);
  ------------------
  |  |   39|  1.73M|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  1.73M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.73M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  1.73M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  1.73M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|  1.73M|    }
  372|  16.6M|}
bstr.c:h_to_i:
  428|  1.83k|{
  429|  1.83k|    if (c >= '0' && c <= '9')
  ------------------
  |  Branch (429:9): [True: 1.82k, False: 8]
  |  Branch (429:21): [True: 206, False: 1.62k]
  ------------------
  430|    206|        return c - '0';
  431|  1.63k|    if (c >= 'a' && c <= 'f')
  ------------------
  |  Branch (431:9): [True: 683, False: 947]
  |  Branch (431:21): [True: 656, False: 27]
  ------------------
  432|    656|        return c - 'a' + 10;
  433|    974|    if (c >= 'A' && c <= 'F')
  ------------------
  |  Branch (433:9): [True: 966, False: 8]
  |  Branch (433:21): [True: 933, False: 33]
  ------------------
  434|    933|        return c - 'A' + 10;
  435|       |
  436|     41|    return -1; // invalid char
  437|    974|}

client.c:bstr0:
   62|   260k|{
   63|   260k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 260k, False: 0]
  ------------------
   64|   260k|}
command.c:bstr0:
   62|  1.28M|{
   63|  1.28M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.28M, False: 0]
  ------------------
   64|  1.28M|}
configfiles.c:bstr0:
   62|  63.4k|{
   63|  63.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 63.4k, False: 0]
  ------------------
   64|  63.4k|}
main.c:bstr0:
   62|  28.9k|{
   63|  28.9k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 28.9k, False: 0]
  ------------------
   64|  28.9k|}
misc.c:bstr0:
   62|  48.0k|{
   63|  48.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 48.0k, False: 0]
  ------------------
   64|  48.0k|}
misc.c:bstr_xappend0:
  180|  48.0k|{
  181|  48.0k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|  48.0k|}
misc.c:bstrto0:
   46|  24.0k|{
   47|  24.0k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 24.0k, False: 0]
  ------------------
   48|  24.0k|}
misc.c:bstrdup0:
   40|  24.0k|{
   41|  24.0k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  24.0k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  24.0k|}
scripting.c:bstr0:
   62|  28.9k|{
   63|  28.9k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 28.9k, False: 0]
  ------------------
   64|  28.9k|}
stream.c:bstr0:
   62|   215k|{
   63|   215k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 215k, False: 0]
  ------------------
   64|   215k|}
stream.c:bstr_startswith0:
  246|   184k|{
  247|   184k|    return bstr_startswith(str, bstr0(prefix));
  248|   184k|}
stream.c:bstr_startswith:
  239|   184k|{
  240|   184k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 463, False: 183k]
  ------------------
  241|    463|        return false;
  242|   183k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   184k|}
stream_cb.c:bstr0:
   62|  29.8k|{
   63|  29.8k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 29.8k, False: 0]
  ------------------
   64|  29.8k|}
stream_cb.c:bstrto0:
   46|  29.8k|{
   47|  29.8k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 29.8k, False: 0]
  ------------------
   48|  29.8k|}
stream_cb.c:bstrdup0:
   40|  29.8k|{
   41|  29.8k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  29.8k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  29.8k|}
stream_file.c:bstrcasecmp0:
  281|   134k|{
  282|   134k|    return bstrcasecmp(str1, bstr0(str2));
  283|   134k|}
stream_file.c:bstr0:
   62|   135k|{
   63|   135k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 135k, False: 0]
  ------------------
   64|   135k|}
stream_file.c:bstrto0:
   46|    863|{
   47|    863|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 863, False: 0]
  ------------------
   48|    863|}
stream_file.c:bstrdup0:
   40|    863|{
   41|    863|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|    863|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|    863|}
stream_file.c:bstr_startswith0:
  246|    417|{
  247|    417|    return bstr_startswith(str, bstr0(prefix));
  248|    417|}
stream_file.c:bstr_startswith:
  239|    417|{
  240|    417|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 41, False: 376]
  ------------------
  241|     41|        return false;
  242|    376|    return !memcmp(str.start, prefix.start, prefix.len);
  243|    417|}
stream_lavf.c:bstr0:
   62|  5.07M|{
   63|  5.07M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.95M, False: 3.11M]
  ------------------
   64|  5.07M|}
stream_lavf.c:bstr_eatstart0:
  291|   186k|{
  292|   186k|    return bstr_eatstart(s, bstr0(prefix));
  293|   186k|}
stream_lavf.c:bstr_equals0:
  276|  1.71M|{
  277|  1.71M|    return bstr_equals(str1, bstr0(str2));
  278|  1.71M|}
stream_lavf.c:bstr_equals:
  268|  1.71M|{
  269|  1.71M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 1.68M, False: 21.9k]
  ------------------
  270|  1.68M|        return false;
  271|       |
  272|  21.9k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 21.9k]
  |  Branch (272:40): [True: 27, False: 21.9k]
  ------------------
  273|  1.71M|}
stream_memory.c:bstr0:
   62|   182k|{
   63|   182k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 182k, False: 0]
  ------------------
   64|   182k|}
stream_memory.c:bstr_eatstart0:
  291|   121k|{
  292|   121k|    return bstr_eatstart(s, bstr0(prefix));
  293|   121k|}
stream_memory.c:bstrdup:
   52|  60.8k|{
   53|  60.8k|    struct bstr r = { NULL, str.len };
   54|  60.8k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 60.8k, False: 0]
  ------------------
   55|  60.8k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  60.8k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  60.8k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  60.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  60.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  60.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  60.8k|    return r;
   57|  60.8k|}
vo.c:bstr0:
   62|  9.61k|{
   63|  9.61k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 9.61k, False: 0]
  ------------------
   64|  9.61k|}
chmap.c:bstr_eatstart0:
  291|   233k|{
  292|   233k|    return bstr_eatstart(s, bstr0(prefix));
  293|   233k|}
chmap.c:bstr_equals0:
  276|  4.30M|{
  277|  4.30M|    return bstr_equals(str1, bstr0(str2));
  278|  4.30M|}
chmap.c:bstr_equals:
  268|  4.30M|{
  269|  4.30M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 1.87M, False: 2.43M]
  ------------------
  270|  1.87M|        return false;
  271|       |
  272|  2.43M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 346k, False: 2.08M]
  |  Branch (272:40): [True: 498k, False: 1.59M]
  ------------------
  273|  4.30M|}
chmap.c:bstr0:
   62|  5.00M|{
   63|  5.00M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 5.00M, False: 0]
  ------------------
   64|  5.00M|}
ao.c:bstr0:
   62|  7.98k|{
   63|  7.98k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 7.98k, False: 0]
  ------------------
   64|  7.98k|}
codecs.c:bstr0:
   62|  21.8k|{
   63|  21.8k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 21.8k]
  ------------------
   64|  21.8k|}
msg.c:bstr_eatstart0:
  291|  44.7M|{
  292|  44.7M|    return bstr_eatstart(s, bstr0(prefix));
  293|  44.7M|}
msg.c:bstr0:
   62|  44.7M|{
   63|  44.7M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 44.7M, False: 0]
  ------------------
   64|  44.7M|}
msg.c:bstr_getline:
  156|  46.7M|{
  157|  46.7M|    return bstr_splitchar(str, rest, '\n');
  158|  46.7M|}
msg.c:bstrdup0:
   40|  1.10M|{
   41|  1.10M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.10M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.10M|}
playlist.c:bstr0:
   62|   133k|{
   63|   133k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 133k, False: 0]
  ------------------
   64|   133k|}
tags.c:bstr0:
   62|  2.23M|{
   63|  2.23M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 2.23M, False: 0]
  ------------------
   64|  2.23M|}
tags.c:bstrcasecmp0:
  281|  69.6k|{
  282|  69.6k|    return bstrcasecmp(str1, bstr0(str2));
  283|  69.6k|}
tags.c:bstrto0:
   46|  50.8k|{
   47|  50.8k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 50.8k, False: 0]
  ------------------
   48|  50.8k|}
tags.c:bstrdup0:
   40|  50.8k|{
   41|  50.8k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  50.8k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  50.8k|}
demux.c:bstr_xappend0:
  180|  24.0k|{
  181|  24.0k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|  24.0k|}
demux.c:bstr0:
   62|  66.1k|{
   63|  66.1k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 66.1k, False: 0]
  ------------------
   64|  66.1k|}
demux_edl.c:bstr0:
   62|   152k|{
   63|   152k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 152k, False: 0]
  ------------------
   64|   152k|}
demux_edl.c:bstr_eatstart0:
  291|  91.5k|{
  292|  91.5k|    return bstr_eatstart(s, bstr0(prefix));
  293|  91.5k|}
demux_edl.c:bstr_cut:
  227|  11.2k|{
  228|  11.2k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 11.2k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  11.2k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 11.2k]
  ------------------
  234|      0|        n = str.len;
  235|  11.2k|    return (struct bstr){str.start + n, str.len - n};
  236|  11.2k|}
demux_edl.c:bstr_startswith0:
  246|     23|{
  247|     23|    return bstr_startswith(str, bstr0(prefix));
  248|     23|}
demux_edl.c:bstr_startswith:
  239|     23|{
  240|     23|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 1, False: 22]
  ------------------
  241|      1|        return false;
  242|     22|    return !memcmp(str.start, prefix.start, prefix.len);
  243|     23|}
demux_edl.c:bstr_equals:
  268|  21.8k|{
  269|  21.8k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 12.8k, False: 9.01k]
  ------------------
  270|  12.8k|        return false;
  271|       |
  272|  9.01k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 7.95k, False: 1.06k]
  |  Branch (272:40): [True: 172, False: 888]
  ------------------
  273|  21.8k|}
demux_edl.c:bstr_equals0:
  276|  7.56k|{
  277|  7.56k|    return bstr_equals(str1, bstr0(str2));
  278|  7.56k|}
demux_edl.c:bstrdup0:
   40|  14.6k|{
   41|  14.6k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  14.6k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  14.6k|}
demux_edl.c:bstrcasecmp0:
  281|     30|{
  282|     30|    return bstrcasecmp(str1, bstr0(str2));
  283|     30|}
demux_lavf.c:bstrcasecmp0:
  281|   124k|{
  282|   124k|    return bstrcasecmp(str1, bstr0(str2));
  283|   124k|}
demux_lavf.c:bstr0:
   62|   181k|{
   63|   181k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 181k, False: 0]
  ------------------
   64|   181k|}
demux_lavf.c:bstr_endswith0:
  258|  8.39k|{
  259|  8.39k|    return bstr_endswith(str, bstr0(suffix));
  260|  8.39k|}
demux_lavf.c:bstr_endswith:
  251|  8.39k|{
  252|  8.39k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 4.92k, False: 3.47k]
  ------------------
  253|  4.92k|        return false;
  254|  3.47k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  8.39k|}
demux_mf.c:bstrto0:
   46|     74|{
   47|     74|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 74, False: 0]
  ------------------
   48|     74|}
demux_mf.c:bstr0:
   62|     86|{
   63|     86|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 86, False: 0]
  ------------------
   64|     86|}
demux_mf.c:bstrdup0:
   40|  3.22k|{
   41|  3.22k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  3.22k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  3.22k|}
demux_null.c:bstr_startswith0:
  246|  15.7k|{
  247|  15.7k|    return bstr_startswith(str, bstr0(prefix));
  248|  15.7k|}
demux_null.c:bstr_startswith:
  239|  15.7k|{
  240|  15.7k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 0, False: 15.7k]
  ------------------
  241|      0|        return false;
  242|  15.7k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  15.7k|}
demux_null.c:bstr0:
   62|  31.4k|{
   63|  31.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 31.4k, False: 0]
  ------------------
   64|  31.4k|}
demux_playlist.c:bstr_equals0:
  276|  50.2k|{
  277|  50.2k|    return bstr_equals(str1, bstr0(str2));
  278|  50.2k|}
demux_playlist.c:bstr_equals:
  268|  50.2k|{
  269|  50.2k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 47.0k, False: 3.23k]
  ------------------
  270|  47.0k|        return false;
  271|       |
  272|  3.23k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 3.23k]
  |  Branch (272:40): [True: 1.18k, False: 2.05k]
  ------------------
  273|  50.2k|}
demux_playlist.c:bstr0:
   62|  1.55M|{
   63|  1.55M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.55M, False: 5.78k]
  ------------------
   64|  1.55M|}
demux_playlist.c:bstr_eatstart0:
  291|   237k|{
  292|   237k|    return bstr_eatstart(s, bstr0(prefix));
  293|   237k|}
demux_playlist.c:bstrto0:
   46|   105k|{
   47|   105k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 105k, False: 0]
  ------------------
   48|   105k|}
demux_playlist.c:bstrdup0:
   40|   105k|{
   41|   105k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   105k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   105k|}
demux_playlist.c:bstr_startswith0:
  246|   346k|{
  247|   346k|    return bstr_startswith(str, bstr0(prefix));
  248|   346k|}
demux_playlist.c:bstr_startswith:
  239|   346k|{
  240|   346k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 178k, False: 168k]
  ------------------
  241|   178k|        return false;
  242|   168k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   346k|}
demux_playlist.c:bstrcasecmp0:
  281|   223k|{
  282|   223k|    return bstrcasecmp(str1, bstr0(str2));
  283|   223k|}
demux_playlist.c:bstr_endswith0:
  258|    152|{
  259|    152|    return bstr_endswith(str, bstr0(suffix));
  260|    152|}
demux_playlist.c:bstr_endswith:
  251|    152|{
  252|    152|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 0, False: 152]
  ------------------
  253|      0|        return false;
  254|    152|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|    152|}
cmd.c:bstr_equals0:
  276|  1.04M|{
  277|  1.04M|    return bstr_equals(str1, bstr0(str2));
  278|  1.04M|}
cmd.c:bstr_equals:
  268|  1.04M|{
  269|  1.04M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 955k, False: 86.8k]
  ------------------
  270|   955k|        return false;
  271|       |
  272|  86.8k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 86.8k]
  |  Branch (272:40): [True: 0, False: 86.8k]
  ------------------
  273|  1.04M|}
cmd.c:bstr0:
   62|  1.24M|{
   63|  1.24M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.24M, False: 0]
  ------------------
   64|  1.24M|}
input.c:bstrdup:
   52|  28.9k|{
   53|  28.9k|    struct bstr r = { NULL, str.len };
   54|  28.9k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 28.9k, False: 0]
  ------------------
   55|  28.9k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  28.9k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  28.9k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  28.9k|    return r;
   57|  28.9k|}
input.c:bstr0:
   62|   115k|{
   63|   115k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 86.8k, False: 28.9k]
  ------------------
   64|   115k|}
input.c:bstr_equals:
  268|  28.9k|{
  269|  28.9k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 0, False: 28.9k]
  ------------------
  270|      0|        return false;
  271|       |
  272|  28.9k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 28.9k, False: 0]
  |  Branch (272:40): [True: 0, False: 0]
  ------------------
  273|  28.9k|}
bstr.c:bstr_startswith:
  239|   106M|{
  240|   106M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 12.3M, False: 94.3M]
  ------------------
  241|  12.3M|        return false;
  242|  94.3M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   106M|}
bstr.c:bstr_cut:
  227|  54.8M|{
  228|  54.8M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 54.8M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  54.8M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 2.35M, False: 52.4M]
  ------------------
  234|  2.35M|        n = str.len;
  235|  54.8M|    return (struct bstr){str.start + n, str.len - n};
  236|  54.8M|}
bstr.c:bstr0:
   62|  7.94M|{
   63|  7.94M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 7.94M, False: 0]
  ------------------
   64|  7.94M|}
bstr.c:bstr_endswith0:
  258|  5.96M|{
  259|  5.96M|    return bstr_endswith(str, bstr0(suffix));
  260|  5.96M|}
bstr.c:bstr_endswith:
  251|  5.96M|{
  252|  5.96M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 385k, False: 5.57M]
  ------------------
  253|   385k|        return false;
  254|  5.57M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  5.96M|}
bstr.c:bstrcasecmp0:
  281|   604k|{
  282|   604k|    return bstrcasecmp(str1, bstr0(str2));
  283|   604k|}
charset_conv.c:bstr0:
   62|  1.15M|{
   63|  1.15M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.15M, False: 0]
  ------------------
   64|  1.15M|}
charset_conv.c:bstr_startswith0:
  246|  1.14M|{
  247|  1.14M|    return bstr_startswith(str, bstr0(prefix));
  248|  1.14M|}
charset_conv.c:bstr_startswith:
  239|  1.14M|{
  240|  1.14M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 635k, False: 514k]
  ------------------
  241|   635k|        return false;
  242|   514k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  1.14M|}
json.c:bstr0:
   62|   694k|{
   63|   694k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 521k, False: 173k]
  ------------------
   64|   694k|}
node.c:bstr0:
   62|  28.9k|{
   63|  28.9k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 28.9k, False: 0]
  ------------------
   64|  28.9k|}
node.c:bstrdup0:
   40|  28.9k|{
   41|  28.9k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  28.9k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  28.9k|}
path_utils.c:bstr0:
   62|  2.40M|{
   63|  2.40M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 2.40M, False: 0]
  ------------------
   64|  2.40M|}
path_utils.c:bstrdup0:
   40|  58.0k|{
   41|  58.0k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  58.0k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  58.0k|}
path_utils.c:bstr_find0:
  286|  1.24M|{
  287|  1.24M|    return bstr_find(haystack, bstr0(needle));
  288|  1.24M|}
m_config_frontend.c:bstr0:
   62|   161M|{
   63|   161M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 161M, False: 0]
  ------------------
   64|   161M|}
m_config_frontend.c:bstrcmp0:
  263|  30.6M|{
  264|  30.6M|    return bstrcmp(str1, bstr0(str2));
  265|  30.6M|}
m_config_frontend.c:bstr_eatstart0:
  291|   347k|{
  292|   347k|    return bstr_eatstart(s, bstr0(prefix));
  293|   347k|}
m_config_frontend.c:bstr_startswith:
  239|   119M|{
  240|   119M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 83.1M, False: 36.1M]
  ------------------
  241|  83.1M|        return false;
  242|  36.1M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   119M|}
m_config_frontend.c:bstr_endswith:
  251|   405k|{
  252|   405k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 0, False: 405k]
  ------------------
  253|      0|        return false;
  254|   405k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|   405k|}
m_config_frontend.c:bstr_equals0:
  276|  9.39M|{
  277|  9.39M|    return bstr_equals(str1, bstr0(str2));
  278|  9.39M|}
m_config_frontend.c:bstr_equals:
  268|  9.39M|{
  269|  9.39M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 8.61M, False: 782k]
  ------------------
  270|  8.61M|        return false;
  271|       |
  272|   782k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 28.9k, False: 753k]
  |  Branch (272:40): [True: 57.9k, False: 695k]
  ------------------
  273|  9.39M|}
m_config_frontend.c:bstrto0:
   46|  3.41M|{
   47|  3.41M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 3.41M, False: 0]
  ------------------
   48|  3.41M|}
m_config_frontend.c:bstrdup0:
   40|  3.41M|{
   41|  3.41M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  3.41M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  3.41M|}
m_option.c:bstr_equals0:
  276|  4.33M|{
  277|  4.33M|    return bstr_equals(str1, bstr0(str2));
  278|  4.33M|}
m_option.c:bstr_equals:
  268|  4.36M|{
  269|  4.36M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 3.15M, False: 1.20M]
  ------------------
  270|  3.15M|        return false;
  271|       |
  272|  1.20M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 202k, False: 1.00M]
  |  Branch (272:40): [True: 799k, False: 202k]
  ------------------
  273|  4.36M|}
m_option.c:bstr0:
   62|  11.8M|{
   63|  11.8M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 11.7M, False: 57.9k]
  ------------------
   64|  11.8M|}
m_option.c:bstrcasecmp0:
  281|  86.8k|{
  282|  86.8k|    return bstrcasecmp(str1, bstr0(str2));
  283|  86.8k|}
m_option.c:bstrcmp0:
  263|  1.99M|{
  264|  1.99M|    return bstrcmp(str1, bstr0(str2));
  265|  1.99M|}
m_option.c:bstr_eatstart0:
  291|  2.46M|{
  292|  2.46M|    return bstr_eatstart(s, bstr0(prefix));
  293|  2.46M|}
m_option.c:bstrdup0:
   40|   839k|{
   41|   839k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   839k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   839k|}
m_option.c:bstr_endswith0:
  258|  2.57M|{
  259|  2.57M|    return bstr_endswith(str, bstr0(suffix));
  260|  2.57M|}
m_option.c:bstr_endswith:
  251|  2.57M|{
  252|  2.57M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 926k, False: 1.65M]
  ------------------
  253|   926k|        return false;
  254|  1.65M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  2.57M|}
m_option.c:bstr_cut:
  227|   637k|{
  228|   637k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 637k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   637k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 86.8k, False: 550k]
  ------------------
  234|  86.8k|        n = str.len;
  235|   637k|    return (struct bstr){str.start + n, str.len - n};
  236|   637k|}
m_option.c:bstrdup:
   52|  86.8k|{
   53|  86.8k|    struct bstr r = { NULL, str.len };
   54|  86.8k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 86.8k, False: 0]
  ------------------
   55|  86.8k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  86.8k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  86.8k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  86.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  86.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  86.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  86.8k|    return r;
   57|  86.8k|}
m_option.c:bstrto0:
   46|   579k|{
   47|   579k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 579k, False: 0]
  ------------------
   48|   579k|}
m_property.c:bstrcmp0:
  263|  1.66M|{
  264|  1.66M|    return bstrcmp(str1, bstr0(str2));
  265|  1.66M|}
m_property.c:bstr0:
   62|  6.47M|{
   63|  6.47M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 6.47M, False: 0]
  ------------------
   64|  6.47M|}
m_property.c:bstr_eatstart0:
  291|  3.51M|{
  292|  3.51M|    return bstr_eatstart(s, bstr0(prefix));
  293|  3.51M|}
m_property.c:bstr_startswith0:
  246|   986k|{
  247|   986k|    return bstr_startswith(str, bstr0(prefix));
  248|   986k|}
m_property.c:bstr_startswith:
  239|   986k|{
  240|   986k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 61.6k, False: 924k]
  ------------------
  241|  61.6k|        return false;
  242|   924k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   986k|}
m_property.c:bstr_cut:
  227|  1.17M|{
  228|  1.17M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 1.17M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  1.17M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 1.17M]
  ------------------
  234|      0|        n = str.len;
  235|  1.17M|    return (struct bstr){str.start + n, str.len - n};
  236|  1.17M|}
m_property.c:bstrdup0:
   40|   184k|{
   41|   184k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   184k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   184k|}
parse_configfile.c:bstr_eatstart0:
  291|  7.78M|{
  292|  7.78M|    return bstr_eatstart(s, bstr0(prefix));
  293|  7.78M|}
parse_configfile.c:bstr0:
   62|  16.6M|{
   63|  16.6M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 16.6M, False: 0]
  ------------------
   64|  16.6M|}
parse_configfile.c:bstr_getline:
  156|  2.92M|{
  157|  2.92M|    return bstr_splitchar(str, rest, '\n');
  158|  2.92M|}
parse_configfile.c:bstr_startswith0:
  246|  8.83M|{
  247|  8.83M|    return bstr_startswith(str, bstr0(prefix));
  248|  8.83M|}
parse_configfile.c:bstr_startswith:
  239|  8.83M|{
  240|  8.83M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 2.57M, False: 6.25M]
  ------------------
  241|  2.57M|        return false;
  242|  6.25M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  8.83M|}
parse_configfile.c:bstrto0:
   46|   347k|{
   47|   347k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 347k, False: 0]
  ------------------
   48|   347k|}
parse_configfile.c:bstrdup0:
   40|   347k|{
   41|   347k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   347k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   347k|}
parse_configfile.c:bstr_cut:
  227|  23.0M|{
  228|  23.0M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 23.0M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  23.0M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 23.0M]
  ------------------
  234|      0|        n = str.len;
  235|  23.0M|    return (struct bstr){str.start + n, str.len - n};
  236|  23.0M|}
path.c:bstr0:
   62|  1.36M|{
   63|  1.36M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.30M, False: 57.9k]
  ------------------
   64|  1.36M|}
path.c:bstr_eatstart0:
  291|   279k|{
  292|   279k|    return bstr_eatstart(s, bstr0(prefix));
  293|   279k|}
path.c:bstr_equals0:
  276|   117k|{
  277|   117k|    return bstr_equals(str1, bstr0(str2));
  278|   117k|}
path.c:bstr_equals:
  268|   117k|{
  269|   117k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 117k, False: 159]
  ------------------
  270|   117k|        return false;
  271|       |
  272|    159|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 159]
  |  Branch (272:40): [True: 118, False: 41]
  ------------------
  273|   117k|}
external_files.c:bstr0:
   62|  43.6k|{
   63|  43.6k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 43.6k, False: 0]
  ------------------
   64|  43.6k|}
external_files.c:bstrdup:
   52|  21.8k|{
   53|  21.8k|    struct bstr r = { NULL, str.len };
   54|  21.8k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 21.8k, False: 0]
  ------------------
   55|  21.8k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  21.8k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  21.8k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  21.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  21.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  21.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  21.8k|    return r;
   57|  21.8k|}
external_files.c:bstrdup0:
   40|  21.8k|{
   41|  21.8k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  21.8k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  21.8k|}
vd_lavc.c:bstr0:
   62|  93.5k|{
   63|  93.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 93.5k, False: 0]
  ------------------
   64|  93.5k|}
vd_lavc.c:bstr_equals0:
  276|  85.7k|{
  277|  85.7k|    return bstr_equals(str1, bstr0(str2));
  278|  85.7k|}
vd_lavc.c:bstr_equals:
  268|  85.7k|{
  269|  85.7k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 77.9k, False: 7.79k]
  ------------------
  270|  77.9k|        return false;
  271|       |
  272|  7.79k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 7.79k]
  |  Branch (272:40): [True: 7.79k, False: 0]
  ------------------
  273|  85.7k|}
ad_dsd.c:bstr0:
   62|    127|{
   63|    127|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 127]
  ------------------
   64|    127|}
ad_spdif.c:bstr0:
   62|  3.35k|{
   63|  3.35k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 3.35k]
  ------------------
   64|  3.35k|}
cue.c:bstr_startswith0:
  246|  40.4k|{
  247|  40.4k|    return bstr_startswith(str, bstr0(prefix));
  248|  40.4k|}
cue.c:bstr_startswith:
  239|  40.4k|{
  240|  40.4k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 62, False: 40.3k]
  ------------------
  241|     62|        return false;
  242|  40.3k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  40.4k|}
cue.c:bstr_cut:
  227|  11.9k|{
  228|  11.9k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 11.9k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  11.9k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 11.9k]
  ------------------
  234|      0|        n = str.len;
  235|  11.9k|    return (struct bstr){str.start + n, str.len - n};
  236|  11.9k|}
cue.c:bstr_getline:
  156|  56.6k|{
  157|  56.6k|    return bstr_splitchar(str, rest, '\n');
  158|  56.6k|}
cue.c:bstr_find0:
  286|    225|{
  287|    225|    return bstr_find(haystack, bstr0(needle));
  288|    225|}
cue.c:bstr0:
   62|   654k|{
   63|   654k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 654k, False: 0]
  ------------------
   64|   654k|}
cue.c:bstr_eatstart0:
  291|    174|{
  292|    174|    return bstr_eatstart(s, bstr0(prefix));
  293|    174|}
cue.c:bstr_eatend0:
  296|    125|{
  297|    125|    return bstr_eatend(s, bstr0(prefix));
  298|    125|}
cue.c:bstrto0:
   46|  1.02k|{
   47|  1.02k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 1.02k, False: 0]
  ------------------
   48|  1.02k|}
cue.c:bstrdup0:
   40|  1.02k|{
   41|  1.02k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.02k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.02k|}

mp_charset_is_utf8:
   42|   587k|{
   43|   587k|    return user_cp && (strcasecmp(user_cp, "utf8") == 0 ||
  ------------------
  |  Branch (43:12): [True: 587k, False: 0]
  |  Branch (43:24): [True: 0, False: 587k]
  ------------------
   44|   587k|                       strcasecmp(user_cp, "utf-8") == 0);
  ------------------
  |  Branch (44:24): [True: 240k, False: 347k]
  ------------------
   45|   587k|}
mp_charset_is_utf16:
   48|  2.00k|{
   49|  2.00k|    bstr s = bstr0(user_cp);
   50|  2.00k|    return bstr_case_startswith(s, bstr0("utf16")) ||
  ------------------
  |  Branch (50:12): [True: 0, False: 2.00k]
  ------------------
   51|  2.00k|           bstr_case_startswith(s, bstr0("utf-16"));
  ------------------
  |  Branch (51:12): [True: 38, False: 1.96k]
  ------------------
   52|  2.00k|}
mp_charset_guess:
  103|   384k|{
  104|   384k|    if (user_cp[0] == '+') {
  ------------------
  |  Branch (104:9): [True: 0, False: 384k]
  ------------------
  105|      0|        mp_verbose(log, "Forcing charset '%s'.\n", user_cp + 1);
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  106|      0|        return user_cp + 1;
  107|      0|    }
  108|       |
  109|   384k|    const char *bom_cp = ms_bom_guess(buf);
  110|   384k|    if (bom_cp) {
  ------------------
  |  Branch (110:9): [True: 4.31k, False: 380k]
  ------------------
  111|  4.31k|        mp_verbose(log, "Data has a BOM, assuming %s as charset.\n", bom_cp);
  ------------------
  |  |   79|  4.31k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  112|  4.31k|        return bom_cp;
  113|  4.31k|    }
  114|       |
  115|   380k|    int r = bstr_validate_utf8(buf);
  116|   380k|    if (r >= 0 || (r > -8 && (flags & MP_ICONV_ALLOW_CUTOFF))) {
  ------------------
  |  Branch (116:9): [True: 235k, False: 144k]
  |  Branch (116:20): [True: 2.30k, False: 141k]
  |  Branch (116:30): [True: 0, False: 2.30k]
  ------------------
  117|   235k|        if (strcmp(user_cp, "auto") != 0 && !mp_charset_is_utf8(user_cp))
  ------------------
  |  Branch (117:13): [True: 0, False: 235k]
  |  Branch (117:45): [True: 0, False: 0]
  ------------------
  118|      0|            mp_verbose(log, "Data looks like UTF-8, ignoring user-provided charset.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  119|   235k|        return "utf-8";
  120|   235k|    }
  121|       |
  122|   144k|    const char *res = NULL;
  123|   144k|    if (strcasecmp(user_cp, "auto") == 0) {
  ------------------
  |  Branch (123:9): [True: 144k, False: 0]
  ------------------
  124|   144k|#if HAVE_UCHARDET
  125|   144k|        res = mp_uchardet(talloc_ctx, log, buf);
  126|   144k|#endif
  127|   144k|        if (!res) {
  ------------------
  |  Branch (127:13): [True: 14.2k, False: 130k]
  ------------------
  128|  14.2k|            mp_verbose(log, "Charset auto-detection failed.\n");
  ------------------
  |  |   79|  14.2k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  129|  14.2k|            res = "UTF-8-BROKEN";
  130|  14.2k|        }
  131|   144k|    } else {
  132|      0|        res = user_cp;
  133|      0|    }
  134|       |
  135|   144k|    mp_verbose(log, "Using charset '%s'.\n", res);
  ------------------
  |  |   79|   144k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  136|   144k|    return res;
  137|   380k|}
mp_iconv_to_utf8:
  151|   183k|{
  152|   183k|#if HAVE_ICONV
  153|   183k|    if (!buf.len)
  ------------------
  |  Branch (153:9): [True: 8.89k, False: 174k]
  ------------------
  154|  8.89k|        return buf;
  155|       |
  156|   174k|    if (!cp || !cp[0] || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (156:9): [True: 0, False: 174k]
  |  Branch (156:16): [True: 0, False: 174k]
  |  Branch (156:26): [True: 0, False: 174k]
  ------------------
  157|      0|        return buf;
  158|       |
  159|   174k|    if (strcasecmp(cp, "ASCII") == 0)
  ------------------
  |  Branch (159:9): [True: 0, False: 174k]
  ------------------
  160|      0|        return buf;
  161|       |
  162|   174k|    if (strcasecmp(cp, "UTF-8-BROKEN") == 0)
  ------------------
  |  Branch (162:9): [True: 15.3k, False: 159k]
  ------------------
  163|  15.3k|        return bstr_sanitize_utf8_latin1(NULL, buf);
  164|       |
  165|       |    // Force CP949 over EUC-KR since iconv distinguishes them and
  166|       |    // EUC-KR causes error on CP949 encoded data
  167|   159k|    if (strcasecmp(cp, "EUC-KR") == 0)
  ------------------
  |  Branch (167:9): [True: 0, False: 159k]
  ------------------
  168|      0|        cp = "CP949";
  169|       |
  170|   159k|    iconv_t icdsc;
  171|   159k|    if ((icdsc = iconv_open("UTF-8", cp)) == (iconv_t) (-1)) {
  ------------------
  |  Branch (171:9): [True: 21.5k, False: 137k]
  ------------------
  172|  21.5k|        if (flags & MP_ICONV_VERBOSE)
  ------------------
  |  Branch (172:13): [True: 0, False: 21.5k]
  ------------------
  173|      0|            mp_err(log, "Error opening iconv with codepage '%s'\n", cp);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  174|  21.5k|        goto failure;
  175|  21.5k|    }
  176|       |
  177|   137k|    size_t size = buf.len;
  178|   137k|    size_t osize = size;
  179|   137k|    size_t ileft = size;
  180|   137k|    size_t oleft = size - 1;
  181|       |
  182|   137k|    char *outbuf = talloc_size(NULL, osize);
  ------------------
  |  |   43|   137k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|   137k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|   137k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   137k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   137k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   137k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|   137k|    char *ip = buf.start;
  184|   137k|    char *op = outbuf;
  185|       |
  186|   446k|    while (1) {
  ------------------
  |  Branch (186:12): [True: 446k, Folded]
  ------------------
  187|   446k|        int clear = 0;
  188|   446k|        size_t rc;
  189|   446k|        if (ileft)
  ------------------
  |  Branch (189:13): [True: 315k, False: 130k]
  ------------------
  190|   315k|            rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
  191|   130k|        else {
  192|   130k|            clear = 1; // clear the conversion state and leave
  193|   130k|            rc = iconv(icdsc, NULL, NULL, &op, &oleft);
  194|   130k|        }
  195|   446k|        if (rc == (size_t) (-1)) {
  ------------------
  |  Branch (195:13): [True: 186k, False: 260k]
  ------------------
  196|   186k|            if (errno == E2BIG) {
  ------------------
  |  Branch (196:17): [True: 178k, False: 7.08k]
  ------------------
  197|   178k|                size_t offset = op - outbuf;
  198|   178k|                outbuf = talloc_realloc_size(NULL, outbuf, osize + size);
  ------------------
  |  |   39|   178k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|   178k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   178k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   178k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   178k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|   178k|                op = outbuf + offset;
  200|   178k|                osize += size;
  201|   178k|                oleft += size;
  202|   178k|            } else {
  203|  7.08k|                if (errno == EINVAL && (flags & MP_ICONV_ALLOW_CUTOFF)) {
  ------------------
  |  Branch (203:21): [True: 2.82k, False: 4.26k]
  |  Branch (203:40): [True: 0, False: 2.82k]
  ------------------
  204|       |                    // This is intended for cases where the input buffer is cut
  205|       |                    // at a random byte position. If this happens in the middle
  206|       |                    // of the buffer, it should still be an error. We say it's
  207|       |                    // fine if the error is within 10 bytes of the end.
  208|      0|                    if (ileft <= 10)
  ------------------
  |  Branch (208:25): [True: 0, False: 0]
  ------------------
  209|      0|                        break;
  210|      0|                }
  211|  7.08k|                if (flags & MP_ICONV_VERBOSE) {
  ------------------
  |  Branch (211:21): [True: 182, False: 6.90k]
  ------------------
  212|    182|                    mp_err(log, "Error recoding text with codepage '%s'\n", cp);
  ------------------
  |  |   76|    182|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  213|    182|                }
  214|  7.08k|                talloc_free(outbuf);
  ------------------
  |  |   47|  7.08k|#define talloc_free                     ta_free
  ------------------
  215|  7.08k|                iconv_close(icdsc);
  216|  7.08k|                goto failure;
  217|  7.08k|            }
  218|   260k|        } else if (clear)
  ------------------
  |  Branch (218:20): [True: 130k, False: 130k]
  ------------------
  219|   130k|            break;
  220|   446k|    }
  221|       |
  222|   130k|    iconv_close(icdsc);
  223|       |
  224|   130k|    outbuf[osize - oleft - 1] = 0;
  225|   130k|    return (bstr){outbuf, osize - oleft - 1};
  226|       |
  227|  28.6k|failure:
  228|  28.6k|#endif
  229|       |
  230|  28.6k|    if (flags & MP_NO_LATIN1_FALLBACK) {
  ------------------
  |  Branch (230:9): [True: 21.5k, False: 7.08k]
  ------------------
  231|  21.5k|        return buf;
  232|  21.5k|    } else {
  233|       |        return bstr_sanitize_utf8_latin1(NULL, buf);
  234|  7.08k|    }
  235|  28.6k|}
charset_conv.c:ms_bom_guess:
   58|   384k|{
   59|  1.52M|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (59:21): [True: 1.14M, False: 380k]
  ------------------
   60|  1.14M|        if (bstr_startswith0(buf, utf_bom[n]))
  ------------------
  |  Branch (60:13): [True: 4.31k, False: 1.14M]
  ------------------
   61|  4.31k|            return utf_enc[n];
   62|  1.14M|    }
   63|   380k|    return NULL;
   64|   384k|}
charset_conv.c:mp_uchardet:
   68|   144k|{
   69|   144k|    uchardet_t det = uchardet_new();
   70|   144k|    if (!det)
  ------------------
  |  Branch (70:9): [True: 0, False: 144k]
  ------------------
   71|      0|        return NULL;
   72|   144k|    if (uchardet_handle_data(det, buf.start, buf.len) != 0) {
  ------------------
  |  Branch (72:9): [True: 0, False: 144k]
  ------------------
   73|      0|        uchardet_delete(det);
   74|      0|        return NULL;
   75|      0|    }
   76|   144k|    uchardet_data_end(det);
   77|   144k|    char *res = talloc_strdup(talloc_ctx, uchardet_get_charset(det));
  ------------------
  |  |   50|   144k|#define talloc_strdup                   ta_xstrdup
  ------------------
   78|   144k|    if (res && !res[0])
  ------------------
  |  Branch (78:9): [True: 144k, False: 0]
  |  Branch (78:16): [True: 14.2k, False: 130k]
  ------------------
   79|  14.2k|        res = NULL;
   80|   144k|    if (res) {
  ------------------
  |  Branch (80:9): [True: 130k, False: 14.2k]
  ------------------
   81|   130k|        mp_verbose(log, "libuchardet detected charset as %s\n", res);
  ------------------
  |  |   79|   130k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   82|   130k|        iconv_t icdsc = iconv_open("UTF-8", res);
   83|   130k|        if (icdsc == (iconv_t)(-1)) {
  ------------------
  |  Branch (83:13): [True: 0, False: 130k]
  ------------------
   84|      0|            mp_warn(log, "Charset '%s' not supported by iconv.\n", res);
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
   85|      0|            res = NULL;
   86|   130k|        } else {
   87|   130k|            iconv_close(icdsc);
   88|   130k|        }
   89|   130k|    }
   90|   144k|    uchardet_delete(det);
   91|   144k|    return res;
   92|   144k|}

client.c:mp_isalnum:
   14|   202k|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 202k, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
client.c:mp_isalpha:
   13|   202k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 202k]
  |  Branch (13:64): [True: 202k, False: 0]
  ------------------
client.c:mp_isupper:
   10|   202k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 202k, False: 0]
  |  Branch (10:59): [True: 0, False: 202k]
  ------------------
client.c:mp_islower:
   11|   202k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 202k, False: 0]
  |  Branch (11:59): [True: 202k, False: 0]
  ------------------
demux_mf.c:mp_isdigit:
   12|     59|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 47, False: 12]
  |  Branch (12:59): [True: 28, False: 19]
  ------------------
bstr.c:mp_isspace:
    8|  12.7M|static inline int mp_isspace(char c) { return c == ' ' || c == '\f' || c == '\n' ||
  ------------------
  |  Branch (8:47): [True: 1.63M, False: 11.0M]
  |  Branch (8:59): [True: 3.81k, False: 11.0M]
  |  Branch (8:72): [True: 2.76k, False: 11.0M]
  ------------------
    9|  11.0M|                                              c == '\r' || c == '\t' || c =='\v'; }
  ------------------
  |  Branch (9:47): [True: 9.99k, False: 11.0M]
  |  Branch (9:60): [True: 9.88k, False: 11.0M]
  |  Branch (9:73): [True: 39.8k, False: 11.0M]
  ------------------
path_utils.c:mp_isalpha:
   13|  4.79M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 12.3k, False: 4.78M]
  |  Branch (13:64): [True: 4.74M, False: 38.8k]
  ------------------
path_utils.c:mp_isupper:
   10|  4.79M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 4.75M, False: 36.4k]
  |  Branch (10:59): [True: 12.3k, False: 4.74M]
  ------------------
path_utils.c:mp_islower:
   11|  4.78M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 4.74M, False: 37.0k]
  |  Branch (11:59): [True: 4.74M, False: 1.83k]
  ------------------
path_utils.c:mp_isalnum:
   14|  3.83M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 3.80M, False: 28.1k]
  |  Branch (14:64): [True: 4.24k, False: 23.9k]
  ------------------
path_utils.c:mp_isdigit:
   12|  28.1k|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 19.8k, False: 8.36k]
  |  Branch (12:59): [True: 4.24k, False: 15.5k]
  ------------------
parse_configfile.c:mp_isalnum:
   14|  24.9M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 21.0M, False: 3.85M]
  |  Branch (14:64): [True: 0, False: 3.85M]
  ------------------
parse_configfile.c:mp_isalpha:
   13|  24.9M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 24.9M]
  |  Branch (13:64): [True: 21.0M, False: 3.85M]
  ------------------
parse_configfile.c:mp_isupper:
   10|  24.9M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 21.0M, False: 3.85M]
  |  Branch (10:59): [True: 0, False: 21.0M]
  ------------------
parse_configfile.c:mp_islower:
   11|  24.9M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 21.0M, False: 3.85M]
  |  Branch (11:59): [True: 21.0M, False: 0]
  ------------------
parse_configfile.c:mp_isdigit:
   12|  3.85M|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 1.85M, False: 1.99M]
  |  Branch (12:59): [True: 0, False: 1.85M]
  ------------------

mp_dispatch_create:
   84|  38.5k|{
   85|  38.5k|    struct mp_dispatch_queue *queue = talloc_ptrtype(ta_parent, queue);
  ------------------
  |  |   34|  38.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  38.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  38.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|  38.5k|    *queue = (struct mp_dispatch_queue){0};
   87|  38.5k|    talloc_set_destructor(queue, queue_dtor);
  ------------------
  |  |   41|  38.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   88|  38.5k|    mp_mutex_init(&queue->lock);
   89|  38.5k|    mp_cond_init(&queue->cond);
   90|  38.5k|    return queue;
   91|  38.5k|}
mp_dispatch_set_wakeup_fn:
  105|  9.61k|{
  106|  9.61k|    queue->wakeup_fn = wakeup_fn;
  107|  9.61k|    queue->wakeup_ctx = wakeup_ctx;
  108|  9.61k|}
mp_dispatch_enqueue_autofree:
  186|  22.2k|{
  187|  22.2k|    struct mp_dispatch_item *item = talloc_ptrtype(NULL, item);
  ------------------
  |  |   34|  22.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  22.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  22.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|  22.2k|    *item = (struct mp_dispatch_item){
  189|  22.2k|        .fn = fn,
  190|  22.2k|        .fn_data = talloc_steal(item, fn_data),
  ------------------
  |  |   38|  22.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  22.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  191|       |        .asynchronous = true,
  192|  22.2k|    };
  193|  22.2k|    mp_dispatch_append(queue, item);
  194|  22.2k|}
mp_dispatch_cancel_fn:
  220|  38.5k|{
  221|  38.5k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  38.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  222|  38.5k|    struct mp_dispatch_item **pcur = &queue->head;
  223|  38.5k|    queue->tail = NULL;
  224|  38.5k|    while (*pcur) {
  ------------------
  |  Branch (224:12): [True: 0, False: 38.5k]
  ------------------
  225|      0|        struct mp_dispatch_item *cur = *pcur;
  226|      0|        if (cur->fn == fn && cur->fn_data == fn_data) {
  ------------------
  |  Branch (226:13): [True: 0, False: 0]
  |  Branch (226:30): [True: 0, False: 0]
  ------------------
  227|      0|            *pcur = cur->next;
  228|      0|            talloc_free(cur);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  229|      0|        } else {
  230|      0|            queue->tail = cur;
  231|      0|            pcur = &cur->next;
  232|      0|        }
  233|      0|    }
  234|  38.5k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  38.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  235|  38.5k|}
mp_dispatch_run:
  243|  55.6k|{
  244|  55.6k|    struct mp_dispatch_item item = {
  245|  55.6k|        .fn = fn,
  246|  55.6k|        .fn_data = fn_data,
  247|  55.6k|    };
  248|  55.6k|    mp_dispatch_append(queue, &item);
  249|       |
  250|  55.6k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  55.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  251|   111k|    while (!item.completed)
  ------------------
  |  Branch (251:12): [True: 55.5k, False: 55.6k]
  ------------------
  252|  55.5k|        mp_cond_wait(&queue->cond, &queue->lock);
  253|  55.6k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  55.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  254|  55.6k|}
mp_dispatch_queue_process:
  273|   621k|{
  274|   621k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   621k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  275|   621k|    queue->wait = timeout > 0 ? mp_time_ns_add(mp_time_ns(), timeout) : 0;
  ------------------
  |  Branch (275:19): [True: 443k, False: 178k]
  ------------------
  276|   621k|    mp_assert(!queue->in_process); // recursion not allowed
  ------------------
  |  |   41|   621k|#define mp_assert assert
  ------------------
  |  Branch (276:5): [True: 621k, False: 6]
  ------------------
  277|   621k|    queue->in_process = true;
  278|   621k|    queue->in_process_thread_id = mp_thread_current_id();
  ------------------
  |  |  217|   621k|#define mp_thread_current_id      pthread_self
  ------------------
  279|       |    // Wake up thread which called mp_dispatch_lock().
  280|   621k|    if (queue->lock_requests)
  ------------------
  |  Branch (280:9): [True: 44.8k, False: 576k]
  ------------------
  281|  44.8k|        mp_cond_broadcast(&queue->cond);
  282|  1.08M|    while (1) {
  ------------------
  |  Branch (282:12): [True: 1.08M, Folded]
  ------------------
  283|  1.08M|        if (queue->lock_requests) {
  ------------------
  |  Branch (283:13): [True: 141k, False: 947k]
  ------------------
  284|       |            // Block due to something having called mp_dispatch_lock().
  285|   141k|            mp_cond_wait(&queue->cond, &queue->lock);
  286|   947k|        } else if (queue->head) {
  ------------------
  |  Branch (286:20): [True: 77.9k, False: 869k]
  ------------------
  287|  77.9k|            struct mp_dispatch_item *item = queue->head;
  288|  77.9k|            queue->head = item->next;
  289|  77.9k|            if (!queue->head)
  ------------------
  |  Branch (289:17): [True: 71.0k, False: 6.91k]
  ------------------
  290|  71.0k|                queue->tail = NULL;
  291|  77.9k|            item->next = NULL;
  292|       |            // Unlock, because we want to allow other threads to queue items
  293|       |            // while the dispatch item is processed.
  294|       |            // At the same time, we must prevent other threads from returning
  295|       |            // from mp_dispatch_lock(), which is done by locked=true.
  296|  77.9k|            mp_assert(!queue->locked);
  ------------------
  |  |   41|  77.9k|#define mp_assert assert
  ------------------
  |  Branch (296:13): [True: 77.9k, False: 0]
  ------------------
  297|  77.9k|            queue->locked = true;
  298|  77.9k|            mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  77.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  299|       |
  300|  77.9k|            item->fn(item->fn_data);
  301|       |
  302|  77.9k|            mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  77.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  303|  77.9k|            mp_assert(queue->locked);
  ------------------
  |  |   41|  77.9k|#define mp_assert assert
  ------------------
  |  Branch (303:13): [True: 77.9k, False: 0]
  ------------------
  304|  77.9k|            queue->locked = false;
  305|       |            // Wakeup mp_dispatch_run(), also mp_dispatch_lock().
  306|  77.9k|            mp_cond_broadcast(&queue->cond);
  307|  77.9k|            if (item->asynchronous) {
  ------------------
  |  Branch (307:17): [True: 22.2k, False: 55.6k]
  ------------------
  308|  22.2k|                talloc_free(item);
  ------------------
  |  |   47|  22.2k|#define talloc_free                     ta_free
  ------------------
  309|  55.6k|            } else {
  310|  55.6k|                item->completed = true;
  311|  55.6k|            }
  312|   869k|        } else if (queue->wait > 0 && !queue->interrupted) {
  ------------------
  |  Branch (312:20): [True: 691k, False: 178k]
  |  Branch (312:39): [True: 247k, False: 443k]
  ------------------
  313|   247k|            if (mp_cond_timedwait_until(&queue->cond, &queue->lock, queue->wait))
  ------------------
  |  Branch (313:17): [True: 129, False: 247k]
  ------------------
  314|    129|                queue->wait = 0;
  315|   621k|        } else {
  316|   621k|            break;
  317|   621k|        }
  318|  1.08M|    }
  319|   621k|    mp_assert(!queue->locked);
  ------------------
  |  |   41|   621k|#define mp_assert assert
  ------------------
  |  Branch (319:5): [True: 621k, False: 18.4E]
  ------------------
  320|   621k|    queue->in_process = false;
  321|   621k|    queue->interrupted = false;
  322|   621k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   621k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  323|   621k|}
mp_dispatch_interrupt:
  332|  1.21M|{
  333|  1.21M|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  1.21M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  334|  1.21M|    queue->interrupted = true;
  335|  1.21M|    mp_cond_broadcast(&queue->cond);
  336|  1.21M|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  1.21M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  337|  1.21M|}
mp_dispatch_adjust_timeout:
  348|   617k|{
  349|   617k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   617k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  350|   617k|    if (queue->in_process && queue->wait > until) {
  ------------------
  |  Branch (350:9): [True: 0, False: 617k]
  |  Branch (350:30): [True: 0, False: 0]
  ------------------
  351|      0|        queue->wait = until;
  352|      0|        mp_cond_broadcast(&queue->cond);
  353|      0|    }
  354|   617k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   617k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  355|   617k|}
mp_dispatch_lock:
  365|   427k|{
  366|   427k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   427k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  367|       |    // Must not be called recursively from dispatched callbacks.
  368|   427k|    if (queue->in_process)
  ------------------
  |  Branch (368:9): [True: 382k, False: 44.8k]
  ------------------
  369|   427k|        mp_assert(!mp_thread_id_equal(queue->in_process_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (369:9): [True: 382k, False: 0]
  ------------------
  370|       |    // Must not be called recursively at all.
  371|   427k|    if (queue->locked_explicit)
  ------------------
  |  Branch (371:9): [True: 0, False: 427k]
  ------------------
  372|   427k|        mp_assert(!mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (372:9): [True: 0, False: 0]
  ------------------
  373|   427k|    queue->lock_requests += 1;
  374|       |    // And now wait until the target thread gets "trapped" within the
  375|       |    // mp_dispatch_queue_process() call, which will mean we get exclusive
  376|       |    // access to the target's thread state.
  377|   427k|    if (queue->onlock_fn)
  ------------------
  |  Branch (377:9): [True: 0, False: 427k]
  ------------------
  378|      0|        queue->onlock_fn(queue->onlock_ctx);
  379|   472k|    while (!queue->in_process) {
  ------------------
  |  Branch (379:12): [True: 44.9k, False: 427k]
  ------------------
  380|  44.9k|        mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  44.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  381|  44.9k|        if (queue->wakeup_fn)
  ------------------
  |  Branch (381:13): [True: 0, False: 44.9k]
  ------------------
  382|      0|            queue->wakeup_fn(queue->wakeup_ctx);
  383|  44.9k|        mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  44.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  384|  44.9k|        if (queue->in_process)
  ------------------
  |  Branch (384:13): [True: 56, False: 44.8k]
  ------------------
  385|     56|            break;
  386|  44.8k|        mp_cond_wait(&queue->cond, &queue->lock);
  387|  44.8k|    }
  388|       |    // Wait until we can get the lock.
  389|   427k|    while (!queue->in_process || queue->locked)
  ------------------
  |  Branch (389:12): [True: 0, False: 427k]
  |  Branch (389:34): [True: 0, False: 427k]
  ------------------
  390|      0|        mp_cond_wait(&queue->cond, &queue->lock);
  391|       |    // "Lock".
  392|   427k|    mp_assert(queue->lock_requests);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (392:5): [True: 427k, False: 0]
  ------------------
  393|   427k|    mp_assert(!queue->locked);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (393:5): [True: 427k, False: 0]
  ------------------
  394|   427k|    mp_assert(!queue->locked_explicit);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (394:5): [True: 427k, False: 0]
  ------------------
  395|   427k|    queue->locked = true;
  396|   427k|    queue->locked_explicit = true;
  397|   427k|    queue->locked_explicit_thread_id = mp_thread_current_id();
  ------------------
  |  |  217|   427k|#define mp_thread_current_id      pthread_self
  ------------------
  398|   427k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   427k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  399|   427k|}
mp_dispatch_unlock:
  403|   427k|{
  404|   427k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   427k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  405|   427k|    mp_assert(queue->locked);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (405:5): [True: 427k, False: 0]
  ------------------
  406|       |    // Must be called after a mp_dispatch_lock(), from the same thread.
  407|   427k|    mp_assert(queue->locked_explicit);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (407:5): [True: 427k, False: 0]
  ------------------
  408|   427k|    mp_assert(mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (408:5): [True: 427k, False: 0]
  ------------------
  409|       |    // "Unlock".
  410|   427k|    queue->locked = false;
  411|   427k|    queue->locked_explicit = false;
  412|   427k|    queue->lock_requests -= 1;
  413|       |    // Wakeup mp_dispatch_queue_process(), and maybe other mp_dispatch_lock()s.
  414|       |    // (Would be nice to wake up only 1 other locker if lock_requests>0.)
  415|   427k|    mp_cond_broadcast(&queue->cond);
  416|   427k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   427k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  417|   427k|}
dispatch.c:queue_dtor:
   64|  38.5k|{
   65|  38.5k|    struct mp_dispatch_queue *queue = p;
   66|  38.5k|    mp_assert(!queue->head);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (66:5): [True: 38.5k, False: 0]
  ------------------
   67|  38.5k|    mp_assert(!queue->in_process);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (67:5): [True: 38.5k, False: 0]
  ------------------
   68|  38.5k|    mp_assert(!queue->lock_requests);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (68:5): [True: 38.5k, False: 0]
  ------------------
   69|  38.5k|    mp_assert(!queue->locked);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (69:5): [True: 38.5k, False: 0]
  ------------------
   70|  38.5k|    mp_cond_destroy(&queue->cond);
   71|  38.5k|    mp_mutex_destroy(&queue->lock);
  ------------------
  |  |  133|  38.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   72|  38.5k|}
dispatch.c:mp_dispatch_append:
  128|  77.9k|{
  129|  77.9k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  77.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  130|  77.9k|    if (item->mergeable) {
  ------------------
  |  Branch (130:9): [True: 0, False: 77.9k]
  ------------------
  131|      0|        for (struct mp_dispatch_item *cur = queue->head; cur; cur = cur->next) {
  ------------------
  |  Branch (131:58): [True: 0, False: 0]
  ------------------
  132|      0|            if (cur->mergeable && cur->fn == item->fn &&
  ------------------
  |  Branch (132:17): [True: 0, False: 0]
  |  Branch (132:35): [True: 0, False: 0]
  ------------------
  133|      0|                cur->fn_data == item->fn_data)
  ------------------
  |  Branch (133:17): [True: 0, False: 0]
  ------------------
  134|      0|            {
  135|      0|                talloc_free(item);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  136|      0|                mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  137|      0|                return;
  138|      0|            }
  139|      0|        }
  140|      0|    }
  141|       |
  142|  77.9k|    if (queue->tail) {
  ------------------
  |  Branch (142:9): [True: 6.91k, False: 71.0k]
  ------------------
  143|  6.91k|        queue->tail->next = item;
  144|  71.0k|    } else {
  145|  71.0k|        queue->head = item;
  146|  71.0k|    }
  147|  77.9k|    queue->tail = item;
  148|       |
  149|       |    // Wake up the main thread; note that other threads might wait on this
  150|       |    // condition for reasons, so broadcast the condition.
  151|  77.9k|    mp_cond_broadcast(&queue->cond);
  152|       |    // No wakeup callback -> assume mp_dispatch_queue_process() needs to be
  153|       |    // interrupted instead.
  154|  77.9k|    if (!queue->wakeup_fn)
  ------------------
  |  Branch (154:9): [True: 0, False: 77.9k]
  ------------------
  155|      0|        queue->interrupted = true;
  156|  77.9k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  77.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  157|       |
  158|  77.9k|    if (queue->wakeup_fn)
  ------------------
  |  Branch (158:9): [True: 77.9k, False: 0]
  ------------------
  159|  77.9k|        queue->wakeup_fn(queue->wakeup_ctx);
  160|  77.9k|}

mp_hash_to_bstr:
   26|   136k|{
   27|   136k|    struct AVHashContext *ctx = NULL;
   28|   136k|    mp_require(av_hash_alloc(&ctx, algorithm) == 0);
  ------------------
  |  |   42|   136k|#define mp_require assert
  ------------------
  |  Branch (28:5): [True: 136k, False: 0]
  ------------------
   29|   136k|    int size = av_hash_get_size(ctx);
   30|   136k|    uint8_t hash[AV_HASH_MAX_SIZE] = {0};
   31|       |
   32|   136k|    av_hash_init(ctx);
   33|   136k|    av_hash_update(ctx, data, len);
   34|   136k|    av_hash_final(ctx, hash);
   35|   136k|    av_hash_freep(&ctx);
   36|       |
   37|   136k|    bstr ret = {0};
   38|  2.32M|    for (int n = 0; n < size; n++)
  ------------------
  |  Branch (38:21): [True: 2.18M, False: 136k]
  ------------------
   39|  2.18M|        bstr_xappend_asprintf(talloc_ctx, &ret, "%02X", hash[n]);
   40|   136k|    return ret;
   41|   136k|}

json_append:
  295|   173k|{
  296|   173k|    switch (src->format) {
  ------------------
  |  Branch (296:13): [True: 173k, False: 0]
  ------------------
  297|      0|    case MPV_FORMAT_NONE:
  ------------------
  |  Branch (297:5): [True: 0, False: 173k]
  ------------------
  298|      0|        APPEND(b, "null");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  299|      0|        return 0;
  300|      0|    case MPV_FORMAT_FLAG:
  ------------------
  |  Branch (300:5): [True: 0, False: 173k]
  ------------------
  301|      0|        APPEND(b, src->u.flag ? "true" : "false");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  |  |  ------------------
  |  |  |  Branch (248:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  302|      0|        return 0;
  303|      0|    case MPV_FORMAT_INT64:
  ------------------
  |  Branch (303:5): [True: 0, False: 173k]
  ------------------
  304|      0|        bstr_xappend_asprintf(NULL, b, "%"PRId64, src->u.int64);
  305|      0|        return 0;
  306|      0|    case MPV_FORMAT_DOUBLE: {
  ------------------
  |  Branch (306:5): [True: 0, False: 173k]
  ------------------
  307|      0|        const char *px = (isfinite(src->u.double_) || indent == 0) ? "" : "\"";
  ------------------
  |  Branch (307:27): [True: 0, False: 0]
  |  Branch (307:55): [True: 0, False: 0]
  ------------------
  308|      0|        bstr_xappend_asprintf(NULL, b, "%s%f%s", px, src->u.double_, px);
  309|      0|        return 0;
  310|      0|    }
  311|   173k|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (311:5): [True: 173k, False: 0]
  ------------------
  312|   173k|        if (indent == 0)
  ------------------
  |  Branch (312:13): [True: 0, False: 173k]
  ------------------
  313|      0|            APPEND(b, src->u.string);
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  314|   173k|        else
  315|   173k|            write_json_str(b, src->u.string);
  316|   173k|        return 0;
  317|      0|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (317:5): [True: 0, False: 173k]
  ------------------
  318|      0|    case MPV_FORMAT_NODE_MAP: {
  ------------------
  |  Branch (318:5): [True: 0, False: 173k]
  ------------------
  319|      0|        struct mpv_node_list *list = src->u.list;
  320|      0|        bool is_obj = src->format == MPV_FORMAT_NODE_MAP;
  321|      0|        APPEND(b, is_obj ? "{" : "[");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  |  |  ------------------
  |  |  |  Branch (248:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  322|      0|        int next_indent = indent >= 0 ? indent + 1 : -1;
  ------------------
  |  Branch (322:27): [True: 0, False: 0]
  ------------------
  323|      0|        for (int n = 0; n < list->num; n++) {
  ------------------
  |  Branch (323:25): [True: 0, False: 0]
  ------------------
  324|      0|            if (n)
  ------------------
  |  Branch (324:17): [True: 0, False: 0]
  ------------------
  325|      0|                APPEND(b, ",");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  326|      0|            add_indent(b, next_indent);
  327|      0|            if (is_obj) {
  ------------------
  |  Branch (327:17): [True: 0, False: 0]
  ------------------
  328|      0|                write_json_str(b, list->keys[n]);
  329|      0|                APPEND(b, ":");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  330|      0|            }
  331|      0|            json_append(b, &list->values[n], next_indent);
  332|      0|        }
  333|      0|        add_indent(b, indent);
  334|      0|        APPEND(b, is_obj ? "}" : "]");
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  |  |  ------------------
  |  |  |  Branch (248:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  335|      0|        return 0;
  336|      0|    }
  337|   173k|    }
  338|      0|    return -1; // unknown format
  339|   173k|}
json_write:
  355|   173k|{
  356|   173k|    return json_append_str(dst, src, -1);
  357|   173k|}
json.c:write_json_str:
  259|   173k|{
  260|   173k|    mp_assert(str);
  ------------------
  |  |   41|   173k|#define mp_assert assert
  ------------------
  |  Branch (260:5): [True: 173k, False: 0]
  ------------------
  261|       |
  262|   173k|    APPEND(b, "\"");
  ------------------
  |  |  248|   173k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  263|  37.8M|    while (1) {
  ------------------
  |  Branch (263:12): [True: 37.8M, Folded]
  ------------------
  264|  37.8M|        unsigned char *cur = str;
  265|   182M|        while (cur[0] >= 32 && cur[0] != '"' && cur[0] != '\\')
  ------------------
  |  Branch (265:16): [True: 145M, False: 37.2M]
  |  Branch (265:32): [True: 145M, False: 322k]
  |  Branch (265:49): [True: 144M, False: 223k]
  ------------------
  266|   144M|            cur++;
  267|  37.8M|        if (!cur[0])
  ------------------
  |  Branch (267:13): [True: 173k, False: 37.6M]
  ------------------
  268|   173k|            break;
  269|  37.6M|        bstr_xappend(NULL, b, (bstr){str, cur - str});
  270|  37.6M|        if (cur[0] == '\"') {
  ------------------
  |  Branch (270:13): [True: 322k, False: 37.3M]
  ------------------
  271|   322k|            bstr_xappend(NULL, b, (bstr){"\\\"", 2});
  272|  37.3M|        } else if (cur[0] == '\\') {
  ------------------
  |  Branch (272:20): [True: 223k, False: 37.0M]
  ------------------
  273|   223k|            bstr_xappend(NULL, b, (bstr){"\\\\", 2});
  274|  37.0M|        } else if (cur[0] < sizeof(special_escape) && special_escape[cur[0]]) {
  ------------------
  |  Branch (274:20): [True: 22.1M, False: 14.9M]
  |  Branch (274:55): [True: 10.9M, False: 11.1M]
  ------------------
  275|  10.9M|            bstr_xappend_asprintf(NULL, b, "\\%c", special_escape[cur[0]]);
  276|  26.0M|        } else {
  277|  26.0M|            bstr_xappend_asprintf(NULL, b, "\\u%04x", (unsigned char)cur[0]);
  278|  26.0M|        }
  279|  37.6M|        str = cur + 1;
  280|  37.6M|    }
  281|   173k|    APPEND(b, str);
  ------------------
  |  |  248|   173k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  282|       |    APPEND(b, "\"");
  ------------------
  |  |  248|   173k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  283|   173k|}
json.c:json_append_str:
  342|   173k|{
  343|   173k|    bstr buffer = bstr0(*dst);
  344|   173k|    int r = json_append(&buffer, src, indent);
  345|   173k|    *dst = buffer.start;
  346|   173k|    return r;
  347|   173k|}

mp_match_lang:
  255|  4.25k|{
  256|  4.25k|    if (!lang)
  ------------------
  |  Branch (256:9): [True: 4.25k, False: 0]
  ------------------
  257|  4.25k|        return 0;
  258|       |
  259|      0|    void *ta_ctx = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  260|      0|    int lang_parts_n = 0;
  261|      0|    bstr *lang_parts = NULL;
  262|      0|    bstr rest = bstr0(lang);
  263|      0|    while (rest.len) {
  ------------------
  |  Branch (263:12): [True: 0, False: 0]
  ------------------
  264|      0|        bstr s = bstr_split(rest, "-", &rest);
  265|      0|        MP_TARRAY_APPEND(ta_ctx, lang_parts, lang_parts_n, s);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  266|      0|    }
  267|       |
  268|      0|    int best_score = 0;
  269|      0|    if (!lang_parts_n)
  ------------------
  |  Branch (269:9): [True: 0, False: 0]
  ------------------
  270|      0|        goto done;
  271|       |
  272|      0|    for (int idx = 0; langs && langs[idx]; idx++) {
  ------------------
  |  Branch (272:23): [True: 0, False: 0]
  |  Branch (272:32): [True: 0, False: 0]
  ------------------
  273|      0|        rest = bstr0(langs[idx]);
  274|      0|        int part = 0;
  275|      0|        int score = 0;
  276|      0|        while (rest.len) {
  ------------------
  |  Branch (276:16): [True: 0, False: 0]
  ------------------
  277|      0|            bstr s = bstr_split(rest, "-", &rest);
  278|      0|            if (!part) {
  ------------------
  |  Branch (278:17): [True: 0, False: 0]
  ------------------
  279|      0|                if (bstrcasecmp(canonicalize(lang_parts[0]), canonicalize(s)))
  ------------------
  |  Branch (279:21): [True: 0, False: 0]
  ------------------
  280|      0|                    break;
  281|      0|                score = INT_MAX - idx;
  282|      0|                part++;
  283|      0|                continue;
  284|      0|            }
  285|       |
  286|      0|            if (part >= lang_parts_n)
  ------------------
  |  Branch (286:17): [True: 0, False: 0]
  ------------------
  287|      0|                break;
  288|       |
  289|      0|            if (bstrcasecmp(lang_parts[part], s))
  ------------------
  |  Branch (289:17): [True: 0, False: 0]
  ------------------
  290|      0|                score -= 1000;
  291|       |
  292|      0|            part++;
  293|      0|        }
  294|      0|        score -= (lang_parts_n - part) * 1000;
  295|      0|        best_score = MPMAX(best_score, score);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  296|      0|    }
  297|       |
  298|      0|done:
  299|      0|    talloc_free(ta_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  300|      0|    return best_score;
  301|      0|}

node_init:
   13|   115k|{
   14|       |    // Other formats need to be initialized manually.
   15|   115k|    mp_assert(format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY ||
  ------------------
  |  |   41|   115k|#define mp_assert assert
  ------------------
  |  Branch (15:5): [True: 57.9k, False: 57.9k]
  |  Branch (15:5): [True: 28.9k, False: 28.9k]
  |  Branch (15:5): [True: 0, False: 28.9k]
  |  Branch (15:5): [True: 28.9k, False: 0]
  |  Branch (15:5): [True: 0, False: 0]
  |  Branch (15:5): [True: 0, False: 0]
  |  Branch (15:5): [True: 0, False: 0]
  ------------------
   16|   115k|           format == MPV_FORMAT_FLAG || format == MPV_FORMAT_INT64 ||
   17|   115k|           format == MPV_FORMAT_DOUBLE || format == MPV_FORMAT_BYTE_ARRAY ||
   18|   115k|           format == MPV_FORMAT_NONE);
   19|       |
   20|   115k|    void *ta_parent = NULL;
   21|   115k|    if (parent) {
  ------------------
  |  Branch (21:9): [True: 28.9k, False: 86.8k]
  ------------------
   22|  28.9k|        mp_assert(parent->format == MPV_FORMAT_NODE_MAP ||
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (22:9): [True: 28.9k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  ------------------
   23|  28.9k|               parent->format == MPV_FORMAT_NODE_ARRAY);
   24|  28.9k|        ta_parent = parent->u.list;
   25|  28.9k|    }
   26|       |
   27|   115k|    *dst = (struct mpv_node){ .format = format };
   28|   115k|    if (format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY)
  ------------------
  |  Branch (28:9): [True: 57.9k, False: 57.9k]
  |  Branch (28:42): [True: 28.9k, False: 28.9k]
  ------------------
   29|  86.8k|        dst->u.list = talloc_zero(ta_parent, struct mpv_node_list);
  ------------------
  |  |   27|  86.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  86.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  86.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   30|   115k|    if (format == MPV_FORMAT_BYTE_ARRAY)
  ------------------
  |  Branch (30:9): [True: 0, False: 115k]
  ------------------
   31|      0|        dst->u.ba = talloc_zero(ta_parent, struct mpv_byte_array);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   32|   115k|}
node_map_add:
   49|  28.9k|{
   50|  28.9k|    mp_assert(key);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (50:5): [True: 28.9k, False: 0]
  ------------------
   51|  28.9k|    return node_map_badd(dst, bstr0(key), format);
   52|  28.9k|}
node_map_badd:
   55|  28.9k|{
   56|  28.9k|    mp_assert(key.start);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 28.9k, False: 0]
  ------------------
   57|       |
   58|  28.9k|    struct mpv_node_list *list = dst->u.list;
   59|  28.9k|    mp_assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (59:5): [True: 28.9k, False: 0]
  |  Branch (59:5): [True: 28.9k, False: 0]
  ------------------
   60|  28.9k|    MP_TARRAY_GROW(list, list->values, list->num);
  ------------------
  |  |   96|  28.9k|    do {                                            \
  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
   61|  28.9k|    MP_TARRAY_GROW(list, list->keys, list->num);
  ------------------
  |  |   96|  28.9k|    do {                                            \
  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
   62|  28.9k|    list->keys[list->num] = bstrdup0(list, key);
   63|  28.9k|    node_init(&list->values[list->num], format, dst);
   64|  28.9k|    return &list->values[list->num++];
   65|  28.9k|}
node_map_add_int64:
   89|  28.9k|{
   90|  28.9k|    node_map_add(dst, key, MPV_FORMAT_INT64)->u.int64 = v;
   91|  28.9k|}

mp_basename_bstr:
   43|   766k|{
   44|   766k|    int separator_pos;
   45|       |
   46|       |#if HAVE_DOS_PATHS
   47|       |    if (!mp_is_url(path)) {
   48|       |        separator_pos = bstrrchr(path, '\\');
   49|       |        if (separator_pos >= 0)
   50|       |            path = bstr_splice(path, separator_pos + 1, path.len);
   51|       |        separator_pos = bstrrchr(path, ':');
   52|       |        if (separator_pos >= 0)
   53|       |            path = bstr_splice(path, separator_pos + 1, path.len);
   54|       |    }
   55|       |#endif
   56|   766k|    separator_pos = bstrrchr(path, '/');
   57|   766k|    if (separator_pos < 0)
  ------------------
  |  Branch (57:9): [True: 24.6k, False: 741k]
  ------------------
   58|  24.6k|        return path;
   59|   741k|    return bstr_splice(path, separator_pos + 1, path.len);
   60|   766k|}
mp_basename:
   63|   659k|{
   64|   659k|    return mp_basename_bstr(bstr0(path)).start;
   65|   659k|}
mp_dirname:
   68|  21.8k|{
   69|  21.8k|    struct bstr ret = {
   70|  21.8k|        (uint8_t *)path, mp_basename(path) - path
   71|  21.8k|    };
   72|  21.8k|    if (ret.len == 0)
  ------------------
  |  Branch (72:9): [True: 0, False: 21.8k]
  ------------------
   73|      0|        return bstr0(".");
   74|  21.8k|    return ret;
   75|  21.8k|}
mp_strip_ext:
  114|  21.8k|{
  115|  21.8k|    bstr root = {0};
  116|  21.8k|    split_ext(path, &root);
  117|  21.8k|    return root.len ? root : path;
  ------------------
  |  Branch (117:12): [True: 6.96k, False: 14.8k]
  ------------------
  118|  21.8k|}
mp_get_ext:
  121|  85.2k|{
  122|       |    return split_ext(path, NULL);
  123|  85.2k|}
mp_path_is_absolute:
  126|   279k|{
  127|   279k|    if (path.len && strchr(mp_path_separators, path.start[0]))
  ------------------
  |  Branch (127:9): [True: 279k, False: 0]
  |  Branch (127:21): [True: 94.7k, False: 184k]
  ------------------
  128|  94.7k|        return true;
  129|       |
  130|       |#if HAVE_DOS_PATHS
  131|       |    // Note: "X:filename" is a path relative to the current working directory
  132|       |    //       of drive X, and thus is not an absolute path. It needs to be
  133|       |    //       followed by \ or /.
  134|       |    if (path.len >= 3 && path.start[1] == ':' &&
  135|       |        strchr(mp_path_separators, path.start[2]))
  136|       |        return true;
  137|       |#endif
  138|       |
  139|   184k|    return false;
  140|   279k|}
mp_path_join_bstr:
  143|   150k|{
  144|   150k|    if (p1.len == 0)
  ------------------
  |  Branch (144:9): [True: 57.9k, False: 92.3k]
  ------------------
  145|  57.9k|        return bstrdup0(talloc_ctx, p2);
  146|  92.3k|    if (p2.len == 0)
  ------------------
  |  Branch (146:9): [True: 0, False: 92.3k]
  ------------------
  147|      0|        return bstrdup0(talloc_ctx, p1);
  148|       |
  149|  92.3k|    if (mp_path_is_absolute(p2))
  ------------------
  |  Branch (149:9): [True: 116, False: 92.2k]
  ------------------
  150|    116|        return bstrdup0(talloc_ctx, p2);
  151|       |
  152|  92.3k|    bool have_separator = strchr(mp_path_separators, p1.start[p1.len - 1]);
  153|       |#if HAVE_DOS_PATHS
  154|       |    // "X:" only => path relative to "X:" current working directory.
  155|       |    if (p1.len == 2 && p1.start[1] == ':')
  156|       |        have_separator = true;
  157|       |#endif
  158|       |
  159|  92.2k|    return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1),
  ------------------
  |  |   52|  92.2k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   553k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 92.2k, False: 0]
  |  |  |  |  |  Branch (127:62): [True: 0, False: 92.2k]
  |  |  |  |  |  Branch (127:62): [True: 92.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|  92.3k|                           have_separator ? "" : "/", BSTR_P(p2));
  161|  92.3k|}
mp_path_join:
  164|  92.2k|{
  165|  92.2k|    return mp_path_join_bstr(talloc_ctx, bstr0(p1), bstr0(p2));
  166|  92.2k|}
mp_getcwd:
  169|  92.2k|{
  170|  92.2k|#if !HAVE_DOS_PATHS
  171|  92.2k|    char *e_wd = getenv("PWD");
  172|  92.2k|    struct stat pwd_st, dot_st;
  173|  92.2k|    if (e_wd && mp_path_is_absolute(bstr0(e_wd)) &&
  ------------------
  |  Branch (173:9): [True: 92.2k, False: 0]
  |  Branch (173:17): [True: 92.2k, False: 0]
  ------------------
  174|  92.2k|        stat(e_wd, &pwd_st) == 0 && stat(".", &dot_st) == 0 &&
  ------------------
  |  Branch (174:9): [True: 92.2k, False: 0]
  |  Branch (174:37): [True: 92.2k, False: 0]
  ------------------
  175|  92.2k|        pwd_st.st_dev == dot_st.st_dev && pwd_st.st_ino == dot_st.st_ino)
  ------------------
  |  Branch (175:9): [True: 92.2k, False: 0]
  |  Branch (175:43): [True: 92.2k, False: 0]
  ------------------
  176|  92.2k|        return talloc_strdup(talloc_ctx, e_wd);
  ------------------
  |  |   50|  92.2k|#define talloc_strdup                   ta_xstrdup
  ------------------
  177|      0|#endif
  178|       |
  179|      0|    char *wd = talloc_array(talloc_ctx, char, 20);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|      0|    while (getcwd(wd, talloc_get_size(wd)) == NULL) {
  ------------------
  |  |   45|      0|#define talloc_get_size                 ta_get_size
  ------------------
  |  Branch (180:12): [True: 0, False: 0]
  ------------------
  181|      0|        if (errno != ERANGE) {
  ------------------
  |  Branch (181:13): [True: 0, False: 0]
  ------------------
  182|      0|            talloc_free(wd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  183|      0|            return NULL;
  184|      0|        }
  185|      0|        wd = talloc_realloc(talloc_ctx, wd, char, talloc_get_size(wd) * 2);
  ------------------
  |  |   33|      0|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|      0|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|      0|    }
  187|      0|    return wd;
  188|      0|}
mp_normalize_path:
  191|   133k|{
  192|   133k|    if (!path)
  ------------------
  |  Branch (192:9): [True: 0, False: 133k]
  ------------------
  193|      0|        return NULL;
  194|       |
  195|   133k|    if (!path[0] || mp_is_url(bstr0(path)) || !strcmp(path, "-"))
  ------------------
  |  Branch (195:9): [True: 947, False: 132k]
  |  Branch (195:21): [True: 37.4k, False: 95.5k]
  |  Branch (195:47): [True: 872, False: 94.6k]
  ------------------
  196|  39.2k|        return talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|  39.2k|#define talloc_strdup                   ta_xstrdup
  ------------------
  197|       |
  198|  94.6k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  94.6k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  94.6k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  199|  94.6k|    char *result;
  200|       |
  201|       |#if HAVE_DOS_PATHS
  202|       |    wchar_t *pathw = mp_from_utf8(tmp, path);
  203|       |    DWORD len = GetFullPathNameW(pathw, 0, NULL, NULL);
  204|       |    wchar_t *pathc = talloc_array(tmp, wchar_t, len);
  205|       |    if (!len || !GetFullPathNameW(pathw, len, pathc, NULL)) {
  206|       |        result = talloc_strdup(talloc_ctx, path);
  207|       |        goto exit;
  208|       |    }
  209|       |    // PathAllocCanonicalize() treats the "." of a \\.\ path as a directory and
  210|       |    // removes it, so skip it for device paths.
  211|       |    wchar_t *pathx = NULL;
  212|       |    if (wcsncmp(pathc, L"\\\\.\\", 4) &&
  213|       |        SUCCEEDED(PathAllocCanonicalize(pathc, PATHCCH_ALLOW_LONG_PATHS, &pathx)))
  214|       |        pathc = pathx;
  215|       |    result = mp_to_utf8(talloc_ctx, pathc);
  216|       |    LocalFree(pathx);
  217|       |#else
  218|  94.6k|    if (!mp_path_is_absolute(bstr0(path))) {
  ------------------
  |  Branch (218:9): [True: 92.2k, False: 2.38k]
  ------------------
  219|  92.2k|        char *cwd = mp_getcwd(tmp);
  220|  92.2k|        if (!cwd) {
  ------------------
  |  Branch (220:13): [True: 0, False: 92.2k]
  ------------------
  221|      0|            result = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  222|      0|            goto exit;
  223|      0|        }
  224|  92.2k|        path = mp_path_join(tmp, cwd, path);
  225|  92.2k|    }
  226|       |
  227|  94.6k|    result = talloc_strdup(tmp, "");
  ------------------
  |  |   50|  94.6k|#define talloc_strdup                   ta_xstrdup
  ------------------
  228|  94.6k|    const char *next;
  229|  94.6k|    const char *end = path + strlen(path);
  230|       |
  231|   617k|    for (const char *ptr = path; ptr < end; ptr = next + 1) {
  ------------------
  |  Branch (231:34): [True: 522k, False: 94.4k]
  ------------------
  232|   522k|        next = memchr(ptr, '/', end - ptr);
  233|   522k|        if (next == NULL)
  ------------------
  |  Branch (233:13): [True: 93.7k, False: 429k]
  ------------------
  234|  93.7k|            next = end;
  235|       |
  236|   522k|        switch (next - ptr) {
  ------------------
  |  Branch (236:17): [True: 129k, False: 393k]
  ------------------
  237|   114k|            case 0:
  ------------------
  |  Branch (237:13): [True: 114k, False: 407k]
  ------------------
  238|   114k|                continue;
  239|  8.09k|            case 1:
  ------------------
  |  Branch (239:13): [True: 8.09k, False: 514k]
  ------------------
  240|  8.09k|                if (ptr[0] == '.')
  ------------------
  |  Branch (240:21): [True: 395, False: 7.69k]
  ------------------
  241|    395|                    continue;
  242|  7.69k|                break;
  243|  7.69k|            case 2:
  ------------------
  |  Branch (243:13): [True: 6.18k, False: 516k]
  ------------------
  244|       |                // Normalizing symlink/.. results in a wrong path: if the
  245|       |                // current working directory is /tmp/foo, and it is a symlink to
  246|       |                // /usr/bin, mpv ../file.mkv opens /usr/file.mkv, so we can't
  247|       |                // normalize the path to /tmp/file.mkv. Resolve symlinks to fix
  248|       |                // this. Otherwise we don't use realpath so users can use
  249|       |                // symlinks e.g. to hide how media files are distributed over
  250|       |                // real storage and move them while still resuming playback as
  251|       |                // long as the symlinked path doesn't change.
  252|  6.18k|                if (ptr[0] == '.' && ptr[1] == '.') {
  ------------------
  |  Branch (252:21): [True: 939, False: 5.24k]
  |  Branch (252:38): [True: 228, False: 711]
  ------------------
  253|    228|                    char *tmp_result = realpath(path, NULL);
  254|    228|                    result = talloc_strdup(talloc_ctx,
  ------------------
  |  |   50|    228|#define talloc_strdup                   ta_xstrdup
  ------------------
  255|    228|                                           tmp_result ? tmp_result : path);
  ------------------
  |  Branch (255:44): [True: 148, False: 80]
  ------------------
  256|    228|                    free(tmp_result);
  257|    228|                    goto exit;
  258|    228|                }
  259|   522k|        }
  260|       |
  261|   407k|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|   407k|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  262|   407k|        result = talloc_strndup_append_buffer(result, ptr, next - ptr);
  ------------------
  |  |   60|   407k|#define talloc_strndup_append_buffer    ta_talloc_strndup_append_buffer
  ------------------
  263|   407k|    }
  264|       |
  265|  94.4k|    if (!result[0])
  ------------------
  |  Branch (265:9): [True: 81, False: 94.3k]
  ------------------
  266|     81|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|     81|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  267|       |
  268|  94.4k|    result = talloc_steal(talloc_ctx, result);
  ------------------
  |  |   38|  94.4k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  94.4k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  269|  94.4k|#endif
  270|       |
  271|  94.6k|exit:
  272|  94.6k|    talloc_free(tmp);
  ------------------
  |  |   47|  94.6k|#define talloc_free                     ta_free
  ------------------
  273|  94.6k|    return result;
  274|  94.4k|}
mp_path_exists:
  277|  3.24k|{
  278|  3.24k|    struct stat st;
  279|  3.24k|    return path && stat(path, &st) == 0;
  ------------------
  |  Branch (279:12): [True: 3.24k, False: 0]
  |  Branch (279:20): [True: 51, False: 3.19k]
  ------------------
  280|  3.24k|}
mp_is_url:
  290|  1.24M|{
  291|  1.24M|    int proto = bstr_find0(path, "://");
  292|  1.24M|    if (proto < 1)
  ------------------
  |  Branch (292:9): [True: 280k, False: 961k]
  ------------------
  293|   280k|        return false;
  294|       |    // Per RFC3986, the first character of the protocol must be alphabetic.
  295|       |    // The rest must be alphanumeric plus -, + and .
  296|  4.77M|    for (int i = 0; i < proto; i++) {
  ------------------
  |  Branch (296:21): [True: 3.84M, False: 930k]
  ------------------
  297|  3.84M|        unsigned char c = path.start[i];
  298|  3.84M|        if ((i == 0 && !mp_isalpha(c)) ||
  ------------------
  |  Branch (298:14): [True: 961k, False: 2.88M]
  |  Branch (298:24): [True: 10.7k, False: 950k]
  ------------------
  299|  3.83M|            (!mp_isalnum(c) && c != '.' && c != '-' && c != '+'))
  ------------------
  |  Branch (299:14): [True: 23.9k, False: 3.80M]
  |  Branch (299:32): [True: 22.7k, False: 1.22k]
  |  Branch (299:44): [True: 21.5k, False: 1.21k]
  |  Branch (299:56): [True: 20.2k, False: 1.21k]
  ------------------
  300|  30.9k|        {
  301|  30.9k|            return false;
  302|  30.9k|        }
  303|  3.84M|    }
  304|   930k|    return true;
  305|   961k|}
mp_split_proto:
  310|   331k|{
  311|   331k|    if (!mp_is_url(path))
  ------------------
  |  Branch (311:9): [True: 116k, False: 215k]
  ------------------
  312|   116k|        return (bstr){0};
  313|   215k|    bstr r;
  314|   215k|    bstr_split_tok(path, "://", &r, out_url ? out_url : &(bstr){0});
  ------------------
  |  Branch (314:37): [True: 38.1k, False: 177k]
  ------------------
  315|   215k|    return r;
  316|   331k|}
path_utils.c:split_ext:
   97|   107k|{
   98|   107k|    bstr basename = mp_basename_bstr(path);
   99|       |
  100|       |    // Skip all leading dots, not just for "hidden" unix files, otherwise we
  101|       |    // end up splitting a part of the filename sans leading dot.
  102|   107k|    basename = bstr_splice(basename, bstrspn(basename, "."), basename.len);
  103|       |
  104|   107k|    int dot_pos = bstrrchr(basename, '.');
  105|   107k|    if (dot_pos < 0 || dot_pos == basename.len - 1)
  ------------------
  |  Branch (105:9): [True: 80.6k, False: 26.3k]
  |  Branch (105:24): [True: 409, False: 25.9k]
  ------------------
  106|  81.0k|        return (bstr){0};
  107|  25.9k|    bstr ext = bstr_splice(basename, dot_pos + 1, basename.len);
  108|  25.9k|    if (root)
  ------------------
  |  Branch (108:9): [True: 6.96k, False: 18.9k]
  ------------------
  109|  6.96k|        *root = (bstr){path.start, ext.start - 1 - path.start};
  110|  25.9k|    return ext;
  111|   107k|}

mp_rendezvous:
   33|  19.2k|{
   34|  19.2k|    struct waiter wait = { .tag = tag, .value = &value };
   35|  19.2k|    mp_mutex_lock(&lock);
  ------------------
  |  |  134|  19.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   36|  19.2k|    struct waiter **prev = &waiters;
   37|  19.2k|    while (*prev) {
  ------------------
  |  Branch (37:12): [True: 9.61k, False: 9.61k]
  ------------------
   38|  9.61k|        if ((*prev)->tag == tag) {
  ------------------
  |  Branch (38:13): [True: 9.61k, False: 0]
  ------------------
   39|  9.61k|            intptr_t tmp = *(*prev)->value;
   40|  9.61k|            *(*prev)->value = value;
   41|  9.61k|            value = tmp;
   42|  9.61k|            (*prev)->value = NULL; // signals completion
   43|  9.61k|            *prev = (*prev)->next; // unlink
   44|  9.61k|            mp_cond_broadcast(&wakeup);
   45|  9.61k|            goto done;
   46|  9.61k|        }
   47|      0|        prev = &(*prev)->next;
   48|      0|    }
   49|  9.61k|    *prev = &wait;
   50|  19.2k|    while (wait.value)
  ------------------
  |  Branch (50:12): [True: 9.61k, False: 9.61k]
  ------------------
   51|  9.61k|        mp_cond_wait(&wakeup, &lock);
   52|  19.2k|done:
   53|  19.2k|    mp_mutex_unlock(&lock);
  ------------------
  |  |  136|  19.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   54|  19.2k|    return value;
   55|  9.61k|}

mp_thread_pool_create:
  155|  28.9k|{
  156|  28.9k|    mp_assert(min_threads >= 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (156:5): [True: 28.9k, False: 0]
  ------------------
  157|  28.9k|    mp_assert(init_threads <= min_threads);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (157:5): [True: 28.9k, False: 0]
  ------------------
  158|  28.9k|    mp_assert(max_threads > 0 && max_threads >= min_threads);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (158:5): [True: 28.9k, False: 0]
  |  Branch (158:5): [True: 28.9k, False: 0]
  ------------------
  159|       |
  160|  28.9k|    struct mp_thread_pool *pool = talloc_zero(ta_parent, struct mp_thread_pool);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|  28.9k|    talloc_set_destructor(pool, thread_pool_dtor);
  ------------------
  |  |   41|  28.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  162|       |
  163|  28.9k|    mp_mutex_init(&pool->lock);
  164|  28.9k|    mp_cond_init(&pool->wakeup);
  165|       |
  166|  28.9k|    pool->min_threads = min_threads;
  167|  28.9k|    pool->max_threads = max_threads;
  168|       |
  169|  28.9k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  170|  28.9k|    for (int n = 0; n < init_threads; n++)
  ------------------
  |  Branch (170:21): [True: 0, False: 28.9k]
  ------------------
  171|      0|        add_thread(pool);
  172|  28.9k|    bool ok = pool->num_threads >= init_threads;
  173|  28.9k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  174|       |
  175|  28.9k|    if (!ok)
  ------------------
  |  Branch (175:9): [True: 0, False: 28.9k]
  ------------------
  176|      0|        TA_FREEP(&pool);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  177|       |
  178|  28.9k|    return pool;
  179|  28.9k|}
mp_thread_pool_queue:
  215|  21.8k|{
  216|       |    return thread_pool_add(pool, fn, fn_ctx, true);
  217|  21.8k|}
thread_pool.c:thread_pool_dtor:
  116|  28.9k|{
  117|  28.9k|    struct mp_thread_pool *pool = ctx;
  118|       |
  119|       |
  120|  28.9k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  121|       |
  122|  28.9k|    pool->terminate = true;
  123|  28.9k|    mp_cond_broadcast(&pool->wakeup);
  124|       |
  125|  28.9k|    mp_thread *threads = pool->threads;
  126|  28.9k|    int num_threads = pool->num_threads;
  127|       |
  128|  28.9k|    pool->threads = NULL;
  129|  28.9k|    pool->num_threads = 0;
  130|       |
  131|  28.9k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  132|       |
  133|  50.6k|    for (int n = 0; n < num_threads; n++)
  ------------------
  |  Branch (133:21): [True: 21.6k, False: 28.9k]
  ------------------
  134|  21.6k|        mp_thread_join(threads[n]);
  ------------------
  |  |  215|  21.6k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  135|       |
  136|  28.9k|    mp_assert(pool->num_work == 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (136:5): [True: 28.9k, False: 0]
  ------------------
  137|  28.9k|    mp_assert(pool->num_threads == 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (137:5): [True: 28.9k, False: 0]
  ------------------
  138|  28.9k|    mp_cond_destroy(&pool->wakeup);
  139|  28.9k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  140|  28.9k|}
thread_pool.c:add_thread:
  143|  21.6k|{
  144|  21.6k|    mp_thread thread;
  145|       |
  146|  21.6k|    if (mp_thread_create(&thread, worker_thread, pool) != 0)
  ------------------
  |  |  214|  21.6k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (146:9): [True: 0, False: 21.6k]
  ------------------
  147|      0|        return false;
  148|       |
  149|  21.6k|    MP_TARRAY_APPEND(pool, pool->threads, pool->num_threads, thread);
  ------------------
  |  |  105|  21.6k|    do {                                            \
  |  |  106|  21.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.6k|    do {                                            \
  |  |  |  |   97|  21.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.6k|    do {                                                        \
  |  |  |  |  |  |   89|  21.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.6k|        (idxvar)++;                                 \
  |  |  109|  21.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.6k]
  |  |  ------------------
  ------------------
  150|       |    return true;
  151|  21.6k|}
thread_pool.c:worker_thread:
   52|  21.6k|{
   53|  21.6k|    struct mp_thread_pool *pool = arg;
   54|       |
   55|  21.6k|    mp_thread_set_name("worker");
   56|       |
   57|  21.6k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  21.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   58|       |
   59|  21.6k|    int64_t destroy_deadline = 0;
   60|  21.6k|    bool got_timeout = false;
   61|  65.2k|    while (1) {
  ------------------
  |  Branch (61:12): [True: 65.2k, Folded]
  ------------------
   62|  65.2k|        struct work work = {0};
   63|  65.2k|        if (pool->num_work > 0) {
  ------------------
  |  Branch (63:13): [True: 21.8k, False: 43.4k]
  ------------------
   64|  21.8k|            work = pool->work[pool->num_work - 1];
   65|  21.8k|            pool->num_work -= 1;
   66|  21.8k|        }
   67|       |
   68|  65.2k|        if (!work.fn) {
  ------------------
  |  Branch (68:13): [True: 43.4k, False: 21.8k]
  ------------------
   69|  43.4k|            if (got_timeout || pool->terminate)
  ------------------
  |  Branch (69:17): [True: 0, False: 43.4k]
  |  Branch (69:32): [True: 21.6k, False: 21.8k]
  ------------------
   70|  21.6k|                break;
   71|       |
   72|  21.8k|            if (pool->num_threads > pool->min_threads) {
  ------------------
  |  Branch (72:17): [True: 0, False: 21.8k]
  ------------------
   73|      0|                if (!destroy_deadline)
  ------------------
  |  Branch (73:21): [True: 0, False: 0]
  ------------------
   74|      0|                    destroy_deadline = mp_time_ns() + MP_TIME_S_TO_NS(DESTROY_TIMEOUT);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   75|      0|                if (mp_cond_timedwait_until(&pool->wakeup, &pool->lock, destroy_deadline))
  ------------------
  |  Branch (75:21): [True: 0, False: 0]
  ------------------
   76|      0|                    got_timeout = pool->num_threads > pool->min_threads;
   77|  21.8k|            } else {
   78|  21.8k|                mp_cond_wait(&pool->wakeup, &pool->lock);
   79|  21.8k|            }
   80|  21.8k|            continue;
   81|  43.4k|        }
   82|       |
   83|  21.8k|        pool->busy_threads += 1;
   84|  21.8k|        mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  21.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|       |
   86|  21.8k|        work.fn(work.fn_ctx);
   87|       |
   88|  21.8k|        mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  21.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   89|  21.8k|        pool->busy_threads -= 1;
   90|       |
   91|  21.8k|        destroy_deadline = 0;
   92|  21.8k|        got_timeout = false;
   93|  21.8k|    }
   94|       |
   95|       |    // If no termination signal was given, it must mean we died because of a
   96|       |    // timeout, and nobody is waiting for us. We have to remove ourselves.
   97|  21.6k|    if (!pool->terminate) {
  ------------------
  |  Branch (97:9): [True: 0, False: 21.6k]
  ------------------
   98|      0|        for (int n = 0; n < pool->num_threads; n++) {
  ------------------
  |  Branch (98:25): [True: 0, False: 0]
  ------------------
   99|      0|            if (mp_thread_id_equal(mp_thread_get_id(pool->threads[n]),
  ------------------
  |  |  218|      0|#define mp_thread_id_equal(a, b)  ((a) == (b))
  |  |  ------------------
  |  |  |  Branch (218:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  100|      0|                                   mp_thread_current_id()))
  101|      0|            {
  102|      0|                mp_thread_detach(pool->threads[n]);
  ------------------
  |  |  216|      0|#define mp_thread_detach          pthread_detach
  ------------------
  103|      0|                MP_TARRAY_REMOVE_AT(pool->threads, pool->num_threads, n);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (103:17): [True: 0, False: 0]
  ------------------
  104|      0|                mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  105|      0|                MP_THREAD_RETURN();
  ------------------
  |  |  212|      0|#define MP_THREAD_RETURN() return NULL
  ------------------
  106|      0|            }
  107|      0|        }
  108|      0|        MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (108:9): [Folded, False: 0]
  ------------------
  109|      0|    }
  110|       |
  111|  21.6k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  21.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  112|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  21.6k|#define MP_THREAD_RETURN() return NULL
  ------------------
  113|  21.6k|}
thread_pool.c:thread_pool_add:
  183|  21.8k|{
  184|  21.8k|    bool ok = true;
  185|       |
  186|  21.8k|    mp_assert(fn);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (186:5): [True: 21.8k, False: 0]
  ------------------
  187|       |
  188|  21.8k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  21.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  189|  21.8k|    struct work work = {fn, fn_ctx};
  190|       |
  191|       |    // If there are not enough threads to process all at once, but we can
  192|       |    // create a new thread, then do so. If work is queued quickly, it can
  193|       |    // happen that not all available threads have picked up work yet (up to
  194|       |    // num_threads - busy_threads threads), which has to be accounted for.
  195|  21.8k|    if (pool->busy_threads + pool->num_work + 1 > pool->num_threads &&
  ------------------
  |  Branch (195:9): [True: 21.6k, False: 155]
  ------------------
  196|  21.6k|        pool->num_threads < pool->max_threads)
  ------------------
  |  Branch (196:9): [True: 21.6k, False: 0]
  ------------------
  197|  21.6k|    {
  198|  21.6k|        if (!add_thread(pool)) {
  ------------------
  |  Branch (198:13): [True: 0, False: 21.6k]
  ------------------
  199|       |            // If we can queue it, it'll get done as long as there is 1 thread.
  200|      0|            ok = allow_queue && pool->num_threads > 0;
  ------------------
  |  Branch (200:18): [True: 0, False: 0]
  |  Branch (200:33): [True: 0, False: 0]
  ------------------
  201|      0|        }
  202|  21.6k|    }
  203|       |
  204|  21.8k|    if (ok) {
  ------------------
  |  Branch (204:9): [True: 21.8k, False: 0]
  ------------------
  205|  21.8k|        MP_TARRAY_INSERT_AT(pool, pool->work, pool->num_work, 0, work);
  ------------------
  |  |  115|  21.8k|    do {                                            \
  |  |  116|  21.8k|        size_t at_ = (at);                          \
  |  |  117|  21.8k|        assert(at_ <= (idxvar));                    \
  |  |  118|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.6k, False: 155]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.6k|    do {                                                        \
  |  |  |  |  |  |   89|  21.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  21.8k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  21.8k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  21.8k|        (idxvar)++;                                 \
  |  |  122|  21.8k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  |  Branch (205:9): [True: 21.8k, False: 0]
  ------------------
  206|  21.8k|        mp_cond_signal(&pool->wakeup);
  207|  21.8k|    }
  208|       |
  209|  21.8k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  21.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  210|  21.8k|    return ok;
  211|  21.8k|}

mp_waiter_wait:
   36|   108k|{
   37|   108k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|   108k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   38|   108k|    while (!waiter->done)
  ------------------
  |  Branch (38:12): [True: 0, False: 108k]
  ------------------
   39|      0|        mp_cond_wait(&waiter->wakeup, &waiter->lock);
   40|   108k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|   108k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   41|       |
   42|   108k|    uintptr_t ret = waiter->value;
   43|       |
   44|       |    // We document that after mp_waiter_wait() the waiter object becomes
   45|       |    // invalid. (It strictly returns only after mp_waiter_wakeup() has returned,
   46|       |    // and the object is "single-shot".) So destroy it here.
   47|       |
   48|       |    // Normally, we expect that the system uses futexes, in which case the
   49|       |    // following functions will do nearly nothing. This is true for Windows
   50|       |    // and Linux. But some lesser OSes still might allocate kernel objects
   51|       |    // when initializing mutexes, so destroy them here.
   52|   108k|    mp_mutex_destroy(&waiter->lock);
  ------------------
  |  |  133|   108k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   53|   108k|    mp_cond_destroy(&waiter->wakeup);
   54|       |
   55|   108k|    memset(waiter, 0xCA, sizeof(*waiter)); // for debugging
   56|       |
   57|   108k|    return ret;
   58|   108k|}
mp_waiter_wakeup:
   61|   108k|{
   62|   108k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|   108k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   63|   108k|    mp_assert(!waiter->done);
  ------------------
  |  |   41|   108k|#define mp_assert assert
  ------------------
  |  Branch (63:5): [True: 108k, False: 0]
  ------------------
   64|   108k|    waiter->done = true;
   65|   108k|    waiter->value = value;
   66|   108k|    mp_cond_signal(&waiter->wakeup);
   67|   108k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|   108k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   68|   108k|}
mp_waiter_poll:
   71|  43.6k|{
   72|  43.6k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|  43.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   73|  43.6k|    bool r = waiter->done;
   74|  43.6k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|  43.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   75|  43.6k|    return r;
   76|  43.6k|}
mp_cancel_new:
  124|  92.4k|{
  125|  92.4k|    struct mp_cancel *c = talloc_ptrtype(talloc_ctx, c);
  ------------------
  |  |   34|  92.4k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  92.4k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  92.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  126|  92.4k|    talloc_set_destructor(c, cancel_destroy);
  ------------------
  |  |   41|  92.4k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  127|  92.4k|    *c = (struct mp_cancel){
  128|       |        .triggered = false,
  129|  92.4k|        .wakeup_pipe = {-1, -1},
  130|  92.4k|    };
  131|  92.4k|    mp_mutex_init(&c->lock);
  132|  92.4k|    mp_cond_init(&c->wakeup);
  133|  92.4k|    return c;
  134|  92.4k|}
mp_cancel_trigger:
  158|   199k|{
  159|   199k|    mp_mutex_lock(&c->lock);
  ------------------
  |  |  134|   199k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  160|   199k|    trigger_locked(c);
  161|   199k|    mp_mutex_unlock(&c->lock);
  ------------------
  |  |  136|   199k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  162|   199k|}
mp_cancel_reset:
  165|   133k|{
  166|   133k|    mp_mutex_lock(&c->lock);
  ------------------
  |  |  134|   133k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  167|       |
  168|   133k|    atomic_store(&c->triggered, false);
  169|       |
  170|   133k|    if (c->wakeup_pipe[0] >= 0) {
  ------------------
  |  Branch (170:9): [True: 0, False: 133k]
  ------------------
  171|       |        // Flush it fully.
  172|      0|        while (1) {
  ------------------
  |  Branch (172:16): [True: 0, Folded]
  ------------------
  173|      0|            int r = read(c->wakeup_pipe[0], &(char[256]){0}, 256);
  174|      0|            if (r <= 0 && !(r < 0 && errno == EINTR))
  ------------------
  |  Branch (174:17): [True: 0, False: 0]
  |  Branch (174:29): [True: 0, False: 0]
  |  Branch (174:38): [True: 0, False: 0]
  ------------------
  175|      0|                break;
  176|      0|        }
  177|      0|    }
  178|       |
  179|       |#ifdef _WIN32
  180|       |    if (c->win32_event)
  181|       |        ResetEvent(c->win32_event);
  182|       |#endif
  183|       |
  184|   133k|    mp_mutex_unlock(&c->lock);
  ------------------
  |  |  136|   133k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  185|   133k|}
mp_cancel_test:
  188|  7.77M|{
  189|  7.77M|    return c ? atomic_load_explicit(&c->triggered, memory_order_relaxed) : false;
  ------------------
  |  Branch (189:12): [True: 7.58M, False: 196k]
  ------------------
  190|  7.77M|}
mp_cancel_set_parent:
  223|   180k|{
  224|       |    // We can access c->parent without synchronization, because:
  225|       |    //  - concurrent mp_cancel_set_parent() calls to slave are not allowed
  226|       |    //  - slave->parent needs to stay valid as long as the slave exists
  227|   180k|    if (slave->parent == parent)
  ------------------
  |  Branch (227:9): [True: 28.9k, False: 151k]
  ------------------
  228|  28.9k|        return;
  229|   151k|    if (slave->parent) {
  ------------------
  |  Branch (229:9): [True: 88.0k, False: 63.4k]
  ------------------
  230|  88.0k|        mp_mutex_lock(&slave->parent->lock);
  ------------------
  |  |  134|  88.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|  88.0k|        LL_REMOVE(siblings, &slave->parent->slaves, slave);
  ------------------
  |  |   78|  88.0k|#define LL_REMOVE(field, list, item) do {                               \
  |  |   79|  88.0k|    if ((item)->field.prev) {                                           \
  |  |  ------------------
  |  |  |  Branch (79:9): [True: 0, False: 88.0k]
  |  |  ------------------
  |  |   80|      0|        (item)->field.prev->field.next = (item)->field.next;            \
  |  |   81|  88.0k|    } else {                                                            \
  |  |   82|  88.0k|        (list)->head = (item)->field.next;                              \
  |  |   83|  88.0k|    }                                                                   \
  |  |   84|  88.0k|    if ((item)->field.next) {                                           \
  |  |  ------------------
  |  |  |  Branch (84:9): [True: 24.6k, False: 63.4k]
  |  |  ------------------
  |  |   85|  24.6k|        (item)->field.next->field.prev = (item)->field.prev;            \
  |  |   86|  63.4k|    } else {                                                            \
  |  |   87|  63.4k|        (list)->tail = (item)->field.prev;                              \
  |  |   88|  63.4k|    }                                                                   \
  |  |   89|  88.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (89:10): [Folded, False: 88.0k]
  |  |  ------------------
  ------------------
  232|  88.0k|        mp_mutex_unlock(&slave->parent->lock);
  ------------------
  |  |  136|  88.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|  88.0k|    }
  234|   151k|    slave->parent = parent;
  235|   151k|    if (slave->parent) {
  ------------------
  |  Branch (235:9): [True: 88.0k, False: 63.4k]
  ------------------
  236|  88.0k|        mp_mutex_lock(&slave->parent->lock);
  ------------------
  |  |  134|  88.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  237|  88.0k|        LL_APPEND(siblings, &slave->parent->slaves, slave);
  ------------------
  |  |   44|  88.0k|#define LL_APPEND(field, list, item)  do {                              \
  |  |   45|  88.0k|    (item)->field.prev = (list)->tail;                                  \
  |  |   46|  88.0k|    (item)->field.next = NULL;                                          \
  |  |   47|  88.0k|    LL_RELINK_(field, list, item)                                       \
  |  |  ------------------
  |  |  |  |   98|  88.0k|    if ((item)->field.prev) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:9): [True: 24.6k, False: 63.4k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.6k|        (item)->field.prev->field.next = (item);                        \
  |  |  |  |  100|  63.4k|    } else {                                                            \
  |  |  |  |  101|  63.4k|        (list)->head = (item);                                          \
  |  |  |  |  102|  63.4k|    }                                                                   \
  |  |  |  |  103|  88.0k|    if ((item)->field.next) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:9): [True: 0, False: 88.0k]
  |  |  |  |  ------------------
  |  |  |  |  104|      0|        (item)->field.next->field.prev = (item);                        \
  |  |  |  |  105|  88.0k|    } else {                                                            \
  |  |  |  |  106|  88.0k|        (list)->tail = (item);                                          \
  |  |  |  |  107|  88.0k|    }
  |  |  ------------------
  |  |   48|  88.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (48:10): [Folded, False: 88.0k]
  |  |  ------------------
  ------------------
  238|  88.0k|        retrigger_locked(slave->parent);
  239|  88.0k|        mp_mutex_unlock(&slave->parent->lock);
  ------------------
  |  |  136|  88.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  240|  88.0k|    }
  241|   151k|}
thread_tools.c:cancel_destroy:
  102|  92.4k|{
  103|  92.4k|    struct mp_cancel *c = p;
  104|       |
  105|  92.4k|    mp_assert(!c->slaves.head); // API user error
  ------------------
  |  |   41|  92.4k|#define mp_assert assert
  ------------------
  |  Branch (105:5): [True: 92.4k, False: 0]
  ------------------
  106|       |
  107|  92.4k|    mp_cancel_set_parent(c, NULL);
  108|       |
  109|  92.4k|    if (c->wakeup_pipe[0] >= 0) {
  ------------------
  |  Branch (109:9): [True: 0, False: 92.4k]
  ------------------
  110|      0|        close(c->wakeup_pipe[0]);
  111|      0|        close(c->wakeup_pipe[1]);
  112|      0|    }
  113|       |
  114|       |#ifdef _WIN32
  115|       |    if (c->win32_event)
  116|       |        CloseHandle(c->win32_event);
  117|       |#endif
  118|       |
  119|  92.4k|    mp_mutex_destroy(&c->lock);
  ------------------
  |  |  133|  92.4k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  120|  92.4k|    mp_cond_destroy(&c->wakeup);
  121|  92.4k|}
thread_tools.c:trigger_locked:
  137|   199k|{
  138|   199k|    atomic_store(&c->triggered, true);
  139|       |
  140|   199k|    mp_cond_broadcast(&c->wakeup); // condition bound to c->triggered
  141|       |
  142|   199k|    if (c->cb)
  ------------------
  |  Branch (142:9): [True: 0, False: 199k]
  ------------------
  143|      0|        c->cb(c->cb_ctx);
  144|       |
  145|   199k|    for (struct mp_cancel *sub = c->slaves.head; sub; sub = sub->siblings.next)
  ------------------
  |  Branch (145:50): [True: 0, False: 199k]
  ------------------
  146|      0|        mp_cancel_trigger(sub);
  147|       |
  148|   199k|    if (c->wakeup_pipe[1] >= 0)
  ------------------
  |  Branch (148:9): [True: 0, False: 199k]
  ------------------
  149|      0|        (void)write(c->wakeup_pipe[1], &(char){0}, 1);
  150|       |
  151|       |#ifdef _WIN32
  152|       |    if (c->win32_event)
  153|       |        SetEvent(c->win32_event);
  154|       |#endif
  155|   199k|}
thread_tools.c:retrigger_locked:
  208|  88.0k|{
  209|  88.0k|    if (mp_cancel_test(c))
  ------------------
  |  Branch (209:9): [True: 0, False: 88.0k]
  ------------------
  210|      0|        trigger_locked(c);
  211|  88.0k|}

m_config_shadow_get_next_opt:
  187|  22.7M|{
  188|  22.7M|    return iter_next(shadow, 0, shadow->num_groups, p_id);
  189|  22.7M|}
m_config_shadow_get_opt:
  212|  22.7M|{
  213|  22.7M|    int group_index, opt_index;
  214|  22.7M|    get_opt_from_id(shadow, id, &group_index, &opt_index);
  215|       |
  216|  22.7M|    return &shadow->groups[group_index].group->opts[opt_index];
  217|  22.7M|}
m_config_shadow_get_opt_name:
  221|  22.7M|{
  222|  22.7M|    int group_index, opt_index;
  223|  22.7M|    get_opt_from_id(shadow, id, &group_index, &opt_index);
  224|       |
  225|  22.7M|    struct m_config_group *g = &shadow->groups[group_index];
  226|  22.7M|    return concat_name_buf(buf, buf_size, g->prefix,
  227|  22.7M|                           g->group->opts[opt_index].name);
  228|  22.7M|}
m_config_shadow_get_alias_from_opt:
  232|  1.33M|{
  233|  1.33M|    int group_index, opt_index;
  234|  1.33M|    get_opt_from_id(shadow, id, &group_index, &opt_index);
  235|       |
  236|  1.33M|    struct m_config_group *g = &shadow->groups[group_index];
  237|  1.33M|    const struct m_option *opt = &shadow->groups[group_index].group->opts[opt_index];
  238|  1.33M|    if (opt->alias_use_prefix)
  ------------------
  |  Branch (238:9): [True: 347k, False: 984k]
  ------------------
  239|   347k|        return concat_name_buf(buf, buf_size, g->prefix, (const char *)opt->priv);
  240|   984k|    return (const char *)opt->priv;
  241|  1.33M|}
m_config_cache_get_opt_data:
  265|  22.7M|{
  266|  22.7M|    int group_index, opt_index;
  267|  22.7M|    get_opt_from_id(cache->shadow, id, &group_index, &opt_index);
  268|       |
  269|  22.7M|    mp_assert(group_index >= cache->internal->group_start &&
  ------------------
  |  |   41|  22.7M|#define mp_assert assert
  ------------------
  |  Branch (269:5): [True: 22.7M, False: 0]
  |  Branch (269:5): [True: 22.7M, False: 0]
  ------------------
  270|  22.7M|           group_index < cache->internal->group_end);
  271|       |
  272|  22.7M|    struct m_group_data *gd = m_config_gdata(cache->internal->data, group_index);
  273|  22.7M|    const struct m_option *opt =
  274|  22.7M|        &cache->shadow->groups[group_index].group->opts[opt_index];
  275|       |
  276|  22.7M|    return gd && opt->offset >= 0 ? gd->udata + opt->offset : NULL;
  ------------------
  |  Branch (276:12): [True: 22.7M, False: 0]
  |  Branch (276:18): [True: 21.2M, False: 1.44M]
  ------------------
  277|  22.7M|}
m_config_cache_get_option_change_mask:
  293|   521k|{
  294|   521k|    struct m_config_shadow *shadow = cache->shadow;
  295|   521k|    int group_index, opt_index;
  296|   521k|    get_opt_from_id(shadow, id, &group_index, &opt_index);
  297|       |
  298|   521k|    mp_assert(group_index >= cache->internal->group_start &&
  ------------------
  |  |   41|   521k|#define mp_assert assert
  ------------------
  |  Branch (298:5): [True: 521k, False: 0]
  |  Branch (298:5): [True: 521k, False: 0]
  ------------------
  299|   521k|           group_index < cache->internal->group_end);
  300|       |
  301|   521k|    return get_opt_change_mask(cache->shadow, group_index,
  302|   521k|                               cache->internal->data->group_index,
  303|   521k|                               &shadow->groups[group_index].group->opts[opt_index]);
  304|   521k|}
m_config_shadow_new:
  443|  28.9k|{
  444|  28.9k|    struct m_config_shadow *shadow = talloc_zero(NULL, struct m_config_shadow);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|  28.9k|    talloc_set_destructor(shadow, shadow_destroy);
  ------------------
  |  |   41|  28.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  446|  28.9k|    mp_mutex_init(&shadow->lock);
  447|       |
  448|  28.9k|    add_sub_group(shadow, NULL, -1, -1, root);
  449|       |
  450|  28.9k|    if (!root->size)
  ------------------
  |  Branch (450:9): [True: 0, False: 28.9k]
  ------------------
  451|      0|        return shadow;
  452|       |
  453|  28.9k|    shadow->data = allocate_option_data(shadow, shadow, 0, NULL);
  454|       |
  455|  28.9k|    return shadow;
  456|  28.9k|}
m_config_cache_from_shadow:
  561|  1.26M|{
  562|  1.26M|    int group_index = -1;
  563|       |
  564|  33.9M|    for (int n = 0; n < shadow->num_groups; n++) {
  ------------------
  |  Branch (564:21): [True: 33.9M, False: 0]
  ------------------
  565|  33.9M|        if (shadow->groups[n].group == group) {
  ------------------
  |  Branch (565:13): [True: 1.26M, False: 32.6M]
  ------------------
  566|  1.26M|            group_index = n;
  567|  1.26M|            break;
  568|  1.26M|        }
  569|  33.9M|    }
  570|       |
  571|  1.26M|    mp_assert(group_index >= 0); // invalid group (or not in option tree)
  ------------------
  |  |   41|  1.26M|#define mp_assert assert
  ------------------
  |  Branch (571:5): [True: 1.26M, False: 0]
  ------------------
  572|       |
  573|  1.26M|    struct cache_alloc {
  574|  1.26M|        struct m_config_cache a;
  575|  1.26M|        struct config_cache b;
  576|  1.26M|    };
  577|  1.26M|    struct cache_alloc *alloc = talloc_zero(ta_parent, struct cache_alloc);
  ------------------
  |  |   27|  1.26M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.26M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.26M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  578|  1.26M|    mp_assert((void *)&alloc->a == (void *)alloc);
  ------------------
  |  |   41|  1.26M|#define mp_assert assert
  ------------------
  |  Branch (578:5): [True: 1.26M, False: 0]
  ------------------
  579|  1.26M|    struct m_config_cache *cache = &alloc->a;
  580|  1.26M|    talloc_set_destructor(cache, cache_destroy);
  ------------------
  |  |   41|  1.26M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  581|  1.26M|    cache->internal = &alloc->b;
  582|  1.26M|    cache->shadow = shadow;
  583|       |
  584|  1.26M|    struct config_cache *in = cache->internal;
  585|  1.26M|    in->shadow = shadow;
  586|  1.26M|    in->src = shadow->data;
  587|       |
  588|  1.26M|    mp_mutex_lock(&shadow->lock);
  ------------------
  |  |  134|  1.26M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  589|  1.26M|    in->data = allocate_option_data(cache, shadow, group_index, in->src);
  590|  1.26M|    mp_mutex_unlock(&shadow->lock);
  ------------------
  |  |  136|  1.26M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  591|       |
  592|  1.26M|    cache->opts = in->data->gdata[0].udata;
  593|       |
  594|  1.26M|    in->group_start = in->data->group_index;
  595|  1.26M|    in->group_end = in->group_start + in->data->num_gdata;
  596|  1.26M|    mp_assert(shadow->groups[in->group_start].group_count == in->data->num_gdata);
  ------------------
  |  |   41|  1.26M|#define mp_assert assert
  ------------------
  |  Branch (596:5): [True: 1.26M, False: 0]
  ------------------
  597|       |
  598|  1.26M|    in->upd_group = -1;
  599|       |
  600|  1.26M|    return cache;
  601|  1.26M|}
m_config_cache_alloc:
  606|  1.23M|{
  607|  1.23M|    return m_config_cache_from_shadow(ta_parent, global->config, group);
  608|  1.23M|}
m_config_cache_update:
  720|  6.38M|{
  721|  6.38M|    struct config_cache *in = cache->internal;
  722|  6.38M|    struct m_config_shadow *shadow = in->shadow;
  723|       |
  724|  6.38M|    if (!cache_check_update(cache))
  ------------------
  |  Branch (724:9): [True: 6.26M, False: 123k]
  ------------------
  725|  6.26M|        return false;
  726|       |
  727|   123k|    mp_mutex_lock(&shadow->lock);
  ------------------
  |  |  134|   123k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  728|   123k|    bool res = false;
  729|   239k|    while (1) {
  ------------------
  |  Branch (729:12): [True: 239k, Folded]
  ------------------
  730|   239k|        void *p;
  731|   239k|        update_next_option(cache, &p);
  732|   239k|        if (!p)
  ------------------
  |  Branch (732:13): [True: 123k, False: 115k]
  ------------------
  733|   123k|            break;
  734|   115k|        res = true;
  735|   115k|    }
  736|   123k|    mp_mutex_unlock(&shadow->lock);
  ------------------
  |  |  136|   123k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  737|   123k|    return res;
  738|  6.38M|}
m_config_cache_write_opt:
  782|   674k|{
  783|   674k|    struct config_cache *in = cache->internal;
  784|   674k|    struct m_config_shadow *shadow = in->shadow;
  785|       |
  786|   674k|    int group_idx = -1;
  787|   674k|    int opt_idx = -1;
  788|   674k|    find_opt(shadow, in->data, ptr, &group_idx, &opt_idx);
  789|       |
  790|       |    // ptr was not in cache->opts, or no option declaration matching it.
  791|   674k|    mp_assert(group_idx >= 0);
  ------------------
  |  |   41|   674k|#define mp_assert assert
  ------------------
  |  Branch (791:5): [True: 674k, False: 0]
  ------------------
  792|       |
  793|   674k|    struct m_config_group *g = &shadow->groups[group_idx];
  794|   674k|    const struct m_option *opt = &g->group->opts[opt_idx];
  795|       |
  796|   674k|    mp_mutex_lock(&shadow->lock);
  ------------------
  |  |  134|   674k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  797|       |
  798|   674k|    struct m_group_data *gdst = m_config_gdata(in->data, group_idx);
  799|   674k|    struct m_group_data *gsrc = m_config_gdata(in->src, group_idx);
  800|   674k|    mp_assert(gdst && gsrc);
  ------------------
  |  |   41|   674k|#define mp_assert assert
  ------------------
  |  Branch (800:5): [True: 674k, False: 0]
  |  Branch (800:5): [True: 674k, False: 0]
  ------------------
  801|       |
  802|   674k|    bool changed = !m_option_equal(opt, gsrc->udata + opt->offset, ptr) ||
  ------------------
  |  Branch (802:20): [True: 521k, False: 153k]
  ------------------
  803|   153k|                   opt->force_update;
  ------------------
  |  Branch (803:20): [True: 0, False: 153k]
  ------------------
  804|   674k|    if (changed) {
  ------------------
  |  Branch (804:9): [True: 521k, False: 153k]
  ------------------
  805|   521k|        m_option_copy(opt, gsrc->udata + opt->offset, ptr);
  806|       |
  807|   521k|        gsrc->ts = atomic_fetch_add(&shadow->ts, 1) + 1;
  808|       |
  809|   521k|        for (int n = 0; n < shadow->num_listeners; n++) {
  ------------------
  |  Branch (809:25): [True: 0, False: 521k]
  ------------------
  810|      0|            struct config_cache *listener = shadow->listeners[n];
  811|      0|            if (listener->wakeup_cb && m_config_gdata(listener->data, group_idx))
  ------------------
  |  Branch (811:17): [True: 0, False: 0]
  |  Branch (811:40): [True: 0, False: 0]
  ------------------
  812|      0|                listener->wakeup_cb(listener->wakeup_cb_ctx);
  813|      0|        }
  814|   521k|    }
  815|       |
  816|   674k|    if (opt->force_update)
  ------------------
  |  Branch (816:9): [True: 0, False: 674k]
  ------------------
  817|      0|        append_force_update(cache, gsrc, opt->name);
  818|       |
  819|   674k|    mp_mutex_unlock(&shadow->lock);
  ------------------
  |  |  136|   674k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  820|       |
  821|   674k|    return changed;
  822|   674k|}
m_config_cache_set_wakeup_cb:
  826|  2.61M|{
  827|  2.61M|    struct config_cache *in = cache->internal;
  828|  2.61M|    struct m_config_shadow *shadow = in->shadow;
  829|       |
  830|  2.61M|    mp_mutex_lock(&shadow->lock);
  ------------------
  |  |  134|  2.61M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  831|  2.61M|    if (in->in_list) {
  ------------------
  |  Branch (831:9): [True: 77.1k, False: 2.53M]
  ------------------
  832|  96.3k|        for (int n = 0; n < shadow->num_listeners; n++) {
  ------------------
  |  Branch (832:25): [True: 57.8k, False: 38.5k]
  ------------------
  833|  57.8k|            if (shadow->listeners[n] == in) {
  ------------------
  |  Branch (833:17): [True: 38.5k, False: 19.2k]
  ------------------
  834|  38.5k|                MP_TARRAY_REMOVE_AT(shadow->listeners, shadow->num_listeners, n);
  ------------------
  |  |  143|  38.5k|    do {                                            \
  |  |  144|  38.5k|        size_t at_ = (at);                          \
  |  |  145|  38.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  38.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  38.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  38.5k|        (idxvar)--;                                 \
  |  |  149|  38.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 38.5k]
  |  |  ------------------
  ------------------
  |  Branch (834:17): [True: 38.5k, False: 0]
  ------------------
  835|  38.5k|                break;
  836|  38.5k|            }
  837|  57.8k|        }
  838|  96.3k|        for (int n = 0; n < shadow->num_listeners; n++)
  ------------------
  |  Branch (838:25): [True: 19.2k, False: 77.1k]
  ------------------
  839|  77.1k|            mp_assert(shadow->listeners[n] != in); // only 1 wakeup_cb per cache
  ------------------
  |  |   41|  77.1k|#define mp_assert assert
  ------------------
  |  Branch (839:13): [True: 19.2k, False: 0]
  ------------------
  840|       |        // (The deinitialization path relies on this to free all memory.)
  841|  77.1k|        if (!shadow->num_listeners) {
  ------------------
  |  Branch (841:13): [True: 57.9k, False: 19.2k]
  ------------------
  842|  57.9k|            talloc_free(shadow->listeners);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
  843|  57.9k|            shadow->listeners = NULL;
  844|  57.9k|        }
  845|  77.1k|    }
  846|  2.61M|    if (cb) {
  ------------------
  |  Branch (846:9): [True: 38.5k, False: 2.57M]
  ------------------
  847|  38.5k|        MP_TARRAY_APPEND(NULL, shadow->listeners, shadow->num_listeners, in);
  ------------------
  |  |  105|  38.5k|    do {                                            \
  |  |  106|  38.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  38.5k|    do {                                            \
  |  |  |  |   97|  38.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  38.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  38.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  38.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 9.61k]
  |  |  |  |  ------------------
  |  |  |  |   99|  38.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  38.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 38.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  38.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  38.5k|        (idxvar)++;                                 \
  |  |  109|  38.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 38.5k]
  |  |  ------------------
  ------------------
  848|  38.5k|        in->in_list = true;
  849|  38.5k|        in->wakeup_cb = cb;
  850|  38.5k|        in->wakeup_cb_ctx = cb_ctx;
  851|  38.5k|    }
  852|  2.61M|    mp_mutex_unlock(&shadow->lock);
  ------------------
  |  |  136|  2.61M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  853|  2.61M|}
m_config_cache_set_dispatch_change_cb:
  868|  1.30M|{
  869|  1.30M|    struct config_cache *in = cache->internal;
  870|       |
  871|       |    // Removing the old one is tricky. First make sure no new notifications will
  872|       |    // come.
  873|  1.30M|    m_config_cache_set_wakeup_cb(cache, NULL, NULL);
  874|       |    // Remove any pending notifications (assume we're on the same thread as
  875|       |    // any potential mp_dispatch_queue_process() callers).
  876|  1.30M|    if (in->wakeup_dispatch_queue) {
  ------------------
  |  Branch (876:9): [True: 38.5k, False: 1.26M]
  ------------------
  877|  38.5k|        mp_dispatch_cancel_fn(in->wakeup_dispatch_queue,
  878|  38.5k|                              in->wakeup_dispatch_cb,
  879|  38.5k|                              in->wakeup_dispatch_cb_ctx);
  880|  38.5k|    }
  881|       |
  882|  1.30M|    in->wakeup_dispatch_queue = NULL;
  883|  1.30M|    in->wakeup_dispatch_cb = NULL;
  884|  1.30M|    in->wakeup_dispatch_cb_ctx = NULL;
  885|       |
  886|  1.30M|    if (cb) {
  ------------------
  |  Branch (886:9): [True: 38.5k, False: 1.26M]
  ------------------
  887|  38.5k|        in->wakeup_dispatch_queue = dispatch;
  888|  38.5k|        in->wakeup_dispatch_cb = cb;
  889|  38.5k|        in->wakeup_dispatch_cb_ctx = cb_ctx;
  890|  38.5k|        m_config_cache_set_wakeup_cb(cache, dispatch_notify, in);
  891|  38.5k|    }
  892|  1.30M|}
mp_get_config_group:
  896|   732k|{
  897|   732k|    struct m_config_cache *cache = m_config_cache_alloc(NULL, global, group);
  898|       |    // Make talloc_free(cache->opts) free the entire cache.
  899|   732k|    ta_set_parent(cache->opts, ta_parent);
  900|   732k|    ta_set_parent(cache, cache->opts);
  901|   732k|    return cache->opts;
  902|   732k|}
m_config_group_from_desc:
  919|  17.6k|{
  920|  17.6k|    const struct m_config_group *group = find_group(global, desc->options);
  921|  17.6k|    if (group) {
  ------------------
  |  Branch (921:9): [True: 17.6k, False: 0]
  ------------------
  922|  17.6k|        return mp_get_config_group(ta_parent, global, group->group);
  923|  17.6k|    } else {
  924|      0|        void *d = talloc_zero_size(ta_parent, desc->priv_size);
  ------------------
  |  |   44|      0|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|      0|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  925|      0|        if (desc->priv_defaults)
  ------------------
  |  Branch (925:13): [True: 0, False: 0]
  ------------------
  926|      0|            memcpy(d, desc->priv_defaults, desc->priv_size);
  927|      0|        return d;
  928|      0|    }
  929|  17.6k|}
m_config_core.c:iter_next:
  154|  22.7M|{
  155|  22.7M|    int32_t id = *p_id;
  156|  22.7M|    int group_index = id == -1 ? group_start : id >> 16;
  ------------------
  |  Branch (156:23): [True: 28.9k, False: 22.7M]
  ------------------
  157|  22.7M|    int opt_index = id == -1 ? -1 : id & 0xFFFF;
  ------------------
  |  Branch (157:21): [True: 28.9k, False: 22.7M]
  ------------------
  158|       |
  159|  22.7M|    mp_assert(group_index >= group_start && group_index <= group_end);
  ------------------
  |  |   41|  22.7M|#define mp_assert assert
  ------------------
  |  Branch (159:5): [True: 22.7M, False: 0]
  |  Branch (159:5): [True: 22.7M, False: 0]
  ------------------
  160|       |
  161|  25.3M|    while (1) {
  ------------------
  |  Branch (161:12): [True: 25.3M, Folded]
  ------------------
  162|  25.3M|        if (group_index >= group_end)
  ------------------
  |  Branch (162:13): [True: 28.9k, False: 25.3M]
  ------------------
  163|  28.9k|            return false;
  164|       |
  165|  25.3M|        struct m_config_group *g = &shadow->groups[group_index];
  166|  25.3M|        const struct m_option *opts = g->group->opts;
  167|       |
  168|  25.3M|        mp_assert(opt_index >= -1 && opt_index < g->opt_count);
  ------------------
  |  |   41|  25.3M|#define mp_assert assert
  ------------------
  |  Branch (168:9): [True: 25.3M, False: 0]
  |  Branch (168:9): [True: 25.3M, False: 0]
  ------------------
  169|       |
  170|  25.3M|        opt_index += 1;
  171|       |
  172|  25.3M|        if (!opts || !opts[opt_index].name) {
  ------------------
  |  Branch (172:13): [True: 0, False: 25.3M]
  |  Branch (172:22): [True: 1.41M, False: 23.9M]
  ------------------
  173|  1.41M|            group_index += 1;
  174|  1.41M|            opt_index = -1;
  175|  1.41M|            continue;
  176|  1.41M|        }
  177|       |
  178|  23.9M|        if (opts[opt_index].type == &m_option_type_subconfig)
  ------------------
  |  Branch (178:13): [True: 1.21M, False: 22.7M]
  ------------------
  179|  1.21M|            continue;
  180|       |
  181|  22.7M|        *p_id = (group_index << 16) | opt_index;
  182|       |        return true;
  183|  23.9M|    }
  184|  22.7M|}
m_config_core.c:get_opt_from_id:
  199|  69.9M|{
  200|  69.9M|    int group_index = id >> 16;
  201|  69.9M|    int opt_index = id & 0xFFFF;
  202|       |
  203|  69.9M|    mp_assert(group_index >= 0 && group_index < shadow->num_groups);
  ------------------
  |  |   41|  69.9M|#define mp_assert assert
  ------------------
  |  Branch (203:5): [True: 69.9M, False: 0]
  |  Branch (203:5): [True: 69.9M, False: 0]
  ------------------
  204|  69.9M|    mp_assert(opt_index >= 0 && opt_index < shadow->groups[group_index].opt_count);
  ------------------
  |  |   41|  69.9M|#define mp_assert assert
  ------------------
  |  Branch (204:5): [True: 69.9M, False: 0]
  |  Branch (204:5): [True: 69.9M, False: 0]
  ------------------
  205|       |
  206|  69.9M|    *out_group_index = group_index;
  207|  69.9M|    *out_opt_index = opt_index;
  208|  69.9M|}
m_config_core.c:concat_name_buf:
  132|  24.2M|{
  133|  24.2M|    mp_assert(a);
  ------------------
  |  |   41|  24.2M|#define mp_assert assert
  ------------------
  |  Branch (133:5): [True: 24.2M, False: 0]
  ------------------
  134|  24.2M|    mp_assert(b);
  ------------------
  |  |   41|  24.2M|#define mp_assert assert
  ------------------
  |  Branch (134:5): [True: 24.2M, False: 0]
  ------------------
  135|  24.2M|    if (!a[0])
  ------------------
  |  Branch (135:9): [True: 18.9M, False: 5.32M]
  ------------------
  136|  18.9M|        return b;
  137|  5.32M|    if (!b[0])
  ------------------
  |  Branch (137:9): [True: 0, False: 5.32M]
  ------------------
  138|      0|        return a;
  139|  5.32M|    snprintf(buf, buf_size, "%s-%s", a, b);
  140|  5.32M|    return buf;
  141|  5.32M|}
m_config_core.c:m_config_gdata:
  120|  45.6M|{
  121|  45.6M|    if (group_index < data->group_index ||
  ------------------
  |  Branch (121:9): [True: 0, False: 45.6M]
  ------------------
  122|  45.6M|        group_index >= data->group_index + data->num_gdata)
  ------------------
  |  Branch (122:9): [True: 0, False: 45.6M]
  ------------------
  123|      0|        return NULL;
  124|       |
  125|  45.6M|    return &data->gdata[group_index - data->group_index];
  126|  45.6M|}
m_config_core.c:get_opt_change_mask:
  281|   637k|{
  282|   637k|    uint64_t changed = opt->flags & UPDATE_OPTS_MASK;
  ------------------
  |  |  465|   637k|#define UPDATE_OPTS_MASK        ((UPDATE_OPT_LAST << 1) - 1)
  |  |  ------------------
  |  |  |  |  462|   637k|#define UPDATE_OPT_LAST         (UINT64_C(1) << 20)
  |  |  ------------------
  ------------------
  283|   897k|    while (group_index != group_root) {
  ------------------
  |  Branch (283:12): [True: 260k, False: 637k]
  ------------------
  284|   260k|        struct m_config_group *g = &shadow->groups[group_index];
  285|   260k|        changed |= g->group->change_flags;
  286|   260k|        group_index = g->parent_group;
  287|   260k|    }
  288|   637k|    return changed;
  289|   637k|}
m_config_core.c:shadow_destroy:
  432|  28.9k|{
  433|  28.9k|    struct m_config_shadow *shadow = p;
  434|       |
  435|       |    // must all have been unregistered
  436|  28.9k|    mp_assert(shadow->num_listeners == 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (436:5): [True: 28.9k, False: 0]
  ------------------
  437|       |
  438|  28.9k|    talloc_free(shadow->data);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  439|  28.9k|    mp_mutex_destroy(&shadow->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  440|  28.9k|}
m_config_core.c:allocate_option_data:
  414|  1.29M|{
  415|  1.29M|    mp_assert(group_index >= 0 && group_index < shadow->num_groups);
  ------------------
  |  |   41|  1.29M|#define mp_assert assert
  ------------------
  |  Branch (415:5): [True: 1.29M, False: 0]
  |  Branch (415:5): [True: 1.29M, False: 0]
  ------------------
  416|  1.29M|    struct m_config_data *data = talloc_zero(ta_parent, struct m_config_data);
  ------------------
  |  |   27|  1.29M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.29M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.29M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|  1.29M|    talloc_set_destructor(data, free_option_data);
  ------------------
  |  |   41|  1.29M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  418|       |
  419|  1.29M|    data->shadow = shadow;
  420|  1.29M|    data->group_index = group_index;
  421|       |
  422|  1.29M|    struct m_config_group *root_group = &shadow->groups[group_index];
  423|  1.29M|    mp_assert(root_group->group_count > 0);
  ------------------
  |  |   41|  1.29M|#define mp_assert assert
  ------------------
  |  Branch (423:5): [True: 1.29M, False: 0]
  ------------------
  424|       |
  425|  10.4M|    for (int n = group_index; n < group_index + root_group->group_count; n++)
  ------------------
  |  Branch (425:31): [True: 9.10M, False: 1.29M]
  ------------------
  426|  9.10M|        alloc_group(data, n, copy);
  427|       |
  428|  1.29M|    return data;
  429|  1.29M|}
m_config_core.c:free_option_data:
  388|  1.29M|{
  389|  1.29M|    struct m_config_data *data = p;
  390|       |
  391|  10.4M|    for (int i = 0; i < data->num_gdata; i++) {
  ------------------
  |  Branch (391:21): [True: 9.10M, False: 1.29M]
  ------------------
  392|  9.10M|        struct m_group_data *gdata = &data->gdata[i];
  393|  9.10M|        struct m_config_group *group =
  394|  9.10M|            &data->shadow->groups[data->group_index + i];
  395|  9.10M|        const struct m_option *opts = group->group->opts;
  396|       |
  397|   160M|        for (int n = 0; opts && opts[n].name; n++) {
  ------------------
  |  Branch (397:25): [True: 160M, False: 0]
  |  Branch (397:33): [True: 151M, False: 9.10M]
  ------------------
  398|   151M|            const struct m_option *opt = &opts[n];
  399|       |
  400|   151M|            if (opt->offset >= 0 && opt->type->size > 0)
  ------------------
  |  Branch (400:17): [True: 142M, False: 8.13M]
  |  Branch (400:37): [True: 136M, False: 6.75M]
  ------------------
  401|   136M|                m_option_free(opt, gdata->udata + opt->offset);
  402|   151M|        }
  403|  9.10M|    }
  404|  1.29M|}
m_config_core.c:alloc_group:
  341|  9.10M|{
  342|  9.10M|    mp_assert(group_index == data->group_index + data->num_gdata);
  ------------------
  |  |   41|  9.10M|#define mp_assert assert
  ------------------
  |  Branch (342:5): [True: 9.10M, False: 0]
  ------------------
  343|  9.10M|    mp_assert(group_index < data->shadow->num_groups);
  ------------------
  |  |   41|  9.10M|#define mp_assert assert
  ------------------
  |  Branch (343:5): [True: 9.10M, False: 0]
  ------------------
  344|  9.10M|    struct m_config_group *group = &data->shadow->groups[group_index];
  345|  9.10M|    const struct m_sub_options *opts = group->group;
  346|       |
  347|  9.10M|    MP_TARRAY_GROW(data, data->gdata, data->num_gdata);
  ------------------
  |  |   96|  9.10M|    do {                                            \
  |  |   97|  9.10M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  9.10M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  9.10M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  9.10M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 2.01M, False: 7.09M]
  |  |  ------------------
  |  |   99|  9.10M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  2.01M|    do {                                                        \
  |  |  |  |   89|  2.01M|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  2.01M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  2.01M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  2.01M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.01M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  2.01M|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  2.01M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 2.01M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  9.10M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 9.10M]
  |  |  ------------------
  ------------------
  348|  9.10M|    struct m_group_data *gdata = &data->gdata[data->num_gdata++];
  349|       |
  350|  9.10M|    struct m_group_data *copy_gdata =
  351|  9.10M|        copy ? m_config_gdata(copy, group_index) : NULL;
  ------------------
  |  Branch (351:9): [True: 7.68M, False: 1.41M]
  ------------------
  352|       |
  353|  9.10M|    *gdata = (struct m_group_data){
  354|  9.10M|        .udata = talloc_zero_size(data, opts->size),
  ------------------
  |  |   44|  9.10M|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|  9.10M|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  9.10M|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  9.10M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  9.10M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  9.10M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|  9.10M|        .ts = copy_gdata ? copy_gdata->ts : 0,
  ------------------
  |  Branch (355:15): [True: 7.68M, False: 1.41M]
  ------------------
  356|  9.10M|    };
  357|       |
  358|  9.10M|    if (opts->defaults)
  ------------------
  |  Branch (358:9): [True: 8.08M, False: 1.02M]
  ------------------
  359|  8.08M|        memcpy(gdata->udata, opts->defaults, opts->size);
  360|       |
  361|  9.10M|    char *copy_src = copy_gdata ? copy_gdata->udata : NULL;
  ------------------
  |  Branch (361:22): [True: 7.68M, False: 1.41M]
  ------------------
  362|       |
  363|   160M|    for (int n = 0; opts->opts && opts->opts[n].name; n++) {
  ------------------
  |  Branch (363:21): [True: 160M, False: 0]
  |  Branch (363:35): [True: 151M, False: 9.10M]
  ------------------
  364|   151M|        const struct m_option *opt = &opts->opts[n];
  365|       |
  366|   151M|        if (opt->offset < 0 || opt->type->size == 0)
  ------------------
  |  Branch (366:13): [True: 8.13M, False: 142M]
  |  Branch (366:32): [True: 6.75M, False: 136M]
  ------------------
  367|  14.8M|            continue;
  368|       |
  369|   136M|        void *dst = gdata->udata + opt->offset;
  370|   136M|        const void *defptr = opt->defval ? opt->defval : dst;
  ------------------
  |  Branch (370:30): [True: 198k, False: 136M]
  ------------------
  371|   136M|        if (copy_src)
  ------------------
  |  Branch (371:13): [True: 114M, False: 21.2M]
  ------------------
  372|   114M|            defptr = copy_src + opt->offset;
  373|       |
  374|   136M|        init_opt_inplace(opt, dst, defptr);
  375|   136M|    }
  376|       |
  377|       |    // If there's a parent, update its pointer to the new struct.
  378|  9.10M|    if (group->parent_group >= data->group_index && group->parent_ptr >= 0) {
  ------------------
  |  Branch (378:9): [True: 7.81M, False: 1.29M]
  |  Branch (378:53): [True: 6.75M, False: 1.05M]
  ------------------
  379|  6.75M|        struct m_group_data *parent_gdata =
  380|  6.75M|            m_config_gdata(data, group->parent_group);
  381|  6.75M|        mp_assert(parent_gdata);
  ------------------
  |  |   41|  6.75M|#define mp_assert assert
  ------------------
  |  Branch (381:9): [True: 6.75M, False: 0]
  ------------------
  382|       |
  383|  6.75M|        substruct_write_ptr(parent_gdata->udata + group->parent_ptr, gdata->udata);
  384|  6.75M|    }
  385|  9.10M|}
m_config_core.c:init_opt_inplace:
  327|   136M|{
  328|       |    // The option will use dynamic memory allocation iff it has a free callback.
  329|   136M|    if (opt->type->free) {
  ------------------
  |  Branch (329:9): [True: 23.9M, False: 112M]
  ------------------
  330|  23.9M|        union m_option_value temp;
  331|  23.9M|        memcpy(&temp, src, opt->type->size);
  332|  23.9M|        memset(dst, 0, opt->type->size);
  333|  23.9M|        m_option_copy(opt, dst, &temp);
  334|   112M|    } else if (src != dst) {
  ------------------
  |  Branch (334:16): [True: 94.8M, False: 17.4M]
  ------------------
  335|  94.8M|        memcpy(dst, src, opt->type->size);
  336|  94.8M|    }
  337|   136M|}
m_config_core.c:substruct_write_ptr:
  318|  6.75M|{
  319|  6.75M|    struct mp_dummy_ *src = val;
  320|  6.75M|    memcpy(ptr, &src, sizeof(src));
  321|  6.75M|}
m_config_core.c:add_sub_group:
  486|  1.41M|{
  487|       |    // Can't be used multiple times.
  488|  35.4M|    for (int n = 0; n < shadow->num_groups; n++)
  ------------------
  |  Branch (488:21): [True: 34.0M, False: 1.41M]
  ------------------
  489|  34.0M|        mp_assert(shadow->groups[n].group != subopts);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (489:9): [True: 34.0M, False: 0]
  ------------------
  490|       |
  491|  1.41M|    if (!name_prefix)
  ------------------
  |  Branch (491:9): [True: 202k, False: 1.21M]
  ------------------
  492|   202k|        name_prefix = "";
  493|  1.41M|    if (subopts->prefix && subopts->prefix[0]) {
  ------------------
  |  Branch (493:9): [True: 144k, False: 1.27M]
  |  Branch (493:28): [True: 144k, False: 0]
  ------------------
  494|   144k|        mp_assert(!name_prefix[0]);
  ------------------
  |  |   41|   144k|#define mp_assert assert
  ------------------
  |  Branch (494:9): [True: 144k, False: 0]
  ------------------
  495|   144k|        name_prefix = subopts->prefix;
  496|   144k|    }
  497|       |
  498|       |    // You can only use UPDATE_ flags here.
  499|  1.41M|    mp_assert(!(subopts->change_flags & ~UPDATE_OPTS_MASK));
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (499:5): [True: 1.41M, False: 0]
  ------------------
  500|       |
  501|  1.41M|    mp_assert(parent_group_index >= -1 && parent_group_index < shadow->num_groups);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (501:5): [True: 1.41M, False: 0]
  |  Branch (501:5): [True: 1.41M, False: 0]
  ------------------
  502|       |
  503|  1.41M|    int group_index = shadow->num_groups++;
  504|  1.41M|    MP_TARRAY_GROW(shadow, shadow->groups, group_index);
  ------------------
  |  |   96|  1.41M|    do {                                            \
  |  |   97|  1.41M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.41M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.41M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.41M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 144k, False: 1.27M]
  |  |  ------------------
  |  |   99|  1.41M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   144k|    do {                                                        \
  |  |  |  |   89|   144k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   144k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   144k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   144k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   144k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   144k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   144k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 144k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.41M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.41M]
  |  |  ------------------
  ------------------
  505|  1.41M|    shadow->groups[group_index] = (struct m_config_group){
  506|  1.41M|        .group = subopts,
  507|  1.41M|        .parent_group = parent_group_index,
  508|  1.41M|        .parent_ptr = parent_ptr,
  509|  1.41M|        .prefix = name_prefix,
  510|  1.41M|    };
  511|       |
  512|  25.3M|    for (int i = 0; subopts->opts && subopts->opts[i].name; i++) {
  ------------------
  |  Branch (512:21): [True: 25.3M, False: 0]
  |  Branch (512:38): [True: 23.9M, False: 1.41M]
  ------------------
  513|  23.9M|        const struct m_option *opt = &subopts->opts[i];
  514|       |
  515|  23.9M|        if (opt->type == &m_option_type_subconfig) {
  ------------------
  |  Branch (515:13): [True: 1.21M, False: 22.7M]
  ------------------
  516|  1.21M|            const struct m_sub_options *new_subopts = opt->priv;
  517|       |
  518|       |            // Providing default structs in-place is not allowed.
  519|  1.21M|            if (opt->offset >= 0 && subopts->defaults) {
  ------------------
  |  Branch (519:17): [True: 1.21M, False: 0]
  |  Branch (519:37): [True: 1.18M, False: 28.9k]
  ------------------
  520|  1.18M|                void *ptr = (char *)subopts->defaults + opt->offset;
  521|  1.18M|                mp_assert(!substruct_read_ptr(ptr));
  ------------------
  |  |   41|  1.18M|#define mp_assert assert
  ------------------
  |  Branch (521:17): [True: 1.18M, False: 0]
  ------------------
  522|  1.18M|            }
  523|       |
  524|  1.21M|            const char *prefix = concat_name(shadow, name_prefix, opt->name);
  525|  1.21M|            add_sub_group(shadow, prefix, group_index, opt->offset, new_subopts);
  526|       |
  527|  22.7M|        } else if (opt->type == &m_option_type_obj_settings_list) {
  ------------------
  |  Branch (527:20): [True: 202k, False: 22.5M]
  ------------------
  528|   202k|            const struct m_obj_list *objlist = opt->priv;
  529|   202k|            init_obj_settings_list(shadow, group_index, objlist);
  530|   202k|        }
  531|       |
  532|  23.9M|        shadow->groups[group_index].opt_count = i + 1;
  533|  23.9M|    }
  534|       |
  535|  1.41M|    if (subopts->get_sub_options) {
  ------------------
  |  Branch (535:9): [True: 28.9k, False: 1.38M]
  ------------------
  536|   376k|        for (int i = 0; ; i++) {
  537|   376k|            const struct m_sub_options *sub = NULL;
  538|   376k|            if (!subopts->get_sub_options(i, &sub))
  ------------------
  |  Branch (538:17): [True: 28.9k, False: 347k]
  ------------------
  539|  28.9k|                break;
  540|   347k|            if (sub)
  ------------------
  |  Branch (540:17): [True: 0, False: 347k]
  ------------------
  541|      0|                add_sub_group(shadow, NULL, group_index, -1, sub);
  542|   347k|        }
  543|  28.9k|    }
  544|       |
  545|  1.41M|    shadow->groups[group_index].group_count = shadow->num_groups - group_index;
  546|  1.41M|}
m_config_core.c:substruct_read_ptr:
  312|  1.18M|{
  313|  1.18M|    struct mp_dummy_ *res;
  314|  1.18M|    memcpy(&res, ptr, sizeof(res));
  315|  1.18M|    return res;
  316|  1.18M|}
m_config_core.c:concat_name:
  146|  1.21M|{
  147|  1.21M|    char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  148|  1.21M|    const char *r = concat_name_buf(buf, sizeof(buf), a, b);
  149|  1.21M|    return r == buf ? talloc_strdup(ta_parent, r) : r;
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (149:12): [True: 0, False: 1.21M]
  ------------------
  150|  1.21M|}
m_config_core.c:init_obj_settings_list:
  461|   202k|{
  462|   202k|    struct m_obj_desc desc;
  463|   955k|    for (int n = 0; ; n++) {
  464|   955k|        if (!list->get_desc(&desc, n))
  ------------------
  |  Branch (464:13): [True: 202k, False: 752k]
  ------------------
  465|   202k|            break;
  466|   752k|        if (desc.global_opts) {
  ------------------
  |  Branch (466:13): [True: 28.9k, False: 723k]
  ------------------
  467|  28.9k|            add_sub_group(shadow, NULL, parent_group_index, -1,
  468|  28.9k|                          desc.global_opts);
  469|  28.9k|        }
  470|   752k|        if (list->use_global_options && desc.options) {
  ------------------
  |  Branch (470:13): [True: 405k, False: 347k]
  |  Branch (470:41): [True: 144k, False: 260k]
  ------------------
  471|   144k|            struct m_sub_options *conf = talloc_ptrtype(shadow, conf);
  ------------------
  |  |   34|   144k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   144k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   144k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  472|   144k|            *conf = (struct m_sub_options){
  473|   144k|                .prefix = desc.options_prefix,
  474|   144k|                .opts = desc.options,
  475|   144k|                .defaults = desc.priv_defaults,
  476|   144k|                .size = desc.priv_size,
  477|   144k|            };
  478|       |            add_sub_group(shadow, NULL, parent_group_index, -1, conf);
  479|   144k|        }
  480|   752k|    }
  481|   202k|}
m_config_core.c:cache_destroy:
  549|  1.26M|{
  550|  1.26M|    struct m_config_cache *cache = p;
  551|       |
  552|       |    // (technically speaking, being able to call them both without anything
  553|       |    // breaking is a feature provided by these functions)
  554|  1.26M|    m_config_cache_set_wakeup_cb(cache, NULL, NULL);
  555|  1.26M|    m_config_cache_set_dispatch_change_cb(cache, NULL, NULL, NULL);
  556|  1.26M|}
m_config_core.c:cache_check_update:
  703|  6.38M|{
  704|  6.38M|    struct config_cache *in = cache->internal;
  705|  6.38M|    struct m_config_shadow *shadow = in->shadow;
  706|       |
  707|       |    // Using atomics and checking outside of the lock - it's unknown whether
  708|       |    // this makes it faster or slower. Just cargo culting it.
  709|  6.38M|    uint64_t new_ts = atomic_load(&shadow->ts);
  710|  6.38M|    if (in->ts >= new_ts)
  ------------------
  |  Branch (710:9): [True: 6.26M, False: 123k]
  ------------------
  711|  6.26M|        return false;
  712|       |
  713|   123k|    in->ts = new_ts;
  714|   123k|    in->upd_group = in->data->group_index;
  715|   123k|    in->upd_opt = 0;
  716|       |    return true;
  717|  6.38M|}
m_config_core.c:update_next_option:
  639|   239k|{
  640|   239k|    struct config_cache *in = cache->internal;
  641|   239k|    struct m_config_data *dst = in->data;
  642|   239k|    struct m_config_data *src = in->src;
  643|       |
  644|   239k|    mp_assert(src->group_index == 0); // must be the option root currently
  ------------------
  |  |   41|   239k|#define mp_assert assert
  ------------------
  |  Branch (644:5): [True: 239k, False: 0]
  ------------------
  645|       |
  646|   239k|    *p_opt = NULL;
  647|       |
  648|   507k|    while (in->upd_group < dst->group_index + dst->num_gdata) {
  ------------------
  |  Branch (648:12): [True: 384k, False: 123k]
  ------------------
  649|   384k|        struct m_group_data *gsrc = m_config_gdata(src, in->upd_group);
  650|   384k|        struct m_group_data *gdst = m_config_gdata(dst, in->upd_group);
  651|   384k|        mp_assert(gsrc && gdst);
  ------------------
  |  |   41|   384k|#define mp_assert assert
  ------------------
  |  Branch (651:9): [True: 384k, False: 0]
  |  Branch (651:9): [True: 384k, False: 0]
  ------------------
  652|       |
  653|   384k|        if (gdst->ts < gsrc->ts) {
  ------------------
  |  Branch (653:13): [True: 144k, False: 239k]
  ------------------
  654|   144k|            struct m_config_group *g = &dst->shadow->groups[in->upd_group];
  655|   144k|            const struct m_option *opts = g->group->opts;
  656|       |
  657|   608k|            while (opts && opts[in->upd_opt].name) {
  ------------------
  |  Branch (657:20): [True: 608k, False: 0]
  |  Branch (657:28): [True: 579k, False: 28.9k]
  ------------------
  658|   579k|                const struct m_option *opt = &opts[in->upd_opt];
  659|   579k|                void *dsrc = gsrc->udata + opt->offset;
  660|   579k|                void *ddst = gdst->udata + opt->offset;
  661|       |
  662|   579k|                if (opt->offset >= 0 && opt->type->size) {
  ------------------
  |  Branch (662:21): [True: 521k, False: 57.9k]
  |  Branch (662:41): [True: 521k, False: 0]
  ------------------
  663|   521k|                    bool opt_equal = m_option_equal(opt, ddst, dsrc);
  664|   521k|                    bool force_update = opt->force_update &&
  ------------------
  |  Branch (664:41): [True: 0, False: 521k]
  ------------------
  665|      0|                                        check_force_update(gsrc, opt->name, in->ts);
  ------------------
  |  Branch (665:41): [True: 0, False: 0]
  ------------------
  666|   521k|                    if (!opt_equal || force_update) {
  ------------------
  |  Branch (666:25): [True: 115k, False: 405k]
  |  Branch (666:39): [True: 0, False: 405k]
  ------------------
  667|   115k|                        uint64_t ch = get_opt_change_mask(dst->shadow,
  668|   115k|                                        in->upd_group, dst->group_index, opt);
  669|       |
  670|   115k|                        if (cache->debug && !opt_equal) {
  ------------------
  |  Branch (670:29): [True: 0, False: 115k]
  |  Branch (670:45): [True: 0, False: 0]
  ------------------
  671|      0|                            char *vdst = m_option_print(opt, ddst);
  672|      0|                            char *vsrc = m_option_print(opt, dsrc);
  673|      0|                            mp_warn(cache->debug, "Option '%s' changed from "
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  674|      0|                                    "'%s' to' %s' (flags = 0x%"PRIx64")\n",
  675|      0|                                    opt->name, vdst, vsrc, ch);
  676|      0|                            talloc_free(vdst);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  677|      0|                            talloc_free(vsrc);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  678|      0|                        }
  679|       |
  680|   115k|                        m_option_copy(opt, ddst, dsrc);
  681|   115k|                        cache->change_flags |= ch;
  682|       |
  683|   115k|                        in->upd_opt++; // skip this next time
  684|   115k|                        *p_opt = ddst;
  685|   115k|                        return;
  686|   115k|                    }
  687|   521k|                }
  688|       |
  689|   463k|                in->upd_opt++;
  690|   463k|            }
  691|       |
  692|  28.9k|            gdst->ts = gsrc->ts;
  693|  28.9k|        }
  694|       |
  695|   268k|        in->upd_group++;
  696|   268k|        in->upd_opt = 0;
  697|   268k|    }
  698|       |
  699|   123k|    in->upd_group = -1;
  700|   123k|}
m_config_core.c:find_opt:
  757|   674k|{
  758|   674k|    *group_idx = -1;
  759|   674k|    *opt_idx = -1;
  760|       |
  761|  6.35M|    for (int n = data->group_index; n < data->group_index + data->num_gdata; n++)
  ------------------
  |  Branch (761:37): [True: 6.35M, False: 0]
  ------------------
  762|  6.35M|    {
  763|  6.35M|        struct m_group_data *gd = m_config_gdata(data, n);
  764|  6.35M|        struct m_config_group *g = &shadow->groups[n];
  765|  6.35M|        const struct m_option *opts = g->group->opts;
  766|       |
  767|   147M|        for (int i = 0; opts && opts[i].name; i++) {
  ------------------
  |  Branch (767:25): [True: 147M, False: 0]
  |  Branch (767:33): [True: 142M, False: 5.67M]
  ------------------
  768|   142M|            const struct m_option *opt = &opts[i];
  769|       |
  770|   142M|            if (opt->offset >= 0 && opt->type->size &&
  ------------------
  |  Branch (770:17): [True: 126M, False: 15.8M]
  |  Branch (770:37): [True: 115M, False: 11.0M]
  ------------------
  771|   115M|                ptr == gd->udata + opt->offset)
  ------------------
  |  Branch (771:17): [True: 674k, False: 114M]
  ------------------
  772|   674k|            {
  773|   674k|                *group_idx = n;
  774|   674k|                *opt_idx = i;
  775|   674k|                return;
  776|   674k|            }
  777|   142M|        }
  778|  6.35M|    }
  779|   674k|}
m_config_core.c:find_group:
  906|  17.6k|{
  907|  17.6k|    struct m_config_shadow *shadow = global->config;
  908|       |
  909|   517k|    for (int n = 0; n < shadow->num_groups; n++) {
  ------------------
  |  Branch (909:21): [True: 517k, False: 0]
  ------------------
  910|   517k|        if (shadow->groups[n].group->opts == cfg)
  ------------------
  |  Branch (910:13): [True: 17.6k, False: 499k]
  ------------------
  911|  17.6k|            return &shadow->groups[n];
  912|   517k|    }
  913|       |
  914|      0|    return NULL;
  915|  17.6k|}

m_config_restore_backups:
  235|   162k|{
  236|   162k|    restore_backups(&config->backup_opts, config);
  237|   162k|}
m_config_backup_watch_later_opts:
  276|  28.9k|{
  277|       |    // Runs once on the empty list, which is looked up by name.
  278|  28.9k|    mp_assert(!config->watch_later_backup_opts);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (278:5): [True: 28.9k, False: 0]
  ------------------
  279|  22.7M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (279:21): [True: 22.7M, False: 28.9k]
  ------------------
  280|  22.7M|        if (config->opts[n].data)
  ------------------
  |  Branch (280:13): [True: 21.2M, False: 1.44M]
  ------------------
  281|  21.2M|            add_backup(&config->watch_later_backup_opts, 0, &config->opts[n]);
  282|  22.7M|    }
  283|  28.9k|}
m_config_get_co_raw:
  300|  3.41M|{
  301|  3.41M|    struct m_config_option **co =
  302|  3.41M|        bsearch(&name, config->sorted_opts, config->num_opts,
  303|  3.41M|                sizeof(config->sorted_opts[0]), search_opt_name);
  304|  3.41M|    return co ? *co : NULL;
  ------------------
  |  Branch (304:12): [True: 3.09M, False: 318k]
  ------------------
  305|  3.41M|}
m_config_get_co:
  359|  2.40M|{
  360|  2.40M|    struct m_config_option *co = m_config_get_co_any(config, name);
  361|       |    // CLI aliases should not be real options, and are explicitly handled by
  362|       |    // m_config_set_option_cli(). So pretend it does not exist.
  363|  2.40M|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (363:9): [True: 2.22M, False: 173k]
  |  Branch (363:15): [True: 202k, False: 2.02M]
  ------------------
  364|   202k|        co = NULL;
  365|  2.40M|    return co;
  366|  2.40M|}
m_config_get_co_count:
  369|  28.9k|{
  370|  28.9k|    return config->num_opts;
  371|  28.9k|}
m_config_get_co_index:
  374|  22.7M|{
  375|  22.7M|    return &config->opts[index];
  376|  22.7M|}
m_config_mark_co_flags:
  431|   521k|{
  432|   521k|    if (flags & M_SETOPT_FROM_CMDLINE)
  ------------------
  |  Branch (432:9): [True: 0, False: 521k]
  ------------------
  433|      0|        co->is_set_from_cmdline = true;
  434|       |
  435|   521k|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (435:9): [True: 260k, False: 260k]
  ------------------
  436|   260k|        co->is_set_from_config = true;
  437|   521k|}
m_config_set_update_dispatch_queue:
  530|  28.9k|{
  531|  28.9k|    m_config_cache_set_dispatch_change_cb(config->cache, dispatch,
  532|  28.9k|                                          async_change_cb, config);
  533|  28.9k|}
m_config_new:
  554|  28.9k|{
  555|  28.9k|    struct m_config *config = talloc(talloc_ctx, struct m_config);
  ------------------
  |  |   26|  28.9k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  28.9k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  28.9k|    talloc_set_destructor(config, config_destroy);
  ------------------
  |  |   41|  28.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  557|  28.9k|    *config = (struct m_config){.log = log,};
  558|       |
  559|  28.9k|    config->shadow = m_config_shadow_new(root);
  560|       |
  561|  28.9k|    if (root->size) {
  ------------------
  |  Branch (561:9): [True: 28.9k, False: 0]
  ------------------
  562|  28.9k|        config->cache = m_config_cache_from_shadow(config, config->shadow, root);
  563|  28.9k|        config->optstruct = config->cache->opts;
  564|  28.9k|    }
  565|       |
  566|  28.9k|    int32_t optid = -1;
  567|  22.7M|    while (m_config_shadow_get_next_opt(config->shadow, &optid)) {
  ------------------
  |  Branch (567:12): [True: 22.7M, False: 28.9k]
  ------------------
  568|  22.7M|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  569|  22.7M|        const char *opt_name =
  570|  22.7M|            m_config_shadow_get_opt_name(config->shadow, optid, buf, sizeof(buf));
  571|       |
  572|  22.7M|        struct m_config_option co = {
  573|  22.7M|            .name = talloc_strdup(config, opt_name),
  ------------------
  |  |   50|  22.7M|#define talloc_strdup                   ta_xstrdup
  ------------------
  574|  22.7M|            .opt = m_config_shadow_get_opt(config->shadow, optid),
  575|  22.7M|            .opt_id = optid,
  576|  22.7M|        };
  577|       |
  578|  22.7M|        if (config->cache)
  ------------------
  |  Branch (578:13): [True: 22.7M, False: 0]
  ------------------
  579|  22.7M|            co.data = m_config_cache_get_opt_data(config->cache, optid);
  580|       |
  581|  22.7M|        MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
  ------------------
  |  |  105|  22.7M|    do {                                            \
  |  |  106|  22.7M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  22.7M|    do {                                            \
  |  |  |  |   97|  22.7M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  22.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  22.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  22.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 260k, False: 22.4M]
  |  |  |  |  ------------------
  |  |  |  |   99|  22.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   260k|    do {                                                        \
  |  |  |  |  |  |   89|   260k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   260k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   260k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   260k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   260k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   260k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   260k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 260k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  22.7M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 22.7M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  22.7M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  22.7M|        (idxvar)++;                                 \
  |  |  109|  22.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 22.7M]
  |  |  ------------------
  ------------------
  582|  22.7M|    }
  583|       |
  584|  28.9k|    config->sorted_opts = talloc_array(config, struct m_config_option *, config->num_opts);
  ------------------
  |  |   29|  28.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  28.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|  22.7M|    for (int n = 0; n < config->num_opts; n++)
  ------------------
  |  Branch (585:21): [True: 22.7M, False: 28.9k]
  ------------------
  586|  22.7M|        config->sorted_opts[n] = &config->opts[n];
  587|  28.9k|    qsort(config->sorted_opts, config->num_opts, sizeof(config->sorted_opts[0]), compare_opt_name);
  588|       |
  589|  28.9k|    return config;
  590|  28.9k|}
m_config_notify_change_opt_ptr:
  623|   153k|{
  624|       |    notify_opt(config, ptr, true);
  625|   153k|}
m_config_set_option_raw:
  637|  2.22M|{
  638|  2.22M|    if (!co)
  ------------------
  |  Branch (638:9): [True: 0, False: 2.22M]
  ------------------
  639|      0|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  640|       |
  641|  2.22M|    int r = handle_set_opt_flags(config, co, flags);
  642|  2.22M|    if (r <= 1)
  ------------------
  |  Branch (642:9): [True: 1.70M, False: 521k]
  ------------------
  643|  1.70M|        return r;
  644|       |
  645|   521k|    r = m_config_handle_special_options(config, co, data, flags);
  646|   521k|    if (r != M_OPT_UNKNOWN)
  ------------------
  |  |  529|   521k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (646:9): [True: 0, False: 521k]
  ------------------
  647|      0|        return r;
  648|       |
  649|       |    // This affects some special options like "playlist", "v". Maybe these
  650|       |    // should work, or maybe not. For now they would require special code.
  651|   521k|    if (!co->data)
  ------------------
  |  Branch (651:9): [True: 0, False: 521k]
  ------------------
  652|      0|        return flags & M_SETOPT_FROM_CMDLINE ? 0 : M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (652:16): [True: 0, False: 0]
  ------------------
  653|       |
  654|   521k|    if (config->profile_backup_tmp)
  ------------------
  |  Branch (654:9): [True: 0, False: 521k]
  ------------------
  655|      0|        ensure_backup(config->profile_backup_tmp, config->profile_backup_flags, co);
  656|       |
  657|   521k|    m_config_mark_co_flags(co, flags);
  658|       |
  659|   521k|    m_option_copy(co->opt, co->data, data);
  660|   521k|    if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (660:9): [True: 521k, False: 0]
  ------------------
  661|   521k|        force_self_notify_change_opt(config, co, false);
  662|       |
  663|   521k|    return 0;
  664|   521k|}
m_config_set_option_cli:
  739|  2.11M|{
  740|  2.11M|    int r;
  741|  2.11M|    mp_assert(config != NULL);
  ------------------
  |  |   41|  2.11M|#define mp_assert assert
  ------------------
  |  Branch (741:5): [True: 2.11M, False: 0]
  ------------------
  742|       |
  743|  2.11M|    bool negate;
  744|  2.11M|    struct m_config_option *co =
  745|  2.11M|        m_config_mogrify_cli_opt(config, &name, &negate, &(int){0});
  746|       |
  747|  2.11M|    if (!co) {
  ------------------
  |  Branch (747:9): [True: 144k, False: 1.96M]
  ------------------
  748|   144k|        r = M_OPT_UNKNOWN;
  ------------------
  |  |  529|   144k|#define M_OPT_UNKNOWN           -1
  ------------------
  749|   144k|        goto done;
  750|   144k|    }
  751|       |
  752|  1.96M|    if (negate) {
  ------------------
  |  Branch (752:9): [True: 0, False: 1.96M]
  ------------------
  753|      0|        if (param.len) {
  ------------------
  |  Branch (753:13): [True: 0, False: 0]
  ------------------
  754|      0|            r = M_OPT_DISALLOW_PARAM;
  ------------------
  |  |  542|      0|#define M_OPT_DISALLOW_PARAM    -5
  ------------------
  755|      0|            goto done;
  756|      0|        }
  757|       |
  758|      0|        param = bstr0("no");
  759|      0|    }
  760|       |
  761|  1.96M|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (761:9): [True: 1.96M, False: 0]
  ------------------
  762|  1.96M|        co->coalesce = true;
  763|       |
  764|       |    // This is the only mandatory function
  765|  1.96M|    mp_assert(co->opt->type->parse);
  ------------------
  |  |   41|  1.96M|#define mp_assert assert
  ------------------
  |  Branch (765:5): [True: 1.96M, False: 0]
  ------------------
  766|       |
  767|  1.96M|    r = handle_set_opt_flags(config, co, flags);
  768|  1.96M|    if (r <= 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 1.96M]
  ------------------
  769|      0|        goto done;
  770|       |
  771|  1.96M|    if (r == 2) {
  ------------------
  |  Branch (771:9): [True: 260k, False: 1.70M]
  ------------------
  772|   260k|        MP_VERBOSE(config, "Setting option '%.*s' = '%.*s' (flags = %d)\n",
  ------------------
  |  |   92|   260k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.04M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 260k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 260k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|   260k|                   BSTR_P(name), BSTR_P(param), flags);
  774|   260k|    }
  775|       |
  776|  1.96M|    union m_option_value val = m_option_value_default;
  777|       |
  778|       |    // Some option types are "impure" and work on the existing data.
  779|       |    // (Prime examples: --vf-add, --sub-file)
  780|  1.96M|    if (co->data)
  ------------------
  |  Branch (780:9): [True: 1.88M, False: 86.8k]
  ------------------
  781|  1.88M|        m_option_copy(co->opt, &val, co->data);
  782|       |
  783|  1.96M|    r = m_option_parse(config->log, co->opt, name, param, &val);
  784|       |
  785|  1.96M|    if (r >= 0)
  ------------------
  |  Branch (785:9): [True: 1.96M, False: 0]
  ------------------
  786|  1.96M|        r = m_config_set_option_raw(config, co, &val, flags);
  787|       |
  788|  1.96M|    m_option_free(co->opt, &val);
  789|       |
  790|  2.11M|done:
  791|  2.11M|    if (r < 0 && r != M_OPT_EXIT) {
  ------------------
  |  |  545|   144k|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (791:9): [True: 144k, False: 1.96M]
  |  Branch (791:18): [True: 144k, False: 0]
  ------------------
  792|   144k|        MP_ERR(config, "Error parsing option %.*s (%s)\n",
  ------------------
  |  |   89|   144k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   289k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 144k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|   144k|               BSTR_P(name), m_option_strerror(r));
  794|   144k|        r = M_OPT_INVALID;
  ------------------
  |  |  535|   144k|#define M_OPT_INVALID           -3
  ------------------
  795|   144k|    }
  796|  2.11M|    return r;
  797|  1.96M|}
m_config_set_option_node:
  801|   260k|{
  802|   260k|    int r;
  803|       |
  804|   260k|    struct m_config_option *co = m_config_get_co(config, name);
  805|   260k|    if (!co)
  ------------------
  |  Branch (805:9): [True: 0, False: 260k]
  ------------------
  806|      0|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  807|       |
  808|       |    // Do this on an "empty" type to make setting the option strictly overwrite
  809|       |    // the old value, as opposed to e.g. appending to lists.
  810|   260k|    union m_option_value val = m_option_value_default;
  811|       |
  812|   260k|    r = m_option_set_node_or_string(mp_null_log, co->opt, name, &val, data);
  813|   260k|    if (r >= 0)
  ------------------
  |  Branch (813:9): [True: 260k, False: 0]
  ------------------
  814|   260k|        r = m_config_set_option_raw(config, co, &val, flags);
  815|       |
  816|   260k|    if (mp_msg_test(config->log, MSGL_V)) {
  ------------------
  |  Branch (816:9): [True: 0, False: 260k]
  ------------------
  817|      0|        char *s = m_option_type_node.print(NULL, data);
  818|      0|        MP_DBG(config, "Setting option '%.*s' = %s (flags = %d) -> %d\n",
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|      0|               BSTR_P(name), s ? s : "?", flags, r);
  820|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  821|      0|    }
  822|       |
  823|   260k|    m_option_free(co->opt, &val);
  824|   260k|    return r;
  825|   260k|}
m_config_get_profile:
  939|   504k|{
  940|  4.25M|    for (struct m_profile *p = config->profiles; p; p = p->next) {
  ------------------
  |  Branch (940:50): [True: 3.83M, False: 417k]
  ------------------
  941|  3.83M|        if (bstr_equals0(name, p->name))
  ------------------
  |  Branch (941:13): [True: 86.8k, False: 3.74M]
  ------------------
  942|  86.8k|            return p;
  943|  3.83M|    }
  944|   417k|    return NULL;
  945|   504k|}
m_config_get_profile0:
  949|   504k|{
  950|   504k|    return m_config_get_profile(config, bstr0(name));
  951|   504k|}
m_config_add_profile:
  954|   405k|{
  955|   405k|    if (!name || !name[0])
  ------------------
  |  Branch (955:9): [True: 57.9k, False: 347k]
  |  Branch (955:18): [True: 0, False: 347k]
  ------------------
  956|  57.9k|        name = "default";
  957|   405k|    struct m_profile *p = m_config_get_profile0(config, name);
  958|   405k|    if (p)
  ------------------
  |  Branch (958:9): [True: 28.9k, False: 376k]
  ------------------
  959|  28.9k|        return p;
  960|   376k|    p = talloc_zero(config, struct m_profile);
  ------------------
  |  |   27|   376k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   376k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   376k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|   376k|    p->name = talloc_strdup(p, name);
  ------------------
  |  |   50|   376k|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|   376k|    p->next = config->profiles;
  963|   376k|    config->profiles = p;
  964|   376k|    return p;
  965|   405k|}
m_config_set_profile_option:
  969|  1.85M|{
  970|  1.85M|    if (bstr_equals0(name, "profile-desc")) {
  ------------------
  |  Branch (970:9): [True: 0, False: 1.85M]
  ------------------
  971|      0|        talloc_free(p->desc);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  972|      0|        p->desc = bstrto0(p, val);
  973|      0|        return 0;
  974|      0|    }
  975|  1.85M|    if (bstr_equals0(name, "profile-cond")) {
  ------------------
  |  Branch (975:9): [True: 0, False: 1.85M]
  ------------------
  976|      0|        TA_FREEP(&p->cond);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  977|      0|        val = bstr_strip(val);
  978|      0|        if (val.len)
  ------------------
  |  Branch (978:13): [True: 0, False: 0]
  ------------------
  979|      0|            p->cond = bstrto0(p, val);
  980|      0|        return 0;
  981|      0|    }
  982|  1.85M|    if (bstr_equals0(name, profile_restore_mode_opt.name)) {
  ------------------
  |  Branch (982:9): [True: 0, False: 1.85M]
  ------------------
  983|      0|        return m_option_parse(config->log, &profile_restore_mode_opt, name, val,
  984|      0|                              &p->restore_mode);
  985|      0|    }
  986|       |
  987|  1.85M|    int i = m_config_set_option_cli(config, name, val,
  988|  1.85M|                                    M_SETOPT_CHECK_ONLY |
  989|  1.85M|                                    M_SETOPT_FROM_CONFIG_FILE);
  990|  1.85M|    if (i < 0)
  ------------------
  |  Branch (990:9): [True: 144k, False: 1.70M]
  ------------------
  991|   144k|        return i;
  992|  1.70M|    p->opts = talloc_realloc(p, p->opts, char *, 2 * (p->num_opts + 2));
  ------------------
  |  |   33|  1.70M|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  1.70M|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  1.70M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.70M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.70M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.70M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|  1.70M|    p->opts[p->num_opts * 2] = bstrto0(p, name);
  994|  1.70M|    p->opts[p->num_opts * 2 + 1] = bstrto0(p, val);
  995|  1.70M|    p->num_opts++;
  996|       |    p->opts[p->num_opts * 2] = p->opts[p->num_opts * 2 + 1] = NULL;
  997|  1.70M|    return 1;
  998|  1.85M|}
m_config_set_profile:
 1021|  57.9k|{
 1022|  57.9k|    MP_VERBOSE(config, "Applying profile '%s'...\n", name);
  ------------------
  |  |   92|  57.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  57.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1023|  57.9k|    struct m_profile *p = find_check_profile(config, name);
 1024|  57.9k|    if (!p)
  ------------------
  |  Branch (1024:9): [True: 0, False: 57.9k]
  ------------------
 1025|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1026|       |
 1027|  57.9k|    if (!config->profile_backup_tmp && p->restore_mode) {
  ------------------
  |  Branch (1027:9): [True: 57.9k, False: 0]
  |  Branch (1027:40): [True: 0, False: 57.9k]
  ------------------
 1028|      0|        config->profile_backup_tmp = &p->backups;
 1029|      0|        config->profile_backup_flags = p->restore_mode == 2 ? BACKUP_NVAL : 0;
  ------------------
  |  |  187|      0|#define BACKUP_NVAL 2
  ------------------
  |  Branch (1029:40): [True: 0, False: 0]
  ------------------
 1030|      0|    }
 1031|       |
 1032|  57.9k|    char *profile_name = talloc_strdup(NULL, name);
  ------------------
  |  |   50|  57.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1033|       |    // Note that we don't check if profile applied correctly, it doesn't matter.
 1034|  57.9k|    MP_TARRAY_APPEND(config, config->profile_stack, config->profile_stack_depth, profile_name);
  ------------------
  |  |  105|  57.9k|    do {                                            \
  |  |  106|  57.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.9k|    do {                                            \
  |  |  |  |   97|  57.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  57.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.9k|        (idxvar)++;                                 \
  |  |  109|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
 1035|  57.9k|    talloc_steal(config->profile_stack, profile_name);
  ------------------
  |  |   38|  57.9k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  57.9k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1036|   318k|    for (int i = 0; i < p->num_opts; i++) {
  ------------------
  |  Branch (1036:21): [True: 260k, False: 57.9k]
  ------------------
 1037|   260k|        m_config_set_option_cli(config,
 1038|   260k|                                bstr0(p->opts[2 * i]),
 1039|   260k|                                bstr0(p->opts[2 * i + 1]),
 1040|   260k|                                flags | M_SETOPT_FROM_CONFIG_FILE);
 1041|   260k|    }
 1042|  57.9k|    if (MP_TARRAY_POP(config->profile_stack, config->profile_stack_depth, &profile_name))
  ------------------
  |  |  153|  57.9k|    ((idxvar) > 0                                   \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 57.9k, False: 0]
  |  |  |  Branch (153:6): [True: 57.9k, False: 0]
  |  |  ------------------
  |  |  154|  57.9k|        ? (*(out) = (p)[--(idxvar)], true)          \
  |  |  155|  57.9k|        : false                                     \
  |  |  156|  57.9k|    )
  ------------------
 1043|  57.9k|        talloc_free(profile_name);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
 1044|       |
 1045|  57.9k|    if (config->profile_backup_tmp == &p->backups) {
  ------------------
  |  Branch (1045:9): [True: 0, False: 57.9k]
  ------------------
 1046|      0|        config->profile_backup_tmp = NULL;
 1047|       |
 1048|      0|        for (struct m_opt_backup *bc = p->backups; bc; bc = bc->next) {
  ------------------
  |  Branch (1048:52): [True: 0, False: 0]
  ------------------
 1049|      0|            if (bc && bc->nval)
  ------------------
  |  Branch (1049:17): [True: 0, False: 0]
  |  Branch (1049:23): [True: 0, False: 0]
  ------------------
 1050|      0|                m_option_copy(bc->co->opt, bc->nval, bc->co->data);
 1051|      0|            talloc_steal(p, bc);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1052|      0|        }
 1053|      0|    }
 1054|       |
 1055|  57.9k|    return 0;
 1056|  57.9k|}
m_config_finish_default_profile:
 1074|  28.9k|{
 1075|       |    struct m_profile *p = m_config_add_profile(config, NULL);
 1076|  28.9k|    m_config_set_profile(config, p->name, flags & ~M_SETOPT_FROM_CONFIG_FILE);
 1077|  28.9k|    p->num_opts = 0;
 1078|  28.9k|}
m_config_frontend.c:restore_backups:
  220|   162k|{
  221|   162k|    while (*list) {
  ------------------
  |  Branch (221:12): [True: 0, False: 162k]
  ------------------
  222|      0|        struct m_opt_backup *bc = *list;
  223|      0|        *list = bc->next;
  224|       |
  225|      0|        if (!bc->nval || m_option_equal(bc->co->opt, bc->co->data, bc->nval))
  ------------------
  |  Branch (225:13): [True: 0, False: 0]
  |  Branch (225:26): [True: 0, False: 0]
  ------------------
  226|      0|            m_config_set_option_raw(config, bc->co, bc->backup, 0);
  227|       |
  228|      0|        if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|      0|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (228:13): [True: 0, False: 0]
  ------------------
  229|      0|            bc->co->is_set_locally = false;
  230|      0|        talloc_free(bc);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  231|      0|    }
  232|   162k|}
m_config_frontend.c:add_backup:
  190|  21.2M|{
  191|  21.2M|    struct m_opt_backup *bc = talloc_ptrtype(NULL, bc);
  ------------------
  |  |   34|  21.2M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  21.2M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.2M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  21.2M|    talloc_set_destructor(bc, backup_dtor);
  ------------------
  |  |   41|  21.2M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  193|  21.2M|    *bc = (struct m_opt_backup) {
  194|  21.2M|        .co = co,
  195|  21.2M|        .backup = talloc_zero_size(bc, co->opt->type->size),
  ------------------
  |  |   44|  21.2M|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|  21.2M|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  21.2M|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  21.2M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  21.2M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.2M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  21.2M|        .nval = flags & BACKUP_NVAL
  ------------------
  |  |  187|  21.2M|#define BACKUP_NVAL 2
  ------------------
  |  Branch (196:17): [True: 0, False: 21.2M]
  ------------------
  197|  21.2M|            ? talloc_zero_size(bc, co->opt->type->size) : NULL,
  ------------------
  |  |   44|      0|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|      0|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|  21.2M|        .flags = flags,
  199|  21.2M|    };
  200|  21.2M|    m_option_copy(co->opt, bc->backup, co->data);
  201|  21.2M|    bc->next = *list;
  202|  21.2M|    *list = bc;
  203|  21.2M|    if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|  21.2M|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (203:9): [True: 0, False: 21.2M]
  ------------------
  204|      0|        co->is_set_locally = true;
  205|  21.2M|}
m_config_frontend.c:backup_dtor:
  179|  21.2M|{
  180|  21.2M|    struct m_opt_backup *bc = p;
  181|  21.2M|    m_option_free(bc->co->opt, bc->backup);
  182|  21.2M|    if (bc->nval)
  ------------------
  |  Branch (182:9): [True: 0, False: 21.2M]
  ------------------
  183|      0|        m_option_free(bc->co->opt, bc->nval);
  184|  21.2M|}
m_config_frontend.c:search_opt_name:
  293|  30.6M|{
  294|  30.6M|    const struct m_config_option *co = *(const struct m_config_option **)pelem;
  295|  30.6M|    return bstrcmp0(*(const bstr *)pkey, co->name);
  296|  30.6M|}
m_config_frontend.c:m_config_get_co_any:
  310|  2.75M|{
  311|  2.75M|    struct m_config_option *co = m_config_get_co_raw(config, name);
  312|  2.75M|    if (!co)
  ------------------
  |  Branch (312:9): [True: 318k, False: 2.43M]
  ------------------
  313|   318k|        return NULL;
  314|       |
  315|  2.43M|    const char *prefix = config->is_toplevel ? "--" : "";
  ------------------
  |  Branch (315:26): [True: 2.43M, False: 0]
  ------------------
  316|  2.43M|    if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (316:9): [True: 0, False: 2.43M]
  ------------------
  317|      0|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  318|      0|        const char *alias = m_config_shadow_get_alias_from_opt(config->shadow, co->opt_id,
  319|      0|                                                               buf, sizeof(buf));
  320|      0|        if (co->opt->deprecation_message && !co->warning_was_printed) {
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  |  Branch (320:45): [True: 0, False: 0]
  ------------------
  321|      0|            if (co->opt->deprecation_message[0]) {
  ------------------
  |  Branch (321:17): [True: 0, False: 0]
  ------------------
  322|      0|                MP_WARN(config, "Warning: option %s%s was replaced with "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  323|      0|                        "%s%s: %s\n", prefix, co->name, prefix, alias,
  324|      0|                        co->opt->deprecation_message);
  325|      0|            } else {
  326|      0|                MP_WARN(config, "Warning: option %s%s was replaced with "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  327|      0|                        "%s%s and might be removed in the future.\n",
  328|      0|                        prefix, co->name, prefix, alias);
  329|      0|            }
  330|      0|            co->warning_was_printed = true;
  331|      0|        }
  332|      0|        return m_config_get_co_any(config, bstr0(alias));
  333|  2.43M|    } else if (co->opt->type == &m_option_type_removed) {
  ------------------
  |  Branch (333:16): [True: 0, False: 2.43M]
  ------------------
  334|      0|        if (!co->warning_was_printed) {
  ------------------
  |  Branch (334:13): [True: 0, False: 0]
  ------------------
  335|      0|            char *msg = co->opt->priv;
  336|      0|            if (msg) {
  ------------------
  |  Branch (336:17): [True: 0, False: 0]
  ------------------
  337|      0|                MP_FATAL(config, "Option %s%s was removed: %s\n",
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  338|      0|                         prefix, co->name, msg);
  339|      0|            } else {
  340|      0|                MP_FATAL(config, "Option %s%s was removed.\n",
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  341|      0|                         prefix, co->name);
  342|      0|            }
  343|      0|            co->warning_was_printed = true;
  344|      0|        }
  345|      0|        return NULL;
  346|  2.43M|    } else if (co->opt->deprecation_message) {
  ------------------
  |  Branch (346:16): [True: 0, False: 2.43M]
  ------------------
  347|      0|        if (!co->warning_was_printed) {
  ------------------
  |  Branch (347:13): [True: 0, False: 0]
  ------------------
  348|      0|            MP_WARN(config, "Warning: option %s%s is deprecated "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  349|      0|                    "and might be removed in the future (%s).\n",
  350|      0|                    prefix, co->name, co->opt->deprecation_message);
  351|      0|            co->warning_was_printed = true;
  352|      0|        }
  353|      0|    }
  354|  2.43M|    return co;
  355|  2.43M|}
m_config_frontend.c:config_destroy:
  536|  28.9k|{
  537|  28.9k|    struct m_config *config = p;
  538|  28.9k|    config->option_change_callback = NULL;
  539|  28.9k|    m_config_restore_backups(config);
  540|       |
  541|  28.9k|    struct m_opt_backup **list = &config->watch_later_backup_opts;
  542|  21.2M|    while (*list) {
  ------------------
  |  Branch (542:12): [True: 21.2M, False: 28.9k]
  ------------------
  543|  21.2M|        struct m_opt_backup *bc = *list;
  544|  21.2M|        *list = bc->next;
  545|  21.2M|        talloc_free(bc);
  ------------------
  |  |   47|  21.2M|#define talloc_free                     ta_free
  ------------------
  546|  21.2M|    }
  547|       |
  548|  28.9k|    talloc_free(config->cache);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  549|  28.9k|    talloc_free(config->shadow);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  550|  28.9k|}
m_config_frontend.c:compare_opt_name:
  286|   178M|{
  287|   178M|    const struct m_config_option *a = *(const struct m_config_option **)pa;
  288|   178M|    const struct m_config_option *b = *(const struct m_config_option **)pb;
  289|   178M|    return strcmp(a->name, b->name);
  290|   178M|}
m_config_frontend.c:notify_opt:
  608|   153k|{
  609|  7.20M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (609:21): [True: 7.20M, False: 0]
  ------------------
  610|  7.20M|        struct m_config_option *co = &config->opts[n];
  611|  7.20M|        if (co->data == ptr) {
  ------------------
  |  Branch (611:13): [True: 153k, False: 7.05M]
  ------------------
  612|   153k|            if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (612:17): [True: 0, False: 153k]
  ------------------
  613|      0|                force_self_notify_change_opt(config, co, self_notification);
  614|   153k|            return;
  615|   153k|        }
  616|  7.20M|    }
  617|       |    // ptr doesn't point to any config->optstruct field declared in the
  618|       |    // option list?
  619|      0|    mp_assert(false);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (619:5): [Folded, False: 0]
  ------------------
  620|      0|}
m_config_frontend.c:handle_set_opt_flags:
  401|  4.19M|{
  402|  4.19M|    uint64_t optflags = co->opt->flags;
  403|  4.19M|    bool set = !(flags & M_SETOPT_CHECK_ONLY);
  404|       |
  405|  4.19M|    if ((flags & M_SETOPT_PRE_PARSE_ONLY) && !(optflags & M_OPT_PRE_PARSE))
  ------------------
  |  |  471|      0|#define M_OPT_PRE_PARSE         (UINT64_C(1) << 62)
  ------------------
  |  Branch (405:9): [True: 0, False: 4.19M]
  |  Branch (405:46): [True: 0, False: 0]
  ------------------
  406|      0|        return 0;
  407|       |
  408|  4.19M|    if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline)
  ------------------
  |  Branch (408:9): [True: 0, False: 4.19M]
  |  Branch (408:48): [True: 0, False: 0]
  ------------------
  409|      0|        set = false;
  410|       |
  411|  4.19M|    if ((flags & M_SETOPT_NO_OVERWRITE) &&
  ------------------
  |  Branch (411:9): [True: 0, False: 4.19M]
  ------------------
  412|      0|        (co->is_set_from_cmdline || co->is_set_from_config))
  ------------------
  |  Branch (412:10): [True: 0, False: 0]
  |  Branch (412:37): [True: 0, False: 0]
  ------------------
  413|      0|        set = false;
  414|       |
  415|  4.19M|    if ((flags & M_SETOPT_NO_PRE_PARSE) && (optflags & M_OPT_PRE_PARSE))
  ------------------
  |  |  471|      0|#define M_OPT_PRE_PARSE         (UINT64_C(1) << 62)
  ------------------
  |  Branch (415:9): [True: 0, False: 4.19M]
  |  Branch (415:44): [True: 0, False: 0]
  ------------------
  416|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  417|       |
  418|       |    // Check if this option isn't forbidden in the current mode
  419|  4.19M|    if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
  ------------------
  |  |  468|  3.93M|#define M_OPT_NOCFG             (UINT64_C(1) << 63)
  ------------------
  |  Branch (419:9): [True: 3.93M, False: 260k]
  |  Branch (419:48): [True: 0, False: 3.93M]
  ------------------
  420|      0|        MP_ERR(config, "The %s option can't be used in a config file.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  421|      0|               co->name);
  422|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  423|      0|    }
  424|  4.19M|    if ((flags & M_SETOPT_BACKUP) && set)
  ------------------
  |  Branch (424:9): [True: 0, False: 4.19M]
  |  Branch (424:38): [True: 0, False: 0]
  ------------------
  425|      0|        ensure_backup(&config->backup_opts, BACKUP_LOCAL, co);
  ------------------
  |  |  186|      0|#define BACKUP_LOCAL 1
  ------------------
  426|       |
  427|  4.19M|    return set ? 2 : 1;
  ------------------
  |  Branch (427:12): [True: 781k, False: 3.41M]
  ------------------
  428|  4.19M|}
m_config_frontend.c:m_config_handle_special_options:
  446|   521k|{
  447|   521k|    if (config->use_profiles && strcmp(co->name, "profile") == 0) {
  ------------------
  |  Branch (447:9): [True: 521k, False: 0]
  |  Branch (447:33): [True: 0, False: 521k]
  ------------------
  448|      0|        char **list = *(char ***)data;
  449|       |
  450|      0|        if (list && list[0] && !list[1] && strcmp(list[0], "help") == 0) {
  ------------------
  |  Branch (450:13): [True: 0, False: 0]
  |  Branch (450:21): [True: 0, False: 0]
  |  Branch (450:32): [True: 0, False: 0]
  |  Branch (450:44): [True: 0, False: 0]
  ------------------
  451|      0|            if (!config->profiles) {
  ------------------
  |  Branch (451:17): [True: 0, False: 0]
  ------------------
  452|      0|                MP_INFO(config, "No profiles have been defined.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  453|      0|                return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  454|      0|            }
  455|      0|            list_profiles(config);
  456|      0|            return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  457|      0|        }
  458|       |
  459|      0|        for (int n = 0; list && list[n]; n++) {
  ------------------
  |  Branch (459:25): [True: 0, False: 0]
  |  Branch (459:33): [True: 0, False: 0]
  ------------------
  460|      0|            int r = m_config_set_profile(config, list[n], flags);
  461|      0|            if (r < 0)
  ------------------
  |  Branch (461:17): [True: 0, False: 0]
  ------------------
  462|      0|                return r;
  463|      0|        }
  464|      0|        return 0;
  465|      0|    }
  466|       |
  467|   521k|    if (config->includefunc && strcmp(co->name, "include") == 0) {
  ------------------
  |  Branch (467:9): [True: 521k, False: 0]
  |  Branch (467:32): [True: 0, False: 521k]
  ------------------
  468|      0|        char *param = *(char **)data;
  469|      0|        if (!param || !param[0])
  ------------------
  |  Branch (469:13): [True: 0, False: 0]
  |  Branch (469:23): [True: 0, False: 0]
  ------------------
  470|      0|            return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  471|      0|        if (config->recursion_depth >= MAX_RECURSION_DEPTH) {
  ------------------
  |  |   45|      0|#define MAX_RECURSION_DEPTH 8
  ------------------
  |  Branch (471:13): [True: 0, False: 0]
  ------------------
  472|      0|            MP_ERR(config, "Maximum 'include' nesting depth exceeded.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  473|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  474|      0|        }
  475|      0|        config->recursion_depth += 1;
  476|      0|        config->includefunc(config->includefunc_ctx, param, flags);
  477|      0|        config->recursion_depth -= 1;
  478|      0|        if (config->recursion_depth == 0 && config->profile_stack_depth == 0)
  ------------------
  |  Branch (478:13): [True: 0, False: 0]
  |  Branch (478:45): [True: 0, False: 0]
  ------------------
  479|      0|            m_config_finish_default_profile(config, flags);
  480|      0|        return 1;
  481|      0|    }
  482|       |
  483|   521k|    if (config->use_profiles && strcmp(co->name, "show-profile") == 0)
  ------------------
  |  Branch (483:9): [True: 521k, False: 0]
  |  Branch (483:33): [True: 0, False: 521k]
  ------------------
  484|      0|        return show_profile(config, bstr0(*(char **)data), 0);
  485|       |
  486|   521k|    if (config->is_toplevel && (strcmp(co->name, "h") == 0 ||
  ------------------
  |  Branch (486:9): [True: 521k, False: 0]
  |  Branch (486:33): [True: 0, False: 521k]
  ------------------
  487|   521k|                                strcmp(co->name, "help") == 0))
  ------------------
  |  Branch (487:33): [True: 0, False: 521k]
  ------------------
  488|      0|    {
  489|      0|        char *h = *(char **)data;
  490|      0|        mp_info(config->log, "%s", mp_help_text);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  491|      0|        if (h && h[0])
  ------------------
  |  Branch (491:13): [True: 0, False: 0]
  |  Branch (491:18): [True: 0, False: 0]
  ------------------
  492|      0|            m_config_print_option_list(config, h);
  493|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  494|      0|    }
  495|       |
  496|   521k|    if (strcmp(co->name, "list-options") == 0) {
  ------------------
  |  Branch (496:9): [True: 0, False: 521k]
  ------------------
  497|      0|        m_config_print_option_list(config, "*");
  498|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  499|      0|    }
  500|       |
  501|   521k|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|   521k|#define M_OPT_UNKNOWN           -1
  ------------------
  502|   521k|}
m_config_frontend.c:force_self_notify_change_opt:
  597|   521k|{
  598|   521k|    int changed =
  599|   521k|        m_config_cache_get_option_change_mask(config->cache, co->opt_id);
  600|       |
  601|   521k|    if (config->option_change_callback) {
  ------------------
  |  Branch (601:9): [True: 0, False: 521k]
  ------------------
  602|      0|        config->option_change_callback(config->option_change_callback_ctx, co,
  603|      0|                                       changed, self_notification);
  604|      0|    }
  605|   521k|}
m_config_frontend.c:m_config_mogrify_cli_opt:
  673|  2.11M|{
  674|  2.11M|    *out_negate = false;
  675|  2.11M|    *out_add_flags = 0;
  676|       |
  677|  2.11M|    struct m_config_option *co = m_config_get_co(config, *name);
  678|  2.11M|    if (co)
  ------------------
  |  Branch (678:9): [True: 1.76M, False: 347k]
  ------------------
  679|  1.76M|        return co;
  680|       |
  681|       |    // Turn "--no-foo" into "foo" + set *out_negate.
  682|   347k|    bstr no_name = *name;
  683|   347k|    if (!co && bstr_eatstart0(&no_name, "no-")) {
  ------------------
  |  Branch (683:9): [True: 347k, False: 0]
  |  Branch (683:16): [True: 0, False: 347k]
  ------------------
  684|      0|        co = m_config_get_co(config, no_name);
  685|      0|        if (!co)
  ------------------
  |  Branch (685:13): [True: 0, False: 0]
  ------------------
  686|      0|            return NULL;
  687|       |
  688|       |        // Not all choice types have this value - if they don't, then parsing
  689|       |        // them will simply result in an error. Good enough.
  690|      0|        if (!(co->opt->type->flags & M_OPT_TYPE_CHOICE) &&
  ------------------
  |  |  512|      0|#define M_OPT_TYPE_CHOICE               (1 << 1)
  ------------------
  |  Branch (690:13): [True: 0, False: 0]
  ------------------
  691|      0|            !(co->opt->flags & M_OPT_ALLOW_NO))
  ------------------
  |  |  488|      0|#define M_OPT_ALLOW_NO          (UINT64_C(1) << 57)
  ------------------
  |  Branch (691:13): [True: 0, False: 0]
  ------------------
  692|      0|            return NULL;
  693|       |
  694|      0|        *name = no_name;
  695|      0|        *out_negate = true;
  696|      0|        return co;
  697|      0|    }
  698|       |
  699|       |    // Resolve CLI alias. (We don't allow you to combine them with "--no-".)
  700|   347k|    co = m_config_get_co_any(config, *name);
  701|   347k|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (701:9): [True: 202k, False: 144k]
  |  Branch (701:15): [True: 202k, False: 0]
  ------------------
  702|   202k|        *name = bstr0((char *)co->opt->priv);
  703|       |
  704|       |    // Might be a suffix "action", like "--vf-add". Expensively check for
  705|       |    // matches. (We don't allow you to combine them with "--no-".)
  706|   119M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (706:21): [True: 119M, False: 144k]
  ------------------
  707|   119M|        co = &config->opts[n];
  708|   119M|        struct bstr basename = bstr0(co->name);
  709|       |
  710|   119M|        if (!bstr_startswith(*name, basename))
  ------------------
  |  Branch (710:13): [True: 118M, False: 492k]
  ------------------
  711|   118M|            continue;
  712|       |
  713|       |        // Aliased option + a suffix action, e.g. --opengl-shaders-append
  714|   492k|        if (co->opt->type == &m_option_type_alias)
  ------------------
  |  Branch (714:13): [True: 0, False: 492k]
  ------------------
  715|      0|            co = m_config_get_co_any(config, basename);
  716|   492k|        if (!co)
  ------------------
  |  Branch (716:13): [True: 0, False: 492k]
  ------------------
  717|      0|            continue;
  718|       |
  719|   492k|        const struct m_option_type *type = co->opt->type;
  720|   694k|        for (int i = 0; type->actions && type->actions[i].name; i++) {
  ------------------
  |  Branch (720:25): [True: 405k, False: 289k]
  |  Branch (720:42): [True: 405k, False: 0]
  ------------------
  721|   405k|            const struct m_option_action *action = &type->actions[i];
  722|   405k|            bstr suffix = bstr0(action->name);
  723|       |
  724|   405k|            if (bstr_endswith(*name, suffix) &&
  ------------------
  |  Branch (724:17): [True: 202k, False: 202k]
  ------------------
  725|   202k|                (name->len == basename.len + 1 + suffix.len) &&
  ------------------
  |  Branch (725:17): [True: 202k, False: 0]
  ------------------
  726|   202k|                name->start[basename.len] == '-')
  ------------------
  |  Branch (726:17): [True: 202k, False: 0]
  ------------------
  727|   202k|            {
  728|   202k|                *out_add_flags = action->flags;
  729|   202k|                return co;
  730|   202k|            }
  731|   405k|        }
  732|   492k|    }
  733|       |
  734|   144k|    return NULL;
  735|   347k|}
m_config_frontend.c:find_check_profile:
 1001|  57.9k|{
 1002|  57.9k|    struct m_profile *p = m_config_get_profile0(config, name);
 1003|  57.9k|    if (!p) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 57.9k]
  ------------------
 1004|      0|        MP_WARN(config, "Unknown profile '%s'.\n", name);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1005|      0|        return NULL;
 1006|      0|    }
 1007|  57.9k|    for (size_t i = 0; i < config->profile_stack_depth; ++i) {
  ------------------
  |  Branch (1007:24): [True: 0, False: 57.9k]
  ------------------
 1008|      0|        if (strcmp(config->profile_stack[i], name))
  ------------------
  |  Branch (1008:13): [True: 0, False: 0]
  ------------------
 1009|      0|            continue;
 1010|      0|        MP_WARN(config, "Profile '%s' has already been applied.\n", name);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1011|      0|        return NULL;
 1012|      0|    }
 1013|  57.9k|    if (config->profile_stack_depth > MAX_PROFILE_DEPTH) {
  ------------------
  |  |   43|  57.9k|#define MAX_PROFILE_DEPTH 20
  ------------------
  |  Branch (1013:9): [True: 0, False: 57.9k]
  ------------------
 1014|      0|        MP_WARN(config, "Profile inclusion too deep.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1015|      0|        return NULL;
 1016|      0|    }
 1017|  57.9k|    return p;
 1018|  57.9k|}

m_option_parse:
   65|  2.25M|{
   66|  2.25M|    int r = M_OPT_INVALID;
  ------------------
  |  |  535|  2.25M|#define M_OPT_INVALID           -3
  ------------------
   67|  2.25M|    if (bstr_equals0(param, "help") && opt->help) {
  ------------------
  |  Branch (67:9): [True: 0, False: 2.25M]
  |  Branch (67:40): [True: 0, False: 0]
  ------------------
   68|      0|        r = opt->help(log, opt, name);
   69|      0|        if (r < 0)
  ------------------
  |  Branch (69:13): [True: 0, False: 0]
  ------------------
   70|      0|            return r;
   71|      0|    }
   72|       |
   73|  2.25M|    r = opt->type->parse(log, opt, name, param, dst);
   74|  2.25M|    if (r < 0)
  ------------------
  |  Branch (74:9): [True: 0, False: 2.25M]
  ------------------
   75|      0|        return r;
   76|       |
   77|  2.25M|    if (opt->validate) {
  ------------------
  |  Branch (77:9): [True: 0, False: 2.25M]
  ------------------
   78|      0|        r = opt->validate(log, opt, name, dst);
   79|      0|        if (r < 0) {
  ------------------
  |  Branch (79:13): [True: 0, False: 0]
  ------------------
   80|      0|            if (opt->type->free)
  ------------------
  |  Branch (80:17): [True: 0, False: 0]
  ------------------
   81|      0|                opt->type->free(dst);
   82|      0|            return r;
   83|      0|        }
   84|      0|    }
   85|  2.25M|    return 1;
   86|  2.25M|}
m_option_strerror:
   89|   144k|{
   90|   144k|    switch (code) {
   91|   144k|    case M_OPT_UNKNOWN:
  ------------------
  |  |  529|   144k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (91:5): [True: 144k, False: 0]
  ------------------
   92|   144k|        return "option not found";
   93|      0|    case M_OPT_MISSING_PARAM:
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (93:5): [True: 0, False: 144k]
  ------------------
   94|      0|        return "option requires parameter";
   95|      0|    case M_OPT_INVALID:
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (95:5): [True: 0, False: 144k]
  ------------------
   96|      0|        return "option parameter could not be parsed";
   97|      0|    case M_OPT_OUT_OF_RANGE:
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  |  Branch (97:5): [True: 0, False: 144k]
  ------------------
   98|      0|        return "parameter is outside values allowed for option";
   99|      0|    case M_OPT_DISALLOW_PARAM:
  ------------------
  |  |  542|      0|#define M_OPT_DISALLOW_PARAM    -5
  ------------------
  |  Branch (99:5): [True: 0, False: 144k]
  ------------------
  100|      0|        return "option doesn't take a parameter";
  101|      0|    default:
  ------------------
  |  Branch (101:5): [True: 0, False: 144k]
  ------------------
  102|      0|        return "parser error";
  103|   144k|    }
  104|   144k|}
m_option_set_node_or_string:
  124|   289k|{
  125|   289k|    if (src->format == MPV_FORMAT_STRING) {
  ------------------
  |  Branch (125:9): [True: 289k, False: 0]
  ------------------
  126|   289k|        return m_option_parse(log, opt, name, bstr0(src->u.string), dst);
  127|   289k|    } else {
  128|      0|        return m_option_set_node(opt, dst, src);
  129|      0|    }
  130|   289k|}
m_opt_choice_str:
  608|   100k|{
  609|   100k|    const char *val = m_opt_choice_str_def(choices, value, NULL);
  610|   100k|    if (val)
  ------------------
  |  Branch (610:9): [True: 100k, False: 0]
  ------------------
  611|   100k|        return val;
  612|      0|    return "<unknown>";
  613|   100k|}
m_opt_choice_str_def:
  617|   100k|{
  618|   360k|    for (const struct m_opt_choice_alternatives *c = choices; c->name; c++) {
  ------------------
  |  Branch (618:63): [True: 360k, False: 0]
  ------------------
  619|   360k|        if (c->value == value)
  ------------------
  |  Branch (619:13): [True: 100k, False: 260k]
  ------------------
  620|   100k|            return c->name;
  621|   360k|    }
  622|      0|    return def;
  623|   100k|}
m_obj_list_find:
 3045|   133k|{
 3046|   509k|    for (int i = 0; ; i++) {
 3047|   509k|        if (!l->get_desc(dst, i))
  ------------------
  |  Branch (3047:13): [True: 0, False: 509k]
  ------------------
 3048|      0|            break;
 3049|   509k|        if (bstr_equals0(name, dst->name))
  ------------------
  |  Branch (3049:13): [True: 133k, False: 376k]
  ------------------
 3050|   133k|            return true;
 3051|   509k|    }
 3052|      0|    for (int i = 0; l->aliases[i][0]; i++) {
  ------------------
  |  Branch (3052:21): [True: 0, False: 0]
  ------------------
 3053|      0|        const char *aname = l->aliases[i][0];
 3054|      0|        const char *alias = l->aliases[i][1];
 3055|      0|        if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias)))
  ------------------
  |  Branch (3055:13): [True: 0, False: 0]
  |  Branch (3055:42): [True: 0, False: 0]
  ------------------
 3056|      0|        {
 3057|      0|            dst->replaced_name = aname;
 3058|      0|            return true;
 3059|      0|        }
 3060|      0|    }
 3061|      0|    return false;
 3062|      0|}
node_get_alloc:
 4018|  86.8k|{
 4019|       |    // Assume it was allocated with copy_node(), which allocates all
 4020|       |    // sub-nodes with the parent node as talloc parent.
 4021|  86.8k|    switch (node->format) {
 4022|      0|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (4022:5): [True: 0, False: 86.8k]
  ------------------
 4023|      0|        return node->u.string;
 4024|      0|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (4024:5): [True: 0, False: 86.8k]
  ------------------
 4025|  28.9k|    case MPV_FORMAT_NODE_MAP:
  ------------------
  |  Branch (4025:5): [True: 28.9k, False: 57.9k]
  ------------------
 4026|  28.9k|        return node->u.list;
 4027|  57.9k|    default:
  ------------------
  |  Branch (4027:5): [True: 57.9k, False: 28.9k]
  ------------------
 4028|       |        return NULL;
 4029|  86.8k|    }
 4030|  86.8k|}
m_option.c:parse_bool:
  146|   839k|{
  147|   839k|    if (bstr_equals0(param, "yes") || !param.len) {
  ------------------
  |  Branch (147:9): [True: 144k, False: 694k]
  |  Branch (147:39): [True: 0, False: 694k]
  ------------------
  148|   144k|        if (dst)
  ------------------
  |  Branch (148:13): [True: 144k, False: 0]
  ------------------
  149|   144k|            VAL(dst) = 1;
  ------------------
  |  |  142|   144k|#define VAL(x) (*(bool *)(x))
  ------------------
  150|   144k|        return 1;
  151|   144k|    }
  152|   694k|    if (bstr_equals0(param, "no")) {
  ------------------
  |  Branch (152:9): [True: 694k, False: 0]
  ------------------
  153|   694k|        if (dst)
  ------------------
  |  Branch (153:13): [True: 694k, False: 0]
  ------------------
  154|   694k|            VAL(dst) = 0;
  ------------------
  |  |  142|   694k|#define VAL(x) (*(bool *)(x))
  ------------------
  155|   694k|        return 1;
  156|   694k|    }
  157|   694k|    bool is_help = bstr_equals0(param, "help");
  158|      0|    if (is_help) {
  ------------------
  |  Branch (158:9): [True: 0, False: 0]
  ------------------
  159|      0|        mp_info(log, "Valid values for %.*s flag are:\n", BSTR_P(name));
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  160|      0|    } else {
  161|      0|        mp_fatal(log, "Invalid parameter for %.*s flag: %.*s\n",
  ------------------
  |  |   75|      0|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 0, False: 0]
  |  |  |  Branch (75:57): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  162|      0|                 BSTR_P(name), BSTR_P(param));
  163|      0|        mp_info(log, "Valid values are:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  164|      0|    }
  165|      0|    mp_info(log, "    yes\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  166|      0|    mp_info(log, "    no\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  167|      0|    mp_info(log, "    (passing nothing)\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  168|      0|    return is_help ? M_OPT_EXIT : M_OPT_INVALID;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
                  return is_help ? M_OPT_EXIT : M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (168:12): [True: 0, False: 0]
  ------------------
  169|   694k|}
m_option.c:copy_opt:
  135|  20.0M|{
  136|  20.0M|    if (dst && src)
  ------------------
  |  Branch (136:9): [True: 20.0M, False: 0]
  |  Branch (136:16): [True: 20.0M, False: 0]
  ------------------
  137|  20.0M|        memcpy(dst, src, opt->type->size);
  138|  20.0M|}
m_option.c:bool_equal:
  202|   816k|{
  203|   816k|    return VAL(a) == VAL(b);
  ------------------
  |  |  142|   816k|#define VAL(x) (*(bool *)(x))
  ------------------
                  return VAL(a) == VAL(b);
  ------------------
  |  |  142|   816k|#define VAL(x) (*(bool *)(x))
  ------------------
  204|   816k|}
m_option.c:parse_int:
  352|  28.9k|{
  353|  28.9k|    long long tmp;
  354|  28.9k|    int r = parse_longlong(log, opt, INT_MIN, INT_MAX, name, param, &tmp);
  355|  28.9k|    if (r >= 0 && dst)
  ------------------
  |  Branch (355:9): [True: 28.9k, False: 0]
  |  Branch (355:19): [True: 28.9k, False: 0]
  ------------------
  356|  28.9k|        *(int *)dst = tmp;
  357|  28.9k|    return r;
  358|  28.9k|}
m_option.c:parse_longlong:
  308|  28.9k|{
  309|  28.9k|    if (param.len == 0)
  ------------------
  |  Branch (309:9): [True: 0, False: 28.9k]
  ------------------
  310|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  311|       |
  312|  28.9k|    struct bstr rest;
  313|  28.9k|    long long tmp_int = bstrtoll(param, &rest, 10);
  314|  28.9k|    if (rest.len)
  ------------------
  |  Branch (314:9): [True: 0, False: 28.9k]
  ------------------
  315|      0|        tmp_int = bstrtoll(param, &rest, 0);
  316|  28.9k|    if (rest.len) {
  ------------------
  |  Branch (316:9): [True: 0, False: 28.9k]
  ------------------
  317|      0|        mp_err(log, "The %.*s option must be an integer: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  318|      0|               BSTR_P(name), BSTR_P(param));
  319|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  320|      0|    }
  321|       |
  322|  28.9k|    long long min = OPT_INT_MIN(opt, long long, i_min);
  ------------------
  |  |   58|  28.9k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   59|  28.9k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 28.9k]
  |  |  ------------------
  ------------------
  323|  28.9k|    if (tmp_int < min) {
  ------------------
  |  Branch (323:9): [True: 0, False: 28.9k]
  ------------------
  324|      0|        mp_err(log, "The %.*s option must be >= %lld: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  325|      0|               BSTR_P(name), min, BSTR_P(param));
  326|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  327|      0|    }
  328|       |
  329|  28.9k|    long long max = OPT_INT_MAX(opt, long long, i_max);
  ------------------
  |  |   60|  28.9k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   61|  28.9k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 28.9k, False: 0]
  |  |  ------------------
  ------------------
  330|  28.9k|    if (tmp_int > max) {
  ------------------
  |  Branch (330:9): [True: 0, False: 28.9k]
  ------------------
  331|      0|        mp_err(log, "The %.*s option must be <= %lld: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  332|      0|               BSTR_P(name), max, BSTR_P(param));
  333|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  334|      0|    }
  335|       |
  336|  28.9k|    if (dst)
  ------------------
  |  Branch (336:9): [True: 28.9k, False: 0]
  ------------------
  337|  28.9k|        *(long long *)dst = tmp_int;
  338|       |
  339|  28.9k|    return 1;
  340|  28.9k|}
m_option.c:print_int:
  371|  86.8k|{
  372|  86.8k|    if (opt->type->size == sizeof(int64_t))
  ------------------
  |  Branch (372:9): [True: 0, False: 86.8k]
  ------------------
  373|      0|        return talloc_asprintf(NULL, "%"PRId64, *(const int64_t *)val);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  374|  86.8k|    return talloc_asprintf(NULL, "%d", *(const int *)val);
  ------------------
  |  |   52|  86.8k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  86.8k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  375|  86.8k|}
m_option.c:int_equal:
  468|   176k|{
  469|   176k|    return *(int *)a == *(int *)b;
  470|   176k|}
m_option.c:parse_byte_size:
  507|  28.9k|{
  508|  28.9k|    if (param.len == 0)
  ------------------
  |  Branch (508:9): [True: 0, False: 28.9k]
  ------------------
  509|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  510|       |
  511|  28.9k|    struct bstr r;
  512|  28.9k|    long long tmp_int = bstrtoll(param, &r, 0);
  513|  28.9k|    int64_t unit = 1;
  514|  28.9k|    if (r.len) {
  ------------------
  |  Branch (514:9): [True: 28.9k, False: 0]
  ------------------
  515|  28.9k|        if (bstrcasecmp0(r, "b") == 0) {
  ------------------
  |  Branch (515:13): [True: 0, False: 28.9k]
  ------------------
  516|      0|            unit = 1;
  517|  28.9k|        } else if (bstrcasecmp0(r, "kib") == 0 || bstrcasecmp0(r, "k") == 0) {
  ------------------
  |  Branch (517:20): [True: 0, False: 28.9k]
  |  Branch (517:51): [True: 28.9k, False: 0]
  ------------------
  518|  28.9k|            unit = 1024;
  519|  28.9k|        } else if (bstrcasecmp0(r, "mib") == 0 || bstrcasecmp0(r, "m") == 0) {
  ------------------
  |  Branch (519:20): [True: 0, False: 0]
  |  Branch (519:51): [True: 0, False: 0]
  ------------------
  520|      0|            unit = 1024 * 1024;
  521|      0|        } else if (bstrcasecmp0(r, "gib") == 0 || bstrcasecmp0(r, "g") == 0) {
  ------------------
  |  Branch (521:20): [True: 0, False: 0]
  |  Branch (521:51): [True: 0, False: 0]
  ------------------
  522|      0|            unit = 1024 * 1024 * 1024;
  523|      0|        } else if (bstrcasecmp0(r, "tib") == 0 || bstrcasecmp0(r, "t") == 0) {
  ------------------
  |  Branch (523:20): [True: 0, False: 0]
  |  Branch (523:51): [True: 0, False: 0]
  ------------------
  524|      0|            unit = 1024 * 1024 * 1024 * 1024LL;
  525|      0|        } else {
  526|      0|            mp_err(log, "The %.*s option must be an integer: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  527|      0|                   BSTR_P(name), BSTR_P(param));
  528|      0|            mp_err(log, "The following suffixes are also allowed: "
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  529|      0|                   "KiB, MiB, GiB, TiB, B, K, M, G, T.\n");
  530|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  531|      0|        }
  532|  28.9k|    }
  533|       |
  534|  28.9k|    if (tmp_int < 0) {
  ------------------
  |  Branch (534:9): [True: 0, False: 28.9k]
  ------------------
  535|      0|        mp_err(log, "The %.*s option does not support negative numbers: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  536|      0|               BSTR_P(name), BSTR_P(param));
  537|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  538|      0|    }
  539|       |
  540|  28.9k|    if (INT64_MAX / unit < tmp_int) {
  ------------------
  |  Branch (540:9): [True: 0, False: 28.9k]
  ------------------
  541|      0|        mp_err(log, "The %.*s option overflows: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  542|      0|               BSTR_P(name), BSTR_P(param));
  543|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  544|      0|    }
  545|       |
  546|  28.9k|    tmp_int *= unit;
  547|       |
  548|  28.9k|    int64_t min = OPT_INT_MIN(opt, int64_t, INT64_MIN);
  ------------------
  |  |   58|  28.9k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   59|  28.9k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 28.9k]
  |  |  ------------------
  ------------------
  549|  28.9k|    if (tmp_int < min) {
  ------------------
  |  Branch (549:9): [True: 0, False: 28.9k]
  ------------------
  550|      0|        mp_err(log, "The %.*s option must be >= %"PRId64": %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  551|      0|               BSTR_P(name), min, BSTR_P(param));
  552|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  553|      0|    }
  554|       |
  555|  28.9k|    int64_t max = OPT_INT_MAX(opt, int64_t, INT64_MAX);
  ------------------
  |  |   60|  28.9k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 28.9k, False: 0]
  |  |  ------------------
  |  |   61|  28.9k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 0, False: 28.9k]
  |  |  ------------------
  ------------------
  556|  28.9k|    if (tmp_int > max) {
  ------------------
  |  Branch (556:9): [True: 0, False: 28.9k]
  ------------------
  557|      0|        mp_err(log, "The %.*s option must be <= %"PRId64": %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  558|      0|               BSTR_P(name), max, BSTR_P(param));
  559|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  560|      0|    }
  561|       |
  562|  28.9k|    if (dst)
  ------------------
  |  Branch (562:9): [True: 28.9k, False: 0]
  ------------------
  563|  28.9k|        *(int64_t *)dst = tmp_int;
  564|       |
  565|  28.9k|    return 1;
  566|  28.9k|}
m_option.c:parse_choice:
  636|   550k|{
  637|   550k|    const struct m_opt_choice_alternatives *alt = opt->priv;
  638|  1.88M|    for ( ; alt->name; alt++) {
  ------------------
  |  Branch (638:13): [True: 1.88M, False: 0]
  ------------------
  639|  1.88M|        if (!bstrcmp0(param, alt->name))
  ------------------
  |  Branch (639:13): [True: 550k, False: 1.33M]
  ------------------
  640|   550k|            break;
  641|  1.88M|    }
  642|   550k|    if (!alt->name && param.len == 0) {
  ------------------
  |  Branch (642:9): [True: 0, False: 550k]
  |  Branch (642:23): [True: 0, False: 0]
  ------------------
  643|       |        // allow flag-style options, e.g. "--mute" implies "--mute=yes"
  644|      0|        for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (644:31): [True: 0, False: 0]
  ------------------
  645|      0|            if (!strcmp("yes", alt->name))
  ------------------
  |  Branch (645:17): [True: 0, False: 0]
  ------------------
  646|      0|                break;
  647|      0|        }
  648|      0|    }
  649|   550k|    if (!alt->name) {
  ------------------
  |  Branch (649:9): [True: 0, False: 550k]
  ------------------
  650|      0|        if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (650:13): [True: 0, False: 0]
  ------------------
  651|      0|            mp_info(log, "Valid values for option %.*s are:\n", BSTR_P(name));
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  652|      0|            print_choice_values(log, opt);
  653|      0|            return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  654|      0|        }
  655|      0|        if (param.len == 0)
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  657|      0|        if (opt->min < opt->max) {
  ------------------
  |  Branch (657:13): [True: 0, False: 0]
  ------------------
  658|      0|            long long val;
  659|      0|            if (parse_longlong(mp_null_log, opt, INT_MIN, INT_MAX, name, param,
  ------------------
  |  Branch (659:17): [True: 0, False: 0]
  ------------------
  660|      0|                               &val) == 1)
  661|      0|            {
  662|      0|                if (dst)
  ------------------
  |  Branch (662:21): [True: 0, False: 0]
  ------------------
  663|      0|                    *(int *)dst = val;
  664|      0|                return 1;
  665|      0|            }
  666|      0|        }
  667|      0|        mp_fatal(log, "Invalid value for option %.*s: %.*s\n",
  ------------------
  |  |   75|      0|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 0, False: 0]
  |  |  |  Branch (75:57): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  668|      0|                 BSTR_P(name), BSTR_P(param));
  669|      0|        mp_info(log, "Valid values are:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  670|      0|        print_choice_values(log, opt);
  671|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  672|      0|    }
  673|   550k|    if (dst)
  ------------------
  |  Branch (673:9): [True: 550k, False: 0]
  ------------------
  674|   550k|        *(int *)dst = alt->value;
  675|       |
  676|   550k|    return 1;
  677|   550k|}
m_option.c:print_flags:
  933|  28.9k|{
  934|  28.9k|    int value = *(int *)val;
  935|  28.9k|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  28.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
  936|  28.9k|    while (1) {
  ------------------
  |  Branch (936:12): [True: 28.9k, Folded]
  ------------------
  937|  28.9k|        const char *flag = find_next_flag(opt, &value);
  938|  28.9k|        if (!flag)
  ------------------
  |  Branch (938:13): [True: 28.9k, False: 0]
  ------------------
  939|  28.9k|            break;
  940|       |
  941|      0|        res = talloc_asprintf_append_buffer(res, "%s%s", res[0] ? "+" : "", flag);
  ------------------
  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  |  Branch (941:58): [True: 0, False: 0]
  ------------------
  942|      0|    }
  943|  28.9k|    return res;
  944|  28.9k|}
m_option.c:find_next_flag:
  849|  28.9k|{
  850|  28.9k|    const struct m_opt_choice_alternatives *best = NULL;
  851|  28.9k|    const struct m_opt_choice_alternatives *alt;
  852|   260k|    for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (852:27): [True: 231k, False: 28.9k]
  ------------------
  853|   231k|        if (alt->value && (alt->value & (*val)) == alt->value) {
  ------------------
  |  Branch (853:13): [True: 231k, False: 0]
  |  Branch (853:27): [True: 0, False: 231k]
  ------------------
  854|      0|            if (!best || av_popcount64(alt->value) > av_popcount64(best->value))
  ------------------
  |  Branch (854:17): [True: 0, False: 0]
  |  Branch (854:26): [True: 0, False: 0]
  ------------------
  855|      0|                best = alt;
  856|      0|        }
  857|   231k|    }
  858|  28.9k|    if (best) {
  ------------------
  |  Branch (858:9): [True: 0, False: 28.9k]
  ------------------
  859|      0|        *val = *val & ~(unsigned)best->value;
  860|      0|        return best->name;
  861|      0|    }
  862|  28.9k|    *val = 0; // if there are still flags left, there's not much we can do
  863|       |    return NULL;
  864|  28.9k|}
m_option.c:parse_double:
 1021|  86.8k|{
 1022|  86.8k|    double tmp;
 1023|  86.8k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_double);
 1024|  86.8k|    if (r == 1 && dst)
  ------------------
  |  Branch (1024:9): [True: 86.8k, False: 0]
  |  Branch (1024:19): [True: 86.8k, False: 0]
  ------------------
 1025|  86.8k|        VAL(dst) = tmp;
  ------------------
  |  |  960|  86.8k|#define VAL(x) (*(double *)(x))
  ------------------
 1026|  86.8k|    return r;
 1027|  86.8k|}
m_option.c:parse_numeric:
  988|   318k|{
  989|   318k|    if (param.len == 0)
  ------------------
  |  Branch (989:9): [True: 0, False: 318k]
  ------------------
  990|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  991|       |
  992|   318k|    struct bstr rest;
  993|   318k|    *out = bstrtod(param, &rest);
  994|       |
  995|   318k|    if (bstr_eatstart0(&rest, ":") || bstr_eatstart0(&rest, "/"))
  ------------------
  |  Branch (995:9): [True: 0, False: 318k]
  |  Branch (995:39): [True: 0, False: 318k]
  ------------------
  996|      0|        *out /= bstrtod(rest, &rest);
  997|       |
  998|   318k|    if ((opt->flags & M_OPT_DEFAULT_NAN) && bstr_equals0(param, "default")) {
  ------------------
  |  |  483|   318k|#define M_OPT_DEFAULT_NAN       (UINT64_C(1) << 58)
  ------------------
  |  Branch (998:9): [True: 0, False: 318k]
  |  Branch (998:45): [True: 0, False: 0]
  ------------------
  999|      0|        *out = NAN;
 1000|      0|        return 1;
 1001|      0|    }
 1002|       |
 1003|   318k|    if (rest.len) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 318k]
  ------------------
 1004|      0|        mp_err(log, "The %.*s option must be a floating point number or a "
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1005|      0|               "ratio (numerator[:/]denominator): %.*s\n",
 1006|      0|               BSTR_P(name), BSTR_P(param));
 1007|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1008|      0|    }
 1009|       |
 1010|   318k|    if (clamp(opt, out) < 0) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 318k]
  ------------------
 1011|      0|        mp_err(log, "The %.*s option is out of range: %.*s\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1012|      0|               BSTR_P(name), BSTR_P(param));
 1013|      0|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
 1014|      0|    }
 1015|       |
 1016|   318k|    return 1;
 1017|   318k|}
m_option.c:clamp_double:
  963|   318k|{
  964|   318k|    double v = *val;
  965|   318k|    int r = 0;
  966|   318k|    if (opt->min < opt->max) {
  ------------------
  |  Branch (966:9): [True: 202k, False: 115k]
  ------------------
  967|   202k|        if (v > opt->max) {
  ------------------
  |  Branch (967:13): [True: 0, False: 202k]
  ------------------
  968|      0|            v = opt->max;
  969|      0|            r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  970|      0|        }
  971|   202k|        if (v < opt->min) {
  ------------------
  |  Branch (971:13): [True: 0, False: 202k]
  ------------------
  972|      0|            v = opt->min;
  973|      0|            r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  974|      0|        }
  975|   202k|    }
  976|       |    // (setting max/min to INFINITY/-INFINITY is allowed)
  977|   318k|    if (!isfinite(v) && v != opt->max && v != opt->min) {
  ------------------
  |  Branch (977:9): [True: 0, False: 318k]
  |  Branch (977:25): [True: 0, False: 0]
  |  Branch (977:42): [True: 0, False: 0]
  ------------------
  978|      0|        v = opt->min;
  979|      0|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  980|      0|    }
  981|   318k|    *val = v;
  982|   318k|    return r;
  983|   318k|}
m_option.c:double_equal:
 1100|  57.9k|{
 1101|  57.9k|    double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  57.9k|#define VAL(x) (*(double *)(x))
  ------------------
                  double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  57.9k|#define VAL(x) (*(double *)(x))
  ------------------
 1102|  57.9k|    if (isnan(fa) || isnan(fb))
  ------------------
  |  Branch (1102:9): [True: 0, False: 57.9k]
  |  Branch (1102:22): [True: 0, False: 57.9k]
  ------------------
 1103|      0|        return isnan(fa) == isnan(fb);
 1104|  57.9k|    return fa == fb;
 1105|  57.9k|}
m_option.c:parse_float:
 1172|   231k|{
 1173|   231k|    double tmp;
 1174|   231k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_float);
 1175|   231k|    if (r == 1 && dst)
  ------------------
  |  Branch (1175:9): [True: 231k, False: 0]
  |  Branch (1175:19): [True: 231k, False: 0]
  ------------------
 1176|   231k|        VAL(dst) = tmp;
  ------------------
  |  | 1150|   231k|#define VAL(x) (*(float *)(x))
  ------------------
 1177|   231k|    return r;
 1178|   231k|}
m_option.c:clamp_float:
 1153|   231k|{
 1154|   231k|    double v = *val;
 1155|   231k|    int r = clamp_double(opt, &v);
 1156|       |    // Handle the case where range is not set and v is finite
 1157|       |    // but overflows the float range.
 1158|   231k|    if (isfinite(v) && v > FLT_MAX) {
  ------------------
  |  Branch (1158:9): [True: 231k, False: 0]
  |  Branch (1158:24): [True: 0, False: 231k]
  ------------------
 1159|      0|        v = FLT_MAX;
 1160|      0|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
 1161|      0|    }
 1162|   231k|    if (isfinite(v) && v < -FLT_MAX) {
  ------------------
  |  Branch (1162:9): [True: 231k, False: 0]
  |  Branch (1162:24): [True: 0, False: 231k]
  ------------------
 1163|      0|        v = -FLT_MAX;
 1164|      0|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
 1165|      0|    }
 1166|   231k|    *val = v;
 1167|   231k|    return r;
 1168|   231k|}
m_option.c:parse_str:
 1254|  57.9k|{
 1255|  57.9k|    if (dst) {
  ------------------
  |  Branch (1255:9): [True: 57.9k, False: 0]
  ------------------
 1256|  57.9k|        talloc_free(VAL(dst));
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(dst));
  ------------------
  |  | 1250|  57.9k|#define VAL(x) (*(char **)(x))
  ------------------
 1257|  57.9k|        VAL(dst) = bstrdup0(NULL, param);
  ------------------
  |  | 1250|  57.9k|#define VAL(x) (*(char **)(x))
  ------------------
 1258|  57.9k|    }
 1259|       |
 1260|  57.9k|    return 0;
 1261|  57.9k|}
m_option.c:print_str:
 1264|   213k|{
 1265|   213k|    return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  |   50|   213k|#define talloc_strdup                   ta_xstrdup
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|   213k|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 213k, False: 0]
  |  |  ------------------
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|   213k|#define VAL(x) (*(char **)(x))
  ------------------
 1266|   213k|}
m_option.c:copy_str:
 1269|  16.8M|{
 1270|  16.8M|    if (dst && src)
  ------------------
  |  Branch (1270:9): [True: 16.8M, False: 0]
  |  Branch (1270:16): [True: 16.8M, False: 0]
  ------------------
 1271|  16.8M|        talloc_replace(NULL, VAL(dst), VAL(src));
  ------------------
  |  |   54|  16.8M|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  16.8M|    do {                                                \
  |  |  |  |  107|  16.8M|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 16.8M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|  16.8M|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  16.8M|        } else {                                        \
  |  |  |  |  110|      0|            *(str) = '\0';                              \
  |  |  |  |  111|      0|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|      0|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|      0|        }                                               \
  |  |  |  |  113|  16.8M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 16.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1272|  16.8M|}
m_option.c:free_str:
 1299|  17.0M|{
 1300|  17.0M|    if (src && VAL(src)) {
  ------------------
  |  | 1250|  17.0M|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 4.54M, False: 12.4M]
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 17.0M, False: 0]
  ------------------
 1301|  4.54M|        talloc_free(VAL(src));
  ------------------
  |  |   47|  4.54M|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(src));
  ------------------
  |  | 1250|  4.54M|#define VAL(x) (*(char **)(x))
  ------------------
 1302|  4.54M|        VAL(src) = NULL;
  ------------------
  |  | 1250|  4.54M|#define VAL(x) (*(char **)(x))
  ------------------
 1303|  4.54M|    }
 1304|  17.0M|}
m_option.c:str_equal:
 1294|  28.9k|{
 1295|  28.9k|    return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  28.9k|#define VAL(x) (*(char **)(x))
  ------------------
                  return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  28.9k|#define VAL(x) (*(char **)(x))
  ------------------
 1296|  28.9k|}
m_option.c:parse_str_list:
 1622|  86.8k|{
 1623|  86.8k|    return parse_str_list_impl(log, opt, name, param, dst, OP_NONE);
  ------------------
  |  | 1323|  86.8k|#define OP_NONE 0
  ------------------
 1624|  86.8k|}
m_option.c:parse_str_list_impl:
 1467|  86.8k|{
 1468|  86.8k|    char **res;
 1469|  86.8k|    int op = default_op;
 1470|       |
 1471|  86.8k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1471:9): [True: 0, False: 86.8k]
  ------------------
 1472|      0|        op = OP_ADD;
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
 1473|  86.8k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1473:16): [True: 0, False: 86.8k]
  ------------------
 1474|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 1475|  86.8k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (1475:16): [True: 0, False: 86.8k]
  ------------------
 1476|      0|        op = OP_PRE;
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
 1477|  86.8k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1477:16): [True: 0, False: 86.8k]
  ------------------
 1478|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 1479|  86.8k|    } else if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1479:16): [True: 0, False: 86.8k]
  ------------------
 1480|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1481|  86.8k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (1481:16): [True: 0, False: 86.8k]
  ------------------
 1482|      0|        op = OP_NONE;
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
 1483|  86.8k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (1483:16): [True: 0, False: 86.8k]
  ------------------
 1484|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 1485|  86.8k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1485:16): [True: 0, False: 86.8k]
  ------------------
 1486|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1487|      0|    }
 1488|       |
 1489|  86.8k|    if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1328|   173k|#define OP_TOGGLE 5
  ------------------
                  if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1330|  86.8k|#define OP_REMOVE 7
  ------------------
  |  Branch (1489:9): [True: 0, False: 86.8k]
  |  Branch (1489:28): [True: 0, False: 86.8k]
  ------------------
 1490|      0|        if (dst) {
  ------------------
  |  Branch (1490:13): [True: 0, False: 0]
  ------------------
 1491|      0|            res = talloc_array(NULL, char *, 2);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|      0|            res[0] = bstrdup0(res, param);
 1493|      0|            res[1] = NULL;
 1494|      0|            bool found = str_list_remove(res, 2, dst);
 1495|      0|            if (found)
  ------------------
  |  Branch (1495:17): [True: 0, False: 0]
  ------------------
 1496|      0|                return 1;
 1497|      0|        }
 1498|      0|        if (op == OP_REMOVE)
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
  |  Branch (1498:13): [True: 0, False: 0]
  ------------------
 1499|      0|            return 1; // ignore if not found
 1500|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 1501|      0|    }
 1502|       |
 1503|       |    // Clear the list ??
 1504|  86.8k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|  86.8k|#define OP_CLR 3
  ------------------
  |  Branch (1504:9): [True: 0, False: 86.8k]
  ------------------
 1505|      0|        if (dst)
  ------------------
  |  Branch (1505:13): [True: 0, False: 0]
  ------------------
 1506|      0|            free_str_list(dst);
 1507|      0|        return 0;
 1508|      0|    }
 1509|       |
 1510|       |    // All other ops need a param
 1511|  86.8k|    if (param.len == 0 && op != OP_NONE)
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
  |  Branch (1511:9): [True: 0, False: 86.8k]
  |  Branch (1511:27): [True: 0, False: 0]
  ------------------
 1512|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 1513|       |
 1514|  86.8k|    if (!dst)
  ------------------
  |  Branch (1514:9): [True: 0, False: 86.8k]
  ------------------
 1515|      0|        return 1;
 1516|       |
 1517|  86.8k|    int n = 0;
 1518|  86.8k|    res = separate_input_param(opt, param, &n, op);
 1519|  86.8k|    if (!res)
  ------------------
  |  Branch (1519:9): [True: 0, False: 86.8k]
  ------------------
 1520|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1521|       |
 1522|  86.8k|    switch (op) {
  ------------------
  |  Branch (1522:13): [True: 0, False: 86.8k]
  ------------------
 1523|      0|    case OP_ADD:
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
  |  Branch (1523:5): [True: 0, False: 86.8k]
  ------------------
 1524|      0|    case OP_APPEND:
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
  |  Branch (1524:5): [True: 0, False: 86.8k]
  ------------------
 1525|      0|        return str_list_add(res, n, dst, 0);
 1526|      0|    case OP_PRE:
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
  |  Branch (1526:5): [True: 0, False: 86.8k]
  ------------------
 1527|      0|        return str_list_add(res, n, dst, 1);
 1528|      0|    case OP_DEL:
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
  |  Branch (1528:5): [True: 0, False: 86.8k]
  ------------------
 1529|      0|        return str_list_remove(res, n, dst);
 1530|  86.8k|    }
 1531|       |
 1532|  86.8k|    if (VAL(dst))
  ------------------
  |  | 1321|  86.8k|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 0, False: 86.8k]
  |  |  ------------------
  ------------------
 1533|      0|        free_str_list(dst);
 1534|  86.8k|    VAL(dst) = res;
  ------------------
  |  | 1321|  86.8k|#define VAL(x) (*(char ***)(x))
  ------------------
 1535|       |
 1536|  86.8k|    if (!res[0])
  ------------------
  |  Branch (1536:9): [True: 0, False: 86.8k]
  ------------------
 1537|      0|        free_str_list(dst);
 1538|       |
 1539|  86.8k|    return 1;
 1540|  86.8k|}
m_option.c:separate_input_param:
 1405|  86.8k|{
 1406|  86.8k|    char separator = opt->priv ? *(char *)opt->priv : OPTION_LIST_SEPARATOR;
  ------------------
  |  |  644|   173k|#define OPTION_LIST_SEPARATOR ','
  ------------------
  |  Branch (1406:22): [True: 0, False: 86.8k]
  ------------------
 1407|  86.8k|    if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1329|   173k|#define OP_APPEND 6
  ------------------
                  if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1330|  86.8k|#define OP_REMOVE 7
  ------------------
  |  Branch (1407:9): [True: 0, False: 86.8k]
  |  Branch (1407:28): [True: 0, False: 86.8k]
  ------------------
 1408|      0|        separator = 0; // specially handled
 1409|  86.8k|    struct bstr str = param;
 1410|  86.8k|    int n = *len;
 1411|   173k|    while (str.len) {
  ------------------
  |  Branch (1411:12): [True: 86.8k, False: 86.8k]
  ------------------
 1412|  86.8k|        get_nextsep(&str, separator, 0);
 1413|  86.8k|        str = bstr_cut(str, 1);
 1414|  86.8k|        n++;
 1415|  86.8k|    }
 1416|  86.8k|    if (n == 0 && op != OP_NONE)
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
  |  Branch (1416:9): [True: 0, False: 86.8k]
  |  Branch (1416:19): [True: 0, False: 0]
  ------------------
 1417|      0|        return NULL;
 1418|       |
 1419|  86.8k|    char **list = talloc_array(NULL, char *, n + 2);
  ------------------
  |  |   29|  86.8k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  86.8k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  86.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|  86.8k|    str = bstrdup(NULL, param);
 1421|  86.8k|    char *ptr = str.start;
 1422|  86.8k|    n = 0;
 1423|       |
 1424|  86.8k|    while (1) {
  ------------------
  |  Branch (1424:12): [True: 86.8k, Folded]
  ------------------
 1425|  86.8k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1426|  86.8k|        if (n >= 100)
  ------------------
  |  Branch (1426:13): [True: 0, False: 86.8k]
  ------------------
 1427|      0|            break;
 1428|  86.8k|#endif
 1429|  86.8k|        struct bstr el = get_nextsep(&str, separator, 1);
 1430|  86.8k|        list[n] = bstrdup0(NULL, el);
 1431|  86.8k|        n++;
 1432|  86.8k|        if (!str.len)
  ------------------
  |  Branch (1432:13): [True: 86.8k, False: 0]
  ------------------
 1433|  86.8k|            break;
 1434|      0|        str = bstr_cut(str, 1);
 1435|      0|    }
 1436|  86.8k|    list[n] = NULL;
 1437|  86.8k|    *len = n;
 1438|  86.8k|    talloc_free(ptr);
  ------------------
  |  |   47|  86.8k|#define talloc_free                     ta_free
  ------------------
 1439|  86.8k|    return list;
 1440|  86.8k|}
m_option.c:get_nextsep:
 1382|   173k|{
 1383|   173k|    struct bstr str = *ptr;
 1384|   173k|    struct bstr orig = str;
 1385|   173k|    for (;;) {
 1386|   173k|        int idx = sep ? bstrchr(str, sep) : -1;
  ------------------
  |  Branch (1386:19): [True: 173k, False: 0]
  ------------------
 1387|   173k|        if (idx > 0 && str.start[idx - 1] == '\\') {
  ------------------
  |  Branch (1387:13): [True: 0, False: 173k]
  |  Branch (1387:24): [True: 0, False: 0]
  ------------------
 1388|      0|            if (modify) {
  ------------------
  |  Branch (1388:17): [True: 0, False: 0]
  ------------------
 1389|      0|                memmove(str.start + idx - 1, str.start + idx, str.len - idx);
 1390|      0|                str.len--;
 1391|      0|                str = bstr_cut(str, idx);
 1392|      0|            } else
 1393|      0|                str = bstr_cut(str, idx + 1);
 1394|   173k|        } else {
 1395|   173k|            str = bstr_cut(str, idx < 0 ? str.len : idx);
  ------------------
  |  Branch (1395:33): [True: 173k, False: 0]
  ------------------
 1396|   173k|            break;
 1397|   173k|        }
 1398|   173k|    }
 1399|   173k|    *ptr = str;
 1400|   173k|    return bstr_splice(orig, 0, str.start - orig.start);
 1401|   173k|}
m_option.c:copy_str_list:
 1543|  10.8M|{
 1544|  10.8M|    int n;
 1545|  10.8M|    char **d, **s;
 1546|       |
 1547|  10.8M|    if (!(dst && src))
  ------------------
  |  Branch (1547:11): [True: 10.8M, False: 0]
  |  Branch (1547:18): [True: 10.8M, False: 0]
  ------------------
 1548|      0|        return;
 1549|  10.8M|    s = VAL(src);
  ------------------
  |  | 1321|  10.8M|#define VAL(x) (*(char ***)(x))
  ------------------
 1550|       |
 1551|  10.8M|    if (VAL(dst))
  ------------------
  |  | 1321|  10.8M|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 0, False: 10.8M]
  |  |  ------------------
  ------------------
 1552|      0|        free_str_list(dst);
 1553|       |
 1554|  10.8M|    if (!s) {
  ------------------
  |  Branch (1554:9): [True: 7.12M, False: 3.67M]
  ------------------
 1555|  7.12M|        VAL(dst) = NULL;
  ------------------
  |  | 1321|  7.12M|#define VAL(x) (*(char ***)(x))
  ------------------
 1556|  7.12M|        return;
 1557|  7.12M|    }
 1558|       |
 1559|  42.5M|    for (n = 0; s[n] != NULL; n++)
  ------------------
  |  Branch (1559:17): [True: 38.8M, False: 3.67M]
  ------------------
 1560|  38.8M|        /* NOTHING */;
 1561|  3.67M|    d = talloc_array(NULL, char *, n + 1);
  ------------------
  |  |   29|  3.67M|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  3.67M|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  3.67M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1562|  46.2M|    for (; n >= 0; n--)
  ------------------
  |  Branch (1562:12): [True: 42.5M, False: 3.67M]
  ------------------
 1563|  42.5M|        d[n] = talloc_strdup(NULL, s[n]);
  ------------------
  |  |   50|  42.5M|#define talloc_strdup                   ta_xstrdup
  ------------------
 1564|       |
 1565|  3.67M|    VAL(dst) = d;
  ------------------
  |  | 1321|  3.67M|#define VAL(x) (*(char ***)(x))
  ------------------
 1566|  3.67M|}
m_option.c:free_str_list:
 1333|  11.0M|{
 1334|  11.0M|    char **d;
 1335|  11.0M|    int i;
 1336|       |
 1337|  11.0M|    if (!dst || !VAL(dst))
  ------------------
  |  | 1321|  11.0M|#define VAL(x) (*(char ***)(x))
  ------------------
  |  Branch (1337:9): [True: 0, False: 11.0M]
  |  Branch (1337:17): [True: 7.03M, False: 3.99M]
  ------------------
 1338|  7.03M|        return;
 1339|  3.99M|    d = VAL(dst);
  ------------------
  |  | 1321|  3.99M|#define VAL(x) (*(char ***)(x))
  ------------------
 1340|       |
 1341|  43.4M|    for (i = 0; d[i] != NULL; i++)
  ------------------
  |  Branch (1341:17): [True: 39.4M, False: 3.99M]
  ------------------
 1342|  39.4M|        talloc_free(d[i]);
  ------------------
  |  |   47|  39.4M|#define talloc_free                     ta_free
  ------------------
 1343|  3.99M|    talloc_free(d);
  ------------------
  |  |   47|  3.99M|#define talloc_free                     ta_free
  ------------------
 1344|  3.99M|    VAL(dst) = NULL;
  ------------------
  |  | 1321|  3.99M|#define VAL(x) (*(char ***)(x))
  ------------------
 1345|  3.99M|}
m_option.c:str_list_equal:
 1627|  57.9k|{
 1628|  57.9k|    char **la = VAL(a);
  ------------------
  |  | 1321|  57.9k|#define VAL(x) (*(char ***)(x))
  ------------------
 1629|  57.9k|    char **lb = VAL(b);
  ------------------
  |  | 1321|  57.9k|#define VAL(x) (*(char ***)(x))
  ------------------
 1630|       |
 1631|  57.9k|    bool a_empty = !la || !la[0];
  ------------------
  |  Branch (1631:20): [True: 57.9k, False: 0]
  |  Branch (1631:27): [True: 0, False: 0]
  ------------------
 1632|  57.9k|    bool b_empty = !lb || !lb[0];
  ------------------
  |  Branch (1632:20): [True: 0, False: 57.9k]
  |  Branch (1632:27): [True: 0, False: 57.9k]
  ------------------
 1633|  57.9k|    if (a_empty || b_empty)
  ------------------
  |  Branch (1633:9): [True: 57.9k, False: 0]
  |  Branch (1633:20): [True: 0, False: 0]
  ------------------
 1634|  57.9k|        return a_empty == b_empty;
 1635|       |
 1636|      0|    for (int n = 0; la[n] || lb[n]; n++) {
  ------------------
  |  Branch (1636:21): [True: 0, False: 0]
  |  Branch (1636:30): [True: 0, False: 0]
  ------------------
 1637|      0|        if (!la[n] || !lb[n])
  ------------------
  |  Branch (1637:13): [True: 0, False: 0]
  |  Branch (1637:23): [True: 0, False: 0]
  ------------------
 1638|      0|            return false;
 1639|      0|        if (strcmp(la[n], lb[n]) != 0)
  ------------------
  |  Branch (1639:13): [True: 0, False: 0]
  ------------------
 1640|      0|            return false;
 1641|      0|    }
 1642|       |
 1643|      0|    return true;
 1644|      0|}
m_option.c:parse_keyvalue_list:
 1799|   231k|{
 1800|   231k|    char **lst = NULL;
 1801|   231k|    int num = 0;
 1802|   231k|    int r = 0;
 1803|   231k|    bool append = false;
 1804|   231k|    bool full_value = false;
 1805|       |
 1806|   231k|    if ((opt->flags & M_OPT_HAVE_HELP) && bstr_equals0(param, "help"))
  ------------------
  |  |  480|   231k|#define M_OPT_HAVE_HELP         (UINT64_C(1) << 59)
  ------------------
  |  Branch (1806:9): [True: 0, False: 231k]
  |  Branch (1806:43): [True: 0, False: 0]
  ------------------
 1807|      0|        param = bstr0("help=");
 1808|       |
 1809|   231k|    int op = 0;
 1810|   231k|    if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1810:9): [True: 0, False: 231k]
  ------------------
 1811|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1812|   231k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1812:16): [True: 0, False: 231k]
  ------------------
 1813|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1814|      0|    }
 1815|       |
 1816|   231k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1816:9): [True: 0, False: 231k]
  ------------------
 1817|      0|        append = true;
 1818|   231k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1818:16): [True: 202k, False: 28.9k]
  ------------------
 1819|   202k|        append = full_value = true;
 1820|   202k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1820:16): [True: 0, False: 28.9k]
  ------------------
 1821|      0|        if (dst)
  ------------------
  |  Branch (1821:13): [True: 0, False: 0]
  ------------------
 1822|      0|            free_str_list(dst);
 1823|      0|        return 0;
 1824|  28.9k|    } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1327|  57.9k|#define OP_DEL 4
  ------------------
                  } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1330|  28.9k|#define OP_REMOVE 7
  ------------------
  |  Branch (1824:16): [True: 0, False: 28.9k]
  |  Branch (1824:32): [True: 0, False: 28.9k]
  ------------------
 1825|      0|        int n = 0;
 1826|      0|        char **res = separate_input_param(opt, param, &n, op);
 1827|      0|        if (!res)
  ------------------
  |  Branch (1827:13): [True: 0, False: 0]
  ------------------
 1828|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1829|      0|        lst = dst ? VAL(dst) : NULL;
  ------------------
  |  | 1321|      0|#define VAL(x) (*(char ***)(x))
  ------------------
  |  Branch (1829:15): [True: 0, False: 0]
  ------------------
 1830|      0|        for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (1830:25): [True: 0, False: 0]
  ------------------
 1831|      0|            int index = dst ? keyvalue_list_find_key(lst, bstr0(res[i])) : -1;
  ------------------
  |  Branch (1831:25): [True: 0, False: 0]
  ------------------
 1832|      0|            if (index >= 0) {
  ------------------
  |  Branch (1832:17): [True: 0, False: 0]
  ------------------
 1833|      0|                keyvalue_list_del_key(lst, index);
 1834|      0|                VAL(dst) = lst;
  ------------------
  |  | 1321|      0|#define VAL(x) (*(char ***)(x))
  ------------------
 1835|      0|            }
 1836|      0|            talloc_free(res[i]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1837|      0|        }
 1838|      0|        talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1839|      0|        return 1;
 1840|      0|    }
 1841|       |
 1842|   231k|    if (append && dst) {
  ------------------
  |  Branch (1842:9): [True: 202k, False: 28.9k]
  |  Branch (1842:19): [True: 202k, False: 0]
  ------------------
 1843|   202k|        lst = VAL(dst);
  ------------------
  |  | 1321|   202k|#define VAL(x) (*(char ***)(x))
  ------------------
 1844|   202k|        for (int n = 0; lst && lst[n]; n++)
  ------------------
  |  Branch (1844:25): [True: 0, False: 202k]
  |  Branch (1844:32): [True: 0, False: 0]
  ------------------
 1845|      0|            num++;
 1846|   202k|    }
 1847|       |
 1848|   231k|    while (param.len) {
  ------------------
  |  Branch (1848:12): [True: 231k, False: 0]
  ------------------
 1849|   231k|        bstr key, val;
 1850|   231k|        r = read_subparam(log, name, "=", &param, &key);
 1851|   231k|        if (r < 0)
  ------------------
  |  Branch (1851:13): [True: 0, False: 231k]
  ------------------
 1852|      0|            break;
 1853|   231k|        if (!bstr_eatstart0(&param, "=")) {
  ------------------
  |  Branch (1853:13): [True: 0, False: 231k]
  ------------------
 1854|      0|            mp_err(log, "Expected '=' and a value.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 1855|      0|            r = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1856|      0|            break;
 1857|      0|        }
 1858|   231k|        if (full_value) {
  ------------------
  |  Branch (1858:13): [True: 202k, False: 28.9k]
  ------------------
 1859|   202k|            val = param;
 1860|   202k|            param.len = 0;
 1861|   202k|        } else {
 1862|  28.9k|            r = read_subparam(log, name, ",", &param, &val);
 1863|  28.9k|            if (r < 0)
  ------------------
  |  Branch (1863:17): [True: 0, False: 28.9k]
  ------------------
 1864|      0|                break;
 1865|  28.9k|        }
 1866|   231k|        if (dst) {
  ------------------
  |  Branch (1866:13): [True: 231k, False: 0]
  ------------------
 1867|   231k|            int index = keyvalue_list_find_key(lst, key);
 1868|   231k|            if (index >= 0) {
  ------------------
  |  Branch (1868:17): [True: 0, False: 231k]
  ------------------
 1869|      0|                keyvalue_list_del_key(lst, index);
 1870|      0|                num -= 2;
 1871|      0|            }
 1872|   231k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, key));
  ------------------
  |  |  105|   231k|    do {                                            \
  |  |  106|   231k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   231k|    do {                                            \
  |  |  |  |   97|   231k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   231k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   231k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   231k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 231k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|   231k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   231k|    do {                                                        \
  |  |  |  |  |  |   89|   231k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   231k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   231k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   231k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   231k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   231k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   231k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 231k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   231k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 231k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   231k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   231k|        (idxvar)++;                                 \
  |  |  109|   231k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 231k]
  |  |  ------------------
  ------------------
 1873|   231k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, val));
  ------------------
  |  |  105|   231k|    do {                                            \
  |  |  106|   231k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   231k|    do {                                            \
  |  |  |  |   97|   231k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   231k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   231k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   231k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 231k]
  |  |  |  |  ------------------
  |  |  |  |   99|   231k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   231k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 231k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   231k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   231k|        (idxvar)++;                                 \
  |  |  109|   231k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 231k]
  |  |  ------------------
  ------------------
 1874|   231k|            MP_TARRAY_APPEND(NULL, lst, num, NULL);
  ------------------
  |  |  105|   231k|    do {                                            \
  |  |  106|   231k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   231k|    do {                                            \
  |  |  |  |   97|   231k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   231k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   231k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   231k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 231k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|   231k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   231k|    do {                                                        \
  |  |  |  |  |  |   89|   231k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   231k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   231k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   231k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   231k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   231k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   231k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 231k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   231k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 231k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   231k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   231k|        (idxvar)++;                                 \
  |  |  109|   231k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 231k]
  |  |  ------------------
  ------------------
 1875|   231k|            num -= 1;
 1876|   231k|        }
 1877|       |
 1878|   231k|        if (!bstr_eatstart0(&param, ",") && !bstr_eatstart0(&param, ":"))
  ------------------
  |  Branch (1878:13): [True: 231k, False: 0]
  |  Branch (1878:45): [True: 231k, False: 0]
  ------------------
 1879|   231k|            break;
 1880|   231k|    }
 1881|       |
 1882|   231k|    if (param.len) {
  ------------------
  |  Branch (1882:9): [True: 0, False: 231k]
  ------------------
 1883|      0|        mp_err(log, "Unparsable garbage at end of option value: '%.*s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1884|      0|               BSTR_P(param));
 1885|      0|        r = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1886|      0|    }
 1887|       |
 1888|   231k|    if (dst) {
  ------------------
  |  Branch (1888:9): [True: 231k, False: 0]
  ------------------
 1889|   231k|        if (!append)
  ------------------
  |  Branch (1889:13): [True: 28.9k, False: 202k]
  ------------------
 1890|  28.9k|            free_str_list(dst);
 1891|   231k|        VAL(dst) = lst;
  ------------------
  |  | 1321|   231k|#define VAL(x) (*(char ***)(x))
  ------------------
 1892|   231k|        if (r < 0)
  ------------------
  |  Branch (1892:13): [True: 0, False: 231k]
  ------------------
 1893|      0|            free_str_list(dst);
 1894|   231k|    } else {
 1895|      0|        free_str_list(&lst);
 1896|      0|    }
 1897|   231k|    return r;
 1898|   231k|}
m_option.c:keyvalue_list_find_key:
 1776|   231k|{
 1777|   231k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1777:21): [True: 0, False: 231k]
  |  Branch (1777:28): [True: 0, False: 0]
  |  Branch (1777:38): [True: 0, False: 0]
  ------------------
 1778|      0|        if (bstr_equals0(str, lst[n]))
  ------------------
  |  Branch (1778:13): [True: 0, False: 0]
  ------------------
 1779|      0|            return n / 2;
 1780|      0|    }
 1781|   231k|    return -1;
 1782|   231k|}
m_option.c:read_subparam:
 2081|   260k|{
 2082|   260k|    bstr p = *str;
 2083|   260k|    bstr subparam = {0};
 2084|       |
 2085|   260k|    if (bstr_eatstart0(&p, "\"")) {
  ------------------
  |  Branch (2085:9): [True: 0, False: 260k]
  ------------------
 2086|      0|        int optlen = bstrcspn(p, "\"");
 2087|      0|        subparam = bstr_splice(p, 0, optlen);
 2088|      0|        p = bstr_cut(p, optlen);
 2089|      0|        if (!bstr_startswith0(p, "\"")) {
  ------------------
  |  Branch (2089:13): [True: 0, False: 0]
  ------------------
 2090|      0|            mp_err(log, "Terminating '\"' missing for '%.*s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2091|      0|                   BSTR_P(optname));
 2092|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 2093|      0|        }
 2094|      0|        p = bstr_cut(p, 1);
 2095|   260k|    } else if (bstr_eatstart0(&p, "[")) {
  ------------------
  |  Branch (2095:16): [True: 0, False: 260k]
  ------------------
 2096|      0|        bstr s = p;
 2097|      0|        int balance = 1;
 2098|      0|        while (p.len && balance > 0) {
  ------------------
  |  Branch (2098:16): [True: 0, False: 0]
  |  Branch (2098:25): [True: 0, False: 0]
  ------------------
 2099|      0|            if (p.start[0] == '[') {
  ------------------
  |  Branch (2099:17): [True: 0, False: 0]
  ------------------
 2100|      0|                balance++;
 2101|      0|            } else if (p.start[0] == ']') {
  ------------------
  |  Branch (2101:24): [True: 0, False: 0]
  ------------------
 2102|      0|                balance--;
 2103|      0|            }
 2104|      0|            p = bstr_cut(p, 1);
 2105|      0|        }
 2106|      0|        if (balance != 0) {
  ------------------
  |  Branch (2106:13): [True: 0, False: 0]
  ------------------
 2107|      0|            mp_err(log, "Terminating ']' missing for '%.*s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2108|      0|                   BSTR_P(optname));
 2109|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 2110|      0|        }
 2111|      0|        subparam = bstr_splice(s, 0, s.len - p.len - 1);
 2112|   260k|    } else if (bstr_eatstart0(&p, "%")) {
  ------------------
  |  Branch (2112:16): [True: 0, False: 260k]
  ------------------
 2113|      0|        int optlen = bstrtoll(p, &p, 0);
 2114|      0|        if (!bstr_startswith0(p, "%") || (optlen > p.len - 1)) {
  ------------------
  |  Branch (2114:13): [True: 0, False: 0]
  |  Branch (2114:42): [True: 0, False: 0]
  ------------------
 2115|      0|            mp_err(log, "Invalid length %d for '%.*s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2116|      0|                   optlen, BSTR_P(optname));
 2117|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 2118|      0|        }
 2119|      0|        subparam = bstr_splice(p, 1, optlen + 1);
 2120|      0|        p = bstr_cut(p, optlen + 1);
 2121|   260k|    } else {
 2122|       |        // Skip until the next character that could possibly be a meta
 2123|       |        // character in option parsing.
 2124|   260k|        int optlen = bstrcspn(p, termset);
 2125|   260k|        subparam = bstr_splice(p, 0, optlen);
 2126|   260k|        p = bstr_cut(p, optlen);
 2127|   260k|    }
 2128|       |
 2129|   260k|    *str = p;
 2130|   260k|    *out_subparam = subparam;
 2131|   260k|    return 0;
 2132|   260k|}
m_option.c:print_keyvalue_list:
 1901|  28.9k|{
 1902|  28.9k|    char **lst = VAL(src);
  ------------------
  |  | 1321|  28.9k|#define VAL(x) (*(char ***)(x))
  ------------------
 1903|  28.9k|    char *ret = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  28.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1904|  28.9k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1904:21): [True: 0, False: 28.9k]
  |  Branch (1904:28): [True: 0, False: 0]
  |  Branch (1904:38): [True: 0, False: 0]
  ------------------
 1905|      0|        if (ret[0])
  ------------------
  |  Branch (1905:13): [True: 0, False: 0]
  ------------------
 1906|      0|            ret = talloc_strdup_append(ret, ",");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 1907|      0|        ret = talloc_asprintf_append(ret, "%s=%s", lst[n], lst[n + 1]);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 1908|      0|    }
 1909|  28.9k|    return ret;
 1910|  28.9k|}
m_option.c:parse_msglevels:
 1993|  28.9k|{
 1994|  28.9k|    if (bstr_equals0(param, "help")) {
  ------------------
  |  Branch (1994:9): [True: 0, False: 28.9k]
  ------------------
 1995|      0|        mp_info(log, "Syntax:\n\n   --msg-level=module1=level,module2=level,...\n\n"
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 1996|      0|                     "'module' is output prefix as shown with -v, or a prefix\n"
 1997|      0|                     "of it. level is one of:\n\n"
 1998|      0|                     "  fatal error warn info status v debug trace\n\n"
 1999|      0|                     "The level specifies the minimum log level a message\n"
 2000|      0|                     "must have to be printed.\n"
 2001|      0|                     "The special module name 'all' affects all modules.\n");
 2002|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 2003|      0|    }
 2004|       |
 2005|  28.9k|    char **dst_copy = NULL;
 2006|  28.9k|    int r = m_option_type_keyvalue_list.parse(log, opt, name, param, &dst_copy);
 2007|  28.9k|    if (r >= 0)
  ------------------
  |  Branch (2007:9): [True: 28.9k, False: 0]
  ------------------
 2008|  28.9k|        r = check_msg_levels(log, dst_copy);
 2009|       |
 2010|  28.9k|    if (r >= 0)
  ------------------
  |  Branch (2010:9): [True: 28.9k, False: 0]
  ------------------
 2011|  28.9k|        m_option_type_keyvalue_list.copy(opt, dst, &dst_copy);
 2012|  28.9k|    m_option_type_keyvalue_list.free(&dst_copy);
 2013|  28.9k|    return r;
 2014|  28.9k|}
m_option.c:check_msg_levels:
 1980|  28.9k|{
 1981|  57.9k|    for (int n = 0; list && list[n * 2 + 0]; n++) {
  ------------------
  |  Branch (1981:21): [True: 57.9k, False: 0]
  |  Branch (1981:29): [True: 28.9k, False: 28.9k]
  ------------------
 1982|  28.9k|        char *level = list[n * 2 + 1];
 1983|  28.9k|        if (mp_msg_find_level(level) < 0 && strcmp(level, "no") != 0) {
  ------------------
  |  Branch (1983:13): [True: 0, False: 28.9k]
  |  Branch (1983:45): [True: 0, False: 0]
  ------------------
 1984|      0|            mp_err(log, "Invalid message level '%s'\n", level);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 1985|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1986|      0|        }
 1987|  28.9k|    }
 1988|  28.9k|    return 1;
 1989|  28.9k|}
m_option.c:copy_channels:
 2801|   624k|{
 2802|   624k|    if (!(dst && src))
  ------------------
  |  Branch (2802:11): [True: 624k, False: 0]
  |  Branch (2802:18): [True: 624k, False: 0]
  ------------------
 2803|      0|        return;
 2804|       |
 2805|   624k|    struct m_channels *ch = dst;
 2806|   624k|    free_channels(dst);
 2807|   624k|    *ch = *(struct m_channels *)src;
 2808|   624k|    ch->chmaps =
 2809|   624k|        talloc_memdup(NULL, ch->chmaps, sizeof(ch->chmaps[0]) * ch->num_chmaps);
  ------------------
  |  |   49|   624k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   624k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   624k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   624k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   624k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2810|   624k|}
m_option.c:free_channels:
 2791|  1.24M|{
 2792|  1.24M|    if (!src)
  ------------------
  |  Branch (2792:9): [True: 0, False: 1.24M]
  ------------------
 2793|      0|        return;
 2794|       |
 2795|  1.24M|    struct m_channels *ch = src;
 2796|  1.24M|    talloc_free(ch->chmaps);
  ------------------
  |  |   47|  1.24M|#define talloc_free                     ta_free
  ------------------
 2797|  1.24M|    *ch = (struct m_channels){0};
 2798|  1.24M|}
m_option.c:parse_obj_settings_list:
 3510|   115k|{
 3511|   115k|    m_obj_settings_t *res = NULL;
 3512|   115k|    int op = OP_NONE;
  ------------------
  |  | 1323|   115k|#define OP_NONE 0
  ------------------
 3513|   115k|    bool *mark_del = NULL;
 3514|   115k|    int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0);
  ------------------
  |  | 3041|   115k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3514:49): [True: 115k, False: 0]
  ------------------
 3515|   115k|    const struct m_obj_list *ol = opt->priv;
 3516|   115k|    int ret = 1;
 3517|       |
 3518|   115k|    mp_assert(opt->priv);
  ------------------
  |  |   41|   115k|#define mp_assert assert
  ------------------
  |  Branch (3518:5): [True: 115k, False: 0]
  ------------------
 3519|       |
 3520|   115k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (3520:9): [True: 0, False: 115k]
  ------------------
 3521|      0|        op = OP_ADD;
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
 3522|   115k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (3522:16): [True: 0, False: 115k]
  ------------------
 3523|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 3524|   115k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (3524:16): [True: 0, False: 115k]
  ------------------
 3525|      0|        op = OP_NONE;
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
 3526|   115k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (3526:16): [True: 0, False: 115k]
  ------------------
 3527|      0|        op = OP_PRE;
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
 3528|   115k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (3528:16): [True: 0, False: 115k]
  ------------------
 3529|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 3530|   115k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (3530:16): [True: 0, False: 115k]
  ------------------
 3531|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 3532|   115k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (3532:16): [True: 0, False: 115k]
  ------------------
 3533|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 3534|   115k|    } else if (bstr_endswith0(name, "-help")) {
  ------------------
  |  Branch (3534:16): [True: 0, False: 115k]
  ------------------
 3535|      0|        mp_err(log, "Option %s:\n"
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3536|      0|                "Supported operations are:\n"
 3537|      0|                "  %s-set\n"
 3538|      0|                " Overwrite the old list with the given list\n\n"
 3539|      0|                "  %s-append\n"
 3540|      0|                " Append the given item to the current list\n\n"
 3541|      0|                "  %s-add\n"
 3542|      0|                " Append the given list to the current list\n\n"
 3543|      0|                "  %s-pre\n"
 3544|      0|                " Prepend the given list to the current list\n\n"
 3545|      0|                "  %s-remove\n"
 3546|      0|                " Remove the given item from the current list\n\n"
 3547|      0|                "  %s-toggle\n"
 3548|      0|                " Add the item to the list, or remove it if it's already added.\n\n"
 3549|      0|                "  %s-clr\n"
 3550|      0|                " Clear the current list.\n\n",
 3551|      0|                opt->name, opt->name, opt->name, opt->name, opt->name,
 3552|      0|                opt->name, opt->name, opt->name);
 3553|       |
 3554|      0|        ret = M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 3555|      0|        goto done;
 3556|      0|    }
 3557|       |
 3558|   115k|    if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (3558:9): [True: 0, False: 115k]
  ------------------
 3559|      0|        mp_info(log, "Available %s:\n", ol->description);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3560|      0|        for (int n = 0; ; n++) {
 3561|      0|            struct m_obj_desc desc;
 3562|      0|            if (!ol->get_desc(&desc, n))
  ------------------
  |  Branch (3562:17): [True: 0, False: 0]
  ------------------
 3563|      0|                break;
 3564|      0|            if (!desc.hidden) {
  ------------------
  |  Branch (3564:17): [True: 0, False: 0]
  ------------------
 3565|      0|                mp_info(log, "  %-16s %s\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3566|      0|                       desc.name, desc.description);
 3567|      0|            }
 3568|      0|        }
 3569|      0|        mp_info(log, "\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3570|      0|        if (ol->print_help_list)
  ------------------
  |  Branch (3570:13): [True: 0, False: 0]
  ------------------
 3571|      0|            ol->print_help_list(log);
 3572|      0|        if (!ol->use_global_options) {
  ------------------
  |  Branch (3572:13): [True: 0, False: 0]
  ------------------
 3573|      0|            mp_info(log, "Get help on individual entries via: --%s=entry=help\n",
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3574|      0|                    opt->name);
 3575|      0|        }
 3576|      0|        ret = M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 3577|      0|        goto done;
 3578|      0|    }
 3579|       |
 3580|   115k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|   115k|#define OP_CLR 3
  ------------------
  |  Branch (3580:9): [True: 0, False: 115k]
  ------------------
 3581|      0|        if (param.len) {
  ------------------
  |  Branch (3581:13): [True: 0, False: 0]
  ------------------
 3582|      0|            mp_err(log, "Option %.*s: -clr does not take an argument.\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3583|      0|                   BSTR_P(name));
 3584|      0|            ret = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3585|      0|            goto done;
 3586|      0|        }
 3587|      0|        if (dst)
  ------------------
  |  Branch (3587:13): [True: 0, False: 0]
  ------------------
 3588|      0|            free_obj_settings_list(dst);
 3589|      0|        ret = 0;
 3590|      0|        goto done;
 3591|   115k|    } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|   115k|#define OP_REMOVE 7
  ------------------
  |  Branch (3591:16): [True: 0, False: 115k]
  ------------------
 3592|      0|        mark_del = talloc_zero_array(NULL, bool, num_items + 1);
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3593|      0|    }
 3594|       |
 3595|   115k|    if (op != OP_NONE && param.len == 0) {
  ------------------
  |  | 1323|   231k|#define OP_NONE 0
  ------------------
  |  Branch (3595:9): [True: 0, False: 115k]
  |  Branch (3595:26): [True: 0, False: 0]
  ------------------
 3596|      0|        ret = M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 3597|      0|        goto done;
 3598|      0|    }
 3599|       |
 3600|   231k|    while (param.len > 0) {
  ------------------
  |  Branch (3600:12): [True: 115k, False: 115k]
  ------------------
 3601|   115k|        int r = 0;
 3602|   115k|        if (op == OP_REMOVE)
  ------------------
  |  | 1330|   115k|#define OP_REMOVE 7
  ------------------
  |  Branch (3602:13): [True: 0, False: 115k]
  ------------------
 3603|      0|            r = parse_obj_settings_del(log, name, &param, dst, mark_del);
 3604|   115k|        if (r == 0) {
  ------------------
  |  Branch (3604:13): [True: 115k, False: 0]
  ------------------
 3605|   115k|            r = parse_obj_settings(log, name, op, &param, ol, dst ? &res : NULL);
  ------------------
  |  Branch (3605:63): [True: 115k, False: 0]
  ------------------
 3606|   115k|        }
 3607|   115k|        if (r < 0) {
  ------------------
  |  Branch (3607:13): [True: 0, False: 115k]
  ------------------
 3608|      0|            free_obj_settings_list(&res);
 3609|      0|            ret = r;
 3610|      0|            goto done;
 3611|      0|        }
 3612|   115k|        if (param.len > 0) {
  ------------------
  |  Branch (3612:13): [True: 0, False: 115k]
  ------------------
 3613|      0|            const char sep[2] = {OPTION_LIST_SEPARATOR, 0};
  ------------------
  |  |  644|      0|#define OPTION_LIST_SEPARATOR ','
  ------------------
 3614|      0|            if (!bstr_eatstart0(&param, sep)) {
  ------------------
  |  Branch (3614:17): [True: 0, False: 0]
  ------------------
 3615|      0|                free_obj_settings_list(&res);
 3616|      0|                ret = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3617|      0|                goto done;
 3618|      0|            }
 3619|      0|            if (param.len == 0) {
  ------------------
  |  Branch (3619:17): [True: 0, False: 0]
  ------------------
 3620|      0|                if (!ol->allow_trailer) {
  ------------------
  |  Branch (3620:21): [True: 0, False: 0]
  ------------------
 3621|      0|                    free_obj_settings_list(&res);
 3622|      0|                    ret = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3623|      0|                    goto done;
 3624|      0|                }
 3625|      0|                if (dst) {
  ------------------
  |  Branch (3625:21): [True: 0, False: 0]
  ------------------
 3626|      0|                    m_obj_settings_t item = {
 3627|      0|                        .name = talloc_strdup(NULL, ""),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3628|      0|                    };
 3629|      0|                    if (!obj_settings_list_insert_at(log, &res, -1, &item))
  ------------------
  |  Branch (3629:25): [True: 0, False: 0]
  ------------------
 3630|      0|                        obj_setting_free(&item);
 3631|      0|                }
 3632|      0|            }
 3633|      0|        }
 3634|   115k|    }
 3635|       |
 3636|   115k|    if (op != OP_NONE && res && res[0].name && res[1].name) {
  ------------------
  |  | 1323|   231k|#define OP_NONE 0
  ------------------
  |  Branch (3636:9): [True: 0, False: 115k]
  |  Branch (3636:26): [True: 0, False: 0]
  |  Branch (3636:33): [True: 0, False: 0]
  |  Branch (3636:48): [True: 0, False: 0]
  ------------------
 3637|      0|        if (op == OP_APPEND) {
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
  |  Branch (3637:13): [True: 0, False: 0]
  ------------------
 3638|      0|            mp_err(log, "Option %.*s: -append takes only 1 item (no ',').\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3639|      0|                   BSTR_P(name));
 3640|      0|            free_obj_settings_list(&res);
 3641|      0|            ret = M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3642|      0|            goto done;
 3643|      0|        }
 3644|      0|    }
 3645|       |
 3646|   115k|    if (dst) {
  ------------------
  |  Branch (3646:9): [True: 115k, False: 0]
  ------------------
 3647|   115k|        m_obj_settings_t *list = VAL(dst);
  ------------------
  |  | 3041|   115k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3648|   115k|        if (op == OP_PRE) {
  ------------------
  |  | 1325|   115k|#define OP_PRE 2
  ------------------
  |  Branch (3648:13): [True: 0, False: 115k]
  ------------------
 3649|      0|            int prepend_counter = 0;
 3650|      0|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3650:29): [True: 0, False: 0]
  |  Branch (3650:36): [True: 0, False: 0]
  ------------------
 3651|      0|                int label = obj_settings_list_find_by_label0(list, res[n].label);
 3652|      0|                if (label < 0) {
  ------------------
  |  Branch (3652:21): [True: 0, False: 0]
  ------------------
 3653|      0|                    if (!obj_settings_list_insert_at(log, &list, prepend_counter, &res[n]))
  ------------------
  |  Branch (3653:25): [True: 0, False: 0]
  ------------------
 3654|      0|                        obj_setting_free(&res[n]);
 3655|      0|                    prepend_counter++;
 3656|      0|                } else {
 3657|       |                    // Prefer replacement semantics, instead of actually
 3658|       |                    // prepending.
 3659|      0|                    obj_setting_free(&list[label]);
 3660|      0|                    list[label] = res[n];
 3661|      0|                }
 3662|      0|            }
 3663|      0|            talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3664|   115k|        } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1324|   231k|#define OP_ADD 1
  ------------------
                      } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1329|   115k|#define OP_APPEND 6
  ------------------
  |  Branch (3664:20): [True: 0, False: 115k]
  |  Branch (3664:36): [True: 0, False: 115k]
  ------------------
 3665|      0|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3665:29): [True: 0, False: 0]
  |  Branch (3665:36): [True: 0, False: 0]
  ------------------
 3666|      0|                int label = obj_settings_list_find_by_label0(list, res[n].label);
 3667|      0|                if (label < 0) {
  ------------------
  |  Branch (3667:21): [True: 0, False: 0]
  ------------------
 3668|      0|                    if (!obj_settings_list_insert_at(log, &list, -1, &res[n]))
  ------------------
  |  Branch (3668:25): [True: 0, False: 0]
  ------------------
 3669|      0|                        obj_setting_free(&res[n]);
 3670|      0|                } else {
 3671|       |                    // Prefer replacement semantics, instead of actually
 3672|       |                    // appending.
 3673|      0|                    obj_setting_free(&list[label]);
 3674|      0|                    list[label] = res[n];
 3675|      0|                }
 3676|      0|            }
 3677|      0|            talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3678|   115k|        } else if (op == OP_TOGGLE) {
  ------------------
  |  | 1328|   115k|#define OP_TOGGLE 5
  ------------------
  |  Branch (3678:20): [True: 0, False: 115k]
  ------------------
 3679|      0|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3679:29): [True: 0, False: 0]
  |  Branch (3679:36): [True: 0, False: 0]
  ------------------
 3680|      0|                if (res[n].label && !res[n].name[0]) {
  ------------------
  |  Branch (3680:21): [True: 0, False: 0]
  |  Branch (3680:37): [True: 0, False: 0]
  ------------------
 3681|       |                    // Toggle enable/disable special case.
 3682|      0|                    int found =
 3683|      0|                        obj_settings_list_find_by_label0(list, res[n].label);
 3684|      0|                    if (found < 0) {
  ------------------
  |  Branch (3684:25): [True: 0, False: 0]
  ------------------
 3685|      0|                        mp_warn(log, "Option %.*s: Label %s not found\n",
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3686|      0|                                BSTR_P(name), res[n].label);
 3687|      0|                    } else {
 3688|      0|                        list[found].enabled = !list[found].enabled;
 3689|      0|                    }
 3690|      0|                    obj_setting_free(&res[n]);
 3691|      0|                } else {
 3692|      0|                    int found = obj_settings_find_by_content(list, &res[n]);
 3693|      0|                    if (found < 0) {
  ------------------
  |  Branch (3693:25): [True: 0, False: 0]
  ------------------
 3694|      0|                        if (!obj_settings_list_insert_at(log, &list, -1, &res[n]))
  ------------------
  |  Branch (3694:29): [True: 0, False: 0]
  ------------------
 3695|      0|                            obj_setting_free(&res[n]);
 3696|      0|                    } else {
 3697|      0|                        obj_settings_list_del_at(&list, found);
 3698|      0|                        obj_setting_free(&res[n]);
 3699|      0|                    }
 3700|      0|                }
 3701|      0|            }
 3702|      0|            talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3703|   115k|        } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|   115k|#define OP_REMOVE 7
  ------------------
  |  Branch (3703:20): [True: 0, False: 115k]
  ------------------
 3704|      0|            for (int n = num_items - 1; n >= 0; n--) {
  ------------------
  |  Branch (3704:41): [True: 0, False: 0]
  ------------------
 3705|      0|                if (mark_del[n])
  ------------------
  |  Branch (3705:21): [True: 0, False: 0]
  ------------------
 3706|      0|                    obj_settings_list_del_at(&list, n);
 3707|      0|            }
 3708|      0|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3708:29): [True: 0, False: 0]
  |  Branch (3708:36): [True: 0, False: 0]
  ------------------
 3709|      0|                int found = obj_settings_find_by_content(list, &res[n]);
 3710|      0|                if (found >= 0)
  ------------------
  |  Branch (3710:21): [True: 0, False: 0]
  ------------------
 3711|      0|                    obj_settings_list_del_at(&list, found);
 3712|      0|            }
 3713|      0|            free_obj_settings_list(&res);
 3714|   115k|        } else {
 3715|   115k|            mp_assert(op == OP_NONE);
  ------------------
  |  |   41|   115k|#define mp_assert assert
  ------------------
  |  Branch (3715:13): [True: 115k, False: 0]
  ------------------
 3716|   115k|            free_obj_settings_list(&list);
 3717|   115k|            list = res;
 3718|   115k|        }
 3719|   115k|        VAL(dst) = list;
  ------------------
  |  | 3041|   115k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3720|   115k|    }
 3721|       |
 3722|   115k|done:
 3723|   115k|    talloc_free(mark_del);
  ------------------
  |  |   47|   115k|#define talloc_free                     ta_free
  ------------------
 3724|   115k|    return ret;
 3725|   115k|}
m_option.c:obj_settings_list_num_items:
 3082|   231k|{
 3083|   231k|    int num = 0;
 3084|   231k|    while (obj_list && obj_list[num].name)
  ------------------
  |  Branch (3084:12): [True: 0, False: 231k]
  |  Branch (3084:24): [True: 0, False: 0]
  ------------------
 3085|      0|        num++;
 3086|   231k|    return num;
 3087|   231k|}
m_option.c:parse_obj_settings:
 3389|   115k|{
 3390|   115k|    int r;
 3391|   115k|    char **plist = NULL;
 3392|   115k|    struct m_obj_desc desc;
 3393|   115k|    bstr str = {0};
 3394|   115k|    bstr label = {0};
 3395|   115k|    bool nopos = list->disallow_positional_parameters;
 3396|   115k|    bool enabled = true;
 3397|       |
 3398|   115k|    if (bstr_eatstart0(pstr, "@")) {
  ------------------
  |  Branch (3398:9): [True: 0, False: 115k]
  ------------------
 3399|      0|        bstr rest;
 3400|      0|        if (!bstr_split_tok(*pstr, ":", &label, &rest)) {
  ------------------
  |  Branch (3400:13): [True: 0, False: 0]
  ------------------
 3401|       |            // "@labelname" is the special enable/disable toggle syntax
 3402|      0|            if (op == OP_TOGGLE) {
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
  |  Branch (3402:17): [True: 0, False: 0]
  ------------------
 3403|      0|                int idx = bstrspn(*pstr, NAMECH);
  ------------------
  |  | 3383|      0|#define NAMECH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  ------------------
 3404|      0|                label = bstr_splice(*pstr, 0, idx);
 3405|      0|                if (label.len) {
  ------------------
  |  Branch (3405:21): [True: 0, False: 0]
  ------------------
 3406|      0|                    *pstr = bstr_cut(*pstr, idx);
 3407|      0|                    goto done;
 3408|      0|                }
 3409|      0|            }
 3410|      0|            mp_err(log, "Option %.*s: ':' expected after label.\n", BSTR_P(opt));
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3411|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3412|      0|        }
 3413|      0|        *pstr = rest;
 3414|      0|        if (label.len == 0) {
  ------------------
  |  Branch (3414:13): [True: 0, False: 0]
  ------------------
 3415|      0|            mp_err(log, "Option %.*s: label name expected.\n", BSTR_P(opt));
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3416|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3417|      0|        }
 3418|      0|    }
 3419|       |
 3420|   115k|    if (list->allow_disable_entries && bstr_eatstart0(pstr, "!"))
  ------------------
  |  Branch (3420:9): [True: 0, False: 115k]
  |  Branch (3420:40): [True: 0, False: 0]
  ------------------
 3421|      0|        enabled = false;
 3422|       |
 3423|   115k|    bool has_param = false;
 3424|   115k|    int idx = bstrspn(*pstr, NAMECH);
  ------------------
  |  | 3383|   115k|#define NAMECH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  ------------------
 3425|   115k|    str = bstr_splice(*pstr, 0, idx);
 3426|   115k|    if (!str.len) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 115k]
  ------------------
 3427|      0|        mp_err(log, "Option %.*s: item name expected.\n", BSTR_P(opt));
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3428|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3429|      0|    }
 3430|   115k|    *pstr = bstr_cut(*pstr, idx);
 3431|       |    // video filters use "=", VOs use ":"
 3432|   115k|    if (bstr_eatstart0(pstr, "=") || bstr_eatstart0(pstr, ":"))
  ------------------
  |  Branch (3432:9): [True: 0, False: 115k]
  |  Branch (3432:38): [True: 0, False: 115k]
  ------------------
 3433|      0|        has_param = true;
 3434|       |
 3435|   115k|    bool skip = false;
 3436|   115k|    if (m_obj_list_find(&desc, list, str)) {
  ------------------
  |  Branch (3436:9): [True: 115k, False: 0]
  ------------------
 3437|   115k|        if (desc.replaced_name)
  ------------------
  |  Branch (3437:13): [True: 0, False: 115k]
  ------------------
 3438|      0|            mp_warn(log, "Driver '%s' has been replaced with '%s'!\n",
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
 3439|   115k|                   desc.replaced_name, desc.name);
 3440|   115k|    } else {
 3441|      0|        char name[80];
 3442|      0|        snprintf(name, sizeof(name), "%.*s", BSTR_P(str));
  ------------------
  |  |  307|      0|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3443|      0|        if (list->check_unknown_entry && !list->check_unknown_entry(name)) {
  ------------------
  |  Branch (3443:13): [True: 0, False: 0]
  |  Branch (3443:42): [True: 0, False: 0]
  ------------------
 3444|      0|            mp_err(log, "Option %.*s: '%.*s' isn't supported.\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  |  Branch (76:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3445|      0|                   BSTR_P(opt), BSTR_P(str));
 3446|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 3447|      0|        }
 3448|      0|        desc = (struct m_obj_desc){0};
 3449|      0|        skip = true;
 3450|      0|    }
 3451|       |
 3452|   115k|    if (has_param) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 115k]
  ------------------
 3453|      0|        struct m_config *config = NULL;
 3454|      0|        if (!skip)
  ------------------
  |  Branch (3454:13): [True: 0, False: 0]
  ------------------
 3455|      0|            config = m_config_from_obj_desc_noalloc(NULL, log, &desc);
 3456|      0|        r = m_obj_parse_sub_config(log, opt, str, pstr, config,
 3457|      0|                                   M_SETOPT_CHECK_ONLY, nopos, &desc, list,
 3458|      0|                                   _ret ? &plist : NULL);
  ------------------
  |  Branch (3458:36): [True: 0, False: 0]
  ------------------
 3459|      0|        talloc_free(config);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3460|      0|        if (r < 0)
  ------------------
  |  Branch (3460:13): [True: 0, False: 0]
  ------------------
 3461|      0|            return r;
 3462|      0|    }
 3463|   115k|    if (!_ret)
  ------------------
  |  Branch (3463:9): [True: 0, False: 115k]
  ------------------
 3464|      0|        return 1;
 3465|       |
 3466|   115k|done: ;
 3467|   115k|    m_obj_settings_t item = {
 3468|   115k|        .name = bstrto0(NULL, str),
 3469|   115k|        .label = bstrdup0(NULL, label),
 3470|   115k|        .enabled = enabled,
 3471|   115k|        .attribs = plist,
 3472|   115k|    };
 3473|   115k|    if (!obj_settings_list_insert_at(log, _ret, -1, &item))
  ------------------
  |  Branch (3473:9): [True: 0, False: 115k]
  ------------------
 3474|      0|        obj_setting_free(&item);
 3475|   115k|    return 1;
 3476|   115k|}
m_option.c:obj_settings_list_insert_at:
 3117|   115k|{
 3118|   115k|    int num = obj_settings_list_num_items(*p_obj_list);
 3119|       |    // Limit list entries. obj_settings_list is not designed to hold more
 3120|       |    // items, and it quickly starts taking ages to add all items.
 3121|   115k|    if (num >= OBJ_SETTINGS_LIST_MAX) {
  ------------------
  |  | 3106|   115k|#define OBJ_SETTINGS_LIST_MAX 8
  ------------------
  |  Branch (3121:9): [True: 0, False: 115k]
  ------------------
 3122|      0|        mp_warn(log, "Object settings list capacity exceeded: "
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
 3123|      0|                     "a maximum of %d elements is allowed.\n",
 3124|      0|                OBJ_SETTINGS_LIST_MAX);
 3125|      0|        return false;
 3126|      0|    }
 3127|   115k|    if (idx < 0)
  ------------------
  |  Branch (3127:9): [True: 115k, False: 0]
  ------------------
 3128|   115k|        idx = num + idx + 1;
 3129|   115k|    mp_assert(idx >= 0 && idx <= num);
  ------------------
  |  |   41|   115k|#define mp_assert assert
  ------------------
  |  Branch (3129:5): [True: 115k, False: 0]
  |  Branch (3129:5): [True: 115k, False: 0]
  ------------------
 3130|   115k|    *p_obj_list = talloc_realloc(NULL, *p_obj_list, struct m_obj_settings,
  ------------------
  |  |   33|   115k|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|   115k|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   115k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   115k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   115k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   115k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3131|   115k|                                 num + 2);
 3132|   115k|    memmove(*p_obj_list + idx + 1, *p_obj_list + idx,
 3133|   115k|            (num - idx) * sizeof(m_obj_settings_t));
 3134|   115k|    (*p_obj_list)[idx] = *item;
 3135|   115k|    (*p_obj_list)[num + 1] = (m_obj_settings_t){0};
 3136|       |    return true;
 3137|   115k|}
m_option.c:obj_setting_free:
 3065|  1.60M|{
 3066|  1.60M|    talloc_free(item->name);
  ------------------
  |  |   47|  1.60M|#define talloc_free                     ta_free
  ------------------
 3067|  1.60M|    talloc_free(item->label);
  ------------------
  |  |   47|  1.60M|#define talloc_free                     ta_free
  ------------------
 3068|  1.60M|    free_str_list(&(item->attribs));
 3069|  1.60M|}
m_option.c:copy_obj_settings_list:
 3182|  1.54M|{
 3183|  1.54M|    m_obj_settings_t *d, *s;
 3184|  1.54M|    int n;
 3185|       |
 3186|  1.54M|    if (!(dst && src))
  ------------------
  |  Branch (3186:11): [True: 1.54M, False: 0]
  |  Branch (3186:18): [True: 1.54M, False: 0]
  ------------------
 3187|      0|        return;
 3188|       |
 3189|  1.54M|    s = VAL(src);
  ------------------
  |  | 3041|  1.54M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3190|       |
 3191|  1.54M|    if (VAL(dst))
  ------------------
  |  | 3041|  1.54M|#define VAL(x) (*(m_obj_settings_t **)(x))
  |  |  ------------------
  |  |  |  Branch (3041:16): [True: 0, False: 1.54M]
  |  |  ------------------
  ------------------
 3192|      0|        free_obj_settings_list(dst);
 3193|  1.54M|    if (!s)
  ------------------
  |  Branch (3193:9): [True: 921k, False: 624k]
  ------------------
 3194|   921k|        return;
 3195|       |
 3196|  2.11M|    for (n = 0; s[n].name; n++)
  ------------------
  |  Branch (3196:17): [True: 1.48M, False: 624k]
  ------------------
 3197|  1.48M|        /* NOP */;
 3198|   624k|    d = talloc_array(NULL, struct m_obj_settings, n + 1);
  ------------------
  |  |   29|   624k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|   624k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   624k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3199|  2.11M|    for (n = 0; s[n].name; n++) {
  ------------------
  |  Branch (3199:17): [True: 1.48M, False: 624k]
  ------------------
 3200|  1.48M|        d[n].name = talloc_strdup(NULL, s[n].name);
  ------------------
  |  |   50|  1.48M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3201|  1.48M|        d[n].label = talloc_strdup(NULL, s[n].label);
  ------------------
  |  |   50|  1.48M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3202|  1.48M|        d[n].enabled = s[n].enabled;
 3203|  1.48M|        d[n].attribs = NULL;
 3204|  1.48M|        copy_str_list(NULL, &(d[n].attribs), &(s[n].attribs));
 3205|  1.48M|    }
 3206|   624k|    d[n].name = NULL;
 3207|   624k|    d[n].label = NULL;
 3208|   624k|    d[n].attribs = NULL;
 3209|   624k|    VAL(dst) = d;
  ------------------
  |  | 3041|   624k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3210|   624k|}
m_option.c:free_obj_settings_list:
 3166|  1.71M|{
 3167|  1.71M|    int n;
 3168|  1.71M|    m_obj_settings_t *d;
 3169|       |
 3170|  1.71M|    if (!dst || !VAL(dst))
  ------------------
  |  | 3041|  1.71M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3170:9): [True: 0, False: 1.71M]
  |  Branch (3170:17): [True: 970k, False: 740k]
  ------------------
 3171|   970k|        return;
 3172|       |
 3173|   740k|    d = VAL(dst);
  ------------------
  |  | 3041|   740k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3174|  2.34M|    for (n = 0; d[n].name; n++)
  ------------------
  |  Branch (3174:17): [True: 1.60M, False: 740k]
  ------------------
 3175|  1.60M|        obj_setting_free(&d[n]);
 3176|   740k|    talloc_free(d);
  ------------------
  |  |   47|   740k|#define talloc_free                     ta_free
  ------------------
 3177|   740k|    VAL(dst) = NULL;
  ------------------
  |  | 3041|   740k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3178|   740k|}
m_option.c:obj_settings_list_equal:
 3873|  57.9k|{
 3874|  57.9k|    struct m_obj_settings *a = VAL(pa);
  ------------------
  |  | 3041|  57.9k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3875|  57.9k|    struct m_obj_settings *b = VAL(pb);
  ------------------
  |  | 3041|  57.9k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3876|       |
 3877|  57.9k|    if (a == b || !a || !b)
  ------------------
  |  Branch (3877:9): [True: 0, False: 57.9k]
  |  Branch (3877:19): [True: 57.9k, False: 0]
  |  Branch (3877:25): [True: 0, False: 0]
  ------------------
 3878|  57.9k|        return a == b || (!a && !b[0].name) || (!b && !a[0].name);
  ------------------
  |  Branch (3878:16): [True: 0, False: 57.9k]
  |  Branch (3878:27): [True: 57.9k, False: 0]
  |  Branch (3878:33): [True: 0, False: 57.9k]
  |  Branch (3878:49): [True: 0, False: 57.9k]
  |  Branch (3878:55): [True: 0, False: 0]
  ------------------
 3879|       |
 3880|      0|    for (int n = 0; a[n].name || b[n].name; n++) {
  ------------------
  |  Branch (3880:21): [True: 0, False: 0]
  |  Branch (3880:34): [True: 0, False: 0]
  ------------------
 3881|      0|        if (!a[n].name || !b[n].name)
  ------------------
  |  Branch (3881:13): [True: 0, False: 0]
  |  Branch (3881:27): [True: 0, False: 0]
  ------------------
 3882|      0|            return false;
 3883|      0|        if (!m_obj_settings_equal(&a[n], &b[n]))
  ------------------
  |  Branch (3883:13): [True: 0, False: 0]
  ------------------
 3884|      0|            return false;
 3885|      0|    }
 3886|       |
 3887|      0|    return true;
 3888|      0|}
m_option.c:free_node:
 4033|  86.8k|{
 4034|  86.8k|    if (src) {
  ------------------
  |  Branch (4034:9): [True: 86.8k, False: 0]
  ------------------
 4035|  86.8k|        struct mpv_node *node = &VAL(src);
  ------------------
  |  | 3928|  86.8k|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4036|  86.8k|        talloc_free(node_get_alloc(node));
  ------------------
  |  |   47|  86.8k|#define talloc_free                     ta_free
  ------------------
 4037|  86.8k|        *node = (struct mpv_node){{0}};
 4038|  86.8k|    }
 4039|  86.8k|}

client.c:m_option_free:
  589|  86.8k|{
  590|  86.8k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 86.8k, False: 0]
  ------------------
  591|  86.8k|        opt->type->free(dst);
  592|  86.8k|}
command.c:m_option_free:
  589|  28.9k|{
  590|  28.9k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 28.9k, False: 0]
  ------------------
  591|  28.9k|        opt->type->free(dst);
  592|  28.9k|}
f_output_chain.c:m_option_free:
  589|   106k|{
  590|   106k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 106k, False: 0]
  ------------------
  591|   106k|        opt->type->free(dst);
  592|   106k|}
cmd.c:m_option_free:
  589|   173k|{
  590|   173k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 57.9k, False: 115k]
  ------------------
  591|  57.9k|        opt->type->free(dst);
  592|   173k|}
cmd.c:m_option_copy:
  582|  28.9k|{
  583|  28.9k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 28.9k, False: 0]
  ------------------
  584|  28.9k|        opt->type->copy(opt, dst, src);
  585|  28.9k|}
cmd.c:m_option_print:
  559|   173k|{
  560|   173k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 173k, False: 0]
  ------------------
  561|   173k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|   173k|}
m_config_core.c:m_option_free:
  589|   136M|{
  590|   136M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 23.9M, False: 112M]
  ------------------
  591|  23.9M|        opt->type->free(dst);
  592|   136M|}
m_config_core.c:m_option_equal:
  617|  1.19M|{
  618|       |    // Handle trivial equivalence.
  619|       |    // If not implemented, assume this type has no actual values => always equal.
  620|  1.19M|    if (a == b || !opt->type->equal)
  ------------------
  |  Branch (620:9): [True: 0, False: 1.19M]
  |  Branch (620:19): [True: 0, False: 1.19M]
  ------------------
  621|      0|        return true;
  622|  1.19M|    return opt->type->equal(opt, a, b);
  623|  1.19M|}
m_config_core.c:m_option_copy:
  582|  24.5M|{
  583|  24.5M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 24.5M, False: 0]
  ------------------
  584|  24.5M|        opt->type->copy(opt, dst, src);
  585|  24.5M|}
m_config_frontend.c:m_option_copy:
  582|  23.6M|{
  583|  23.6M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 23.6M, False: 0]
  ------------------
  584|  23.6M|        opt->type->copy(opt, dst, src);
  585|  23.6M|}
m_config_frontend.c:m_option_free:
  589|  23.4M|{
  590|  23.4M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 4.25M, False: 19.2M]
  ------------------
  591|  4.25M|        opt->type->free(dst);
  592|  23.4M|}
m_property.c:m_option_pretty_print:
  569|  61.6k|{
  570|  61.6k|    m_option_t o = *opt;
  571|  61.6k|    if (fixed_len)
  ------------------
  |  Branch (571:9): [True: 0, False: 61.6k]
  ------------------
  572|      0|        o.flags |= M_OPT_FIXED_LEN_PRINT;
  ------------------
  |  |  494|      0|#define M_OPT_FIXED_LEN_PRINT   (UINT64_C(1) << 55)
  ------------------
  573|  61.6k|    if (opt->type->pretty_print)
  ------------------
  |  Branch (573:9): [True: 0, False: 61.6k]
  ------------------
  574|      0|        return opt->type->pretty_print(&o, val_ptr);
  575|  61.6k|    else
  576|  61.6k|        return m_option_print(&o, val_ptr);
  577|  61.6k|}
m_property.c:m_option_free:
  589|   184k|{
  590|   184k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 184k, False: 0]
  ------------------
  591|   184k|        opt->type->free(dst);
  592|   184k|}
m_property.c:m_option_print:
  559|   184k|{
  560|   184k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 184k, False: 0]
  ------------------
  561|   184k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|   184k|}

m_property_list_sort:
   45|  28.9k|{
   46|  28.9k|    qsort(list->props, list->num, sizeof(list->props[0]), compare_prop_name);
   47|  28.9k|}
m_property_do:
  142|   184k|{
  143|   184k|    union m_option_value val = m_option_value_default;
  144|   184k|    int r;
  145|       |
  146|   184k|    const char *key;
  147|   184k|    struct m_property *prop = resolve_name(prop_list, name, &key);
  148|   184k|    if (!prop)
  ------------------
  |  Branch (148:9): [True: 0, False: 184k]
  ------------------
  149|      0|        return M_PROPERTY_UNKNOWN;
  150|       |
  151|   184k|    struct m_option opt = {0};
  152|   184k|    bool get_opt_required[M_PROPERTY_MAX_ACTION] = {
  153|   184k|        [M_PROPERTY_FIXED_LEN_PRINT] = true, [M_PROPERTY_PRINT] = true,
  154|   184k|        [M_PROPERTY_PRINT_UNCUT] = true, [M_PROPERTY_GET_STRING] = true,
  155|   184k|        [M_PROPERTY_MULTIPLY] = true, [M_PROPERTY_SWITCH] = true,
  156|   184k|        [M_PROPERTY_GET_NODE] = true, [M_PROPERTY_SET_NODE] = true,
  157|   184k|    };
  158|   184k|    if (get_opt_required[action]) {
  ------------------
  |  Branch (158:9): [True: 184k, False: 0]
  ------------------
  159|   184k|        r = do_action(prop, key, M_PROPERTY_GET_TYPE, &opt, ctx);
  160|   184k|        if (r <= 0)
  ------------------
  |  Branch (160:13): [True: 0, False: 184k]
  ------------------
  161|      0|            return r;
  162|   184k|        mp_assert(opt.type);
  ------------------
  |  |   41|   184k|#define mp_assert assert
  ------------------
  |  Branch (162:9): [True: 184k, False: 0]
  ------------------
  163|       |        // Make sure dynamic range from properties with M_PROPERTY_GET_CONSTRICTED_TYPE is applied
  164|   184k|        struct m_option copt = {0};
  165|   184k|        r = do_action(prop, key, M_PROPERTY_GET_CONSTRICTED_TYPE, &copt, ctx);
  166|   184k|        if (r == M_PROPERTY_OK) {
  ------------------
  |  Branch (166:13): [True: 0, False: 184k]
  ------------------
  167|      0|            opt.min = copt.min;
  168|      0|            opt.max = copt.max;
  169|      0|        }
  170|   184k|    }
  171|       |
  172|   184k|    switch (action) {
  173|      0|    case M_PROPERTY_PRINT_UNCUT:
  ------------------
  |  Branch (173:5): [True: 0, False: 184k]
  ------------------
  174|      0|    case M_PROPERTY_FIXED_LEN_PRINT:
  ------------------
  |  Branch (174:5): [True: 0, False: 184k]
  ------------------
  175|  61.6k|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (175:5): [True: 61.6k, False: 123k]
  ------------------
  176|  61.6k|        if ((r = do_action(prop, key, action, arg, ctx)) >= 0)
  ------------------
  |  Branch (176:13): [True: 0, False: 61.6k]
  ------------------
  177|      0|            return r;
  178|  61.6k|        if (action == M_PROPERTY_PRINT_UNCUT &&
  ------------------
  |  Branch (178:13): [True: 0, False: 61.6k]
  ------------------
  179|      0|            (r = do_action(prop, key, M_PROPERTY_PRINT, arg, ctx)) >= 0)
  ------------------
  |  Branch (179:13): [True: 0, False: 0]
  ------------------
  180|      0|            return r;
  181|       |        // Fallback to m_option
  182|  61.6k|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (182:13): [True: 0, False: 61.6k]
  ------------------
  183|      0|            return r;
  184|  61.6k|        char *str = m_option_pretty_print(&opt, &val, action == M_PROPERTY_FIXED_LEN_PRINT);
  185|  61.6k|        m_option_free(&opt, &val);
  186|  61.6k|        *(char **)arg = str;
  187|  61.6k|        return str != NULL;
  188|  61.6k|    }
  189|   123k|    case M_PROPERTY_GET_STRING: {
  ------------------
  |  Branch (189:5): [True: 123k, False: 61.6k]
  ------------------
  190|   123k|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (190:13): [True: 0, False: 123k]
  ------------------
  191|      0|            return r;
  192|   123k|        char *str = m_option_print(&opt, &val);
  193|   123k|        m_option_free(&opt, &val);
  194|   123k|        *(char **)arg = str;
  195|   123k|        return str != NULL;
  196|   123k|    }
  197|      0|    case M_PROPERTY_SET_STRING: {
  ------------------
  |  Branch (197:5): [True: 0, False: 184k]
  ------------------
  198|      0|        struct mpv_node node = { .format = MPV_FORMAT_STRING, .u.string = arg };
  199|      0|        return m_property_do(log, prop_list, name, M_PROPERTY_SET_NODE, &node, ctx);
  200|   123k|    }
  201|      0|    case M_PROPERTY_MULTIPLY: {
  ------------------
  |  Branch (201:5): [True: 0, False: 184k]
  ------------------
  202|      0|        return m_property_multiply(log, prop, key, *(double *)arg, ctx, &opt);
  203|   123k|    }
  204|      0|    case M_PROPERTY_SWITCH: {
  ------------------
  |  Branch (204:5): [True: 0, False: 184k]
  ------------------
  205|      0|        return m_property_switch(log, prop, key, arg, ctx, &opt);
  206|   123k|    }
  207|      0|    case M_PROPERTY_GET_CONSTRICTED_TYPE: {
  ------------------
  |  Branch (207:5): [True: 0, False: 184k]
  ------------------
  208|      0|        r = do_action(prop, key, action, arg, ctx);
  209|      0|        if (r >= 0 || r == M_PROPERTY_UNAVAILABLE)
  ------------------
  |  Branch (209:13): [True: 0, False: 0]
  |  Branch (209:23): [True: 0, False: 0]
  ------------------
  210|      0|            return r;
  211|      0|        if ((r = do_action(prop, key, M_PROPERTY_GET_TYPE, arg, ctx)) >= 0)
  ------------------
  |  Branch (211:13): [True: 0, False: 0]
  ------------------
  212|      0|            return r;
  213|      0|        return M_PROPERTY_NOT_IMPLEMENTED;
  214|      0|    }
  215|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (215:5): [True: 0, False: 184k]
  ------------------
  216|      0|        return do_action(prop, key, M_PROPERTY_SET, arg, ctx);
  217|      0|    }
  218|      0|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (218:5): [True: 0, False: 184k]
  ------------------
  219|      0|        if ((r = do_action(prop, key, M_PROPERTY_GET_NODE, arg, ctx)) !=
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|      0|            M_PROPERTY_NOT_IMPLEMENTED)
  221|      0|            return r;
  222|      0|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (222:13): [True: 0, False: 0]
  ------------------
  223|      0|            return r;
  224|      0|        struct mpv_node *node = arg;
  225|      0|        int err = m_option_get_node(&opt, NULL, node, &val);
  226|      0|        if (err == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (226:13): [True: 0, False: 0]
  ------------------
  227|      0|            r = M_PROPERTY_NOT_IMPLEMENTED;
  228|      0|        } else if (err < 0) {
  ------------------
  |  Branch (228:20): [True: 0, False: 0]
  ------------------
  229|      0|            r = M_PROPERTY_INVALID_FORMAT;
  230|      0|        } else {
  231|      0|            r = M_PROPERTY_OK;
  232|      0|        }
  233|      0|        m_option_free(&opt, &val);
  234|      0|        return r;
  235|      0|    }
  236|      0|    case M_PROPERTY_SET_NODE: {
  ------------------
  |  Branch (236:5): [True: 0, False: 184k]
  ------------------
  237|      0|        if (!log)
  ------------------
  |  Branch (237:13): [True: 0, False: 0]
  ------------------
  238|      0|            return M_PROPERTY_ERROR;
  239|      0|        if ((r = do_action(prop, key, M_PROPERTY_SET_NODE, arg, ctx)) !=
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  ------------------
  240|      0|            M_PROPERTY_NOT_IMPLEMENTED)
  241|      0|            return r;
  242|      0|        int err = m_option_set_node_or_string(log, &opt, bstr0(name), &val, arg);
  243|      0|        if (err == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (243:13): [True: 0, False: 0]
  ------------------
  244|      0|            r = M_PROPERTY_NOT_IMPLEMENTED;
  245|      0|        } else if (err < 0) {
  ------------------
  |  Branch (245:20): [True: 0, False: 0]
  ------------------
  246|      0|            r = M_PROPERTY_INVALID_FORMAT;
  247|      0|        } else {
  248|      0|            r = do_action(prop, key, M_PROPERTY_SET, &val, ctx);
  249|      0|        }
  250|      0|        m_option_free(&opt, &val);
  251|      0|        return r;
  252|      0|    }
  253|      0|    default:
  ------------------
  |  Branch (253:5): [True: 0, False: 184k]
  ------------------
  254|      0|        return do_action(prop, key, action, arg, ctx);
  255|   184k|    }
  256|   184k|}
m_properties_expand_string:
  338|  61.6k|{
  339|  61.6k|    char *ret = NULL;
  340|  61.6k|    int ret_len = 0;
  341|  61.6k|    bool skip = false;
  342|  61.6k|    int level = 0, skip_level = 0;
  343|  61.6k|    bstr str = bstr0(str0);
  344|  61.6k|    int last_brace = bstrrchr(str, '}');
  345|  61.6k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  346|  61.6k|    int n = 0;
  347|  61.6k|#endif
  348|       |
  349|  1.23M|    while (str.len) {
  ------------------
  |  Branch (349:12): [True: 1.17M, False: 61.6k]
  ------------------
  350|  1.17M|        if (level > 0 && bstr_eatstart0(&str, "}")) {
  ------------------
  |  Branch (350:13): [True: 678k, False: 493k]
  |  Branch (350:26): [True: 184k, False: 493k]
  ------------------
  351|   184k|            if (skip && level <= skip_level)
  ------------------
  |  Branch (351:17): [True: 123k, False: 61.6k]
  |  Branch (351:25): [True: 123k, False: 0]
  ------------------
  352|   123k|                skip = false;
  353|   184k|            level--;
  354|   986k|        } else if (bstr_startswith0(str, "${") && str.start - (unsigned char *)str0 < last_brace) {
  ------------------
  |  Branch (354:20): [True: 184k, False: 801k]
  |  Branch (354:51): [True: 184k, False: 0]
  ------------------
  355|   184k|            str = bstr_cut(str, 2);
  356|   184k|            level++;
  357|       |
  358|       |            // Assume ":" and "}" can't be part of the property name
  359|       |            // => if ":" comes before "}", it must be for the fallback
  360|   184k|            int term_pos = bstrcspn(str, ":}");
  361|   184k|            bstr name = bstr_splice(str, 0, term_pos < 0 ? str.len : term_pos);
  ------------------
  |  Branch (361:45): [True: 0, False: 184k]
  ------------------
  362|   184k|            str = bstr_cut(str, term_pos);
  363|   184k|            bool have_fallback = bstr_eatstart0(&str, ":");
  364|       |
  365|   184k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  366|   184k|            if (n++ > 10)
  ------------------
  |  Branch (366:17): [True: 0, False: 184k]
  ------------------
  367|      0|                break;
  368|   184k|#endif
  369|       |
  370|   184k|            if (!skip) {
  ------------------
  |  Branch (370:17): [True: 184k, False: 0]
  ------------------
  371|   184k|                skip = expand_property(prop_list, &ret, &ret_len, name,
  372|   184k|                                       have_fallback, ctx, print_action);
  373|   184k|                if (skip)
  ------------------
  |  Branch (373:21): [True: 123k, False: 61.6k]
  ------------------
  374|   123k|                    skip_level = level;
  375|   184k|            }
  376|   801k|        } else if (level == 0 && bstr_eatstart0(&str, "$>")) {
  ------------------
  |  Branch (376:20): [True: 369k, False: 431k]
  |  Branch (376:34): [True: 0, False: 369k]
  ------------------
  377|      0|            append_str(&ret, &ret_len, str);
  378|      0|            break;
  379|   801k|        } else {
  380|   801k|            char c;
  381|       |
  382|       |            // Other combinations, e.g. "$x", are added verbatim
  383|   801k|            if (bstr_eatstart0(&str, "$$")) {
  ------------------
  |  Branch (383:17): [True: 0, False: 801k]
  ------------------
  384|      0|                c = '$';
  385|   801k|            } else if (bstr_eatstart0(&str, "$}")) {
  ------------------
  |  Branch (385:24): [True: 0, False: 801k]
  ------------------
  386|      0|                c = '}';
  387|   801k|            } else {
  388|   801k|                c = str.start[0];
  389|   801k|                str = bstr_cut(str, 1);
  390|   801k|            }
  391|       |
  392|   801k|            if (!skip)
  ------------------
  |  Branch (392:17): [True: 369k, False: 431k]
  ------------------
  393|   369k|                MP_TARRAY_APPEND(NULL, ret, ret_len, c);
  ------------------
  |  |  105|   369k|    do {                                            \
  |  |  106|   369k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   369k|    do {                                            \
  |  |  |  |   97|   369k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   369k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   369k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   369k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3.72k, False: 366k]
  |  |  |  |  ------------------
  |  |  |  |   99|   369k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  3.72k|    do {                                                        \
  |  |  |  |  |  |   89|  3.72k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  3.72k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  3.72k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.72k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.72k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  3.72k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  3.72k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3.72k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   369k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 369k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   369k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   369k|        (idxvar)++;                                 \
  |  |  109|   369k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 369k]
  |  |  ------------------
  ------------------
  394|   801k|        }
  395|  1.17M|    }
  396|       |
  397|  61.6k|    MP_TARRAY_APPEND(NULL, ret, ret_len, '\0');
  ------------------
  |  |  105|  61.6k|    do {                                            \
  |  |  106|  61.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  61.6k|    do {                                            \
  |  |  |  |   97|  61.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  61.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  61.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  61.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 932, False: 60.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  61.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    932|    do {                                                        \
  |  |  |  |  |  |   89|    932|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    932|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    932|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    932|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    932|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    932|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    932|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 932]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  61.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 61.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  61.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  61.6k|        (idxvar)++;                                 \
  |  |  109|  61.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 61.6k]
  |  |  ------------------
  ------------------
  398|  61.6k|    return ret;
  399|  61.6k|}
m_property_strdup_ro:
  476|   616k|{
  477|   616k|    if (!var)
  ------------------
  |  Branch (477:9): [True: 0, False: 616k]
  ------------------
  478|      0|        return M_PROPERTY_UNAVAILABLE;
  479|   616k|    switch (action) {
  ------------------
  |  Branch (479:13): [True: 369k, False: 246k]
  ------------------
  480|   184k|    case M_PROPERTY_GET:
  ------------------
  |  Branch (480:5): [True: 184k, False: 431k]
  ------------------
  481|   184k|        *(char **)arg = talloc_strdup(NULL, var);
  ------------------
  |  |   50|   184k|#define talloc_strdup                   ta_xstrdup
  ------------------
  482|   184k|        return M_PROPERTY_OK;
  483|   184k|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (483:5): [True: 184k, False: 431k]
  ------------------
  484|   184k|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|   184k|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  485|   184k|        return M_PROPERTY_OK;
  486|   616k|    }
  487|   246k|    return M_PROPERTY_NOT_IMPLEMENTED;
  488|   616k|}
m_property.c:compare_prop_name:
   39|   220M|{
   40|   220M|    const struct m_property *a = pa, *b = pb;
   41|   220M|    return strcmp(a->name, b->name);
   42|   220M|}
m_property.c:find_prop:
   57|   184k|{
   58|   184k|    return bsearch(&name, list->props, list->num, sizeof(list->props[0]),
   59|   184k|                   search_prop_name);
   60|   184k|}
m_property.c:search_prop_name:
   50|  1.66M|{
   51|  1.66M|    const struct m_property *prop = pelem;
   52|  1.66M|    return bstrcmp0(*(const bstr *)pkey, prop->name);
   53|  1.66M|}
m_property.c:resolve_name:
   72|   184k|{
   73|   184k|    *key = NULL;
   74|   184k|    const char *sep = strchr(name, '/');
   75|   184k|    if (sep && sep[1]) {
  ------------------
  |  Branch (75:9): [True: 0, False: 184k]
  |  Branch (75:16): [True: 0, False: 0]
  ------------------
   76|      0|        *key = sep + 1;
   77|      0|        return find_prop(list, bstr_splice(bstr0(name), 0, sep - name));
   78|      0|    }
   79|   184k|    return find_prop(list, bstr0(name));
   80|   184k|}
m_property.c:do_action:
   84|   616k|{
   85|   616k|    if (key) {
  ------------------
  |  Branch (85:9): [True: 0, False: 616k]
  ------------------
   86|      0|        struct m_property_action_arg ka = {
   87|      0|            .key = key,
   88|      0|            .action = action,
   89|      0|            .arg = arg,
   90|      0|        };
   91|      0|        return prop->call(ctx, prop, M_PROPERTY_KEY_ACTION, &ka);
   92|      0|    }
   93|   616k|    return prop->call(ctx, prop, action, arg);
   94|   616k|}
m_property.c:expand_property:
  305|   184k|{
  306|   184k|    bool cond_yes = bstr_eatstart0(&prop, "?");
  307|   184k|    bool cond_no = !cond_yes && bstr_eatstart0(&prop, "!");
  ------------------
  |  Branch (307:20): [True: 123k, False: 61.6k]
  |  Branch (307:33): [True: 61.6k, False: 61.6k]
  ------------------
  308|   184k|    bool test = cond_yes || cond_no;
  ------------------
  |  Branch (308:17): [True: 61.6k, False: 123k]
  |  Branch (308:29): [True: 61.6k, False: 61.6k]
  ------------------
  309|   184k|    bool raw = bstr_eatstart0(&prop, "=");
  310|   184k|    bool fixed_len = !raw && bstr_eatstart0(&prop, ">");
  ------------------
  |  Branch (310:22): [True: 184k, False: 0]
  |  Branch (310:30): [True: 0, False: 184k]
  ------------------
  311|   184k|    bstr comp_with = {0};
  312|   184k|    bool comp = test && bstr_split_tok(prop, "==", &prop, &comp_with);
  ------------------
  |  Branch (312:17): [True: 123k, False: 61.6k]
  |  Branch (312:25): [True: 0, False: 123k]
  ------------------
  313|   184k|    if (test && !comp)
  ------------------
  |  Branch (313:9): [True: 123k, False: 61.6k]
  |  Branch (313:17): [True: 123k, False: 0]
  ------------------
  314|   123k|        raw = true;
  315|   184k|    int method = raw ? M_PROPERTY_GET_STRING : print_action;
  ------------------
  |  Branch (315:18): [True: 123k, False: 61.6k]
  ------------------
  316|   184k|    method = fixed_len ? M_PROPERTY_FIXED_LEN_PRINT : method;
  ------------------
  |  Branch (316:14): [True: 0, False: 184k]
  ------------------
  317|       |
  318|   184k|    char *s = NULL;
  319|   184k|    int r = m_property_do_bstr(prop_list, prop, method, &s, ctx);
  320|   184k|    bool skip;
  321|   184k|    if (comp) {
  ------------------
  |  Branch (321:9): [True: 0, False: 184k]
  ------------------
  322|      0|        skip = ((s && bstr_equals0(comp_with, s)) != cond_yes);
  ------------------
  |  Branch (322:18): [True: 0, False: 0]
  |  Branch (322:23): [True: 0, False: 0]
  ------------------
  323|   184k|    } else if (test) {
  ------------------
  |  Branch (323:16): [True: 123k, False: 61.6k]
  ------------------
  324|   123k|        skip = (!!s != cond_yes);
  325|   123k|    } else {
  326|  61.6k|        skip = !!s;
  327|  61.6k|        char *append = s;
  328|  61.6k|        if (!s && !silent_error && !raw)
  ------------------
  |  Branch (328:13): [True: 0, False: 61.6k]
  |  Branch (328:19): [True: 0, False: 0]
  |  Branch (328:36): [True: 0, False: 0]
  ------------------
  329|      0|            append = (r == M_PROPERTY_UNAVAILABLE) ? "(unavailable)" : "(error)";
  ------------------
  |  Branch (329:22): [True: 0, False: 0]
  ------------------
  330|  61.6k|        append_str(ret, ret_len, bstr0(append));
  331|  61.6k|    }
  332|   184k|    talloc_free(s);
  ------------------
  |  |   47|   184k|#define talloc_free                     ta_free
  ------------------
  333|   184k|    return skip;
  334|   184k|}
m_property.c:m_property_do_bstr:
  287|   184k|{
  288|   184k|    char *name0 = bstrdup0(NULL, name);
  289|   184k|    int ret = m_property_do(NULL, prop_list, name0, action, arg, ctx);
  290|   184k|    talloc_free(name0);
  ------------------
  |  |   47|   184k|#define talloc_free                     ta_free
  ------------------
  291|   184k|    return ret;
  292|   184k|}
m_property.c:append_str:
  295|  61.6k|{
  296|  61.6k|    MP_TARRAY_GROW(NULL, *s, *len + append.len);
  ------------------
  |  |   96|  61.6k|    do {                                            \
  |  |   97|  61.6k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  61.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  61.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  61.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 61.6k, False: 0]
  |  |  ------------------
  |  |   99|  61.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  61.6k|    do {                                                        \
  |  |  |  |   89|  61.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  61.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  61.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  61.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  61.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  61.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  61.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 61.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  61.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 61.6k]
  |  |  ------------------
  ------------------
  297|  61.6k|    if (append.len)
  ------------------
  |  Branch (297:9): [True: 61.6k, False: 0]
  ------------------
  298|  61.6k|        memcpy(*s + *len, append.start, append.len);
  299|  61.6k|    *len = *len + append.len;
  300|  61.6k|}

m_config_parse:
   45|  28.9k|{
   46|  28.9k|    m_profile_t *profile = m_config_add_profile(config, initial_section);
   47|  28.9k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  28.9k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  28.9k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   48|  28.9k|    int line_no = 0;
   49|  28.9k|    int errors = 0;
   50|       |
   51|  28.9k|    bstr_eatstart0(&data, "\xEF\xBB\xBF"); // skip BOM
   52|       |
   53|  2.95M|    while (data.len) {
  ------------------
  |  Branch (53:12): [True: 2.92M, False: 28.9k]
  ------------------
   54|  2.92M|        talloc_free_children(tmp);
  ------------------
  |  |   46|  2.92M|#define talloc_free_children            ta_free_children
  ------------------
   55|  2.92M|        bool ok = false;
   56|       |
   57|  2.92M|        line_no++;
   58|  2.92M|        char loc[512];
   59|  2.92M|        snprintf(loc, sizeof(loc), "%s:%d:", location, line_no);
   60|       |
   61|  2.92M|        bstr line = bstr_strip_linebreaks(bstr_getline(data, &data));
   62|  2.92M|        if (!skip_ws(&line))
  ------------------
  |  Branch (62:13): [True: 723k, False: 2.20M]
  ------------------
   63|   723k|            continue;
   64|       |
   65|       |        // Profile declaration
   66|  2.20M|        if (bstr_eatstart0(&line, "[")) {
  ------------------
  |  Branch (66:13): [True: 347k, False: 1.85M]
  ------------------
   67|   347k|            bstr profilename;
   68|   347k|            if (!bstr_split_tok(line, "]", &profilename, &line)) {
  ------------------
  |  Branch (68:17): [True: 0, False: 347k]
  ------------------
   69|      0|                MP_ERR(config, "%s missing closing ]\n", loc);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   70|      0|                goto error;
   71|      0|            }
   72|   347k|            if (skip_ws(&line)) {
  ------------------
  |  Branch (72:17): [True: 0, False: 347k]
  ------------------
   73|      0|                MP_ERR(config, "%s unparsable extra characters: '%.*s'\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   74|      0|                       loc, BSTR_P(line));
   75|      0|                goto error;
   76|      0|            }
   77|   347k|            profile = m_config_add_profile(config, bstrto0(tmp, profilename));
   78|   347k|            continue;
   79|   347k|        }
   80|       |
   81|  1.85M|        bstr_eatstart0(&line, "--");
   82|       |
   83|  1.85M|        bstr option = line;
   84|  24.9M|        while (line.len && (mp_isalnum(line.start[0]) || line.start[0] == '_' ||
  ------------------
  |  Branch (84:16): [True: 24.9M, False: 0]
  |  Branch (84:29): [True: 21.0M, False: 3.85M]
  |  Branch (84:58): [True: 0, False: 3.85M]
  ------------------
   85|  3.85M|                            line.start[0] == '-'))
  ------------------
  |  Branch (85:29): [True: 1.99M, False: 1.85M]
  ------------------
   86|  23.0M|            line = bstr_cut(line, 1);
   87|  1.85M|        option.len = option.len - line.len;
   88|  1.85M|        skip_ws(&line);
   89|       |
   90|  1.85M|        bstr value = {0};
   91|  1.85M|        if (bstr_eatstart0(&line, "=")) {
  ------------------
  |  Branch (91:13): [True: 1.85M, False: 0]
  ------------------
   92|  1.85M|            skip_ws(&line);
   93|  1.85M|            if (line.len && (line.start[0] == '"' || line.start[0] == '\'')) {
  ------------------
  |  Branch (93:17): [True: 1.85M, False: 0]
  |  Branch (93:30): [True: 0, False: 1.85M]
  |  Branch (93:54): [True: 0, False: 1.85M]
  ------------------
   94|       |                // Simple quoting, like "value"
   95|      0|                char term[2] = {line.start[0], 0};
   96|      0|                line = bstr_cut(line, 1);
   97|      0|                if (!bstr_split_tok(line, term, &value, &line)) {
  ------------------
  |  Branch (97:21): [True: 0, False: 0]
  ------------------
   98|      0|                    MP_ERR(config, "%s unterminated quote\n", loc);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   99|      0|                    goto error;
  100|      0|                }
  101|  1.85M|            } else if (bstr_eatstart0(&line, "%")) {
  ------------------
  |  Branch (101:24): [True: 0, False: 1.85M]
  ------------------
  102|       |                // Quoting with length, like %5%value
  103|      0|                bstr rest;
  104|      0|                long long len = bstrtoll(line, &rest, 10);
  105|      0|                if (rest.len == line.len || !bstr_eatstart0(&rest, "%") ||
  ------------------
  |  Branch (105:21): [True: 0, False: 0]
  |  Branch (105:45): [True: 0, False: 0]
  ------------------
  106|      0|                    len > rest.len)
  ------------------
  |  Branch (106:21): [True: 0, False: 0]
  ------------------
  107|      0|                {
  108|      0|                    MP_ERR(config, "%s fixed-length quoting expected - put "
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  109|      0|                           "\"quotes\" around the option value if you did not "
  110|      0|                           "intend to use this, but your option value starts "
  111|      0|                           "with '%%'\n", loc);
  112|      0|                    goto error;
  113|      0|                }
  114|      0|                value = bstr_splice(rest, 0, len);
  115|      0|                line = bstr_cut(rest, len);
  116|  1.85M|            } else {
  117|       |                // No quoting; take everything until the comment or end of line
  118|  1.85M|                int end = bstrchr(line, '#');
  119|  1.85M|                value = bstr_strip(end < 0 ? line : bstr_splice(line, 0, end));
  ------------------
  |  Branch (119:36): [True: 1.56M, False: 289k]
  ------------------
  120|  1.85M|                line.len = 0;
  121|  1.85M|            }
  122|  1.85M|        }
  123|  1.85M|        if (skip_ws(&line)) {
  ------------------
  |  Branch (123:13): [True: 0, False: 1.85M]
  ------------------
  124|      0|            MP_ERR(config, "%s unparsable extra characters: '%.*s'\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|      0|                   loc, BSTR_P(line));
  126|      0|            goto error;
  127|      0|        }
  128|       |
  129|  1.85M|        int res = m_config_set_profile_option(config, profile, option, value);
  130|  1.85M|        if (res < 0) {
  ------------------
  |  Branch (130:13): [True: 144k, False: 1.70M]
  ------------------
  131|   144k|            MP_ERR(config, "%s setting option %.*s='%.*s' failed.\n",
  ------------------
  |  |   89|   144k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   579k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 144k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 144k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|   144k|                   loc, BSTR_P(option), BSTR_P(value));
  133|   144k|            goto error;
  134|   144k|        }
  135|       |
  136|  1.70M|        ok = true;
  137|  1.85M|    error:
  138|  1.85M|        if (!ok)
  ------------------
  |  Branch (138:13): [True: 144k, False: 1.70M]
  ------------------
  139|   144k|            errors++;
  140|  1.85M|        if (errors > 16) {
  ------------------
  |  Branch (140:13): [True: 0, False: 1.85M]
  ------------------
  141|      0|            MP_ERR(config, "%s: too many errors, stopping.\n", location);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  142|      0|            break;
  143|      0|        }
  144|  1.85M|    }
  145|       |
  146|  28.9k|    if (config->recursion_depth == 0)
  ------------------
  |  Branch (146:9): [True: 28.9k, False: 0]
  ------------------
  147|  28.9k|        m_config_finish_default_profile(config, flags);
  148|       |
  149|  28.9k|    talloc_free(tmp);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  150|  28.9k|    return 1;
  151|  28.9k|}
parse_configfile.c:skip_ws:
   36|  8.83M|{
   37|  8.83M|    *s = bstr_lstrip(*s);
   38|  8.83M|    if (bstr_startswith0(*s, "#"))
  ------------------
  |  Branch (38:9): [True: 347k, False: 8.48M]
  ------------------
   39|   347k|        s->len = 0;
   40|  8.83M|    return s->len;
   41|  8.83M|}

mp_init_paths:
  109|  28.9k|{
  110|  28.9k|    TA_FREEP(&global->configdir);
  ------------------
  |  |   81|  28.9k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  28.9k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
  111|       |
  112|  28.9k|    const char *force_configdir = getenv("MPV_HOME");
  113|  28.9k|    if (opts->force_configdir && opts->force_configdir[0])
  ------------------
  |  Branch (113:9): [True: 0, False: 28.9k]
  |  Branch (113:34): [True: 0, False: 0]
  ------------------
  114|      0|        force_configdir = opts->force_configdir;
  115|  28.9k|    if (!opts->load_config)
  ------------------
  |  Branch (115:9): [True: 28.9k, False: 0]
  ------------------
  116|  28.9k|        force_configdir = "";
  117|       |
  118|  28.9k|    global->configdir = mp_get_user_path(global, global, force_configdir);
  119|  28.9k|}
mp_find_user_file:
  123|   165k|{
  124|   165k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   165k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   165k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  125|   165k|    char *res = (char *)mp_get_platform_path(tmp, global, type);
  126|   165k|    if (res)
  ------------------
  |  Branch (126:9): [True: 0, False: 165k]
  ------------------
  127|      0|        res = mp_path_join(talloc_ctx, res, filename);
  128|   165k|    talloc_free(tmp);
  ------------------
  |  |   47|   165k|#define talloc_free                     ta_free
  ------------------
  129|   165k|    MP_DBG(global, "%s path: '%s' -> '%s'\n", type, filename, res ? res : "-");
  ------------------
  |  |   93|   165k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   330k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 165k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|   165k|    return res;
  131|   165k|}
mp_find_all_config_files:
  170|   115k|{
  171|   115k|    return mp_find_all_config_files_limited(talloc_ctx, global, 64, filename);
  172|   115k|}
mp_find_config_file:
  176|  21.8k|{
  177|  21.8k|    char **l = mp_find_all_config_files_limited(talloc_ctx, global, 1, filename);
  178|  21.8k|    char *r = l && l[0] ? talloc_steal(talloc_ctx, l[0]) : NULL;
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  |  Branch (178:15): [True: 21.8k, False: 0]
  |  Branch (178:20): [True: 0, False: 21.8k]
  ------------------
  179|  21.8k|    talloc_free(l);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  180|  21.8k|    return r;
  181|  21.8k|}
mp_get_user_path:
  185|   365k|{
  186|   365k|    if (!path)
  ------------------
  |  Branch (186:9): [True: 144k, False: 220k]
  ------------------
  187|   144k|        return NULL;
  188|   220k|    char *res = NULL;
  189|   220k|    bstr bpath = bstr0(path);
  190|   220k|    if (bstr_eatstart0(&bpath, "~")) {
  ------------------
  |  Branch (190:9): [True: 59.8k, False: 160k]
  ------------------
  191|       |        // parse to "~" <prefix> "/" <rest>
  192|  59.8k|        bstr prefix, rest;
  193|  59.8k|        if (bstr_split_tok(bpath, "/", &prefix, &rest)) {
  ------------------
  |  Branch (193:13): [True: 58.7k, False: 1.08k]
  ------------------
  194|  58.7k|            const char *rest0 = rest.start; // ok in this case
  195|  58.7k|            if (bstr_equals0(prefix, "~")) {
  ------------------
  |  Branch (195:17): [True: 0, False: 58.7k]
  ------------------
  196|      0|                res = mp_find_config_file(talloc_ctx, global, rest0);
  197|      0|                if (!res) {
  ------------------
  |  Branch (197:21): [True: 0, False: 0]
  ------------------
  198|      0|                    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  199|      0|                    const char *p = mp_get_platform_path(tmp, global, "home");
  200|      0|                    res = mp_path_join_bstr(talloc_ctx, bstr0(p), rest);
  201|      0|                    talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  202|      0|                }
  203|  58.7k|            } else if (bstr_equals0(prefix, "")) {
  ------------------
  |  Branch (203:24): [True: 118, False: 58.6k]
  ------------------
  204|    118|                char *home = getenv("HOME");
  205|    118|                if (!home)
  ------------------
  |  Branch (205:21): [True: 0, False: 118]
  ------------------
  206|      0|                    home = getenv("USERPROFILE");
  207|    118|                res = mp_path_join_bstr(talloc_ctx, bstr0(home), rest);
  208|  58.6k|            } else if (bstr_eatstart0(&prefix, "~")) {
  ------------------
  |  Branch (208:24): [True: 57.9k, False: 697]
  ------------------
  209|  57.9k|                void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  57.9k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  57.9k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  210|  57.9k|                char type[80];
  211|  57.9k|                snprintf(type, sizeof(type), "%.*s", BSTR_P(prefix));
  ------------------
  |  |  307|  57.9k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 57.9k, False: 0]
  |  |  ------------------
  ------------------
  212|  57.9k|                const char *p = mp_get_platform_path(tmp, global, type);
  213|  57.9k|                res = mp_path_join_bstr(talloc_ctx, bstr0(p), rest);
  214|  57.9k|                talloc_free(tmp);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
  215|  57.9k|            }
  216|  58.7k|        }
  217|  59.8k|    }
  218|   220k|    if (!res) {
  ------------------
  |  Branch (218:9): [True: 162k, False: 58.0k]
  ------------------
  219|   162k|        res = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|   162k|#define talloc_strdup                   ta_xstrdup
  ------------------
  220|   162k|    } else {
  221|  58.0k|        MP_DBG(global, "user path: '%s' -> '%s'\n", path, res);
  ------------------
  |  |   93|  58.0k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  58.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  222|  58.0k|    }
  223|   220k|    return res;
  224|   365k|}
mp_mk_user_dir:
  236|  28.9k|{
  237|  28.9k|    char *dir = mp_find_user_file(NULL, global, type, subdir);
  238|  28.9k|    if (dir)
  ------------------
  |  Branch (238:9): [True: 0, False: 28.9k]
  ------------------
  239|      0|        mp_mkdirp(dir);
  240|  28.9k|    talloc_free(dir);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  241|  28.9k|}
path.c:mp_get_platform_path:
   74|   911k|{
   75|   911k|    mp_assert(talloc_ctx);
  ------------------
  |  |   41|   911k|#define mp_assert assert
  ------------------
  |  Branch (75:5): [True: 911k, False: 0]
  ------------------
   76|       |
   77|   911k|    if (global->configdir) {
  ------------------
  |  Branch (77:9): [True: 911k, False: 0]
  ------------------
   78|       |        // Return NULL for all platform paths if --no-config is passed
   79|   911k|        if (!global->configdir[0])
  ------------------
  |  Branch (79:13): [True: 911k, False: 0]
  ------------------
   80|   911k|            return NULL;
   81|       |
   82|       |        // force all others to NULL, only first returns the path
   83|      0|        for (int n = 0; n < MP_ARRAY_SIZE(config_dirs); n++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (83:25): [True: 0, False: 0]
  ------------------
   84|      0|            if (strcmp(config_dirs[n], type) == 0)
  ------------------
  |  Branch (84:17): [True: 0, False: 0]
  ------------------
   85|      0|                return (n == 0) ? global->configdir : NULL;
  ------------------
  |  Branch (85:24): [True: 0, False: 0]
  ------------------
   86|      0|        }
   87|      0|    }
   88|       |
   89|       |    // Return the native config path if the platform doesn't support the
   90|       |    // type we are trying to fetch.
   91|      0|    const char *fallback_type = NULL;
   92|      0|    if (!strcmp(type, "cache") || !strcmp(type, "state"))
  ------------------
  |  Branch (92:9): [True: 0, False: 0]
  |  Branch (92:35): [True: 0, False: 0]
  ------------------
   93|      0|        fallback_type = "home";
   94|       |
   95|      0|    for (int n = 0; n < MP_ARRAY_SIZE(path_resolvers); n++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (95:21): [True: 0, False: 0]
  ------------------
   96|      0|        const char *path = path_resolvers[n](talloc_ctx, type);
   97|      0|        if (path && path[0])
  ------------------
  |  Branch (97:13): [True: 0, False: 0]
  |  Branch (97:21): [True: 0, False: 0]
  ------------------
   98|      0|            return path;
   99|      0|    }
  100|       |
  101|      0|    if (fallback_type) {
  ------------------
  |  Branch (101:9): [True: 0, False: 0]
  ------------------
  102|      0|        mp_assert(strcmp(fallback_type, type) != 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (102:9): [True: 0, False: 0]
  ------------------
  103|      0|        return mp_get_platform_path(talloc_ctx, global, fallback_type);
  104|      0|    }
  105|      0|    return NULL;
  106|      0|}
path.c:mp_find_all_config_files_limited:
  137|   137k|{
  138|   137k|    char **ret = talloc_array(talloc_ctx, char*, 2); // 2 preallocated
  ------------------
  |  |   29|   137k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|   137k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   137k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  139|   137k|    int num_ret = 0;
  140|       |
  141|   825k|    for (int i = 0; i < MP_ARRAY_SIZE(config_dirs); i++) {
  ------------------
  |  |   49|   825k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (141:21): [True: 688k, False: 137k]
  ------------------
  142|   688k|        const char *dir = mp_get_platform_path(ret, global, config_dirs[i]);
  143|   688k|        bstr s = bstr0(filename);
  144|   688k|        while (dir && num_ret < max_files && s.len) {
  ------------------
  |  Branch (144:16): [True: 0, False: 688k]
  |  Branch (144:23): [True: 0, False: 0]
  |  Branch (144:46): [True: 0, False: 0]
  ------------------
  145|      0|            bstr fn;
  146|      0|            bstr_split_tok(s, "|", &fn, &s);
  147|       |
  148|      0|            char *file = mp_path_join_bstr(ret, bstr0(dir), fn);
  149|      0|            if (mp_path_exists(file)) {
  ------------------
  |  Branch (149:17): [True: 0, False: 0]
  ------------------
  150|      0|                MP_DBG(global, "config path: '%.*s' -> '%s'\n",
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  151|      0|                        BSTR_P(fn), file);
  152|      0|                MP_TARRAY_APPEND(NULL, ret, num_ret, file);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  153|      0|            } else {
  154|      0|                MP_DBG(global, "config path: '%.*s' -/-> '%s'\n",
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|      0|                        BSTR_P(fn), file);
  156|      0|            }
  157|      0|        }
  158|   688k|    }
  159|       |
  160|   137k|    MP_TARRAY_GROW(NULL, ret, num_ret);
  ------------------
  |  |   96|   137k|    do {                                            \
  |  |   97|   137k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   137k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   137k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   137k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 137k]
  |  |  ------------------
  |  |   99|   137k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   137k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 137k]
  |  |  ------------------
  ------------------
  161|   137k|    ret[num_ret] = NULL;
  162|       |
  163|   137k|    for (int n = 0; n < num_ret / 2; n++)
  ------------------
  |  Branch (163:21): [True: 0, False: 137k]
  ------------------
  164|      0|        MPSWAP(char*, ret[n], ret[num_ret - n - 1]);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
  165|   137k|    return ret;
  166|   137k|}

mp_open:
  171|    545|{
  172|    545|    if (oflag & (O_WRONLY | O_RDWR | O_CREAT | O_TRUNC))
  ------------------
  |  Branch (172:9): [True: 0, False: 545]
  ------------------
  173|      0|        return memfd_create("mpv", oflag & O_CLOEXEC ? MFD_CLOEXEC : 0);
  ------------------
  |  Branch (173:36): [True: 0, False: 0]
  ------------------
  174|    545|    return (open)(filename, oflag);
  175|    545|}

mp_get_user_langs:
   26|  21.8k|{
   27|  21.8k|    static const char *const list[] = {
   28|  21.8k|        "LC_ALL",
   29|  21.8k|        "LC_MESSAGES",
   30|  21.8k|        "LANG",
   31|  21.8k|        NULL
   32|  21.8k|    };
   33|       |
   34|  21.8k|    size_t nb = 0;
   35|  21.8k|    char **ret = NULL;
   36|  21.8k|    bool has_c = false;
   37|       |
   38|       |    // Prefer anything we get from LANGUAGE first
   39|  21.8k|    for (const char *langList = getenv("LANGUAGE"); langList && *langList;) {
  ------------------
  |  Branch (39:53): [True: 0, False: 21.8k]
  |  Branch (39:65): [True: 0, False: 0]
  ------------------
   40|      0|        size_t len = strcspn(langList, ":");
   41|      0|        MP_TARRAY_GROW(NULL, ret, nb);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   42|      0|        char *lang = talloc_strndup(ret, langList, len);
  ------------------
  |  |   51|      0|#define talloc_strndup                  ta_xstrndup
  ------------------
   43|      0|        for (int i = 0; i < len; i++) {
  ------------------
  |  Branch (43:25): [True: 0, False: 0]
  ------------------
   44|      0|            if (lang[i] == '_')
  ------------------
  |  Branch (44:17): [True: 0, False: 0]
  ------------------
   45|      0|                lang[i] = '-';
   46|      0|        }
   47|      0|        ret[nb++] = lang;
   48|      0|        langList += len;
   49|      0|        while (*langList == ':')
  ------------------
  |  Branch (49:16): [True: 0, False: 0]
  ------------------
   50|      0|            langList++;
   51|      0|    }
   52|       |
   53|       |    // Then, the language components of other relevant locale env vars
   54|  87.2k|    for (int i = 0; list[i]; i++) {
  ------------------
  |  Branch (54:21): [True: 65.4k, False: 21.8k]
  ------------------
   55|  65.4k|        const char *envval = getenv(list[i]);
   56|  65.4k|        if (envval && *envval) {
  ------------------
  |  Branch (56:13): [True: 0, False: 65.4k]
  |  Branch (56:23): [True: 0, False: 0]
  ------------------
   57|      0|            size_t len = strcspn(envval, ".@");
   58|      0|            if (!strncmp("C", envval, len)) {
  ------------------
  |  Branch (58:17): [True: 0, False: 0]
  ------------------
   59|      0|                has_c = true;
   60|      0|                continue;
   61|      0|            }
   62|       |
   63|      0|            MP_TARRAY_GROW(NULL, ret, nb);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   64|      0|            char *lang = talloc_strndup(ret, envval, len);
  ------------------
  |  |   51|      0|#define talloc_strndup                  ta_xstrndup
  ------------------
   65|      0|            for (int j = 0; j < len; j++) {
  ------------------
  |  Branch (65:29): [True: 0, False: 0]
  ------------------
   66|      0|                if (lang[j] == '_')
  ------------------
  |  Branch (66:21): [True: 0, False: 0]
  ------------------
   67|      0|                    lang[j] = '-';
   68|      0|            }
   69|       |
   70|      0|            ret[nb++] = lang;
   71|      0|        }
   72|  65.4k|    }
   73|       |
   74|  21.8k|    if (has_c && !nb) {
  ------------------
  |  Branch (74:9): [True: 0, False: 21.8k]
  |  Branch (74:18): [True: 0, False: 0]
  ------------------
   75|      0|        MP_TARRAY_GROW(NULL, ret, nb);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   76|      0|        ret[nb++] = talloc_strdup(ret, "en");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
   77|      0|    }
   78|       |
   79|       |    // Null-terminate the list
   80|  21.8k|    MP_TARRAY_APPEND(NULL, ret, nb, NULL);
  ------------------
  |  |  105|  21.8k|    do {                                            \
  |  |  106|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 21.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  21.8k|    do {                                                        \
  |  |  |  |  |  |   89|  21.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  21.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  21.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  21.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  21.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  21.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  21.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 21.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.8k|        (idxvar)++;                                 \
  |  |  109|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
   81|       |
   82|  21.8k|    return ret;
   83|  21.8k|}

client.c:mp_mutex_init:
  113|   144k|{
  114|   144k|#ifndef NDEBUG
  115|   144k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   144k|    int ret = 0;
  121|   144k|    pthread_mutexattr_t attr;
  122|   144k|    ret = pthread_mutexattr_init(&attr);
  123|   144k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 144k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   144k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   144k|    ret = pthread_mutex_init(mutex, &attr);
  128|   144k|    pthread_mutexattr_destroy(&attr);
  129|   144k|    mp_assert(!ret);
  ------------------
  |  |   41|   144k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 144k, False: 0]
  ------------------
  130|   144k|    return ret;
  131|   144k|}
client.c:mp_cond_init:
  139|  57.9k|{
  140|  57.9k|    mp_assert(cond);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 57.9k, False: 0]
  ------------------
  141|       |
  142|  57.9k|    int ret = 0;
  143|  57.9k|    pthread_condattr_t attr;
  144|  57.9k|    ret = pthread_condattr_init(&attr);
  145|  57.9k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 57.9k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  57.9k|    cond->clk_id = CLOCK_REALTIME;
  149|  57.9k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  57.9k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 57.9k, False: 0]
  ------------------
  151|  57.9k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  57.9k|#endif
  153|       |
  154|  57.9k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  57.9k|    pthread_condattr_destroy(&attr);
  156|  57.9k|    return ret;
  157|  57.9k|}
client.c:mp_cond_timedwait_until:
  205|   272k|{
  206|   272k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   272k|}
client.c:mp_cond_timedwait:
  184|   272k|{
  185|   272k|    mp_assert(cond);
  ------------------
  |  |   41|   272k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 272k, False: 0]
  ------------------
  186|       |
  187|   272k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   272k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 272k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   272k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   272k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 231k, False: 41.3k]
  ------------------
  190|   231k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  41.3k|    struct timespec ts;
  193|  41.3k|    clock_gettime(cond->clk_id, &ts);
  194|  41.3k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  41.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  41.3k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  41.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  41.3k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  41.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 41.3k, False: 0]
  ------------------
  197|  41.3k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  41.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  41.3k|        ts.tv_sec++;
  199|  41.3k|    }
  200|       |
  201|  41.3k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   272k|}
client.c:mp_cond_destroy:
  160|  57.9k|{
  161|  57.9k|    mp_assert(cond);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 57.9k, False: 0]
  ------------------
  162|  57.9k|    return pthread_cond_destroy(&cond->cond);
  163|  57.9k|}
client.c:mp_thread_set_name:
  222|  28.9k|{
  223|  28.9k|#if HAVE_GLIBC_THREAD_NAME
  224|  28.9k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 28.9k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  28.9k|}
client.c:mp_cond_broadcast:
  166|   293k|{
  167|   293k|    mp_assert(cond);
  ------------------
  |  |   41|   293k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 293k, False: 0]
  ------------------
  168|   293k|    return pthread_cond_broadcast(&cond->cond);
  169|   293k|}
loadfile.c:mp_thread_set_name:
  222|  31.7k|{
  223|  31.7k|#if HAVE_GLIBC_THREAD_NAME
  224|  31.7k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 31.7k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  31.7k|}
main.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
osd.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
clipboard.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
vo.c:mp_mutex_init:
  113|  19.2k|{
  114|  19.2k|#ifndef NDEBUG
  115|  19.2k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  19.2k|    int ret = 0;
  121|  19.2k|    pthread_mutexattr_t attr;
  122|  19.2k|    ret = pthread_mutexattr_init(&attr);
  123|  19.2k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 19.2k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  19.2k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  19.2k|    ret = pthread_mutex_init(mutex, &attr);
  128|  19.2k|    pthread_mutexattr_destroy(&attr);
  129|  19.2k|    mp_assert(!ret);
  ------------------
  |  |   41|  19.2k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 19.2k, False: 0]
  ------------------
  130|  19.2k|    return ret;
  131|  19.2k|}
vo.c:mp_cond_init:
  139|  9.61k|{
  140|  9.61k|    mp_assert(cond);
  ------------------
  |  |   41|  9.61k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 9.61k, False: 0]
  ------------------
  141|       |
  142|  9.61k|    int ret = 0;
  143|  9.61k|    pthread_condattr_t attr;
  144|  9.61k|    ret = pthread_condattr_init(&attr);
  145|  9.61k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 9.61k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  9.61k|    cond->clk_id = CLOCK_REALTIME;
  149|  9.61k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  9.61k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 9.61k, False: 0]
  ------------------
  151|  9.61k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  9.61k|#endif
  153|       |
  154|  9.61k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  9.61k|    pthread_condattr_destroy(&attr);
  156|  9.61k|    return ret;
  157|  9.61k|}
vo.c:mp_thread_set_name:
  222|  9.61k|{
  223|  9.61k|#if HAVE_GLIBC_THREAD_NAME
  224|  9.61k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 9.61k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  9.61k|}
vo.c:mp_thread_set_min_timer_slack:
  237|  9.61k|{
  238|  9.61k|#if HAVE_PR_SET_TIMERSLACK
  239|       |    prctl(PR_SET_TIMERSLACK, 1UL);
  240|  9.61k|#endif
  241|  9.61k|}
vo.c:mp_cond_broadcast:
  166|   192k|{
  167|   192k|    mp_assert(cond);
  ------------------
  |  |   41|   192k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 192k, False: 0]
  ------------------
  168|   192k|    return pthread_cond_broadcast(&cond->cond);
  169|   192k|}
vo.c:mp_cond_destroy:
  160|  9.61k|{
  161|  9.61k|    mp_assert(cond);
  ------------------
  |  |   41|  9.61k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 9.61k, False: 0]
  ------------------
  162|  9.61k|    return pthread_cond_destroy(&cond->cond);
  163|  9.61k|}
vo.c:mp_cond_timedwait_until:
  205|   121k|{
  206|   121k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   121k|}
vo.c:mp_cond_timedwait:
  184|   121k|{
  185|   121k|    mp_assert(cond);
  ------------------
  |  |   41|   121k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 121k, False: 0]
  ------------------
  186|       |
  187|   121k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   121k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 121k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   121k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   121k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 0, False: 121k]
  ------------------
  190|      0|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   121k|    struct timespec ts;
  193|   121k|    clock_gettime(cond->clk_id, &ts);
  194|   121k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   121k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   121k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   121k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   121k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   121k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 121k, False: 0]
  ------------------
  197|   121k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   121k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|   121k|        ts.tv_sec++;
  199|   121k|    }
  200|       |
  201|   121k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   121k|}
vo.c:mp_cond_wait:
  178|  1.00k|{
  179|  1.00k|    mp_assert(cond);
  ------------------
  |  |   41|  1.00k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 1.00k, False: 0]
  ------------------
  180|  1.00k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  1.00k|}
buffer.c:mp_cond_broadcast:
  166|  1.39M|{
  167|  1.39M|    mp_assert(cond);
  ------------------
  |  |   41|  1.39M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 1.39M, False: 2]
  ------------------
  168|  1.39M|    return pthread_cond_broadcast(&cond->cond);
  169|  1.39M|}
buffer.c:mp_cond_timedwait:
  184|   659k|{
  185|   659k|    mp_assert(cond);
  ------------------
  |  |   41|   659k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 659k, False: 0]
  ------------------
  186|       |
  187|   659k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   659k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 659k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   659k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   659k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 16.4k, False: 642k]
  ------------------
  190|  16.4k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   642k|    struct timespec ts;
  193|   642k|    clock_gettime(cond->clk_id, &ts);
  194|   642k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   642k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   642k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   642k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   642k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   642k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 30.4k, False: 612k]
  ------------------
  197|  30.4k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  30.4k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  30.4k|        ts.tv_sec++;
  199|  30.4k|    }
  200|       |
  201|   642k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   659k|}
buffer.c:mp_cond_destroy:
  160|  15.9k|{
  161|  15.9k|    mp_assert(cond);
  ------------------
  |  |   41|  15.9k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 15.9k, False: 0]
  ------------------
  162|  15.9k|    return pthread_cond_destroy(&cond->cond);
  163|  15.9k|}
buffer.c:mp_mutex_init:
  113|  15.8k|{
  114|  15.8k|#ifndef NDEBUG
  115|  15.8k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  15.8k|    int ret = 0;
  121|  15.8k|    pthread_mutexattr_t attr;
  122|  15.8k|    ret = pthread_mutexattr_init(&attr);
  123|  15.8k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 15.8k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  15.8k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  15.8k|    ret = pthread_mutex_init(mutex, &attr);
  128|  15.8k|    pthread_mutexattr_destroy(&attr);
  129|  15.8k|    mp_assert(!ret);
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 15.8k, False: 0]
  ------------------
  130|  15.8k|    return ret;
  131|  15.8k|}
buffer.c:mp_cond_init:
  139|  15.8k|{
  140|  15.8k|    mp_assert(cond);
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 15.8k, False: 0]
  ------------------
  141|       |
  142|  15.8k|    int ret = 0;
  143|  15.8k|    pthread_condattr_t attr;
  144|  15.8k|    ret = pthread_condattr_init(&attr);
  145|  15.8k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 15.8k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  15.8k|    cond->clk_id = CLOCK_REALTIME;
  149|  15.8k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  15.8k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 15.8k, False: 0]
  ------------------
  151|  15.8k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  15.8k|#endif
  153|       |
  154|  15.8k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  15.8k|    pthread_condattr_destroy(&attr);
  156|  15.8k|    return ret;
  157|  15.8k|}
buffer.c:mp_thread_set_name:
  222|  7.92k|{
  223|  7.92k|#if HAVE_GLIBC_THREAD_NAME
  224|  7.92k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 7.92k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  7.92k|}
msg.c:mp_mutex_init:
  113|   115k|{
  114|   115k|#ifndef NDEBUG
  115|   115k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   115k|    int ret = 0;
  121|   115k|    pthread_mutexattr_t attr;
  122|   115k|    ret = pthread_mutexattr_init(&attr);
  123|   115k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 115k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   115k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   115k|    ret = pthread_mutex_init(mutex, &attr);
  128|   115k|    pthread_mutexattr_destroy(&attr);
  129|   115k|    mp_assert(!ret);
  ------------------
  |  |   41|   115k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 115k, False: 0]
  ------------------
  130|   115k|    return ret;
  131|   115k|}
msg.c:mp_cond_init:
  139|  28.9k|{
  140|  28.9k|    mp_assert(cond);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 28.9k, False: 0]
  ------------------
  141|       |
  142|  28.9k|    int ret = 0;
  143|  28.9k|    pthread_condattr_t attr;
  144|  28.9k|    ret = pthread_condattr_init(&attr);
  145|  28.9k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 28.9k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  28.9k|    cond->clk_id = CLOCK_REALTIME;
  149|  28.9k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  28.9k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 28.9k, False: 0]
  ------------------
  151|  28.9k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  28.9k|#endif
  153|       |
  154|  28.9k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  28.9k|    pthread_condattr_destroy(&attr);
  156|  28.9k|    return ret;
  157|  28.9k|}
msg.c:mp_cond_destroy:
  160|  28.9k|{
  161|  28.9k|    mp_assert(cond);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 28.9k, False: 0]
  ------------------
  162|  28.9k|    return pthread_cond_destroy(&cond->cond);
  163|  28.9k|}
stats.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
demux.c:mp_cond_destroy:
  160|   391k|{
  161|   391k|    mp_assert(cond);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 391k, False: 0]
  ------------------
  162|   391k|    return pthread_cond_destroy(&cond->cond);
  163|   391k|}
demux.c:mp_cond_signal:
  172|   234k|{
  173|   234k|    mp_assert(cond);
  ------------------
  |  |   41|   234k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 234k, False: 0]
  ------------------
  174|   234k|    return pthread_cond_signal(&cond->cond);
  175|   234k|}
demux.c:mp_thread_set_name:
  222|  19.9k|{
  223|  19.9k|#if HAVE_GLIBC_THREAD_NAME
  224|  19.9k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 19.9k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  19.9k|}
demux.c:mp_cond_timedwait_until:
  205|  59.8k|{
  206|  59.8k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  59.8k|}
demux.c:mp_cond_timedwait:
  184|  59.8k|{
  185|  59.8k|    mp_assert(cond);
  ------------------
  |  |   41|  59.8k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 59.8k, False: 0]
  ------------------
  186|       |
  187|  59.8k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  59.8k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 59.8k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  59.8k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  59.8k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 12.1k, False: 47.7k]
  ------------------
  190|  12.1k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  47.7k|    struct timespec ts;
  193|  47.7k|    clock_gettime(cond->clk_id, &ts);
  194|  47.7k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  47.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  47.7k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  47.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  47.7k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  47.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 47.6k, False: 15]
  ------------------
  197|  47.6k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  47.6k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  47.6k|        ts.tv_sec++;
  199|  47.6k|    }
  200|       |
  201|  47.7k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  59.8k|}
demux.c:mp_mutex_init:
  113|   391k|{
  114|   391k|#ifndef NDEBUG
  115|   391k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   391k|    int ret = 0;
  121|   391k|    pthread_mutexattr_t attr;
  122|   391k|    ret = pthread_mutexattr_init(&attr);
  123|   391k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 391k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   391k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   391k|    ret = pthread_mutex_init(mutex, &attr);
  128|   391k|    pthread_mutexattr_destroy(&attr);
  129|   391k|    mp_assert(!ret);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 391k, False: 0]
  ------------------
  130|   391k|    return ret;
  131|   391k|}
demux.c:mp_cond_init:
  139|   391k|{
  140|   391k|    mp_assert(cond);
  ------------------
  |  |   41|   391k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 391k, False: 0]
  ------------------
  141|       |
  142|   391k|    int ret = 0;
  143|   391k|    pthread_condattr_t attr;
  144|   391k|    ret = pthread_condattr_init(&attr);
  145|   391k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 391k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|   391k|    cond->clk_id = CLOCK_REALTIME;
  149|   391k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|   391k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 391k, False: 0]
  ------------------
  151|   391k|        cond->clk_id = CLOCK_MONOTONIC;
  152|   391k|#endif
  153|       |
  154|   391k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|   391k|    pthread_condattr_destroy(&attr);
  156|   391k|    return ret;
  157|   391k|}
packet_pool.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
f_async_queue.c:mp_mutex_init:
  113|  7.92k|{
  114|  7.92k|#ifndef NDEBUG
  115|  7.92k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  7.92k|    int ret = 0;
  121|  7.92k|    pthread_mutexattr_t attr;
  122|  7.92k|    ret = pthread_mutexattr_init(&attr);
  123|  7.92k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 7.92k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  7.92k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  7.92k|    ret = pthread_mutex_init(mutex, &attr);
  128|  7.92k|    pthread_mutexattr_destroy(&attr);
  129|  7.92k|    mp_assert(!ret);
  ------------------
  |  |   41|  7.92k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 7.92k, False: 0]
  ------------------
  130|  7.92k|    return ret;
  131|  7.92k|}
f_decoder_wrapper.c:mp_mutex_init:
  113|  21.8k|{
  114|  21.8k|#ifndef NDEBUG
  115|  21.8k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  21.8k|    int ret = 0;
  121|  21.8k|    pthread_mutexattr_t attr;
  122|  21.8k|    ret = pthread_mutexattr_init(&attr);
  123|  21.8k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 21.8k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  21.8k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  21.8k|    ret = pthread_mutex_init(mutex, &attr);
  128|  21.8k|    pthread_mutexattr_destroy(&attr);
  129|  21.8k|    mp_assert(!ret);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 21.8k, False: 0]
  ------------------
  130|  21.8k|    return ret;
  131|  21.8k|}
filter.c:mp_mutex_init:
  113|   141k|{
  114|   141k|#ifndef NDEBUG
  115|   141k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   141k|    int ret = 0;
  121|   141k|    pthread_mutexattr_t attr;
  122|   141k|    ret = pthread_mutexattr_init(&attr);
  123|   141k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 141k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   141k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   141k|    ret = pthread_mutex_init(mutex, &attr);
  128|   141k|    pthread_mutexattr_destroy(&attr);
  129|   141k|    mp_assert(!ret);
  ------------------
  |  |   41|   141k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 141k, False: 0]
  ------------------
  130|   141k|    return ret;
  131|   141k|}
input.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
dispatch.c:mp_cond_destroy:
  160|  38.5k|{
  161|  38.5k|    mp_assert(cond);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 38.5k, False: 0]
  ------------------
  162|  38.5k|    return pthread_cond_destroy(&cond->cond);
  163|  38.5k|}
dispatch.c:mp_mutex_init:
  113|  38.5k|{
  114|  38.5k|#ifndef NDEBUG
  115|  38.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  38.5k|    int ret = 0;
  121|  38.5k|    pthread_mutexattr_t attr;
  122|  38.5k|    ret = pthread_mutexattr_init(&attr);
  123|  38.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 38.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  38.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  38.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  38.5k|    pthread_mutexattr_destroy(&attr);
  129|  38.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 38.5k, False: 0]
  ------------------
  130|  38.5k|    return ret;
  131|  38.5k|}
dispatch.c:mp_cond_init:
  139|  38.5k|{
  140|  38.5k|    mp_assert(cond);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 38.5k, False: 0]
  ------------------
  141|       |
  142|  38.5k|    int ret = 0;
  143|  38.5k|    pthread_condattr_t attr;
  144|  38.5k|    ret = pthread_condattr_init(&attr);
  145|  38.5k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 38.5k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  38.5k|    cond->clk_id = CLOCK_REALTIME;
  149|  38.5k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  38.5k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 38.5k, False: 0]
  ------------------
  151|  38.5k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  38.5k|#endif
  153|       |
  154|  38.5k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  38.5k|    pthread_condattr_destroy(&attr);
  156|  38.5k|    return ret;
  157|  38.5k|}
dispatch.c:mp_cond_wait:
  178|   241k|{
  179|   241k|    mp_assert(cond);
  ------------------
  |  |   41|   241k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 241k, False: 0]
  ------------------
  180|   241k|    return pthread_cond_wait(&cond->cond, mutex);
  181|   241k|}
dispatch.c:mp_cond_broadcast:
  166|  1.83M|{
  167|  1.83M|    mp_assert(cond);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 1.83M, False: 0]
  ------------------
  168|  1.83M|    return pthread_cond_broadcast(&cond->cond);
  169|  1.83M|}
dispatch.c:mp_cond_timedwait_until:
  205|   247k|{
  206|   247k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   247k|}
dispatch.c:mp_cond_timedwait:
  184|   247k|{
  185|   247k|    mp_assert(cond);
  ------------------
  |  |   41|   247k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 247k, False: 0]
  ------------------
  186|       |
  187|   247k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   247k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 247k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   247k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   247k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 727, False: 247k]
  ------------------
  190|    727|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   247k|    struct timespec ts;
  193|   247k|    clock_gettime(cond->clk_id, &ts);
  194|   247k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   247k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   247k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   247k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   247k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   247k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 39.3k, False: 207k]
  ------------------
  197|  39.3k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  39.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  39.3k|        ts.tv_sec++;
  199|  39.3k|    }
  200|       |
  201|   247k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   247k|}
rendezvous.c:mp_cond_broadcast:
  166|  9.61k|{
  167|  9.61k|    mp_assert(cond);
  ------------------
  |  |   41|  9.61k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 9.61k, False: 0]
  ------------------
  168|  9.61k|    return pthread_cond_broadcast(&cond->cond);
  169|  9.61k|}
rendezvous.c:mp_cond_wait:
  178|  9.61k|{
  179|  9.61k|    mp_assert(cond);
  ------------------
  |  |   41|  9.61k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 9.61k, False: 0]
  ------------------
  180|  9.61k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  9.61k|}
thread_pool.c:mp_cond_broadcast:
  166|  28.9k|{
  167|  28.9k|    mp_assert(cond);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 28.9k, False: 0]
  ------------------
  168|  28.9k|    return pthread_cond_broadcast(&cond->cond);
  169|  28.9k|}
thread_pool.c:mp_cond_destroy:
  160|  28.9k|{
  161|  28.9k|    mp_assert(cond);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 28.9k, False: 0]
  ------------------
  162|  28.9k|    return pthread_cond_destroy(&cond->cond);
  163|  28.9k|}
thread_pool.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
thread_pool.c:mp_cond_init:
  139|  28.9k|{
  140|  28.9k|    mp_assert(cond);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 28.9k, False: 0]
  ------------------
  141|       |
  142|  28.9k|    int ret = 0;
  143|  28.9k|    pthread_condattr_t attr;
  144|  28.9k|    ret = pthread_condattr_init(&attr);
  145|  28.9k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 28.9k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  28.9k|    cond->clk_id = CLOCK_REALTIME;
  149|  28.9k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  28.9k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 28.9k, False: 0]
  ------------------
  151|  28.9k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  28.9k|#endif
  153|       |
  154|  28.9k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  28.9k|    pthread_condattr_destroy(&attr);
  156|  28.9k|    return ret;
  157|  28.9k|}
thread_pool.c:mp_thread_set_name:
  222|  21.6k|{
  223|  21.6k|#if HAVE_GLIBC_THREAD_NAME
  224|  21.6k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 21.6k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  21.6k|}
thread_pool.c:mp_cond_wait:
  178|  21.8k|{
  179|  21.8k|    mp_assert(cond);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 21.8k, False: 0]
  ------------------
  180|  21.8k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  21.8k|}
thread_pool.c:mp_cond_signal:
  172|  21.8k|{
  173|  21.8k|    mp_assert(cond);
  ------------------
  |  |   41|  21.8k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 21.8k, False: 0]
  ------------------
  174|  21.8k|    return pthread_cond_signal(&cond->cond);
  175|  21.8k|}
thread_tools.c:mp_cond_destroy:
  160|   201k|{
  161|   201k|    mp_assert(cond);
  ------------------
  |  |   41|   201k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 201k, False: 0]
  ------------------
  162|   201k|    return pthread_cond_destroy(&cond->cond);
  163|   201k|}
thread_tools.c:mp_cond_signal:
  172|   108k|{
  173|   108k|    mp_assert(cond);
  ------------------
  |  |   41|   108k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 108k, False: 0]
  ------------------
  174|   108k|    return pthread_cond_signal(&cond->cond);
  175|   108k|}
thread_tools.c:mp_mutex_init:
  113|  92.4k|{
  114|  92.4k|#ifndef NDEBUG
  115|  92.4k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  92.4k|    int ret = 0;
  121|  92.4k|    pthread_mutexattr_t attr;
  122|  92.4k|    ret = pthread_mutexattr_init(&attr);
  123|  92.4k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 92.4k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  92.4k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  92.4k|    ret = pthread_mutex_init(mutex, &attr);
  128|  92.4k|    pthread_mutexattr_destroy(&attr);
  129|  92.4k|    mp_assert(!ret);
  ------------------
  |  |   41|  92.4k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 92.4k, False: 0]
  ------------------
  130|  92.4k|    return ret;
  131|  92.4k|}
thread_tools.c:mp_cond_init:
  139|  92.4k|{
  140|  92.4k|    mp_assert(cond);
  ------------------
  |  |   41|  92.4k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 92.4k, False: 0]
  ------------------
  141|       |
  142|  92.4k|    int ret = 0;
  143|  92.4k|    pthread_condattr_t attr;
  144|  92.4k|    ret = pthread_condattr_init(&attr);
  145|  92.4k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 92.4k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  92.4k|    cond->clk_id = CLOCK_REALTIME;
  149|  92.4k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  92.4k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 92.4k, False: 0]
  ------------------
  151|  92.4k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  92.4k|#endif
  153|       |
  154|  92.4k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  92.4k|    pthread_condattr_destroy(&attr);
  156|  92.4k|    return ret;
  157|  92.4k|}
thread_tools.c:mp_cond_broadcast:
  166|   199k|{
  167|   199k|    mp_assert(cond);
  ------------------
  |  |   41|   199k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 199k, False: 0]
  ------------------
  168|   199k|    return pthread_cond_broadcast(&cond->cond);
  169|   199k|}
m_config_core.c:mp_mutex_init:
  113|  28.9k|{
  114|  28.9k|#ifndef NDEBUG
  115|  28.9k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  28.9k|    int ret = 0;
  121|  28.9k|    pthread_mutexattr_t attr;
  122|  28.9k|    ret = pthread_mutexattr_init(&attr);
  123|  28.9k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 28.9k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  28.9k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  28.9k|    ret = pthread_mutex_init(mutex, &attr);
  128|  28.9k|    pthread_mutexattr_destroy(&attr);
  129|  28.9k|    mp_assert(!ret);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 28.9k, False: 0]
  ------------------
  130|  28.9k|    return ret;
  131|  28.9k|}
vd_lavc.c:mp_mutex_init:
  113|  7.79k|{
  114|  7.79k|#ifndef NDEBUG
  115|  7.79k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  7.79k|    int ret = 0;
  121|  7.79k|    pthread_mutexattr_t attr;
  122|  7.79k|    ret = pthread_mutexattr_init(&attr);
  123|  7.79k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 7.79k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  7.79k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  7.79k|    ret = pthread_mutex_init(mutex, &attr);
  128|  7.79k|    pthread_mutexattr_destroy(&attr);
  129|  7.79k|    mp_assert(!ret);
  ------------------
  |  |   41|  7.79k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 7.79k, False: 0]
  ------------------
  130|  7.79k|    return ret;
  131|  7.79k|}

mp_sleep_ns:
   31|  43.7k|{
   32|  43.7k|    if (ns < 0)
  ------------------
  |  Branch (32:9): [True: 43.7k, False: 0]
  ------------------
   33|  43.7k|        return;
   34|      0|    struct timespec ts;
   35|      0|    ts.tv_sec  = ns / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   36|      0|    ts.tv_nsec = ns % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   37|       |    nanosleep(&ts, NULL);
   38|      0|}
mp_set_idle_power_mode:
   41|  18.1k|{
   42|  18.1k|}
mp_raw_time_ns:
   45|  38.2M|{
   46|  38.2M|    struct timespec tp = {0};
   47|  38.2M|    clock_gettime(clk_id, &tp);
   48|       |    return MP_TIME_S_TO_NS(tp.tv_sec) + tp.tv_nsec;
  ------------------
  |  |   71|  38.2M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   49|  38.2M|}
mp_raw_time_init:
   52|      1|{
   53|      1|    static const clockid_t clock_ids[] = {
   54|      1|#ifdef CLOCK_MONOTONIC_RAW
   55|      1|        CLOCK_MONOTONIC_RAW,
   56|      1|#endif
   57|      1|        CLOCK_MONOTONIC,
   58|      1|    };
   59|       |
   60|      1|    struct timespec tp;
   61|      1|    for (int i = 0; i < MP_ARRAY_SIZE(clock_ids); ++i) {
  ------------------
  |  |   49|      1|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (61:21): [True: 1, False: 0]
  ------------------
   62|      1|        clk_id = clock_ids[i];
   63|      1|        if (!clock_gettime(clk_id, &tp))
  ------------------
  |  Branch (63:13): [True: 1, False: 0]
  ------------------
   64|      1|            return;
   65|      1|    }
   66|      0|    fputs("No clock source available!\n", stderr);
   67|      0|    abort();
   68|      1|}

mp_time_init:
   39|  28.9k|{
   40|  28.9k|    mp_exec_once(&timer_init_once, do_timer_init);
  ------------------
  |  |  209|  28.9k|#define mp_exec_once pthread_once
  ------------------
   41|  28.9k|}
mp_time_ns:
   44|  38.2M|{
   45|  38.2M|    return mp_time_ns_from_raw_time(mp_raw_time_ns());
   46|  38.2M|}
mp_time_ns_from_raw_time:
   49|  38.2M|{
   50|  38.2M|    return raw_time - raw_time_offset;
   51|  38.2M|}
mp_time_sec:
   54|  1.43M|{
   55|  1.43M|    return mp_time_ns() / 1e9;
   56|  1.43M|}
mp_time_ns_add:
   59|  1.73M|{
   60|  1.73M|    mp_assert(time_ns > 0); // mp_time_ns() returns strictly positive values
  ------------------
  |  |   41|  1.73M|#define mp_assert assert
  ------------------
  |  Branch (60:5): [True: 1.73M, False: 0]
  ------------------
   61|  1.73M|    double t = MPCLAMP(timeout_sec * 1e9, -0x1p63, 0x1p63);
  ------------------
  |  |   46|  1.73M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 1.73M]
  |  |  |  Branch (46:56): [True: 483k, False: 1.25M]
  |  |  ------------------
  ------------------
   62|  1.73M|    int64_t ti = t == 0x1p63 ? INT64_MAX : (int64_t)t;
  ------------------
  |  Branch (62:18): [True: 483k, False: 1.25M]
  ------------------
   63|  1.73M|    if (ti > INT64_MAX - time_ns)
  ------------------
  |  Branch (63:9): [True: 483k, False: 1.25M]
  ------------------
   64|   483k|        return INT64_MAX;
   65|  1.25M|    if (ti <= -time_ns)
  ------------------
  |  Branch (65:9): [True: 0, False: 1.25M]
  ------------------
   66|      0|        return 1;
   67|  1.25M|    return time_ns + ti;
   68|  1.25M|}
timer.c:do_timer_init:
   32|      1|{
   33|      1|    mp_raw_time_init();
   34|      1|    raw_time_offset = mp_raw_time_ns();
   35|       |    mp_assert(raw_time_offset > 0);
  ------------------
  |  |   41|      1|#define mp_assert assert
  ------------------
  |  Branch (35:5): [True: 1, False: 0]
  ------------------
   36|      1|}

audio_get_gain:
  174|  15.8k|{
  175|  15.8k|    struct MPOpts *opts = mpctx->opts;
  176|  15.8k|    float gain = MPMAX(opts->softvol_volume / 100.0, 0);
  ------------------
  |  |   44|  15.8k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 15.8k, False: 0]
  |  |  ------------------
  ------------------
  177|  15.8k|    gain = pow(gain, 3);
  178|  15.8k|    gain *= compute_replaygain(mpctx);
  179|  15.8k|    gain *= db_gain(opts->softvol_gain);
  180|  15.8k|    if (opts->softvol_mute)
  ------------------
  |  Branch (180:9): [True: 0, False: 15.8k]
  ------------------
  181|      0|        gain = 0.0;
  182|  15.8k|    return gain;
  183|  15.8k|}
audio_update_volume:
  187|  44.8k|{
  188|  44.8k|    struct ao_chain *ao_c = mpctx->ao_chain;
  189|  44.8k|    if (!ao_c || !ao_c->ao)
  ------------------
  |  Branch (189:9): [True: 28.9k, False: 15.9k]
  |  Branch (189:18): [True: 29, False: 15.8k]
  ------------------
  190|  28.9k|        return;
  191|       |
  192|  15.8k|    float gain = audio_get_gain(mpctx);
  193|  15.8k|    ao_set_gain(ao_c->ao, gain);
  194|  15.8k|}
update_playback_speed:
  198|  21.8k|{
  199|  21.8k|    mpctx->audio_speed = mpctx->opts->playback_speed * mpctx->speed_factor_a;
  200|  21.8k|    mpctx->video_speed = mpctx->opts->playback_speed * mpctx->speed_factor_v;
  201|       |
  202|  21.8k|    update_speed_filters(mpctx);
  203|  21.8k|}
reset_audio_state:
  231|   145k|{
  232|   145k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (232:9): [True: 11.7k, False: 133k]
  ------------------
  233|  11.7k|        ao_chain_reset_state(mpctx->ao_chain);
  234|  11.7k|        struct track *t = mpctx->ao_chain->track;
  235|  11.7k|        if (t && t->dec)
  ------------------
  |  Branch (235:13): [True: 11.7k, False: 0]
  |  Branch (235:18): [True: 11.7k, False: 0]
  ------------------
  236|  11.7k|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  237|  11.7k|    }
  238|   145k|    mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (238:27): [True: 11.7k, False: 133k]
  ------------------
  239|   145k|    mpctx->delay = 0;
  240|   145k|}
uninit_audio_out:
  243|   105k|{
  244|   105k|    struct ao_chain *ao_c = mpctx->ao_chain;
  245|   105k|    if (ao_c) {
  ------------------
  |  Branch (245:9): [True: 7.98k, False: 97.8k]
  ------------------
  246|  7.98k|        ao_c->ao_queue = NULL;
  247|  7.98k|        TA_FREEP(&ao_c->queue_filter);
  ------------------
  |  |   81|  7.98k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  7.98k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 7.98k]
  |  |  ------------------
  ------------------
  248|  7.98k|        ao_c->ao = NULL;
  249|  7.98k|    }
  250|   105k|    if (mpctx->ao) {
  ------------------
  |  Branch (250:9): [True: 7.92k, False: 97.8k]
  ------------------
  251|       |        // Note: with gapless_audio, stop_play is not correctly set
  252|  7.92k|        if ((mpctx->opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) &&
  ------------------
  |  Branch (252:14): [True: 7.92k, False: 0]
  |  Branch (252:44): [True: 0, False: 0]
  ------------------
  253|  7.92k|            ao_is_playing(mpctx->ao) && !get_internal_paused(mpctx))
  ------------------
  |  Branch (253:13): [True: 1.99k, False: 5.93k]
  |  Branch (253:41): [True: 1.99k, False: 0]
  ------------------
  254|  1.99k|        {
  255|  1.99k|            MP_VERBOSE(mpctx, "draining left over audio\n");
  ------------------
  |  |   92|  1.99k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.99k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  256|  1.99k|            ao_drain(mpctx->ao);
  257|  1.99k|        }
  258|  7.92k|        ao_uninit(mpctx->ao);
  259|       |
  260|  7.92k|        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  261|  7.92k|    }
  262|   105k|    mpctx->ao = NULL;
  263|       |    TA_FREEP(&mpctx->ao_filter_fmt);
  ------------------
  |  |   81|   105k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   105k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 105k]
  |  |  ------------------
  ------------------
  264|   105k|}
uninit_audio_chain:
  289|   134k|{
  290|   134k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (290:9): [True: 12.1k, False: 122k]
  ------------------
  291|  12.1k|        ao_chain_uninit(mpctx->ao_chain);
  292|  12.1k|        mpctx->ao_chain = NULL;
  293|       |
  294|  12.1k|        mpctx->audio_status = STATUS_EOF;
  295|       |
  296|       |        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  297|  12.1k|    }
  298|   134k|}
init_audio_decoder:
  522|  12.1k|{
  523|  12.1k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  12.1k|#define mp_assert assert
  ------------------
  |  Branch (523:5): [True: 12.1k, False: 0]
  ------------------
  524|  12.1k|    if (!track->stream)
  ------------------
  |  Branch (524:9): [True: 0, False: 12.1k]
  ------------------
  525|      0|        goto init_error;
  526|       |
  527|  12.1k|    track->dec = mp_decoder_wrapper_create(mpctx->filter_root, track->stream);
  528|  12.1k|    if (!track->dec)
  ------------------
  |  Branch (528:9): [True: 0, False: 12.1k]
  ------------------
  529|      0|        goto init_error;
  530|       |
  531|  12.1k|    if (track->ao_c)
  ------------------
  |  Branch (531:9): [True: 12.1k, False: 0]
  ------------------
  532|  12.1k|        mp_decoder_wrapper_set_spdif_flag(track->dec, true);
  533|       |
  534|  12.1k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (534:9): [True: 427, False: 11.7k]
  ------------------
  535|    427|        goto init_error;
  536|       |
  537|  11.7k|    return 1;
  538|       |
  539|    427|init_error:
  540|    427|    if (track->sink)
  ------------------
  |  Branch (540:9): [True: 0, False: 427]
  ------------------
  541|      0|        mp_pin_disconnect(track->sink);
  542|    427|    track->sink = NULL;
  543|       |    track->dec_failed = true;
  544|    427|    return 0;
  545|  12.1k|}
reinit_audio_chain:
  548|  22.2k|{
  549|  22.2k|    struct track *track = NULL;
  550|  22.2k|    track = mpctx->current_track[0][STREAM_AUDIO];
  551|  22.2k|    if (!track || !track->stream) {
  ------------------
  |  Branch (551:9): [True: 10.0k, False: 12.1k]
  |  Branch (551:19): [True: 0, False: 12.1k]
  ------------------
  552|  10.0k|        if (!mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (552:13): [True: 10.0k, False: 0]
  ------------------
  553|  10.0k|            uninit_audio_out(mpctx);
  554|  10.0k|        error_on_track(mpctx, track);
  555|  10.0k|        return;
  556|  10.0k|    }
  557|  12.1k|    reinit_audio_chain_src(mpctx, track);
  558|  12.1k|}
reinit_audio_chain_src:
  603|  12.1k|{
  604|  12.1k|    mp_assert(!mpctx->ao_chain);
  ------------------
  |  |   41|  12.1k|#define mp_assert assert
  ------------------
  |  Branch (604:5): [True: 12.1k, False: 0]
  ------------------
  605|       |
  606|  12.1k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  607|       |
  608|  12.1k|    struct ao_chain *ao_c = talloc_zero(NULL, struct ao_chain);
  ------------------
  |  |   27|  12.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  12.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  12.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|  12.1k|    mpctx->ao_chain = ao_c;
  610|  12.1k|    ao_c->mpctx = mpctx;
  611|  12.1k|    ao_c->log = mpctx->log;
  612|  12.1k|    ao_c->filter =
  613|  12.1k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_AUDIO);
  614|  12.1k|    ao_c->spdif_passthrough = true;
  615|  12.1k|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  12.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  616|  12.1k|    ao_c->delay = mpctx->opts->audio_delay;
  617|       |
  618|  12.1k|    ao_c->ao_filter = mp_filter_create(mpctx->filter_root, &ao_filter);
  619|  12.1k|    if (!ao_c->filter || !ao_c->ao_filter)
  ------------------
  |  Branch (619:9): [True: 0, False: 12.1k]
  |  Branch (619:26): [True: 0, False: 12.1k]
  ------------------
  620|      0|        goto init_error;
  621|  12.1k|    ao_c->ao_filter->priv = ao_c;
  622|       |
  623|  12.1k|    mp_filter_add_pin(ao_c->ao_filter, MP_PIN_IN, "in");
  624|  12.1k|    mp_pin_connect(ao_c->ao_filter->pins[0], ao_c->filter->f->pins[1]);
  625|       |
  626|  12.1k|    if (track) {
  ------------------
  |  Branch (626:9): [True: 12.1k, False: 0]
  ------------------
  627|  12.1k|        ao_c->track = track;
  628|  12.1k|        track->ao_c = ao_c;
  629|  12.1k|        if (!ao_chain_init_decoder(mpctx, ao_c))
  ------------------
  |  Branch (629:13): [True: 427, False: 11.7k]
  ------------------
  630|    427|            goto init_error;
  631|  12.1k|    }
  632|       |
  633|  11.7k|    reset_audio_state(mpctx);
  634|       |
  635|  11.7k|    if (recreate_audio_filters(mpctx) < 0)
  ------------------
  |  Branch (635:9): [True: 0, False: 11.7k]
  ------------------
  636|      0|        goto init_error;
  637|       |
  638|  11.7k|    if (mpctx->ao)
  ------------------
  |  Branch (638:9): [True: 29, False: 11.7k]
  ------------------
  639|     29|        audio_update_volume(mpctx);
  640|       |
  641|  11.7k|    mp_wakeup_core(mpctx);
  642|  11.7k|    return;
  643|       |
  644|    427|init_error:
  645|    427|    uninit_audio_chain(mpctx);
  646|    427|    uninit_audio_out(mpctx);
  647|    427|    error_on_track(mpctx, track);
  648|    427|}
written_audio_pts:
  653|  56.0k|{
  654|  56.0k|    return mpctx->ao_chain ? mpctx->ao_chain->last_out_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.11k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:12): [True: 46.8k, False: 9.11k]
  ------------------
  655|  56.0k|}
playing_audio_pts:
  660|  56.0k|{
  661|  56.0k|    double pts = written_audio_pts(mpctx);
  662|  56.0k|    if (pts == MP_NOPTS_VALUE || !mpctx->ao)
  ------------------
  |  |   39|   112k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (662:9): [True: 22.5k, False: 33.4k]
  |  Branch (662:34): [True: 0, False: 33.4k]
  ------------------
  663|  22.5k|        return pts;
  664|  33.4k|    return pts - mpctx->audio_speed * ao_get_delay(mpctx->ao);
  665|  56.0k|}
reload_audio_output:
  787|  28.9k|{
  788|  28.9k|    if (!mpctx->ao)
  ------------------
  |  Branch (788:9): [True: 28.9k, False: 0]
  ------------------
  789|  28.9k|        return;
  790|       |
  791|      0|    ao_reset(mpctx->ao);
  792|      0|    uninit_audio_out(mpctx);
  793|      0|    reinit_audio_filters(mpctx); // mostly to issue refresh seek
  794|       |
  795|      0|    struct ao_chain *ao_c = mpctx->ao_chain;
  796|       |
  797|      0|    if (ao_c) {
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      0|        reset_audio_state(mpctx);
  799|      0|        mp_output_chain_reset_harder(ao_c->filter);
  800|      0|    }
  801|       |
  802|       |    // Whether we can use spdif might have changed. If we failed to use spdif
  803|       |    // in the previous initialization, try it with spdif again (we'll fallback
  804|       |    // to PCM again if necessary).
  805|      0|    if (ao_c && ao_c->track) {
  ------------------
  |  Branch (805:9): [True: 0, False: 0]
  |  Branch (805:17): [True: 0, False: 0]
  ------------------
  806|      0|        struct mp_decoder_wrapper *dec = ao_c->track->dec;
  807|      0|        if (dec && ao_c->spdif_failed) {
  ------------------
  |  Branch (807:13): [True: 0, False: 0]
  |  Branch (807:20): [True: 0, False: 0]
  ------------------
  808|      0|            ao_c->spdif_passthrough = true;
  809|      0|            ao_c->spdif_failed = false;
  810|      0|            mp_decoder_wrapper_set_spdif_flag(ao_c->track->dec, true);
  811|      0|            if (!mp_decoder_wrapper_reinit(dec)) {
  ------------------
  |  Branch (811:17): [True: 0, False: 0]
  ------------------
  812|      0|                MP_ERR(mpctx, "Error reinitializing audio.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  813|      0|                error_on_track(mpctx, ao_c->track);
  814|      0|            }
  815|      0|        }
  816|      0|    }
  817|       |
  818|      0|    mp_wakeup_core(mpctx);
  819|      0|}
audio_start_ao:
  854|  23.6k|{
  855|  23.6k|    struct ao_chain *ao_c = mpctx->ao_chain;
  856|  23.6k|    if (!ao_c || !ao_c->ao || mpctx->audio_status != STATUS_READY)
  ------------------
  |  Branch (856:9): [True: 0, False: 23.6k]
  |  Branch (856:18): [True: 2.04k, False: 21.5k]
  |  Branch (856:31): [True: 15.4k, False: 6.07k]
  ------------------
  857|  17.5k|        return;
  858|  6.07k|    double pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  6.07k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  859|  6.07k|    if (!get_sync_pts(mpctx, &pts))
  ------------------
  |  Branch (859:9): [True: 0, False: 6.07k]
  ------------------
  860|      0|        return;
  861|  6.07k|    double apts = playing_audio_pts(mpctx);
  862|  6.07k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (862:9): [True: 0, False: 6.07k]
  ------------------
  863|      0|        double speed = mpctx->opts->playback_speed;
  864|      0|        if (!ao_c->delaying_audio_start && pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:13): [True: 0, False: 0]
  |  Branch (864:44): [True: 0, False: 0]
  ------------------
  865|      0|            apts != MP_NOPTS_VALUE && pts < apts)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (865:13): [True: 0, False: 0]
  |  Branch (865:39): [True: 0, False: 0]
  ------------------
  866|      0|        {
  867|      0|            MP_VERBOSE(mpctx, "delaying audio start %f vs. %f, diff=%f\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  868|      0|                       apts, pts, (apts - pts) / speed);
  869|      0|            ao_c->delaying_audio_start = true;
  870|      0|            ao_c->delayed_start_gap = apts - pts;
  871|      0|            mpctx->delay += apts - pts;
  872|      0|            ao_c->delayed_start_speed = 0;
  873|      0|        }
  874|      0|        if (ao_c->delaying_audio_start) {
  ------------------
  |  Branch (874:13): [True: 0, False: 0]
  ------------------
  875|       |            // Start audio once the video has played the gap to it. The video
  876|       |            // pts moves in frame steps and ahead of the display, so the gap
  877|       |            // is counted down in playback time from the first check on, every
  878|       |            // interval at the speed it was played with.
  879|      0|            int64_t now = mp_time_ns();
  880|      0|            double passed = MP_TIME_NS_TO_S(now - ao_c->delayed_start_last);
  ------------------
  |  |   76|      0|#define MP_TIME_NS_TO_S(ns) ((ns) / (double)1000000000)
  ------------------
  881|      0|            ao_c->delayed_start_gap -= passed * ao_c->delayed_start_speed;
  882|      0|            ao_c->delayed_start_last = now;
  883|      0|            ao_c->delayed_start_speed = get_internal_paused(mpctx) ? 0 : speed;
  ------------------
  |  Branch (883:41): [True: 0, False: 0]
  ------------------
  884|      0|            if (ao_c->delayed_start_gap > 0) {
  ------------------
  |  Branch (884:17): [True: 0, False: 0]
  ------------------
  885|      0|                if (ao_c->delayed_start_speed > 0)
  ------------------
  |  Branch (885:21): [True: 0, False: 0]
  ------------------
  886|      0|                    mp_set_timeout(mpctx, ao_c->delayed_start_gap / speed);
  887|      0|                return;
  888|      0|            }
  889|      0|        }
  890|      0|    }
  891|       |
  892|  6.07k|    MP_VERBOSE(mpctx, "starting audio playback\n");
  ------------------
  |  |   92|  6.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  893|  6.07k|    ao_c->delaying_audio_start = false;
  894|  6.07k|    ao_start(ao_c->ao);
  895|  6.07k|    mpctx->audio_status = STATUS_PLAYING;
  896|  6.07k|    if (ao_c->out_eof) {
  ------------------
  |  Branch (896:9): [True: 2.45k, False: 3.62k]
  ------------------
  897|  2.45k|        mpctx->audio_status = STATUS_DRAINING;
  898|  2.45k|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|  2.45k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  899|  2.45k|    }
  900|       |    ao_c->underrun = false;
  901|  6.07k|    mp_wakeup_core(mpctx);
  902|  6.07k|}
fill_audio_out_buffers:
  905|   131k|{
  906|   131k|    struct MPOpts *opts = mpctx->opts;
  907|       |
  908|   131k|    if (mpctx->ao && ao_query_and_reset_events(mpctx->ao, AO_EVENT_RELOAD))
  ------------------
  |  Branch (908:9): [True: 21.7k, False: 109k]
  |  Branch (908:22): [True: 0, False: 21.7k]
  ------------------
  909|      0|        reload_audio_output(mpctx);
  910|       |
  911|   131k|    update_throttle(mpctx);
  912|       |
  913|   131k|    struct ao_chain *ao_c = mpctx->ao_chain;
  914|   131k|    if (!ao_c)
  ------------------
  |  Branch (914:9): [True: 59.7k, False: 71.7k]
  ------------------
  915|  59.7k|        return;
  916|       |
  917|  71.7k|    if (ao_c->filter->failed_output_conversion) {
  ------------------
  |  Branch (917:9): [True: 0, False: 71.7k]
  ------------------
  918|      0|        error_on_track(mpctx, ao_c->track);
  919|      0|        return;
  920|      0|    }
  921|       |
  922|  71.7k|    if (ao_c->filter->ao_needs_update) {
  ------------------
  |  Branch (922:9): [True: 9.04k, False: 62.7k]
  ------------------
  923|  9.04k|        if (reinit_audio_filters_and_output(mpctx) < 0)
  ------------------
  |  Branch (923:13): [True: 64, False: 8.98k]
  ------------------
  924|     64|            return;
  925|  9.04k|    }
  926|       |
  927|  71.6k|    if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
  ------------------
  |  Branch (927:9): [True: 11.1k, False: 60.5k]
  |  Branch (927:28): [True: 11.1k, False: 0]
  |  Branch (927:43): [True: 11.1k, False: 0]
  ------------------
  928|  11.1k|        mp_decoder_wrapper_get_pts_reset(ao_c->track->dec))
  ------------------
  |  Branch (928:9): [True: 0, False: 11.1k]
  ------------------
  929|      0|    {
  930|      0|        MP_WARN(mpctx, "Reset playback due to audio timestamp reset.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  931|      0|        reset_playback_state(mpctx);
  932|      0|        mp_wakeup_core(mpctx);
  933|      0|    }
  934|       |
  935|  71.6k|    if (mpctx->audio_status == STATUS_SYNCING) {
  ------------------
  |  Branch (935:9): [True: 49.5k, False: 22.1k]
  ------------------
  936|  49.5k|        double pts;
  937|  49.5k|        bool ok = get_sync_pts(mpctx, &pts);
  938|       |
  939|       |        // If the AO is still playing from the previous file (due to gapless),
  940|       |        // but if video is active, this may not work if audio starts later than
  941|       |        // video, and gapless has no advantages anyway. So block doing anything
  942|       |        // until the old audio is fully played.
  943|       |        // (Buggy if AO underruns.)
  944|  49.5k|        if (mpctx->ao && ao_is_playing(mpctx->ao) &&
  ------------------
  |  Branch (944:13): [True: 11.2k, False: 38.2k]
  |  Branch (944:26): [True: 0, False: 11.2k]
  ------------------
  945|      0|            mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (945:13): [True: 0, False: 0]
  ------------------
  946|      0|            MP_VERBOSE(mpctx, "blocked, waiting for old audio to play\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  947|      0|            ok = false;
  948|      0|        }
  949|       |
  950|  49.5k|        if (ao_c->start_pts_known != ok || ao_c->start_pts != pts) {
  ------------------
  |  Branch (950:13): [True: 9.13k, False: 40.3k]
  |  Branch (950:44): [True: 0, False: 40.3k]
  ------------------
  951|  9.13k|            ao_c->start_pts_known = ok;
  952|  9.13k|            ao_c->start_pts = pts;
  953|  9.13k|            mp_filter_wakeup(ao_c->ao_filter);
  954|  9.13k|        }
  955|       |
  956|  49.5k|        if (ao_c->ao && mp_async_queue_is_full(ao_c->ao_queue)) {
  ------------------
  |  Branch (956:13): [True: 11.1k, False: 38.3k]
  |  Branch (956:25): [True: 2.59k, False: 8.58k]
  ------------------
  957|  2.59k|            mpctx->audio_status = STATUS_READY;
  958|  2.59k|            mp_wakeup_core(mpctx);
  959|  2.59k|            MP_VERBOSE(mpctx, "audio ready\n");
  ------------------
  |  |   92|  2.59k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.59k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  960|  46.9k|        } else if (ao_c->out_eof) {
  ------------------
  |  Branch (960:20): [True: 2.45k, False: 44.4k]
  ------------------
  961|       |            // Force playback start early.
  962|  2.45k|            mpctx->audio_status = STATUS_READY;
  963|  2.45k|            mp_wakeup_core(mpctx);
  964|  2.45k|            MP_VERBOSE(mpctx, "audio ready (and EOF)\n");
  ------------------
  |  |   92|  2.45k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  965|  2.45k|        }
  966|  49.5k|    }
  967|       |
  968|  71.6k|    if (ao_c->ao && !ao_is_playing(ao_c->ao) && !ao_c->underrun &&
  ------------------
  |  Branch (968:9): [True: 27.7k, False: 43.9k]
  |  Branch (968:21): [True: 14.4k, False: 13.2k]
  |  Branch (968:49): [True: 14.4k, False: 0]
  ------------------
  969|  14.4k|        (mpctx->audio_status == STATUS_PLAYING ||
  ------------------
  |  Branch (969:10): [True: 1.88k, False: 12.5k]
  ------------------
  970|  12.5k|         mpctx->audio_status == STATUS_DRAINING))
  ------------------
  |  Branch (970:10): [True: 362, False: 12.2k]
  ------------------
  971|  2.24k|    {
  972|       |        // Should be playing, but somehow isn't.
  973|       |
  974|  2.24k|        if (ao_c->out_eof && !mp_async_queue_get_frames(ao_c->ao_queue)) {
  ------------------
  |  Branch (974:13): [True: 2.24k, False: 0]
  |  Branch (974:30): [True: 2.24k, False: 0]
  ------------------
  975|  2.24k|            MP_VERBOSE(mpctx, "AO signaled EOF (while in state %s)\n",
  ------------------
  |  |   92|  2.24k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.24k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  976|  2.24k|                       mp_status_str(mpctx->audio_status));
  977|  2.24k|            mpctx->audio_status = STATUS_EOF;
  978|  2.24k|            mp_wakeup_core(mpctx);
  979|       |            // stops untimed AOs, stops pull AOs from streaming silence
  980|  2.24k|            ao_reset(ao_c->ao);
  981|  2.24k|        } else {
  982|      0|            if (!ao_c->ao_underrun) {
  ------------------
  |  Branch (982:17): [True: 0, False: 0]
  ------------------
  983|      0|                MP_WARN(mpctx, "Audio device underrun detected.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  984|      0|                ao_c->ao_underrun = true;
  985|      0|                mp_wakeup_core(mpctx);
  986|      0|                ao_c->underrun = true;
  987|      0|            }
  988|       |
  989|       |            // Wait until buffers are filled before recovering underrun.
  990|      0|            if (ao_c->out_eof || mp_async_queue_is_full(ao_c->ao_queue)) {
  ------------------
  |  Branch (990:17): [True: 0, False: 0]
  |  Branch (990:34): [True: 0, False: 0]
  ------------------
  991|      0|                MP_VERBOSE(mpctx, "restarting audio after underrun\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  992|      0|                ao_start(mpctx->ao_chain->ao);
  993|      0|                ao_c->ao_underrun = false;
  994|      0|                ao_c->underrun = false;
  995|      0|                mp_wakeup_core(mpctx);
  996|      0|            }
  997|      0|        }
  998|  2.24k|    }
  999|       |
 1000|  71.6k|    if (mpctx->audio_status == STATUS_PLAYING && ao_c->out_eof) {
  ------------------
  |  Branch (1000:9): [True: 11.1k, False: 60.5k]
  |  Branch (1000:50): [True: 1.69k, False: 9.46k]
  ------------------
 1001|  1.69k|        mpctx->audio_status = STATUS_DRAINING;
 1002|  1.69k|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|  1.69k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.69k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1003|  1.69k|        mp_wakeup_core(mpctx);
 1004|  1.69k|    }
 1005|       |
 1006|  71.6k|    if (mpctx->audio_status == STATUS_DRAINING) {
  ------------------
  |  Branch (1006:9): [True: 9.40k, False: 62.2k]
  ------------------
 1007|       |        // Wait until the AO has played all queued data. In the gapless case,
 1008|       |        // we trigger EOF immediately, and let it play asynchronously.
 1009|  9.40k|        if (!ao_c->ao || (!ao_is_playing(ao_c->ao) || opts->gapless_audio))
  ------------------
  |  Branch (1009:13): [True: 5.62k, False: 3.78k]
  |  Branch (1009:27): [True: 140, False: 3.64k]
  |  Branch (1009:55): [True: 3.64k, False: 0]
  ------------------
 1010|  9.40k|        {
 1011|  9.40k|            MP_VERBOSE(mpctx, "audio EOF reached\n");
  ------------------
  |  |   92|  9.40k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.40k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1012|  9.40k|            mpctx->audio_status = STATUS_EOF;
 1013|  9.40k|            mp_wakeup_core(mpctx);
 1014|  9.40k|        }
 1015|  9.40k|    }
 1016|       |
 1017|  71.6k|    if (mpctx->restart_complete)
  ------------------
  |  Branch (1017:9): [True: 17.5k, False: 54.1k]
  ------------------
 1018|  17.5k|        audio_start_ao(mpctx); // in case it got delayed
 1019|  71.6k|}
clear_audio_output_buffers:
 1023|   117k|{
 1024|   117k|    if (mpctx->ao)
  ------------------
  |  Branch (1024:9): [True: 53, False: 117k]
  ------------------
 1025|     53|        ao_reset(mpctx->ao);
 1026|   117k|}
audio.c:recreate_audio_filters:
   89|  11.7k|{
   90|  11.7k|    struct ao_chain *ao_c = mpctx->ao_chain;
   91|  11.7k|    mp_assert(ao_c);
  ------------------
  |  |   41|  11.7k|#define mp_assert assert
  ------------------
  |  Branch (91:5): [True: 11.7k, False: 0]
  ------------------
   92|       |
   93|  11.7k|    if (!mp_output_chain_update_filters(ao_c->filter, mpctx->opts->af_settings))
  ------------------
  |  Branch (93:9): [True: 0, False: 11.7k]
  ------------------
   94|      0|        goto fail;
   95|       |
   96|  11.7k|    update_speed_filters(mpctx);
   97|       |
   98|  11.7k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
   99|       |
  100|  11.7k|    return 0;
  101|       |
  102|      0|fail:
  103|      0|    MP_ERR(mpctx, "Audio filter initialized failed!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  104|      0|    return -1;
  105|  11.7k|}
audio.c:compute_replaygain:
  133|  15.8k|{
  134|  15.8k|    struct MPOpts *opts = mpctx->opts;
  135|       |
  136|  15.8k|    float rgain = 1.0;
  137|       |
  138|  15.8k|    struct replaygain_data *rg = NULL;
  139|  15.8k|    struct track *track = mpctx->current_track[0][STREAM_AUDIO];
  140|  15.8k|    if (track)
  ------------------
  |  Branch (140:9): [True: 15.8k, False: 0]
  ------------------
  141|  15.8k|        rg = track->stream->codec->replaygain_data;
  142|  15.8k|    if (opts->rgain_mode && rg) {
  ------------------
  |  Branch (142:9): [True: 0, False: 15.8k]
  |  Branch (142:29): [True: 0, False: 0]
  ------------------
  143|      0|        MP_VERBOSE(mpctx, "Replaygain: Track=%f/%f Album=%f/%f\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  144|      0|                   rg->track_gain, rg->track_peak,
  145|      0|                   rg->album_gain, rg->album_peak);
  146|       |
  147|      0|        float gain, peak;
  148|      0|        if (opts->rgain_mode == 1) {
  ------------------
  |  Branch (148:13): [True: 0, False: 0]
  ------------------
  149|      0|            gain = rg->track_gain;
  150|      0|            peak = rg->track_peak;
  151|      0|        } else {
  152|      0|            gain = rg->album_gain;
  153|      0|            peak = rg->album_peak;
  154|      0|        }
  155|       |
  156|      0|        gain += opts->rgain_preamp;
  157|      0|        rgain = db_gain(gain);
  158|       |
  159|      0|        MP_VERBOSE(mpctx, "Applying replay-gain: %f\n", rgain);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|       |
  161|      0|        if (!opts->rgain_clip) { // clipping prevention
  ------------------
  |  Branch (161:13): [True: 0, False: 0]
  ------------------
  162|      0|            rgain = MPMIN(rgain, 1.0 / peak);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  163|      0|            MP_VERBOSE(mpctx, "...with clipping prevention: %f\n", rgain);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  164|      0|        }
  165|  15.8k|    } else if (opts->rgain_fallback) {
  ------------------
  |  Branch (165:16): [True: 0, False: 15.8k]
  ------------------
  166|      0|        rgain = db_gain(opts->rgain_fallback);
  167|      0|        MP_VERBOSE(mpctx, "Applying fallback gain: %f\n", rgain);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  168|      0|    }
  169|       |
  170|  15.8k|    return rgain;
  171|  15.8k|}
audio.c:db_gain:
  128|  15.8k|{
  129|  15.8k|    return pow(10.0, db/20.0);
  130|  15.8k|}
audio.c:update_speed_filters:
   52|  33.5k|{
   53|  33.5k|    struct ao_chain *ao_c = mpctx->ao_chain;
   54|  33.5k|    if (!ao_c)
  ------------------
  |  Branch (54:9): [True: 21.8k, False: 11.7k]
  ------------------
   55|  21.8k|        return;
   56|       |
   57|  11.7k|    double pitch = mpctx->opts->playback_pitch;
   58|  11.7k|    double speed = mpctx->opts->playback_speed;
   59|  11.7k|    double resample = mpctx->speed_factor_a;
   60|  11.7k|    double drop = 1.0;
   61|       |
   62|  11.7k|    if (!mpctx->opts->pitch_correction) {
  ------------------
  |  Branch (62:9): [True: 0, False: 11.7k]
  ------------------
   63|      0|        resample *= speed;
   64|      0|        speed = 1.0;
   65|      0|    }
   66|       |
   67|  11.7k|    int video_sync = mpctx->display_sync_active ?
  ------------------
  |  Branch (67:22): [True: 0, False: 11.7k]
  ------------------
   68|  11.7k|        mpctx->video_out->opts->video_sync : VS_NONE;
   69|  11.7k|    switch (video_sync) {
   70|      0|        case VS_DISP_ADROP:
  ------------------
  |  Branch (70:9): [True: 0, False: 11.7k]
  ------------------
   71|      0|            drop *= speed * resample / pitch;
   72|      0|            resample = pitch;
   73|      0|            speed = 1.0;
   74|      0|            break;
   75|      0|        case VS_DISP_TEMPO:
  ------------------
  |  Branch (75:9): [True: 0, False: 11.7k]
  ------------------
   76|      0|            speed = mpctx->audio_speed / pitch;
   77|      0|            resample = pitch;
   78|      0|            break;
   79|  11.7k|        default:
  ------------------
  |  Branch (79:9): [True: 11.7k, False: 0]
  ------------------
   80|  11.7k|            resample *= pitch;
   81|  11.7k|            speed /= pitch;
   82|  11.7k|            break;
   83|  11.7k|    }
   84|       |
   85|  11.7k|    mp_output_chain_set_audio_speed(ao_c->filter, speed, resample, drop);
   86|  11.7k|}
audio.c:ao_chain_reset_state:
  220|  11.7k|{
  221|  11.7k|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  11.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  222|  11.7k|    ao_c->out_eof = false;
  223|  11.7k|    ao_c->start_pts_known = false;
  224|  11.7k|    ao_c->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  11.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  225|  11.7k|    ao_c->untimed_throttle = false;
  226|  11.7k|    ao_c->underrun = false;
  227|       |    ao_c->delaying_audio_start = false;
  228|  11.7k|}
audio.c:ao_chain_uninit:
  267|  12.1k|{
  268|  12.1k|    struct track *track = ao_c->track;
  269|  12.1k|    if (track) {
  ------------------
  |  Branch (269:9): [True: 12.1k, False: 0]
  ------------------
  270|  12.1k|        mp_assert(track->ao_c == ao_c);
  ------------------
  |  |   41|  12.1k|#define mp_assert assert
  ------------------
  |  Branch (270:9): [True: 12.1k, False: 0]
  ------------------
  271|  12.1k|        track->ao_c = NULL;
  272|  12.1k|        if (ao_c->dec_src)
  ------------------
  |  Branch (272:13): [True: 11.7k, False: 427]
  ------------------
  273|  12.1k|            mp_assert(track->dec->f->pins[0] == ao_c->dec_src);
  ------------------
  |  |   41|  12.1k|#define mp_assert assert
  ------------------
  |  Branch (273:13): [True: 11.7k, False: 0]
  ------------------
  274|  12.1k|        if (track->dec) {
  ------------------
  |  Branch (274:13): [True: 12.1k, False: 0]
  ------------------
  275|  12.1k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  276|  12.1k|            track->dec = NULL;
  277|  12.1k|        }
  278|  12.1k|    }
  279|       |
  280|  12.1k|    if (ao_c->filter_src)
  ------------------
  |  Branch (280:9): [True: 0, False: 12.1k]
  ------------------
  281|      0|        mp_pin_disconnect(ao_c->filter_src);
  282|       |
  283|  12.1k|    talloc_free(ao_c->filter->f);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  284|  12.1k|    talloc_free(ao_c->ao_filter);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  285|  12.1k|    talloc_free(ao_c);
  ------------------
  |  |   47|  12.1k|#define talloc_free                     ta_free
  ------------------
  286|  12.1k|}
audio.c:ao_chain_init_decoder:
  567|  12.1k|{
  568|  12.1k|    struct track *track = ao_c->track;
  569|  12.1k|    if (!init_audio_decoder(mpctx, track))
  ------------------
  |  Branch (569:9): [True: 427, False: 11.7k]
  ------------------
  570|    427|        return false;
  571|  11.7k|    ao_c->dec_src = track->dec->f->pins[0];
  572|  11.7k|    mp_pin_connect(ao_c->filter->f->pins[0], ao_c->dec_src);
  573|       |    return true;
  574|  12.1k|}
audio.c:ao_process:
  684|  1.64M|{
  685|  1.64M|    struct ao_chain *ao_c = f->priv;
  686|  1.64M|    struct MPContext *mpctx = ao_c->mpctx;
  687|       |
  688|       |    // Once the chain reached EOF nothing is read from it again.
  689|  1.64M|    if (ao_c->out_eof)
  ------------------
  |  Branch (689:9): [True: 12.6k, False: 1.63M]
  ------------------
  690|  12.6k|        return;
  691|       |
  692|  1.63M|    if (!ao_c->queue_filter) {
  ------------------
  |  Branch (692:9): [True: 17.3k, False: 1.61M]
  ------------------
  693|       |        // This will eventually lead to the creation of the AO + queue, due
  694|       |        // to how f_output_chain and AO management works.
  695|  17.3k|        mp_pin_out_request_data(f->ppins[0]);
  696|       |        // Check for EOF with no data case, which is a mess because everything
  697|       |        // hates us.
  698|  17.3k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  699|  17.3k|        if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (699:13): [True: 5.62k, False: 11.7k]
  ------------------
  700|  5.62k|            MP_VERBOSE(mpctx, "got EOF with no data before it\n");
  ------------------
  |  |   92|  5.62k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.62k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  701|  5.62k|            ao_c->out_eof = true;
  702|  5.62k|            mpctx->audio_status = STATUS_DRAINING;
  703|  5.62k|            mp_wakeup_core(mpctx);
  704|  11.7k|        } else if (frame.type) {
  ------------------
  |  Branch (704:20): [True: 0, False: 11.7k]
  ------------------
  705|      0|            mp_pin_out_unread(f->ppins[0], frame);
  706|      0|        }
  707|  17.3k|        return;
  708|  17.3k|    }
  709|       |
  710|       |    // Due to mp_async_queue_set_notifier() this function is called when the
  711|       |    // queue becomes full. This affects state changes in the normal playloop,
  712|       |    // so wake it up. But avoid redundant wakeups during normal playback.
  713|  1.61M|    if (mpctx->audio_status != STATUS_PLAYING &&
  ------------------
  |  Branch (713:9): [True: 68.8k, False: 1.54M]
  ------------------
  714|  68.8k|        mp_async_queue_is_full(ao_c->ao_queue))
  ------------------
  |  Branch (714:9): [True: 2.59k, False: 66.2k]
  ------------------
  715|  2.59k|        mp_wakeup_core(mpctx);
  716|       |
  717|  1.61M|    if (mpctx->audio_status == STATUS_SYNCING && !ao_c->start_pts_known)
  ------------------
  |  Branch (717:9): [True: 68.8k, False: 1.54M]
  |  Branch (717:50): [True: 36, False: 68.8k]
  ------------------
  718|     36|        return;
  719|       |
  720|  1.61M|    if (ao_c->untimed_throttle)
  ------------------
  |  Branch (720:9): [True: 0, False: 1.61M]
  ------------------
  721|      0|        return;
  722|       |
  723|  1.61M|    if (!mp_pin_can_transfer_data(ao_c->queue_filter->pins[0], f->ppins[0]))
  ------------------
  |  Branch (723:9): [True: 808k, False: 806k]
  ------------------
  724|   808k|        return;
  725|       |
  726|   806k|    struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  727|   806k|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (727:9): [True: 800k, False: 6.04k]
  ------------------
  728|   800k|        struct mp_aframe *af = frame.data;
  729|       |
  730|   800k|        double endpts = get_play_end_pts(mpctx);
  731|   800k|        if (endpts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   800k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (731:13): [True: 0, False: 800k]
  ------------------
  732|      0|            endpts *= mpctx->play_dir;
  733|       |            // Avoid decoding and discarding the entire rest of the file.
  734|      0|            if (mp_aframe_get_pts(af) >= endpts) {
  ------------------
  |  Branch (734:17): [True: 0, False: 0]
  ------------------
  735|      0|                mp_pin_out_unread(f->ppins[0], frame);
  736|      0|                if (!ao_c->out_eof) {
  ------------------
  |  Branch (736:21): [True: 0, False: 0]
  ------------------
  737|      0|                    ao_c->out_eof = true;
  738|      0|                    mp_pin_in_write(ao_c->queue_filter->pins[0], MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  739|      0|                }
  740|      0|                return;
  741|      0|            }
  742|      0|        }
  743|   800k|        double startpts = mpctx->audio_status == STATUS_SYNCING ?
  ------------------
  |  Branch (743:27): [True: 32.6k, False: 768k]
  ------------------
  744|   768k|                                            ao_c->start_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|   768k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  745|   800k|        mp_aframe_clip_timestamps(af, startpts, endpts);
  746|       |
  747|   800k|        int samples = mp_aframe_get_size(af);
  748|   800k|        if (!samples) {
  ------------------
  |  Branch (748:13): [True: 0, False: 800k]
  ------------------
  749|      0|            mp_filter_internal_mark_progress(f);
  750|      0|            mp_frame_unref(&frame);
  751|      0|            return;
  752|      0|        }
  753|       |
  754|   800k|        mpctx->shown_aframes += samples;
  755|   800k|        double real_samplerate = mp_aframe_get_rate(af) / mpctx->audio_speed;
  756|   800k|        if (mpctx->video_status != STATUS_EOF)
  ------------------
  |  Branch (756:13): [True: 0, False: 800k]
  ------------------
  757|      0|            mpctx->delay += samples / real_samplerate;
  758|   800k|        ao_c->last_out_pts = mp_aframe_end_pts(af);
  759|   800k|        update_throttle(mpctx);
  760|       |
  761|       |        // Gapless case: the AO is still playing from previous file. It makes
  762|       |        // no sense to wait, and in fact the "full queue" event we're waiting
  763|       |        // for may never happen, so start immediately.
  764|       |        // If the new audio starts "later" (big video sync offset), transfer
  765|       |        // of data is stopped somewhere else.
  766|   800k|        if (mpctx->audio_status == STATUS_SYNCING && ao_is_playing(ao_c->ao)) {
  ------------------
  |  Branch (766:13): [True: 32.6k, False: 768k]
  |  Branch (766:54): [True: 0, False: 32.6k]
  ------------------
  767|      0|            mpctx->audio_status = STATUS_READY;
  768|      0|            mp_wakeup_core(mpctx);
  769|      0|            MP_VERBOSE(mpctx, "previous audio still playing; continuing\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  770|      0|        }
  771|       |
  772|   800k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  773|   800k|    } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (773:16): [True: 6.04k, False: 0]
  ------------------
  774|  6.04k|        MP_VERBOSE(mpctx, "audio filter EOF\n");
  ------------------
  |  |   92|  6.04k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.04k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  775|       |
  776|  6.04k|        ao_c->out_eof = true;
  777|  6.04k|        mp_wakeup_core(mpctx);
  778|       |
  779|  6.04k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  780|  6.04k|        mp_filter_internal_mark_progress(f);
  781|  6.04k|    } else {
  782|      0|        mp_frame_unref(&frame);
  783|      0|    }
  784|   806k|}
audio.c:get_sync_pts:
  824|  55.5k|{
  825|  55.5k|    struct MPOpts *opts = mpctx->opts;
  826|       |
  827|  55.5k|    *pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  55.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  828|       |
  829|  55.5k|    if (!opts->initial_audio_sync)
  ------------------
  |  Branch (829:9): [True: 0, False: 55.5k]
  ------------------
  830|      0|        return true;
  831|       |
  832|  55.5k|    bool sync_to_video = mpctx->vo_chain && mpctx->video_status != STATUS_EOF &&
  ------------------
  |  Branch (832:26): [True: 8.52k, False: 47.0k]
  |  Branch (832:45): [True: 8.39k, False: 129]
  ------------------
  833|  8.39k|                         !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (833:26): [True: 8.39k, False: 0]
  ------------------
  834|       |
  835|  55.5k|    if (sync_to_video) {
  ------------------
  |  Branch (835:9): [True: 8.39k, False: 47.1k]
  ------------------
  836|  8.39k|        if (mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (836:13): [True: 8.39k, False: 0]
  ------------------
  837|  8.39k|            return false; // wait until we know a video PTS
  838|      0|        if (mpctx->video_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (838:13): [True: 0, False: 0]
  ------------------
  839|      0|            *pts = mpctx->video_pts - opts->audio_delay;
  840|  47.1k|    } else if (mpctx->hrseek_active) {
  ------------------
  |  Branch (840:16): [True: 0, False: 47.1k]
  ------------------
  841|      0|        *pts = mpctx->hrseek_pts;
  842|  47.1k|    } else {
  843|       |        // If audio-only is enabled mid-stream during playback, sync accordingly.
  844|  47.1k|        *pts = mpctx->playback_pts;
  845|  47.1k|    }
  846|       |
  847|  47.1k|    return true;
  848|  55.5k|}
audio.c:update_throttle:
  670|   932k|{
  671|   932k|    struct ao_chain *ao_c = mpctx->ao_chain;
  672|   932k|    bool new_throttle = mpctx->audio_status == STATUS_PLAYING &&
  ------------------
  |  Branch (672:25): [True: 781k, False: 151k]
  ------------------
  673|   781k|                        mpctx->delay > 0 && ao_c && ao_c->ao &&
  ------------------
  |  Branch (673:25): [True: 0, False: 781k]
  |  Branch (673:45): [True: 0, False: 0]
  |  Branch (673:53): [True: 0, False: 0]
  ------------------
  674|      0|                        ao_untimed(ao_c->ao) &&
  ------------------
  |  Branch (674:25): [True: 0, False: 0]
  ------------------
  675|      0|                        mpctx->video_status != STATUS_EOF;
  ------------------
  |  Branch (675:25): [True: 0, False: 0]
  ------------------
  676|   932k|    if (ao_c && new_throttle != ao_c->untimed_throttle) {
  ------------------
  |  Branch (676:9): [True: 872k, False: 59.7k]
  |  Branch (676:17): [True: 0, False: 872k]
  ------------------
  677|      0|        ao_c->untimed_throttle = new_throttle;
  678|      0|        mp_wakeup_core(mpctx);
  679|      0|        mp_filter_wakeup(ao_c->ao_filter);
  680|      0|    }
  681|   932k|}
audio.c:reinit_audio_filters_and_output:
  360|  9.04k|{
  361|  9.04k|    struct MPOpts *opts = mpctx->opts;
  362|  9.04k|    struct ao_chain *ao_c = mpctx->ao_chain;
  363|  9.04k|    mp_assert(ao_c);
  ------------------
  |  |   41|  9.04k|#define mp_assert assert
  ------------------
  |  Branch (363:5): [True: 9.04k, False: 0]
  ------------------
  364|  9.04k|    struct track *track = ao_c->track;
  365|       |
  366|  9.04k|    mp_assert(ao_c->filter->ao_needs_update);
  ------------------
  |  |   41|  9.04k|#define mp_assert assert
  ------------------
  |  Branch (366:5): [True: 9.04k, False: 0]
  ------------------
  367|       |
  368|       |    // The "ideal" filter output format
  369|  9.04k|    struct mp_aframe *out_fmt = mp_aframe_new_ref(ao_c->filter->output_aformat);
  370|  9.04k|    MP_HANDLE_OOM(out_fmt);
  ------------------
  |  |  206|  9.04k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  9.04k|        void *oom_p_ = (x);     \
  |  |  208|  9.04k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 9.04k]
  |  |  ------------------
  |  |  209|  9.04k|            abort();            \
  |  |  210|  9.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 9.04k]
  |  |  ------------------
  ------------------
  371|       |
  372|  9.04k|    if (!mp_aframe_config_is_valid(out_fmt)) {
  ------------------
  |  Branch (372:9): [True: 0, False: 9.04k]
  ------------------
  373|      0|        talloc_free(out_fmt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  374|      0|        goto init_error;
  375|      0|    }
  376|       |
  377|  9.04k|    if (af_fmt_is_pcm(mp_aframe_get_format(out_fmt))) {
  ------------------
  |  Branch (377:9): [True: 9.04k, False: 0]
  ------------------
  378|  9.04k|        if (opts->force_srate)
  ------------------
  |  Branch (378:13): [True: 0, False: 9.04k]
  ------------------
  379|      0|            mp_aframe_set_rate(out_fmt, opts->force_srate);
  380|  9.04k|        if (opts->audio_output_format)
  ------------------
  |  Branch (380:13): [True: 0, False: 9.04k]
  ------------------
  381|      0|            mp_aframe_set_format(out_fmt, opts->audio_output_format);
  382|  9.04k|        if (opts->audio_output_channels.num_chmaps == 1)
  ------------------
  |  Branch (382:13): [True: 0, False: 9.04k]
  ------------------
  383|      0|            mp_aframe_set_chmap(out_fmt, &opts->audio_output_channels.chmaps[0]);
  384|  9.04k|    }
  385|       |
  386|       |    // Weak gapless audio: if the filter output format is the same as the
  387|       |    // previous one, keep the AO and don't reinit anything.
  388|       |    // Strong gapless: always keep the AO
  389|  9.04k|    if ((mpctx->ao_filter_fmt && mpctx->ao && opts->gapless_audio < 0 &&
  ------------------
  |  Branch (389:10): [True: 2.93k, False: 6.11k]
  |  Branch (389:34): [True: 2.93k, False: 0]
  |  Branch (389:47): [True: 2.93k, False: 0]
  ------------------
  390|  2.93k|         keep_weak_gapless_format(mpctx->ao_filter_fmt, out_fmt)) ||
  ------------------
  |  Branch (390:10): [True: 29, False: 2.90k]
  ------------------
  391|  9.01k|        (mpctx->ao && opts->gapless_audio > 0))
  ------------------
  |  Branch (391:10): [True: 2.90k, False: 6.11k]
  |  Branch (391:23): [True: 0, False: 2.90k]
  ------------------
  392|     29|    {
  393|     29|        ao_chain_set_ao(ao_c, mpctx->ao);
  394|     29|        talloc_free(out_fmt);
  ------------------
  |  |   47|     29|#define talloc_free                     ta_free
  ------------------
  395|     29|        return 0;
  396|     29|    }
  397|       |
  398|       |    // Format change during syncing. Force playback start early, then wait.
  399|  9.01k|    if (ao_c->ao_queue && mp_async_queue_get_frames(ao_c->ao_queue) &&
  ------------------
  |  Branch (399:9): [True: 2.90k, False: 6.11k]
  |  Branch (399:27): [True: 2.03k, False: 870]
  ------------------
  400|  2.03k|        mpctx->audio_status == STATUS_SYNCING)
  ------------------
  |  Branch (400:9): [True: 1.03k, False: 1.00k]
  ------------------
  401|  1.03k|    {
  402|  1.03k|        mpctx->audio_status = STATUS_READY;
  403|  1.03k|        mp_wakeup_core(mpctx);
  404|  1.03k|        talloc_free(out_fmt);
  ------------------
  |  |   47|  1.03k|#define talloc_free                     ta_free
  ------------------
  405|  1.03k|        return 0;
  406|  1.03k|    }
  407|  7.98k|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (407:9): [True: 0, False: 7.98k]
  ------------------
  408|      0|        talloc_free(out_fmt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  409|      0|        return 0;
  410|      0|    }
  411|       |
  412|  7.98k|    uninit_audio_out(mpctx);
  413|       |
  414|  7.98k|    int out_rate = mp_aframe_get_rate(out_fmt);
  415|  7.98k|    int out_format = mp_aframe_get_format(out_fmt);
  416|  7.98k|    struct mp_chmap out_channels = {0};
  417|  7.98k|    mp_aframe_get_chmap(out_fmt, &out_channels);
  418|       |
  419|  7.98k|    int ao_flags = 0;
  420|  7.98k|    bool spdif_fallback = !af_fmt_is_pcm(out_format) &&
  ------------------
  |  Branch (420:27): [True: 0, False: 7.98k]
  ------------------
  421|      0|                          ao_c->spdif_passthrough;
  ------------------
  |  Branch (421:27): [True: 0, False: 0]
  ------------------
  422|       |
  423|  7.98k|    if (opts->ao_null_fallback && !spdif_fallback)
  ------------------
  |  Branch (423:9): [True: 0, False: 7.98k]
  |  Branch (423:35): [True: 0, False: 0]
  ------------------
  424|      0|        ao_flags |= AO_INIT_NULL_FALLBACK;
  425|       |
  426|  7.98k|    if (opts->audio_stream_silence)
  ------------------
  |  Branch (426:9): [True: 0, False: 7.98k]
  ------------------
  427|      0|        ao_flags |= AO_INIT_STREAM_SILENCE;
  428|       |
  429|  7.98k|    if (opts->audio_exclusive)
  ------------------
  |  Branch (429:9): [True: 0, False: 7.98k]
  ------------------
  430|      0|        ao_flags |= AO_INIT_EXCLUSIVE;
  431|       |
  432|  7.98k|    if (af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (432:9): [True: 7.98k, False: 0]
  ------------------
  433|  7.98k|        if (!opts->audio_output_channels.set ||
  ------------------
  |  Branch (433:13): [True: 0, False: 7.98k]
  ------------------
  434|  7.98k|            opts->audio_output_channels.auto_safe)
  ------------------
  |  Branch (434:13): [True: 7.98k, False: 0]
  ------------------
  435|  7.98k|            ao_flags |= AO_INIT_SAFE_MULTICHANNEL_ONLY;
  436|       |
  437|  7.98k|        mp_chmap_sel_list(&out_channels,
  438|  7.98k|                          opts->audio_output_channels.chmaps,
  439|  7.98k|                          opts->audio_output_channels.num_chmaps);
  440|  7.98k|    }
  441|       |
  442|  7.98k|    if (!has_video_track(mpctx))
  ------------------
  |  Branch (442:9): [True: 7.88k, False: 99]
  ------------------
  443|  7.88k|        ao_flags |= AO_INIT_MEDIA_ROLE_MUSIC;
  444|       |
  445|  7.98k|    mpctx->ao_filter_fmt = out_fmt;
  446|       |
  447|  7.98k|    mpctx->ao = ao_init_best(mpctx->global, ao_flags, mp_wakeup_core_cb,
  448|  7.98k|                             mpctx, mpctx->encode_lavc_ctx, out_rate,
  449|  7.98k|                             out_format, out_channels);
  450|       |
  451|  7.98k|    int ao_rate = 0;
  452|  7.98k|    int ao_format = 0;
  453|  7.98k|    struct mp_chmap ao_channels = {0};
  454|  7.98k|    if (mpctx->ao)
  ------------------
  |  Branch (454:9): [True: 7.92k, False: 64]
  ------------------
  455|  7.92k|        ao_get_format(mpctx->ao, &ao_rate, &ao_format, &ao_channels);
  456|       |
  457|       |    // Verify passthrough format was not changed.
  458|  7.98k|    if (mpctx->ao && !af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (458:9): [True: 7.92k, False: 64]
  |  Branch (458:22): [True: 0, False: 7.92k]
  ------------------
  459|      0|        if (out_rate != ao_rate || out_format != ao_format ||
  ------------------
  |  Branch (459:13): [True: 0, False: 0]
  |  Branch (459:36): [True: 0, False: 0]
  ------------------
  460|      0|            !mp_chmap_equals(&out_channels, &ao_channels))
  ------------------
  |  Branch (460:13): [True: 0, False: 0]
  ------------------
  461|      0|        {
  462|      0|            MP_ERR(mpctx, "Passthrough format unsupported.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  463|      0|            ao_uninit(mpctx->ao);
  464|      0|            mpctx->ao = NULL;
  465|      0|        }
  466|      0|    }
  467|       |
  468|  7.98k|    if (!mpctx->ao) {
  ------------------
  |  Branch (468:9): [True: 64, False: 7.92k]
  ------------------
  469|       |        // If spdif was used, try to fallback to PCM.
  470|     64|        if (spdif_fallback && ao_c->track && ao_c->track->dec) {
  ------------------
  |  Branch (470:13): [True: 0, False: 64]
  |  Branch (470:31): [True: 0, False: 0]
  |  Branch (470:46): [True: 0, False: 0]
  ------------------
  471|      0|            MP_VERBOSE(mpctx, "Falling back to PCM output.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  472|      0|            ao_c->spdif_passthrough = false;
  473|      0|            ao_c->spdif_failed = true;
  474|      0|            mp_decoder_wrapper_set_spdif_flag(ao_c->track->dec, false);
  475|      0|            if (!mp_decoder_wrapper_reinit(ao_c->track->dec))
  ------------------
  |  Branch (475:17): [True: 0, False: 0]
  ------------------
  476|      0|                goto init_error;
  477|      0|            reset_audio_state(mpctx);
  478|      0|            mp_output_chain_reset_harder(ao_c->filter);
  479|      0|            mp_wakeup_core(mpctx); // reinit with new format next time
  480|      0|            return 0;
  481|      0|        }
  482|       |
  483|     64|        MP_ERR(mpctx, "Could not open/initialize audio device -> no sound.\n");
  ------------------
  |  |   89|     64|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     64|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|     64|        mpctx->error_playing = MPV_ERROR_AO_INIT_FAILED;
  485|     64|        goto init_error;
  486|     64|    }
  487|       |
  488|  7.92k|    char tmp[192];
  489|  7.92k|    MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(mpctx->ao),
  ------------------
  |  |   91|  7.92k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.92k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  7.92k|            audio_config_to_str_buf(tmp, sizeof(tmp), ao_rate, ao_format,
  491|  7.92k|                                    ao_channels));
  492|  7.92k|    MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(mpctx->ao));
  ------------------
  |  |   92|  7.92k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.92k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  493|  7.92k|    update_window_title(mpctx, true);
  494|       |
  495|  7.92k|    ao_c->ao_resume_time =
  496|  7.92k|        opts->audio_wait_open > 0 ? mp_time_sec() + opts->audio_wait_open : 0;
  ------------------
  |  Branch (496:9): [True: 0, False: 7.92k]
  ------------------
  497|       |
  498|  7.92k|    bool eof = mpctx->audio_status == STATUS_EOF;
  499|  7.92k|    ao_set_paused(mpctx->ao, get_internal_paused(mpctx), eof);
  500|       |
  501|  7.92k|    ao_chain_set_ao(ao_c, mpctx->ao);
  502|       |
  503|  7.92k|    audio_update_volume(mpctx);
  504|       |
  505|       |    // Almost nonsensical hack to deal with certain format change scenarios.
  506|  7.92k|    if (mpctx->audio_status == STATUS_PLAYING)
  ------------------
  |  Branch (506:9): [True: 1.87k, False: 6.04k]
  ------------------
  507|  1.87k|        ao_start(mpctx->ao);
  508|       |
  509|  7.92k|    mp_wakeup_core(mpctx);
  510|  7.92k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  511|       |
  512|  7.92k|    return 0;
  513|       |
  514|     64|init_error:
  515|     64|    uninit_audio_chain(mpctx);
  516|     64|    uninit_audio_out(mpctx);
  517|     64|    error_on_track(mpctx, track);
  518|     64|    return -1;
  519|  7.98k|}
audio.c:keep_weak_gapless_format:
  315|  2.93k|{
  316|  2.93k|    bool res = false;
  317|  2.93k|    struct mp_aframe *new_mod = mp_aframe_new_ref(new);
  318|  2.93k|    MP_HANDLE_OOM(new_mod);
  ------------------
  |  |  206|  2.93k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  2.93k|        void *oom_p_ = (x);     \
  |  |  208|  2.93k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 2.93k]
  |  |  ------------------
  |  |  209|  2.93k|            abort();            \
  |  |  210|  2.93k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 2.93k]
  |  |  ------------------
  ------------------
  319|       |
  320|       |    // If the sample formats are compatible (== libswresample generally can
  321|       |    // convert them), keep the AO. On other changes, recreate it.
  322|       |
  323|  2.93k|    int old_fmt = mp_aframe_get_format(old);
  324|  2.93k|    int new_fmt = mp_aframe_get_format(new);
  325|       |
  326|  2.93k|    if (af_format_conversion_score(old_fmt, new_fmt) == INT_MIN)
  ------------------
  |  Branch (326:9): [True: 0, False: 2.93k]
  ------------------
  327|      0|        goto done; // completely incompatible formats
  328|       |
  329|  2.93k|    if (!mp_aframe_set_format(new_mod, old_fmt))
  ------------------
  |  Branch (329:9): [True: 0, False: 2.93k]
  ------------------
  330|      0|        goto done;
  331|       |
  332|  2.93k|    res = mp_aframe_config_equals(old, new_mod);
  333|       |
  334|  2.93k|done:
  335|  2.93k|    talloc_free(new_mod);
  ------------------
  |  |   47|  2.93k|#define talloc_free                     ta_free
  ------------------
  336|  2.93k|    return res;
  337|  2.93k|}
audio.c:ao_chain_set_ao:
  340|  7.95k|{
  341|  7.95k|    if (ao_c->ao != ao) {
  ------------------
  |  Branch (341:9): [True: 7.95k, False: 0]
  ------------------
  342|  7.95k|        mp_assert(!ao_c->ao);
  ------------------
  |  |   41|  7.95k|#define mp_assert assert
  ------------------
  |  Branch (342:9): [True: 7.95k, False: 0]
  ------------------
  343|  7.95k|        ao_c->ao = ao;
  344|  7.95k|        ao_c->ao_queue = ao_get_queue(ao_c->ao);
  345|  7.95k|        ao_c->queue_filter = mp_async_queue_create_filter(ao_c->ao_filter,
  346|  7.95k|                                                          MP_PIN_IN, ao_c->ao_queue);
  347|  7.95k|        mp_async_queue_set_notifier(ao_c->queue_filter, ao_c->ao_filter);
  348|       |        // Make sure filtering never stops with frames stuck in access filter.
  349|  7.95k|        mp_filter_set_high_priority(ao_c->queue_filter, true);
  350|  7.95k|        audio_update_volume(ao_c->mpctx);
  351|  7.95k|    }
  352|       |
  353|  7.95k|    if (ao_c->filter->ao_needs_update)
  ------------------
  |  Branch (353:9): [True: 7.95k, False: 0]
  ------------------
  354|  7.95k|        mp_output_chain_set_ao(ao_c->filter, ao_c->ao);
  355|       |
  356|  7.95k|    mp_filter_wakeup(ao_c->ao_filter);
  357|  7.95k|}
audio.c:has_video_track:
  206|  7.98k|{
  207|  7.98k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart)
  ------------------
  |  Branch (207:9): [True: 43, False: 7.94k]
  |  Branch (207:28): [True: 0, False: 43]
  ------------------
  208|      0|        return false;
  209|       |
  210|  15.9k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (210:21): [True: 8.10k, False: 7.88k]
  ------------------
  211|  8.10k|        struct track *track = mpctx->tracks[n];
  212|  8.10k|        if (track->type == STREAM_VIDEO && !track->attached_picture && !track->image)
  ------------------
  |  Branch (212:13): [True: 99, False: 8.00k]
  |  Branch (212:44): [True: 99, False: 0]
  |  Branch (212:72): [True: 99, False: 0]
  ------------------
  213|     99|            return true;
  214|  8.10k|    }
  215|       |
  216|  7.88k|    return false;
  217|  7.98k|}
audio.c:audio_config_to_str_buf:
  302|  7.92k|{
  303|  7.92k|    char ch[128];
  304|  7.92k|    mp_chmap_to_str_buf(ch, sizeof(ch), &channels);
  305|  7.92k|    char *hr_ch = mp_chmap_to_str_hr(&channels);
  ------------------
  |  |  153|  7.92k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  7.92k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  306|  7.92k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (306:9): [True: 292, False: 7.62k]
  ------------------
  307|    292|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  308|  7.92k|    snprintf(buf, buf_sz, "%dHz %s %dch %s", rate,
  309|  7.92k|             ch, channels.num, af_fmt_to_str(format));
  310|  7.92k|    return buf;
  311|  7.92k|}

mp_clients_init:
  180|  28.9k|{
  181|  28.9k|    mpctx->clients = talloc_ptrtype(NULL, mpctx->clients);
  ------------------
  |  |   34|  28.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  28.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|  28.9k|    *mpctx->clients = (struct mp_client_api) {
  183|  28.9k|        .mpctx = mpctx,
  184|  28.9k|    };
  185|  28.9k|    mpctx->global->client_api = mpctx->clients;
  186|  28.9k|    mp_mutex_init(&mpctx->clients->lock);
  187|  28.9k|}
mp_clients_destroy:
  190|  28.9k|{
  191|  28.9k|    if (!mpctx->clients)
  ------------------
  |  Branch (191:9): [True: 0, False: 28.9k]
  ------------------
  192|      0|        return;
  193|  28.9k|    mp_assert(mpctx->clients->num_clients == 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (193:5): [True: 28.9k, False: 0]
  ------------------
  194|       |
  195|       |    // The API user is supposed to call mpv_render_context_free(). It's simply
  196|       |    // not allowed not to do this.
  197|  28.9k|    if (mpctx->clients->render_context) {
  ------------------
  |  Branch (197:9): [True: 0, False: 28.9k]
  ------------------
  198|      0|        MP_FATAL(mpctx, "Broken API use: mpv_render_context_free() not called.\n");
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  199|      0|        abort();
  200|      0|    }
  201|       |
  202|  28.9k|    mp_mutex_destroy(&mpctx->clients->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  203|  28.9k|    talloc_free(mpctx->clients);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  204|       |    mpctx->clients = NULL;
  205|  28.9k|}
mp_clients_all_initialized:
  210|  28.9k|{
  211|  28.9k|    bool all_ok = true;
  212|  28.9k|    mp_mutex_lock(&mpctx->clients->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  213|  57.9k|    for (int n = 0; n < mpctx->clients->num_clients; n++) {
  ------------------
  |  Branch (213:21): [True: 28.9k, False: 28.9k]
  ------------------
  214|  28.9k|        struct mpv_handle *ctx = mpctx->clients->clients[n];
  215|  28.9k|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  216|  28.9k|        all_ok &= ctx->fuzzy_initialized;
  217|  28.9k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  218|  28.9k|    }
  219|  28.9k|    mp_mutex_unlock(&mpctx->clients->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  220|  28.9k|    return all_ok;
  221|  28.9k|}
mp_new_weak_client:
  324|  28.9k|{
  325|       |    return new_client(clients, name, true);
  326|  28.9k|}
mpv_wait_async_requests:
  398|  57.9k|{
  399|  57.9k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  400|  57.9k|    while (ctx->reserved_events || ctx->async_counter)
  ------------------
  |  Branch (400:12): [True: 0, False: 57.9k]
  |  Branch (400:36): [True: 0, False: 57.9k]
  ------------------
  401|      0|        wait_wakeup(ctx, INT64_MAX);
  402|  57.9k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  403|  57.9k|}
mpv_destroy:
  537|  28.9k|{
  538|       |    mp_destroy_client(ctx, false);
  539|  28.9k|}
mpv_terminate_destroy:
  542|  28.9k|{
  543|       |    mp_destroy_client(ctx, true);
  544|  28.9k|}
mp_shutdown_clients:
  549|  57.9k|{
  550|  57.9k|    struct mp_client_api *clients = mpctx->clients;
  551|       |
  552|       |    // Forcefully abort async work after 2 seconds of waiting.
  553|  57.9k|    double abort_time = mp_time_sec() + 2;
  554|       |
  555|  57.9k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  556|       |
  557|       |    // Prevent that new clients can appear.
  558|  57.9k|    clients->shutting_down = true;
  559|       |
  560|       |    // Wait until we can terminate.
  561|   122k|    while (clients->num_clients || mpctx->outstanding_async ||
  ------------------
  |  Branch (561:12): [True: 57.7k, False: 64.4k]
  |  Branch (561:36): [True: 0, False: 64.4k]
  ------------------
  562|  64.4k|           !(mpctx->is_cli || clients->terminate_core_thread))
  ------------------
  |  Branch (562:14): [True: 0, False: 64.4k]
  |  Branch (562:31): [True: 57.9k, False: 6.53k]
  ------------------
  563|  64.2k|    {
  564|  64.2k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  64.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  565|       |
  566|  64.2k|        double left = abort_time - mp_time_sec();
  567|  64.2k|        if (left >= 0) {
  ------------------
  |  Branch (567:13): [True: 64.2k, False: 0]
  ------------------
  568|  64.2k|            mp_set_timeout(mpctx, left);
  569|  64.2k|        } else {
  570|       |            // Forcefully abort any ongoing async work. This is quite rude and
  571|       |            // probably not what everyone wants, so it happens only after a
  572|       |            // timeout.
  573|      0|            abort_async(mpctx, NULL, 0, 0);
  574|      0|        }
  575|       |
  576|  64.2k|        mp_client_broadcast_event(mpctx, MPV_EVENT_SHUTDOWN, NULL);
  577|  64.2k|        mp_wait_events(mpctx);
  578|       |
  579|  64.2k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  64.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  580|  64.2k|    }
  581|       |
  582|  57.9k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  583|  57.9k|}
mpv_create:
  639|  28.9k|{
  640|       |    return create_core(false);
  641|  28.9k|}
mpv_initialize_opts:
  669|  28.9k|{
  670|  28.9k|    lock_core(ctx);
  671|  28.9k|    int res = mp_initialize(ctx->mpctx, options) ? MPV_ERROR_INVALID_PARAMETER : 0;
  ------------------
  |  Branch (671:15): [True: 0, False: 28.9k]
  ------------------
  672|  28.9k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  673|       |    // Only the options parser fuzzer passes options. It wants them parsed and
  674|       |    // applied, not played.
  675|  28.9k|    if (options)
  ------------------
  |  Branch (675:9): [True: 0, False: 28.9k]
  ------------------
  676|      0|        ctx->mpctx->stop_play = PT_QUIT;
  677|  28.9k|#endif
  678|  28.9k|    mp_wakeup_core(ctx->mpctx);
  679|  28.9k|    unlock_core(ctx);
  680|  28.9k|    return res;
  681|  28.9k|}
mpv_initialize:
  684|  28.9k|{
  685|       |    return mpv_initialize_opts(ctx, NULL);
  686|  28.9k|}
mp_client_broadcast_event:
  786|   894k|{
  787|   894k|    struct mp_client_api *clients = mpctx->clients;
  788|       |
  789|   894k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   894k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  790|       |
  791|  1.78M|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (791:21): [True: 887k, False: 894k]
  ------------------
  792|   887k|        struct mpv_event event_data = {
  793|   887k|            .event_id = event,
  794|   887k|            .data = data,
  795|   887k|        };
  796|   887k|        send_event(clients->clients[n], &event_data, true);
  797|   887k|    }
  798|       |
  799|   894k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   894k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  800|   894k|}
mpv_request_event:
  872|  57.9k|{
  873|  57.9k|    if (!mpv_event_name(event) || enable < 0 || enable > 1)
  ------------------
  |  Branch (873:9): [True: 0, False: 57.9k]
  |  Branch (873:35): [True: 0, False: 57.9k]
  |  Branch (873:49): [True: 0, False: 57.9k]
  ------------------
  874|      0|        return MPV_ERROR_INVALID_PARAMETER;
  875|  57.9k|    if (event == MPV_EVENT_SHUTDOWN && !enable)
  ------------------
  |  Branch (875:9): [True: 0, False: 57.9k]
  |  Branch (875:40): [True: 0, False: 0]
  ------------------
  876|      0|        return MPV_ERROR_INVALID_PARAMETER;
  877|  57.9k|    mp_assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (877:5): [True: 57.9k, False: 0]
  ------------------
  878|  57.9k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  879|  57.9k|    uint64_t bit = 1ULL << event;
  880|  57.9k|    ctx->event_mask = enable ? ctx->event_mask | bit : ctx->event_mask & ~bit;
  ------------------
  |  Branch (880:23): [True: 0, False: 57.9k]
  ------------------
  881|  57.9k|    if (enable && event < MP_ARRAY_SIZE(deprecated_events) &&
  ------------------
  |  |   49|  57.9k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (881:9): [True: 0, False: 57.9k]
  |  Branch (881:19): [True: 0, False: 0]
  ------------------
  882|      0|        deprecated_events[event])
  ------------------
  |  Branch (882:9): [True: 0, False: 0]
  ------------------
  883|      0|    {
  884|      0|        MP_WARN(ctx, "The '%s' event is deprecated and will be removed.\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  885|      0|                mpv_event_name(event));
  886|      0|    }
  887|  57.9k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  888|  57.9k|    return 0;
  889|  57.9k|}
mpv_wait_event:
  913|   491k|{
  914|   491k|    mpv_event *event = ctx->cur_event;
  915|       |
  916|   491k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   491k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  917|       |
  918|   491k|    if (!ctx->fuzzy_initialized)
  ------------------
  |  Branch (918:9): [True: 0, False: 491k]
  ------------------
  919|      0|        mp_wakeup_core(ctx->clients->mpctx);
  920|   491k|    ctx->fuzzy_initialized = true;
  921|       |
  922|   491k|    if (timeout < 0)
  ------------------
  |  Branch (922:9): [True: 449k, False: 42.2k]
  ------------------
  923|   449k|        timeout = 1e20;
  924|       |
  925|   491k|    int64_t deadline = mp_time_ns_add(mp_time_ns(), timeout);
  926|       |
  927|   491k|    *event = (mpv_event){0};
  928|   491k|    talloc_free_children(event);
  ------------------
  |  |   46|   491k|#define talloc_free_children            ta_free_children
  ------------------
  929|       |
  930|   784k|    while (1) {
  ------------------
  |  Branch (930:12): [True: 784k, Folded]
  ------------------
  931|   784k|        if (ctx->queued_wakeup)
  ------------------
  |  Branch (931:13): [True: 0, False: 784k]
  ------------------
  932|      0|            deadline = 0;
  933|       |        // Recover from overflow.
  934|   784k|        if (ctx->choked && !ctx->num_events) {
  ------------------
  |  Branch (934:13): [True: 0, False: 784k]
  |  Branch (934:28): [True: 0, False: 0]
  ------------------
  935|      0|            ctx->choked = false;
  936|      0|            event->event_id = MPV_EVENT_QUEUE_OVERFLOW;
  937|      0|            break;
  938|      0|        }
  939|   784k|        struct mpv_event *ev =
  940|   784k|            ctx->num_events ? &ctx->events[ctx->first_event] : NULL;
  ------------------
  |  Branch (940:13): [True: 462k, False: 322k]
  ------------------
  941|   784k|        if (ev && ev->event_id == MPV_EVENT_HOOK) {
  ------------------
  |  Branch (941:13): [True: 462k, False: 322k]
  |  Branch (941:19): [True: 0, False: 462k]
  ------------------
  942|       |            // Give old property notifications priority over hooks. This is a
  943|       |            // guarantee given to clients to simplify their logic. New property
  944|       |            // changes after this are treated normally, so
  945|      0|            if (!ctx->hook_pending) {
  ------------------
  |  Branch (945:17): [True: 0, False: 0]
  ------------------
  946|      0|                ctx->hook_pending = true;
  947|      0|                set_wait_for_hook_flags(ctx);
  948|      0|            }
  949|      0|            if (check_for_for_hook_flags(ctx)) {
  ------------------
  |  Branch (949:17): [True: 0, False: 0]
  ------------------
  950|      0|                ev = NULL; // delay
  951|      0|            } else {
  952|      0|                ctx->hook_pending = false;
  953|      0|            }
  954|      0|        }
  955|   784k|        if (ev) {
  ------------------
  |  Branch (955:13): [True: 462k, False: 322k]
  ------------------
  956|   462k|            *event = *ev;
  957|   462k|            ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  958|   462k|            ctx->num_events--;
  959|   462k|            talloc_steal(event, event->data);
  ------------------
  |  |   38|   462k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   462k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  960|   462k|            break;
  961|   462k|        }
  962|       |        // If there's a changed property, generate change event (never queued).
  963|   322k|        if (gen_property_change_event(ctx))
  ------------------
  |  Branch (963:13): [True: 29.0k, False: 293k]
  ------------------
  964|  29.0k|            break;
  965|       |        // Pop item from message queue, and return as event.
  966|   293k|        if (gen_log_message_event(ctx))
  ------------------
  |  Branch (966:13): [True: 0, False: 293k]
  ------------------
  967|      0|            break;
  968|   293k|        int r = wait_wakeup(ctx, deadline);
  969|   293k|        if (r == ETIMEDOUT)
  ------------------
  |  Branch (969:13): [True: 1, False: 293k]
  ------------------
  970|      1|            break;
  971|   293k|    }
  972|   491k|    ctx->queued_wakeup = false;
  973|       |
  974|   491k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   491k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  975|       |
  976|   491k|    return event;
  977|   491k|}
mpv_free_node_contents:
 1038|  86.8k|{
 1039|  86.8k|    static const struct m_option type = { .type = CONF_TYPE_NODE };
  ------------------
  |  |  253|  86.8k|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 1040|  86.8k|    m_option_free(&type, node);
 1041|  86.8k|}
mpv_set_option:
 1045|   260k|{
 1046|   260k|    const struct m_option *type = get_mp_type(format);
 1047|   260k|    if (!type)
  ------------------
  |  Branch (1047:9): [True: 0, False: 260k]
  ------------------
 1048|      0|        return MPV_ERROR_OPTION_FORMAT;
 1049|   260k|    struct mpv_node tmp;
 1050|   260k|    if (format != MPV_FORMAT_NODE) {
  ------------------
  |  Branch (1050:9): [True: 260k, False: 0]
  ------------------
 1051|   260k|        tmp.format = format;
 1052|   260k|        memcpy(&tmp.u, data, type->type->size);
 1053|   260k|        data = &tmp;
 1054|   260k|    }
 1055|   260k|    lock_core(ctx);
 1056|   260k|    int err = m_config_set_option_node(ctx->mpctx->mconfig, bstr0(name), data, 0);
 1057|   260k|    unlock_core(ctx);
 1058|   260k|    switch (err) {
 1059|      0|    case M_OPT_MISSING_PARAM:
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (1059:5): [True: 0, False: 260k]
  ------------------
 1060|      0|    case M_OPT_INVALID:
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (1060:5): [True: 0, False: 260k]
  ------------------
 1061|      0|        return MPV_ERROR_OPTION_ERROR;
 1062|      0|    case M_OPT_OUT_OF_RANGE:
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  |  Branch (1062:5): [True: 0, False: 260k]
  ------------------
 1063|      0|        return MPV_ERROR_OPTION_FORMAT;
 1064|      0|    case M_OPT_UNKNOWN:
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (1064:5): [True: 0, False: 260k]
  ------------------
 1065|      0|        return MPV_ERROR_OPTION_NOT_FOUND;
 1066|   260k|    default:
  ------------------
  |  Branch (1066:5): [True: 260k, False: 0]
  ------------------
 1067|   260k|        if (err >= 0)
  ------------------
  |  Branch (1067:13): [True: 260k, False: 0]
  ------------------
 1068|   260k|            return 0;
 1069|      0|        return MPV_ERROR_OPTION_ERROR;
 1070|   260k|    }
 1071|   260k|}
mpv_set_option_string:
 1074|   260k|{
 1075|   260k|    return mpv_set_option(ctx, name, MPV_FORMAT_STRING, &data);
 1076|   260k|}
mpv_command:
 1165|  86.8k|{
 1166|       |    return run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), NULL);
 1167|  86.8k|}
mpv_observe_property:
 1558|  57.9k|{
 1559|  57.9k|    const struct m_option *type = get_mp_type_get(format);
 1560|  57.9k|    if (format != MPV_FORMAT_NONE && !type)
  ------------------
  |  Branch (1560:9): [True: 0, False: 57.9k]
  |  Branch (1560:38): [True: 0, False: 0]
  ------------------
 1561|      0|        return MPV_ERROR_PROPERTY_FORMAT;
 1562|       |    // Explicitly disallow this, because it would require a special code path.
 1563|  57.9k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1563:9): [True: 0, False: 57.9k]
  ------------------
 1564|      0|        return MPV_ERROR_PROPERTY_FORMAT;
 1565|       |
 1566|  57.9k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1567|  57.9k|    mp_assert(!ctx->destroying);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (1567:5): [True: 57.9k, False: 0]
  ------------------
 1568|  57.9k|    struct observe_property *prop = talloc_ptrtype(ctx, prop);
  ------------------
  |  |   34|  57.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  57.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|  57.9k|    talloc_set_destructor(prop, property_free);
  ------------------
  |  |   41|  57.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1570|  57.9k|    *prop = (struct observe_property){
 1571|  57.9k|        .owner = ctx,
 1572|  57.9k|        .name = talloc_strdup(prop, name),
  ------------------
  |  |   50|  57.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1573|  57.9k|        .id = mp_get_property_id(ctx->mpctx, name),
 1574|  57.9k|        .event_mask = mp_get_property_event_mask(name),
 1575|  57.9k|        .reply_id = userdata,
 1576|  57.9k|        .format = format,
 1577|  57.9k|        .type = type,
 1578|  57.9k|        .change_ts = 1, // force initial event
 1579|  57.9k|        .refcount = 1,
 1580|  57.9k|        .value = m_option_value_default,
 1581|  57.9k|        .value_ret = m_option_value_default,
 1582|  57.9k|    };
 1583|  57.9k|    ctx->properties_change_ts += 1;
 1584|  57.9k|    MP_TARRAY_APPEND(ctx, ctx->properties, ctx->num_properties, prop);
  ------------------
  |  |  105|  57.9k|    do {                                            \
  |  |  106|  57.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.9k|    do {                                            \
  |  |  |  |   97|  57.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  57.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.9k|        (idxvar)++;                                 \
  |  |  109|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
 1585|  57.9k|    ctx->property_event_masks |= prop->event_mask;
 1586|  57.9k|    ctx->new_property_events = true;
 1587|  57.9k|    ctx->cur_property_index = 0;
 1588|  57.9k|    ctx->has_pending_properties = true;
 1589|  57.9k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1590|  57.9k|    mp_wakeup_core(ctx->mpctx);
 1591|  57.9k|    return 0;
 1592|  57.9k|}
mpv_unobserve_property:
 1595|  57.9k|{
 1596|  57.9k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1597|  57.9k|    int count = 0;
 1598|   115k|    for (int n = ctx->num_properties - 1; n >= 0; n--) {
  ------------------
  |  Branch (1598:43): [True: 57.9k, False: 57.9k]
  ------------------
 1599|  57.9k|        struct observe_property *prop = ctx->properties[n];
 1600|       |        // Perform actual removal of the property lazily to avoid creating
 1601|       |        // dangling pointers and such.
 1602|  57.9k|        if (prop->reply_id == userdata) {
  ------------------
  |  Branch (1602:13): [True: 57.9k, False: 0]
  ------------------
 1603|  57.9k|            prop_unref(prop);
 1604|  57.9k|            ctx->properties_change_ts += 1;
 1605|  57.9k|            MP_TARRAY_REMOVE_AT(ctx->properties, ctx->num_properties, n);
  ------------------
  |  |  143|  57.9k|    do {                                            \
  |  |  144|  57.9k|        size_t at_ = (at);                          \
  |  |  145|  57.9k|        assert(at_ < (idxvar));                     \
  |  |  146|  57.9k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  57.9k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  57.9k|        (idxvar)--;                                 \
  |  |  149|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
  |  Branch (1605:13): [True: 57.9k, False: 0]
  ------------------
 1606|  57.9k|            ctx->cur_property_index = 0;
 1607|  57.9k|            count++;
 1608|  57.9k|        }
 1609|  57.9k|    }
 1610|  57.9k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1611|  57.9k|    return count;
 1612|  57.9k|}
mp_client_property_change:
 1640|  66.3k|{
 1641|  66.3k|    struct mp_client_api *clients = mpctx->clients;
 1642|  66.3k|    int id = mp_get_property_id(mpctx, name);
 1643|  66.3k|    bool any_pending = false;
 1644|       |
 1645|  66.3k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  66.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1646|       |
 1647|   132k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1647:21): [True: 66.3k, False: 66.3k]
  ------------------
 1648|  66.3k|        struct mpv_handle *client = clients->clients[n];
 1649|  66.3k|        mp_mutex_lock(&client->lock);
  ------------------
  |  |  134|  66.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1650|  66.3k|        for (int i = 0; i < client->num_properties; i++) {
  ------------------
  |  Branch (1650:25): [True: 0, False: 66.3k]
  ------------------
 1651|      0|            if (client->properties[i]->id == id &&
  ------------------
  |  Branch (1651:17): [True: 0, False: 0]
  ------------------
 1652|      0|                property_shared_prefix(name, client->properties[i]->name)) {
  ------------------
  |  Branch (1652:17): [True: 0, False: 0]
  ------------------
 1653|      0|                client->properties[i]->change_ts += 1;
 1654|      0|                client->has_pending_properties = true;
 1655|      0|                any_pending = true;
 1656|      0|            }
 1657|      0|        }
 1658|  66.3k|        mp_mutex_unlock(&client->lock);
  ------------------
  |  |  136|  66.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1659|  66.3k|    }
 1660|       |
 1661|  66.3k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  66.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1662|       |
 1663|       |    // If we're inside mp_dispatch_queue_process(), this will cause the playloop
 1664|       |    // to be re-run (to get mp_client_send_property_changes() called). If we're
 1665|       |    // inside the normal playloop, this does nothing, but the latter function
 1666|       |    // will be called at the end of the playloop anyway.
 1667|  66.3k|    if (any_pending)
  ------------------
  |  Branch (1667:9): [True: 0, False: 66.3k]
  ------------------
 1668|      0|        mp_dispatch_adjust_timeout(mpctx->dispatch, 0);
 1669|  66.3k|}
mp_client_send_property_changes:
 1774|   479k|{
 1775|   479k|    struct mp_client_api *clients = mpctx->clients;
 1776|       |
 1777|   479k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   479k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1778|   479k|    uint64_t cur_ts = clients->clients_list_change_ts;
 1779|       |
 1780|   953k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1780:21): [True: 473k, False: 479k]
  ------------------
 1781|   473k|        struct mpv_handle *ctx = clients->clients[n];
 1782|       |
 1783|   473k|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   473k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1784|   473k|        if (!ctx->has_pending_properties || ctx->destroying) {
  ------------------
  |  Branch (1784:13): [True: 415k, False: 57.8k]
  |  Branch (1784:45): [True: 0, False: 57.8k]
  ------------------
 1785|   415k|            mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   415k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1786|   415k|            continue;
 1787|   415k|        }
 1788|       |        // Keep ctx->lock locked (unlock order does not matter).
 1789|  57.8k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  57.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1790|  57.8k|        send_client_property_changes(ctx);
 1791|  57.8k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1792|  57.8k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  57.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1793|  57.8k|        if (cur_ts != clients->clients_list_change_ts) {
  ------------------
  |  Branch (1793:13): [True: 0, False: 57.8k]
  ------------------
 1794|       |            // List changed; need to start over. Do it in the next iteration.
 1795|      0|            mp_wakeup_core(mpctx);
 1796|      0|            break;
 1797|      0|        }
 1798|  57.8k|    }
 1799|       |
 1800|   479k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   479k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1801|   479k|}
mpv_error_string:
 2107|   133k|{
 2108|   133k|    error = -error;
 2109|   133k|    if (error < 0)
  ------------------
  |  Branch (2109:9): [True: 0, False: 133k]
  ------------------
 2110|      0|        error = 0;
 2111|   133k|    const char *name = NULL;
 2112|   133k|    if (error < MP_ARRAY_SIZE(err_table))
  ------------------
  |  |   49|   133k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2112:9): [True: 133k, False: 0]
  ------------------
 2113|   133k|        name = err_table[error];
 2114|   133k|    return name ? name : "unknown error";
  ------------------
  |  Branch (2114:12): [True: 133k, False: 0]
  ------------------
 2115|   133k|}
mpv_event_name:
 2140|  57.9k|{
 2141|  57.9k|    if ((unsigned)event >= MP_ARRAY_SIZE(event_table))
  ------------------
  |  |   49|  57.9k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2141:9): [True: 0, False: 57.9k]
  ------------------
 2142|      0|        return NULL;
 2143|  57.9k|    return event_table[event];
 2144|  57.9k|}
mp_streamcb_lookup:
 2252|  29.8k|{
 2253|  29.8k|    struct mp_client_api *clients = g->client_api;
 2254|  29.8k|    bool found = false;
 2255|  29.8k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  29.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2256|  29.8k|    for (int n = 0; n < clients->num_custom_protocols; n++) {
  ------------------
  |  Branch (2256:21): [True: 0, False: 29.8k]
  ------------------
 2257|      0|        struct mp_custom_protocol *proto = &clients->custom_protocols[n];
 2258|      0|        if (strcmp(proto->protocol, protocol) == 0) {
  ------------------
  |  Branch (2258:13): [True: 0, False: 0]
  ------------------
 2259|      0|            *out_user_data = proto->user_data;
 2260|      0|            *out_fn = proto->open_fn;
 2261|      0|            found = true;
 2262|      0|            break;
 2263|      0|        }
 2264|      0|    }
 2265|  29.8k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  29.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2266|  29.8k|    return found;
 2267|  29.8k|}
client.c:new_client:
  262|  57.9k|{
  263|  57.9k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  264|       |
  265|  57.9k|    char nname[MAX_CLIENT_NAME];
  266|  57.9k|    for (int n = 1; n < 1000; n++) {
  ------------------
  |  Branch (266:21): [True: 57.9k, False: 0]
  ------------------
  267|  57.9k|        if (!name)
  ------------------
  |  Branch (267:13): [True: 0, False: 57.9k]
  ------------------
  268|      0|            name = "client";
  269|  57.9k|        snprintf(nname, sizeof(nname) - 3, "%s", name); // - space for number
  270|   260k|        for (int i = 0; nname[i]; i++)
  ------------------
  |  Branch (270:25): [True: 202k, False: 57.9k]
  ------------------
  271|   202k|            nname[i] = mp_isalnum(nname[i]) ? nname[i] : '_';
  ------------------
  |  Branch (271:24): [True: 202k, False: 0]
  ------------------
  272|  57.9k|        if (n > 1)
  ------------------
  |  Branch (272:13): [True: 0, False: 57.9k]
  ------------------
  273|      0|            mp_snprintf_cat(nname, sizeof(nname), "%d", n);
  274|  57.9k|        if (!find_client(clients, nname))
  ------------------
  |  Branch (274:13): [True: 57.9k, False: 0]
  ------------------
  275|  57.9k|            break;
  276|      0|        nname[0] = '\0';
  277|      0|    }
  278|       |
  279|  57.9k|    if (!nname[0] || clients->shutting_down) {
  ------------------
  |  Branch (279:9): [True: 0, False: 57.9k]
  |  Branch (279:22): [True: 0, False: 57.9k]
  ------------------
  280|      0|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  281|      0|        return NULL;
  282|      0|    }
  283|       |
  284|  57.9k|    int num_events = 1000;
  285|       |
  286|  57.9k|    struct mpv_handle *client = talloc_ptrtype(NULL, client);
  ------------------
  |  |   34|  57.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  57.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|  57.9k|    *client = (struct mpv_handle){
  288|  57.9k|        .log = mp_log_new(client, clients->mpctx->log, nname),
  289|  57.9k|        .mpctx = clients->mpctx,
  290|  57.9k|        .clients = clients,
  291|  57.9k|        .id = ++(clients->id_alloc),
  292|  57.9k|        .cur_event = talloc_zero(client, struct mpv_event),
  ------------------
  |  |   27|  57.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  57.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|  57.9k|        .events = talloc_array(client, mpv_event, num_events),
  ------------------
  |  |   29|  57.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  57.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|  57.9k|        .max_events = num_events,
  295|  57.9k|        .event_mask = (1ULL << INTERNAL_EVENT_BASE) - 1, // exclude internal events
  296|  57.9k|        .wakeup_pipe = {-1, -1},
  297|  57.9k|        .is_weak = weak,
  298|  57.9k|    };
  299|  57.9k|    mp_mutex_init(&client->lock);
  300|  57.9k|    mp_mutex_init(&client->wakeup_lock);
  301|  57.9k|    mp_cond_init(&client->wakeup);
  302|       |
  303|  57.9k|    snprintf(client->name, sizeof(client->name), "%s", nname);
  304|       |
  305|  57.9k|    clients->clients_list_change_ts += 1;
  306|  57.9k|    MP_TARRAY_APPEND(clients, clients->clients, clients->num_clients, client);
  ------------------
  |  |  105|  57.9k|    do {                                            \
  |  |  106|  57.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.9k|    do {                                            \
  |  |  |  |   97|  57.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  57.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.9k|        (idxvar)++;                                 \
  |  |  109|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
  307|       |
  308|  57.9k|    if (clients->num_clients == 1 && !clients->mpctx->is_cli)
  ------------------
  |  Branch (308:9): [True: 28.9k, False: 28.9k]
  |  Branch (308:38): [True: 28.9k, False: 0]
  ------------------
  309|  28.9k|        client->fuzzy_initialized = true;
  310|       |
  311|  57.9k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  312|       |
  313|  57.9k|    mpv_request_event(client, MPV_EVENT_TICK, 0);
  314|       |
  315|  57.9k|    return client;
  316|  57.9k|}
client.c:wait_wakeup:
  364|   293k|{
  365|   293k|    int r = 0;
  366|   293k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   293k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  367|   293k|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|   293k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  368|   293k|    if (!ctx->need_wakeup)
  ------------------
  |  Branch (368:9): [True: 272k, False: 20.2k]
  ------------------
  369|   272k|        r = mp_cond_timedwait_until(&ctx->wakeup, &ctx->wakeup_lock, end);
  370|   293k|    if (r == 0)
  ------------------
  |  Branch (370:9): [True: 293k, False: 1]
  ------------------
  371|   293k|        ctx->need_wakeup = false;
  372|   293k|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|   293k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  373|   293k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   293k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  374|   293k|    return r;
  375|   293k|}
client.c:mp_destroy_client:
  430|  57.9k|{
  431|  57.9k|    if (!ctx)
  ------------------
  |  Branch (431:9): [True: 0, False: 57.9k]
  ------------------
  432|      0|        return;
  433|       |
  434|  57.9k|    struct MPContext *mpctx = ctx->mpctx;
  435|  57.9k|    struct mp_client_api *clients = ctx->clients;
  436|       |
  437|  57.9k|    MP_DBG(ctx, "Destroying client handle...\n");
  ------------------
  |  |   93|  57.9k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  57.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|  57.9k|    if (terminate)
  ------------------
  |  Branch (439:9): [True: 28.9k, False: 28.9k]
  ------------------
  440|  28.9k|        mpv_command(ctx, (const char*[]){"quit", NULL});
  441|       |
  442|  57.9k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  443|       |
  444|  57.9k|    ctx->destroying = true;
  445|       |
  446|  57.9k|    for (int n = 0; n < ctx->num_properties; n++)
  ------------------
  |  Branch (446:21): [True: 0, False: 57.9k]
  ------------------
  447|      0|        prop_unref(ctx->properties[n]);
  448|  57.9k|    ctx->num_properties = 0;
  449|  57.9k|    ctx->properties_change_ts += 1;
  450|       |
  451|  57.9k|    prop_unref(ctx->cur_property);
  452|  57.9k|    ctx->cur_property = NULL;
  453|       |
  454|  57.9k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  455|       |
  456|  57.9k|    abort_async(mpctx, ctx, 0, 0);
  457|       |
  458|       |    // reserved_events equals the number of asynchronous requests that weren't
  459|       |    // yet replied. In order to avoid that trying to reply to a removed client
  460|       |    // causes a crash, block until all asynchronous requests were served.
  461|  57.9k|    mpv_wait_async_requests(ctx);
  462|       |
  463|  57.9k|    osd_set_external_remove_owner(mpctx->osd, ctx);
  464|  57.9k|    mp_input_remove_sections_by_owner(mpctx->input, ctx->name);
  465|       |
  466|  57.9k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  467|       |
  468|  86.8k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (468:21): [True: 86.8k, False: 0]
  ------------------
  469|  86.8k|        if (clients->clients[n] == ctx) {
  ------------------
  |  Branch (469:13): [True: 57.9k, False: 28.9k]
  ------------------
  470|  57.9k|            clients->clients_list_change_ts += 1;
  471|  57.9k|            MP_TARRAY_REMOVE_AT(clients->clients, clients->num_clients, n);
  ------------------
  |  |  143|  57.9k|    do {                                            \
  |  |  144|  57.9k|        size_t at_ = (at);                          \
  |  |  145|  57.9k|        assert(at_ < (idxvar));                     \
  |  |  146|  57.9k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  57.9k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  57.9k|        (idxvar)--;                                 \
  |  |  149|  57.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 57.9k]
  |  |  ------------------
  ------------------
  |  Branch (471:13): [True: 57.9k, False: 0]
  ------------------
  472|  57.9k|            while (ctx->num_events) {
  ------------------
  |  Branch (472:20): [True: 50, False: 57.9k]
  ------------------
  473|     50|                talloc_free(ctx->events[ctx->first_event].data);
  ------------------
  |  |   47|     50|#define talloc_free                     ta_free
  ------------------
  474|     50|                ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  475|     50|                ctx->num_events--;
  476|     50|            }
  477|  57.9k|            mp_msg_log_buffer_destroy(ctx->messages);
  478|  57.9k|            mp_cond_destroy(&ctx->wakeup);
  479|  57.9k|            mp_mutex_destroy(&ctx->wakeup_lock);
  ------------------
  |  |  133|  57.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  480|  57.9k|            mp_mutex_destroy(&ctx->lock);
  ------------------
  |  |  133|  57.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  481|  57.9k|            if (ctx->wakeup_pipe[0] != -1) {
  ------------------
  |  Branch (481:17): [True: 0, False: 57.9k]
  ------------------
  482|      0|                close(ctx->wakeup_pipe[0]);
  483|      0|                close(ctx->wakeup_pipe[1]);
  484|      0|            }
  485|  57.9k|            talloc_free(ctx);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
  486|  57.9k|            ctx = NULL;
  487|  57.9k|            break;
  488|  57.9k|        }
  489|  86.8k|    }
  490|  57.9k|    mp_assert(!ctx);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (490:5): [True: 57.9k, False: 0]
  ------------------
  491|       |
  492|  57.9k|    if (mpctx->is_cli) {
  ------------------
  |  Branch (492:9): [True: 0, False: 57.9k]
  ------------------
  493|      0|        terminate = false;
  494|  57.9k|    } else {
  495|       |        // If the last strong mpv_handle got destroyed, destroy the core.
  496|  57.9k|        bool has_strong_ref = false;
  497|  86.8k|        for (int n = 0; n < clients->num_clients; n++)
  ------------------
  |  Branch (497:25): [True: 28.9k, False: 57.9k]
  ------------------
  498|  28.9k|            has_strong_ref |= !clients->clients[n]->is_weak;
  499|  57.9k|        if (!has_strong_ref)
  ------------------
  |  Branch (499:13): [True: 28.9k, False: 28.9k]
  ------------------
  500|  28.9k|            terminate = true;
  501|       |
  502|       |        // Reserve the right to destroy mpctx for us.
  503|  57.9k|        if (clients->have_terminator)
  ------------------
  |  Branch (503:13): [True: 0, False: 57.9k]
  ------------------
  504|      0|            terminate = false;
  505|  57.9k|        clients->have_terminator |= terminate;
  506|  57.9k|    }
  507|       |
  508|       |    // mp_shutdown_clients() sleeps to avoid wasting CPU.
  509|       |    // mp_hook_test_completion() also relies on this a bit.
  510|  57.9k|    mp_wakeup_core(mpctx);
  511|       |
  512|  57.9k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  513|       |
  514|       |    // Note that even if num_clients==0, having set have_terminator keeps mpctx
  515|       |    // and the core thread alive.
  516|  57.9k|    if (terminate) {
  ------------------
  |  Branch (516:9): [True: 28.9k, False: 28.9k]
  ------------------
  517|       |        // Make sure the core stops playing files etc. Being able to lock the
  518|       |        // dispatch queue requires that the core thread is still active.
  519|  28.9k|        mp_dispatch_lock(mpctx->dispatch);
  520|  28.9k|        mpctx->stop_play = PT_QUIT;
  521|  28.9k|        mp_dispatch_unlock(mpctx->dispatch);
  522|       |
  523|       |        // Ask the core thread to stop.
  524|  28.9k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  525|  28.9k|        clients->terminate_core_thread = true;
  526|  28.9k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  527|  28.9k|        mp_wakeup_core(mpctx);
  528|       |
  529|       |        // Blocking wait for all clients and core thread to terminate.
  530|  28.9k|        mp_thread_join(mpctx->core_thread);
  ------------------
  |  |  215|  28.9k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  531|       |
  532|  28.9k|        mp_destroy(mpctx);
  533|  28.9k|    }
  534|  57.9k|}
client.c:abort_async:
  410|  57.9k|{
  411|  57.9k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  412|       |
  413|       |    // Destroy all => ensure any newly appearing work is aborted immediately.
  414|  57.9k|    if (ctx == NULL)
  ------------------
  |  Branch (414:9): [True: 0, False: 57.9k]
  ------------------
  415|      0|        mpctx->abort_all = true;
  416|       |
  417|  57.9k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (417:21): [True: 0, False: 57.9k]
  ------------------
  418|      0|        struct mp_abort_entry *abort = mpctx->abort_list[n];
  419|      0|        if (!ctx || (abort->client == ctx && (!type ||
  ------------------
  |  Branch (419:13): [True: 0, False: 0]
  |  Branch (419:22): [True: 0, False: 0]
  |  Branch (419:47): [True: 0, False: 0]
  ------------------
  420|      0|            (abort->client_work_type == type && abort->client_work_id == id))))
  ------------------
  |  Branch (420:14): [True: 0, False: 0]
  |  Branch (420:49): [True: 0, False: 0]
  ------------------
  421|      0|        {
  422|      0|            mp_abort_trigger_locked(mpctx, abort);
  423|      0|        }
  424|      0|    }
  425|       |
  426|  57.9k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  427|  57.9k|}
client.c:create_core:
  615|  28.9k|{
  616|  28.9k|    struct MPContext *mpctx = mp_create();
  617|  28.9k|    if (!mpctx)
  ------------------
  |  Branch (617:9): [True: 0, False: 28.9k]
  ------------------
  618|      0|        return NULL;
  619|       |
  620|  28.9k|    m_config_set_profile(mpctx->mconfig, "libmpv", 0);
  621|       |
  622|  28.9k|    mpv_handle *ctx = new_client(mpctx->clients, "main", weak);
  623|  28.9k|    if (!ctx) {
  ------------------
  |  Branch (623:9): [True: 0, False: 28.9k]
  ------------------
  624|      0|        mp_destroy(mpctx);
  625|      0|        return NULL;
  626|      0|    }
  627|       |
  628|  28.9k|    if (mp_thread_create(&mpctx->core_thread, core_thread, mpctx) != 0) {
  ------------------
  |  |  214|  28.9k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (628:9): [True: 0, False: 28.9k]
  ------------------
  629|      0|        ctx->clients->have_terminator = true; // avoid blocking
  630|      0|        mpv_terminate_destroy(ctx);
  631|      0|        mp_destroy(mpctx);
  632|      0|        return NULL;
  633|      0|    }
  634|       |
  635|  28.9k|    return ctx;
  636|  28.9k|}
client.c:core_thread:
  595|  28.9k|{
  596|  28.9k|    struct MPContext *mpctx = p;
  597|       |
  598|  28.9k|    mp_thread_set_name("core");
  599|       |
  600|  63.3k|    while (!mpctx->initialized && mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (600:12): [True: 34.3k, False: 28.9k]
  |  Branch (600:35): [True: 34.3k, False: 0]
  ------------------
  601|  34.3k|        mp_idle(mpctx);
  602|       |
  603|  28.9k|    if (mpctx->initialized)
  ------------------
  |  Branch (603:9): [True: 28.9k, False: 0]
  ------------------
  604|  28.9k|        mp_play_files(mpctx);
  605|       |
  606|       |    // This actually waits until all clients are gone before actually
  607|       |    // destroying mpctx. Actual destruction is done by whatever destroys
  608|       |    // the last mpv_handle.
  609|  28.9k|    mp_shutdown_clients(mpctx);
  610|       |
  611|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  28.9k|#define MP_THREAD_RETURN() return NULL
  ------------------
  612|  28.9k|}
client.c:lock_core:
  388|   376k|{
  389|   376k|    mp_dispatch_lock(ctx->mpctx->dispatch);
  390|   376k|}
client.c:unlock_core:
  393|   376k|{
  394|   376k|    mp_dispatch_unlock(ctx->mpctx->dispatch);
  395|   376k|}
client.c:send_event:
  749|   887k|{
  750|   887k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   887k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  751|   887k|    uint64_t mask = 1ULL << event->event_id;
  752|   887k|    if (ctx->property_event_masks & mask)
  ------------------
  |  Branch (752:9): [True: 312k, False: 574k]
  ------------------
  753|   312k|        notify_property_events(ctx, event->event_id);
  754|   887k|    int r;
  755|   887k|    if (!(ctx->event_mask & mask)) {
  ------------------
  |  Branch (755:9): [True: 424k, False: 462k]
  ------------------
  756|   424k|        r = 0;
  757|   462k|    } else if (ctx->choked) {
  ------------------
  |  Branch (757:16): [True: 0, False: 462k]
  ------------------
  758|      0|        r = -1;
  759|   462k|    } else {
  760|   462k|        r = append_event(ctx, *event, copy);
  761|   462k|        if (r < 0) {
  ------------------
  |  Branch (761:13): [True: 0, False: 462k]
  ------------------
  762|      0|            MP_ERR(ctx, "Too many events queued.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  763|      0|            ctx->choked = true;
  764|      0|        }
  765|   462k|    }
  766|   887k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   887k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  767|   887k|    return r;
  768|   887k|}
client.c:notify_property_events:
 1674|   312k|{
 1675|   312k|    uint64_t mask = 1ULL << event;
 1676|   312k|    for (int i = 0; i < ctx->num_properties; i++) {
  ------------------
  |  Branch (1676:21): [True: 8, False: 312k]
  ------------------
 1677|      8|        if (ctx->properties[i]->event_mask & mask) {
  ------------------
  |  Branch (1677:13): [True: 8, False: 0]
  ------------------
 1678|      8|            ctx->properties[i]->change_ts += 1;
 1679|      8|            ctx->has_pending_properties = true;
 1680|      8|        }
 1681|      8|    }
 1682|       |
 1683|       |    // Same as in mp_client_property_change().
 1684|   312k|    if (ctx->has_pending_properties)
  ------------------
  |  Branch (1684:9): [True: 8, False: 312k]
  ------------------
 1685|      8|        mp_dispatch_adjust_timeout(ctx->mpctx->dispatch, 0);
 1686|   312k|}
client.c:append_event:
  735|   462k|{
  736|   462k|    if (ctx->num_events + ctx->reserved_events >= ctx->max_events)
  ------------------
  |  Branch (736:9): [True: 0, False: 462k]
  ------------------
  737|      0|        return -1;
  738|   462k|    if (copy)
  ------------------
  |  Branch (738:9): [True: 462k, False: 0]
  ------------------
  739|   462k|        dup_event_data(&event);
  740|   462k|    ctx->events[(ctx->first_event + ctx->num_events) % ctx->max_events] = event;
  741|   462k|    ctx->num_events++;
  742|   462k|    wakeup_client(ctx);
  743|   462k|    if (event.event_id == MPV_EVENT_SHUTDOWN)
  ------------------
  |  Branch (743:9): [True: 28.8k, False: 433k]
  ------------------
  744|  28.8k|        ctx->event_mask &= ctx->event_mask & ~(1ULL << MPV_EVENT_SHUTDOWN);
  745|   462k|    return 0;
  746|   462k|}
client.c:find_client:
  234|  57.9k|{
  235|  57.9k|    if (name[0] == '@') {
  ------------------
  |  Branch (235:9): [True: 0, False: 57.9k]
  ------------------
  236|      0|        char *end;
  237|      0|        errno = 0;
  238|      0|        long long int id = strtoll(name + 1, &end, 10);
  239|      0|        if (errno || end[0])
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  |  Branch (239:22): [True: 0, False: 0]
  ------------------
  240|      0|            return NULL;
  241|      0|        return find_client_id(clients, id);
  242|      0|    }
  243|       |
  244|  86.8k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (244:21): [True: 28.9k, False: 57.9k]
  ------------------
  245|  28.9k|        if (strcmp(clients->clients[n]->name, name) == 0)
  ------------------
  |  Branch (245:13): [True: 0, False: 28.9k]
  ------------------
  246|      0|            return clients->clients[n];
  247|  28.9k|    }
  248|       |
  249|  57.9k|    return NULL;
  250|  57.9k|}
client.c:dup_event_data:
  691|   462k|{
  692|   462k|    switch (ev->event_id) {
  693|      0|    case MPV_EVENT_CLIENT_MESSAGE: {
  ------------------
  |  Branch (693:5): [True: 0, False: 462k]
  ------------------
  694|      0|        struct mpv_event_client_message *src = ev->data;
  695|      0|        struct mpv_event_client_message *msg =
  696|      0|            talloc_zero(NULL, struct mpv_event_client_message);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|      0|        for (int n = 0; n < src->num_args; n++) {
  ------------------
  |  Branch (697:25): [True: 0, False: 0]
  ------------------
  698|      0|            MP_TARRAY_APPEND(msg, msg->args, msg->num_args,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  699|      0|                             talloc_strdup(msg, src->args[n]));
  700|      0|        }
  701|      0|        ev->data = msg;
  702|      0|        break;
  703|      0|    }
  704|   133k|    case MPV_EVENT_START_FILE:
  ------------------
  |  Branch (704:5): [True: 133k, False: 328k]
  ------------------
  705|   133k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_start_file));
  ------------------
  |  |   49|   133k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   133k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   133k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   133k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   133k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  706|   133k|        break;
  707|   133k|    case MPV_EVENT_END_FILE:
  ------------------
  |  Branch (707:5): [True: 133k, False: 328k]
  ------------------
  708|   133k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_end_file));
  ------------------
  |  |   49|   133k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   133k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   133k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   133k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   133k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|   133k|        break;
  710|   194k|    default:
  ------------------
  |  Branch (710:5): [True: 194k, False: 267k]
  ------------------
  711|       |        // Doesn't use events with memory allocation.
  712|   194k|        if (ev->data)
  ------------------
  |  Branch (712:13): [True: 0, False: 194k]
  ------------------
  713|      0|            abort();
  714|   462k|    }
  715|   462k|}
client.c:wakeup_client:
  349|   520k|{
  350|   520k|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|   520k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  351|   520k|    if (!ctx->need_wakeup) {
  ------------------
  |  Branch (351:9): [True: 293k, False: 226k]
  ------------------
  352|   293k|        ctx->need_wakeup = true;
  353|   293k|        mp_cond_broadcast(&ctx->wakeup);
  354|   293k|        if (ctx->wakeup_cb)
  ------------------
  |  Branch (354:13): [True: 0, False: 293k]
  ------------------
  355|      0|            ctx->wakeup_cb(ctx->wakeup_cb_ctx);
  356|   293k|        if (ctx->wakeup_pipe[0] != -1)
  ------------------
  |  Branch (356:13): [True: 0, False: 293k]
  ------------------
  357|      0|            (void)write(ctx->wakeup_pipe[1], &(char){0}, 1);
  358|   293k|    }
  359|   520k|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|   520k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  360|   520k|}
client.c:get_mp_type:
  997|   318k|{
  998|   318k|    if ((unsigned)format >= MP_ARRAY_SIZE(type_conv))
  ------------------
  |  |   49|   318k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (998:9): [True: 0, False: 318k]
  ------------------
  999|      0|        return NULL;
 1000|   318k|    if (!type_conv[format].type)
  ------------------
  |  Branch (1000:9): [True: 57.9k, False: 260k]
  ------------------
 1001|  57.9k|        return NULL;
 1002|   260k|    return &type_conv[format];
 1003|   318k|}
client.c:run_client_command:
 1126|  86.8k|{
 1127|  86.8k|    if (!cmd)
  ------------------
  |  Branch (1127:9): [True: 0, False: 86.8k]
  ------------------
 1128|      0|        return MPV_ERROR_INVALID_PARAMETER;
 1129|  86.8k|    if (!ctx->mpctx->initialized) {
  ------------------
  |  Branch (1129:9): [True: 0, False: 86.8k]
  ------------------
 1130|      0|        talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1131|      0|        return MPV_ERROR_UNINITIALIZED;
 1132|      0|    }
 1133|       |
 1134|  86.8k|    cmd->sender = ctx->name;
 1135|       |
 1136|  86.8k|    struct cmd_request req = {
 1137|  86.8k|        .mpctx = ctx->mpctx,
 1138|  86.8k|        .cmd = cmd,
 1139|  86.8k|        .res = res,
 1140|  86.8k|        .completion = MP_WAITER_INITIALIZER,
  ------------------
  |  |   19|  86.8k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  86.8k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  86.8k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  86.8k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  86.8k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  86.8k|    }
  ------------------
 1141|  86.8k|    };
 1142|       |
 1143|  86.8k|    bool async = cmd->flags & MP_ASYNC_CMD;
 1144|       |
 1145|  86.8k|    lock_core(ctx);
 1146|  86.8k|    if (async) {
  ------------------
  |  Branch (1146:9): [True: 0, False: 86.8k]
  ------------------
 1147|      0|        run_command(ctx->mpctx, cmd, NULL, NULL, NULL);
 1148|  86.8k|    } else {
 1149|  86.8k|        struct mp_abort_entry *abort = NULL;
 1150|  86.8k|        if (cmd->def->can_abort) {
  ------------------
  |  Branch (1150:13): [True: 0, False: 86.8k]
  ------------------
 1151|      0|            abort = talloc_zero(NULL, struct mp_abort_entry);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|      0|            abort->client = ctx;
 1153|      0|        }
 1154|  86.8k|        run_command(ctx->mpctx, cmd, abort, cmd_complete, &req);
 1155|  86.8k|    }
 1156|  86.8k|    unlock_core(ctx);
 1157|       |
 1158|  86.8k|    if (!async)
  ------------------
  |  Branch (1158:9): [True: 86.8k, False: 0]
  ------------------
 1159|  86.8k|        mp_waiter_wait(&req.completion);
 1160|       |
 1161|  86.8k|    return req.status;
 1162|  86.8k|}
client.c:cmd_complete:
 1112|  86.8k|{
 1113|  86.8k|    struct cmd_request *req = cmd->on_completion_priv;
 1114|       |
 1115|  86.8k|    req->status = cmd->success ? 0 : MPV_ERROR_COMMAND;
  ------------------
  |  Branch (1115:19): [True: 86.8k, False: 0]
  ------------------
 1116|  86.8k|    if (req->res) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 86.8k]
  ------------------
 1117|      0|        *req->res = cmd->result;
 1118|      0|        cmd->result = (mpv_node){0};
 1119|      0|    }
 1120|       |
 1121|       |    // Unblock the waiting thread (especially for async commands).
 1122|  86.8k|    mp_waiter_wakeup(&req->completion, 0);
 1123|  86.8k|}
client.c:get_mp_type_get:
 1007|  57.9k|{
 1008|  57.9k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1008:9): [True: 0, False: 57.9k]
  ------------------
 1009|      0|        format = MPV_FORMAT_STRING; // it's string data, just other semantics
 1010|  57.9k|    return get_mp_type(format);
 1011|  57.9k|}
client.c:property_free:
 1545|  57.9k|{
 1546|  57.9k|    struct observe_property *prop = p;
 1547|       |
 1548|  57.9k|    mp_assert(prop->refcount == 0);
  ------------------
  |  |   41|  57.9k|#define mp_assert assert
  ------------------
  |  Branch (1548:5): [True: 57.9k, False: 0]
  ------------------
 1549|       |
 1550|  57.9k|    if (prop->type) {
  ------------------
  |  Branch (1550:9): [True: 0, False: 57.9k]
  ------------------
 1551|      0|        m_option_free(prop->type, &prop->value);
 1552|      0|        m_option_free(prop->type, &prop->value_ret);
 1553|      0|    }
 1554|  57.9k|}
client.c:prop_unref:
  169|   144k|{
  170|   144k|    if (!prop)
  ------------------
  |  Branch (170:9): [True: 57.9k, False: 87.0k]
  ------------------
  171|  57.9k|        return;
  172|       |
  173|  87.0k|    mp_assert(prop->refcount > 0);
  ------------------
  |  |   41|  87.0k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 87.0k, False: 0]
  ------------------
  174|  87.0k|    prop->refcount -= 1;
  175|  87.0k|    if (!prop->refcount)
  ------------------
  |  Branch (175:9): [True: 57.9k, False: 29.0k]
  ------------------
  176|  57.9k|        talloc_free(prop);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
  177|  87.0k|}
client.c:send_client_property_changes:
 1690|  57.8k|{
 1691|  57.8k|    uint64_t cur_ts = ctx->properties_change_ts;
 1692|       |
 1693|  57.8k|    ctx->has_pending_properties = false;
 1694|       |
 1695|   115k|    for (int n = 0; n < ctx->num_properties; n++) {
  ------------------
  |  Branch (1695:21): [True: 57.7k, False: 57.8k]
  ------------------
 1696|  57.7k|        struct observe_property *prop = ctx->properties[n];
 1697|       |
 1698|  57.7k|        if (prop->value_ts == prop->change_ts)
  ------------------
  |  Branch (1698:13): [True: 0, False: 57.7k]
  ------------------
 1699|      0|            continue;
 1700|       |
 1701|  57.7k|        bool changed = false;
 1702|  57.7k|        if (prop->format) {
  ------------------
  |  Branch (1702:13): [True: 0, False: 57.7k]
  ------------------
 1703|      0|            const struct m_option *type = prop->type;
 1704|      0|            union m_option_value val = m_option_value_default;
 1705|      0|            struct getproperty_request req = {
 1706|      0|                .mpctx = ctx->mpctx,
 1707|      0|                .name = prop->name,
 1708|      0|                .format = prop->format,
 1709|      0|                .data = &val,
 1710|      0|            };
 1711|       |
 1712|       |            // Temporarily unlock and read the property. The very important
 1713|       |            // thing is that property getters can do whatever they want, _and_
 1714|       |            // that they may wait on the client API user thread (if vo_libmpv
 1715|       |            // or similar things are involved).
 1716|      0|            prop->refcount += 1; // keep prop alive (esp. prop->name)
 1717|      0|            ctx->async_counter += 1; // keep ctx alive
 1718|      0|            mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1719|      0|            getproperty_fn(&req);
 1720|      0|            mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1721|      0|            ctx->async_counter -= 1;
 1722|      0|            prop_unref(prop);
 1723|       |
 1724|       |            // Set if observed properties was changed or something similar
 1725|       |            // => start over, retry next time.
 1726|      0|            if (cur_ts != ctx->properties_change_ts || ctx->destroying) {
  ------------------
  |  Branch (1726:17): [True: 0, False: 0]
  |  Branch (1726:56): [True: 0, False: 0]
  ------------------
 1727|      0|                m_option_free(type, &val);
 1728|      0|                mp_wakeup_core(ctx->mpctx);
 1729|      0|                ctx->has_pending_properties = true;
 1730|      0|                break;
 1731|      0|            }
 1732|      0|            mp_assert(prop->refcount > 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1732:13): [True: 0, False: 0]
  ------------------
 1733|       |
 1734|      0|            bool val_valid = req.status >= 0;
 1735|      0|            changed = prop->value_valid != val_valid;
 1736|      0|            if (prop->value_valid && val_valid)
  ------------------
  |  Branch (1736:17): [True: 0, False: 0]
  |  Branch (1736:38): [True: 0, False: 0]
  ------------------
 1737|      0|                changed = !equal_mpv_value(&prop->value, &val, prop->format);
 1738|      0|            if (prop->value_ts == 0)
  ------------------
  |  Branch (1738:17): [True: 0, False: 0]
  ------------------
 1739|      0|                changed = true; // initial event
 1740|       |
 1741|      0|            prop->value_valid = val_valid;
 1742|      0|            if (changed && val_valid) {
  ------------------
  |  Branch (1742:17): [True: 0, False: 0]
  |  Branch (1742:28): [True: 0, False: 0]
  ------------------
 1743|       |                // move val to prop->value
 1744|      0|                m_option_free(type, &prop->value);
 1745|      0|                memcpy(&prop->value, &val, type->type->size);
 1746|      0|                memset(&val, 0, type->type->size);
 1747|      0|            }
 1748|       |
 1749|      0|            m_option_free(prop->type, &val);
 1750|  57.7k|        } else {
 1751|  57.7k|            changed = true;
 1752|  57.7k|        }
 1753|       |
 1754|  57.7k|        if (prop->waiting_for_hook)
  ------------------
  |  Branch (1754:13): [True: 0, False: 57.7k]
  ------------------
 1755|      0|            ctx->new_property_events = true; // make sure to wakeup
 1756|       |
 1757|       |        // Avoid retriggering the change event if the property didn't change,
 1758|       |        // and the previous value was actually returned to the client.
 1759|  57.7k|        if (!changed && prop->value_ret_ts == prop->value_ts) {
  ------------------
  |  Branch (1759:13): [True: 0, False: 57.7k]
  |  Branch (1759:25): [True: 0, False: 0]
  ------------------
 1760|      0|            prop->value_ret_ts = prop->change_ts; // no change => no event
 1761|      0|            prop->waiting_for_hook = false;
 1762|  57.7k|        } else {
 1763|  57.7k|            ctx->new_property_events = true;
 1764|  57.7k|        }
 1765|       |
 1766|  57.7k|        prop->value_ts = prop->change_ts;
 1767|  57.7k|    }
 1768|       |
 1769|  57.8k|    if (ctx->destroying || ctx->new_property_events)
  ------------------
  |  Branch (1769:9): [True: 0, False: 57.8k]
  |  Branch (1769:28): [True: 57.7k, False: 92]
  ------------------
 1770|  57.7k|        wakeup_client(ctx);
 1771|  57.8k|}
client.c:gen_property_change_event:
 1806|   322k|{
 1807|   322k|    if (!ctx->mpctx->initialized)
  ------------------
  |  Branch (1807:9): [True: 0, False: 322k]
  ------------------
 1808|      0|        return false;
 1809|       |
 1810|   437k|    while (1) {
  ------------------
  |  Branch (1810:12): [True: 437k, Folded]
  ------------------
 1811|   437k|        if (ctx->cur_property_index >= ctx->num_properties) {
  ------------------
  |  Branch (1811:13): [True: 379k, False: 57.8k]
  ------------------
 1812|   379k|            ctx->new_property_events &= ctx->num_properties > 0;
 1813|   379k|            if (!ctx->new_property_events)
  ------------------
  |  Branch (1813:17): [True: 293k, False: 86.8k]
  ------------------
 1814|   293k|                break;
 1815|  86.8k|            ctx->new_property_events = false;
 1816|  86.8k|            ctx->cur_property_index = 0;
 1817|  86.8k|        }
 1818|       |
 1819|   144k|        struct observe_property *prop = ctx->properties[ctx->cur_property_index++];
 1820|       |
 1821|   144k|        if (prop->value_ts == prop->change_ts &&    // not a stale value?
  ------------------
  |  Branch (1821:13): [True: 29.0k, False: 115k]
  ------------------
 1822|  29.0k|            prop->value_ret_ts != prop->value_ts)   // other value than last time?
  ------------------
  |  Branch (1822:13): [True: 29.0k, False: 0]
  ------------------
 1823|  29.0k|        {
 1824|  29.0k|            prop->value_ret_ts = prop->value_ts;
 1825|  29.0k|            prop->waiting_for_hook = false;
 1826|  29.0k|            prop_unref(ctx->cur_property);
 1827|  29.0k|            ctx->cur_property = prop;
 1828|  29.0k|            prop->refcount += 1;
 1829|       |
 1830|  29.0k|            if (prop->value_valid)
  ------------------
  |  Branch (1830:17): [True: 0, False: 29.0k]
  ------------------
 1831|      0|                m_option_copy(prop->type, &prop->value_ret, &prop->value);
 1832|       |
 1833|  29.0k|            ctx->cur_property_event = (struct mpv_event_property){
 1834|  29.0k|                .name = prop->name,
 1835|  29.0k|                .format = prop->value_valid ? prop->format : 0,
  ------------------
  |  Branch (1835:27): [True: 0, False: 29.0k]
  ------------------
 1836|  29.0k|                .data = prop->value_valid ? &prop->value_ret : NULL,
  ------------------
  |  Branch (1836:25): [True: 0, False: 29.0k]
  ------------------
 1837|  29.0k|            };
 1838|  29.0k|            *ctx->cur_event = (struct mpv_event){
 1839|  29.0k|                .event_id = MPV_EVENT_PROPERTY_CHANGE,
 1840|  29.0k|                .reply_userdata = prop->reply_id,
 1841|  29.0k|                .data = &ctx->cur_property_event,
 1842|  29.0k|            };
 1843|  29.0k|            return true;
 1844|  29.0k|        }
 1845|   144k|    }
 1846|       |
 1847|   293k|    return false;
 1848|   322k|}
client.c:gen_log_message_event:
 1928|   293k|{
 1929|   293k|    if (ctx->messages) {
  ------------------
  |  Branch (1929:9): [True: 0, False: 293k]
  ------------------
 1930|      0|        struct mp_log_buffer_entry *msg =
 1931|      0|            mp_msg_log_buffer_read(ctx->messages);
 1932|      0|        if (msg) {
  ------------------
  |  Branch (1932:13): [True: 0, False: 0]
  ------------------
 1933|      0|            struct mpv_event_log_message *cmsg =
 1934|      0|                talloc_ptrtype(ctx->cur_event, cmsg);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1935|      0|            talloc_steal(cmsg, msg);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1936|      0|            *cmsg = (struct mpv_event_log_message){
 1937|      0|                .prefix = msg->prefix,
 1938|      0|                .level = mp_log_levels[msg->level],
 1939|      0|                .log_level = mp_mpv_log_levels[msg->level],
 1940|      0|                .text = msg->text,
 1941|      0|            };
 1942|      0|            *ctx->cur_event = (struct mpv_event){
 1943|      0|                .event_id = MPV_EVENT_LOG_MESSAGE,
 1944|      0|                .data = cmsg,
 1945|      0|            };
 1946|      0|            return true;
 1947|      0|        }
 1948|      0|    }
 1949|   293k|    return false;
 1950|   293k|}

clipboard-vo.c:init:
   29|  28.9k|{
   30|  28.9k|    struct clipboard_vo_priv *priv = talloc_ptrtype(cl, priv);
  ------------------
  |  |   34|  28.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  28.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   31|  28.9k|    priv->mpctx = params->mpctx;
   32|  28.9k|    priv->log = mp_log_new(priv, cl->log, "vo"),
   33|  28.9k|    cl->priv = priv;
   34|  28.9k|    return CLIPBOARD_SUCCESS;
   35|  28.9k|}

mp_clipboard_destroy:
  131|  57.9k|{
  132|  57.9k|    mp_mutex_lock(&cl->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  133|  57.9k|    if (cl->backend && cl->backend->uninit)
  ------------------
  |  Branch (133:9): [True: 28.9k, False: 28.9k]
  |  Branch (133:24): [True: 0, False: 28.9k]
  ------------------
  134|      0|        cl->backend->uninit(cl);
  135|  57.9k|    cl->backend = cl->priv = NULL;
  136|  57.9k|    mp_mutex_unlock(&cl->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  137|  57.9k|}
mp_clipboard_data_changed:
  140|   432k|{
  141|   432k|    if (cl->backend && cl->backend->data_changed && cl->monitor)
  ------------------
  |  Branch (141:9): [True: 398k, False: 34.3k]
  |  Branch (141:24): [True: 0, False: 398k]
  |  Branch (141:53): [True: 0, False: 0]
  ------------------
  142|      0|        return cl->backend->data_changed(cl);
  143|   432k|    return false;
  144|   432k|}
reinit_clipboard:
  194|  28.9k|{
  195|  28.9k|    mp_clipboard_destroy(mpctx->clipboard);
  196|       |
  197|  28.9k|    struct clipboard_opts *opts = mp_get_config_group(NULL, mpctx->global, &clipboard_conf);
  198|  28.9k|    if (opts->backends && opts->backends[0].name) {
  ------------------
  |  Branch (198:9): [True: 28.9k, False: 0]
  |  Branch (198:27): [True: 28.9k, False: 0]
  ------------------
  199|  28.9k|        struct clipboard_init_params params = {
  200|  28.9k|            .mpctx = mpctx,
  201|  28.9k|            .backends = opts->backends,
  202|  28.9k|        };
  203|  28.9k|        params.flags |= opts->monitor ? CLIPBOARD_INIT_ENABLE_MONITORING : 0;
  ------------------
  |  |   28|      0|#define CLIPBOARD_INIT_ENABLE_MONITORING (1 << 0)
  ------------------
  |  Branch (203:25): [True: 0, False: 28.9k]
  ------------------
  204|  28.9k|        params.flags |= opts->xwayland ? CLIPBOARD_INIT_ENABLE_XWAYLAND : 0;
  ------------------
  |  |   29|      0|#define CLIPBOARD_INIT_ENABLE_XWAYLAND   (1 << 1)
  ------------------
  |  Branch (204:25): [True: 0, False: 28.9k]
  ------------------
  205|  28.9k|        mp_clipboard_create(mpctx->clipboard, &params);
  206|  28.9k|    }
  207|  28.9k|    talloc_free(opts);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  208|  28.9k|}
clipboard_init:
  217|  28.9k|{
  218|  28.9k|    struct clipboard_ctx *cl = talloc_zero_ptrtype(mpctx, cl);
  ------------------
  |  |   35|  28.9k|#define talloc_zero_ptrtype             ta_xznew_ptrtype
  |  |  ------------------
  |  |  |  |  139|  28.9k|#define ta_xznew_ptrtype(...)           ta_oom_g(ta_znew_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|  28.9k|    talloc_set_destructor(cl, clipboard_destructor);
  ------------------
  |  |   41|  28.9k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  220|  28.9k|    cl->log = mp_log_new(cl, mpctx->global->log, "clipboard");
  221|  28.9k|    mp_mutex_init(&cl->lock);
  222|  28.9k|    mpctx->clipboard = cl;
  223|  28.9k|}
clipboard.c:get_desc:
   56|  57.9k|{
   57|  57.9k|    if (index >= MP_ARRAY_SIZE(clipboard_backend_list))
  ------------------
  |  |   49|  57.9k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (57:9): [True: 28.9k, False: 28.9k]
  ------------------
   58|  28.9k|        return false;
   59|  28.9k|    const struct clipboard_backend *backend = clipboard_backend_list[index];
   60|  28.9k|    *dst = (struct m_obj_desc) {
   61|  28.9k|        .name = backend->name,
   62|  28.9k|        .description = backend->desc,
   63|  28.9k|    };
   64|       |    return true;
   65|  57.9k|}
clipboard.c:mp_clipboard_create:
   99|  28.9k|{
  100|  28.9k|    cl->monitor = params->flags & CLIPBOARD_INIT_ENABLE_MONITORING;
  ------------------
  |  |   28|  28.9k|#define CLIPBOARD_INIT_ENABLE_MONITORING (1 << 0)
  ------------------
  101|       |
  102|   144k|    for (int n = 0; params->backends && params->backends[n].name; n++) {
  ------------------
  |  Branch (102:21): [True: 144k, False: 0]
  |  Branch (102:41): [True: 144k, False: 0]
  ------------------
  103|   144k|        if (!params->backends[n].enabled)
  ------------------
  |  Branch (103:13): [True: 0, False: 144k]
  ------------------
  104|      0|            continue;
  105|   260k|        for (int i = 0; i < MP_ARRAY_SIZE(clipboard_backend_list); i++) {
  ------------------
  |  |   49|   260k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (105:25): [True: 144k, False: 115k]
  ------------------
  106|   144k|            const struct clipboard_backend *backend = clipboard_backend_list[i];
  107|   144k|            if (strcmp(params->backends[n].name, backend->name))
  ------------------
  |  Branch (107:17): [True: 115k, False: 28.9k]
  ------------------
  108|   115k|                continue;
  109|  28.9k|            if (backend->init(cl, params) != CLIPBOARD_SUCCESS)
  ------------------
  |  Branch (109:17): [True: 0, False: 28.9k]
  ------------------
  110|      0|                break;
  111|  28.9k|            mp_mutex_lock(&cl->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  112|  28.9k|            cl->backend = backend;
  113|  28.9k|            mp_mutex_unlock(&cl->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  114|  28.9k|            MP_VERBOSE(cl, "Initialized %s clipboard backend.\n", cl->backend->name);
  ------------------
  |  |   92|  28.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  115|  28.9k|            return;
  116|  28.9k|        }
  117|   144k|    }
  118|       |
  119|      0|    MP_WARN(cl, "Failed to initialize any clipboard backend.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  120|      0|}
clipboard.c:clipboard_destructor:
  211|  28.9k|{
  212|  28.9k|    struct clipboard_ctx *cl = ctx;
  213|  28.9k|    mp_mutex_destroy(&cl->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  214|  28.9k|}

mp_hook_test_completion:
  204|   483k|{
  205|   483k|    struct command_ctx *cmd = mpctx->command_ctx;
  206|   483k|    for (int n = 0; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (206:21): [True: 0, False: 483k]
  ------------------
  207|      0|        struct hook_handler *h = cmd->hooks[n];
  208|      0|        if (h->active && strcmp(h->type, type) == 0) {
  ------------------
  |  Branch (208:13): [True: 0, False: 0]
  |  Branch (208:26): [True: 0, False: 0]
  ------------------
  209|      0|            if (!mp_client_id_exists(mpctx, h->client_id)) {
  ------------------
  |  Branch (209:17): [True: 0, False: 0]
  ------------------
  210|      0|                MP_WARN(mpctx, "client removed during hook handling\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  211|       |                // Trigger completion of this hook and continue with the next one.
  212|      0|                mp_hook_continue(mpctx, h->client_id, h->seq);
  213|      0|                hook_remove(mpctx, h);
  214|      0|            }
  215|      0|            return false;
  216|      0|        }
  217|      0|    }
  218|   483k|    return true;
  219|   483k|}
mp_hook_start:
  269|   483k|{
  270|   483k|    run_next_hook_handler(mpctx, type, 0);
  271|   483k|}
mp_get_property_event_mask:
 5025|  57.9k|{
 5026|  57.9k|    uint64_t mask = 0;
 5027|  2.54M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_event_property_change); n++) {
  ------------------
  |  |   49|  2.54M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (5027:21): [True: 2.49M, False: 57.9k]
  ------------------
 5028|  2.49M|        const char *const *const list = mp_event_property_change[n];
 5029|  10.1M|        for (int i = 0; list && list[i]; i++) {
  ------------------
  |  Branch (5029:25): [True: 9.15M, False: 1.04M]
  |  Branch (5029:33): [True: 7.70M, False: 1.44M]
  ------------------
 5030|  7.70M|            if (match_property(list[i], name))
  ------------------
  |  Branch (5030:17): [True: 289k, False: 7.41M]
  ------------------
 5031|   289k|                mask |= 1ULL << n;
 5032|  7.70M|        }
 5033|  2.49M|    }
 5034|  57.9k|    return mask;
 5035|  57.9k|}
mp_get_property_id:
 5040|   124k|{
 5041|   124k|    struct command_ctx *ctx = mpctx->command_ctx;
 5042|  82.7M|    for (int n = 0; n < ctx->properties.num; n++) {
  ------------------
  |  Branch (5042:21): [True: 82.7M, False: 0]
  ------------------
 5043|  82.7M|        if (match_property(ctx->properties.props[n].name, name))
  ------------------
  |  Branch (5043:13): [True: 124k, False: 82.6M]
  ------------------
 5044|   124k|            return n;
 5045|  82.7M|    }
 5046|      0|    return -1;
 5047|   124k|}
mp_property_expand_string:
 5098|  61.6k|{
 5099|  61.6k|    struct command_ctx *ctx = mpctx->command_ctx;
 5100|  61.6k|    return m_properties_expand_string(&ctx->properties, str, mpctx,
 5101|  61.6k|                                      M_PROPERTY_PRINT);
 5102|  61.6k|}
mp_cmd_ctx_complete:
 5933|  86.8k|{
 5934|  86.8k|    cmd->completed = true;
 5935|  86.8k|    if (!cmd->success)
  ------------------
  |  Branch (5935:9): [True: 0, False: 86.8k]
  ------------------
 5936|      0|        mpv_free_node_contents(&cmd->result);
 5937|  86.8k|    if (cmd->on_completion)
  ------------------
  |  Branch (5937:9): [True: 86.8k, False: 0]
  ------------------
 5938|  86.8k|        cmd->on_completion(cmd);
 5939|  86.8k|    if (cmd->abort)
  ------------------
  |  Branch (5939:9): [True: 0, False: 86.8k]
  ------------------
 5940|      0|        mp_abort_remove(cmd->mpctx, cmd->abort);
 5941|  86.8k|    mpv_free_node_contents(&cmd->result);
 5942|  86.8k|    talloc_free(cmd);
  ------------------
  |  |   47|  86.8k|#define talloc_free                     ta_free
  ------------------
 5943|  86.8k|}
run_command:
 5980|  86.8k|{
 5981|  86.8k|    struct mp_cmd_ctx *ctx = talloc(NULL, struct mp_cmd_ctx);
  ------------------
  |  |   26|  86.8k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  86.8k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  86.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5982|  86.8k|    *ctx = (struct mp_cmd_ctx){
 5983|  86.8k|        .mpctx = mpctx,
 5984|  86.8k|        .cmd = talloc_steal(ctx, cmd),
  ------------------
  |  |   38|  86.8k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  86.8k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5985|  86.8k|        .args = cmd->args,
 5986|  86.8k|        .num_args = cmd->nargs,
 5987|  86.8k|        .priv = cmd->def->priv,
 5988|  86.8k|        .abort = talloc_steal(ctx, abort),
  ------------------
  |  |   38|  86.8k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  86.8k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5989|  86.8k|        .success = true,
 5990|  86.8k|        .completed = true,
 5991|  86.8k|        .on_completion = on_completion,
 5992|  86.8k|        .on_completion_priv = on_completion_priv,
 5993|  86.8k|    };
 5994|       |
 5995|  86.8k|    if (!ctx->abort && cmd->def->can_abort)
  ------------------
  |  Branch (5995:9): [True: 86.8k, False: 0]
  |  Branch (5995:24): [True: 0, False: 86.8k]
  ------------------
 5996|      0|        ctx->abort = talloc_zero(ctx, struct mp_abort_entry);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5997|       |
 5998|  86.8k|    mp_assert(cmd->def->can_abort == !!ctx->abort);
  ------------------
  |  |   41|  86.8k|#define mp_assert assert
  ------------------
  |  Branch (5998:5): [True: 86.8k, False: 0]
  ------------------
 5999|       |
 6000|  86.8k|    if (ctx->abort) {
  ------------------
  |  Branch (6000:9): [True: 0, False: 86.8k]
  ------------------
 6001|      0|        ctx->abort->coupled_to_playback |= cmd->def->abort_on_playback_end;
 6002|      0|        mp_abort_add(mpctx, ctx->abort);
 6003|      0|    }
 6004|       |
 6005|  86.8k|    struct MPOpts *opts = mpctx->opts;
 6006|  86.8k|    ctx->on_osd = cmd->flags & MP_ON_OSD_FLAGS;
 6007|  86.8k|    bool auto_osd = ctx->on_osd == MP_ON_OSD_AUTO;
 6008|  86.8k|    ctx->msg_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_MSG);
  ------------------
  |  Branch (6008:20): [True: 0, False: 86.8k]
  |  Branch (6008:32): [True: 0, False: 86.8k]
  ------------------
 6009|  86.8k|    ctx->bar_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_BAR);
  ------------------
  |  Branch (6009:20): [True: 0, False: 86.8k]
  |  Branch (6009:32): [True: 0, False: 86.8k]
  ------------------
 6010|  86.8k|    ctx->seek_msg_osd = auto_osd ? opts->osd_on_seek & 2 : ctx->msg_osd;
  ------------------
  |  Branch (6010:25): [True: 0, False: 86.8k]
  ------------------
 6011|  86.8k|    ctx->seek_bar_osd = auto_osd ? opts->osd_on_seek & 1 : ctx->bar_osd;
  ------------------
  |  Branch (6011:25): [True: 0, False: 86.8k]
  ------------------
 6012|       |
 6013|  86.8k|    bool noise = cmd->def->is_noisy || cmd->mouse_move;
  ------------------
  |  Branch (6013:18): [True: 0, False: 86.8k]
  |  Branch (6013:40): [True: 0, False: 86.8k]
  ------------------
 6014|  86.8k|    mp_cmd_dump(mpctx->log, noise ? MSGL_TRACE : MSGL_DEBUG, "Run command:", cmd);
  ------------------
  |  Branch (6014:29): [True: 0, False: 86.8k]
  ------------------
 6015|       |
 6016|  86.8k|    if (cmd->flags & MP_EXPAND_PROPERTIES) {
  ------------------
  |  Branch (6016:9): [True: 0, False: 86.8k]
  ------------------
 6017|      0|        for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (6017:25): [True: 0, False: 0]
  ------------------
 6018|      0|            const m_option_type_t *type = cmd->args[n].type->type;
 6019|      0|            char **list = NULL;
 6020|      0|            if (type == CONF_TYPE_STRING)
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  |  Branch (6020:17): [True: 0, False: 0]
  ------------------
 6021|      0|                list = &cmd->args[n].v.s;
 6022|      0|            else if (type == CONF_TYPE_STRING_LIST || type == CONF_TYPE_KV_LIST)
  ------------------
  |  |  245|      0|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
                          else if (type == CONF_TYPE_STRING_LIST || type == CONF_TYPE_KV_LIST)
  ------------------
  |  |  246|      0|#define CONF_TYPE_KV_LIST       (&m_option_type_keyvalue_list)
  ------------------
  |  Branch (6022:22): [True: 0, False: 0]
  |  Branch (6022:55): [True: 0, False: 0]
  ------------------
 6023|      0|                list = cmd->args[n].v.str_list;
 6024|      0|            for (; list && *list; list++) {
  ------------------
  |  Branch (6024:20): [True: 0, False: 0]
  |  Branch (6024:28): [True: 0, False: 0]
  ------------------
 6025|      0|                char *s = mp_property_expand_string(mpctx, *list);
 6026|      0|                if (!s) {
  ------------------
  |  Branch (6026:21): [True: 0, False: 0]
  ------------------
 6027|      0|                    ctx->success = false;
 6028|      0|                    mp_cmd_ctx_complete(ctx);
 6029|      0|                    return;
 6030|      0|                }
 6031|      0|                talloc_free(*list);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 6032|      0|                *list = s;
 6033|      0|                if (type == CONF_TYPE_STRING)
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  |  Branch (6033:21): [True: 0, False: 0]
  ------------------
 6034|      0|                    break;
 6035|      0|            }
 6036|      0|        }
 6037|      0|    }
 6038|       |
 6039|  86.8k|    if (cmd->def->spawn_thread) {
  ------------------
  |  Branch (6039:9): [True: 0, False: 86.8k]
  ------------------
 6040|      0|        mpctx->outstanding_async += 1; // prevent that core disappears
 6041|      0|        if (!mp_thread_pool_queue(mpctx->thread_pool,
  ------------------
  |  Branch (6041:13): [True: 0, False: 0]
  ------------------
 6042|      0|                                  run_command_on_worker_thread, ctx))
 6043|      0|        {
 6044|      0|            mpctx->outstanding_async -= 1;
 6045|      0|            ctx->success = false;
 6046|      0|            mp_cmd_ctx_complete(ctx);
 6047|      0|        }
 6048|  86.8k|    } else {
 6049|  86.8k|        bool exec_async = cmd->def->exec_async;
 6050|  86.8k|        cmd->def->handler(ctx);
 6051|  86.8k|        if (!exec_async)
  ------------------
  |  Branch (6051:13): [True: 86.8k, False: 0]
  ------------------
 6052|  86.8k|            mp_cmd_ctx_complete(ctx);
 6053|  86.8k|    }
 6054|  86.8k|}
mp_abort_cache_dumping:
 7482|   133k|{
 7483|   133k|    struct command_ctx *ctx = mpctx->command_ctx;
 7484|       |
 7485|   133k|    if (ctx->cache_dump_cmd)
  ------------------
  |  Branch (7485:9): [True: 0, False: 133k]
  ------------------
 7486|      0|        mp_cancel_trigger(ctx->cache_dump_cmd->abort->cancel);
 7487|   133k|    cache_dump_poll(mpctx);
 7488|       |    mp_assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (7488:5): [True: 133k, False: 0]
  ------------------
 7489|   133k|}
command_uninit:
 8218|  28.9k|{
 8219|  28.9k|    struct command_ctx *ctx = mpctx->command_ctx;
 8220|       |
 8221|  28.9k|    mp_assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (8221:5): [True: 28.9k, False: 0]
  ------------------
 8222|       |
 8223|  28.9k|    overlay_uninit(mpctx);
 8224|  28.9k|    ao_hotplug_destroy(ctx->hotplug);
 8225|       |
 8226|  28.9k|    m_option_free(&script_props_type, &ctx->script_props);
 8227|       |
 8228|  28.9k|    talloc_free(mpctx->command_ctx);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 8229|       |    mpctx->command_ctx = NULL;
 8230|  28.9k|}
command_init:
 8238|  28.9k|{
 8239|  28.9k|    struct command_ctx *ctx = talloc(NULL, struct command_ctx);
  ------------------
  |  |   26|  28.9k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  28.9k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8240|  28.9k|    *ctx = (struct command_ctx){
 8241|  28.9k|        .last_seek_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  28.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8242|  28.9k|    };
 8243|  28.9k|    mpctx->command_ctx = ctx;
 8244|       |
 8245|  28.9k|    int num_base = MP_ARRAY_SIZE(mp_properties_base);
  ------------------
  |  |   49|  28.9k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 8246|  28.9k|    int num_opts = m_config_get_co_count(mpctx->mconfig);
 8247|  28.9k|    struct m_property *props =
 8248|  28.9k|        talloc_zero_array(ctx, struct m_property, num_base + num_opts);
  ------------------
  |  |   30|  28.9k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  28.9k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8249|  28.9k|    memcpy(props, mp_properties_base, sizeof(mp_properties_base));
 8250|       |
 8251|  28.9k|    const char **prop_names = talloc_array(NULL, const char *, num_base);
  ------------------
  |  |   29|  28.9k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  28.9k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8252|  5.67M|    for (int i = 0; i < num_base; ++i)
  ------------------
  |  Branch (8252:21): [True: 5.64M, False: 28.9k]
  ------------------
 8253|  5.64M|        prop_names[i] = mp_properties_base[i].name;
 8254|  28.9k|    qsort(prop_names, num_base, sizeof(const char *), str_compare);
 8255|       |
 8256|  28.9k|    int count = num_base;
 8257|  22.7M|    for (int n = 0; n < num_opts; n++) {
  ------------------
  |  Branch (8257:21): [True: 22.7M, False: 28.9k]
  ------------------
 8258|  22.7M|        struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n);
 8259|  22.7M|        mp_assert(co->name[0]);
  ------------------
  |  |   41|  22.7M|#define mp_assert assert
  ------------------
  |  Branch (8259:9): [True: 22.7M, False: 0]
  ------------------
 8260|  22.7M|        if (co->opt->flags & M_OPT_NOPROP)
  ------------------
  |  |  477|  22.7M|#define M_OPT_NOPROP            (UINT64_C(1) << 60)
  ------------------
  |  Branch (8260:13): [True: 810k, False: 21.8M]
  ------------------
 8261|   810k|            continue;
 8262|       |
 8263|  21.8M|        struct m_property prop = {
 8264|  21.8M|            .name = co->name,
 8265|  21.8M|            .call = mp_property_generic_option,
 8266|  21.8M|            .priv = co,
 8267|  21.8M|            .is_option = true,
 8268|  21.8M|        };
 8269|       |
 8270|  21.8M|        if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8270:13): [True: 666k, False: 21.2M]
  ------------------
 8271|   666k|            char buf[M_CONFIG_MAX_OPT_NAME_LEN];
 8272|   666k|            const char *alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co->opt_id,
 8273|   666k|                                                                   buf, sizeof(buf));
 8274|   666k|            prop.priv = talloc_strdup(ctx, alias);
  ------------------
  |  |   50|   666k|#define talloc_strdup                   ta_xstrdup
  ------------------
 8275|       |
 8276|   666k|            prop.call = co->opt->deprecation_message ?
  ------------------
  |  Branch (8276:25): [True: 202k, False: 463k]
  ------------------
 8277|   463k|                            mp_property_deprecated_alias : mp_property_alias;
 8278|       |
 8279|       |            // Check whether this eventually arrives at a real option. If not,
 8280|       |            // it's some CLI special handling thing. For example, "nosound" is
 8281|       |            // mapped to "no-audio", which has CLI special-handling, and cannot
 8282|       |            // be set as property.
 8283|   666k|            struct m_config_option *co2 = co;
 8284|  1.33M|            while (co2 && co2->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8284:20): [True: 1.33M, False: 0]
  |  Branch (8284:27): [True: 666k, False: 666k]
  ------------------
 8285|   666k|                const char *co2_alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co2->opt_id,
 8286|   666k|                                                                           buf, sizeof(buf));
 8287|   666k|                co2 = m_config_get_co_raw(mpctx->mconfig, bstr0(co2_alias));
 8288|   666k|            }
 8289|   666k|            if (!co2)
  ------------------
  |  Branch (8289:17): [True: 0, False: 666k]
  ------------------
 8290|      0|                continue;
 8291|   666k|        }
 8292|       |
 8293|       |        // The option might be covered by a manual property already.
 8294|  21.8M|        if (bsearch(&prop.name, prop_names, num_base, sizeof(const char *), str_compare))
  ------------------
  |  Branch (8294:13): [True: 694k, False: 21.1M]
  ------------------
 8295|   694k|            continue;
 8296|       |
 8297|  21.1M|        props[count++] = prop;
 8298|  21.1M|    }
 8299|       |
 8300|  28.9k|    ctx->properties = (struct m_property_list){props, count};
 8301|  28.9k|    m_property_list_sort(&ctx->properties);
 8302|       |
 8303|  28.9k|    node_init(&ctx->mdata, MPV_FORMAT_NODE_ARRAY, NULL);
 8304|  28.9k|    talloc_steal(ctx, ctx->mdata.u.list);
  ------------------
  |  |   38|  28.9k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  28.9k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8305|       |
 8306|  28.9k|    node_init(&ctx->udata, MPV_FORMAT_NODE_MAP, NULL);
 8307|  28.9k|    talloc_steal(ctx, ctx->udata.u.list);
  ------------------
  |  |   38|  28.9k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  28.9k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8308|  28.9k|    talloc_free(prop_names);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 8309|  28.9k|}
handle_command_updates:
 8357|   432k|{
 8358|   432k|    struct command_ctx *ctx = mpctx->command_ctx;
 8359|       |
 8360|       |    // This is a bit messy: ao_hotplug wakes up the player, and then we have
 8361|       |    // to recheck the state. Then the client(s) will read the property.
 8362|   432k|    if (ctx->hotplug && ao_hotplug_check_update(ctx->hotplug))
  ------------------
  |  Branch (8362:9): [True: 0, False: 432k]
  |  Branch (8362:25): [True: 0, False: 0]
  ------------------
 8363|      0|        mp_notify_property(mpctx, "audio-device-list");
 8364|       |
 8365|       |    // Depends on polling demuxer wakeup callback notifications.
 8366|   432k|    cache_dump_poll(mpctx);
 8367|   432k|}
run_command_opts:
 8370|  74.5k|{
 8371|  74.5k|    struct MPOpts *opts = mpctx->opts;
 8372|  74.5k|    struct command_ctx *ctx = mpctx->command_ctx;
 8373|       |
 8374|  74.5k|    if (!opts->input_commands || ctx->command_opts_processed)
  ------------------
  |  Branch (8374:9): [True: 74.5k, False: 0]
  |  Branch (8374:34): [True: 0, False: 0]
  ------------------
 8375|  74.5k|        return;
 8376|       |
 8377|       |    // Take easy way out and add these to the input queue.
 8378|      0|    for (int i = 0; opts->input_commands[i]; i++) {
  ------------------
  |  Branch (8378:21): [True: 0, False: 0]
  ------------------
 8379|      0|        struct mp_cmd *cmd = mp_input_parse_cmd(mpctx->input, bstr0(opts->input_commands[i]),
 8380|      0|                                                "the command line");
 8381|      0|        if (cmd) {
  ------------------
  |  Branch (8381:13): [True: 0, False: 0]
  ------------------
 8382|      0|            cmd->coalesce = true;
 8383|      0|            mp_input_queue_cmd(mpctx->input, cmd);
 8384|      0|        }
 8385|      0|    }
 8386|       |    ctx->command_opts_processed = true;
 8387|      0|}
mp_notify:
 8390|   829k|{
 8391|       |    // The OSD can implicitly reference some properties.
 8392|   829k|    mpctx->osd_idle_update = true;
 8393|       |
 8394|   829k|    command_event(mpctx, event, arg);
 8395|       |
 8396|   829k|    mp_client_broadcast_event(mpctx, event, arg);
 8397|   829k|}
mp_option_change_callback:
 8429|  28.9k|{
 8430|  28.9k|    struct MPContext *mpctx = ctx;
 8431|  28.9k|    struct MPOpts *opts = mpctx->opts;
 8432|  28.9k|    void *opt_ptr = !co ? NULL : co->data; // NULL on start
  ------------------
  |  Branch (8432:21): [True: 28.9k, False: 0]
  ------------------
 8433|       |
 8434|  28.9k|    if (co)
  ------------------
  |  Branch (8434:9): [True: 0, False: 28.9k]
  ------------------
 8435|      0|        mp_notify_property(mpctx, co->name);
 8436|  28.9k|    if (opt_ptr == &opts->media_title)
  ------------------
  |  Branch (8436:9): [True: 0, False: 28.9k]
  ------------------
 8437|      0|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
 8438|       |
 8439|  28.9k|    if (self_update)
  ------------------
  |  Branch (8439:9): [True: 0, False: 28.9k]
  ------------------
 8440|      0|        return;
 8441|       |
 8442|       |    // Run these immediately.
 8443|  28.9k|    if (co && !co->coalesce) {
  ------------------
  |  Branch (8443:9): [True: 0, False: 28.9k]
  |  Branch (8443:15): [True: 0, False: 0]
  ------------------
 8444|      0|        struct mp_option_callback callback = {.co = co, .flags = flags};
 8445|      0|        mp_option_run_callback(mpctx, &callback);
 8446|      0|        return;
 8447|      0|    }
 8448|       |
 8449|       |    // Coalesce redundant updates and only keep the newest one.
 8450|  28.9k|    bool drop = false;
 8451|  28.9k|    for (int i = 0; i < mpctx->num_option_callbacks; i++) {
  ------------------
  |  Branch (8451:21): [True: 0, False: 28.9k]
  ------------------
 8452|      0|        if ((mpctx->option_callbacks[i].co && opt_ptr == mpctx->option_callbacks[i].co->data) ||
  ------------------
  |  Branch (8452:14): [True: 0, False: 0]
  |  Branch (8452:47): [True: 0, False: 0]
  ------------------
 8453|      0|            (flags && flags == mpctx->option_callbacks[i].flags))
  ------------------
  |  Branch (8453:14): [True: 0, False: 0]
  |  Branch (8453:23): [True: 0, False: 0]
  ------------------
 8454|      0|            drop = true;
 8455|      0|        if (!drop)
  ------------------
  |  Branch (8455:13): [True: 0, False: 0]
  ------------------
 8456|      0|            continue;
 8457|      0|        if (i < mpctx->num_option_callbacks - 1)
  ------------------
  |  Branch (8457:13): [True: 0, False: 0]
  ------------------
 8458|      0|            mpctx->option_callbacks[i] = mpctx->option_callbacks[i + 1];
 8459|      0|        if (i == mpctx->num_option_callbacks - 1) {
  ------------------
  |  Branch (8459:13): [True: 0, False: 0]
  ------------------
 8460|      0|            mpctx->option_callbacks[i].co = co;
 8461|      0|            mpctx->option_callbacks[i].flags = flags;
 8462|      0|        }
 8463|      0|    }
 8464|       |
 8465|  28.9k|    if (!drop) {
  ------------------
  |  Branch (8465:9): [True: 28.9k, False: 0]
  ------------------
 8466|  28.9k|        struct mp_option_callback callback = {.co = co, .flags = flags};
 8467|  28.9k|        MP_TARRAY_APPEND(mpctx, mpctx->option_callbacks, mpctx->num_option_callbacks, callback);
  ------------------
  |  |  105|  28.9k|    do {                                            \
  |  |  106|  28.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  28.9k|    do {                                            \
  |  |  |  |   97|  28.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  28.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  28.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  28.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 28.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  28.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  28.9k|    do {                                                        \
  |  |  |  |  |  |   89|  28.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  28.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  28.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  28.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  28.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  28.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  28.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 28.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  28.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  28.9k|        (idxvar)++;                                 \
  |  |  109|  28.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 28.9k]
  |  |  ------------------
  ------------------
 8468|  28.9k|    }
 8469|  28.9k|}
mp_option_run_callback:
 8472|  28.9k|{
 8473|  28.9k|    struct MPOpts *opts = mpctx->opts;
 8474|  28.9k|    struct m_config_option *co = callback->co;
 8475|  28.9k|    void *opt_ptr = co ? co->data : NULL;
  ------------------
  |  Branch (8475:21): [True: 0, False: 28.9k]
  ------------------
 8476|  28.9k|    uint64_t flags = callback->flags;
 8477|       |
 8478|  28.9k|    if (flags & UPDATE_TERM)
  ------------------
  |  |  442|  28.9k|#define UPDATE_TERM             (UINT64_C(1) << 0)   // terminal options
  ------------------
  |  Branch (8478:9): [True: 28.9k, False: 0]
  ------------------
 8479|  28.9k|        mp_update_logging(mpctx, false);
 8480|       |
 8481|  28.9k|    if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  444|  28.9k|#define UPDATE_OSD              (UINT64_C(1) << 2)   // related to OSD rendering
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  443|  28.9k|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  455|  28.9k|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (8481:9): [True: 28.9k, False: 0]
  ------------------
 8482|  86.8k|        for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (8482:25): [True: 57.9k, False: 28.9k]
  ------------------
 8483|  57.9k|            struct track *track = mpctx->current_track[n][STREAM_SUB];
 8484|  57.9k|            struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (8484:35): [True: 0, False: 57.9k]
  ------------------
 8485|  57.9k|            if (sub) {
  ------------------
  |  Branch (8485:17): [True: 0, False: 57.9k]
  ------------------
 8486|      0|                int ret = sub_control(sub, SD_CTRL_UPDATE_OPTS, &flags);
 8487|      0|                if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
                              if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  443|      0|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
                              if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  455|      0|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (8487:21): [True: 0, False: 0]
  |  Branch (8487:42): [True: 0, False: 0]
  ------------------
 8488|      0|                    sub_redecode_cached_packets(sub);
 8489|      0|                }
 8490|      0|            }
 8491|  57.9k|        }
 8492|       |        // For subs on a still image.
 8493|  28.9k|        redraw_subs(mpctx);
 8494|  28.9k|        osd_changed(mpctx->osd);
 8495|  28.9k|    }
 8496|       |
 8497|  28.9k|    if (flags & UPDATE_BUILTIN_SCRIPTS)
  ------------------
  |  |  445|  28.9k|#define UPDATE_BUILTIN_SCRIPTS  (UINT64_C(1) << 3)   // osc/ytdl/stats
  ------------------
  |  Branch (8497:9): [True: 28.9k, False: 0]
  ------------------
 8498|  28.9k|        mp_load_builtin_scripts(mpctx);
 8499|       |
 8500|  28.9k|    if (flags & UPDATE_IMGPAR) {
  ------------------
  |  |  446|  28.9k|#define UPDATE_IMGPAR           (UINT64_C(1) << 4)   // video image params overrides
  ------------------
  |  Branch (8500:9): [True: 28.9k, False: 0]
  ------------------
 8501|  28.9k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8502|  28.9k|        if (track && track->dec) {
  ------------------
  |  Branch (8502:13): [True: 0, False: 28.9k]
  |  Branch (8502:22): [True: 0, False: 0]
  ------------------
 8503|      0|            mp_decoder_wrapper_reset_params(track->dec);
 8504|      0|            mp_force_video_refresh(mpctx);
 8505|      0|        }
 8506|  28.9k|    }
 8507|       |
 8508|  28.9k|    if (flags & UPDATE_INPUT)
  ------------------
  |  |  447|  28.9k|#define UPDATE_INPUT            (UINT64_C(1) << 5)   // mostly --input-* options
  ------------------
  |  Branch (8508:9): [True: 28.9k, False: 0]
  ------------------
 8509|  28.9k|        mp_input_update_opts(mpctx->input);
 8510|       |
 8511|  28.9k|    if (flags & UPDATE_CLIPBOARD)
  ------------------
  |  |  458|  28.9k|#define UPDATE_CLIPBOARD        (UINT64_C(1) << 17)  // reinit the clipboard
  ------------------
  |  Branch (8511:9): [True: 28.9k, False: 0]
  ------------------
 8512|  28.9k|        reinit_clipboard(mpctx);
 8513|       |
 8514|  28.9k|    if (opt_ptr == &opts->ipc_path || opt_ptr == &opts->ipc_client) {
  ------------------
  |  Branch (8514:9): [True: 0, False: 28.9k]
  |  Branch (8514:39): [True: 0, False: 28.9k]
  ------------------
 8515|      0|        mp_uninit_ipc(mpctx->ipc_ctx);
 8516|      0|        mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
 8517|      0|    }
 8518|       |
 8519|  28.9k|    if (flags & UPDATE_VO && mpctx->video_out) {
  ------------------
  |  |  457|  57.9k|#define UPDATE_VO               (UINT64_C(1) << 16)  // reinit the VO
  ------------------
  |  Branch (8519:9): [True: 28.9k, False: 0]
  |  Branch (8519:30): [True: 0, False: 28.9k]
  ------------------
 8520|      0|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8521|      0|        struct mp_pin *filter_src = mpctx->vo_chain ? mpctx->vo_chain->filter_src : NULL;
  ------------------
  |  Branch (8521:37): [True: 0, False: 0]
  ------------------
 8522|      0|        uninit_video_out(mpctx);
 8523|      0|        handle_force_window(mpctx, true);
 8524|       |
 8525|      0|        if (filter_src) {
  ------------------
  |  Branch (8525:13): [True: 0, False: 0]
  ------------------
 8526|      0|            reinit_video_chain_src(mpctx, NULL);
 8527|      0|            if (mpctx->vo_chain) {
  ------------------
  |  Branch (8527:17): [True: 0, False: 0]
  ------------------
 8528|      0|                mpctx->vo_chain->filter_src = filter_src;
 8529|      0|                mp_pin_connect(mpctx->vo_chain->filter->f->pins[0], filter_src);
 8530|      0|            }
 8531|      0|        } else {
 8532|      0|            reinit_video_chain(mpctx);
 8533|      0|        }
 8534|       |
 8535|      0|        if (track || filter_src)
  ------------------
  |  Branch (8535:13): [True: 0, False: 0]
  |  Branch (8535:22): [True: 0, False: 0]
  ------------------
 8536|      0|            queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);
 8537|       |
 8538|      0|        mp_wakeup_core(mpctx);
 8539|      0|    }
 8540|       |
 8541|  28.9k|    if (flags & UPDATE_AUDIO)
  ------------------
  |  |  448|  28.9k|#define UPDATE_AUDIO            (UINT64_C(1) << 6)   // --audio-channels etc.
  ------------------
  |  Branch (8541:9): [True: 28.9k, False: 0]
  ------------------
 8542|  28.9k|        reload_audio_output(mpctx);
 8543|       |
 8544|  28.9k|    if (flags & UPDATE_PRIORITY)
  ------------------
  |  |  449|  28.9k|#define UPDATE_PRIORITY         (UINT64_C(1) << 7)   // --priority (Windows-only)
  ------------------
  |  Branch (8544:9): [True: 28.9k, False: 0]
  ------------------
 8545|  28.9k|        update_priority(mpctx);
 8546|       |
 8547|  28.9k|    if (flags & UPDATE_SCREENSAVER)
  ------------------
  |  |  450|  28.9k|#define UPDATE_SCREENSAVER      (UINT64_C(1) << 8)   // --stop-screensaver
  ------------------
  |  Branch (8547:9): [True: 28.9k, False: 0]
  ------------------
 8548|  28.9k|        update_screensaver_state(mpctx);
 8549|       |
 8550|  28.9k|    if (flags & UPDATE_VOL)
  ------------------
  |  |  451|  28.9k|#define UPDATE_VOL              (UINT64_C(1) << 9)   // softvol related options
  ------------------
  |  Branch (8550:9): [True: 28.9k, False: 0]
  ------------------
 8551|  28.9k|        audio_update_volume(mpctx);
 8552|       |
 8553|  28.9k|    if (flags & UPDATE_LAVFI_COMPLEX)
  ------------------
  |  |  452|  28.9k|#define UPDATE_LAVFI_COMPLEX    (UINT64_C(1) << 10)  // --lavfi-complex
  ------------------
  |  Branch (8553:9): [True: 28.9k, False: 0]
  ------------------
 8554|  28.9k|        update_lavfi_complex(mpctx);
 8555|       |
 8556|  28.9k|    if (flags & UPDATE_VIDEO) {
  ------------------
  |  |  456|  28.9k|#define UPDATE_VIDEO            (UINT64_C(1) << 15)  // force redraw if needed
  ------------------
  |  Branch (8556:9): [True: 28.9k, False: 0]
  ------------------
 8557|  28.9k|        if (mpctx->video_out) {
  ------------------
  |  Branch (8557:13): [True: 0, False: 28.9k]
  ------------------
 8558|      0|            vo_control(mpctx->video_out, VOCTRL_UPDATE_RENDER_OPTS, NULL);
 8559|      0|            mp_wakeup_core(mpctx);
 8560|      0|        }
 8561|  28.9k|    }
 8562|       |
 8563|  28.9k|    if (flags & UPDATE_HWDEC) {
  ------------------
  |  |  453|  28.9k|#define UPDATE_HWDEC            (UINT64_C(1) << 11)  // --hwdec
  ------------------
  |  Branch (8563:9): [True: 28.9k, False: 0]
  ------------------
 8564|  28.9k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8565|  28.9k|        struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
  ------------------
  |  Branch (8565:42): [True: 0, False: 28.9k]
  ------------------
 8566|  28.9k|        if (dec) {
  ------------------
  |  Branch (8566:13): [True: 0, False: 28.9k]
  ------------------
 8567|      0|            mp_decoder_wrapper_control(dec, VDCTRL_REINIT, NULL);
 8568|       |            // filter chain might not change (which normally triggers this), but
 8569|       |            // hwdec will.
 8570|      0|            mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 8571|      0|            double last_pts = mpctx->video_pts;
 8572|      0|            if (last_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (8572:17): [True: 0, False: 0]
  ------------------
 8573|      0|                queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0);
 8574|      0|        }
 8575|  28.9k|    }
 8576|       |
 8577|  28.9k|    if (flags & UPDATE_DVB_PROG) {
  ------------------
  |  |  454|  28.9k|#define UPDATE_DVB_PROG         (UINT64_C(1) << 12)  // some --dvbin-...
  ------------------
  |  Branch (8577:9): [True: 28.9k, False: 0]
  ------------------
 8578|  28.9k|        if (!mpctx->stop_play)
  ------------------
  |  Branch (8578:13): [True: 0, False: 28.9k]
  ------------------
 8579|      0|            mpctx->stop_play = PT_CURRENT_ENTRY;
 8580|  28.9k|    }
 8581|       |
 8582|  28.9k|    if (flags & UPDATE_DEMUXER)
  ------------------
  |  |  459|  28.9k|#define UPDATE_DEMUXER          (UINT64_C(1) << 18)  // invalidate --prefetch-playlist's data
  ------------------
  |  Branch (8582:9): [True: 28.9k, False: 0]
  ------------------
 8583|  28.9k|        mpctx->demuxer_changed = true;
 8584|       |
 8585|  28.9k|    if (flags & UPDATE_AD && mpctx->ao_chain) {
  ------------------
  |  |  460|  57.9k|#define UPDATE_AD               (UINT64_C(1) << 19)  // reinit audio chain and decoder
  ------------------
  |  Branch (8585:9): [True: 28.9k, False: 0]
  |  Branch (8585:30): [True: 0, False: 28.9k]
  ------------------
 8586|      0|        uninit_audio_chain(mpctx);
 8587|      0|        reinit_audio_chain(mpctx);
 8588|      0|    }
 8589|       |
 8590|  28.9k|    if (flags & UPDATE_VD && mpctx->vo_chain) {
  ------------------
  |  |  461|  57.9k|#define UPDATE_VD               (UINT64_C(1) << 20)  // reinit video chain and decoder
  ------------------
  |  Branch (8590:9): [True: 28.9k, False: 0]
  |  Branch (8590:30): [True: 0, False: 28.9k]
  ------------------
 8591|      0|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8592|      0|        uninit_video_chain(mpctx);
 8593|      0|        reinit_video_chain(mpctx);
 8594|      0|        if (track)
  ------------------
  |  Branch (8594:13): [True: 0, False: 0]
  ------------------
 8595|      0|            queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);
 8596|      0|    }
 8597|       |
 8598|  28.9k|    if (opt_ptr == &opts->vo->android_surface_size || opt_ptr == &opts->vo->d3d11_composition_size) {
  ------------------
  |  Branch (8598:9): [True: 0, False: 28.9k]
  |  Branch (8598:55): [True: 0, False: 28.9k]
  ------------------
 8599|      0|        if (mpctx->video_out)
  ------------------
  |  Branch (8599:13): [True: 0, False: 0]
  ------------------
 8600|      0|            vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL);
 8601|      0|    }
 8602|       |
 8603|  28.9k|    if (opt_ptr == &opts->input_commands) {
  ------------------
  |  Branch (8603:9): [True: 0, False: 28.9k]
  ------------------
 8604|      0|        mpctx->command_ctx->command_opts_processed = false;
 8605|      0|        run_command_opts(mpctx);
 8606|      0|    }
 8607|       |
 8608|  28.9k|    if (opt_ptr == &opts->playback_speed || opt_ptr == &opts->playback_pitch ||
  ------------------
  |  Branch (8608:9): [True: 0, False: 28.9k]
  |  Branch (8608:45): [True: 0, False: 28.9k]
  ------------------
 8609|  28.9k|        opt_ptr == &opts->pitch_correction) {
  ------------------
  |  Branch (8609:9): [True: 0, False: 28.9k]
  ------------------
 8610|      0|        update_playback_speed(mpctx);
 8611|      0|        mp_wakeup_core(mpctx);
 8612|      0|    }
 8613|       |
 8614|  28.9k|    if (opt_ptr == &opts->play_dir) {
  ------------------
  |  Branch (8614:9): [True: 0, False: 28.9k]
  ------------------
 8615|      0|        if (mpctx->play_dir != opts->play_dir) {
  ------------------
  |  Branch (8615:13): [True: 0, False: 0]
  ------------------
 8616|       |            // The option must be set before we seek if we're at EOF.
 8617|      0|            if (mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (8617:17): [True: 0, False: 0]
  ------------------
 8618|      0|                mpctx->play_dir = opts->play_dir;
 8619|      0|            queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx),
 8620|      0|                       MPSEEK_EXACT, 0);
 8621|      0|        }
 8622|      0|    }
 8623|       |
 8624|  28.9k|    if (opt_ptr == &opts->edition_id) {
  ------------------
  |  Branch (8624:9): [True: 0, False: 28.9k]
  ------------------
 8625|      0|        struct demuxer *demuxer = mpctx->demuxer;
 8626|      0|        if (mpctx->playback_initialized && demuxer && demuxer->num_editions > 0) {
  ------------------
  |  Branch (8626:13): [True: 0, False: 0]
  |  Branch (8626:44): [True: 0, False: 0]
  |  Branch (8626:55): [True: 0, False: 0]
  ------------------
 8627|      0|            if (opts->edition_id != demuxer->edition) {
  ------------------
  |  Branch (8627:17): [True: 0, False: 0]
  ------------------
 8628|      0|                if (demuxer->edition_is_track_mapping) {
  ------------------
  |  Branch (8628:21): [True: 0, False: 0]
  ------------------
 8629|      0|                    int new_ed = opts->edition_id;
 8630|      0|                    if (new_ed < 0 || new_ed >= demuxer->num_editions)
  ------------------
  |  Branch (8630:25): [True: 0, False: 0]
  |  Branch (8630:39): [True: 0, False: 0]
  ------------------
 8631|      0|                        new_ed = 0;
 8632|      0|                    demuxer->edition = new_ed;
 8633|      0|                    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (8633:37): [True: 0, False: 0]
  ------------------
 8634|      0|                        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (8634:41): [True: 0, False: 0]
  ------------------
 8635|      0|                            struct track *sel = select_default_track(mpctx, i, t);
 8636|      0|                            if (sel != mpctx->current_track[i][t])
  ------------------
  |  Branch (8636:33): [True: 0, False: 0]
  ------------------
 8637|      0|                                mp_switch_track_n(mpctx, i, t, sel, 0);
 8638|      0|                        }
 8639|      0|                    }
 8640|      0|                    if (demuxer->ts_resets_possible) {
  ------------------
  |  Branch (8640:25): [True: 0, False: 0]
  ------------------
 8641|      0|                        reset_playback_state(mpctx);
 8642|      0|                        demux_flush(demuxer);
 8643|      0|                    }
 8644|      0|                    mp_notify_property(mpctx, "current-edition");
 8645|      0|                    print_track_list(mpctx,
 8646|      0|                        mp_tprintf(42, "Selected edition %d:", demuxer->edition));
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 8647|      0|                } else if (disc_nav_get_stream(mpctx)) {
  ------------------
  |  Branch (8647:28): [True: 0, False: 0]
  ------------------
 8648|      0|                    unsigned new_title = opts->edition_id;
 8649|      0|                    stream_control(demuxer->stream,
 8650|      0|                                   STREAM_CTRL_SET_CURRENT_TITLE, &new_title);
 8651|      0|                } else {
 8652|      0|                    if (!mpctx->stop_play)
  ------------------
  |  Branch (8652:25): [True: 0, False: 0]
  ------------------
 8653|      0|                        mpctx->stop_play = PT_CURRENT_ENTRY;
 8654|      0|                }
 8655|      0|                mp_wakeup_core(mpctx);
 8656|      0|            }
 8657|      0|        }
 8658|      0|    }
 8659|       |
 8660|       |#if HAVE_LIBBLURAY
 8661|       |    if (opt_ptr == &opts->stream_bluray_opts->angle) {
 8662|       |        struct demuxer *demuxer = mpctx->demuxer;
 8663|       |        if (mpctx->playback_initialized && demuxer && demuxer->stream &&
 8664|       |                (!strcmp(demuxer->stream->info->name, "bd") ||
 8665|       |                 !strcmp(demuxer->stream->info->name, "bdmv/bluray"))) {
 8666|       |            int angle = opts->stream_bluray_opts->angle;
 8667|       |            stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle);
 8668|       |        }
 8669|       |    }
 8670|       |#endif
 8671|       |
 8672|       |#if HAVE_DVDA
 8673|       |    if (opt_ptr == &opts->dvda_opts->page) {
 8674|       |        struct demuxer *demuxer = mpctx->demuxer;
 8675|       |        if (mpctx->playback_initialized && demuxer && demuxer->stream &&
 8676|       |                (!strcmp(demuxer->stream->info->name, "dvda") ||
 8677|       |                 !strcmp(demuxer->stream->info->name, "ifo_dvda"))) {
 8678|       |            int page = opts->dvda_opts->page;
 8679|       |            stream_control(demuxer->stream, STREAM_CTRL_SET_STILL_PAGE, &page);
 8680|       |        }
 8681|       |    }
 8682|       |#endif
 8683|       |
 8684|  28.9k|    if (opt_ptr == &opts->pause)
  ------------------
  |  Branch (8684:9): [True: 0, False: 28.9k]
  ------------------
 8685|      0|        set_pause_state(mpctx, opts->pause);
 8686|       |
 8687|  28.9k|    if (opt_ptr == &opts->audio_delay) {
  ------------------
  |  Branch (8687:9): [True: 0, False: 28.9k]
  ------------------
 8688|      0|        if (mpctx->ao_chain) {
  ------------------
  |  Branch (8688:13): [True: 0, False: 0]
  ------------------
 8689|      0|            double change = mpctx->opts->audio_delay - mpctx->ao_chain->delay;
 8690|      0|            mpctx->delay += change;
 8691|      0|            mpctx->ao_chain->delayed_start_gap += change;
 8692|      0|            mpctx->ao_chain->delay = mpctx->opts->audio_delay;
 8693|      0|        }
 8694|      0|        mp_wakeup_core(mpctx);
 8695|      0|    }
 8696|       |
 8697|  28.9k|    if (opt_ptr == &opts->vo->window_scale)
  ------------------
  |  Branch (8697:9): [True: 0, False: 28.9k]
  ------------------
 8698|      0|        update_window_scale(mpctx);
 8699|       |
 8700|  28.9k|    if (opt_ptr == &opts->vo->hidpi_window_scale)
  ------------------
  |  Branch (8700:9): [True: 0, False: 28.9k]
  ------------------
 8701|      0|        update_hidpi_window_scale(mpctx, opts->vo->hidpi_window_scale);
 8702|       |
 8703|  28.9k|    if (opt_ptr == &opts->cursor_autohide_delay)
  ------------------
  |  Branch (8703:9): [True: 0, False: 28.9k]
  ------------------
 8704|      0|        mpctx->mouse_timer = 0;
 8705|       |
 8706|  28.9k|    if (opt_ptr == &opts->loop_file) {
  ------------------
  |  Branch (8706:9): [True: 0, False: 28.9k]
  ------------------
 8707|      0|        mpctx->remaining_file_loops = opts->loop_file;
 8708|      0|        mp_notify_property(mpctx, "remaining-file-loops");
 8709|      0|    }
 8710|       |
 8711|  28.9k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1] ||
  ------------------
  |  Branch (8711:9): [True: 0, False: 28.9k]
  |  Branch (8711:41): [True: 0, False: 28.9k]
  ------------------
 8712|  28.9k|        opt_ptr == &opts->ab_loop_count) {
  ------------------
  |  Branch (8712:9): [True: 0, False: 28.9k]
  ------------------
 8713|      0|        mpctx->remaining_ab_loops = opts->ab_loop_count;
 8714|      0|        mp_notify_property(mpctx, "remaining-ab-loops");
 8715|      0|    }
 8716|       |
 8717|  28.9k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) {
  ------------------
  |  Branch (8717:9): [True: 0, False: 28.9k]
  |  Branch (8717:41): [True: 0, False: 28.9k]
  ------------------
 8718|      0|        update_ab_loop_clip(mpctx);
 8719|       |        // Update if visible
 8720|      0|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
 8721|      0|        mp_wakeup_core(mpctx);
 8722|      0|    }
 8723|       |
 8724|  28.9k|    if (opt_ptr == &opts->vf_settings)
  ------------------
  |  Branch (8724:9): [True: 0, False: 28.9k]
  ------------------
 8725|      0|        set_filters(mpctx, STREAM_VIDEO, opts->vf_settings);
 8726|       |
 8727|  28.9k|    if (opt_ptr == &opts->af_settings)
  ------------------
  |  Branch (8727:9): [True: 0, False: 28.9k]
  ------------------
 8728|      0|        set_filters(mpctx, STREAM_AUDIO, opts->af_settings);
 8729|       |
 8730|   115k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (8730:24): [True: 86.8k, False: 28.9k]
  ------------------
 8731|   202k|        for (int order = 0; order < num_ptracks[type]; order++) {
  ------------------
  |  Branch (8731:29): [True: 115k, False: 86.8k]
  ------------------
 8732|   115k|            if (opt_ptr == &opts->stream_id[order][type])
  ------------------
  |  Branch (8732:17): [True: 0, False: 115k]
  ------------------
 8733|      0|                update_track_switch(mpctx, order, type);
 8734|   115k|        }
 8735|  86.8k|    }
 8736|       |
 8737|  28.9k|    if (opt_ptr == &opts->vo->fullscreen && !opts->vo->fullscreen)
  ------------------
  |  Branch (8737:9): [True: 0, False: 28.9k]
  |  Branch (8737:45): [True: 0, False: 0]
  ------------------
 8738|      0|        mpctx->mouse_event_ts--; // Show mouse cursor
 8739|       |
 8740|  28.9k|    if (opt_ptr == &opts->vo->taskbar_progress)
  ------------------
  |  Branch (8740:9): [True: 0, False: 28.9k]
  ------------------
 8741|      0|        update_vo_playback_state(mpctx);
 8742|       |
 8743|  28.9k|    if (opt_ptr == &opts->force_vo)
  ------------------
  |  Branch (8743:9): [True: 0, False: 28.9k]
  ------------------
 8744|      0|        handle_force_window(mpctx, false);
 8745|       |
 8746|  28.9k|    if (opt_ptr == &opts->image_display_duration && mpctx->vo_chain
  ------------------
  |  Branch (8746:9): [True: 0, False: 28.9k]
  |  Branch (8746:53): [True: 0, False: 0]
  ------------------
 8747|      0|        && mpctx->vo_chain->is_sparse && !mpctx->ao_chain
  ------------------
  |  Branch (8747:12): [True: 0, False: 0]
  |  Branch (8747:42): [True: 0, False: 0]
  ------------------
 8748|      0|        && mpctx->video_status == STATUS_DRAINING)
  ------------------
  |  Branch (8748:12): [True: 0, False: 0]
  ------------------
 8749|      0|        mpctx->time_frame = opts->image_display_duration / opts->playback_speed;
 8750|  28.9k|}
mp_notify_property:
 8753|  66.3k|{
 8754|  66.3k|    mp_client_property_change(mpctx, property);
 8755|  66.3k|}
command.c:run_next_hook_handler:
  246|   483k|{
  247|   483k|    struct command_ctx *cmd = mpctx->command_ctx;
  248|       |
  249|   483k|    for (int n = start; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (249:25): [True: 0, False: 483k]
  ------------------
  250|      0|        struct hook_handler *h = cmd->hooks[n];
  251|      0|        if (strcmp(h->type, type) == 0) {
  ------------------
  |  Branch (251:13): [True: 0, False: 0]
  ------------------
  252|      0|            int ret = invoke_hook_handler(mpctx, h);
  253|       |            // Repeat until the hook is successfully started or none are left.
  254|      0|            if (ret < 0) {
  ------------------
  |  Branch (254:17): [True: 0, False: 0]
  ------------------
  255|      0|                --n;
  256|      0|                continue;
  257|      0|            }
  258|      0|            return ret;
  259|      0|        }
  260|      0|    }
  261|       |
  262|   483k|    mp_wakeup_core(mpctx); // finished hook
  263|   483k|    return 0;
  264|   483k|}
command.c:match_property:
 5009|  90.4M|{
 5010|  90.4M|    if (strcmp(a, "*") == 0)
  ------------------
  |  Branch (5010:9): [True: 289k, False: 90.1M]
  ------------------
 5011|   289k|        return true;
 5012|       |    // Give options and properties the same ID each, so change notifications
 5013|       |    // work both way.
 5014|  90.1M|    if (strncmp(a, "options/", 8) == 0)
  ------------------
  |  Branch (5014:9): [True: 0, False: 90.1M]
  ------------------
 5015|      0|        a += 8;
 5016|  90.1M|    if (strncmp(b, "options/", 8) == 0)
  ------------------
  |  Branch (5016:9): [True: 0, False: 90.1M]
  ------------------
 5017|      0|        b += 8;
 5018|  90.1M|    int len_a = prefix_len(a);
 5019|  90.1M|    int len_b = prefix_len(b);
 5020|  90.1M|    return strncmp(a, b, MPMIN(len_a, len_b)) == 0;
  ------------------
  |  |   45|  90.1M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 54.4M, False: 35.7M]
  |  |  ------------------
  ------------------
 5021|  90.4M|}
command.c:prefix_len:
 5003|   180M|{
 5004|   180M|    const char *end = strchr(p, '/');
 5005|   180M|    return end ? end - p : strlen(p) + 1;
  ------------------
  |  Branch (5005:12): [True: 54.0M, False: 126M]
  ------------------
 5006|   180M|}
command.c:cache_dump_poll:
 7450|   566k|{
 7451|   566k|    struct command_ctx *ctx = mpctx->command_ctx;
 7452|   566k|    struct mp_cmd_ctx *cmd = ctx->cache_dump_cmd;
 7453|       |
 7454|   566k|    if (!cmd)
  ------------------
  |  Branch (7454:9): [True: 566k, False: 0]
  ------------------
 7455|   566k|        return;
 7456|       |
 7457|       |    // Can't close demuxer without stopping dumping.
 7458|      0|    mp_assert(mpctx->demuxer);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (7458:5): [True: 0, False: 0]
  ------------------
 7459|       |
 7460|      0|    if (mp_cancel_test(cmd->abort->cancel)) {
  ------------------
  |  Branch (7460:9): [True: 0, False: 0]
  ------------------
 7461|       |        // Synchronous abort. In particular, the dump command shall not report
 7462|       |        // completion to the user before the dump target file was closed.
 7463|      0|        demux_cache_dump_set(mpctx->demuxer, 0, 0, NULL);
 7464|      0|        mp_assert(demux_cache_dump_get_status(mpctx->demuxer) <= 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (7464:9): [True: 0, False: 0]
  ------------------
 7465|      0|    }
 7466|       |
 7467|      0|    int status = demux_cache_dump_get_status(mpctx->demuxer);
 7468|      0|    if (status <= 0) {
  ------------------
  |  Branch (7468:9): [True: 0, False: 0]
  ------------------
 7469|      0|        if (status < 0) {
  ------------------
  |  Branch (7469:13): [True: 0, False: 0]
  ------------------
 7470|      0|            mp_cmd_msg(cmd, MSGL_ERR, "Cache dumping stopped due to error.");
 7471|      0|            cmd->success = false;
 7472|      0|        } else {
 7473|      0|            mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping successfully ended.");
 7474|      0|            cmd->success = true;
 7475|      0|        }
 7476|       |        ctx->cache_dump_cmd = NULL;
 7477|      0|        mp_cmd_ctx_complete(cmd);
 7478|      0|    }
 7479|      0|}
command.c:cmd_quit:
 6327|  57.9k|{
 6328|  57.9k|    struct mp_cmd_ctx *cmd = p;
 6329|  57.9k|    struct MPContext *mpctx = cmd->mpctx;
 6330|  57.9k|    bool write_watch_later = *(bool *)cmd->priv;
 6331|  57.9k|    if (write_watch_later || mpctx->opts->position_save_on_quit)
  ------------------
  |  Branch (6331:9): [True: 0, False: 57.9k]
  |  Branch (6331:30): [True: 0, False: 57.9k]
  ------------------
 6332|      0|        mp_write_watch_later_conf(mpctx);
 6333|  57.9k|    mpctx->stop_play = PT_QUIT;
 6334|  57.9k|    mpctx->quit_custom_rc = cmd->args[0].v.i;
 6335|       |    mpctx->has_quit_custom_rc = true;
 6336|  57.9k|    mp_wakeup_core(mpctx);
 6337|  57.9k|}
command.c:cmd_loadfile:
 6569|  28.9k|{
 6570|  28.9k|    struct mp_cmd_ctx *cmd = p;
 6571|  28.9k|    struct MPContext *mpctx = cmd->mpctx;
 6572|  28.9k|    char *filename = cmd->args[0].v.s;
 6573|  28.9k|    int action_flag = cmd->args[1].v.i;
 6574|  28.9k|    int insert_at_idx = cmd->args[2].v.i;
 6575|       |
 6576|  28.9k|    struct load_action action = get_load_action(mpctx, action_flag);
 6577|       |
 6578|  28.9k|    if (action.type == LOAD_TYPE_REPLACE)
  ------------------
  |  Branch (6578:9): [True: 28.9k, False: 0]
  ------------------
 6579|  28.9k|        playlist_clear(mpctx->playlist);
 6580|       |
 6581|  28.9k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 6582|  28.9k|    struct playlist_entry *entry = playlist_entry_new(path);
 6583|  28.9k|    talloc_free(path);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
 6584|  28.9k|    if (cmd->args[3].v.str_list) {
  ------------------
  |  Branch (6584:9): [True: 0, False: 28.9k]
  ------------------
 6585|      0|        char **pairs = cmd->args[3].v.str_list;
 6586|      0|        for (int i = 0; pairs[i] && pairs[i + 1]; i += 2)
  ------------------
  |  Branch (6586:25): [True: 0, False: 0]
  |  Branch (6586:37): [True: 0, False: 0]
  ------------------
 6587|      0|            playlist_entry_add_param(entry, bstr0(pairs[i]), bstr0(pairs[i + 1]));
 6588|      0|    }
 6589|       |
 6590|  28.9k|    struct playlist_entry *at = get_insert_entry(mpctx, &action, insert_at_idx);
 6591|  28.9k|    playlist_insert_at(mpctx->playlist, entry, at);
 6592|       |
 6593|  28.9k|    struct mpv_node *res = &cmd->result;
 6594|  28.9k|    node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 6595|  28.9k|    node_map_add_int64(res, "playlist_entry_id", entry->id);
 6596|       |
 6597|  28.9k|    if (action.type == LOAD_TYPE_REPLACE || (action.play && !mpctx->playlist->current)) {
  ------------------
  |  Branch (6597:9): [True: 28.9k, False: 0]
  |  Branch (6597:46): [True: 0, False: 0]
  |  Branch (6597:61): [True: 0, False: 0]
  ------------------
 6598|  28.9k|        if (mpctx->opts->position_save_on_quit) // requested in issue #1148
  ------------------
  |  Branch (6598:13): [True: 0, False: 28.9k]
  ------------------
 6599|      0|            mp_write_watch_later_conf(mpctx);
 6600|  28.9k|        mp_set_playlist_entry(mpctx, entry);
 6601|  28.9k|    }
 6602|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6603|  28.9k|    mp_wakeup_core(mpctx);
 6604|  28.9k|}
command.c:get_load_action:
 6536|  28.9k|{
 6537|  28.9k|    int type = action_flag & 3;
 6538|  28.9k|    bool play = (action_flag >> 3) & 1;
 6539|  28.9k|    switch (type) {
 6540|  28.9k|    case 0:
  ------------------
  |  Branch (6540:5): [True: 28.9k, False: 0]
  ------------------
 6541|  28.9k|        return (struct load_action){LOAD_TYPE_REPLACE, .play = play};
 6542|      0|    case 1:
  ------------------
  |  Branch (6542:5): [True: 0, False: 28.9k]
  ------------------
 6543|      0|        return (struct load_action){LOAD_TYPE_APPEND, .play = play};
 6544|      0|    case 2:
  ------------------
  |  Branch (6544:5): [True: 0, False: 28.9k]
  ------------------
 6545|      0|        return (struct load_action){LOAD_TYPE_INSERT_NEXT, .play = play};
 6546|      0|    case 3:
  ------------------
  |  Branch (6546:5): [True: 0, False: 28.9k]
  ------------------
 6547|      0|        return (struct load_action){LOAD_TYPE_INSERT_AT, .play = play};
 6548|      0|    default: // default: replace
  ------------------
  |  Branch (6548:5): [True: 0, False: 28.9k]
  ------------------
 6549|       |        return (struct load_action){LOAD_TYPE_REPLACE, .play = true};
 6550|  28.9k|    }
 6551|  28.9k|}
command.c:get_insert_entry:
 6555|  28.9k|{
 6556|  28.9k|    switch (action->type) {
 6557|      0|    case LOAD_TYPE_INSERT_NEXT:
  ------------------
  |  Branch (6557:5): [True: 0, False: 28.9k]
  ------------------
 6558|      0|        return playlist_get_next(mpctx->playlist, +1);
 6559|      0|    case LOAD_TYPE_INSERT_AT:
  ------------------
  |  Branch (6559:5): [True: 0, False: 28.9k]
  ------------------
 6560|      0|        return playlist_entry_from_index(mpctx->playlist, insert_at_idx);
 6561|  28.9k|    case LOAD_TYPE_REPLACE:
  ------------------
  |  Branch (6561:5): [True: 28.9k, False: 0]
  ------------------
 6562|  28.9k|    case LOAD_TYPE_APPEND:
  ------------------
  |  Branch (6562:5): [True: 0, False: 28.9k]
  ------------------
 6563|  28.9k|    default:
  ------------------
  |  Branch (6563:5): [True: 0, False: 28.9k]
  ------------------
 6564|       |        return NULL;
 6565|  28.9k|    }
 6566|  28.9k|}
command.c:overlay_uninit:
 5652|  28.9k|{
 5653|  28.9k|    struct command_ctx *cmd = mpctx->command_ctx;
 5654|  28.9k|    if (!mpctx->osd)
  ------------------
  |  Branch (5654:9): [True: 0, False: 28.9k]
  ------------------
 5655|      0|        return;
 5656|  28.9k|    for (int id = 0; id < cmd->num_overlays; id++)
  ------------------
  |  Branch (5656:22): [True: 0, False: 28.9k]
  ------------------
 5657|      0|        replace_overlay(mpctx, id, &(struct overlay){0});
 5658|  28.9k|    osd_set_bitmaps(mpctx->osd, OSDTYPE_EXTERNAL2, NULL);
 5659|  86.8k|    for (int n = 0; n < 2; n++)
  ------------------
  |  Branch (5659:21): [True: 57.9k, False: 28.9k]
  ------------------
 5660|  57.9k|        mp_image_unrefp(&cmd->overlay_osd[n].packed);
 5661|  28.9k|}
command.c:mp_property_filename:
  534|   615k|{
  535|   615k|    MPContext *mpctx = ctx;
  536|   615k|    if (!mpctx->filename)
  ------------------
  |  Branch (536:9): [True: 0, False: 615k]
  ------------------
  537|      0|        return M_PROPERTY_UNAVAILABLE;
  538|   615k|    const char *name = mpctx->demuxer ? mpctx->demuxer->server_filename : NULL;
  ------------------
  |  Branch (538:24): [True: 615k, False: 20]
  ------------------
  539|   615k|    char *filename = talloc_strdup(NULL, name ? name : mpctx->filename);
  ------------------
  |  |   50|   615k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (539:42): [True: 0, False: 615k]
  ------------------
  540|   615k|    char *f = filename;
  541|   615k|    if (!name) {
  ------------------
  |  Branch (541:9): [True: 615k, False: 0]
  ------------------
  542|   615k|        if (mp_is_url(bstr0(filename)))
  ------------------
  |  Branch (542:13): [True: 615k, False: 0]
  ------------------
  543|   615k|            mp_url_unescape_inplace(filename);
  544|   615k|        f = (char *)mp_basename(filename);
  545|   615k|        if (!f[0])
  ------------------
  |  Branch (545:13): [True: 2.23k, False: 613k]
  ------------------
  546|  2.23k|            f = filename;
  547|   615k|    }
  548|   615k|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (548:9): [True: 0, False: 615k]
  ------------------
  549|      0|        struct m_property_action_arg *ka = arg;
  550|      0|        if (strcmp(ka->key, "no-ext") == 0) {
  ------------------
  |  Branch (550:13): [True: 0, False: 0]
  ------------------
  551|      0|            action = ka->action;
  552|      0|            arg = ka->arg;
  553|      0|            f = bstrto0(filename, mp_strip_ext(bstr0(f)));
  554|      0|        }
  555|      0|    }
  556|   615k|    int r = m_property_strdup_ro(action, arg, f);
  557|   615k|    talloc_free(filename);
  ------------------
  |  |   47|   615k|#define talloc_free                     ta_free
  ------------------
  558|   615k|    return r;
  559|   615k|}
command.c:mp_property_media_title:
  635|   616k|{
  636|   616k|    MPContext *mpctx = ctx;
  637|   616k|    const char *name = mp_find_non_filename_media_title(mpctx);
  638|   616k|    if (name && name[0])
  ------------------
  |  Branch (638:9): [True: 890, False: 615k]
  |  Branch (638:17): [True: 890, False: 0]
  ------------------
  639|    890|        return m_property_strdup_ro(action, arg, name);
  640|   615k|    return mp_property_filename(ctx, prop, action, arg);
  641|   616k|}
command.c:str_compare:
 8233|   202M|{
 8234|   202M|    return strcmp(*(const char **)a, *(const char **)b);
 8235|   202M|}
command.c:command_event:
 8312|   829k|{
 8313|   829k|    struct command_ctx *ctx = mpctx->command_ctx;
 8314|       |
 8315|   829k|    if (event == MPV_EVENT_START_FILE) {
  ------------------
  |  Branch (8315:9): [True: 133k, False: 696k]
  ------------------
 8316|   133k|        ctx->last_seek_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   133k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8317|   133k|        ctx->marked_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   133k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8318|   133k|        ctx->marked_permanent = false;
 8319|   133k|    }
 8320|       |
 8321|   829k|    if (event == MPV_EVENT_PLAYBACK_RESTART) {
  ------------------
  |  Branch (8321:9): [True: 16.7k, False: 813k]
  ------------------
 8322|  16.7k|        ctx->last_seek_time = mp_time_sec();
 8323|  16.7k|        run_command_opts(mpctx);
 8324|  16.7k|    }
 8325|       |
 8326|   829k|    if (event == MPV_EVENT_VIDEO_RECONFIG && ctx->hwdec_osd_mode) {
  ------------------
  |  Branch (8326:9): [True: 22.9k, False: 806k]
  |  Branch (8326:46): [True: 0, False: 22.9k]
  ------------------
 8327|      0|        show_property_osd(mpctx, "hwdec", ctx->hwdec_osd_mode);
 8328|      0|        ctx->hwdec_osd_mode = 0;
 8329|      0|    }
 8330|       |
 8331|   829k|    if (event == MPV_EVENT_IDLE)
  ------------------
  |  Branch (8331:9): [True: 57.7k, False: 772k]
  ------------------
 8332|  57.7k|        run_command_opts(mpctx);
 8333|       |
 8334|   829k|    if (event == MPV_EVENT_END_FILE)
  ------------------
  |  Branch (8334:9): [True: 133k, False: 696k]
  ------------------
 8335|   133k|        mp_msg_flush_status_line(mpctx->log, false);
 8336|       |
 8337|   829k|    if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
  ------------------
  |  Branch (8337:9): [True: 133k, False: 696k]
  |  Branch (8337:40): [True: 16.7k, False: 679k]
  ------------------
 8338|       |        // Update chapters - does nothing if something else is visible.
 8339|   150k|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
 8340|   150k|    }
 8341|   829k|    if (event == MP_EVENT_WIN_STATE2)
  ------------------
  |  Branch (8341:9): [True: 0, False: 829k]
  ------------------
 8342|      0|        ctx->cached_window_scale = 0;
 8343|       |
 8344|   829k|    if (event == MP_EVENT_METADATA_UPDATE) {
  ------------------
  |  Branch (8344:9): [True: 21.8k, False: 808k]
  ------------------
 8345|  21.8k|        struct playlist_entry *const pe = mpctx->playing;
 8346|  21.8k|        if (pe && !pe->title) {
  ------------------
  |  Branch (8346:13): [True: 21.8k, False: 0]
  |  Branch (8346:19): [True: 21.8k, False: 3]
  ------------------
 8347|  21.8k|            const char *const name = mp_find_non_filename_media_title(mpctx);
 8348|  21.8k|            if (name && name[0]) {
  ------------------
  |  Branch (8348:17): [True: 138, False: 21.6k]
  |  Branch (8348:25): [True: 138, False: 0]
  ------------------
 8349|    138|                pe->title = talloc_strdup(pe, name);
  ------------------
  |  |   50|    138|#define talloc_strdup                   ta_xstrdup
  ------------------
 8350|    138|                mp_notify_property(mpctx, "playlist");
 8351|    138|            }
 8352|  21.8k|        }
 8353|  21.8k|    }
 8354|   829k|}
command.c:update_priority:
 8400|  28.9k|{
 8401|       |#if HAVE_WIN32_DESKTOP
 8402|       |    struct MPOpts *opts = mpctx->opts;
 8403|       |    if (opts->w32_priority > 0)
 8404|       |        SetPriorityClass(GetCurrentProcess(), opts->w32_priority);
 8405|       |#endif
 8406|  28.9k|}

mp_parse_cfgfiles:
   69|  28.9k|{
   70|  28.9k|    struct MPOpts *opts = mpctx->opts;
   71|       |
   72|  28.9k|    mp_mk_user_dir(mpctx->global, "home", "");
   73|       |
   74|  28.9k|    char *p1 = mp_get_user_path(NULL, mpctx->global, "~~home/");
   75|  28.9k|    char *p2 = mp_get_user_path(NULL, mpctx->global, "~~old_home/");
   76|  28.9k|    if (strcmp(p1, p2) != 0 && mp_path_exists(p2)) {
  ------------------
  |  Branch (76:9): [True: 0, False: 28.9k]
  |  Branch (76:32): [True: 0, False: 0]
  ------------------
   77|      0|        MP_WARN(mpctx, "Warning, two config dirs found:\n   %s (main)\n"
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   78|      0|                "   %s (bogus)\nYou should merge or delete the second one.\n",
   79|      0|                p1, p2);
   80|      0|    }
   81|  28.9k|    talloc_free(p1);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
   82|  28.9k|    talloc_free(p2);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
   83|       |
   84|  28.9k|    char *section = NULL;
   85|  28.9k|    bool encoding = opts->encode_opts->file && opts->encode_opts->file[0];
  ------------------
  |  Branch (85:21): [True: 0, False: 28.9k]
  |  Branch (85:48): [True: 0, False: 0]
  ------------------
   86|       |    // In encoding mode, we don't want to apply normal config options.
   87|       |    // So we "divert" normal options into a separate section, and the diverted
   88|       |    // section is never used - unless maybe it's explicitly referenced from an
   89|       |    // encoding profile.
   90|  28.9k|    if (encoding)
  ------------------
  |  Branch (90:9): [True: 0, False: 28.9k]
  ------------------
   91|      0|        section = "playback-default";
   92|       |
   93|  28.9k|    load_all_cfgfiles(mpctx, NULL, "encoding-profiles.conf");
   94|       |
   95|  28.9k|    load_all_cfgfiles(mpctx, section, "mpv.conf|config");
   96|       |
   97|  28.9k|    if (encoding) {
  ------------------
  |  Branch (97:9): [True: 0, False: 28.9k]
  ------------------
   98|      0|        m_config_set_profile(mpctx->mconfig, SECT_ENCODE, 0);
  ------------------
  |  |   66|      0|#define SECT_ENCODE "encoding"
  ------------------
   99|      0|        mp_input_enable_section(mpctx->input, "encode", MP_INPUT_EXCLUSIVE);
  100|      0|    }
  101|  28.9k|}
mp_load_auto_profiles:
  165|  31.7k|{
  166|  31.7k|    mp_auto_load_profile(mpctx, "protocol",
  167|  31.7k|                         mp_split_proto(bstr0(mpctx->filename), NULL));
  168|  31.7k|    mp_auto_load_profile(mpctx, "extension",
  169|  31.7k|                         mp_get_ext(bstr0(mpctx->filename)));
  170|       |
  171|  31.7k|    mp_load_per_file_config(mpctx);
  172|  31.7k|}
mp_get_playback_resume_dir:
  203|   136k|{
  204|   136k|    char *wl_dir = mpctx->opts->watch_later_dir;
  205|   136k|    if (wl_dir && wl_dir[0]) {
  ------------------
  |  Branch (205:9): [True: 0, False: 136k]
  |  Branch (205:19): [True: 0, False: 0]
  ------------------
  206|      0|        wl_dir = mp_get_user_path(NULL, mpctx->global, wl_dir);
  207|   136k|    } else {
  208|   136k|        wl_dir = mp_find_user_file(NULL, mpctx->global, "state", MP_WATCH_LATER_CONF);
  ------------------
  |  |  174|   136k|#define MP_WATCH_LATER_CONF "watch_later"
  ------------------
  209|   136k|    }
  210|   136k|    return wl_dir;
  211|   136k|}
mp_load_playback_resume:
  418|  31.7k|{
  419|  31.7k|    bool resume = false;
  420|  31.7k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (420:9): [True: 0, False: 31.7k]
  ------------------
  421|      0|        return resume;
  422|  31.7k|    char *fname = mp_get_playback_resume_config_filename(mpctx, file);
  423|  31.7k|    if (fname && mp_path_exists(fname)) {
  ------------------
  |  Branch (423:9): [True: 0, False: 31.7k]
  |  Branch (423:18): [True: 0, False: 0]
  ------------------
  424|      0|        if (mpctx->opts->position_check_mtime &&
  ------------------
  |  Branch (424:13): [True: 0, False: 0]
  ------------------
  425|      0|            !mp_is_url(bstr0(file)) && !check_mtime(file, fname))
  ------------------
  |  Branch (425:13): [True: 0, False: 0]
  |  Branch (425:40): [True: 0, False: 0]
  ------------------
  426|      0|        {
  427|      0|            talloc_free(fname);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  428|      0|            return resume;
  429|      0|        }
  430|       |
  431|       |        // Never apply the saved start position to following files
  432|      0|        m_config_backup_opt(mpctx->mconfig, "start");
  433|      0|        MP_INFO(mpctx, "Resuming playback. This behavior can "
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  434|      0|               "be disabled with --no-resume-playback.\n");
  435|      0|        try_load_config(mpctx, fname, M_SETOPT_PRESERVE_CMDLINE, MSGL_V);
  436|      0|        resume = true;
  437|      0|    }
  438|  31.7k|    talloc_free(fname);
  ------------------
  |  |   47|  31.7k|#define talloc_free                     ta_free
  ------------------
  439|  31.7k|    return resume;
  440|  31.7k|}
mp_check_playlist_resume:
  449|  31.6k|{
  450|  31.6k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (450:9): [True: 0, False: 31.6k]
  ------------------
  451|      0|        return NULL;
  452|   136k|    for (int n = 0; n < playlist->num_entries; n++) {
  ------------------
  |  Branch (452:21): [True: 104k, False: 31.6k]
  ------------------
  453|   104k|        struct playlist_entry *e = playlist->entries[n];
  454|   104k|        char *conf = mp_get_playback_resume_config_filename(mpctx, e->filename);
  455|   104k|        bool exists = conf && mp_path_exists(conf);
  ------------------
  |  Branch (455:23): [True: 0, False: 104k]
  |  Branch (455:31): [True: 0, False: 0]
  ------------------
  456|   104k|        talloc_free(conf);
  ------------------
  |  |   47|   104k|#define talloc_free                     ta_free
  ------------------
  457|   104k|        if (exists)
  ------------------
  |  Branch (457:13): [True: 0, False: 104k]
  ------------------
  458|      0|            return e;
  459|   104k|    }
  460|  31.6k|    return NULL;
  461|  31.6k|}
configfiles.c:load_all_cfgfiles:
   58|  57.9k|{
   59|  57.9k|    char **cf = mp_find_all_config_files(NULL, mpctx->global, filename);
   60|  57.9k|    for (int i = 0; cf && cf[i]; i++)
  ------------------
  |  Branch (60:21): [True: 57.9k, False: 0]
  |  Branch (60:27): [True: 0, False: 57.9k]
  ------------------
   61|      0|        m_config_parse_config_file(mpctx->mconfig, mpctx->global, cf[i], section, 0);
   62|  57.9k|    talloc_free(cf);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
   63|  57.9k|}
configfiles.c:mp_auto_load_profile:
  151|  63.4k|{
  152|  63.4k|    if (!item.len)
  ------------------
  |  Branch (152:9): [True: 22.2k, False: 41.1k]
  ------------------
  153|  22.2k|        return;
  154|       |
  155|  41.1k|    char t[512];
  156|  41.1k|    snprintf(t, sizeof(t), "%s.%.*s", category, BSTR_P(item));
  ------------------
  |  |  307|  41.1k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 41.1k, False: 0]
  |  |  ------------------
  ------------------
  157|  41.1k|    m_profile_t *p = m_config_get_profile0(mpctx->mconfig, t);
  158|  41.1k|    if (p) {
  ------------------
  |  Branch (158:9): [True: 0, False: 41.1k]
  ------------------
  159|      0|        MP_INFO(mpctx, "Auto-loading profile '%s'\n", t);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|      0|        m_config_set_profile(mpctx->mconfig, t, FILE_LOCAL_FLAGS);
  ------------------
  |  |  115|      0|#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE)
  ------------------
  161|      0|    }
  162|  41.1k|}
configfiles.c:mp_load_per_file_config:
  118|  31.7k|{
  119|  31.7k|    struct MPOpts *opts = mpctx->opts;
  120|  31.7k|    char *confpath;
  121|  31.7k|    char cfg[512];
  122|  31.7k|    const char *file = mpctx->filename;
  123|       |
  124|  31.7k|    if (opts->use_filedir_conf) {
  ------------------
  |  Branch (124:9): [True: 0, False: 31.7k]
  ------------------
  125|      0|        if (snprintf(cfg, sizeof(cfg), "%s.conf", file) >= sizeof(cfg)) {
  ------------------
  |  Branch (125:13): [True: 0, False: 0]
  ------------------
  126|      0|            MP_VERBOSE(mpctx, "Filename is too long, can not load file or "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  127|      0|                              "directory specific config files\n");
  128|      0|            return;
  129|      0|        }
  130|       |
  131|      0|        const char *name = mp_basename(cfg);
  132|       |
  133|      0|        bstr dir = mp_dirname(cfg);
  134|      0|        char *dircfg = mp_path_join_bstr(NULL, dir, bstr0("mpv.conf"));
  135|      0|        try_load_config(mpctx, dircfg, FILE_LOCAL_FLAGS, MSGL_INFO);
  ------------------
  |  |  115|      0|#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE)
  ------------------
  136|      0|        talloc_free(dircfg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  137|       |
  138|      0|        if (try_load_config(mpctx, cfg, FILE_LOCAL_FLAGS, MSGL_INFO))
  ------------------
  |  |  115|      0|#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE)
  ------------------
  |  Branch (138:13): [True: 0, False: 0]
  ------------------
  139|      0|            return;
  140|       |
  141|      0|        if ((confpath = mp_find_config_file(NULL, mpctx->global, name))) {
  ------------------
  |  Branch (141:13): [True: 0, False: 0]
  ------------------
  142|      0|            try_load_config(mpctx, confpath, FILE_LOCAL_FLAGS, MSGL_INFO);
  ------------------
  |  |  115|      0|#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE)
  ------------------
  143|       |
  144|      0|            talloc_free(confpath);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        }
  146|      0|    }
  147|  31.7k|}
configfiles.c:mp_get_playback_resume_config_filename:
  215|   136k|{
  216|   136k|    struct MPOpts *opts = mpctx->opts;
  217|   136k|    char *res = NULL;
  218|   136k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   136k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   136k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  219|   136k|    if (opts->ignore_path_in_watch_later_config && !mp_is_url(bstr0(path)))
  ------------------
  |  Branch (219:9): [True: 0, False: 136k]
  |  Branch (219:52): [True: 0, False: 0]
  ------------------
  220|      0|        path = mp_basename(path);
  221|       |
  222|   136k|    bstr hashstr = mp_hash_to_bstr(tmp, path, strlen(path), "MD5");
  223|   136k|    char *wl_dir = mp_get_playback_resume_dir(mpctx);
  224|   136k|    if (wl_dir && wl_dir[0])
  ------------------
  |  Branch (224:9): [True: 0, False: 136k]
  |  Branch (224:19): [True: 0, False: 0]
  ------------------
  225|      0|        res = mp_path_join_bstr(NULL, bstr0(wl_dir), hashstr);
  226|   136k|    talloc_free(wl_dir);
  ------------------
  |  |   47|   136k|#define talloc_free                     ta_free
  ------------------
  227|   136k|    talloc_free(tmp);
  ------------------
  |  |   47|   136k|#define talloc_free                     ta_free
  ------------------
  228|   136k|    return res;
  229|   136k|}

disc_nav_reset:
  100|   267k|{
  101|   267k|    struct disc_nav_state *st = mpctx->disc_nav;
  102|   267k|    if (!st)
  ------------------
  |  Branch (102:9): [True: 267k, False: 0]
  ------------------
  103|   267k|        return;
  104|      0|    if (st->overlay_visible) {
  ------------------
  |  Branch (104:9): [True: 0, False: 0]
  ------------------
  105|       |        osd_set_bitmaps(mpctx->osd, OSDTYPE_DISC_MENU, NULL);
  106|      0|        mp_input_disable_section(mpctx->input, "discnav");
  107|      0|    }
  108|      0|    mp_image_unrefp(&st->bd_image);
  109|      0|    *st = (struct disc_nav_state){0};
  110|      0|}
disc_nav_destroy:
  113|  28.9k|{
  114|  28.9k|    if (!mpctx->disc_nav)
  ------------------
  |  Branch (114:9): [True: 28.9k, False: 0]
  ------------------
  115|  28.9k|        return;
  116|      0|    mp_image_unrefp(&mpctx->disc_nav->bd_image);
  117|       |    TA_FREEP(&mpctx->disc_nav);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  118|      0|}
disc_nav_get_stream:
  121|   131k|{
  122|   131k|    if (!mpctx->demuxer || !mpctx->demuxer->stream)
  ------------------
  |  Branch (122:9): [True: 0, False: 131k]
  |  Branch (122:28): [True: 0, False: 131k]
  ------------------
  123|      0|        return NULL;
  124|   131k|    struct stream *s = mpctx->demuxer->stream;
  125|   131k|    if (!s->info || !s->info->name)
  ------------------
  |  Branch (125:9): [True: 0, False: 131k]
  |  Branch (125:21): [True: 0, False: 131k]
  ------------------
  126|      0|        return NULL;
  127|   131k|    const char *n = s->info->name;
  128|   131k|    if (strcmp(n, "dvdnav") == 0 || strcmp(n, "ifo_dvdnav") == 0 ||
  ------------------
  |  Branch (128:9): [True: 0, False: 131k]
  |  Branch (128:37): [True: 0, False: 131k]
  ------------------
  129|   131k|        strcmp(n, "bd") == 0 || strcmp(n, "bdmv/bluray") == 0)
  ------------------
  |  Branch (129:9): [True: 0, False: 131k]
  |  Branch (129:33): [True: 0, False: 131k]
  ------------------
  130|      0|    {
  131|      0|        return s;
  132|      0|    }
  133|   131k|    return NULL;
  134|   131k|}
disc_nav_update:
  516|   131k|{
  517|   131k|    struct stream *s = disc_nav_get_stream(mpctx);
  518|   131k|    if (!s && !mpctx->disc_nav)
  ------------------
  |  Branch (518:9): [True: 131k, False: 0]
  |  Branch (518:15): [True: 131k, False: 0]
  ------------------
  519|   131k|        return;
  520|      0|    struct disc_nav_state *st = get_state(mpctx);
  521|      0|    struct stream_nav_state nav = {0};
  522|      0|    bool have = s && stream_control(s, STREAM_CTRL_GET_NAV_STATE, &nav) >= 1;
  ------------------
  |  Branch (522:17): [True: 0, False: 0]
  |  Branch (522:22): [True: 0, False: 0]
  ------------------
  523|      0|    bool still = have && nav.still_active;
  ------------------
  |  Branch (523:18): [True: 0, False: 0]
  |  Branch (523:26): [True: 0, False: 0]
  ------------------
  524|      0|    if (s && still != mpctx->disc_nav_still_frame)
  ------------------
  |  Branch (524:9): [True: 0, False: 0]
  |  Branch (524:14): [True: 0, False: 0]
  ------------------
  525|      0|        MP_VERBOSE(s, "still_frame %d->%d\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  526|      0|                   mpctx->disc_nav_still_frame, still);
  527|      0|    mpctx->disc_nav_still_frame = still;
  528|       |
  529|       |    // BD-J applets schedule against the presentation clock. Left alone
  530|       |    // libbluray derives it from the read position, which runs ahead by the
  531|       |    // whole readahead, set the real playback time.
  532|      0|    if (have && mpctx->playback_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (532:9): [True: 0, False: 0]
  |  Branch (532:17): [True: 0, False: 0]
  ------------------
  533|      0|        double t = mpctx->playback_pts;
  534|      0|        stream_control(s, STREAM_CTRL_SET_PLAYBACK_TIME, &t);
  535|      0|    }
  536|       |
  537|      0|    double rate = mpctx->paused ? 0.0 : mpctx->opts->playback_speed;
  ------------------
  |  Branch (537:19): [True: 0, False: 0]
  ------------------
  538|      0|    if (have && rate != st->pushed_rate) {
  ------------------
  |  Branch (538:9): [True: 0, False: 0]
  |  Branch (538:17): [True: 0, False: 0]
  ------------------
  539|      0|        if (stream_control(s, STREAM_CTRL_SET_PLAYBACK_RATE, &rate) >= 1)
  ------------------
  |  Branch (539:13): [True: 0, False: 0]
  ------------------
  540|      0|            st->pushed_rate = rate;
  541|      0|    }
  542|       |
  543|       |    // The BD-J VM progresses only on reads, pump them while playback idles
  544|       |    // at EOF or a held still, per libbluray's requirement. Our core wakes up
  545|       |    // at 1s intervals even at pause, but that's not enough for fluid button
  546|       |    // navigation. So, we always drive the VM at least at 20Hz.
  547|      0|    if (have && mpctx->demuxer) {
  ------------------
  |  Branch (547:9): [True: 0, False: 0]
  |  Branch (547:17): [True: 0, False: 0]
  ------------------
  548|      0|        bool bd_idle = (strcmp(s->info->name, "bd") == 0 ||
  ------------------
  |  Branch (548:25): [True: 0, False: 0]
  ------------------
  549|      0|                        strcmp(s->info->name, "bdmv/bluray") == 0) &&
  ------------------
  |  Branch (549:25): [True: 0, False: 0]
  ------------------
  550|      0|                       (still || (mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (550:25): [True: 0, False: 0]
  |  Branch (550:35): [True: 0, False: 0]
  ------------------
  551|      0|                                  mpctx->audio_status == STATUS_EOF));
  ------------------
  |  Branch (551:35): [True: 0, False: 0]
  ------------------
  552|      0|        if (bd_idle || (nav.menu_active && mpctx->paused)) {
  ------------------
  |  Branch (552:13): [True: 0, False: 0]
  |  Branch (552:25): [True: 0, False: 0]
  |  Branch (552:44): [True: 0, False: 0]
  ------------------
  553|      0|            if (bd_idle)
  ------------------
  |  Branch (553:17): [True: 0, False: 0]
  ------------------
  554|      0|                demux_drive_nav(mpctx->demuxer);
  555|      0|            mp_set_timeout(mpctx, 0.05);
  556|      0|        }
  557|      0|    }
  558|       |
  559|      0|    if (!have) {
  ------------------
  |  Branch (559:9): [True: 0, False: 0]
  ------------------
  560|      0|        if (st->overlay_visible) {
  ------------------
  |  Branch (560:13): [True: 0, False: 0]
  ------------------
  561|      0|            osd_set_bitmaps(mpctx->osd, OSDTYPE_DISC_MENU, NULL);
  562|      0|            mp_input_disable_section(mpctx->input, "discnav");
  563|      0|            st->overlay_visible = false;
  564|      0|        }
  565|      0|        st->bd_last_change_id = 0;
  566|      0|        st->bd_last_vo_res = (struct mp_osd_res){0};
  567|      0|        st->menu_selected_track = NULL;
  568|      0|        st->menu_saved_track = NULL;
  569|      0|        st->overlay_change_seen = false;
  570|      0|        if (st->menu_active_seen && st->last_menu_active) {
  ------------------
  |  Branch (570:13): [True: 0, False: 0]
  |  Branch (570:37): [True: 0, False: 0]
  ------------------
  571|      0|            st->last_menu_active = false;
  572|      0|            mp_notify_property(mpctx, "disc-menu-active");
  573|      0|        }
  574|      0|        return;
  575|      0|    }
  576|       |
  577|      0|    if (!st->menu_active_seen || nav.menu_active != st->last_menu_active) {
  ------------------
  |  Branch (577:9): [True: 0, False: 0]
  |  Branch (577:34): [True: 0, False: 0]
  ------------------
  578|      0|        st->menu_active_seen = true;
  579|      0|        st->last_menu_active = nav.menu_active;
  580|      0|        mp_notify_property(mpctx, "disc-menu-active");
  581|      0|    }
  582|       |
  583|      0|    run_timed_still(mpctx, s, &nav);
  584|      0|    check_async_discontinuity(mpctx, s, &nav);
  585|      0|    sync_current_edition(mpctx, s, &nav);
  586|      0|    sync_disc_track_selection(mpctx, s, &nav);
  587|       |
  588|      0|    bool is_bd = strcmp(s->info->name, "bd") == 0 || strcmp(s->info->name, "bdmv/bluray") == 0;
  ------------------
  |  Branch (588:18): [True: 0, False: 0]
  |  Branch (588:54): [True: 0, False: 0]
  ------------------
  589|      0|    bool visible = nav.menu_active &&
  ------------------
  |  Branch (589:20): [True: 0, False: 0]
  ------------------
  590|      0|                   (is_bd || (mp_rect_w(nav.hl.rect) > 0 && mp_rect_h(nav.hl.rect) > 0));
  ------------------
  |  |  157|      0|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                                 (is_bd || (mp_rect_w(nav.hl.rect) > 0 && mp_rect_h(nav.hl.rect) > 0));
  ------------------
  |  |  158|      0|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (590:21): [True: 0, False: 0]
  |  Branch (590:31): [True: 0, False: 0]
  |  Branch (590:61): [True: 0, False: 0]
  ------------------
  591|       |
  592|      0|    if (is_bd) {
  ------------------
  |  Branch (592:9): [True: 0, False: 0]
  ------------------
  593|      0|        push_bd_overlay(mpctx, s, &nav, visible);
  594|      0|    } else {
  595|      0|        push_dvd_overlay(mpctx, &nav);
  596|      0|        ensure_menu_sub_selection(mpctx, nav.menu_active);
  597|      0|    }
  598|       |
  599|      0|    if (!st->overlay_change_seen || nav.change_id != st->last_overlay_change_id) {
  ------------------
  |  Branch (599:9): [True: 0, False: 0]
  |  Branch (599:37): [True: 0, False: 0]
  ------------------
  600|      0|        st->overlay_change_seen = true;
  601|      0|        st->last_overlay_change_id = nav.change_id;
  602|      0|        osd_changed(mpctx->osd);
  603|      0|    }
  604|       |
  605|      0|    if (visible != st->overlay_visible) {
  ------------------
  |  Branch (605:9): [True: 0, False: 0]
  ------------------
  606|      0|        MP_VERBOSE(s, "overlay %s\n", visible ? "on" : "off");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|      0|        if (visible) {
  ------------------
  |  Branch (607:13): [True: 0, False: 0]
  ------------------
  608|      0|            mp_input_enable_section(mpctx->input, "discnav",
  609|      0|                MP_INPUT_ON_TOP | MP_INPUT_ALLOW_VO_DRAGGING | MP_INPUT_ALLOW_HIDE_CURSOR);
  610|      0|        } else {
  611|      0|            mp_input_disable_section(mpctx->input, "discnav");
  612|      0|        }
  613|      0|        st->overlay_visible = visible;
  614|      0|    }
  615|      0|}

find_external_files:
  254|  21.8k|{
  255|  21.8k|    struct subfn *slist = talloc_array_ptrtype(NULL, slist, 1);
  ------------------
  |  |   36|  21.8k|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|  21.8k|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  21.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|  21.8k|    int n = 0;
  257|       |
  258|       |    // Load subtitles from current media directory
  259|  21.8k|    append_dir_external_files(global, opts, &slist, &n, mp_dirname(fname), fname, 0, -1);
  260|       |
  261|       |    // Load subtitles in dirs specified by sub-paths option
  262|  21.8k|    if (opts->sub_auto >= 0) {
  ------------------
  |  Branch (262:9): [True: 21.8k, False: 0]
  ------------------
  263|  21.8k|        load_paths(global, opts, &slist, &n, fname, opts->sub_paths, "sub",
  264|  21.8k|                   STREAM_SUB);
  265|  21.8k|    }
  266|       |
  267|  21.8k|    if (opts->audiofile_auto >= 0) {
  ------------------
  |  Branch (267:9): [True: 0, False: 21.8k]
  ------------------
  268|      0|        load_paths(global, opts, &slist, &n, fname, opts->audiofile_paths,
  269|      0|                   "audio", STREAM_AUDIO);
  270|      0|    }
  271|       |
  272|       |    // Sort by name for filter_subidx()
  273|  21.8k|    qsort(slist, n, sizeof(*slist), compare_filename);
  274|       |
  275|  21.8k|    filter_subidx(&slist, &n);
  276|       |
  277|       |    // Sort subs by priority and append them
  278|  21.8k|    qsort(slist, n, sizeof(*slist), compare_priority);
  279|       |
  280|  21.8k|    struct subfn z = {0};
  281|  21.8k|    MP_TARRAY_APPEND(NULL, slist, n, z);
  ------------------
  |  |  105|  21.8k|    do {                                            \
  |  |  106|  21.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  21.8k|    do {                                            \
  |  |  |  |   97|  21.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  21.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  21.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  21.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 21.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  21.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  21.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 21.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  21.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  21.8k|        (idxvar)++;                                 \
  |  |  109|  21.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 21.8k]
  |  |  ------------------
  ------------------
  282|       |
  283|  21.8k|    return slist;
  284|  21.8k|}
external_files.c:append_dir_external_files:
   75|  21.8k|{
   76|  21.8k|    void *tmpmem = talloc_new(NULL);
  ------------------
  |  |   40|  21.8k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  21.8k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   77|  21.8k|    struct mp_log *log = mp_log_new(tmpmem, global->log, "find_files");
   78|       |
   79|  21.8k|    struct bstr f_fbname = bstr0(mp_basename(fname));
   80|  21.8k|    struct bstr f_fname = mp_iconv_to_utf8(log, f_fbname,
   81|  21.8k|                                           "UTF-8-MAC", MP_NO_LATIN1_FALLBACK);
   82|  21.8k|    struct bstr f_fname_noext = bstrdup(tmpmem, mp_strip_ext(f_fname));
   83|  21.8k|    struct bstr f_fname_trim = bstr_strip(f_fname_noext);
   84|       |
   85|  21.8k|    if (f_fbname.start != f_fname.start)
  ------------------
  |  Branch (85:9): [True: 0, False: 21.8k]
  ------------------
   86|      0|        talloc_steal(tmpmem, f_fname.start);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
   87|       |
   88|  21.8k|    char *path0 = bstrdup0(tmpmem, path);
   89|       |
   90|  21.8k|    if (mp_is_url(bstr0(path0)))
  ------------------
  |  Branch (90:9): [True: 21.8k, False: 0]
  ------------------
   91|  21.8k|        goto out;
   92|       |
   93|      0|    DIR *d = opendir(path0);
   94|      0|    if (!d)
  ------------------
  |  Branch (94:9): [True: 0, False: 0]
  ------------------
   95|      0|        goto out;
   96|      0|    mp_verbose(log, "Loading external files in %.*s\n", BSTR_P(path));
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (79:53): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   97|      0|    struct dirent *de;
   98|      0|    while ((de = readdir(d))) {
  ------------------
  |  Branch (98:12): [True: 0, False: 0]
  ------------------
   99|      0|        void *tmpmem2 = talloc_new(tmpmem);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  100|      0|        struct bstr den = bstr0(de->d_name);
  101|      0|        struct bstr dename = mp_iconv_to_utf8(log, den,
  102|      0|                                              "UTF-8-MAC", MP_NO_LATIN1_FALLBACK);
  103|       |        // retrieve various parts of the filename
  104|      0|        struct bstr tmp_fname_noext = bstrdup(tmpmem2, mp_strip_ext(dename));
  105|      0|        struct bstr tmp_fname_ext = mp_get_ext(dename);
  106|      0|        struct bstr tmp_fname_trim = bstr_strip(tmp_fname_noext);
  107|       |
  108|      0|        if (den.start != dename.start)
  ------------------
  |  Branch (108:13): [True: 0, False: 0]
  ------------------
  109|      0|            talloc_steal(tmpmem2, dename.start);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  110|       |
  111|       |        // check what it is (most likely)
  112|      0|        int type = test_ext(opts, tmp_fname_ext);
  113|      0|        char **langs = NULL;
  114|      0|        int fuzz = -1;
  115|      0|        switch (type) {
  ------------------
  |  Branch (115:17): [True: 0, False: 0]
  ------------------
  116|      0|        case STREAM_SUB:
  ------------------
  |  Branch (116:9): [True: 0, False: 0]
  ------------------
  117|      0|            langs = opts->stream_lang[type];
  118|      0|            fuzz = opts->sub_auto;
  119|      0|            break;
  120|      0|        case STREAM_AUDIO:
  ------------------
  |  Branch (120:9): [True: 0, False: 0]
  ------------------
  121|      0|            langs = opts->stream_lang[type];
  122|      0|            fuzz = opts->audiofile_auto;
  123|      0|            break;
  124|      0|        case STREAM_VIDEO:
  ------------------
  |  Branch (124:9): [True: 0, False: 0]
  ------------------
  125|      0|            fuzz = opts->coverart_auto;
  126|      0|            break;
  127|      0|        }
  128|       |
  129|      0|        if (fuzz < 0 || (limit_type >= 0 && limit_type != type))
  ------------------
  |  Branch (129:13): [True: 0, False: 0]
  |  Branch (129:26): [True: 0, False: 0]
  |  Branch (129:45): [True: 0, False: 0]
  ------------------
  130|      0|            goto next_file;
  131|       |
  132|       |        // we have a (likely) subtitle file
  133|       |        // higher prio -> auto-selection may prefer it (0 = not loaded)
  134|      0|        int prio = 0;
  135|       |
  136|      0|        if (bstrcasecmp(tmp_fname_trim, f_fname_trim) == 0)
  ------------------
  |  Branch (136:13): [True: 0, False: 0]
  ------------------
  137|      0|            prio |= 32; // exact movie name match
  138|       |
  139|      0|        bstr lang = {0};
  140|      0|        int start = 0;
  141|      0|        enum track_flags flags = 0;
  142|      0|        lang = mp_guess_lang_from_filename(dename, &start, &flags);
  143|      0|        if (bstr_case_startswith(tmp_fname_trim, f_fname_trim)) {
  ------------------
  |  Branch (143:13): [True: 0, False: 0]
  ------------------
  144|      0|            if (lang.len && start == f_fname_trim.len)
  ------------------
  |  Branch (144:17): [True: 0, False: 0]
  |  Branch (144:29): [True: 0, False: 0]
  ------------------
  145|      0|                prio |= 16; // exact movie name + followed by lang
  146|       |
  147|      0|            if (lang.len && fuzz >= 1)
  ------------------
  |  Branch (147:17): [True: 0, False: 0]
  |  Branch (147:29): [True: 0, False: 0]
  ------------------
  148|      0|                prio |= 4; // matches the movie name + a language was matched
  149|       |
  150|      0|            for (int n = 0; langs && langs[n]; n++) {
  ------------------
  |  Branch (150:29): [True: 0, False: 0]
  |  Branch (150:38): [True: 0, False: 0]
  ------------------
  151|      0|                if (lang.len && bstr_case_startswith(lang, bstr0(langs[n]))) {
  ------------------
  |  Branch (151:21): [True: 0, False: 0]
  |  Branch (151:33): [True: 0, False: 0]
  ------------------
  152|      0|                    if (fuzz >= 1)
  ------------------
  |  Branch (152:25): [True: 0, False: 0]
  ------------------
  153|      0|                        prio |= 8; // known language -> boost priority
  154|      0|                    break;
  155|      0|                }
  156|      0|            }
  157|      0|        }
  158|       |
  159|      0|        if (bstr_find(tmp_fname_trim, f_fname_trim) >= 0 && fuzz >= 1)
  ------------------
  |  Branch (159:13): [True: 0, False: 0]
  |  Branch (159:61): [True: 0, False: 0]
  ------------------
  160|      0|            prio |= 2; // contains the movie name
  161|       |
  162|      0|        if (type == STREAM_VIDEO && prio == 0)
  ------------------
  |  Branch (162:13): [True: 0, False: 0]
  |  Branch (162:37): [True: 0, False: 0]
  ------------------
  163|      0|            prio = test_cover_filename(tmp_fname_trim, opts->coverart_whitelist);
  164|       |
  165|       |        // doesn't contain the movie name
  166|       |        // don't try in the mplayer subtitle directory
  167|      0|        if (!limit_fuzziness && fuzz >= 2 && prio == 0)
  ------------------
  |  Branch (167:13): [True: 0, False: 0]
  |  Branch (167:33): [True: 0, False: 0]
  |  Branch (167:46): [True: 0, False: 0]
  ------------------
  168|      0|            prio = INT_MIN;
  169|       |
  170|      0|        if (prio) {
  ------------------
  |  Branch (170:13): [True: 0, False: 0]
  ------------------
  171|      0|            mp_trace(log, "Potential external file: \"%s\"  Priority: %d\n",
  ------------------
  |  |   81|      0|#define mp_trace(log, ...)      mp_msg(log, MSGL_TRACE, __VA_ARGS__)
  ------------------
  172|      0|                   de->d_name, prio);
  173|      0|            char *extpath = mp_path_join_bstr(*slist, path, dename);
  174|      0|            if (mp_path_exists(extpath)) {
  ------------------
  |  Branch (174:17): [True: 0, False: 0]
  ------------------
  175|      0|                MP_TARRAY_GROW(NULL, *slist, *nsub);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  176|      0|                struct subfn *sub = *slist + (*nsub)++;
  177|       |
  178|       |                // annoying and redundant
  179|      0|                if (strncmp(extpath, "./", 2) == 0)
  ------------------
  |  Branch (179:21): [True: 0, False: 0]
  ------------------
  180|      0|                    extpath += 2;
  181|       |
  182|      0|                sub->type     = type;
  183|      0|                sub->priority = prio;
  184|      0|                sub->fname    = extpath;
  185|      0|                sub->lang     = lang.len ? bstrdup0(*slist, lang) : NULL;
  ------------------
  |  Branch (185:33): [True: 0, False: 0]
  ------------------
  186|      0|                sub->flags    = flags;
  187|      0|            } else
  188|      0|                talloc_free(extpath);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  189|      0|        }
  190|       |
  191|      0|    next_file:
  192|      0|        talloc_free(tmpmem2);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  193|      0|    }
  194|      0|    closedir(d);
  195|       |
  196|  21.8k| out:
  197|  21.8k|    talloc_free(tmpmem);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  198|  21.8k|}
external_files.c:load_paths:
  230|  21.8k|{
  231|  21.8k|    for (int i = 0; paths && paths[i]; i++) {
  ------------------
  |  Branch (231:21): [True: 0, False: 21.8k]
  |  Branch (231:30): [True: 0, False: 0]
  ------------------
  232|      0|        char *expanded_path = mp_get_user_path(NULL, global, paths[i]);
  233|      0|        char *path = mp_path_join_bstr(
  234|      0|            *slist, mp_dirname(fname),
  235|      0|            bstr0(expanded_path ? expanded_path : paths[i]));
  ------------------
  |  Branch (235:19): [True: 0, False: 0]
  ------------------
  236|      0|        append_dir_external_files(global, opts, slist, nsubs, bstr0(path),
  237|      0|                                  fname, 0, type);
  238|      0|        talloc_free(expanded_path);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  239|      0|    }
  240|       |
  241|       |    // Load subtitles in ~/.mpv/sub (or similar) limiting sub fuzziness
  242|  21.8k|    char *mp_subdir = mp_find_config_file(NULL, global, cfg_path);
  243|  21.8k|    if (mp_subdir) {
  ------------------
  |  Branch (243:9): [True: 0, False: 21.8k]
  ------------------
  244|      0|        append_dir_external_files(global, opts, slist, nsubs, bstr0(mp_subdir),
  245|      0|                                  fname, 1, type);
  246|      0|    }
  247|  21.8k|    talloc_free(mp_subdir);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  248|  21.8k|}
external_files.c:filter_subidx:
  210|  21.8k|{
  211|  21.8k|    const char *prev = NULL;
  212|  21.8k|    for (int n = 0; n < *nsub; n++) {
  ------------------
  |  Branch (212:21): [True: 0, False: 21.8k]
  ------------------
  213|      0|        const char *fname = (*slist)[n].fname;
  214|      0|        if (case_endswith(fname, ".idx")) {
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            prev = fname;
  216|      0|        } else if (case_endswith(fname, ".sub")) {
  ------------------
  |  Branch (216:20): [True: 0, False: 0]
  ------------------
  217|      0|            if (prev && strncmp(prev, fname, strlen(fname) - 4) == 0)
  ------------------
  |  Branch (217:17): [True: 0, False: 0]
  |  Branch (217:25): [True: 0, False: 0]
  ------------------
  218|      0|                (*slist)[n].priority = 0;
  219|      0|        }
  220|      0|    }
  221|  21.8k|    for (int n = *nsub - 1; n >= 0; n--) {
  ------------------
  |  Branch (221:29): [True: 0, False: 21.8k]
  ------------------
  222|      0|        if ((*slist)[n].priority == 0)
  ------------------
  |  Branch (222:13): [True: 0, False: 0]
  ------------------
  223|       |            MP_TARRAY_REMOVE_AT(*slist, *nsub, n);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (223:13): [True: 0, False: 0]
  ------------------
  224|      0|    }
  225|  21.8k|}

mp_abort_playback_async:
   73|   133k|{
   74|   133k|    mp_cancel_trigger(mpctx->playback_abort);
   75|       |
   76|   133k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|   133k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   77|       |
   78|   133k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (78:21): [True: 0, False: 133k]
  ------------------
   79|      0|        struct mp_abort_entry *abort = mpctx->abort_list[n];
   80|      0|        if (abort->coupled_to_playback)
  ------------------
  |  Branch (80:13): [True: 0, False: 0]
  ------------------
   81|      0|            mp_abort_trigger_locked(mpctx, abort);
   82|      0|    }
   83|       |
   84|   133k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|   133k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|   133k|}
track_is_visible:
  318|  50.5k|{
  319|  50.5k|    if (!track_in_current_edition(mpctx, track))
  ------------------
  |  Branch (319:9): [True: 0, False: 50.5k]
  ------------------
  320|      0|        return false;
  321|  50.5k|    if (track->dependent_track && !mpctx->opts->show_dependent_tracks)
  ------------------
  |  Branch (321:9): [True: 0, False: 50.5k]
  |  Branch (321:35): [True: 0, False: 0]
  ------------------
  322|      0|        return false;
  323|  50.5k|    return true;
  324|  50.5k|}
print_track_list:
  327|  21.8k|{
  328|  21.8k|    if (mpctx->opts->term_show_tracks == 2)
  ------------------
  |  Branch (328:9): [True: 0, False: 21.8k]
  ------------------
  329|      0|        return;
  330|  21.8k|    if (msg)
  ------------------
  |  Branch (330:9): [True: 0, False: 21.8k]
  ------------------
  331|  21.8k|        MP_INFO(mpctx, "%s\n", msg);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  332|  87.2k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (332:21): [True: 65.4k, False: 21.8k]
  ------------------
  333|   137k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (333:25): [True: 72.1k, False: 65.4k]
  ------------------
  334|  72.1k|            struct track *track = mpctx->tracks[n];
  335|  72.1k|            if (track->type != t || !track_is_visible(mpctx, track))
  ------------------
  |  Branch (335:17): [True: 48.0k, False: 24.0k]
  |  Branch (335:37): [True: 0, False: 24.0k]
  ------------------
  336|  48.0k|                continue;
  337|  24.0k|            if (mpctx->opts->term_show_tracks == 1 && !track->selected)
  ------------------
  |  Branch (337:17): [True: 0, False: 24.0k]
  |  Branch (337:55): [True: 0, False: 0]
  ------------------
  338|      0|                continue;
  339|       |            // Indent tracks after messages like "Tracks switched" and
  340|       |            // "Playing:".
  341|  24.0k|            print_stream(mpctx, track, msg ||
  ------------------
  |  Branch (341:40): [True: 0, False: 24.0k]
  ------------------
  342|  24.0k|                         mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (342:26): [True: 392, False: 23.6k]
  ------------------
  343|  23.6k|                         mpctx->playing->playlist_path);
  ------------------
  |  Branch (343:26): [True: 54, False: 23.5k]
  ------------------
  344|  24.0k|        }
  345|  65.4k|    }
  346|  21.8k|}
update_demuxer_properties:
  349|   153k|{
  350|   153k|    struct demuxer *demuxer = mpctx->demuxer;
  351|   153k|    if (!demuxer)
  ------------------
  |  Branch (351:9): [True: 0, False: 153k]
  ------------------
  352|      0|        return;
  353|   153k|    demux_update(demuxer, get_current_time(mpctx));
  354|   153k|    int events = demuxer->events;
  355|   153k|    if ((events & DEMUX_EVENT_INIT) && demuxer->num_editions > 1 &&
  ------------------
  |  Branch (355:9): [True: 21.8k, False: 131k]
  |  Branch (355:40): [True: 0, False: 21.8k]
  ------------------
  356|      0|        mpctx->opts->term_show_editions != 2)
  ------------------
  |  Branch (356:9): [True: 0, False: 0]
  ------------------
  357|      0|    {
  358|      0|        for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (358:25): [True: 0, False: 0]
  ------------------
  359|      0|            if (mpctx->opts->term_show_editions == 1 && n != demuxer->edition)
  ------------------
  |  Branch (359:17): [True: 0, False: 0]
  |  Branch (359:57): [True: 0, False: 0]
  ------------------
  360|      0|                continue;
  361|      0|            struct demux_edition *edition = &demuxer->editions[n];
  362|      0|            char b[128] = {0};
  363|      0|            if (mpctx->playlist->num_entries > 1 || mpctx->playing->playlist_path)
  ------------------
  |  Branch (363:17): [True: 0, False: 0]
  |  Branch (363:53): [True: 0, False: 0]
  ------------------
  364|      0|                APPEND(b, " ");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  365|      0|            APPEND(b, "%s --edition=%d", n == demuxer->edition ?
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  366|      0|                   BLACK_CIRCLE : WHITE_CIRCLE, n);
  367|      0|            char *name = mp_tags_get_str(edition->metadata, "title");
  368|      0|            if (name)
  ------------------
  |  Branch (368:17): [True: 0, False: 0]
  ------------------
  369|      0|                APPEND(b, " '%s'", name);
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  370|      0|            if (edition->default_edition)
  ------------------
  |  Branch (370:17): [True: 0, False: 0]
  ------------------
  371|      0|                APPEND(b, " [default]");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  372|      0|            MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  373|      0|        }
  374|      0|    }
  375|   153k|    struct demuxer *tracks = mpctx->demuxer;
  376|   153k|    if (tracks->events & DEMUX_EVENT_STREAMS) {
  ------------------
  |  Branch (376:9): [True: 21.8k, False: 131k]
  ------------------
  377|  21.8k|        int num_old_tracks = mpctx->num_tracks;
  378|  21.8k|        add_demuxer_tracks(mpctx, tracks);
  379|  21.8k|        tracks->events &= ~DEMUX_EVENT_STREAMS;
  380|       |
  381|       |        // Streams surfaced after play_current_file's selection phase (e.g.
  382|       |        // disc-nav playlist hop, or lavf identifying a PES stream only once
  383|       |        // its first packet arrives) wouldn't otherwise get auto-selected.
  384|       |        // Only such a stream may claim a free slot, one that disc navigation
  385|       |        // or a failed decoder emptied stays empty.
  386|  21.8k|        if (mpctx->playback_initialized && mpctx->opts->stream_auto_sel) {
  ------------------
  |  Branch (386:13): [True: 9, False: 21.8k]
  |  Branch (386:44): [True: 9, False: 0]
  ------------------
  387|     36|            for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (387:29): [True: 27, False: 9]
  ------------------
  388|     63|                for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (388:33): [True: 36, False: 27]
  ------------------
  389|     36|                    if (mpctx->current_track[i][t])
  ------------------
  |  Branch (389:25): [True: 9, False: 27]
  ------------------
  390|      9|                        continue;
  391|       |                    // The output belongs to a complex filter.
  392|     27|                    if ((t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (392:26): [True: 9, False: 18]
  |  Branch (392:47): [True: 0, False: 9]
  ------------------
  393|     27|                        (t == STREAM_AUDIO && mpctx->ao_chain))
  ------------------
  |  Branch (393:26): [True: 0, False: 27]
  |  Branch (393:47): [True: 0, False: 0]
  ------------------
  394|      0|                        continue;
  395|     27|                    if (mpctx->opts->stream_id[i][t] == -2)
  ------------------
  |  Branch (395:25): [True: 9, False: 18]
  ------------------
  396|      9|                        continue;
  397|     18|                    struct track *sel = select_default_track(mpctx, i, t);
  398|     18|                    bool is_new = false;
  399|     36|                    for (int n = num_old_tracks; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (399:50): [True: 18, False: 18]
  ------------------
  400|     18|                        is_new |= mpctx->tracks[n] == sel;
  401|     18|                    if (is_new)
  ------------------
  |  Branch (401:25): [True: 2, False: 16]
  ------------------
  402|      2|                        mp_switch_track_n(mpctx, i, t, sel, 0);
  403|     18|                }
  404|     27|            }
  405|      9|        }
  406|  21.8k|        print_track_list(mpctx, NULL);
  407|  21.8k|    }
  408|   153k|    if (events & DEMUX_EVENT_METADATA) {
  ------------------
  |  Branch (408:9): [True: 21.8k, False: 131k]
  ------------------
  409|  21.8k|        struct mp_tags *info =
  410|  21.8k|            mp_tags_filtered(mpctx, demuxer->metadata, mpctx->opts->display_tags);
  411|       |        // prev is used to attempt to print changed tags only (to some degree)
  412|  21.8k|        struct mp_tags *prev = mpctx->filtered_tags;
  413|  21.8k|        int n_prev = 0;
  414|  21.8k|        bool had_output = false;
  415|  22.7k|        for (int n = 0; n < info->num_keys; n++) {
  ------------------
  |  Branch (415:25): [True: 903, False: 21.8k]
  ------------------
  416|    903|            if (prev && n_prev < prev->num_keys) {
  ------------------
  |  Branch (416:17): [True: 0, False: 903]
  |  Branch (416:25): [True: 0, False: 0]
  ------------------
  417|      0|                if (strcmp(prev->keys[n_prev], info->keys[n]) == 0) {
  ------------------
  |  Branch (417:21): [True: 0, False: 0]
  ------------------
  418|      0|                    n_prev++;
  419|      0|                    if (strcmp(prev->values[n_prev - 1], info->values[n]) == 0)
  ------------------
  |  Branch (419:25): [True: 0, False: 0]
  ------------------
  420|      0|                        continue;
  421|      0|                }
  422|      0|            }
  423|    903|            struct mp_log *log = mp_log_new(NULL, mpctx->log, "!display-tags");
  424|    903|            if (!had_output)
  ------------------
  |  Branch (424:17): [True: 181, False: 722]
  ------------------
  425|    181|                mp_info(log, "File tags:\n");
  ------------------
  |  |   78|    181|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  426|    903|            mp_info(log, " %s: ", info->keys[n]);
  ------------------
  |  |   78|    903|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  427|    903|            const char *p = info->values[n];
  428|  14.0k|            while (*p) {
  ------------------
  |  Branch (428:20): [True: 13.1k, False: 903]
  ------------------
  429|  13.1k|                int len = strcspn(p, "\x8\xa\xb\xc\xd");
  430|  13.1k|                mp_info(log, "%.*s", len, p);
  ------------------
  |  |   78|  13.1k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  431|  13.1k|                p += len;
  432|  13.1k|                if (*p == '\r')
  ------------------
  |  Branch (432:21): [True: 879, False: 12.2k]
  ------------------
  433|    879|                    mp_info(log, " ");
  ------------------
  |  |   78|    879|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  434|       |                // Align continued lines with header
  435|  13.1k|                if (*p == '\n')
  ------------------
  |  Branch (435:21): [True: 7.47k, False: 5.70k]
  ------------------
  436|  7.47k|                    mp_info(log, "\n %-*s  ", (int)strlen(info->keys[n]), "");
  ------------------
  |  |   78|  7.47k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  437|  13.1k|                if (*p)
  ------------------
  |  Branch (437:21): [True: 12.3k, False: 839]
  ------------------
  438|  12.3k|                    p++;
  439|  13.1k|            }
  440|    903|            mp_info(log, "\n");
  ------------------
  |  |   78|    903|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  441|    903|            had_output = true;
  442|    903|            talloc_free(log);
  ------------------
  |  |   47|    903|#define talloc_free                     ta_free
  ------------------
  443|    903|        }
  444|  21.8k|        talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  445|  21.8k|        mpctx->filtered_tags = info;
  446|  21.8k|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
  447|  21.8k|    }
  448|   153k|    if (events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (448:9): [True: 40.5k, False: 112k]
  ------------------
  449|  40.5k|        mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL);
  450|   153k|    if (events & DEMUX_EVENT_CODEC)
  ------------------
  |  Branch (450:9): [True: 0, False: 153k]
  ------------------
  451|      0|        mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  452|   153k|    if (events & DEMUX_EVENT_LISTS) {
  ------------------
  |  Branch (452:9): [True: 0, False: 153k]
  ------------------
  453|       |        // Demuxer just published a new chapter / edition list at runtime.
  454|      0|        char *chapter_file = mpctx->opts->chapter_file;
  455|      0|        if (!chapter_file || !chapter_file[0]) {
  ------------------
  |  Branch (455:13): [True: 0, False: 0]
  |  Branch (455:30): [True: 0, False: 0]
  ------------------
  456|      0|            TA_FREEP(&mpctx->chapters);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  457|      0|            mpctx->num_chapters = demuxer->num_chapters;
  458|      0|            if (demuxer->num_chapters > 0) {
  ------------------
  |  Branch (458:17): [True: 0, False: 0]
  ------------------
  459|      0|                mpctx->chapters = demux_copy_chapter_data(demuxer->chapters,
  460|      0|                                                         demuxer->num_chapters);
  461|      0|                if (mpctx->opts->rebase_start_time) {
  ------------------
  |  Branch (461:21): [True: 0, False: 0]
  ------------------
  462|      0|                    for (int n = 0; n < mpctx->num_chapters; n++)
  ------------------
  |  Branch (462:37): [True: 0, False: 0]
  ------------------
  463|      0|                        mpctx->chapters[n].pts -= demuxer->start_time;
  464|      0|                }
  465|      0|            }
  466|       |            mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
  467|      0|            mp_notify_property(mpctx, "chapter-list");
  468|      0|            mp_notify_property(mpctx, "chapters");
  469|      0|        }
  470|      0|        mp_notify_property(mpctx, "edition");
  471|      0|        mp_notify_property(mpctx, "edition-list");
  472|      0|        mp_notify_property(mpctx, "current-edition");
  473|      0|        mp_notify_property(mpctx, "editions");
  474|      0|    }
  475|   153k|    demuxer->events = 0;
  476|   153k|}
reselect_demux_stream:
  483|  26.5k|{
  484|  26.5k|    if (!track->stream)
  ------------------
  |  Branch (484:9): [True: 0, False: 26.5k]
  ------------------
  485|      0|        return;
  486|  26.5k|    double pts = get_current_time(mpctx);
  487|  26.5k|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  26.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (487:9): [True: 26.5k, False: 0]
  ------------------
  488|  26.5k|        pts += get_track_seek_offset(mpctx, track);
  489|  26.5k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (489:13): [True: 1.94k, False: 24.5k]
  ------------------
  490|  1.94k|            pts -= 10.0;
  491|  26.5k|    }
  492|  26.5k|    if (refresh_only)
  ------------------
  |  Branch (492:9): [True: 0, False: 26.5k]
  ------------------
  493|      0|        demuxer_refresh_track(track->demuxer, track->stream, pts);
  494|  26.5k|    else
  495|  26.5k|        demuxer_select_track(track->demuxer, track->stream, pts, track->selected);
  496|  26.5k|}
add_demuxer_tracks:
  556|  43.6k|{
  557|  91.6k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++)
  ------------------
  |  Branch (557:21): [True: 48.0k, False: 43.6k]
  ------------------
  558|  48.0k|        add_stream_track(mpctx, demuxer, demux_get_stream(demuxer, n));
  559|  43.6k|}
select_default_track:
  677|  89.6k|{
  678|  89.6k|    struct MPOpts *opts = mpctx->opts;
  679|  89.6k|    int tid = opts->stream_id[order][type];
  680|  89.6k|    const struct demuxer *demuxer = mpctx->demuxer;
  681|  89.6k|    if (tid == -2)
  ------------------
  |  Branch (681:9): [True: 21.8k, False: 67.8k]
  ------------------
  682|  21.8k|        return NULL;
  683|  67.8k|    char **langs = process_langs(opts->stream_lang[type]);
  684|  67.8k|    bool os_langs = false;
  685|       |    // Try to add OS languages if enabled by the user and we don't already have a lang from slang.
  686|  67.8k|    if (type == STREAM_SUB && (!langs || !strcmp(langs[0], "")) && opts->subs_match_os_language) {
  ------------------
  |  Branch (686:9): [True: 21.8k, False: 46.0k]
  |  Branch (686:32): [True: 21.8k, False: 0]
  |  Branch (686:42): [True: 0, False: 0]
  |  Branch (686:68): [True: 21.8k, False: 0]
  ------------------
  687|  21.8k|        talloc_free(langs);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  688|  21.8k|        langs = add_os_langs();
  689|  21.8k|        os_langs = true;
  690|  21.8k|    }
  691|  67.8k|    const char *audio_lang = mpctx->current_track[0][STREAM_AUDIO] ?
  ------------------
  |  Branch (691:30): [True: 12.8k, False: 55.0k]
  ------------------
  692|  12.8k|                             mpctx->current_track[0][STREAM_AUDIO]->lang :
  693|  67.8k|                             NULL;
  694|  67.8k|    bool sub = type == STREAM_SUB;
  695|  67.8k|    int *preferred_programs = NULL;
  696|  67.8k|    int num_preferred_programs = 0;
  697|  67.8k|    struct track *cvt = mpctx->current_track[0][STREAM_VIDEO];
  698|  67.8k|    bool video_has_programs = cvt && cvt->stream && cvt->stream->num_program_ids;
  ------------------
  |  Branch (698:31): [True: 21.4k, False: 46.4k]
  |  Branch (698:38): [True: 21.4k, False: 0]
  |  Branch (698:53): [True: 0, False: 21.4k]
  ------------------
  699|  67.8k|    bool no_edition_mapping = !demuxer || !demuxer->edition_is_track_mapping ||
  ------------------
  |  Branch (699:31): [True: 0, False: 67.8k]
  |  Branch (699:43): [True: 67.8k, False: 0]
  ------------------
  700|      0|                              demuxer->num_editions <= 1;
  ------------------
  |  Branch (700:31): [True: 0, False: 0]
  ------------------
  701|  67.8k|    if (type != STREAM_VIDEO && video_has_programs && no_edition_mapping) {
  ------------------
  |  Branch (701:9): [True: 44.0k, False: 23.8k]
  |  Branch (701:33): [True: 0, False: 44.0k]
  |  Branch (701:55): [True: 0, False: 0]
  ------------------
  702|      0|        preferred_programs = cvt->stream->program_ids;
  703|      0|        num_preferred_programs = cvt->stream->num_program_ids;
  704|      0|    }
  705|  67.8k|    struct track *pick = NULL;
  706|   142k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (706:21): [True: 74.7k, False: 67.8k]
  ------------------
  707|  74.7k|        struct track *track = mpctx->tracks[n];
  708|  74.7k|        if (track->type != type)
  ------------------
  |  Branch (708:13): [True: 48.3k, False: 26.4k]
  ------------------
  709|  48.3k|            continue;
  710|  26.4k|        if (!track_is_visible(mpctx, track))
  ------------------
  |  Branch (710:13): [True: 0, False: 26.4k]
  ------------------
  711|      0|            continue;
  712|  26.4k|        if (track->user_tid == tid) {
  ------------------
  |  Branch (712:13): [True: 0, False: 26.4k]
  ------------------
  713|      0|            pick = track;
  714|      0|            goto cleanup;
  715|      0|        }
  716|  26.4k|        if (track->no_auto_select || track->dec_failed)
  ------------------
  |  Branch (716:13): [True: 0, False: 26.4k]
  |  Branch (716:38): [True: 2.45k, False: 24.0k]
  ------------------
  717|  2.45k|            continue;
  718|  24.0k|        if (!opts->autoload_files && track->is_external)
  ------------------
  |  Branch (718:13): [True: 0, False: 24.0k]
  |  Branch (718:38): [True: 0, False: 0]
  ------------------
  719|      0|            continue;
  720|       |        // Prefer tracks from the same programs as the selected video.
  721|  24.0k|        bool in_program = !num_preferred_programs || track->is_external ||
  ------------------
  |  Branch (721:27): [True: 24.0k, False: 0]
  |  Branch (721:54): [True: 0, False: 0]
  ------------------
  722|      0|                          !track->stream || !track->stream->num_program_ids;
  ------------------
  |  Branch (722:27): [True: 0, False: 0]
  |  Branch (722:45): [True: 0, False: 0]
  ------------------
  723|  24.0k|        for (int i = 0; i < num_preferred_programs && !in_program; i++)
  ------------------
  |  Branch (723:25): [True: 0, False: 24.0k]
  |  Branch (723:55): [True: 0, False: 0]
  ------------------
  724|      0|            in_program = track_has_program(track, preferred_programs[i]);
  725|  24.0k|        if (!in_program)
  ------------------
  |  Branch (725:13): [True: 0, False: 24.0k]
  ------------------
  726|      0|            continue;
  727|  24.0k|        if (duplicate_track(mpctx, order, type, track))
  ------------------
  |  Branch (727:13): [True: 0, False: 24.0k]
  ------------------
  728|      0|            continue;
  729|  24.0k|        if (sub) {
  ------------------
  |  Branch (729:13): [True: 1.94k, False: 22.0k]
  ------------------
  730|       |            // Subtitle specific auto-selecting crap.
  731|  1.94k|            bool audio_matches = mp_match_lang((char *[]){ (char *)audio_lang, NULL }, track->lang) > 0;
  732|  1.94k|            bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
  ------------------
  |  Branch (732:27): [True: 0, False: 1.94k]
  |  Branch (732:51): [True: 0, False: 0]
  ------------------
  733|      0|                          (audio_matches && opts->subs_fallback_forced == 1));
  ------------------
  |  Branch (733:28): [True: 0, False: 0]
  |  Branch (733:45): [True: 0, False: 0]
  ------------------
  734|  1.94k|            bool lang_match = !os_langs && mp_match_lang(langs, track->lang) > 0;
  ------------------
  |  Branch (734:31): [True: 0, False: 1.94k]
  |  Branch (734:44): [True: 0, False: 0]
  ------------------
  735|  1.94k|            bool subs_fallback = (track->is_external && !track->no_default) || opts->subs_fallback == 2 ||
  ------------------
  |  Branch (735:35): [True: 0, False: 1.94k]
  |  Branch (735:57): [True: 0, False: 0]
  |  Branch (735:80): [True: 0, False: 1.94k]
  ------------------
  736|  1.94k|                                 (opts->subs_fallback == 1 && track->default_track);
  ------------------
  |  Branch (736:35): [True: 1.94k, False: 0]
  |  Branch (736:63): [True: 0, False: 1.94k]
  ------------------
  737|  1.94k|            bool subs_matching_audio = (!mp_match_lang(langs, audio_lang) || opts->subs_with_matching_audio == 2 ||
  ------------------
  |  Branch (737:41): [True: 1.94k, False: 0]
  |  Branch (737:78): [True: 0, False: 0]
  ------------------
  738|      0|                                        (opts->subs_with_matching_audio == 1 && track->forced_track));
  ------------------
  |  Branch (738:42): [True: 0, False: 0]
  |  Branch (738:81): [True: 0, False: 0]
  ------------------
  739|  1.94k|            if (!subs_matching_audio)
  ------------------
  |  Branch (739:17): [True: 0, False: 1.94k]
  ------------------
  740|      0|                continue;
  741|  1.94k|            if (!forced && !lang_match && !subs_fallback)
  ------------------
  |  Branch (741:17): [True: 1.94k, False: 0]
  |  Branch (741:28): [True: 1.94k, False: 0]
  |  Branch (741:43): [True: 1.94k, False: 0]
  ------------------
  742|  1.94k|                continue;
  743|      0|            track->forced_select = forced;
  744|      0|        }
  745|  22.0k|        if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts)) {
  ------------------
  |  Branch (745:13): [True: 21.8k, False: 185]
  |  Branch (745:22): [True: 0, False: 185]
  ------------------
  746|  21.8k|            pick = track;
  747|  21.8k|        }
  748|  22.0k|    }
  749|       |
  750|  67.8k|    if (pick && pick->attached_picture && !mpctx->opts->audio_display)
  ------------------
  |  Branch (750:9): [True: 21.8k, False: 45.9k]
  |  Branch (750:17): [True: 0, False: 21.8k]
  |  Branch (750:43): [True: 0, False: 0]
  ------------------
  751|      0|        pick = NULL;
  752|  67.8k|cleanup:
  753|  67.8k|    talloc_free(langs);
  ------------------
  |  |   47|  67.8k|#define talloc_free                     ta_free
  ------------------
  754|  67.8k|    return pick;
  755|  67.8k|}
mark_track_selection:
  801|  2.50k|{
  802|  2.50k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  2.50k|#define mp_assert assert
  ------------------
  |  Branch (802:5): [True: 2.50k, False: 0]
  |  Branch (802:5): [True: 2.50k, False: 0]
  ------------------
  803|  2.50k|    mpctx->opts->stream_id[order][type] = value;
  804|  2.50k|    m_config_notify_change_opt_ptr(mpctx->mconfig,
  805|  2.50k|                                   &mpctx->opts->stream_id[order][type]);
  806|  2.50k|}
mp_switch_track_n:
  810|  2.51k|{
  811|  2.51k|    mp_assert(!track || track->type == type);
  ------------------
  |  |   41|  2.51k|#define mp_assert assert
  ------------------
  |  Branch (811:5): [True: 2.50k, False: 12]
  |  Branch (811:5): [True: 12, False: 0]
  ------------------
  812|  2.51k|    mp_assert(type >= 0 && type < STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  2.51k|#define mp_assert assert
  ------------------
  |  Branch (812:5): [True: 2.51k, False: 0]
  |  Branch (812:5): [True: 2.51k, False: 0]
  ------------------
  813|  2.51k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  2.51k|#define mp_assert assert
  ------------------
  |  Branch (813:5): [True: 2.51k, False: 0]
  |  Branch (813:5): [True: 2.51k, False: 0]
  ------------------
  814|       |
  815|       |    // Mark the current track selection as explicitly user-requested. (This is
  816|       |    // different from auto-selection or disabling a track due to errors.)
  817|  2.51k|    if (flags & FLAG_MARK_SELECTION)
  ------------------
  |  |  559|  2.51k|#define FLAG_MARK_SELECTION 1
  ------------------
  |  Branch (817:9): [True: 0, False: 2.51k]
  ------------------
  818|      0|        mark_track_selection(mpctx, order, type, track ? track->user_tid : -2);
  ------------------
  |  Branch (818:50): [True: 0, False: 0]
  ------------------
  819|       |
  820|       |    // No decoder should be initialized yet.
  821|  2.51k|    if (!mpctx->demuxer)
  ------------------
  |  Branch (821:9): [True: 0, False: 2.51k]
  ------------------
  822|      0|        return;
  823|       |
  824|  2.51k|    struct track *current = mpctx->current_track[order][type];
  825|  2.51k|    if (track == current)
  ------------------
  |  Branch (825:9): [True: 0, False: 2.51k]
  ------------------
  826|      0|        return;
  827|       |
  828|  2.51k|    if (current && current->sink) {
  ------------------
  |  Branch (828:9): [True: 2.51k, False: 2]
  |  Branch (828:20): [True: 0, False: 2.51k]
  ------------------
  829|      0|        MP_ERR(mpctx, "Can't disable input to complex filter.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  830|      0|        goto error;
  831|      0|    }
  832|  2.51k|    if ((type == STREAM_VIDEO && mpctx->vo_chain && !mpctx->vo_chain->track) ||
  ------------------
  |  Branch (832:10): [True: 2.02k, False: 491]
  |  Branch (832:34): [True: 0, False: 2.02k]
  |  Branch (832:53): [True: 0, False: 0]
  ------------------
  833|  2.51k|        (type == STREAM_AUDIO && mpctx->ao_chain && !mpctx->ao_chain->track))
  ------------------
  |  Branch (833:10): [True: 491, False: 2.02k]
  |  Branch (833:34): [True: 0, False: 491]
  |  Branch (833:53): [True: 0, False: 0]
  ------------------
  834|      0|    {
  835|      0|        MP_ERR(mpctx, "Can't switch away from complex filter output.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  836|      0|        goto error;
  837|      0|    }
  838|       |
  839|  2.51k|    if (track && track->selected) {
  ------------------
  |  Branch (839:9): [True: 12, False: 2.50k]
  |  Branch (839:18): [True: 0, False: 12]
  ------------------
  840|       |        // Track has been selected in a different order parameter.
  841|      0|        MP_ERR(mpctx, "Track %d is already selected.\n", track->user_tid);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  842|      0|        goto error;
  843|      0|    }
  844|       |
  845|  2.51k|    if (order == 0) {
  ------------------
  |  Branch (845:9): [True: 2.51k, False: 0]
  ------------------
  846|  2.51k|        if (type == STREAM_VIDEO) {
  ------------------
  |  Branch (846:13): [True: 2.02k, False: 491]
  ------------------
  847|  2.02k|            uninit_video_chain(mpctx);
  848|  2.02k|            if (!track)
  ------------------
  |  Branch (848:17): [True: 2.01k, False: 6]
  ------------------
  849|  2.01k|                handle_force_window(mpctx, true);
  850|  2.02k|        } else if (type == STREAM_AUDIO) {
  ------------------
  |  Branch (850:20): [True: 491, False: 0]
  ------------------
  851|    491|            clear_audio_output_buffers(mpctx);
  852|    491|            uninit_audio_chain(mpctx);
  853|    491|            if (!track)
  ------------------
  |  Branch (853:17): [True: 485, False: 6]
  ------------------
  854|    485|                uninit_audio_out(mpctx);
  855|    491|        }
  856|  2.51k|    }
  857|  2.51k|    if (type == STREAM_SUB)
  ------------------
  |  Branch (857:9): [True: 0, False: 2.51k]
  ------------------
  858|      0|        uninit_sub(mpctx, current);
  859|       |
  860|  2.51k|    if (current) {
  ------------------
  |  Branch (860:9): [True: 2.51k, False: 2]
  ------------------
  861|  2.51k|        current->selected = false;
  862|  2.51k|        reselect_demux_stream(mpctx, current, false);
  863|  2.51k|    }
  864|       |
  865|       |    // For the edge case of switching from no video to a still image, we need to
  866|       |    // flush the ass events of any sub track for potential animations.
  867|  2.51k|    if (type == STREAM_VIDEO && order == 0 && !current && track->image) {
  ------------------
  |  Branch (867:9): [True: 2.02k, False: 491]
  |  Branch (867:33): [True: 2.02k, False: 0]
  |  Branch (867:47): [True: 2, False: 2.02k]
  |  Branch (867:59): [True: 0, False: 2]
  ------------------
  868|      0|        for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (868:25): [True: 0, False: 0]
  ------------------
  869|      0|            struct track *sub_track = mpctx->current_track[n][STREAM_SUB];
  870|      0|            if (sub_track && sub_track->d_sub) {
  ------------------
  |  Branch (870:17): [True: 0, False: 0]
  |  Branch (870:30): [True: 0, False: 0]
  ------------------
  871|      0|                sub_control(sub_track->d_sub, SD_CTRL_RESET_SOFT, NULL);
  872|      0|                sub_reset(sub_track->d_sub);
  873|      0|                if (sub_track->selected)
  ------------------
  |  Branch (873:21): [True: 0, False: 0]
  ------------------
  874|      0|                    reselect_demux_stream(mpctx, sub_track, true);
  875|      0|            }
  876|      0|        }
  877|      0|    }
  878|       |
  879|  2.51k|    mpctx->current_track[order][type] = track;
  880|       |
  881|  2.51k|    if (track) {
  ------------------
  |  Branch (881:9): [True: 12, False: 2.50k]
  ------------------
  882|     12|        track->selected = true;
  883|     12|        reselect_demux_stream(mpctx, track, false);
  884|     12|    }
  885|       |
  886|  2.51k|    if (type == STREAM_VIDEO && order == 0) {
  ------------------
  |  Branch (886:9): [True: 2.02k, False: 491]
  |  Branch (886:33): [True: 2.02k, False: 0]
  ------------------
  887|  2.02k|        reinit_video_chain(mpctx);
  888|  2.02k|    } else if (type == STREAM_AUDIO && order == 0) {
  ------------------
  |  Branch (888:16): [True: 491, False: 0]
  |  Branch (888:40): [True: 491, False: 0]
  ------------------
  889|    491|        reinit_audio_chain(mpctx);
  890|    491|    } else if (type == STREAM_SUB && order >= 0 && order <= 2) {
  ------------------
  |  Branch (890:16): [True: 0, False: 0]
  |  Branch (890:38): [True: 0, False: 0]
  |  Branch (890:52): [True: 0, False: 0]
  ------------------
  891|      0|        reinit_sub(mpctx, track);
  892|      0|    }
  893|       |
  894|  2.51k|    mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL);
  895|  2.51k|    mp_wakeup_core(mpctx);
  896|       |
  897|  2.51k|    talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|  2.51k|#define talloc_free                     ta_free
  ------------------
  898|  2.51k|    mpctx->track_layout_hash = talloc_steal(mpctx, track_layout_hash(mpctx));
  ------------------
  |  |   38|  2.51k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.51k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  899|       |
  900|  2.51k|    return;
  901|      0|error:
  902|      0|    mark_track_selection(mpctx, order, type, -1);
  903|      0|}
mp_deselect_track:
  912|  2.50k|{
  913|  2.50k|    if (track && track->selected) {
  ------------------
  |  Branch (913:9): [True: 2.50k, False: 0]
  |  Branch (913:18): [True: 2.50k, False: 0]
  ------------------
  914|  5.00k|        for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (914:25): [True: 2.50k, False: 2.50k]
  ------------------
  915|  2.50k|            if (mpctx->current_track[t][track->type] != track)
  ------------------
  |  Branch (915:17): [True: 0, False: 2.50k]
  ------------------
  916|      0|                continue;
  917|  2.50k|            mp_switch_track_n(mpctx, t, track->type, NULL, 0);
  918|  2.50k|            mark_track_selection(mpctx, t, track->type, -1); // default
  919|  2.50k|        }
  920|  2.50k|    }
  921|  2.50k|}
autoload_external_files:
 1105|  21.8k|{
 1106|  21.8k|    struct MPOpts *opts = mpctx->opts;
 1107|       |
 1108|  21.8k|    if (opts->sub_auto < 0 && opts->audiofile_auto < 0 && opts->coverart_auto < 0)
  ------------------
  |  Branch (1108:9): [True: 0, False: 21.8k]
  |  Branch (1108:31): [True: 0, False: 0]
  |  Branch (1108:59): [True: 0, False: 0]
  ------------------
 1109|      0|        return;
 1110|  21.8k|    if (!opts->autoload_files || strcmp(mpctx->filename, "-") == 0)
  ------------------
  |  Branch (1110:9): [True: 0, False: 21.8k]
  |  Branch (1110:34): [True: 0, False: 21.8k]
  ------------------
 1111|      0|        return;
 1112|       |
 1113|  21.8k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  21.8k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  21.8k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1114|  21.8k|    struct subfn *list = find_external_files(mpctx->global, mpctx->filename, opts);
 1115|  21.8k|    talloc_steal(tmp, list);
  ------------------
  |  |   38|  21.8k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  21.8k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1116|       |
 1117|       |    // demux_edl allocates metadata track with type set to STREAM_TYPE_COUNT,
 1118|       |    // count this too, even though it won't have any effect on the selection.
 1119|  21.8k|    int sc[STREAM_TYPE_COUNT + 1] = {0};
 1120|  45.8k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1120:21): [True: 24.0k, False: 21.8k]
  ------------------
 1121|  24.0k|        mp_assert(mpctx->tracks[n]->type >= 0);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (1121:9): [True: 24.0k, False: 0]
  ------------------
 1122|  24.0k|        mp_assert(mpctx->tracks[n]->type <= STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (1122:9): [True: 24.0k, False: 0]
  ------------------
 1123|  24.0k|        if (!mpctx->tracks[n]->attached_picture)
  ------------------
  |  Branch (1123:13): [True: 24.0k, False: 0]
  ------------------
 1124|  24.0k|            sc[mpctx->tracks[n]->type]++;
 1125|  24.0k|    }
 1126|       |
 1127|  21.8k|    for (int i = 0; list && list[i].fname; i++) {
  ------------------
  |  Branch (1127:21): [True: 21.8k, False: 0]
  |  Branch (1127:29): [True: 0, False: 21.8k]
  ------------------
 1128|      0|        struct subfn *e = &list[i];
 1129|       |
 1130|      0|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1130:25): [True: 0, False: 0]
  ------------------
 1131|      0|            struct track *t = mpctx->tracks[n];
 1132|      0|            if (t->demuxer && strcmp(t->demuxer->filename, e->fname) == 0)
  ------------------
  |  Branch (1132:17): [True: 0, False: 0]
  |  Branch (1132:31): [True: 0, False: 0]
  ------------------
 1133|      0|                goto skip;
 1134|      0|        }
 1135|      0|        if (e->type == STREAM_SUB && !sc[STREAM_VIDEO] && !sc[STREAM_AUDIO])
  ------------------
  |  Branch (1135:13): [True: 0, False: 0]
  |  Branch (1135:38): [True: 0, False: 0]
  |  Branch (1135:59): [True: 0, False: 0]
  ------------------
 1136|      0|            goto skip;
 1137|      0|        if (e->type == STREAM_AUDIO && !sc[STREAM_VIDEO])
  ------------------
  |  Branch (1137:13): [True: 0, False: 0]
  |  Branch (1137:40): [True: 0, False: 0]
  ------------------
 1138|      0|            goto skip;
 1139|      0|        if (e->type == STREAM_VIDEO && (sc[STREAM_VIDEO] || !sc[STREAM_AUDIO]))
  ------------------
  |  Branch (1139:13): [True: 0, False: 0]
  |  Branch (1139:41): [True: 0, False: 0]
  |  Branch (1139:61): [True: 0, False: 0]
  ------------------
 1140|      0|            goto skip;
 1141|       |
 1142|      0|        enum track_flags flags = e->flags;
 1143|       |        // when given filter is set to video, we are loading up cover art
 1144|      0|        flags |= e->type == STREAM_VIDEO ? TRACK_ATTACHED_PICTURE : 0;
  ------------------
  |  Branch (1144:18): [True: 0, False: 0]
  ------------------
 1145|      0|        int first = mp_add_external_file(mpctx, e->fname, e->type, cancel, flags);
 1146|      0|        if (first < 0)
  ------------------
  |  Branch (1146:13): [True: 0, False: 0]
  ------------------
 1147|      0|            goto skip;
 1148|       |
 1149|      0|        for (int n = first; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1149:29): [True: 0, False: 0]
  ------------------
 1150|      0|            struct track *t = mpctx->tracks[n];
 1151|      0|            t->auto_loaded = true;
 1152|      0|            if (!t->lang)
  ------------------
  |  Branch (1152:17): [True: 0, False: 0]
  ------------------
 1153|      0|                t->lang = talloc_strdup(t, e->lang);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1154|      0|        }
 1155|      0|    skip:;
 1156|      0|    }
 1157|       |
 1158|  21.8k|    talloc_free(tmp);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
 1159|  21.8k|}
prepare_playlist:
 1164|  31.6k|{
 1165|  31.6k|    struct MPOpts *opts = mpctx->opts;
 1166|  31.6k|    struct playlist_entry *entry = NULL;
 1167|       |
 1168|  31.6k|    if (overwrite_current)
  ------------------
  |  Branch (1168:9): [True: 2.66k, False: 28.9k]
  ------------------
 1169|  2.66k|        pl->current = NULL;
 1170|       |
 1171|  31.6k|    pl->playlist_completed = false;
 1172|  31.6k|    pl->playlist_started = false;
 1173|       |
 1174|  31.6k|    if (opts->playlist_pos >= 0) {
  ------------------
  |  Branch (1174:9): [True: 0, False: 31.6k]
  ------------------
 1175|      0|        entry = playlist_entry_from_index(pl, opts->playlist_pos);
 1176|      0|        pl->current = overwrite_current || entry ? entry : pl->current;
  ------------------
  |  Branch (1176:23): [True: 0, False: 0]
  |  Branch (1176:44): [True: 0, False: 0]
  ------------------
 1177|      0|    }
 1178|       |
 1179|  31.6k|    if (pl->playlist_dir)
  ------------------
  |  Branch (1179:9): [True: 0, False: 31.6k]
  ------------------
 1180|      0|        playlist_set_current(pl);
 1181|       |
 1182|  31.6k|    if (opts->shuffle)
  ------------------
  |  Branch (1182:9): [True: 0, False: 31.6k]
  ------------------
 1183|      0|        playlist_shuffle(pl);
 1184|       |
 1185|  31.6k|    if (opts->merge_files)
  ------------------
  |  Branch (1185:9): [True: 0, False: 31.6k]
  ------------------
 1186|      0|        merge_playlist_files(pl);
 1187|       |
 1188|  31.6k|    if (!pl->current || (!overwrite_current && !entry)) {
  ------------------
  |  Branch (1188:9): [True: 31.6k, False: 0]
  |  Branch (1188:26): [True: 0, False: 0]
  |  Branch (1188:48): [True: 0, False: 0]
  ------------------
 1189|  31.6k|        entry = mp_check_playlist_resume(mpctx, pl);
 1190|  31.6k|        pl->current = overwrite_current || entry ? entry : pl->current;
  ------------------
  |  Branch (1190:23): [True: 2.66k, False: 28.9k]
  |  Branch (1190:44): [True: 0, False: 28.9k]
  ------------------
 1191|  31.6k|    }
 1192|       |
 1193|  31.6k|    if (!pl->current)
  ------------------
  |  Branch (1193:9): [True: 31.6k, False: 0]
  ------------------
 1194|  31.6k|        pl->current = playlist_get_first(pl);
 1195|  31.6k|}
prefetch_next:
 1440|  42.1k|{
 1441|  42.1k|    if (!mpctx->opts->prefetch_open || mpctx->open_active)
  ------------------
  |  Branch (1441:9): [True: 42.1k, False: 0]
  |  Branch (1441:40): [True: 0, False: 0]
  ------------------
 1442|  42.1k|        return;
 1443|       |
 1444|      0|    struct playlist_entry *new_entry = mp_next_file(mpctx, +1, false, false);
 1445|      0|    if (new_entry && new_entry->filename) {
  ------------------
  |  Branch (1445:9): [True: 0, False: 0]
  |  Branch (1445:22): [True: 0, False: 0]
  ------------------
 1446|      0|        MP_VERBOSE(mpctx, "Prefetching: %s\n", new_entry->filename);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1447|       |        start_open(mpctx, new_entry->filename, new_entry->stream_flags, true);
 1448|      0|    }
 1449|      0|}
update_vo_chain_el_pair:
 1672|   160k|{
 1673|   160k|    if (!mpctx->vo_chain || !mpctx->vo_chain->filter)
  ------------------
  |  Branch (1673:9): [True: 74.6k, False: 86.2k]
  |  Branch (1673:29): [True: 0, False: 86.2k]
  ------------------
 1674|  74.6k|        return;
 1675|  86.2k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1676|  86.2k|    mp_output_chain_set_el_stream(mpctx->vo_chain->filter,
 1677|  86.2k|        track ? sh_stream_dependent_sibling(track->stream) : NULL);
  ------------------
  |  Branch (1677:9): [True: 86.2k, False: 0]
  ------------------
 1678|  86.2k|}
update_lavfi_complex:
 1681|  28.9k|{
 1682|  28.9k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1682:9): [True: 0, False: 28.9k]
  ------------------
 1683|      0|        int r = reinit_complex_filters(mpctx, false);
 1684|      0|        if (r != 0)
  ------------------
  |  Branch (1684:13): [True: 0, False: 0]
  ------------------
 1685|      0|            issue_refresh_seek(mpctx, MPSEEK_EXACT);
 1686|      0|        if (r > 0)
  ------------------
  |  Branch (1686:13): [True: 0, False: 0]
  ------------------
 1687|      0|            update_vo_chain_el_pair(mpctx);
 1688|      0|    }
 1689|  28.9k|}
mp_next_file:
 2250|   133k|{
 2251|   133k|    struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
 2252|   133k|    if (next && direction < 0 && !force)
  ------------------
  |  Branch (2252:9): [True: 104k, False: 28.7k]
  |  Branch (2252:17): [True: 0, False: 104k]
  |  Branch (2252:34): [True: 0, False: 0]
  ------------------
 2253|      0|        next->playlist_prev_attempt = true;
 2254|   133k|    if (!next && mpctx->opts->loop_times != 1) {
  ------------------
  |  Branch (2254:9): [True: 28.7k, False: 104k]
  |  Branch (2254:18): [True: 0, False: 28.7k]
  ------------------
 2255|      0|        if (direction > 0) {
  ------------------
  |  Branch (2255:13): [True: 0, False: 0]
  ------------------
 2256|      0|            if (mpctx->opts->shuffle) {
  ------------------
  |  Branch (2256:17): [True: 0, False: 0]
  ------------------
 2257|      0|                if (!update_loop)
  ------------------
  |  Branch (2257:21): [True: 0, False: 0]
  ------------------
 2258|      0|                    return NULL;
 2259|      0|                playlist_shuffle(mpctx->playlist);
 2260|      0|            }
 2261|      0|            next = playlist_get_first(mpctx->playlist);
 2262|      0|            if (next && mpctx->opts->loop_times > 1 && update_loop) {
  ------------------
  |  Branch (2262:17): [True: 0, False: 0]
  |  Branch (2262:25): [True: 0, False: 0]
  |  Branch (2262:56): [True: 0, False: 0]
  ------------------
 2263|      0|                mpctx->opts->loop_times--;
 2264|      0|                m_config_notify_change_opt_ptr(mpctx->mconfig,
 2265|      0|                                               &mpctx->opts->loop_times);
 2266|      0|            }
 2267|      0|        } else {
 2268|      0|            next = playlist_get_last(mpctx->playlist);
 2269|      0|        }
 2270|      0|        bool ignore_failures = mpctx->opts->loop_times == -2;
 2271|      0|        if (!force && next && next->init_failed && !ignore_failures) {
  ------------------
  |  Branch (2271:13): [True: 0, False: 0]
  |  Branch (2271:23): [True: 0, False: 0]
  |  Branch (2271:31): [True: 0, False: 0]
  |  Branch (2271:52): [True: 0, False: 0]
  ------------------
 2272|       |            // Don't endless loop if no file in playlist is playable
 2273|      0|            bool all_failed = true;
 2274|      0|            for (int n = 0; n < mpctx->playlist->num_entries; n++) {
  ------------------
  |  Branch (2274:29): [True: 0, False: 0]
  ------------------
 2275|      0|                all_failed &= mpctx->playlist->entries[n]->init_failed;
 2276|      0|                if (!all_failed)
  ------------------
  |  Branch (2276:21): [True: 0, False: 0]
  ------------------
 2277|      0|                    break;
 2278|      0|            }
 2279|      0|            if (all_failed)
  ------------------
  |  Branch (2279:17): [True: 0, False: 0]
  ------------------
 2280|      0|                next = NULL;
 2281|      0|        }
 2282|      0|    }
 2283|   133k|    return next;
 2284|   133k|}
mp_play_files:
 2289|  28.9k|{
 2290|  28.9k|    stats_register_thread_cputime(mpctx->stats, "thread");
 2291|       |
 2292|       |    // Wait for all scripts to load before possibly starting playback.
 2293|  28.9k|    if (!mp_clients_all_initialized(mpctx)) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 28.9k]
  ------------------
 2294|      0|        MP_VERBOSE(mpctx, "Waiting for scripts...\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2295|      0|        while (!mp_clients_all_initialized(mpctx))
  ------------------
  |  Branch (2295:16): [True: 0, False: 0]
  ------------------
 2296|      0|            mp_idle(mpctx);
 2297|      0|        mp_wakeup_core(mpctx); // avoid lost wakeups during waiting
 2298|      0|        MP_VERBOSE(mpctx, "Done loading scripts.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2299|      0|    }
 2300|       |    // After above is finished; but even if it's skipped.
 2301|  28.9k|    mp_msg_set_early_logging(mpctx->global, false);
 2302|       |
 2303|  28.9k|    prepare_playlist(mpctx, mpctx->playlist, false);
 2304|       |
 2305|   162k|    for (;;) {
 2306|   162k|        idle_loop(mpctx);
 2307|       |
 2308|   162k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2308:13): [True: 28.8k, False: 133k]
  ------------------
 2309|  28.8k|            break;
 2310|       |
 2311|   133k|        if (mpctx->playlist->current)
  ------------------
  |  Branch (2311:13): [True: 133k, False: 0]
  ------------------
 2312|   133k|            play_current_file(mpctx);
 2313|       |
 2314|   133k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2314:13): [True: 137, False: 133k]
  ------------------
 2315|    137|            break;
 2316|       |
 2317|   133k|        struct playlist_entry *new_entry = NULL;
 2318|   133k|        if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR ||
  ------------------
  |  Branch (2318:13): [True: 0, False: 133k]
  |  Branch (2318:50): [True: 116k, False: 16.6k]
  ------------------
 2319|  16.6k|            mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (2319:13): [True: 16.5k, False: 59]
  ------------------
 2320|   133k|        {
 2321|   133k|            new_entry = mp_next_file(mpctx, +1, false, true);
 2322|   133k|        } else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
  ------------------
  |  Branch (2322:20): [True: 0, False: 59]
  ------------------
 2323|      0|            new_entry = mpctx->playlist->current;
 2324|      0|        }
 2325|       |
 2326|   133k|        if (!new_entry)
  ------------------
  |  Branch (2326:13): [True: 28.8k, False: 104k]
  ------------------
 2327|  28.8k|            mpctx->playlist->playlist_completed = true;
 2328|       |
 2329|   133k|        mpctx->playlist->current = new_entry;
 2330|   133k|        mpctx->playlist->current_was_replaced = false;
 2331|   133k|        mpctx->stop_play = new_entry ? PT_NEXT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2331:28): [True: 104k, False: 28.8k]
  ------------------
 2332|       |
 2333|   133k|        if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2)
  ------------------
  |  Branch (2333:13): [True: 28.8k, False: 104k]
  |  Branch (2333:42): [True: 0, False: 28.8k]
  ------------------
 2334|      0|            break;
 2335|   133k|    }
 2336|       |
 2337|  28.9k|    cancel_open(mpctx);
 2338|       |
 2339|  28.9k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2339:9): [True: 0, False: 28.9k]
  ------------------
 2340|       |        // Make sure all streams get finished.
 2341|      0|        uninit_audio_out(mpctx);
 2342|      0|        uninit_video_out(mpctx);
 2343|       |
 2344|      0|        if (!encode_lavc_free(mpctx->encode_lavc_ctx))
  ------------------
  |  Branch (2344:13): [True: 0, False: 0]
  ------------------
 2345|      0|            mpctx->files_errored += 1;
 2346|       |
 2347|       |        mpctx->encode_lavc_ctx = NULL;
 2348|      0|    }
 2349|  28.9k|}
mp_set_playlist_entry:
 2354|  28.9k|{
 2355|  28.9k|    mp_assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (2355:5): [True: 0, False: 28.9k]
  |  Branch (2355:5): [True: 28.9k, False: 0]
  ------------------
 2356|  28.9k|    mpctx->playlist->current = e;
 2357|  28.9k|    mpctx->playlist->current_was_replaced = false;
 2358|  28.9k|    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 2359|       |    // Make it pick up the new entry.
 2360|  28.9k|    if (mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (2360:9): [True: 28.9k, False: 0]
  ------------------
 2361|  28.9k|        mpctx->stop_play = e ? PT_CURRENT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2361:28): [True: 28.9k, False: 0]
  ------------------
 2362|  28.9k|    mp_wakeup_core(mpctx);
 2363|  28.9k|}
loadfile.c:track_in_current_edition:
  301|  50.5k|{
  302|  50.5k|    struct demuxer *demuxer = mpctx->demuxer;
  303|  50.5k|    if (!demuxer || !demuxer->edition_is_track_mapping || demuxer->num_editions <= 1)
  ------------------
  |  Branch (303:9): [True: 0, False: 50.5k]
  |  Branch (303:21): [True: 50.5k, False: 0]
  |  Branch (303:59): [True: 0, False: 0]
  ------------------
  304|  50.5k|        return true;
  305|      0|    if (track->is_external)
  ------------------
  |  Branch (305:9): [True: 0, False: 0]
  ------------------
  306|      0|        return true;
  307|      0|    int program = demuxer->editions[demuxer->edition].demuxer_id;
  308|      0|    if (track_has_program(track, program))
  ------------------
  |  Branch (308:9): [True: 0, False: 0]
  ------------------
  309|      0|        return true;
  310|       |    // Program-agnostic tracks only show in editions that don't supply their own
  311|       |    // track of this type.
  312|      0|    if (!track->stream || !track->stream->num_program_ids)
  ------------------
  |  Branch (312:9): [True: 0, False: 0]
  |  Branch (312:27): [True: 0, False: 0]
  ------------------
  313|      0|        return !edition_has_track_of_type(mpctx, track->type);
  314|      0|    return false;
  315|      0|}
loadfile.c:print_stream:
  244|  24.0k|{
  245|  24.0k|    const char *tname = "?";
  246|  24.0k|    const char *selopt = "?";
  247|  24.0k|    const char *langopt = "?";
  248|  24.0k|    switch (t->type) {
  ------------------
  |  Branch (248:13): [True: 24.0k, False: 0]
  ------------------
  249|  9.69k|    case STREAM_VIDEO:
  ------------------
  |  Branch (249:5): [True: 9.69k, False: 14.3k]
  ------------------
  250|  9.69k|        tname = t->image ? "Image" : "Video"; selopt = "vid"; langopt = "vlang";
  ------------------
  |  Branch (250:17): [True: 4.76k, False: 4.93k]
  ------------------
  251|  9.69k|        break;
  252|  12.4k|    case STREAM_AUDIO:
  ------------------
  |  Branch (252:5): [True: 12.4k, False: 11.6k]
  ------------------
  253|  12.4k|        tname = "Audio"; selopt = "aid"; langopt = "alang";
  254|  12.4k|        break;
  255|  1.94k|    case STREAM_SUB:
  ------------------
  |  Branch (255:5): [True: 1.94k, False: 22.0k]
  ------------------
  256|  1.94k|        tname = "Subs"; selopt = "sid"; langopt = "slang";
  257|  1.94k|        break;
  258|  24.0k|    }
  259|  24.0k|    char b[2048] = {0};
  260|       |
  261|  24.0k|    int max_lang_length = 0;
  262|  54.5k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (262:21): [True: 30.4k, False: 24.0k]
  ------------------
  263|  30.4k|        if (mpctx->tracks[n]->lang)
  ------------------
  |  Branch (263:13): [True: 0, False: 30.4k]
  ------------------
  264|      0|            max_lang_length = MPMAX(strlen(mpctx->tracks[n]->lang), max_lang_length);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  265|  30.4k|    }
  266|       |
  267|  24.0k|    if (indent)
  ------------------
  |  Branch (267:9): [True: 446, False: 23.5k]
  ------------------
  268|    446|        APPEND(b, " ");
  ------------------
  |  |  240|    446|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  269|  24.0k|    APPEND(b, "%s %-5s  --%s=%-2d", t->selected ? BLACK_CIRCLE : WHITE_CIRCLE,
  ------------------
  |  |  240|  48.0k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 21.8k, False: 2.15k]
  |  |  ------------------
  ------------------
  270|  24.0k|           tname, selopt, t->user_tid);
  271|  24.0k|    if (t->lang) {
  ------------------
  |  Branch (271:9): [True: 0, False: 24.0k]
  ------------------
  272|      0|        APPEND(b, " --%s=%-*s ", langopt, max_lang_length, t->lang);
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  273|  24.0k|    } else if (max_lang_length) {
  ------------------
  |  Branch (273:16): [True: 0, False: 24.0k]
  ------------------
  274|      0|        FILL(b, (int) strlen(" --alang= ") + max_lang_length);
  ------------------
  |  |  241|      0|#define FILL(s, n) mp_snprintf_cat(s, sizeof(s), "%*s", n, "")
  ------------------
  275|      0|    }
  276|       |
  277|  24.0k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|  24.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  278|  24.0k|    APPEND(b, " %s", mp_format_track_metadata(ctx, t, false));
  ------------------
  |  |  240|  24.0k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  279|  24.0k|    talloc_free(ctx);
  ------------------
  |  |   47|  24.0k|#define talloc_free                     ta_free
  ------------------
  280|       |
  281|  24.0k|    MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|  24.0k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  282|  24.0k|}
loadfile.c:add_stream_track:
  520|  48.0k|{
  521|  54.4k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (521:21): [True: 30.4k, False: 24.0k]
  ------------------
  522|  30.4k|        struct track *track = mpctx->tracks[i];
  523|  30.4k|        if (track->stream == stream)
  ------------------
  |  Branch (523:13): [True: 24.0k, False: 6.38k]
  ------------------
  524|  24.0k|            return track;
  525|  30.4k|    }
  526|       |
  527|  24.0k|    struct track *track = talloc_ptrtype(NULL, track);
  ------------------
  |  |   34|  24.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|  24.0k|    *track = (struct track) {
  529|  24.0k|        .type = stream->type,
  530|  24.0k|        .user_tid = find_new_tid(mpctx, stream->type),
  531|  24.0k|        .demuxer_id = stream->demuxer_id,
  532|  24.0k|        .ff_index = stream->ff_index,
  533|  24.0k|        .hls_bitrate = stream->hls_bitrate,
  534|  24.0k|        .title = stream->title,
  535|  24.0k|        .default_track = stream->default_track,
  536|  24.0k|        .forced_track = stream->forced_track,
  537|  24.0k|        .dependent_track = stream->dependent_track,
  538|  24.0k|        .visual_impaired_track = stream->visual_impaired_track,
  539|  24.0k|        .hearing_impaired_track = stream->hearing_impaired_track,
  540|  24.0k|        .original_track = stream->original_track,
  541|  24.0k|        .commentary_track = stream->commentary_track,
  542|  24.0k|        .image = stream->image,
  543|  24.0k|        .attached_picture = stream->attached_picture != NULL,
  544|  24.0k|        .lang = stream->lang,
  545|  24.0k|        .demuxer = demuxer,
  546|  24.0k|        .stream = stream,
  547|  24.0k|    };
  548|  24.0k|    MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
  ------------------
  |  |  105|  24.0k|    do {                                            \
  |  |  106|  24.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.0k|    do {                                            \
  |  |  |  |   97|  24.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 20.9k, False: 3.07k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  20.9k|    do {                                                        \
  |  |  |  |  |  |   89|  20.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  20.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  20.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  20.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  20.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  20.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  20.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 20.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.0k|        (idxvar)++;                                 \
  |  |  109|  24.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.0k]
  |  |  ------------------
  ------------------
  549|       |
  550|  24.0k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  551|       |
  552|  24.0k|    return track;
  553|  48.0k|}
loadfile.c:find_new_tid:
  507|  24.0k|{
  508|  24.0k|    int new_id = 0;
  509|  27.2k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (509:21): [True: 3.19k, False: 24.0k]
  ------------------
  510|  3.19k|        struct track *track = mpctx->tracks[i];
  511|  3.19k|        if (track->type == t)
  ------------------
  |  Branch (511:13): [True: 267, False: 2.92k]
  ------------------
  512|    267|            new_id = MPMAX(new_id, track->user_tid);
  ------------------
  |  |   44|    267|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 267]
  |  |  ------------------
  ------------------
  513|  3.19k|    }
  514|  24.0k|    return new_id + 1;
  515|  24.0k|}
loadfile.c:process_langs:
  665|  67.8k|{
  666|  67.8k|    size_t nb = 0;
  667|  67.8k|    char **out = NULL;
  668|  67.8k|    for (int i = 0; in && in[i]; i++) {
  ------------------
  |  Branch (668:21): [True: 0, False: 67.8k]
  |  Branch (668:27): [True: 0, False: 0]
  ------------------
  669|      0|        if (!append_lang(&nb, &out, talloc_strdup(NULL, in[i])))
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (669:13): [True: 0, False: 0]
  ------------------
  670|      0|            break;
  671|      0|    }
  672|  67.8k|    return out;
  673|  67.8k|}
loadfile.c:add_os_langs:
  650|  21.8k|{
  651|  21.8k|    size_t nb = 0;
  652|  21.8k|    char **out = NULL;
  653|  21.8k|    char **autos = mp_get_user_langs();
  654|  21.8k|    for (int i = 0; autos && autos[i]; i++) {
  ------------------
  |  Branch (654:21): [True: 21.8k, False: 0]
  |  Branch (654:30): [True: 0, False: 21.8k]
  ------------------
  655|      0|        if (!append_lang(&nb, &out, autos[i]))
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            goto cleanup;
  657|      0|    }
  658|       |
  659|  21.8k|cleanup:
  660|  21.8k|    talloc_free(autos);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
  661|  21.8k|    return out;
  662|  21.8k|}
loadfile.c:duplicate_track:
  630|  24.0k|{
  631|  24.0k|    for (int i = 0; i < order; i++) {
  ------------------
  |  Branch (631:21): [True: 0, False: 24.0k]
  ------------------
  632|      0|        if (mpctx->current_track[i][type] == track)
  ------------------
  |  Branch (632:13): [True: 0, False: 0]
  ------------------
  633|      0|            return true;
  634|      0|    }
  635|  24.0k|    return false;
  636|  24.0k|}
loadfile.c:compare_track:
  585|    185|{
  586|    185|    bool sub = t2->type == STREAM_SUB;
  587|    185|    bool ext1 = t1->is_external && !t1->no_default;
  ------------------
  |  Branch (587:17): [True: 0, False: 185]
  |  Branch (587:36): [True: 0, False: 0]
  ------------------
  588|    185|    bool ext2 = t2->is_external && !t2->no_default;
  ------------------
  |  Branch (588:17): [True: 0, False: 185]
  |  Branch (588:36): [True: 0, False: 0]
  ------------------
  589|    185|    if (ext1 != ext2 && t1->image == t2->image) {
  ------------------
  |  Branch (589:9): [True: 0, False: 185]
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|        if (t1->attached_picture && t2->attached_picture
  ------------------
  |  Branch (590:13): [True: 0, False: 0]
  |  Branch (590:37): [True: 0, False: 0]
  ------------------
  591|      0|            && opts->audio_display == 1)
  ------------------
  |  Branch (591:16): [True: 0, False: 0]
  ------------------
  592|      0|            return !ext1;
  593|      0|        return ext1;
  594|      0|    }
  595|    185|    if (t1->auto_loaded != t2->auto_loaded)
  ------------------
  |  Branch (595:9): [True: 0, False: 185]
  ------------------
  596|      0|        return !t1->auto_loaded;
  597|    185|    int l1 = mp_match_lang(langs, t1->lang), l2 = mp_match_lang(langs, t2->lang);
  598|    185|    if (!os_langs && l1 != l2)
  ------------------
  |  Branch (598:9): [True: 185, False: 0]
  |  Branch (598:22): [True: 0, False: 185]
  ------------------
  599|      0|        return l1 > l2;
  600|    185|    if (t1->forced_select != t2->forced_select)
  ------------------
  |  Branch (600:9): [True: 0, False: 185]
  ------------------
  601|      0|        return t1->forced_select;
  602|    185|    if (t1->default_track != t2->default_track)
  ------------------
  |  Branch (602:9): [True: 0, False: 185]
  ------------------
  603|      0|        return t1->default_track;
  604|    185|    if (sub && t1->forced_track != t2->forced_track)
  ------------------
  |  Branch (604:9): [True: 0, False: 185]
  |  Branch (604:16): [True: 0, False: 0]
  ------------------
  605|      0|        return !t1->forced_track;
  606|    185|    if (os_langs && l1 != l2)
  ------------------
  |  Branch (606:9): [True: 0, False: 185]
  |  Branch (606:21): [True: 0, False: 0]
  ------------------
  607|      0|        return l1 > l2;
  608|    185|    if (t1->attached_picture != t2->attached_picture)
  ------------------
  |  Branch (608:9): [True: 0, False: 185]
  ------------------
  609|      0|        return !t1->attached_picture;
  610|    185|    if (t1->image != t2->image)
  ------------------
  |  Branch (610:9): [True: 0, False: 185]
  ------------------
  611|      0|        return !t1->image;
  612|    185|    if (t1->dependent_track != t2->dependent_track)
  ------------------
  |  Branch (612:9): [True: 0, False: 185]
  ------------------
  613|      0|        return !t1->dependent_track;
  614|    185|    if (t1->stream && t2->stream && opts->hls_bitrate >= 0 &&
  ------------------
  |  Branch (614:9): [True: 185, False: 0]
  |  Branch (614:23): [True: 185, False: 0]
  |  Branch (614:37): [True: 185, False: 0]
  ------------------
  615|    185|        t1->stream->hls_bitrate != t2->stream->hls_bitrate)
  ------------------
  |  Branch (615:9): [True: 0, False: 185]
  ------------------
  616|      0|    {
  617|      0|        bool t1_ok = t1->stream->hls_bitrate <= opts->hls_bitrate;
  618|      0|        bool t2_ok = t2->stream->hls_bitrate <= opts->hls_bitrate;
  619|      0|        if (t1_ok != t2_ok)
  ------------------
  |  Branch (619:13): [True: 0, False: 0]
  ------------------
  620|      0|            return t1_ok;
  621|      0|        if (t1_ok && t2_ok)
  ------------------
  |  Branch (621:13): [True: 0, False: 0]
  |  Branch (621:22): [True: 0, False: 0]
  ------------------
  622|      0|            return t1->stream->hls_bitrate > t2->stream->hls_bitrate;
  623|      0|        return t1->stream->hls_bitrate < t2->stream->hls_bitrate;
  624|      0|    }
  625|    185|    return t1->user_tid <= t2->user_tid;
  626|    185|}
loadfile.c:track_layout_hash:
  758|  2.53k|{
  759|  2.53k|    char *h = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  2.53k|#define talloc_strdup                   ta_xstrdup
  ------------------
  760|  10.1k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (760:24): [True: 7.61k, False: 2.53k]
  ------------------
  761|  16.2k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (761:25): [True: 8.59k, False: 7.61k]
  ------------------
  762|  8.59k|            struct track *track = mpctx->tracks[n];
  763|  8.59k|            if (track->type != type)
  ------------------
  |  Branch (763:17): [True: 5.72k, False: 2.86k]
  ------------------
  764|  5.72k|                continue;
  765|  2.86k|            h = talloc_asprintf_append_buffer(h, "%d-%d-%d-%d-%s\n", type,
  ------------------
  |  |   64|  2.86k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  766|  2.86k|                    track->user_tid, track->default_track, track->is_external,
  767|  2.86k|                    track->lang ? track->lang : "");
  ------------------
  |  Branch (767:21): [True: 0, False: 2.86k]
  ------------------
  768|  2.86k|        }
  769|  7.61k|    }
  770|  2.53k|    return h;
  771|  2.53k|}
loadfile.c:enable_demux_thread:
  499|  21.8k|{
  500|  21.8k|    if (mpctx->opts->demuxer_thread && !demux->fully_read) {
  ------------------
  |  Branch (500:9): [True: 21.8k, False: 0]
  |  Branch (500:40): [True: 19.9k, False: 1.86k]
  ------------------
  501|  19.9k|        demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
  502|  19.9k|        demux_start_thread(demux);
  503|  19.9k|    }
  504|  21.8k|}
loadfile.c:wakeup_demux:
   66|  61.1k|{
   67|  61.1k|    struct MPContext *mpctx = pctx;
   68|  61.1k|    mp_wakeup_core(mpctx);
   69|  61.1k|}
loadfile.c:start_open:
 1356|  31.7k|{
 1357|  31.7k|    cancel_open(mpctx);
 1358|       |
 1359|  31.7k|    mp_assert(!mpctx->open_active);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1359:5): [True: 31.7k, False: 0]
  ------------------
 1360|  31.7k|    mp_assert(!mpctx->open_cancel);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1360:5): [True: 31.7k, False: 0]
  ------------------
 1361|  31.7k|    mp_assert(!mpctx->open_res_demuxer);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1361:5): [True: 31.7k, False: 0]
  ------------------
 1362|  31.7k|    mp_assert(!atomic_load(&mpctx->open_done));
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1362:5): [True: 31.7k, False: 0]
  ------------------
 1363|       |
 1364|  31.7k|    mpctx->open_cancel = mp_cancel_new(NULL);
 1365|  31.7k|    mpctx->open_url = talloc_strdup(NULL, url);
  ------------------
  |  |   50|  31.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1366|  31.7k|    mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name);
  ------------------
  |  |   50|  31.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1367|  31.7k|    mpctx->open_url_flags = url_flags;
 1368|  31.7k|    mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
  ------------------
  |  Branch (1368:32): [True: 0, False: 31.7k]
  |  Branch (1368:48): [True: 0, False: 0]
  ------------------
 1369|  31.7k|    mpctx->demuxer_changed = false;
 1370|       |
 1371|  31.7k|    if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
  ------------------
  |  |  214|  31.7k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 31.7k]
  |  |  ------------------
  ------------------
 1372|      0|        cancel_open(mpctx);
 1373|      0|        return;
 1374|      0|    }
 1375|       |
 1376|  31.7k|    mpctx->open_active = true;
 1377|  31.7k|}
loadfile.c:open_demux_thread:
 1287|  31.7k|{
 1288|  31.7k|    struct MPContext *mpctx = ctx;
 1289|       |
 1290|  31.7k|    mp_thread_set_name("opener");
 1291|       |
 1292|  31.7k|    struct demuxer_params p = {
 1293|  31.7k|        .force_format = mpctx->open_format,
 1294|  31.7k|        .stream_flags = mpctx->open_url_flags,
 1295|  31.7k|        .stream_record = true,
 1296|  31.7k|        .is_top_level = true,
 1297|  31.7k|        .allow_playlist_create = mpctx->playlist->num_entries <= 1 &&
  ------------------
  |  Branch (1297:34): [True: 30.3k, False: 1.34k]
  ------------------
 1298|  30.3k|                                 !mpctx->playlist->playlist_dir,
  ------------------
  |  Branch (1298:34): [True: 30.3k, False: 0]
  ------------------
 1299|  31.7k|    };
 1300|  31.7k|    struct demuxer *demux =
 1301|  31.7k|        demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);
 1302|  31.7k|    mpctx->open_res_demuxer = demux;
 1303|       |
 1304|  31.7k|    if (demux) {
  ------------------
  |  Branch (1304:9): [True: 24.6k, False: 7.12k]
  ------------------
 1305|  24.6k|        MP_VERBOSE(mpctx, "Opening done: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  24.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1306|       |
 1307|  24.6k|        if (mpctx->open_for_prefetch && !demux->fully_read) {
  ------------------
  |  Branch (1307:13): [True: 0, False: 24.6k]
  |  Branch (1307:41): [True: 0, False: 0]
  ------------------
 1308|      0|            int num_streams = demux_get_num_stream(demux);
 1309|      0|            for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (1309:29): [True: 0, False: 0]
  ------------------
 1310|      0|                struct sh_stream *sh = demux_get_stream(demux, n);
 1311|      0|                demuxer_select_track(demux, sh, MP_NOPTS_VALUE, true);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1312|      0|            }
 1313|       |
 1314|      0|            demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
 1315|      0|            demux_start_thread(demux);
 1316|      0|            demux_start_prefetch(demux);
 1317|      0|        }
 1318|  24.6k|    } else {
 1319|  7.12k|        MP_VERBOSE(mpctx, "Opening failed or was aborted: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  7.12k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.12k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1320|       |
 1321|  7.12k|        if (p.demuxer_failed) {
  ------------------
  |  Branch (1321:13): [True: 5.98k, False: 1.14k]
  ------------------
 1322|  5.98k|            mpctx->open_res_error = MPV_ERROR_UNKNOWN_FORMAT;
 1323|  5.98k|        } else {
 1324|  1.14k|            mpctx->open_res_error = MPV_ERROR_LOADING_FAILED;
 1325|  1.14k|        }
 1326|  7.12k|    }
 1327|       |
 1328|  31.7k|    atomic_store(&mpctx->open_done, true);
 1329|  31.7k|    mp_wakeup_core(mpctx);
 1330|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  31.7k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1331|  31.7k|}
loadfile.c:reinit_complex_filters:
 1533|   155k|{
 1534|   155k|    char *graph = mpctx->opts->lavfi_complex;
 1535|   155k|    bool have_graph = graph && graph[0] && !force_uninit;
  ------------------
  |  Branch (1535:23): [True: 0, False: 155k]
  |  Branch (1535:32): [True: 0, False: 0]
  |  Branch (1535:44): [True: 0, False: 0]
  ------------------
 1536|   155k|    if (have_graph && mpctx->lavfi &&
  ------------------
  |  Branch (1536:9): [True: 0, False: 155k]
  |  Branch (1536:23): [True: 0, False: 0]
  ------------------
 1537|      0|        strcmp(graph, mpctx->lavfi_graph) == 0 &&
  ------------------
  |  Branch (1537:9): [True: 0, False: 0]
  ------------------
 1538|      0|        !mp_filter_has_failed(mpctx->lavfi))
  ------------------
  |  Branch (1538:9): [True: 0, False: 0]
  ------------------
 1539|      0|        return 0;
 1540|   155k|    if (!mpctx->lavfi && !have_graph)
  ------------------
  |  Branch (1540:9): [True: 155k, False: 0]
  |  Branch (1540:26): [True: 155k, False: 0]
  ------------------
 1541|   155k|        return 0;
 1542|       |
 1543|       |    // Deassociate the old filter pads. We leave both sources (tracks) and
 1544|       |    // sinks (AO/VO) "dangling", connected to neither track or filter pad.
 1545|       |    // Later, we either reassociate them with new pads, or uninit them if
 1546|       |    // they are still dangling. This avoids too interruptive actions like
 1547|       |    // recreating the VO.
 1548|      0|    deassociate_complex_filters(mpctx);
 1549|       |
 1550|      0|    bool success = false;
 1551|      0|    if (!have_graph) {
  ------------------
  |  Branch (1551:9): [True: 0, False: 0]
  ------------------
 1552|      0|        success = true; // normal full removal of graph
 1553|      0|        goto done;
 1554|      0|    }
 1555|       |
 1556|      0|    struct mp_lavfi *l =
 1557|      0|        mp_lavfi_create_graph(mpctx->filter_root, 0, false, NULL, NULL, graph);
 1558|      0|    if (!l)
  ------------------
  |  Branch (1558:9): [True: 0, False: 0]
  ------------------
 1559|      0|        goto done;
 1560|      0|    mpctx->lavfi = l->f;
 1561|      0|    mpctx->lavfi_graph = talloc_strdup(NULL, graph);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1562|       |
 1563|      0|    mp_filter_set_error_handler(mpctx->lavfi, mpctx->filter_root);
 1564|       |
 1565|      0|    for (int n = 0; n < mpctx->lavfi->num_pins; n++)
  ------------------
  |  Branch (1565:21): [True: 0, False: 0]
  ------------------
 1566|      0|        mp_pin_disconnect(mpctx->lavfi->pins[n]);
 1567|       |
 1568|      0|    struct mp_pin *pad = mp_filter_get_named_pin(mpctx->lavfi, "vo");
 1569|      0|    if (pad && mp_pin_get_dir(pad) == MP_PIN_OUT) {
  ------------------
  |  Branch (1569:9): [True: 0, False: 0]
  |  Branch (1569:16): [True: 0, False: 0]
  ------------------
 1570|      0|        if (mpctx->vo_chain && mpctx->vo_chain->track)
  ------------------
  |  Branch (1570:13): [True: 0, False: 0]
  |  Branch (1570:32): [True: 0, False: 0]
  ------------------
 1571|      0|            kill_outputs(mpctx, mpctx->vo_chain->track);
 1572|      0|        if (!mpctx->vo_chain) {
  ------------------
  |  Branch (1572:13): [True: 0, False: 0]
  ------------------
 1573|      0|            reinit_video_chain_src(mpctx, NULL);
 1574|      0|            if (!mpctx->vo_chain)
  ------------------
  |  Branch (1574:17): [True: 0, False: 0]
  ------------------
 1575|      0|                goto done;
 1576|      0|        }
 1577|      0|        struct vo_chain *vo_c = mpctx->vo_chain;
 1578|      0|        mp_assert(!vo_c->track);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1578:9): [True: 0, False: 0]
  ------------------
 1579|      0|        vo_c->filter_src = pad;
 1580|      0|        mp_pin_connect(vo_c->filter->f->pins[0], vo_c->filter_src);
 1581|      0|    }
 1582|       |
 1583|      0|    pad = mp_filter_get_named_pin(mpctx->lavfi, "ao");
 1584|      0|    if (pad && mp_pin_get_dir(pad) == MP_PIN_OUT) {
  ------------------
  |  Branch (1584:9): [True: 0, False: 0]
  |  Branch (1584:16): [True: 0, False: 0]
  ------------------
 1585|      0|        if (mpctx->ao_chain && mpctx->ao_chain->track)
  ------------------
  |  Branch (1585:13): [True: 0, False: 0]
  |  Branch (1585:32): [True: 0, False: 0]
  ------------------
 1586|      0|            kill_outputs(mpctx, mpctx->ao_chain->track);
 1587|      0|        if (!mpctx->ao_chain) {
  ------------------
  |  Branch (1587:13): [True: 0, False: 0]
  ------------------
 1588|      0|            reinit_audio_chain_src(mpctx, NULL);
 1589|      0|            if (!mpctx->ao_chain)
  ------------------
  |  Branch (1589:17): [True: 0, False: 0]
  ------------------
 1590|      0|                goto done;
 1591|      0|        }
 1592|      0|        struct ao_chain *ao_c = mpctx->ao_chain;
 1593|      0|        mp_assert(!ao_c->track);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1593:9): [True: 0, False: 0]
  ------------------
 1594|      0|        ao_c->filter_src = pad;
 1595|      0|        mp_pin_connect(ao_c->filter->f->pins[0], ao_c->filter_src);
 1596|      0|    }
 1597|       |
 1598|      0|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1598:21): [True: 0, False: 0]
  ------------------
 1599|      0|        struct track *track = mpctx->tracks[n];
 1600|       |
 1601|      0|        char label[32];
 1602|      0|        char prefix;
 1603|      0|        switch (track->type) {
 1604|      0|        case STREAM_VIDEO: prefix = 'v'; break;
  ------------------
  |  Branch (1604:9): [True: 0, False: 0]
  ------------------
 1605|      0|        case STREAM_AUDIO: prefix = 'a'; break;
  ------------------
  |  Branch (1605:9): [True: 0, False: 0]
  ------------------
 1606|      0|        default: continue;
  ------------------
  |  Branch (1606:9): [True: 0, False: 0]
  ------------------
 1607|      0|        }
 1608|      0|        snprintf(label, sizeof(label), "%cid%d", prefix, track->user_tid);
 1609|       |
 1610|      0|        pad = mp_filter_get_named_pin(mpctx->lavfi, label);
 1611|      0|        if (!pad)
  ------------------
  |  Branch (1611:13): [True: 0, False: 0]
  ------------------
 1612|      0|            continue;
 1613|      0|        if (mp_pin_get_dir(pad) != MP_PIN_IN)
  ------------------
  |  Branch (1613:13): [True: 0, False: 0]
  ------------------
 1614|      0|            continue;
 1615|      0|        mp_assert(!mp_pin_is_connected(pad));
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1615:9): [True: 0, False: 0]
  ------------------
 1616|       |
 1617|      0|        mp_assert(!track->sink);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1617:9): [True: 0, False: 0]
  ------------------
 1618|       |
 1619|      0|        kill_outputs(mpctx, track);
 1620|       |
 1621|      0|        track->sink = pad;
 1622|      0|        track->selected = true;
 1623|       |
 1624|      0|        if (!track->dec) {
  ------------------
  |  Branch (1624:13): [True: 0, False: 0]
  ------------------
 1625|      0|            bool ok = track->type == STREAM_VIDEO ? init_video_decoder(mpctx, track)
  ------------------
  |  Branch (1625:23): [True: 0, False: 0]
  ------------------
 1626|      0|                                                  : init_audio_decoder(mpctx, track);
 1627|      0|            if (!ok) {
  ------------------
  |  Branch (1627:17): [True: 0, False: 0]
  ------------------
 1628|      0|                error_on_track(mpctx, track);
 1629|      0|                goto done;
 1630|      0|            }
 1631|      0|        }
 1632|       |
 1633|      0|        mp_pin_connect(track->sink, track->dec->f->pins[0]);
 1634|      0|    }
 1635|       |
 1636|       |    // Don't allow unconnected pins. Libavfilter would make the data flow a
 1637|       |    // real pain anyway.
 1638|      0|    for (int n = 0; n < mpctx->lavfi->num_pins; n++) {
  ------------------
  |  Branch (1638:21): [True: 0, False: 0]
  ------------------
 1639|      0|        struct mp_pin *pin = mpctx->lavfi->pins[n];
 1640|      0|        if (!mp_pin_is_connected(pin)) {
  ------------------
  |  Branch (1640:13): [True: 0, False: 0]
  ------------------
 1641|      0|            MP_ERR(mpctx, "Pad %s is not connected to anything.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1642|      0|                   mp_pin_get_name(pin));
 1643|      0|            goto done;
 1644|      0|        }
 1645|      0|    }
 1646|       |
 1647|      0|    success = true;
 1648|      0|done:
 1649|       |
 1650|      0|    if (!success)
  ------------------
  |  Branch (1650:9): [True: 0, False: 0]
  ------------------
 1651|      0|        deassociate_complex_filters(mpctx);
 1652|       |
 1653|      0|    cleanup_deassociated_complex_filters(mpctx);
 1654|       |
 1655|      0|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1655:9): [True: 0, False: 0]
  ------------------
 1656|      0|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1656:25): [True: 0, False: 0]
  ------------------
 1657|      0|            struct track *t = mpctx->tracks[n];
 1658|      0|            if (t->stream && t->stream->dependent_track && !t->selected)
  ------------------
  |  Branch (1658:17): [True: 0, False: 0]
  |  Branch (1658:30): [True: 0, False: 0]
  |  Branch (1658:60): [True: 0, False: 0]
  ------------------
 1659|      0|                continue;
 1660|      0|            reselect_demux_stream(mpctx, t, false);
 1661|      0|        }
 1662|      0|    }
 1663|       |
 1664|      0|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 1665|       |
 1666|      0|    return success ? 1 : -1;
  ------------------
  |  Branch (1666:12): [True: 0, False: 0]
  ------------------
 1667|      0|}
loadfile.c:play_current_file:
 1820|   133k|{
 1821|   133k|    struct MPOpts *opts = mpctx->opts;
 1822|       |
 1823|   133k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (1823:5): [True: 133k, False: 0]
  ------------------
 1824|   133k|    mpctx->stop_play = 0;
 1825|       |
 1826|   133k|    process_hooks(mpctx, "on_before_start_file");
 1827|   133k|    if (mpctx->stop_play || !mpctx->playlist->current)
  ------------------
  |  Branch (1827:9): [True: 0, False: 133k]
  |  Branch (1827:29): [True: 0, False: 133k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|   133k|    mpv_event_start_file start_event = {
 1831|   133k|        .playlist_entry_id = mpctx->playlist->current->id,
 1832|   133k|    };
 1833|   133k|    mpv_event_end_file end_event = {
 1834|   133k|        .playlist_entry_id = start_event.playlist_entry_id,
 1835|   133k|    };
 1836|       |
 1837|   133k|    mp_notify(mpctx, MPV_EVENT_START_FILE, &start_event);
 1838|       |
 1839|   133k|    mp_cancel_reset(mpctx->playback_abort);
 1840|       |
 1841|   133k|    mpctx->error_playing = MPV_ERROR_LOADING_FAILED;
 1842|   133k|    mpctx->filename = NULL;
 1843|   133k|    mpctx->shown_aframes = 0;
 1844|   133k|    mpctx->shown_vframes = 0;
 1845|   133k|    mpctx->last_chapter_seek = -2;
 1846|   133k|    mpctx->last_chapter_flag = false;
 1847|   133k|    mpctx->last_chapter = -2;
 1848|   133k|    mpctx->paused = false;
 1849|   133k|    mpctx->playing_msg_shown = false;
 1850|   133k|    mpctx->max_frames = -1;
 1851|   133k|    mpctx->video_speed = mpctx->audio_speed = opts->playback_speed;
 1852|   133k|    mpctx->speed_factor_a = mpctx->speed_factor_v = 1.0;
 1853|   133k|    mpctx->display_sync_error = 0.0;
 1854|   133k|    mpctx->display_sync_active = false;
 1855|       |    // let get_current_time() show 0 as start time (before playback_pts is set)
 1856|   133k|    mpctx->last_seek_pts = 0.0;
 1857|   133k|    mpctx->seek = (struct seek_params){ 0 };
 1858|   133k|    disc_nav_reset(mpctx);
 1859|   133k|    mpctx->filter_root = mp_filter_create_root(mpctx->global);
 1860|   133k|    mp_filter_graph_set_wakeup_cb(mpctx->filter_root, mp_wakeup_core_cb, mpctx);
 1861|   133k|    mp_filter_graph_set_max_run_time(mpctx->filter_root, 0.1);
 1862|       |
 1863|   133k|    reset_playback_state(mpctx);
 1864|       |
 1865|   133k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1866|   133k|    if (mpctx->playlist->num_entries > 3)
  ------------------
  |  Branch (1866:9): [True: 102k, False: 31.7k]
  ------------------
 1867|   102k|        goto terminate_playback;
 1868|  31.7k|#endif
 1869|       |
 1870|  31.7k|    mpctx->playing = mpctx->playlist->current;
 1871|  31.7k|    mp_assert(mpctx->playing);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1871:5): [True: 31.7k, False: 0]
  ------------------
 1872|  31.7k|    mp_assert(mpctx->playing->filename);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1872:5): [True: 31.7k, False: 0]
  ------------------
 1873|  31.7k|    mpctx->playing->reserved += 1;
 1874|       |
 1875|  31.7k|    mpctx->filename = talloc_strdup(NULL, mpctx->playing->filename);
  ------------------
  |  |   50|  31.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1876|  31.7k|    mpctx->stream_open_filename = mpctx->filename;
 1877|       |
 1878|  31.7k|    mpctx->add_osd_seek_info &= OSD_SEEK_INFO_CURRENT_FILE;
 1879|       |
 1880|  31.7k|    if (opts->reset_options) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 31.7k]
  ------------------
 1881|      0|        for (int n = 0; opts->reset_options[n]; n++) {
  ------------------
  |  Branch (1881:25): [True: 0, False: 0]
  ------------------
 1882|      0|            const char *opt = opts->reset_options[n];
 1883|      0|            if (opt[0]) {
  ------------------
  |  Branch (1883:17): [True: 0, False: 0]
  ------------------
 1884|      0|                if (strcmp(opt, "all") == 0) {
  ------------------
  |  Branch (1884:21): [True: 0, False: 0]
  ------------------
 1885|      0|                    m_config_backup_all_opts(mpctx->mconfig);
 1886|      0|                } else {
 1887|      0|                    m_config_backup_opt(mpctx->mconfig, opt);
 1888|      0|                }
 1889|      0|            }
 1890|      0|        }
 1891|      0|    }
 1892|       |
 1893|  31.7k|    mp_load_auto_profiles(mpctx);
 1894|       |
 1895|  31.7k|    bool watch_later = mp_load_playback_resume(mpctx, mpctx->filename);
 1896|       |
 1897|  31.7k|    load_per_file_options(mpctx->mconfig, mpctx->playing->params,
 1898|  31.7k|                          mpctx->playing->num_params);
 1899|       |
 1900|  31.7k|    mpctx->remaining_file_loops = mpctx->opts->loop_file;
 1901|  31.7k|    mp_notify_property(mpctx, "remaining-file-loops");
 1902|  31.7k|    mpctx->remaining_ab_loops = mpctx->opts->ab_loop_count;
 1903|  31.7k|    mp_notify_property(mpctx, "remaining-ab-loops");
 1904|       |
 1905|  31.7k|    mpctx->max_frames = opts->play_frames;
 1906|       |
 1907|  31.7k|    handle_force_window(mpctx, false);
 1908|       |
 1909|  31.7k|    if (mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (1909:9): [True: 1.34k, False: 30.3k]
  ------------------
 1910|  30.3k|        mpctx->playing->playlist_path)
  ------------------
  |  Branch (1910:9): [True: 1.42k, False: 28.9k]
  ------------------
 1911|  31.7k|        MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
  ------------------
  |  |   91|  2.77k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.77k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1912|       |
 1913|  31.7k|    mp_assert(mpctx->demuxer == NULL);
  ------------------
  |  |   41|  31.7k|#define mp_assert assert
  ------------------
  |  Branch (1913:5): [True: 31.7k, False: 0]
  ------------------
 1914|       |
 1915|  31.7k|    process_hooks(mpctx, "on_load");
 1916|  31.7k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1916:9): [True: 0, False: 31.7k]
  ------------------
 1917|      0|        goto terminate_playback;
 1918|       |
 1919|  31.7k|    if (opts->stream_dump && opts->stream_dump[0]) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 31.7k]
  |  Branch (1919:30): [True: 0, False: 0]
  ------------------
 1920|      0|        if (stream_dump(mpctx, mpctx->stream_open_filename) >= 0)
  ------------------
  |  Branch (1920:13): [True: 0, False: 0]
  ------------------
 1921|      0|            mpctx->error_playing = 1;
 1922|      0|        goto terminate_playback;
 1923|      0|    }
 1924|       |
 1925|  31.7k|    open_demux_reentrant(mpctx);
 1926|  31.7k|    if (!mpctx->stop_play && !mpctx->demuxer) {
  ------------------
  |  Branch (1926:9): [True: 31.7k, False: 0]
  |  Branch (1926:30): [True: 7.12k, False: 24.6k]
  ------------------
 1927|  7.12k|        process_hooks(mpctx, "on_load_fail");
 1928|  7.12k|        if (strcmp(mpctx->stream_open_filename, mpctx->filename) != 0 &&
  ------------------
  |  Branch (1928:13): [True: 0, False: 7.12k]
  ------------------
 1929|      0|            !mpctx->stop_play)
  ------------------
  |  Branch (1929:13): [True: 0, False: 0]
  ------------------
 1930|      0|        {
 1931|      0|            mpctx->error_playing = MPV_ERROR_LOADING_FAILED;
 1932|      0|            open_demux_reentrant(mpctx);
 1933|      0|        }
 1934|  7.12k|    }
 1935|  31.7k|    if (!mpctx->demuxer || mpctx->stop_play)
  ------------------
  |  Branch (1935:9): [True: 7.12k, False: 24.6k]
  |  Branch (1935:28): [True: 0, False: 24.6k]
  ------------------
 1936|  7.12k|        goto terminate_playback;
 1937|       |
 1938|  24.6k|    struct playlist *pl = mpctx->demuxer->playlist;
 1939|  24.6k|    if (pl) {
  ------------------
  |  Branch (1939:9): [True: 2.79k, False: 21.8k]
  ------------------
 1940|       |        // pl->playlist_dir indicates that the playlist was auto-created from
 1941|       |        // the parent file. In this case, mpctx->filename points to real file.
 1942|  2.79k|        if (watch_later && !pl->playlist_dir)
  ------------------
  |  Branch (1942:13): [True: 0, False: 2.79k]
  |  Branch (1942:28): [True: 0, False: 0]
  ------------------
 1943|      0|            mp_delete_watch_later_conf(mpctx, mpctx->filename);
 1944|  2.79k|        playlist_populate_playlist_path(pl, mpctx->filename);
 1945|  2.79k|        if (infinite_playlist_loading_loop(mpctx, pl)) {
  ------------------
  |  Branch (1945:13): [True: 59, False: 2.74k]
  ------------------
 1946|     59|            mpctx->stop_play = PT_STOP;
 1947|     59|            MP_ERR(mpctx, "Infinite playlist loading loop detected.\n");
  ------------------
  |  |   89|     59|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     59|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1948|     59|            goto terminate_playback;
 1949|     59|        }
 1950|  2.74k|        transfer_playlist(mpctx, pl, &end_event.playlist_insert_id,
 1951|  2.74k|                          &end_event.playlist_insert_num_entries);
 1952|  2.74k|        mp_notify_property(mpctx, "playlist");
 1953|  2.74k|        mpctx->error_playing = 2;
 1954|  2.74k|        goto terminate_playback;
 1955|  2.79k|    }
 1956|       |
 1957|  21.8k|    if (mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (1957:9): [True: 21.8k, False: 0]
  ------------------
 1958|  21.8k|        demux_set_ts_offset(mpctx->demuxer, -mpctx->demuxer->start_time);
 1959|  21.8k|    enable_demux_thread(mpctx, mpctx->demuxer);
 1960|       |
 1961|  21.8k|    add_demuxer_tracks(mpctx, mpctx->demuxer);
 1962|       |
 1963|  21.8k|    load_external_opts(mpctx);
 1964|  21.8k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1964:9): [True: 0, False: 21.8k]
  ------------------
 1965|      0|        goto terminate_playback;
 1966|       |
 1967|  21.8k|    check_previous_track_selection(mpctx);
 1968|       |
 1969|  21.8k|    process_hooks(mpctx, "on_preloaded");
 1970|  21.8k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1970:9): [True: 0, False: 21.8k]
  ------------------
 1971|      0|        goto terminate_playback;
 1972|       |
 1973|  21.8k|    if (reinit_complex_filters(mpctx, false) < 0)
  ------------------
  |  Branch (1973:9): [True: 0, False: 21.8k]
  ------------------
 1974|      0|        goto terminate_playback;
 1975|       |
 1976|  87.2k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1976:21): [True: 65.4k, False: 21.8k]
  ------------------
 1977|   152k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1977:25): [True: 87.2k, False: 65.4k]
  ------------------
 1978|  87.2k|            struct track *sel = NULL;
 1979|  87.2k|            bool taken = (t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (1979:27): [True: 21.8k, False: 65.4k]
  |  Branch (1979:48): [True: 0, False: 21.8k]
  ------------------
 1980|  87.2k|                         (t == STREAM_AUDIO && mpctx->ao_chain);
  ------------------
  |  Branch (1980:27): [True: 21.8k, False: 65.4k]
  |  Branch (1980:48): [True: 0, False: 21.8k]
  ------------------
 1981|  87.2k|            if (!taken && opts->stream_auto_sel)
  ------------------
  |  Branch (1981:17): [True: 87.2k, False: 0]
  |  Branch (1981:27): [True: 87.2k, False: 0]
  ------------------
 1982|  87.2k|                sel = select_default_track(mpctx, i, t);
 1983|  87.2k|            mpctx->current_track[i][t] = sel;
 1984|  87.2k|        }
 1985|  65.4k|    }
 1986|  87.2k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1986:21): [True: 65.4k, False: 21.8k]
  ------------------
 1987|   152k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1987:25): [True: 87.2k, False: 65.4k]
  ------------------
 1988|       |            // One track can strictly feed at most 1 decoder
 1989|  87.2k|            struct track *track = mpctx->current_track[i][t];
 1990|  87.2k|            if (track) {
  ------------------
  |  Branch (1990:17): [True: 21.8k, False: 65.3k]
  ------------------
 1991|  21.8k|                if (track->type != STREAM_SUB &&
  ------------------
  |  Branch (1991:21): [True: 21.8k, False: 0]
  ------------------
 1992|  21.8k|                    mpctx->encode_lavc_ctx &&
  ------------------
  |  Branch (1992:21): [True: 0, False: 21.8k]
  ------------------
 1993|      0|                    !encode_lavc_stream_type_ok(mpctx->encode_lavc_ctx,
  ------------------
  |  Branch (1993:21): [True: 0, False: 0]
  ------------------
 1994|      0|                                                track->type))
 1995|      0|                {
 1996|      0|                    MP_WARN(mpctx, "Disabling %s (not supported by target "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1997|      0|                            "format).\n", stream_type_name(track->type));
 1998|      0|                    mpctx->current_track[i][t] = NULL;
 1999|      0|                    mark_track_selection(mpctx, i, t, -2); // disable
 2000|  21.8k|                } else if (track->selected) {
  ------------------
  |  Branch (2000:28): [True: 0, False: 21.8k]
  ------------------
 2001|      0|                    MP_ERR(mpctx, "Track %d can't be selected twice.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2002|      0|                           track->user_tid);
 2003|      0|                    mpctx->current_track[i][t] = NULL;
 2004|      0|                    mark_track_selection(mpctx, i, t, -2); // disable
 2005|  21.8k|                } else {
 2006|  21.8k|                    track->selected = true;
 2007|  21.8k|                }
 2008|  21.8k|            }
 2009|       |
 2010|       |            // Revert selection of unselected tracks to default. This is needed
 2011|       |            // because track properties have inconsistent behavior.
 2012|  87.2k|            if (!track && opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (2012:17): [True: 65.3k, False: 21.8k]
  |  Branch (2012:27): [True: 0, False: 65.3k]
  ------------------
 2013|      0|                mark_track_selection(mpctx, i, t, -1); // default
 2014|  87.2k|        }
 2015|  65.4k|    }
 2016|       |
 2017|  21.8k|    process_hooks(mpctx, "on_loaded");
 2018|  87.2k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (2018:21): [True: 65.4k, False: 21.8k]
  ------------------
 2019|   137k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2019:25): [True: 72.0k, False: 65.4k]
  ------------------
 2020|  72.0k|            struct track *track = mpctx->tracks[n];
 2021|  72.0k|            if (track->type != t)
  ------------------
  |  Branch (2021:17): [True: 48.0k, False: 24.0k]
  ------------------
 2022|  48.0k|                continue;
 2023|       |            // Only reselect dependent tracks when explicitly selected by user
 2024|  24.0k|            if (track->stream && track->stream->dependent_track &&
  ------------------
  |  Branch (2024:17): [True: 24.0k, False: 0]
  |  Branch (2024:34): [True: 0, False: 24.0k]
  ------------------
 2025|      0|                !track->selected)
  ------------------
  |  Branch (2025:17): [True: 0, False: 0]
  ------------------
 2026|      0|                continue;
 2027|  24.0k|            reselect_demux_stream(mpctx, track, false);
 2028|  24.0k|        }
 2029|  65.4k|    }
 2030|       |
 2031|  21.8k|    update_demuxer_properties(mpctx);
 2032|       |
 2033|  21.8k|    update_playback_speed(mpctx);
 2034|       |
 2035|  21.8k|    reinit_video_chain(mpctx);
 2036|  21.8k|    reinit_audio_chain(mpctx);
 2037|  21.8k|    reinit_sub_all(mpctx);
 2038|       |    // For lavfi-complex mode reinit_video_chain skips chain setup, so set up
 2039|       |    // the enhancement-layer pairing here. No-op in non-lavfi-complex mode.
 2040|  21.8k|    update_vo_chain_el_pair(mpctx);
 2041|       |
 2042|  21.8k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2042:9): [True: 0, False: 21.8k]
  ------------------
 2043|      0|        if (mpctx->vo_chain)
  ------------------
  |  Branch (2043:13): [True: 0, False: 0]
  ------------------
 2044|      0|            encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_VIDEO);
 2045|      0|        if (mpctx->ao_chain)
  ------------------
  |  Branch (2045:13): [True: 0, False: 0]
  ------------------
 2046|      0|            encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_AUDIO);
 2047|      0|        encode_lavc_set_metadata(mpctx->encode_lavc_ctx,
 2048|      0|                                 mpctx->demuxer->metadata);
 2049|      0|    }
 2050|       |
 2051|  21.8k|    if (!mpctx->vo_chain && !mpctx->ao_chain && opts->stream_auto_sel) {
  ------------------
  |  Branch (2051:9): [True: 14.1k, False: 7.67k]
  |  Branch (2051:29): [True: 5.04k, False: 9.08k]
  |  Branch (2051:49): [True: 5.04k, False: 0]
  ------------------
 2052|  5.04k|        MP_FATAL(mpctx, "No video or audio streams selected.\n");
  ------------------
  |  |   88|  5.04k|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.04k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2053|  5.04k|        mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2054|  5.04k|        goto terminate_playback;
 2055|  5.04k|    }
 2056|       |
 2057|  16.7k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart) {
  ------------------
  |  Branch (2057:9): [True: 7.67k, False: 9.08k]
  |  Branch (2057:28): [True: 0, False: 7.67k]
  ------------------
 2058|      0|        MP_INFO(mpctx,
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2059|      0|            "Displaying cover art. Use --no-audio-display to prevent this.\n");
 2060|      0|    }
 2061|       |
 2062|  16.7k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2062:9): [True: 9.08k, False: 7.67k]
  ------------------
 2063|  9.08k|        handle_force_window(mpctx, true);
 2064|       |
 2065|  16.7k|    MP_VERBOSE(mpctx, "Starting playback...\n");
  ------------------
  |  |   92|  16.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  16.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2066|       |
 2067|  16.7k|    mpctx->playback_initialized = true;
 2068|  16.7k|    mpctx->playing->playlist_prev_attempt = false;
 2069|  16.7k|    mpctx->playlist->playlist_completed = false;
 2070|  16.7k|    mpctx->playlist->playlist_started = true;
 2071|  16.7k|    mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
 2072|  16.7k|    update_screensaver_state(mpctx);
 2073|  16.7k|    clear_playlist_paths(mpctx);
 2074|       |
 2075|       |    // Clear out subs from the previous file if the video track is a still image.
 2076|  16.7k|    redraw_subs(mpctx);
 2077|       |
 2078|  16.7k|    if (watch_later)
  ------------------
  |  Branch (2078:9): [True: 0, False: 16.7k]
  ------------------
 2079|      0|        mp_delete_watch_later_conf(mpctx, mpctx->filename);
 2080|       |
 2081|  16.7k|    append_to_watch_history(mpctx);
 2082|       |
 2083|  16.7k|    if (mpctx->max_frames == 0) {
  ------------------
  |  Branch (2083:9): [True: 0, False: 16.7k]
  ------------------
 2084|      0|        if (!mpctx->stop_play)
  ------------------
  |  Branch (2084:13): [True: 0, False: 0]
  ------------------
 2085|      0|            mpctx->stop_play = PT_NEXT_ENTRY;
 2086|      0|        mpctx->error_playing = 0;
 2087|      0|        goto terminate_playback;
 2088|      0|    }
 2089|       |
 2090|  16.7k|    if (opts->demuxer_cache_wait) {
  ------------------
  |  Branch (2090:9): [True: 0, False: 16.7k]
  ------------------
 2091|      0|        demux_start_prefetch(mpctx->demuxer);
 2092|       |
 2093|      0|        while (!mpctx->stop_play) {
  ------------------
  |  Branch (2093:16): [True: 0, False: 0]
  ------------------
 2094|      0|            struct demux_reader_state s;
 2095|      0|            demux_get_reader_state(mpctx->demuxer, &s);
 2096|      0|            if (s.idle)
  ------------------
  |  Branch (2096:17): [True: 0, False: 0]
  ------------------
 2097|      0|                break;
 2098|       |
 2099|      0|            mp_idle(mpctx);
 2100|      0|        }
 2101|      0|    }
 2102|       |
 2103|       |    // (Not get_play_start_pts(), which would always trigger a seek.)
 2104|  16.7k|    double play_start_pts = rel_time_to_abs(mpctx, opts->play_start);
 2105|       |
 2106|       |    // Backward playback -> start from end by default.
 2107|  16.7k|    if (play_start_pts == MP_NOPTS_VALUE && opts->play_dir < 0)
  ------------------
  |  |   39|  33.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2107:9): [True: 16.7k, False: 0]
  |  Branch (2107:45): [True: 0, False: 16.7k]
  ------------------
 2108|      0|        play_start_pts = get_start_time(mpctx, -1);
 2109|       |
 2110|  16.7k|    if (play_start_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  16.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2110:9): [True: 0, False: 16.7k]
  ------------------
 2111|      0|        queue_seek(mpctx, MPSEEK_ABSOLUTE, play_start_pts, MPSEEK_DEFAULT, 0);
 2112|      0|        execute_queued_seek(mpctx);
 2113|      0|    }
 2114|       |
 2115|  16.7k|    update_internal_pause_state(mpctx);
 2116|       |
 2117|  16.7k|    mpctx->error_playing = 0;
 2118|  16.7k|    mpctx->in_playloop = true;
 2119|   148k|    while (!mpctx->stop_play)
  ------------------
  |  Branch (2119:12): [True: 131k, False: 16.7k]
  ------------------
 2120|   131k|        run_playloop(mpctx);
 2121|  16.7k|    mpctx->in_playloop = false;
 2122|       |
 2123|  16.7k|    MP_VERBOSE(mpctx, "EOF code: %d\n", mpctx->stop_play);
  ------------------
  |  |   92|  16.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  16.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2124|       |
 2125|   133k|terminate_playback:
 2126|       |
 2127|   133k|    if (!mpctx->stop_play)
  ------------------
  |  Branch (2127:9): [True: 114k, False: 19.0k]
  ------------------
 2128|   114k|        mpctx->stop_play = PT_ERROR;
 2129|       |
 2130|   133k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (2130:9): [True: 117k, False: 16.5k]
  ------------------
 2131|   117k|        clear_audio_output_buffers(mpctx);
 2132|       |
 2133|   133k|    update_core_idle_state(mpctx);
 2134|       |
 2135|   133k|    if (mpctx->step_frames) {
  ------------------
  |  Branch (2135:9): [True: 0, False: 133k]
  ------------------
 2136|      0|        opts->pause = true;
 2137|      0|        m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
 2138|      0|    }
 2139|       |
 2140|   133k|    process_hooks(mpctx, "on_unload");
 2141|       |
 2142|       |    // time to uninit all, except global stuff:
 2143|   133k|    reinit_complex_filters(mpctx, true);
 2144|   133k|    uninit_audio_chain(mpctx);
 2145|   133k|    uninit_video_chain(mpctx);
 2146|   133k|    uninit_sub_all(mpctx);
 2147|   133k|    if (!opts->gapless_audio && !mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (2147:9): [True: 0, False: 133k]
  |  Branch (2147:33): [True: 0, False: 0]
  ------------------
 2148|      0|        uninit_audio_out(mpctx);
 2149|       |
 2150|   133k|    mpctx->playback_initialized = false;
 2151|       |
 2152|   133k|    uninit_demuxer(mpctx);
 2153|       |
 2154|       |    // Possibly stop ongoing async commands.
 2155|   133k|    mp_abort_playback_async(mpctx);
 2156|       |
 2157|   133k|    struct playlist_entry *current = mpctx->playlist->current;
 2158|   133k|    bool reloading = mpctx->stop_play == PT_CURRENT_ENTRY &&
  ------------------
  |  Branch (2158:22): [True: 0, False: 133k]
  ------------------
 2159|      0|                     current && current->reloading;
  ------------------
  |  Branch (2159:22): [True: 0, False: 0]
  |  Branch (2159:33): [True: 0, False: 0]
  ------------------
 2160|   133k|    if (current)
  ------------------
  |  Branch (2160:9): [True: 133k, False: 0]
  ------------------
 2161|   133k|        current->reloading = false;
 2162|   133k|    if (!reloading)
  ------------------
  |  Branch (2162:9): [True: 133k, False: 0]
  ------------------
 2163|   133k|        m_config_restore_backups(mpctx->mconfig);
 2164|       |
 2165|   133k|    TA_FREEP(&mpctx->filter_root);
  ------------------
  |  |   81|   133k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   133k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 133k]
  |  |  ------------------
  ------------------
 2166|   133k|    talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
 2167|   133k|    mpctx->filtered_tags = NULL;
 2168|       |
 2169|   133k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 2170|       |
 2171|   133k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx))
  ------------------
  |  Branch (2171:9): [True: 0, False: 133k]
  ------------------
 2172|      0|        mpctx->stop_play = PT_ERROR;
 2173|       |
 2174|   133k|    if (mpctx->stop_play == PT_ERROR && !mpctx->error_playing)
  ------------------
  |  Branch (2174:9): [True: 116k, False: 16.7k]
  |  Branch (2174:41): [True: 0, False: 116k]
  ------------------
 2175|      0|        mpctx->error_playing = MPV_ERROR_GENERIC;
 2176|       |
 2177|   133k|    bool nothing_played = !mpctx->shown_aframes && !mpctx->shown_vframes &&
  ------------------
  |  Branch (2177:27): [True: 127k, False: 6.07k]
  |  Branch (2177:52): [True: 126k, False: 1.00k]
  ------------------
 2178|   126k|                          mpctx->error_playing <= 0;
  ------------------
  |  Branch (2178:27): [True: 123k, False: 2.74k]
  ------------------
 2179|   133k|    bool playlist_prev_continue = false;
 2180|   133k|    switch (mpctx->stop_play) {
  ------------------
  |  Branch (2180:13): [True: 133k, False: 0]
  ------------------
 2181|   116k|    case PT_ERROR:
  ------------------
  |  Branch (2181:5): [True: 116k, False: 16.7k]
  ------------------
 2182|   133k|    case AT_END_OF_FILE:
  ------------------
  |  Branch (2182:5): [True: 16.5k, False: 117k]
  ------------------
 2183|   133k|    {
 2184|   133k|        if (mpctx->error_playing == 0 && nothing_played)
  ------------------
  |  Branch (2184:13): [True: 16.5k, False: 116k]
  |  Branch (2184:42): [True: 9.61k, False: 6.94k]
  ------------------
 2185|  9.61k|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2186|   133k|        if (mpctx->error_playing < 0) {
  ------------------
  |  Branch (2186:13): [True: 123k, False: 9.68k]
  ------------------
 2187|   123k|            end_event.error = mpctx->error_playing;
 2188|   123k|            end_event.reason = MPV_END_FILE_REASON_ERROR;
 2189|   123k|        } else if (mpctx->error_playing == 2) {
  ------------------
  |  Branch (2189:20): [True: 2.74k, False: 6.94k]
  ------------------
 2190|  2.74k|            end_event.reason = MPV_END_FILE_REASON_REDIRECT;
 2191|  6.94k|        } else {
 2192|  6.94k|            end_event.reason = MPV_END_FILE_REASON_EOF;
 2193|  6.94k|        }
 2194|   133k|        if (mpctx->playing) {
  ------------------
  |  Branch (2194:13): [True: 31.5k, False: 102k]
  ------------------
 2195|  31.5k|            mpctx->playing->init_failed = nothing_played;
 2196|  31.5k|            playlist_prev_continue = mpctx->playing->playlist_prev_attempt &&
  ------------------
  |  Branch (2196:38): [True: 0, False: 31.5k]
  ------------------
 2197|      0|                                     nothing_played;
  ------------------
  |  Branch (2197:38): [True: 0, False: 0]
  ------------------
 2198|  31.5k|            mpctx->playing->playlist_prev_attempt = false;
 2199|  31.5k|        }
 2200|   133k|        break;
 2201|   116k|    }
 2202|       |    // Note that error_playing is meaningless in these cases.
 2203|      0|    case PT_NEXT_ENTRY:
  ------------------
  |  Branch (2203:5): [True: 0, False: 133k]
  ------------------
 2204|      0|    case PT_CURRENT_ENTRY:
  ------------------
  |  Branch (2204:5): [True: 0, False: 133k]
  ------------------
 2205|     59|    case PT_STOP:           end_event.reason = MPV_END_FILE_REASON_STOP; break;
  ------------------
  |  Branch (2205:5): [True: 59, False: 133k]
  ------------------
 2206|    137|    case PT_QUIT:           end_event.reason = MPV_END_FILE_REASON_QUIT; break;
  ------------------
  |  Branch (2206:5): [True: 137, False: 133k]
  ------------------
 2207|   133k|    };
 2208|   133k|    mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event);
 2209|       |
 2210|   133k|    MP_VERBOSE(mpctx, "finished playback, %s (reason %d)\n",
  ------------------
  |  |   92|   133k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   133k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2211|   133k|               mpv_error_string(end_event.error), end_event.reason);
 2212|   133k|    if (end_event.error == MPV_ERROR_UNKNOWN_FORMAT)
  ------------------
  |  Branch (2212:9): [True: 5.98k, False: 127k]
  ------------------
 2213|   133k|        MP_ERR(mpctx, "Failed to recognize file format.\n");
  ------------------
  |  |   89|  5.98k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2214|       |
 2215|   133k|    if (mpctx->playing)
  ------------------
  |  Branch (2215:9): [True: 31.7k, False: 102k]
  ------------------
 2216|  31.7k|        playlist_entry_unref(mpctx->playing);
 2217|   133k|    mpctx->playing = NULL;
 2218|   133k|    talloc_free(mpctx->filename);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
 2219|   133k|    mpctx->filename = NULL;
 2220|   133k|    mpctx->stream_open_filename = NULL;
 2221|       |
 2222|   133k|    if (end_event.error < 0 && nothing_played) {
  ------------------
  |  Branch (2222:9): [True: 123k, False: 9.88k]
  |  Branch (2222:32): [True: 123k, False: 0]
  ------------------
 2223|   123k|        mpctx->files_broken++;
 2224|   123k|    } else if (end_event.error < 0) {
  ------------------
  |  Branch (2224:16): [True: 0, False: 9.88k]
  ------------------
 2225|      0|        mpctx->files_errored++;
 2226|  9.88k|    } else {
 2227|  9.88k|        mpctx->files_played++;
 2228|  9.88k|    }
 2229|       |
 2230|   133k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (2230:5): [True: 133k, False: 0]
  ------------------
 2231|       |
 2232|   133k|    process_hooks(mpctx, "on_after_end_file");
 2233|       |
 2234|   133k|    if (playlist_prev_continue) {
  ------------------
  |  Branch (2234:9): [True: 0, False: 133k]
  ------------------
 2235|      0|        struct playlist_entry *e = mp_next_file(mpctx, -1, false, true);
 2236|      0|        if (e) {
  ------------------
  |  Branch (2236:13): [True: 0, False: 0]
  ------------------
 2237|      0|            mp_set_playlist_entry(mpctx, e);
 2238|      0|            play_current_file(mpctx);
 2239|      0|        }
 2240|      0|    }
 2241|   133k|}
loadfile.c:process_hooks:
 1225|   483k|{
 1226|   483k|    mp_hook_start(mpctx, name);
 1227|       |
 1228|   483k|    while (!mp_hook_test_completion(mpctx, name)) {
  ------------------
  |  Branch (1228:12): [True: 0, False: 483k]
  ------------------
 1229|      0|        mp_idle(mpctx);
 1230|       |
 1231|       |        // We have no idea what blocks a hook, so just do a full abort. This
 1232|       |        // does nothing for hooks that happen outside of playback.
 1233|      0|        if (mpctx->stop_play)
  ------------------
  |  Branch (1233:13): [True: 0, False: 0]
  ------------------
 1234|      0|            mp_abort_playback_async(mpctx);
 1235|      0|    }
 1236|   483k|}
loadfile.c:load_per_file_options:
 1279|  31.7k|{
 1280|  31.7k|    for (int n = 0; n < params_count; n++) {
  ------------------
  |  Branch (1280:21): [True: 0, False: 31.7k]
  ------------------
 1281|      0|        m_config_set_option_cli(conf, params[n].name, params[n].value,
 1282|      0|                                M_SETOPT_BACKUP);
 1283|      0|    }
 1284|  31.7k|}
loadfile.c:open_demux_reentrant:
 1380|  31.7k|{
 1381|  31.7k|    char *url = mpctx->stream_open_filename;
 1382|       |
 1383|  31.7k|    if (mpctx->open_active) {
  ------------------
  |  Branch (1383:9): [True: 0, False: 31.7k]
  ------------------
 1384|      0|        bool done = atomic_load(&mpctx->open_done);
 1385|      0|        bool failed = done && !mpctx->open_res_demuxer;
  ------------------
  |  Branch (1385:23): [True: 0, False: 0]
  |  Branch (1385:31): [True: 0, False: 0]
  ------------------
 1386|      0|        bool correct_url = strcmp(mpctx->open_url, url) == 0;
 1387|       |
 1388|      0|        if (correct_url && !mpctx->demuxer_changed && !failed) {
  ------------------
  |  Branch (1388:13): [True: 0, False: 0]
  |  Branch (1388:28): [True: 0, False: 0]
  |  Branch (1388:55): [True: 0, False: 0]
  ------------------
 1389|      0|            MP_VERBOSE(mpctx, "Using prefetched/prefetching URL.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1390|      0|        } else {
 1391|      0|            if (correct_url && failed) {
  ------------------
  |  Branch (1391:17): [True: 0, False: 0]
  |  Branch (1391:32): [True: 0, False: 0]
  ------------------
 1392|      0|                MP_VERBOSE(mpctx, "Prefetched URL failed, retrying.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1393|      0|            } else if (mpctx->demuxer_changed) {
  ------------------
  |  Branch (1393:24): [True: 0, False: 0]
  ------------------
 1394|      0|                if (done) {
  ------------------
  |  Branch (1394:21): [True: 0, False: 0]
  ------------------
 1395|      0|                    MP_VERBOSE(mpctx, "Dropping finished prefetch because demuxer options changed.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1396|      0|                } else {
 1397|      0|                    MP_VERBOSE(mpctx, "Aborting ongoing prefetch because demuxer options changed.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1398|      0|                }
 1399|      0|            } else {
 1400|      0|                if (done) {
  ------------------
  |  Branch (1400:21): [True: 0, False: 0]
  ------------------
 1401|      0|                    MP_VERBOSE(mpctx, "Dropping finished prefetch of wrong URL.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1402|      0|                } else {
 1403|      0|                    MP_VERBOSE(mpctx, "Aborting ongoing prefetch of wrong URL.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1404|      0|                }
 1405|      0|            }
 1406|      0|            cancel_open(mpctx);
 1407|      0|        }
 1408|      0|    }
 1409|       |
 1410|  31.7k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1410:9): [True: 31.7k, False: 0]
  ------------------
 1411|  31.7k|        start_open(mpctx, url, mpctx->playing->stream_flags, false);
 1412|       |
 1413|       |    // If thread failed to start, cancel the playback
 1414|  31.7k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1414:9): [True: 0, False: 31.7k]
  ------------------
 1415|      0|        goto cancel;
 1416|       |
 1417|       |    // User abort should cancel the opener now.
 1418|  31.7k|    mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort);
 1419|       |
 1420|  95.3k|    while (!atomic_load(&mpctx->open_done)) {
  ------------------
  |  Branch (1420:12): [True: 63.5k, False: 31.7k]
  ------------------
 1421|  63.5k|        mp_idle(mpctx);
 1422|       |
 1423|  63.5k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1423:13): [True: 0, False: 63.5k]
  ------------------
 1424|      0|            mp_abort_playback_async(mpctx);
 1425|  63.5k|    }
 1426|       |
 1427|  31.7k|    if (mpctx->open_res_demuxer) {
  ------------------
  |  Branch (1427:9): [True: 24.6k, False: 7.12k]
  ------------------
 1428|  24.6k|        mpctx->demuxer = mpctx->open_res_demuxer;
 1429|  24.6k|        mpctx->open_res_demuxer = NULL;
 1430|  24.6k|        mp_cancel_set_parent(mpctx->demuxer->cancel, mpctx->playback_abort);
 1431|  24.6k|    } else {
 1432|  7.12k|        mpctx->error_playing = mpctx->open_res_error;
 1433|  7.12k|    }
 1434|       |
 1435|  31.7k|cancel:
 1436|  31.7k|    cancel_open(mpctx); // cleanup
 1437|  31.7k|}
loadfile.c:infinite_playlist_loading_loop:
 1458|  2.79k|{
 1459|  2.79k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1460|  2.79k|    if (mpctx->playlist_paths_len >= 10) {
  ------------------
  |  Branch (1460:9): [True: 58, False: 2.74k]
  ------------------
 1461|     58|        clear_playlist_paths(mpctx);
 1462|     58|        return true;
 1463|     58|    }
 1464|  2.74k|#endif
 1465|  2.74k|    if (pl->num_entries) {
  ------------------
  |  Branch (1465:9): [True: 2.66k, False: 73]
  ------------------
 1466|  2.66k|        struct playlist_entry *e = pl->entries[0];
 1467|  8.08k|        for (int n = 0; n < mpctx->playlist_paths_len; n++) {
  ------------------
  |  Branch (1467:25): [True: 5.41k, False: 2.66k]
  ------------------
 1468|  5.41k|            if (strcmp(mpctx->playlist_paths[n], e->filename) == 0) {
  ------------------
  |  Branch (1468:17): [True: 1, False: 5.41k]
  ------------------
 1469|      1|                clear_playlist_paths(mpctx);
 1470|      1|                return true;
 1471|      1|            }
 1472|  5.41k|        }
 1473|  2.66k|    }
 1474|  2.74k|    MP_TARRAY_APPEND(mpctx, mpctx->playlist_paths, mpctx->playlist_paths_len,
  ------------------
  |  |  105|  2.74k|    do {                                            \
  |  |  106|  2.74k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.74k|    do {                                            \
  |  |  |  |   97|  2.74k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.74k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.74k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.74k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.76k, False: 975]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.74k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.76k|    do {                                                        \
  |  |  |  |  |  |   89|  1.76k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.76k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.76k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.76k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.76k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.76k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.76k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.76k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  2.74k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  2.74k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  2.74k|        (idxvar)++;                                 \
  |  |  109|  2.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.74k]
  |  |  ------------------
  ------------------
 1475|  2.74k|                     talloc_strdup(mpctx->playlist_paths, mpctx->filename));
 1476|       |    return false;
 1477|  2.74k|}
loadfile.c:transfer_playlist:
 1202|  2.74k|{
 1203|  2.74k|    if (pl->num_entries) {
  ------------------
  |  Branch (1203:9): [True: 2.66k, False: 73]
  ------------------
 1204|  2.66k|        prepare_playlist(mpctx, pl, true);
 1205|  2.66k|        struct playlist_entry *new = pl->current;
 1206|  2.66k|        struct playlist_entry *current = mpctx->playlist->current;
 1207|  2.66k|        *num_new_entries = pl->num_entries;
 1208|  2.66k|        if (current && mpctx->opts->playlist_inherit_options == 1)
  ------------------
  |  Branch (1208:13): [True: 2.66k, False: 0]
  |  Branch (1208:24): [True: 0, False: 2.66k]
  ------------------
 1209|      0|            playlist_set_params(pl, current->params, current->num_params);
 1210|  2.66k|        else if (current && new && mpctx->opts->playlist_inherit_options == 2)
  ------------------
  |  Branch (1210:18): [True: 2.66k, False: 0]
  |  Branch (1210:29): [True: 2.66k, False: 0]
  |  Branch (1210:36): [True: 0, False: 2.66k]
  ------------------
 1211|      0|            playlist_entry_add_params(new, current->params, current->num_params);
 1212|  2.66k|        *start_id = playlist_transfer_entries(mpctx->playlist, pl);
 1213|       |        // current entry is replaced
 1214|  2.66k|        if (current)
  ------------------
  |  Branch (1214:13): [True: 2.66k, False: 0]
  ------------------
 1215|  2.66k|            playlist_remove(mpctx->playlist, current);
 1216|  2.66k|        if (new)
  ------------------
  |  Branch (1216:13): [True: 2.66k, False: 0]
  ------------------
 1217|  2.66k|            mpctx->playlist->current = new;
 1218|  2.66k|        mpctx->playlist->playlist_dir = talloc_steal(mpctx->playlist, pl->playlist_dir);
  ------------------
  |  |   38|  2.66k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.66k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1219|  2.66k|    } else {
 1220|     73|        MP_WARN(mpctx, "Empty playlist!\n");
  ------------------
  |  |   90|     73|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     73|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1221|     73|    }
 1222|  2.74k|}
loadfile.c:load_external_opts:
 1715|  21.8k|{
 1716|  21.8k|    struct mp_waiter wait = MP_WAITER_INITIALIZER;
  ------------------
  |  |   19|  21.8k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  21.8k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  21.8k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  21.8k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  21.8k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  21.8k|    }
  ------------------
 1717|       |
 1718|  21.8k|    void *a[] = {mpctx, &wait};
 1719|  21.8k|    if (!mp_thread_pool_queue(mpctx->thread_pool, load_external_opts_thread, a)) {
  ------------------
  |  Branch (1719:9): [True: 0, False: 21.8k]
  ------------------
 1720|      0|        mpctx->stop_play = PT_ERROR;
 1721|      0|        return;
 1722|      0|    }
 1723|       |
 1724|  43.6k|    while (!mp_waiter_poll(&wait)) {
  ------------------
  |  Branch (1724:12): [True: 21.8k, False: 21.8k]
  ------------------
 1725|  21.8k|        mp_idle(mpctx);
 1726|       |
 1727|  21.8k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1727:13): [True: 0, False: 21.8k]
  ------------------
 1728|      0|            mp_abort_playback_async(mpctx);
 1729|  21.8k|    }
 1730|       |
 1731|  21.8k|    mp_waiter_wait(&wait);
 1732|  21.8k|}
loadfile.c:load_external_opts_thread:
 1695|  21.8k|{
 1696|  21.8k|    void **a = p;
 1697|  21.8k|    struct MPContext *mpctx = a[0];
 1698|  21.8k|    struct mp_waiter *waiter = a[1];
 1699|       |
 1700|  21.8k|    mp_core_lock(mpctx);
 1701|       |
 1702|  21.8k|    load_chapters(mpctx);
 1703|  21.8k|    open_external_files(mpctx, mpctx->opts->audio_files, STREAM_AUDIO);
 1704|  21.8k|    open_external_files(mpctx, mpctx->opts->sub_name, STREAM_SUB);
 1705|  21.8k|    open_external_files(mpctx, mpctx->opts->coverart_files, STREAM_VIDEO);
 1706|  21.8k|    open_external_files(mpctx, mpctx->opts->external_files, STREAM_TYPE_COUNT);
 1707|  21.8k|    autoload_external_files(mpctx, mpctx->playback_abort);
 1708|       |
 1709|  21.8k|    mp_waiter_wakeup(waiter, 0);
 1710|  21.8k|    mp_wakeup_core(mpctx);
 1711|  21.8k|    mp_core_unlock(mpctx);
 1712|  21.8k|}
loadfile.c:load_chapters:
 1240|  21.8k|{
 1241|  21.8k|    struct demuxer *src = mpctx->demuxer;
 1242|  21.8k|    bool free_src = false;
 1243|  21.8k|    char *chapter_file = mpctx->opts->chapter_file;
 1244|  21.8k|    if (chapter_file && chapter_file[0]) {
  ------------------
  |  Branch (1244:9): [True: 0, False: 21.8k]
  |  Branch (1244:25): [True: 0, False: 0]
  ------------------
 1245|      0|        chapter_file = mp_get_user_path(NULL, mpctx->global, chapter_file);
 1246|      0|        mp_core_unlock(mpctx);
 1247|      0|        struct demuxer_params p = {
 1248|      0|            .stream_flags = STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   47|      0|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
 1249|      0|            .depth = src ? src->depth + 1 : 0,
  ------------------
  |  Branch (1249:22): [True: 0, False: 0]
  ------------------
 1250|      0|        };
 1251|      0|        struct demuxer *demux = demux_open_url(chapter_file, &p,
 1252|      0|                                               mpctx->playback_abort,
 1253|      0|                                               mpctx->global);
 1254|      0|        mp_core_lock(mpctx);
 1255|      0|        if (demux) {
  ------------------
  |  Branch (1255:13): [True: 0, False: 0]
  ------------------
 1256|      0|            src = demux;
 1257|      0|            free_src = true;
 1258|      0|        }
 1259|      0|        talloc_free(mpctx->chapters);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1260|      0|        mpctx->chapters = NULL;
 1261|      0|        talloc_free(chapter_file);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1262|      0|    }
 1263|  21.8k|    if (src && !mpctx->chapters) {
  ------------------
  |  Branch (1263:9): [True: 21.8k, False: 0]
  |  Branch (1263:16): [True: 21.8k, False: 0]
  ------------------
 1264|  21.8k|        talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  21.8k|#define talloc_free                     ta_free
  ------------------
 1265|  21.8k|        mpctx->num_chapters = src->num_chapters;
 1266|  21.8k|        mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters);
 1267|  21.8k|        if (mpctx->opts->rebase_start_time) {
  ------------------
  |  Branch (1267:13): [True: 21.8k, False: 0]
  ------------------
 1268|  35.0k|            for (int n = 0; n < mpctx->num_chapters; n++)
  ------------------
  |  Branch (1268:29): [True: 13.2k, False: 21.8k]
  ------------------
 1269|  13.2k|                mpctx->chapters[n].pts -= src->start_time;
 1270|  21.8k|        }
 1271|  21.8k|    }
 1272|  21.8k|    if (free_src)
  ------------------
  |  Branch (1272:9): [True: 0, False: 21.8k]
  ------------------
 1273|      0|        demux_cancel_and_free(src);
 1274|  21.8k|}
loadfile.c:open_external_files:
 1090|  87.2k|{
 1091|       |    // Need a copy, because the option value could be mutated during iteration.
 1092|  87.2k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  87.2k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  87.2k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1093|  87.2k|    files = mp_dup_str_array(tmp, files);
 1094|       |
 1095|  87.2k|    for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1095:21): [True: 0, False: 87.2k]
  |  Branch (1095:30): [True: 0, False: 0]
  ------------------
 1096|       |        // when given filter is set to video, we are loading up cover art
 1097|      0|        mp_add_external_file(mpctx, files[n], filter, mpctx->playback_abort,
 1098|      0|                             filter == STREAM_VIDEO ? TRACK_ATTACHED_PICTURE : 0);
  ------------------
  |  Branch (1098:30): [True: 0, False: 0]
  ------------------
 1099|       |
 1100|  87.2k|    talloc_free(tmp);
  ------------------
  |  |   47|  87.2k|#define talloc_free                     ta_free
  ------------------
 1101|  87.2k|}
loadfile.c:check_previous_track_selection:
  776|  21.8k|{
  777|  21.8k|    struct MPOpts *opts = mpctx->opts;
  778|       |
  779|  21.8k|    if (!mpctx->track_layout_hash)
  ------------------
  |  Branch (779:9): [True: 21.7k, False: 21]
  ------------------
  780|  21.7k|        return;
  781|       |
  782|     21|    char *h = track_layout_hash(mpctx);
  783|     21|    if (strcmp(h, mpctx->track_layout_hash) != 0) {
  ------------------
  |  Branch (783:9): [True: 5, False: 16]
  ------------------
  784|       |        // Reset selection, but only if they're not "auto" or "off". The
  785|       |        // defaults are -1 (default selection), or -2 (off) for secondary tracks.
  786|     20|        for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (786:25): [True: 15, False: 5]
  ------------------
  787|     35|            for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (787:29): [True: 20, False: 15]
  ------------------
  788|     20|                if (opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (788:21): [True: 0, False: 20]
  ------------------
  789|      0|                    mark_track_selection(mpctx, i, t, i == 0 ? -1 : -2);
  ------------------
  |  Branch (789:55): [True: 0, False: 0]
  ------------------
  790|     20|            }
  791|     15|        }
  792|      5|        talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|      5|#define talloc_free                     ta_free
  ------------------
  793|      5|        mpctx->track_layout_hash = NULL;
  794|      5|    }
  795|     21|    talloc_free(h);
  ------------------
  |  |   47|     21|#define talloc_free                     ta_free
  ------------------
  796|     21|}
loadfile.c:clear_playlist_paths:
 1452|  16.8k|{
 1453|       |    TA_FREEP(&mpctx->playlist_paths);
  ------------------
  |  |   81|  16.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  16.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 16.8k]
  |  |  ------------------
  ------------------
 1454|  16.8k|    mpctx->playlist_paths_len = 0;
 1455|  16.8k|}
loadfile.c:append_to_watch_history:
 1735|  16.7k|{
 1736|  16.7k|    if (!mpctx->opts->save_watch_history)
  ------------------
  |  Branch (1736:9): [True: 16.7k, False: 0]
  ------------------
 1737|  16.7k|        return;
 1738|       |
 1739|      0|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1740|      0|    char *history_path = mp_get_user_path(ctx, mpctx->global,
 1741|      0|                                          mpctx->opts->watch_history_path);
 1742|      0|    char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
 1743|      0|    mp_mkdirp(history_path_dir);
 1744|       |
 1745|      0|    FILE *history_file = fopen(history_path, "ab");
  ------------------
  |  |   84|      0|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
 1746|      0|    if (!history_file) {
  ------------------
  |  Branch (1746:9): [True: 0, False: 0]
  ------------------
 1747|      0|        MP_ERR(mpctx, "Failed to open history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1748|      0|               mp_strerror(errno));
 1749|      0|        goto done;
 1750|      0|    }
 1751|       |
 1752|      0|    char *title = (char *)mp_find_non_filename_media_title(mpctx);
 1753|       |
 1754|      0|    mpv_node_list *list = talloc_zero(ctx, mpv_node_list);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|      0|    mpv_node node = {
 1756|      0|        .format = MPV_FORMAT_NODE_MAP,
 1757|      0|        .u.list = list,
 1758|      0|    };
 1759|      0|    list->num = title ? 3 : 2;
  ------------------
  |  Branch (1759:17): [True: 0, False: 0]
  ------------------
 1760|      0|    list->keys = talloc_array(ctx, char*, list->num);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|      0|    list->values = talloc_array(ctx, mpv_node, list->num);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1762|      0|    list->keys[0] = "time";
 1763|      0|    list->values[0] = (struct mpv_node) {
 1764|      0|        .format = MPV_FORMAT_INT64,
 1765|      0|        .u.int64 = time(NULL),
 1766|      0|    };
 1767|      0|    list->keys[1] = "path";
 1768|      0|    list->values[1] = (struct mpv_node) {
 1769|      0|        .format = MPV_FORMAT_STRING,
 1770|      0|        .u.string = mpctx->filename,
 1771|      0|    };
 1772|      0|    if (title) {
  ------------------
  |  Branch (1772:9): [True: 0, False: 0]
  ------------------
 1773|      0|        list->keys[2] = "title";
 1774|      0|        list->values[2] = (struct mpv_node) {
 1775|      0|            .format = MPV_FORMAT_STRING,
 1776|      0|            .u.string = title,
 1777|      0|        };
 1778|      0|    }
 1779|       |
 1780|      0|    bstr dst = {0};
 1781|      0|    json_append(&dst, &node, -1);
 1782|      0|    talloc_steal(ctx, dst.start);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1783|      0|    if (!dst.len) {
  ------------------
  |  Branch (1783:9): [True: 0, False: 0]
  ------------------
 1784|      0|        MP_ERR(mpctx, "Failed to serialize history entry\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1785|      0|        goto done;
 1786|      0|    }
 1787|      0|    bstr_xappend0(ctx, &dst, "\n");
 1788|       |
 1789|      0|    int seek = fseek(history_file, 0, SEEK_END);
 1790|      0|    off_t history_size = ftell(history_file);
 1791|      0|    if (seek != 0 || history_size == -1) {
  ------------------
  |  Branch (1791:9): [True: 0, False: 0]
  |  Branch (1791:22): [True: 0, False: 0]
  ------------------
 1792|      0|        MP_ERR(mpctx, "Failed to get history file size: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1793|      0|               mp_strerror(errno));
 1794|      0|        goto done;
 1795|      0|    }
 1796|       |
 1797|      0|    bool failed = fwrite(dst.start, dst.len, 1, history_file) != 1 ||
  ------------------
  |  Branch (1797:19): [True: 0, False: 0]
  ------------------
 1798|      0|                  fflush(history_file) != 0;
  ------------------
  |  Branch (1798:19): [True: 0, False: 0]
  ------------------
 1799|       |
 1800|      0|    if (failed) {
  ------------------
  |  Branch (1800:9): [True: 0, False: 0]
  ------------------
 1801|      0|        MP_ERR(mpctx, "Failed to write to history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1802|      0|               mp_strerror(errno));
 1803|       |
 1804|      0|        int fd = fileno(history_file);
 1805|      0|        if (fd == -1 || ftruncate(fd, history_size) == -1)
  ------------------
  |  Branch (1805:13): [True: 0, False: 0]
  |  Branch (1805:25): [True: 0, False: 0]
  ------------------
 1806|      0|            MP_ERR(mpctx, "Failed to roll-back history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1807|      0|                   mp_strerror(errno));
 1808|      0|    }
 1809|       |
 1810|      0|done:
 1811|      0|    if (history_file != NULL && fclose(history_file) != 0)
  ------------------
  |  Branch (1811:9): [True: 0, False: 0]
  |  Branch (1811:33): [True: 0, False: 0]
  ------------------
 1812|      0|        MP_ERR(mpctx, "Failed to close history file: %s\n", mp_strerror(errno));
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1813|       |
 1814|      0|    talloc_free(ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1815|      0|}
loadfile.c:uninit_demuxer:
  193|   133k|{
  194|   534k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (194:21): [True: 401k, False: 133k]
  ------------------
  195|   936k|        for (int r = 0; r < num_ptracks[t]; r++)
  ------------------
  |  Branch (195:25): [True: 534k, False: 401k]
  ------------------
  196|   534k|            mpctx->current_track[r][t] = NULL;
  197|   401k|    }
  198|       |
  199|   133k|    talloc_free(mpctx->chapters);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
  200|   133k|    mpctx->chapters = NULL;
  201|   133k|    mpctx->num_chapters = 0;
  202|       |
  203|   133k|    mp_abort_cache_dumping(mpctx);
  204|       |
  205|   133k|    struct demuxer **demuxers = NULL;
  206|   133k|    int num_demuxers = 0;
  207|       |
  208|   133k|    if (mpctx->demuxer)
  ------------------
  |  Branch (208:9): [True: 24.6k, False: 109k]
  ------------------
  209|  24.6k|        MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, mpctx->demuxer);
  ------------------
  |  |  105|  24.6k|    do {                                            \
  |  |  106|  24.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.6k|    do {                                            \
  |  |  |  |   97|  24.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.6k|    do {                                                        \
  |  |  |  |  |  |   89|  24.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.6k|        (idxvar)++;                                 \
  |  |  109|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
  210|   133k|    mpctx->demuxer = NULL;
  211|       |
  212|   157k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (212:21): [True: 24.0k, False: 133k]
  ------------------
  213|  24.0k|        struct track *track = mpctx->tracks[i];
  214|       |
  215|  24.0k|        mp_assert(!track->dec && !track->d_sub);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (215:9): [True: 24.0k, False: 0]
  |  Branch (215:9): [True: 24.0k, False: 0]
  ------------------
  216|  24.0k|        mp_assert(!track->vo_c && !track->ao_c);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (216:9): [True: 24.0k, False: 0]
  |  Branch (216:9): [True: 24.0k, False: 0]
  ------------------
  217|  24.0k|        mp_assert(!track->sink);
  ------------------
  |  |   41|  24.0k|#define mp_assert assert
  ------------------
  |  Branch (217:9): [True: 24.0k, False: 0]
  ------------------
  218|       |
  219|       |        // Demuxers can be added in any order (if they appear mid-stream), and
  220|       |        // we can't know which tracks uses which, so here's some O(n^2) trash.
  221|  24.0k|        for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (221:25): [True: 24.0k, False: 0]
  ------------------
  222|  24.0k|            if (demuxers[n] == track->demuxer) {
  ------------------
  |  Branch (222:17): [True: 24.0k, False: 0]
  ------------------
  223|  24.0k|                track->demuxer = NULL;
  224|  24.0k|                break;
  225|  24.0k|            }
  226|  24.0k|        }
  227|  24.0k|        if (track->demuxer)
  ------------------
  |  Branch (227:13): [True: 0, False: 24.0k]
  ------------------
  228|      0|            MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, track->demuxer);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  229|       |
  230|  24.0k|        talloc_free(track);
  ------------------
  |  |   47|  24.0k|#define talloc_free                     ta_free
  ------------------
  231|  24.0k|    }
  232|   133k|    mpctx->num_tracks = 0;
  233|       |
  234|   133k|    kill_demuxers_reentrant(mpctx, demuxers, num_demuxers);
  235|   133k|    talloc_free(demuxers);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
  236|       |
  237|   133k|    disc_nav_reset(mpctx);
  238|   133k|}
loadfile.c:kill_demuxers_reentrant:
  135|   133k|{
  136|   133k|    struct demux_free_async_state **items = NULL;
  137|   133k|    int num_items = 0;
  138|       |
  139|   158k|    for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (139:21): [True: 24.6k, False: 133k]
  ------------------
  140|  24.6k|        struct demuxer *d = demuxers[n];
  141|       |
  142|  24.6k|        if (!demux_cancel_test(d)) {
  ------------------
  |  Branch (142:13): [True: 24.6k, False: 0]
  ------------------
  143|       |            // Make sure it is set if it wasn't yet.
  144|  24.6k|            demux_set_wakeup_cb(d, wakeup_demux, mpctx);
  145|       |
  146|  24.6k|            struct demux_free_async_state *item = demux_free_async(d);
  147|  24.6k|            if (item) {
  ------------------
  |  Branch (147:17): [True: 19.9k, False: 4.66k]
  ------------------
  148|  19.9k|                MP_TARRAY_APPEND(NULL, items, num_items, item);
  ------------------
  |  |  105|  19.9k|    do {                                            \
  |  |  106|  19.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.9k|    do {                                            \
  |  |  |  |   97|  19.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  19.9k|    do {                                                        \
  |  |  |  |  |  |   89|  19.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  19.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  19.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  19.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  19.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  19.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  19.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 19.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  19.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.9k|        (idxvar)++;                                 \
  |  |  109|  19.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.9k]
  |  |  ------------------
  ------------------
  149|  19.9k|                d = NULL;
  150|  19.9k|            }
  151|  24.6k|        }
  152|       |
  153|  24.6k|        demux_cancel_and_free(d);
  154|  24.6k|    }
  155|       |
  156|   133k|    if (!num_items)
  ------------------
  |  Branch (156:9): [True: 113k, False: 19.9k]
  ------------------
  157|   113k|        return;
  158|       |
  159|  19.9k|    MP_DBG(mpctx, "Terminating demuxers...\n");
  ------------------
  |  |   93|  19.9k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|       |
  161|  19.9k|    double end = mp_time_sec() + mpctx->opts->demux_termination_timeout;
  162|  19.9k|    bool force = false;
  163|  79.8k|    while (num_items) {
  ------------------
  |  Branch (163:12): [True: 59.8k, False: 19.9k]
  ------------------
  164|  59.8k|        double wait = end - mp_time_sec();
  165|       |
  166|  99.7k|        for (int n = 0; n < num_items; n++) {
  ------------------
  |  Branch (166:25): [True: 59.8k, False: 39.9k]
  ------------------
  167|  59.8k|            struct demux_free_async_state *item = items[n];
  168|  59.8k|            if (demux_free_async_finish(item)) {
  ------------------
  |  Branch (168:17): [True: 19.9k, False: 39.9k]
  ------------------
  169|  19.9k|                items[n] = items[num_items - 1];
  170|  19.9k|                num_items -= 1;
  171|  19.9k|                n--;
  172|  19.9k|                goto repeat;
  173|  39.9k|            } else if (wait < 0) {
  ------------------
  |  Branch (173:24): [True: 0, False: 39.9k]
  ------------------
  174|      0|                demux_free_async_force(item);
  175|      0|                if (!force)
  ------------------
  |  Branch (175:21): [True: 0, False: 0]
  ------------------
  176|      0|                    MP_VERBOSE(mpctx, "Forcefully terminating demuxers...\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  177|      0|                force = true;
  178|      0|            }
  179|  59.8k|        }
  180|       |
  181|  39.9k|        if (wait >= 0)
  ------------------
  |  Branch (181:13): [True: 39.9k, False: 0]
  ------------------
  182|  39.9k|            mp_set_timeout(mpctx, wait);
  183|  39.9k|        mp_idle(mpctx);
  184|  59.8k|    repeat:;
  185|  59.8k|    }
  186|       |
  187|  19.9k|    talloc_free(items);
  ------------------
  |  |   47|  19.9k|#define talloc_free                     ta_free
  ------------------
  188|       |
  189|  19.9k|    MP_DBG(mpctx, "Done terminating demuxers.\n");
  ------------------
  |  |   93|  19.9k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  190|  19.9k|}
loadfile.c:cancel_open:
 1334|  92.4k|{
 1335|  92.4k|    if (mpctx->open_cancel)
  ------------------
  |  Branch (1335:9): [True: 31.7k, False: 60.6k]
  ------------------
 1336|  31.7k|        mp_cancel_trigger(mpctx->open_cancel);
 1337|       |
 1338|  92.4k|    if (mpctx->open_active)
  ------------------
  |  Branch (1338:9): [True: 31.7k, False: 60.6k]
  ------------------
 1339|  31.7k|        mp_thread_join(mpctx->open_thread);
  ------------------
  |  |  215|  31.7k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1340|  92.4k|    mpctx->open_active = false;
 1341|       |
 1342|  92.4k|    if (mpctx->open_res_demuxer)
  ------------------
  |  Branch (1342:9): [True: 0, False: 92.4k]
  ------------------
 1343|      0|        demux_cancel_and_free(mpctx->open_res_demuxer);
 1344|  92.4k|    mpctx->open_res_demuxer = NULL;
 1345|       |
 1346|  92.4k|    TA_FREEP(&mpctx->open_cancel);
  ------------------
  |  |   81|  92.4k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  92.4k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 92.4k]
  |  |  ------------------
  ------------------
 1347|  92.4k|    TA_FREEP(&mpctx->open_url);
  ------------------
  |  |   81|  92.4k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  92.4k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 92.4k]
  |  |  ------------------
  ------------------
 1348|  92.4k|    TA_FREEP(&mpctx->open_format);
  ------------------
  |  |   81|  92.4k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  92.4k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 92.4k]
  |  |  ------------------
  ------------------
 1349|       |
 1350|       |    atomic_store(&mpctx->open_done, false);
 1351|  92.4k|}

mp_update_logging:
  129|  57.9k|{
  130|  57.9k|    bool had_log_file = mp_msg_has_log_file(mpctx->global);
  131|       |
  132|  57.9k|    mp_msg_update_msglevels(mpctx->global, mpctx->opts);
  133|       |
  134|  57.9k|    bool enable = mpctx->opts->use_terminal;
  135|  57.9k|    bool enabled = cas_terminal_owner(mpctx, mpctx);
  136|  57.9k|    if (enable != enabled) {
  ------------------
  |  Branch (136:9): [True: 0, False: 57.9k]
  ------------------
  137|      0|        if (enable && cas_terminal_owner(NULL, mpctx)) {
  ------------------
  |  Branch (137:13): [True: 0, False: 0]
  |  Branch (137:23): [True: 0, False: 0]
  ------------------
  138|      0|            terminal_init();
  139|      0|            enabled = true;
  140|      0|        } else if (!enable) {
  ------------------
  |  Branch (140:20): [True: 0, False: 0]
  ------------------
  141|      0|            terminal_uninit();
  142|      0|            cas_terminal_owner(mpctx, NULL);
  143|      0|        }
  144|      0|    }
  145|       |
  146|  57.9k|    if (mp_msg_has_log_file(mpctx->global) && !had_log_file) {
  ------------------
  |  Branch (146:9): [True: 0, False: 57.9k]
  |  Branch (146:47): [True: 0, False: 0]
  ------------------
  147|       |        // for log-file=... in config files.
  148|       |        // we did flush earlier messages, but they were in a cyclic buffer, so
  149|       |        // the version might have been overwritten. ensure we have it.
  150|      0|        mp_print_version(mpctx->log, false);
  151|      0|    }
  152|       |
  153|  57.9k|    if (enabled && !preinit && mpctx->opts->consolecontrols)
  ------------------
  |  Branch (153:9): [True: 0, False: 57.9k]
  |  Branch (153:20): [True: 0, False: 0]
  |  Branch (153:32): [True: 0, False: 0]
  ------------------
  154|      0|        terminal_setup_getch(mpctx->input);
  155|       |
  156|  57.9k|    if (enabled)
  ------------------
  |  Branch (156:9): [True: 0, False: 57.9k]
  ------------------
  157|      0|        mp_encoder_update_log(mpctx->global);
  158|  57.9k|}
mp_print_version:
  161|  28.9k|{
  162|  28.9k|    int v = always ? MSGL_INFO : MSGL_V;
  ------------------
  |  Branch (162:13): [True: 0, False: 28.9k]
  ------------------
  163|  28.9k|    mp_msg(log, v, "%s %s\n", mpv_version, mpv_copyright);
  164|  28.9k|    if (strcmp(mpv_builddate, "UNKNOWN"))
  ------------------
  |  Branch (164:9): [True: 28.9k, False: 0]
  ------------------
  165|  28.9k|        mp_msg(log, v, " built on %s\n", mpv_builddate);
  166|  28.9k|    mp_msg(log, v, "libplacebo version: %s\n", PL_VERSION);
  ------------------
  |  |   32|  28.9k|#define PL_VERSION (pl_version())
  ------------------
  167|  28.9k|    check_library_versions(log, v);
  168|       |    // Only in verbose mode.
  169|  28.9k|    if (!always) {
  ------------------
  |  Branch (169:9): [True: 28.9k, False: 0]
  ------------------
  170|  28.9k|        mp_msg(log, MSGL_V, "Configuration: " CONFIGURATION "\n");
  171|  28.9k|        mp_msg(log, MSGL_V, "List of enabled features: " FULLCONFIG "\n");
  172|       |        #ifdef NDEBUG
  173|       |            mp_msg(log, MSGL_V, "Built with NDEBUG.\n");
  174|       |        #endif
  175|  28.9k|    }
  176|  28.9k|}
mp_destroy:
  179|  28.9k|{
  180|  28.9k|    mp_shutdown_clients(mpctx);
  181|       |
  182|  28.9k|    mp_uninit_ipc(mpctx->ipc_ctx);
  183|  28.9k|    mpctx->ipc_ctx = NULL;
  184|       |
  185|  28.9k|    uninit_audio_out(mpctx);
  186|  28.9k|    uninit_video_out(mpctx);
  187|       |
  188|       |    // If it's still set here, it's an error.
  189|  28.9k|    encode_lavc_free(mpctx->encode_lavc_ctx);
  190|  28.9k|    mpctx->encode_lavc_ctx = NULL;
  191|       |
  192|  28.9k|    command_uninit(mpctx);
  193|  28.9k|    disc_nav_destroy(mpctx);
  194|       |
  195|  28.9k|    mp_clients_destroy(mpctx);
  196|       |
  197|  28.9k|    osd_free(mpctx->osd);
  198|       |
  199|       |#if HAVE_COCOA
  200|       |    cocoa_set_input_context(NULL);
  201|       |#endif
  202|       |
  203|  28.9k|    if (cas_terminal_owner(mpctx, mpctx)) {
  ------------------
  |  Branch (203:9): [True: 0, False: 28.9k]
  ------------------
  204|      0|        terminal_uninit();
  205|      0|        cas_terminal_owner(mpctx, NULL);
  206|      0|    }
  207|       |
  208|  28.9k|    mp_input_uninit(mpctx->input);
  209|  28.9k|    mp_clipboard_destroy(mpctx->clipboard);
  210|       |
  211|  28.9k|    uninit_libav(mpctx->global);
  212|       |
  213|  28.9k|    mp_msg_uninit(mpctx->global);
  214|  28.9k|    mp_assert(!mpctx->num_abort_list);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 28.9k, False: 0]
  ------------------
  215|  28.9k|    talloc_free(mpctx->abort_list);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  216|  28.9k|    mp_mutex_destroy(&mpctx->abort_lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  217|  28.9k|    talloc_free(mpctx->mconfig); // destroy before dispatch
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  218|  28.9k|    talloc_free(mpctx);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  219|  28.9k|}
mp_create:
  261|  28.9k|{
  262|  28.9k|    if (!check_locale()) {
  ------------------
  |  Branch (262:9): [True: 0, False: 28.9k]
  ------------------
  263|       |        // Normally, we never print anything (except if the "terminal" option
  264|       |        // is enabled), so this is an exception.
  265|      0|        fprintf(stderr, "Non-C locale detected. This is not supported.\n"
  266|      0|                        "Call 'setlocale(LC_NUMERIC, \"C\");' in your code.\n");
  267|      0|        return NULL;
  268|      0|    }
  269|       |
  270|  28.9k|    char *enable_talloc = getenv("MPV_LEAK_REPORT");
  271|  28.9k|    if (enable_talloc && strcmp(enable_talloc, "1") == 0)
  ------------------
  |  Branch (271:9): [True: 0, False: 28.9k]
  |  Branch (271:26): [True: 0, False: 0]
  ------------------
  272|      0|        talloc_enable_leak_report();
  ------------------
  |  |   42|      0|#define talloc_enable_leak_report       ta_enable_leak_report
  ------------------
  273|       |
  274|  28.9k|    mp_time_init();
  275|       |
  276|  28.9k|    struct MPContext *mpctx = talloc(NULL, MPContext);
  ------------------
  |  |   26|  28.9k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  28.9k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|  28.9k|    *mpctx = (struct MPContext){
  278|  28.9k|        .last_chapter = -2,
  279|  28.9k|        .term_osd_contents = talloc_strdup(mpctx, ""),
  ------------------
  |  |   50|  28.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
  280|  28.9k|        .osd_progbar = { .type = -1 },
  281|  28.9k|        .playlist = talloc_zero(mpctx, struct playlist),
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  282|  28.9k|        .dispatch = mp_dispatch_create(mpctx),
  283|  28.9k|        .playback_abort = mp_cancel_new(mpctx),
  284|  28.9k|        .thread_pool = mp_thread_pool_create(mpctx, 0, 1, 30),
  285|  28.9k|        .stop_play = PT_NEXT_ENTRY,
  286|  28.9k|        .play_dir = 1,
  287|  28.9k|    };
  288|       |
  289|  28.9k|    mp_mutex_init(&mpctx->abort_lock);
  290|       |
  291|  28.9k|    mpctx->global = talloc_zero(mpctx, struct mpv_global);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|  28.9k|    demux_packet_pool_init(mpctx->global);
  294|  28.9k|    stats_global_init(mpctx->global);
  295|       |#if HAVE_LIBCURL
  296|       |    mp_curl_global_init(mpctx->global);
  297|       |#endif
  298|       |
  299|       |    // Nothing must call mp_msg*() and related before this
  300|  28.9k|    mp_msg_init(mpctx->global);
  301|  28.9k|    mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer");
  302|  28.9k|    mpctx->statusline = mp_log_new(mpctx, mpctx->log, "!statusline");
  303|       |
  304|  28.9k|    mpctx->stats = stats_ctx_create(mpctx, mpctx->global, "main");
  305|       |
  306|       |    // Create the config context and register the options
  307|  28.9k|    mpctx->mconfig = m_config_new(mpctx, mpctx->log, &mp_opt_root);
  308|  28.9k|    mpctx->opts = mpctx->mconfig->optstruct;
  309|  28.9k|    mpctx->global->config = mpctx->mconfig->shadow;
  310|  28.9k|    mpctx->mconfig->includefunc = cfg_include;
  311|  28.9k|    mpctx->mconfig->includefunc_ctx = mpctx;
  312|  28.9k|    mpctx->mconfig->use_profiles = true;
  313|  28.9k|    mpctx->mconfig->is_toplevel = true;
  314|  28.9k|    mpctx->mconfig->global = mpctx->global;
  315|  28.9k|    m_config_parse(mpctx->mconfig, "", bstr0(def_config), NULL, 0);
  316|       |
  317|  28.9k|    mpctx->input = mp_input_init(mpctx->global, mp_wakeup_core_cb, mpctx);
  318|  28.9k|    clipboard_init(mpctx);
  319|  28.9k|    screenshot_init(mpctx);
  320|  28.9k|    command_init(mpctx);
  321|  28.9k|    init_libav(mpctx->global);
  322|  28.9k|    mp_clients_init(mpctx);
  323|  28.9k|    mpctx->osd = osd_create(mpctx->global);
  324|       |
  325|       |#if HAVE_COCOA
  326|       |    cocoa_set_input_context(mpctx->input);
  327|       |#endif
  328|       |
  329|  28.9k|    char *verbose_env = getenv("MPV_VERBOSE");
  330|  28.9k|    if (verbose_env)
  ------------------
  |  Branch (330:9): [True: 0, False: 28.9k]
  ------------------
  331|      0|        mpctx->opts->verbose = strtol(verbose_env, NULL, 10);
  332|       |
  333|  28.9k|    mp_cancel_trigger(mpctx->playback_abort);
  334|       |
  335|  28.9k|    return mpctx;
  336|  28.9k|}
mp_initialize:
  344|  28.9k|{
  345|  28.9k|    struct MPOpts *opts = mpctx->opts;
  346|       |
  347|  28.9k|    mp_assert(!mpctx->initialized);
  ------------------
  |  |   41|  28.9k|#define mp_assert assert
  ------------------
  |  Branch (347:5): [True: 28.9k, False: 0]
  ------------------
  348|       |
  349|       |    // Preparse the command line, so we can init the terminal early.
  350|  28.9k|    if (options) {
  ------------------
  |  Branch (350:9): [True: 0, False: 28.9k]
  ------------------
  351|      0|        m_config_preparse_command_line(mpctx->mconfig, mpctx->global,
  352|      0|                                       &opts->verbose, options);
  353|      0|    }
  354|       |
  355|  28.9k|    mp_init_paths(mpctx->global, opts);
  356|  28.9k|    mp_msg_set_early_logging(mpctx->global, true);
  357|  28.9k|    mp_update_logging(mpctx, true);
  358|       |
  359|  28.9k|    if (options) {
  ------------------
  |  Branch (359:9): [True: 0, False: 28.9k]
  ------------------
  360|      0|        MP_VERBOSE(mpctx, "Command line options:");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  361|      0|        for (int i = 0; options[i]; i++)
  ------------------
  |  Branch (361:25): [True: 0, False: 0]
  ------------------
  362|      0|            MP_VERBOSE(mpctx, " '%s'", options[i]);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  363|      0|        MP_VERBOSE(mpctx, "\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  364|      0|    }
  365|       |
  366|  28.9k|    mp_print_version(mpctx->log, false);
  367|       |
  368|  28.9k|    mp_parse_cfgfiles(mpctx);
  369|       |
  370|  28.9k|    if (options) {
  ------------------
  |  Branch (370:9): [True: 0, False: 28.9k]
  ------------------
  371|      0|        int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
  372|      0|                                               mpctx->global, options);
  373|      0|        if (r < 0)
  ------------------
  |  Branch (373:13): [True: 0, False: 0]
  ------------------
  374|      0|            return r == M_OPT_EXIT ? 1 : -1;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (374:20): [True: 0, False: 0]
  ------------------
  375|      0|    }
  376|       |
  377|  28.9k|    if (opts->operation_mode == 1) {
  ------------------
  |  Branch (377:9): [True: 0, False: 28.9k]
  ------------------
  378|      0|        m_config_set_profile(mpctx->mconfig, "builtin-pseudo-gui",
  379|      0|                             M_SETOPT_NO_OVERWRITE);
  380|      0|        m_config_set_profile(mpctx->mconfig, "pseudo-gui", 0);
  381|      0|    }
  382|       |
  383|       |    // Backup the default settings, which should not be stored in the resume
  384|       |    // config files. This explicitly includes values set by config files and
  385|       |    // the command line.
  386|  28.9k|    m_config_backup_watch_later_opts(mpctx->mconfig);
  387|       |
  388|  28.9k|    mp_input_load_config(mpctx->input);
  389|       |
  390|       |    // From this point on, all mpctx members are initialized.
  391|  28.9k|    mpctx->initialized = true;
  392|  28.9k|    mpctx->mconfig->option_change_callback = mp_option_change_callback;
  393|  28.9k|    mpctx->mconfig->option_change_callback_ctx = mpctx;
  394|  28.9k|    m_config_set_update_dispatch_queue(mpctx->mconfig, mpctx->dispatch);
  395|       |    // Run all update handlers.
  396|  28.9k|    mp_option_change_callback(mpctx, NULL, UPDATE_OPTS_MASK, false);
  ------------------
  |  |  465|  28.9k|#define UPDATE_OPTS_MASK        ((UPDATE_OPT_LAST << 1) - 1)
  |  |  ------------------
  |  |  |  |  462|  28.9k|#define UPDATE_OPT_LAST         (UINT64_C(1) << 20)
  |  |  ------------------
  ------------------
  397|  28.9k|    handle_option_callbacks(mpctx);
  398|       |
  399|  28.9k|    if (handle_help_options(mpctx))
  ------------------
  |  Branch (399:9): [True: 0, False: 28.9k]
  ------------------
  400|      0|        return 1; // help
  401|       |
  402|       |#if HAVE_WIN32_DESKTOP
  403|       |    if (mp_w32_handle_register(mpctx))
  404|       |        return 1; // register/unregister
  405|       |#endif
  406|       |
  407|  28.9k|    check_library_versions(mp_null_log, 0);
  408|       |
  409|  28.9k|    if (!mpctx->playlist->num_entries && !opts->player_idle_mode &&
  ------------------
  |  Branch (409:9): [True: 28.9k, False: 0]
  |  Branch (409:42): [True: 0, False: 28.9k]
  ------------------
  410|      0|        options)
  ------------------
  |  Branch (410:9): [True: 0, False: 0]
  ------------------
  411|      0|    {
  412|       |        // nothing to play
  413|      0|        mp_print_version(mpctx->log, true);
  414|      0|        MP_INFO(mpctx, "%s", mp_help_text);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  415|      0|        return 1;
  416|      0|    }
  417|       |
  418|  28.9k|    MP_STATS(mpctx, "start init");
  ------------------
  |  |   99|  28.9k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  419|       |
  420|       |#if HAVE_COCOA
  421|       |    mpv_handle *ctx = mp_new_client(mpctx->clients, "mac");
  422|       |    cocoa_set_mpv_handle(ctx);
  423|       |#endif
  424|       |
  425|       |#if HAVE_WIN32_SMTC
  426|       |    mp_smtc_init(mp_new_weak_client(mpctx->clients, "SystemMediaTransportControls"));
  427|       |#endif
  428|       |
  429|  28.9k|    mp_dnd_init(mp_new_weak_client(mpctx->clients, "dnd"));
  430|       |
  431|  28.9k|    mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
  432|       |
  433|  28.9k|    if (opts->encode_opts->file && opts->encode_opts->file[0]) {
  ------------------
  |  Branch (433:9): [True: 0, False: 28.9k]
  |  Branch (433:36): [True: 0, False: 0]
  ------------------
  434|      0|        mpctx->encode_lavc_ctx = encode_lavc_init(mpctx->global);
  435|      0|        if(!mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (435:12): [True: 0, False: 0]
  ------------------
  436|      0|            MP_INFO(mpctx, "Encoding initialization failed.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  437|      0|            return -1;
  438|      0|        }
  439|      0|    }
  440|       |
  441|  28.9k|    mp_load_scripts(mpctx);
  442|       |
  443|  28.9k|    if (opts->force_vo == 2 && handle_force_window(mpctx, false) < 0)
  ------------------
  |  Branch (443:9): [True: 0, False: 28.9k]
  |  Branch (443:32): [True: 0, False: 0]
  ------------------
  444|      0|        return -1;
  445|       |
  446|       |    // Needed to properly enter _initial_ idle mode if playlist empty.
  447|  28.9k|    if (mpctx->opts->player_idle_mode && !mpctx->playlist->num_entries)
  ------------------
  |  Branch (447:9): [True: 28.9k, False: 0]
  |  Branch (447:42): [True: 28.9k, False: 0]
  ------------------
  448|  28.9k|        mpctx->stop_play = PT_STOP;
  449|       |
  450|  28.9k|    MP_STATS(mpctx, "end init");
  ------------------
  |  |   99|  28.9k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  451|       |
  452|  28.9k|    return 0;
  453|  28.9k|}
main.c:cas_terminal_owner:
  119|  86.8k|{
  120|  86.8k|    mp_mutex_lock(&terminal_owner_lock);
  ------------------
  |  |  134|  86.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  121|  86.8k|    bool r = terminal_owner == old;
  122|  86.8k|    if (r)
  ------------------
  |  Branch (122:9): [True: 0, False: 86.8k]
  ------------------
  123|      0|        terminal_owner = new;
  124|  86.8k|    mp_mutex_unlock(&terminal_owner_lock);
  ------------------
  |  |  136|  86.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  125|  86.8k|    return r;
  126|  86.8k|}
main.c:check_locale:
  255|  28.9k|{
  256|  28.9k|    char *name = setlocale(LC_NUMERIC, NULL);
  257|  28.9k|    return !name || strcmp(name, "C") == 0 || strcmp(name, "C.UTF-8") == 0;
  ------------------
  |  Branch (257:12): [True: 0, False: 28.9k]
  |  Branch (257:21): [True: 28.9k, False: 0]
  |  Branch (257:47): [True: 0, False: 0]
  ------------------
  258|  28.9k|}
main.c:handle_help_options:
  222|  28.9k|{
  223|  28.9k|    struct MPOpts *opts = mpctx->opts;
  224|  28.9k|    struct mp_log *log = mpctx->log;
  225|  28.9k|    if (opts->ao_opts->audio_device &&
  ------------------
  |  Branch (225:9): [True: 28.9k, False: 0]
  ------------------
  226|  28.9k|        strcmp(opts->ao_opts->audio_device, "help") == 0)
  ------------------
  |  Branch (226:9): [True: 0, False: 28.9k]
  ------------------
  227|      0|    {
  228|      0|        ao_print_devices(mpctx->global, log, mpctx->ao);
  229|      0|        return true;
  230|      0|    }
  231|  28.9k|    if (opts->property_print_help) {
  ------------------
  |  Branch (231:9): [True: 0, False: 28.9k]
  ------------------
  232|      0|        property_print_help(mpctx);
  233|      0|        return true;
  234|      0|    }
  235|  28.9k|    if (encode_lavc_showhelp(log, opts->encode_opts))
  ------------------
  |  Branch (235:9): [True: 0, False: 28.9k]
  ------------------
  236|      0|        return true;
  237|  28.9k|    return false;
  238|  28.9k|}

rel_time_to_abs:
   55|  1.70M|{
   56|  1.70M|    double length = get_time_length(mpctx);
   57|       |    // Relative times are an offset to the start of the file.
   58|  1.70M|    double start = 0;
   59|  1.70M|    if (mpctx->demuxer && !mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (59:9): [True: 1.70M, False: 0]
  |  Branch (59:27): [True: 0, False: 1.70M]
  ------------------
   60|      0|        start = mpctx->demuxer->start_time;
   61|       |
   62|  1.70M|    switch (t.type) {
  ------------------
  |  Branch (62:13): [True: 0, False: 1.70M]
  ------------------
   63|      0|    case REL_TIME_ABSOLUTE:
  ------------------
  |  Branch (63:5): [True: 0, False: 1.70M]
  ------------------
   64|      0|        return t.pos;
   65|      0|    case REL_TIME_RELATIVE:
  ------------------
  |  Branch (65:5): [True: 0, False: 1.70M]
  ------------------
   66|      0|        if (t.pos >= 0) {
  ------------------
  |  Branch (66:13): [True: 0, False: 0]
  ------------------
   67|      0|            return start + t.pos;
   68|      0|        } else {
   69|      0|            if (length >= 0)
  ------------------
  |  Branch (69:17): [True: 0, False: 0]
  ------------------
   70|      0|                return start + MPMAX(length + t.pos, 0.0);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   71|      0|        }
   72|      0|        break;
   73|      0|    case REL_TIME_PERCENT:
  ------------------
  |  Branch (73:5): [True: 0, False: 1.70M]
  ------------------
   74|      0|        if (length >= 0)
  ------------------
  |  Branch (74:13): [True: 0, False: 0]
  ------------------
   75|      0|            return start + length * (t.pos / 100.0);
   76|      0|        break;
   77|      0|    case REL_TIME_CHAPTER:
  ------------------
  |  Branch (77:5): [True: 0, False: 1.70M]
  ------------------
   78|      0|        return chapter_start_time(mpctx, t.pos); // already absolute time
   79|  1.70M|    }
   80|       |
   81|  1.70M|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.70M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   82|  1.70M|}
get_play_end_pts:
  100|   844k|{
  101|   844k|    double end = get_play_end_pts_setting(mpctx);
  102|   844k|    double ab[2];
  103|   844k|    if (mpctx->ab_loop_clip && get_ab_loop_times(mpctx, ab)) {
  ------------------
  |  Branch (103:9): [True: 33.6k, False: 810k]
  |  Branch (103:32): [True: 0, False: 33.6k]
  ------------------
  104|      0|        if (end == MP_NOPTS_VALUE || end > ab[1])
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (104:13): [True: 0, False: 0]
  |  Branch (104:38): [True: 0, False: 0]
  ------------------
  105|      0|            end = ab[1];
  106|      0|    }
  107|   844k|    return end;
  108|   844k|}
get_ab_loop_times:
  125|  67.0k|{
  126|  67.0k|    struct MPOpts *opts = mpctx->opts;
  127|  67.0k|    int dir = mpctx->play_dir;
  128|       |
  129|  67.0k|    t[0] = opts->ab_loop[0];
  130|  67.0k|    t[1] = opts->ab_loop[1];
  131|       |
  132|  67.0k|    if (!mpctx->remaining_ab_loops)
  ------------------
  |  Branch (132:9): [True: 0, False: 67.0k]
  ------------------
  133|      0|        return false;
  134|       |
  135|  67.0k|    if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|   134k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|  67.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (135:9): [True: 67.0k, False: 0]
  |  Branch (135:35): [True: 0, False: 0]
  |  Branch (135:61): [True: 0, False: 0]
  ------------------
  136|  67.0k|        return false;
  137|       |
  138|      0|    if (t[0] * dir > t[1] * dir)
  ------------------
  |  Branch (138:9): [True: 0, False: 0]
  ------------------
  139|      0|        MPSWAP(double, t[0], t[1]);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
  140|       |
  141|       |    return true;
  142|  67.0k|}
get_track_seek_offset:
  145|  26.5k|{
  146|  26.5k|    struct MPOpts *opts = mpctx->opts;
  147|  26.5k|    if (track->selected) {
  ------------------
  |  Branch (147:9): [True: 21.8k, False: 4.64k]
  ------------------
  148|  21.8k|        if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (148:13): [True: 12.1k, False: 9.69k]
  ------------------
  149|  12.1k|            return -opts->audio_delay;
  150|  9.69k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (150:13): [True: 0, False: 9.69k]
  ------------------
  151|      0|        {
  152|      0|            for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (152:29): [True: 0, False: 0]
  ------------------
  153|      0|                if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (153:21): [True: 0, False: 0]
  ------------------
  154|      0|                    return -opts->subs_shared->sub_delay[n];
  155|      0|            }
  156|      0|        }
  157|  9.69k|    }
  158|  14.3k|    return 0;
  159|  26.5k|}
update_content_type:
  178|  7.67k|{
  179|  7.67k|    enum mp_content_type content_type;
  180|  7.67k|    if (!track || !track->vo_c) {
  ------------------
  |  Branch (180:9): [True: 0, False: 7.67k]
  |  Branch (180:19): [True: 0, False: 7.67k]
  ------------------
  181|      0|        content_type = MP_CONTENT_NONE;
  182|  7.67k|    } else if (track->image) {
  ------------------
  |  Branch (182:16): [True: 3.02k, False: 4.65k]
  ------------------
  183|  3.02k|        content_type = MP_CONTENT_IMAGE;
  184|  4.65k|    } else {
  185|  4.65k|        content_type = MP_CONTENT_VIDEO;
  186|  4.65k|    }
  187|  7.67k|    if (mpctx->video_out)
  ------------------
  |  Branch (187:9): [True: 7.67k, False: 0]
  ------------------
  188|  7.67k|        vo_control(mpctx->video_out, VOCTRL_CONTENT_TYPE, &content_type);
  189|  7.67k|}
update_vo_playback_state:
  192|  73.2k|{
  193|  73.2k|    if (mpctx->video_out && mpctx->video_out->config_ok) {
  ------------------
  |  Branch (193:9): [True: 43.7k, False: 29.5k]
  |  Branch (193:29): [True: 43.7k, False: 2]
  ------------------
  194|  43.7k|        struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
  195|  43.7k|        double pos = get_current_pos_ratio(mpctx, false);
  196|  43.7k|        struct voctrl_playback_state newstate = {
  197|  43.7k|            .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
  ------------------
  |  Branch (197:33): [True: 43.7k, False: 0]
  |  Branch (197:70): [True: 43.5k, False: 162]
  ------------------
  198|  43.7k|            .playing = mpctx->playing,
  199|  43.7k|            .paused = mpctx->paused,
  200|  43.7k|            .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
  ------------------
  |  Branch (200:25): [True: 42.4k, False: 1.31k]
  ------------------
  201|  43.7k|        };
  202|       |
  203|  43.7k|        bool state_changed = oldstate.taskbar_progress != newstate.taskbar_progress ||
  ------------------
  |  Branch (203:30): [True: 854, False: 42.9k]
  ------------------
  204|  42.9k|                             oldstate.playing != newstate.playing ||
  ------------------
  |  Branch (204:30): [True: 162, False: 42.7k]
  ------------------
  205|  42.7k|                             oldstate.paused != newstate.paused;
  ------------------
  |  Branch (205:30): [True: 0, False: 42.7k]
  ------------------
  206|  43.7k|        if (state_changed || oldstate.position != newstate.position) {
  ------------------
  |  Branch (206:13): [True: 1.01k, False: 42.7k]
  |  Branch (206:30): [True: 42.4k, False: 325]
  ------------------
  207|       |            // Don't update progress bar if it was and still is hidden
  208|  43.4k|            if ((oldstate.playing && oldstate.taskbar_progress) ||
  ------------------
  |  Branch (208:18): [True: 42.4k, False: 1.00k]
  |  Branch (208:38): [True: 42.4k, False: 13]
  ------------------
  209|  1.01k|                (newstate.playing && newstate.taskbar_progress))
  ------------------
  |  Branch (209:18): [True: 1.01k, False: 0]
  |  Branch (209:38): [True: 854, False: 162]
  ------------------
  210|  43.2k|            {
  211|       |                // Rate-limit progress-only updates. The win32 backend forwards
  212|       |                // these to the shell (explorer.exe), we don't want to spam it
  213|       |                // too much to avoid performance issues, when stealing cpu time
  214|       |                // from the shell thread. In normal playback, this doesn't update
  215|       |                // at all, but in live streams the duration can change, even on
  216|       |                // every frame.
  217|  43.2k|                int64_t now = mp_time_ns();
  218|  43.2k|                int64_t elapsed = now - mpctx->vo_playback_state_time;
  219|  43.2k|                if (!state_changed && elapsed < MP_TIME_MS_TO_NS(1000))
  ------------------
  |  |   72|  42.4k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  |  Branch (219:21): [True: 42.4k, False: 854]
  |  Branch (219:39): [True: 42.4k, False: 0]
  ------------------
  220|  42.4k|                    return;
  221|    854|                mpctx->vo_playback_state_time = now;
  222|    854|                vo_control_async(mpctx->video_out,
  223|    854|                                 VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
  224|    854|            }
  225|  1.01k|            mpctx->vo_playback_state = newstate;
  226|  1.01k|        }
  227|  43.7k|    } else {
  228|  29.5k|        mpctx->vo_playback_state = (struct voctrl_playback_state){ 0 };
  229|  29.5k|    }
  230|  73.2k|}
update_window_title:
  233|  90.9k|{
  234|  90.9k|    if (!mpctx->video_out && !mpctx->ao) {
  ------------------
  |  Branch (234:9): [True: 37.4k, False: 53.4k]
  |  Branch (234:30): [True: 29.2k, False: 8.14k]
  ------------------
  235|  29.2k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  29.2k|#define talloc_free                     ta_free
  ------------------
  236|  29.2k|        mpctx->last_window_title = NULL;
  237|  29.2k|        return;
  238|  29.2k|    }
  239|  61.6k|    char *title = mp_property_expand_string(mpctx, mpctx->opts->wintitle);
  240|  61.6k|    if (!mpctx->last_window_title || force ||
  ------------------
  |  Branch (240:9): [True: 15.5k, False: 46.0k]
  |  Branch (240:38): [True: 2.05k, False: 44.0k]
  ------------------
  241|  44.0k|        strcmp(title, mpctx->last_window_title) != 0)
  ------------------
  |  Branch (241:9): [True: 8, False: 44.0k]
  ------------------
  242|  17.6k|    {
  243|  17.6k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  17.6k|#define talloc_free                     ta_free
  ------------------
  244|  17.6k|        mpctx->last_window_title = talloc_steal(mpctx, title);
  ------------------
  |  |   38|  17.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  17.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  245|       |
  246|  17.6k|        if (mpctx->video_out)
  ------------------
  |  Branch (246:13): [True: 9.73k, False: 7.88k]
  ------------------
  247|  9.73k|            vo_control(mpctx->video_out, VOCTRL_UPDATE_WINDOW_TITLE, title);
  248|       |
  249|  17.6k|        if (mpctx->ao) {
  ------------------
  |  Branch (249:13): [True: 7.93k, False: 9.69k]
  ------------------
  250|  7.93k|            ao_control(mpctx->ao, AOCONTROL_UPDATE_STREAM_TITLE, title);
  251|  7.93k|        }
  252|  44.0k|    } else {
  253|  44.0k|        talloc_free(title);
  ------------------
  |  |   47|  44.0k|#define talloc_free                     ta_free
  ------------------
  254|  44.0k|    }
  255|  61.6k|}
error_on_track:
  258|  26.7k|{
  259|  26.7k|    if (!track || !track->selected)
  ------------------
  |  Branch (259:9): [True: 24.2k, False: 2.51k]
  |  Branch (259:19): [True: 0, False: 2.51k]
  ------------------
  260|  24.2k|        return;
  261|  2.51k|    int order = -1;
  262|  2.51k|    for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (262:21): [True: 2.51k, False: 0]
  ------------------
  263|  2.51k|        if (mpctx->current_track[t][track->type] == track) {
  ------------------
  |  Branch (263:13): [True: 2.51k, False: 0]
  ------------------
  264|  2.51k|            order = t;
  265|  2.51k|            break;
  266|  2.51k|        }
  267|  2.51k|    }
  268|       |    // Select the next best track, if the current one failed to initialize.
  269|  2.51k|    if (order >= 0 && track->dec_failed && mpctx->opts->stream_auto_sel &&
  ------------------
  |  Branch (269:9): [True: 2.51k, False: 0]
  |  Branch (269:23): [True: 2.45k, False: 64]
  |  Branch (269:44): [True: 2.45k, False: 0]
  ------------------
  270|  2.45k|        mpctx->opts->stream_id[order][track->type] == -1)
  ------------------
  |  Branch (270:9): [True: 2.45k, False: 0]
  ------------------
  271|  2.45k|    {
  272|  2.45k|        struct track *next = select_default_track(mpctx, order, track->type);
  273|  2.45k|        if (next) {
  ------------------
  |  Branch (273:13): [True: 10, False: 2.44k]
  ------------------
  274|     10|            MP_WARN(mpctx, "Falling back to %s track %d.\n",
  ------------------
  |  |   90|     10|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     10|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  275|     10|                    stream_type_name(track->type), next->user_tid);
  276|     10|            mp_switch_track_n(mpctx, order, track->type, next, 0);
  277|     10|            if (mpctx->current_track[order][track->type] != track)
  ------------------
  |  Branch (277:17): [True: 10, False: 0]
  ------------------
  278|     10|                return;
  279|     10|        }
  280|  2.45k|    }
  281|  2.50k|    mp_deselect_track(mpctx, track);
  282|  2.50k|    if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (282:9): [True: 485, False: 2.01k]
  ------------------
  283|  2.50k|        MP_INFO(mpctx, "Audio: no audio\n");
  ------------------
  |  |   91|    485|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    485|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  284|  2.50k|    if (track->type == STREAM_VIDEO)
  ------------------
  |  Branch (284:9): [True: 2.01k, False: 485]
  ------------------
  285|  2.50k|        MP_INFO(mpctx, "Video: no video\n");
  ------------------
  |  |   91|  2.01k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.01k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|  2.50k|    if (mpctx->opts->stop_playback_on_init_failure ||
  ------------------
  |  Branch (286:9): [True: 0, False: 2.50k]
  ------------------
  287|  2.50k|        (!mpctx->current_track[0][STREAM_AUDIO] &&
  ------------------
  |  Branch (287:10): [True: 2.32k, False: 175]
  ------------------
  288|  2.32k|         !mpctx->current_track[0][STREAM_VIDEO]))
  ------------------
  |  Branch (288:10): [True: 2.32k, False: 2]
  ------------------
  289|  2.32k|    {
  290|  2.32k|        if (!mpctx->stop_play)
  ------------------
  |  Branch (290:13): [True: 2.32k, False: 0]
  ------------------
  291|  2.32k|            mpctx->stop_play = PT_ERROR;
  292|  2.32k|        if (mpctx->error_playing >= 0)
  ------------------
  |  Branch (292:13): [True: 0, False: 2.32k]
  ------------------
  293|      0|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
  294|  2.32k|    }
  295|  2.50k|    mp_wakeup_core(mpctx);
  296|  2.50k|}
mp_status_str:
  375|   106k|{
  376|   106k|    switch (st) {
  377|  24.6k|    case STATUS_SYNCING:    return "syncing";
  ------------------
  |  Branch (377:5): [True: 24.6k, False: 81.9k]
  ------------------
  378|      0|    case STATUS_READY:      return "ready";
  ------------------
  |  Branch (378:5): [True: 0, False: 106k]
  ------------------
  379|  50.6k|    case STATUS_PLAYING:    return "playing";
  ------------------
  |  Branch (379:5): [True: 50.6k, False: 56.0k]
  ------------------
  380|  4.83k|    case STATUS_DRAINING:   return "draining";
  ------------------
  |  Branch (380:5): [True: 4.83k, False: 101k]
  ------------------
  381|  26.5k|    case STATUS_EOF:        return "eof";
  ------------------
  |  Branch (381:5): [True: 26.5k, False: 80.1k]
  ------------------
  382|      0|    default:                return "bug";
  ------------------
  |  Branch (382:5): [True: 0, False: 106k]
  ------------------
  383|   106k|    }
  384|   106k|}
mp_format_track_metadata:
  392|  24.0k|{
  393|  24.0k|    struct sh_stream *s = t->stream;
  394|  24.0k|    bstr dst = {0};
  395|       |
  396|  24.0k|    if (t->title)
  ------------------
  |  Branch (396:9): [True: 0, False: 24.0k]
  ------------------
  397|      0|        bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title);
  398|       |
  399|  24.0k|    bstr_xappend0(ctx, &dst, "(");
  400|       |
  401|  24.0k|    if (add_lang && t->lang)
  ------------------
  |  Branch (401:9): [True: 0, False: 24.0k]
  |  Branch (401:21): [True: 0, False: 0]
  ------------------
  402|      0|        bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang);
  403|       |
  404|  24.0k|    if (s) {
  ------------------
  |  Branch (404:9): [True: 24.0k, False: 0]
  ------------------
  405|  24.0k|        demux_append_codec_desc(ctx, &dst, s, NULL);
  406|  24.0k|    } else {
  407|      0|        bstr_xappend0(ctx, &dst, "<unknown>");
  408|      0|    }
  409|  24.0k|    bstr_xappend0(ctx, &dst, ")");
  410|       |
  411|  24.0k|    bool first = true;
  412|  24.0k|    if (t->default_track)
  ------------------
  |  Branch (412:9): [True: 0, False: 24.0k]
  ------------------
  413|      0|        ADD_FLAG(ctx, dst, "default", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  414|  24.0k|    if (t->forced_track)
  ------------------
  |  Branch (414:9): [True: 0, False: 24.0k]
  ------------------
  415|      0|        ADD_FLAG(ctx, dst, "forced", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  416|  24.0k|    if (t->dependent_track)
  ------------------
  |  Branch (416:9): [True: 0, False: 24.0k]
  ------------------
  417|      0|        ADD_FLAG(ctx, dst, "dependent", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  418|  24.0k|    if (t->visual_impaired_track)
  ------------------
  |  Branch (418:9): [True: 1, False: 24.0k]
  ------------------
  419|      1|        ADD_FLAG(ctx, dst, "visual-impaired", first);
  ------------------
  |  |  386|      1|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      1|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 1, False: 0]
  |  |  ------------------
  |  |  388|      1|    first = false;                                                     \
  |  |  389|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 1]
  |  |  ------------------
  ------------------
  420|  24.0k|    if (t->hearing_impaired_track)
  ------------------
  |  Branch (420:9): [True: 1, False: 24.0k]
  ------------------
  421|      1|        ADD_FLAG(ctx, dst, "hearing-impaired", first);
  ------------------
  |  |  386|      1|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      1|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 1, False: 0]
  |  |  ------------------
  |  |  388|      1|    first = false;                                                     \
  |  |  389|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 1]
  |  |  ------------------
  ------------------
  422|  24.0k|    if (t->original_track)
  ------------------
  |  Branch (422:9): [True: 0, False: 24.0k]
  ------------------
  423|      0|        ADD_FLAG(ctx, dst, "original", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  424|  24.0k|    if (t->commentary_track)
  ------------------
  |  Branch (424:9): [True: 2, False: 24.0k]
  ------------------
  425|      2|        ADD_FLAG(ctx, dst, "commentary", first);
  ------------------
  |  |  386|      2|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      2|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 2, False: 0]
  |  |  ------------------
  |  |  388|      2|    first = false;                                                     \
  |  |  389|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 2]
  |  |  ------------------
  ------------------
  426|  24.0k|    if (t->is_external)
  ------------------
  |  Branch (426:9): [True: 0, False: 24.0k]
  ------------------
  427|      0|        ADD_FLAG(ctx, dst, "external", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  428|  24.0k|    if (!first)
  ------------------
  |  Branch (428:9): [True: 4, False: 24.0k]
  ------------------
  429|      4|        bstr_xappend0(ctx, &dst, "]");
  430|       |
  431|  24.0k|    return bstrto0(ctx, dst);
  432|  24.0k|}
mp_find_non_filename_media_title:
  435|   638k|{
  436|   638k|    const char *name = mpctx->opts->media_title;
  437|   638k|    if (name && name[0])
  ------------------
  |  Branch (437:9): [True: 0, False: 638k]
  |  Branch (437:17): [True: 0, False: 0]
  ------------------
  438|      0|        return name;
  439|   638k|    if (mpctx->demuxer) {
  ------------------
  |  Branch (439:9): [True: 638k, False: 20]
  ------------------
  440|   638k|        name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
  441|   638k|        if (name && name[0])
  ------------------
  |  Branch (441:13): [True: 0, False: 638k]
  |  Branch (441:21): [True: 0, False: 0]
  ------------------
  442|      0|            return name;
  443|   638k|        name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
  444|   638k|        if (name && name[0])
  ------------------
  |  Branch (444:13): [True: 1.00k, False: 637k]
  |  Branch (444:21): [True: 998, False: 2]
  ------------------
  445|    998|            return name;
  446|   637k|        name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
  447|   637k|        if (name && name[0])
  ------------------
  |  Branch (447:13): [True: 0, False: 637k]
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|      0|            return name;
  449|   637k|    }
  450|   637k|    if (mpctx->playing && mpctx->playing->title)
  ------------------
  |  Branch (450:9): [True: 637k, False: 0]
  |  Branch (450:27): [True: 30, False: 637k]
  ------------------
  451|     30|        return mpctx->playing->title;
  452|   637k|    if (mpctx->demuxer && mpctx->demuxer->server_filename)
  ------------------
  |  Branch (452:9): [True: 637k, False: 20]
  |  Branch (452:27): [True: 0, False: 637k]
  ------------------
  453|      0|        return mpctx->demuxer->server_filename;
  454|   637k|    return NULL;
  455|   637k|}
misc.c:get_play_end_pts_setting:
   85|   844k|{
   86|   844k|    struct MPOpts *opts = mpctx->opts;
   87|   844k|    double end = rel_time_to_abs(mpctx, opts->play_end);
   88|   844k|    double length = rel_time_to_abs(mpctx, opts->play_length);
   89|   844k|    if (length != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   844k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (89:9): [True: 0, False: 844k]
  ------------------
   90|      0|        double start = get_play_start_pts(mpctx);
   91|      0|        if (end == MP_NOPTS_VALUE || start + length < end)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (91:13): [True: 0, False: 0]
  |  Branch (91:38): [True: 0, False: 0]
  ------------------
   92|      0|            end = start + length;
   93|      0|    }
   94|   844k|    return end;
   95|   844k|}

term_osd_clear_subs:
  123|   141k|{
  124|   141k|    term_osd_set_subs(mpctx, NULL, 0);
  125|       |    term_osd_set_subs(mpctx, NULL, 1);
  126|   141k|}
term_osd_set_subs:
  129|   282k|{
  130|   282k|    if (mpctx->video_out || !text || !mpctx->opts->subs_shared->sub_visibility[order])
  ------------------
  |  Branch (130:9): [True: 15.5k, False: 267k]
  |  Branch (130:29): [True: 267k, False: 0]
  |  Branch (130:38): [True: 0, False: 0]
  ------------------
  131|   282k|        text = ""; // disable
  132|   282k|    if (strcmp(mpctx->term_osd_subs[order] ? mpctx->term_osd_subs[order] : "", text) == 0)
  ------------------
  |  Branch (132:9): [True: 282k, False: 0]
  |  Branch (132:16): [True: 0, False: 282k]
  ------------------
  133|   282k|        return;
  134|      0|    talloc_replace(mpctx, mpctx->term_osd_subs[order], text);
  ------------------
  |  |   54|      0|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|      0|    do {                                                \
  |  |  |  |  107|      0|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|      0|        } else {                                        \
  |  |  |  |  110|      0|            *(str) = '\0';                              \
  |  |  |  |  111|      0|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|      0|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|      0|        }                                               \
  |  |  |  |  113|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|      0|    term_osd_update(mpctx);
  136|      0|}
set_osd_bar_chapters:
  377|   150k|{
  378|   150k|    if (mpctx->osd_progbar.type != type)
  ------------------
  |  Branch (378:9): [True: 150k, False: 0]
  ------------------
  379|   150k|        return;
  380|       |
  381|      0|    mpctx->osd_progbar.num_stops = 0;
  382|      0|    double len = get_time_length(mpctx);
  383|      0|    if (len > 0) {
  ------------------
  |  Branch (383:9): [True: 0, False: 0]
  ------------------
  384|       |        // Always render the loop points, even if they're incomplete.
  385|      0|        double ab[2];
  386|      0|        bool valid = get_ab_loop_times(mpctx, ab);
  387|      0|        for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (387:25): [True: 0, False: 0]
  ------------------
  388|      0|            if (ab[n] != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (388:17): [True: 0, False: 0]
  ------------------
  389|      0|                MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  390|      0|                                 mpctx->osd_progbar.num_stops, ab[n] / len);
  391|      0|            }
  392|      0|        }
  393|      0|        if (!valid) {
  ------------------
  |  Branch (393:13): [True: 0, False: 0]
  ------------------
  394|      0|            int num = get_chapter_count(mpctx);
  395|      0|            for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (395:29): [True: 0, False: 0]
  ------------------
  396|      0|                double time = chapter_start_time(mpctx, n);
  397|      0|                if (time >= 0) {
  ------------------
  |  Branch (397:21): [True: 0, False: 0]
  ------------------
  398|      0|                    float pos = time / len;
  399|      0|                    MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  400|      0|                                     mpctx->osd_progbar.num_stops, pos);
  401|      0|                }
  402|      0|            }
  403|      0|        }
  404|      0|    }
  405|      0|    osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  406|      0|    mp_wakeup_core(mpctx);
  407|      0|}
update_osd_msg:
  503|   476k|{
  504|   476k|    struct MPOpts *opts = mpctx->opts;
  505|   476k|    struct osd_state *osd = mpctx->osd;
  506|       |
  507|   476k|    double now = mp_time_sec();
  508|       |
  509|   476k|    if (!mpctx->osd_force_update) {
  ------------------
  |  Branch (509:9): [True: 432k, False: 43.7k]
  ------------------
  510|       |        // Assume nothing is going on at all.
  511|   432k|        if (!mpctx->osd_idle_update)
  ------------------
  |  Branch (511:13): [True: 6.04k, False: 426k]
  ------------------
  512|  6.04k|            return;
  513|       |
  514|   426k|        double delay = 0.050; // update the OSD at most this often
  515|   426k|        double diff = now - mpctx->osd_last_update;
  516|   426k|        if (diff < delay) {
  ------------------
  |  Branch (516:13): [True: 396k, False: 29.5k]
  ------------------
  517|   396k|            mp_set_timeout(mpctx, delay - diff);
  518|   396k|            return;
  519|   396k|        }
  520|   426k|    }
  521|  73.2k|    mpctx->osd_force_update = false;
  522|  73.2k|    mpctx->osd_idle_update = false;
  523|  73.2k|    mpctx->osd_last_update = now;
  524|       |
  525|  73.2k|    if (mpctx->osd_visible) {
  ------------------
  |  Branch (525:9): [True: 0, False: 73.2k]
  ------------------
  526|      0|        double sleep = mpctx->osd_visible - now;
  527|      0|        if (sleep > 0) {
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            mp_set_timeout(mpctx, sleep);
  529|      0|            mpctx->osd_idle_update = true;
  530|      0|        } else {
  531|      0|            mpctx->osd_visible = 0;
  532|      0|            mpctx->osd_progbar.type = -1; // disable
  533|      0|            osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  534|      0|        }
  535|      0|    }
  536|       |
  537|  73.2k|    if (mpctx->osd_function_visible) {
  ------------------
  |  Branch (537:9): [True: 0, False: 73.2k]
  ------------------
  538|      0|        double sleep = mpctx->osd_function_visible - now;
  539|      0|        if (sleep > 0) {
  ------------------
  |  Branch (539:13): [True: 0, False: 0]
  ------------------
  540|      0|            mp_set_timeout(mpctx, sleep);
  541|      0|            mpctx->osd_idle_update = true;
  542|      0|        } else {
  543|      0|            mpctx->osd_function_visible = 0;
  544|      0|            mpctx->osd_function = 0;
  545|      0|        }
  546|      0|    }
  547|       |
  548|  73.2k|    if (mpctx->osd_msg_next_duration > 0) {
  ------------------
  |  Branch (548:9): [True: 0, False: 73.2k]
  ------------------
  549|       |        // This is done to avoid cutting the OSD message short if slow commands
  550|       |        // are executed between setting the OSD message and showing it.
  551|      0|        mpctx->osd_msg_visible = now + mpctx->osd_msg_next_duration;
  552|      0|        mpctx->osd_msg_next_duration = 0;
  553|      0|    }
  554|       |
  555|  73.2k|    if (mpctx->osd_msg_visible) {
  ------------------
  |  Branch (555:9): [True: 0, False: 73.2k]
  ------------------
  556|      0|        double sleep = mpctx->osd_msg_visible - now;
  557|      0|        if (sleep > 0) {
  ------------------
  |  Branch (557:13): [True: 0, False: 0]
  ------------------
  558|      0|            mp_set_timeout(mpctx, sleep);
  559|      0|            mpctx->osd_idle_update = true;
  560|      0|        } else {
  561|      0|            talloc_free(mpctx->osd_msg_text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  562|      0|            mpctx->osd_msg_text = NULL;
  563|      0|            mpctx->osd_msg_visible = 0;
  564|      0|            mpctx->osd_show_pos = false;
  565|      0|        }
  566|      0|    }
  567|       |
  568|  73.2k|    add_seek_osd_messages(mpctx);
  569|       |
  570|  73.2k|    if (mpctx->osd_progbar.type == OSD_BAR_SEEK) {
  ------------------
  |  Branch (570:9): [True: 0, False: 73.2k]
  ------------------
  571|      0|        double pos = get_current_pos_ratio(mpctx, false);
  572|      0|        update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, MPCLAMP(pos, 0, 1));
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  573|      0|    }
  574|       |
  575|  73.2k|    term_osd_set_text_lazy(mpctx, mpctx->osd_msg_text);
  576|  73.2k|    term_osd_print_status_lazy(mpctx);
  577|  73.2k|    term_osd_update(mpctx);
  578|       |
  579|  73.2k|    if (!opts->video_osd)
  ------------------
  |  Branch (579:9): [True: 71.2k, False: 2.06k]
  ------------------
  580|  71.2k|        return;
  581|       |
  582|  2.06k|    int osd_level = opts->osd_level;
  583|  2.06k|    if (mpctx->osd_show_pos)
  ------------------
  |  Branch (583:9): [True: 0, False: 2.06k]
  ------------------
  584|      0|        osd_level = 3;
  585|       |
  586|  2.06k|    char *text = NULL;
  587|  2.06k|    sadd_osd_status(&text, mpctx, osd_level);
  588|  2.06k|    if (mpctx->osd_msg_text && mpctx->osd_msg_text[0]) {
  ------------------
  |  Branch (588:9): [True: 0, False: 2.06k]
  |  Branch (588:32): [True: 0, False: 0]
  ------------------
  589|      0|        text = talloc_asprintf_append(text, "%s%s", text ? "\n" : "",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (589:53): [True: 0, False: 0]
  ------------------
  590|      0|                                      mpctx->osd_msg_text);
  591|      0|    }
  592|  2.06k|    osd_set_text(osd, text);
  593|  2.06k|    talloc_free(text);
  ------------------
  |  |   47|  2.06k|#define talloc_free                     ta_free
  ------------------
  594|  2.06k|}
osd.c:term_osd_update:
   76|  73.2k|{
   77|  73.2k|    int num_parts = 0;
   78|  73.2k|    char *parts[4] = {0};
   79|       |
   80|  73.2k|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (80:9): [True: 73.2k, False: 0]
  ------------------
   81|  73.2k|        return;
   82|       |
   83|      0|    if (!term_osd_empty(mpctx->term_osd_subs[0]))
  ------------------
  |  Branch (83:9): [True: 0, False: 0]
  ------------------
   84|      0|        parts[num_parts++] = mpctx->term_osd_subs[0];
   85|      0|    if (!term_osd_empty(mpctx->term_osd_subs[1]))
  ------------------
  |  Branch (85:9): [True: 0, False: 0]
  ------------------
   86|      0|        parts[num_parts++] = mpctx->term_osd_subs[1];
   87|      0|    if (!term_osd_empty(mpctx->term_osd_text))
  ------------------
  |  Branch (87:9): [True: 0, False: 0]
  ------------------
   88|      0|        parts[num_parts++] = mpctx->term_osd_text;
   89|      0|    if (!term_osd_empty(mpctx->term_osd_status))
  ------------------
  |  Branch (89:9): [True: 0, False: 0]
  ------------------
   90|      0|        parts[num_parts++] = mpctx->term_osd_status;
   91|       |
   92|      0|    char *s = join_lines(mpctx, parts, num_parts);
   93|       |
   94|      0|    if (strcmp(mpctx->term_osd_contents, s) == 0 &&
  ------------------
  |  Branch (94:9): [True: 0, False: 0]
  ------------------
   95|      0|        mp_msg_has_status_line(mpctx->global))
  ------------------
  |  Branch (95:9): [True: 0, False: 0]
  ------------------
   96|      0|    {
   97|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   98|      0|    } else {
   99|      0|        talloc_free(mpctx->term_osd_contents);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  100|      0|        mpctx->term_osd_contents = s;
  101|      0|        mp_msg(mpctx->statusline, MSGL_STATUS, "%s", s);
  102|      0|    }
  103|      0|}
osd.c:add_seek_osd_messages:
  472|  73.2k|{
  473|  73.2k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
  ------------------
  |  Branch (473:9): [True: 0, False: 73.2k]
  ------------------
  474|      0|        double pos = get_current_pos_ratio(mpctx, false);
  475|      0|        set_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, 0, MPCLAMP(pos, 0, 1));
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  476|      0|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
  477|      0|    }
  478|  73.2k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
  ------------------
  |  Branch (478:9): [True: 0, False: 73.2k]
  ------------------
  479|       |        // Never in term-osd mode
  480|      0|        bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (480:26): [True: 0, False: 0]
  |  Branch (480:46): [True: 0, False: 0]
  ------------------
  481|      0|        if (video_osd && mpctx->opts->term_osd != 1) {
  ------------------
  |  Branch (481:13): [True: 0, False: 0]
  |  Branch (481:26): [True: 0, False: 0]
  ------------------
  482|      0|            if (set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, ""))
  ------------------
  |  Branch (482:17): [True: 0, False: 0]
  ------------------
  483|      0|                mpctx->osd_show_pos = true;
  484|      0|        }
  485|      0|    }
  486|  73.2k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) {
  ------------------
  |  Branch (486:9): [True: 0, False: 73.2k]
  ------------------
  487|      0|        char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx));
  488|      0|        set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
  489|      0|                     "Chapter: %s", chapter);
  490|      0|        talloc_free(chapter);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  491|      0|    }
  492|  73.2k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CURRENT_FILE) {
  ------------------
  |  Branch (492:9): [True: 0, False: 73.2k]
  ------------------
  493|      0|        if (mpctx->filename) {
  ------------------
  |  Branch (493:13): [True: 0, False: 0]
  ------------------
  494|      0|            set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, "%s",
  495|      0|                        mpctx->filename);
  496|      0|        }
  497|      0|    }
  498|  73.2k|    mpctx->add_osd_seek_info = 0;
  499|  73.2k|}
osd.c:term_osd_set_text_lazy:
  139|  73.2k|{
  140|  73.2k|    bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (140:22): [True: 43.7k, False: 29.5k]
  |  Branch (140:42): [True: 0, False: 43.7k]
  ------------------
  141|  73.2k|    if ((video_osd && mpctx->opts->term_osd != 1) || !text)
  ------------------
  |  Branch (141:10): [True: 0, False: 73.2k]
  |  Branch (141:23): [True: 0, False: 0]
  |  Branch (141:54): [True: 73.2k, False: 0]
  ------------------
  142|  73.2k|        text = ""; // disable
  143|  73.2k|    talloc_replace(mpctx, mpctx->term_osd_text, text);
  ------------------
  |  |   54|  73.2k|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  73.2k|    do {                                                \
  |  |  |  |  107|  73.2k|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 28.9k, False: 44.3k]
  |  |  |  |  ------------------
  |  |  |  |  108|  28.9k|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  44.3k|        } else {                                        \
  |  |  |  |  110|  44.3k|            *(str) = '\0';                              \
  |  |  |  |  111|  44.3k|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|  44.3k|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|  44.3k|        }                                               \
  |  |  |  |  113|  73.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 73.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|  73.2k|}
osd.c:term_osd_print_status_lazy:
  281|  73.2k|{
  282|  73.2k|    struct MPOpts *opts = mpctx->opts;
  283|       |
  284|  73.2k|    term_osd_update_title(mpctx);
  285|  73.2k|    update_window_title(mpctx, false);
  286|  73.2k|    update_vo_playback_state(mpctx);
  287|       |
  288|  73.2k|    if (!opts->use_terminal)
  ------------------
  |  Branch (288:9): [True: 73.2k, False: 0]
  ------------------
  289|  73.2k|        return;
  290|       |
  291|      0|    if (opts->quiet || !mpctx->playback_initialized || !mpctx->playing_msg_shown)
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  |  Branch (291:24): [True: 0, False: 0]
  |  Branch (291:56): [True: 0, False: 0]
  ------------------
  292|      0|    {
  293|      0|        if (!mpctx->playing)
  ------------------
  |  Branch (293:13): [True: 0, False: 0]
  ------------------
  294|      0|            term_osd_set_status_lazy(mpctx, "");
  295|      0|        return;
  296|      0|    }
  297|       |
  298|      0|    char *line = get_term_status_msg(mpctx);
  299|       |
  300|      0|    if (opts->term_osd_bar) {
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|        saddf(&line, "\n");
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  302|      0|        int w = 80, h = 24;
  303|      0|        terminal_get_size(&w, &h);
  304|      0|        add_term_osd_bar(mpctx, &line, w);
  305|      0|    }
  306|       |
  307|      0|    term_osd_set_status_lazy(mpctx, line);
  308|      0|    talloc_free(line);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  309|      0|}
osd.c:term_osd_update_title:
  106|  73.2k|{
  107|  73.2k|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (107:9): [True: 73.2k, False: 0]
  ------------------
  108|  73.2k|        return;
  109|       |
  110|      0|    char *s = mp_property_expand_escaped_string(mpctx, mpctx->opts->term_title);
  111|      0|    bstr title = bstr0(s);
  112|      0|    mp_msg_sanitize(&title, false);
  113|      0|    if (bstr_equals(title, bstr0(mpctx->term_osd_title))) {
  ------------------
  |  Branch (113:9): [True: 0, False: 0]
  ------------------
  114|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  115|      0|        return;
  116|      0|    }
  117|       |
  118|      0|    mp_msg_set_term_title(mpctx->statusline, s);
  119|      0|    mpctx->term_osd_title = talloc_steal(mpctx, s);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  120|      0|}
osd.c:sadd_osd_status:
  438|  2.06k|{
  439|  2.06k|    mp_assert(level >= 0 && level <= 3);
  ------------------
  |  |   41|  2.06k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 2.06k, False: 0]
  |  Branch (439:5): [True: 2.06k, False: 0]
  ------------------
  440|  2.06k|    if (level == 0)
  ------------------
  |  Branch (440:9): [True: 0, False: 2.06k]
  ------------------
  441|      0|        return;
  442|  2.06k|    char *msg = mpctx->opts->osd_msg[level - 1];
  443|       |
  444|  2.06k|    if (msg && msg[0]) {
  ------------------
  |  Branch (444:9): [True: 0, False: 2.06k]
  |  Branch (444:16): [True: 0, False: 0]
  ------------------
  445|      0|        char *text = mp_property_expand_escaped_string(mpctx, msg);
  446|      0|        *buffer = talloc_strdup_append(*buffer, text);
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  447|      0|        talloc_free(text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  448|  2.06k|    } else if (level >= 2) {
  ------------------
  |  Branch (448:16): [True: 0, False: 2.06k]
  ------------------
  449|      0|        bool fractions = mpctx->opts->osd_fractions;
  450|      0|        char sym[10];
  451|      0|        get_current_osd_sym(mpctx, sym, sizeof(sym));
  452|      0|        saddf(buffer, "%s ", sym);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  453|      0|        char *custom_msg = mpctx->opts->osd_status_msg;
  454|      0|        if (custom_msg && level == 3) {
  ------------------
  |  Branch (454:13): [True: 0, False: 0]
  |  Branch (454:27): [True: 0, False: 0]
  ------------------
  455|      0|            char *text = mp_property_expand_escaped_string(mpctx, custom_msg);
  456|      0|            *buffer = talloc_strdup_append(*buffer, text);
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  457|      0|            talloc_free(text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  458|      0|        } else {
  459|      0|            sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions);
  460|      0|            if (level == 3) {
  ------------------
  |  Branch (460:17): [True: 0, False: 0]
  ------------------
  461|      0|                saddf(buffer, " / ");
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  462|      0|                sadd_hhmmssff(buffer, get_time_length(mpctx), fractions);
  463|       |                sadd_percentage(buffer, get_current_pos_ratio(mpctx, false));
  464|      0|            }
  465|      0|        }
  466|      0|    }
  467|  2.06k|}

mp_wait_events:
   55|   479k|{
   56|   479k|    mp_client_send_property_changes(mpctx);
   57|       |
   58|   479k|    stats_event(mpctx->stats, "iterations");
   59|       |
   60|   479k|    bool sleeping = mpctx->sleeptime > 0;
   61|   479k|    if (sleeping)
  ------------------
  |  Branch (61:9): [True: 443k, False: 36.5k]
  ------------------
   62|   479k|        MP_STATS(mpctx, "start sleep");
  ------------------
  |  |   99|   443k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   443k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   63|       |
   64|   479k|    mp_dispatch_queue_process(mpctx->dispatch, mpctx->sleeptime);
   65|       |
   66|   479k|    mpctx->sleeptime = INFINITY;
   67|       |
   68|   479k|    if (sleeping)
  ------------------
  |  Branch (68:9): [True: 443k, False: 36.5k]
  ------------------
   69|   479k|        MP_STATS(mpctx, "end sleep");
  ------------------
  |  |   99|   443k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   443k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   70|   479k|}
mp_set_timeout:
   76|  1.11M|{
   77|  1.11M|    if (mpctx->sleeptime > sleeptime) {
  ------------------
  |  Branch (77:9): [True: 617k, False: 499k]
  ------------------
   78|   617k|        mpctx->sleeptime = sleeptime;
   79|   617k|        int64_t abstime = mp_time_ns_add(mp_time_ns(), sleeptime);
   80|   617k|        mp_dispatch_adjust_timeout(mpctx->dispatch, abstime);
   81|   617k|    }
   82|  1.11M|}
mp_wakeup_core:
   88|  1.21M|{
   89|  1.21M|    mp_dispatch_interrupt(mpctx->dispatch);
   90|  1.21M|}
mp_wakeup_core_cb:
   94|   182k|{
   95|   182k|    struct MPContext *mpctx = ctx;
   96|   182k|    mp_wakeup_core(mpctx);
   97|   182k|}
mp_core_lock:
  100|  21.8k|{
  101|  21.8k|    mp_dispatch_lock(mpctx->dispatch);
  102|  21.8k|}
mp_core_unlock:
  105|  21.8k|{
  106|  21.8k|    mp_dispatch_unlock(mpctx->dispatch);
  107|  21.8k|}
handle_option_callbacks:
  128|   444k|{
  129|   473k|    for (int i = 0; i < mpctx->num_option_callbacks; i++)
  ------------------
  |  Branch (129:21): [True: 28.9k, False: 444k]
  ------------------
  130|  28.9k|        mp_option_run_callback(mpctx, &mpctx->option_callbacks[i]);
  131|   444k|    mpctx->num_option_callbacks = 0;
  132|   444k|}
get_relative_time:
  135|  60.3k|{
  136|  60.3k|    int64_t new_time = mp_time_ns();
  137|  60.3k|    int64_t delta = new_time - mpctx->last_time;
  138|  60.3k|    mpctx->last_time = new_time;
  139|  60.3k|    return delta * 1e-9;
  140|  60.3k|}
update_core_idle_state:
  143|   566k|{
  144|   566k|    bool eof = mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (144:16): [True: 496k, False: 69.9k]
  ------------------
  145|   496k|               mpctx->audio_status == STATUS_EOF;
  ------------------
  |  Branch (145:16): [True: 425k, False: 70.8k]
  ------------------
  146|   566k|    bool active = !mpctx->paused && mpctx->restart_complete &&
  ------------------
  |  Branch (146:19): [True: 566k, False: 0]
  |  Branch (146:37): [True: 111k, False: 454k]
  ------------------
  147|   111k|                  !mpctx->stop_play && mpctx->in_playloop && !eof;
  ------------------
  |  Branch (147:19): [True: 78.3k, False: 33.4k]
  |  Branch (147:40): [True: 78.3k, False: 0]
  |  Branch (147:62): [True: 70.7k, False: 7.63k]
  ------------------
  148|       |
  149|   566k|    if (mpctx->playback_active != active) {
  ------------------
  |  Branch (149:9): [True: 18.1k, False: 548k]
  ------------------
  150|  18.1k|        mpctx->playback_active = active;
  151|       |
  152|  18.1k|        update_screensaver_state(mpctx);
  153|  18.1k|        mp_set_idle_power_mode(!active);
  154|       |
  155|       |        mp_notify(mpctx, MP_EVENT_CORE_IDLE, NULL);
  156|  18.1k|    }
  157|   566k|}
get_internal_paused:
  160|   184k|{
  161|   184k|    return mpctx->opts->pause || mpctx->paused_for_cache;
  ------------------
  |  Branch (161:12): [True: 0, False: 184k]
  |  Branch (161:34): [True: 0, False: 184k]
  ------------------
  162|   184k|}
set_pause_state:
  166|   150k|{
  167|   150k|    struct MPOpts *opts = mpctx->opts;
  168|       |
  169|   150k|    opts->pause = user_pause;
  170|       |
  171|   150k|    bool internal_paused = get_internal_paused(mpctx);
  172|   150k|    if (internal_paused != mpctx->paused) {
  ------------------
  |  Branch (172:9): [True: 0, False: 150k]
  ------------------
  173|      0|        mpctx->paused = internal_paused;
  174|       |
  175|      0|        if (mpctx->ao) {
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  ------------------
  176|      0|            bool eof = mpctx->audio_status == STATUS_EOF;
  177|      0|            ao_set_paused(mpctx->ao, internal_paused, eof);
  178|      0|        }
  179|       |
  180|      0|        if (mpctx->video_out)
  ------------------
  |  Branch (180:13): [True: 0, False: 0]
  ------------------
  181|      0|            vo_set_paused(mpctx->video_out, internal_paused);
  182|       |
  183|      0|        mpctx->osd_function = 0;
  184|      0|        mpctx->osd_force_update = true;
  185|       |
  186|      0|        mp_wakeup_core(mpctx);
  187|       |
  188|      0|        if (internal_paused) {
  ------------------
  |  Branch (188:13): [True: 0, False: 0]
  ------------------
  189|      0|            mpctx->step_frames = 0;
  190|      0|            mpctx->time_frame -= get_relative_time(mpctx);
  191|      0|        } else {
  192|      0|            (void)get_relative_time(mpctx); // ignore time that passed during pause
  193|      0|        }
  194|      0|    }
  195|       |
  196|   150k|    update_core_idle_state(mpctx);
  197|       |
  198|   150k|    m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
  199|   150k|}
update_internal_pause_state:
  202|   150k|{
  203|   150k|    set_pause_state(mpctx, mpctx->opts->pause);
  204|   150k|}
update_screensaver_state:
  207|  71.5k|{
  208|  71.5k|    if (!mpctx->video_out)
  ------------------
  |  Branch (208:9): [True: 50.1k, False: 21.3k]
  ------------------
  209|  50.1k|        return;
  210|       |
  211|  71.5k|    bool saver_state = (!mpctx->playback_active || !mpctx->opts->stop_screensaver) &&
  ------------------
  |  Branch (211:25): [True: 18.3k, False: 3.02k]
  |  Branch (211:52): [True: 0, False: 3.02k]
  ------------------
  212|  18.3k|                       mpctx->opts->stop_screensaver != 2;
  ------------------
  |  Branch (212:24): [True: 18.3k, False: 0]
  ------------------
  213|  21.3k|    vo_control_async(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
  ------------------
  |  Branch (213:40): [True: 18.3k, False: 3.02k]
  ------------------
  214|  21.3k|                                                   : VOCTRL_KILL_SCREENSAVER, NULL);
  215|  21.3k|}
reset_playback_state:
  243|   133k|{
  244|   133k|    mp_filter_reset(mpctx->filter_root);
  245|       |
  246|   133k|    reset_video_state(mpctx);
  247|   133k|    reset_audio_state(mpctx);
  248|   133k|    reset_subtitle_state(mpctx);
  249|       |
  250|   133k|    if (mpctx->demuxer)
  ------------------
  |  Branch (250:9): [True: 0, False: 133k]
  ------------------
  251|      0|        demux_nav_refresh(mpctx->demuxer);
  252|       |
  253|   133k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (253:21): [True: 0, False: 133k]
  ------------------
  254|      0|        struct track *t = mpctx->tracks[n];
  255|       |        // (Often, but not always, this is redundant and also done elsewhere.)
  256|      0|        if (t->dec)
  ------------------
  |  Branch (256:13): [True: 0, False: 0]
  ------------------
  257|      0|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  258|      0|        if (t->d_sub)
  ------------------
  |  Branch (258:13): [True: 0, False: 0]
  ------------------
  259|      0|            sub_set_play_dir(t->d_sub, mpctx->play_dir);
  260|      0|    }
  261|       |
  262|       |    // May need unpause first
  263|   133k|    if (mpctx->paused_for_cache)
  ------------------
  |  Branch (263:9): [True: 0, False: 133k]
  ------------------
  264|      0|        update_internal_pause_state(mpctx);
  265|       |
  266|   133k|    mpctx->hrseek_active = false;
  267|   133k|    mpctx->hrseek_lastframe = false;
  268|   133k|    mpctx->hrseek_backstep = false;
  269|   133k|    mpctx->current_seek = (struct seek_params){0};
  270|   133k|    mpctx->playback_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   133k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  271|   133k|    mpctx->step_frames = 0;
  272|   133k|    mpctx->ab_loop_clip = true;
  273|   133k|    mpctx->restart_complete = false;
  274|   133k|    mpctx->paused_for_cache = false;
  275|   133k|    mpctx->cache_buffer = 100;
  276|   133k|    mpctx->cache_update_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   133k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  277|       |
  278|   133k|    encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
  279|       |
  280|   133k|    update_internal_pause_state(mpctx);
  281|   133k|    update_core_idle_state(mpctx);
  282|   133k|}
execute_queued_seek:
  502|   131k|{
  503|   131k|    if (mpctx->seek.type) {
  ------------------
  |  Branch (503:9): [True: 0, False: 131k]
  ------------------
  504|      0|        bool queued_hr_seek = mpctx->seek.exact != MPSEEK_KEYFRAME;
  505|       |        // Let explicitly imprecise seeks cancel precise seeks:
  506|      0|        if (mpctx->hrseek_active && !queued_hr_seek)
  ------------------
  |  Branch (506:13): [True: 0, False: 0]
  |  Branch (506:37): [True: 0, False: 0]
  ------------------
  507|      0|            mpctx->start_timestamp = -1e9;
  508|       |        // If the user seeks continuously (keeps arrow key down) try to finish
  509|       |        // showing a frame from one location before doing another seek (instead
  510|       |        // of never updating the screen).
  511|      0|        if ((mpctx->seek.flags & MPSEEK_FLAG_DELAY) &&
  ------------------
  |  Branch (511:13): [True: 0, False: 0]
  ------------------
  512|      0|            mp_time_sec() - mpctx->start_timestamp < 0.3)
  ------------------
  |  Branch (512:13): [True: 0, False: 0]
  ------------------
  513|      0|        {
  514|       |            // Wait until a video frame is available and has been shown.
  515|      0|            if (mpctx->video_status < STATUS_PLAYING)
  ------------------
  |  Branch (515:17): [True: 0, False: 0]
  ------------------
  516|      0|                return;
  517|       |            // On A/V hr-seeks, always wait for the full result, to avoid corner
  518|       |            // cases when seeking past EOF (we want it to determine that EOF
  519|       |            // actually happened, instead of overwriting it with the new seek).
  520|      0|            if (mpctx->hrseek_active && queued_hr_seek && mpctx->vo_chain &&
  ------------------
  |  Branch (520:17): [True: 0, False: 0]
  |  Branch (520:41): [True: 0, False: 0]
  |  Branch (520:59): [True: 0, False: 0]
  ------------------
  521|      0|                mpctx->ao_chain && !mpctx->restart_complete)
  ------------------
  |  Branch (521:17): [True: 0, False: 0]
  |  Branch (521:36): [True: 0, False: 0]
  ------------------
  522|      0|                return;
  523|      0|        }
  524|      0|        mp_seek(mpctx, mpctx->seek);
  525|      0|        mpctx->seek = (struct seek_params){0};
  526|      0|    }
  527|   131k|}
get_time_length:
  531|  1.76M|{
  532|  1.76M|    struct demuxer *demuxer = mpctx->demuxer;
  533|  1.76M|    return demuxer && demuxer->duration >= 0 ? demuxer->duration : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  20.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (533:12): [True: 1.76M, False: 0]
  |  Branch (533:23): [True: 1.74M, False: 20.3k]
  ------------------
  534|  1.76M|}
get_current_time:
  551|   240k|{
  552|   240k|    if (!mpctx->demuxer)
  ------------------
  |  Branch (552:9): [True: 0, False: 240k]
  ------------------
  553|      0|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  554|   240k|    if (mpctx->playback_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   240k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (554:9): [True: 109k, False: 131k]
  ------------------
  555|   109k|        return mpctx->playback_pts * mpctx->play_dir;
  556|   131k|    return mpctx->last_seek_pts;
  557|   240k|}
get_current_pos_ratio:
  577|  43.7k|{
  578|  43.7k|    struct demuxer *demuxer = mpctx->demuxer;
  579|  43.7k|    if (!demuxer)
  ------------------
  |  Branch (579:9): [True: 0, False: 43.7k]
  ------------------
  580|      0|        return -1;
  581|  43.7k|    double ret = -1;
  582|  43.7k|    double start = 0;
  583|  43.7k|    double len = get_time_length(mpctx);
  584|  43.7k|    if (use_range) {
  ------------------
  |  Branch (584:9): [True: 0, False: 43.7k]
  ------------------
  585|      0|        double startpos = get_play_start_pts(mpctx);
  586|      0|        double endpos = get_play_end_pts(mpctx);
  587|      0|        if (endpos > MPMAX(0, len))
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (587:13): [True: 0, False: 0]
  ------------------
  588|      0|            endpos = MPMAX(0, len);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  589|      0|        if (endpos < startpos)
  ------------------
  |  Branch (589:13): [True: 0, False: 0]
  ------------------
  590|      0|            endpos = startpos;
  591|      0|        start = startpos;
  592|      0|        len = endpos - startpos;
  593|      0|    }
  594|  43.7k|    double pos = get_current_time(mpctx);
  595|  43.7k|    if (len > 0)
  ------------------
  |  Branch (595:9): [True: 43.5k, False: 163]
  ------------------
  596|  43.5k|        ret = MPCLAMP((pos - start) / len, 0, 1);
  ------------------
  |  |   46|  43.5k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 43.5k]
  |  |  |  Branch (46:56): [True: 0, False: 43.5k]
  |  |  ------------------
  ------------------
  597|  43.7k|    if (ret < 0) {
  ------------------
  |  Branch (597:9): [True: 163, False: 43.5k]
  ------------------
  598|    163|        int64_t size = demuxer->filesize;
  599|    163|        if (size > 0 && demuxer->filepos >= 0)
  ------------------
  |  Branch (599:13): [True: 1, False: 162]
  |  Branch (599:25): [True: 1, False: 0]
  ------------------
  600|      1|            ret = MPCLAMP(demuxer->filepos / (double)size, 0, 1);
  ------------------
  |  |   46|      1|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 1]
  |  |  |  Branch (46:56): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  601|    163|    }
  602|  43.7k|    if (use_range) {
  ------------------
  |  Branch (602:9): [True: 0, False: 43.7k]
  ------------------
  603|      0|        if (mpctx->opts->play_frames > 0)
  ------------------
  |  Branch (603:13): [True: 0, False: 0]
  ------------------
  604|      0|            ret = MPMAX(ret, 1.0 -
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  605|      0|                    mpctx->max_frames / (double) mpctx->opts->play_frames);
  606|      0|    }
  607|  43.7k|    return ret;
  608|  43.7k|}
get_current_chapter:
  612|   114k|{
  613|   114k|    if (!mpctx->num_chapters)
  ------------------
  |  Branch (613:9): [True: 114k, False: 0]
  ------------------
  614|   114k|        return -2;
  615|      0|    double current_pts = get_current_time(mpctx);
  616|      0|    int i;
  617|      0|    for (i = 0; i < mpctx->num_chapters; i++)
  ------------------
  |  Branch (617:17): [True: 0, False: 0]
  ------------------
  618|      0|        if (current_pts < mpctx->chapters[i].pts)
  ------------------
  |  Branch (618:13): [True: 0, False: 0]
  ------------------
  619|      0|            break;
  620|      0|    return mpctx->last_chapter_flag ?
  ------------------
  |  Branch (620:12): [True: 0, False: 0]
  ------------------
  621|      0|        mpctx->last_chapter_seek : MPMAX(mpctx->last_chapter_seek, i - 1);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  622|   114k|}
update_ab_loop_clip:
  670|  16.7k|{
  671|  16.7k|    double pts = get_current_time(mpctx);
  672|  16.7k|    double ab[2];
  673|  16.7k|    mpctx->ab_loop_clip = pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  33.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (673:27): [True: 16.7k, False: 0]
  ------------------
  674|  16.7k|                          get_ab_loop_times(mpctx, ab) &&
  ------------------
  |  Branch (674:27): [True: 0, False: 16.7k]
  ------------------
  675|      0|                          pts * mpctx->play_dir <= ab[1] * mpctx->play_dir;
  ------------------
  |  Branch (675:27): [True: 0, False: 0]
  ------------------
  676|  16.7k|}
handle_force_window:
 1032|   217k|{
 1033|       |    // True if we're either in idle mode, or loading of the file has finished.
 1034|       |    // It's also set via force in some stages during file loading.
 1035|   217k|    bool act = mpctx->stop_play || mpctx->playback_initialized || force;
  ------------------
  |  Branch (1035:16): [True: 59.7k, False: 157k]
  |  Branch (1035:36): [True: 114k, False: 43.0k]
  |  Branch (1035:67): [True: 11.2k, False: 31.7k]
  ------------------
 1036|       |
 1037|       |    // On the other hand, if a video track is selected, but no video is ever
 1038|       |    // decoded on it, then create the window.
 1039|   217k|    bool stalled_video = mpctx->playback_initialized && mpctx->restart_complete &&
  ------------------
  |  Branch (1039:26): [True: 114k, False: 102k]
  |  Branch (1039:57): [True: 61.6k, False: 53.1k]
  ------------------
 1040|  61.6k|                         mpctx->video_status == STATUS_EOF && mpctx->vo_chain &&
  ------------------
  |  Branch (1040:26): [True: 17.5k, False: 44.1k]
  |  Branch (1040:63): [True: 2.02k, False: 15.4k]
  ------------------
 1041|  2.02k|                         !mpctx->video_out->config_ok;
  ------------------
  |  Branch (1041:26): [True: 2.02k, False: 0]
  ------------------
 1042|       |
 1043|       |    // Don't interfere with real video playback
 1044|   217k|    if (mpctx->vo_chain && !stalled_video)
  ------------------
  |  Branch (1044:9): [True: 63.2k, False: 154k]
  |  Branch (1044:28): [True: 61.2k, False: 2.02k]
  ------------------
 1045|  61.2k|        return 0;
 1046|       |
 1047|   156k|    if (!mpctx->opts->force_vo) {
  ------------------
  |  Branch (1047:9): [True: 156k, False: 0]
  ------------------
 1048|   156k|        if (act && !mpctx->vo_chain)
  ------------------
  |  Branch (1048:13): [True: 124k, False: 31.7k]
  |  Branch (1048:20): [True: 122k, False: 2.02k]
  ------------------
 1049|   122k|            uninit_video_out(mpctx);
 1050|   156k|        return 0;
 1051|   156k|    }
 1052|       |
 1053|      0|    if (mpctx->opts->force_vo != 2 && !act)
  ------------------
  |  Branch (1053:9): [True: 0, False: 0]
  |  Branch (1053:39): [True: 0, False: 0]
  ------------------
 1054|      0|        return 0;
 1055|       |
 1056|      0|    if (!mpctx->video_out) {
  ------------------
  |  Branch (1056:9): [True: 0, False: 0]
  ------------------
 1057|      0|        struct vo_extra ex = {
 1058|      0|            .input_ctx = mpctx->input,
 1059|      0|            .osd = mpctx->osd,
 1060|      0|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
 1061|      0|            .wakeup_cb = mp_wakeup_core_cb,
 1062|      0|            .wakeup_ctx = mpctx,
 1063|      0|        };
 1064|      0|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
 1065|      0|        if (!mpctx->video_out)
  ------------------
  |  Branch (1065:13): [True: 0, False: 0]
  ------------------
 1066|      0|            goto err;
 1067|      0|        mpctx->mouse_cursor_visible = true;
 1068|      0|    }
 1069|       |
 1070|      0|    if (!mpctx->video_out->config_ok || force) {
  ------------------
  |  Branch (1070:9): [True: 0, False: 0]
  |  Branch (1070:41): [True: 0, False: 0]
  ------------------
 1071|      0|        struct vo *vo = mpctx->video_out;
 1072|       |        // Pick whatever works
 1073|      0|        int config_format = 0;
 1074|      0|        uint8_t fmts[IMGFMT_END - IMGFMT_START] = {0};
 1075|      0|        vo_query_formats(vo, fmts);
 1076|      0|        if (fmts[IMGFMT_RGBA - IMGFMT_START])
  ------------------
  |  Branch (1076:13): [True: 0, False: 0]
  ------------------
 1077|      0|            config_format = IMGFMT_RGBA;
 1078|      0|        for (int fmt = IMGFMT_START; fmt < IMGFMT_END && !config_format; fmt++) {
  ------------------
  |  Branch (1078:38): [True: 0, False: 0]
  |  Branch (1078:58): [True: 0, False: 0]
  ------------------
 1079|      0|            if (fmts[fmt - IMGFMT_START]) {
  ------------------
  |  Branch (1079:17): [True: 0, False: 0]
  ------------------
 1080|      0|                config_format = fmt;
 1081|      0|                break;
 1082|      0|            }
 1083|      0|        }
 1084|       |
 1085|       |        // Use a 16:9 aspect ratio so that fullscreen on a 16:9 screen will not
 1086|       |        // have vertical margins, which can lead to a different size or position
 1087|       |        // of subtitles than with 16:9 videos.
 1088|      0|        int w = 960;
 1089|      0|        int h = 540;
 1090|      0|        struct mp_image_params p = {
 1091|      0|            .imgfmt = config_format,
 1092|      0|            .w = w,   .h = h,
 1093|      0|            .p_w = 1, .p_h = 1,
 1094|      0|            .force_window = true,
 1095|      0|            .color = pl_color_space_srgb,
 1096|      0|        };
 1097|      0|        mp_image_params_guess_csp(&p);
 1098|      0|        if (vo_reconfig(vo, &p) < 0)
  ------------------
  |  Branch (1098:13): [True: 0, False: 0]
  ------------------
 1099|      0|            goto err;
 1100|      0|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1101|      0|        update_window_title(mpctx, true);
 1102|      0|        update_content_type(mpctx, track);
 1103|      0|        update_screensaver_state(mpctx);
 1104|      0|        vo_set_paused(vo, true);
 1105|      0|        vo_redraw(vo);
 1106|      0|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1107|      0|    }
 1108|       |
 1109|      0|    return 0;
 1110|       |
 1111|      0|err:
 1112|      0|    mpctx->opts->force_vo = 0;
 1113|      0|    m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->force_vo);
 1114|      0|    uninit_video_out(mpctx);
 1115|      0|    MP_FATAL(mpctx, "Error opening/initializing the VO window.\n");
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1116|      0|    return -1;
 1117|      0|}
run_playloop:
 1329|   131k|{
 1330|   131k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) {
  ------------------
  |  Branch (1330:9): [True: 0, False: 131k]
  ------------------
 1331|      0|        mpctx->stop_play = PT_ERROR;
 1332|      0|        return;
 1333|      0|    }
 1334|       |
 1335|   131k|    update_demuxer_properties(mpctx);
 1336|       |
 1337|   131k|    update_vo_chain_el_pair(mpctx);
 1338|       |
 1339|   131k|    handle_cursor_autohide(mpctx);
 1340|   131k|    handle_vo_events(mpctx);
 1341|   131k|    handle_command_updates(mpctx);
 1342|       |
 1343|   131k|    if (mpctx->lavfi && mp_filter_has_failed(mpctx->lavfi))
  ------------------
  |  Branch (1343:9): [True: 0, False: 131k]
  |  Branch (1343:25): [True: 0, False: 0]
  ------------------
 1344|      0|        mpctx->stop_play = AT_END_OF_FILE;
 1345|       |
 1346|   131k|    fill_audio_out_buffers(mpctx);
 1347|   131k|    write_video(mpctx);
 1348|       |
 1349|   131k|    handle_lazy_streams(mpctx);
 1350|       |
 1351|   131k|    handle_playback_restart(mpctx);
 1352|       |
 1353|   131k|    handle_playback_time(mpctx);
 1354|       |
 1355|   131k|    handle_dummy_ticks(mpctx);
 1356|       |
 1357|   131k|    handle_clipboard_updates(mpctx);
 1358|       |
 1359|   131k|    update_osd_msg(mpctx);
 1360|       |
 1361|   131k|    handle_update_subtitles(mpctx);
 1362|       |
 1363|   131k|    disc_nav_update(mpctx);
 1364|       |
 1365|   131k|    handle_each_frame_screenshot(mpctx);
 1366|       |
 1367|   131k|    handle_eof(mpctx);
 1368|       |
 1369|   131k|    handle_loop_file(mpctx);
 1370|       |
 1371|   131k|    handle_keep_open(mpctx);
 1372|       |
 1373|   131k|    handle_sstep(mpctx);
 1374|       |
 1375|   131k|    update_core_idle_state(mpctx);
 1376|       |
 1377|   131k|    execute_queued_seek(mpctx);
 1378|       |
 1379|   131k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1379:9): [True: 16.6k, False: 114k]
  ------------------
 1380|  16.6k|        return;
 1381|       |
 1382|   114k|    handle_osd_redraw(mpctx);
 1383|       |
 1384|   114k|    if (mp_filter_graph_run(mpctx->filter_root))
  ------------------
  |  Branch (1384:9): [True: 693, False: 114k]
  ------------------
 1385|    693|        mp_wakeup_core(mpctx);
 1386|       |
 1387|   114k|    mp_wait_events(mpctx);
 1388|       |
 1389|   114k|    handle_update_cache(mpctx);
 1390|       |
 1391|   114k|    mp_process_input(mpctx);
 1392|       |
 1393|   114k|    handle_option_callbacks(mpctx);
 1394|       |
 1395|   114k|    handle_chapter_change(mpctx);
 1396|       |
 1397|       |    handle_force_window(mpctx, false);
 1398|   114k|}
mp_idle:
 1401|   300k|{
 1402|   300k|    handle_dummy_ticks(mpctx);
 1403|   300k|    handle_clipboard_updates(mpctx);
 1404|   300k|    mp_wait_events(mpctx);
 1405|   300k|    mp_process_input(mpctx);
 1406|   300k|    handle_option_callbacks(mpctx);
 1407|   300k|    handle_command_updates(mpctx);
 1408|   300k|    handle_update_cache(mpctx);
 1409|   300k|    handle_cursor_autohide(mpctx);
 1410|   300k|    handle_vo_events(mpctx);
 1411|   300k|    update_osd_msg(mpctx);
 1412|   300k|    handle_osd_redraw(mpctx);
 1413|   300k|}
idle_loop:
 1417|   162k|{
 1418|       |    // ================= idle loop (STOP state) =========================
 1419|   162k|    bool need_reinit = true;
 1420|   303k|    while (mpctx->opts->player_idle_mode && mpctx->stop_play == PT_STOP) {
  ------------------
  |  Branch (1420:12): [True: 303k, False: 0]
  |  Branch (1420:45): [True: 141k, False: 162k]
  ------------------
 1421|   141k|        if (need_reinit) {
  ------------------
  |  Branch (1421:13): [True: 57.7k, False: 83.4k]
  ------------------
 1422|  57.7k|            uninit_audio_out(mpctx);
 1423|  57.7k|            handle_force_window(mpctx, true);
 1424|  57.7k|            mp_wakeup_core(mpctx);
 1425|  57.7k|            mp_notify(mpctx, MPV_EVENT_IDLE, NULL);
 1426|  57.7k|            demux_packet_pool_clear(demux_packet_pool_get(mpctx->global));
 1427|       |            need_reinit = false;
 1428|  57.7k|        }
 1429|   141k|        mp_idle(mpctx);
 1430|   141k|    }
 1431|   162k|}
playloop.c:handle_cursor_autohide:
  850|   432k|{
  851|   432k|    struct MPOpts *opts = mpctx->opts;
  852|   432k|    struct vo *vo = mpctx->video_out;
  853|       |
  854|   432k|    if (!vo)
  ------------------
  |  Branch (854:9): [True: 345k, False: 86.5k]
  ------------------
  855|   345k|        return;
  856|       |
  857|   432k|    bool mouse_cursor_visible = mpctx->mouse_cursor_visible;
  858|  86.5k|    double now = mp_time_sec();
  859|       |
  860|  86.5k|    unsigned mouse_event_ts = mp_input_get_mouse_event_counter(mpctx->input);
  861|  86.5k|    if (mpctx->mouse_event_ts != mouse_event_ts) {
  ------------------
  |  Branch (861:9): [True: 0, False: 86.5k]
  ------------------
  862|      0|        mpctx->mouse_event_ts = mouse_event_ts;
  863|      0|        mpctx->mouse_timer = now + opts->cursor_autohide_delay / 1000.0;
  864|      0|        mouse_cursor_visible = true;
  865|      0|    }
  866|       |
  867|  86.5k|    if (mpctx->mouse_timer > now) {
  ------------------
  |  Branch (867:9): [True: 0, False: 86.5k]
  ------------------
  868|      0|        mp_set_timeout(mpctx, mpctx->mouse_timer - now);
  869|  86.5k|    } else {
  870|  86.5k|        mouse_cursor_visible = false;
  871|  86.5k|    }
  872|       |
  873|  86.5k|    if (opts->cursor_autohide_delay == -1)
  ------------------
  |  Branch (873:9): [True: 0, False: 86.5k]
  ------------------
  874|      0|        mouse_cursor_visible = true;
  875|       |
  876|  86.5k|    if (opts->cursor_autohide_delay == -2)
  ------------------
  |  Branch (876:9): [True: 0, False: 86.5k]
  ------------------
  877|      0|        mouse_cursor_visible = false;
  878|       |
  879|  86.5k|    if (opts->cursor_autohide_fs && !opts->vo->fullscreen)
  ------------------
  |  Branch (879:9): [True: 0, False: 86.5k]
  |  Branch (879:37): [True: 0, False: 0]
  ------------------
  880|      0|        mouse_cursor_visible = true;
  881|       |
  882|  86.5k|    if (mouse_cursor_visible != mpctx->mouse_cursor_visible)
  ------------------
  |  Branch (882:9): [True: 7.59k, False: 78.9k]
  ------------------
  883|  7.59k|        vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &mouse_cursor_visible);
  884|  86.5k|    mpctx->mouse_cursor_visible = mouse_cursor_visible;
  885|  86.5k|}
playloop.c:handle_vo_events:
  888|   432k|{
  889|   432k|    struct vo *vo = mpctx->video_out;
  890|   432k|    int events = vo ? vo_query_and_reset_events(vo, VO_EVENTS_USER) : 0;
  ------------------
  |  Branch (890:18): [True: 86.5k, False: 345k]
  ------------------
  891|   432k|    if (events & VO_EVENT_RESIZE)
  ------------------
  |  Branch (891:9): [True: 0, False: 432k]
  ------------------
  892|      0|        mp_notify(mpctx, MP_EVENT_WIN_RESIZE, NULL);
  893|   432k|    if (events & VO_EVENT_WIN_STATE)
  ------------------
  |  Branch (893:9): [True: 7.59k, False: 424k]
  ------------------
  894|  7.59k|        mp_notify(mpctx, MP_EVENT_WIN_STATE, NULL);
  895|   432k|    if (events & VO_EVENT_DPI)
  ------------------
  |  Branch (895:9): [True: 0, False: 432k]
  ------------------
  896|      0|        mp_notify(mpctx, MP_EVENT_WIN_STATE2, NULL);
  897|   432k|    if (events & VO_EVENT_FOCUS)
  ------------------
  |  Branch (897:9): [True: 0, False: 432k]
  ------------------
  898|      0|        mp_notify(mpctx, MP_EVENT_FOCUS, NULL);
  899|   432k|    if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED)
  ------------------
  |  Branch (899:9): [True: 0, False: 432k]
  ------------------
  900|      0|        mp_notify(mpctx, MP_EVENT_AMBIENT_LIGHTING_CHANGED, NULL);
  901|   432k|    if (events & VO_EVENT_PRESENTATION_DELAY)
  ------------------
  |  Branch (901:9): [True: 0, False: 432k]
  ------------------
  902|      0|        mp_notify(mpctx, MP_EVENT_PRESENTATION_DELAY, NULL);
  903|   432k|}
playloop.c:handle_lazy_streams:
 1242|   131k|{
 1243|   131k|    struct track *track = mpctx->vo_chain ? mpctx->vo_chain->track : NULL;
  ------------------
  |  Branch (1243:27): [True: 70.8k, False: 60.5k]
  ------------------
 1244|   131k|    if (track) {
  ------------------
  |  Branch (1244:9): [True: 70.8k, False: 60.5k]
  ------------------
 1245|  70.8k|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1246|  70.8k|        if (!track->dec) {
  ------------------
  |  Branch (1246:13): [True: 0, False: 70.8k]
  ------------------
 1247|       |            // After a lazy EOF wait for packets, otherwise create the decoder
 1248|       |            // right away. A syncing chain needs one to finish the restart,
 1249|       |            // with a frame or with EOF.
 1250|      0|            if (!lazy || demux_stream_has_packets(track->stream) ||
  ------------------
  |  Branch (1250:17): [True: 0, False: 0]
  |  Branch (1250:26): [True: 0, False: 0]
  ------------------
 1251|      0|                mpctx->video_status == STATUS_SYNCING)
  ------------------
  |  Branch (1251:17): [True: 0, False: 0]
  ------------------
 1252|      0|            {
 1253|      0|                MP_VERBOSE(mpctx, "video stream delivers, new decoder\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1254|      0|                reinit_video_decoder(mpctx);
 1255|      0|                mp_wakeup_core(mpctx);
 1256|      0|            }
 1257|  70.8k|        } else if (mpctx->video_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1257:20): [True: 9.72k, False: 61.1k]
  |  Branch (1257:57): [True: 0, False: 9.72k]
  ------------------
 1258|      0|            MP_VERBOSE(mpctx, "video chain at EOF, decoder done\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1259|      0|            uninit_video_decoder(mpctx);
 1260|      0|        }
 1261|  70.8k|    }
 1262|       |
 1263|   131k|    track = mpctx->ao_chain ? mpctx->ao_chain->track : NULL;
  ------------------
  |  Branch (1263:13): [True: 71.6k, False: 59.7k]
  ------------------
 1264|   131k|    if (track) {
  ------------------
  |  Branch (1264:9): [True: 71.6k, False: 59.7k]
  ------------------
 1265|  71.6k|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1266|  71.6k|        if (!track->dec) {
  ------------------
  |  Branch (1266:13): [True: 0, False: 71.6k]
  ------------------
 1267|      0|            if (!lazy || demux_stream_has_packets(track->stream) ||
  ------------------
  |  Branch (1267:17): [True: 0, False: 0]
  |  Branch (1267:26): [True: 0, False: 0]
  ------------------
 1268|      0|                mpctx->audio_status == STATUS_SYNCING)
  ------------------
  |  Branch (1268:17): [True: 0, False: 0]
  ------------------
 1269|      0|            {
 1270|      0|                MP_VERBOSE(mpctx, "audio stream delivers, new decoder\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1271|      0|                reinit_audio_decoder(mpctx);
 1272|      0|                mp_wakeup_core(mpctx);
 1273|      0|            }
 1274|  71.6k|        } else if (mpctx->audio_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1274:20): [True: 11.6k, False: 60.0k]
  |  Branch (1274:57): [True: 0, False: 11.6k]
  ------------------
 1275|      0|            MP_VERBOSE(mpctx, "audio chain at EOF, decoder done\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1276|      0|            uninit_audio_decoder(mpctx);
 1277|      0|        }
 1278|  71.6k|    }
 1279|   131k|}
playloop.c:handle_playback_restart:
 1160|   131k|{
 1161|   131k|    struct MPOpts *opts = mpctx->opts;
 1162|       |
 1163|   131k|    if (mpctx->audio_status < STATUS_READY ||
  ------------------
  |  Branch (1163:9): [True: 42.4k, False: 89.0k]
  ------------------
 1164|  89.0k|        mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (1164:9): [True: 10.7k, False: 78.3k]
  ------------------
 1165|  53.1k|        return;
 1166|       |
 1167|  78.3k|    handle_update_cache(mpctx);
 1168|       |
 1169|  78.3k|    if (mpctx->video_status == STATUS_READY) {
  ------------------
  |  Branch (1169:9): [True: 1.00k, False: 77.3k]
  ------------------
 1170|  1.00k|        mpctx->video_status = STATUS_PLAYING;
 1171|  1.00k|        get_relative_time(mpctx);
 1172|  1.00k|        mp_wakeup_core(mpctx);
 1173|  1.00k|        MP_DBG(mpctx, "starting video playback\n");
  ------------------
  |  |   93|  1.00k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.00k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1174|  1.00k|    }
 1175|       |
 1176|  78.3k|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (1176:9): [True: 6.07k, False: 72.2k]
  ------------------
 1177|       |        // If a new seek is queued while the current one finishes, don't
 1178|       |        // actually play the audio, but resume seeking immediately.
 1179|  6.07k|        if (mpctx->seek.type && mpctx->video_status == STATUS_PLAYING) {
  ------------------
  |  Branch (1179:13): [True: 0, False: 6.07k]
  |  Branch (1179:33): [True: 0, False: 0]
  ------------------
 1180|      0|            handle_playback_time(mpctx);
 1181|      0|            mpctx->seek.flags &= ~MPSEEK_FLAG_DELAY; // immediately
 1182|      0|            execute_queued_seek(mpctx);
 1183|      0|            return;
 1184|      0|        }
 1185|       |
 1186|  6.07k|        audio_start_ao(mpctx);
 1187|  6.07k|    }
 1188|       |
 1189|  78.3k|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (1189:9): [True: 16.7k, False: 61.5k]
  ------------------
 1190|  16.7k|        mpctx->hrseek_active = false;
 1191|  16.7k|        mpctx->restart_complete = true;
 1192|  16.7k|        mpctx->current_seek = (struct seek_params){0};
 1193|  16.7k|        handle_playback_time(mpctx);
 1194|  16.7k|        mp_notify(mpctx, MPV_EVENT_PLAYBACK_RESTART, NULL);
 1195|  16.7k|        update_core_idle_state(mpctx);
 1196|  16.7k|        if (!mpctx->playing_msg_shown) {
  ------------------
  |  Branch (1196:13): [True: 16.7k, False: 0]
  ------------------
 1197|  16.7k|            if (opts->playing_msg && opts->playing_msg[0]) {
  ------------------
  |  Branch (1197:17): [True: 0, False: 16.7k]
  |  Branch (1197:38): [True: 0, False: 0]
  ------------------
 1198|      0|                char *msg =
 1199|      0|                    mp_property_expand_escaped_string(mpctx, opts->playing_msg);
 1200|      0|                struct mp_log *log = mp_log_new(NULL, mpctx->log, "!term-msg");
 1201|      0|                mp_info(log, "%s\n", msg);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 1202|      0|                talloc_free(log);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1203|      0|                talloc_free(msg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1204|      0|            }
 1205|  16.7k|            if (opts->osd_playing_msg && opts->osd_playing_msg[0]) {
  ------------------
  |  Branch (1205:17): [True: 0, False: 16.7k]
  |  Branch (1205:42): [True: 0, False: 0]
  ------------------
 1206|      0|                char *msg =
 1207|      0|                    mp_property_expand_escaped_string(mpctx, opts->osd_playing_msg);
 1208|      0|                set_osd_msg(mpctx, 1, opts->osd_playing_msg_duration ?
  ------------------
  |  Branch (1208:39): [True: 0, False: 0]
  ------------------
 1209|      0|                            opts->osd_playing_msg_duration : opts->osd_duration,
 1210|      0|                            "%s", msg);
 1211|      0|                talloc_free(msg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1212|      0|            }
 1213|  16.7k|        }
 1214|  16.7k|        mpctx->playing_msg_shown = true;
 1215|  16.7k|        mp_wakeup_core(mpctx);
 1216|  16.7k|        update_ab_loop_clip(mpctx);
 1217|  16.7k|        MP_VERBOSE(mpctx, "playback restart complete @ %f, audio=%s, video=%s%s\n",
  ------------------
  |  |   92|  16.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  33.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 16.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|  16.7k|                   mpctx->playback_pts, mp_status_str(mpctx->audio_status),
 1219|  16.7k|                   mp_status_str(mpctx->video_status),
 1220|  16.7k|                   get_internal_paused(mpctx) ? " (paused)" : "");
 1221|       |
 1222|       |        // To avoid strange effects when using relative seeks, especially if
 1223|       |        // there are no proper audio & video timestamps (seeks after EOF).
 1224|  16.7k|        double length = get_time_length(mpctx);
 1225|  16.7k|        if (mpctx->last_seek_pts != MP_NOPTS_VALUE && length >= 0)
  ------------------
  |  |   39|  33.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1225:13): [True: 16.7k, False: 0]
  |  Branch (1225:55): [True: 11.1k, False: 5.63k]
  ------------------
 1226|  11.1k|            mpctx->last_seek_pts = MPCLAMP(mpctx->last_seek_pts, 0, length);
  ------------------
  |  |   46|  11.1k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 11.1k]
  |  |  |  Branch (46:56): [True: 0, False: 11.1k]
  |  |  ------------------
  ------------------
 1227|       |
 1228|       |        // Continuous seeks past EOF => treat as EOF instead of repeating seek.
 1229|  16.7k|        if (mpctx->seek.type == MPSEEK_RELATIVE && mpctx->seek.amount > 0 &&
  ------------------
  |  Branch (1229:13): [True: 0, False: 16.7k]
  |  Branch (1229:52): [True: 0, False: 0]
  ------------------
 1230|      0|            mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1230:13): [True: 0, False: 0]
  ------------------
 1231|      0|            mpctx->audio_status == STATUS_EOF)
  ------------------
  |  Branch (1231:13): [True: 0, False: 0]
  ------------------
 1232|      0|            mpctx->seek = (struct seek_params){0};
 1233|  16.7k|    }
 1234|  78.3k|}
playloop.c:handle_playback_time:
 1135|   148k|{
 1136|   148k|    if (mpctx->vo_chain &&
  ------------------
  |  Branch (1136:9): [True: 78.5k, False: 69.6k]
  ------------------
 1137|  78.5k|        !mpctx->vo_chain->is_sparse &&
  ------------------
  |  Branch (1137:9): [True: 78.5k, False: 0]
  ------------------
 1138|  78.5k|        mpctx->video_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1138:9): [True: 61.5k, False: 17.0k]
  ------------------
 1139|  61.5k|        mpctx->video_status < STATUS_EOF)
  ------------------
  |  Branch (1139:9): [True: 45.1k, False: 16.3k]
  ------------------
 1140|  45.1k|    {
 1141|  45.1k|        mpctx->playback_pts = mpctx->video_pts;
 1142|   103k|    } else if (mpctx->audio_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1142:16): [True: 60.6k, False: 42.4k]
  ------------------
 1143|  60.6k|               mpctx->audio_status < STATUS_EOF)
  ------------------
  |  Branch (1143:16): [True: 25.5k, False: 35.0k]
  ------------------
 1144|  25.5k|    {
 1145|  25.5k|        mpctx->playback_pts = playing_audio_pts(mpctx);
 1146|  77.4k|    } else if (mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1146:16): [True: 60.4k, False: 17.0k]
  ------------------
 1147|  60.4k|               mpctx->audio_status == STATUS_EOF)
  ------------------
  |  Branch (1147:16): [True: 24.3k, False: 36.1k]
  ------------------
 1148|  24.3k|    {
 1149|  24.3k|        double apts = playing_audio_pts(mpctx);
 1150|  24.3k|        double vpts = mpctx->video_pts;
 1151|  24.3k|        double mpts = MP_PTS_MAX(apts, vpts);
  ------------------
  |  |   65|  24.3k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  48.7k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 24.3k]
  |  |  |  |  |  Branch (44:23): [True: 18.3k, False: 5.98k]
  |  |  |  |  |  Branch (44:29): [True: 23.4k, False: 943]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 23.4k, False: 943]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|  24.3k|        if (mpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  24.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1152:13): [True: 6.92k, False: 17.4k]
  ------------------
 1153|  6.92k|            mpctx->playback_pts = mpts;
 1154|  24.3k|    }
 1155|   148k|}
playloop.c:handle_dummy_ticks:
 1121|   432k|{
 1122|   432k|    if ((mpctx->video_status != STATUS_PLAYING &&
  ------------------
  |  Branch (1122:10): [True: 388k, False: 44.1k]
  ------------------
 1123|   388k|         mpctx->video_status != STATUS_DRAINING) ||
  ------------------
  |  Branch (1123:10): [True: 388k, False: 2]
  ------------------
 1124|  44.1k|         mpctx->paused)
  ------------------
  |  Branch (1124:10): [True: 0, False: 44.1k]
  ------------------
 1125|   388k|    {
 1126|   388k|        if (mp_time_sec() - mpctx->last_idle_tick > 0.050) {
  ------------------
  |  Branch (1126:13): [True: 29.6k, False: 358k]
  ------------------
 1127|  29.6k|            mpctx->last_idle_tick = mp_time_sec();
 1128|       |            mp_notify(mpctx, MPV_EVENT_TICK, NULL);
 1129|  29.6k|        }
 1130|   388k|    }
 1131|   432k|}
playloop.c:handle_clipboard_updates:
 1323|   432k|{
 1324|   432k|    if (mp_clipboard_data_changed(mpctx->clipboard))
  ------------------
  |  Branch (1324:9): [True: 0, False: 432k]
  ------------------
 1325|      0|        mp_notify_property(mpctx, "clipboard");
 1326|   432k|}
playloop.c:handle_update_subtitles:
  834|   131k|{
  835|   131k|    if (mpctx->video_status == STATUS_EOF) {
  ------------------
  |  Branch (835:9): [True: 70.2k, False: 61.1k]
  ------------------
  836|  70.2k|        update_subtitles(mpctx, mpctx->playback_pts);
  837|  70.2k|        return;
  838|  70.2k|    }
  839|       |
  840|   128k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (840:21): [True: 67.7k, False: 61.1k]
  ------------------
  841|  67.7k|        struct track *track = mpctx->tracks[n];
  842|  67.7k|        if (track->type == STREAM_SUB && !track->demuxer_ready) {
  ------------------
  |  Branch (842:13): [True: 0, False: 67.7k]
  |  Branch (842:42): [True: 0, False: 0]
  ------------------
  843|      0|            update_subtitles(mpctx, mpctx->playback_pts);
  844|      0|            break;
  845|      0|        }
  846|  67.7k|    }
  847|  61.1k|}
playloop.c:handle_eof:
 1282|   131k|{
 1283|   131k|    if (mpctx->seek.type)
  ------------------
  |  Branch (1283:9): [True: 0, False: 131k]
  ------------------
 1284|      0|        return; // for proper keep-open operation
 1285|       |
 1286|       |    /* Don't quit while paused and we're displaying the last video frame. On the
 1287|       |     * other hand, if we don't have a video frame, then the user probably seeked
 1288|       |     * outside of the video, and we do want to quit. */
 1289|   131k|    bool prevent_eof =
 1290|   131k|        mpctx->paused && mpctx->video_out && vo_has_frame(mpctx->video_out) &&
  ------------------
  |  Branch (1290:9): [True: 0, False: 131k]
  |  Branch (1290:26): [True: 0, False: 0]
  |  Branch (1290:46): [True: 0, False: 0]
  ------------------
 1291|      0|        !mpctx->vo_chain->is_coverart;
  ------------------
  |  Branch (1291:9): [True: 0, False: 0]
  ------------------
 1292|       |    /* A disc menu parked on an infinite still frame reports EOF so the decoder
 1293|       |     * drains and the menu frame is shown. Hold it until the user navigates,
 1294|       |     * rather than ending the file. */
 1295|   131k|    prevent_eof |= mpctx->disc_nav_still_frame;
 1296|       |    /* It's possible for the user to simultaneously switch both audio
 1297|       |     * and video streams to "disabled" at runtime. Handle this by waiting
 1298|       |     * rather than immediately stopping playback due to EOF.
 1299|       |     */
 1300|   131k|    if ((mpctx->ao_chain || mpctx->vo_chain) && !prevent_eof &&
  ------------------
  |  Branch (1300:10): [True: 71.6k, False: 59.7k]
  |  Branch (1300:29): [True: 59.7k, False: 64]
  |  Branch (1300:49): [True: 131k, False: 0]
  ------------------
 1301|   131k|        mpctx->audio_status == STATUS_EOF &&
  ------------------
  |  Branch (1301:9): [True: 71.3k, False: 60.0k]
  ------------------
 1302|  71.3k|        mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1302:9): [True: 16.5k, False: 54.8k]
  ------------------
 1303|  16.5k|        !mpctx->stop_play)
  ------------------
  |  Branch (1303:9): [True: 16.5k, False: 0]
  ------------------
 1304|  16.5k|    {
 1305|       |        /* A chain without a decoder is waiting for its stream to continue
 1306|       |         * (see handle_lazy_streams()). Only end the file if the demuxer
 1307|       |         * reached EOF. */
 1308|  16.5k|        bool waiting = (mpctx->vo_chain && mpctx->vo_chain->track &&
  ------------------
  |  Branch (1308:25): [True: 7.61k, False: 8.97k]
  |  Branch (1308:44): [True: 7.61k, False: 0]
  ------------------
 1309|  7.61k|                        !mpctx->vo_chain->track->dec) ||
  ------------------
  |  Branch (1309:25): [True: 0, False: 7.61k]
  ------------------
 1310|  16.5k|                       (mpctx->ao_chain && mpctx->ao_chain->track &&
  ------------------
  |  Branch (1310:25): [True: 11.6k, False: 4.93k]
  |  Branch (1310:44): [True: 11.6k, False: 0]
  ------------------
 1311|  11.6k|                        !mpctx->ao_chain->track->dec);
  ------------------
  |  Branch (1311:25): [True: 0, False: 11.6k]
  ------------------
 1312|  16.5k|        if (waiting) {
  ------------------
  |  Branch (1312:13): [True: 0, False: 16.5k]
  ------------------
 1313|      0|            struct demux_reader_state s;
 1314|      0|            demux_get_reader_state(mpctx->demuxer, &s);
 1315|      0|            if (!s.eof)
  ------------------
  |  Branch (1315:17): [True: 0, False: 0]
  ------------------
 1316|      0|                return;
 1317|      0|        }
 1318|  16.5k|        mpctx->stop_play = AT_END_OF_FILE;
 1319|  16.5k|    }
 1320|   131k|}
playloop.c:handle_loop_file:
  925|   131k|{
  926|   131k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (926:9): [True: 114k, False: 16.5k]
  ------------------
  927|   114k|        return;
  928|       |
  929|  16.5k|    double target = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  16.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  930|  16.5k|    enum seek_precision prec = MPSEEK_DEFAULT;
  931|       |
  932|  16.5k|    double ab[2];
  933|  16.5k|    if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) {
  ------------------
  |  Branch (933:9): [True: 0, False: 16.5k]
  |  Branch (933:41): [True: 0, False: 0]
  ------------------
  934|      0|        if (mpctx->remaining_ab_loops > 0) {
  ------------------
  |  Branch (934:13): [True: 0, False: 0]
  ------------------
  935|      0|            mpctx->remaining_ab_loops--;
  936|      0|            mp_notify_property(mpctx, "remaining-ab-loops");
  937|      0|        }
  938|      0|        target = ab[0];
  939|      0|        prec = MPSEEK_EXACT;
  940|  16.5k|    } else if (mpctx->remaining_file_loops) {
  ------------------
  |  Branch (940:16): [True: 0, False: 16.5k]
  ------------------
  941|      0|        if (mpctx->remaining_file_loops > 0) {
  ------------------
  |  Branch (941:13): [True: 0, False: 0]
  ------------------
  942|      0|            mpctx->remaining_file_loops--;
  943|      0|            mp_notify_property(mpctx, "remaining-file-loops");
  944|      0|        }
  945|      0|        target = get_start_time(mpctx, mpctx->play_dir);
  946|      0|    }
  947|       |
  948|  16.5k|    if (target != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  16.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (948:9): [True: 0, False: 16.5k]
  ------------------
  949|      0|        if (!mpctx->shown_aframes && !mpctx->shown_vframes) {
  ------------------
  |  Branch (949:13): [True: 0, False: 0]
  |  Branch (949:38): [True: 0, False: 0]
  ------------------
  950|      0|            MP_WARN(mpctx, "No media data to loop.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  951|      0|            return;
  952|      0|        }
  953|       |
  954|      0|        mpctx->stop_play = KEEP_PLAYING;
  955|      0|        set_osd_function(mpctx, OSD_FFW);
  956|      0|        mark_seek(mpctx);
  957|       |
  958|       |        // Assumes execute_queued_seek() happens before next audio/video is
  959|       |        // attempted to be decoded or filtered.
  960|      0|        queue_seek(mpctx, MPSEEK_ABSOLUTE, target, prec, MPSEEK_FLAG_NOFLUSH);
  961|      0|    }
  962|  16.5k|}
playloop.c:handle_keep_open:
  994|   131k|{
  995|   131k|    struct MPOpts *opts = mpctx->opts;
  996|   131k|    if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE &&
  ------------------
  |  Branch (996:9): [True: 0, False: 131k]
  |  Branch (996:28): [True: 0, False: 0]
  ------------------
  997|      0|        (opts->keep_open == 2 ||
  ------------------
  |  Branch (997:10): [True: 0, False: 0]
  ------------------
  998|      0|        (!playlist_get_next(mpctx->playlist, 1) && opts->loop_times == 1)))
  ------------------
  |  Branch (998:10): [True: 0, False: 0]
  |  Branch (998:52): [True: 0, False: 0]
  ------------------
  999|      0|    {
 1000|      0|        mpctx->stop_play = KEEP_PLAYING;
 1001|      0|        if (mpctx->vo_chain) {
  ------------------
  |  Branch (1001:13): [True: 0, False: 0]
  ------------------
 1002|      0|            if (!vo_has_frame(mpctx->video_out)) { // EOF not reached normally
  ------------------
  |  Branch (1002:17): [True: 0, False: 0]
  ------------------
 1003|      0|                seek_to_last_frame(mpctx);
 1004|      0|                mpctx->audio_status = STATUS_EOF;
 1005|      0|                mpctx->video_status = STATUS_EOF;
 1006|      0|            }
 1007|      0|        }
 1008|      0|        if (opts->keep_open_pause) {
  ------------------
  |  Branch (1008:13): [True: 0, False: 0]
  ------------------
 1009|      0|            if (mpctx->ao && ao_is_playing(mpctx->ao))
  ------------------
  |  Branch (1009:17): [True: 0, False: 0]
  |  Branch (1009:30): [True: 0, False: 0]
  ------------------
 1010|      0|                return;
 1011|      0|            set_pause_state(mpctx, true);
 1012|      0|        }
 1013|      0|    }
 1014|   131k|}
playloop.c:handle_sstep:
  906|   131k|{
  907|   131k|    struct MPOpts *opts = mpctx->opts;
  908|   131k|    if (mpctx->stop_play || !mpctx->restart_complete)
  ------------------
  |  Branch (908:9): [True: 16.6k, False: 114k]
  |  Branch (908:29): [True: 53.1k, False: 61.6k]
  ------------------
  909|  69.7k|        return;
  910|       |
  911|  61.6k|    if (opts->step_sec > 0 && !mpctx->paused) {
  ------------------
  |  Branch (911:9): [True: 0, False: 61.6k]
  |  Branch (911:31): [True: 0, False: 0]
  ------------------
  912|      0|        set_osd_function(mpctx, OSD_FFW);
  913|      0|        queue_seek(mpctx, MPSEEK_RELATIVE, opts->step_sec, MPSEEK_DEFAULT, 0);
  914|      0|    }
  915|       |
  916|  61.6k|    if (mpctx->video_status >= STATUS_EOF) {
  ------------------
  |  Branch (916:9): [True: 17.5k, False: 44.1k]
  ------------------
  917|  17.5k|        if (mpctx->max_frames >= 0 && !mpctx->stop_play)
  ------------------
  |  Branch (917:13): [True: 0, False: 17.5k]
  |  Branch (917:39): [True: 0, False: 0]
  ------------------
  918|      0|            mpctx->stop_play = AT_END_OF_FILE; // force EOF even if audio left
  919|  17.5k|        if (mpctx->step_frames > 0 && !mpctx->paused)
  ------------------
  |  Branch (919:13): [True: 0, False: 17.5k]
  |  Branch (919:39): [True: 0, False: 0]
  ------------------
  920|      0|            set_pause_state(mpctx, true);
  921|  17.5k|    }
  922|  61.6k|}
playloop.c:handle_osd_redraw:
  679|   415k|{
  680|   415k|    if (!mpctx->video_out || !mpctx->video_out->config_ok || (mpctx->playing && mpctx->stop_play))
  ------------------
  |  Branch (680:9): [True: 336k, False: 78.8k]
  |  Branch (680:30): [True: 32.6k, False: 46.1k]
  |  Branch (680:63): [True: 46.1k, False: 0]
  |  Branch (680:81): [True: 2.04k, False: 44.1k]
  ------------------
  681|   371k|        return;
  682|       |    // If we're playing normally, let OSD be redrawn naturally as part of
  683|       |    // video display.
  684|  44.1k|    if (!mpctx->paused) {
  ------------------
  |  Branch (684:9): [True: 44.1k, False: 0]
  ------------------
  685|  44.1k|        if (mpctx->sleeptime < 0.1 && mpctx->video_status == STATUS_PLAYING)
  ------------------
  |  Branch (685:13): [True: 44.1k, False: 0]
  |  Branch (685:39): [True: 44.1k, False: 2]
  ------------------
  686|  44.1k|            return;
  687|  44.1k|    }
  688|       |    // Don't redraw immediately during a seek (makes it significantly slower).
  689|  44.1k|    bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (689:22): [True: 2, False: 0]
  |  Branch (689:41): [True: 2, False: 0]
  ------------------
  690|      2|    if (use_video && mp_time_sec() - mpctx->start_timestamp < 0.1) {
  ------------------
  |  Branch (690:9): [True: 2, False: 0]
  |  Branch (690:22): [True: 0, False: 2]
  ------------------
  691|      0|        mp_set_timeout(mpctx, 0.1);
  692|      0|        return;
  693|      0|    }
  694|      2|    bool want_redraw = osd_query_and_reset_want_redraw(mpctx->osd) ||
  ------------------
  |  Branch (694:24): [True: 2, False: 0]
  ------------------
  695|      0|                       vo_want_redraw(mpctx->video_out);
  ------------------
  |  Branch (695:24): [True: 0, False: 0]
  ------------------
  696|      2|    if (!want_redraw)
  ------------------
  |  Branch (696:9): [True: 0, False: 2]
  ------------------
  697|      0|        return;
  698|      2|    vo_redraw(mpctx->video_out);
  699|      2|}
playloop.c:handle_update_cache:
  715|   494k|{
  716|   494k|    bool force_update = false;
  717|   494k|    struct MPOpts *opts = mpctx->opts;
  718|       |
  719|   494k|    if (!mpctx->demuxer || mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (719:9): [True: 279k, False: 214k]
  |  Branch (719:28): [True: 0, False: 214k]
  ------------------
  720|   279k|        clear_underruns(mpctx);
  721|   279k|        return;
  722|   279k|    }
  723|       |
  724|   214k|    double now = mp_time_sec();
  725|       |
  726|   214k|    struct demux_reader_state s;
  727|   214k|    demux_get_reader_state(mpctx->demuxer, &s);
  728|       |
  729|   214k|    mpctx->demux_underrun |= s.underrun;
  730|       |
  731|   214k|    int cache_buffer = 100;
  732|   214k|    bool use_pause_on_low_cache = opts->cache_pause && mpctx->play_dir > 0;
  ------------------
  |  Branch (732:35): [True: 214k, False: 0]
  |  Branch (732:56): [True: 214k, False: 0]
  ------------------
  733|       |
  734|   214k|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (734:9): [True: 91.7k, False: 123k]
  ------------------
  735|       |        // Audio or video is restarting, and initial buffering is enabled. Make
  736|       |        // sure we actually restart them in paused mode, so no audio gets
  737|       |        // dropped and video technically doesn't start yet.
  738|  91.7k|        use_pause_on_low_cache &= opts->cache_pause_initial &&
  ------------------
  |  Branch (738:35): [True: 0, False: 91.7k]
  ------------------
  739|      0|                                    (mpctx->video_status == STATUS_READY ||
  ------------------
  |  Branch (739:38): [True: 0, False: 0]
  ------------------
  740|      0|                                     mpctx->audio_status == STATUS_READY);
  ------------------
  |  Branch (740:38): [True: 0, False: 0]
  ------------------
  741|  91.7k|    }
  742|       |
  743|   214k|    bool is_low = use_pause_on_low_cache && !s.idle &&
  ------------------
  |  Branch (743:19): [True: 123k, False: 91.7k]
  |  Branch (743:45): [True: 2.38k, False: 120k]
  ------------------
  744|  2.38k|                  s.ts_info.duration < opts->cache_pause_wait;
  ------------------
  |  Branch (744:19): [True: 594, False: 1.78k]
  ------------------
  745|       |
  746|       |    // Enter buffering state only if there actually was an underrun (or if
  747|       |    // initial caching before playback restart is used).
  748|   214k|    bool need_wait = is_low;
  749|   214k|    if (is_low && !mpctx->paused_for_cache && mpctx->restart_complete) {
  ------------------
  |  Branch (749:9): [True: 594, False: 214k]
  |  Branch (749:19): [True: 594, False: 0]
  |  Branch (749:47): [True: 594, False: 0]
  ------------------
  750|       |        // Wait only if an output underrun was registered. (Or if there is no
  751|       |        // underrun detection.)
  752|    594|        bool output_underrun = false;
  753|       |
  754|    594|        if (mpctx->ao_chain)
  ------------------
  |  Branch (754:13): [True: 145, False: 449]
  ------------------
  755|    145|            output_underrun |= mpctx->ao_chain->underrun;
  756|    594|        if (mpctx->vo_chain)
  ------------------
  |  Branch (756:13): [True: 449, False: 145]
  ------------------
  757|    449|            output_underrun |= mpctx->vo_chain->underrun;
  758|       |
  759|       |        // Output underruns could be sporadic (unrelated to demuxer buffer state
  760|       |        // and for example caused by slow decoding), so use a past demuxer
  761|       |        // underrun as indication that the underrun was possibly due to a
  762|       |        // demuxer underrun.
  763|    594|        need_wait = mpctx->demux_underrun && output_underrun;
  ------------------
  |  Branch (763:21): [True: 100, False: 494]
  |  Branch (763:46): [True: 0, False: 100]
  ------------------
  764|    594|    }
  765|       |
  766|       |    // Let the underrun flag "stick" around until the cache has fully recovered.
  767|       |    // See logic where demux_underrun is used.
  768|   214k|    if (!is_low)
  ------------------
  |  Branch (768:9): [True: 214k, False: 594]
  ------------------
  769|   214k|        mpctx->demux_underrun = false;
  770|       |
  771|   214k|    if (mpctx->paused_for_cache != need_wait) {
  ------------------
  |  Branch (771:9): [True: 0, False: 214k]
  ------------------
  772|      0|        mpctx->paused_for_cache = need_wait;
  773|      0|        update_internal_pause_state(mpctx);
  774|      0|        force_update = true;
  775|      0|        if (mpctx->paused_for_cache)
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            mpctx->cache_stop_time = now;
  777|      0|    }
  778|       |
  779|   214k|    if (!mpctx->paused_for_cache)
  ------------------
  |  Branch (779:9): [True: 214k, False: 0]
  ------------------
  780|   214k|        clear_underruns(mpctx);
  781|       |
  782|   214k|    if (mpctx->paused_for_cache) {
  ------------------
  |  Branch (782:9): [True: 0, False: 214k]
  ------------------
  783|      0|        cache_buffer =
  784|      0|            100 * MPCLAMP(s.ts_info.duration / opts->cache_pause_wait, 0, 0.99);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  785|      0|        mp_set_timeout(mpctx, 0.2);
  786|      0|    }
  787|       |
  788|       |    // Also update cache properties.
  789|   214k|    bool busy = !s.idle;
  790|   214k|    if (fabs(mpctx->cache_update_pts - mpctx->playback_pts) >= 1.0)
  ------------------
  |  Branch (790:9): [True: 117k, False: 97.0k]
  ------------------
  791|   117k|        busy = true;
  792|   214k|    if (busy || mpctx->next_cache_update > 0) {
  ------------------
  |  Branch (792:9): [True: 148k, False: 66.7k]
  |  Branch (792:17): [True: 44.6k, False: 22.0k]
  ------------------
  793|   192k|        if (mpctx->next_cache_update <= now) {
  ------------------
  |  Branch (793:13): [True: 16.5k, False: 176k]
  ------------------
  794|  16.5k|            mpctx->next_cache_update = busy ? now + 0.25 : 0;
  ------------------
  |  Branch (794:40): [True: 16.5k, False: 3]
  ------------------
  795|  16.5k|            force_update = true;
  796|  16.5k|        }
  797|   192k|        if (mpctx->next_cache_update > 0)
  ------------------
  |  Branch (797:13): [True: 192k, False: 3]
  ------------------
  798|   192k|            mp_set_timeout(mpctx, mpctx->next_cache_update - now);
  799|   192k|    }
  800|       |
  801|   214k|    if (mpctx->cache_buffer != cache_buffer) {
  ------------------
  |  Branch (801:9): [True: 0, False: 214k]
  ------------------
  802|      0|        if ((mpctx->cache_buffer == 100) != (cache_buffer == 100)) {
  ------------------
  |  Branch (802:13): [True: 0, False: 0]
  ------------------
  803|      0|            if (cache_buffer < 100) {
  ------------------
  |  Branch (803:17): [True: 0, False: 0]
  ------------------
  804|      0|                MP_VERBOSE(mpctx, "Enter buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  805|      0|                           mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  806|      0|            } else {
  807|      0|                double t = now - mpctx->cache_stop_time;
  808|      0|                MP_VERBOSE(mpctx, "End buffering (waited %f secs) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  809|      0|                           t, s.ts_info.duration);
  810|      0|            }
  811|      0|        } else {
  812|      0|            MP_VERBOSE(mpctx, "Still buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  813|      0|                       mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  814|      0|        }
  815|      0|        mpctx->cache_buffer = cache_buffer;
  816|      0|        force_update = true;
  817|      0|    }
  818|       |
  819|   214k|    if (s.eof && !busy)
  ------------------
  |  Branch (819:9): [True: 157k, False: 57.2k]
  |  Branch (819:18): [True: 42.1k, False: 115k]
  ------------------
  820|  42.1k|        prefetch_next(mpctx);
  821|       |
  822|   214k|    if (force_update) {
  ------------------
  |  Branch (822:9): [True: 16.5k, False: 198k]
  ------------------
  823|  16.5k|        mpctx->cache_update_pts = mpctx->playback_pts;
  824|       |        mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
  825|  16.5k|    }
  826|   214k|}
playloop.c:clear_underruns:
  702|   494k|{
  703|   494k|    if (mpctx->ao_chain && mpctx->ao_chain->underrun) {
  ------------------
  |  Branch (703:9): [True: 89.2k, False: 404k]
  |  Branch (703:28): [True: 0, False: 89.2k]
  ------------------
  704|      0|        mpctx->ao_chain->underrun = false;
  705|      0|        mp_wakeup_core(mpctx);
  706|      0|    }
  707|       |
  708|   494k|    if (mpctx->vo_chain && mpctx->vo_chain->underrun) {
  ------------------
  |  Branch (708:9): [True: 117k, False: 376k]
  |  Branch (708:28): [True: 0, False: 117k]
  ------------------
  709|       |        mpctx->vo_chain->underrun = false;
  710|      0|        mp_wakeup_core(mpctx);
  711|      0|    }
  712|   494k|}
playloop.c:mp_process_input:
  111|   415k|{
  112|   415k|    bool notify = false;
  113|   415k|    for (;;) {
  114|   415k|        mp_cmd_t *cmd = mp_input_read_cmd(mpctx->input);
  115|   415k|        if (!cmd)
  ------------------
  |  Branch (115:13): [True: 415k, False: 0]
  ------------------
  116|   415k|            break;
  117|      0|        if (cmd->notify_event)
  ------------------
  |  Branch (117:13): [True: 0, False: 0]
  ------------------
  118|      0|            notify = true;
  119|      0|        run_command(mpctx, cmd, NULL, NULL, NULL);
  120|      0|    }
  121|   415k|    mp_set_timeout(mpctx, mp_input_get_delay(mpctx->input));
  122|   415k|    if (notify)
  ------------------
  |  Branch (122:9): [True: 0, False: 415k]
  ------------------
  123|      0|        mp_notify(mpctx, MP_EVENT_INPUT_PROCESSED, NULL);
  124|   415k|}
playloop.c:handle_chapter_change:
 1017|   114k|{
 1018|   114k|    int chapter = get_current_chapter(mpctx);
 1019|   114k|    if (chapter != mpctx->last_chapter) {
  ------------------
  |  Branch (1019:9): [True: 0, False: 114k]
  ------------------
 1020|      0|        mpctx->last_chapter = chapter;
 1021|       |        mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
 1022|      0|    }
 1023|   114k|}

screenshot_init:
   64|  28.9k|{
   65|  28.9k|    mpctx->screenshot_ctx = talloc(mpctx, screenshot_ctx);
  ------------------
  |  |   26|  28.9k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  28.9k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|  28.9k|    *mpctx->screenshot_ctx = (screenshot_ctx) {
   67|  28.9k|        .mpctx = mpctx,
   68|  28.9k|        .frameno = 1,
   69|  28.9k|        .log = mp_log_new(mpctx, mpctx->log, "screenshot")
   70|  28.9k|    };
   71|  28.9k|}
handle_each_frame_screenshot:
  607|   131k|{
  608|   131k|    screenshot_ctx *ctx = mpctx->screenshot_ctx;
  609|       |
  610|   131k|    if (!ctx->each_frame)
  ------------------
  |  Branch (610:9): [True: 131k, False: 0]
  ------------------
  611|   131k|        return;
  612|       |
  613|      0|    if (ctx->last_frame_count == mpctx->shown_vframes)
  ------------------
  |  Branch (613:9): [True: 0, False: 0]
  ------------------
  614|      0|        return;
  615|      0|    ctx->last_frame_count = mpctx->shown_vframes;
  616|       |
  617|      0|    struct mp_waiter wait = MP_WAITER_INITIALIZER;
  ------------------
  |  |   19|      0|#define MP_WAITER_INITIALIZER { \
  |  |   20|      0|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|      0|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|      0|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|      0|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|      0|    }
  ------------------
  618|      0|    void *a[] = {mpctx, &wait};
  619|      0|    run_command(mpctx, mp_cmd_clone(ctx->each_frame), NULL, screenshot_fin, a);
  620|       |
  621|       |    // Block (in a reentrant way) until the screenshot was written. Otherwise,
  622|       |    // we could pile up screenshot requests forever.
  623|      0|    while (!mp_waiter_poll(&wait))
  ------------------
  |  Branch (623:12): [True: 0, False: 0]
  ------------------
  624|      0|        mp_idle(mpctx);
  625|       |
  626|      0|    mp_waiter_wait(&wait);
  627|      0|}

mp_load_builtin_scripts:
  262|  28.9k|{
  263|  28.9k|    load_builtin_script(mpctx, 0, mpctx->opts->lua_load_osc, "@osc.lua");
  264|  28.9k|    load_builtin_script(mpctx, 1, mpctx->opts->lua_load_ytdl, "@ytdl_hook.lua");
  265|  28.9k|    load_builtin_script(mpctx, 2, mpctx->opts->lua_load_stats, "@stats.lua");
  266|  28.9k|    load_builtin_script(mpctx, 3, mpctx->opts->lua_load_console, "@console.lua");
  267|  28.9k|    load_builtin_script(mpctx, 4, mpctx->opts->lua_load_auto_profiles,
  268|  28.9k|                        "@auto_profiles.lua");
  269|  28.9k|    load_builtin_script(mpctx, 5, mpctx->opts->lua_load_select, "@select.lua");
  270|  28.9k|    load_builtin_script(mpctx, 6, mpctx->opts->lua_load_positioning, "@positioning.lua");
  271|  28.9k|    load_builtin_script(mpctx, 7, mpctx->opts->lua_load_commands, "@commands.lua");
  272|       |
  273|       |    // select.lua uses context_menu.lua in D3D11 exclusive fullscreen.
  274|  28.9k|    struct m_config_option *co = m_config_get_co(mpctx->mconfig, bstr0("d3d11-exclusive-fs"));
  275|  28.9k|    bool context_menu = mpctx->opts->lua_load_context_menu || (co && *(bool *)co->data);
  ------------------
  |  Branch (275:25): [True: 0, False: 28.9k]
  |  Branch (275:64): [True: 0, False: 28.9k]
  |  Branch (275:70): [True: 0, False: 0]
  ------------------
  276|  28.9k|    load_builtin_script(mpctx, 8, context_menu, "@context_menu.lua");
  277|  28.9k|}
mp_load_scripts:
  280|  28.9k|{
  281|  28.9k|    bool ok = true;
  282|       |
  283|       |    // Load scripts from options
  284|  28.9k|    char **files = mpctx->opts->script_files;
  285|  28.9k|    for (int n = 0; files && files[n]; n++) {
  ------------------
  |  Branch (285:21): [True: 0, False: 28.9k]
  |  Branch (285:30): [True: 0, False: 0]
  ------------------
  286|      0|        if (files[n][0])
  ------------------
  |  Branch (286:13): [True: 0, False: 0]
  ------------------
  287|      0|            ok &= mp_load_user_script(mpctx, files[n]) >= 0;
  288|      0|    }
  289|  28.9k|    if (!mpctx->opts->auto_load_scripts)
  ------------------
  |  Branch (289:9): [True: 0, False: 28.9k]
  ------------------
  290|      0|        return ok;
  291|       |
  292|       |    // Load all scripts
  293|  28.9k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  28.9k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  28.9k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  294|  28.9k|    char **scriptsdir = mp_find_all_config_files(tmp, mpctx->global, "scripts");
  295|  28.9k|    for (int i = 0; scriptsdir && scriptsdir[i]; i++) {
  ------------------
  |  Branch (295:21): [True: 28.9k, False: 0]
  |  Branch (295:35): [True: 0, False: 28.9k]
  ------------------
  296|      0|        files = list_script_files(tmp, scriptsdir[i]);
  297|      0|        for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (297:25): [True: 0, False: 0]
  |  Branch (297:34): [True: 0, False: 0]
  ------------------
  298|      0|            ok &= mp_load_script(mpctx, files[n]) >= 0;
  299|      0|    }
  300|  28.9k|    talloc_free(tmp);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  301|       |
  302|  28.9k|    return ok;
  303|  28.9k|}
scripting.c:load_builtin_script:
  242|   260k|{
  243|   260k|    mp_assert(slot < MP_ARRAY_SIZE(mpctx->builtin_script_ids));
  ------------------
  |  |   41|   260k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 260k, False: 0]
  ------------------
  244|   260k|    int64_t *pid = &mpctx->builtin_script_ids[slot];
  245|   260k|    if (*pid > 0 && !mp_client_id_exists(mpctx, *pid)) {
  ------------------
  |  Branch (245:9): [True: 0, False: 260k]
  |  Branch (245:21): [True: 0, False: 0]
  ------------------
  246|      0|        MP_DBG(mpctx, "Client for script %s is no longer alive. Marking as unloaded.\n", fname);
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  247|      0|        *pid = 0; // died
  248|      0|    }
  249|   260k|    if ((*pid > 0) != enable) {
  ------------------
  |  Branch (249:9): [True: 0, False: 260k]
  ------------------
  250|      0|        if (enable) {
  ------------------
  |  Branch (250:13): [True: 0, False: 0]
  ------------------
  251|      0|            *pid = mp_load_script(mpctx, fname);
  252|      0|        } else {
  253|      0|            char *name = mp_tprintf(22, "@%"PRIi64, *pid);
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  254|      0|            MP_DBG(mpctx, "Unloading script %s (disabled by option)\n", fname);
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  255|      0|            mp_client_send_event(mpctx, name, 0, MPV_EVENT_SHUTDOWN, NULL);
  256|       |            // note: there is no synchronization of script exit
  257|      0|        }
  258|      0|    }
  259|   260k|}

redraw_subs:
   57|  45.7k|{
   58|   137k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (58:21): [True: 91.4k, False: 45.7k]
  ------------------
   59|  91.4k|        if (mpctx->current_track[n][STREAM_SUB] &&
  ------------------
  |  Branch (59:13): [True: 0, False: 91.4k]
  ------------------
   60|      0|            mpctx->current_track[n][STREAM_SUB]->d_sub)
  ------------------
  |  Branch (60:13): [True: 0, False: 0]
  ------------------
   61|      0|        {
   62|       |            mpctx->current_track[n][STREAM_SUB]->redraw_subs = true;
   63|      0|        }
   64|  91.4k|    }
   65|  45.7k|}
reset_subtitle_state:
   68|   133k|{
   69|   133k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (69:21): [True: 0, False: 133k]
  ------------------
   70|      0|        reset_subtitles(mpctx, mpctx->tracks[n]);
   71|   133k|    term_osd_clear_subs(mpctx);
   72|   133k|}
uninit_sub:
   75|  24.0k|{
   76|  24.0k|    if (track && track->d_sub) {
  ------------------
  |  Branch (76:9): [True: 24.0k, False: 0]
  |  Branch (76:18): [True: 0, False: 24.0k]
  ------------------
   77|      0|        int order = get_order(mpctx, track);
   78|      0|        reset_subtitles(mpctx, track);
   79|      0|        sub_select(track->d_sub, false);
   80|      0|        if (order >= 0) {
  ------------------
  |  Branch (80:13): [True: 0, False: 0]
  ------------------
   81|      0|            term_osd_set_subs(mpctx, NULL, order);
   82|      0|            osd_set_sub(mpctx->osd, order, NULL);
   83|      0|        }
   84|      0|        sub_destroy(track->d_sub);
   85|       |        track->d_sub = NULL;
   86|      0|    }
   87|  24.0k|}
uninit_sub_all:
   90|   133k|{
   91|   157k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (91:21): [True: 24.0k, False: 133k]
  ------------------
   92|  24.0k|        uninit_sub(mpctx, mpctx->tracks[n]);
   93|   133k|}
update_subtitles:
  166|   114k|{
  167|   114k|    bool ok = true;
  168|   343k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (168:21): [True: 228k, False: 114k]
  ------------------
  169|   228k|        ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
  170|   114k|    return ok;
  171|   114k|}
reinit_sub:
  219|  43.6k|{
  220|  43.6k|    if (!track || !track->stream || track->stream->type != STREAM_SUB)
  ------------------
  |  Branch (220:9): [True: 43.6k, False: 0]
  |  Branch (220:19): [True: 0, False: 0]
  |  Branch (220:37): [True: 0, False: 0]
  ------------------
  221|  43.6k|        return;
  222|       |
  223|      0|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (223:5): [True: 0, False: 0]
  ------------------
  224|       |
  225|      0|    if (!init_subdec(mpctx, track)) {
  ------------------
  |  Branch (225:9): [True: 0, False: 0]
  ------------------
  226|      0|        track->dec_failed = true;
  227|      0|        error_on_track(mpctx, track);
  228|      0|        return;
  229|      0|    }
  230|       |
  231|      0|    sub_select(track->d_sub, true);
  232|      0|    int order = get_order(mpctx, track);
  233|      0|    osd_set_sub(mpctx->osd, order, track->d_sub);
  234|       |
  235|       |    // When paused we have to wait for packets to be available.
  236|       |    // Retry on a timeout until we get a packet. If still not successful,
  237|       |    // then queue it for later in the playloop (but this will have a delay).
  238|      0|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (238:9): [True: 0, False: 0]
  ------------------
  239|      0|        track->demuxer_ready = false;
  240|      0|        int64_t end = mp_time_ns() + MP_TIME_MS_TO_NS(50);
  ------------------
  |  |   72|      0|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  241|      0|        while (!track->demuxer_ready && mp_time_ns() < end)
  ------------------
  |  Branch (241:16): [True: 0, False: 0]
  |  Branch (241:41): [True: 0, False: 0]
  ------------------
  242|      0|            track->demuxer_ready = update_subtitles(mpctx, mpctx->playback_pts) ||
  ------------------
  |  Branch (242:36): [True: 0, False: 0]
  ------------------
  243|      0|                                  !mpctx->paused;
  ------------------
  |  Branch (243:35): [True: 0, False: 0]
  ------------------
  244|      0|        if (!track->demuxer_ready)
  ------------------
  |  Branch (244:13): [True: 0, False: 0]
  ------------------
  245|      0|            mp_wakeup_core(mpctx);
  246|       |
  247|      0|    }
  248|      0|}
reinit_sub_all:
  251|  21.8k|{
  252|  65.4k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (252:21): [True: 43.6k, False: 21.8k]
  ------------------
  253|  43.6k|        reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
  254|  21.8k|}
sub.c:update_subtitle:
   97|   228k|{
   98|   228k|    struct dec_sub *dec_sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (98:31): [True: 0, False: 228k]
  ------------------
   99|       |
  100|   228k|    if (!dec_sub)
  ------------------
  |  Branch (100:9): [True: 228k, False: 0]
  ------------------
  101|   228k|        return true;
  102|       |
  103|      0|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (103:9): [True: 0, False: 0]
  ------------------
  104|      0|        struct mp_image_params params = mpctx->vo_chain->filter->input_params;
  105|      0|        if (params.imgfmt)
  ------------------
  |  Branch (105:13): [True: 0, False: 0]
  ------------------
  106|      0|            sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
  107|      0|    }
  108|       |
  109|       |    // Checking if packets have special animations is relatively expensive.
  110|       |    // This is only needed if we are rendering ASS subtitles with no video
  111|       |    // being played.
  112|      0|    bool still_image = mpctx->video_out && ((mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (112:24): [True: 0, False: 0]
  |  Branch (112:46): [True: 0, False: 0]
  ------------------
  113|      0|                       mpctx->opts->subs_rend->sub_past_video_end) ||
  ------------------
  |  Branch (113:24): [True: 0, False: 0]
  ------------------
  114|      0|                       !mpctx->current_track[0][STREAM_VIDEO] ||
  ------------------
  |  Branch (114:24): [True: 0, False: 0]
  ------------------
  115|      0|                       mpctx->current_track[0][STREAM_VIDEO]->image);
  ------------------
  |  Branch (115:24): [True: 0, False: 0]
  ------------------
  116|      0|    sub_control(dec_sub, SD_CTRL_SET_ANIMATED_CHECK, &still_image);
  117|       |
  118|      0|    if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
  ------------------
  |  Branch (118:9): [True: 0, False: 0]
  |  Branch (118:39): [True: 0, False: 0]
  ------------------
  119|       |        // Assume fully_read implies no interleaved audio/video streams.
  120|       |        // (Reading packets will change the demuxer position.)
  121|      0|        demux_seek(track->demuxer, 0, 0);
  122|      0|        sub_preload(dec_sub);
  123|      0|    }
  124|       |
  125|      0|    bool packets_read = false;
  126|      0|    bool sub_updated = false;
  127|      0|    sub_read_packets(dec_sub, video_pts, mpctx->paused, &packets_read, &sub_updated);
  128|       |
  129|      0|    double osd_pts = osd_get_force_video_pts(mpctx->osd);
  130|       |
  131|       |    // Check if we need to update subtitles for these special cases. Always
  132|       |    // update on discontinuities like seeking or a new file.
  133|      0|    if (sub_updated || track->redraw_subs || osd_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  |  Branch (133:24): [True: 0, False: 0]
  |  Branch (133:46): [True: 0, False: 0]
  ------------------
  134|       |        // Always force a redecode of all packets if we seek on a still image.
  135|      0|        if (track->redraw_subs && still_image)
  ------------------
  |  Branch (135:13): [True: 0, False: 0]
  |  Branch (135:35): [True: 0, False: 0]
  ------------------
  136|      0|            sub_redecode_cached_packets(dec_sub);
  137|       |
  138|       |        // Handle displaying subtitles on terminal.
  139|      0|        if (track->selected && track->type == STREAM_SUB && !mpctx->video_out) {
  ------------------
  |  Branch (139:13): [True: 0, False: 0]
  |  Branch (139:32): [True: 0, False: 0]
  |  Branch (139:61): [True: 0, False: 0]
  ------------------
  140|      0|            char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
  141|      0|            int order = get_order(mpctx, track);
  142|      0|            if (order >= 0)
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|                term_osd_set_subs(mpctx, text, order);
  144|      0|            talloc_free(text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        }
  146|       |
  147|       |        // Handle displaying subtitles on VO with no video being played. This is
  148|       |        // quite different, because normally subtitles are redrawn on new video
  149|       |        // frames, using the video frames' timestamps.
  150|      0|        if (still_image) {
  ------------------
  |  Branch (150:13): [True: 0, False: 0]
  ------------------
  151|      0|            if (osd_pts != video_pts) {
  ------------------
  |  Branch (151:17): [True: 0, False: 0]
  ------------------
  152|      0|                osd_set_force_video_pts(mpctx->osd, video_pts);
  153|      0|                osd_query_and_reset_want_redraw(mpctx->osd);
  154|      0|                vo_redraw(mpctx->video_out);
  155|      0|            }
  156|      0|        }
  157|      0|    }
  158|       |
  159|       |    track->redraw_subs = false;
  160|      0|    return packets_read;
  161|   228k|}

reset_video_state:
  100|   151k|{
  101|   151k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (101:9): [True: 17.3k, False: 133k]
  ------------------
  102|  17.3k|        vo_chain_reset_state(mpctx->vo_chain);
  103|  17.3k|        struct track *t = mpctx->vo_chain->track;
  104|  17.3k|        if (t && t->dec)
  ------------------
  |  Branch (104:13): [True: 17.3k, False: 0]
  |  Branch (104:18): [True: 17.3k, False: 0]
  ------------------
  105|  17.3k|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  106|  17.3k|    }
  107|       |
  108|   151k|    for (int n = 0; n < mpctx->num_next_frames; n++)
  ------------------
  |  Branch (108:21): [True: 0, False: 151k]
  ------------------
  109|      0|        mp_image_unrefp(&mpctx->next_frames[n]);
  110|   151k|    mpctx->num_next_frames = 0;
  111|   151k|    mp_image_unrefp(&mpctx->saved_frame);
  112|       |
  113|   151k|    mpctx->delay = 0;
  114|   151k|    mpctx->time_frame = 0;
  115|   151k|    mpctx->video_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   151k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  116|   151k|    mpctx->last_frame_duration = 0;
  117|   151k|    mpctx->num_past_frames = 0;
  118|   151k|    mpctx->total_avsync_change = 0;
  119|   151k|    mpctx->last_av_difference = 0;
  120|   151k|    mpctx->mistimed_frames_total = 0;
  121|   151k|    mpctx->drop_message_shown = 0;
  122|   151k|    mpctx->audio_drift_compensation = 0;
  123|   151k|    mpctx->avd_filtered = 0;
  124|   151k|    mpctx->display_sync_error = 0;
  125|   151k|    mpctx->display_sync_active = 0;
  126|       |
  127|   151k|    mpctx->video_status = mpctx->vo_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (127:27): [True: 17.3k, False: 133k]
  ------------------
  128|   151k|}
uninit_video_out:
  131|   151k|{
  132|   151k|    uninit_video_chain(mpctx);
  133|   151k|    if (mpctx->video_out) {
  ------------------
  |  Branch (133:9): [True: 9.61k, False: 141k]
  ------------------
  134|  9.61k|        vo_destroy(mpctx->video_out);
  135|  9.61k|        mpctx->video_out = NULL;
  136|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  137|  9.61k|    }
  138|   151k|}
uninit_video_chain:
  164|   289k|{
  165|   289k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (165:9): [True: 9.69k, False: 279k]
  ------------------
  166|  9.69k|        reset_video_state(mpctx);
  167|  9.69k|        vo_chain_uninit(mpctx->vo_chain);
  168|  9.69k|        mpctx->vo_chain = NULL;
  169|       |
  170|  9.69k|        mpctx->video_status = STATUS_EOF;
  171|       |
  172|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  173|  9.69k|    }
  174|   289k|}
init_video_decoder:
  177|  9.69k|{
  178|  9.69k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  9.69k|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 9.69k, False: 0]
  ------------------
  179|  9.69k|    if (!track->stream)
  ------------------
  |  Branch (179:9): [True: 0, False: 9.69k]
  ------------------
  180|      0|        goto err_out;
  181|       |
  182|  9.69k|    struct mp_filter *parent = mpctx->filter_root;
  183|       |
  184|       |    // If possible, set this as parent so the decoder gets the hwdec and DR
  185|       |    // interfaces.
  186|       |    // Note: We rely on being able to get rid of all references to the VO by
  187|       |    //       destroying the VO chain. Thus, decoders not linked to vo_chain
  188|       |    //       must not use the hwdec context.
  189|  9.69k|    if (track->vo_c)
  ------------------
  |  Branch (189:9): [True: 9.69k, False: 0]
  ------------------
  190|  9.69k|        parent = track->vo_c->filter->f;
  191|       |
  192|  9.69k|    track->dec = mp_decoder_wrapper_create(parent, track->stream);
  193|  9.69k|    if (!track->dec)
  ------------------
  |  Branch (193:9): [True: 0, False: 9.69k]
  ------------------
  194|      0|        goto err_out;
  195|       |
  196|  9.69k|    if (sh_stream_dependent_sibling(track->stream))
  ------------------
  |  Branch (196:9): [True: 0, False: 9.69k]
  ------------------
  197|      0|        mp_decoder_wrapper_set_extra_hw_frames(track->dec, MP_ENHANCEMENT_PAIR_QUEUE_MAX);
  ------------------
  |  |   25|      0|#define MP_ENHANCEMENT_PAIR_QUEUE_MAX 8
  ------------------
  198|       |
  199|  9.69k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (199:9): [True: 2.02k, False: 7.67k]
  ------------------
  200|  2.02k|        goto err_out;
  201|       |
  202|  7.67k|    return 1;
  203|       |
  204|  2.02k|err_out:
  205|  2.02k|    if (track->sink)
  ------------------
  |  Branch (205:9): [True: 0, False: 2.02k]
  ------------------
  206|      0|        mp_pin_disconnect(track->sink);
  207|  2.02k|    track->sink = NULL;
  208|       |    track->dec_failed = true;
  209|  2.02k|    return 0;
  210|  9.69k|}
reinit_video_chain:
  213|  23.8k|{
  214|  23.8k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
  215|  23.8k|    if (!track || !track->stream) {
  ------------------
  |  Branch (215:9): [True: 14.1k, False: 9.69k]
  |  Branch (215:19): [True: 0, False: 9.69k]
  ------------------
  216|  14.1k|        error_on_track(mpctx, track);
  217|  14.1k|        return;
  218|  14.1k|    }
  219|  9.69k|    reinit_video_chain_src(mpctx, track);
  220|  9.69k|}
reinit_video_chain_src:
  272|  9.69k|{
  273|  9.69k|    mp_assert(!mpctx->vo_chain);
  ------------------
  |  |   41|  9.69k|#define mp_assert assert
  ------------------
  |  Branch (273:5): [True: 9.69k, False: 0]
  ------------------
  274|       |
  275|  9.69k|    if (!mpctx->video_out) {
  ------------------
  |  Branch (275:9): [True: 9.61k, False: 78]
  ------------------
  276|  9.61k|        struct vo_extra ex = {
  277|  9.61k|            .input_ctx = mpctx->input,
  278|  9.61k|            .osd = mpctx->osd,
  279|  9.61k|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
  280|  9.61k|            .wakeup_cb = mp_wakeup_core_cb,
  281|  9.61k|            .wakeup_ctx = mpctx,
  282|  9.61k|        };
  283|  9.61k|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
  284|  9.61k|        if (!mpctx->video_out) {
  ------------------
  |  Branch (284:13): [True: 0, False: 9.61k]
  ------------------
  285|      0|            MP_FATAL(mpctx, "Error opening/initializing "
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|      0|                    "the selected video_out (--vo) device.\n");
  287|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
  288|      0|            goto err_out;
  289|      0|        }
  290|  9.61k|        mpctx->mouse_cursor_visible = true;
  291|  9.61k|    }
  292|       |
  293|  9.69k|    update_window_title(mpctx, true);
  294|       |
  295|  9.69k|    struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain);
  ------------------
  |  |   27|  9.69k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  9.69k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  9.69k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|  9.69k|    mpctx->vo_chain = vo_c;
  297|  9.69k|    vo_c->log = mpctx->log;
  298|  9.69k|    vo_c->vo = mpctx->video_out;
  299|  9.69k|    vo_c->filter =
  300|  9.69k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_VIDEO);
  301|  9.69k|    mp_output_chain_set_vo(vo_c->filter, vo_c->vo);
  302|  9.69k|    vo_c->filter->update_subtitles = filter_update_subtitles;
  303|  9.69k|    vo_c->filter->update_subtitles_ctx = mpctx;
  304|       |
  305|  9.69k|    if (track) {
  ------------------
  |  Branch (305:9): [True: 9.69k, False: 0]
  ------------------
  306|  9.69k|        vo_c->track = track;
  307|  9.69k|        track->vo_c = vo_c;
  308|  9.69k|        vo_c->is_coverart = !!track->attached_picture;
  309|  9.69k|        vo_c->is_sparse = track->stream->still_image || vo_c->is_coverart;
  ------------------
  |  Branch (309:27): [True: 0, False: 9.69k]
  |  Branch (309:57): [True: 0, False: 9.69k]
  ------------------
  310|  9.69k|        if (!vo_chain_init_decoder(mpctx, vo_c))
  ------------------
  |  Branch (310:13): [True: 2.02k, False: 7.67k]
  ------------------
  311|  2.02k|            goto err_out;
  312|  9.69k|    }
  313|       |
  314|  7.67k|    update_vo_chain_el_pair(mpctx);
  315|       |
  316|  7.67k|    if (!recreate_video_filters(mpctx))
  ------------------
  |  Branch (316:9): [True: 0, False: 7.67k]
  ------------------
  317|      0|        goto err_out;
  318|       |
  319|  7.67k|    update_content_type(mpctx, track);
  320|  7.67k|    update_screensaver_state(mpctx);
  321|       |
  322|  7.67k|    vo_set_paused(vo_c->vo, get_internal_paused(mpctx));
  323|       |
  324|  7.67k|    reset_video_state(mpctx);
  325|  7.67k|    term_osd_clear_subs(mpctx);
  326|       |
  327|  7.67k|    return;
  328|       |
  329|  2.02k|err_out:
  330|  2.02k|    uninit_video_chain(mpctx);
  331|  2.02k|    error_on_track(mpctx, track);
  332|       |    handle_force_window(mpctx, true);
  333|  2.02k|}
write_video:
 1109|   131k|{
 1110|   131k|    struct MPOpts *opts = mpctx->opts;
 1111|       |
 1112|   131k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (1112:9): [True: 60.5k, False: 70.8k]
  ------------------
 1113|  60.5k|        return;
 1114|  70.8k|    struct track *track = mpctx->vo_chain->track;
 1115|  70.8k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1116|  70.8k|    struct vo *vo = vo_c->vo;
 1117|       |
 1118|  70.8k|    if (vo_c->filter->reconfig_happened) {
  ------------------
  |  Branch (1118:9): [True: 1.78k, False: 69.1k]
  ------------------
 1119|  1.78k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1120|  1.78k|        vo_c->filter->reconfig_happened = false;
 1121|  1.78k|    }
 1122|       |
 1123|       |    // Actual playback starts when both audio and video are ready.
 1124|  70.8k|    if (mpctx->video_status == STATUS_READY)
  ------------------
  |  Branch (1124:9): [True: 0, False: 70.8k]
  ------------------
 1125|      0|        return;
 1126|       |
 1127|  70.8k|    if (mpctx->paused && mpctx->video_status >= STATUS_READY)
  ------------------
  |  Branch (1127:9): [True: 0, False: 70.8k]
  |  Branch (1127:26): [True: 0, False: 0]
  ------------------
 1128|      0|        return;
 1129|       |
 1130|       |    // Once the chain reached EOF nothing is read from it again.
 1131|  70.8k|    bool logical_eof = false;
 1132|  70.8k|    int r = VD_EOF;
 1133|  70.8k|    if (mpctx->video_status < STATUS_DRAINING)
  ------------------
  |  Branch (1133:9): [True: 68.7k, False: 2.11k]
  ------------------
 1134|  68.7k|        r = video_output_image(mpctx, &logical_eof);
 1135|  70.8k|    MP_TRACE(mpctx, "video_output_image: r=%d/eof=%d/st=%s\n", r, logical_eof,
  ------------------
  |  |   94|  70.8k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  70.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|  70.8k|             mp_status_str(mpctx->video_status));
 1137|       |
 1138|  70.8k|    if (r < 0)
  ------------------
  |  Branch (1138:9): [True: 0, False: 70.8k]
  ------------------
 1139|      0|        goto error;
 1140|       |
 1141|  70.8k|    if (r == VD_WAIT) {
  ------------------
  |  Branch (1141:9): [True: 17.0k, False: 53.8k]
  ------------------
 1142|       |        // Heuristic to detect underruns.
 1143|  17.0k|        if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo) &&
  ------------------
  |  Branch (1143:13): [True: 0, False: 17.0k]
  |  Branch (1143:54): [True: 0, False: 0]
  ------------------
 1144|      0|            !vo_c->underrun_signaled)
  ------------------
  |  Branch (1144:13): [True: 0, False: 0]
  ------------------
 1145|      0|        {
 1146|      0|            vo_c->underrun = true;
 1147|      0|            vo_c->underrun_signaled = true;
 1148|      0|        }
 1149|       |        // Demuxer will wake us up for more packets to decode.
 1150|  17.0k|        return;
 1151|  17.0k|    }
 1152|       |
 1153|  53.8k|    if (r == VD_EOF) {
  ------------------
  |  Branch (1153:9): [True: 9.72k, False: 44.1k]
  ------------------
 1154|  9.72k|        if (check_for_hwdec_fallback(mpctx))
  ------------------
  |  Branch (1154:13): [True: 0, False: 9.72k]
  ------------------
 1155|      0|            return;
 1156|  9.72k|        if (check_for_forced_eof(mpctx)) {
  ------------------
  |  Branch (1156:13): [True: 0, False: 9.72k]
  ------------------
 1157|      0|            uninit_video_chain(mpctx);
 1158|      0|            handle_force_window(mpctx, true);
 1159|      0|            return;
 1160|      0|        }
 1161|  9.72k|        if (vo_c->filter->failed_output_conversion)
  ------------------
  |  Branch (1161:13): [True: 0, False: 9.72k]
  ------------------
 1162|      0|            goto error;
 1163|       |
 1164|  9.72k|        mpctx->delay = 0;
 1165|  9.72k|        mpctx->last_av_difference = 0;
 1166|       |
 1167|  9.72k|        if (mpctx->video_status <= STATUS_PLAYING) {
  ------------------
  |  Branch (1167:13): [True: 7.61k, False: 2.11k]
  ------------------
 1168|  7.61k|            mpctx->video_status = STATUS_DRAINING;
 1169|  7.61k|            get_relative_time(mpctx);
 1170|  7.61k|            if (vo_c->is_sparse && !mpctx->ao_chain) {
  ------------------
  |  Branch (1170:17): [True: 0, False: 7.61k]
  |  Branch (1170:36): [True: 0, False: 0]
  ------------------
 1171|      0|                MP_VERBOSE(mpctx, "assuming this is an image\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1172|      0|                mpctx->time_frame += opts->image_display_duration / opts->playback_speed;
 1173|  7.61k|            } else if (mpctx->last_frame_duration > 0 && !opts->untimed &&
  ------------------
  |  Branch (1173:24): [True: 734, False: 6.87k]
  |  Branch (1173:58): [True: 0, False: 734]
  ------------------
 1174|      0|                       !(vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1174:24): [True: 0, False: 0]
  ------------------
 1175|      0|            {
 1176|      0|                MP_VERBOSE(mpctx, "using demuxer frame duration for last frame\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1177|      0|                mpctx->time_frame += mpctx->last_frame_duration;
 1178|  7.61k|            } else {
 1179|  7.61k|                mpctx->time_frame = 0;
 1180|  7.61k|            }
 1181|       |            // Encode mode can't honor this; it'll only delay finishing.
 1182|  7.61k|            if (mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (1182:17): [True: 0, False: 7.61k]
  ------------------
 1183|      0|                mpctx->time_frame = 0;
 1184|  7.61k|        }
 1185|       |
 1186|       |        // Wait for the VO to signal actual EOF, then exit if the frame timer
 1187|       |        // has expired.
 1188|  9.72k|        bool has_frame = vo_has_frame(vo); // maybe not configured
 1189|  9.72k|        if (mpctx->video_status == STATUS_DRAINING &&
  ------------------
  |  Branch (1189:13): [True: 7.61k, False: 2.10k]
  ------------------
 1190|  7.61k|            (vo_is_ready_for_frame(vo, -1) || !has_frame))
  ------------------
  |  Branch (1190:14): [True: 943, False: 6.67k]
  |  Branch (1190:47): [True: 6.67k, False: 2]
  ------------------
 1191|  7.61k|        {
 1192|  7.61k|            mpctx->time_frame -= get_relative_time(mpctx);
 1193|  7.61k|            mp_set_timeout(mpctx, mpctx->time_frame);
 1194|  7.61k|            if (mpctx->time_frame <= 0 || !has_frame) {
  ------------------
  |  Branch (1194:17): [True: 7.61k, False: 0]
  |  Branch (1194:43): [True: 0, False: 0]
  ------------------
 1195|  7.61k|                MP_VERBOSE(mpctx, "video EOF reached\n");
  ------------------
  |  |   92|  7.61k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.61k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1196|  7.61k|                mpctx->video_status = STATUS_EOF;
 1197|  7.61k|            }
 1198|  7.61k|        }
 1199|       |
 1200|       |        // Avoid pointlessly spamming the logs every frame.
 1201|  9.72k|        if (!vo_c->is_sparse || !vo_c->sparse_eof_signalled) {
  ------------------
  |  Branch (1201:13): [True: 9.72k, False: 0]
  |  Branch (1201:33): [True: 0, False: 0]
  ------------------
 1202|  9.72k|            MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status);
  ------------------
  |  |   93|  9.72k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.72k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1203|  9.72k|            vo_c->sparse_eof_signalled = vo_c->is_sparse;
 1204|  9.72k|        }
 1205|  9.72k|        return;
 1206|  9.72k|    }
 1207|       |
 1208|  44.1k|    if (r != VD_NEW_FRAME) {
  ------------------
  |  Branch (1208:9): [True: 0, False: 44.1k]
  ------------------
 1209|      0|        mp_wakeup_core(mpctx); // Decode more in next iteration.
 1210|      0|        return;
 1211|      0|    }
 1212|       |
 1213|       |    // A sparse still-image stream may have no frame at the seek target.
 1214|       |    // Complete the restart without showing it.
 1215|  44.1k|    if (vo_c->is_sparse && mpctx->video_status < STATUS_READY) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 44.1k]
  |  Branch (1215:28): [True: 0, False: 0]
  ------------------
 1216|      0|        double ref = mpctx->playback_pts != MP_NOPTS_VALUE
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1216:22): [True: 0, False: 0]
  ------------------
 1217|      0|                        ? mpctx->playback_pts : mpctx->last_seek_pts;
 1218|      0|        if (ref != MP_NOPTS_VALUE && mpctx->next_frames[0]->pts > ref + 1.0) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1218:13): [True: 0, False: 0]
  |  Branch (1218:38): [True: 0, False: 0]
  ------------------
 1219|      0|            MP_VERBOSE(mpctx, "sparse video: frame %f is ahead of %f, not "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1220|      0|                       "showing it for the restart\n",
 1221|      0|                       mpctx->next_frames[0]->pts, ref);
 1222|      0|            mpctx->video_status = STATUS_READY;
 1223|      0|            return;
 1224|      0|        }
 1225|      0|    }
 1226|       |
 1227|  44.1k|    if (logical_eof && !mpctx->num_past_frames && mpctx->num_next_frames == 1 &&
  ------------------
  |  Branch (1227:9): [True: 0, False: 44.1k]
  |  Branch (1227:24): [True: 0, False: 0]
  |  Branch (1227:51): [True: 0, False: 0]
  ------------------
 1228|      0|        use_video_lookahead(mpctx) && !vo_c->is_sparse)
  ------------------
  |  Branch (1228:9): [True: 0, False: 0]
  |  Branch (1228:39): [True: 0, False: 0]
  ------------------
 1229|      0|    {
 1230|       |        // Too much danger to accidentally mark video as sparse when e.g.
 1231|       |        // seeking exactly to the last frame, so as a heuristic, do this only
 1232|       |        // if it looks like the "first" video frame (unreliable, but often
 1233|       |        // works out well). Helps with seeking with single-image video tracks,
 1234|       |        // as well as detecting whether as video track is really an image.
 1235|      0|        if (mpctx->next_frames[0]->pts == 0) {
  ------------------
  |  Branch (1235:13): [True: 0, False: 0]
  ------------------
 1236|      0|            MP_VERBOSE(mpctx, "assuming single-image video stream\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1237|      0|            vo_c->is_sparse = true;
 1238|      0|        }
 1239|      0|    }
 1240|       |
 1241|       |    // Inject vo crop to notify and reconfig if needed
 1242|  44.1k|    apply_video_crop(mpctx, vo);
 1243|       |
 1244|       |    // Filter output is different from VO input?
 1245|  44.1k|    struct mp_image_params *p = &mpctx->next_frames[0]->params;
 1246|  44.1k|    if (!vo->params || !mp_image_params_static_equal(p, vo->params)) {
  ------------------
  |  Branch (1246:9): [True: 1.00k, False: 43.1k]
  |  Branch (1246:24): [True: 839, False: 42.3k]
  ------------------
 1247|       |        // Changing config deletes the current frame; wait until it's finished.
 1248|  1.84k|        if (vo_still_displaying(vo)) {
  ------------------
  |  Branch (1248:13): [True: 0, False: 1.84k]
  ------------------
 1249|      0|            vo_request_wakeup_on_done(vo);
 1250|      0|            return;
 1251|      0|        }
 1252|       |
 1253|  1.84k|        const struct vo_driver *info = mpctx->video_out->driver;
 1254|  1.84k|        char extra[20] = {0};
 1255|  1.84k|        if (p->p_w != p->p_h) {
  ------------------
  |  Branch (1255:13): [True: 46, False: 1.79k]
  ------------------
 1256|     46|            int d_w, d_h;
 1257|     46|            mp_image_params_get_dsize(p, &d_w, &d_h);
 1258|     46|            snprintf(extra, sizeof(extra), " => %dx%d", d_w, d_h);
 1259|     46|        }
 1260|  1.84k|        char sfmt[20] = {0};
 1261|  1.84k|        if (p->hw_subfmt)
  ------------------
  |  Branch (1261:13): [True: 0, False: 1.84k]
  ------------------
 1262|      0|            snprintf(sfmt, sizeof(sfmt), "[%s]", mp_imgfmt_to_name(p->hw_subfmt));
  ------------------
  |  |  333|      0|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
 1263|  1.84k|        MP_INFO(mpctx, "VO: [%s] %dx%d%s %s%s\n",
  ------------------
  |  |   91|  1.84k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.84k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1264|  1.84k|                info->name, p->w, p->h, extra, mp_imgfmt_to_name(p->imgfmt), sfmt);
 1265|  1.84k|        MP_VERBOSE(mpctx, "VO: Description: %s\n", info->description);
  ------------------
  |  |   92|  1.84k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.84k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1266|       |
 1267|  1.84k|        int vo_r = vo_reconfig2(vo, mpctx->next_frames[0]);
 1268|  1.84k|        if (vo_r < 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 1.84k]
  ------------------
 1269|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
 1270|      0|            goto error;
 1271|      0|        }
 1272|  1.84k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1273|  42.3k|    } else {
 1274|       |        // Update parameters that don't require reconfiguring the VO.
 1275|  42.3k|        mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|  42.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1276|  42.3k|        mp_image_params_update_dynamic(vo->params, p, vo->has_peak_detect_values);
 1277|  42.3k|        mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|  42.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1278|  42.3k|    }
 1279|       |
 1280|  44.1k|    mpctx->time_frame -= get_relative_time(mpctx);
 1281|  44.1k|    update_avsync_before_frame(mpctx);
 1282|       |
 1283|       |    // Enforce timing subtitles to video frames.
 1284|  44.1k|    osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  44.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1285|       |
 1286|  44.1k|    if (!update_subtitles(mpctx, mpctx->next_frames[0]->pts)) {
  ------------------
  |  Branch (1286:9): [True: 0, False: 44.1k]
  ------------------
 1287|      0|        MP_VERBOSE(mpctx, "Video frame delayed due to waiting on subtitles.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1288|      0|        return;
 1289|      0|    }
 1290|       |
 1291|  44.1k|    double time_frame = MPMAX(mpctx->time_frame, -1);
  ------------------
  |  |   44|  44.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 44.1k, False: 0]
  |  |  ------------------
  ------------------
 1292|  44.1k|    int64_t pts = mp_time_ns() + (int64_t)(time_frame * 1e9);
 1293|       |
 1294|       |    // wait until VO wakes us up to get more frames
 1295|       |    // (NB: in theory, the 1st frame after display sync mode change uses the
 1296|       |    //      wrong waiting mode)
 1297|  44.1k|    if (!vo_is_ready_for_frame(vo, mpctx->display_sync_active ? -1 : pts))
  ------------------
  |  Branch (1297:9): [True: 387, False: 43.7k]
  |  Branch (1297:36): [True: 0, False: 44.1k]
  ------------------
 1298|    387|        return;
 1299|       |
 1300|       |    // In encoding mode, wait for the ao to finish initializing.
 1301|  43.7k|    if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_AUDIO] && !mpctx->ao)
  ------------------
  |  Branch (1301:9): [True: 0, False: 43.7k]
  |  Branch (1301:35): [True: 0, False: 0]
  |  Branch (1301:76): [True: 0, False: 0]
  ------------------
 1302|      0|        return;
 1303|       |
 1304|  43.7k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (1304:5): [True: 43.7k, False: 0]
  ------------------
 1305|       |
 1306|  43.7k|    if (mpctx->num_past_frames >= MAX_NUM_VO_PTS)
  ------------------
  |  Branch (1306:9): [True: 16.4k, False: 27.3k]
  ------------------
 1307|  16.4k|        mpctx->num_past_frames--;
 1308|  43.7k|    MP_TARRAY_INSERT_AT(mpctx, mpctx->past_frames, mpctx->num_past_frames, 0,
  ------------------
  |  |  115|  43.7k|    do {                                            \
  |  |  116|  43.7k|        size_t at_ = (at);                          \
  |  |  117|  43.7k|        assert(at_ <= (idxvar));                    \
  |  |  118|  43.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  43.7k|    do {                                            \
  |  |  |  |   97|  43.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  43.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  43.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  43.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 2.78k, False: 40.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  43.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  2.78k|    do {                                                        \
  |  |  |  |  |  |   89|  2.78k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  2.78k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  2.78k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  2.78k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.78k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  2.78k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  2.78k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 2.78k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  43.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 43.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  43.7k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  43.7k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  43.7k|        (idxvar)++;                                 \
  |  |  122|  43.7k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  43.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 43.7k]
  |  |  ------------------
  ------------------
  |  Branch (1308:5): [True: 43.7k, False: 0]
  ------------------
 1309|  43.7k|                        (struct frame_info){0});
 1310|  43.7k|    mpctx->past_frames[0] = (struct frame_info){
 1311|  43.7k|        .pts = mpctx->next_frames[0]->pts,
 1312|  43.7k|        .num_vsyncs = -1,
 1313|  43.7k|    };
 1314|  43.7k|    calculate_frame_duration(mpctx);
 1315|       |
 1316|  43.7k|    int req = vo_get_num_req_frames(mpctx->video_out);
 1317|  43.7k|    mp_assert(req >= 1 && req <= VO_MAX_REQ_FRAMES);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 43.7k, False: 0]
  |  Branch (1317:5): [True: 43.7k, False: 0]
  ------------------
 1318|  43.7k|    struct vo_frame dummy = {
 1319|  43.7k|        .pts = pts,
 1320|  43.7k|        .duration = -1,
 1321|  43.7k|        .still = mpctx->step_frames > 0,
 1322|  43.7k|        .can_drop = opts->frame_dropping & 1,
 1323|  43.7k|        .num_frames = MPMIN(mpctx->num_next_frames, req),
  ------------------
  |  |   45|  43.7k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 43.7k]
  |  |  ------------------
  ------------------
 1324|  43.7k|        .num_vsyncs = 1,
 1325|  43.7k|    };
 1326|  87.5k|    for (int n = 0; n < dummy.num_frames; n++)
  ------------------
  |  Branch (1326:21): [True: 43.7k, False: 43.7k]
  ------------------
 1327|  43.7k|        dummy.frames[n] = mpctx->next_frames[n];
 1328|  43.7k|    struct vo_frame *frame = vo_frame_ref(&dummy);
 1329|       |
 1330|  43.7k|    double diff = mpctx->past_frames[0].approx_duration;
 1331|  43.7k|    if (opts->untimed || (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1331:9): [True: 43.7k, False: 0]
  |  Branch (1331:26): [True: 0, False: 0]
  ------------------
 1332|  43.7k|        diff = -1; // disable frame dropping and aspects of frame timing
 1333|  43.7k|    if (diff >= 0) {
  ------------------
  |  Branch (1333:9): [True: 0, False: 43.7k]
  ------------------
 1334|      0|        diff /= mpctx->video_speed;
 1335|      0|        frame->duration = MP_TIME_S_TO_NS(MPCLAMP(diff, 0, 10));
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 0, False: 0]
  |  |  |  Branch (71:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1336|      0|    }
 1337|       |
 1338|  43.7k|    mpctx->video_pts = mpctx->next_frames[0]->pts;
 1339|  43.7k|    mpctx->video_pts_unrounded = mpctx->next_pts_unrounded;
 1340|  43.7k|    mpctx->last_frame_duration =
 1341|  43.7k|        mpctx->next_frames[0]->pkt_duration / mpctx->video_speed;
 1342|       |
 1343|  43.7k|    shift_frames(mpctx);
 1344|       |
 1345|  43.7k|    schedule_frame(mpctx, frame);
 1346|       |
 1347|  43.7k|    mpctx->osd_force_update = true;
 1348|  43.7k|    update_osd_msg(mpctx);
 1349|       |
 1350|  43.7k|    vo_queue_frame(vo, frame);
 1351|       |
 1352|  43.7k|    check_framedrop(mpctx, vo_c);
 1353|       |
 1354|       |    // The frames were shifted down; "initialize" the new first entry.
 1355|  43.7k|    if (mpctx->num_next_frames >= 1)
  ------------------
  |  Branch (1355:9): [True: 0, False: 43.7k]
  ------------------
 1356|      0|        handle_new_frame(mpctx);
 1357|       |
 1358|  43.7k|    mpctx->shown_vframes++;
 1359|  43.7k|    if (mpctx->video_status < STATUS_PLAYING) {
  ------------------
  |  Branch (1359:9): [True: 1.00k, False: 42.7k]
  ------------------
 1360|  1.00k|        mpctx->video_status = STATUS_READY;
 1361|       |        // After a seek, make sure to wait until the first frame is visible.
 1362|  1.00k|        if (!opts->video_latency_hacks) {
  ------------------
  |  Branch (1362:13): [True: 1.00k, False: 0]
  ------------------
 1363|  1.00k|            vo_wait_frame(vo);
 1364|  1.00k|            MP_VERBOSE(mpctx, "first video frame after restart shown\n");
  ------------------
  |  |   92|  1.00k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.00k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1365|  1.00k|        }
 1366|  1.00k|    }
 1367|       |
 1368|  43.7k|    mp_notify(mpctx, MPV_EVENT_TICK, NULL);
 1369|       |
 1370|       |    // hr-seek past EOF -> returns last frame, but terminates playback. The
 1371|       |    // early EOF is needed to trigger the exit before the next seek is executed.
 1372|       |    // Always using early EOF breaks other cases, like images.
 1373|  43.7k|    if (logical_eof && !mpctx->num_next_frames && mpctx->ao_chain)
  ------------------
  |  Branch (1373:9): [True: 0, False: 43.7k]
  |  Branch (1373:24): [True: 0, False: 0]
  |  Branch (1373:51): [True: 0, False: 0]
  ------------------
 1374|      0|        mpctx->video_status = STATUS_EOF;
 1375|       |
 1376|  43.7k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (1376:9): [True: 43.7k, False: 0]
  ------------------
 1377|  43.7k|        if (mpctx->step_frames > 0) {
  ------------------
  |  Branch (1377:13): [True: 0, False: 43.7k]
  ------------------
 1378|      0|            mpctx->step_frames--;
 1379|      0|            if (!mpctx->step_frames) {
  ------------------
  |  Branch (1379:17): [True: 0, False: 0]
  ------------------
 1380|      0|                set_pause_state(mpctx, true);
 1381|      0|                step_frame_mute(mpctx, false);
 1382|      0|            }
 1383|      0|        }
 1384|  43.7k|        if (mpctx->max_frames == 0 && !mpctx->stop_play)
  ------------------
  |  Branch (1384:13): [True: 0, False: 43.7k]
  |  Branch (1384:39): [True: 0, False: 0]
  ------------------
 1385|      0|            mpctx->stop_play = AT_END_OF_FILE;
 1386|  43.7k|        if (mpctx->max_frames > 0)
  ------------------
  |  Branch (1386:13): [True: 0, False: 43.7k]
  ------------------
 1387|      0|            mpctx->max_frames--;
 1388|  43.7k|    }
 1389|       |
 1390|  43.7k|    vo_c->underrun_signaled = false;
 1391|       |
 1392|  43.7k|    if (mpctx->video_status == STATUS_EOF || mpctx->stop_play)
  ------------------
  |  Branch (1392:9): [True: 0, False: 43.7k]
  |  Branch (1392:46): [True: 0, False: 43.7k]
  ------------------
 1393|      0|        mp_wakeup_core(mpctx);
 1394|  43.7k|    return;
 1395|       |
 1396|      0|error:
 1397|      0|    MP_FATAL(mpctx, "Could not initialize video chain.\n");
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1398|      0|    uninit_video_chain(mpctx);
 1399|      0|    error_on_track(mpctx, track);
 1400|       |    handle_force_window(mpctx, true);
 1401|      0|    mp_wakeup_core(mpctx);
 1402|      0|}
video.c:recreate_video_filters:
   67|  7.67k|{
   68|  7.67k|    struct MPOpts *opts = mpctx->opts;
   69|  7.67k|    struct vo_chain *vo_c = mpctx->vo_chain;
   70|  7.67k|    mp_assert(vo_c);
  ------------------
  |  |   41|  7.67k|#define mp_assert assert
  ------------------
  |  Branch (70:5): [True: 7.67k, False: 0]
  ------------------
   71|       |
   72|  7.67k|    return mp_output_chain_update_filters(vo_c->filter, opts->vf_settings);
   73|  7.67k|}
video.c:vo_chain_reset_state:
   93|  17.3k|{
   94|  17.3k|    vo_seek_reset(vo_c->vo);
   95|  17.3k|    vo_c->underrun = false;
   96|       |    vo_c->underrun_signaled = false;
   97|  17.3k|}
video.c:vo_chain_uninit:
  141|  9.69k|{
  142|  9.69k|    struct track *track = vo_c->track;
  143|  9.69k|    if (track) {
  ------------------
  |  Branch (143:9): [True: 9.69k, False: 0]
  ------------------
  144|  9.69k|        mp_assert(track->vo_c == vo_c);
  ------------------
  |  |   41|  9.69k|#define mp_assert assert
  ------------------
  |  Branch (144:9): [True: 9.69k, False: 0]
  ------------------
  145|  9.69k|        track->vo_c = NULL;
  146|  9.69k|        if (vo_c->dec_src)
  ------------------
  |  Branch (146:13): [True: 7.67k, False: 2.02k]
  ------------------
  147|  9.69k|            mp_assert(track->dec->f->pins[0] == vo_c->dec_src);
  ------------------
  |  |   41|  9.69k|#define mp_assert assert
  ------------------
  |  Branch (147:13): [True: 7.67k, False: 0]
  ------------------
  148|       |        // This is NULL if a sh_stream_group's filter fails.
  149|  9.69k|        if (track->dec) {
  ------------------
  |  Branch (149:13): [True: 9.69k, False: 0]
  ------------------
  150|  9.69k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  9.69k|#define talloc_free                     ta_free
  ------------------
  151|  9.69k|            track->dec = NULL;
  152|  9.69k|        }
  153|  9.69k|    }
  154|       |
  155|  9.69k|    if (vo_c->filter_src)
  ------------------
  |  Branch (155:9): [True: 0, False: 9.69k]
  ------------------
  156|      0|        mp_pin_disconnect(vo_c->filter_src);
  157|       |
  158|  9.69k|    talloc_free(vo_c->filter->f);
  ------------------
  |  |   47|  9.69k|#define talloc_free                     ta_free
  ------------------
  159|  9.69k|    talloc_free(vo_c);
  ------------------
  |  |   47|  9.69k|#define talloc_free                     ta_free
  ------------------
  160|       |    // this does not free the VO
  161|  9.69k|}
video.c:vo_chain_init_decoder:
  232|  9.69k|{
  233|  9.69k|    struct track *track = vo_c->track;
  234|  9.69k|    if (!init_video_decoder(mpctx, track))
  ------------------
  |  Branch (234:9): [True: 2.02k, False: 7.67k]
  ------------------
  235|  2.02k|        return false;
  236|  7.67k|    vo_c->dec_src = track->dec->f->pins[0];
  237|  7.67k|    vo_c->filter->container_fps =
  238|  7.67k|        mp_decoder_wrapper_get_container_fps(track->dec);
  239|  7.67k|    if (vo_c->is_coverart)
  ------------------
  |  Branch (239:9): [True: 0, False: 7.67k]
  ------------------
  240|      0|        mp_decoder_wrapper_set_coverart_flag(track->dec, true);
  241|  7.67k|    mp_pin_connect(vo_c->filter->f->pins[0], vo_c->dec_src);
  242|       |    return true;
  243|  9.69k|}
video.c:filter_update_subtitles:
  223|  43.7k|{
  224|  43.7k|    struct MPContext *mpctx = ctx;
  225|       |
  226|  43.7k|    if (osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  Branch (226:9): [True: 0, False: 43.7k]
  ------------------
  227|      0|        update_subtitles(mpctx, pts);
  228|  43.7k|}
video.c:video_output_image:
  520|  68.7k|{
  521|  68.7k|    struct vo_chain *vo_c = mpctx->vo_chain;
  522|  68.7k|    bool hrseek = false;
  523|  68.7k|    double hrseek_pts = mpctx->hrseek_pts;
  524|  68.7k|    double tolerance = mpctx->hrseek_backstep ? 0 : .005;
  ------------------
  |  Branch (524:24): [True: 0, False: 68.7k]
  ------------------
  525|  68.7k|    if (mpctx->video_status == STATUS_SYNCING) {
  ------------------
  |  Branch (525:9): [True: 24.6k, False: 44.0k]
  ------------------
  526|  24.6k|        hrseek = mpctx->hrseek_active;
  527|       |        // playback_pts is normally only set when audio and video have started
  528|       |        // playing normally. If video is in syncing mode, then this must mean
  529|       |        // video was just enabled via track switching - skip to current time.
  530|  24.6k|        if (!hrseek && mpctx->playback_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  24.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (530:13): [True: 24.6k, False: 0]
  |  Branch (530:24): [True: 0, False: 24.6k]
  ------------------
  531|      0|            hrseek = true;
  532|      0|            hrseek_pts = mpctx->playback_pts;
  533|      0|        }
  534|  24.6k|    }
  535|       |
  536|  68.7k|    if (vo_c->is_coverart) {
  ------------------
  |  Branch (536:9): [True: 0, False: 68.7k]
  ------------------
  537|      0|        *logical_eof = true;
  538|      0|        if (vo_has_frame(mpctx->video_out))
  ------------------
  |  Branch (538:13): [True: 0, False: 0]
  ------------------
  539|      0|            return VD_EOF;
  540|      0|    }
  541|       |
  542|       |    // Sparse streams usually have no frame at the seek target, or rather we
  543|       |    // don't want to jump to next keyframe, when there is a lot of other stream
  544|       |    // data in between.
  545|  68.7k|    if (vo_c->is_sparse)
  ------------------
  |  Branch (545:9): [True: 0, False: 68.7k]
  ------------------
  546|      0|        hrseek = false;
  547|       |
  548|  68.7k|    if (have_new_frame(mpctx, false))
  ------------------
  |  Branch (548:9): [True: 387, False: 68.3k]
  ------------------
  549|    387|        return VD_NEW_FRAME;
  550|       |
  551|       |    // Get a new frame if we need one.
  552|  68.3k|    int r = VD_PROGRESS;
  553|  68.3k|    if (needs_new_frame(mpctx)) {
  ------------------
  |  Branch (553:9): [True: 68.3k, False: 0]
  ------------------
  554|       |        // Filter a new frame.
  555|  68.3k|        struct mp_image *img = NULL;
  556|  68.3k|        struct mp_frame frame = mp_pin_out_read(vo_c->filter->f->pins[1]);
  557|  68.3k|        if (frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (557:13): [True: 17.0k, False: 51.3k]
  ------------------
  558|  17.0k|            r = vo_c->filter->got_output_eof ? VD_EOF : VD_WAIT;
  ------------------
  |  Branch (558:17): [True: 0, False: 17.0k]
  ------------------
  559|  51.3k|        } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (559:20): [True: 7.61k, False: 43.7k]
  ------------------
  560|  7.61k|            r = VD_EOF;
  561|  43.7k|        } else if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (561:20): [True: 43.7k, False: 0]
  ------------------
  562|  43.7k|            img = frame.data;
  563|  43.7k|        } else {
  564|      0|            MP_ERR(mpctx, "unexpected frame type %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  565|      0|                   mp_frame_type_str(frame.type));
  566|      0|            mp_frame_unref(&frame);
  567|      0|            return VD_ERROR;
  568|      0|        }
  569|  68.3k|        if (img) {
  ------------------
  |  Branch (569:13): [True: 43.7k, False: 24.6k]
  ------------------
  570|  43.7k|            double endpts = get_play_end_pts(mpctx);
  571|  43.7k|            if (endpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (571:17): [True: 0, False: 43.7k]
  ------------------
  572|      0|                endpts *= mpctx->play_dir;
  573|  43.7k|            if ((endpts != MP_NOPTS_VALUE && img->pts >= endpts) ||
  ------------------
  |  |   39|  87.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (573:18): [True: 0, False: 43.7k]
  |  Branch (573:46): [True: 0, False: 0]
  ------------------
  574|  43.7k|                mpctx->max_frames == 0)
  ------------------
  |  Branch (574:17): [True: 0, False: 43.7k]
  ------------------
  575|      0|            {
  576|      0|                mp_pin_out_unread(vo_c->filter->f->pins[1], frame);
  577|      0|                img = NULL;
  578|      0|                r = VD_EOF;
  579|  43.7k|            } else if (hrseek && (img->pts < hrseek_pts - tolerance ||
  ------------------
  |  Branch (579:24): [True: 0, False: 43.7k]
  |  Branch (579:35): [True: 0, False: 0]
  ------------------
  580|      0|                                  mpctx->hrseek_lastframe))
  ------------------
  |  Branch (580:35): [True: 0, False: 0]
  ------------------
  581|      0|            {
  582|       |                /* just skip - but save in case it was the last frame */
  583|      0|                mp_image_setrefp(&mpctx->saved_frame, img);
  584|  43.7k|            } else {
  585|  43.7k|                if (hrseek && mpctx->hrseek_backstep) {
  ------------------
  |  Branch (585:21): [True: 0, False: 43.7k]
  |  Branch (585:31): [True: 0, False: 0]
  ------------------
  586|      0|                    if (mpctx->saved_frame) {
  ------------------
  |  Branch (586:25): [True: 0, False: 0]
  ------------------
  587|      0|                        add_new_frame(mpctx, mpctx->saved_frame);
  588|      0|                        mpctx->saved_frame = NULL;
  589|      0|                    } else {
  590|      0|                        MP_WARN(mpctx, "Backstep failed.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  591|      0|                    }
  592|      0|                    mpctx->hrseek_backstep = false;
  593|      0|                }
  594|  43.7k|                mp_image_unrefp(&mpctx->saved_frame);
  595|  43.7k|                add_new_frame(mpctx, img);
  596|  43.7k|                img = NULL;
  597|  43.7k|            }
  598|  43.7k|            talloc_free(img);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
  599|  43.7k|        }
  600|  68.3k|    }
  601|       |
  602|  68.3k|    if (!hrseek)
  ------------------
  |  Branch (602:9): [True: 68.3k, False: 0]
  ------------------
  603|  68.3k|        mp_image_unrefp(&mpctx->saved_frame);
  604|       |
  605|  68.3k|    if (r == VD_EOF) {
  ------------------
  |  Branch (605:9): [True: 7.61k, False: 60.7k]
  ------------------
  606|       |        // If hr-seek went past EOF, use the last frame.
  607|  7.61k|        if (mpctx->saved_frame)
  ------------------
  |  Branch (607:13): [True: 0, False: 7.61k]
  ------------------
  608|      0|            add_new_frame(mpctx, mpctx->saved_frame);
  609|  7.61k|        mpctx->saved_frame = NULL;
  610|  7.61k|        *logical_eof = true;
  611|  7.61k|    }
  612|       |
  613|  68.3k|    return have_new_frame(mpctx, r <= 0) ? VD_NEW_FRAME : r;
  ------------------
  |  Branch (613:12): [True: 43.7k, False: 24.6k]
  ------------------
  614|  68.3k|}
video.c:have_new_frame:
  512|   137k|{
  513|   137k|    return mpctx->num_next_frames >= get_req_frames(mpctx, eof);
  514|   137k|}
video.c:get_req_frames:
  471|   205k|{
  472|       |    // On EOF, drain all frames.
  473|   205k|    if (eof)
  ------------------
  |  Branch (473:9): [True: 7.61k, False: 197k]
  ------------------
  474|  7.61k|        return 1;
  475|       |
  476|   197k|    if (!use_video_lookahead(mpctx))
  ------------------
  |  Branch (476:9): [True: 197k, False: 0]
  ------------------
  477|   197k|        return 1;
  478|       |
  479|      0|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (479:9): [True: 0, False: 0]
  |  Branch (479:28): [True: 0, False: 0]
  ------------------
  480|      0|        return 1;
  481|       |
  482|       |    // Normally require at least 2 frames, so we can compute a frame duration.
  483|      0|    int min = 2;
  484|       |
  485|       |    // On the first frame, output a new frame as quickly as possible.
  486|      0|    if (mpctx->video_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (486:9): [True: 0, False: 0]
  ------------------
  487|      0|        return min;
  488|       |
  489|      0|    int req = vo_get_num_req_frames(mpctx->video_out);
  490|      0|    return MPCLAMP(req, min, MP_ARRAY_SIZE(mpctx->next_frames) - 1);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  491|      0|}
video.c:needs_new_frame:
  495|  68.3k|{
  496|       |    return mpctx->num_next_frames < get_req_frames(mpctx, false);
  497|  68.3k|}
video.c:add_new_frame:
  501|  43.7k|{
  502|  43.7k|    mp_assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames));
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (502:5): [True: 43.7k, False: 0]
  ------------------
  503|  43.7k|    mp_assert(frame);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (503:5): [True: 43.7k, False: 0]
  ------------------
  504|  43.7k|    mpctx->next_frames[mpctx->num_next_frames++] = frame;
  505|  43.7k|    if (mpctx->num_next_frames == 1)
  ------------------
  |  Branch (505:9): [True: 43.7k, False: 0]
  ------------------
  506|  43.7k|        handle_new_frame(mpctx);
  507|  43.7k|}
video.c:check_for_hwdec_fallback:
  617|  9.72k|{
  618|  9.72k|    struct vo_chain *vo_c = mpctx->vo_chain;
  619|       |
  620|  9.72k|    if (!vo_c->filter->failed_output_conversion || !vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (620:9): [True: 9.72k, False: 0]
  |  Branch (620:52): [True: 0, False: 0]
  |  Branch (620:68): [True: 0, False: 0]
  ------------------
  621|  9.72k|        return false;
  622|       |
  623|      0|    if (mp_decoder_wrapper_control(vo_c->track->dec,
  ------------------
  |  Branch (623:9): [True: 0, False: 0]
  ------------------
  624|      0|                            VDCTRL_FORCE_HWDEC_FALLBACK, NULL) != CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  625|      0|        return false;
  626|       |
  627|      0|    mp_output_chain_reset_harder(vo_c->filter);
  628|       |    return true;
  629|      0|}
video.c:check_for_forced_eof:
  632|  9.72k|{
  633|  9.72k|    struct vo_chain *vo_c = mpctx->vo_chain;
  634|       |
  635|  9.72k|    if (!vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (635:9): [True: 0, False: 9.72k]
  |  Branch (635:25): [True: 0, False: 9.72k]
  ------------------
  636|      0|        return false;
  637|       |
  638|  9.72k|    struct mp_decoder_wrapper *dec = vo_c->track->dec;
  639|  9.72k|    bool forced_eof = false;
  640|       |
  641|  9.72k|    mp_decoder_wrapper_control(dec, VDCTRL_CHECK_FORCED_EOF, &forced_eof);
  642|  9.72k|    return forced_eof;
  643|  9.72k|}
video.c:use_video_lookahead:
  463|   197k|{
  464|   197k|    return mpctx->video_out &&
  ------------------
  |  Branch (464:12): [True: 197k, False: 0]
  ------------------
  465|   197k|           !(mpctx->video_out->driver->caps & VO_CAP_NORETAIN) &&
  ------------------
  |  Branch (465:12): [True: 197k, False: 0]
  ------------------
  466|   197k|           !(mpctx->opts->untimed || (mpctx->video_out->driver->caps & VO_CAP_UNTIMED)) &&
  ------------------
  |  Branch (466:14): [True: 197k, False: 0]
  |  Branch (466:38): [True: 0, False: 0]
  ------------------
  467|      0|           !mpctx->opts->video_latency_hacks;
  ------------------
  |  Branch (467:12): [True: 0, False: 0]
  ------------------
  468|   197k|}
video.c:apply_video_crop:
 1083|  44.1k|{
 1084|  88.2k|    for (int n = 0; n < mpctx->num_next_frames; n++) {
  ------------------
  |  Branch (1084:21): [True: 44.1k, False: 44.1k]
  ------------------
 1085|  44.1k|        struct m_geometry *gm = &vo->opts->video_crop;
 1086|  44.1k|        struct mp_image_params p = mpctx->next_frames[n]->params;
 1087|  44.1k|        if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
  ------------------
  |  Branch (1087:13): [True: 0, False: 44.1k]
  |  Branch (1087:30): [True: 0, False: 44.1k]
  |  Branch (1087:47): [True: 0, False: 0]
  |  Branch (1087:60): [True: 0, False: 0]
  ------------------
 1088|      0|        {
 1089|      0|            m_rect_apply(&p.crop, p.w, p.h, gm);
 1090|      0|        }
 1091|       |
 1092|  44.1k|        if (p.crop.x1 == 0 && p.crop.y1 == 0)
  ------------------
  |  Branch (1092:13): [True: 0, False: 44.1k]
  |  Branch (1092:31): [True: 0, False: 0]
  ------------------
 1093|      0|            return;
 1094|       |
 1095|  44.1k|        if (!mp_image_crop_valid(&p)) {
  ------------------
  |  Branch (1095:13): [True: 0, False: 44.1k]
  ------------------
 1096|      0|            char *str = m_option_type_rect.print(NULL, gm);
 1097|      0|            MP_WARN(vo, "Ignoring invalid --video-crop=%s for %dx%d image\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1098|      0|                    str, p.w, p.h);
 1099|      0|            talloc_free(str);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1100|      0|            *gm = (struct m_geometry){0};
 1101|      0|            mp_property_do("video-crop", M_PROPERTY_SET, gm, mpctx);
 1102|      0|            return;
 1103|      0|        }
 1104|  44.1k|        mpctx->next_frames[n]->params.crop = p.crop;
 1105|  44.1k|    }
 1106|  44.1k|}
video.c:update_avsync_before_frame:
  649|  44.1k|{
  650|  44.1k|    struct MPOpts *opts = mpctx->opts;
  651|  44.1k|    struct vo *vo = mpctx->video_out;
  652|       |
  653|       |    // First frame after a reset while audio is already playing: the chain was
  654|       |    // started mid-playback (track switch, disc stream delivering again), or a
  655|       |    // sparse stream's frame was held through the restart. delay is zero from
  656|       |    // the reset and the frame would be shown right away. Set it to the audio
  657|       |    // written past the frame's pts, so the audio sync below shows the frame
  658|       |    // at its time like any later one.
  659|  44.1k|    bool first_frame = mpctx->video_pts == MP_NOPTS_VALUE;
  ------------------
  |  |   39|  44.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  660|  44.1k|    if (first_frame && mpctx->audio_status == STATUS_PLAYING) {
  ------------------
  |  Branch (660:9): [True: 1.00k, False: 43.1k]
  |  Branch (660:24): [True: 0, False: 1.00k]
  ------------------
  661|      0|        double apts = written_audio_pts(mpctx);
  662|      0|        double pts = mpctx->next_frames[0]->pts;
  663|      0|        if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (663:13): [True: 0, False: 0]
  |  Branch (663:39): [True: 0, False: 0]
  ------------------
  664|      0|            mpctx->delay = apts + opts->audio_delay - pts;
  665|      0|    }
  666|       |
  667|  44.1k|    if (mpctx->video_status < STATUS_READY && mpctx->audio_status != STATUS_PLAYING) {
  ------------------
  |  Branch (667:9): [True: 1.00k, False: 43.1k]
  |  Branch (667:47): [True: 1.00k, False: 0]
  ------------------
  668|  1.00k|        mpctx->time_frame = 0;
  669|  43.1k|    } else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
  ------------------
  |  Branch (669:16): [True: 0, False: 43.1k]
  |  Branch (669:46): [True: 0, False: 43.1k]
  ------------------
  670|       |        // don't touch the timing
  671|  43.1k|    } else if (mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao)) {
  ------------------
  |  Branch (671:16): [True: 0, False: 43.1k]
  |  Branch (671:57): [True: 0, False: 0]
  ------------------
  672|      0|        double buffered_audio = ao_get_delay(mpctx->ao);
  673|       |
  674|      0|        double predicted = mpctx->delay / mpctx->video_speed +
  675|      0|                           mpctx->time_frame;
  676|      0|        double difference = buffered_audio - predicted;
  677|      0|        MP_STATS(mpctx, "value %f audio-diff", difference);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  678|       |
  679|      0|        if (opts->autosync && !first_frame) {
  ------------------
  |  Branch (679:13): [True: 0, False: 0]
  |  Branch (679:31): [True: 0, False: 0]
  ------------------
  680|       |            /* Smooth reported playback position from AO by averaging
  681|       |             * it with the value expected based on previous value and
  682|       |             * time elapsed since then. May help smooth video timing
  683|       |             * with audio output that have inaccurate position reporting.
  684|       |             * This is badly implemented; the behavior of the smoothing
  685|       |             * now undesirably depends on how often this code runs
  686|       |             * (mainly depends on video frame rate). */
  687|      0|            buffered_audio = predicted + difference / opts->autosync;
  688|      0|        }
  689|       |
  690|      0|        mpctx->time_frame = buffered_audio - mpctx->delay / mpctx->video_speed;
  691|  43.1k|    } else {
  692|       |        /* If we're more than 200 ms behind the right playback
  693|       |         * position, don't try to speed up display of following
  694|       |         * frames to catch up; continue with default speed from
  695|       |         * the current frame instead.
  696|       |         * If untimed is set always output frames immediately
  697|       |         * without sleeping.
  698|       |         */
  699|  43.1k|        if (mpctx->time_frame < -0.2 || opts->untimed ||
  ------------------
  |  Branch (699:13): [True: 0, False: 43.1k]
  |  Branch (699:41): [True: 43.1k, False: 0]
  ------------------
  700|      0|            (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (700:13): [True: 0, False: 0]
  ------------------
  701|  43.1k|            mpctx->time_frame = 0;
  702|  43.1k|    }
  703|  44.1k|}
video.c:calculate_frame_duration:
 1032|  43.7k|{
 1033|  43.7k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1034|  43.7k|    mp_assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (1034:5): [True: 43.7k, False: 0]
  |  Branch (1034:5): [True: 43.7k, False: 0]
  ------------------
 1035|       |
 1036|  43.7k|    double demux_duration = vo_c->filter->container_fps > 0
  ------------------
  |  Branch (1036:29): [True: 43.6k, False: 67]
  ------------------
 1037|  43.7k|                            ? 1.0 / vo_c->filter->container_fps : -1;
 1038|  43.7k|    double duration = demux_duration;
 1039|       |
 1040|  43.7k|    if (mpctx->num_next_frames >= 2) {
  ------------------
  |  Branch (1040:9): [True: 0, False: 43.7k]
  ------------------
 1041|      0|        double pts0 = mpctx->next_frames[0]->pts;
 1042|      0|        double pts1 = mpctx->next_frames[1]->pts;
 1043|      0|        if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1043:13): [True: 0, False: 0]
  |  Branch (1043:39): [True: 0, False: 0]
  |  Branch (1043:65): [True: 0, False: 0]
  ------------------
 1044|      0|            duration = pts1 - pts0;
 1045|      0|    }
 1046|       |
 1047|       |    // The following code tries to compensate for rounded Matroska timestamps
 1048|       |    // by "unrounding" frame durations, or if not possible, approximating them.
 1049|  43.7k|    double tolerance = MP_PTS_ROUNDING_TOLERANCE;
  ------------------
  |  |   72|  43.7k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
 1050|       |
 1051|  43.7k|    double total = 0;
 1052|  43.7k|    int num_dur = 0;
 1053|  2.79M|    for (int n = 1; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (1053:21): [True: 2.75M, False: 43.7k]
  ------------------
 1054|       |        // Eliminate likely outliers using a really dumb heuristic.
 1055|  2.75M|        double dur = mpctx->past_frames[n].duration;
 1056|  2.75M|        if (dur <= 0 || fabs(dur - duration) >= tolerance)
  ------------------
  |  Branch (1056:13): [True: 0, False: 2.75M]
  |  Branch (1056:25): [True: 0, False: 2.75M]
  ------------------
 1057|      0|            break;
 1058|  2.75M|        total += dur;
 1059|  2.75M|        num_dur += 1;
 1060|  2.75M|    }
 1061|  43.7k|    double approx_duration = num_dur > 0 ? total / num_dur : duration;
  ------------------
  |  Branch (1061:30): [True: 42.7k, False: 1.00k]
  ------------------
 1062|       |
 1063|       |    // Try if the demuxer frame rate fits - if so, just take it.
 1064|  43.7k|    if (demux_duration > 0) {
  ------------------
  |  Branch (1064:9): [True: 43.6k, False: 67]
  ------------------
 1065|       |        // Note that even if each timestamp is within rounding tolerance, it
 1066|       |        // could literally not add up (e.g. if demuxer FPS is rounded itself).
 1067|  43.6k|        if (fabs(duration - demux_duration) < tolerance &&
  ------------------
  |  Branch (1067:13): [True: 43.6k, False: 0]
  ------------------
 1068|  43.6k|            fabs(total - demux_duration * num_dur) < tolerance &&
  ------------------
  |  Branch (1068:13): [True: 43.6k, False: 0]
  ------------------
 1069|  43.6k|            (num_dur >= 16 || num_dur >= mpctx->num_past_frames - 4))
  ------------------
  |  Branch (1069:14): [True: 36.5k, False: 7.11k]
  |  Branch (1069:31): [True: 7.11k, False: 0]
  ------------------
 1070|  43.6k|        {
 1071|  43.6k|            approx_duration = demux_duration;
 1072|  43.6k|        }
 1073|  43.6k|    }
 1074|       |
 1075|  43.7k|    mpctx->past_frames[0].duration = duration;
 1076|  43.7k|    mpctx->past_frames[0].approx_duration = approx_duration;
 1077|       |
 1078|  43.7k|    MP_STATS(mpctx, "value %f frame-duration", MPMAX(0, duration));
  ------------------
  |  |   99|  43.7k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  87.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 67, False: 43.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1079|  43.7k|    MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
  ------------------
  |  |   99|  43.7k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  87.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 67, False: 43.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|  43.7k|}
video.c:shift_frames:
  453|  43.7k|{
  454|  43.7k|    if (mpctx->num_next_frames < 1)
  ------------------
  |  Branch (454:9): [True: 0, False: 43.7k]
  ------------------
  455|      0|        return;
  456|  43.7k|    talloc_free(mpctx->next_frames[0]);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
  457|  43.7k|    for (int n = 0; n < mpctx->num_next_frames - 1; n++)
  ------------------
  |  Branch (457:21): [True: 0, False: 43.7k]
  ------------------
  458|      0|        mpctx->next_frames[n] = mpctx->next_frames[n + 1];
  459|  43.7k|    mpctx->num_next_frames -= 1;
  460|  43.7k|}
video.c:schedule_frame:
 1008|  43.7k|{
 1009|  43.7k|    handle_display_sync_frame(mpctx, frame);
 1010|       |
 1011|  43.7k|    if (mpctx->num_past_frames > 1 &&
  ------------------
  |  Branch (1011:9): [True: 42.7k, False: 1.00k]
  ------------------
 1012|  42.7k|        ((mpctx->past_frames[1].num_vsyncs >= 0) != mpctx->display_sync_active))
  ------------------
  |  Branch (1012:9): [True: 0, False: 42.7k]
  ------------------
 1013|      0|    {
 1014|      0|        MP_VERBOSE(mpctx, "Video sync mode %s.\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1015|      0|                   mpctx->display_sync_active ? "enabled" : "disabled");
 1016|      0|    }
 1017|       |
 1018|  43.7k|    if (!mpctx->display_sync_active) {
  ------------------
  |  Branch (1018:9): [True: 43.7k, False: 0]
  ------------------
 1019|  43.7k|        if (mpctx->num_past_frames > 1 && mpctx->past_frames[1].num_vsyncs >= 0) {
  ------------------
  |  Branch (1019:13): [True: 42.7k, False: 1.00k]
  |  Branch (1019:43): [True: 0, False: 42.7k]
  ------------------
 1020|      0|            mpctx->speed_factor_a = 1.0;
 1021|      0|            mpctx->speed_factor_v = 1.0;
 1022|      0|            update_playback_speed(mpctx);
 1023|      0|        }
 1024|       |
 1025|  43.7k|        update_av_diff(mpctx, mpctx->time_frame > 0 ?
  ------------------
  |  Branch (1025:31): [True: 0, False: 43.7k]
  ------------------
 1026|  43.7k|            mpctx->time_frame * mpctx->video_speed : 0);
 1027|  43.7k|    }
 1028|  43.7k|}
video.c:handle_display_sync_frame:
  861|  43.7k|{
  862|  43.7k|    struct MPOpts *opts = mpctx->opts;
  863|  43.7k|    struct vo *vo = mpctx->video_out;
  864|  43.7k|    int mode = vo->opts->video_sync;
  865|       |
  866|  43.7k|    bool sync_start = !mpctx->display_sync_active;
  867|  43.7k|    if (sync_start) {
  ------------------
  |  Branch (867:9): [True: 43.7k, False: 0]
  ------------------
  868|  43.7k|        mpctx->display_sync_error = 0.0;
  869|  43.7k|        mpctx->audio_drift_compensation = 0.0;
  870|  43.7k|        mpctx->avd_filtered = 0;
  871|  43.7k|    }
  872|       |
  873|  43.7k|    mpctx->display_sync_active = false;
  874|       |
  875|  43.7k|    if (!VS_IS_DISP(mode) || !vo_is_visible(vo) || mpctx->vo_chain->is_sparse ||
  ------------------
  |  |  131|  87.5k|#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE ||       \
  |  |  ------------------
  |  |  |  Branch (131:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  132|  43.7k|                       (x) == VS_DISP_RESAMPLE_VDROP || \
  |  |  ------------------
  |  |  |  Branch (132:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  133|  43.7k|                       (x) == VS_DISP_RESAMPLE_NONE ||  \
  |  |  ------------------
  |  |  |  Branch (133:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  134|  43.7k|                       (x) == VS_DISP_TEMPO ||          \
  |  |  ------------------
  |  |  |  Branch (134:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  135|  43.7k|                       (x) == VS_DISP_ADROP ||          \
  |  |  ------------------
  |  |  |  Branch (135:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  136|  43.7k|                       (x) == VS_DISP_VDROP ||          \
  |  |  ------------------
  |  |  |  Branch (136:24): [True: 0, False: 43.7k]
  |  |  ------------------
  |  |  137|  87.5k|                       (x) == VS_DISP_NONE)
  |  |  ------------------
  |  |  |  Branch (137:24): [True: 0, False: 43.7k]
  |  |  ------------------
  ------------------
  |  Branch (875:30): [True: 0, False: 0]
  |  Branch (875:52): [True: 0, False: 0]
  ------------------
  876|      0|        mpctx->video_status < STATUS_PLAYING)
  ------------------
  |  Branch (876:9): [True: 0, False: 0]
  ------------------
  877|  43.7k|        return;
  878|       |
  879|      0|    if (opts->playback_speed != mpctx->display_sync_speed) {
  ------------------
  |  Branch (879:9): [True: 0, False: 0]
  ------------------
  880|      0|        mpctx->display_sync_error = 0.0;
  881|      0|        mpctx->display_sync_speed = opts->playback_speed;
  882|      0|    }
  883|       |
  884|      0|    bool resample = mode == VS_DISP_RESAMPLE || mode == VS_DISP_RESAMPLE_VDROP ||
  ------------------
  |  Branch (884:21): [True: 0, False: 0]
  |  Branch (884:49): [True: 0, False: 0]
  ------------------
  885|      0|                    mode == VS_DISP_RESAMPLE_NONE;
  ------------------
  |  Branch (885:21): [True: 0, False: 0]
  ------------------
  886|      0|    bool drop = mode == VS_DISP_VDROP || mode == VS_DISP_RESAMPLE ||
  ------------------
  |  Branch (886:17): [True: 0, False: 0]
  |  Branch (886:42): [True: 0, False: 0]
  ------------------
  887|      0|                mode == VS_DISP_ADROP || mode == VS_DISP_RESAMPLE_VDROP ||
  ------------------
  |  Branch (887:17): [True: 0, False: 0]
  |  Branch (887:42): [True: 0, False: 0]
  ------------------
  888|      0|                mode == VS_DISP_TEMPO;
  ------------------
  |  Branch (888:17): [True: 0, False: 0]
  ------------------
  889|      0|    drop &= frame->can_drop;
  890|       |
  891|      0|    if (resample && using_spdif_passthrough(mpctx))
  ------------------
  |  Branch (891:9): [True: 0, False: 0]
  |  Branch (891:21): [True: 0, False: 0]
  ------------------
  892|      0|        return;
  893|       |
  894|      0|    double vsync = vo_get_vsync_interval(vo) / 1e9;
  895|      0|    if (vsync <= 0)
  ------------------
  |  Branch (895:9): [True: 0, False: 0]
  ------------------
  896|      0|        return;
  897|       |
  898|      0|    double approx_duration = MPMAX(0, mpctx->past_frames[0].approx_duration);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  899|      0|    double adjusted_duration = approx_duration / opts->playback_speed;
  900|      0|    if (adjusted_duration > 0.5)
  ------------------
  |  Branch (900:9): [True: 0, False: 0]
  ------------------
  901|      0|        return;
  902|       |
  903|      0|    mpctx->speed_factor_v = 1.0;
  904|      0|    if (mode != VS_DISP_VDROP)
  ------------------
  |  Branch (904:9): [True: 0, False: 0]
  ------------------
  905|      0|        mpctx->speed_factor_v = find_best_speed(mpctx, vsync);
  906|       |
  907|       |    // Determine for how many vsyncs a frame should be displayed. This can be
  908|       |    // e.g. 2 for 30hz on a 60hz display. It can also be 0 if the video
  909|       |    // framerate is higher than the display framerate.
  910|       |    // We use the speed-adjusted (i.e. real) frame duration for this.
  911|      0|    double frame_duration = adjusted_duration / mpctx->speed_factor_v;
  912|      0|    double ratio = (frame_duration + mpctx->display_sync_error) / vsync;
  913|      0|    int num_vsyncs = MPMAX(lrint(ratio), 0);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  914|      0|    double prev_error = mpctx->display_sync_error;
  915|      0|    mpctx->display_sync_error += frame_duration - num_vsyncs * vsync;
  916|       |
  917|      0|    MP_TRACE(mpctx, "s=%f vsyncs=%d dur=%f ratio=%f err=%.20f (%f/%f)\n",
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  918|      0|            mpctx->speed_factor_v, num_vsyncs, adjusted_duration, ratio,
  919|      0|            mpctx->display_sync_error, mpctx->display_sync_error / vsync,
  920|      0|            mpctx->display_sync_error / frame_duration);
  921|       |
  922|      0|    double av_diff = mpctx->last_av_difference;
  923|      0|    MP_STATS(mpctx, "value %f avdiff", av_diff);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  924|       |
  925|       |    // Estimate the video position, so we can calculate a good A/V difference
  926|       |    // value below. This is used to estimate A/V drift. The first display
  927|       |    // synced frame is shown at its target time, time_frame from now.
  928|      0|    double time_left = sync_start ? MPMAX(mpctx->time_frame, 0) : vo_get_delay(vo);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (928:24): [True: 0, False: 0]
  ------------------
  929|       |
  930|       |    // Intended number of additional display frames to drop (<0) or repeat (>0)
  931|      0|    int drop_repeat = 0;
  932|       |
  933|       |    // If we are too far ahead/behind, attempt to drop/repeat frames.
  934|       |    // Tolerate some desync to avoid frame dropping due to jitter. Without
  935|       |    // display timing the difference is stale, and only a shown frame brings
  936|       |    // the timing back.
  937|      0|    av_diff /= opts->playback_speed;
  938|      0|    if (drop && !isnan(time_left) && fabs(av_diff) >= 0.020 &&
  ------------------
  |  Branch (938:9): [True: 0, False: 0]
  |  Branch (938:17): [True: 0, False: 0]
  |  Branch (938:38): [True: 0, False: 0]
  ------------------
  939|      0|        fabs(av_diff) / vsync >= 1)
  ------------------
  |  Branch (939:9): [True: 0, False: 0]
  ------------------
  940|      0|        drop_repeat = -av_diff / vsync; // round towards 0
  941|       |
  942|       |    // We can only drop all frames at most. We can repeat much more frames,
  943|       |    // but we still limit it to 10 times the original frames to avoid that
  944|       |    // corner cases or exceptional situations cause too much havoc.
  945|      0|    drop_repeat = MPCLAMP(drop_repeat, -num_vsyncs, num_vsyncs * 10);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  946|      0|    num_vsyncs += drop_repeat;
  947|       |
  948|       |    // Always show the first frame.
  949|      0|    if (mpctx->num_past_frames <= 1 && num_vsyncs < 1)
  ------------------
  |  Branch (949:9): [True: 0, False: 0]
  |  Branch (949:40): [True: 0, False: 0]
  ------------------
  950|      0|        num_vsyncs = 1;
  951|       |
  952|       |    // We also know that the timing is (necessarily) off, because we have to
  953|       |    // align frame timings on the vsync boundaries. This is unavoidable, and
  954|       |    // for the sake of the A/V sync calculations we pretend it's perfect.
  955|      0|    time_left += prev_error;
  956|       |    // Likewise, we know sync is off, but is going to be compensated.
  957|      0|    time_left += drop_repeat * vsync;
  958|       |
  959|      0|    if (drop_repeat) {
  ------------------
  |  Branch (959:9): [True: 0, False: 0]
  ------------------
  960|      0|        mpctx->mistimed_frames_total += 1;
  961|      0|        MP_STATS(mpctx, "mistimed");
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  962|      0|    }
  963|       |
  964|      0|    mpctx->total_avsync_change = 0;
  965|       |    // Without display timing it is unknown when the frame will be displayed,
  966|       |    // keep the last A/V difference.
  967|      0|    if (!isnan(time_left))
  ------------------
  |  Branch (967:9): [True: 0, False: 0]
  ------------------
  968|      0|        update_av_diff(mpctx, time_left * opts->playback_speed);
  969|       |
  970|      0|    mpctx->past_frames[0].num_vsyncs = num_vsyncs;
  971|       |
  972|      0|    if (resample || mode == VS_DISP_ADROP || mode == VS_DISP_TEMPO) {
  ------------------
  |  Branch (972:9): [True: 0, False: 0]
  |  Branch (972:21): [True: 0, False: 0]
  |  Branch (972:46): [True: 0, False: 0]
  ------------------
  973|      0|        adjust_audio_drift_compensation(mpctx, num_vsyncs * vsync);
  974|      0|    } else {
  975|      0|        mpctx->speed_factor_a = 1.0;
  976|      0|    }
  977|       |
  978|       |    // A bad guess, only needed when reverting to audio sync.
  979|      0|    mpctx->time_frame = isnan(time_left) ? 0 : time_left;
  ------------------
  |  Branch (979:25): [True: 0, False: 0]
  ------------------
  980|       |
  981|      0|    frame->vsync_interval = vsync;
  982|      0|    frame->vsync_offset = -prev_error;
  983|      0|    frame->ideal_frame_duration = frame_duration;
  984|      0|    frame->ideal_frame_vsync = (-prev_error / frame_duration) * approx_duration;
  985|      0|    frame->ideal_frame_vsync_duration = (vsync / frame_duration) * approx_duration;
  986|      0|    frame->num_vsyncs = num_vsyncs;
  987|      0|    frame->display_synced = true;
  988|      0|    frame->approx_duration = approx_duration;
  989|       |
  990|       |    // Spread the frame over its dropped or repeated vsyncs.
  991|      0|    if (drop_repeat && num_vsyncs > 0) {
  ------------------
  |  Branch (991:9): [True: 0, False: 0]
  |  Branch (991:24): [True: 0, False: 0]
  ------------------
  992|      0|        double spread = (double)(num_vsyncs - drop_repeat) / num_vsyncs;
  993|      0|        frame->vsync_interval *= spread;
  994|      0|        frame->ideal_frame_vsync_duration *= spread;
  995|      0|    }
  996|       |
  997|      0|    mpctx->display_sync_active = true;
  998|       |    // Try to avoid audio underruns that may occur if we update
  999|       |    // the playback speed while in the STATUS_SYNCING state.
 1000|      0|    if (mpctx->video_status != STATUS_SYNCING)
  ------------------
  |  Branch (1000:9): [True: 0, False: 0]
  ------------------
 1001|      0|        update_playback_speed(mpctx);
 1002|       |
 1003|      0|    MP_STATS(mpctx, "value %f aspeed", mpctx->speed_factor_a - 1);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1004|      0|    MP_STATS(mpctx, "value %f vspeed", mpctx->speed_factor_v - 1);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1005|      0|}
video.c:update_av_diff:
  707|  43.7k|{
  708|  43.7k|    struct MPOpts *opts = mpctx->opts;
  709|       |
  710|  43.7k|    mpctx->last_av_difference = 0;
  711|       |
  712|  43.7k|    if (mpctx->audio_status != STATUS_PLAYING ||
  ------------------
  |  Branch (712:9): [True: 43.7k, False: 0]
  ------------------
  713|      0|        mpctx->video_status != STATUS_PLAYING)
  ------------------
  |  Branch (713:9): [True: 0, False: 0]
  ------------------
  714|  43.7k|        return;
  715|       |
  716|      0|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  |  Branch (716:28): [True: 0, False: 0]
  ------------------
  717|      0|        return;
  718|       |
  719|      0|    double a_pos = playing_audio_pts(mpctx);
  720|      0|    if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (720:9): [True: 0, False: 0]
  |  Branch (720:36): [True: 0, False: 0]
  ------------------
  721|      0|        mpctx->last_av_difference = a_pos - mpctx->video_pts_unrounded
  722|      0|                                  + opts->audio_delay + offset;
  723|      0|    }
  724|       |
  725|      0|    if (fabs(mpctx->last_av_difference) > 0.5 && !mpctx->drop_message_shown) {
  ------------------
  |  Branch (725:9): [True: 0, False: 0]
  |  Branch (725:50): [True: 0, False: 0]
  ------------------
  726|      0|        MP_WARN(mpctx, "%s", av_desync_help_text);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  727|       |        mpctx->drop_message_shown = true;
  728|      0|    }
  729|      0|}
video.c:check_framedrop:
  355|  43.7k|{
  356|  43.7k|    struct MPOpts *opts = mpctx->opts;
  357|       |    // check for frame-drop:
  358|  43.7k|    if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
  ------------------
  |  Branch (358:9): [True: 42.7k, False: 1.00k]
  |  Branch (358:50): [True: 42.7k, False: 0]
  ------------------
  359|  42.7k|        mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao) &&
  ------------------
  |  Branch (359:9): [True: 0, False: 42.7k]
  |  Branch (359:50): [True: 0, False: 0]
  ------------------
  360|      0|        vo_c->track && vo_c->track->dec && (opts->frame_dropping & 2))
  ------------------
  |  Branch (360:9): [True: 0, False: 0]
  |  Branch (360:24): [True: 0, False: 0]
  |  Branch (360:44): [True: 0, False: 0]
  ------------------
  361|      0|    {
  362|      0|        float fps = vo_c->filter->container_fps;
  363|       |        // it's a crappy heuristic; avoid getting upset by incorrect fps
  364|      0|        if (fps <= 20 || fps >= 500)
  ------------------
  |  Branch (364:13): [True: 0, False: 0]
  |  Branch (364:26): [True: 0, False: 0]
  ------------------
  365|      0|            return;
  366|      0|        double frame_time =  1.0 / fps;
  367|       |        // try to drop as many frames as we appear to be behind
  368|      0|        mp_decoder_wrapper_set_frame_drops(vo_c->track->dec,
  369|      0|            MPCLAMP((mpctx->last_av_difference - 0.010) / frame_time, 0, 100));
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  370|      0|    }
  371|  43.7k|}
video.c:handle_new_frame:
  411|  43.7k|{
  412|  43.7k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 43.7k, False: 0]
  ------------------
  413|       |
  414|  43.7k|    double frame_time = 0;
  415|  43.7k|    double pts = mpctx->next_frames[0]->pts;
  416|  43.7k|    bool is_sparse = mpctx->vo_chain && mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (416:22): [True: 43.7k, False: 0]
  |  Branch (416:41): [True: 0, False: 43.7k]
  ------------------
  417|       |
  418|  43.7k|    mpctx->next_pts_unrounded = pts;
  419|  43.7k|    if (mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  43.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (419:9): [True: 42.7k, False: 1.00k]
  ------------------
  420|  42.7k|        frame_time = pts - mpctx->video_pts;
  421|  42.7k|        double tolerance = mpctx->demuxer->ts_resets_possible &&
  ------------------
  |  Branch (421:28): [True: 0, False: 42.7k]
  ------------------
  422|  42.7k|                           !is_sparse ? 5 : 1e4;
  ------------------
  |  Branch (422:28): [True: 0, False: 0]
  ------------------
  423|  42.7k|        if (frame_time <= 0 || frame_time >= tolerance) {
  ------------------
  |  Branch (423:13): [True: 0, False: 42.7k]
  |  Branch (423:32): [True: 0, False: 42.7k]
  ------------------
  424|       |            // Assume a discontinuity.
  425|      0|            MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  426|      0|                    mpctx->video_pts, pts);
  427|      0|            frame_time = 0;
  428|  42.7k|        } else {
  429|       |            // The timestamps of the file are rounded, and frames of one rate
  430|       |            // come 42, 42 and 41 ms apart. The frame is paced by the time of
  431|       |            // the frame before plus its un-rounded duration, as long as its
  432|       |            // own timestamp agrees. It moves a 64th of the way to the
  433|       |            // timestamp, which holds it there when the duration is a little
  434|       |            // off. The pts itself stays what the file says, seeks, frame
  435|       |            // steps and subtitles go by it.
  436|  42.7k|            double duration = mpctx->past_frames[0].approx_duration;
  437|  42.7k|            double unrounded = mpctx->video_pts_unrounded + duration;
  438|  42.7k|            if (duration > 0 && fabs(pts - unrounded) < MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|  42.7k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (438:17): [True: 42.7k, False: 0]
  |  Branch (438:33): [True: 33.7k, False: 9.03k]
  ------------------
  439|  33.7k|                mpctx->next_pts_unrounded = unrounded + (pts - unrounded) / 64;
  440|  42.7k|            frame_time = mpctx->next_pts_unrounded - mpctx->video_pts_unrounded;
  441|  42.7k|        }
  442|  42.7k|    }
  443|  43.7k|    mpctx->time_frame += frame_time / mpctx->video_speed;
  444|  43.7k|    if (mpctx->ao_chain)
  ------------------
  |  Branch (444:9): [True: 64, False: 43.6k]
  ------------------
  445|     64|        mpctx->delay -= frame_time;
  446|  43.7k|    if (mpctx->video_status >= STATUS_PLAYING)
  ------------------
  |  Branch (446:9): [True: 42.7k, False: 1.00k]
  ------------------
  447|  42.7k|        adjust_sync(mpctx, mpctx->next_pts_unrounded, frame_time);
  448|  43.7k|    MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
  ------------------
  |  |   94|  43.7k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  449|  43.7k|}
video.c:adjust_sync:
  383|  42.7k|{
  384|  42.7k|    struct MPOpts *opts = mpctx->opts;
  385|       |
  386|  42.7k|    if (mpctx->audio_status != STATUS_PLAYING)
  ------------------
  |  Branch (386:9): [True: 42.7k, False: 0]
  ------------------
  387|  42.7k|        return;
  388|       |
  389|      0|    double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay;
  390|      0|    double av_delay = a_pts - v_pts;
  391|       |
  392|      0|    double change = av_delay * 0.1;
  393|      0|    double factor = fabs(av_delay) < 0.3 ? 0.1 : 0.4;
  ------------------
  |  Branch (393:21): [True: 0, False: 0]
  ------------------
  394|      0|    double max_change = opts->default_max_pts_correction >= 0 ?
  ------------------
  |  Branch (394:25): [True: 0, False: 0]
  ------------------
  395|      0|                        opts->default_max_pts_correction : frame_time * factor;
  396|      0|    if (change < -max_change)
  ------------------
  |  Branch (396:9): [True: 0, False: 0]
  ------------------
  397|      0|        change = -max_change;
  398|      0|    else if (change > max_change)
  ------------------
  |  Branch (398:14): [True: 0, False: 0]
  ------------------
  399|      0|        change = max_change;
  400|      0|    mpctx->delay += change;
  401|      0|    mpctx->total_avsync_change += change;
  402|       |
  403|      0|    if (mpctx->display_sync_active)
  ------------------
  |  Branch (403:9): [True: 0, False: 0]
  ------------------
  404|      0|        mpctx->total_avsync_change = 0;
  405|      0|}

mp_parse_icy_metadata:
  181|  1.55M|{
  182|  1.55M|    if (!headers.len && !packet.len)
  ------------------
  |  Branch (182:9): [True: 1.55M, False: 0]
  |  Branch (182:25): [True: 1.55M, False: 0]
  ------------------
  183|  1.55M|        return NULL;
  184|       |
  185|      0|    struct mp_tags *res = talloc_zero(NULL, struct mp_tags);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|       |
  187|      0|    while (headers.len) {
  ------------------
  |  Branch (187:12): [True: 0, False: 0]
  ------------------
  188|      0|        bstr line = bstr_strip_linebreaks(bstr_getline(headers, &headers));
  189|      0|        bstr name, val;
  190|      0|        if (bstr_split_tok(line, ": ", &name, &val))
  ------------------
  |  Branch (190:13): [True: 0, False: 0]
  ------------------
  191|      0|            mp_tags_set_bstr(res, name, val);
  192|      0|    }
  193|       |
  194|      0|    bstr head = bstr0("StreamTitle='");
  195|      0|    int i = bstr_find(packet, head);
  196|      0|    if (i >= 0) {
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|        packet = bstr_cut(packet, i + head.len);
  198|      0|        int end = bstr_find(packet, bstr0("\';"));
  199|      0|        if (end >= 0)
  ------------------
  |  Branch (199:13): [True: 0, False: 0]
  ------------------
  200|      0|            packet = bstr_splice(packet, 0, end);
  201|       |
  202|      0|        bool allocated = false;
  203|      0|        struct demux_opts *opts = mp_get_config_group(NULL, s->global, &demux_conf);
  204|      0|        const char *charset = mp_charset_guess(s, s->log, packet, opts->meta_cp, 0);
  205|      0|        if (charset && !mp_charset_is_utf8(charset)) {
  ------------------
  |  Branch (205:13): [True: 0, False: 0]
  |  Branch (205:24): [True: 0, False: 0]
  ------------------
  206|      0|            bstr conv = mp_iconv_to_utf8(s->log, packet, charset, 0);
  207|      0|            if (conv.start && conv.start != packet.start) {
  ------------------
  |  Branch (207:17): [True: 0, False: 0]
  |  Branch (207:31): [True: 0, False: 0]
  ------------------
  208|      0|                allocated = true;
  209|      0|                packet = conv;
  210|      0|            }
  211|      0|        }
  212|      0|        mp_tags_set_bstr(res, bstr0("icy-title"), packet);
  213|      0|        talloc_free(opts);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  214|      0|        if (allocated)
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            talloc_free(packet.start);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  216|      0|    }
  217|       |
  218|      0|    return res;
  219|  1.55M|}

mp_url_unescape_inplace:
  152|   616k|{
  153|  7.71G|    for (int len = strlen(url), i = 0, o = 0; i <= len;) {
  ------------------
  |  Branch (153:47): [True: 7.71G, False: 616k]
  ------------------
  154|  7.71G|        if ((url[i] != '%') || (i > len - 3)) {  // %NN can't start after len-3
  ------------------
  |  Branch (154:13): [True: 7.70G, False: 8.06M]
  |  Branch (154:32): [True: 372, False: 8.06M]
  ------------------
  155|  7.70G|            url[o++] = url[i++];
  156|  7.70G|            continue;
  157|  7.70G|        }
  158|       |
  159|  8.06M|        int msd = hex2dec(url[i + 1]),
  160|  8.06M|            lsd = hex2dec(url[i + 2]);
  161|       |
  162|  8.06M|        if (msd >= 0 && lsd >= 0) {
  ------------------
  |  Branch (162:13): [True: 1.13M, False: 6.92M]
  |  Branch (162:25): [True: 205k, False: 931k]
  ------------------
  163|   205k|            url[o++] = 16 * msd + lsd;
  164|   205k|            i += 3;
  165|  7.85M|        } else {
  166|  7.85M|            url[o++] = url[i++];
  167|  7.85M|            url[o++] = url[i++];
  168|  7.85M|            url[o++] = url[i++];
  169|  7.85M|        }
  170|  8.06M|    }
  171|   616k|}
mp_url_escape:
  196|     27|{
  197|     27|    char *rv = talloc_size(talloc_ctx, strlen(url) * 3 + 1);
  ------------------
  |  |   43|     27|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|     27|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|     27|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     27|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     27|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     27|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|     27|    char *out = rv;
  199|     27|    bool negate = ok && ok[0] == '~';
  ------------------
  |  Branch (199:19): [True: 27, False: 0]
  |  Branch (199:25): [True: 0, False: 27]
  ------------------
  200|       |
  201|  3.83k|    for (char c; (c = *url); url++) {
  ------------------
  |  Branch (201:18): [True: 3.81k, False: 27]
  ------------------
  202|  3.81k|        bool as_is = negate ? !strchr(ok + 1, c)
  ------------------
  |  Branch (202:22): [True: 0, False: 3.81k]
  ------------------
  203|  3.81k|                            : (strchr(url_default_ok, c) || (ok && strchr(ok, c)));
  ------------------
  |  Branch (203:32): [True: 2.25k, False: 1.55k]
  |  Branch (203:62): [True: 1.55k, False: 0]
  |  Branch (203:68): [True: 370, False: 1.18k]
  ------------------
  204|  3.81k|        if (as_is) {
  ------------------
  |  Branch (204:13): [True: 2.62k, False: 1.18k]
  ------------------
  205|  2.62k|            *out++ = c;
  206|  2.62k|        } else {
  207|  1.18k|            unsigned char v = c;
  208|  1.18k|            *out++ = '%';
  209|  1.18k|            *out++ = hex_digits[v / 16];
  210|  1.18k|            *out++ = hex_digits[v % 16];
  211|  1.18k|        }
  212|  3.81k|    }
  213|       |
  214|     27|    *out = 0;
  215|     27|    return rv;
  216|     27|}
stream_create_with_args:
  444|  92.6k|{
  445|  92.6k|    mp_assert(args->url);
  ------------------
  |  |   41|  92.6k|#define mp_assert assert
  ------------------
  |  Branch (445:5): [True: 92.6k, False: 0]
  ------------------
  446|       |
  447|  92.6k|    int r = STREAM_NO_MATCH;
  ------------------
  |  |   65|  92.6k|#define STREAM_NO_MATCH -2
  ------------------
  448|  92.6k|    *ret = NULL;
  449|       |
  450|       |    // Open stream proper
  451|  92.6k|    if (args->sinfo) {
  ------------------
  |  Branch (451:9): [True: 60.8k, False: 31.7k]
  ------------------
  452|  60.8k|        r = stream_create_instance(args->sinfo, args, ret);
  453|  60.8k|    } else {
  454|   439k|        for (int i = 0; i < MP_ARRAY_SIZE(stream_list); i++) {
  ------------------
  |  |   49|   439k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (454:25): [True: 439k, False: 136]
  ------------------
  455|   439k|            r = stream_create_instance(stream_list[i], args, ret);
  456|   439k|            if (r == STREAM_OK)
  ------------------
  |  |   68|   439k|#define STREAM_OK    1
  ------------------
  |  Branch (456:17): [True: 30.5k, False: 409k]
  ------------------
  457|  30.5k|                break;
  458|   409k|            if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   65|   818k|#define STREAM_NO_MATCH -2
  ------------------
                          if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   66|  32.2k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (458:17): [True: 376k, False: 32.2k]
  |  Branch (458:41): [True: 29.8k, False: 2.40k]
  ------------------
  459|   406k|                continue;
  460|  2.40k|            if (r == STREAM_UNSAFE)
  ------------------
  |  |   64|  2.40k|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (460:17): [True: 1.36k, False: 1.04k]
  ------------------
  461|  1.36k|                continue;
  462|  1.04k|            break;
  463|  2.40k|        }
  464|  31.7k|    }
  465|       |
  466|  92.6k|    if (!*ret && !(args->flags & STREAM_SILENT) && !mp_cancel_test(args->cancel))
  ------------------
  |  |   44|  1.18k|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (466:9): [True: 1.18k, False: 91.4k]
  |  Branch (466:18): [True: 1.18k, False: 0]
  |  Branch (466:52): [True: 1.18k, False: 0]
  ------------------
  467|  1.18k|    {
  468|  1.18k|        struct mp_log *log = mp_log_new(NULL, args->global->log, "!stream");
  469|       |
  470|  1.18k|        if (r == STREAM_UNSAFE) {
  ------------------
  |  |   64|  1.18k|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (470:13): [True: 0, False: 1.18k]
  ------------------
  471|      0|            mp_err(log, "\nRefusing to load potentially unsafe URL from a playlist.\n"
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  472|      0|                   "Use the --load-unsafe-playlists option to load it anyway.\n\n");
  473|  1.18k|        } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   65|  2.36k|#define STREAM_NO_MATCH -2
  ------------------
                      } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   66|  1.04k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (473:20): [True: 136, False: 1.04k]
  |  Branch (473:44): [True: 0, False: 1.04k]
  ------------------
  474|    136|            mp_err(log, "No protocol handler found to open URL %s\n", args->url);
  ------------------
  |  |   76|    136|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  475|    136|            mp_err(log, "The protocol is either unsupported, or was disabled "
  ------------------
  |  |   76|    136|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  476|    136|                        "at compile-time.\n");
  477|  1.04k|        } else {
  478|  1.04k|            mp_err(log, "Failed to open %s.\n", args->url);
  ------------------
  |  |   76|  1.04k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  479|  1.04k|        }
  480|       |
  481|  1.18k|        talloc_free(log);
  ------------------
  |  |   47|  1.18k|#define talloc_free                     ta_free
  ------------------
  482|  1.18k|    }
  483|       |
  484|  92.6k|    return r;
  485|  92.6k|}
stream_create:
  489|  31.7k|{
  490|  31.7k|    struct stream_open_args args = {
  491|  31.7k|        .global = global,
  492|  31.7k|        .cancel = c,
  493|  31.7k|        .flags = flags,
  494|  31.7k|        .url = url,
  495|  31.7k|    };
  496|  31.7k|    struct stream *s;
  497|  31.7k|    stream_create_with_args(&args, &s);
  498|  31.7k|    return s;
  499|  31.7k|}
stream_read_partial:
  616|   151k|{
  617|   151k|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   151k|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 151k, False: 0]
  ------------------
  618|   151k|    mp_assert(buf_size >= 0);
  ------------------
  |  |   41|   151k|#define mp_assert assert
  ------------------
  |  Branch (618:5): [True: 151k, False: 0]
  ------------------
  619|   151k|    if (s->buf_cur == s->buf_end && buf_size > 0) {
  ------------------
  |  Branch (619:9): [True: 117k, False: 34.1k]
  |  Branch (619:37): [True: 117k, False: 0]
  ------------------
  620|   117k|        if (buf_size > (s->buffer_mask + 1) / 2) {
  ------------------
  |  Branch (620:13): [True: 3.48k, False: 114k]
  ------------------
  621|       |            // Direct read if the buffer is too small anyway.
  622|  3.48k|            stream_drop_buffers(s);
  623|  3.48k|            return stream_read_unbuffered(s, buf, buf_size);
  624|  3.48k|        }
  625|   114k|        stream_read_more(s, 1);
  626|   114k|    }
  627|   148k|    int res = ring_copy(s, buf, buf_size, s->buf_cur);
  628|   148k|    s->buf_cur += res;
  629|   148k|    return res;
  630|   151k|}
stream_read_char_fallback:
  634|  1.88k|{
  635|  1.88k|    uint8_t c;
  636|  1.88k|    return stream_read_partial(s, &c, 1) ? c : STREAM_EOF;
  ------------------
  |  |   71|  1.88k|#define STREAM_EOF (-256)
  ------------------
  |  Branch (636:12): [True: 0, False: 1.88k]
  ------------------
  637|  1.88k|}
stream_read:
  640|  8.46k|{
  641|  8.46k|    int len = total;
  642|  16.9k|    while (len > 0) {
  ------------------
  |  Branch (642:12): [True: 12.1k, False: 4.80k]
  ------------------
  643|  12.1k|        int read = stream_read_partial(s, mem, len);
  644|  12.1k|        if (read <= 0)
  ------------------
  |  Branch (644:13): [True: 3.65k, False: 8.49k]
  ------------------
  645|  3.65k|            break; // EOF
  646|  8.49k|        mem = (char *)mem + read;
  647|  8.49k|        len -= read;
  648|  8.49k|    }
  649|  8.46k|    total -= len;
  650|  8.46k|    return total;
  651|  8.46k|}
stream_peek:
  656|  1.11M|{
  657|  1.20M|    while (stream_read_more(s, forward_size)) {}
  ------------------
  |  Branch (657:12): [True: 90.0k, False: 1.11M]
  ------------------
  658|  1.11M|    return s->buf_end - s->buf_cur;
  659|  1.11M|}
stream_read_peek:
  664|  1.11M|{
  665|  1.11M|    stream_peek(s, buf_size);
  666|  1.11M|    return ring_copy(s, buf, buf_size, s->buf_cur);
  667|  1.11M|}
stream_drop_buffers:
  708|  3.56k|{
  709|  3.56k|    s->pos = stream_tell(s);
  710|  3.56k|    s->buf_start = s->buf_cur = s->buf_end = 0;
  711|  3.56k|    s->eof = 0;
  712|  3.56k|    stream_resize_buffer(s, 0, 0);
  713|  3.56k|}
stream_seek:
  754|  3.76M|{
  755|  3.76M|    MP_TRACE(s, "seek request from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   94|  3.76M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.76M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  756|  3.76M|             stream_tell(s), pos);
  757|       |
  758|  3.76M|    s->eof = 0; // eof should be set only on read; seeking always clears it
  759|       |
  760|  3.76M|    if (pos < 0) {
  ------------------
  |  Branch (760:9): [True: 0, False: 3.76M]
  ------------------
  761|      0|        MP_ERR(s, "Invalid seek to negative position %lld!\n", (long long)pos);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  762|      0|        pos = 0;
  763|      0|    }
  764|       |
  765|  3.76M|    if (pos <= s->pos) {
  ------------------
  |  Branch (765:9): [True: 2.34M, False: 1.41M]
  ------------------
  766|  2.34M|        int64_t x = pos - (s->pos - (int)s->buf_end);
  767|  2.34M|        if (x >= (int)s->buf_start) {
  ------------------
  |  Branch (767:13): [True: 2.34M, False: 889]
  ------------------
  768|  2.34M|            s->buf_cur = x;
  769|  2.34M|            mp_assert(s->buf_cur >= s->buf_start);
  ------------------
  |  |   41|  2.34M|#define mp_assert assert
  ------------------
  |  Branch (769:13): [True: 2.34M, False: 0]
  ------------------
  770|  2.34M|            mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|  2.34M|#define mp_assert assert
  ------------------
  |  Branch (770:13): [True: 2.34M, False: 0]
  ------------------
  771|  2.34M|            return true;
  772|  2.34M|        }
  773|  2.34M|    }
  774|       |
  775|  1.41M|    if (s->mode == STREAM_WRITE)
  ------------------
  |  |   42|  1.41M|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (775:9): [True: 0, False: 1.41M]
  ------------------
  776|      0|        return s->seekable && s->seek(s, pos);
  ------------------
  |  Branch (776:16): [True: 0, False: 0]
  |  Branch (776:31): [True: 0, False: 0]
  ------------------
  777|       |
  778|       |    // Skip data instead of performing a seek in some cases.
  779|  1.41M|    if (pos >= s->pos &&
  ------------------
  |  Branch (779:9): [True: 1.41M, False: 889]
  ------------------
  780|  1.41M|        ((!s->seekable && s->fast_skip) ||
  ------------------
  |  Branch (780:11): [True: 0, False: 1.41M]
  |  Branch (780:27): [True: 0, False: 0]
  ------------------
  781|  1.41M|         pos - s->pos <= s->requested_buffer_size))
  ------------------
  |  Branch (781:10): [True: 12.4k, False: 1.40M]
  ------------------
  782|  12.4k|    {
  783|  12.4k|        return stream_skip_read(s, pos - stream_tell(s));
  784|  12.4k|    }
  785|       |
  786|  1.40M|    return stream_seek_unbuffered(s, pos);
  787|  1.41M|}
stream_seek_skip:
  792|   432k|{
  793|   432k|    uint64_t cur_pos = stream_tell(s);
  794|       |
  795|   432k|    if (cur_pos == pos)
  ------------------
  |  Branch (795:9): [True: 37.2k, False: 395k]
  ------------------
  796|  37.2k|        return true;
  797|       |
  798|   395k|    return !s->seekable && pos > cur_pos
  ------------------
  |  Branch (798:12): [True: 0, False: 395k]
  |  Branch (798:28): [True: 0, False: 0]
  ------------------
  799|   395k|        ? stream_skip_read(s, pos - cur_pos)
  800|   395k|        : stream_seek(s, pos);
  801|   432k|}
stream_control:
  804|  1.58M|{
  805|  1.58M|    return s->control ? s->control(s, cmd, arg) : STREAM_UNSUPPORTED;
  ------------------
  |  |   66|  2.01k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (805:12): [True: 1.57M, False: 2.01k]
  ------------------
  806|  1.58M|}
stream_get_size:
  810|  1.55M|{
  811|  1.55M|    return s->get_size ? s->get_size(s) : -1;
  ------------------
  |  Branch (811:12): [True: 1.55M, False: 14]
  ------------------
  812|  1.55M|}
free_stream:
  815|   462k|{
  816|   462k|    if (!s)
  ------------------
  |  Branch (816:9): [True: 371k, False: 91.4k]
  ------------------
  817|   371k|        return;
  818|       |
  819|  91.4k|    if (s->close)
  ------------------
  |  Branch (819:9): [True: 30.4k, False: 60.9k]
  ------------------
  820|  30.4k|        s->close(s);
  821|  91.4k|    talloc_free(s);
  ------------------
  |  |   47|  91.4k|#define talloc_free                     ta_free
  ------------------
  822|  91.4k|}
stream_skip_bom:
  828|  61.6k|{
  829|  61.6k|    char buf[4];
  830|  61.6k|    int len = stream_read_peek(s, buf, sizeof(buf));
  831|  61.6k|    bstr data = {buf, len};
  832|   245k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (832:21): [True: 184k, False: 60.9k]
  ------------------
  833|   184k|        if (bstr_startswith0(data, bom[n])) {
  ------------------
  |  Branch (833:13): [True: 681, False: 183k]
  ------------------
  834|    681|            stream_seek_skip(s, stream_tell(s) + strlen(bom[n]));
  835|    681|            return n;
  836|    681|        }
  837|   184k|    }
  838|  60.9k|    return -1; // default to 8 bit codepages
  839|  61.6k|}
stream_read_complete:
  854|  3.45k|{
  855|  3.45k|    if (max_size < 0 || max_size > STREAM_MAX_READ_SIZE)
  ------------------
  |  |   36|  3.45k|#define STREAM_MAX_READ_SIZE (INT_MAX - 1)
  ------------------
  |  Branch (855:9): [True: 0, False: 3.45k]
  |  Branch (855:25): [True: 0, False: 3.45k]
  ------------------
  856|      0|        abort();
  857|  3.45k|    if (s->is_directory)
  ------------------
  |  Branch (857:9): [True: 0, False: 3.45k]
  ------------------
  858|      0|        return (struct bstr){NULL, 0};
  859|       |
  860|  3.45k|    int bufsize;
  861|  3.45k|    int total_read = 0;
  862|  3.45k|    int padding = 1;
  863|  3.45k|    char *buf = NULL;
  864|  3.45k|    int64_t size = stream_get_size(s) - stream_tell(s);
  865|  3.45k|    if (size > max_size && !s->allow_partial_read)
  ------------------
  |  Branch (865:9): [True: 0, False: 3.45k]
  |  Branch (865:28): [True: 0, False: 0]
  ------------------
  866|      0|        return (struct bstr){NULL, 0};
  867|  3.45k|    if (size > 0)
  ------------------
  |  Branch (867:9): [True: 5, False: 3.44k]
  ------------------
  868|      5|        bufsize = size + padding;
  869|  3.44k|    else
  870|  3.44k|        bufsize = 1000;
  871|  3.45k|    if (s->allow_partial_read)
  ------------------
  |  Branch (871:9): [True: 0, False: 3.45k]
  ------------------
  872|      0|        bufsize = MPMIN(bufsize, max_size + padding);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  873|  8.04k|    while (1) {
  ------------------
  |  Branch (873:12): [True: 8.04k, Folded]
  ------------------
  874|  8.04k|        buf = talloc_realloc_size(talloc_ctx, buf, bufsize);
  ------------------
  |  |   39|  8.04k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  8.04k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  8.04k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  8.04k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  8.04k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  875|  8.04k|        int readsize = stream_read(s, buf + total_read, bufsize - total_read);
  876|  8.04k|        total_read += readsize;
  877|  8.04k|        if (total_read >= max_size && s->allow_partial_read) {
  ------------------
  |  Branch (877:13): [True: 0, False: 8.04k]
  |  Branch (877:39): [True: 0, False: 0]
  ------------------
  878|      0|            total_read = max_size;
  879|      0|            break;
  880|      0|        }
  881|  8.04k|        if (total_read < bufsize)
  ------------------
  |  Branch (881:13): [True: 3.45k, False: 4.59k]
  ------------------
  882|  3.45k|            break;
  883|  4.59k|        if (bufsize > max_size) {
  ------------------
  |  Branch (883:13): [True: 0, False: 4.59k]
  ------------------
  884|      0|            talloc_free(buf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  885|      0|            return (struct bstr){NULL, 0};
  886|      0|        }
  887|  4.59k|        bufsize = MPMIN(bufsize + (bufsize >> 1), max_size + padding);
  ------------------
  |  |   45|  4.59k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 4.59k]
  |  |  ------------------
  ------------------
  888|  4.59k|    }
  889|  3.45k|    buf = talloc_realloc_size(talloc_ctx, buf, total_read + padding);
  ------------------
  |  |   39|  3.45k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  3.45k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.45k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  3.45k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  3.45k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  890|  3.45k|    memset(&buf[total_read], 0, padding);
  891|  3.45k|    return (struct bstr){buf, total_read};
  892|  3.45k|}
stream.c:hex2dec:
  140|  16.1M|{
  141|  16.1M|    if (c >= '0' && c <= '9')
  ------------------
  |  Branch (141:9): [True: 3.35M, False: 12.7M]
  |  Branch (141:21): [True: 27.2k, False: 3.32M]
  ------------------
  142|  27.2k|        return c - '0';
  143|  16.0M|    if (c >= 'A' && c <= 'F')
  ------------------
  |  Branch (143:9): [True: 2.51M, False: 13.5M]
  |  Branch (143:21): [True: 17.1k, False: 2.49M]
  ------------------
  144|  17.1k|        return 10 + c - 'A';
  145|  16.0M|    if (c >= 'a' && c <= 'f')
  ------------------
  |  Branch (145:9): [True: 2.10M, False: 13.9M]
  |  Branch (145:21): [True: 1.71M, False: 390k]
  ------------------
  146|  1.71M|        return 10 + c - 'a';
  147|  14.3M|    return -1;
  148|  16.0M|}
stream.c:stream_create_instance:
  337|   500k|{
  338|   500k|    const char *url = args->url;
  339|   500k|    int flags = args->flags;
  340|       |
  341|   500k|    *ret = NULL;
  342|       |
  343|   500k|    const char *path = url;
  344|       |
  345|   500k|    if (flags & STREAM_LOCAL_FS_ONLY) {
  ------------------
  |  |   54|   500k|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  ------------------
  |  Branch (345:9): [True: 0, False: 500k]
  ------------------
  346|      0|        if (!sinfo->local_fs)
  ------------------
  |  Branch (346:13): [True: 0, False: 0]
  ------------------
  347|      0|            return STREAM_NO_MATCH;
  ------------------
  |  |   65|      0|#define STREAM_NO_MATCH -2
  ------------------
  348|   500k|    } else {
  349|   500k|        char **get_protocols = sinfo->get_protocols ? sinfo->get_protocols() : NULL;
  ------------------
  |  Branch (349:32): [True: 60.9k, False: 439k]
  ------------------
  350|   500k|        char **protocols = get_protocols ? get_protocols : (char **)sinfo->protocols;
  ------------------
  |  Branch (350:28): [True: 60.9k, False: 439k]
  ------------------
  351|       |
  352|  1.36M|        for (int n = 0; protocols && protocols[n]; n++) {
  ------------------
  |  Branch (352:25): [True: 1.33M, False: 31.1k]
  |  Branch (352:38): [True: 953k, False: 376k]
  ------------------
  353|   953k|            path = match_proto(url, protocols[n]);
  354|   953k|            if (path)
  ------------------
  |  Branch (354:17): [True: 92.5k, False: 861k]
  ------------------
  355|  92.5k|                break;
  356|   953k|        }
  357|       |
  358|   500k|        talloc_free(get_protocols);
  ------------------
  |  |   47|   500k|#define talloc_free                     ta_free
  ------------------
  359|       |
  360|   500k|        if (!path)
  ------------------
  |  Branch (360:13): [True: 376k, False: 123k]
  ------------------
  361|   376k|            return STREAM_NO_MATCH;
  ------------------
  |  |   65|   376k|#define STREAM_NO_MATCH -2
  ------------------
  362|   500k|    }
  363|       |
  364|   123k|    stream_t *s = talloc_zero(NULL, stream_t);
  ------------------
  |  |   27|   123k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   123k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   123k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|   123k|    s->global = args->global;
  366|   123k|    struct stream_opts *opts = mp_get_config_group(s, s->global, &stream_conf);
  367|   123k|    if (flags & STREAM_SILENT) {
  ------------------
  |  |   44|   123k|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (367:9): [True: 60.8k, False: 62.8k]
  ------------------
  368|  60.8k|        s->log = mp_null_log;
  369|  62.8k|    } else {
  370|  62.8k|        s->log = mp_log_new(s, s->global->log, sinfo->name);
  371|  62.8k|    }
  372|   123k|    s->info = sinfo;
  373|   123k|    s->autoprobed = !args->sinfo;
  374|   123k|    s->cancel = args->cancel;
  375|   123k|    s->url = talloc_strdup(s, url);
  ------------------
  |  |   50|   123k|#define talloc_strdup                   ta_xstrdup
  ------------------
  376|   123k|    s->path = talloc_strdup(s, path);
  ------------------
  |  |   50|   123k|#define talloc_strdup                   ta_xstrdup
  ------------------
  377|   123k|    s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   41|   123k|#define STREAM_READ               0
  ------------------
                  s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   42|   123k|#define STREAM_WRITE              (1 << 0)
  ------------------
  378|   123k|    s->requested_buffer_size = opts->buffer_size;
  379|   123k|    s->allow_partial_read = flags & STREAM_ALLOW_PARTIAL_READ;
  ------------------
  |  |   56|   123k|#define STREAM_ALLOW_PARTIAL_READ (1 << 7) // allows partial read with stream_read_file()
  ------------------
  380|       |
  381|   123k|    if (flags & STREAM_LESS_NOISE)
  ------------------
  |  |   55|   123k|#define STREAM_LESS_NOISE         (1 << 6) // try to log errors only
  ------------------
  |  Branch (381:9): [True: 0, False: 123k]
  ------------------
  382|      0|        mp_msg_set_max_level(s->log, MSGL_WARN);
  383|       |
  384|   123k|    struct demux_opts *demux_opts = mp_get_config_group(s, s->global, &demux_conf);
  385|   123k|    s->access_references = demux_opts->access_references;
  386|   123k|    talloc_free(demux_opts);
  ------------------
  |  |   47|   123k|#define talloc_free                     ta_free
  ------------------
  387|       |
  388|   123k|    MP_VERBOSE(s, "Opening %s\n", url);
  ------------------
  |  |   92|   123k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   123k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  389|       |
  390|   123k|    if (strlen(url) > INT_MAX / 8) {
  ------------------
  |  Branch (390:9): [True: 0, False: 123k]
  ------------------
  391|      0|        MP_ERR(s, "URL too large.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  392|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  393|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  394|      0|    }
  395|       |
  396|   123k|    if ((s->mode & STREAM_WRITE) && !sinfo->can_write) {
  ------------------
  |  |   42|   123k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (396:9): [True: 0, False: 123k]
  |  Branch (396:37): [True: 0, False: 0]
  ------------------
  397|      0|        MP_DBG(s, "No write access implemented.\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  398|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  399|      0|        return STREAM_NO_MATCH;
  ------------------
  |  |   65|      0|#define STREAM_NO_MATCH -2
  ------------------
  400|      0|    }
  401|       |
  402|   123k|    s->stream_origin = flags & STREAM_ORIGIN_MASK; // pass through by default
  ------------------
  |  |   52|   123k|#define STREAM_ORIGIN_MASK        (7 << 2) // for extracting origin value from flags
  ------------------
  403|   123k|    if (opts->load_unsafe_playlists) {
  ------------------
  |  Branch (403:9): [True: 0, False: 123k]
  ------------------
  404|      0|        s->stream_origin = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|      0|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  405|   123k|    } else if (sinfo->stream_origin) {
  ------------------
  |  Branch (405:16): [True: 62.8k, False: 60.9k]
  ------------------
  406|  62.8k|        s->stream_origin = check_origin(s->stream_origin, sinfo->stream_origin);
  407|  62.8k|    }
  408|       |
  409|   123k|    if (!s->stream_origin) {
  ------------------
  |  Branch (409:9): [True: 1.36k, False: 122k]
  ------------------
  410|  1.36k|        talloc_free(s);
  ------------------
  |  |   47|  1.36k|#define talloc_free                     ta_free
  ------------------
  411|  1.36k|        return STREAM_UNSAFE;
  ------------------
  |  |   64|  1.36k|#define STREAM_UNSAFE -3
  ------------------
  412|  1.36k|    }
  413|       |
  414|   122k|    int r = STREAM_UNSUPPORTED;
  ------------------
  |  |   66|   122k|#define STREAM_UNSUPPORTED -1
  ------------------
  415|   122k|    if (sinfo->open2) {
  ------------------
  |  Branch (415:9): [True: 61.3k, False: 61.0k]
  ------------------
  416|  61.3k|        r = sinfo->open2(s, args);
  417|  61.3k|    } else if (!args->special_arg) {
  ------------------
  |  Branch (417:16): [True: 61.0k, False: 0]
  ------------------
  418|  61.0k|        r = (sinfo->open)(s);
  419|  61.0k|    }
  420|   122k|    if (r != STREAM_OK) {
  ------------------
  |  |   68|   122k|#define STREAM_OK    1
  ------------------
  |  Branch (420:9): [True: 30.9k, False: 91.4k]
  ------------------
  421|  30.9k|        talloc_free(s);
  ------------------
  |  |   47|  30.9k|#define talloc_free                     ta_free
  ------------------
  422|  30.9k|        return r;
  423|  30.9k|    }
  424|       |
  425|  91.4k|    if (!stream_resize_buffer(s, 0, 0)) {
  ------------------
  |  Branch (425:9): [True: 0, False: 91.4k]
  ------------------
  426|      0|        free_stream(s);
  427|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  428|      0|    }
  429|       |
  430|  91.4k|    mp_assert(s->seekable == !!s->seek);
  ------------------
  |  |   41|  91.4k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 91.4k, False: 0]
  ------------------
  431|       |
  432|  91.4k|    if (s->mime_type)
  ------------------
  |  Branch (432:9): [True: 0, False: 91.4k]
  ------------------
  433|  91.4k|        MP_VERBOSE(s, "Mime-type: '%s'\n", s->mime_type);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  434|  91.4k|    if (s->server_filename)
  ------------------
  |  Branch (434:9): [True: 0, False: 91.4k]
  ------------------
  435|  91.4k|        MP_VERBOSE(s, "Server filename: '%s'\n", s->server_filename);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  436|       |
  437|  91.4k|    MP_DBG(s, "Stream opened successfully.\n");
  ------------------
  |  |   93|  91.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  91.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|  91.4k|    *ret = s;
  440|  91.4k|    return STREAM_OK;
  ------------------
  |  |   68|  91.4k|#define STREAM_OK    1
  ------------------
  441|  91.4k|}
stream.c:match_proto:
  219|   953k|{
  220|   953k|    int l = strlen(proto);
  221|   953k|    if (l > 0) {
  ------------------
  |  Branch (221:9): [True: 922k, False: 31.6k]
  ------------------
  222|   922k|        if (strncasecmp(url, proto, l) == 0 && strncmp("://", url + l, 3) == 0)
  ------------------
  |  Branch (222:13): [True: 92.0k, False: 830k]
  |  Branch (222:48): [True: 92.0k, False: 10]
  ------------------
  223|  92.0k|            return url + l + 3;
  224|   922k|    } else if (!mp_is_url(bstr0(url))) {
  ------------------
  |  Branch (224:16): [True: 492, False: 31.1k]
  ------------------
  225|    492|        return url; // pure filenames
  226|    492|    }
  227|   861k|    return NULL;
  228|   953k|}
stream.c:check_origin:
  234|  62.8k|{
  235|  62.8k|    switch (src) {
  ------------------
  |  Branch (235:13): [True: 62.8k, False: 0]
  ------------------
  236|  57.9k|    case STREAM_ORIGIN_DIRECT:
  ------------------
  |  |   47|  57.9k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  |  Branch (236:5): [True: 57.9k, False: 4.92k]
  ------------------
  237|  60.2k|    case STREAM_ORIGIN_UNSAFE:
  ------------------
  |  |   50|  60.2k|#define STREAM_ORIGIN_UNSAFE      (4 << 2) // from a grotesque source
  ------------------
  |  Branch (237:5): [True: 2.34k, False: 60.4k]
  ------------------
  238|       |        // Allow anything, but constrain it to the new origin.
  239|  60.2k|        return new;
  240|     44|    case STREAM_ORIGIN_FS:
  ------------------
  |  |   48|     44|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
  |  Branch (240:5): [True: 44, False: 62.7k]
  ------------------
  241|       |        // From unix FS, allow all but unsafe.
  242|     44|        if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   48|     88|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
                      if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|     30|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (242:13): [True: 14, False: 30]
  |  Branch (242:40): [True: 14, False: 16]
  ------------------
  243|     28|            return new;
  244|     16|        break;
  245|  2.53k|    case STREAM_ORIGIN_NET:
  ------------------
  |  |   49|  2.53k|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (245:5): [True: 2.53k, False: 60.3k]
  ------------------
  246|       |        // Allow only other network links.
  247|  2.53k|        if (new == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|  2.53k|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (247:13): [True: 1.18k, False: 1.34k]
  ------------------
  248|  1.18k|            return new;
  249|  1.34k|        break;
  250|  62.8k|    }
  251|  1.36k|    return 0;
  252|  62.8k|}
stream.c:stream_read_unbuffered:
  517|   585k|{
  518|   585k|    mp_assert(len >= 0);
  ------------------
  |  |   41|   585k|#define mp_assert assert
  ------------------
  |  Branch (518:5): [True: 585k, False: 0]
  ------------------
  519|   585k|    if (len <= 0)
  ------------------
  |  Branch (519:9): [True: 0, False: 585k]
  ------------------
  520|      0|        return 0;
  521|       |
  522|   585k|    int res = 0;
  523|       |    // we will retry even if we already reached EOF previously.
  524|   585k|    if (s->fill_buffer && !mp_cancel_test(s->cancel))
  ------------------
  |  Branch (524:9): [True: 585k, False: 98]
  |  Branch (524:27): [True: 585k, False: 0]
  ------------------
  525|   585k|        res = s->fill_buffer(s, buf, len);
  526|   585k|    if (res <= 0) {
  ------------------
  |  Branch (526:9): [True: 491k, False: 94.1k]
  ------------------
  527|   491k|        s->eof = 1;
  528|   491k|        return 0;
  529|   491k|    }
  530|  94.1k|    mp_assert(res <= len);
  ------------------
  |  |   41|  94.1k|#define mp_assert assert
  ------------------
  |  Branch (530:5): [True: 94.1k, False: 0]
  ------------------
  531|       |    // When reading succeeded we are obviously not at eof.
  532|  94.1k|    s->eof = 0;
  533|  94.1k|    s->pos += res;
  534|  94.1k|    s->total_unbuffered_read_bytes += res;
  535|  94.1k|    return res;
  536|  94.1k|}
stream.c:stream_read_more:
  543|  1.32M|{
  544|  1.32M|    mp_assert(forward >= 0);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (544:5): [True: 1.32M, False: 0]
  ------------------
  545|       |
  546|  1.32M|    int forward_avail = s->buf_end - s->buf_cur;
  547|  1.32M|    if (forward_avail >= forward)
  ------------------
  |  Branch (547:9): [True: 746k, False: 582k]
  ------------------
  548|   746k|        return false;
  549|       |
  550|       |    // Avoid that many small reads will lead to many low-level read calls.
  551|   582k|    forward = MPMAX(forward, s->requested_buffer_size / 2);
  ------------------
  |  |   44|   582k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.47k, False: 580k]
  |  |  ------------------
  ------------------
  552|   582k|    mp_assert(forward_avail < forward);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (552:5): [True: 582k, False: 0]
  ------------------
  553|       |
  554|       |    // Keep guaranteed seek-back.
  555|   582k|    int buf_old = MPMIN(s->buf_cur - s->buf_start, s->requested_buffer_size / 2);
  ------------------
  |  |   45|   582k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 3.47k, False: 578k]
  |  |  ------------------
  ------------------
  556|       |
  557|       |    // Never shrink the buffer here. That's stream_drop_buffers()'s job. Otherwise
  558|       |    // data fetched by earlier larger reads (e.g. demuxer probing) would be
  559|       |    // discarded, forcing redundant re-reads on backward seeks.
  560|   582k|    int new_size = MPMAX(buf_old + forward, s->buffer_mask + 1);
  ------------------
  |  |   44|   582k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 245, False: 581k]
  |  |  ------------------
  ------------------
  561|       |
  562|   582k|    if (!stream_resize_buffer(s, buf_old + forward_avail, new_size))
  ------------------
  |  Branch (562:9): [True: 0, False: 582k]
  ------------------
  563|      0|        return false;
  564|       |
  565|   582k|    int buf_alloc = s->buffer_mask + 1;
  566|       |
  567|   582k|    mp_assert(s->buf_start <= s->buf_cur);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (567:5): [True: 582k, False: 0]
  ------------------
  568|   582k|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (568:5): [True: 582k, False: 0]
  ------------------
  569|   582k|    mp_assert(s->buf_cur < buf_alloc * 2);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (569:5): [True: 582k, False: 0]
  ------------------
  570|   582k|    mp_assert(s->buf_end < buf_alloc * 2);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (570:5): [True: 582k, False: 0]
  ------------------
  571|   582k|    mp_assert(s->buf_start < buf_alloc);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (571:5): [True: 582k, False: 0]
  ------------------
  572|       |
  573|       |    // Note: read as much as possible, even if forward is much smaller. Do
  574|       |    // this because the stream buffer is supposed to set an approx. minimum
  575|       |    // read size on it.
  576|   582k|    int read = buf_alloc - (buf_old + forward_avail); // free buffer past end
  577|       |
  578|   582k|    int pos = s->buf_end & s->buffer_mask;
  579|   582k|    read = MPMIN(read, buf_alloc - pos);
  ------------------
  |  |   45|   582k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 3.45k, False: 578k]
  |  |  ------------------
  ------------------
  580|       |
  581|       |    // Note: if wrap-around happens, we need to make two calls. This may
  582|       |    // affect latency (e.g. waiting for new data on a socket), so do only
  583|       |    // 1 read call always.
  584|   582k|    read = stream_read_unbuffered(s, &s->buffer[pos], read);
  585|       |
  586|   582k|    s->buf_end += read;
  587|       |
  588|       |    // May have overwritten old data.
  589|   582k|    if (s->buf_end - s->buf_start >= buf_alloc) {
  ------------------
  |  Branch (589:9): [True: 28, False: 582k]
  ------------------
  590|     28|        mp_assert(s->buf_end >= buf_alloc);
  ------------------
  |  |   41|     28|#define mp_assert assert
  ------------------
  |  Branch (590:9): [True: 28, False: 0]
  ------------------
  591|       |
  592|     28|        s->buf_start = s->buf_end - buf_alloc;
  593|       |
  594|     28|        mp_assert(s->buf_start <= s->buf_cur);
  ------------------
  |  |   41|     28|#define mp_assert assert
  ------------------
  |  Branch (594:9): [True: 28, False: 0]
  ------------------
  595|     28|        mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|     28|#define mp_assert assert
  ------------------
  |  Branch (595:9): [True: 28, False: 0]
  ------------------
  596|       |
  597|     28|        if (s->buf_start >= buf_alloc) {
  ------------------
  |  Branch (597:13): [True: 1, False: 27]
  ------------------
  598|      1|            s->buf_start -= buf_alloc;
  599|      1|            s->buf_cur -= buf_alloc;
  600|      1|            s->buf_end -= buf_alloc;
  601|      1|        }
  602|     28|    }
  603|       |
  604|       |    // Must not have overwritten guaranteed old data.
  605|   582k|    mp_assert(s->buf_cur - s->buf_start >= buf_old);
  ------------------
  |  |   41|   582k|#define mp_assert assert
  ------------------
  |  Branch (605:5): [True: 582k, False: 0]
  ------------------
  606|       |
  607|   582k|    if (s->buf_cur < s->buf_end)
  ------------------
  |  Branch (607:9): [True: 383k, False: 198k]
  ------------------
  608|   383k|        s->eof = 0;
  609|       |
  610|   582k|    return !!read;
  611|   582k|}
stream.c:ring_copy:
  260|  1.26M|{
  261|  1.26M|    mp_assert(len >= 0);
  ------------------
  |  |   41|  1.26M|#define mp_assert assert
  ------------------
  |  Branch (261:5): [True: 1.26M, False: 0]
  ------------------
  262|       |
  263|  1.26M|    if (pos < s->buf_start || pos > s->buf_end)
  ------------------
  |  Branch (263:9): [True: 0, False: 1.26M]
  |  Branch (263:31): [True: 0, False: 1.26M]
  ------------------
  264|      0|        return 0;
  265|       |
  266|  1.26M|    int copied = 0;
  267|  1.26M|    len = MPMIN(len, s->buf_end - pos);
  ------------------
  |  |   45|  1.26M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 505k, False: 754k]
  |  |  ------------------
  ------------------
  268|       |
  269|  1.26M|    if (len && pos <= s->buffer_mask) {
  ------------------
  |  Branch (269:9): [True: 1.07M, False: 186k]
  |  Branch (269:16): [True: 1.07M, False: 13]
  ------------------
  270|  1.07M|        int copy = MPMIN(len, s->buffer_mask + 1 - pos);
  ------------------
  |  |   45|  1.07M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 1.07M]
  |  |  ------------------
  ------------------
  271|  1.07M|        memcpy(dst, &s->buffer[pos], copy);
  272|  1.07M|        copied += copy;
  273|  1.07M|        len -= copy;
  274|  1.07M|        pos += copy;
  275|  1.07M|    }
  276|       |
  277|  1.26M|    if (len) {
  ------------------
  |  Branch (277:9): [True: 13, False: 1.26M]
  ------------------
  278|     13|        memcpy((char *)dst + copied, &s->buffer[pos & s->buffer_mask], len);
  279|     13|        copied += len;
  280|     13|    }
  281|       |
  282|  1.26M|    return copied;
  283|  1.26M|}
stream.c:stream_resize_buffer:
  293|   677k|{
  294|   677k|    mp_assert(keep >= s->buf_end - s->buf_cur);
  ------------------
  |  |   41|   677k|#define mp_assert assert
  ------------------
  |  Branch (294:5): [True: 677k, False: 0]
  ------------------
  295|   677k|    mp_assert(keep <= new);
  ------------------
  |  |   41|   677k|#define mp_assert assert
  ------------------
  |  Branch (295:5): [True: 677k, False: 0]
  ------------------
  296|       |
  297|   677k|    new = MPMAX(new, s->requested_buffer_size);
  ------------------
  |  |   44|   677k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.15k, False: 675k]
  |  |  ------------------
  ------------------
  298|   677k|    new = MPMIN(new, STREAM_MAX_BUFFER_SIZE);
  ------------------
  |  |   45|   677k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 677k]
  |  |  ------------------
  ------------------
  299|   677k|    new = mp_round_next_power_of_2(new);
  300|       |
  301|   677k|    mp_assert(keep <= new); // can't fail (if old buffer size was valid)
  ------------------
  |  |   41|   677k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 677k, False: 0]
  ------------------
  302|       |
  303|   677k|    if (new == s->buffer_mask + 1)
  ------------------
  |  Branch (303:9): [True: 585k, False: 91.6k]
  ------------------
  304|   585k|        return true;
  305|       |
  306|  91.6k|    int old_pos = s->buf_cur - s->buf_start;
  307|  91.6k|    int old_used_len = s->buf_end - s->buf_start;
  308|  91.6k|    int skip = old_used_len > new ? old_used_len - new : 0;
  ------------------
  |  Branch (308:16): [True: 0, False: 91.6k]
  ------------------
  309|       |
  310|  91.6k|    MP_DBG(s, "resize stream to %d bytes, drop %d bytes\n", new, skip);
  ------------------
  |  |   93|  91.6k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  91.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  311|       |
  312|  91.6k|    void *nbuf = ta_alloc_size(s, new);
  ------------------
  |  |  153|  91.6k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  ------------------
  |  |  |  |   43|  91.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  91.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   37|  91.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|  91.6k|    if (!nbuf)
  ------------------
  |  Branch (313:9): [True: 0, False: 91.6k]
  ------------------
  314|      0|        return false; // oom; tolerate it, caller needs to check if required
  315|       |
  316|  91.6k|    int new_len = 0;
  317|  91.6k|    if (s->buffer)
  ------------------
  |  Branch (317:9): [True: 245, False: 91.4k]
  ------------------
  318|    245|        new_len = ring_copy(s, nbuf, new, s->buf_start + skip);
  319|  91.6k|    mp_assert(new_len == old_used_len - skip);
  ------------------
  |  |   41|  91.6k|#define mp_assert assert
  ------------------
  |  Branch (319:5): [True: 91.6k, False: 0]
  ------------------
  320|  91.6k|    mp_assert(old_pos >= skip); // "keep" too low
  ------------------
  |  |   41|  91.6k|#define mp_assert assert
  ------------------
  |  Branch (320:5): [True: 91.6k, False: 0]
  ------------------
  321|  91.6k|    mp_assert(old_pos - skip <= new_len);
  ------------------
  |  |   41|  91.6k|#define mp_assert assert
  ------------------
  |  Branch (321:5): [True: 91.6k, False: 0]
  ------------------
  322|  91.6k|    s->buf_start = 0;
  323|  91.6k|    s->buf_cur = old_pos - skip;
  324|  91.6k|    s->buf_end = new_len;
  325|       |
  326|  91.6k|    ta_free(s->buffer);
  327|       |
  328|  91.6k|    s->buffer = nbuf;
  329|  91.6k|    s->buffer_mask = new - 1;
  330|       |
  331|       |    return true;
  332|  91.6k|}
stream.c:stream_skip_read:
  689|  12.4k|{
  690|  12.7k|    while (len > 0) {
  ------------------
  |  Branch (690:12): [True: 12.7k, False: 2]
  ------------------
  691|  12.7k|        unsigned int left = s->buf_end - s->buf_cur;
  692|  12.7k|        if (!left) {
  ------------------
  |  Branch (692:13): [True: 12.4k, False: 276]
  ------------------
  693|  12.4k|            if (!stream_read_more(s, 1))
  ------------------
  |  Branch (693:17): [True: 12.4k, False: 22]
  ------------------
  694|  12.4k|                return false;
  695|     22|            continue;
  696|  12.4k|        }
  697|    276|        unsigned skip = MPMIN(len, left);
  ------------------
  |  |   45|    276|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 274, False: 2]
  |  |  ------------------
  ------------------
  698|    276|        s->buf_cur += skip;
  699|    276|        len -= skip;
  700|    276|    }
  701|      2|    return true;
  702|  12.4k|}
stream.c:stream_seek_unbuffered:
  726|  1.40M|{
  727|  1.40M|    if (newpos != s->pos) {
  ------------------
  |  Branch (727:9): [True: 1.40M, False: 0]
  ------------------
  728|  1.40M|        MP_VERBOSE(s, "stream level seek from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   92|  1.40M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.40M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  729|  1.40M|                   s->pos, newpos);
  730|       |
  731|  1.40M|        s->total_stream_seeks++;
  732|       |
  733|  1.40M|        if (newpos > s->pos && !s->seekable) {
  ------------------
  |  Branch (733:13): [True: 1.40M, False: 889]
  |  Branch (733:32): [True: 0, False: 1.40M]
  ------------------
  734|      0|            MP_ERR(s, "Cannot seek forward in this stream\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  735|      0|            return false;
  736|      0|        }
  737|  1.40M|        if (newpos < s->pos && !s->seekable) {
  ------------------
  |  Branch (737:13): [True: 889, False: 1.40M]
  |  Branch (737:32): [True: 0, False: 889]
  ------------------
  738|      0|            MP_ERR(s, "Cannot seek backward in linear streams!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  739|      0|            return false;
  740|      0|        }
  741|  1.40M|        if (s->seek(s, newpos) <= 0) {
  ------------------
  |  Branch (741:13): [True: 1.40M, False: 78]
  ------------------
  742|  1.40M|            int level = mp_cancel_test(s->cancel) ? MSGL_V : MSGL_ERR;
  ------------------
  |  Branch (742:25): [True: 0, False: 1.40M]
  ------------------
  743|  1.40M|            MP_MSG(s, level, "Seek failed (to %lld, size %lld)\n",
  ------------------
  |  |   86|  1.40M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  744|  1.40M|                   (long long)newpos, (long long)stream_get_size(s));
  745|  1.40M|            return false;
  746|  1.40M|        }
  747|     78|        stream_drop_buffers(s);
  748|     78|        s->pos = newpos;
  749|     78|    }
  750|     78|    return true;
  751|  1.40M|}

stream.c:stream_tell:
  389|  4.21M|{
  390|  4.21M|    return s->pos + s->buf_cur - s->buf_end;
  391|  4.21M|}
demux_lavf.c:stream_tell:
  389|  1.57M|{
  390|  1.57M|    return s->pos + s->buf_cur - s->buf_end;
  391|  1.57M|}
demux_mf.c:stream_tell:
  389|     74|{
  390|     74|    return s->pos + s->buf_cur - s->buf_end;
  391|     74|}
demux_playlist.c:stream_read_char:
  380|   194k|{
  381|   194k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 193k, False: 1.87k]
  ------------------
  382|   194k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|   194k|        : stream_read_char_fallback(s);
  384|   194k|}
demux_playlist.c:stream_tell:
  389|   490k|{
  390|   490k|    return s->pos + s->buf_cur - s->buf_end;
  391|   490k|}
ebml.c:stream_read_char:
  380|  78.8k|{
  381|  78.8k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 78.8k, False: 12]
  ------------------
  382|  78.8k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  78.8k|        : stream_read_char_fallback(s);
  384|  78.8k|}

stream_avdevice.c:open_f:
   21|      5|{
   22|      5|    stream->demuxer = "lavf";
   23|       |
   24|      5|    return STREAM_OK;
  ------------------
  |  |   68|      5|#define STREAM_OK    1
  ------------------
   25|      5|}

stream_bstr_open2:
   48|  60.8k|{
   49|  60.8k|    s->fill_buffer = bs_fill_buffer;
   50|  60.8k|    s->seek = bs_seek;
   51|  60.8k|    s->seekable = true;
   52|  60.8k|    s->get_size = bs_get_size;
   53|       |
   54|  60.8k|    struct priv *p = talloc_zero(s, struct priv);
  ------------------
  |  |   27|  60.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  60.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  60.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  60.8k|    s->priv = p;
   56|       |
   57|  60.8k|    ta_set_parent(data.start, p);
   58|  60.8k|    p->data = data;
   59|       |
   60|  60.8k|    return STREAM_OK;
  ------------------
  |  |   68|  60.8k|#define STREAM_OK    1
  ------------------
   61|  60.8k|}
stream_bstr.c:bs_fill_buffer:
   26|   196k|{
   27|   196k|    struct priv *p = s->priv;
   28|   196k|    bstr data = p->data;
   29|   196k|    if (s->pos < 0 || s->pos > data.len)
  ------------------
  |  Branch (29:9): [True: 0, False: 196k]
  |  Branch (29:23): [True: 0, False: 196k]
  ------------------
   30|      0|        return 0;
   31|   196k|    len = MPMIN(len, data.len - s->pos);
  ------------------
  |  |   45|   196k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 196k, False: 9]
  |  |  ------------------
  ------------------
   32|   196k|    memcpy(buffer, data.start + s->pos, len);
   33|   196k|    return len;
   34|   196k|}
stream_bstr.c:bs_get_size:
   42|  3.32k|{
   43|  3.32k|    struct priv *p = s->priv;
   44|  3.32k|    return p->data.len;
   45|  3.32k|}

stream_cb.c:open_cb:
   55|  29.8k|{
   56|  29.8k|    struct priv *p = talloc_ptrtype(stream, p);
  ------------------
  |  |   34|  29.8k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  29.8k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  29.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   57|  29.8k|    stream->priv = p;
   58|       |
   59|  29.8k|    bstr bproto = mp_split_proto(bstr0(stream->url), NULL);
   60|  29.8k|    char *proto = bstrto0(stream, bproto);
   61|       |
   62|  29.8k|    void *user_data;
   63|  29.8k|    mpv_stream_cb_open_ro_fn open_fn;
   64|       |
   65|  29.8k|    if (!mp_streamcb_lookup(stream->global, proto, &user_data, &open_fn))
  ------------------
  |  Branch (65:9): [True: 29.8k, False: 0]
  ------------------
   66|  29.8k|        return STREAM_UNSUPPORTED;
  ------------------
  |  |   66|  29.8k|#define STREAM_UNSUPPORTED -1
  ------------------
   67|       |
   68|      0|    mpv_stream_cb_info info = {0};
   69|       |
   70|      0|    int r = open_fn(user_data, stream->url, &info);
   71|      0|    if (r < 0) {
  ------------------
  |  Branch (71:9): [True: 0, False: 0]
  ------------------
   72|      0|        if (r != MPV_ERROR_LOADING_FAILED)
  ------------------
  |  Branch (72:13): [True: 0, False: 0]
  ------------------
   73|      0|            MP_WARN(stream, "unknown error from user callback\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   74|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
   75|      0|    }
   76|       |
   77|      0|    if (!info.read_fn || !info.close_fn) {
  ------------------
  |  Branch (77:9): [True: 0, False: 0]
  |  Branch (77:26): [True: 0, False: 0]
  ------------------
   78|      0|        MP_FATAL(stream, "required read_fn or close_fn callbacks not set.\n");
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   79|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
   80|      0|    }
   81|       |
   82|      0|    p->info = info;
   83|       |
   84|      0|    if (p->info.seek_fn && p->info.seek_fn(p->info.cookie, 0) >= 0) {
  ------------------
  |  Branch (84:9): [True: 0, False: 0]
  |  Branch (84:28): [True: 0, False: 0]
  ------------------
   85|      0|        stream->seek = seek;
   86|      0|        stream->seekable = true;
   87|      0|    }
   88|      0|    stream->fast_skip = true;
   89|      0|    stream->fill_buffer = fill_buffer;
   90|      0|    stream->get_size = get_size;
   91|      0|    stream->close = s_close;
   92|       |
   93|      0|    if (p->info.cancel_fn && stream->cancel) {
  ------------------
  |  Branch (93:9): [True: 0, False: 0]
  |  Branch (93:30): [True: 0, False: 0]
  ------------------
   94|      0|        p->cancel = mp_cancel_new(p);
   95|      0|        mp_cancel_set_parent(p->cancel, stream->cancel);
   96|      0|        mp_cancel_set_cb(p->cancel, p->info.cancel_fn, p->info.cookie);
   97|      0|    }
   98|       |
   99|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  100|      0|}

dvb_get_state:
 1047|      1|{
 1048|      1|    dvb_priv_t *priv = stream->priv;
 1049|      1|    if (global_dvb_state)
  ------------------
  |  Branch (1049:9): [True: 0, False: 1]
  ------------------
 1050|      0|        return global_dvb_state;
 1051|       |
 1052|      1|    struct mp_log *log = stream->log;
 1053|      1|    struct mpv_global *global = stream->global;
 1054|       |
 1055|      1|    dvb_state_t *state = talloc_zero(NULL, dvb_state_t);
  ------------------
  |  |   27|      1|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      1|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|      1|    state->switching_channel = false;
 1057|      1|    state->is_on = false;
 1058|      1|    state->stream_used = true;
 1059|      1|    state->fe_fd = state->dvr_fd = -1;
 1060|       |
 1061|     17|    for (unsigned int i = 0; i < MAX_ADAPTERS; i++) {
  ------------------
  |  |   27|     17|#define MAX_ADAPTERS 16
  ------------------
  |  Branch (1061:30): [True: 16, False: 1]
  ------------------
 1062|     16|        dvb_channels_list_t *list = NULL;
 1063|     16|        unsigned int delsys_mask[MAX_FRONTENDS];
 1064|    144|        for (unsigned int f = 0; f < MAX_FRONTENDS; f++) {
  ------------------
  |  |   28|    144|#define MAX_FRONTENDS 8
  ------------------
  |  Branch (1064:34): [True: 128, False: 16]
  ------------------
 1065|    128|            char filename[100];
 1066|    128|            snprintf(filename, sizeof(filename), "/dev/dvb/adapter%u/frontend%u", i, f);
 1067|    128|            int fd = open(filename, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
  ------------------
  |  |  269|    128|#define open(...) mp_open(__VA_ARGS__)
  ------------------
 1068|    128|            if (fd < 0)
  ------------------
  |  Branch (1068:17): [True: 128, False: 0]
  ------------------
 1069|    128|                continue;
 1070|       |
 1071|      0|            delsys_mask[f] = dvb_get_tuner_delsys_mask(fd, log);
 1072|      0|            delsys_mask[f] &= DELSYS_SUPP_MASK; /* Filter unsupported delivery systems. */
  ------------------
  |  |  126|      0|    (                                                                   \
  |  |  127|      0|        DELSYS_BIT(SYS_DVBC_ANNEX_A) |                                  \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  128|      0|        DELSYS_BIT(SYS_DVBT) |                                          \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  129|      0|        DELSYS_BIT(SYS_DVBS) |                                          \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  130|      0|        DELSYS_BIT(SYS_DVBS2) |                                         \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  131|      0|        DELSYS_BIT(SYS_ATSC) |                                          \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  132|      0|        DELSYS_BIT(SYS_DVBC_ANNEX_B) |                                  \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  133|      0|        DELSYS_BIT(SYS_DVBT2) |                                         \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  134|      0|        DELSYS_BIT(SYS_ISDBT) |                                         \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  135|      0|        DELSYS_BIT(SYS_DVBC_ANNEX_C)                                    \
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  136|      0|    )
  ------------------
 1073|      0|            close(fd);
 1074|      0|            if (delsys_mask[f] == 0) {
  ------------------
  |  Branch (1074:17): [True: 0, False: 0]
  ------------------
 1075|      0|                mp_verbose(log, "Frontend device %s has no supported delivery systems.\n",
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 1076|      0|                       filename);
 1077|      0|                continue; /* Skip tuner. */
 1078|      0|            }
 1079|       |
 1080|       |            /* Create channel list for adapter. */
 1081|      0|            for (unsigned int delsys = 0; delsys < SYS_DVB__COUNT__; delsys++) {
  ------------------
  |  |  113|      0|#define SYS_DVB__COUNT__            (SYS_DVBC_ANNEX_C + 1)
  ------------------
  |  Branch (1081:43): [True: 0, False: 0]
  ------------------
 1082|      0|                if (!DELSYS_IS_SET(delsys_mask[f], delsys))
  ------------------
  |  |  122|      0|    (0 != ((__mask) & DELSYS_BIT((__bit))))
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  ------------------
  |  Branch (1082:21): [True: 0, False: 0]
  ------------------
 1083|      0|                    continue; /* Skip unsupported. */
 1084|       |
 1085|      0|                mp_verbose(log, "Searching channel list for delivery system %s\n", get_dvb_delsys(delsys));
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 1086|      0|                const char *conf_file_name;
 1087|      0|                switch (delsys) {
 1088|      0|                case SYS_DVBC_ANNEX_A:
  ------------------
  |  Branch (1088:17): [True: 0, False: 0]
  ------------------
 1089|      0|                case SYS_DVBC_ANNEX_C:
  ------------------
  |  Branch (1089:17): [True: 0, False: 0]
  ------------------
 1090|      0|                    conf_file_name = "channels.conf.cbl";
 1091|      0|                    break;
 1092|      0|                case SYS_ATSC:
  ------------------
  |  Branch (1092:17): [True: 0, False: 0]
  ------------------
 1093|      0|                    conf_file_name = "channels.conf.atsc";
 1094|      0|                    break;
 1095|      0|                case SYS_DVBT:
  ------------------
  |  Branch (1095:17): [True: 0, False: 0]
  ------------------
 1096|      0|                    if (DELSYS_IS_SET(delsys_mask[f], SYS_DVBT2)) {
  ------------------
  |  |  122|      0|    (0 != ((__mask) & DELSYS_BIT((__bit))))
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  |  Branch (122:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1097|       |                        // only if ter1 is present, interpret as DVB-T, else will be loaded as DVB-T2
 1098|      0|                        conf_file_name = "channels.conf.ter1";
 1099|      0|                    } else {
 1100|      0|                        conf_file_name = "channels.conf.ter";
 1101|      0|                    }
 1102|      0|                    break;
 1103|      0|                case SYS_DVBT2:
  ------------------
  |  Branch (1103:17): [True: 0, False: 0]
  ------------------
 1104|      0|                    conf_file_name = "channels.conf.ter";
 1105|      0|                    break;
 1106|      0|                case SYS_ISDBT:
  ------------------
  |  Branch (1106:17): [True: 0, False: 0]
  ------------------
 1107|      0|                    conf_file_name = "channels.conf.isdbt";
 1108|      0|                    break;
 1109|      0|                case SYS_DVBS:
  ------------------
  |  Branch (1109:17): [True: 0, False: 0]
  ------------------
 1110|      0|                    if (DELSYS_IS_SET(delsys_mask[f], SYS_DVBS2)) {
  ------------------
  |  |  122|      0|    (0 != ((__mask) & DELSYS_BIT((__bit))))
  |  |  ------------------
  |  |  |  |  116|      0|#define DELSYS_BIT(__bit)        (((unsigned int)1) << (__bit))
  |  |  ------------------
  |  |  |  Branch (122:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1111|       |                        // only if sat1 is present, interpret as DVB-S, else will be loaded as DVB-S2
 1112|      0|                        conf_file_name = "channels.conf.sat1";
 1113|      0|                    } else {
 1114|      0|                        conf_file_name = "channels.conf.sat";
 1115|      0|                    }
 1116|      0|                    break;
 1117|      0|                case SYS_DVBS2:
  ------------------
  |  Branch (1117:17): [True: 0, False: 0]
  ------------------
 1118|      0|                    conf_file_name = "channels.conf.sat";
 1119|      0|                    break;
 1120|      0|                default:
  ------------------
  |  Branch (1120:17): [True: 0, False: 0]
  ------------------
 1121|      0|                    continue;
 1122|      0|                }
 1123|       |
 1124|      0|                void *talloc_ctx = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1125|      0|                char *conf_file;
 1126|      0|                if (priv->opts->cfg_file && priv->opts->cfg_file[0]) {
  ------------------
  |  Branch (1126:21): [True: 0, False: 0]
  |  Branch (1126:45): [True: 0, False: 0]
  ------------------
 1127|      0|                    conf_file = mp_get_user_path(talloc_ctx, global, priv->opts->cfg_file);
 1128|      0|                } else {
 1129|      0|                    conf_file = mp_find_config_file(talloc_ctx, global, conf_file_name);
 1130|      0|                    if (conf_file) {
  ------------------
  |  Branch (1130:25): [True: 0, False: 0]
  ------------------
 1131|      0|                        mp_verbose(log, "Ignoring other channels.conf files.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 1132|      0|                    } else {
 1133|      0|                        conf_file = mp_find_config_file(talloc_ctx, global,
 1134|      0|                                        "channels.conf");
 1135|      0|                    }
 1136|      0|                }
 1137|       |
 1138|      0|                list = dvb_get_channels(log, list, priv->opts->cfg_full_transponder,
 1139|      0|                                        conf_file, f, delsys, delsys_mask[f]);
 1140|      0|                talloc_free(talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1141|      0|            }
 1142|      0|        }
 1143|       |        /* Add adapter with non zero channel list. */
 1144|     16|        if (!list)
  ------------------
  |  Branch (1144:13): [True: 16, False: 0]
  ------------------
 1145|     16|            continue;
 1146|       |
 1147|      0|        dvb_adapter_config_t tmp = {
 1148|      0|            .devno = i,
 1149|      0|            .list = talloc_steal(state, list),
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1150|      0|        };
 1151|      0|        memcpy(&tmp.delsys_mask, delsys_mask, sizeof(delsys_mask));
 1152|       |
 1153|      0|        MP_TARRAY_APPEND(state, state->adapters, state->adapters_count, tmp);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1154|       |
 1155|      0|        mp_verbose(log, "Added adapter with channels to state list, now %d.\n",
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 1156|      0|                   state->adapters_count);
 1157|      0|    }
 1158|       |
 1159|      1|    if (state->adapters_count == 0)
  ------------------
  |  Branch (1159:9): [True: 1, False: 0]
  ------------------
 1160|      1|        TA_FREEP(&state);
  ------------------
  |  |   81|      1|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      1|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1161|       |
 1162|      1|    global_dvb_state = state;
 1163|      1|    return state;
 1164|      1|}
stream_dvb.c:dvb_open:
  923|      1|{
  924|      1|    dvb_priv_t *priv = NULL;
  925|       |
  926|      1|    mp_mutex_lock(&global_dvb_state_lock);
  ------------------
  |  |  134|      1|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  927|      1|    if (global_dvb_state && global_dvb_state->stream_used) {
  ------------------
  |  Branch (927:9): [True: 0, False: 1]
  |  Branch (927:29): [True: 0, False: 0]
  ------------------
  928|      0|        MP_ERR(stream, "DVB stream already in use, only one DVB stream can exist at a time!\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  929|      0|        mp_mutex_unlock(&global_dvb_state_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  930|      0|        goto err_out;
  931|      0|    }
  932|       |
  933|       |    // Need to re-get config in any case, not part of global state.
  934|      1|    stream->priv = talloc_zero(stream, dvb_priv_t);
  ------------------
  |  |   27|      1|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      1|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  935|      1|    priv = stream->priv;
  936|      1|    priv->opts_cache = m_config_cache_alloc(stream, stream->global, &stream_dvb_conf);
  937|      1|    priv->opts = priv->opts_cache->opts;
  938|       |
  939|      1|    dvb_state_t *state = dvb_get_state(stream);
  940|       |
  941|      1|    priv->state = state;
  942|      1|    priv->log = stream->log;
  943|      1|    if (!state) {
  ------------------
  |  Branch (943:9): [True: 1, False: 0]
  ------------------
  944|      1|        MP_ERR(stream, "DVB configuration is empty\n");
  ------------------
  |  |   89|      1|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  945|      1|        mp_mutex_unlock(&global_dvb_state_lock);
  ------------------
  |  |  136|      1|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  946|      1|        goto err_out;
  947|      1|    }
  948|       |
  949|      0|    if (!dvb_parse_path(stream)) {
  ------------------
  |  Branch (949:9): [True: 0, False: 0]
  ------------------
  950|      0|        mp_mutex_unlock(&global_dvb_state_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  951|      0|        goto err_out;
  952|      0|    }
  953|       |
  954|      0|    state->stream_used = true;
  955|      0|    mp_mutex_unlock(&global_dvb_state_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  956|       |
  957|      0|    if (!state->is_on) {
  ------------------
  |  Branch (957:9): [True: 0, False: 0]
  ------------------
  958|       |        // State could be already initialized, for example, we just did a channel switch.
  959|       |        // The following setup only has to be done once.
  960|       |
  961|      0|        state->cur_frontend = -1;
  962|       |
  963|      0|        if (!dvb_streaming_start(stream, priv->prog))
  ------------------
  |  Branch (963:13): [True: 0, False: 0]
  ------------------
  964|      0|            goto err_out;
  965|      0|    }
  966|       |
  967|      0|    stream->fill_buffer = dvb_streaming_read;
  968|      0|    stream->close = dvbin_close;
  969|      0|    stream->control = dvbin_stream_control;
  970|      0|    stream->streaming = true;
  971|      0|    stream->demuxer = "lavf";
  972|      0|    stream->lavf_type = "mpegts";
  973|       |
  974|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  975|       |
  976|      1|err_out:
  977|      1|    talloc_free(priv);
  ------------------
  |  |   47|      1|#define talloc_free                     ta_free
  ------------------
  978|      1|    stream->priv = NULL;
  979|      1|    return STREAM_ERROR;
  ------------------
  |  |   67|      1|#define STREAM_ERROR 0
  ------------------
  980|      0|}

mp_file_url_to_filename:
  176|   134k|{
  177|   134k|    bstr proto = mp_split_proto(url, &url);
  178|   134k|    if (bstrcasecmp0(proto, "file") != 0)
  ------------------
  |  Branch (178:9): [True: 133k, False: 863]
  ------------------
  179|   133k|        return NULL;
  180|    863|    char *filename = bstrto0(talloc_ctx, url);
  181|    863|    mp_url_unescape_inplace(filename);
  182|       |#if HAVE_DOS_PATHS
  183|       |    // extract '/' from '/x:/path'
  184|       |    if (filename[0] == '/' && filename[1] && filename[2] == ':')
  185|       |        memmove(filename, filename + 1, strlen(filename)); // including \0
  186|       |#endif
  187|    863|    return filename;
  188|   134k|}
stream_file.c:open_f:
  277|    447|{
  278|    447|    struct priv *p = talloc_ptrtype(stream, p);
  ------------------
  |  |   34|    447|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    447|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    447|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|    447|    *p = (struct priv) {
  280|    447|        .fd = -1,
  281|    447|    };
  282|    447|    stream->priv = p;
  283|    447|    stream->is_local_fs = true;
  284|       |
  285|    447|    bool strict_fs = args->flags & STREAM_LOCAL_FS_ONLY;
  ------------------
  |  |   54|    447|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  ------------------
  286|    447|    bool write = stream->mode == STREAM_WRITE;
  ------------------
  |  |   42|    447|#define STREAM_WRITE              (1 << 0)
  ------------------
  287|    447|    int m = O_CLOEXEC | (write ? O_RDWR | O_CREAT | O_TRUNC : O_RDONLY);
  ------------------
  |  Branch (287:26): [True: 0, False: 447]
  ------------------
  288|       |
  289|    447|    char *filename = stream->path;
  290|    447|    char *url = "";
  291|    447|    if (!strict_fs) {
  ------------------
  |  Branch (291:9): [True: 447, False: 0]
  ------------------
  292|    447|        char *fn = mp_file_url_to_filename(stream, bstr0(stream->url));
  293|    447|        if (fn)
  ------------------
  |  Branch (293:13): [True: 0, False: 447]
  ------------------
  294|      0|            filename = stream->path = fn;
  295|    447|        url = stream->url;
  296|    447|    }
  297|       |
  298|    447|    bool is_fdclose = strncmp(url, "fdclose://", 10) == 0;
  299|    447|    if (strncmp(url, "fd://", 5) == 0 || is_fdclose) {
  ------------------
  |  Branch (299:9): [True: 20, False: 427]
  |  Branch (299:42): [True: 0, False: 427]
  ------------------
  300|     20|        stream->is_local_fs = false;
  301|     20|        char *begin = strstr(stream->url, "://") + 3, *end = NULL;
  302|     20|        p->fd = strtol(begin, &end, 0);
  303|     20|        if (end == begin || end[0] || p->fd < 0) {
  ------------------
  |  Branch (303:13): [True: 10, False: 10]
  |  Branch (303:29): [True: 10, False: 0]
  |  Branch (303:39): [True: 0, False: 0]
  ------------------
  304|     20|            MP_ERR(stream, "Invalid FD number: %s\n", stream->url);
  ------------------
  |  |   89|     20|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     20|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  305|     20|            return STREAM_ERROR;
  ------------------
  |  |   67|     20|#define STREAM_ERROR 0
  ------------------
  306|     20|        }
  307|      0|#ifdef F_SETFD
  308|      0|        if (fcntl(p->fd, F_GETFD) == -1) {
  ------------------
  |  Branch (308:13): [True: 0, False: 0]
  ------------------
  309|      0|            MP_ERR(stream, "Invalid FD: %d\n", p->fd);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  310|      0|            return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  311|      0|        }
  312|      0|#endif
  313|      0|        if (is_fdclose)
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  ------------------
  314|      0|            p->close = true;
  315|    427|    } else if (!strict_fs && !strcmp(filename, "-")) {
  ------------------
  |  Branch (315:16): [True: 427, False: 0]
  |  Branch (315:30): [True: 10, False: 417]
  ------------------
  316|     10|        stream->is_local_fs = false;
  317|     10|        if (!write) {
  ------------------
  |  Branch (317:13): [True: 10, False: 0]
  ------------------
  318|     10|            MP_INFO(stream, "Reading from stdin...\n");
  ------------------
  |  |   91|     10|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     10|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  319|     10|            p->fd = 0;
  320|     10|        } else {
  321|      0|            MP_INFO(stream, "Writing to stdout...\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  322|      0|            p->fd = 1;
  323|      0|        }
  324|    417|    } else {
  325|    417|        if (bstr_startswith0(bstr0(stream->url), "appending://"))
  ------------------
  |  Branch (325:13): [True: 5, False: 412]
  ------------------
  326|      5|            p->appending = true;
  327|       |
  328|    417|        mode_t openmode = S_IRUSR | S_IWUSR;
  329|    417|#ifndef __MINGW32__
  330|    417|        openmode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
  331|    417|        if (!write)
  ------------------
  |  Branch (331:13): [True: 417, False: 0]
  ------------------
  332|    417|            m |= O_NONBLOCK;
  333|    417|#endif
  334|    417|        p->fd = open(filename, m | O_BINARY, openmode);
  ------------------
  |  |  269|    417|#define open(...) mp_open(__VA_ARGS__)
  ------------------
  335|    417|        if (p->fd < 0) {
  ------------------
  |  Branch (335:13): [True: 409, False: 8]
  ------------------
  336|    409|            MP_ERR(stream, "Cannot open file '%s': %s\n",
  ------------------
  |  |   89|    409|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    409|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  337|    409|                   filename, mp_strerror(errno));
  338|    409|            return STREAM_ERROR;
  ------------------
  |  |   67|    409|#define STREAM_ERROR 0
  ------------------
  339|    409|        }
  340|      8|        p->close = true;
  341|      8|    }
  342|       |
  343|     18|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  344|     18|    if (is_fdclose)
  ------------------
  |  Branch (344:9): [True: 0, False: 18]
  ------------------
  345|      0|        p->close = false;
  346|     18|    if (p->fd != 42) {
  ------------------
  |  Branch (346:9): [True: 18, False: 0]
  ------------------
  347|     18|        s_close(stream);
  348|     18|        return STREAM_ERROR;
  ------------------
  |  |   67|     18|#define STREAM_ERROR 0
  ------------------
  349|     18|    }
  350|      0|#endif
  351|       |
  352|      0|    struct stat st;
  353|      0|    bool is_sock_or_fifo = false;
  354|      0|    if (fstat(p->fd, &st) == 0) {
  ------------------
  |  Branch (354:9): [True: 0, False: 0]
  ------------------
  355|      0|        if (S_ISDIR(st.st_mode)) {
  ------------------
  |  Branch (355:13): [True: 0, False: 0]
  ------------------
  356|      0|            stream->is_directory = true;
  357|      0|        } else if (S_ISREG(st.st_mode)) {
  ------------------
  |  Branch (357:20): [True: 0, False: 0]
  ------------------
  358|      0|            p->regular_file = true;
  359|      0|            stream->is_regular = true;
  360|      0|#ifndef _WIN32
  361|       |            // O_NONBLOCK has weird semantics on file locks; remove it.
  362|      0|            int val = fcntl(p->fd, F_GETFL) & ~(unsigned)O_NONBLOCK;
  363|      0|            fcntl(p->fd, F_SETFL, val);
  364|      0|#endif
  365|      0|        } else {
  366|      0|#ifndef __MINGW32__
  367|      0|            is_sock_or_fifo = S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode);
  ------------------
  |  Branch (367:31): [True: 0, False: 0]
  |  Branch (367:55): [True: 0, False: 0]
  ------------------
  368|      0|#endif
  369|      0|            p->use_poll = true;
  370|      0|        }
  371|      0|    }
  372|       |
  373|       |#ifdef _WIN32
  374|       |    setmode(p->fd, O_BINARY);
  375|       |#endif
  376|       |
  377|      0|    off_t len = lseek(p->fd, 0, SEEK_END);
  378|      0|    lseek(p->fd, 0, SEEK_SET);
  379|      0|    if (len != (off_t)-1) {
  ------------------
  |  Branch (379:9): [True: 0, False: 0]
  ------------------
  380|      0|        stream->seek = seek;
  381|      0|        stream->seekable = true;
  382|      0|    }
  383|       |
  384|      0|    stream->fast_skip = true;
  385|      0|    stream->fill_buffer = fill_buffer;
  386|      0|    stream->write_buffer = write_buffer;
  387|      0|    stream->get_size = get_size;
  388|      0|    stream->close = s_close;
  389|       |
  390|      0|    if (is_sock_or_fifo || check_stream_network(p->fd)) {
  ------------------
  |  Branch (390:9): [True: 0, False: 0]
  |  Branch (390:28): [True: 0, False: 0]
  ------------------
  391|      0|        stream->streaming = true;
  392|       |#if HAVE_COCOA
  393|       |        if (fcntl(p->fd, F_RDAHEAD, 0) < 0) {
  394|       |            MP_VERBOSE(stream, "Cannot disable read ahead on file '%s': %s\n",
  395|       |                       filename, mp_strerror(errno));
  396|       |        }
  397|       |#endif
  398|      0|    }
  399|       |
  400|      0|    p->orig_size = get_size(stream);
  401|       |
  402|      0|    p->cancel = mp_cancel_new(p);
  403|      0|    if (stream->cancel)
  ------------------
  |  Branch (403:9): [True: 0, False: 0]
  ------------------
  404|      0|        mp_cancel_set_parent(p->cancel, stream->cancel);
  405|       |
  406|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  407|     18|}
stream_file.c:s_close:
  168|     18|{
  169|     18|    struct priv *p = s->priv;
  170|     18|    if (p->close)
  ------------------
  |  Branch (170:9): [True: 8, False: 10]
  ------------------
  171|      8|        close(p->fd);
  172|     18|}

mp_setup_av_network_options:
  158|  31.0k|{
  159|  31.0k|    void *temp = talloc_new(NULL);
  ------------------
  |  |   40|  31.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  31.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  160|  31.0k|    struct mp_network_opts *opts =
  161|  31.0k|        mp_get_config_group(temp, global, &mp_network_conf);
  162|       |
  163|       |    // HTTP specific options (other protocols ignore them)
  164|  31.0k|    if (opts->useragent)
  ------------------
  |  Branch (164:9): [True: 31.0k, False: 0]
  ------------------
  165|  31.0k|        av_dict_set(dict, "user_agent", opts->useragent, 0);
  166|  31.0k|    if (opts->cookies_enabled) {
  ------------------
  |  Branch (166:9): [True: 0, False: 31.0k]
  ------------------
  167|      0|        char *file = opts->cookies_file;
  168|      0|        if (file && file[0])
  ------------------
  |  Branch (168:13): [True: 0, False: 0]
  |  Branch (168:21): [True: 0, False: 0]
  ------------------
  169|      0|            file = mp_get_user_path(temp, global, file);
  170|      0|        char *cookies = cookies_lavf(temp, global, log, file);
  171|      0|        if (cookies && cookies[0])
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  |  Branch (171:24): [True: 0, False: 0]
  ------------------
  172|      0|            av_dict_set(dict, "cookies", cookies, 0);
  173|      0|    }
  174|  31.0k|    av_dict_set(dict, "tls_verify", opts->tls_verify ? "1" : "0", 0);
  ------------------
  |  Branch (174:37): [True: 31.0k, False: 0]
  ------------------
  175|  31.0k|    if (opts->tls_ca_file) {
  ------------------
  |  Branch (175:9): [True: 0, False: 31.0k]
  ------------------
  176|      0|        char *file = mp_get_user_path(temp, global, opts->tls_ca_file);
  177|      0|        av_dict_set(dict, "ca_file", file, 0);
  178|      0|    }
  179|  31.0k|    if (opts->tls_cert_file) {
  ------------------
  |  Branch (179:9): [True: 0, False: 31.0k]
  ------------------
  180|      0|        char *file = mp_get_user_path(temp, global, opts->tls_cert_file);
  181|      0|        av_dict_set(dict, "cert_file", file, 0);
  182|      0|    }
  183|  31.0k|    if (opts->tls_key_file) {
  ------------------
  |  Branch (183:9): [True: 0, False: 31.0k]
  ------------------
  184|      0|        char *file = mp_get_user_path(temp, global, opts->tls_key_file);
  185|      0|        av_dict_set(dict, "key_file", file, 0);
  186|      0|    }
  187|  31.0k|    char *cust_headers = talloc_strdup(temp, "");
  ------------------
  |  |   50|  31.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  188|  31.0k|    if (opts->referrer) {
  ------------------
  |  Branch (188:9): [True: 0, False: 31.0k]
  ------------------
  189|      0|        cust_headers = talloc_asprintf_append(cust_headers, "Referer: %s\r\n",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  190|      0|                                              opts->referrer);
  191|      0|    }
  192|  31.0k|    if (opts->http_header_fields) {
  ------------------
  |  Branch (192:9): [True: 0, False: 31.0k]
  ------------------
  193|      0|        for (int n = 0; opts->http_header_fields[n]; n++) {
  ------------------
  |  Branch (193:25): [True: 0, False: 0]
  ------------------
  194|      0|            cust_headers = talloc_asprintf_append(cust_headers, "%s\r\n",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  195|      0|                                                  opts->http_header_fields[n]);
  196|      0|        }
  197|      0|    }
  198|  31.0k|    if (strlen(cust_headers))
  ------------------
  |  Branch (198:9): [True: 0, False: 31.0k]
  ------------------
  199|      0|        av_dict_set(dict, "headers", cust_headers, 0);
  200|  31.0k|    av_dict_set(dict, "icy", "1", 0);
  201|       |    // So far, every known protocol uses microseconds for this
  202|       |    // Except rtsp.
  203|  31.0k|    if (opts->timeout > 0) {
  ------------------
  |  Branch (203:9): [True: 31.0k, False: 0]
  ------------------
  204|  31.0k|        if (target_fmt && strcmp(target_fmt, "rtsp") == 0) {
  ------------------
  |  Branch (204:13): [True: 0, False: 31.0k]
  |  Branch (204:27): [True: 0, False: 0]
  ------------------
  205|      0|            mp_verbose(log, "Broken FFmpeg RTSP API => not setting timeout.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  206|  31.0k|        } else {
  207|  31.0k|            char buf[80];
  208|  31.0k|            snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
  209|  31.0k|            av_dict_set(dict, "timeout", buf, 0);
  210|  31.0k|        }
  211|  31.0k|    }
  212|  31.0k|    if (opts->http_proxy && opts->http_proxy[0])
  ------------------
  |  Branch (212:9): [True: 0, False: 31.0k]
  |  Branch (212:29): [True: 0, False: 0]
  ------------------
  213|      0|        av_dict_set(dict, "http_proxy", opts->http_proxy, 0);
  214|       |
  215|  31.0k|    struct stream_lavf_opts *lavf_opts =
  216|  31.0k|        mp_get_config_group(temp, global, &stream_lavf_conf);
  217|  31.0k|    mp_set_avdict(dict, lavf_opts->avopts);
  218|       |
  219|  31.0k|    talloc_free(temp);
  ------------------
  |  |   47|  31.0k|#define talloc_free                     ta_free
  ------------------
  220|  31.0k|}
stream_lavf.c:open_f:
  332|  31.0k|{
  333|  31.0k|    AVIOContext *avio = NULL;
  334|  31.0k|    int res = STREAM_ERROR;
  ------------------
  |  |   67|  31.0k|#define STREAM_ERROR 0
  ------------------
  335|  31.0k|    AVDictionary *dict = NULL;
  336|  31.0k|    void *temp = talloc_new(NULL);
  ------------------
  |  |   40|  31.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  31.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  337|       |
  338|  31.0k|    stream->seek = NULL;
  339|  31.0k|    stream->seekable = false;
  340|       |
  341|  31.0k|    int flags = stream->mode == STREAM_WRITE ? AVIO_FLAG_WRITE : AVIO_FLAG_READ;
  ------------------
  |  |   42|  31.0k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (341:17): [True: 0, False: 31.0k]
  ------------------
  342|  31.0k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  343|  31.0k|    if (flags & AVIO_FLAG_WRITE)
  ------------------
  |  Branch (343:9): [True: 0, False: 31.0k]
  ------------------
  344|      0|        goto out;
  345|  31.0k|#endif
  346|       |
  347|  31.0k|    const char *filename = stream->url;
  348|  31.0k|    if (!filename) {
  ------------------
  |  Branch (348:9): [True: 0, False: 31.0k]
  ------------------
  349|      0|        MP_ERR(stream, "No URL\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  350|      0|        goto out;
  351|      0|    }
  352|  93.1k|    for (int i = 0; i < MP_ARRAY_SIZE(prefix); i++)
  ------------------
  |  |   49|  93.1k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (352:21): [True: 62.0k, False: 31.0k]
  ------------------
  353|  62.0k|        if (!strncmp(filename, prefix[i], strlen(prefix[i])))
  ------------------
  |  Branch (353:13): [True: 29.6k, False: 32.4k]
  ------------------
  354|  29.6k|            filename += strlen(prefix[i]);
  355|       |    // URLs that libavformat handles in a demuxer rather than in a protocol.
  356|       |    // The demuxer opens the URL itself, so there is no stream layer and
  357|       |    // demux_lavf does all the real work.
  358|  31.0k|    char *lavf_demuxer = NULL;
  359|  31.0k|    if (!strncmp(filename, "rtsp:", 5) || !strncmp(filename, "rtsps:", 6)) {
  ------------------
  |  Branch (359:9): [True: 8, False: 31.0k]
  |  Branch (359:43): [True: 1, False: 31.0k]
  ------------------
  360|      9|        lavf_demuxer = "rtsp";
  361|  31.0k|    } else if (!strncmp(filename, "rtp:", 4)) {
  ------------------
  |  Branch (361:16): [True: 2, False: 31.0k]
  ------------------
  362|      2|        lavf_demuxer = "rtp";
  363|      2|    }
  364|  31.0k|    if (lavf_demuxer) {
  ------------------
  |  Branch (364:9): [True: 11, False: 31.0k]
  ------------------
  365|     11|        stream->demuxer = "lavf";
  366|     11|        stream->lavf_type = lavf_demuxer;
  367|     11|        stream->streaming = true;
  368|     11|        if (stream->info->stream_origin == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|     11|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (368:13): [True: 0, False: 11]
  ------------------
  369|      0|            stream->is_network = true;
  370|     11|        talloc_free(temp);
  ------------------
  |  |   47|     11|#define talloc_free                     ta_free
  ------------------
  371|     11|        return STREAM_OK;
  ------------------
  |  |   68|     11|#define STREAM_OK    1
  ------------------
  372|     11|    }
  373|       |
  374|       |    // Replace "mms://" with "mmsh://", so that most mms:// URLs just work.
  375|       |    // Replace "dav://" or "webdav://" with "http://" and "davs://" or "webdavs://" with "https://"
  376|  31.0k|    bstr b_filename = bstr0(filename);
  377|  31.0k|    if (bstr_eatstart0(&b_filename, "mms://") ||
  ------------------
  |  Branch (377:9): [True: 1, False: 31.0k]
  ------------------
  378|  31.0k|        bstr_eatstart0(&b_filename, "mmshttp://"))
  ------------------
  |  Branch (378:9): [True: 2, False: 31.0k]
  ------------------
  379|      3|    {
  380|      3|        filename = talloc_asprintf(temp, "mmsh://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   52|      3|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      6|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|  31.0k|    } else if (bstr_eatstart0(&b_filename, "dav://") || bstr_eatstart0(&b_filename, "webdav://"))
  ------------------
  |  Branch (381:16): [True: 13, False: 31.0k]
  |  Branch (381:57): [True: 5, False: 31.0k]
  ------------------
  382|     18|    {
  383|     18|        filename = talloc_asprintf(temp, "http://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   52|     18|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     36|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|  31.0k|    } else if (bstr_eatstart0(&b_filename, "davs://") || bstr_eatstart0(&b_filename, "webdavs://"))
  ------------------
  |  Branch (384:16): [True: 5, False: 31.0k]
  |  Branch (384:58): [True: 1, False: 31.0k]
  ------------------
  385|      6|    {
  386|      6|        filename = talloc_asprintf(temp, "https://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   52|      6|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     12|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  387|      6|    }
  388|       |
  389|  31.0k|    av_dict_set(&dict, "reconnect", "1", 0);
  390|  31.0k|    av_dict_set(&dict, "reconnect_delay_max", "7", 0);
  391|       |
  392|  31.0k|    mp_setup_av_network_options(&dict, NULL, stream->global, stream->log);
  393|       |
  394|  31.0k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  395|  31.0k|    av_dict_set(&dict, "protocol_blacklist", "fd,pipe", 0);
  396|  31.0k|#endif
  397|       |
  398|  31.0k|    AVIOInterruptCB cb = {
  399|  31.0k|        .callback = interrupt_cb,
  400|  31.0k|        .opaque = stream,
  401|  31.0k|    };
  402|       |
  403|  31.0k|    filename = normalize_url(stream, filename);
  404|       |
  405|  31.0k|    if (strncmp(filename, "rtmp", 4) == 0) {
  ------------------
  |  Branch (405:9): [True: 2, False: 31.0k]
  ------------------
  406|      2|        stream->demuxer = "lavf";
  407|      2|        stream->lavf_type = "flv";
  408|       |        // Setting timeout enables listen mode - force it to disabled.
  409|      2|        av_dict_set(&dict, "timeout", "0", 0);
  410|      2|    }
  411|       |
  412|  31.0k|    int err = avio_open2(&avio, filename, flags, &cb, &dict);
  413|  31.0k|    if (err < 0) {
  ------------------
  |  Branch (413:9): [True: 566, False: 30.4k]
  ------------------
  414|    566|        if (err == AVERROR_PROTOCOL_NOT_FOUND)
  ------------------
  |  Branch (414:13): [True: 106, False: 460]
  ------------------
  415|    566|            MP_ERR(stream, "Protocol not found. Make sure"
  ------------------
  |  |   89|    106|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    106|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  416|    566|                   " FFmpeg is compiled with networking support.\n");
  417|    566|        goto out;
  418|    566|    }
  419|       |
  420|  30.4k|    mp_avdict_print_unset(stream->log, MSGL_V, dict);
  421|       |
  422|  30.4k|    if (avio->av_class) {
  ------------------
  |  Branch (422:9): [True: 30.4k, False: 0]
  ------------------
  423|  30.4k|        uint8_t *mt = NULL;
  424|  30.4k|        if (av_opt_get(avio, "mime_type", AV_OPT_SEARCH_CHILDREN, &mt) >= 0) {
  ------------------
  |  Branch (424:13): [True: 0, False: 30.4k]
  ------------------
  425|      0|            stream->mime_type = talloc_strdup(stream, mt);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  426|      0|            av_free(mt);
  427|      0|        }
  428|  30.4k|        uint8_t *location = NULL;
  429|  30.4k|        if (av_opt_get(avio, "location", AV_OPT_SEARCH_CHILDREN, &location) >= 0) {
  ------------------
  |  Branch (429:13): [True: 0, False: 30.4k]
  ------------------
  430|      0|            if (*location)
  ------------------
  |  Branch (430:17): [True: 0, False: 0]
  ------------------
  431|      0|                stream->effective_url = talloc_strdup(stream, location);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  432|      0|            av_free(location);
  433|      0|        }
  434|  30.4k|    }
  435|       |
  436|  30.4k|    stream->priv = avio;
  437|  30.4k|    stream->seekable = avio->seekable & AVIO_SEEKABLE_NORMAL;
  438|  30.4k|    stream->seek = stream->seekable ? seek : NULL;
  ------------------
  |  Branch (438:20): [True: 30.4k, False: 0]
  ------------------
  439|  30.4k|    stream->fill_buffer = fill_buffer;
  440|  30.4k|    stream->write_buffer = write_buffer;
  441|  30.4k|    stream->get_size = get_size;
  442|  30.4k|    stream->control = control;
  443|  30.4k|    stream->close = close_f;
  444|       |    // enable cache (should be avoided for files, but no way to detect this)
  445|  30.4k|    stream->streaming = true;
  446|  30.4k|    if (stream->info->stream_origin == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|  30.4k|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (446:9): [True: 1.41k, False: 29.0k]
  ------------------
  447|  1.41k|        stream->is_network = true;
  448|  30.4k|    res = STREAM_OK;
  ------------------
  |  |   68|  30.4k|#define STREAM_OK    1
  ------------------
  449|       |
  450|  31.0k|out:
  451|  31.0k|    av_dict_free(&dict);
  452|  31.0k|    talloc_free(temp);
  ------------------
  |  |   47|  31.0k|#define talloc_free                     ta_free
  ------------------
  453|  31.0k|    return res;
  454|  30.4k|}
stream_lavf.c:interrupt_cb:
  149|   423k|{
  150|   423k|    struct stream *stream = ctx;
  151|   423k|    return mp_cancel_test(stream->cancel);
  152|   423k|}
stream_lavf.c:normalize_url:
  320|  31.0k|{
  321|  31.0k|    bstr proto = mp_split_proto(bstr0(filename), NULL);
  322|   186k|    for (int n = 0; http_like[n]; n++) {
  ------------------
  |  Branch (322:21): [True: 155k, False: 31.0k]
  ------------------
  323|   155k|        if (bstr_equals0(proto, http_like[n]))
  ------------------
  |  Branch (323:13): [True: 27, False: 155k]
  ------------------
  324|       |            // Escape everything but reserved characters.
  325|       |            // Also don't double-scape, so include '%'.
  326|     27|            return mp_url_escape(ta_parent, filename, ":/?#[]@!$&'()*+,;=%");
  327|   155k|    }
  328|  31.0k|    return (char *)filename;
  329|  31.0k|}
stream_lavf.c:seek:
   75|  1.40M|{
   76|  1.40M|    AVIOContext *avio = s->priv;
   77|  1.40M|    if (avio_seek(avio, newpos, SEEK_SET) < 0) {
  ------------------
  |  Branch (77:9): [True: 1.40M, False: 78]
  ------------------
   78|  1.40M|        return 0;
   79|  1.40M|    }
   80|     78|    return 1;
   81|  1.40M|}
stream_lavf.c:fill_buffer:
   58|   388k|{
   59|   388k|    AVIOContext *avio = s->priv;
   60|   388k|    int r = avio_read_partial(avio, buffer, max_len);
   61|   388k|    return (r <= 0) ? -1 : r;
  ------------------
  |  Branch (61:12): [True: 355k, False: 33.3k]
  ------------------
   62|   388k|}
stream_lavf.c:get_size:
   84|  1.55M|{
   85|  1.55M|    AVIOContext *avio = s->priv;
   86|  1.55M|    return avio_size(avio);
   87|  1.55M|}
stream_lavf.c:control:
  102|  1.57M|{
  103|  1.57M|    AVIOContext *avio = s->priv;
  104|  1.57M|    switch(cmd) {
  ------------------
  |  Branch (104:12): [True: 1.57M, False: 0]
  ------------------
  105|      0|    case STREAM_CTRL_AVSEEK: {
  ------------------
  |  Branch (105:5): [True: 0, False: 1.57M]
  ------------------
  106|      0|        struct stream_avseek *c = arg;
  107|      0|        int64_t r = avio_seek_time(avio, c->stream_index, c->timestamp, c->flags);
  108|      0|        if (r >= 0) {
  ------------------
  |  Branch (108:13): [True: 0, False: 0]
  ------------------
  109|      0|            stream_drop_buffers(s);
  110|      0|            return 1;
  111|      0|        }
  112|      0|        break;
  113|      0|    }
  114|  23.2k|    case STREAM_CTRL_HAS_AVSEEK: {
  ------------------
  |  Branch (114:5): [True: 23.2k, False: 1.55M]
  ------------------
  115|       |        // Starting at some point, read_seek is always available, and runtime
  116|       |        // behavior decides whether it exists or not. FFmpeg's API doesn't
  117|       |        // return anything helpful to determine seekability upfront, so here's
  118|       |        // a hardcoded whitelist. Not our fault.
  119|       |        // In addition we also have to jump through ridiculous hoops just to
  120|       |        // get the fucking protocol name.
  121|  23.2k|        const char *proto = NULL;
  122|  23.2k|        if (avio->av_class && avio->av_class->child_next) {
  ------------------
  |  Branch (122:13): [True: 23.2k, False: 0]
  |  Branch (122:31): [True: 23.2k, False: 0]
  ------------------
  123|       |            // This usually yields the URLContext (why does it even exist?),
  124|       |            // which holds the name of the actual protocol implementation.
  125|  23.2k|            void *child = avio->av_class->child_next(avio, NULL);
  126|  23.2k|            AVClass *cl = child ? *(AVClass **)child : NULL;
  ------------------
  |  Branch (126:27): [True: 23.2k, False: 0]
  ------------------
  127|  23.2k|            if (cl && cl->item_name)
  ------------------
  |  Branch (127:17): [True: 23.2k, False: 0]
  |  Branch (127:23): [True: 23.2k, False: 0]
  ------------------
  128|  23.2k|                proto = cl->item_name(child);
  129|  23.2k|        }
  130|  23.2k|        static const char *const has_read_seek[] = {
  131|  23.2k|            "rtmp", "rtmpt", "rtmpe", "rtmpte", "rtmps", "rtmpts", "mmsh", 0};
  132|   186k|        for (int n = 0; has_read_seek[n]; n++) {
  ------------------
  |  Branch (132:25): [True: 162k, False: 23.2k]
  ------------------
  133|   162k|            if (avio->read_seek && proto && strcmp(proto, has_read_seek[n]) == 0)
  ------------------
  |  Branch (133:17): [True: 0, False: 162k]
  |  Branch (133:36): [True: 0, False: 0]
  |  Branch (133:45): [True: 0, False: 0]
  ------------------
  134|      0|                return 1;
  135|   162k|        }
  136|  23.2k|        break;
  137|  23.2k|    }
  138|  1.55M|    case STREAM_CTRL_GET_METADATA: {
  ------------------
  |  Branch (138:5): [True: 1.55M, False: 23.2k]
  ------------------
  139|  1.55M|        *(struct mp_tags **)arg = read_icy(s);
  140|  1.55M|        if (!*(struct mp_tags **)arg)
  ------------------
  |  Branch (140:13): [True: 1.55M, False: 0]
  ------------------
  141|  1.55M|            break;
  142|      0|        return 1;
  143|  1.55M|    }
  144|  1.57M|    }
  145|  1.57M|    return STREAM_UNSUPPORTED;
  ------------------
  |  |   66|  1.57M|#define STREAM_UNSUPPORTED -1
  ------------------
  146|  1.57M|}
stream_lavf.c:read_icy:
  457|  1.55M|{
  458|  1.55M|    AVIOContext *avio = s->priv;
  459|       |
  460|  1.55M|    if (!avio->av_class)
  ------------------
  |  Branch (460:9): [True: 0, False: 1.55M]
  ------------------
  461|      0|        return NULL;
  462|       |
  463|  1.55M|    uint8_t *icy_header = NULL;
  464|  1.55M|    if (av_opt_get(avio, "icy_metadata_headers", AV_OPT_SEARCH_CHILDREN,
  ------------------
  |  Branch (464:9): [True: 1.55M, False: 0]
  ------------------
  465|  1.55M|                   &icy_header) < 0)
  466|  1.55M|        icy_header = NULL;
  467|       |
  468|  1.55M|    uint8_t *icy_packet;
  469|  1.55M|    if (av_opt_get(avio, "icy_metadata_packet", AV_OPT_SEARCH_CHILDREN,
  ------------------
  |  Branch (469:9): [True: 1.55M, False: 0]
  ------------------
  470|  1.55M|                   &icy_packet) < 0)
  471|  1.55M|        icy_packet = NULL;
  472|       |
  473|       |    // Send a metadata update only 1. on start, and 2. on a new metadata packet.
  474|       |    // To detect new packages, set the icy_metadata_packet to "-" once we've
  475|       |    // read it (a bit hacky, but works).
  476|  1.55M|    struct mp_tags *res = NULL;
  477|  1.55M|    bstr packet = bstr0(icy_packet);
  478|  1.55M|    if (!bstr_equals0(packet, "-"))
  ------------------
  |  Branch (478:9): [True: 1.55M, False: 0]
  ------------------
  479|  1.55M|        res = mp_parse_icy_metadata(s, bstr0(icy_header), packet);
  480|       |
  481|  1.55M|    if (res)
  ------------------
  |  Branch (481:9): [True: 0, False: 1.55M]
  ------------------
  482|      0|        av_opt_set(avio, "icy_metadata_packet", "-", AV_OPT_SEARCH_CHILDREN);
  483|       |
  484|  1.55M|    av_free(icy_header);
  485|  1.55M|    av_free(icy_packet);
  486|  1.55M|    return res;
  487|  1.55M|}
stream_lavf.c:close_f:
   90|  30.4k|{
   91|  30.4k|    AVIOContext *avio = stream->priv;
   92|       |    /* NOTE: As of 2011 write streams must be manually flushed before close.
   93|       |     * Currently write_buffer() always flushes them after writing.
   94|       |     * avio_close() could return an error, but we have no way to return that
   95|       |     * with the current stream API.
   96|       |     */
   97|  30.4k|    if (avio)
  ------------------
  |  Branch (97:9): [True: 30.4k, False: 0]
  ------------------
   98|  30.4k|        avio_close(avio);
   99|  30.4k|}
stream_lavf.c:get_safe_protocols:
  250|  60.9k|{
  251|  60.9k|    int num = 0;
  252|  60.9k|    char **protocols = NULL;
  253|  60.9k|    char **ffmpeg_demuxers = mp_get_lavf_demuxers();
  254|  60.9k|    char **ffmpeg_protos = mp_get_lavf_protocols();
  255|       |
  256|   730k|    for (int i = 0; ffmpeg_protos[i]; i++) {
  ------------------
  |  Branch (256:21): [True: 670k, False: 60.9k]
  ------------------
  257|  12.8M|        for (int j = 0; safe_protos[j]; j++) {
  ------------------
  |  Branch (257:25): [True: 12.2M, False: 609k]
  ------------------
  258|  12.2M|            if (strcmp(ffmpeg_protos[i], safe_protos[j][0]) != 0)
  ------------------
  |  Branch (258:17): [True: 12.1M, False: 60.9k]
  ------------------
  259|  12.1M|                continue;
  260|   121k|            for (int k = 0; safe_protos[j][k]; k++)
  ------------------
  |  Branch (260:29): [True: 60.9k, False: 60.9k]
  ------------------
  261|  60.9k|                MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, safe_protos[j][k]));
  ------------------
  |  |  105|   121k|    do {                                            \
  |  |  106|  60.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.9k|    do {                                            \
  |  |  |  |   97|  60.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 60.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  60.9k|    do {                                                        \
  |  |  |  |  |  |   89|  60.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  60.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  60.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  60.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  60.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  60.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  60.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 60.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.9k|        (idxvar)++;                                 \
  |  |  109|  60.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.9k]
  |  |  ------------------
  ------------------
  262|  60.9k|            break;
  263|  12.2M|        }
  264|   670k|    }
  265|       |
  266|       |    // rtsp is a demuxer not protocol in ffmpeg so it is handled separately
  267|  22.2M|    for (int i = 0; ffmpeg_demuxers[i]; i++) {
  ------------------
  |  Branch (267:21): [True: 22.2M, False: 60.9k]
  ------------------
  268|  22.2M|        if (strcmp("rtsp", ffmpeg_demuxers[i]) == 0) {
  ------------------
  |  Branch (268:13): [True: 0, False: 22.2M]
  ------------------
  269|      0|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "rtsp"));
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  270|      0|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "rtsps"));
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  271|      0|            break;
  272|      0|        }
  273|  22.2M|    }
  274|       |
  275|  60.9k|    MP_TARRAY_APPEND(NULL, protocols, num, NULL);
  ------------------
  |  |  105|  60.9k|    do {                                            \
  |  |  106|  60.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.9k|    do {                                            \
  |  |  |  |   97|  60.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 60.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.9k|        (idxvar)++;                                 \
  |  |  109|  60.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.9k]
  |  |  ------------------
  ------------------
  276|       |
  277|  60.9k|    talloc_free(ffmpeg_demuxers);
  ------------------
  |  |   47|  60.9k|#define talloc_free                     ta_free
  ------------------
  278|  60.9k|    talloc_free(ffmpeg_protos);
  ------------------
  |  |   47|  60.9k|#define talloc_free                     ta_free
  ------------------
  279|       |
  280|  60.9k|    return protocols;
  281|  60.9k|}
stream_lavf.c:get_unsafe_protocols:
  284|  29.7k|{
  285|  29.7k|    int num = 0;
  286|  29.7k|    char **protocols = NULL;
  287|  29.7k|    char **safe_protocols = get_safe_protocols();
  288|  29.7k|    char **ffmpeg_protos = mp_get_lavf_protocols();
  289|       |
  290|   356k|    for (int i = 0; ffmpeg_protos[i]; i++) {
  ------------------
  |  Branch (290:21): [True: 327k, False: 29.7k]
  ------------------
  291|   327k|        bool safe_protocol = false;
  292|   624k|        for (int j = 0; safe_protocols[j]; j++) {
  ------------------
  |  Branch (292:25): [True: 327k, False: 297k]
  ------------------
  293|   327k|            if (strcmp(ffmpeg_protos[i], safe_protocols[j]) == 0) {
  ------------------
  |  Branch (293:17): [True: 29.7k, False: 297k]
  ------------------
  294|  29.7k|                safe_protocol = true;
  295|  29.7k|                break;
  296|  29.7k|            }
  297|   327k|        }
  298|       |        // Skip to avoid name conflict with builtin mpv protocol.
  299|   327k|        if (strcmp(ffmpeg_protos[i], "bluray") == 0 || strcmp(ffmpeg_protos[i], "dvd") == 0)
  ------------------
  |  Branch (299:13): [True: 0, False: 327k]
  |  Branch (299:56): [True: 0, False: 327k]
  ------------------
  300|      0|            continue;
  301|       |
  302|   327k|        if (!safe_protocol)
  ------------------
  |  Branch (302:13): [True: 297k, False: 29.7k]
  ------------------
  303|   297k|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, ffmpeg_protos[i]));
  ------------------
  |  |  105|   297k|    do {                                            \
  |  |  106|   297k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   297k|    do {                                            \
  |  |  |  |   97|   297k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   297k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   297k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   297k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 89.2k, False: 208k]
  |  |  |  |  ------------------
  |  |  |  |   99|   297k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  89.2k|    do {                                                        \
  |  |  |  |  |  |   89|  89.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  89.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  89.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  89.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  89.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  89.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  89.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 89.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   297k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 297k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   297k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   297k|        (idxvar)++;                                 \
  |  |  109|   297k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 297k]
  |  |  ------------------
  ------------------
  304|   327k|    }
  305|       |
  306|  29.7k|    MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "ffmpeg"));
  ------------------
  |  |  105|  29.7k|    do {                                            \
  |  |  106|  29.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.7k|    do {                                            \
  |  |  |  |   97|  29.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 29.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.7k|        (idxvar)++;                                 \
  |  |  109|  29.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.7k]
  |  |  ------------------
  ------------------
  307|  29.7k|    MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "lavf"));
  ------------------
  |  |  105|  29.7k|    do {                                            \
  |  |  106|  29.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.7k|    do {                                            \
  |  |  |  |   97|  29.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 29.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.7k|        (idxvar)++;                                 \
  |  |  109|  29.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.7k]
  |  |  ------------------
  ------------------
  308|       |
  309|  29.7k|    MP_TARRAY_APPEND(NULL, protocols, num, NULL);
  ------------------
  |  |  105|  29.7k|    do {                                            \
  |  |  106|  29.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.7k|    do {                                            \
  |  |  |  |   97|  29.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 29.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.7k|        (idxvar)++;                                 \
  |  |  109|  29.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.7k]
  |  |  ------------------
  ------------------
  310|       |
  311|  29.7k|    talloc_free(ffmpeg_protos);
  ------------------
  |  |   47|  29.7k|#define talloc_free                     ta_free
  ------------------
  312|  29.7k|    talloc_free(safe_protocols);
  ------------------
  |  |   47|  29.7k|#define talloc_free                     ta_free
  ------------------
  313|  29.7k|    return protocols;
  314|  29.7k|}

stream_memory_open:
   51|  60.8k|{
   52|  60.8k|    mp_assert(len >= 0);
  ------------------
  |  |   41|  60.8k|#define mp_assert assert
  ------------------
  |  Branch (52:5): [True: 60.8k, False: 0]
  ------------------
   53|       |
   54|  60.8k|    struct stream_open_args sargs = {
   55|  60.8k|        .global = global,
   56|  60.8k|        .url = "memory://",
   57|  60.8k|        .flags = STREAM_READ | STREAM_SILENT | STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   41|  60.8k|#define STREAM_READ               0
  ------------------
                      .flags = STREAM_READ | STREAM_SILENT | STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   44|  60.8k|#define STREAM_SILENT             (1 << 1)
  ------------------
                      .flags = STREAM_READ | STREAM_SILENT | STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   47|  60.8k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
   58|  60.8k|        .sinfo = &stream_info_memory,
   59|  60.8k|        .special_arg = &(bstr){data, len},
   60|  60.8k|    };
   61|       |
   62|  60.8k|    struct stream *s = NULL;
   63|  60.8k|    stream_create_with_args(&sargs, &s);
   64|  60.8k|    MP_HANDLE_OOM(s);
  ------------------
  |  |  206|  60.8k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  60.8k|        void *oom_p_ = (x);     \
  |  |  208|  60.8k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 60.8k]
  |  |  ------------------
  |  |  209|  60.8k|            abort();            \
  |  |  210|  60.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 60.8k]
  |  |  ------------------
  ------------------
   65|  60.8k|    return s;
   66|  60.8k|}
stream_memory.c:open2:
   22|  60.8k|{
   23|       |    // Initial data
   24|  60.8k|    bstr data = bstr0(stream->url);
   25|  60.8k|    bool use_hex = bstr_eatstart0(&data, "hex://");
   26|  60.8k|    if (!use_hex)
  ------------------
  |  Branch (26:9): [True: 60.8k, False: 32]
  ------------------
   27|  60.8k|        bstr_eatstart0(&data, "memory://");
   28|       |
   29|  60.8k|    if (args->special_arg)
  ------------------
  |  Branch (29:9): [True: 60.8k, False: 34]
  ------------------
   30|  60.8k|        data = *(bstr *)args->special_arg;
   31|       |
   32|  60.8k|    data = bstrdup(stream, data);
   33|       |
   34|  60.8k|    if (use_hex && !bstr_decode_hex(stream, data, &data)) {
  ------------------
  |  Branch (34:9): [True: 32, False: 60.8k]
  |  Branch (34:20): [True: 31, False: 1]
  ------------------
   35|     31|        MP_FATAL(stream, "Invalid data.\n");
  ------------------
  |  |   88|     31|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     31|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   36|     31|        return STREAM_ERROR;
  ------------------
  |  |   67|     31|#define STREAM_ERROR 0
  ------------------
   37|     31|    }
   38|       |
   39|  60.8k|    return stream_bstr_open2(stream, args, data);
   40|  60.8k|}

stream_mf.c:mf_stream_open:
   30|     96|{
   31|     96|    stream->demuxer = "mf";
   32|       |
   33|     96|    return STREAM_OK;
  ------------------
  |  |   68|     96|#define STREAM_OK    1
  ------------------
   34|     96|}

stream_null.c:open_s:
   26|     15|{
   27|     15|    return 1;
   28|     15|}

osd_create:
  159|  28.9k|{
  160|  28.9k|    static_assert(MAX_OSD_PARTS >= OSDTYPE_COUNT, "");
  161|       |
  162|  28.9k|    struct osd_state *osd = talloc_zero(NULL, struct osd_state);
  ------------------
  |  |   27|  28.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|  28.9k|    *osd = (struct osd_state) {
  164|  28.9k|        .opts_cache = m_config_cache_alloc(osd, global, &mp_osd_render_sub_opts),
  165|  28.9k|        .global = global,
  166|  28.9k|        .log = mp_log_new(osd, global->log, "osd"),
  167|  28.9k|        .force_video_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  28.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  28.9k|        .stats = stats_ctx_create(osd, global, "osd"),
  169|  28.9k|    };
  170|  28.9k|    mp_mutex_init(&osd->lock);
  171|  28.9k|    osd->opts = osd->opts_cache->opts;
  172|       |
  173|   202k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   202k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (173:21): [True: 173k, False: 28.9k]
  ------------------
  174|   173k|        struct osd_object *obj = talloc(osd, struct osd_object);
  ------------------
  |  |   26|   173k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   173k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   173k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|   173k|        *obj = (struct osd_object) {
  176|   173k|            .type = n,
  177|   173k|            .text = talloc_strdup(obj, ""),
  ------------------
  |  |   50|   173k|#define talloc_strdup                   ta_xstrdup
  ------------------
  178|   173k|            .progbar_state = {.type = -1},
  179|   173k|            .vo_change_id = 1,
  180|   173k|        };
  181|   173k|        osd->objs[n] = obj;
  182|   173k|    }
  183|       |
  184|  28.9k|    osd->objs[OSDTYPE_SUB]->is_sub = true;
  185|  28.9k|    osd->objs[OSDTYPE_SUB2]->is_sub = true;
  186|       |
  187|  28.9k|    return osd;
  188|  28.9k|}
osd_free:
  191|  28.9k|{
  192|  28.9k|    if (!osd)
  ------------------
  |  Branch (192:9): [True: 0, False: 28.9k]
  ------------------
  193|      0|        return;
  194|  28.9k|    osd_destroy_backend(osd);
  195|  28.9k|    talloc_free(osd->objs[OSDTYPE_EXTERNAL2]->image_overlay);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  196|  28.9k|    talloc_free(osd->objs[OSDTYPE_DISC_MENU]->image_overlay);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  197|  28.9k|    mp_mutex_destroy(&osd->lock);
  ------------------
  |  |  133|  28.9k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  198|  28.9k|    talloc_free(osd);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  199|  28.9k|}
osd_set_text:
  202|  2.06k|{
  203|  2.06k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  2.06k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  204|  2.06k|    struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
  205|  2.06k|    if (!text)
  ------------------
  |  Branch (205:9): [True: 2.06k, False: 0]
  ------------------
  206|  2.06k|        text = "";
  207|  2.06k|    if (strcmp(osd_obj->text, text) != 0) {
  ------------------
  |  Branch (207:9): [True: 0, False: 2.06k]
  ------------------
  208|      0|        talloc_free(osd_obj->text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  209|      0|        osd_obj->text = talloc_strdup(osd_obj, text);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  210|      0|        osd_obj->osd_changed = true;
  211|      0|        osd->want_redraw_notification = true;
  212|      0|    }
  213|  2.06k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  2.06k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  214|  2.06k|}
osd_get_render_subs_in_filter:
  229|  43.7k|{
  230|  43.7k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|  43.7k|    bool r = osd->render_subs_in_filter;
  232|  43.7k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|  43.7k|    return r;
  234|  43.7k|}
osd_set_force_video_pts:
  252|  44.1k|{
  253|       |    atomic_store(&osd->force_video_pts, video_pts);
  254|  44.1k|}
osd_set_bitmaps:
  279|  28.9k|{
  280|  28.9k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  281|  28.9k|    struct osd_object *obj = osd->objs[type];
  282|  28.9k|    talloc_free(obj->image_overlay);
  ------------------
  |  |   47|  28.9k|#define talloc_free                     ta_free
  ------------------
  283|  28.9k|    obj->image_overlay = sub_bitmaps_copy(NULL, imgs);
  284|  28.9k|    obj->vo_change_id += 1;
  285|  28.9k|    osd->want_redraw_notification = true;
  286|  28.9k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  287|  28.9k|}
osd_changed:
  508|  28.9k|{
  509|  28.9k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  28.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  510|  28.9k|    osd->objs[OSDTYPE_OSD]->osd_changed = true;
  511|  28.9k|    osd->want_redraw_notification = true;
  512|       |    // Done here for a lack of a better place.
  513|  28.9k|    m_config_cache_update(osd->opts_cache);
  514|  28.9k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  28.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  515|  28.9k|}
osd_query_and_reset_want_redraw:
  518|      2|{
  519|      2|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|      2|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  520|      2|    bool r = osd->want_redraw_notification;
  521|      2|    osd->want_redraw_notification = false;
  522|      2|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|      2|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  523|      2|    return r;
  524|      2|}
sub_bitmaps_copy:
  585|  28.9k|{
  586|  28.9k|    if (!in || !in->num_parts)
  ------------------
  |  Branch (586:9): [True: 28.9k, False: 0]
  |  Branch (586:16): [True: 0, False: 0]
  ------------------
  587|  28.9k|        return NULL;
  588|       |
  589|      0|    struct sub_bitmaps *res = talloc(NULL, struct sub_bitmaps);
  ------------------
  |  |   26|      0|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|      0|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|      0|    *res = *in;
  591|       |
  592|       |    // Note: the p_cache thing is a lie and unused.
  593|       |
  594|       |    // The bitmaps being refcounted is essential for performance, and for
  595|       |    // not invalidating in->parts[*].bitmap pointers.
  596|      0|    mp_assert(in->packed && in->packed->bufs[0]);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  ------------------
  597|       |
  598|      0|    res->packed = mp_image_new_ref(res->packed);
  599|      0|    talloc_steal(res, res->packed);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  600|       |
  601|      0|    res->parts = NULL;
  602|      0|    MP_RESIZE_ARRAY(res, res->parts, res->num_parts);
  ------------------
  |  |   88|      0|    do {                                                        \
  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  603|      0|    memcpy(res->parts, in->parts, sizeof(res->parts[0]) * res->num_parts);
  604|       |
  605|      0|    return res;
  606|      0|}

osd_destroy_backend:
   86|  28.9k|{
   87|   202k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   202k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (87:21): [True: 173k, False: 28.9k]
  ------------------
   88|   173k|        struct osd_object *obj = osd->objs[n];
   89|   173k|        destroy_ass_renderer(&obj->ass);
   90|   173k|        for (int i = 0; i < obj->num_externals; i++)
  ------------------
  |  Branch (90:25): [True: 0, False: 173k]
  ------------------
   91|      0|            destroy_external(obj->externals[i]);
   92|   173k|        obj->num_externals = 0;
   93|   173k|    }
   94|  28.9k|}
osd_set_external_remove_owner:
  648|  57.9k|{
  649|  57.9k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  650|  57.9k|    struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
  651|  57.9k|    for (int n = obj->num_externals - 1; n >= 0; n--) {
  ------------------
  |  Branch (651:42): [True: 0, False: 57.9k]
  ------------------
  652|      0|        struct osd_external *e = obj->externals[n];
  653|      0|        if (e->ov.owner == owner) {
  ------------------
  |  Branch (653:13): [True: 0, False: 0]
  ------------------
  654|      0|            destroy_external(e);
  655|      0|            MP_TARRAY_REMOVE_AT(obj->externals, obj->num_externals, n);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            obj->changed = true;
  657|      0|            osd->want_redraw_notification = true;
  658|      0|        }
  659|      0|    }
  660|  57.9k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  661|  57.9k|}
osd_libass.c:destroy_ass_renderer:
   65|   173k|{
   66|   173k|    if (ass->track)
  ------------------
  |  Branch (66:9): [True: 0, False: 173k]
  ------------------
   67|      0|        ass_free_track(ass->track);
   68|   173k|    ass->track = NULL;
   69|   173k|    if (ass->render)
  ------------------
  |  Branch (69:9): [True: 0, False: 173k]
  ------------------
   70|      0|        ass_renderer_done(ass->render);
   71|   173k|    ass->render = NULL;
   72|   173k|    if (ass->library)
  ------------------
  |  Branch (72:9): [True: 0, False: 173k]
  ------------------
   73|      0|        ass_library_done(ass->library);
   74|   173k|    ass->library = NULL;
   75|   173k|    talloc_free(ass->log);
  ------------------
  |  |   47|   173k|#define talloc_free                     ta_free
  ------------------
   76|       |    ass->log = NULL;
   77|   173k|}

ta_set_parent:
   88|   526M|{
   89|   526M|    struct ta_header *ch = get_header(ptr);
   90|   526M|    if (!ch)
  ------------------
  |  Branch (90:9): [True: 388k, False: 525M]
  ------------------
   91|   388k|        return;
   92|   525M|    struct ta_header *new_parent = get_header(ta_parent);
   93|       |    // Unlink from previous parent
   94|   525M|    if (ch->prev)
  ------------------
  |  Branch (94:9): [True: 502k, False: 525M]
  ------------------
   95|   502k|        ch->prev->next = ch->next;
   96|   525M|    if (ch->next)
  ------------------
  |  Branch (96:9): [True: 85.6M, False: 440M]
  ------------------
   97|  85.6M|        ch->next->prev = ch->prev;
   98|       |    // If ch was the first child, change child link of old parent
   99|   525M|    if (ch->parent) {
  ------------------
  |  Branch (99:9): [True: 119M, False: 406M]
  ------------------
  100|   119M|        assert(ch->parent->child == ch);
  ------------------
  |  Branch (100:9): [True: 119M, False: 18.4E]
  ------------------
  101|   119M|        ch->parent->child = ch->next;
  102|   119M|        if (ch->parent->child) {
  ------------------
  |  Branch (102:13): [True: 85.2M, False: 33.7M]
  ------------------
  103|  85.2M|            assert(!ch->parent->child->parent);
  ------------------
  |  Branch (103:13): [True: 85.2M, False: 18.4E]
  ------------------
  104|  85.2M|            ch->parent->child->parent = ch->parent;
  105|  85.2M|        }
  106|   119M|    }
  107|   525M|    ch->next = ch->prev = ch->parent = NULL;
  108|       |    // Link to new parent - insert at start of list (LIFO destructor order)
  109|   525M|    if (new_parent) {
  ------------------
  |  Branch (109:9): [True: 119M, False: 406M]
  ------------------
  110|   119M|        ch->next = new_parent->child;
  111|   119M|        if (ch->next) {
  ------------------
  |  Branch (111:13): [True: 85.7M, False: 33.7M]
  ------------------
  112|  85.7M|            ch->next->prev = ch;
  113|       |            ch->next->parent = NULL;
  114|  85.7M|        }
  115|   119M|        new_parent->child = ch;
  116|   119M|        ch->parent = new_parent;
  117|   119M|    }
  118|   525M|}
ta_alloc_size:
  136|   162M|{
  137|   162M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   162M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (137:9): [True: 0, False: 162M]
  ------------------
  138|      0|        return NULL;
  139|   162M|    struct ta_header *h = malloc(sizeof(union aligned_header) + size);
  140|   162M|    if (!h)
  ------------------
  |  Branch (140:9): [True: 0, False: 162M]
  ------------------
  141|      0|        return NULL;
  142|   162M|    *h = (struct ta_header) {.size = size};
  143|   162M|    ta_dbg_add(h);
  144|   162M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|   162M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  145|   162M|    ta_set_parent(ptr, ta_parent);
  146|   162M|    return ptr;
  147|   162M|}
ta_zalloc_size:
  153|  38.4M|{
  154|  38.4M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|  38.4M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (154:9): [True: 0, False: 38.4M]
  ------------------
  155|      0|        return NULL;
  156|  38.4M|    struct ta_header *h = calloc(1, sizeof(union aligned_header) + size);
  157|  38.4M|    if (!h)
  ------------------
  |  Branch (157:9): [True: 0, False: 38.4M]
  ------------------
  158|      0|        return NULL;
  159|  38.4M|    *h = (struct ta_header) {.size = size};
  160|  38.4M|    ta_dbg_add(h);
  161|  38.4M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  38.4M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  162|  38.4M|    ta_set_parent(ptr, ta_parent);
  163|  38.4M|    return ptr;
  164|  38.4M|}
ta_realloc_size:
  179|   132M|{
  180|   132M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   132M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (180:9): [True: 0, False: 132M]
  ------------------
  181|      0|        return NULL;
  182|   132M|    if (!size) {
  ------------------
  |  Branch (182:9): [True: 48.2k, False: 132M]
  ------------------
  183|  48.2k|        ta_free(ptr);
  184|  48.2k|        return NULL;
  185|  48.2k|    }
  186|   132M|    if (!ptr)
  ------------------
  |  Branch (186:9): [True: 126M, False: 6.14M]
  ------------------
  187|   126M|        return ta_alloc_size(ta_parent, size);
  188|  6.14M|    struct ta_header *h = get_header(ptr);
  189|  6.14M|    struct ta_header *old_h = h;
  190|  6.14M|    if (h->size == size)
  ------------------
  |  Branch (190:9): [True: 7, False: 6.14M]
  ------------------
  191|      7|        return ptr;
  192|  6.14M|    ta_dbg_remove(h);
  193|  6.14M|    h = realloc(h, sizeof(union aligned_header) + size);
  194|  18.4E|    ta_dbg_add(h ? h : old_h);
  ------------------
  |  Branch (194:16): [True: 6.14M, False: 18.4E]
  ------------------
  195|  6.14M|    if (!h)
  ------------------
  |  Branch (195:9): [True: 0, False: 6.14M]
  ------------------
  196|      0|        return NULL;
  197|  6.14M|    h->size = size;
  198|  6.14M|    if (h != old_h) {
  ------------------
  |  Branch (198:9): [True: 3.91M, False: 2.22M]
  ------------------
  199|       |        // Relink parent
  200|  3.91M|        if (h->parent)
  ------------------
  |  Branch (200:13): [True: 607k, False: 3.30M]
  ------------------
  201|   607k|            h->parent->child = h;
  202|       |        // Relink siblings
  203|  3.91M|        if (h->next)
  ------------------
  |  Branch (203:13): [True: 1.85M, False: 2.06M]
  ------------------
  204|  1.85M|            h->next->prev = h;
  205|  3.91M|        if (h->prev)
  ------------------
  |  Branch (205:13): [True: 2.37M, False: 1.53M]
  ------------------
  206|  2.37M|            h->prev->next = h;
  207|       |        // Relink children
  208|  3.91M|        if (h->child)
  ------------------
  |  Branch (208:13): [True: 414k, False: 3.50M]
  ------------------
  209|   414k|            h->child->parent = h;
  210|  3.91M|    }
  211|  6.14M|    return PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  6.14M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  212|  6.14M|}
ta_get_size:
  219|   469M|{
  220|   469M|    struct ta_header *h = get_header(ptr);
  221|   469M|    return h ? h->size : 0;
  ------------------
  |  Branch (221:12): [True: 220M, False: 248M]
  ------------------
  222|   469M|}
ta_free_children:
  228|   206M|{
  229|   206M|    struct ta_header *h = get_header(ptr);
  230|   324M|    while (h && h->child)
  ------------------
  |  Branch (230:12): [True: 324M, False: 3.24k]
  |  Branch (230:17): [True: 118M, False: 206M]
  ------------------
  231|   118M|        ta_free(PTR_FROM_HEADER(h->child));
  ------------------
  |  |   64|   118M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  232|   206M|}
ta_free:
  237|   224M|{
  238|   224M|    struct ta_header *h = get_header(ptr);
  239|   224M|    if (!h)
  ------------------
  |  Branch (239:9): [True: 23.6M, False: 200M]
  ------------------
  240|  23.6M|        return;
  241|   200M|    if (h->destructor)
  ------------------
  |  Branch (241:9): [True: 29.4M, False: 171M]
  ------------------
  242|  29.4M|        h->destructor(ptr);
  243|   200M|    ta_free_children(ptr);
  244|       |    ta_set_parent(ptr, NULL);
  245|   200M|    ta_dbg_remove(h);
  246|   200M|    free(h);
  247|   200M|}
ta_set_destructor:
  260|  29.4M|{
  261|  29.4M|    struct ta_header *h = get_header(ptr);
  262|  29.4M|    if (h)
  ------------------
  |  Branch (262:9): [True: 29.4M, False: 18.4E]
  ------------------
  263|  29.4M|        h->destructor = destructor;
  264|  29.4M|}
ta_dbg_set_loc:
  379|   206M|{
  380|   206M|    struct ta_header *h = get_header(ptr);
  381|   206M|    if (h)
  ------------------
  |  Branch (381:9): [True: 205M, False: 577k]
  ------------------
  382|   205M|        h->name = loc;
  383|   206M|    return ptr;
  384|   206M|}
ta_dbg_mark_as_string:
  389|   122M|{
  390|       |    // Specially handled by leak report code.
  391|   122M|    return ta_dbg_set_loc(ptr, &allocation_is_string);
  392|   122M|}
ta.c:get_header:
   73|  2.19G|{
   74|  2.19G|    struct ta_header *h = ptr ? PTR_TO_HEADER(ptr) : NULL;
  ------------------
  |  |   63|  1.51G|#define PTR_TO_HEADER(ptr) (&((union aligned_header *)(ptr) - 1)->ta)
  ------------------
  |  Branch (74:27): [True: 1.51G, False: 679M]
  ------------------
   75|  2.19G|    ta_dbg_check_header(h);
   76|  2.19G|    return h;
   77|  2.19G|}
ta.c:ta_dbg_check_header:
  289|  2.40G|{
  290|  2.40G|    if (h) {
  ------------------
  |  Branch (290:9): [True: 1.72G, False: 679M]
  ------------------
  291|  1.72G|        assert(h->canary == CANARY);
  ------------------
  |  Branch (291:9): [True: 1.72G, False: 18.4E]
  ------------------
  292|  1.72G|        if (h->parent) {
  ------------------
  |  Branch (292:13): [True: 517M, False: 1.20G]
  ------------------
  293|   517M|            assert(!h->prev);
  ------------------
  |  Branch (293:13): [True: 517M, False: 18.4E]
  ------------------
  294|   517M|            assert(h->parent->child == h);
  ------------------
  |  Branch (294:13): [True: 517M, False: 18.4E]
  ------------------
  295|   517M|        }
  296|  1.72G|    }
  297|  2.40G|}
ta.c:ta_dbg_add:
  276|   206M|{
  277|   206M|    h->canary = CANARY;
  ------------------
  |  |   50|   206M|#define CANARY 0xD3ADB3EF
  ------------------
  278|   206M|    if (enable_leak_check) {
  ------------------
  |  Branch (278:9): [True: 0, False: 206M]
  ------------------
  279|      0|        mp_mutex_lock(&ta_dbg_mutex);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  280|      0|        h->leak_next = &leak_node;
  281|      0|        h->leak_prev = leak_node.leak_prev;
  282|      0|        leak_node.leak_prev->leak_next = h;
  283|      0|        leak_node.leak_prev = h;
  284|      0|        mp_mutex_unlock(&ta_dbg_mutex);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  285|      0|    }
  286|   206M|}
ta.c:ta_dbg_remove:
  300|   206M|{
  301|   206M|    ta_dbg_check_header(h);
  302|   206M|    if (h->leak_next) { // assume checking for !=NULL invariant ok without lock
  ------------------
  |  Branch (302:9): [True: 0, False: 206M]
  ------------------
  303|      0|        mp_mutex_lock(&ta_dbg_mutex);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  304|      0|        h->leak_next->leak_prev = h->leak_prev;
  305|      0|        h->leak_prev->leak_next = h->leak_next;
  306|      0|        mp_mutex_unlock(&ta_dbg_mutex);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  307|       |        h->leak_next = h->leak_prev = NULL;
  308|      0|    }
  309|   206M|    h->canary = 0;
  310|   206M|}

client.c:ta_oom_p:
  162|   260k|{
  163|   260k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 260k]
  ------------------
  164|      0|        abort();
  165|   260k|    return p;
  166|   260k|}
command.c:ta_oom_p:
  162|   173k|{
  163|   173k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 173k]
  ------------------
  164|      0|        abort();
  165|   173k|    return p;
  166|   173k|}
configfiles.c:ta_oom_p:
  162|   136k|{
  163|   136k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 136k]
  ------------------
  164|      0|        abort();
  165|   136k|    return p;
  166|   136k|}
loadfile.c:ta_oom_p:
  162|   157k|{
  163|   157k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 157k]
  ------------------
  164|      0|        abort();
  165|   157k|    return p;
  166|   157k|}
main.c:ta_oom_p:
  162|  86.8k|{
  163|  86.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 86.8k]
  ------------------
  164|      0|        abort();
  165|  86.8k|    return p;
  166|  86.8k|}
osd.c:ta_oom_b:
  169|  44.3k|{
  170|  44.3k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 44.3k]
  ------------------
  171|      0|        abort();
  172|  44.3k|}
osd.c:ta_oom_p:
  162|   202k|{
  163|   202k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 202k]
  ------------------
  164|      0|        abort();
  165|   202k|    return p;
  166|   202k|}
screenshot.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
scripting.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
video.c:ta_oom_p:
  162|  9.69k|{
  163|  9.69k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 9.69k]
  ------------------
  164|      0|        abort();
  165|  9.69k|    return p;
  166|  9.69k|}
clipboard.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
clipboard-vo.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
stream.c:ta_oom_p:
  162|   123k|{
  163|   123k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 123k]
  ------------------
  164|      0|        abort();
  165|   123k|    return p;
  166|   123k|}
stream_cb.c:ta_oom_p:
  162|  29.8k|{
  163|  29.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 29.8k]
  ------------------
  164|      0|        abort();
  165|  29.8k|    return p;
  166|  29.8k|}
stream_file.c:ta_oom_p:
  162|    447|{
  163|    447|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 447]
  ------------------
  164|      0|        abort();
  165|    447|    return p;
  166|    447|}
stream_lavf.c:ta_oom_p:
  162|  62.0k|{
  163|  62.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 62.0k]
  ------------------
  164|      0|        abort();
  165|  62.0k|    return p;
  166|  62.0k|}
stream_lavf.c:ta_oom_s:
  175|     27|{
  176|     27|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 27]
  ------------------
  177|      0|        abort();
  178|     27|    return s;
  179|     27|}
stream_bstr.c:ta_oom_p:
  162|  60.8k|{
  163|  60.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 60.8k]
  ------------------
  164|      0|        abort();
  165|  60.8k|    return p;
  166|  60.8k|}
mp_image.c:ta_oom_p:
  162|   131k|{
  163|   131k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 131k]
  ------------------
  164|      0|        abort();
  165|   131k|    return p;
  166|   131k|}
mp_image_pool.c:ta_oom_p:
  162|  15.5k|{
  163|  15.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 15.5k]
  ------------------
  164|      0|        abort();
  165|  15.5k|    return p;
  166|  15.5k|}
vo.c:ta_oom_p:
  162|   109k|{
  163|   109k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 109k]
  ------------------
  164|      0|        abort();
  165|   109k|    return p;
  166|   109k|}
ta_talloc.c:ta_oom_b:
  169|   840k|{
  170|   840k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 840k]
  ------------------
  171|      0|        abort();
  172|   840k|}
ta_utils.c:ta_oom_b:
  169|   151M|{
  170|   151M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 151M]
  ------------------
  171|      0|        abort();
  172|   151M|}
ipc-unix.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
stream_dvb.c:ta_oom_p:
  162|      2|{
  163|      2|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2]
  ------------------
  164|      0|        abort();
  165|      2|    return p;
  166|      2|}
aframe.c:ta_oom_p:
  162|   979k|{
  163|   979k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 979k]
  ------------------
  164|      0|        abort();
  165|   979k|    return p;
  166|   979k|}
ao.c:ta_oom_p:
  162|  15.9k|{
  163|  15.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 15.9k]
  ------------------
  164|      0|        abort();
  165|  15.9k|    return p;
  166|  15.9k|}
buffer.c:ta_oom_p:
  162|  7.98k|{
  163|  7.98k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 7.98k]
  ------------------
  164|      0|        abort();
  165|  7.98k|    return p;
  166|  7.98k|}
codecs.c:ta_oom_p:
  162|  21.8k|{
  163|  21.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 21.8k]
  ------------------
  164|      0|        abort();
  165|  21.8k|    return p;
  166|  21.8k|}
msg.c:ta_oom_p:
  162|  2.90M|{
  163|  2.90M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.90M]
  ------------------
  164|      0|        abort();
  165|  2.90M|    return p;
  166|  2.90M|}
msg.c:ta_oom_s:
  175|   266k|{
  176|   266k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 266k]
  ------------------
  177|      0|        abort();
  178|   266k|    return s;
  179|   266k|}
playlist.c:ta_oom_p:
  162|   133k|{
  163|   133k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 133k]
  ------------------
  164|      0|        abort();
  165|   133k|    return p;
  166|   133k|}
stats.c:ta_oom_p:
  162|   536k|{
  163|   536k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 536k]
  ------------------
  164|      0|        abort();
  165|   536k|    return p;
  166|   536k|}
stats.c:ta_oom_s:
  175|  48.8k|{
  176|  48.8k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 48.8k]
  ------------------
  177|      0|        abort();
  178|  48.8k|    return s;
  179|  48.8k|}
tags.c:ta_oom_p:
  162|  59.6k|{
  163|  59.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 59.6k]
  ------------------
  164|      0|        abort();
  165|  59.6k|    return p;
  166|  59.6k|}
demux.c:ta_oom_p:
  162|  1.74M|{
  163|  1.74M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.74M]
  ------------------
  164|      0|        abort();
  165|  1.74M|    return p;
  166|  1.74M|}
demux_cue.c:ta_oom_p:
  162|    294|{
  163|    294|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 294]
  ------------------
  164|      0|        abort();
  165|    294|    return p;
  166|    294|}
demux_disc.c:ta_oom_p:
  162|  40.3k|{
  163|  40.3k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 40.3k]
  ------------------
  164|      0|        abort();
  165|  40.3k|    return p;
  166|  40.3k|}
demux_edl.c:ta_oom_p:
  162|  40.7k|{
  163|  40.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 40.7k]
  ------------------
  164|      0|        abort();
  165|  40.7k|    return p;
  166|  40.7k|}
demux_lavf.c:ta_oom_p:
  162|   114k|{
  163|   114k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 114k]
  ------------------
  164|      0|        abort();
  165|   114k|    return p;
  166|   114k|}
demux_lavf.c:ta_oom_s:
  175|     95|{
  176|     95|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 95]
  ------------------
  177|      0|        abort();
  178|     95|    return s;
  179|     95|}
demux_mf.c:ta_oom_p:
  162|  19.7k|{
  163|  19.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.7k]
  ------------------
  164|      0|        abort();
  165|  19.7k|    return p;
  166|  19.7k|}
demux_mkv.c:ta_oom_p:
  162|  40.1k|{
  163|  40.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 40.1k]
  ------------------
  164|      0|        abort();
  165|  40.1k|    return p;
  166|  40.1k|}
demux_playlist.c:ta_oom_p:
  162|   222k|{
  163|   222k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 222k]
  ------------------
  164|      0|        abort();
  165|   222k|    return p;
  166|   222k|}
ebml.c:ta_oom_p:
  162|    419|{
  163|    419|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 419]
  ------------------
  164|      0|        abort();
  165|    419|    return p;
  166|    419|}
packet.c:ta_oom_p:
  162|  1.48M|{
  163|  1.48M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.48M]
  ------------------
  164|      0|        abort();
  165|  1.48M|    return p;
  166|  1.48M|}
packet_pool.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
timeline.c:ta_oom_p:
  162|    173|{
  163|    173|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 173]
  ------------------
  164|      0|        abort();
  165|    173|    return p;
  166|    173|}
f_async_queue.c:ta_oom_p:
  162|  15.8k|{
  163|  15.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 15.8k]
  ------------------
  164|      0|        abort();
  165|  15.8k|    return p;
  166|  15.8k|}
f_decoder_wrapper.c:ta_oom_p:
  162|  21.8k|{
  163|  21.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 21.8k]
  ------------------
  164|      0|        abort();
  165|  21.8k|    return p;
  166|  21.8k|}
f_output_chain.c:ta_oom_p:
  162|  19.4k|{
  163|  19.4k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.4k]
  ------------------
  164|      0|        abort();
  165|  19.4k|    return p;
  166|  19.4k|}
filter.c:ta_oom_p:
  162|  2.60M|{
  163|  2.60M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.60M]
  ------------------
  164|      0|        abort();
  165|  2.60M|    return p;
  166|  2.60M|}
cmd.c:ta_oom_p:
  162|   173k|{
  163|   173k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 173k]
  ------------------
  164|      0|        abort();
  165|   173k|    return p;
  166|   173k|}
input.c:ta_oom_p:
  162|   144k|{
  163|   144k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 144k]
  ------------------
  164|      0|        abort();
  165|   144k|    return p;
  166|   144k|}
bstr.c:ta_oom_p:
  162|     32|{
  163|     32|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32]
  ------------------
  164|      0|        abort();
  165|     32|    return p;
  166|     32|}
charset_conv.c:ta_oom_p:
  162|   137k|{
  163|   137k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 137k]
  ------------------
  164|      0|        abort();
  165|   137k|    return p;
  166|   137k|}
dispatch.c:ta_oom_p:
  162|  60.8k|{
  163|  60.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 60.8k]
  ------------------
  164|      0|        abort();
  165|  60.8k|    return p;
  166|  60.8k|}
node.c:ta_oom_p:
  162|  86.8k|{
  163|  86.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 86.8k]
  ------------------
  164|      0|        abort();
  165|  86.8k|    return p;
  166|  86.8k|}
path_utils.c:ta_oom_s:
  175|  92.2k|{
  176|  92.2k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 92.2k]
  ------------------
  177|      0|        abort();
  178|  92.2k|    return s;
  179|  92.2k|}
path_utils.c:ta_oom_p:
  162|  94.6k|{
  163|  94.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 94.6k]
  ------------------
  164|      0|        abort();
  165|  94.6k|    return p;
  166|  94.6k|}
thread_pool.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
thread_tools.c:ta_oom_p:
  162|  92.4k|{
  163|  92.4k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 92.4k]
  ------------------
  164|      0|        abort();
  165|  92.4k|    return p;
  166|  92.4k|}
m_config_core.c:ta_oom_p:
  162|  11.8M|{
  163|  11.8M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.8M]
  ------------------
  164|      0|        abort();
  165|  11.8M|    return p;
  166|  11.8M|}
m_config_frontend.c:ta_oom_p:
  162|  42.9M|{
  163|  42.9M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 42.9M]
  ------------------
  164|      0|        abort();
  165|  42.9M|    return p;
  166|  42.9M|}
m_option.c:ta_oom_s:
  175|  86.8k|{
  176|  86.8k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 86.8k]
  ------------------
  177|      0|        abort();
  178|  86.8k|    return s;
  179|  86.8k|}
m_option.c:ta_oom_p:
  162|  4.39M|{
  163|  4.39M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.39M]
  ------------------
  164|      0|        abort();
  165|  4.39M|    return p;
  166|  4.39M|}
parse_configfile.c:ta_oom_p:
  162|  28.9k|{
  163|  28.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.9k]
  ------------------
  164|      0|        abort();
  165|  28.9k|    return p;
  166|  28.9k|}
path.c:ta_oom_p:
  162|   361k|{
  163|   361k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 361k]
  ------------------
  164|      0|        abort();
  165|   361k|    return p;
  166|   361k|}
audio.c:ta_oom_p:
  162|  12.1k|{
  163|  12.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.1k]
  ------------------
  164|      0|        abort();
  165|  12.1k|    return p;
  166|  12.1k|}
external_files.c:ta_oom_p:
  162|  43.6k|{
  163|  43.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 43.6k]
  ------------------
  164|      0|        abort();
  165|  43.6k|    return p;
  166|  43.6k|}
ad_dsd.c:ta_oom_p:
  162|  12.1k|{
  163|  12.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.1k]
  ------------------
  164|      0|        abort();
  165|  12.1k|    return p;
  166|  12.1k|}
ad_spdif.c:ta_oom_p:
  162|  12.1k|{
  163|  12.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.1k]
  ------------------
  164|      0|        abort();
  165|  12.1k|    return p;
  166|  12.1k|}
cue.c:ta_oom_p:
  162|    520|{
  163|    520|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 520]
  ------------------
  164|      0|        abort();
  165|    520|    return p;
  166|    520|}

ta_talloc_strdup_append_buffer:
   30|   407k|{
   31|   407k|    ta_xstrdup_append_buffer(&s, a);
  ------------------
  |  |  124|   407k|#define ta_xstrdup_append_buffer(...)   ta_oom_b(ta_strdup_append_buffer(__VA_ARGS__))
  ------------------
   32|   407k|    return s;
   33|   407k|}
ta_talloc_strndup_append_buffer:
   42|   407k|{
   43|   407k|    ta_xstrndup_append_buffer(&s, a, n);
  ------------------
  |  |  126|   407k|#define ta_xstrndup_append_buffer(...)  ta_oom_b(ta_strndup_append_buffer(__VA_ARGS__))
  ------------------
   44|   407k|    return s;
   45|   407k|}
ta_talloc_vasprintf_append_buffer:
   54|  26.0k|{
   55|  26.0k|    ta_xvasprintf_append_buffer(&s, fmt, ap);
  ------------------
  |  |  132|  26.0k|#define ta_xvasprintf_append_buffer(...) ta_oom_b(ta_vasprintf_append_buffer(__VA_ARGS__))
  ------------------
   56|  26.0k|    return s;
   57|  26.0k|}
ta_talloc_asprintf_append_buffer:
   70|  26.0k|{
   71|  26.0k|    char *res;
   72|  26.0k|    va_list ap;
   73|  26.0k|    va_start(ap, fmt);
   74|  26.0k|    res = talloc_vasprintf_append_buffer(s, fmt, ap);
  ------------------
  |  |   62|  26.0k|#define talloc_vasprintf_append_buffer  ta_talloc_vasprintf_append_buffer
  ------------------
   75|       |    va_end(ap);
   76|  26.0k|    return res;
   77|  26.0k|}

ta_calc_array_size:
   30|  13.1M|{
   31|  13.1M|    if (count > (((size_t)-1) / element_size))
  ------------------
  |  Branch (31:9): [True: 0, False: 13.1M]
  ------------------
   32|      0|        return (size_t)-1;
   33|  13.1M|    return element_size * count;
   34|  13.1M|}
ta_calc_prealloc_elems:
   41|  6.20M|{
   42|  6.20M|    if (nextidx >= ((size_t)-1) / 2 - 1)
  ------------------
  |  Branch (42:9): [True: 0, False: 6.20M]
  ------------------
   43|      0|        return (size_t)-1;
   44|  6.20M|    return (nextidx + 1) * 2;
   45|  6.20M|}
ta_new_context:
   50|   987k|{
   51|   987k|    return ta_alloc_size(ta_parent, 0);
   52|   987k|}
ta_steal_:
   58|  1.60M|{
   59|  1.60M|    ta_set_parent(ptr, ta_parent);
   60|  1.60M|    return ptr;
   61|  1.60M|}
ta_memdup:
   66|  1.24M|{
   67|  1.24M|    if (!ptr) {
  ------------------
  |  Branch (67:9): [True: 529k, False: 717k]
  ------------------
   68|   529k|        assert(!size);
  ------------------
  |  Branch (68:9): [True: 529k, False: 0]
  ------------------
   69|   529k|        return NULL;
   70|   529k|    }
   71|   717k|    void *res = ta_alloc_size(ta_parent, size);
   72|   717k|    if (!res)
  ------------------
  |  Branch (72:9): [True: 0, False: 717k]
  ------------------
   73|      0|        return NULL;
   74|   717k|    memcpy(res, ptr, size);
   75|   717k|    return res;
   76|   717k|}
ta_strdup:
  113|   133M|{
  114|   133M|    return ta_strndup(ta_parent, str, str ? strlen(str) : 0);
  ------------------
  |  Branch (114:39): [True: 115M, False: 18.1M]
  ------------------
  115|   133M|}
ta_strndup:
  123|   139M|{
  124|   139M|    if (!str)
  ------------------
  |  Branch (124:9): [True: 18.2M, False: 121M]
  ------------------
  125|  18.2M|        return NULL;
  126|   121M|    char *new = NULL;
  127|   121M|    strndup_append_at(&new, 0, str, n);
  128|   121M|    ta_set_parent(new, ta_parent);
  129|   121M|    return new;
  130|   139M|}
ta_strdup_append:
  137|  44.3k|{
  138|  44.3k|    return strndup_append_at(str, *str ? strlen(*str) : 0, a, (size_t)-1);
  ------------------
  |  Branch (138:35): [True: 44.3k, False: 0]
  ------------------
  139|  44.3k|}
ta_strdup_append_buffer:
  145|   407k|{
  146|   407k|    size_t size = ta_get_size(*str);
  147|   407k|    if (size > 0)
  ------------------
  |  Branch (147:9): [True: 407k, False: 0]
  ------------------
  148|   407k|        size -= 1;
  149|   407k|    return strndup_append_at(str, size, a, (size_t)-1);
  150|   407k|}
ta_strndup_append_buffer:
  164|   407k|{
  165|   407k|    size_t size = ta_get_size(*str);
  166|   407k|    if (size > 0)
  ------------------
  |  Branch (166:9): [True: 407k, False: 0]
  ------------------
  167|   407k|        size -= 1;
  168|   407k|    return strndup_append_at(str, size, a, n);
  169|   407k|}
ta_asprintf:
  204|   495k|{
  205|   495k|    char *res;
  206|   495k|    va_list ap;
  207|   495k|    va_start(ap, fmt);
  208|   495k|    res = ta_vasprintf(ta_parent, fmt, ap);
  209|       |    va_end(ap);
  210|   495k|    return res;
  211|   495k|}
ta_vasprintf:
  214|   495k|{
  215|   495k|    char *res = NULL;
  216|   495k|    ta_vasprintf_append_at(&res, 0, fmt, ap);
  217|   495k|    ta_set_parent(res, ta_parent);
  218|   495k|    if (!res) {
  ------------------
  |  Branch (218:9): [True: 0, False: 495k]
  ------------------
  219|      0|        ta_free(res);
  220|      0|        return NULL;
  221|      0|    }
  222|   495k|    return res;
  223|   495k|}
ta_vasprintf_append_buffer:
  262|  26.0k|{
  263|  26.0k|    size_t size = ta_get_size(*str);
  264|  26.0k|    if (size > 0)
  ------------------
  |  Branch (264:9): [True: 26.0k, False: 0]
  ------------------
  265|  26.0k|        size -= 1;
  266|  26.0k|    return ta_vasprintf_append_at(str, size, fmt, ap);
  267|  26.0k|}
ta_xmemdup:
  270|  1.24M|{
  271|  1.24M|    void *new = ta_memdup(ta_parent, ptr, size);
  272|  1.24M|    ta_oom_b(new || !ptr);
  ------------------
  |  Branch (272:14): [True: 715k, False: 529k]
  |  Branch (272:21): [True: 529k, False: 0]
  ------------------
  273|  1.24M|    return new;
  274|  1.24M|}
ta_xrealloc_size:
  277|  10.0M|{
  278|  10.0M|    ptr = ta_realloc_size(ta_parent, ptr, size);
  279|  10.0M|    ta_oom_b(ptr || !size);
  ------------------
  |  Branch (279:14): [True: 10.0M, False: 48.2k]
  |  Branch (279:21): [True: 48.2k, False: 0]
  ------------------
  280|  10.0M|    return ptr;
  281|  10.0M|}
ta_xstrdup:
  284|   133M|{
  285|   133M|    char *res = ta_strdup(ta_parent, str);
  286|   133M|    ta_oom_b(res || !str);
  ------------------
  |  Branch (286:14): [True: 115M, False: 18.1M]
  |  Branch (286:21): [True: 18.1M, False: 0]
  ------------------
  287|   133M|    return res;
  288|   133M|}
ta_xstrndup:
  291|  6.22M|{
  292|  6.22M|    char *res = ta_strndup(ta_parent, str, n);
  293|  6.22M|    ta_oom_b(res || !str);
  ------------------
  |  Branch (293:14): [True: 6.10M, False: 123k]
  |  Branch (293:21): [True: 123k, False: 0]
  ------------------
  294|  6.22M|    return res;
  295|  6.22M|}
ta_utils.c:strndup_append_at:
   82|   122M|{
   83|   122M|    assert(ta_get_size(*str) >= at);
  ------------------
  |  Branch (83:5): [True: 122M, False: 0]
  ------------------
   84|       |
   85|   122M|    if (!*str && !append)
  ------------------
  |  Branch (85:9): [True: 121M, False: 859k]
  |  Branch (85:18): [True: 0, False: 121M]
  ------------------
   86|      0|        return true; // stays NULL, but not an OOM condition
   87|       |
   88|   122M|    size_t real_len = append ? strnlen(append, append_len) : 0;
  ------------------
  |  Branch (88:23): [True: 122M, False: 0]
  ------------------
   89|   122M|    if (append_len > real_len)
  ------------------
  |  Branch (89:9): [True: 451k, False: 121M]
  ------------------
   90|   451k|        append_len = real_len;
   91|       |
   92|   122M|    if (ta_get_size(*str) < at + append_len + 1) {
  ------------------
  |  Branch (92:9): [True: 122M, False: 44.3k]
  ------------------
   93|   122M|        char *t = ta_realloc_size(NULL, *str, at + append_len + 1);
   94|   122M|        if (!t)
  ------------------
  |  Branch (94:13): [True: 0, False: 122M]
  ------------------
   95|      0|            return false;
   96|   122M|        *str = t;
   97|   122M|    }
   98|       |
   99|   122M|    if (append_len)
  ------------------
  |  Branch (99:9): [True: 121M, False: 743k]
  ------------------
  100|   121M|        memcpy(*str + at, append, append_len);
  101|       |
  102|   122M|    (*str)[at + append_len] = '\0';
  103|       |
  104|   122M|    ta_dbg_mark_as_string(*str);
  105|       |
  106|       |    return true;
  107|   122M|}
ta_utils.c:ta_vasprintf_append_at:
  174|   521k|{
  175|   521k|    assert(ta_get_size(*str) >= at);
  ------------------
  |  Branch (175:5): [True: 521k, False: 0]
  ------------------
  176|       |
  177|   521k|    int size;
  178|   521k|    va_list copy;
  179|   521k|    va_copy(copy, ap);
  180|   521k|    char c;
  181|   521k|    size = vsnprintf(&c, 1, fmt, copy);
  182|   521k|    va_end(copy);
  183|       |
  184|   521k|    if (size < 0)
  ------------------
  |  Branch (184:9): [True: 0, False: 521k]
  ------------------
  185|      0|        return false;
  186|       |
  187|   521k|    if (ta_get_size(*str) < at + size + 1) {
  ------------------
  |  Branch (187:9): [True: 521k, False: 0]
  ------------------
  188|   521k|        char *t = ta_realloc_size(NULL, *str, at + size + 1);
  189|   521k|        if (!t)
  ------------------
  |  Branch (189:13): [True: 0, False: 521k]
  ------------------
  190|      0|            return false;
  191|   521k|        *str = t;
  192|   521k|    }
  193|   521k|    vsnprintf(*str + at, size + 1, fmt, ap);
  194|       |
  195|   521k|    ta_dbg_mark_as_string(*str);
  196|       |
  197|       |    return true;
  198|   521k|}

mp_csp_guess_colorspace:
  191|    556|{
  192|    556|    return width >= 1280 || height > 576 ? PL_COLOR_SYSTEM_BT_709 : PL_COLOR_SYSTEM_BT_601;
  ------------------
  |  Branch (192:12): [True: 0, False: 556]
  |  Branch (192:29): [True: 0, False: 556]
  ------------------
  193|    556|}
mp_csp_guess_primaries:
  196|    556|{
  197|       |    // HD content
  198|    556|    if (width >= 1280 || height > 576)
  ------------------
  |  Branch (198:9): [True: 0, False: 556]
  |  Branch (198:26): [True: 0, False: 556]
  ------------------
  199|      0|        return PL_COLOR_PRIM_BT_709;
  200|       |
  201|    556|    switch (height) {
  202|      0|    case 576: // Typical PAL content, including anamorphic/squared
  ------------------
  |  Branch (202:5): [True: 0, False: 556]
  ------------------
  203|      0|        return PL_COLOR_PRIM_BT_601_625;
  204|       |
  205|      0|    case 480: // Typical NTSC content, including squared
  ------------------
  |  Branch (205:5): [True: 0, False: 556]
  ------------------
  206|      0|    case 486: // NTSC Pro or anamorphic NTSC
  ------------------
  |  Branch (206:5): [True: 0, False: 556]
  ------------------
  207|      0|        return PL_COLOR_PRIM_BT_601_525;
  208|       |
  209|    556|    default: // No good metric, just pick BT.709 to minimize damage
  ------------------
  |  Branch (209:5): [True: 556, False: 0]
  ------------------
  210|    556|        return PL_COLOR_PRIM_BT_709;
  211|    556|    }
  212|    556|}

vd_lavc.c:add_all_hwdec_methods:
  346|  7.79k|{
  347|  7.79k|    const AVCodec *codec = NULL;
  348|  7.79k|    void *iter = NULL;
  349|  3.91M|    while (1) {
  ------------------
  |  Branch (349:12): [True: 3.91M, Folded]
  ------------------
  350|  3.91M|        codec = av_codec_iterate(&iter);
  351|  3.91M|        if (!codec)
  ------------------
  |  Branch (351:13): [True: 7.79k, False: 3.90M]
  ------------------
  352|  7.79k|            break;
  353|  3.90M|        if (codec->type != AVMEDIA_TYPE_VIDEO || !av_codec_is_decoder(codec))
  ------------------
  |  Branch (353:13): [True: 1.91M, False: 1.99M]
  |  Branch (353:50): [True: 0, False: 1.99M]
  ------------------
  354|  1.91M|            continue;
  355|       |
  356|  1.99M|        struct hwdec_info info_template = {
  357|  1.99M|            .pix_fmt = AV_PIX_FMT_NONE,
  358|  1.99M|            .codec = codec,
  359|  1.99M|        };
  360|       |
  361|  1.99M|        const char *wrapper = NULL;
  362|  1.99M|        if (codec->capabilities & (AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_HYBRID))
  ------------------
  |  Branch (362:13): [True: 70.1k, False: 1.92M]
  ------------------
  363|  70.1k|            wrapper = codec->wrapper_name;
  364|       |
  365|       |        // A decoder can provide multiple methods. In particular, hwaccels
  366|       |        // provide various methods (e.g. native h264 with vaapi & d3d11), but
  367|       |        // even wrapper decoders could provide multiple methods.
  368|  1.99M|        bool found_any = false;
  369|  1.99M|        for (int n = 0; ; n++) {
  370|  1.99M|            const AVCodecHWConfig *cfg = avcodec_get_hw_config(codec, n);
  371|  1.99M|            if (!cfg)
  ------------------
  |  Branch (371:17): [True: 1.99M, False: 0]
  ------------------
  372|  1.99M|                break;
  373|       |
  374|      0|            if ((cfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) ||
  ------------------
  |  Branch (374:17): [True: 0, False: 0]
  ------------------
  375|      0|                (cfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
  ------------------
  |  Branch (375:17): [True: 0, False: 0]
  ------------------
  376|      0|            {
  377|      0|                struct hwdec_info info = info_template;
  378|      0|                info.lavc_device = cfg->device_type;
  379|      0|                info.pix_fmt = cfg->pix_fmt;
  380|       |
  381|      0|                const char *name = av_hwdevice_get_type_name(cfg->device_type);
  382|      0|                mp_assert(name); // API violation by libavcodec
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (382:17): [True: 0, False: 0]
  ------------------
  383|       |
  384|       |                // nvdec hwaccels and the cuvid full decoder clash with their
  385|       |                // naming, so fix it here; we also prefer nvdec for the hwaccel.
  386|      0|                if (strcmp(name, "cuda") == 0 && !wrapper)
  ------------------
  |  Branch (386:21): [True: 0, False: 0]
  |  Branch (386:50): [True: 0, False: 0]
  ------------------
  387|      0|                    name = "nvdec";
  388|       |
  389|      0|                snprintf(info.method_name, sizeof(info.method_name), "%s", name);
  390|       |
  391|       |                // Usually we want to prefer using hw_frames_ctx for true
  392|       |                // hwaccels only, but we actually don't have any way to detect
  393|       |                // those, so always use hw_frames_ctx if offered.
  394|      0|                if (cfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) {
  ------------------
  |  Branch (394:21): [True: 0, False: 0]
  ------------------
  395|      0|                    info.use_hw_frames = true;
  396|      0|                } else {
  397|      0|                    info.use_hw_device = true;
  398|      0|                }
  399|       |
  400|       |                // Direct variant.
  401|      0|                add_hwdec_item(infos, num_infos, info);
  402|       |
  403|       |                // Copy variant.
  404|      0|                info.copying = true;
  405|      0|                if (cfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
  ------------------
  |  Branch (405:21): [True: 0, False: 0]
  ------------------
  406|      0|                    info.use_hw_frames = false;
  407|      0|                    info.use_hw_device = true;
  408|      0|                }
  409|      0|                add_hwdec_item(infos, num_infos, info);
  410|       |
  411|      0|                found_any = true;
  412|      0|            } else if (cfg->methods & AV_CODEC_HW_CONFIG_METHOD_INTERNAL) {
  ------------------
  |  Branch (412:24): [True: 0, False: 0]
  ------------------
  413|      0|                struct hwdec_info info = info_template;
  414|      0|                info.pix_fmt = cfg->pix_fmt;
  415|       |
  416|      0|                const char *name = wrapper;
  417|      0|                if (!name)
  ------------------
  |  Branch (417:21): [True: 0, False: 0]
  ------------------
  418|      0|                    name = av_get_pix_fmt_name(info.pix_fmt);
  419|      0|                mp_assert(name); // API violation by libavcodec
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (419:17): [True: 0, False: 0]
  ------------------
  420|       |
  421|      0|                snprintf(info.method_name, sizeof(info.method_name), "%s", name);
  422|       |
  423|       |                // Direct variant.
  424|      0|                add_hwdec_item(infos, num_infos, info);
  425|       |
  426|       |                // Copy variant.
  427|      0|                info.copying = true;
  428|      0|                info.pix_fmt = AV_PIX_FMT_NONE; // trust it can do sw output
  429|      0|                add_hwdec_item(infos, num_infos, info);
  430|       |
  431|      0|                found_any = true;
  432|      0|            }
  433|      0|        }
  434|       |
  435|  1.99M|        if (!found_any && wrapper) {
  ------------------
  |  Branch (435:13): [True: 1.99M, False: 0]
  |  Branch (435:27): [True: 70.1k, False: 1.92M]
  ------------------
  436|       |            // We _know_ there's something supported here, usually outputting
  437|       |            // sw surfaces. E.g. mediacodec (before hw_device_ctx support).
  438|       |
  439|  70.1k|            struct hwdec_info info = info_template;
  440|  70.1k|            info.copying = true; // probably
  441|       |
  442|  70.1k|            snprintf(info.method_name, sizeof(info.method_name), "%s", wrapper);
  443|  70.1k|            add_hwdec_item(infos, num_infos, info);
  444|  70.1k|        }
  445|  1.99M|    }
  446|       |
  447|  7.79k|    qsort(*infos, *num_infos, sizeof(struct hwdec_info), hwdec_compare);
  448|  7.79k|}
vd_lavc.c:add_hwdec_item:
  321|  70.1k|{
  322|  70.1k|    if (info.copying)
  ------------------
  |  Branch (322:9): [True: 70.1k, False: 0]
  ------------------
  323|  70.1k|        mp_snprintf_cat(info.method_name, sizeof(info.method_name), "-copy");
  324|       |
  325|       |    // (Including the codec name in case this is a wrapper looks pretty dumb,
  326|       |    // but better not have them clash with hwaccels and others.)
  327|  70.1k|    snprintf(info.name, sizeof(info.name), "%s-%s",
  328|  70.1k|             info.codec->name, info.method_name);
  329|       |
  330|  70.1k|    info.rank = *num_infos;
  331|  70.1k|    info.auto_pos = INT_MAX;
  332|       |
  333|  1.33M|    for (int x = 0; hwdec_autoprobe_info[x].method_name; x++) {
  ------------------
  |  Branch (333:21): [True: 1.26M, False: 70.1k]
  ------------------
  334|  1.26M|        const struct autoprobe_info *entry = &hwdec_autoprobe_info[x];
  335|  1.26M|        if (strcmp(entry->method_name, info.method_name) == 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 1.26M]
  ------------------
  336|      0|            info.flags |= entry->flags;
  337|      0|            if (info.flags & HWDEC_FLAG_AUTO)
  ------------------
  |  Branch (337:17): [True: 0, False: 0]
  ------------------
  338|      0|                info.auto_pos = x;
  339|      0|        }
  340|  1.26M|    }
  341|       |
  342|  70.1k|    MP_TARRAY_APPEND(NULL, *infos, *num_infos, info);
  ------------------
  |  |  105|  70.1k|    do {                                            \
  |  |  106|  70.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  70.1k|    do {                                            \
  |  |  |  |   97|  70.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  70.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  70.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  70.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 23.3k, False: 46.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  70.1k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  23.3k|    do {                                                        \
  |  |  |  |  |  |   89|  23.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  23.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  23.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  23.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  23.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  23.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  23.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 23.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  70.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 70.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  70.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  70.1k|        (idxvar)++;                                 \
  |  |  109|  70.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 70.1k]
  |  |  ------------------
  ------------------
  343|  70.1k|}
vd_lavc.c:hwdec_compare:
  295|   101k|{
  296|   101k|    struct hwdec_info *h1 = (void *)p1;
  297|   101k|    struct hwdec_info *h2 = (void *)p2;
  298|       |
  299|   101k|    if (h1 == h2)
  ------------------
  |  Branch (299:9): [True: 0, False: 101k]
  ------------------
  300|      0|        return 0;
  301|       |
  302|       |    // Strictly put non-preferred hwdecs to the end of the list.
  303|   101k|    if ((h1->auto_pos == INT_MAX) != (h2->auto_pos == INT_MAX))
  ------------------
  |  Branch (303:9): [True: 0, False: 101k]
  ------------------
  304|      0|        return h1->auto_pos == INT_MAX ? 1 : -1;
  ------------------
  |  Branch (304:16): [True: 0, False: 0]
  ------------------
  305|       |    // List non-copying entries first, so --hwdec=auto takes them.
  306|   101k|    if (h1->copying != h2->copying)
  ------------------
  |  Branch (306:9): [True: 0, False: 101k]
  ------------------
  307|      0|        return h1->copying ? 1 : -1;
  ------------------
  |  Branch (307:16): [True: 0, False: 0]
  ------------------
  308|       |    // Order by autoprobe preference order.
  309|   101k|    if (h1->auto_pos != h2->auto_pos)
  ------------------
  |  Branch (309:9): [True: 0, False: 101k]
  ------------------
  310|      0|        return h1->auto_pos > h2->auto_pos ? 1 : -1;
  ------------------
  |  Branch (310:16): [True: 0, False: 0]
  ------------------
  311|       |    // Put hwdecs without hw_device_ctx last
  312|   101k|    if ((!!h1->lavc_device) != (!!h2->lavc_device))
  ------------------
  |  Branch (312:9): [True: 0, False: 101k]
  ------------------
  313|      0|        return h1->lavc_device ? -1 : 1;
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|       |    // Fallback sort order to make sorting stable.
  315|   101k|    return h1->rank > h2->rank ? 1 :-1;
  ------------------
  |  Branch (315:12): [True: 0, False: 101k]
  ------------------
  316|   101k|}
vd_lavc.c:create:
 1503|  7.79k|{
 1504|  7.79k|    struct mp_filter *vd = mp_filter_create(parent, &vd_lavc_filter);
 1505|  7.79k|    if (!vd)
  ------------------
  |  Branch (1505:9): [True: 0, False: 7.79k]
  ------------------
 1506|      0|        return NULL;
 1507|       |
 1508|  7.79k|    mp_filter_add_pin(vd, MP_PIN_IN, "in");
 1509|  7.79k|    mp_filter_add_pin(vd, MP_PIN_OUT, "out");
 1510|       |
 1511|  7.79k|    vd->log = mp_log_new(vd, parent->log, NULL);
 1512|       |
 1513|  7.79k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1514|  7.79k|    ctx->log = vd->log;
 1515|  7.79k|    ctx->opts_cache = m_config_cache_alloc(ctx, vd->global, &vd_lavc_conf);
 1516|  7.79k|    ctx->opts = ctx->opts_cache->opts;
 1517|  7.79k|    ctx->hwdec_opts_cache = m_config_cache_alloc(ctx, vd->global, &hwdec_conf);
 1518|  7.79k|    ctx->hwdec_opts = ctx->hwdec_opts_cache->opts;
 1519|  7.79k|    ctx->codec = codec;
 1520|  7.79k|    ctx->decoder = talloc_strdup(ctx, decoder);
  ------------------
  |  |   50|  7.79k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1521|  7.79k|    ctx->hwdec_swpool = mp_image_pool_new(ctx);
 1522|  7.79k|    ctx->dr_pool = mp_image_pool_new(ctx);
 1523|       |
 1524|  7.79k|    ctx->public.f = vd;
 1525|  7.79k|    ctx->public.control = control;
 1526|       |
 1527|  7.79k|    mp_mutex_init(&ctx->dr_lock);
 1528|       |
 1529|       |    // hwdec/DR
 1530|  7.79k|    struct mp_stream_info *info = mp_filter_find_stream_info(vd);
 1531|  7.79k|    if (info) {
  ------------------
  |  Branch (1531:9): [True: 7.79k, False: 0]
  ------------------
 1532|  7.79k|        ctx->hwdec_devs = info->hwdec_devs;
 1533|  7.79k|        ctx->vo = info->dr_vo;
 1534|  7.79k|        ctx->force_swdec = info->force_swdec;
 1535|  7.79k|    }
 1536|       |
 1537|  7.79k|    reinit(vd);
 1538|       |
 1539|  7.79k|    if (!ctx->avctx) {
  ------------------
  |  Branch (1539:9): [True: 125, False: 7.67k]
  ------------------
 1540|    125|        talloc_free(vd);
  ------------------
  |  |   47|    125|#define talloc_free                     ta_free
  ------------------
 1541|    125|        return NULL;
 1542|    125|    }
 1543|       |
 1544|  7.67k|    codec->codec_desc = ctx->avctx->codec_descriptor->long_name;
 1545|       |
 1546|  7.67k|    return &ctx->public;
 1547|  7.79k|}
vd_lavc.c:vd_lavc_destroy:
 1484|  7.79k|{
 1485|  7.79k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1486|       |
 1487|  7.79k|    uninit_avctx(vd);
 1488|       |
 1489|  7.79k|    mp_mutex_destroy(&ctx->dr_lock);
  ------------------
  |  |  133|  7.79k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1490|  7.79k|}
vd_lavc.c:uninit_avctx:
  937|  15.7k|{
  938|  15.7k|    vd_ffmpeg_ctx *ctx = vd->priv;
  939|       |
  940|  15.7k|    flush_all(vd);
  941|  15.7k|    av_frame_free(&ctx->pic);
  942|  15.7k|    mp_free_av_packet(&ctx->avpkt);
  943|  15.7k|    av_buffer_unref(&ctx->cached_hw_frames_ctx);
  944|       |
  945|  15.7k|    avcodec_free_context(&ctx->avctx);
  946|       |
  947|  15.7k|    av_buffer_unref(&ctx->hwdec_dev);
  948|       |
  949|  15.7k|    ctx->hwdec_failed = false;
  950|  15.7k|    ctx->hwdec_fail_count = 0;
  951|  15.7k|    ctx->max_delay_queue = 0;
  952|  15.7k|    ctx->hw_probing = false;
  953|  15.7k|    ctx->hwdec = (struct hwdec_info){0};
  954|       |    ctx->use_hwdec = false;
  955|  15.7k|}
vd_lavc.c:flush_all:
  918|  15.7k|{
  919|  15.7k|    vd_ffmpeg_ctx *ctx = vd->priv;
  920|       |
  921|  15.7k|    for (int n = 0; n < ctx->num_delay_queue; n++)
  ------------------
  |  Branch (921:21): [True: 0, False: 15.7k]
  ------------------
  922|      0|        talloc_free(ctx->delay_queue[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  923|  15.7k|    ctx->num_delay_queue = 0;
  924|       |
  925|  15.7k|    for (int n = 0; n < ctx->num_sent_packets; n++)
  ------------------
  |  Branch (925:21): [True: 0, False: 15.7k]
  ------------------
  926|      0|        talloc_free(ctx->sent_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  927|  15.7k|    ctx->num_sent_packets = 0;
  928|       |
  929|  15.7k|    for (int n = 0; n < ctx->num_requeue_packets; n++)
  ------------------
  |  Branch (929:21): [True: 0, False: 15.7k]
  ------------------
  930|      0|        talloc_free(ctx->requeue_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  931|  15.7k|    ctx->num_requeue_packets = 0;
  932|       |
  933|  15.7k|    reset_avctx(vd);
  934|  15.7k|}
vd_lavc.c:reset_avctx:
  905|  21.8k|{
  906|  21.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
  907|       |
  908|  21.8k|    if (ctx->avctx && avcodec_is_open(ctx->avctx))
  ------------------
  |  Branch (908:9): [True: 13.9k, False: 7.92k]
  |  Branch (908:23): [True: 13.7k, False: 125]
  ------------------
  909|  13.7k|        avcodec_flush_buffers(ctx->avctx);
  910|  21.8k|    ctx->flushing = false;
  911|  21.8k|    ctx->hwdec_request_reinit = false;
  912|       |    // Wait for the first keyframe after reset to ensure the decoder state is
  913|       |    // valid. Seeking should already jump to a keyframe, so this is safe.
  914|  21.8k|    ctx->wait_for_keyframe = ctx->use_hwdec ? HWDEC_WAIT_KEYFRAME_COUNT : 0;
  ------------------
  |  |   69|      0|#define HWDEC_WAIT_KEYFRAME_COUNT 96
  ------------------
  |  Branch (914:30): [True: 0, False: 21.8k]
  ------------------
  915|  21.8k|}
vd_lavc.c:vd_lavc_process:
 1467|   373k|{
 1468|   373k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1469|       |
 1470|   373k|    lavc_process(vd, &ctx->state, send_packet, receive_frame);
 1471|   373k|}
vd_lavc.c:send_packet:
 1224|   155k|{
 1225|   155k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1226|   155k|    AVCodecContext *avctx = ctx->avctx;
 1227|       |
 1228|   155k|    if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt)
  ------------------
  |  Branch (1228:9): [True: 0, False: 155k]
  |  Branch (1228:37): [True: 0, False: 0]
  ------------------
 1229|      0|        return AVERROR(EAGAIN); // cannot consume the packet
 1230|       |
 1231|   155k|    if (ctx->hwdec_failed)
  ------------------
  |  Branch (1231:9): [True: 0, False: 155k]
  ------------------
 1232|      0|        return AVERROR(EAGAIN);
 1233|       |
 1234|   155k|    if (!ctx->avctx)
  ------------------
  |  Branch (1234:9): [True: 0, False: 155k]
  ------------------
 1235|      0|        return AVERROR_EOF;
 1236|       |
 1237|   155k|    prepare_decoding(vd);
 1238|       |
 1239|   155k|    if (ctx->wait_for_keyframe > 0 && pkt) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 155k]
  |  Branch (1239:39): [True: 0, False: 0]
  ------------------
 1240|      0|        if (!pkt->keyframe && !ctx->intra_only) {
  ------------------
  |  Branch (1240:13): [True: 0, False: 0]
  |  Branch (1240:31): [True: 0, False: 0]
  ------------------
 1241|      0|            MP_DBG(vd, "Waiting for keyframe after reinit (dropping frame).\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1242|      0|            ctx->wait_for_keyframe--;
 1243|      0|            return 0;
 1244|      0|        }
 1245|      0|        ctx->wait_for_keyframe = 0;
 1246|      0|    }
 1247|       |
 1248|   155k|    if (avctx->skip_frame == AVDISCARD_ALL)
  ------------------
  |  Branch (1248:9): [True: 0, False: 155k]
  ------------------
 1249|      0|        return 0;
 1250|       |
 1251|   155k|    mp_set_av_packet(ctx->avpkt, pkt, &ctx->codec_timebase);
 1252|       |
 1253|   155k|    int ret = avcodec_send_packet(avctx, pkt ? ctx->avpkt : NULL);
  ------------------
  |  Branch (1253:42): [True: 149k, False: 6.12k]
  ------------------
 1254|   155k|    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
  ------------------
  |  Branch (1254:9): [True: 0, False: 155k]
  |  Branch (1254:35): [True: 0, False: 155k]
  ------------------
 1255|      0|        return ret;
 1256|       |
 1257|   155k|    if (ctx->hw_probing && ctx->num_sent_packets < 32 &&
  ------------------
  |  Branch (1257:9): [True: 0, False: 155k]
  |  Branch (1257:28): [True: 0, False: 0]
  ------------------
 1258|      0|        ctx->hwdec_opts->software_fallback <= 32)
  ------------------
  |  Branch (1258:9): [True: 0, False: 0]
  ------------------
 1259|      0|    {
 1260|      0|        pkt = pkt ? demux_copy_packet(vd->packet_pool, pkt) : NULL;
  ------------------
  |  Branch (1260:15): [True: 0, False: 0]
  ------------------
 1261|      0|        MP_TARRAY_APPEND(ctx, ctx->sent_packets, ctx->num_sent_packets, pkt);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1262|      0|    }
 1263|       |
 1264|   155k|    if (ret < 0)
  ------------------
  |  Branch (1264:9): [True: 51.9k, False: 103k]
  ------------------
 1265|  51.9k|        handle_err(vd);
 1266|   155k|    return ret;
 1267|   155k|}
vd_lavc.c:prepare_decoding:
 1184|   521k|{
 1185|   521k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1186|   521k|    AVCodecContext *avctx = ctx->avctx;
 1187|   521k|    struct vd_lavc_params *opts = ctx->opts;
 1188|       |
 1189|   521k|    if (!avctx)
  ------------------
  |  Branch (1189:9): [True: 0, False: 521k]
  ------------------
 1190|      0|        return;
 1191|       |
 1192|   521k|    int drop = ctx->framedrop_flags;
 1193|   521k|    if (drop == 1) {
  ------------------
  |  Branch (1193:9): [True: 0, False: 521k]
  ------------------
 1194|      0|        avctx->skip_frame = opts->framedrop;    // normal framedrop
 1195|   521k|    } else if (drop == 2) {
  ------------------
  |  Branch (1195:16): [True: 0, False: 521k]
  ------------------
 1196|      0|        avctx->skip_frame = AVDISCARD_NONREF;   // hr-seek framedrop
 1197|       |        // Can be much more aggressive for true intra codecs.
 1198|      0|        if (ctx->intra_only)
  ------------------
  |  Branch (1198:13): [True: 0, False: 0]
  ------------------
 1199|      0|            avctx->skip_frame = AVDISCARD_ALL;
 1200|   521k|    } else {
 1201|   521k|        avctx->skip_frame = ctx->skip_frame;    // normal playback
 1202|   521k|    }
 1203|       |
 1204|   521k|    if (ctx->hwdec_request_reinit)
  ------------------
  |  Branch (1204:9): [True: 0, False: 521k]
  ------------------
 1205|      0|        reset_avctx(vd);
 1206|   521k|}
vd_lavc.c:handle_err:
 1209|  54.2k|{
 1210|  54.2k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1211|  54.2k|    struct hwdec_opts *hwdec_opts = ctx->hwdec_opts;
 1212|       |
 1213|  54.2k|    MP_WARN(vd, "Error while decoding frame%s!\n",
  ------------------
  |  |   90|  54.2k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   108k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 54.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1214|  54.2k|            ctx->use_hwdec ? " (hardware decoding)" : "");
 1215|       |
 1216|  54.2k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (1216:9): [True: 0, False: 54.2k]
  ------------------
 1217|      0|        ctx->hwdec_fail_count += 1;
 1218|      0|        if (ctx->hwdec_fail_count >= hwdec_opts->software_fallback)
  ------------------
  |  Branch (1218:13): [True: 0, False: 0]
  ------------------
 1219|      0|            ctx->hwdec_failed = true;
 1220|      0|    }
 1221|  54.2k|}
vd_lavc.c:receive_frame:
 1345|   365k|{
 1346|   365k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1347|       |
 1348|   365k|    int ret = decode_frame(vd);
 1349|       |
 1350|   365k|    if (ctx->hwdec_failed) {
  ------------------
  |  Branch (1350:9): [True: 0, False: 365k]
  ------------------
 1351|       |        // Failed hardware decoding? Try the next one, and eventually software.
 1352|      0|        struct demux_packet **pkts = ctx->sent_packets;
 1353|      0|        int num_pkts = ctx->num_sent_packets;
 1354|      0|        ctx->sent_packets = NULL;
 1355|      0|        ctx->num_sent_packets = 0;
 1356|       |
 1357|       |        /*
 1358|       |         * We repeatedly force_fallback until we get an avctx, because there are
 1359|       |         * certain hwdecs that are really full decoders, and so if these fail,
 1360|       |         * they also fail to give us a valid avctx, and the early return path
 1361|       |         * here will simply give up on decoding completely if there is no
 1362|       |         * decoder. We should never hit an infinite loop as the hwdec list is
 1363|       |         * finite and we will eventually exhaust it and fall back to software
 1364|       |         * decoding (and in practice, most hwdecs are hwaccels and so the
 1365|       |         * decoder will successfully init even if the hwaccel fails later.)
 1366|       |         */
 1367|      0|        do {
 1368|      0|            force_fallback(vd);
 1369|      0|        } while (!ctx->avctx);
  ------------------
  |  Branch (1369:18): [True: 0, False: 0]
  ------------------
 1370|       |
 1371|      0|        ctx->requeue_packets = pkts;
 1372|      0|        ctx->num_requeue_packets = num_pkts;
 1373|       |
 1374|      0|        return 0; // force retry
 1375|      0|    }
 1376|       |
 1377|   365k|    if (ret == AVERROR(EAGAIN) && ctx->num_requeue_packets)
  ------------------
  |  Branch (1377:9): [True: 313k, False: 52.1k]
  |  Branch (1377:35): [True: 0, False: 313k]
  ------------------
 1378|      0|        return 0; // force retry, so send_queued_packet() gets called
 1379|       |
 1380|   365k|    if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF)
  ------------------
  |  Branch (1380:9): [True: 322k, False: 43.7k]
  |  Branch (1380:57): [True: 315k, False: 6.12k]
  ------------------
 1381|   315k|        return ret;
 1382|       |
 1383|  49.8k|    if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1383:9): [True: 6.12k, False: 43.7k]
  ------------------
 1384|  6.12k|        return ret;
 1385|       |
 1386|  43.7k|    struct mp_image *res = ctx->delay_queue[0];
 1387|  43.7k|    MP_TARRAY_REMOVE_AT(ctx->delay_queue, ctx->num_delay_queue, 0);
  ------------------
  |  |  143|  43.7k|    do {                                            \
  |  |  144|  43.7k|        size_t at_ = (at);                          \
  |  |  145|  43.7k|        assert(at_ < (idxvar));                     \
  |  |  146|  43.7k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  43.7k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  43.7k|        (idxvar)--;                                 \
  |  |  149|  43.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 43.7k]
  |  |  ------------------
  ------------------
  |  Branch (1387:5): [True: 43.7k, False: 0]
  ------------------
 1388|       |
 1389|  43.7k|    res = res ? mp_img_swap_to_native(res) : NULL;
  ------------------
  |  Branch (1389:11): [True: 43.7k, False: 0]
  ------------------
 1390|  43.7k|    if (!res)
  ------------------
  |  Branch (1390:9): [True: 0, False: 43.7k]
  ------------------
 1391|      0|        return AVERROR_UNKNOWN;
 1392|       |
 1393|  43.7k|    if (ctx->use_hwdec && ctx->hwdec.copying && res->hwctx) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 43.7k]
  |  Branch (1393:27): [True: 0, False: 0]
  |  Branch (1393:49): [True: 0, False: 0]
  ------------------
 1394|      0|        struct mp_image *sw = mp_image_hw_download(res, ctx->hwdec_swpool);
 1395|      0|        mp_image_unrefp(&res);
 1396|      0|        res = sw;
 1397|      0|        if (!res) {
  ------------------
  |  Branch (1397:13): [True: 0, False: 0]
  ------------------
 1398|      0|            MP_ERR(vd, "Could not copy back hardware decoded frame.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1399|      0|            ctx->hwdec_fail_count = INT_MAX - 1; // force fallback
 1400|      0|            handle_err(vd);
 1401|      0|            return AVERROR_UNKNOWN;
 1402|      0|        }
 1403|      0|    }
 1404|       |
 1405|  43.7k|    if (!ctx->hwdec_notified) {
  ------------------
  |  Branch (1405:9): [True: 1.00k, False: 42.7k]
  ------------------
 1406|  1.00k|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1406:13): [True: 0, False: 1.00k]
  ------------------
 1407|      0|            MP_INFO(vd, "Using hardware decoding (%s).\n",
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1408|      0|                    ctx->hwdec.method_name);
 1409|  1.00k|        } else {
 1410|  1.00k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  1.00k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.00k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1411|  1.00k|        }
 1412|  1.00k|        ctx->hwdec_notified = true;
 1413|  1.00k|    }
 1414|       |
 1415|  43.7k|    if (ctx->hw_probing) {
  ------------------
  |  Branch (1415:9): [True: 0, False: 43.7k]
  ------------------
 1416|      0|        for (int n = 0; n < ctx->num_sent_packets; n++)
  ------------------
  |  Branch (1416:25): [True: 0, False: 0]
  ------------------
 1417|      0|            demux_packet_pool_push(vd->packet_pool, ctx->sent_packets[n]);
 1418|      0|        ctx->num_sent_packets = 0;
 1419|      0|        ctx->hw_probing = false;
 1420|      0|    }
 1421|       |
 1422|  43.7k|    *out_frame = MAKE_FRAME(MP_FRAME_VIDEO, res);
  ------------------
  |  |   57|  43.7k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1423|  43.7k|    return 0;
 1424|  43.7k|}
vd_lavc.c:decode_frame:
 1283|   365k|{
 1284|   365k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1285|   365k|    AVCodecContext *avctx = ctx->avctx;
 1286|       |
 1287|   365k|    if (!avctx || ctx->force_eof)
  ------------------
  |  Branch (1287:9): [True: 0, False: 365k]
  |  Branch (1287:19): [True: 0, False: 365k]
  ------------------
 1288|      0|        return AVERROR_EOF;
 1289|       |
 1290|   365k|    prepare_decoding(vd);
 1291|       |
 1292|       |    // Re-send old packets (typically after a hwdec fallback during init).
 1293|   365k|    if (ctx->num_requeue_packets)
  ------------------
  |  Branch (1293:9): [True: 0, False: 365k]
  ------------------
 1294|      0|        send_queued_packet(vd);
 1295|       |
 1296|   365k|    int ret = avcodec_receive_frame(avctx, ctx->pic);
 1297|   365k|    if (ret < 0) {
  ------------------
  |  Branch (1297:9): [True: 322k, False: 43.7k]
  ------------------
 1298|   322k|        if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (1298:13): [True: 6.12k, False: 315k]
  ------------------
 1299|       |            // If flushing was initialized earlier and has ended now, make it
 1300|       |            // start over in case we get new packets at some point in the future.
 1301|       |            // This must take the delay queue into account, so avctx returns EOF
 1302|       |            // until the delay queue has been drained.
 1303|  6.12k|            if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1303:17): [True: 6.12k, False: 0]
  ------------------
 1304|  6.12k|                reset_avctx(vd);
 1305|   315k|        } else if (ret == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1305:20): [True: 313k, False: 2.26k]
  ------------------
 1306|       |            // just retry after caller writes a packet
 1307|   313k|        } else {
 1308|  2.26k|            handle_err(vd);
 1309|  2.26k|        }
 1310|   322k|        return ret;
 1311|   322k|    }
 1312|       |
 1313|  43.7k|    mp_codec_info_from_av(avctx, ctx->codec);
 1314|       |
 1315|       |    // If something was decoded successfully, it must return a frame with valid
 1316|       |    // data.
 1317|  43.7k|    mp_assert(ctx->pic->buf[0]);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 43.7k, False: 0]
  ------------------
 1318|       |
 1319|  43.7k|    struct mp_image *mpi = mp_image_from_av_frame(ctx->pic);
 1320|  43.7k|    if (!mpi) {
  ------------------
  |  Branch (1320:9): [True: 0, False: 43.7k]
  ------------------
 1321|      0|        av_frame_unref(ctx->pic);
 1322|      0|        return ret;
 1323|      0|    }
 1324|       |
 1325|  43.7k|    if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 43.7k]
  |  Branch (1325:39): [True: 0, False: 0]
  ------------------
 1326|      0|        MP_ERR(vd, "CUDA frame without data. This is a FFmpeg bug.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1327|      0|        talloc_free(mpi);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1328|      0|        handle_err(vd);
 1329|      0|        return AVERROR_BUG;
 1330|      0|    }
 1331|       |
 1332|  43.7k|    ctx->hwdec_fail_count = 0;
 1333|       |
 1334|  43.7k|    mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
 1335|  43.7k|    mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
 1336|  43.7k|    mpi->pkt_duration = mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
 1337|       |
 1338|  43.7k|    av_frame_unref(ctx->pic);
 1339|       |
 1340|  43.7k|    MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi);
  ------------------
  |  |  105|  43.7k|    do {                                            \
  |  |  106|  43.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  43.7k|    do {                                            \
  |  |  |  |   97|  43.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  43.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  43.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  43.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.00k, False: 42.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  43.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.00k|    do {                                                        \
  |  |  |  |  |  |   89|  1.00k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.00k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.00k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.00k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.00k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.00k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.00k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.00k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  43.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 43.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  43.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  43.7k|        (idxvar)++;                                 \
  |  |  109|  43.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43.7k]
  |  |  ------------------
  ------------------
 1341|  43.7k|    return ret;
 1342|  43.7k|}
vd_lavc.c:select_and_set_hwdec:
  504|  7.79k|{
  505|  7.79k|    vd_ffmpeg_ctx *ctx = vd->priv;
  506|  7.79k|    const char *codec = ctx->codec->codec;
  507|       |
  508|  7.79k|    m_config_cache_update(ctx->hwdec_opts_cache);
  509|       |
  510|  7.79k|    struct hwdec_info *hwdecs = NULL;
  511|  7.79k|    int num_hwdecs = 0;
  512|  7.79k|    add_all_hwdec_methods(&hwdecs, &num_hwdecs);
  513|       |
  514|  7.79k|    char **hwdec_api = ctx->hwdec_opts->hwdec_api;
  515|  7.79k|    for (int i = 0; hwdec_api && hwdec_api[i]; i++) {
  ------------------
  |  Branch (515:21): [True: 7.79k, False: 0]
  |  Branch (515:34): [True: 7.79k, False: 0]
  ------------------
  516|  7.79k|        bstr opt = bstr0(hwdec_api[i]);
  517|       |
  518|  7.79k|        bool hwdec_requested = !bstr_equals0(opt, "no");
  519|  7.79k|        bool hwdec_auto_safe = bstr_equals0(opt, "auto") ||
  ------------------
  |  Branch (519:32): [True: 0, False: 7.79k]
  ------------------
  520|  7.79k|                            bstr_equals0(opt, "auto-safe") ||
  ------------------
  |  Branch (520:29): [True: 0, False: 7.79k]
  ------------------
  521|  7.79k|                            bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (521:29): [True: 0, False: 7.79k]
  ------------------
  522|  7.79k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (522:29): [True: 0, False: 7.79k]
  ------------------
  523|  7.79k|                            bstr_equals0(opt, "yes") ||
  ------------------
  |  Branch (523:29): [True: 0, False: 7.79k]
  ------------------
  524|  7.79k|                            bstr_equals0(opt, "");
  ------------------
  |  Branch (524:29): [True: 0, False: 7.79k]
  ------------------
  525|  7.79k|        bool hwdec_auto_unsafe = bstr_equals0(opt, "auto-unsafe");
  526|  7.79k|        bool hwdec_auto_copy = bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (526:32): [True: 0, False: 7.79k]
  ------------------
  527|  7.79k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (527:29): [True: 0, False: 7.79k]
  ------------------
  528|  7.79k|                            bstr_equals0(opt, "auto-copy-unsafe");
  ------------------
  |  Branch (528:29): [True: 0, False: 7.79k]
  ------------------
  529|  7.79k|        bool hwdec_auto = hwdec_auto_unsafe || hwdec_auto_copy || hwdec_auto_safe;
  ------------------
  |  Branch (529:27): [True: 0, False: 7.79k]
  |  Branch (529:48): [True: 0, False: 7.79k]
  |  Branch (529:67): [True: 0, False: 7.79k]
  ------------------
  530|       |
  531|  7.79k|        if (!hwdec_requested) {
  ------------------
  |  Branch (531:13): [True: 7.79k, False: 0]
  ------------------
  532|  7.79k|            MP_VERBOSE(vd, "No hardware decoding requested.\n");
  ------------------
  |  |   92|  7.79k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.79k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  533|  7.79k|            break;
  534|  7.79k|        } else if (!hwdec_codec_allowed(vd, codec)) {
  ------------------
  |  Branch (534:20): [True: 0, False: 0]
  ------------------
  535|      0|            MP_VERBOSE(vd, "Not trying to use hardware decoding: codec %s is not "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  536|      0|                    "on whitelist.\n", codec);
  537|      0|            break;
  538|      0|        } else if (ctx->force_swdec) {
  ------------------
  |  Branch (538:20): [True: 0, False: 0]
  ------------------
  539|      0|            MP_VERBOSE(vd, "Not trying to use hardware decoding: disallowed\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  540|      0|            break;
  541|      0|        } else {
  542|      0|            bool hwdec_name_supported = false;  // relevant only if !hwdec_auto
  543|      0|            for (int n = 0; n < num_hwdecs; n++) {
  ------------------
  |  Branch (543:29): [True: 0, False: 0]
  ------------------
  544|      0|                struct hwdec_info *hwdec = &hwdecs[n];
  545|       |
  546|      0|                if (!hwdec_auto && !(bstr_equals0(opt, hwdec->method_name) ||
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  |  Branch (546:38): [True: 0, False: 0]
  ------------------
  547|      0|                                    bstr_equals0(opt, hwdec->name)))
  ------------------
  |  Branch (547:37): [True: 0, False: 0]
  ------------------
  548|      0|                    continue;
  549|      0|                hwdec_name_supported = true;
  550|       |
  551|      0|                bool already_attempted = false;
  552|      0|                for (int j = 0; j < ctx->num_attempted_hwdecs; j++) {
  ------------------
  |  Branch (552:33): [True: 0, False: 0]
  ------------------
  553|      0|                    if (bstr_equals0(ctx->attempted_hwdecs[j], hwdec->name)) {
  ------------------
  |  Branch (553:25): [True: 0, False: 0]
  ------------------
  554|      0|                        MP_DBG(vd, "Skipping previously attempted hwdec: %s\n",
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  555|      0|                               hwdec->name);
  556|      0|                        already_attempted = true;
  557|      0|                        break;
  558|      0|                    }
  559|      0|                }
  560|      0|                if (already_attempted)
  ------------------
  |  Branch (560:21): [True: 0, False: 0]
  ------------------
  561|      0|                    continue;
  562|       |
  563|      0|                const char *hw_codec = mp_codec_from_av_codec_id(hwdec->codec->id);
  564|      0|                if (!hw_codec || strcmp(hw_codec, codec) != 0)
  ------------------
  |  Branch (564:21): [True: 0, False: 0]
  |  Branch (564:34): [True: 0, False: 0]
  ------------------
  565|      0|                    continue;
  566|       |
  567|      0|                if (hwdec_auto_safe && !(hwdec->flags & HWDEC_FLAG_WHITELIST))
  ------------------
  |  Branch (567:21): [True: 0, False: 0]
  |  Branch (567:40): [True: 0, False: 0]
  ------------------
  568|      0|                    continue;
  569|       |
  570|      0|                MP_VERBOSE(vd, "Looking at hwdec %s...\n", hwdec->name);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  571|       |
  572|       |                /*
  573|       |                 * Past this point, any kind of failure that results in us
  574|       |                 * looking for a new hwdec should not lead to use trying this
  575|       |                 * hwdec again - so add it to the list, regardless of whether
  576|       |                 * initialisation will succeed or not.
  577|       |                 */
  578|      0|                MP_TARRAY_APPEND(ctx, ctx->attempted_hwdecs,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  579|      0|                                 ctx->num_attempted_hwdecs,
  580|      0|                                 bstrdup(ctx, bstr0(hwdec->name)));
  581|       |
  582|      0|                if (hwdec_auto_copy && !hwdec->copying) {
  ------------------
  |  Branch (582:21): [True: 0, False: 0]
  |  Branch (582:40): [True: 0, False: 0]
  ------------------
  583|      0|                    MP_VERBOSE(vd, "Not using this for auto-copy.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  584|      0|                    continue;
  585|      0|                }
  586|       |
  587|      0|                if (hwdec->lavc_device) {
  ------------------
  |  Branch (587:21): [True: 0, False: 0]
  ------------------
  588|      0|                    ctx->hwdec_dev = hwdec_create_dev(vd, hwdec, hwdec_auto);
  589|      0|                    if (!ctx->hwdec_dev) {
  ------------------
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|                        MP_VERBOSE(vd, "Could not create device.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  591|      0|                        continue;
  592|      0|                    }
  593|       |
  594|      0|                    const struct hwcontext_fns *fns =
  595|      0|                                hwdec_get_hwcontext_fns(hwdec->lavc_device);
  596|      0|                    if (fns && fns->is_codec_allowed &&
  ------------------
  |  Branch (596:25): [True: 0, False: 0]
  |  Branch (596:32): [True: 0, False: 0]
  ------------------
  597|      0|                        !fns->is_codec_allowed(ctx->hwdec_dev, hwdec->codec->id))
  ------------------
  |  Branch (597:25): [True: 0, False: 0]
  ------------------
  598|      0|                    {
  599|      0|                        MP_WARN(vd, "Hardware decoding of '%s' is disabled on this "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  600|      0|                                    "device.\n", codec);
  601|      0|                        av_buffer_unref(&ctx->hwdec_dev);
  602|      0|                        continue;
  603|      0|                    }
  604|      0|                    if (fns && fns->is_emulated && fns->is_emulated(ctx->hwdec_dev)) {
  ------------------
  |  Branch (604:25): [True: 0, False: 0]
  |  Branch (604:32): [True: 0, False: 0]
  |  Branch (604:52): [True: 0, False: 0]
  ------------------
  605|      0|                        if (hwdec_auto) {
  ------------------
  |  Branch (605:29): [True: 0, False: 0]
  ------------------
  606|      0|                            MP_VERBOSE(vd, "Not using emulated API.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  607|      0|                            av_buffer_unref(&ctx->hwdec_dev);
  608|      0|                            continue;
  609|      0|                        }
  610|      0|                        MP_WARN(vd, "Using emulated hardware decoding API.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  611|      0|                    }
  612|      0|                } else if (!hwdec->copying) {
  ------------------
  |  Branch (612:28): [True: 0, False: 0]
  ------------------
  613|       |                    // Most likely METHOD_INTERNAL, which often use delay-loaded
  614|       |                    // VO support as well.
  615|      0|                    if (ctx->hwdec_devs) {
  ------------------
  |  Branch (615:25): [True: 0, False: 0]
  ------------------
  616|      0|                        struct hwdec_imgfmt_request params = {
  617|      0|                            .imgfmt = pixfmt2imgfmt(hwdec->pix_fmt),
  618|      0|                            .probing = hwdec_auto,
  619|      0|                        };
  620|      0|                        hwdec_devices_request_for_img_fmt(
  621|      0|                            ctx->hwdec_devs, &params);
  622|      0|                    }
  623|      0|                }
  624|       |
  625|      0|                ctx->use_hwdec = true;
  626|      0|                ctx->hwdec = *hwdec;
  627|      0|                break;
  628|      0|            }
  629|      0|            if (ctx->use_hwdec)
  ------------------
  |  Branch (629:17): [True: 0, False: 0]
  ------------------
  630|      0|                break;
  631|      0|            else if (!hwdec_auto && !hwdec_name_supported)
  ------------------
  |  Branch (631:22): [True: 0, False: 0]
  |  Branch (631:37): [True: 0, False: 0]
  ------------------
  632|      0|                MP_WARN(vd, "Unsupported hwdec: %.*s\n", BSTR_P(opt));
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|      0|        }
  634|  7.79k|    }
  635|  7.79k|    talloc_free(hwdecs);
  ------------------
  |  |   47|  7.79k|#define talloc_free                     ta_free
  ------------------
  636|       |
  637|       |
  638|  7.79k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (638:9): [True: 0, False: 7.79k]
  ------------------
  639|      0|        MP_VERBOSE(vd, "Trying hardware decoding via %s.\n", ctx->hwdec.name);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  640|      0|        if (strcmp(ctx->decoder, ctx->hwdec.codec->name) != 0)
  ------------------
  |  Branch (640:13): [True: 0, False: 0]
  ------------------
  641|      0|            MP_VERBOSE(vd, "Using underlying hw-decoder '%s'\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  642|      0|                       ctx->hwdec.codec->name);
  643|  7.79k|    } else {
  644|       |        // If software fallback is disabled and we get here, all hwdec must
  645|       |        // have failed. Tell the ctx to always force an eof.
  646|  7.79k|        if (ctx->hwdec_opts->software_fallback == INT_MAX) {
  ------------------
  |  Branch (646:13): [True: 0, False: 7.79k]
  ------------------
  647|      0|            MP_WARN(ctx, "Software decoding fallback is disabled.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  648|      0|            ctx->force_eof = true;
  649|  7.79k|        } else {
  650|  7.79k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  7.79k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.79k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  651|  7.79k|        }
  652|  7.79k|    }
  653|  7.79k|}
vd_lavc.c:init_avctx:
  728|  7.79k|{
  729|  7.79k|    vd_ffmpeg_ctx *ctx = vd->priv;
  730|  7.79k|    struct vd_lavc_params *lavc_param = ctx->opts;
  731|  7.79k|    struct mp_codec_params *c = ctx->codec;
  732|       |
  733|  7.79k|    m_config_cache_update(ctx->opts_cache);
  734|       |
  735|  7.79k|    mp_assert(!ctx->avctx);
  ------------------
  |  |   41|  7.79k|#define mp_assert assert
  ------------------
  |  Branch (735:5): [True: 7.79k, False: 0]
  ------------------
  736|       |
  737|  7.79k|    const AVCodec *lavc_codec = NULL;
  738|       |
  739|  7.79k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (739:9): [True: 0, False: 7.79k]
  ------------------
  740|      0|        lavc_codec = ctx->hwdec.codec;
  741|  7.79k|    } else {
  742|  7.79k|        lavc_codec = avcodec_find_decoder_by_name(ctx->decoder);
  743|  7.79k|    }
  744|  7.79k|    if (!lavc_codec)
  ------------------
  |  Branch (744:9): [True: 0, False: 7.79k]
  ------------------
  745|      0|        return;
  746|       |
  747|  7.79k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id);
  748|  7.79k|    ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY);
  ------------------
  |  Branch (748:23): [True: 7.79k, False: 0]
  |  Branch (748:31): [True: 3.00k, False: 4.79k]
  ------------------
  749|       |
  750|  7.79k|    ctx->codec_timebase = mp_get_codec_timebase(ctx->codec);
  751|       |
  752|  7.79k|    ctx->hwdec_failed = false;
  753|  7.79k|    ctx->hwdec_request_reinit = false;
  754|  7.79k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  755|  7.79k|    AVCodecContext *avctx = ctx->avctx;
  756|  7.79k|    if (!ctx->avctx)
  ------------------
  |  Branch (756:9): [True: 0, False: 7.79k]
  ------------------
  757|      0|        goto error;
  758|  7.79k|    avctx->codec_type = AVMEDIA_TYPE_VIDEO;
  759|  7.79k|    avctx->codec_id = lavc_codec->id;
  760|  7.79k|    avctx->pkt_timebase = ctx->codec_timebase;
  761|       |
  762|  7.79k|    ctx->pic = av_frame_alloc();
  763|  7.79k|    if (!ctx->pic)
  ------------------
  |  Branch (763:9): [True: 0, False: 7.79k]
  ------------------
  764|      0|        goto error;
  765|       |
  766|  7.79k|    ctx->avpkt = av_packet_alloc();
  767|  7.79k|    if (!ctx->avpkt)
  ------------------
  |  Branch (767:9): [True: 0, False: 7.79k]
  ------------------
  768|      0|        goto error;
  769|       |
  770|  7.79k|    int threads = lavc_param->threads;
  771|  7.79k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (771:9): [True: 0, False: 7.79k]
  ------------------
  772|      0|        avctx->opaque = vd;
  773|      0|        avctx->hwaccel_flags |= AV_HWACCEL_FLAG_IGNORE_LEVEL;
  774|      0|        if (!lavc_param->check_hw_profile)
  ------------------
  |  Branch (774:13): [True: 0, False: 0]
  ------------------
  775|      0|            avctx->hwaccel_flags |= AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH;
  776|       |
  777|      0|#ifdef AV_HWACCEL_FLAG_UNSAFE_OUTPUT
  778|       |        /*
  779|       |         * This flag primarily exists for nvdec which has a very limited
  780|       |         * output frame pool, which can get exhausted if consumers don't
  781|       |         * release frames quickly. However, as an implementation
  782|       |         * requirement, we have to copy the frames anyway, so we don't
  783|       |         * need this extra implicit copy.
  784|       |         */
  785|      0|        avctx->hwaccel_flags |= AV_HWACCEL_FLAG_UNSAFE_OUTPUT;
  786|      0|#endif
  787|       |
  788|      0|        if (ctx->hwdec.use_hw_device) {
  ------------------
  |  Branch (788:13): [True: 0, False: 0]
  ------------------
  789|      0|            if (ctx->hwdec_dev)
  ------------------
  |  Branch (789:17): [True: 0, False: 0]
  ------------------
  790|      0|                avctx->hw_device_ctx = av_buffer_ref(ctx->hwdec_dev);
  791|      0|            if (!avctx->hw_device_ctx)
  ------------------
  |  Branch (791:17): [True: 0, False: 0]
  ------------------
  792|      0|                goto error;
  793|      0|        }
  794|      0|        if (ctx->hwdec.use_hw_frames) {
  ------------------
  |  Branch (794:13): [True: 0, False: 0]
  ------------------
  795|      0|            if (!ctx->hwdec_dev)
  ------------------
  |  Branch (795:17): [True: 0, False: 0]
  ------------------
  796|      0|                goto error;
  797|      0|        }
  798|       |
  799|      0|        if (ctx->hwdec.pix_fmt != AV_PIX_FMT_NONE)
  ------------------
  |  Branch (799:13): [True: 0, False: 0]
  ------------------
  800|      0|            avctx->get_format = get_format_hwdec;
  801|       |
  802|       |        // Allow decoder to finish decoding before the frames are passed to the
  803|       |        // renderer.
  804|      0|        if (ctx->hwdec.copying || ctx->hwdec.use_hw_frames)
  ------------------
  |  Branch (804:13): [True: 0, False: 0]
  |  Branch (804:35): [True: 0, False: 0]
  ------------------
  805|      0|            ctx->max_delay_queue = HWDEC_DELAY_QUEUE_COUNT;
  ------------------
  |  |   68|      0|#define HWDEC_DELAY_QUEUE_COUNT 4
  ------------------
  806|      0|        if (ctx->max_delay_queue && !ctx->hwdec.use_hw_frames)
  ------------------
  |  Branch (806:13): [True: 0, False: 0]
  |  Branch (806:37): [True: 0, False: 0]
  ------------------
  807|      0|            avctx->extra_hw_frames = ctx->max_delay_queue;
  808|      0|        ctx->hw_probing = true;
  809|       |
  810|      0|        threads = ctx->hwdec_opts->hwdec_threads;
  811|       |#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(62, 11, 100)
  812|       |        // Vulkan threading was not safe before 62.11.100
  813|       |        bstr hwdec_name = bstr0(ctx->hwdec.name);
  814|       |        if (bstr_endswith0(hwdec_name, "vulkan") || bstr_endswith0(hwdec_name, "vulkan-copy"))
  815|       |            threads = 1;
  816|       |#endif
  817|      0|    }
  818|       |
  819|  7.79k|    mp_set_avcodec_threads(vd->log, avctx, threads);
  820|       |
  821|  7.79k|    if (!ctx->use_hwdec && ctx->vo && lavc_param->dr) {
  ------------------
  |  Branch (821:9): [True: 7.79k, False: 0]
  |  Branch (821:28): [True: 7.79k, False: 0]
  |  Branch (821:39): [True: 7.79k, False: 0]
  ------------------
  822|  7.79k|        avctx->opaque = vd;
  823|  7.79k|        avctx->get_buffer2 = get_buffer2_direct;
  824|  7.79k|    }
  825|       |
  826|  7.79k|    avctx->flags |= lavc_param->bitexact ? AV_CODEC_FLAG_BITEXACT : 0;
  ------------------
  |  Branch (826:21): [True: 0, False: 7.79k]
  ------------------
  827|  7.79k|    avctx->flags2 |= lavc_param->fast ? AV_CODEC_FLAG2_FAST : 0;
  ------------------
  |  Branch (827:22): [True: 0, False: 7.79k]
  ------------------
  828|       |
  829|  7.79k|    if (lavc_param->show_all)
  ------------------
  |  Branch (829:9): [True: 0, False: 7.79k]
  ------------------
  830|      0|        avctx->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT;
  831|       |
  832|  7.79k|    avctx->skip_loop_filter = lavc_param->skip_loop_filter;
  833|  7.79k|    avctx->skip_idct = lavc_param->skip_idct;
  834|  7.79k|    avctx->skip_frame = lavc_param->skip_frame;
  835|  7.79k|    avctx->apply_cropping = lavc_param->apply_cropping;
  836|       |
  837|  7.79k|    if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
  ------------------
  |  Branch (837:9): [True: 2.39k, False: 5.40k]
  |  Branch (837:47): [True: 0, False: 2.39k]
  ------------------
  838|      0|        av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
  839|       |
  840|  7.79k|    switch(ctx->opts->film_grain) {
  841|      0|    case 0: /*CPU*/
  ------------------
  |  Branch (841:5): [True: 0, False: 7.79k]
  ------------------
  842|       |        // default lavc flags handle film grain within the decoder.
  843|      0|        break;
  844|      0|    case 1: /*GPU*/
  ------------------
  |  Branch (844:5): [True: 0, False: 7.79k]
  ------------------
  845|      0|        if (!ctx->vo ||
  ------------------
  |  Branch (845:13): [True: 0, False: 0]
  ------------------
  846|      0|            (ctx->vo && !(ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))) {
  ------------------
  |  Branch (846:14): [True: 0, False: 0]
  |  Branch (846:25): [True: 0, False: 0]
  ------------------
  847|      0|            MP_MSG(vd, ctx->vo ? MSGL_WARN : MSGL_V,
  ------------------
  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (86:52): [True: 0, False: 0]
  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  848|      0|                   "GPU film grain requested, but VO %s, expect wrong output.\n",
  849|      0|                   ctx->vo ?
  850|      0|                   "does not support applying film grain" :
  851|      0|                   "is not available at decoder initialization to verify support");
  852|      0|        }
  853|       |
  854|      0|        avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  855|      0|        break;
  856|  7.79k|    default:
  ------------------
  |  Branch (856:5): [True: 7.79k, False: 0]
  ------------------
  857|  7.79k|        if (ctx->vo && (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))
  ------------------
  |  Branch (857:13): [True: 7.79k, False: 0]
  |  Branch (857:24): [True: 0, False: 7.79k]
  ------------------
  858|      0|            avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  859|       |
  860|  7.79k|        break;
  861|  7.79k|    }
  862|       |
  863|  7.79k|    mp_set_avopts(vd->log, avctx, lavc_param->avopts);
  864|       |
  865|       |    // Do this after the above avopt handling in case it changes values
  866|  7.79k|    ctx->skip_frame = avctx->skip_frame;
  867|       |
  868|  7.79k|    if (mp_set_avctx_codec_headers(avctx, c) < 0) {
  ------------------
  |  Branch (868:9): [True: 0, False: 7.79k]
  ------------------
  869|      0|        MP_ERR(vd, "Could not set codec parameters.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  870|      0|        goto error;
  871|      0|    }
  872|       |
  873|  7.79k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  874|  7.79k|    if (avctx->width > 8192 || avctx->height > 8192) {
  ------------------
  |  Branch (874:9): [True: 17, False: 7.78k]
  |  Branch (874:32): [True: 12, False: 7.76k]
  ------------------
  875|     29|        MP_ERR(vd, "Frame size too big %" PRIu32 "x%" PRIu32 ".\n", avctx->width, avctx->height);
  ------------------
  |  |   89|     29|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     29|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  876|     29|        goto error;
  877|     29|    }
  878|  7.76k|    avctx->max_pixels = 2048 * 2048;
  879|  7.76k|#endif
  880|       |
  881|       |    /* open it */
  882|  7.76k|    if (avcodec_open2(avctx, lavc_codec, NULL) < 0)
  ------------------
  |  Branch (882:9): [True: 96, False: 7.67k]
  ------------------
  883|     96|        goto error;
  884|       |
  885|       |    // Sometimes, the first packet contains information required for correct
  886|       |    // decoding of the rest of the stream. The only currently known case is the
  887|       |    // x264 build number (encoded in a SEI element), needed to enable a
  888|       |    // workaround for broken 4:4:4 streams produced by older x264 versions.
  889|  7.67k|    if (lavc_codec->id == AV_CODEC_ID_H264 && c->first_packet) {
  ------------------
  |  Branch (889:9): [True: 2.39k, False: 5.28k]
  |  Branch (889:47): [True: 0, False: 2.39k]
  ------------------
  890|      0|        mp_set_av_packet(ctx->avpkt, c->first_packet, &ctx->codec_timebase);
  891|      0|        avcodec_send_packet(avctx, ctx->avpkt);
  892|      0|        avcodec_receive_frame(avctx, ctx->pic);
  893|      0|        av_frame_unref(ctx->pic);
  894|      0|        avcodec_flush_buffers(ctx->avctx);
  895|      0|    }
  896|       |
  897|  7.67k|    return;
  898|       |
  899|    125|error:
  900|    125|    MP_ERR(vd, "Could not open codec.\n");
  ------------------
  |  |   89|    125|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    125|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  901|    125|    uninit_avctx(vd);
  902|    125|}
vd_lavc.c:get_buffer2_direct:
 1094|  62.4k|{
 1095|  62.4k|    struct mp_filter *vd = avctx->opaque;
 1096|  62.4k|    vd_ffmpeg_ctx *p = vd->priv;
 1097|       |
 1098|  62.4k|    mp_mutex_lock(&p->dr_lock);
  ------------------
  |  |  134|  62.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1099|       |
 1100|  62.4k|    int w = pic->width;
 1101|  62.4k|    int h = pic->height;
 1102|  62.4k|    int linesize_align[AV_NUM_DATA_POINTERS] = {0};
 1103|  62.4k|    avcodec_align_dimensions2(avctx, &w, &h, linesize_align);
 1104|       |
 1105|       |    // We assume that different alignments are just different power-of-2s.
 1106|       |    // Thus, a higher alignment always satisfies a lower alignment.
 1107|  62.4k|    int stride_align = MP_IMAGE_BYTE_ALIGN;
  ------------------
  |  |   35|  62.4k|#define MP_IMAGE_BYTE_ALIGN 64
  ------------------
 1108|   562k|    for (int n = 0; n < AV_NUM_DATA_POINTERS; n++)
  ------------------
  |  Branch (1108:21): [True: 499k, False: 62.4k]
  ------------------
 1109|   499k|        stride_align = MPMAX(stride_align, linesize_align[n]);
  ------------------
  |  |   44|   499k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 499k, False: 0]
  |  |  ------------------
  ------------------
 1110|       |
 1111|       |    // Note: texel sizes may be NPOT, so use full lcm instead of max
 1112|  62.4k|    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
 1113|  62.4k|    if (!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)) {
  ------------------
  |  Branch (1113:9): [True: 58.6k, False: 3.82k]
  ------------------
 1114|   137k|        for (int n = 0; n < desc->nb_components; n++)
  ------------------
  |  Branch (1114:25): [True: 78.5k, False: 58.6k]
  ------------------
 1115|  78.5k|            stride_align = mp_lcm(stride_align, desc->comp[n].step);
 1116|  58.6k|    }
 1117|       |
 1118|  62.4k|    int imgfmt = pixfmt2imgfmt(pic->format);
 1119|  62.4k|    if (!imgfmt)
  ------------------
  |  Branch (1119:9): [True: 0, False: 62.4k]
  ------------------
 1120|      0|        goto fallback;
 1121|       |
 1122|  62.4k|    if (p->dr_failed)
  ------------------
  |  Branch (1122:9): [True: 59.2k, False: 3.21k]
  ------------------
 1123|  59.2k|        goto fallback;
 1124|       |
 1125|       |    // (For simplicity, we realloc on any parameter change, instead of trying
 1126|       |    // to be clever.)
 1127|  3.21k|    if (stride_align != p->dr_stride_align || w != p->dr_w || h != p->dr_h ||
  ------------------
  |  Branch (1127:9): [True: 3.21k, False: 0]
  |  Branch (1127:47): [True: 0, False: 0]
  |  Branch (1127:63): [True: 0, False: 0]
  ------------------
 1128|      0|        imgfmt != p->dr_imgfmt)
  ------------------
  |  Branch (1128:9): [True: 0, False: 0]
  ------------------
 1129|  3.21k|    {
 1130|  3.21k|        mp_image_pool_clear(p->dr_pool);
 1131|  3.21k|        p->dr_imgfmt = imgfmt;
 1132|  3.21k|        p->dr_w = w;
 1133|  3.21k|        p->dr_h = h;
 1134|  3.21k|        p->dr_stride_align = stride_align;
 1135|  3.21k|        MP_DBG(p, "DR parameter change to %dx%d %s align=%d\n", w, h,
  ------------------
  |  |   93|  3.21k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.21k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|  3.21k|               mp_imgfmt_to_name(imgfmt), stride_align);
 1137|  3.21k|    }
 1138|       |
 1139|  3.21k|    struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);
 1140|  3.21k|    if (!img) {
  ------------------
  |  Branch (1140:9): [True: 3.21k, False: 0]
  ------------------
 1141|  3.21k|        bool host_cached = p->opts->dr == -1; // auto
 1142|  3.21k|        int dr_flags = host_cached ? VO_DR_FLAG_HOST_CACHED : 0;
  ------------------
  |  Branch (1142:24): [True: 3.21k, False: 0]
  ------------------
 1143|  3.21k|        MP_DBG(p, "Allocating new%s DR image...\n", host_cached ? " (host-cached)" : "");
  ------------------
  |  |   93|  3.21k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.43k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 3.21k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|  3.21k|        img = vo_get_image(p->vo, imgfmt, w, h, stride_align, dr_flags);
 1145|  3.21k|        if (!img) {
  ------------------
  |  Branch (1145:13): [True: 3.21k, False: 0]
  ------------------
 1146|  3.21k|            MP_DBG(p, "...failed..\n");
  ------------------
  |  |   93|  3.21k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.21k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1147|  3.21k|            goto fallback;
 1148|  3.21k|        }
 1149|       |
 1150|       |        // Now make the mp_image part of the pool. This requires doing magic to
 1151|       |        // the image, so just add it to the pool and get it back to avoid
 1152|       |        // dealing with magic ourselves. (Normally this never fails.)
 1153|      0|        mp_image_pool_add(p->dr_pool, img);
 1154|      0|        img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);
 1155|      0|        if (!img)
  ------------------
  |  Branch (1155:13): [True: 0, False: 0]
  ------------------
 1156|      0|            goto fallback;
 1157|      0|    }
 1158|       |
 1159|       |    // get_buffer2 callers seem very unappreciative of overwriting pic with a
 1160|       |    // new reference. The AVCodecContext.get_buffer2 comments tell us exactly
 1161|       |    // what we should do, so follow that.
 1162|      0|    for (int n = 0; n < 4; n++) {
  ------------------
  |  Branch (1162:21): [True: 0, False: 0]
  ------------------
 1163|      0|        pic->data[n] = img->planes[n];
 1164|      0|        pic->linesize[n] = img->stride[n];
 1165|      0|        pic->buf[n] = img->bufs[n];
 1166|      0|        img->bufs[n] = NULL;
 1167|      0|    }
 1168|      0|    talloc_free(img);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1169|       |
 1170|      0|    mp_mutex_unlock(&p->dr_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1171|       |
 1172|      0|    return 0;
 1173|       |
 1174|  62.4k|fallback:
 1175|  62.4k|    if (!p->dr_failed)
  ------------------
  |  Branch (1175:9): [True: 3.21k, False: 59.2k]
  ------------------
 1176|  62.4k|        MP_VERBOSE(p, "DR failed - disabling.\n");
  ------------------
  |  |   92|  3.21k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.21k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1177|  62.4k|    p->dr_failed = true;
 1178|  62.4k|    mp_mutex_unlock(&p->dr_lock);
  ------------------
  |  |  136|  62.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1179|       |
 1180|  62.4k|    return avcodec_default_get_buffer2(avctx, pic, flags);
 1181|  3.21k|}
vd_lavc.c:control:
 1427|   183k|{
 1428|   183k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1429|   183k|    switch (cmd) {
  ------------------
  |  Branch (1429:13): [True: 183k, False: 0]
  ------------------
 1430|   156k|    case VDCTRL_SET_FRAMEDROP:
  ------------------
  |  Branch (1430:5): [True: 156k, False: 27.1k]
  ------------------
 1431|   156k|        ctx->framedrop_flags = *(int *)arg;
 1432|   156k|        return CONTROL_TRUE;
  ------------------
  |  |   96|   156k|#define CONTROL_TRUE 1
  ------------------
 1433|      0|    case VDCTRL_SET_EXTRA_HW_FRAMES:
  ------------------
  |  Branch (1433:5): [True: 0, False: 183k]
  ------------------
 1434|      0|        ctx->extra_hw_frames_hint = *(int *)arg;
 1435|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1436|  9.72k|    case VDCTRL_CHECK_FORCED_EOF: {
  ------------------
  |  Branch (1436:5): [True: 9.72k, False: 174k]
  ------------------
 1437|  9.72k|        *(bool *)arg = ctx->force_eof;
 1438|  9.72k|        return CONTROL_TRUE;
  ------------------
  |  |   96|  9.72k|#define CONTROL_TRUE 1
  ------------------
 1439|      0|    }
 1440|      0|    case VDCTRL_GET_BFRAMES: {
  ------------------
  |  Branch (1440:5): [True: 0, False: 183k]
  ------------------
 1441|      0|        AVCodecContext *avctx = ctx->avctx;
 1442|      0|        if (!avctx)
  ------------------
  |  Branch (1442:13): [True: 0, False: 0]
  ------------------
 1443|      0|            break;
 1444|      0|        *(int *)arg = avctx->has_b_frames;
 1445|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1446|      0|    }
 1447|  17.3k|    case VDCTRL_GET_HWDEC: {
  ------------------
  |  Branch (1447:5): [True: 17.3k, False: 166k]
  ------------------
 1448|  17.3k|        if (!ctx->hwdec_notified)
  ------------------
  |  Branch (1448:13): [True: 16.4k, False: 945]
  ------------------
 1449|  16.4k|            return CONTROL_FALSE;
  ------------------
  |  |   97|  16.4k|#define CONTROL_FALSE 0
  ------------------
 1450|    945|        *(char **)arg = ctx->use_hwdec ? ctx->hwdec.method_name : NULL;
  ------------------
  |  Branch (1450:25): [True: 0, False: 945]
  ------------------
 1451|    945|        return CONTROL_TRUE;
  ------------------
  |  |   96|    945|#define CONTROL_TRUE 1
  ------------------
 1452|  17.3k|    }
 1453|      0|    case VDCTRL_FORCE_HWDEC_FALLBACK:
  ------------------
  |  Branch (1453:5): [True: 0, False: 183k]
  ------------------
 1454|      0|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1454:13): [True: 0, False: 0]
  ------------------
 1455|      0|            force_fallback(vd);
 1456|      0|            return ctx->avctx ? CONTROL_OK : CONTROL_ERROR;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
                          return ctx->avctx ? CONTROL_OK : CONTROL_ERROR;
  ------------------
  |  |   99|      0|#define CONTROL_ERROR -2
  ------------------
  |  Branch (1456:20): [True: 0, False: 0]
  ------------------
 1457|      0|        }
 1458|      0|        return CONTROL_FALSE;
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 1459|      0|    case VDCTRL_REINIT:
  ------------------
  |  Branch (1459:5): [True: 0, False: 183k]
  ------------------
 1460|      0|        reinit(vd);
 1461|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1462|   183k|    }
 1463|      0|    return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1464|   183k|}
vd_lavc.c:reinit:
  696|  7.79k|{
  697|  7.79k|    vd_ffmpeg_ctx *ctx = vd->priv;
  698|       |
  699|  7.79k|    uninit_avctx(vd);
  700|       |
  701|       |    /*
  702|       |     * Reset attempted hwdecs so that if the hwdec list is reconfigured
  703|       |     * we attempt all of them from the beginning. The most practical
  704|       |     * reason for this is that ctrl+h toggles between `no` and
  705|       |     * `auto`, and we want to reevaluate from a clean slate each time.
  706|       |     */
  707|  7.79k|    TA_FREEP(&ctx->attempted_hwdecs);
  ------------------
  |  |   81|  7.79k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  7.79k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 7.79k]
  |  |  ------------------
  ------------------
  708|  7.79k|    ctx->num_attempted_hwdecs = 0;
  709|  7.79k|    ctx->hwdec_notified = false;
  710|       |
  711|  7.79k|    select_and_set_hwdec(vd);
  712|       |
  713|  7.79k|    bool use_hwdec = ctx->use_hwdec;
  714|  7.79k|    init_avctx(vd);
  715|  7.79k|    if (!ctx->avctx && use_hwdec) {
  ------------------
  |  Branch (715:9): [True: 125, False: 7.67k]
  |  Branch (715:24): [True: 0, False: 125]
  ------------------
  716|      0|        do {
  717|      0|            force_fallback(vd);
  718|      0|        } while (!ctx->avctx);
  ------------------
  |  Branch (718:18): [True: 0, False: 0]
  ------------------
  719|      0|    }
  720|       |
  721|       |    // Wait for the first keyframe after reinit to ensure the decoder state is
  722|       |    // valid and to avoid decoding errors that could cause hwdec to fail and
  723|       |    // fall back immediately after a reinit.
  724|  7.79k|    ctx->wait_for_keyframe = ctx->use_hwdec ? HWDEC_WAIT_KEYFRAME_COUNT : 0;
  ------------------
  |  |   69|      0|#define HWDEC_WAIT_KEYFRAME_COUNT 96
  ------------------
  |  Branch (724:30): [True: 0, False: 7.79k]
  ------------------
  725|  7.79k|}
vd_lavc.c:add_decoders:
 1550|  9.69k|{
 1551|  9.69k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_VIDEO);
 1552|  9.69k|}

imgfmt2pixfmt:
   76|   111k|{
   77|   111k|    if (fmt == IMGFMT_NONE)
  ------------------
  |  Branch (77:9): [True: 0, False: 111k]
  ------------------
   78|      0|        return AV_PIX_FMT_NONE;
   79|       |
   80|   111k|    if (fmt >= IMGFMT_AVPIXFMT_START && fmt < IMGFMT_AVPIXFMT_END) {
  ------------------
  |  Branch (80:9): [True: 20.9k, False: 90.6k]
  |  Branch (80:41): [True: 20.9k, False: 0]
  ------------------
   81|  20.9k|        enum AVPixelFormat pixfmt = fmt - IMGFMT_AVPIXFMT_START;
   82|       |        // Avoid duplicate format - each format must be unique.
   83|  20.9k|        int mpfmt = pixfmt2imgfmt(pixfmt);
   84|  20.9k|        if (mpfmt == fmt && av_pix_fmt_desc_get(pixfmt))
  ------------------
  |  Branch (84:13): [True: 20.9k, False: 0]
  |  Branch (84:29): [True: 20.9k, False: 0]
  ------------------
   85|  20.9k|            return pixfmt;
   86|      0|        return AV_PIX_FMT_NONE;
   87|  20.9k|    }
   88|       |
   89|   767k|    for (int i = 0; conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (89:21): [True: 767k, False: 0]
  ------------------
   90|   767k|        if (conversion_map[i].fmt == fmt)
  ------------------
  |  Branch (90:13): [True: 90.6k, False: 677k]
  ------------------
   91|  90.6k|            return conversion_map[i].pix_fmt;
   92|   767k|    }
   93|      0|    return AV_PIX_FMT_NONE;
   94|  90.6k|}
pixfmt2imgfmt:
   97|   127k|{
   98|   127k|    if (pix_fmt == AV_PIX_FMT_NONE)
  ------------------
  |  Branch (98:9): [True: 0, False: 127k]
  ------------------
   99|      0|        return IMGFMT_NONE;
  100|       |
  101|  1.97M|    for (int i = 0; conversion_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
  ------------------
  |  Branch (101:21): [True: 1.94M, False: 32.0k]
  ------------------
  102|  1.94M|        if (conversion_map[i].pix_fmt == pix_fmt)
  ------------------
  |  Branch (102:13): [True: 95.0k, False: 1.84M]
  ------------------
  103|  95.0k|            return conversion_map[i].fmt;
  104|  1.94M|    }
  105|       |
  106|  32.0k|    int generic = IMGFMT_AVPIXFMT_START + pix_fmt;
  107|  32.0k|    if (generic < IMGFMT_AVPIXFMT_END && av_pix_fmt_desc_get(pix_fmt))
  ------------------
  |  Branch (107:9): [True: 32.0k, False: 0]
  |  Branch (107:42): [True: 32.0k, False: 0]
  ------------------
  108|  32.0k|        return generic;
  109|       |
  110|      0|    return 0;
  111|  32.0k|}

mp_imgfmt_to_name_buf:
  169|  19.7k|{
  170|  19.7k|    const struct mp_imgfmt_entry *p = get_mp_desc(fmt);
  171|  19.7k|    const char *name = p ? p->name : NULL;
  ------------------
  |  Branch (171:24): [True: 0, False: 19.7k]
  ------------------
  172|  19.7k|    if (!name) {
  ------------------
  |  Branch (172:9): [True: 19.7k, False: 0]
  ------------------
  173|  19.7k|        const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(imgfmt2pixfmt(fmt));
  174|  19.7k|        if (pixdesc)
  ------------------
  |  Branch (174:13): [True: 19.7k, False: 0]
  ------------------
  175|  19.7k|            name = pixdesc->name;
  176|  19.7k|    }
  177|  19.7k|    if (!name)
  ------------------
  |  Branch (177:9): [True: 0, False: 19.7k]
  ------------------
  178|      0|        name = "unknown";
  179|  19.7k|    snprintf(buf, buf_size, "%s", name);
  180|  19.7k|    int len = strlen(buf);
  181|  19.7k|    if (len > 2 && buf[len - 2] == MP_SELECT_LE_BE('l', 'b') && buf[len - 1] == 'e')
  ------------------
  |  |   38|  39.5k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  |  Branch (181:9): [True: 19.7k, False: 0]
  |  Branch (181:20): [True: 6.87k, False: 12.9k]
  |  Branch (181:65): [True: 3.85k, False: 3.02k]
  ------------------
  182|  3.85k|        buf[len - 2] = '\0';
  183|  19.7k|    return buf;
  184|  19.7k|}
mp_imgfmt_desc_get_num_comps:
  557|  48.8k|{
  558|  48.8k|    int flags = desc->flags;
  559|  48.8k|    if (!(flags & MP_IMGFLAG_COLOR_MASK))
  ------------------
  |  |   55|  48.8k|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (559:9): [True: 0, False: 48.8k]
  ------------------
  560|      0|        return 0;
  561|  48.8k|    return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   75|  48.8k|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
                  return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   52|  48.8k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (561:17): [True: 10.9k, False: 37.8k]
  ------------------
  562|  48.8k|}
mp_imgfmt_get_desc:
  565|  47.4k|{
  566|  47.4k|    struct mp_imgfmt_desc desc;
  567|       |
  568|  47.4k|    if (!get_native_desc(mpfmt, &desc) &&
  ------------------
  |  Branch (568:9): [True: 47.4k, False: 0]
  ------------------
  569|  47.4k|        !mp_imgfmt_get_desc_from_pixdesc(mpfmt, &desc))
  ------------------
  |  Branch (569:9): [True: 0, False: 47.4k]
  ------------------
  570|      0|        return (struct mp_imgfmt_desc){0};
  571|       |
  572|  99.1k|    for (int p = 0; p < desc.num_planes; p++) {
  ------------------
  |  Branch (572:21): [True: 51.6k, False: 47.4k]
  ------------------
  573|  51.6k|        desc.xs[p] = (p == 1 || p == 2) ? desc.chroma_xs : 0;
  ------------------
  |  Branch (573:23): [True: 2.11k, False: 49.5k]
  |  Branch (573:33): [True: 2.11k, False: 47.4k]
  ------------------
  574|  51.6k|        desc.ys[p] = (p == 1 || p == 2) ? desc.chroma_ys : 0;
  ------------------
  |  Branch (574:23): [True: 2.11k, False: 49.5k]
  |  Branch (574:33): [True: 2.11k, False: 47.4k]
  ------------------
  575|  51.6k|    }
  576|       |
  577|  47.4k|    bool is_ba = desc.num_planes > 0;
  578|  99.1k|    for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (578:21): [True: 51.6k, False: 47.4k]
  ------------------
  579|  51.6k|        is_ba = !(desc.bpp[p] % 8u);
  580|       |
  581|  47.4k|    if (is_ba)
  ------------------
  |  Branch (581:9): [True: 43.2k, False: 4.21k]
  ------------------
  582|  43.2k|        desc.flags |= MP_IMGFLAG_BYTE_ALIGNED;
  ------------------
  |  |   40|  43.2k|#define MP_IMGFLAG_BYTE_ALIGNED (1 << 2)
  ------------------
  583|       |
  584|  47.4k|    if (desc.flags & MP_IMGFLAG_HAS_COMPS) {
  ------------------
  |  |   34|  47.4k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (584:9): [True: 12.0k, False: 35.4k]
  ------------------
  585|  12.0k|        if (desc.comps[3].size)
  ------------------
  |  Branch (585:13): [True: 138, False: 11.8k]
  ------------------
  586|    138|            desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|    138|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  587|       |
  588|       |        // Assuming all colors are (CCC+[A]) or (C+[A]), the latter being gray.
  589|  12.0k|        if (!desc.comps[1].size)
  ------------------
  |  Branch (589:13): [True: 9.05k, False: 2.95k]
  ------------------
  590|  9.05k|            desc.flags |= MP_IMGFLAG_GRAY;
  ------------------
  |  |   75|  9.05k|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
  591|       |
  592|  12.0k|        bool bb = true;
  593|  60.0k|        for (int n = 0; n < MP_NUM_COMPONENTS; n++) {
  ------------------
  |  |   29|  60.0k|#define MP_NUM_COMPONENTS 4
  ------------------
  |  Branch (593:25): [True: 48.0k, False: 12.0k]
  ------------------
  594|  48.0k|            if (desc.comps[n].offset % 8u || desc.comps[n].size % 8u)
  ------------------
  |  Branch (594:17): [True: 0, False: 48.0k]
  |  Branch (594:46): [True: 4.21k, False: 43.8k]
  ------------------
  595|  4.21k|                bb = false;
  596|  48.0k|        }
  597|  12.0k|        if (bb)
  ------------------
  |  Branch (597:13): [True: 7.78k, False: 4.21k]
  ------------------
  598|  7.78k|            desc.flags |= MP_IMGFLAG_BYTES;
  ------------------
  |  |   37|  7.78k|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  599|  12.0k|    }
  600|       |
  601|  47.4k|    if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   67|  47.4k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|  47.4k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
                  if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   68|  47.4k|#define MP_IMGFLAG_RGB          MP_IMGFLAG_COLOR_RGB
  |  |  ------------------
  |  |  |  |   57|  47.4k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  |  |  ------------------
  ------------------
  |  Branch (601:9): [True: 47.4k, False: 0]
  ------------------
  602|  47.4k|        && (desc.flags & MP_IMGFLAG_HAS_COMPS)
  ------------------
  |  |   34|  47.4k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (602:12): [True: 12.0k, False: 35.4k]
  ------------------
  603|  12.0k|        && (desc.flags & MP_IMGFLAG_BYTES)
  ------------------
  |  |   37|  12.0k|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  |  Branch (603:12): [True: 7.78k, False: 4.21k]
  ------------------
  604|  7.78k|        && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   61|  7.78k|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
                      && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   62|  7.78k|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  |  Branch (604:12): [True: 5.09k, False: 2.69k]
  ------------------
  605|  5.09k|    {
  606|  5.09k|        int cnt = mp_imgfmt_desc_get_num_comps(&desc);
  607|  5.09k|        bool same_depth = true;
  608|  10.5k|        for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (608:25): [True: 5.47k, False: 5.09k]
  ------------------
  609|  5.47k|            same_depth &= desc.bpp[p] == desc.bpp[0];
  610|  5.09k|        if (same_depth && cnt == desc.num_planes) {
  ------------------
  |  Branch (610:13): [True: 5.09k, False: 0]
  |  Branch (610:27): [True: 4.24k, False: 844]
  ------------------
  611|  4.24k|            if (desc.flags & MP_IMGFLAG_YUV) {
  ------------------
  |  |   67|  4.24k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|  4.24k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
  |  Branch (611:17): [True: 4.24k, False: 0]
  ------------------
  612|  4.24k|                desc.flags |= MP_IMGFLAG_YUV_P;
  ------------------
  |  |   94|  4.24k|#define MP_IMGFLAG_YUV_P        (1 << 16)
  ------------------
  613|  4.24k|            } else {
  614|      0|                desc.flags |= MP_IMGFLAG_RGB_P;
  ------------------
  |  |   98|      0|#define MP_IMGFLAG_RGB_P        (1 << 17)
  ------------------
  615|      0|            }
  616|  4.24k|        }
  617|  5.09k|        if (cnt == 3 && desc.num_planes == 2 &&
  ------------------
  |  Branch (617:13): [True: 898, False: 4.19k]
  |  Branch (617:25): [True: 0, False: 898]
  ------------------
  618|      0|            desc.bpp[1] == desc.bpp[0] * 2 &&
  ------------------
  |  Branch (618:13): [True: 0, False: 0]
  ------------------
  619|      0|            (desc.flags & MP_IMGFLAG_YUV))
  ------------------
  |  |   67|      0|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|      0|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
  |  Branch (619:13): [True: 0, False: 0]
  ------------------
  620|      0|        {
  621|       |
  622|      0|            desc.flags |= MP_IMGFLAG_YUV_NV;
  ------------------
  |  |  101|      0|#define MP_IMGFLAG_YUV_NV       (1 << 18)
  ------------------
  623|      0|        }
  624|  5.09k|    }
  625|       |
  626|  47.4k|    return desc;
  627|  47.4k|}
mp_imgfmt_get_forced_csp:
  682|  1.84k|{
  683|  1.84k|    return get_forced_csp_from_flags(mp_imgfmt_get_desc(imgfmt).flags);
  684|  1.84k|}
mp_imgfmt_is_subsampled:
  830|  1.84k|{
  831|  1.84k|    struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
  832|  1.84k|    return desc.chroma_xs || desc.chroma_ys;
  ------------------
  |  Branch (832:12): [True: 64, False: 1.77k]
  |  Branch (832:30): [True: 0, False: 1.77k]
  ------------------
  833|  1.84k|}
img_format.c:get_mp_desc:
  124|  67.2k|{
  125|  67.2k|    if (imgfmt < IMGFMT_CUST_BASE)
  ------------------
  |  Branch (125:9): [True: 51.5k, False: 15.6k]
  ------------------
  126|  51.5k|        return NULL;
  127|  15.6k|    int index = imgfmt - IMGFMT_CUST_BASE;
  128|  15.6k|    if (index >= MP_ARRAY_SIZE(mp_imgfmt_list))
  ------------------
  |  |   49|  15.6k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (128:9): [True: 15.6k, False: 0]
  ------------------
  129|  15.6k|        return NULL;
  130|      0|    const struct mp_imgfmt_entry *e = &mp_imgfmt_list[index];
  131|      0|    return e->name ? e : NULL;
  ------------------
  |  Branch (131:12): [True: 0, False: 0]
  ------------------
  132|  15.6k|}
img_format.c:get_native_desc:
  523|  47.4k|{
  524|  47.4k|    const struct mp_imgfmt_entry *p = get_mp_desc(mpfmt);
  525|  47.4k|    if (!p || !p->desc.flags)
  ------------------
  |  Branch (525:9): [True: 47.4k, False: 0]
  |  Branch (525:15): [True: 0, False: 0]
  ------------------
  526|  47.4k|        return false;
  527|       |
  528|      0|    *desc = p->desc;
  529|       |
  530|       |    // Fill in some fields mp_imgfmt_entry.desc is not required to set.
  531|       |
  532|      0|    desc->id = mpfmt;
  533|       |
  534|      0|    for (int n = 0; n < MP_NUM_COMPONENTS; n++) {
  ------------------
  |  |   29|      0|#define MP_NUM_COMPONENTS 4
  ------------------
  |  Branch (534:21): [True: 0, False: 0]
  ------------------
  535|      0|        struct mp_imgfmt_comp_desc *cd = &desc->comps[n];
  536|      0|        if (cd->size)
  ------------------
  |  Branch (536:13): [True: 0, False: 0]
  ------------------
  537|      0|            desc->num_planes = MPMAX(desc->num_planes, cd->plane + 1);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  538|      0|        desc->bpp[cd->plane] =
  539|      0|            MPMAX(desc->bpp[cd->plane], MP_ALIGN_UP(cd->offset + cd->size, 8));
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  540|      0|    }
  541|       |
  542|      0|    if (!desc->align_x && !desc->align_y) {
  ------------------
  |  Branch (542:9): [True: 0, False: 0]
  |  Branch (542:27): [True: 0, False: 0]
  ------------------
  543|      0|        desc->align_x = 1 << desc->chroma_xs;
  544|      0|        desc->align_y = 1 << desc->chroma_ys;
  545|      0|    }
  546|       |
  547|      0|    if (desc->num_planes)
  ------------------
  |  Branch (547:9): [True: 0, False: 0]
  ------------------
  548|      0|        desc->flags |= MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_NE;
  ------------------
  |  |   34|      0|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
                      desc->flags |= MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_NE;
  ------------------
  |  |   49|      0|#define MP_IMGFLAG_NE           MP_SELECT_LE_BE(MP_IMGFLAG_LE, MP_IMGFLAG_BE)
  |  |  ------------------
  |  |  |  |   38|      0|#define MP_SELECT_LE_BE(LE, BE) LE
  |  |  ------------------
  ------------------
  549|       |
  550|      0|    if (!(desc->flags & MP_IMGFLAG_TYPE_MASK))
  ------------------
  |  |   61|      0|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
  |  Branch (550:9): [True: 0, False: 0]
  ------------------
  551|      0|        desc->flags |= MP_IMGFLAG_TYPE_UINT;
  ------------------
  |  |   62|      0|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  552|       |
  553|       |    return true;
  554|  47.4k|}
img_format.c:mp_imgfmt_get_desc_from_pixdesc:
  413|  47.4k|{
  414|  47.4k|    enum AVPixelFormat fmt = imgfmt2pixfmt(mpfmt);
  415|  47.4k|    const AVPixFmtDescriptor *pd = av_pix_fmt_desc_get(fmt);
  416|  47.4k|    if (!pd || pd->nb_components > 4)
  ------------------
  |  Branch (416:9): [True: 0, False: 47.4k]
  |  Branch (416:16): [True: 0, False: 47.4k]
  ------------------
  417|      0|        return false;
  418|       |
  419|  47.4k|    struct mp_imgfmt_desc desc = {
  420|  47.4k|        .id = mpfmt,
  421|  47.4k|        .chroma_xs = pd->log2_chroma_w,
  422|  47.4k|        .chroma_ys = pd->log2_chroma_h,
  423|  47.4k|    };
  424|       |
  425|  47.4k|    if (pd->flags & AV_PIX_FMT_FLAG_ALPHA)
  ------------------
  |  Branch (425:9): [True: 35.5k, False: 11.8k]
  ------------------
  426|  35.5k|        desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|  35.5k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  427|       |
  428|  47.4k|    if (pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (428:9): [True: 0, False: 47.4k]
  ------------------
  429|      0|        desc.flags |= MP_IMGFLAG_TYPE_HW;
  ------------------
  |  |   65|      0|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  ------------------
  430|       |
  431|       |    // Pixdesc does not provide a flag for XYZ, so this is the best we can do.
  432|  47.4k|    if (strncmp(pd->name, "xyz", 3) == 0) {
  ------------------
  |  Branch (432:9): [True: 0, False: 47.4k]
  ------------------
  433|      0|        desc.flags |= MP_IMGFLAG_COLOR_XYZ;
  ------------------
  |  |   58|      0|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  434|  47.4k|    } else if (pd->flags & AV_PIX_FMT_FLAG_RGB) {
  ------------------
  |  Branch (434:16): [True: 2.76k, False: 44.6k]
  ------------------
  435|  2.76k|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|  2.76k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  436|  44.6k|    } else if (fmt == AV_PIX_FMT_MONOBLACK || fmt == AV_PIX_FMT_MONOWHITE) {
  ------------------
  |  Branch (436:16): [True: 0, False: 44.6k]
  |  Branch (436:47): [True: 4.21k, False: 40.4k]
  ------------------
  437|  4.21k|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|  4.21k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  438|  40.4k|    } else if (fmt == AV_PIX_FMT_PAL8) {
  ------------------
  |  Branch (438:16): [True: 35.4k, False: 5.02k]
  ------------------
  439|  35.4k|        desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   57|  35.4k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
                      desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   64|  35.4k|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  ------------------
  440|  35.4k|    }
  441|       |
  442|  47.4k|    if (pd->flags & AV_PIX_FMT_FLAG_FLOAT)
  ------------------
  |  Branch (442:9): [True: 2.69k, False: 44.7k]
  ------------------
  443|  2.69k|        desc.flags |= MP_IMGFLAG_TYPE_FLOAT;
  ------------------
  |  |   63|  2.69k|#define MP_IMGFLAG_TYPE_FLOAT   (2 << 10)
  ------------------
  444|       |
  445|       |    // Educated guess.
  446|  47.4k|    if (!(desc.flags & MP_IMGFLAG_COLOR_MASK) &&
  ------------------
  |  |   55|  47.4k|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (446:9): [True: 5.02k, False: 42.4k]
  ------------------
  447|  5.02k|        !(desc.flags & MP_IMGFLAG_TYPE_HW))
  ------------------
  |  |   65|  5.02k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  ------------------
  |  Branch (447:9): [True: 5.02k, False: 0]
  ------------------
  448|  5.02k|        desc.flags |= MP_IMGFLAG_COLOR_YUV;
  ------------------
  |  |   56|  5.02k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  ------------------
  449|       |
  450|  47.4k|    desc.align_x = 1 << desc.chroma_xs;
  451|  47.4k|    desc.align_y = 1 << desc.chroma_ys;
  452|       |
  453|  47.4k|    fill_pixdesc_layout(&desc, fmt, pd);
  454|       |
  455|  47.4k|    if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   34|  47.4k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
                  if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   86|  47.4k|#define MP_IMGFLAG_PACKED_SS_YUV (1 << 15)
  ------------------
  |  Branch (455:9): [True: 12.0k, False: 35.4k]
  ------------------
  456|  12.0k|        if (!(desc.flags & MP_IMGFLAG_TYPE_MASK))
  ------------------
  |  |   61|  12.0k|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
  |  Branch (456:13): [True: 9.31k, False: 2.69k]
  ------------------
  457|  9.31k|            desc.flags |= MP_IMGFLAG_TYPE_UINT;
  ------------------
  |  |   62|  9.31k|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  458|  12.0k|    }
  459|       |
  460|  47.4k|    if (desc.bpp[0] % 8u && (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM))
  ------------------
  |  Branch (460:9): [True: 4.21k, False: 43.2k]
  |  Branch (460:29): [True: 4.21k, False: 0]
  ------------------
  461|  4.21k|        desc.align_x = 8 / desc.bpp[0]; // expect power of 2
  462|       |
  463|       |    // Very heuristical.
  464|  47.4k|    bool is_ne = !desc.endian_shift;
  465|  47.4k|    bool need_endian = (desc.comps[0].size % 8u && desc.bpp[0] > 8) ||
  ------------------
  |  Branch (465:25): [True: 4.21k, False: 43.2k]
  |  Branch (465:52): [True: 0, False: 4.21k]
  ------------------
  466|  47.4k|                       desc.comps[0].size > 8;
  ------------------
  |  Branch (466:24): [True: 3.00k, False: 44.4k]
  ------------------
  467|       |
  468|  47.4k|    if (need_endian) {
  ------------------
  |  Branch (468:9): [True: 3.00k, False: 44.4k]
  ------------------
  469|  3.00k|        bool is_le = MP_SELECT_LE_BE(is_ne, !is_ne);
  ------------------
  |  |   38|  3.00k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  470|  3.00k|        desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   43|  3.00k|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   46|  3.00k|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  |  Branch (470:23): [True: 3.00k, False: 0]
  ------------------
  471|  44.4k|    } else {
  472|  44.4k|        desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   43|  44.4k|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   46|  44.4k|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  473|  44.4k|    }
  474|       |
  475|  47.4k|    *out = desc;
  476|       |    return true;
  477|  47.4k|}
img_format.c:fill_pixdesc_layout:
  189|  47.4k|{
  190|  47.4k|    if (pd->flags & AV_PIX_FMT_FLAG_PAL ||
  ------------------
  |  Branch (190:9): [True: 35.4k, False: 12.0k]
  ------------------
  191|  12.0k|        pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (191:9): [True: 0, False: 12.0k]
  ------------------
  192|  35.4k|        goto fail;
  193|       |
  194|  47.4k|    bool has_alpha = pd->flags & AV_PIX_FMT_FLAG_ALPHA;
  195|  12.0k|    if (pd->nb_components != 1 + has_alpha &&
  ------------------
  |  Branch (195:9): [True: 2.95k, False: 9.05k]
  ------------------
  196|  2.95k|        pd->nb_components != 3 + has_alpha)
  ------------------
  |  Branch (196:9): [True: 0, False: 2.95k]
  ------------------
  197|      0|        goto fail;
  198|       |
  199|       |    // Very convenient: we assume we're always on little endian, and FFmpeg
  200|       |    // explicitly marks big endian formats => don't need to guess whether a
  201|       |    // format is little endian, or not affected by byte order.
  202|  12.0k|    bool is_be = pd->flags & AV_PIX_FMT_FLAG_BE;
  203|  12.0k|    bool is_ne = MP_SELECT_LE_BE(false, true) == is_be;
  ------------------
  |  |   38|  12.0k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  204|       |
  205|       |    // Packed sub-sampled YUV is very... special.
  206|  12.0k|    bool is_packed_ss_yuv = pd->log2_chroma_w && !pd->log2_chroma_h &&
  ------------------
  |  Branch (206:29): [True: 192, False: 11.8k]
  |  Branch (206:50): [True: 0, False: 192]
  ------------------
  207|      0|        pd->comp[1].plane == 0 && pd->comp[2].plane == 0 &&
  ------------------
  |  Branch (207:9): [True: 0, False: 0]
  |  Branch (207:35): [True: 0, False: 0]
  ------------------
  208|      0|        pd->nb_components == 3;
  ------------------
  |  Branch (208:9): [True: 0, False: 0]
  ------------------
  209|       |
  210|  12.0k|    if (is_packed_ss_yuv)
  ------------------
  |  Branch (210:9): [True: 0, False: 12.0k]
  ------------------
  211|      0|        desc->bpp[0] = pd->comp[1].step * 8;
  212|       |
  213|       |    // Determine if there are any byte overlaps => relevant for determining
  214|       |    // access unit for endian, since pixdesc does not expose this, and assumes
  215|       |    // a weird model where you do separate memory fetches for each component.
  216|  12.0k|    bool any_shared_bytes = !!(pd->flags & AV_PIX_FMT_FLAG_BITSTREAM);
  217|  30.0k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (217:21): [True: 18.0k, False: 12.0k]
  ------------------
  218|  27.3k|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (218:25): [True: 9.27k, False: 18.0k]
  ------------------
  219|  9.27k|            const AVComponentDescriptor *d1 = &pd->comp[c];
  220|  9.27k|            const AVComponentDescriptor *d2 = &pd->comp[i];
  221|  9.27k|            if (d1->plane == d2->plane) {
  ------------------
  |  Branch (221:17): [True: 2.94k, False: 6.33k]
  ------------------
  222|  2.94k|                if (d1->offset + (d1->depth + 7) / 8u > d2->offset &&
  ------------------
  |  Branch (222:21): [True: 2.53k, False: 414]
  ------------------
  223|  2.53k|                    d2->offset + (d2->depth + 7) / 8u > d1->offset)
  ------------------
  |  Branch (223:21): [True: 0, False: 2.53k]
  ------------------
  224|      0|                    any_shared_bytes = true;
  225|  2.94k|            }
  226|  9.27k|        }
  227|  18.0k|    }
  228|       |
  229|  12.0k|    int el_bits = (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM) ? 1 : 8;
  ------------------
  |  Branch (229:19): [True: 4.21k, False: 7.78k]
  ------------------
  230|  30.0k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (230:21): [True: 18.0k, False: 12.0k]
  ------------------
  231|  18.0k|        const AVComponentDescriptor *d = &pd->comp[c];
  232|  18.0k|        if (d->plane >= MP_MAX_PLANES)
  ------------------
  |  |   28|  18.0k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (232:13): [True: 0, False: 18.0k]
  ------------------
  233|      0|            goto fail;
  234|       |
  235|  18.0k|        desc->num_planes = MPMAX(desc->num_planes, d->plane + 1);
  ------------------
  |  |   44|  18.0k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 3.83k, False: 14.2k]
  |  |  ------------------
  ------------------
  236|       |
  237|  18.0k|        int plane_bits = desc->bpp[d->plane];
  238|  18.0k|        int c_bits = d->step * el_bits;
  239|       |
  240|       |        // The first component wins, because either all components result in
  241|       |        // the same value, or luma wins (luma always comes before chroma).
  242|  18.0k|        if (plane_bits) {
  ------------------
  |  Branch (242:13): [True: 1.82k, False: 16.2k]
  ------------------
  243|  1.82k|            if (c_bits > plane_bits)
  ------------------
  |  Branch (243:17): [True: 0, False: 1.82k]
  ------------------
  244|      0|                goto fail; // inconsistent
  245|  16.2k|        } else {
  246|  16.2k|            desc->bpp[d->plane] = plane_bits = c_bits;
  247|  16.2k|        }
  248|       |
  249|  18.0k|        int shift = d->shift;
  250|       |        // What the fuck: for some inexplicable reason, MONOB uses shift=7
  251|       |        // in pixdesc, which is basically out of bounds. Pixdesc bug?
  252|       |        // Make it behave like MONOW. (No, the bit-order is not different.)
  253|  18.0k|        if (fmt == AV_PIX_FMT_MONOBLACK)
  ------------------
  |  Branch (253:13): [True: 0, False: 18.0k]
  ------------------
  254|      0|            shift = 0;
  255|       |
  256|  18.0k|        int offset = d->offset * el_bits;
  257|       |        // The pixdesc logic for reading and endian swapping is as follows
  258|       |        // (reverse engineered from av_read_image_line2()):
  259|       |        // - determine a word size that will include the component fully;
  260|       |        //   this includes the "active" bits and the amount "shifted" away
  261|       |        //   (for example shift=7/depth=18 => 32 bit word reading [31:0])
  262|       |        // - the same format can use different word sizes (e.g. bgr565: the R
  263|       |        //   component at offset 0 is read as 8 bit; BG is read as 16 bits)
  264|       |        // - if BE flag is set, swap the word before proceeding
  265|       |        // - extract via shift and mask derived by depth
  266|  18.0k|        int word = mp_round_next_power_of_2(MPMAX(d->depth + shift, 8));
  ------------------
  |  |   44|  18.0k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 7.04k, False: 11.0k]
  |  |  ------------------
  ------------------
  267|       |        // The purpose of this is unknown. It's an absurdity fished out of
  268|       |        // av_read_image_line2()'s implementation. It seems technically
  269|       |        // unnecessary, and provides no information. On the other hand, it
  270|       |        // compensates for seemingly bogus packed integer pixdescs; this
  271|       |        // is "why" some formats use d->offset = -1.
  272|  18.0k|        if (is_be && el_bits == 8 && word == 8)
  ------------------
  |  Branch (272:13): [True: 0, False: 18.0k]
  |  Branch (272:22): [True: 0, False: 0]
  |  Branch (272:38): [True: 0, False: 0]
  ------------------
  273|      0|            offset += 8;
  274|       |        // Pixdesc's model sometimes requires accesses with varying word-sizes,
  275|       |        // as seen in bgr565 and other formats. Also, it makes you read some
  276|       |        // formats with multiple endian-dependent accesses, where accessing a
  277|       |        // larger unit would make more sense. (Consider X2RGB10BE, for which
  278|       |        // pixdesc wants you to perform 3 * 2 byte accesses, and swap each of
  279|       |        // the read 16 bit words. What you really want is to swap the entire 4
  280|       |        // byte thing, and then extract the components with bit shifts).
  281|       |        // This is complete bullshit, so we transform it into word swaps before
  282|       |        // further processing. Care needs to be taken to not change formats like
  283|       |        // P010 or YA16 (prefer component accesses for them; P010 isn't even
  284|       |        // representable, because endian_shift is for all planes).
  285|       |        // As a heuristic, assume that if any components share a byte, the whole
  286|       |        // pixel is read as a single memory access and endian swapped at once.
  287|  18.0k|        int access_size = 8;
  288|  18.0k|        if (plane_bits > 8) {
  ------------------
  |  Branch (288:13): [True: 9.41k, False: 8.64k]
  ------------------
  289|  9.41k|            if (any_shared_bytes) {
  ------------------
  |  Branch (289:17): [True: 0, False: 9.41k]
  ------------------
  290|      0|                access_size = plane_bits;
  291|      0|                if (is_be && word != access_size) {
  ------------------
  |  Branch (291:21): [True: 0, False: 0]
  |  Branch (291:30): [True: 0, False: 0]
  ------------------
  292|       |                    // Before: offset = 8*byte_offset (with word bits of data)
  293|       |                    // After: offset = bit_offset into swapped endian_size word
  294|      0|                    offset = access_size - word - offset;
  295|      0|                }
  296|  9.41k|            } else {
  297|  9.41k|                access_size = word;
  298|  9.41k|            }
  299|  9.41k|        }
  300|  18.0k|        int endian_size = (access_size && !is_ne) ? access_size : 8;
  ------------------
  |  Branch (300:28): [True: 18.0k, False: 0]
  |  Branch (300:43): [True: 0, False: 18.0k]
  ------------------
  301|  18.0k|        int endian_shift = mp_log2(endian_size) - 3;
  302|  18.0k|        if (!MP_IS_POWER_OF_2(endian_size) || endian_shift < 0 || endian_shift > 3)
  ------------------
  |  |   56|  36.1k|#define MP_IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1)))
  |  |  ------------------
  |  |  |  Branch (56:30): [True: 18.0k, False: 0]
  |  |  |  Branch (56:41): [True: 18.0k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (302:47): [True: 0, False: 18.0k]
  |  Branch (302:67): [True: 0, False: 18.0k]
  ------------------
  303|      0|            goto fail;
  304|  18.0k|        if (desc->endian_shift && desc->endian_shift != endian_shift)
  ------------------
  |  Branch (304:13): [True: 0, False: 18.0k]
  |  Branch (304:35): [True: 0, False: 0]
  ------------------
  305|      0|            goto fail;
  306|  18.0k|        desc->endian_shift = endian_shift;
  307|       |
  308|       |        // We always use bit offsets; this doesn't lose any information,
  309|       |        // and pixdesc is merely more redundant.
  310|  18.0k|        offset += shift;
  311|  18.0k|        if (offset < 0 || offset >= (1 << 6))
  ------------------
  |  Branch (311:13): [True: 0, False: 18.0k]
  |  Branch (311:27): [True: 0, False: 18.0k]
  ------------------
  312|      0|            goto fail;
  313|  18.0k|        if (offset + d->depth > plane_bits)
  ------------------
  |  Branch (313:13): [True: 0, False: 18.0k]
  ------------------
  314|      0|            goto fail;
  315|  18.0k|        if (d->depth < 0 || d->depth >= (1 << 6))
  ------------------
  |  Branch (315:13): [True: 0, False: 18.0k]
  |  Branch (315:29): [True: 0, False: 18.0k]
  ------------------
  316|      0|            goto fail;
  317|  18.0k|        desc->comps[c] = (struct mp_imgfmt_comp_desc){
  318|  18.0k|            .plane = d->plane,
  319|  18.0k|            .offset = offset,
  320|  18.0k|            .size = d->depth,
  321|  18.0k|        };
  322|  18.0k|    }
  323|       |
  324|  28.2k|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (324:21): [True: 16.2k, False: 12.0k]
  ------------------
  325|  16.2k|        if (!desc->bpp[p])
  ------------------
  |  Branch (325:13): [True: 0, False: 16.2k]
  ------------------
  326|      0|            goto fail; // plane doesn't exist
  327|  16.2k|    }
  328|       |
  329|       |    // What the fuck: this is probably a pixdesc bug, so fix it.
  330|  12.0k|    if (fmt == AV_PIX_FMT_RGB8) {
  ------------------
  |  Branch (330:9): [True: 0, False: 12.0k]
  ------------------
  331|      0|        desc->comps[2] = (struct mp_imgfmt_comp_desc){0, 0, 2};
  332|      0|        desc->comps[1] = (struct mp_imgfmt_comp_desc){0, 2, 3};
  333|      0|        desc->comps[0] = (struct mp_imgfmt_comp_desc){0, 5, 3};
  334|      0|    }
  335|       |
  336|       |    // Overlap test. If any shared bits are happening, this is not a format we
  337|       |    // can represent (or it's something like Bayer: components in the same bits,
  338|       |    // but different alternating lines).
  339|  12.0k|    bool any_shared_bits = false;
  340|  30.0k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (340:21): [True: 18.0k, False: 12.0k]
  ------------------
  341|  27.3k|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (341:25): [True: 9.27k, False: 18.0k]
  ------------------
  342|  9.27k|            struct mp_imgfmt_comp_desc *c1 = &desc->comps[c];
  343|  9.27k|            struct mp_imgfmt_comp_desc *c2 = &desc->comps[i];
  344|  9.27k|            if (c1->plane == c2->plane) {
  ------------------
  |  Branch (344:17): [True: 2.94k, False: 6.33k]
  ------------------
  345|  2.94k|                if (c1->offset + c1->size > c2->offset &&
  ------------------
  |  Branch (345:21): [True: 2.53k, False: 414]
  ------------------
  346|  2.53k|                    c2->offset + c2->size > c1->offset)
  ------------------
  |  Branch (346:21): [True: 0, False: 2.53k]
  ------------------
  347|      0|                    any_shared_bits = true;
  348|  2.94k|            }
  349|  9.27k|        }
  350|  18.0k|    }
  351|       |
  352|  12.0k|    if (any_shared_bits) {
  ------------------
  |  Branch (352:9): [True: 0, False: 12.0k]
  ------------------
  353|      0|        for (int c = 0; c < pd->nb_components; c++)
  ------------------
  |  Branch (353:25): [True: 0, False: 0]
  ------------------
  354|      0|            desc->comps[c] = (struct mp_imgfmt_comp_desc){0};
  355|      0|    }
  356|       |
  357|       |    // Many important formats have padding within an access word. For example
  358|       |    // yuv420p10 has the upper 6 bit cleared to 0; P010 has the lower 6 bits
  359|       |    // cleared to 0. Pixdesc cannot represent that these bits are 0. There are
  360|       |    // other formats where padding is not guaranteed to be 0, but they are
  361|       |    // described in the same way.
  362|       |    // Apply a heuristic that is supposed to identify formats which use
  363|       |    // guaranteed 0 padding. This could fail, but nobody said this pixdesc crap
  364|       |    // is robust.
  365|  30.0k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (365:21): [True: 18.0k, False: 12.0k]
  ------------------
  366|  18.0k|        struct mp_imgfmt_comp_desc *cd = &desc->comps[c];
  367|       |        // Note: rgb444 would defeat our heuristic if we checked only per comp.
  368|       |        //       also, exclude "bitstream" formats due to monow/monob
  369|  18.0k|        int fsize = MP_ALIGN_UP(cd->size, 8);
  ------------------
  |  |   53|  18.0k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  370|  18.0k|        if (!any_shared_bytes && el_bits == 8 && fsize != cd->size &&
  ------------------
  |  Branch (370:13): [True: 13.8k, False: 4.21k]
  |  Branch (370:34): [True: 13.8k, False: 0]
  |  Branch (370:50): [True: 0, False: 13.8k]
  ------------------
  371|      0|            fsize - cd->size <= (1 << 3))
  ------------------
  |  Branch (371:13): [True: 0, False: 0]
  ------------------
  372|      0|        {
  373|      0|            if (!(cd->offset % 8u)) {
  ------------------
  |  Branch (373:17): [True: 0, False: 0]
  ------------------
  374|      0|                cd->pad = -(fsize - cd->size);
  375|      0|                cd->size = fsize;
  376|      0|            } else if (!((cd->offset + cd->size) % 8u)) {
  ------------------
  |  Branch (376:24): [True: 0, False: 0]
  ------------------
  377|      0|                cd->pad = fsize - cd->size;
  378|      0|                cd->size = fsize;
  379|      0|                cd->offset = MP_ALIGN_DOWN(cd->offset, 8);
  ------------------
  |  |   54|      0|#define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
  ------------------
  380|      0|            }
  381|      0|        }
  382|  18.0k|    }
  383|       |
  384|       |    // The alpha component always has ID 4 (index 3) in our representation, so
  385|       |    // move the alpha component to there.
  386|  12.0k|    if (has_alpha && pd->nb_components < 4) {
  ------------------
  |  Branch (386:9): [True: 138, False: 11.8k]
  |  Branch (386:22): [True: 0, False: 138]
  ------------------
  387|      0|        desc->comps[3] = desc->comps[pd->nb_components - 1];
  388|      0|        desc->comps[pd->nb_components - 1] = (struct mp_imgfmt_comp_desc){0};
  389|      0|    }
  390|       |
  391|  12.0k|    if (is_packed_ss_yuv) {
  ------------------
  |  Branch (391:9): [True: 0, False: 12.0k]
  ------------------
  392|      0|        desc->flags |= MP_IMGFLAG_PACKED_SS_YUV;
  ------------------
  |  |   86|      0|#define MP_IMGFLAG_PACKED_SS_YUV (1 << 15)
  ------------------
  393|      0|        desc->bpp[0] /= 1 << pd->log2_chroma_w;
  394|  12.0k|    } else if (!any_shared_bits) {
  ------------------
  |  Branch (394:16): [True: 12.0k, False: 0]
  ------------------
  395|  12.0k|        desc->flags |= MP_IMGFLAG_HAS_COMPS;
  ------------------
  |  |   34|  12.0k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  396|  12.0k|    }
  397|       |
  398|  12.0k|    return;
  399|       |
  400|  35.4k|fail:
  401|   177k|    for (int n = 0; n < 4; n++)
  ------------------
  |  Branch (401:21): [True: 141k, False: 35.4k]
  ------------------
  402|   141k|        desc->comps[n] = (struct mp_imgfmt_comp_desc){0};
  403|       |    // Average bit size fallback.
  404|  35.4k|    int num_planes = av_pix_fmt_count_planes(fmt);
  405|  35.4k|    desc->num_planes = MPCLAMP(num_planes, 0, MP_MAX_PLANES);
  ------------------
  |  |   46|  35.4k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 35.4k]
  |  |  |  Branch (46:56): [True: 0, False: 35.4k]
  |  |  ------------------
  ------------------
  406|  70.8k|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (406:21): [True: 35.4k, False: 35.4k]
  ------------------
  407|  35.4k|        int ls = av_image_get_linesize(fmt, 256, p);
  408|  35.4k|        desc->bpp[p] = ls > 0 ? ls * 8 / 256 : 0;
  ------------------
  |  Branch (408:24): [True: 35.4k, False: 0]
  ------------------
  409|  35.4k|    }
  410|  35.4k|}
img_format.c:get_forced_csp_from_flags:
  671|  1.84k|{
  672|  1.84k|    if (flags & MP_IMGFLAG_COLOR_XYZ)
  ------------------
  |  |   58|  1.84k|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  |  Branch (672:9): [True: 0, False: 1.84k]
  ------------------
  673|      0|        return PL_COLOR_SYSTEM_XYZ;
  674|       |
  675|  1.84k|    if (flags & MP_IMGFLAG_COLOR_RGB)
  ------------------
  |  |   57|  1.84k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  |  Branch (675:9): [True: 1.28k, False: 556]
  ------------------
  676|  1.28k|        return PL_COLOR_SYSTEM_RGB;
  677|       |
  678|    556|    return PL_COLOR_SYSTEM_UNKNOWN;
  679|  1.84k|}

mp_image_sethwfmt:
  199|  43.7k|{
  200|  43.7k|    struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(sw_fmt ? sw_fmt : hw_fmt);
  ------------------
  |  Branch (200:52): [True: 0, False: 43.7k]
  ------------------
  201|  43.7k|    mpi->params.imgfmt = hw_fmt;
  202|  43.7k|    mpi->params.hw_subfmt = sw_fmt;
  203|  43.7k|    mpi->fmt = fmt;
  204|  43.7k|    mpi->imgfmt = hw_fmt;
  205|  43.7k|    mpi->num_planes = fmt.num_planes;
  206|  43.7k|    mpi->params.repr.alpha = (fmt.flags & MP_IMGFLAG_ALPHA) ? PL_ALPHA_INDEPENDENT
  ------------------
  |  |   52|  43.7k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (206:30): [True: 34.8k, False: 8.87k]
  ------------------
  207|  43.7k|                                                            : PL_ALPHA_NONE;
  208|       |    // Calculate bit encoding from all components (excluding alpha)
  209|  43.7k|    struct pl_bit_encoding bits = {0};
  210|  43.7k|    const int num_comps = mp_imgfmt_desc_get_num_comps(&fmt);
  211|   161k|    for (int c = 0; c < MPMIN(num_comps, 3); c++) {
  ------------------
  |  |   45|   161k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 139k, False: 21.6k]
  |  |  ------------------
  ------------------
  |  Branch (211:21): [True: 117k, False: 43.7k]
  ------------------
  212|   117k|        struct pl_bit_encoding cbits = {
  213|   117k|            .sample_depth = fmt.comps[c].size,
  214|   117k|            .color_depth  = fmt.comps[c].size - abs(fmt.comps[c].pad),
  215|   117k|            .bit_shift    = MPMAX(fmt.comps[c].pad, 0),
  ------------------
  |  |   44|   117k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 117k]
  |  |  ------------------
  ------------------
  216|   117k|        };
  217|       |
  218|   117k|        if (bits.sample_depth && !pl_bit_encoding_equal(&bits, &cbits)) {
  ------------------
  |  Branch (218:13): [True: 3.95k, False: 113k]
  |  Branch (218:34): [True: 0, False: 3.95k]
  ------------------
  219|       |            // Bit encoding differs between components, cannot handle this
  220|      0|            bits = (struct pl_bit_encoding) {0};
  221|      0|            break;
  222|      0|        }
  223|       |
  224|   117k|        bits = cbits;
  225|   117k|    }
  226|  43.7k|    mpi->params.repr.bits = bits;
  227|  43.7k|}
mp_image_set_size:
  269|  43.7k|{
  270|  43.7k|    mp_assert(w >= 0 && h >= 0);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (270:5): [True: 43.7k, False: 0]
  |  Branch (270:5): [True: 43.7k, False: 0]
  ------------------
  271|  43.7k|    mpi->w = mpi->params.w = w;
  272|  43.7k|    mpi->h = mpi->params.h = h;
  273|  43.7k|}
mp_image_new_ref:
  360|   131k|{
  361|   131k|    if (!img)
  ------------------
  |  Branch (361:9): [True: 0, False: 131k]
  ------------------
  362|      0|        return NULL;
  363|       |
  364|   131k|    if (!img->bufs[0])
  ------------------
  |  Branch (364:9): [True: 0, False: 131k]
  ------------------
  365|      0|        return mp_image_new_copy(img);
  366|       |
  367|   131k|    struct mp_image *new = talloc_ptrtype(NULL, new);
  ------------------
  |  |   34|   131k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   131k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   131k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|   131k|    talloc_set_destructor(new, mp_image_destructor);
  ------------------
  |  |   41|   131k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  369|   131k|    *new = *img;
  370|       |
  371|   656k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   656k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (371:21): [True: 525k, False: 131k]
  ------------------
  372|   525k|        ref_buffer(&new->bufs[p]);
  373|       |
  374|   131k|    ref_buffer(&new->hwctx);
  375|   131k|    ref_buffer(&new->icc_profile);
  376|   131k|    ref_buffer(&new->a53_cc);
  377|   131k|    ref_buffer(&new->dovi);
  378|   131k|    ref_buffer(&new->film_grain);
  379|       |
  380|   131k|    new->ff_side_data = talloc_memdup(NULL, new->ff_side_data,
  ------------------
  |  |   49|   131k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   131k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   131k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   131k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   131k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|   131k|                        new->num_ff_side_data * sizeof(new->ff_side_data[0]));
  382|   131k|    for (int n = 0; n < new->num_ff_side_data; n++)
  ------------------
  |  Branch (382:21): [True: 0, False: 131k]
  ------------------
  383|      0|        ref_buffer(&new->ff_side_data[n].buf);
  384|       |
  385|   131k|    new->enhancement_layer = img->enhancement_layer
  ------------------
  |  Branch (385:30): [True: 0, False: 131k]
  ------------------
  386|   131k|        ? mp_image_new_ref(img->enhancement_layer) : NULL;
  387|       |
  388|   131k|    return new;
  389|   131k|}
mp_image_unrefp:
  488|   452k|{
  489|   452k|    talloc_free(*p_img);
  ------------------
  |  |   47|   452k|#define talloc_free                     ta_free
  ------------------
  490|       |    *p_img = NULL;
  491|   452k|}
mp_image_crop_valid:
  778|  60.7k|{
  779|  60.7k|    return p->crop.x1 > p->crop.x0 && p->crop.y1 > p->crop.y0 &&
  ------------------
  |  Branch (779:12): [True: 60.7k, False: 0]
  |  Branch (779:39): [True: 60.7k, False: 0]
  ------------------
  780|  60.7k|           p->crop.x0 >= 0 && p->crop.y0 >= 0 &&
  ------------------
  |  Branch (780:12): [True: 60.7k, False: 0]
  |  Branch (780:31): [True: 60.7k, False: 0]
  ------------------
  781|  60.7k|           p->crop.x1 <= p->w && p->crop.y1 <= p->h;
  ------------------
  |  Branch (781:12): [True: 60.7k, False: 0]
  |  Branch (781:34): [True: 60.7k, False: 0]
  ------------------
  782|  60.7k|}
mp_image_params_get_dsize:
  787|  1.88k|{
  788|  1.88k|    if (mp_image_crop_valid(p))
  ------------------
  |  Branch (788:9): [True: 1.88k, False: 0]
  ------------------
  789|  1.88k|    {
  790|  1.88k|        *d_w = mp_rect_w(p->crop);
  ------------------
  |  |  157|  1.88k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  791|  1.88k|        *d_h = mp_rect_h(p->crop);
  ------------------
  |  |  158|  1.88k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  792|  1.88k|    } else {
  793|      0|        *d_w = p->w;
  794|      0|        *d_h = p->h;
  795|      0|    }
  796|       |
  797|  1.88k|    if (p->p_w > p->p_h && p->p_h >= 1)
  ------------------
  |  Branch (797:9): [True: 2, False: 1.88k]
  |  Branch (797:28): [True: 2, False: 0]
  ------------------
  798|      2|        *d_w = MPCLAMP(*d_w * (int64_t)p->p_w / p->p_h, 1, INT_MAX);
  ------------------
  |  |   46|      2|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 2]
  |  |  |  Branch (46:56): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  799|  1.88k|    if (p->p_h > p->p_w && p->p_w >= 1)
  ------------------
  |  Branch (799:9): [True: 90, False: 1.79k]
  |  Branch (799:28): [True: 90, False: 0]
  ------------------
  800|     90|        *d_h = MPCLAMP(*d_h * (int64_t)p->p_h / p->p_w, 1, INT_MAX);
  ------------------
  |  |   46|     90|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 90]
  |  |  |  Branch (46:56): [True: 0, False: 90]
  |  |  ------------------
  ------------------
  801|  1.88k|}
mp_image_params_to_str_buf:
  812|  14.7k|{
  813|  14.7k|    if (p && p->imgfmt) {
  ------------------
  |  Branch (813:9): [True: 14.7k, False: 0]
  |  Branch (813:14): [True: 14.7k, False: 0]
  ------------------
  814|  14.7k|        snprintf(b, bs, "%dx%d", p->w, p->h);
  815|  14.7k|        if (p->p_w != p->p_h || !p->p_w)
  ------------------
  |  Branch (815:13): [True: 2.16k, False: 12.5k]
  |  Branch (815:33): [True: 0, False: 12.5k]
  ------------------
  816|  2.16k|            mp_snprintf_cat(b, bs, " [%d:%d]", p->p_w, p->p_h);
  817|  14.7k|        mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
  ------------------
  |  |  333|  14.7k|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
  818|  14.7k|        if (p->hw_subfmt)
  ------------------
  |  Branch (818:13): [True: 0, False: 14.7k]
  ------------------
  819|      0|            mp_snprintf_cat(b, bs, "[%s]", mp_imgfmt_to_name(p->hw_subfmt));
  ------------------
  |  |  333|      0|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
  820|  14.7k|        mp_snprintf_cat(b, bs, " %s/%s/%s/%s/%s",
  821|  14.7k|                        m_opt_choice_str(pl_csp_names, p->repr.sys),
  822|  14.7k|                        m_opt_choice_str(pl_csp_prim_names, p->color.primaries),
  823|  14.7k|                        m_opt_choice_str(pl_csp_trc_names, p->color.transfer),
  824|  14.7k|                        m_opt_choice_str(pl_csp_levels_names, p->repr.levels),
  825|  14.7k|                        m_opt_choice_str(mp_csp_light_names, p->light));
  826|  14.7k|        mp_snprintf_cat(b, bs, " CL=%s",
  827|  14.7k|                        m_opt_choice_str(pl_chroma_names, p->chroma_location));
  828|  14.7k|        if (mp_image_crop_valid(p)) {
  ------------------
  |  Branch (828:13): [True: 14.7k, False: 0]
  ------------------
  829|  14.7k|            mp_snprintf_cat(b, bs, " crop=%dx%d+%d+%d", mp_rect_w(p->crop),
  ------------------
  |  |  157|  14.7k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  830|  14.7k|                            mp_rect_h(p->crop), p->crop.x0, p->crop.y0);
  ------------------
  |  |  158|  14.7k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  831|  14.7k|        }
  832|  14.7k|        if (p->rotate)
  ------------------
  |  Branch (832:13): [True: 0, False: 14.7k]
  ------------------
  833|      0|            mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
  834|  14.7k|        if (p->stereo3d > 0) {
  ------------------
  |  Branch (834:13): [True: 0, False: 14.7k]
  ------------------
  835|      0|            mp_snprintf_cat(b, bs, " stereo=%s",
  836|      0|                            MP_STEREO3D_NAME_DEF(p->stereo3d, "?"));
  ------------------
  |  |   75|      0|#define MP_STEREO3D_NAME_DEF(x, def) m_opt_choice_str_def(mp_stereo3d_names, x, def)
  ------------------
  837|      0|        }
  838|  14.7k|        if (p->repr.alpha) {
  ------------------
  |  Branch (838:13): [True: 11.9k, False: 2.74k]
  ------------------
  839|  11.9k|            mp_snprintf_cat(b, bs, " A=%s",
  840|  11.9k|                            m_opt_choice_str(pl_alpha_names, p->repr.alpha));
  841|  11.9k|        }
  842|  14.7k|    } else {
  843|      0|        snprintf(b, bs, "???");
  844|      0|    }
  845|  14.7k|    return b;
  846|  14.7k|}
mp_image_params_equal:
  883|   362k|{
  884|   362k|    return p1->imgfmt == p2->imgfmt &&
  ------------------
  |  Branch (884:12): [True: 342k, False: 19.6k]
  ------------------
  885|   342k|           p1->hw_subfmt == p2->hw_subfmt &&
  ------------------
  |  Branch (885:12): [True: 342k, False: 0]
  ------------------
  886|   342k|           p1->w == p2->w && p1->h == p2->h &&
  ------------------
  |  Branch (886:12): [True: 340k, False: 2.04k]
  |  Branch (886:30): [True: 335k, False: 4.95k]
  ------------------
  887|   335k|           p1->p_w == p2->p_w && p1->p_h == p2->p_h &&
  ------------------
  |  Branch (887:12): [True: 335k, False: 0]
  |  Branch (887:34): [True: 335k, False: 0]
  ------------------
  888|   335k|           p1->force_window == p2->force_window &&
  ------------------
  |  Branch (888:12): [True: 335k, False: 0]
  ------------------
  889|   335k|           pl_color_space_equal(&p1->color, &p2->color) &&
  ------------------
  |  Branch (889:12): [True: 335k, False: 0]
  ------------------
  890|   335k|           pl_color_repr_equal(&p1->repr, &p2->repr) &&
  ------------------
  |  Branch (890:12): [True: 335k, False: 0]
  ------------------
  891|   335k|           p1->light == p2->light &&
  ------------------
  |  Branch (891:12): [True: 335k, False: 0]
  ------------------
  892|   335k|           p1->chroma_location == p2->chroma_location &&
  ------------------
  |  Branch (892:12): [True: 335k, False: 0]
  ------------------
  893|   335k|           p1->vflip == p2->vflip &&
  ------------------
  |  Branch (893:12): [True: 335k, False: 0]
  ------------------
  894|   335k|           p1->rotate == p2->rotate &&
  ------------------
  |  Branch (894:12): [True: 335k, False: 0]
  ------------------
  895|   335k|           p1->stereo3d == p2->stereo3d &&
  ------------------
  |  Branch (895:12): [True: 335k, False: 0]
  ------------------
  896|   335k|           mp_rect_equals(&p1->crop, &p2->crop);
  ------------------
  |  Branch (896:12): [True: 335k, False: 0]
  ------------------
  897|   362k|}
mp_image_params_static_equal:
  901|  56.0k|{
  902|       |    // Compare only static video parameters, excluding dynamic metadata.
  903|  56.0k|    struct mp_image_params a = *p1;
  904|  56.0k|    struct mp_image_params b = *p2;
  905|       |    a.repr.dovi = b.repr.dovi = NULL;
  906|  56.0k|    a.color.hdr = b.color.hdr = (struct pl_hdr_metadata){0};
  907|  56.0k|    return mp_image_params_equal(&a, &b);
  908|  56.0k|}
mp_image_params_update_dynamic:
  913|  42.3k|{
  914|  42.3k|    dst->repr.dovi = src->repr.dovi;
  915|       |    // Don't overwrite peak-detected HDR metadata if available.
  916|  42.3k|    struct pl_hdr_metadata *hdr = &dst->color.hdr;
  917|  42.3k|    const struct pl_hdr_metadata prev = *hdr;
  918|  42.3k|    *hdr = src->color.hdr;
  919|  42.3k|    if (has_peak_detect_values) {
  ------------------
  |  Branch (919:9): [True: 0, False: 42.3k]
  ------------------
  920|      0|        hdr->max_pq_y  = prev.max_pq_y;
  921|      0|        hdr->avg_pq_y  = prev.avg_pq_y;
  922|      0|        hdr->scene_avg = prev.scene_avg;
  923|      0|        memcpy(hdr->scene_max, prev.scene_max, sizeof(hdr->scene_max));
  924|      0|    }
  925|  42.3k|}
mp_image_params_guess_csp:
  990|  1.84k|{
  991|  1.84k|    enum pl_color_system forced_csp = mp_image_params_get_forced_csp(params);
  992|  1.84k|    if (forced_csp == PL_COLOR_SYSTEM_UNKNOWN) { // YUV/other
  ------------------
  |  Branch (992:9): [True: 556, False: 1.28k]
  ------------------
  993|    556|        if (params->repr.sys != PL_COLOR_SYSTEM_BT_601 &&
  ------------------
  |  Branch (993:13): [True: 556, False: 0]
  ------------------
  994|    556|            params->repr.sys != PL_COLOR_SYSTEM_BT_709 &&
  ------------------
  |  Branch (994:13): [True: 556, False: 0]
  ------------------
  995|    556|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_NC &&
  ------------------
  |  Branch (995:13): [True: 556, False: 0]
  ------------------
  996|    556|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_C &&
  ------------------
  |  Branch (996:13): [True: 556, False: 0]
  ------------------
  997|    556|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_PQ &&
  ------------------
  |  Branch (997:13): [True: 556, False: 0]
  ------------------
  998|    556|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_HLG &&
  ------------------
  |  Branch (998:13): [True: 556, False: 0]
  ------------------
  999|    556|            params->repr.sys != PL_COLOR_SYSTEM_DOLBYVISION &&
  ------------------
  |  Branch (999:13): [True: 556, False: 0]
  ------------------
 1000|    556|            params->repr.sys != PL_COLOR_SYSTEM_SMPTE_240M &&
  ------------------
  |  Branch (1000:13): [True: 556, False: 0]
  ------------------
 1001|    556|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO &&
  ------------------
  |  Branch (1001:13): [True: 556, False: 0]
  ------------------
 1002|    556|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RE &&
  ------------------
  |  Branch (1002:13): [True: 556, False: 0]
  ------------------
 1003|    556|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RO
  ------------------
  |  Branch (1003:13): [True: 556, False: 0]
  ------------------
 1004|    556|        ) {
 1005|       |            // Makes no sense, so guess instead
 1006|       |            // YCGCO should be separate, but libavcodec disagrees
 1007|    556|            params->repr.sys = PL_COLOR_SYSTEM_UNKNOWN;
 1008|    556|        }
 1009|    556|        if (params->repr.sys == PL_COLOR_SYSTEM_UNKNOWN)
  ------------------
  |  Branch (1009:13): [True: 556, False: 0]
  ------------------
 1010|    556|            params->repr.sys = mp_csp_guess_colorspace(params->w, params->h);
 1011|    556|        if (params->repr.levels == PL_COLOR_LEVELS_UNKNOWN) {
  ------------------
  |  Branch (1011:13): [True: 556, False: 0]
  ------------------
 1012|    556|            if (params->color.transfer == PL_COLOR_TRC_V_LOG) {
  ------------------
  |  Branch (1012:17): [True: 0, False: 556]
  ------------------
 1013|      0|                params->repr.levels = PL_COLOR_LEVELS_FULL;
 1014|    556|            } else {
 1015|    556|                params->repr.levels = infer_levels(params->imgfmt);
 1016|    556|            }
 1017|    556|        }
 1018|    556|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN) {
  ------------------
  |  Branch (1018:13): [True: 556, False: 0]
  ------------------
 1019|       |            // Guess based on the colormatrix as a first priority
 1020|    556|            if (params->repr.sys == PL_COLOR_SYSTEM_BT_2020_NC ||
  ------------------
  |  Branch (1020:17): [True: 0, False: 556]
  ------------------
 1021|    556|                params->repr.sys == PL_COLOR_SYSTEM_BT_2020_C) {
  ------------------
  |  Branch (1021:17): [True: 0, False: 556]
  ------------------
 1022|      0|                params->color.primaries = PL_COLOR_PRIM_BT_2020;
 1023|    556|            } else if (params->repr.sys == PL_COLOR_SYSTEM_BT_709) {
  ------------------
  |  Branch (1023:24): [True: 0, False: 556]
  ------------------
 1024|      0|                params->color.primaries = PL_COLOR_PRIM_BT_709;
 1025|    556|            } else {
 1026|       |                // Ambiguous colormatrix for BT.601, guess based on res
 1027|    556|                params->color.primaries = mp_csp_guess_primaries(params->w, params->h);
 1028|    556|            }
 1029|    556|        }
 1030|    556|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1030:13): [True: 556, False: 0]
  ------------------
 1031|    556|            params->color.transfer = params->repr.levels == PL_COLOR_LEVELS_LIMITED ?
  ------------------
  |  Branch (1031:38): [True: 158, False: 398]
  ------------------
 1032|    398|                                        PL_COLOR_TRC_BT_1886 : PL_COLOR_TRC_SRGB;
 1033|  1.28k|    } else if (forced_csp == PL_COLOR_SYSTEM_RGB) {
  ------------------
  |  Branch (1033:16): [True: 1.28k, False: 0]
  ------------------
 1034|  1.28k|        params->repr.sys = PL_COLOR_SYSTEM_RGB;
 1035|  1.28k|        params->repr.levels = PL_COLOR_LEVELS_FULL;
 1036|       |
 1037|       |        // The majority of RGB content is either sRGB or (rarely) some other
 1038|       |        // color space which we don't even handle, like AdobeRGB or
 1039|       |        // ProPhotoRGB. The only reasonable thing we can do is assume it's
 1040|       |        // sRGB and hope for the best, which should usually just work out fine.
 1041|       |        // Note: sRGB primaries = BT.709 primaries
 1042|  1.28k|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN)
  ------------------
  |  Branch (1042:13): [True: 1.28k, False: 0]
  ------------------
 1043|  1.28k|            params->color.primaries = PL_COLOR_PRIM_BT_709;
 1044|  1.28k|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1044:13): [True: 1.28k, False: 0]
  ------------------
 1045|  1.28k|            params->color.transfer = PL_COLOR_TRC_SRGB;
 1046|  1.28k|    } else if (forced_csp == PL_COLOR_SYSTEM_XYZ) {
  ------------------
  |  Branch (1046:16): [True: 0, False: 0]
  ------------------
 1047|      0|        params->repr.sys = PL_COLOR_SYSTEM_XYZ;
 1048|      0|        params->repr.levels = PL_COLOR_LEVELS_FULL;
 1049|      0|        if (params->color.transfer == PL_COLOR_TRC_LINEAR) {
  ------------------
  |  Branch (1049:13): [True: 0, False: 0]
  ------------------
 1050|       |            // Linear light XYZ is decoded into the tagged primaries
 1051|      0|            if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN)
  ------------------
  |  Branch (1051:17): [True: 0, False: 0]
  ------------------
 1052|      0|                params->color.primaries = PL_COLOR_PRIM_BT_2020;
 1053|      0|        } else {
 1054|       |            // Anything else is DCDM X'Y'Z' (ST 428-1) by default.
 1055|      0|            if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1055:17): [True: 0, False: 0]
  ------------------
 1056|      0|                params->color.transfer = PL_COLOR_TRC_ST428;
 1057|      0|            if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN)
  ------------------
  |  Branch (1057:17): [True: 0, False: 0]
  ------------------
 1058|      0|                params->color.primaries = PL_COLOR_PRIM_DCI_P3;
 1059|      0|        }
 1060|      0|    } else {
 1061|       |        // We have no clue.
 1062|      0|        params->repr.sys = PL_COLOR_SYSTEM_UNKNOWN;
 1063|      0|        params->repr.levels = PL_COLOR_LEVELS_UNKNOWN;
 1064|      0|        params->color.primaries = PL_COLOR_PRIM_UNKNOWN;
 1065|      0|        params->color.transfer = PL_COLOR_TRC_UNKNOWN;
 1066|      0|    }
 1067|       |
 1068|       |    // If the signal peak is unknown, we're forced to pick the TRC's
 1069|       |    // nominal range as the signal peak to prevent clipping
 1070|  1.84k|    pl_color_space_infer(&params->color);
 1071|       |
 1072|  1.84k|    if (!pl_color_space_is_hdr(&params->color)) {
  ------------------
  |  Branch (1072:9): [True: 1.84k, False: 0]
  ------------------
 1073|       |        // Some clips have leftover HDR metadata after conversion to SDR, so to
 1074|       |        // avoid blowing up the tone mapping code, strip/sanitize it
 1075|  1.84k|        params->color.hdr = pl_hdr_metadata_empty;
 1076|  1.84k|    }
 1077|       |
 1078|  1.84k|    if (mp_imgfmt_is_subsampled(params->hw_subfmt ? params->hw_subfmt : params->imgfmt)) {
  ------------------
  |  Branch (1078:9): [True: 64, False: 1.77k]
  |  Branch (1078:33): [True: 0, False: 1.84k]
  ------------------
 1079|     64|        if (params->chroma_location == PL_CHROMA_UNKNOWN) {
  ------------------
  |  Branch (1079:13): [True: 64, False: 0]
  ------------------
 1080|     64|            if (params->repr.levels == PL_COLOR_LEVELS_LIMITED)
  ------------------
  |  Branch (1080:17): [True: 64, False: 0]
  ------------------
 1081|     64|                params->chroma_location = PL_CHROMA_LEFT;
 1082|     64|            if (params->repr.levels == PL_COLOR_LEVELS_FULL)
  ------------------
  |  Branch (1082:17): [True: 0, False: 64]
  ------------------
 1083|      0|                params->chroma_location = PL_CHROMA_CENTER;
 1084|     64|        }
 1085|  1.77k|    } else {
 1086|       |        // Set to center for non-subsampled formats.
 1087|  1.77k|        params->chroma_location = PL_CHROMA_CENTER;
 1088|  1.77k|    }
 1089|       |
 1090|  1.84k|    if (params->light == MP_CSP_LIGHT_AUTO) {
  ------------------
  |  Branch (1090:9): [True: 1.84k, False: 0]
  ------------------
 1091|       |        // HLG is always scene-referred (using its own OOTF), everything else
 1092|       |        // we assume is display-referred by default.
 1093|  1.84k|        if (params->color.transfer == PL_COLOR_TRC_HLG) {
  ------------------
  |  Branch (1093:13): [True: 0, False: 1.84k]
  ------------------
 1094|      0|            params->light = MP_CSP_LIGHT_SCENE_HLG;
 1095|  1.84k|        } else {
 1096|  1.84k|            params->light = MP_CSP_LIGHT_DISPLAY;
 1097|  1.84k|        }
 1098|  1.84k|    }
 1099|  1.84k|}
mp_image_from_av_frame:
 1103|  43.7k|{
 1104|  43.7k|    struct mp_image *dst = &(struct mp_image){0};
 1105|  43.7k|    AVFrameSideData *sd;
 1106|       |
 1107|   218k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   218k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (1107:21): [True: 175k, False: 43.7k]
  ------------------
 1108|   175k|        dst->bufs[p] = src->buf[p];
 1109|       |
 1110|  43.7k|    dst->hwctx = src->hw_frames_ctx;
 1111|       |
 1112|  43.7k|    if (dst->hwctx) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 43.7k]
  ------------------
 1113|      0|        AVHWFramesContext *fctx = (void *)dst->hwctx->data;
 1114|      0|        dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format);
 1115|      0|    }
 1116|       |
 1117|  43.7k|    mp_image_sethwfmt(dst, pixfmt2imgfmt(src->format), dst->params.hw_subfmt);
 1118|  43.7k|    mp_image_set_size(dst, src->width, src->height);
 1119|       |
 1120|  43.7k|    dst->params.p_w = src->sample_aspect_ratio.num;
 1121|  43.7k|    dst->params.p_h = src->sample_aspect_ratio.den;
 1122|       |
 1123|   218k|    for (int i = 0; i < 4; i++) {
  ------------------
  |  Branch (1123:21): [True: 175k, False: 43.7k]
  ------------------
 1124|   175k|        dst->planes[i] = src->data[i];
 1125|   175k|        dst->stride[i] = src->linesize[i];
 1126|   175k|    }
 1127|       |
 1128|  43.7k|    dst->pict_type = src->pict_type;
 1129|       |
 1130|  43.7k|    dst->params.crop.x0 = src->crop_left;
 1131|  43.7k|    dst->params.crop.y0 = src->crop_top;
 1132|  43.7k|    dst->params.crop.x1 = src->width - src->crop_right;
 1133|  43.7k|    dst->params.crop.y1 = src->height - src->crop_bottom;
 1134|       |
 1135|  43.7k|    dst->fields = 0;
 1136|  43.7k|    if (src->flags & AV_FRAME_FLAG_INTERLACED)
  ------------------
  |  Branch (1136:9): [True: 0, False: 43.7k]
  ------------------
 1137|      0|        dst->fields |= MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|      0|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
 1138|  43.7k|    if (src->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
  ------------------
  |  Branch (1138:9): [True: 0, False: 43.7k]
  ------------------
 1139|      0|        dst->fields |= MP_IMGFIELD_TOP_FIRST;
  ------------------
  |  |   37|      0|#define MP_IMGFIELD_TOP_FIRST 0x02
  ------------------
 1140|  43.7k|    if (src->repeat_pict == 1)
  ------------------
  |  Branch (1140:9): [True: 0, False: 43.7k]
  ------------------
 1141|      0|        dst->fields |= MP_IMGFIELD_REPEAT_FIRST;
  ------------------
  |  |   38|      0|#define MP_IMGFIELD_REPEAT_FIRST 0x04
  ------------------
 1142|       |
 1143|  43.7k|    dst->params.repr.sys = pl_system_from_av(src->colorspace);
 1144|  43.7k|    dst->params.repr.levels = pl_levels_from_av(src->color_range);
 1145|       |
 1146|  43.7k|    dst->params.color = (struct pl_color_space){
 1147|  43.7k|        .primaries = pl_primaries_from_av(src->color_primaries),
 1148|  43.7k|        .transfer = pl_transfer_from_av(src->color_trc),
 1149|  43.7k|    };
 1150|       |
 1151|  43.7k|    dst->params.chroma_location = pl_chroma_from_av(src->chroma_location);
 1152|       |
 1153|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_STEREO3D);
 1154|  43.7k|    if (sd)
  ------------------
  |  Branch (1154:9): [True: 0, False: 43.7k]
  ------------------
 1155|      0|        dst->params.stereo3d = mp_stereo3d_from_av((const AVStereo3D *)sd->data);
 1156|       |
 1157|  43.7k|    if (src->opaque_ref) {
  ------------------
  |  Branch (1157:9): [True: 0, False: 43.7k]
  ------------------
 1158|      0|        struct mp_image_params *p = (void *)src->opaque_ref->data;
 1159|      0|        dst->params.stereo3d = p->stereo3d;
 1160|       |        // Might be incorrect if colorspace changes.
 1161|      0|        dst->params.light = p->light;
 1162|      0|        dst->params.no_dovi = p->no_dovi;
 1163|      0|        dst->params.no_enhancement_layer = p->no_enhancement_layer;
 1164|       |#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(60, 11, 100)
 1165|       |        dst->params.repr.alpha = p->repr.alpha;
 1166|       |#endif
 1167|      0|    }
 1168|       |
 1169|  43.7k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(60, 11, 100)
 1170|       |    // mp_image_setfmt sets to PL_ALPHA_INDEPENDENT, if format has alpha.
 1171|  43.7k|    if (dst->params.repr.alpha == PL_ALPHA_INDEPENDENT)
  ------------------
  |  Branch (1171:9): [True: 34.8k, False: 8.87k]
  ------------------
 1172|  34.8k|        dst->params.repr.alpha = pl_alpha_from_av(src->alpha_mode);
 1173|  43.7k|#endif
 1174|       |
 1175|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DISPLAYMATRIX);
 1176|  43.7k|    if (sd) {
  ------------------
  |  Branch (1176:9): [True: 0, False: 43.7k]
  ------------------
 1177|      0|        int32_t *matrix = (int32_t *) sd->data;
 1178|       |        // determinant
 1179|      0|        int vflip = ((int64_t)matrix[0] * (int64_t)matrix[4]
 1180|      0|                    - (int64_t)matrix[1] * (int64_t)matrix[3]) < 0;
 1181|      0|        double r = av_display_rotation_get(matrix);
 1182|      0|        if (!isnan(r)) {
  ------------------
  |  Branch (1182:13): [True: 0, False: 0]
  ------------------
 1183|      0|            dst->params.rotate = (((int)(-r) % 360) + 360) % 360;
 1184|      0|            dst->params.vflip = vflip;
 1185|      0|        }
 1186|      0|    }
 1187|       |
 1188|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE);
 1189|  43.7k|    if (sd)
  ------------------
  |  Branch (1189:9): [True: 0, False: 43.7k]
  ------------------
 1190|      0|        dst->icc_profile = sd->buf;
 1191|       |
 1192|  43.7k|    AVFrameSideData *mdm = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
 1193|  43.7k|    AVFrameSideData *clm = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
 1194|  43.7k|    AVFrameSideData *dhp = av_frame_get_side_data(src, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
 1195|  43.7k|    pl_map_hdr_metadata(&dst->params.color.hdr, &(struct pl_av_hdr_metadata) {
 1196|  43.7k|        .mdm = (void *)(mdm ? mdm->data : NULL),
  ------------------
  |  Branch (1196:25): [True: 0, False: 43.7k]
  ------------------
 1197|  43.7k|        .clm = (void *)(clm ? clm->data : NULL),
  ------------------
  |  Branch (1197:25): [True: 0, False: 43.7k]
  ------------------
 1198|  43.7k|        .dhp = (void *)(dhp ? dhp->data : NULL),
  ------------------
  |  Branch (1198:25): [True: 0, False: 43.7k]
  ------------------
 1199|  43.7k|    });
 1200|       |
 1201|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_A53_CC);
 1202|  43.7k|    if (sd)
  ------------------
  |  Branch (1202:9): [True: 0, False: 43.7k]
  ------------------
 1203|      0|        dst->a53_cc = sd->buf;
 1204|       |
 1205|  43.7k|    dst->params.primaries_orig = dst->params.color.primaries;
 1206|  43.7k|    dst->params.transfer_orig = dst->params.color.transfer;
 1207|  43.7k|    dst->params.sys_orig = dst->params.repr.sys;
 1208|  43.7k|    AVBufferRef *dovi = NULL;
 1209|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_METADATA);
 1210|  43.7k|    if (sd) {
  ------------------
  |  Branch (1210:9): [True: 0, False: 43.7k]
  ------------------
 1211|      0|#ifdef PL_HAVE_LAV_DOLBY_VISION
 1212|      0|        const AVDOVIMetadata *metadata = (const AVDOVIMetadata *)sd->buf->data;
 1213|      0|        dst->dovi = dovi = av_buffer_alloc(sizeof(struct pl_dovi_metadata));
 1214|      0|        MP_HANDLE_OOM(dovi);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1215|      0|        pl_map_avdovi_metadata(&dst->params.color, &dst->params.repr,
 1216|      0|                               (void *)dst->dovi->data, metadata);
 1217|      0|#endif
 1218|      0|    }
 1219|       |
 1220|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_RPU_BUFFER);
 1221|  43.7k|    if (sd) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 43.7k]
  ------------------
 1222|      0|        pl_hdr_metadata_from_dovi_rpu(&dst->params.color.hdr, sd->buf->data,
 1223|      0|                                      sd->buf->size);
 1224|      0|    }
 1225|       |
 1226|  43.7k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
 1227|  43.7k|    if (sd)
  ------------------
  |  Branch (1227:9): [True: 0, False: 43.7k]
  ------------------
 1228|      0|        dst->film_grain = sd->buf;
 1229|       |
 1230|  43.7k|    for (int n = 0; n < src->nb_side_data; n++) {
  ------------------
  |  Branch (1230:21): [True: 0, False: 43.7k]
  ------------------
 1231|      0|        sd = src->side_data[n];
 1232|      0|        struct mp_ff_side_data mpsd = {
 1233|      0|            .type = sd->type,
 1234|      0|            .buf = sd->buf,
 1235|      0|        };
 1236|      0|        MP_TARRAY_APPEND(NULL, dst->ff_side_data, dst->num_ff_side_data, mpsd);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1237|      0|    }
 1238|       |
 1239|  43.7k|    struct mp_image *res = mp_image_new_ref(dst);
 1240|       |
 1241|       |    // Allocated, but non-refcounted data.
 1242|  43.7k|    talloc_free(dst->ff_side_data);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
 1243|  43.7k|    av_buffer_unref(&dovi);
 1244|       |
 1245|  43.7k|    return res;
 1246|  43.7k|}
mp_image.c:mp_image_destructor:
  235|   131k|{
  236|   131k|    mp_image_t *mpi = ptr;
  237|   656k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   656k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (237:21): [True: 525k, False: 131k]
  ------------------
  238|   525k|        av_buffer_unref(&mpi->bufs[p]);
  239|   131k|    av_buffer_unref(&mpi->hwctx);
  240|   131k|    av_buffer_unref(&mpi->icc_profile);
  241|   131k|    av_buffer_unref(&mpi->a53_cc);
  242|   131k|    av_buffer_unref(&mpi->dovi);
  243|   131k|    av_buffer_unref(&mpi->film_grain);
  244|   131k|    for (int n = 0; n < mpi->num_ff_side_data; n++)
  ------------------
  |  Branch (244:21): [True: 0, False: 131k]
  ------------------
  245|      0|        av_buffer_unref(&mpi->ff_side_data[n].buf);
  246|   131k|    talloc_free(mpi->ff_side_data);
  ------------------
  |  |   47|   131k|#define talloc_free                     ta_free
  ------------------
  247|   131k|    mp_image_unrefp(&mpi->enhancement_layer);
  248|   131k|}
mp_image.c:ref_buffer:
  350|  1.18M|{
  351|  1.18M|    if (*dst) {
  ------------------
  |  Branch (351:9): [True: 244k, False: 936k]
  ------------------
  352|   244k|        *dst = av_buffer_ref(*dst);
  353|   244k|        MP_HANDLE_OOM(*dst);
  ------------------
  |  |  206|   244k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   244k|        void *oom_p_ = (x);     \
  |  |  208|   244k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 244k]
  |  |  ------------------
  |  |  209|   244k|            abort();            \
  |  |  210|   244k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 244k]
  |  |  ------------------
  ------------------
  354|   244k|    }
  355|  1.18M|}
mp_image.c:mp_image_params_get_forced_csp:
  529|  1.84k|{
  530|  1.84k|    int imgfmt = params->hw_subfmt ? params->hw_subfmt : params->imgfmt;
  ------------------
  |  Branch (530:18): [True: 0, False: 1.84k]
  ------------------
  531|  1.84k|    enum pl_color_system csp = mp_imgfmt_get_forced_csp(imgfmt);
  532|       |
  533|  1.84k|    if (csp == PL_COLOR_SYSTEM_RGB && params->repr.sys == PL_COLOR_SYSTEM_XYZ)
  ------------------
  |  Branch (533:9): [True: 1.28k, False: 556]
  |  Branch (533:39): [True: 0, False: 1.28k]
  ------------------
  534|      0|        csp = PL_COLOR_SYSTEM_XYZ;
  535|       |
  536|  1.84k|    return csp;
  537|  1.84k|}
mp_image.c:infer_levels:
  959|    556|{
  960|    556|    switch (imgfmt2pixfmt(imgfmt)) {
  961|      0|    case AV_PIX_FMT_YUVJ420P:
  ------------------
  |  Branch (961:5): [True: 0, False: 556]
  ------------------
  962|      0|    case AV_PIX_FMT_YUVJ411P:
  ------------------
  |  Branch (962:5): [True: 0, False: 556]
  ------------------
  963|      0|    case AV_PIX_FMT_YUVJ422P:
  ------------------
  |  Branch (963:5): [True: 0, False: 556]
  ------------------
  964|      0|    case AV_PIX_FMT_YUVJ444P:
  ------------------
  |  Branch (964:5): [True: 0, False: 556]
  ------------------
  965|      0|    case AV_PIX_FMT_YUVJ440P:
  ------------------
  |  Branch (965:5): [True: 0, False: 556]
  ------------------
  966|    337|    case AV_PIX_FMT_GRAY8:
  ------------------
  |  Branch (966:5): [True: 337, False: 219]
  ------------------
  967|    337|    case AV_PIX_FMT_YA8:
  ------------------
  |  Branch (967:5): [True: 0, False: 556]
  ------------------
  968|    337|    case AV_PIX_FMT_GRAY9LE:
  ------------------
  |  Branch (968:5): [True: 0, False: 556]
  ------------------
  969|    337|    case AV_PIX_FMT_GRAY9BE:
  ------------------
  |  Branch (969:5): [True: 0, False: 556]
  ------------------
  970|    337|    case AV_PIX_FMT_GRAY10LE:
  ------------------
  |  Branch (970:5): [True: 0, False: 556]
  ------------------
  971|    337|    case AV_PIX_FMT_GRAY10BE:
  ------------------
  |  Branch (971:5): [True: 0, False: 556]
  ------------------
  972|    337|    case AV_PIX_FMT_GRAY12LE:
  ------------------
  |  Branch (972:5): [True: 0, False: 556]
  ------------------
  973|    337|    case AV_PIX_FMT_GRAY12BE:
  ------------------
  |  Branch (973:5): [True: 0, False: 556]
  ------------------
  974|    337|    case AV_PIX_FMT_GRAY14LE:
  ------------------
  |  Branch (974:5): [True: 0, False: 556]
  ------------------
  975|    337|    case AV_PIX_FMT_GRAY14BE:
  ------------------
  |  Branch (975:5): [True: 0, False: 556]
  ------------------
  976|    398|    case AV_PIX_FMT_GRAY16LE:
  ------------------
  |  Branch (976:5): [True: 61, False: 495]
  ------------------
  977|    398|    case AV_PIX_FMT_GRAY16BE:
  ------------------
  |  Branch (977:5): [True: 0, False: 556]
  ------------------
  978|    398|    case AV_PIX_FMT_YA16BE:
  ------------------
  |  Branch (978:5): [True: 0, False: 556]
  ------------------
  979|    398|    case AV_PIX_FMT_YA16LE:
  ------------------
  |  Branch (979:5): [True: 0, False: 556]
  ------------------
  980|    398|        return PL_COLOR_LEVELS_FULL;
  981|    158|    default:
  ------------------
  |  Branch (981:5): [True: 158, False: 398]
  ------------------
  982|    158|        return PL_COLOR_LEVELS_LIMITED;
  983|    556|    }
  984|    556|}

mp_image_pool_new:
   82|  15.5k|{
   83|  15.5k|    struct mp_image_pool *pool = talloc_ptrtype(tparent, pool);
  ------------------
  |  |   34|  15.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  15.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  15.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  15.5k|    talloc_set_destructor(pool, image_pool_destructor);
  ------------------
  |  |   41|  15.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   85|  15.5k|    *pool = (struct mp_image_pool) {0};
   86|  15.5k|    return pool;
   87|  15.5k|}
mp_image_pool_clear:
   90|  18.8k|{
   91|  18.8k|    for (int n = 0; n < pool->num_images; n++) {
  ------------------
  |  Branch (91:21): [True: 0, False: 18.8k]
  ------------------
   92|      0|        struct mp_image *img = pool->images[n];
   93|      0|        struct image_flags *it = img->priv;
   94|      0|        bool referenced;
   95|      0|        pool_lock();
  ------------------
  |  |   45|      0|#define pool_lock() mp_mutex_lock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
   96|      0|        mp_assert(it->pool_alive);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (96:9): [True: 0, False: 0]
  ------------------
   97|      0|        it->pool_alive = false;
   98|      0|        referenced = it->referenced;
   99|      0|        pool_unlock();
  ------------------
  |  |   46|      0|#define pool_unlock() mp_mutex_unlock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  100|      0|        if (!referenced)
  ------------------
  |  Branch (100:13): [True: 0, False: 0]
  ------------------
  101|      0|            talloc_free(img);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  102|      0|    }
  103|  18.8k|    pool->num_images = 0;
  104|  18.8k|}
mp_image_pool_get_no_alloc:
  126|  3.21k|{
  127|  3.21k|    struct mp_image *new = NULL;
  128|  3.21k|    pool_lock();
  ------------------
  |  |   45|  3.21k|#define pool_lock() mp_mutex_lock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  134|  3.21k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  129|  3.21k|    for (int n = 0; n < pool->num_images; n++) {
  ------------------
  |  Branch (129:21): [True: 0, False: 3.21k]
  ------------------
  130|      0|        struct mp_image *img = pool->images[n];
  131|      0|        struct image_flags *img_it = img->priv;
  132|      0|        mp_assert(img_it->pool_alive);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (132:9): [True: 0, False: 0]
  ------------------
  133|      0|        if (!img_it->referenced) {
  ------------------
  |  Branch (133:13): [True: 0, False: 0]
  ------------------
  134|      0|            if (img->imgfmt == fmt && img->w == w && img->h == h) {
  ------------------
  |  Branch (134:17): [True: 0, False: 0]
  |  Branch (134:39): [True: 0, False: 0]
  |  Branch (134:54): [True: 0, False: 0]
  ------------------
  135|      0|                if (pool->use_lru) {
  ------------------
  |  Branch (135:21): [True: 0, False: 0]
  ------------------
  136|      0|                    struct image_flags *new_it = new ? new->priv : NULL;
  ------------------
  |  Branch (136:50): [True: 0, False: 0]
  ------------------
  137|      0|                    if (!new_it || new_it->order > img_it->order)
  ------------------
  |  Branch (137:25): [True: 0, False: 0]
  |  Branch (137:36): [True: 0, False: 0]
  ------------------
  138|      0|                        new = img;
  139|      0|                } else {
  140|      0|                    new = img;
  141|      0|                    break;
  142|      0|                }
  143|      0|            }
  144|      0|        }
  145|      0|    }
  146|  3.21k|    pool_unlock();
  ------------------
  |  |   46|  3.21k|#define pool_unlock() mp_mutex_unlock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  136|  3.21k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  147|  3.21k|    if (!new)
  ------------------
  |  Branch (147:9): [True: 3.21k, False: 0]
  ------------------
  148|  3.21k|        return NULL;
  149|       |
  150|       |    // Reference the new image. Since mp_image_pool is not declared thread-safe,
  151|       |    // and unreffing images from other threads does not allocate new images,
  152|       |    // no synchronization is required here.
  153|      0|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|      0|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (153:21): [True: 0, False: 0]
  ------------------
  154|      0|        mp_assert(!!new->bufs[p] == !p); // only 1 AVBufferRef
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (154:9): [True: 0, False: 0]
  ------------------
  155|       |
  156|      0|    struct mp_image *ref = mp_image_new_dummy_ref(new);
  157|       |
  158|       |    // This assumes the buffer is at this point exclusively owned by us: we
  159|       |    // can't track whether the buffer is unique otherwise.
  160|       |    // (av_buffer_is_writable() checks the refcount of the new buffer only.)
  161|      0|    int flags = av_buffer_is_writable(new->bufs[0]) ? 0 : AV_BUFFER_FLAG_READONLY;
  ------------------
  |  Branch (161:17): [True: 0, False: 0]
  ------------------
  162|      0|    ref->bufs[0] = av_buffer_create(new->bufs[0]->data, new->bufs[0]->size,
  163|      0|                                    unref_image, new, flags);
  164|      0|    if (!ref->bufs[0]) {
  ------------------
  |  Branch (164:9): [True: 0, False: 0]
  ------------------
  165|      0|        talloc_free(ref);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  166|      0|        return NULL;
  167|      0|    }
  168|       |
  169|      0|    struct image_flags *it = new->priv;
  170|      0|    mp_assert(!it->referenced && it->pool_alive);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (170:5): [True: 0, False: 0]
  |  Branch (170:5): [True: 0, False: 0]
  ------------------
  171|      0|    it->referenced = true;
  172|      0|    it->order = ++pool->lru_counter;
  173|      0|    return ref;
  174|      0|}
mp_image_pool.c:image_pool_destructor:
   75|  15.5k|{
   76|  15.5k|    struct mp_image_pool *pool = ptr;
   77|  15.5k|    mp_image_pool_clear(pool);
   78|  15.5k|}

context.c:get_desc:
  147|  57.9k|{
  148|  57.9k|    if (index >= MP_ARRAY_SIZE(contexts))
  ------------------
  |  |   49|  57.9k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (148:9): [True: 28.9k, False: 28.9k]
  ------------------
  149|  28.9k|        return false;
  150|  28.9k|    const struct ra_ctx_fns *ctx = contexts[index];
  151|  28.9k|    *dst = (struct m_obj_desc) {
  152|  28.9k|        .name = ctx->name,
  153|  28.9k|        .description = ctx->description,
  154|  28.9k|    };
  155|       |    return true;
  156|  57.9k|}
context.c:get_type_desc:
  173|  57.9k|{
  174|  57.9k|    int api_index = 0;
  175|       |
  176|  86.8k|    for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
  ------------------
  |  |   49|  86.8k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (176:21): [True: 57.9k, False: 28.9k]
  ------------------
  177|  57.9k|        if (i && strcmp(contexts[i - 1]->type, contexts[i]->type))
  ------------------
  |  Branch (177:13): [True: 0, False: 57.9k]
  |  Branch (177:18): [True: 0, False: 0]
  ------------------
  178|      0|            api_index++;
  179|       |
  180|  57.9k|        if (api_index == index) {
  ------------------
  |  Branch (180:13): [True: 28.9k, False: 28.9k]
  ------------------
  181|  28.9k|            *dst = (struct m_obj_desc) {
  182|  28.9k|                .name = contexts[i]->type,
  183|  28.9k|                .description = "",
  184|  28.9k|            };
  185|  28.9k|            return true;
  186|  28.9k|        }
  187|  57.9k|    }
  188|       |
  189|  28.9k|    return false;
  190|  57.9k|}

init_best_video_out:
  370|  9.61k|{
  371|  9.61k|    struct mp_vo_opts *opts = mp_get_config_group(NULL, global, &vo_sub_opts);
  372|  9.61k|    struct m_obj_settings *vo_list = opts->video_driver_list;
  373|  9.61k|    struct vo *vo = NULL;
  374|       |    // first try the preferred drivers, with their optional subdevice param:
  375|  9.61k|    if (vo_list && vo_list[0].name) {
  ------------------
  |  Branch (375:9): [True: 9.61k, False: 0]
  |  Branch (375:20): [True: 9.61k, False: 0]
  ------------------
  376|  9.61k|        for (int n = 0; vo_list[n].name; n++) {
  ------------------
  |  Branch (376:25): [True: 9.61k, False: 0]
  ------------------
  377|       |            // Something like "-vo name," allows fallback to autoprobing.
  378|  9.61k|            if (strlen(vo_list[n].name) == 0)
  ------------------
  |  Branch (378:17): [True: 0, False: 9.61k]
  ------------------
  379|      0|                goto autoprobe;
  380|  9.61k|            bool p = !!vo_list[n + 1].name;
  381|  9.61k|            vo = vo_create(p, global, ex, vo_list[n].name);
  382|  9.61k|            if (vo)
  ------------------
  |  Branch (382:17): [True: 9.61k, False: 0]
  ------------------
  383|  9.61k|                goto done;
  384|  9.61k|        }
  385|      0|        goto done;
  386|  9.61k|    }
  387|      0|autoprobe:
  388|       |    // now try the rest...
  389|      0|    for (int i = 0; i < MP_ARRAY_SIZE(video_out_drivers); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (389:21): [True: 0, False: 0]
  ------------------
  390|      0|        const struct vo_driver *driver = video_out_drivers[i];
  391|      0|        if (driver == &video_out_null)
  ------------------
  |  Branch (391:13): [True: 0, False: 0]
  ------------------
  392|      0|            break;
  393|      0|        vo = vo_create(true, global, ex, (char *)driver->name);
  394|      0|        if (vo)
  ------------------
  |  Branch (394:13): [True: 0, False: 0]
  ------------------
  395|      0|            goto done;
  396|      0|    }
  397|  9.61k|done:
  398|  9.61k|    talloc_free(opts);
  ------------------
  |  |   47|  9.61k|#define talloc_free                     ta_free
  ------------------
  399|  9.61k|    return vo;
  400|      0|}
vo_destroy:
  410|  9.61k|{
  411|  9.61k|    struct vo_internal *in = vo->in;
  412|  9.61k|    mp_dispatch_run(in->dispatch, terminate_vo, vo);
  413|       |    mp_thread_join(vo->in->thread);
  ------------------
  |  |  215|  9.61k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  414|  9.61k|    dealloc_vo(vo);
  415|  9.61k|}
vo_reconfig2:
  724|  1.84k|{
  725|  1.84k|    int ret;
  726|  1.84k|    void *p[] = {vo, img, &ret};
  727|  1.84k|    mp_dispatch_run(vo->in->dispatch, run_reconfig, p);
  728|  1.84k|    return ret;
  729|  1.84k|}
vo_control:
  744|  25.0k|{
  745|  25.0k|    int ret;
  746|  25.0k|    void *p[] = {vo, (void *)(intptr_t)request, data, &ret};
  747|  25.0k|    mp_dispatch_run(vo->in->dispatch, run_control, p);
  748|  25.0k|    return ret;
  749|  25.0k|}
vo_control_async:
  754|  22.2k|{
  755|  22.2k|    void *p[4] = {vo, (void *)(intptr_t)request, NULL, NULL};
  756|  22.2k|    void **d = talloc_memdup(NULL, p, sizeof(p));
  ------------------
  |  |   49|  22.2k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  22.2k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  22.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  22.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  22.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|       |
  758|  22.2k|    switch (request) {
  759|    854|    case VOCTRL_UPDATE_PLAYBACK_STATE:
  ------------------
  |  Branch (759:5): [True: 854, False: 21.3k]
  ------------------
  760|    854|        d[2] = talloc_dup(d, (struct voctrl_playback_state *)data);
  ------------------
  |  |   48|    854|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|    854|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    854|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  761|    854|        break;
  762|  3.02k|    case VOCTRL_KILL_SCREENSAVER:
  ------------------
  |  Branch (762:5): [True: 3.02k, False: 19.2k]
  ------------------
  763|  21.3k|    case VOCTRL_RESTORE_SCREENSAVER:
  ------------------
  |  Branch (763:5): [True: 18.3k, False: 3.87k]
  ------------------
  764|  21.3k|        break;
  765|      0|    default:
  ------------------
  |  Branch (765:5): [True: 0, False: 22.2k]
  ------------------
  766|      0|        abort(); // requires explicit support
  767|  22.2k|    }
  768|       |
  769|  22.2k|    mp_dispatch_enqueue_autofree(vo->in->dispatch, run_control, d);
  770|  22.2k|}
vo_wait_default:
  820|   132k|{
  821|   132k|    struct vo_internal *in = vo->in;
  822|       |
  823|   132k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   132k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  824|   132k|    if (!in->need_wakeup)
  ------------------
  |  Branch (824:9): [True: 121k, False: 10.7k]
  ------------------
  825|   121k|        mp_cond_timedwait_until(&in->wakeup, &in->lock, until_time);
  826|   132k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   132k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  827|   132k|}
vo_wakeup:
  857|  77.9k|{
  858|  77.9k|    struct vo_internal *in = vo->in;
  859|       |
  860|  77.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  77.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  861|  77.9k|    wakeup_locked(vo);
  862|  77.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  77.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  863|  77.9k|}
vo_still_displaying:
  912|  1.84k|{
  913|  1.84k|    mp_mutex_lock(&vo->in->lock);
  ------------------
  |  |  134|  1.84k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  914|  1.84k|    bool res = still_displaying(vo);
  915|  1.84k|    mp_mutex_unlock(&vo->in->lock);
  ------------------
  |  |  136|  1.84k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  916|  1.84k|    return res;
  917|  1.84k|}
vo_is_ready_for_frame:
  941|  51.7k|{
  942|  51.7k|    struct vo_internal *in = vo->in;
  943|  51.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  51.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  944|  51.7k|    bool r = vo->config_ok && !in->frame_queued &&
  ------------------
  |  Branch (944:14): [True: 45.0k, False: 6.67k]
  |  Branch (944:31): [True: 44.7k, False: 389]
  ------------------
  945|  44.7k|             (!in->current_frame || in->current_frame->num_vsyncs < 1);
  ------------------
  |  Branch (945:15): [True: 1.84k, False: 42.8k]
  |  Branch (945:37): [True: 42.8k, False: 0]
  ------------------
  946|  51.7k|    if (r && next_pts >= 0) {
  ------------------
  |  Branch (946:9): [True: 44.7k, False: 7.05k]
  |  Branch (946:14): [True: 43.7k, False: 943]
  ------------------
  947|       |        // Don't show the frame too early - it would basically freeze the
  948|       |        // display by disallowing OSD redrawing or VO interaction.
  949|       |        // Actually render the frame at earliest the given offset before target
  950|       |        // time.
  951|  43.7k|        next_pts -= in->timing_offset;
  952|  43.7k|        next_pts -= in->flip_queue_offset;
  953|       |        // The lead presents the frame that much earlier, see check_timed_frame_late().
  954|  43.7k|        next_pts -= (int64_t)(in->vsync_interval * in->late.lead / 2);
  955|  43.7k|        int64_t now = mp_time_ns();
  956|  43.7k|        if (next_pts > now)
  ------------------
  |  Branch (956:13): [True: 0, False: 43.7k]
  ------------------
  957|      0|            r = false;
  958|  43.7k|        if (!in->wakeup_pts || next_pts < in->wakeup_pts) {
  ------------------
  |  Branch (958:13): [True: 43.6k, False: 94]
  |  Branch (958:32): [True: 94, False: 0]
  ------------------
  959|  43.7k|            in->wakeup_pts = next_pts;
  960|       |            // If we have to wait, update the vo thread's timer.
  961|  43.7k|            if (!r)
  ------------------
  |  Branch (961:17): [True: 0, False: 43.7k]
  ------------------
  962|      0|                wakeup_locked(vo);
  963|  43.7k|        }
  964|  43.7k|    }
  965|  51.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  51.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  966|  51.7k|    return r;
  967|  51.7k|}
vo_queue_frame:
  983|  43.7k|{
  984|  43.7k|    struct vo_internal *in = vo->in;
  985|  43.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  986|  43.7k|    mp_assert(vo->config_ok && !in->frame_queued &&
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (986:5): [True: 43.7k, False: 0]
  |  Branch (986:5): [True: 43.7k, False: 0]
  |  Branch (986:5): [True: 1.84k, False: 41.9k]
  |  Branch (986:5): [True: 41.9k, False: 0]
  ------------------
  987|  43.7k|           (!in->current_frame || in->current_frame->num_vsyncs < 1));
  988|  43.7k|    in->hasframe = true;
  989|  43.7k|    frame->frame_id = ++(in->current_frame_id);
  990|  43.7k|    in->frame_queued = frame;
  991|  43.7k|    in->wakeup_pts = frame->display_synced
  ------------------
  |  Branch (991:22): [True: 0, False: 43.7k]
  ------------------
  992|  43.7k|                   ? 0 : frame->pts + MPMAX(frame->duration, 0);
  ------------------
  |  |   44|  87.5k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 43.7k]
  |  |  ------------------
  ------------------
  993|  43.7k|    wakeup_locked(vo);
  994|  43.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  995|  43.7k|}
vo_wait_frame:
 1000|  1.00k|{
 1001|  1.00k|    struct vo_internal *in = vo->in;
 1002|  1.00k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.00k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1003|  2.00k|    while (in->frame_queued || in->rendering)
  ------------------
  |  Branch (1003:12): [True: 1.00k, False: 1.00k]
  |  Branch (1003:32): [True: 0, False: 1.00k]
  ------------------
 1004|  1.00k|        mp_cond_wait(&in->wakeup, &in->lock);
 1005|  1.00k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.00k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1006|  1.00k|}
vo_set_paused:
 1578|  7.67k|{
 1579|  7.67k|    struct vo_internal *in = vo->in;
 1580|  7.67k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  7.67k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1581|  7.67k|    if (in->paused != paused) {
  ------------------
  |  Branch (1581:9): [True: 0, False: 7.67k]
  ------------------
 1582|      0|        in->paused = paused;
 1583|      0|        if (in->paused && in->dropped_frame) {
  ------------------
  |  Branch (1583:13): [True: 0, False: 0]
  |  Branch (1583:27): [True: 0, False: 0]
  ------------------
 1584|      0|            in->request_redraw = true;
 1585|      0|            wakeup_core(vo);
 1586|      0|        }
 1587|      0|        reset_vsync_timings(vo);
 1588|      0|        restart_lateness(in);
 1589|      0|        in->late.drop = false;
 1590|      0|        wakeup_locked(vo);
 1591|      0|    }
 1592|  7.67k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  7.67k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1593|  7.67k|}
vo_redraw:
 1612|      2|{
 1613|      2|    struct vo_internal *in = vo->in;
 1614|      2|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|      2|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1615|      2|    if (!in->request_redraw) {
  ------------------
  |  Branch (1615:9): [True: 2, False: 0]
  ------------------
 1616|      2|        in->request_redraw = true;
 1617|      2|        in->want_redraw = false;
 1618|      2|        wakeup_locked(vo);
 1619|      2|    }
 1620|      2|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      2|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1621|      2|}
vo_seek_reset:
 1633|  17.3k|{
 1634|  17.3k|    struct vo_internal *in = vo->in;
 1635|  17.3k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  17.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1636|  17.3k|    forget_frames(vo);
 1637|  17.3k|    reset_vsync_timings(vo);
 1638|  17.3k|    in->send_reset = true;
 1639|  17.3k|    wakeup_locked(vo);
 1640|  17.3k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  17.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1641|  17.3k|}
vo_has_frame:
 1645|  9.72k|{
 1646|  9.72k|    return vo->in->hasframe;
 1647|  9.72k|}
vo_query_formats:
 1661|  19.2k|{
 1662|  19.2k|    void *p[] = {vo, list};
 1663|  19.2k|    mp_dispatch_run(vo->in->dispatch, run_query_format, p);
 1664|  19.2k|}
vo_get_num_req_frames:
 1704|  43.7k|{
 1705|  43.7k|    struct vo_internal *in = vo->in;
 1706|  43.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1707|  43.7k|    int res = in->req_frames;
 1708|  43.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1709|  43.7k|    return res;
 1710|  43.7k|}
vo_event:
 1798|  9.61k|{
 1799|  9.61k|    struct vo_internal *in = vo->in;
 1800|  9.61k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  9.61k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1801|  9.61k|    if ((in->queued_events & event & VO_EVENTS_USER) != (event & VO_EVENTS_USER))
  ------------------
  |  Branch (1801:9): [True: 9.61k, False: 0]
  ------------------
 1802|  9.61k|        wakeup_core(vo);
 1803|  9.61k|    if (event)
  ------------------
  |  Branch (1803:9): [True: 9.61k, False: 0]
  ------------------
 1804|  9.61k|        wakeup_locked(vo);
 1805|  9.61k|    in->queued_events |= event;
 1806|  9.61k|    in->internal_events |= event;
 1807|  9.61k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  9.61k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1808|  9.61k|}
vo_query_and_reset_events:
 1813|  86.5k|{
 1814|  86.5k|    struct vo_internal *in = vo->in;
 1815|  86.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  86.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1816|  86.5k|    int r = in->queued_events & events;
 1817|  86.5k|    in->queued_events &= ~(unsigned)r;
 1818|  86.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  86.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1819|  86.5k|    return r;
 1820|  86.5k|}
vo_get_image:
 1844|  3.21k|{
 1845|  3.21k|    struct mp_image *img = NULL;
 1846|  3.21k|    if (vo->driver->get_image_ts)
  ------------------
  |  Branch (1846:9): [True: 0, False: 3.21k]
  ------------------
 1847|      0|        img = vo->driver->get_image_ts(vo, imgfmt, w, h, stride_align, flags);
 1848|  3.21k|    if (!img && vo->in->dr_helper)
  ------------------
  |  Branch (1848:9): [True: 3.21k, False: 0]
  |  Branch (1848:17): [True: 0, False: 3.21k]
  ------------------
 1849|      0|        img = dr_helper_get_image(vo->in->dr_helper, imgfmt, w, h, stride_align, flags);
 1850|  3.21k|    return img;
 1851|  3.21k|}
vo_frame_ref:
 1864|  87.5k|{
 1865|  87.5k|    if (!frame)
  ------------------
  |  Branch (1865:9): [True: 0, False: 87.5k]
  ------------------
 1866|      0|        return NULL;
 1867|       |
 1868|  87.5k|    struct vo_frame *new = talloc_ptrtype(NULL, new);
  ------------------
  |  |   34|  87.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  87.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  87.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1869|  87.5k|    talloc_set_destructor(new, destroy_frame);
  ------------------
  |  |   41|  87.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1870|  87.5k|    *new = *frame;
 1871|   175k|    for (int n = 0; n < frame->num_frames; n++)
  ------------------
  |  Branch (1871:21): [True: 87.5k, False: 87.5k]
  ------------------
 1872|  87.5k|        new->frames[n] = mp_image_new_ref(frame->frames[n]);
 1873|  87.5k|    new->current = new->num_frames ? new->frames[0] : NULL;
  ------------------
  |  Branch (1873:20): [True: 87.5k, False: 0]
  ------------------
 1874|  87.5k|    return new;
 1875|  87.5k|}
vo.c:get_desc:
  224|   646k|{
  225|   646k|    if (index >= MP_ARRAY_SIZE(video_out_drivers))
  ------------------
  |  |   49|   646k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (225:9): [True: 28.9k, False: 617k]
  ------------------
  226|  28.9k|        return false;
  227|   617k|    const struct vo_driver *vo = video_out_drivers[index];
  228|   617k|    *dst = (struct m_obj_desc) {
  229|   617k|        .name = vo->name,
  230|   617k|        .description = vo->description,
  231|   617k|        .priv_size = vo->priv_size,
  232|   617k|        .priv_defaults = vo->priv_defaults,
  233|   617k|        .options = vo->options,
  234|   617k|        .options_prefix = vo->options_prefix,
  235|   617k|        .global_opts = vo->global_opts,
  236|   617k|        .hidden = vo->encode,
  237|   617k|        .p = vo,
  238|   617k|    };
  239|       |    return true;
  240|   646k|}
vo.c:vo_create:
  305|  9.61k|{
  306|  9.61k|    mp_assert(ex->wakeup_cb);
  ------------------
  |  |   41|  9.61k|#define mp_assert assert
  ------------------
  |  Branch (306:5): [True: 9.61k, False: 0]
  ------------------
  307|       |
  308|  9.61k|    struct mp_log *log = mp_log_new(NULL, global->log, "vo");
  309|  9.61k|    struct m_obj_desc desc;
  310|  9.61k|    if (!m_obj_list_find(&desc, &vo_obj_list, bstr0(name))) {
  ------------------
  |  Branch (310:9): [True: 0, False: 9.61k]
  ------------------
  311|      0|        mp_msg(log, MSGL_ERR, "Video output %s not found!\n", name);
  312|      0|        talloc_free(log);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  313|      0|        return NULL;
  314|  9.61k|    };
  315|  9.61k|    struct vo *vo = talloc_ptrtype(NULL, vo);
  ------------------
  |  |   34|  9.61k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  9.61k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  9.61k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|  9.61k|    *vo = (struct vo) {
  317|  9.61k|        .log = mp_log_new(vo, log, name),
  318|  9.61k|        .driver = desc.p,
  319|  9.61k|        .global = global,
  320|  9.61k|        .encode_lavc_ctx = ex->encode_lavc_ctx,
  321|  9.61k|        .input_ctx = ex->input_ctx,
  322|  9.61k|        .osd = ex->osd,
  323|  9.61k|        .monitor_par = 1,
  324|  9.61k|        .extra = *ex,
  325|  9.61k|        .probing = probing,
  326|  9.61k|        .in = talloc(vo, struct vo_internal),
  ------------------
  |  |   26|  9.61k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  9.61k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  9.61k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|  9.61k|    };
  328|  9.61k|    mp_mutex_init(&vo->params_mutex);
  329|  9.61k|    talloc_steal(vo, log);
  ------------------
  |  |   38|  9.61k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  9.61k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  330|  9.61k|    *vo->in = (struct vo_internal) {
  331|  9.61k|        .dispatch = mp_dispatch_create(vo),
  332|  9.61k|        .req_frames = 1,
  333|  9.61k|        .frame_refs = 2, // current_frame + frame_queued
  334|  9.61k|        .estimated_vsync_jitter = -1,
  335|  9.61k|        .presentation_delay = INT64_MIN,
  336|  9.61k|        .round_edge = 0.5,
  337|  9.61k|        .stats = stats_ctx_create(vo, global, "vo"),
  338|  9.61k|    };
  339|  9.61k|    mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo);
  340|  9.61k|    mp_mutex_init(&vo->in->lock);
  341|  9.61k|    mp_cond_init(&vo->in->wakeup);
  342|       |
  343|  9.61k|    vo->opts_cache = m_config_cache_alloc(NULL, global, &vo_sub_opts);
  344|  9.61k|    vo->opts = vo->opts_cache->opts;
  345|       |
  346|  9.61k|    m_config_cache_set_dispatch_change_cb(vo->opts_cache, vo->in->dispatch,
  347|  9.61k|                                          update_opts, vo);
  348|       |
  349|  9.61k|    mp_input_set_mouse_transform(vo->input_ctx, NULL, NULL);
  350|  9.61k|    if (vo->driver->encode != !!vo->encode_lavc_ctx)
  ------------------
  |  Branch (350:9): [True: 0, False: 9.61k]
  ------------------
  351|      0|        goto error;
  352|  9.61k|    vo->priv = m_config_group_from_desc(vo, vo->log, global, &desc, name);
  353|  9.61k|    if (!vo->priv)
  ------------------
  |  Branch (353:9): [True: 0, False: 9.61k]
  ------------------
  354|      0|        goto error;
  355|       |
  356|  9.61k|    if (mp_thread_create(&vo->in->thread, vo_thread, vo))
  ------------------
  |  |  214|  9.61k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 9.61k]
  |  |  ------------------
  ------------------
  357|      0|        goto error;
  358|  9.61k|    if (mp_rendezvous(vo, 0) < 0) { // init barrier
  ------------------
  |  Branch (358:9): [True: 0, False: 9.61k]
  ------------------
  359|      0|        mp_thread_join(vo->in->thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  360|      0|        goto error;
  361|      0|    }
  362|  9.61k|    return vo;
  363|       |
  364|      0|error:
  365|      0|    dealloc_vo(vo);
  366|       |    return NULL;
  367|  9.61k|}
vo.c:dispatch_wakeup_cb:
  259|  77.9k|{
  260|  77.9k|    struct vo *vo = ptr;
  261|  77.9k|    vo_wakeup(vo);
  262|  77.9k|}
vo.c:update_opts:
  275|  49.1k|{
  276|  49.1k|    struct vo *vo = p;
  277|       |
  278|  49.1k|    if (m_config_cache_update(vo->opts_cache)) {
  ------------------
  |  Branch (278:9): [True: 0, False: 49.1k]
  ------------------
  279|      0|        read_opts(vo);
  280|      0|        if (vo->driver->control) {
  ------------------
  |  Branch (280:13): [True: 0, False: 0]
  ------------------
  281|      0|            vo->driver->control(vo, VOCTRL_VO_OPTS_CHANGED, NULL);
  282|       |            // "Legacy" update of video position related options.
  283|       |            // Unlike VOCTRL_VO_OPTS_CHANGED, often not propagated to backends.
  284|       |            vo->driver->control(vo, VOCTRL_SET_PANSCAN, NULL);
  285|      0|        }
  286|      0|    }
  287|  49.1k|}
vo.c:read_opts:
  266|  9.61k|{
  267|  9.61k|    struct vo_internal *in = vo->in;
  268|       |
  269|  9.61k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  9.61k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  270|  9.61k|    in->timing_offset = (uint64_t)(MP_TIME_S_TO_NS(vo->opts->timing_offset));
  ------------------
  |  |   71|  9.61k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  271|  9.61k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  9.61k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  272|  9.61k|}
vo.c:vo_thread:
 1469|  9.61k|{
 1470|  9.61k|    struct vo *vo = ptr;
 1471|  9.61k|    struct vo_internal *in = vo->in;
 1472|  9.61k|    bool vo_paused = false;
 1473|       |
 1474|  9.61k|    mp_thread_set_name("vo");
 1475|  9.61k|    mp_thread_set_min_timer_slack();
 1476|       |
 1477|  9.61k|    if (vo->driver->get_image) {
  ------------------
  |  Branch (1477:9): [True: 0, False: 9.61k]
  ------------------
 1478|      0|        in->dr_helper = dr_helper_create(in->dispatch, get_image_vo, vo);
 1479|      0|        dr_helper_acquire_thread(in->dr_helper);
 1480|      0|    }
 1481|       |
 1482|  9.61k|    int r = vo->driver->preinit(vo) ? -1 : 0;
  ------------------
  |  Branch (1482:13): [True: 0, False: 9.61k]
  ------------------
 1483|  9.61k|    mp_rendezvous(vo, r); // init barrier
 1484|  9.61k|    if (r < 0)
  ------------------
  |  Branch (1484:9): [True: 0, False: 9.61k]
  ------------------
 1485|      0|        goto done;
 1486|       |
 1487|  9.61k|    read_opts(vo);
 1488|  9.61k|    update_display_fps(vo);
 1489|  9.61k|    vo_event(vo, VO_EVENT_WIN_STATE);
 1490|       |
 1491|   141k|    while (1) {
  ------------------
  |  Branch (1491:12): [True: 141k, Folded]
  ------------------
 1492|   141k|        mp_dispatch_queue_process(vo->in->dispatch, 0);
 1493|   141k|        if (in->terminate)
  ------------------
  |  Branch (1493:13): [True: 9.61k, False: 132k]
  ------------------
 1494|  9.61k|            break;
 1495|   132k|        stats_event(in->stats, "iterations");
 1496|   132k|        vo->driver->control(vo, VOCTRL_CHECK_EVENTS, NULL);
 1497|   132k|        bool working = render_frame(vo);
 1498|   132k|        int64_t now = mp_time_ns();
 1499|   132k|        int64_t wait_until = now + MP_TIME_S_TO_NS(working ? 0 : 1000);
  ------------------
  |  |   71|   264k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 0, False: 132k]
  |  |  ------------------
  ------------------
 1500|   132k|        bool wakeup_on_done = false;
 1501|   132k|        int64_t wakeup_core_after = 0;
 1502|       |
 1503|   132k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   132k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1504|   132k|        if (in->wakeup_pts) {
  ------------------
  |  Branch (1504:13): [True: 43.7k, False: 88.3k]
  ------------------
 1505|  43.7k|            if (in->wakeup_pts > now) {
  ------------------
  |  Branch (1505:17): [True: 0, False: 43.7k]
  ------------------
 1506|      0|                wait_until = MPMIN(wait_until, in->wakeup_pts);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1507|  43.7k|            } else {
 1508|  43.7k|                in->wakeup_pts = 0;
 1509|  43.7k|                wakeup_core(vo);
 1510|  43.7k|            }
 1511|  43.7k|        }
 1512|   132k|        if (vo->want_redraw) {
  ------------------
  |  Branch (1512:13): [True: 0, False: 132k]
  ------------------
 1513|      0|            in->want_redraw = true;
 1514|      0|            wakeup_core(vo);
 1515|      0|        }
 1516|   132k|        if ((!working && !in->rendering && !in->frame_queued) && in->wakeup_on_done) {
  ------------------
  |  Branch (1516:14): [True: 132k, False: 0]
  |  Branch (1516:26): [True: 132k, False: 0]
  |  Branch (1516:44): [True: 132k, False: 65]
  |  Branch (1516:66): [True: 0, False: 132k]
  ------------------
 1517|       |            // At this point we know VO is going to sleep
 1518|      0|            int64_t frame_end = get_current_frame_end(vo);
 1519|      0|            if (frame_end >= 0)
  ------------------
  |  Branch (1519:17): [True: 0, False: 0]
  ------------------
 1520|      0|                wakeup_core_after = frame_end;
 1521|      0|            wakeup_on_done = true;
 1522|      0|            in->wakeup_on_done = false;
 1523|      0|        }
 1524|   132k|        vo->want_redraw = false;
 1525|   132k|        bool redraw = in->request_redraw;
 1526|   132k|        bool send_reset = in->send_reset;
 1527|   132k|        in->send_reset = false;
 1528|   132k|        bool send_pause = in->paused != vo_paused;
 1529|   132k|        vo_paused = in->paused;
 1530|   132k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   132k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1531|       |
 1532|   132k|        if (send_reset)
  ------------------
  |  Branch (1532:13): [True: 16.9k, False: 115k]
  ------------------
 1533|  16.9k|            vo->driver->control(vo, VOCTRL_RESET, NULL);
 1534|   132k|        if (send_pause)
  ------------------
  |  Branch (1534:13): [True: 0, False: 132k]
  ------------------
 1535|      0|            vo->driver->control(vo, vo_paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL);
  ------------------
  |  Branch (1535:37): [True: 0, False: 0]
  ------------------
 1536|   132k|        if (wait_until > now && redraw) {
  ------------------
  |  Branch (1536:13): [True: 132k, False: 0]
  |  Branch (1536:33): [True: 0, False: 132k]
  ------------------
 1537|       |            // Allow manual redraws at most at display fps.
 1538|      0|            int64_t max_interval = in->vsync_interval > 1 ? in->vsync_interval : 0;
  ------------------
  |  Branch (1538:36): [True: 0, False: 0]
  ------------------
 1539|       |            // Some windowing platforms break if we submit frames too fast.
 1540|      0|            if (vo->previous_redraw_time + max_interval <= now) {
  ------------------
  |  Branch (1540:17): [True: 0, False: 0]
  ------------------
 1541|      0|                vo->driver->control(vo, VOCTRL_REDRAW, NULL);
 1542|      0|                do_redraw(vo); // now is a good time
 1543|      0|                vo->previous_redraw_time = now;
 1544|      0|            } else {
 1545|      0|                wait_vo(vo, now + max_interval);
 1546|      0|            }
 1547|      0|            continue;
 1548|      0|        }
 1549|   132k|        if (vo->want_redraw) // might have been set by VOCTRLs
  ------------------
  |  Branch (1549:13): [True: 0, False: 132k]
  ------------------
 1550|      0|            wait_until = 0;
 1551|       |
 1552|   132k|        if (wait_until <= now)
  ------------------
  |  Branch (1552:13): [True: 0, False: 132k]
  ------------------
 1553|      0|            continue;
 1554|       |
 1555|   132k|        if (wakeup_on_done) {
  ------------------
  |  Branch (1555:13): [True: 0, False: 132k]
  ------------------
 1556|       |            // At this point wait_until should be longer than frame duration
 1557|      0|            if (wakeup_core_after >= 0 && wait_until >= wakeup_core_after) {
  ------------------
  |  Branch (1557:17): [True: 0, False: 0]
  |  Branch (1557:43): [True: 0, False: 0]
  ------------------
 1558|      0|                wait_vo(vo, wakeup_core_after);
 1559|      0|                mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1560|      0|                in->need_wakeup = true;
 1561|      0|                mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1562|      0|            }
 1563|      0|            wakeup_core(vo);
 1564|      0|        }
 1565|       |
 1566|   132k|        wait_vo(vo, wait_until);
 1567|   132k|    }
 1568|  9.61k|    forget_frames(vo); // implicitly synchronized
 1569|  9.61k|    talloc_free(in->current_frame);
  ------------------
  |  |   47|  9.61k|#define talloc_free                     ta_free
  ------------------
 1570|  9.61k|    in->current_frame = NULL;
 1571|  9.61k|    vo->driver->uninit(vo);
 1572|  9.61k|done:
 1573|  9.61k|    TA_FREEP(&in->dr_helper);
  ------------------
  |  |   81|  9.61k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.61k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.61k]
  |  |  ------------------
  ------------------
 1574|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  9.61k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1575|  9.61k|}
vo.c:update_display_fps:
  609|   143k|{
  610|   143k|    struct vo_internal *in = vo->in;
  611|   143k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   143k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  612|   143k|    if (in->internal_events & VO_EVENT_WIN_STATE) {
  ------------------
  |  Branch (612:9): [True: 9.61k, False: 133k]
  ------------------
  613|  9.61k|        in->internal_events &= ~(unsigned)VO_EVENT_WIN_STATE;
  614|       |
  615|  9.61k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  9.61k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  616|       |
  617|  9.61k|        double fps = 0;
  618|  9.61k|        vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &fps);
  619|       |
  620|  9.61k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  9.61k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  621|       |
  622|  9.61k|        in->reported_display_fps = fps;
  623|  9.61k|    }
  624|       |
  625|   143k|    double display_fps = vo->opts->display_fps_override;
  626|   143k|    if (display_fps <= 0)
  ------------------
  |  Branch (626:9): [True: 143k, False: 0]
  ------------------
  627|   143k|        display_fps = in->reported_display_fps;
  628|       |    // Tiny rates overflow the int64_t vsync math.
  629|   143k|    if (!(display_fps >= 1e-6))
  ------------------
  |  Branch (629:9): [True: 143k, False: 0]
  ------------------
  630|   143k|        display_fps = 0;
  631|       |
  632|   143k|    if (in->display_fps != display_fps) {
  ------------------
  |  Branch (632:9): [True: 0, False: 143k]
  ------------------
  633|      0|        in->nominal_vsync_interval =  display_fps > 0 ? 1e9 / display_fps : 0;
  ------------------
  |  Branch (633:39): [True: 0, False: 0]
  ------------------
  634|      0|        in->vsync_interval = MPMAX(in->nominal_vsync_interval, 1);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  635|      0|        in->vsync_grid = 0;
  636|      0|        in->shown_at_once = 0;
  637|      0|        in->display_fps = display_fps;
  638|       |
  639|      0|        MP_VERBOSE(vo, "Assuming %f FPS for display sync.\n", display_fps);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  640|       |
  641|       |        // make sure to update the player
  642|      0|        in->queued_events |= VO_EVENT_WIN_STATE;
  643|      0|        wakeup_core(vo);
  644|      0|    }
  645|       |
  646|   143k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   143k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  647|   143k|}
vo.c:render_frame:
 1156|   132k|{
 1157|   132k|    struct vo_internal *in = vo->in;
 1158|   132k|    struct vo_frame *frame = NULL;
 1159|   132k|    bool more_frames = false;
 1160|       |
 1161|   132k|    update_display_fps(vo);
 1162|       |
 1163|   132k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   132k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1164|       |
 1165|   132k|    int64_t sync_target = 0;
 1166|   132k|    if (in->frame_queued) {
  ------------------
  |  Branch (1166:9): [True: 43.7k, False: 88.3k]
  ------------------
 1167|  43.7k|        if (in->frame_queued->display_synced &&
  ------------------
  |  Branch (1167:13): [True: 0, False: 43.7k]
  ------------------
 1168|      0|            !(in->current_frame && in->current_frame->display_synced))
  ------------------
  |  Branch (1168:15): [True: 0, False: 0]
  |  Branch (1168:36): [True: 0, False: 0]
  ------------------
 1169|      0|            sync_target = in->frame_queued->pts - in->flip_queue_offset;
 1170|  43.7k|        talloc_free(in->current_frame);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
 1171|  43.7k|        in->current_frame = in->frame_queued;
 1172|  43.7k|        in->frame_queued = NULL;
 1173|  88.3k|    } else if (in->paused || !in->current_frame || !in->hasframe ||
  ------------------
  |  Branch (1173:16): [True: 0, False: 88.3k]
  |  Branch (1173:30): [True: 85.4k, False: 2.92k]
  |  Branch (1173:52): [True: 1.01k, False: 1.91k]
  ------------------
 1174|  1.91k|               (in->current_frame->display_synced && in->current_frame->num_vsyncs < 1) ||
  ------------------
  |  Branch (1174:17): [True: 0, False: 1.91k]
  |  Branch (1174:54): [True: 0, False: 0]
  ------------------
 1175|  1.91k|               !in->current_frame->display_synced)
  ------------------
  |  Branch (1175:16): [True: 1.91k, False: 0]
  ------------------
 1176|  88.3k|    {
 1177|  88.3k|        goto done;
 1178|  88.3k|    }
 1179|       |
 1180|  43.7k|    frame = vo_frame_ref(in->current_frame);
 1181|  43.7k|    mp_assert(frame);
  ------------------
  |  |   41|  43.7k|#define mp_assert assert
  ------------------
  |  Branch (1181:5): [True: 43.7k, False: 0]
  ------------------
 1182|       |
 1183|  43.7k|    if (frame->display_synced) {
  ------------------
  |  Branch (1183:9): [True: 0, False: 43.7k]
  ------------------
 1184|      0|        frame->pts = 0;
 1185|      0|        frame->duration = -1;
 1186|      0|    }
 1187|       |
 1188|  43.7k|    int64_t now = mp_time_ns();
 1189|  43.7k|    int64_t pts = frame->pts;
 1190|  43.7k|    int64_t duration = frame->duration;
 1191|  43.7k|    int64_t end_time = pts + duration;
 1192|       |
 1193|       |    // Time at which we should flip_page on the VO.
 1194|  43.7k|    int64_t target = frame->display_synced ? sync_target : pts - in->flip_queue_offset;
  ------------------
  |  Branch (1194:22): [True: 0, False: 43.7k]
  ------------------
 1195|       |
 1196|       |    // A display with a variable refresh rate refreshes when a frame is
 1197|       |    // presented, below its maximum rate, and shows it after its lag alone. A
 1198|       |    // frame presented half a vsync before a vsync is then shown half a vsync
 1199|       |    // early, so the frames go out at their pts there. Such a display is told
 1200|       |    // by the frames placed on the vsync grid that it shows at once instead of
 1201|       |    // on the vsync, its lag is around a millisecond here. Most of the recent
 1202|       |    // frames have to agree, a single one proves nothing either way: DXGI times
 1203|       |    // one present in ten half a vsync before its vsync on an idle desktop,
 1204|       |    // and a compositor repainting for something else holds the presents of a
 1205|       |    // display that follows for a moment.
 1206|  43.7k|    bool follows = in->refresh_kind == VO_REFRESH_VARIABLE ||
  ------------------
  |  Branch (1206:20): [True: 0, False: 43.7k]
  ------------------
 1207|  43.7k|                   (in->refresh_kind != VO_REFRESH_FIXED && in->shown_at_once > 0.5);
  ------------------
  |  Branch (1207:21): [True: 43.7k, False: 0]
  |  Branch (1207:61): [True: 0, False: 43.7k]
  ------------------
 1208|  43.7k|    if (follows != in->follows) {
  ------------------
  |  Branch (1208:9): [True: 0, False: 43.7k]
  ------------------
 1209|      0|        MP_VERBOSE(vo, follows ? "Display shows presents immediately\n"
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1210|      0|                               : "Display shows presents on its vsyncs\n");
 1211|      0|        in->follows = follows;
 1212|       |        // The change moves the presents by up to a vsync, and the display
 1213|       |        // takes two or three frames to settle on the new cadence, below its
 1214|       |        // range it repeats frames on its own. Counted, those frames undo a
 1215|       |        // change made at the middle, so the average starts at the new state.
 1216|      0|        in->shown_at_once = follows;
 1217|      0|    }
 1218|       |
 1219|       |    // When the presentation feedback gives the vsyncs of the display, a timed
 1220|       |    // frame is due on the vsync nearest to its pts and is presented half a
 1221|       |    // vsync before it, clear of the pickup a compositor does right after the
 1222|       |    // previous vsync, where a present lands on either side of it, and well
 1223|       |    // ahead of the latch at its own.
 1224|       |    // The pts phase on the vsync grid decides the vsync. A frame goes on the
 1225|       |    // later vsync when its phase between the two is past the rounding edge,
 1226|       |    // and every frame keeps the edge a tenth of a vsync away from itself,
 1227|       |    // within a tenth of the middle. So the jitter of the pts cannot flip
 1228|       |    // frames between two vsyncs while they sit halfway, which lasts a few
 1229|       |    // frames for most rates, as long as the file for a rate that divides the
 1230|       |    // refresh rate. Frames elsewhere between the vsyncs leave the edge alone,
 1231|       |    // at 24 fps on 60 Hz every second frame is half a vsync from the others.
 1232|  43.7k|    int64_t due = 0;
 1233|  43.7k|    if (!frame->display_synced && !follows && duration >= 0 && in->vsync_grid &&
  ------------------
  |  Branch (1233:9): [True: 43.7k, False: 0]
  |  Branch (1233:35): [True: 43.7k, False: 0]
  |  Branch (1233:47): [True: 0, False: 43.7k]
  |  Branch (1233:64): [True: 0, False: 0]
  ------------------
 1234|      0|        now - in->vsync_grid < MP_TIME_S_TO_NS(1))
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (1234:9): [True: 0, False: 0]
  ------------------
 1235|      0|    {
 1236|      0|        double slots = (pts - in->vsync_grid) / in->vsync_interval;
 1237|      0|        double below = floor(slots);
 1238|      0|        double phase = slots - below;
 1239|      0|        bool up = phase > in->round_edge;
 1240|      0|        in->round_edge = up ? MPMAX(MPMIN(in->round_edge, phase - 0.1), 0.4)
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  |  Branch (44:23): [True: 0, False: 0]
  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1240:26): [True: 0, False: 0]
  ------------------
 1241|      0|                            : MPMIN(MPMAX(in->round_edge, phase + 0.1), 0.6);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  |  Branch (45:23): [True: 0, False: 0]
  |  |  |  Branch (45:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1242|      0|        due = in->vsync_grid + (int64_t)(in->vsync_interval * (below + up));
 1243|      0|        target = due - (int64_t)(in->vsync_interval * (1 + in->late.lead) / 2);
 1244|      0|    }
 1245|       |    // The frame rate counts as matched to the refresh rate when a frame that
 1246|       |    // waits a vsync behind another does not catch up within a second. A
 1247|       |    // frame due on a vsync that already got one can only be shown on the
 1248|       |    // next vsync, it takes that one when the wait clears soon, and is
 1249|       |    // dropped otherwise, every frame after it would wait as well. The grid
 1250|       |    // moves a little with every flip, so two dues less than half a vsync
 1251|       |    // apart are the same vsync.
 1252|  43.7k|    bool rate_matched = due && !late_frame_catches_up(in, duration);
  ------------------
  |  Branch (1252:25): [True: 0, False: 43.7k]
  |  Branch (1252:32): [True: 0, False: 0]
  ------------------
 1253|  43.7k|    bool due_taken = due && due < in->last_due + in->vsync_interval / 2;
  ------------------
  |  Branch (1253:22): [True: 0, False: 43.7k]
  |  Branch (1253:29): [True: 0, False: 0]
  ------------------
 1254|  43.7k|    if (due_taken && !rate_matched) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 43.7k]
  |  Branch (1254:22): [True: 0, False: 0]
  ------------------
 1255|      0|        int64_t shift = in->last_due + (int64_t)in->vsync_interval - due;
 1256|      0|        due += shift;
 1257|      0|        target += shift;
 1258|      0|        due_taken = false;
 1259|      0|    }
 1260|       |    // "normal" strict drop threshold, or the frame cannot be displayed in
 1261|       |    // time because of the frames before it.
 1262|  43.7k|    bool lost = end_time < now || due_taken;
  ------------------
  |  Branch (1262:17): [True: 43.7k, False: 0]
  |  Branch (1262:35): [True: 0, False: 0]
  ------------------
 1263|       |    // What the swapchain cannot hide of the lateness is taken out by a frame
 1264|       |    // that gives up its vsync, the queue then drains by one. That takes a
 1265|       |    // frame that would be shown.
 1266|  43.7k|    bool drain = in->late.drop && rate_matched && !lost;
  ------------------
  |  Branch (1266:18): [True: 0, False: 43.7k]
  |  Branch (1266:35): [True: 0, False: 0]
  |  Branch (1266:51): [True: 0, False: 0]
  ------------------
 1267|  43.7k|    in->dropped_frame = duration >= 0 && (lost || drain);
  ------------------
  |  Branch (1267:25): [True: 0, False: 43.7k]
  |  Branch (1267:43): [True: 0, False: 0]
  |  Branch (1267:51): [True: 0, False: 0]
  ------------------
 1268|       |
 1269|  43.7k|    in->dropped_frame &= !frame->display_synced;
 1270|  43.7k|    in->dropped_frame &= !(vo->driver->caps & VO_CAP_FRAMEDROP);
 1271|  43.7k|    in->dropped_frame &= frame->can_drop;
 1272|       |    // Even if we're hopelessly behind, rather degrade to 10 FPS playback,
 1273|       |    // instead of just freezing the display forever.
 1274|  43.7k|    in->dropped_frame &= now - in->prev_vsync < MP_TIME_MS_TO_NS(100);
  ------------------
  |  |   72|  43.7k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
 1275|  43.7k|    in->dropped_frame &= in->hasframe_rendered;
 1276|       |
 1277|       |    // Setup parameters for the next time this frame is drawn. ("frame" is the
 1278|       |    // frame currently drawn, while in->current_frame is the potentially next.)
 1279|  43.7k|    in->current_frame->repeat = true;
 1280|  43.7k|    if (frame->display_synced) {
  ------------------
  |  Branch (1280:9): [True: 0, False: 43.7k]
  ------------------
 1281|       |        // Increment the offset only if it's not the last vsync. The current_frame
 1282|       |        // can still be reused. This is mostly important for redraws that might
 1283|       |        // overshoot the target vsync point.
 1284|      0|        if (in->current_frame->num_vsyncs > 1) {
  ------------------
  |  Branch (1284:13): [True: 0, False: 0]
  ------------------
 1285|      0|            in->current_frame->vsync_offset += in->current_frame->vsync_interval;
 1286|      0|            in->current_frame->ideal_frame_vsync += in->current_frame->ideal_frame_vsync_duration;
 1287|      0|        }
 1288|      0|        in->dropped_frame |= in->current_frame->num_vsyncs < 1;
 1289|      0|    }
 1290|  43.7k|    if (in->current_frame->num_vsyncs > 0)
  ------------------
  |  Branch (1290:9): [True: 43.7k, False: 0]
  ------------------
 1291|  43.7k|        in->current_frame->num_vsyncs -= 1;
 1292|       |
 1293|       |    // Always render when paused (it's typically the last frame for a while).
 1294|  43.7k|    in->dropped_frame &= !in->paused;
 1295|       |
 1296|       |    // The frames flipped from here on tell what the drop did.
 1297|  43.7k|    bool drained = in->dropped_frame && drain;
  ------------------
  |  Branch (1297:20): [True: 0, False: 43.7k]
  |  Branch (1297:41): [True: 0, False: 0]
  ------------------
 1298|  43.7k|    if (drained) {
  ------------------
  |  Branch (1298:9): [True: 0, False: 43.7k]
  ------------------
 1299|      0|        in->late.prev[0] = in->late.prev[1] = INT_MIN;
 1300|      0|        in->late.drop_flip = in->flips;
 1301|      0|    }
 1302|       |    // Below the refresh rate a queue drains by itself through the vsyncs
 1303|       |    // without a new frame.
 1304|  43.7k|    if (drained || !rate_matched)
  ------------------
  |  Branch (1304:9): [True: 0, False: 43.7k]
  |  Branch (1304:20): [True: 43.7k, False: 0]
  ------------------
 1305|  43.7k|        in->late.drop = false;
 1306|       |    // No other frame takes the vsync a frame gave up for the queue.
 1307|  43.7k|    if (due && (!in->dropped_frame || drained))
  ------------------
  |  Branch (1307:9): [True: 0, False: 43.7k]
  |  Branch (1307:17): [True: 0, False: 0]
  |  Branch (1307:39): [True: 0, False: 0]
  ------------------
 1308|      0|        in->last_due = due;
 1309|       |
 1310|  43.7k|    bool use_vsync = in->current_frame->display_synced && !in->paused;
  ------------------
  |  Branch (1310:22): [True: 0, False: 43.7k]
  |  Branch (1310:59): [True: 0, False: 0]
  ------------------
 1311|  43.7k|    if (use_vsync && !in->expecting_vsync) // first DS frame in a row
  ------------------
  |  Branch (1311:9): [True: 0, False: 43.7k]
  |  Branch (1311:22): [True: 0, False: 0]
  ------------------
 1312|      0|        in->prev_vsync = now;
 1313|  43.7k|    in->expecting_vsync = use_vsync;
 1314|       |
 1315|  43.7k|    if (in->dropped_frame) {
  ------------------
  |  Branch (1315:9): [True: 0, False: 43.7k]
  ------------------
 1316|      0|        in->drop_count += 1;
 1317|      0|        wakeup_core(vo);
 1318|  43.7k|    } else {
 1319|  43.7k|        in->rendering = true;
 1320|  43.7k|        in->hasframe_rendered = true;
 1321|  43.7k|        int64_t prev_drop_count = vo->in->drop_count;
 1322|       |        // Read it before unlocking, in case the frame gets freed by the VO (VO_CAP_FRAMEOWNER).
 1323|  43.7k|        bool display_synced = frame->display_synced;
 1324|       |        // Can the core queue new video now? Non-display-sync uses a separate
 1325|       |        // timer instead, but possibly benefits from preparing a frame early.
 1326|  43.7k|        bool can_queue = !in->frame_queued &&
  ------------------
  |  Branch (1326:26): [True: 43.7k, False: 0]
  ------------------
 1327|  43.7k|            (in->current_frame->num_vsyncs < 1 || !use_vsync);
  ------------------
  |  Branch (1327:14): [True: 43.7k, False: 0]
  |  Branch (1327:51): [True: 0, False: 0]
  ------------------
 1328|       |        // This draw covers every redraw request made so far.
 1329|  43.7k|        in->request_redraw = false;
 1330|  43.7k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  43.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1331|       |
 1332|  43.7k|        if (can_queue)
  ------------------
  |  Branch (1332:13): [True: 43.7k, False: 0]
  ------------------
 1333|  43.7k|            wakeup_core(vo);
 1334|       |
 1335|  43.7k|        stats_time_start(in->stats, "video-draw");
 1336|       |
 1337|  43.7k|        in->visible = vo->driver->draw_frame(vo, frame);
 1338|       |
 1339|  43.7k|        stats_time_end(in->stats, "video-draw");
 1340|       |
 1341|  43.7k|        wait_until(target, follows);
 1342|       |
 1343|  43.7k|        stats_time_start(in->stats, "video-flip");
 1344|       |
 1345|  43.7k|        int64_t present_time = mp_time_ns();
 1346|  43.7k|        vo->driver->flip_page(vo);
 1347|       |
 1348|  43.7k|        struct vo_vsync_info vsync = {
 1349|  43.7k|            .skipped_vsyncs = -1,
 1350|  43.7k|        };
 1351|  43.7k|        if (vo->driver->get_vsync)
  ------------------
  |  Branch (1351:13): [True: 0, False: 43.7k]
  ------------------
 1352|      0|            vo->driver->get_vsync(vo, &vsync);
 1353|  43.7k|        int64_t display_time = predict_display_time(&vsync, present_time);
 1354|  43.7k|        bool have_feedback = display_time > 0;
 1355|       |
 1356|       |        // Make up some crap if presentation feedback is missing.
 1357|  43.7k|        if (!have_feedback)
  ------------------
  |  Branch (1357:13): [True: 43.7k, False: 0]
  ------------------
 1358|  43.7k|            display_time = mp_time_ns();
 1359|       |
 1360|  43.7k|        stats_time_end(in->stats, "video-flip");
 1361|       |
 1362|  43.7k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  43.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1363|  43.7k|        in->dropped_frame = prev_drop_count < vo->in->drop_count;
 1364|  43.7k|        in->rendering = false;
 1365|       |
 1366|  43.7k|        in->refresh_kind = have_feedback ? vsync.refresh_kind : VO_REFRESH_UNKNOWN;
  ------------------
  |  Branch (1366:28): [True: 0, False: 43.7k]
  ------------------
 1367|  43.7k|        record_present(in, (struct present_record){present_time, pts, due});
 1368|       |        // The flip the backend reports as displayed, if it measured the time
 1369|       |        // and the flip is one of the last.
 1370|  43.7k|        int64_t shown_flip = in->flips - 1 - vsync.displayed_age;
 1371|  43.7k|        struct present_record *shown = NULL;
 1372|  43.7k|        if (vsync.displayed_time > 0 && !vsync.displayed_estimated && shown_flip >= 0 &&
  ------------------
  |  Branch (1372:13): [True: 0, False: 43.7k]
  |  Branch (1372:41): [True: 0, False: 0]
  |  Branch (1372:71): [True: 0, False: 0]
  ------------------
 1373|      0|            vsync.displayed_age < MP_ARRAY_SIZE(in->presents))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (1373:13): [True: 0, False: 0]
  ------------------
 1374|      0|            shown = &in->presents[shown_flip % MP_ARRAY_SIZE(in->presents)];
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 1375|  43.7k|        if (shown && shown->pts) {
  ------------------
  |  Branch (1375:13): [True: 0, False: 43.7k]
  |  Branch (1375:22): [True: 0, False: 0]
  ------------------
 1376|      0|            set_presentation_delay(vo, vsync.displayed_time - shown->pts);
 1377|  43.7k|        } else if (due && have_feedback) {
  ------------------
  |  Branch (1377:20): [True: 0, False: 43.7k]
  |  Branch (1377:27): [True: 0, False: 0]
  ------------------
 1378|      0|            set_presentation_delay(vo, display_time - pts);
 1379|  43.7k|        } else if (display_synced || !have_feedback) {
  ------------------
  |  Branch (1379:20): [True: 0, False: 43.7k]
  |  Branch (1379:38): [True: 43.7k, False: 0]
  ------------------
 1380|  43.7k|            set_presentation_delay(vo, INT64_MIN);
 1381|  43.7k|        }
 1382|  43.7k|        if (shown && shown->due)
  ------------------
  |  Branch (1382:13): [True: 0, False: 43.7k]
  |  Branch (1382:22): [True: 0, False: 0]
  ------------------
 1383|      0|            check_timed_frame_late(vo, shown_flip, shown->due, vsync.displayed_time, duration);
 1384|  43.7k|        if (shown && (shown->due || in->follows)) {
  ------------------
  |  Branch (1384:13): [True: 0, False: 43.7k]
  |  Branch (1384:23): [True: 0, False: 0]
  |  Branch (1384:37): [True: 0, False: 0]
  ------------------
 1385|      0|            bool at_once = vsync.displayed_time - shown->time < in->vsync_interval / 4;
 1386|      0|            in->shown_at_once += (at_once - in->shown_at_once) / 16;
 1387|      0|        }
 1388|  43.7k|        bool grid = have_feedback && in->vsync_interval > 1 && !in->follows;
  ------------------
  |  Branch (1388:21): [True: 0, False: 43.7k]
  |  Branch (1388:38): [True: 0, False: 0]
  |  Branch (1388:64): [True: 0, False: 0]
  ------------------
 1389|  43.7k|        bool on_grid = grid && update_vsync_grid(in, display_time);
  ------------------
  |  Branch (1389:24): [True: 0, False: 43.7k]
  |  Branch (1389:32): [True: 0, False: 0]
  ------------------
 1390|  43.7k|        update_vsync_timing_after_swap(vo, display_time, grid, on_grid);
 1391|  43.7k|    }
 1392|       |
 1393|  43.7k|    if (vo->driver->caps & VO_CAP_NORETAIN) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 43.7k]
  ------------------
 1394|      0|        talloc_free(in->current_frame);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1395|      0|        in->current_frame = NULL;
 1396|      0|    }
 1397|       |
 1398|  43.7k|    if (in->dropped_frame)
  ------------------
  |  Branch (1398:9): [True: 0, False: 43.7k]
  ------------------
 1399|  43.7k|        MP_STATS(vo, "drop-vo");
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1400|       |
 1401|       |    // A redraw request that arrived while the VO was unlocked, will be handled
 1402|       |    // by the already queued frame. Clear pending redraw requests to avoid
 1403|       |    // unnecessary wakeups.
 1404|  43.7k|    if (in->frame_queued)
  ------------------
  |  Branch (1404:9): [True: 64, False: 43.6k]
  ------------------
 1405|     64|        in->request_redraw = false;
 1406|       |
 1407|  43.7k|    if (in->current_frame && in->current_frame->num_vsyncs &&
  ------------------
  |  Branch (1407:9): [True: 43.7k, False: 0]
  |  Branch (1407:30): [True: 0, False: 43.7k]
  ------------------
 1408|      0|        in->current_frame->display_synced)
  ------------------
  |  Branch (1408:9): [True: 0, False: 0]
  ------------------
 1409|      0|        more_frames = true;
 1410|       |
 1411|  43.7k|    if (in->frame_queued && in->frame_queued->display_synced)
  ------------------
  |  Branch (1411:9): [True: 64, False: 43.6k]
  |  Branch (1411:29): [True: 0, False: 64]
  ------------------
 1412|      0|        more_frames = true;
 1413|       |
 1414|  43.7k|    mp_cond_broadcast(&in->wakeup); // for vo_wait_frame()
 1415|       |
 1416|   132k|done:
 1417|   132k|    if (!(vo->driver->caps & VO_CAP_FRAMEOWNER) || in->dropped_frame)
  ------------------
  |  Branch (1417:9): [True: 132k, False: 0]
  |  Branch (1417:52): [True: 0, False: 0]
  ------------------
 1418|   132k|        talloc_free(frame);
  ------------------
  |  |   47|   132k|#define talloc_free                     ta_free
  ------------------
 1419|   132k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   132k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1420|       |
 1421|   132k|    return more_frames;
 1422|  43.7k|}
vo.c:wait_until:
 1149|  43.7k|{
 1150|  43.7k|    mp_sleep_ns(target - (exact ? SLEEP_SLACK_NS : 0) - mp_time_ns());
  ------------------
  |  | 1145|      0|#define SLEEP_SLACK_NS 0
  ------------------
  |  Branch (1150:27): [True: 0, False: 43.7k]
  ------------------
 1151|       |    // A sleep can end before its time.
 1152|  43.7k|    while (mp_time_ns() < target) {}
  ------------------
  |  Branch (1152:12): [True: 0, False: 43.7k]
  ------------------
 1153|  43.7k|}
vo.c:predict_display_time:
 1011|  43.7k|{
 1012|  43.7k|    int64_t known = vsync->displayed_time;
 1013|  43.7k|    int age = vsync->displayed_age;
 1014|  43.7k|    int64_t vd = vsync->vsync_duration;
 1015|  43.7k|    if (known <= 0 || (age && vd <= 0))
  ------------------
  |  Branch (1015:9): [True: 43.7k, False: 0]
  |  Branch (1015:24): [True: 0, False: 0]
  |  Branch (1015:31): [True: 0, False: 0]
  ------------------
 1016|  43.7k|        return -1;
 1017|      0|    if (!age)
  ------------------
  |  Branch (1017:9): [True: 0, False: 0]
  ------------------
 1018|      0|        return known;
 1019|      0|    int64_t display = known + age * vd;
 1020|      0|    if (submit_time > known)
  ------------------
  |  Branch (1020:9): [True: 0, False: 0]
  ------------------
 1021|      0|        display = MPMAX(display, known + ((submit_time - known) / vd + 1) * vd);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1022|      0|    return display;
 1023|      0|}
vo.c:record_present:
 1137|  43.7k|{
 1138|  43.7k|    in->presents[in->flips++ % MP_ARRAY_SIZE(in->presents)] = present;
  ------------------
  |  |   49|  43.7k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 1139|  43.7k|}
vo.c:set_presentation_delay:
  783|  82.2k|{
  784|  82.2k|    struct vo_internal *in = vo->in;
  785|  82.2k|    if (in->presentation_delay == delay)
  ------------------
  |  Branch (785:9): [True: 82.2k, False: 0]
  ------------------
  786|  82.2k|        return;
  787|      0|    in->presentation_delay = delay;
  788|      0|    in->queued_events |= VO_EVENT_PRESENTATION_DELAY;
  789|      0|    wakeup_core(vo);
  790|      0|}
vo.c:update_vsync_timing_after_swap:
  541|  43.7k|{
  542|  43.7k|    struct vo_internal *in = vo->in;
  543|       |
  544|  43.7k|    int64_t prev_vsync = in->prev_vsync;
  545|  43.7k|    in->prev_vsync = vsync_time;
  546|       |
  547|  43.7k|    if (!in->expecting_vsync) {
  ------------------
  |  Branch (547:9): [True: 43.7k, False: 0]
  ------------------
  548|  43.7k|        reset_vsync_timings(vo);
  549|  43.7k|        return;
  550|  43.7k|    }
  551|       |
  552|      0|    in->num_successive_vsyncs++;
  553|      0|    if (in->num_successive_vsyncs <= DELAY_VSYNC_SAMPLES) {
  ------------------
  |  |  446|      0|#define DELAY_VSYNC_SAMPLES 10
  ------------------
  |  Branch (553:9): [True: 0, False: 0]
  ------------------
  554|      0|        in->base_vsync = vsync_time;
  555|      0|        return;
  556|      0|    }
  557|       |
  558|      0|    if (vsync_time <= 0 || vsync_time <= prev_vsync) {
  ------------------
  |  Branch (558:9): [True: 0, False: 0]
  |  Branch (558:28): [True: 0, False: 0]
  ------------------
  559|      0|        in->prev_vsync = 0;
  560|      0|        in->base_vsync = 0;
  561|      0|        return;
  562|      0|    }
  563|       |
  564|      0|    if (prev_vsync <= 0)
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|        return;
  566|       |
  567|      0|    if (in->num_vsync_samples >= MAX_VSYNC_SAMPLES)
  ------------------
  |  |  445|      0|#define MAX_VSYNC_SAMPLES 1000
  ------------------
  |  Branch (567:9): [True: 0, False: 0]
  ------------------
  568|      0|        in->num_vsync_samples -= 1;
  569|      0|    MP_TARRAY_INSERT_AT(in, in->vsync_samples, in->num_vsync_samples, 0,
  ------------------
  |  |  115|      0|    do {                                            \
  |  |  116|      0|        size_t at_ = (at);                          \
  |  |  117|      0|        assert(at_ <= (idxvar));                    \
  |  |  118|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|      0|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|      0|        (idxvar)++;                                 \
  |  |  122|      0|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (569:5): [True: 0, False: 0]
  ------------------
  570|      0|                        vsync_time - prev_vsync);
  571|      0|    in->drop_point = MPMIN(in->drop_point + 1, in->num_vsync_samples);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  572|      0|    in->num_total_vsync_samples += 1;
  573|       |    // With presentation feedback the vsync grid has the vsync of this flip,
  574|       |    // and a flip more than one vsync after the previous one was delayed. A
  575|       |    // time that is not on the grid is not a vsync, the flip is taken for one
  576|       |    // vsync after the last. Without feedback the vsyncs are counted and
  577|       |    // checked against the flip times.
  578|      0|    if (on_grid) {
  ------------------
  |  Branch (578:9): [True: 0, False: 0]
  ------------------
  579|      0|        if (in->base_vsync && in->vsync_grid - in->base_vsync > in->vsync_interval * 1.5) {
  ------------------
  |  Branch (579:13): [True: 0, False: 0]
  |  Branch (579:31): [True: 0, False: 0]
  ------------------
  580|      0|            in->delayed_count += 1;
  581|      0|            MP_STATS(vo, "vo-delayed");
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  582|      0|        }
  583|      0|        in->base_vsync = in->vsync_grid;
  584|      0|    } else if (in->base_vsync) {
  ------------------
  |  Branch (584:16): [True: 0, False: 0]
  ------------------
  585|      0|        in->base_vsync += in->vsync_interval;
  586|      0|    } else {
  587|      0|        in->base_vsync = vsync_time;
  588|      0|    }
  589|       |
  590|      0|    double avg = 0;
  591|      0|    for (int n = 0; n < in->num_vsync_samples; n++) {
  ------------------
  |  Branch (591:21): [True: 0, False: 0]
  ------------------
  592|      0|        mp_assert(in->vsync_samples[n] > 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (592:9): [True: 0, False: 0]
  ------------------
  593|      0|        avg += in->vsync_samples[n];
  594|      0|    }
  595|      0|    in->estimated_vsync_interval = avg / in->num_vsync_samples;
  596|      0|    in->estimated_vsync_jitter =
  597|      0|        vsync_stddef(vo, in->vsync_interval) / in->vsync_interval;
  598|       |
  599|      0|    check_estimated_display_fps(vo);
  600|      0|    if (!grid)
  ------------------
  |  Branch (600:9): [True: 0, False: 0]
  ------------------
  601|      0|        vsync_skip_detection(vo);
  602|       |
  603|      0|    MP_STATS(vo, "value %f jitter", in->estimated_vsync_jitter);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  604|      0|    MP_STATS(vo, "value %f vsync-diff", MP_TIME_NS_TO_S(in->vsync_samples[0]));
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  605|      0|}
vo.c:get_current_frame_end:
  866|  1.84k|{
  867|  1.84k|    struct vo_internal *in = vo->in;
  868|  1.84k|    if (!in->current_frame)
  ------------------
  |  Branch (868:9): [True: 1.00k, False: 839]
  ------------------
  869|  1.00k|        return -1;
  870|    839|    return in->current_frame->pts + MPMAX(in->current_frame->duration, 0);
  ------------------
  |  |   44|    839|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 839]
  |  |  ------------------
  ------------------
  871|  1.84k|}
vo.c:wait_vo:
  831|   132k|{
  832|   132k|    struct vo_internal *in = vo->in;
  833|       |
  834|   132k|    if (vo->driver->wait_events) {
  ------------------
  |  Branch (834:9): [True: 0, False: 132k]
  ------------------
  835|      0|        vo->driver->wait_events(vo, until_time);
  836|   132k|    } else {
  837|   132k|        vo_wait_default(vo, until_time);
  838|   132k|    }
  839|   132k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   132k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  840|   132k|    in->need_wakeup = false;
  841|   132k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   132k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|   132k|}
vo.c:terminate_vo:
  403|  9.61k|{
  404|  9.61k|    struct vo *vo = p;
  405|  9.61k|    struct vo_internal *in = vo->in;
  406|       |    in->terminate = true;
  407|  9.61k|}
vo.c:dealloc_vo:
  291|  9.61k|{
  292|  9.61k|    forget_frames(vo); // implicitly synchronized
  293|       |
  294|       |    // These must be free'd before vo->in->dispatch.
  295|  9.61k|    talloc_free(vo->opts_cache);
  ------------------
  |  |   47|  9.61k|#define talloc_free                     ta_free
  ------------------
  296|  9.61k|    mp_mutex_destroy(&vo->params_mutex);
  ------------------
  |  |  133|  9.61k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  297|       |
  298|  9.61k|    mp_mutex_destroy(&vo->in->lock);
  ------------------
  |  |  133|  9.61k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  299|  9.61k|    mp_cond_destroy(&vo->in->wakeup);
  300|  9.61k|    talloc_free(vo);
  ------------------
  |  |   47|  9.61k|#define talloc_free                     ta_free
  ------------------
  301|  9.61k|}
vo.c:run_reconfig:
  665|  1.84k|{
  666|  1.84k|    void **pp = p;
  667|  1.84k|    struct vo *vo = pp[0];
  668|  1.84k|    struct mp_image *img = pp[1];
  669|  1.84k|    int *ret = pp[2];
  670|       |
  671|  1.84k|    struct mp_image_params *params = &img->params;
  672|       |
  673|  1.84k|    struct vo_internal *in = vo->in;
  674|       |
  675|  1.84k|    MP_VERBOSE(vo, "reconfig to %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  1.84k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.84k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  676|       |
  677|  1.84k|    update_opts(vo);
  678|       |
  679|  1.84k|    mp_image_params_get_dsize(params, &vo->dwidth, &vo->dheight);
  680|       |
  681|  1.84k|    mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|  1.84k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  682|  1.84k|    talloc_free(vo->params);
  ------------------
  |  |   47|  1.84k|#define talloc_free                     ta_free
  ------------------
  683|  1.84k|    vo->params = talloc_dup(vo, params);
  ------------------
  |  |   48|  1.84k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  1.84k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.84k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|  1.84k|    vo->has_peak_detect_values = false;
  685|  1.84k|    mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|  1.84k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  686|       |
  687|  1.84k|    if (vo->driver->reconfig2) {
  ------------------
  |  Branch (687:9): [True: 0, False: 1.84k]
  ------------------
  688|      0|        *ret = vo->driver->reconfig2(vo, img);
  689|  1.84k|    } else {
  690|  1.84k|        *ret = vo->driver->reconfig(vo, vo->params);
  691|  1.84k|    }
  692|  1.84k|    vo->config_ok = *ret >= 0;
  693|  1.84k|    if (vo->config_ok) {
  ------------------
  |  Branch (693:9): [True: 1.84k, False: 0]
  ------------------
  694|  1.84k|        check_vo_caps(vo);
  695|  1.84k|    } else {
  696|      0|        mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  697|      0|        talloc_free(vo->params);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  698|      0|        vo->params = NULL;
  699|      0|        vo->has_peak_detect_values = false;
  700|      0|        mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  701|      0|    }
  702|       |
  703|  1.84k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.84k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  704|  1.84k|    talloc_free(in->current_frame);
  ------------------
  |  |   47|  1.84k|#define talloc_free                     ta_free
  ------------------
  705|  1.84k|    in->current_frame = NULL;
  706|  1.84k|    forget_frames(vo);
  707|  1.84k|    reset_vsync_timings(vo);
  708|  1.84k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.84k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  709|       |
  710|  1.84k|    update_display_fps(vo);
  711|  1.84k|}
vo.c:check_vo_caps:
  650|  1.84k|{
  651|  1.84k|    int rot = vo->params->rotate;
  652|  1.84k|    if (rot) {
  ------------------
  |  Branch (652:9): [True: 0, False: 1.84k]
  ------------------
  653|      0|        bool ok = rot % 90 ? false : (vo->driver->caps & VO_CAP_ROTATE90);
  ------------------
  |  Branch (653:19): [True: 0, False: 0]
  ------------------
  654|      0|        if (!ok) {
  ------------------
  |  Branch (654:13): [True: 0, False: 0]
  ------------------
  655|      0|           MP_WARN(vo, "Video is flagged as rotated by %d degrees, but the "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  656|      0|                   "video output does not support this.\n", rot);
  657|      0|        }
  658|      0|    }
  659|  1.84k|    if (vo->params->vflip && !(vo->driver->caps & VO_CAP_VFLIP))
  ------------------
  |  Branch (659:9): [True: 0, False: 1.84k]
  |  Branch (659:30): [True: 0, False: 0]
  ------------------
  660|  1.84k|        MP_WARN(vo, "Video is flagged as vertically flipped, but the "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  661|  1.84k|                    "video output does not support this.\n");
  662|  1.84k|}
vo.c:run_control:
  732|  47.2k|{
  733|  47.2k|    void **pp = p;
  734|  47.2k|    struct vo *vo = pp[0];
  735|  47.2k|    int request = (intptr_t)pp[1];
  736|  47.2k|    void *data = pp[2];
  737|  47.2k|    update_opts(vo);
  738|  47.2k|    int ret = vo->driver->control(vo, request, data);
  739|  47.2k|    if (pp[3])
  ------------------
  |  Branch (739:9): [True: 25.0k, False: 22.2k]
  ------------------
  740|  25.0k|        *(int *)pp[3] = ret;
  741|  47.2k|}
vo.c:wakeup_locked:
  845|   148k|{
  846|   148k|    struct vo_internal *in = vo->in;
  847|       |
  848|   148k|    mp_cond_broadcast(&in->wakeup);
  849|   148k|    if (vo->driver->wakeup)
  ------------------
  |  Branch (849:9): [True: 0, False: 148k]
  ------------------
  850|      0|        vo->driver->wakeup(vo);
  851|       |    in->need_wakeup = true;
  852|   148k|}
vo.c:still_displaying:
  889|  1.84k|{
  890|  1.84k|    struct vo_internal *in = vo->in;
  891|  1.84k|    bool working = in->rendering || in->frame_queued;
  ------------------
  |  Branch (891:20): [True: 0, False: 1.84k]
  |  Branch (891:37): [True: 0, False: 1.84k]
  ------------------
  892|  1.84k|    if (working)
  ------------------
  |  Branch (892:9): [True: 0, False: 1.84k]
  ------------------
  893|      0|        goto done;
  894|       |
  895|  1.84k|    int64_t frame_end = get_display_synced_frame_end(vo);
  896|  1.84k|    if (frame_end > 0) {
  ------------------
  |  Branch (896:9): [True: 0, False: 1.84k]
  ------------------
  897|      0|        working = frame_end > in->base_vsync + in->vsync_interval;
  898|      0|        goto done;
  899|      0|    }
  900|       |
  901|  1.84k|    frame_end = get_current_frame_end(vo);
  902|  1.84k|    if (frame_end < 0)
  ------------------
  |  Branch (902:9): [True: 1.00k, False: 839]
  ------------------
  903|  1.00k|        goto done;
  904|    839|    working = mp_time_ns() < frame_end;
  905|       |
  906|  1.84k|done:
  907|  1.84k|    return working && in->hasframe;
  ------------------
  |  Branch (907:12): [True: 0, False: 1.84k]
  |  Branch (907:23): [True: 0, False: 0]
  ------------------
  908|    839|}
vo.c:wakeup_core:
  419|  97.1k|{
  420|  97.1k|    vo->extra.wakeup_cb(vo->extra.wakeup_ctx);
  421|  97.1k|}
vo.c:reset_vsync_timings:
  426|  62.9k|{
  427|  62.9k|    struct vo_internal *in = vo->in;
  428|  62.9k|    in->drop_point = 0;
  429|  62.9k|    in->base_vsync = 0;
  430|       |    in->expecting_vsync = false;
  431|  62.9k|    in->num_successive_vsyncs = 0;
  432|  62.9k|}
vo.c:restart_lateness:
  776|  38.4k|{
  777|       |    in->late.prev[0] = in->late.prev[1] = INT_MIN;
  778|  38.4k|    in->late.judged = in->flips - 1;
  779|  38.4k|}
vo.c:forget_frames:
  794|  38.4k|{
  795|  38.4k|    struct vo_internal *in = vo->in;
  796|  38.4k|    in->hasframe = false;
  797|  38.4k|    in->hasframe_rendered = false;
  798|  38.4k|    in->drop_count = 0;
  799|  38.4k|    in->delayed_count = 0;
  800|  38.4k|    set_presentation_delay(vo, INT64_MIN);
  801|  38.4k|    in->last_due = 0;
  802|  38.4k|    restart_lateness(in);
  803|  38.4k|    in->late.drop = false;
  804|  38.4k|    in->late.drop_flip = 0;
  805|  38.4k|    in->late.held = 0;
  806|  38.4k|    talloc_free(in->frame_queued);
  ------------------
  |  |   47|  38.4k|#define talloc_free                     ta_free
  ------------------
  807|  38.4k|    in->frame_queued = NULL;
  808|  38.4k|    in->current_frame_id += VO_MAX_REQ_FRAMES + 1;
  ------------------
  |  |  216|  38.4k|#define VO_MAX_REQ_FRAMES 10
  ------------------
  809|       |    // don't unref current_frame; we always want to be able to redraw it
  810|  38.4k|    if (in->current_frame) {
  ------------------
  |  Branch (810:9): [True: 2.00k, False: 36.4k]
  ------------------
  811|  2.00k|        in->current_frame->num_vsyncs = 0; // but reset future repeats
  812|       |        in->current_frame->display_synced = false; // mark discontinuity
  813|  2.00k|    }
  814|  38.4k|}
vo.c:run_query_format:
 1650|  19.2k|{
 1651|  19.2k|    void **pp = p;
 1652|  19.2k|    struct vo *vo = pp[0];
 1653|  19.2k|    uint8_t *list = pp[1];
 1654|  10.7M|    for (int format = IMGFMT_START; format < IMGFMT_END; format++)
  ------------------
  |  Branch (1654:37): [True: 10.7M, False: 19.2k]
  ------------------
 1655|  10.7M|        list[format - IMGFMT_START] = vo->driver->query_format(vo, format);
 1656|  19.2k|}
vo.c:get_display_synced_frame_end:
  874|  1.84k|{
  875|  1.84k|    struct vo_internal *in = vo->in;
  876|  1.84k|    mp_assert(!in->frame_queued);
  ------------------
  |  |   41|  1.84k|#define mp_assert assert
  ------------------
  |  Branch (876:5): [True: 1.84k, False: 0]
  ------------------
  877|  1.84k|    int64_t res = 0;
  878|  1.84k|    if (in->base_vsync && in->vsync_interval > 1 && in->current_frame) {
  ------------------
  |  Branch (878:9): [True: 0, False: 1.84k]
  |  Branch (878:27): [True: 0, False: 0]
  |  Branch (878:53): [True: 0, False: 0]
  ------------------
  879|      0|        res = in->base_vsync;
  880|      0|        int extra = !!in->rendering;
  881|      0|        res += (in->current_frame->num_vsyncs + extra + 1) * in->vsync_interval;
  882|      0|        if (!in->current_frame->display_synced)
  ------------------
  |  Branch (882:13): [True: 0, False: 0]
  ------------------
  883|      0|            res = 0;
  884|      0|    }
  885|  1.84k|    return res;
  886|  1.84k|}
vo.c:destroy_frame:
 1854|  87.5k|{
 1855|  87.5k|    struct vo_frame *frame = p;
 1856|   175k|    for (int n = 0; n < frame->num_frames; n++)
  ------------------
  |  Branch (1856:21): [True: 87.5k, False: 87.5k]
  ------------------
 1857|  87.5k|        talloc_free(frame->frames[n]);
  ------------------
  |  |   47|  87.5k|#define talloc_free                     ta_free
  ------------------
 1858|  87.5k|}

vo_null.c:preinit:
   71|  9.61k|{
   72|  9.61k|    return 0;
   73|  9.61k|}
vo_null.c:query_format:
   57|  10.7M|{
   58|  10.7M|    return 1;
   59|  10.7M|}
vo_null.c:reconfig:
   62|  1.84k|{
   63|  1.84k|    return 0;
   64|  1.84k|}
vo_null.c:control:
   76|   205k|{
   77|   205k|    struct priv *p = vo->priv;
   78|   205k|    switch (request) {
  ------------------
  |  Branch (78:13): [True: 9.61k, False: 196k]
  ------------------
   79|  9.61k|    case VOCTRL_GET_DISPLAY_FPS:
  ------------------
  |  Branch (79:5): [True: 9.61k, False: 196k]
  ------------------
   80|  9.61k|        if (!p->cfg_fps)
  ------------------
  |  Branch (80:13): [True: 9.61k, False: 0]
  ------------------
   81|  9.61k|            break;
   82|      0|        *(double *)data = p->cfg_fps;
   83|      0|        return VO_TRUE;
  ------------------
  |  |  146|      0|#define VO_TRUE         true
  ------------------
   84|   205k|    }
   85|   205k|    return VO_NOTIMPL;
  ------------------
  |  |  150|   205k|#define VO_NOTIMPL      -3
  ------------------
   86|   205k|}
vo_null.c:draw_frame:
   36|  43.7k|{
   37|       |    return VO_TRUE;
  ------------------
  |  |  146|  43.7k|#define VO_TRUE         true
  ------------------
   38|  43.7k|}
vo_null.c:flip_page:
   41|  43.7k|{
   42|  43.7k|    struct priv *p = vo->priv;
   43|  43.7k|    if (p->cfg_fps >= 1e-6) {
  ------------------
  |  Branch (43:9): [True: 0, False: 43.7k]
  ------------------
   44|      0|        int64_t ft = 1e9 / p->cfg_fps;
   45|      0|        int64_t prev_vsync = mp_time_ns() / ft;
   46|      0|        int64_t target_time = (prev_vsync + 1) * ft;
   47|      0|        for (;;) {
   48|      0|            int64_t now = mp_time_ns();
   49|      0|            if (now >= target_time)
  ------------------
  |  Branch (49:17): [True: 0, False: 0]
  ------------------
   50|      0|                break;
   51|      0|            mp_sleep_ns(target_time - now);
   52|      0|        }
   53|      0|    }
   54|  43.7k|}
vo_null.c:uninit:
   67|  9.61k|{
   68|  9.61k|}

mp_img_swap_to_native:
  455|  43.7k|{
  456|  43.7k|    int avfmt = imgfmt2pixfmt(img->imgfmt);
  457|  43.7k|    int to = AV_PIX_FMT_NONE;
  458|   218k|    for (int n = 0; endian_swaps[n][0] != AV_PIX_FMT_NONE; n++) {
  ------------------
  |  Branch (458:21): [True: 175k, False: 43.7k]
  ------------------
  459|   175k|        if (endian_swaps[n][0] == avfmt)
  ------------------
  |  Branch (459:13): [True: 0, False: 175k]
  ------------------
  460|      0|            to = endian_swaps[n][1];
  461|   175k|    }
  462|  43.7k|    if (to == AV_PIX_FMT_NONE || !mp_image_make_writeable(img))
  ------------------
  |  Branch (462:9): [True: 43.7k, False: 0]
  |  Branch (462:34): [True: 0, False: 0]
  ------------------
  463|  43.7k|        return img;
  464|      0|    int elems = img->fmt.bpp[0] / 8 / 2 * img->w;
  465|      0|    for (int y = 0; y < img->h; y++) {
  ------------------
  |  Branch (465:21): [True: 0, False: 0]
  ------------------
  466|      0|        uint16_t *p = (uint16_t *)(img->planes[0] + y * img->stride[0]);
  467|      0|        for (int i = 0; i < elems; i++)
  ------------------
  |  Branch (467:25): [True: 0, False: 0]
  ------------------
  468|      0|            p[i] = av_be2ne16(p[i]);
  469|      0|    }
  470|      0|    mp_image_setfmt(img, pixfmt2imgfmt(to));
  471|      0|    return img;
  472|  43.7k|}

