mp_aframe_create:
   53|   698k|{
   54|   698k|    struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe);
  ------------------
  |  |   27|   698k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   698k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   698k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|   698k|    frame->av_frame = av_frame_alloc();
   56|   698k|    MP_HANDLE_OOM(frame->av_frame);
  ------------------
  |  |  206|   698k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   698k|        void *oom_p_ = (x);     \
  |  |  208|   698k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 698k]
  |  |  ------------------
  |  |  209|   698k|            abort();            \
  |  |  210|   698k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 698k]
  |  |  ------------------
  ------------------
   57|   698k|    talloc_set_destructor(frame, free_frame);
  ------------------
  |  |   41|   698k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   58|   698k|    mp_aframe_reset(frame);
   59|   698k|    return frame;
   60|   698k|}
mp_aframe_new_ref:
   63|  10.4k|{
   64|  10.4k|    if (!frame)
  ------------------
  |  Branch (64:9): [True: 0, False: 10.4k]
  ------------------
   65|      0|        return NULL;
   66|       |
   67|  10.4k|    struct mp_aframe *dst = mp_aframe_create();
   68|       |
   69|  10.4k|    dst->chmap = frame->chmap;
   70|  10.4k|    dst->format = frame->format;
   71|  10.4k|    dst->pts = frame->pts;
   72|  10.4k|    dst->speed = frame->speed;
   73|       |
   74|  10.4k|    if (mp_aframe_is_allocated(frame)) {
  ------------------
  |  Branch (74:9): [True: 0, False: 10.4k]
  ------------------
   75|      0|        if (av_frame_ref(dst->av_frame, frame->av_frame) < 0)
  ------------------
  |  Branch (75:13): [True: 0, False: 0]
  ------------------
   76|      0|            abort();
   77|  10.4k|    } else {
   78|       |        // av_frame_ref() would fail.
   79|  10.4k|        mp_aframe_config_copy(dst, frame);
   80|  10.4k|    }
   81|       |
   82|  10.4k|    return dst;
   83|  10.4k|}
mp_aframe_reset:
   87|   773k|{
   88|   773k|    av_frame_unref(frame->av_frame);
   89|   773k|    frame->chmap.num = 0;
   90|   773k|    frame->format = 0;
   91|   773k|    frame->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   773k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   92|   773k|    frame->speed = 1.0;
   93|   773k|}
mp_aframe_alloc_data:
  110|  8.00k|{
  111|  8.00k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (111:9): [True: 0, False: 8.00k]
  ------------------
  112|      0|        return false;
  113|  8.00k|    struct mp_aframe_pool *p = mp_aframe_pool_create(NULL);
  114|  8.00k|    int r = mp_aframe_pool_allocate(p, frame, samples);
  115|  8.00k|    talloc_free(p);
  ------------------
  |  |   47|  8.00k|#define talloc_free                     ta_free
  ------------------
  116|  8.00k|    return r >= 0;
  117|  8.00k|}
mp_aframe_from_avframe:
  123|   423k|{
  124|   423k|    if (!av_frame || av_frame->width > 0 || av_frame->height > 0)
  ------------------
  |  Branch (124:9): [True: 0, False: 423k]
  |  Branch (124:22): [True: 0, False: 423k]
  |  Branch (124:45): [True: 0, False: 423k]
  ------------------
  125|      0|        return NULL;
  126|       |
  127|   423k|    if (!av_channel_layout_check(&av_frame->ch_layout))
  ------------------
  |  Branch (127:9): [True: 0, False: 423k]
  ------------------
  128|      0|        return NULL;
  129|       |
  130|   423k|    struct mp_chmap converted_map = { 0 };
  131|   423k|    if (!mp_chmap_from_av_layout(&converted_map, &av_frame->ch_layout)) {
  ------------------
  |  Branch (131:9): [True: 0, False: 423k]
  ------------------
  132|      0|        return NULL;
  133|      0|    }
  134|       |
  135|   423k|    int format = af_from_avformat(av_frame->format);
  136|   423k|    if (!format && av_frame->format != AV_SAMPLE_FMT_NONE)
  ------------------
  |  Branch (136:9): [True: 0, False: 423k]
  |  Branch (136:20): [True: 0, False: 0]
  ------------------
  137|      0|        return NULL;
  138|       |
  139|   423k|    struct mp_aframe *frame = mp_aframe_create();
  140|       |
  141|       |    // This also takes care of forcing refcounting.
  142|   423k|    if (av_frame_ref(frame->av_frame, av_frame) < 0)
  ------------------
  |  Branch (142:9): [True: 0, False: 423k]
  ------------------
  143|      0|        abort();
  144|       |
  145|   423k|    frame->format = format;
  146|   423k|    frame->chmap = converted_map;
  147|       |
  148|   423k|    if (av_frame->opaque_ref) {
  ------------------
  |  Branch (148:9): [True: 0, False: 423k]
  ------------------
  149|      0|        struct avframe_opaque *op = (void *)av_frame->opaque_ref->data;
  150|      0|        frame->speed = op->speed;
  151|      0|    }
  152|       |
  153|   423k|    return frame;
  154|   423k|}
mp_aframe_is_allocated:
  198|  1.39M|{
  199|  1.39M|    return frame->av_frame->buf[0] || frame->av_frame->extended_data[0];
  ------------------
  |  Branch (199:12): [True: 1.35M, False: 44.5k]
  |  Branch (199:39): [True: 0, False: 44.5k]
  ------------------
  200|  1.39M|}
mp_aframe_config_copy:
  204|  67.4k|{
  205|  67.4k|    mp_aframe_reset(dst);
  206|       |
  207|  67.4k|    dst->chmap = src->chmap;
  208|  67.4k|    dst->format = src->format;
  209|       |
  210|  67.4k|    mp_aframe_copy_attributes(dst, src);
  211|       |
  212|  67.4k|    dst->av_frame->sample_rate = src->av_frame->sample_rate;
  213|  67.4k|    dst->av_frame->format = src->av_frame->format;
  214|       |
  215|  67.4k|    if (av_channel_layout_copy(&dst->av_frame->ch_layout, &src->av_frame->ch_layout) < 0)
  ------------------
  |  Branch (215:9): [True: 0, False: 67.4k]
  ------------------
  216|      0|        abort();
  217|  67.4k|}
mp_aframe_copy_attributes:
  222|  67.4k|{
  223|  67.4k|    dst->pts = src->pts;
  224|  67.4k|    dst->speed = src->speed;
  225|       |
  226|  67.4k|    int rate = dst->av_frame->sample_rate;
  227|       |
  228|  67.4k|    if (av_frame_copy_props(dst->av_frame, src->av_frame) < 0)
  ------------------
  |  Branch (228:9): [True: 0, False: 67.4k]
  ------------------
  229|      0|        abort();
  230|       |
  231|  67.4k|    dst->av_frame->sample_rate = rate;
  232|  67.4k|}
mp_aframe_config_equals:
  237|  1.68M|{
  238|  1.68M|    struct mp_chmap ca = {0}, cb = {0};
  239|  1.68M|    mp_aframe_get_chmap(a, &ca);
  240|  1.68M|    mp_aframe_get_chmap(b, &cb);
  241|  1.68M|    return mp_chmap_equals(&ca, &cb) &&
  ------------------
  |  Branch (241:12): [True: 1.65M, False: 33.1k]
  ------------------
  242|  1.65M|           mp_aframe_get_rate(a) == mp_aframe_get_rate(b) &&
  ------------------
  |  Branch (242:12): [True: 1.65M, False: 1.35k]
  ------------------
  243|  1.65M|           mp_aframe_get_format(a) == mp_aframe_get_format(b);
  ------------------
  |  Branch (243:12): [True: 1.65M, False: 0]
  ------------------
  244|  1.68M|}
mp_aframe_config_is_valid:
  248|  8.55k|{
  249|  8.55k|    return frame->format && frame->chmap.num && frame->av_frame->sample_rate;
  ------------------
  |  Branch (249:12): [True: 8.55k, False: 0]
  |  Branch (249:29): [True: 8.55k, False: 0]
  |  Branch (249:49): [True: 8.55k, False: 0]
  ------------------
  250|  8.55k|}
mp_aframe_get_data_ro:
  256|   378k|{
  257|   378k|    return mp_aframe_is_allocated(frame) ? frame->av_frame->extended_data : NULL;
  ------------------
  |  Branch (257:12): [True: 378k, False: 0]
  ------------------
  258|   378k|}
mp_aframe_get_data_rw:
  263|   973k|{
  264|   973k|    if (!mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (264:9): [True: 0, False: 973k]
  ------------------
  265|      0|        return NULL;
  266|   973k|    if (av_frame_make_writable(frame->av_frame) < 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 973k]
  ------------------
  267|      0|        return NULL;
  268|   973k|    return frame->av_frame->extended_data;
  269|   973k|}
mp_aframe_get_format:
  272|  7.62M|{
  273|  7.62M|    return frame->format;
  274|  7.62M|}
mp_aframe_get_chmap:
  277|  3.81M|{
  278|  3.81M|    if (!mp_chmap_is_valid(&frame->chmap))
  ------------------
  |  Branch (278:9): [True: 26.5k, False: 3.78M]
  ------------------
  279|  26.5k|        return false;
  280|  3.78M|    *out = frame->chmap;
  281|       |    return true;
  282|  3.81M|}
mp_aframe_get_channels:
  285|  1.56M|{
  286|  1.56M|    return frame->chmap.num;
  287|  1.56M|}
mp_aframe_get_rate:
  290|  7.45M|{
  291|  7.45M|    return frame->av_frame->sample_rate;
  292|  7.45M|}
mp_aframe_get_size:
  295|  4.57M|{
  296|  4.57M|    return frame->av_frame->nb_samples;
  297|  4.57M|}
mp_aframe_get_pts:
  300|  4.21M|{
  301|  4.21M|    return frame->pts;
  302|  4.21M|}
mp_aframe_set_format:
  305|  9.97k|{
  306|  9.97k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (306:9): [True: 0, False: 9.97k]
  ------------------
  307|      0|        return false;
  308|  9.97k|    enum AVSampleFormat av_format = af_to_avformat(format);
  309|  9.97k|    if (av_format == AV_SAMPLE_FMT_NONE && format) {
  ------------------
  |  Branch (309:9): [True: 0, False: 9.97k]
  |  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|  9.97k|    frame->format = format;
  316|  9.97k|    frame->av_frame->format = av_format;
  317|       |    return true;
  318|  9.97k|}
mp_aframe_set_chmap:
  321|  8.06k|{
  322|  8.06k|    if (!mp_chmap_is_valid(in) && !mp_chmap_is_empty(in))
  ------------------
  |  Branch (322:9): [True: 0, False: 8.06k]
  |  Branch (322:35): [True: 0, False: 0]
  ------------------
  323|      0|        return false;
  324|  8.06k|    if (mp_aframe_is_allocated(frame) && in->num != frame->chmap.num)
  ------------------
  |  Branch (324:9): [True: 0, False: 8.06k]
  |  Branch (324:42): [True: 0, False: 0]
  ------------------
  325|      0|        return false;
  326|       |
  327|  8.06k|    frame->chmap = *in;
  328|  8.06k|    mp_chmap_to_av_layout(&frame->av_frame->ch_layout, in);
  329|       |
  330|       |    return true;
  331|  8.06k|}
mp_aframe_set_rate:
  334|  8.06k|{
  335|  8.06k|    if (rate < 1 || rate > 10000000)
  ------------------
  |  Branch (335:9): [True: 0, False: 8.06k]
  |  Branch (335:21): [True: 58, False: 8.00k]
  ------------------
  336|     58|        return false;
  337|  8.00k|    frame->av_frame->sample_rate = rate;
  338|       |    return true;
  339|  8.06k|}
mp_aframe_set_pts:
  350|   844k|{
  351|   844k|    frame->pts = pts;
  352|   844k|}
mp_aframe_get_effective_rate:
  381|  3.30M|{
  382|  3.30M|    return mp_aframe_get_rate(frame) / frame->speed;
  383|  3.30M|}
mp_aframe_get_planes:
  387|  1.56M|{
  388|  1.56M|    return af_fmt_is_planar(mp_aframe_get_format(frame))
  ------------------
  |  Branch (388:12): [True: 1.34M, False: 220k]
  ------------------
  389|  1.56M|           ? mp_aframe_get_channels(frame) : 1;
  390|  1.56M|}
mp_aframe_get_sstride:
  394|  1.15M|{
  395|  1.15M|    int format = mp_aframe_get_format(frame);
  396|  1.15M|    return af_fmt_to_bytes(format) *
  397|  1.15M|           (af_fmt_is_planar(format) ? 1 : mp_aframe_get_channels(frame));
  ------------------
  |  Branch (397:13): [True: 990k, False: 168k]
  ------------------
  398|  1.15M|}
mp_aframe_get_total_plane_samples:
  402|   717k|{
  403|   717k|    return frame->av_frame->nb_samples *
  404|   717k|           (af_fmt_is_planar(mp_aframe_get_format(frame))
  ------------------
  |  Branch (404:13): [True: 665k, False: 51.7k]
  ------------------
  405|   717k|            ? 1 : mp_aframe_get_channels(frame));
  406|   717k|}
mp_aframe_format_str_buf:
  409|  32.5k|{
  410|  32.5k|    char ch[128];
  411|  32.5k|    mp_chmap_to_str_buf(ch, sizeof(ch), &fmt->chmap);
  412|  32.5k|    char *hr_ch = mp_chmap_to_str_hr(&fmt->chmap);
  ------------------
  |  |  153|  32.5k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  32.5k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  413|  32.5k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (413:9): [True: 327, False: 32.2k]
  ------------------
  414|    327|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  415|  32.5k|    snprintf(buf, buf_size, "%dHz %s %dch %s", fmt->av_frame->sample_rate,
  416|  32.5k|             ch, fmt->chmap.num, af_fmt_to_str(fmt->format));
  417|  32.5k|    return buf;
  418|  32.5k|}
mp_aframe_skip_samples:
  422|   379k|{
  423|   379k|    mp_assert(samples >= 0 && samples <= mp_aframe_get_size(f));
  ------------------
  |  |   41|   379k|#define mp_assert assert
  ------------------
  |  Branch (423:5): [True: 379k, False: 0]
  |  Branch (423:5): [True: 379k, False: 0]
  ------------------
  424|       |
  425|   379k|    if (av_frame_make_writable(f->av_frame) < 0)
  ------------------
  |  Branch (425:9): [True: 0, False: 379k]
  ------------------
  426|      0|        return; // go complain to ffmpeg
  427|       |
  428|   379k|    int num_planes = mp_aframe_get_planes(f);
  429|   379k|    size_t sstride = mp_aframe_get_sstride(f);
  430|  1.06M|    for (int n = 0; n < num_planes; n++) {
  ------------------
  |  Branch (430:21): [True: 689k, False: 379k]
  ------------------
  431|   689k|        memmove(f->av_frame->extended_data[n],
  432|   689k|                f->av_frame->extended_data[n] + samples * sstride,
  433|   689k|                (f->av_frame->nb_samples - samples) * sstride);
  434|   689k|    }
  435|       |
  436|   379k|    f->av_frame->nb_samples -= samples;
  437|       |
  438|   379k|    if (f->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   379k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (438:9): [True: 377k, False: 2.46k]
  ------------------
  439|   377k|        f->pts += samples / mp_aframe_get_effective_rate(f);
  440|   379k|}
mp_aframe_sanitize_float:
  449|   423k|{
  450|   423k|    int format = af_fmt_from_planar(mp_aframe_get_format(mpa));
  451|   423k|    if (format != AF_FORMAT_FLOAT && format != AF_FORMAT_DOUBLE)
  ------------------
  |  Branch (451:9): [True: 13.8k, False: 409k]
  |  Branch (451:38): [True: 13.8k, False: 0]
  ------------------
  452|  13.8k|        return;
  453|   409k|    int num_planes = mp_aframe_get_planes(mpa);
  454|   409k|    uint8_t **planes = mp_aframe_get_data_rw(mpa);
  455|   409k|    if (!planes)
  ------------------
  |  Branch (455:9): [True: 0, False: 409k]
  ------------------
  456|      0|        return;
  457|  1.12M|    for (int p = 0; p < num_planes; p++) {
  ------------------
  |  Branch (457:21): [True: 717k, False: 409k]
  ------------------
  458|   717k|        void *ptr = planes[p];
  459|   717k|        int total = mp_aframe_get_total_plane_samples(mpa);
  460|   717k|        switch (format) {
  ------------------
  |  Branch (460:17): [True: 717k, False: 0]
  ------------------
  461|   717k|        case AF_FORMAT_FLOAT:
  ------------------
  |  Branch (461:9): [True: 717k, False: 0]
  ------------------
  462|   550M|            for (int s = 0; s < total; s++)
  ------------------
  |  Branch (462:29): [True: 549M, False: 717k]
  ------------------
  463|   549M|                sanitizef(((float *)ptr)[s]);
  ------------------
  |  |  443|   550M|#define sanitizef(f) do {       \
  |  |  444|   549M|    if (!isnormal(f))           \
  |  |  ------------------
  |  |  |  Branch (444:9): [True: 178M, False: 371M]
  |  |  ------------------
  |  |  445|   549M|        (f) = 0;                \
  |  |  446|   549M|} while (0)
  |  |  ------------------
  |  |  |  Branch (446:10): [Folded, False: 549M]
  |  |  ------------------
  ------------------
  464|   717k|            break;
  465|      0|        case AF_FORMAT_DOUBLE:
  ------------------
  |  Branch (465:9): [True: 0, False: 717k]
  ------------------
  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|   717k|        }
  470|   717k|    }
  471|   409k|}
mp_aframe_end_pts:
  475|  1.66M|{
  476|  1.66M|    double rate = mp_aframe_get_effective_rate(f);
  477|  1.66M|    if (f->pts == MP_NOPTS_VALUE || rate <= 0)
  ------------------
  |  |   39|  3.32M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (477:9): [True: 9.55k, False: 1.65M]
  |  Branch (477:37): [True: 0, False: 1.65M]
  ------------------
  478|  9.55k|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.55k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  479|  1.65M|    return f->pts + f->av_frame->nb_samples / rate;
  480|  1.66M|}
mp_aframe_duration:
  484|   421k|{
  485|   421k|    double rate = mp_aframe_get_effective_rate(f);
  486|   421k|    if (rate <= 0)
  ------------------
  |  Branch (486:9): [True: 0, False: 421k]
  ------------------
  487|      0|        return 0;
  488|   421k|    return f->av_frame->nb_samples / rate;
  489|   421k|}
mp_aframe_clip_timestamps:
  495|   844k|{
  496|   844k|    double f_end = mp_aframe_end_pts(f);
  497|   844k|    double rate = mp_aframe_get_effective_rate(f);
  498|   844k|    if (f_end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   844k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (498:9): [True: 4.77k, False: 839k]
  ------------------
  499|  4.77k|        return;
  500|   839k|    if (end != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   839k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (500:9): [True: 2.40k, False: 837k]
  ------------------
  501|  2.40k|        if (f_end >= end) {
  ------------------
  |  Branch (501:13): [True: 0, False: 2.40k]
  ------------------
  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|  2.40k|    }
  512|   839k|    if (start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   839k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (512:9): [True: 48.6k, False: 791k]
  ------------------
  513|  48.6k|        if (f->pts < start) {
  ------------------
  |  Branch (513:13): [True: 26.4k, False: 22.2k]
  ------------------
  514|  26.4k|            if (f_end <= start) {
  ------------------
  |  Branch (514:17): [True: 25.6k, False: 819]
  ------------------
  515|  25.6k|                f->av_frame->nb_samples = 0;
  516|  25.6k|                f->pts = f_end;
  517|  25.6k|            } else {
  518|    819|                if (!af_fmt_is_pcm(mp_aframe_get_format(f)))
  ------------------
  |  Branch (518:21): [True: 0, False: 819]
  ------------------
  519|      0|                    return;
  520|    819|                int skip = (start - f->pts) * rate;
  521|    819|                skip = MPCLAMP(skip, 0, f->av_frame->nb_samples);
  ------------------
  |  |   46|    819|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 819]
  |  |  |  Branch (46:56): [True: 0, False: 819]
  |  |  ------------------
  ------------------
  522|    819|                mp_aframe_skip_samples(f, skip);
  523|    819|            }
  524|  26.4k|        }
  525|  48.6k|    }
  526|   839k|}
mp_aframe_approx_byte_size:
  614|   770k|{
  615|       |    // God damn, AVFrame is too fucking annoying. Just go with the size that
  616|       |    // allocating a new frame would use.
  617|   770k|    int planes = mp_aframe_get_planes(frame);
  618|   770k|    size_t sstride = mp_aframe_get_sstride(frame);
  619|   770k|    int samples = frame->av_frame->nb_samples;
  620|   770k|    int plane_size = MP_ALIGN_UP(sstride * MPMAX(samples, 1), 32);
  ------------------
  |  |   53|  1.54M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 770k, False: 380]
  |  |  ------------------
  ------------------
  621|   770k|    return plane_size * planes + sizeof(*frame);
  622|   770k|}
mp_aframe_pool_create:
  630|  8.00k|{
  631|  8.00k|    return talloc_zero(ta_parent, struct mp_aframe_pool);
  ------------------
  |  |   27|  8.00k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  8.00k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.00k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|  8.00k|}
mp_aframe_pool_allocate:
  643|  8.00k|{
  644|  8.00k|    int planes = mp_aframe_get_planes(frame);
  645|  8.00k|    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|  8.00k|    int align_samples = MP_ALIGN_UP(MPMAX(samples, 1), 32);
  ------------------
  |  |   53|  16.0k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 8.00k, False: 0]
  |  |  ------------------
  ------------------
  650|  8.00k|    int plane_size = MP_ALIGN_UP(sstride * align_samples, 64);
  ------------------
  |  |   53|  8.00k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  651|  8.00k|    int size = plane_size * planes;
  652|       |
  653|  8.00k|    if (size <= 0 || mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (653:9): [True: 0, False: 8.00k]
  |  Branch (653:22): [True: 0, False: 8.00k]
  ------------------
  654|      0|        return -1;
  655|       |
  656|  8.00k|    if (!pool->avpool || size > pool->element_size) {
  ------------------
  |  Branch (656:9): [True: 8.00k, False: 0]
  |  Branch (656:26): [True: 0, False: 0]
  ------------------
  657|  8.00k|        size_t alloc = ta_calc_prealloc_elems(size);
  658|  8.00k|        if (alloc >= INT_MAX)
  ------------------
  |  Branch (658:13): [True: 0, False: 8.00k]
  ------------------
  659|      0|            return -1;
  660|  8.00k|        av_buffer_pool_uninit(&pool->avpool);
  661|  8.00k|        pool->element_size = alloc;
  662|  8.00k|        pool->avpool = av_buffer_pool_init(pool->element_size, NULL);
  663|  8.00k|        if (!pool->avpool)
  ------------------
  |  Branch (663:13): [True: 0, False: 8.00k]
  ------------------
  664|      0|            return -1;
  665|  8.00k|        talloc_set_destructor(pool, mp_aframe_pool_destructor);
  ------------------
  |  |   41|  8.00k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  666|  8.00k|    }
  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|  8.00k|    AVFrame *av_frame = frame->av_frame;
  672|  8.00k|    if (av_frame->extended_data != av_frame->data)
  ------------------
  |  Branch (672:9): [True: 0, False: 8.00k]
  ------------------
  673|      0|        av_freep(&av_frame->extended_data); // sigh
  674|  8.00k|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (674:9): [True: 86, False: 7.92k]
  ------------------
  675|     86|        av_frame->extended_data =
  676|     86|            av_calloc(planes, sizeof(av_frame->extended_data[0]));
  677|     86|        MP_HANDLE_OOM(av_frame->extended_data);
  ------------------
  |  |  206|     86|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|     86|        void *oom_p_ = (x);     \
  |  |  208|     86|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 86]
  |  |  ------------------
  |  |  209|     86|            abort();            \
  |  |  210|     86|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 86]
  |  |  ------------------
  ------------------
  678|  7.92k|    } else {
  679|  7.92k|        av_frame->extended_data = av_frame->data;
  680|  7.92k|    }
  681|  8.00k|    av_frame->buf[0] = av_buffer_pool_get(pool->avpool);
  682|  8.00k|    if (!av_frame->buf[0])
  ------------------
  |  Branch (682:9): [True: 0, False: 8.00k]
  ------------------
  683|      0|        return -1;
  684|  8.00k|    av_frame->linesize[0] = samples * sstride;
  685|  29.0k|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (685:21): [True: 20.9k, False: 8.00k]
  ------------------
  686|  20.9k|        av_frame->extended_data[n] = av_frame->buf[0]->data + n * plane_size;
  687|  8.00k|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (687:9): [True: 86, False: 7.92k]
  ------------------
  688|    774|        for (int n = 0; n < AV_NUM_DATA_POINTERS; n++)
  ------------------
  |  Branch (688:25): [True: 688, False: 86]
  ------------------
  689|    688|            av_frame->data[n] = av_frame->extended_data[n];
  690|     86|    }
  691|  8.00k|    av_frame->nb_samples = samples;
  692|       |
  693|  8.00k|    return 0;
  694|  8.00k|}
aframe.c:free_frame:
   47|   698k|{
   48|   698k|    struct mp_aframe *frame = ptr;
   49|   698k|    av_frame_free(&frame->av_frame);
   50|   698k|}
aframe.c:mp_aframe_pool_destructor:
  635|  8.00k|{
  636|  8.00k|    struct mp_aframe_pool *pool = p;
  637|  8.00k|    av_buffer_pool_uninit(&pool->avpool);
  638|  8.00k|}

mp_chmap_is_valid:
  126|  3.91M|{
  127|  3.91M|    bool mapped[MP_SPEAKER_ID_COUNT] = {0};
  128|  10.7M|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (128:21): [True: 6.81M, False: 3.91M]
  ------------------
  129|  6.81M|        int sp = src->speaker[n];
  130|  6.81M|        if (sp >= MP_SPEAKER_ID_COUNT || mapped[sp])
  ------------------
  |  Branch (130:13): [True: 18.4E, False: 6.81M]
  |  Branch (130:42): [True: 18.4E, False: 6.81M]
  ------------------
  131|      0|            return false;
  132|  6.81M|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (132:13): [True: 6.49M, False: 322k]
  ------------------
  133|  6.49M|            mapped[sp] = true;
  134|  6.81M|    }
  135|  3.91M|    return src->num > 0;
  136|  3.91M|}
mp_chmap_is_unknown:
  146|   157k|{
  147|   217k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (147:21): [True: 179k, False: 37.5k]
  ------------------
  148|   179k|        if (src->speaker[n] != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (148:13): [True: 120k, False: 59.2k]
  ------------------
  149|   120k|            return false;
  150|   179k|    }
  151|  37.5k|    return mp_chmap_is_valid(src);
  152|   157k|}
mp_chmap_equals:
  156|  2.37M|{
  157|  2.37M|    if (a->num != b->num)
  ------------------
  |  Branch (157:9): [True: 237k, False: 2.13M]
  ------------------
  158|   237k|        return false;
  159|  5.89M|    for (int n = 0; n < a->num; n++) {
  ------------------
  |  Branch (159:21): [True: 3.76M, False: 2.12M]
  ------------------
  160|  3.76M|        if (a->speaker[n] != b->speaker[n])
  ------------------
  |  Branch (160:13): [True: 10.5k, False: 3.75M]
  ------------------
  161|  10.5k|            return false;
  162|  3.76M|    }
  163|  2.12M|    return true;
  164|  2.13M|}
mp_chmap_equals_reordered:
  168|   261k|{
  169|   261k|    struct mp_chmap t1 = *a, t2 = *b;
  170|   261k|    mp_chmap_reorder_norm(&t1);
  171|   261k|    mp_chmap_reorder_norm(&t2);
  172|   261k|    return mp_chmap_equals(&t1, &t2);
  173|   261k|}
mp_chmap_reorder_norm:
  189|   522k|{
  190|   522k|    uint8_t *arr = &map->speaker[0];
  191|   522k|    qsort(arr, map->num, 1, comp_uint8);
  192|   522k|}
mp_chmap_remove_na:
  196|  40.6k|{
  197|  40.6k|    struct mp_chmap new = {0};
  198|   148k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (198:21): [True: 108k, False: 40.6k]
  ------------------
  199|   108k|        int sp = map->speaker[n];
  200|   108k|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (200:13): [True: 96.3k, False: 11.9k]
  ------------------
  201|  96.3k|            new.speaker[new.num++] = map->speaker[n];
  202|   108k|    }
  203|  40.6k|    *map = new;
  204|  40.6k|}
mp_chmap_from_channels:
  218|   280k|{
  219|   280k|    *dst = (struct mp_chmap) {0};
  220|   280k|    if (num_channels >= 0 && num_channels < MP_ARRAY_SIZE(default_layouts))
  ------------------
  |  |   49|   280k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (220:9): [True: 280k, False: 0]
  |  Branch (220:30): [True: 277k, False: 2.92k]
  ------------------
  221|   277k|        *dst = default_layouts[num_channels];
  222|   280k|    if (!dst->num)
  ------------------
  |  Branch (222:9): [True: 3.17k, False: 277k]
  ------------------
  223|  3.17k|        mp_chmap_set_unknown(dst, num_channels);
  224|   280k|}
mp_chmap_set_unknown:
  232|  20.5k|{
  233|  20.5k|    if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  20.5k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (233:9): [True: 2, False: 20.5k]
  |  Branch (233:29): [True: 199, False: 20.3k]
  ------------------
  234|    201|        *dst = (struct mp_chmap) {0};
  235|  20.3k|    } else {
  236|  20.3k|        dst->num = num_channels;
  237|   130k|        for (int n = 0; n < dst->num; n++)
  ------------------
  |  Branch (237:25): [True: 110k, False: 20.3k]
  ------------------
  238|   110k|            dst->speaker[n] = MP_SPEAKER_ID_NA;
  239|  20.3k|    }
  240|  20.5k|}
mp_chmap_to_lavc_unchecked:
  249|  7.98k|{
  250|  7.98k|    struct mp_chmap t = *src;
  251|  7.98k|    if (t.num > 64)
  ------------------
  |  Branch (251:9): [True: 0, False: 7.98k]
  ------------------
  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.98k|    if (mp_chmap_is_unknown(&t))
  ------------------
  |  Branch (256:9): [True: 0, False: 7.98k]
  ------------------
  257|      0|        return t.num == 64 ? (uint64_t)-1 : (1ULL << t.num) - 1;
  ------------------
  |  Branch (257:16): [True: 0, False: 0]
  ------------------
  258|  7.98k|    uint64_t mask = 0;
  259|  27.0k|    for (int n = 0; n < t.num; n++) {
  ------------------
  |  Branch (259:21): [True: 19.0k, False: 7.98k]
  ------------------
  260|  19.0k|        if (t.speaker[n] < 64) // ignore MP_SPEAKER_ID_NA etc.
  ------------------
  |  Branch (260:13): [True: 19.0k, False: 0]
  ------------------
  261|  19.0k|            mask |= 1ULL << t.speaker[n];
  262|  19.0k|    }
  263|  7.98k|    return mask;
  264|  7.98k|}
mp_chmap_to_lavc:
  269|  30.8k|{
  270|  30.8k|    if (!mp_chmap_is_lavc(src))
  ------------------
  |  Branch (270:9): [True: 22.8k, False: 7.98k]
  ------------------
  271|  22.8k|        return 0;
  272|  7.98k|    return mp_chmap_to_lavc_unchecked(src);
  273|  30.8k|}
mp_chmap_from_lavc:
  279|   579k|{
  280|   579k|    dst->num = 0;
  281|  37.6M|    for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (281:21): [True: 37.0M, False: 579k]
  ------------------
  282|  37.0M|        if (src & (1ULL << n)) {
  ------------------
  |  Branch (282:13): [True: 937k, False: 36.1M]
  ------------------
  283|   937k|            if (dst->num >= MP_NUM_CHANNELS) {
  ------------------
  |  |   25|   937k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (283:17): [True: 0, False: 937k]
  ------------------
  284|      0|                dst->num = 0;
  285|      0|                return;
  286|      0|            }
  287|   937k|            dst->speaker[dst->num] = n;
  288|   937k|            dst->num++;
  289|   937k|        }
  290|  37.0M|    }
  291|   579k|}
mp_chmap_is_lavc:
  294|  30.8k|{
  295|  30.8k|    if (!mp_chmap_is_valid(src))
  ------------------
  |  Branch (295:9): [True: 22.8k, False: 7.98k]
  ------------------
  296|  22.8k|        return false;
  297|  7.98k|    if (mp_chmap_is_unknown(src))
  ------------------
  |  Branch (297:9): [True: 0, False: 7.98k]
  ------------------
  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.98k|    mp_assert(src->num > 0);
  ------------------
  |  |   41|  7.98k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 7.98k, False: 0]
  ------------------
  302|  19.0k|    for (int n = 1; n < src->num; n++) {
  ------------------
  |  Branch (302:21): [True: 11.0k, False: 7.98k]
  ------------------
  303|  11.0k|        if (src->speaker[n - 1] >= src->speaker[n])
  ------------------
  |  Branch (303:13): [True: 0, False: 11.0k]
  ------------------
  304|      0|            return false;
  305|  11.0k|    }
  306|  27.0k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (306:21): [True: 19.0k, False: 7.98k]
  ------------------
  307|  19.0k|        if (src->speaker[n] >= 64)
  ------------------
  |  Branch (307:13): [True: 0, False: 19.0k]
  ------------------
  308|      0|            return false;
  309|  19.0k|    }
  310|  7.98k|    return true;
  311|  7.98k|}
mp_chmap_to_str_buf:
  368|  97.4k|{
  369|  97.4k|    buf[0] = '\0';
  370|       |
  371|  97.4k|    if (mp_chmap_is_unknown(src)) {
  ------------------
  |  Branch (371:9): [True: 573, False: 96.9k]
  ------------------
  372|    573|        snprintf(buf, buf_size, "unknown%d", src->num);
  373|    573|        return buf;
  374|    573|    }
  375|       |
  376|   327k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (376:21): [True: 230k, False: 96.9k]
  ------------------
  377|   230k|        int sp = src->speaker[n];
  378|   230k|        const char *s = sp < MP_SPEAKER_ID_COUNT ? speaker_names[sp][0] : NULL;
  ------------------
  |  Branch (378:25): [True: 230k, False: 0]
  ------------------
  379|   230k|        char sp_buf[10];
  380|   230k|        if (!s) {
  ------------------
  |  Branch (380:13): [True: 300, False: 230k]
  ------------------
  381|    300|            snprintf(sp_buf, sizeof(sp_buf), "sp%d", sp);
  382|    300|            s = sp_buf;
  383|    300|        }
  384|   230k|        mp_snprintf_cat(buf, buf_size, "%s%s", n > 0 ? "-" : "", s);
  ------------------
  |  Branch (384:48): [True: 134k, False: 96.5k]
  ------------------
  385|   230k|    }
  386|       |
  387|       |    // To standard layout name
  388|   607k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (388:21): [True: 605k, False: 1.83k]
  ------------------
  389|   605k|        if (strcmp(buf, std_layout_names[n][1]) == 0) {
  ------------------
  |  Branch (389:13): [True: 95.0k, False: 510k]
  ------------------
  390|  95.0k|            snprintf(buf, buf_size, "%s", std_layout_names[n][0]);
  391|  95.0k|            break;
  392|  95.0k|        }
  393|   605k|    }
  394|       |
  395|  96.9k|    return buf;
  396|  97.4k|}
mp_chmap_from_str:
  403|   253k|{
  404|       |    // Single number corresponds to mp_chmap_from_channels()
  405|   253k|    if (src.len > 0) {
  ------------------
  |  Branch (405:9): [True: 253k, False: 0]
  ------------------
  406|   253k|        bstr t = src;
  407|   253k|        bool unknown = bstr_eatstart0(&t, "unknown");
  408|   253k|        bstr rest;
  409|   253k|        long long count = bstrtoll(t, &rest, 10);
  410|   253k|        if (rest.len == 0) {
  ------------------
  |  Branch (410:13): [True: 0, False: 253k]
  ------------------
  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|   253k|    }
  423|       |
  424|       |    // From standard layout name
  425|  1.92M|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (425:21): [True: 1.92M, False: 0]
  ------------------
  426|  1.92M|        if (bstr_equals0(src, std_layout_names[n][0])) {
  ------------------
  |  Branch (426:13): [True: 253k, False: 1.66M]
  ------------------
  427|   253k|            src = bstr0(std_layout_names[n][1]);
  428|   253k|            break;
  429|   253k|        }
  430|  1.92M|    }
  431|       |
  432|       |    // Explicit speaker list (separated by "-")
  433|   253k|    struct mp_chmap res = {0};
  434|   874k|    while (src.len) {
  ------------------
  |  Branch (434:12): [True: 621k, False: 253k]
  ------------------
  435|   621k|        bstr s;
  436|   621k|        bstr_split_tok(src, "-", &s, &src);
  437|   621k|        int speaker = -1;
  438|  2.72M|        for (int n = 0; n < MP_SPEAKER_ID_COUNT; n++) {
  ------------------
  |  Branch (438:25): [True: 2.72M, False: 0]
  ------------------
  439|  2.72M|            const char *name = speaker_names[n][0];
  440|  2.72M|            if (name && bstr_equals0(s, name)) {
  ------------------
  |  Branch (440:17): [True: 2.62M, False: 106k]
  |  Branch (440:25): [True: 621k, False: 1.99M]
  ------------------
  441|   621k|                speaker = n;
  442|   621k|                break;
  443|   621k|            }
  444|  2.72M|        }
  445|   621k|        if (speaker < 0) {
  ------------------
  |  Branch (445:13): [True: 0, False: 621k]
  ------------------
  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|   621k|        if (res.num >= MP_NUM_CHANNELS)
  ------------------
  |  |   25|   621k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (454:13): [True: 0, False: 621k]
  ------------------
  455|      0|            return false;
  456|   621k|        res.speaker[res.num] = speaker;
  457|   621k|        res.num++;
  458|   621k|    }
  459|       |
  460|   253k|    *dst = res;
  461|       |    return true;
  462|   253k|}
mp_chmap_to_str_hr_buf:
  468|  40.6k|{
  469|  40.6k|    struct mp_chmap map = *src;
  470|  40.6k|    mp_chmap_remove_na(&map);
  471|   253k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (471:21): [True: 253k, False: 770]
  ------------------
  472|   253k|        struct mp_chmap s;
  473|   253k|        if (mp_chmap_from_str(&s, bstr0(std_layout_names[n][0])) &&
  ------------------
  |  Branch (473:13): [True: 253k, False: 0]
  ------------------
  474|   253k|            mp_chmap_equals_reordered(&s, &map))
  ------------------
  |  Branch (474:13): [True: 39.8k, False: 213k]
  ------------------
  475|  39.8k|        {
  476|  39.8k|            map = s;
  477|  39.8k|            break;
  478|  39.8k|        }
  479|   253k|    }
  480|  40.6k|    return mp_chmap_to_str_buf(buf, buf_size, &map);
  481|  40.6k|}
chmap.c:comp_uint8:
  182|  1.44M|{
  183|  1.44M|    return *(const uint8_t *)a - *(const uint8_t *)b;
  184|  1.44M|}

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

mp_chmap_sel_add_any:
   88|  8.07k|{
   89|       |    s->allow_any = true;
   90|  8.07k|}
mp_chmap_sel_add_map:
  100|  8.07k|{
  101|  8.07k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (101:9): [True: 0, False: 8.07k]
  ------------------
  102|      0|        return;
  103|  8.07k|    if (!s->chmaps)
  ------------------
  |  Branch (103:9): [True: 8.07k, False: 0]
  ------------------
  104|  8.07k|        s->chmaps = s->chmaps_storage;
  105|  8.07k|    if (s->num_chmaps == MP_ARRAY_SIZE(s->chmaps_storage)) {
  ------------------
  |  |   49|  8.07k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (105:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    if (s->chmaps != s->chmaps_storage)
  ------------------
  |  Branch (110:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    s->chmaps[s->num_chmaps++] = *map;
  113|  8.07k|}
mp_chmap_sel_adjust:
  182|  16.0k|{
  183|  16.0k|    if (test_layout(s, map))
  ------------------
  |  Branch (183:9): [True: 16.0k, False: 0]
  ------------------
  184|  16.0k|        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|  8.07k|{
  310|  8.07k|    struct mp_chmap best = {0};
  311|       |
  312|  8.07k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (312:21): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    if (best.num) {
  ------------------
  |  Branch (322:9): [True: 0, False: 8.07k]
  ------------------
  323|      0|        *map = best;
  324|      0|        return true;
  325|      0|    }
  326|       |
  327|  8.07k|    return false;
  328|  8.07k|}
mp_chmal_sel_log:
  359|  8.07k|{
  360|  8.07k|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (360:9): [True: 0, False: 8.07k]
  ------------------
  361|      0|        return;
  362|       |
  363|  8.07k|    for (int i = 0; i < s->num_chmaps; i++)
  ------------------
  |  Branch (363:21): [True: 0, False: 8.07k]
  ------------------
  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|   532k|    for (int i = 0; i < MP_SPEAKER_ID_COUNT; i++) {
  ------------------
  |  Branch (365:21): [True: 524k, False: 8.07k]
  ------------------
  366|   524k|        if (!s->speakers[i])
  ------------------
  |  Branch (366:13): [True: 524k, False: 0]
  ------------------
  367|   524k|            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|  8.07k|    if (s->allow_waveext)
  ------------------
  |  Branch (372:9): [True: 0, False: 8.07k]
  ------------------
  373|      0|        mp_msg(log, lev, " - waveext\n");
  374|  8.07k|    if (s->allow_any)
  ------------------
  |  Branch (374:9): [True: 8.07k, False: 0]
  ------------------
  375|  8.07k|        mp_msg(log, lev, " - anything\n");
  376|  8.07k|}
mp_chmap_sel_list:
  381|  8.07k|{
  382|       |    // This is a separate function to keep messing with mp_chmap_sel internals
  383|       |    // within this source file.
  384|  8.07k|    struct mp_chmap_sel sel = {
  385|  8.07k|        .chmaps = maps,
  386|  8.07k|        .num_chmaps = num_maps,
  387|  8.07k|    };
  388|  8.07k|    mp_chmap_sel_fallback(&sel, c);
  389|  8.07k|}
chmap_sel.c:test_layout:
  167|  16.0k|{
  168|  16.0k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (168:9): [True: 0, False: 16.0k]
  ------------------
  169|      0|        return false;
  170|       |
  171|  16.0k|    return s->allow_any || test_waveext(s, map) || test_speakers(s, map) ||
  ------------------
  |  Branch (171:12): [True: 8.07k, False: 7.99k]
  |  Branch (171:28): [True: 0, False: 7.99k]
  |  Branch (171:52): [True: 0, False: 7.99k]
  ------------------
  172|  7.99k|           test_maps(s, map);
  ------------------
  |  Branch (172:12): [True: 7.99k, False: 0]
  ------------------
  173|  16.0k|}
chmap_sel.c:test_waveext:
  154|  7.99k|{
  155|  7.99k|    if (s->allow_waveext) {
  ------------------
  |  Branch (155:9): [True: 0, False: 7.99k]
  ------------------
  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.99k|    return false;
  164|  7.99k|}
chmap_sel.c:test_speakers:
  134|  7.99k|{
  135|  7.99k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (135:21): [True: 7.99k, False: 0]
  ------------------
  136|  7.99k|        if (!s->speakers[map->speaker[n]])
  ------------------
  |  Branch (136:13): [True: 7.99k, False: 0]
  ------------------
  137|  7.99k|            return false;
  138|  7.99k|    }
  139|      0|    return true;
  140|  7.99k|}
chmap_sel.c:test_maps:
  143|  7.99k|{
  144|  7.99k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (144:21): [True: 7.99k, False: 0]
  ------------------
  145|  7.99k|        if (mp_chmap_equals_reordered(&s->chmaps[n], map)) {
  ------------------
  |  Branch (145:13): [True: 7.99k, False: 0]
  ------------------
  146|  7.99k|            *map = s->chmaps[n];
  147|  7.99k|            return true;
  148|  7.99k|        }
  149|  7.99k|    }
  150|      0|    return false;
  151|  7.99k|}

select_dsd_codec:
  260|  16.5k|{
  261|  16.5k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  16.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  16.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  16.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|  16.5k|    if (!codec)
  ------------------
  |  Branch (263:9): [True: 0, False: 16.5k]
  ------------------
  264|      0|        return list;
  265|       |
  266|  16.5k|    bool found = false;
  267|  99.5k|    for (int n = 0; n < MP_ARRAY_SIZE(dsd_codecs); n++)
  ------------------
  |  |   49|  99.5k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (267:21): [True: 82.9k, False: 16.5k]
  ------------------
  268|  82.9k|        found |= strcmp(dsd_codecs[n].codec, codec) == 0;
  269|  16.5k|    if (!found)
  ------------------
  |  Branch (269:9): [True: 16.5k, False: 0]
  ------------------
  270|  16.5k|        return list;
  271|       |
  272|      0|    bstr sel = bstr0(pref);
  273|      0|    while (sel.len) {
  ------------------
  |  Branch (273:12): [True: 0, False: 0]
  ------------------
  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|      0|    return list;
  283|  16.5k|}

ad_lavc.c:create:
  303|  14.9k|{
  304|  14.9k|    struct mp_filter *da = mp_filter_create(parent, &ad_lavc_filter);
  305|  14.9k|    if (!da)
  ------------------
  |  Branch (305:9): [True: 0, False: 14.9k]
  ------------------
  306|      0|        return NULL;
  307|       |
  308|  14.9k|    mp_filter_add_pin(da, MP_PIN_IN, "in");
  309|  14.9k|    mp_filter_add_pin(da, MP_PIN_OUT, "out");
  310|       |
  311|  14.9k|    da->log = mp_log_new(da, parent->log, NULL);
  312|       |
  313|  14.9k|    struct priv *priv = da->priv;
  314|  14.9k|    priv->codec = codec;
  315|  14.9k|    priv->public.f = da;
  316|       |
  317|  14.9k|    if (!init(da, codec, decoder)) {
  ------------------
  |  Branch (317:9): [True: 1.25k, False: 13.7k]
  ------------------
  318|  1.25k|        talloc_free(da);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
  319|  1.25k|        return NULL;
  320|  1.25k|    }
  321|       |
  322|  13.7k|    codec->codec_desc = priv->avctx->codec_descriptor->long_name;
  323|  13.7k|    mp_chmap_from_av_layout(&priv->codec->channels, &priv->avctx->ch_layout);
  324|       |
  325|  13.7k|    return &priv->public;
  326|  14.9k|}
ad_lavc.c:ad_lavc_destroy:
  163|  14.9k|{
  164|  14.9k|    struct priv *ctx = da->priv;
  165|       |
  166|  14.9k|    avcodec_free_context(&ctx->avctx);
  167|  14.9k|    av_frame_free(&ctx->avframe);
  168|  14.9k|    mp_free_av_packet(&ctx->avpkt);
  169|  14.9k|}
ad_lavc.c:ad_lavc_process:
  286|  1.22M|{
  287|  1.22M|    struct priv *priv = ad->priv;
  288|       |
  289|  1.22M|    lavc_process(ad, &priv->state, send_packet, receive_frame);
  290|  1.22M|}
ad_lavc.c:send_packet:
  184|   379k|{
  185|   379k|    struct priv *priv = da->priv;
  186|   379k|    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|   379k|    if (mpkt && priv->next_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   369k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (191:9): [True: 369k, False: 9.37k]
  |  Branch (191:17): [True: 9.87k, False: 359k]
  ------------------
  192|  9.87k|        priv->next_pts = mpkt->pts;
  193|       |
  194|   379k|    mp_set_av_packet(priv->avpkt, mpkt, &priv->codec_timebase);
  195|       |
  196|   379k|    int ret = avcodec_send_packet(avctx, mpkt ? priv->avpkt : NULL);
  ------------------
  |  Branch (196:42): [True: 369k, False: 9.37k]
  ------------------
  197|   379k|    if (ret < 0)
  ------------------
  |  Branch (197:9): [True: 174k, False: 204k]
  ------------------
  198|   379k|        MP_ERR(da, "Error decoding audio.\n");
  ------------------
  |  |   89|   174k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   174k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  199|   379k|    return ret;
  200|   379k|}
ad_lavc.c:receive_frame:
  203|  1.21M|{
  204|  1.21M|    struct priv *priv = da->priv;
  205|  1.21M|    AVCodecContext *avctx = priv->avctx;
  206|       |
  207|  1.21M|    int ret = avcodec_receive_frame(avctx, priv->avframe);
  208|       |
  209|  1.21M|    if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (209:9): [True: 9.37k, False: 1.20M]
  ------------------
  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|  9.37k|        avcodec_flush_buffers(priv->avctx);
  214|  9.37k|        return ret;
  215|  1.20M|    } else if (ret < 0 && ret != AVERROR(EAGAIN)) {
  ------------------
  |  Branch (215:16): [True: 778k, False: 422k]
  |  Branch (215:27): [True: 10.9k, False: 767k]
  ------------------
  216|  10.9k|        MP_ERR(da, "Error decoding audio.\n");
  ------------------
  |  |   89|  10.9k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  217|  10.9k|    }
  218|       |
  219|  1.20M|    if (priv->avframe->flags & AV_FRAME_FLAG_DISCARD)
  ------------------
  |  Branch (219:9): [True: 0, False: 1.20M]
  ------------------
  220|      0|        av_frame_unref(priv->avframe);
  221|       |
  222|  1.20M|    if (!priv->avframe->buf[0])
  ------------------
  |  Branch (222:9): [True: 778k, False: 423k]
  ------------------
  223|   778k|        return ret;
  224|       |
  225|   423k|    mp_codec_info_from_av(avctx, priv->codec);
  226|   423k|    mp_chmap_from_av_layout(&priv->codec->channels, &avctx->ch_layout);
  227|       |
  228|   423k|    double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase);
  229|       |
  230|   423k|    struct mp_aframe *mpframe = mp_aframe_from_avframe(priv->avframe);
  231|   423k|    if (!mpframe) {
  ------------------
  |  Branch (231:9): [True: 0, False: 423k]
  ------------------
  232|      0|        MP_ERR(da, "Converting libavcodec frame to mpv frame 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__)
  |  |  ------------------
  ------------------
  233|      0|        return ret;
  234|      0|    }
  235|       |
  236|   423k|    if (priv->force_channel_map.num)
  ------------------
  |  Branch (236:9): [True: 0, False: 423k]
  ------------------
  237|      0|        mp_aframe_set_chmap(mpframe, &priv->force_channel_map);
  238|       |
  239|   423k|    if (out_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   423k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (239:9): [True: 288k, False: 134k]
  ------------------
  240|   288k|        out_pts = priv->next_pts;
  241|   423k|    mp_aframe_set_pts(mpframe, out_pts);
  242|       |
  243|   423k|    priv->next_pts = mp_aframe_end_pts(mpframe);
  244|       |
  245|   423k|    AVFrameSideData *sd =
  246|   423k|        av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
  247|   423k|    if (sd && sd->size >= 10) {
  ------------------
  |  Branch (247:9): [True: 114, False: 422k]
  |  Branch (247:15): [True: 114, False: 0]
  ------------------
  248|    114|        char *d = sd->data;
  249|    114|        priv->skip_samples += AV_RL32(d + 0);
  250|    114|        priv->trim_samples += AV_RL32(d + 4);
  251|    114|    }
  252|       |
  253|   423k|    if (!priv->preroll_done) {
  ------------------
  |  Branch (253:9): [True: 6.92k, False: 416k]
  ------------------
  254|       |        // Skip only if this isn't already handled by AV_FRAME_DATA_SKIP_SAMPLES.
  255|  6.92k|        if (!priv->skip_samples)
  ------------------
  |  Branch (255:13): [True: 6.80k, False: 114]
  ------------------
  256|  6.80k|            priv->skip_samples = avctx->delay;
  257|  6.92k|        priv->preroll_done = true;
  258|  6.92k|    }
  259|       |
  260|   423k|    uint32_t skip = MPMIN(priv->skip_samples, mp_aframe_get_size(mpframe));
  ------------------
  |  |   45|   423k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 53, False: 423k]
  |  |  ------------------
  ------------------
  261|   423k|    if (skip) {
  ------------------
  |  Branch (261:9): [True: 150, False: 422k]
  ------------------
  262|    150|        mp_aframe_skip_samples(mpframe, skip);
  263|    150|        priv->skip_samples -= skip;
  264|    150|    }
  265|   423k|    uint32_t trim = MPMIN(priv->trim_samples, mp_aframe_get_size(mpframe));
  ------------------
  |  |   45|   423k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 423k]
  |  |  ------------------
  ------------------
  266|   423k|    if (trim) {
  ------------------
  |  Branch (266:9): [True: 0, False: 423k]
  ------------------
  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|   423k|    mp_aframe_sanitize_float(mpframe);
  273|       |
  274|   423k|    if (mp_aframe_get_size(mpframe) > 0) {
  ------------------
  |  Branch (274:9): [True: 422k, False: 143]
  ------------------
  275|   422k|        *out = MAKE_FRAME(MP_FRAME_AUDIO, mpframe);
  ------------------
  |  |   57|   422k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
  276|   422k|    } else {
  277|    143|        talloc_free(mpframe);
  ------------------
  |  |   47|    143|#define talloc_free                     ta_free
  ------------------
  278|    143|    }
  279|       |
  280|   423k|    av_frame_unref(priv->avframe);
  281|       |
  282|   423k|    return ret;
  283|   423k|}
ad_lavc.c:ad_lavc_reset:
  172|    870|{
  173|    870|    struct priv *ctx = da->priv;
  174|       |
  175|    870|    avcodec_flush_buffers(ctx->avctx);
  176|    870|    ctx->skip_samples = 0;
  177|    870|    ctx->trim_samples = 0;
  178|    870|    ctx->preroll_done = false;
  179|    870|    ctx->next_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    870|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  180|    870|    ctx->state = (struct lavc_state){0};
  181|    870|}
ad_lavc.c:init:
   85|  14.9k|{
   86|  14.9k|    struct priv *ctx = da->priv;
   87|  14.9k|    struct MPOpts *mpopts = mp_get_config_group(ctx, da->global, &mp_opt_root);
   88|  14.9k|    struct ad_lavc_params *opts =
   89|  14.9k|        mp_get_config_group(ctx, da->global, &ad_lavc_conf);
   90|  14.9k|    const AVCodec *lavc_codec;
   91|       |
   92|  14.9k|    ctx->codec_timebase = mp_get_codec_timebase(codec);
   93|       |
   94|  14.9k|    if (codec->force_channels)
  ------------------
  |  Branch (94:9): [True: 0, False: 14.9k]
  ------------------
   95|      0|        ctx->force_channel_map = codec->channels;
   96|       |
   97|  14.9k|    lavc_codec = avcodec_find_decoder_by_name(decoder);
   98|  14.9k|    if (!lavc_codec) {
  ------------------
  |  Branch (98:9): [True: 0, False: 14.9k]
  ------------------
   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|  14.9k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  104|  14.9k|    MP_HANDLE_OOM(ctx->avctx);
  ------------------
  |  |  206|  14.9k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  14.9k|        void *oom_p_ = (x);     \
  |  |  208|  14.9k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 14.9k]
  |  |  ------------------
  |  |  209|  14.9k|            abort();            \
  |  |  210|  14.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 14.9k]
  |  |  ------------------
  ------------------
  105|  14.9k|    ctx->avframe = av_frame_alloc();
  106|  14.9k|    MP_HANDLE_OOM(ctx->avframe);
  ------------------
  |  |  206|  14.9k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  14.9k|        void *oom_p_ = (x);     \
  |  |  208|  14.9k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 14.9k]
  |  |  ------------------
  |  |  209|  14.9k|            abort();            \
  |  |  210|  14.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 14.9k]
  |  |  ------------------
  ------------------
  107|  14.9k|    ctx->avpkt = av_packet_alloc();
  108|  14.9k|    MP_HANDLE_OOM(ctx->avpkt);
  ------------------
  |  |  206|  14.9k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  14.9k|        void *oom_p_ = (x);     \
  |  |  208|  14.9k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 14.9k]
  |  |  ------------------
  |  |  209|  14.9k|            abort();            \
  |  |  210|  14.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 14.9k]
  |  |  ------------------
  ------------------
  109|  14.9k|    ctx->avctx->codec_type = AVMEDIA_TYPE_AUDIO;
  110|  14.9k|    ctx->avctx->codec_id = lavc_codec->id;
  111|  14.9k|    ctx->avctx->pkt_timebase = ctx->codec_timebase;
  112|       |
  113|  14.9k|    if (opts->downmix && mpopts->audio_output_channels.num_chmaps == 1) {
  ------------------
  |  Branch (113:9): [True: 0, False: 14.9k]
  |  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|  14.9k|    av_opt_set_double(ctx->avctx, "drc_scale", opts->ac3drc,
  129|  14.9k|                      AV_OPT_SEARCH_CHILDREN);
  130|       |
  131|       |    // Let decoder add AV_FRAME_DATA_SKIP_SAMPLES.
  132|  14.9k|    av_opt_set(ctx->avctx, "flags2", "+skip_manual", AV_OPT_SEARCH_CHILDREN);
  133|       |
  134|  14.9k|#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|  14.9k|    if (codec->lav_codecpar && codec->lav_codecpar->format == AV_SAMPLE_FMT_DSD)
  ------------------
  |  Branch (138:9): [True: 0, False: 14.9k]
  |  Branch (138:32): [True: 0, False: 0]
  ------------------
  139|      0|        ctx->avctx->request_sample_fmt = AV_SAMPLE_FMT_DSD;
  140|  14.9k|#endif
  141|       |
  142|  14.9k|    mp_set_avopts(da->log, ctx->avctx, opts->avopts);
  143|       |
  144|  14.9k|    if (mp_set_avctx_codec_headers(ctx->avctx, codec) < 0) {
  ------------------
  |  Branch (144:9): [True: 0, False: 14.9k]
  ------------------
  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|  14.9k|    mp_set_avcodec_threads(da->log, ctx->avctx, opts->threads);
  150|       |
  151|       |    /* open it */
  152|  14.9k|    if (avcodec_open2(ctx->avctx, lavc_codec, NULL) < 0) {
  ------------------
  |  Branch (152:9): [True: 1.25k, False: 13.7k]
  ------------------
  153|  1.25k|        MP_ERR(da, "Could not open codec.\n");
  ------------------
  |  |   89|  1.25k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.25k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  154|  1.25k|        return false;
  155|  1.25k|    }
  156|       |
  157|  13.7k|    ctx->next_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  13.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  158|       |
  159|       |    return true;
  160|  14.9k|}
ad_lavc.c:add_decoders:
  329|  16.5k|{
  330|  16.5k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_AUDIO);
  331|  16.5k|}

select_spdif_codec:
  471|  16.5k|{
  472|  16.5k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  16.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  16.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  16.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|       |
  474|  16.5k|    if (!find_codec(codec))
  ------------------
  |  Branch (474:9): [True: 9.58k, False: 7.00k]
  ------------------
  475|  9.58k|        return list;
  476|       |
  477|  16.5k|    bool spdif_allowed = false, dts_hd_allowed = false;
  478|  7.00k|    bstr sel = bstr0(pref);
  479|  7.00k|    while (sel.len) {
  ------------------
  |  Branch (479:12): [True: 0, False: 7.00k]
  ------------------
  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|  7.00k|    if (!spdif_allowed)
  ------------------
  |  Branch (490:9): [True: 7.00k, False: 0]
  ------------------
  491|  7.00k|        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|  7.00k|}
ad_spdif.c:find_codec:
  458|  16.5k|{
  459|  77.8k|    for (int n = 0; codecs[n] != AV_CODEC_ID_NONE; n++) {
  ------------------
  |  Branch (459:21): [True: 68.2k, False: 9.58k]
  ------------------
  460|  68.2k|        const char *format = mp_codec_from_av_codec_id(codecs[n]);
  461|  68.2k|        if (format && name && strcmp(format, name) == 0)
  ------------------
  |  Branch (461:13): [True: 68.2k, False: 0]
  |  Branch (461:23): [True: 68.2k, False: 0]
  |  Branch (461:31): [True: 7.00k, False: 61.2k]
  ------------------
  462|  7.00k|            return true;
  463|  68.2k|    }
  464|  9.58k|    return false;
  465|  16.5k|}

af_to_avformat:
   49|  9.97k|{
   50|   101k|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (50:21): [True: 101k, False: 1]
  ------------------
   51|   101k|        if (audio_conversion_map[i].fmt == fmt)
  ------------------
  |  Branch (51:13): [True: 9.97k, False: 91.6k]
  ------------------
   52|  9.97k|            return audio_conversion_map[i].sample_fmt;
   53|   101k|    }
   54|      1|    return AV_SAMPLE_FMT_NONE;
   55|  9.97k|}
af_from_avformat:
   58|   423k|{
   59|  4.26M|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (59:21): [True: 4.26M, False: 0]
  ------------------
   60|  4.26M|        if (audio_conversion_map[i].sample_fmt == sample_fmt)
  ------------------
  |  Branch (60:13): [True: 423k, False: 3.84M]
  ------------------
   61|   423k|            return audio_conversion_map[i].fmt;
   62|  4.26M|    }
   63|      0|    return 0;
   64|   423k|}

af_fmt_to_bytes:
   27|  1.16M|{
   28|  1.16M|    switch (af_fmt_from_planar(format)) {
  ------------------
  |  Branch (28:13): [True: 1.16M, False: 8]
  ------------------
   29|  1.59k|    case AF_FORMAT_U8:      return 1;
  ------------------
  |  Branch (29:5): [True: 1.59k, False: 1.16M]
  ------------------
   30|  37.6k|    case AF_FORMAT_S16:     return 2;
  ------------------
  |  Branch (30:5): [True: 37.6k, False: 1.12M]
  ------------------
   31|  4.21k|    case AF_FORMAT_S32:     return 4;
  ------------------
  |  Branch (31:5): [True: 4.21k, False: 1.16M]
  ------------------
   32|      0|    case AF_FORMAT_S64:     return 8;
  ------------------
  |  Branch (32:5): [True: 0, False: 1.16M]
  ------------------
   33|  1.12M|    case AF_FORMAT_FLOAT:   return 4;
  ------------------
  |  Branch (33:5): [True: 1.12M, False: 43.4k]
  ------------------
   34|      0|    case AF_FORMAT_DOUBLE:  return 8;
  ------------------
  |  Branch (34:5): [True: 0, False: 1.16M]
  ------------------
   35|  1.16M|    }
   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.03M|{
   48|  1.03M|    return format == AF_FORMAT_U8 || format == AF_FORMAT_U8P;
  ------------------
  |  Branch (48:12): [True: 429, False: 1.03M]
  |  Branch (48:38): [True: 0, False: 1.03M]
  ------------------
   49|  1.03M|}
af_fmt_is_spdif:
   66|  33.5k|{
   67|  33.5k|    return af_format_sample_alignment(format) > 1;
   68|  33.5k|}
af_fmt_is_pcm:
   71|  33.5k|{
   72|  33.5k|    return af_fmt_is_valid(format) && !af_fmt_is_spdif(format) &&
  ------------------
  |  Branch (72:12): [True: 33.5k, False: 0]
  |  Branch (72:39): [True: 33.5k, False: 0]
  ------------------
   73|  33.5k|           format != AF_FORMAT_S_DOP;
  ------------------
  |  Branch (73:12): [True: 33.5k, False: 0]
  ------------------
   74|  33.5k|}
af_fmt_is_planar:
   86|  4.01M|{
   87|  20.9M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  20.9M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (87:21): [True: 20.4M, False: 535k]
  ------------------
   88|  20.4M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (88:13): [True: 3.47M, False: 16.9M]
  ------------------
   89|  3.47M|            return true;
   90|  20.4M|    }
   91|   535k|    return false;
   92|  4.01M|}
af_fmt_from_planar:
  110|  1.58M|{
  111|  8.30M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  8.30M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (111:21): [True: 8.07M, False: 226k]
  ------------------
  112|  8.07M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (112:13): [True: 1.36M, False: 6.71M]
  ------------------
  113|  1.36M|            return planar_formats[n][1];
  114|  8.07M|    }
  115|   226k|    return format;
  116|  1.58M|}
af_fmt_is_valid:
  119|  33.5k|{
  120|  33.5k|    return format > 0 && format < AF_FORMAT_COUNT;
  ------------------
  |  Branch (120:12): [True: 33.5k, False: 0]
  |  Branch (120:26): [True: 33.5k, False: 0]
  ------------------
  121|  33.5k|}
af_fmt_to_str:
  124|  48.7k|{
  125|  48.7k|    switch (format) {
  ------------------
  |  Branch (125:13): [True: 48.7k, False: 0]
  ------------------
  126|    234|    case AF_FORMAT_U8:          return "u8";
  ------------------
  |  Branch (126:5): [True: 234, False: 48.5k]
  ------------------
  127|  2.75k|    case AF_FORMAT_S16:         return "s16";
  ------------------
  |  Branch (127:5): [True: 2.75k, False: 45.9k]
  ------------------
  128|    144|    case AF_FORMAT_S32:         return "s32";
  ------------------
  |  Branch (128:5): [True: 144, False: 48.5k]
  ------------------
  129|      0|    case AF_FORMAT_S64:         return "s64";
  ------------------
  |  Branch (129:5): [True: 0, False: 48.7k]
  ------------------
  130|    984|    case AF_FORMAT_FLOAT:       return "float";
  ------------------
  |  Branch (130:5): [True: 984, False: 47.7k]
  ------------------
  131|      0|    case AF_FORMAT_DOUBLE:      return "double";
  ------------------
  |  Branch (131:5): [True: 0, False: 48.7k]
  ------------------
  132|      0|    case AF_FORMAT_U8P:         return "u8p";
  ------------------
  |  Branch (132:5): [True: 0, False: 48.7k]
  ------------------
  133|  3.71k|    case AF_FORMAT_S16P:        return "s16p";
  ------------------
  |  Branch (133:5): [True: 3.71k, False: 45.0k]
  ------------------
  134|    366|    case AF_FORMAT_S32P:        return "s32p";
  ------------------
  |  Branch (134:5): [True: 366, False: 48.3k]
  ------------------
  135|      0|    case AF_FORMAT_S64P:        return "s64p";
  ------------------
  |  Branch (135:5): [True: 0, False: 48.7k]
  ------------------
  136|  40.5k|    case AF_FORMAT_FLOATP:      return "floatp";
  ------------------
  |  Branch (136:5): [True: 40.5k, False: 8.19k]
  ------------------
  137|      0|    case AF_FORMAT_DOUBLEP:     return "doublep";
  ------------------
  |  Branch (137:5): [True: 0, False: 48.7k]
  ------------------
  138|      0|    case AF_FORMAT_S_AAC:       return "spdif-aac";
  ------------------
  |  Branch (138:5): [True: 0, False: 48.7k]
  ------------------
  139|      0|    case AF_FORMAT_S_AC3:       return "spdif-ac3";
  ------------------
  |  Branch (139:5): [True: 0, False: 48.7k]
  ------------------
  140|      0|    case AF_FORMAT_S_DTS:       return "spdif-dts";
  ------------------
  |  Branch (140:5): [True: 0, False: 48.7k]
  ------------------
  141|      0|    case AF_FORMAT_S_DTSHD:     return "spdif-dtshd";
  ------------------
  |  Branch (141:5): [True: 0, False: 48.7k]
  ------------------
  142|      0|    case AF_FORMAT_S_EAC3:      return "spdif-eac3";
  ------------------
  |  Branch (142:5): [True: 0, False: 48.7k]
  ------------------
  143|      0|    case AF_FORMAT_S_MP3:       return "spdif-mp3";
  ------------------
  |  Branch (143:5): [True: 0, False: 48.7k]
  ------------------
  144|      0|    case AF_FORMAT_S_TRUEHD:    return "spdif-truehd";
  ------------------
  |  Branch (144:5): [True: 0, False: 48.7k]
  ------------------
  145|      0|    case AF_FORMAT_S_DOP:       return "dop";
  ------------------
  |  Branch (145:5): [True: 0, False: 48.7k]
  ------------------
  146|      0|    case AF_FORMAT_DSD:         return "dsd";
  ------------------
  |  Branch (146:5): [True: 0, False: 48.7k]
  ------------------
  147|  48.7k|    }
  148|      0|    return "??";
  149|  48.7k|}
af_fill_silence:
  152|  1.03M|{
  153|  1.03M|    int fill = 0;
  154|  1.03M|    if (af_fmt_is_unsigned(format))
  ------------------
  |  Branch (154:9): [True: 429, False: 1.03M]
  ------------------
  155|    429|        fill = 0x80;
  156|  1.03M|    if (format == AF_FORMAT_DSD)
  ------------------
  |  Branch (156:9): [True: 0, False: 1.03M]
  ------------------
  157|      0|        fill = 0x69; // only ultrasonic tones, filtered out on playback
  158|  1.03M|    memset(dst, fill, bytes);
  159|  1.03M|}
af_format_conversion_score:
  166|  9.91k|{
  167|  9.91k|    if (dst_format == AF_FORMAT_UNKNOWN || src_format == AF_FORMAT_UNKNOWN)
  ------------------
  |  Branch (167:9): [True: 0, False: 9.91k]
  |  Branch (167:44): [True: 0, False: 9.91k]
  ------------------
  168|      0|        return INT_MIN;
  169|  9.91k|    if (dst_format == src_format)
  ------------------
  |  Branch (169:9): [True: 9.91k, False: 0]
  ------------------
  170|  9.91k|        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.99k|{
  250|  7.99k|    if (!available)
  ------------------
  |  Branch (250:9): [True: 0, False: 7.99k]
  ------------------
  251|      0|        return -1;
  252|       |
  253|  7.99k|    int min_mult_rate = INT_MAX;
  254|  7.99k|    int max_rate      = INT_MIN;
  255|  7.99k|    for (int i = 0; available[i]; i++) {
  ------------------
  |  Branch (255:21): [True: 7.99k, False: 0]
  ------------------
  256|  7.99k|        if (available[i] == src_samplerate)
  ------------------
  |  Branch (256:13): [True: 7.99k, False: 0]
  ------------------
  257|  7.99k|            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|  41.6k|{
  278|  41.6k|    switch (format) {
  279|      0|    case AF_FORMAT_S_AAC:       return 16384 / 4;
  ------------------
  |  Branch (279:5): [True: 0, False: 41.6k]
  ------------------
  280|      0|    case AF_FORMAT_S_AC3:       return 6144 / 4;
  ------------------
  |  Branch (280:5): [True: 0, False: 41.6k]
  ------------------
  281|      0|    case AF_FORMAT_S_DTSHD:     return 32768 / 16;
  ------------------
  |  Branch (281:5): [True: 0, False: 41.6k]
  ------------------
  282|      0|    case AF_FORMAT_S_DTS:       return 2048 / 4;
  ------------------
  |  Branch (282:5): [True: 0, False: 41.6k]
  ------------------
  283|      0|    case AF_FORMAT_S_EAC3:      return 24576 / 4;
  ------------------
  |  Branch (283:5): [True: 0, False: 41.6k]
  ------------------
  284|      0|    case AF_FORMAT_S_MP3:       return 4608 / 4;
  ------------------
  |  Branch (284:5): [True: 0, False: 41.6k]
  ------------------
  285|      0|    case AF_FORMAT_S_TRUEHD:    return 61440 / 16;
  ------------------
  |  Branch (285:5): [True: 0, False: 41.6k]
  ------------------
  286|  41.6k|    default:                    return 1;
  ------------------
  |  Branch (286:5): [True: 41.6k, False: 0]
  ------------------
  287|  41.6k|    }
  288|  41.6k|}

ao_init_best:
  296|  8.07k|{
  297|  8.07k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  8.07k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  8.07k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  298|  8.07k|    struct ao_opts *opts = mp_get_config_group(tmp, global, &ao_conf);
  299|  8.07k|    struct mp_log *log = mp_log_new(tmp, global->log, "ao");
  300|  8.07k|    struct ao *ao = NULL;
  301|  8.07k|    struct m_obj_settings *ao_list = NULL;
  302|  8.07k|    int ao_num = 0;
  303|       |
  304|  16.1k|    for (int n = 0; opts->audio_driver_list && opts->audio_driver_list[n].name; n++)
  ------------------
  |  Branch (304:21): [True: 16.1k, False: 0]
  |  Branch (304:48): [True: 8.07k, False: 8.07k]
  ------------------
  305|  8.07k|        MP_TARRAY_APPEND(tmp, ao_list, ao_num, opts->audio_driver_list[n]);
  ------------------
  |  |  105|  8.07k|    do {                                            \
  |  |  106|  8.07k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  8.07k|    do {                                            \
  |  |  |  |   97|  8.07k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  8.07k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  8.07k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  8.07k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 8.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  8.07k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  8.07k|    do {                                                        \
  |  |  |  |  |  |   89|  8.07k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  8.07k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  8.07k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  8.07k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  8.07k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  8.07k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  8.07k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 8.07k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  8.07k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 8.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  8.07k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  8.07k|        (idxvar)++;                                 \
  |  |  109|  8.07k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.07k]
  |  |  ------------------
  ------------------
  306|       |
  307|  8.07k|    bool forced_dev = false;
  308|  8.07k|    char *pref_ao, *pref_dev;
  309|  8.07k|    split_ao_device(tmp, opts->audio_device, &pref_ao, &pref_dev);
  310|  8.07k|    if (!ao_num && pref_ao) {
  ------------------
  |  Branch (310:9): [True: 0, False: 8.07k]
  |  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|  8.07k|    bool autoprobe = ao_num == 0;
  318|       |
  319|       |    // Something like "--ao=a,b," means do autoprobing after a and b fail.
  320|  8.07k|    if (ao_num && strlen(ao_list[ao_num - 1].name) == 0) {
  ------------------
  |  Branch (320:9): [True: 8.07k, False: 0]
  |  Branch (320:19): [True: 0, False: 8.07k]
  ------------------
  321|      0|        ao_num -= 1;
  322|      0|        autoprobe = true;
  323|      0|    }
  324|       |
  325|  8.07k|    if (autoprobe) {
  ------------------
  |  Branch (325:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    if (init_flags & AO_INIT_NULL_FALLBACK) {
  ------------------
  |  Branch (335:9): [True: 0, False: 8.07k]
  ------------------
  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.07k|    for (int n = 0; n < ao_num; n++) {
  ------------------
  |  Branch (340:21): [True: 8.07k, False: 4]
  ------------------
  341|  8.07k|        struct m_obj_settings *entry = &ao_list[n];
  342|  8.07k|        bool probing = n + 1 != ao_num;
  343|  8.07k|        mp_verbose(log, "Trying audio driver '%s'\n", entry->name);
  ------------------
  |  |   79|  8.07k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  344|  8.07k|        char *dev = NULL;
  345|  8.07k|        if (pref_ao && pref_dev && strcmp(entry->name, pref_ao) == 0) {
  ------------------
  |  Branch (345:13): [True: 0, False: 8.07k]
  |  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|  8.07k|        ao = ao_init(probing, global, wakeup_cb, wakeup_ctx, encode_lavc_ctx,
  350|  8.07k|                     init_flags, samplerate, format, channels, dev, entry->name);
  351|  8.07k|        if (ao)
  ------------------
  |  Branch (351:13): [True: 8.07k, False: 4]
  ------------------
  352|  8.07k|            break;
  353|      4|        if (!probing)
  ------------------
  |  Branch (353:13): [True: 4, False: 0]
  ------------------
  354|      4|            mp_err(log, "Failed to initialize audio driver '%s'\n", entry->name);
  ------------------
  |  |   76|      4|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  355|      4|        if (dev && forced_dev) {
  ------------------
  |  Branch (355:13): [True: 0, False: 4]
  |  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|      4|    }
  360|       |
  361|  8.07k|    talloc_free(tmp);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  362|  8.07k|    return ao;
  363|  8.07k|}
ao_query_and_reset_events:
  367|  57.9k|{
  368|       |    return atomic_fetch_and(&ao->events_, ~(unsigned)events) & events;
  369|  57.9k|}
ao_chmap_sel_adjust:
  395|  8.07k|{
  396|  8.07k|    MP_VERBOSE(ao, "Channel layouts:\n");
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  397|  8.07k|    mp_chmal_sel_log(s, ao->log, MSGL_V);
  398|  8.07k|    bool r = mp_chmap_sel_adjust(s, map);
  399|  8.07k|    if (r)
  ------------------
  |  Branch (399:9): [True: 8.07k, False: 0]
  ------------------
  400|  8.07k|        MP_VERBOSE(ao, "result: %s\n", mp_chmap_to_str(map));
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  401|  8.07k|    return r;
  402|  8.07k|}
ao_get_format:
  437|  16.1k|{
  438|  16.1k|    *samplerate = ao->samplerate;
  439|  16.1k|    *format = ao->format;
  440|  16.1k|    *channels = ao->channels;
  441|  16.1k|}
ao_get_name:
  444|  8.07k|{
  445|  8.07k|    return ao->driver->name;
  446|  8.07k|}
ao_get_description:
  449|  8.07k|{
  450|  8.07k|    return ao->driver->description;
  451|  8.07k|}
ao_untimed:
  454|  31.6k|{
  455|  31.6k|    return ao->untimed;
  456|  31.6k|}
ao_hotplug_destroy:
  587|  24.7k|{
  588|  24.7k|    if (!hp)
  ------------------
  |  Branch (588:9): [True: 24.7k, False: 0]
  ------------------
  589|  24.7k|        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|  24.2k|{
  615|       |    atomic_store(&ao->gain, gain);
  616|  24.2k|}
ao_post_process_data:
  656|   564k|{
  657|   564k|    bool planar = af_fmt_is_planar(ao->format);
  658|   564k|    int planes = planar ? ao->channels.num : 1;
  ------------------
  |  Branch (658:18): [True: 469k, False: 94.6k]
  ------------------
  659|   564k|    int plane_samples = num_samples * (planar ? 1: ao->channels.num);
  ------------------
  |  Branch (659:40): [True: 469k, False: 94.6k]
  ------------------
  660|  1.59M|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (660:21): [True: 1.03M, False: 564k]
  ------------------
  661|  1.03M|        process_plane(ao, data[n], plane_samples);
  662|   564k|}
ao.c:get_desc:
  116|   206k|{
  117|   206k|    if (index >= MP_ARRAY_SIZE(audio_out_drivers))
  ------------------
  |  |   49|   206k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (117:9): [True: 24.7k, False: 181k]
  ------------------
  118|  24.7k|        return false;
  119|   181k|    const struct ao_driver *ao = audio_out_drivers[index];
  120|   181k|    *dst = (struct m_obj_desc) {
  121|   181k|        .name = ao->name,
  122|   181k|        .description = ao->description,
  123|   181k|        .priv_size = ao->priv_size,
  124|   181k|        .priv_defaults = ao->priv_defaults,
  125|   181k|        .options = ao->options,
  126|   181k|        .options_prefix = ao->options_prefix,
  127|   181k|        .global_opts = ao->global_opts,
  128|   181k|        .hidden = ao->encode,
  129|   181k|        .p = ao,
  130|   181k|    };
  131|       |    return true;
  132|   206k|}
ao.c:split_ao_device:
  276|  8.07k|{
  277|  8.07k|    *out_ao = NULL;
  278|  8.07k|    *out_dev = NULL;
  279|  8.07k|    if (!opt)
  ------------------
  |  Branch (279:9): [True: 0, False: 8.07k]
  ------------------
  280|      0|        return;
  281|  8.07k|    if (!opt[0] || strcmp(opt, "auto") == 0)
  ------------------
  |  Branch (281:9): [True: 0, False: 8.07k]
  |  Branch (281:20): [True: 8.07k, False: 0]
  ------------------
  282|  8.07k|        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|  8.07k|{
  208|  8.07k|    struct ao *ao = ao_alloc(probing, global, wakeup_cb, wakeup_ctx, name);
  209|  8.07k|    if (!ao)
  ------------------
  |  Branch (209:9): [True: 0, False: 8.07k]
  ------------------
  210|      0|        return NULL;
  211|  8.07k|    ao->samplerate = samplerate;
  212|  8.07k|    ao->channels = channels;
  213|  8.07k|    ao->format = format;
  214|  8.07k|    ao->encode_lavc_ctx = encode_lavc_ctx;
  215|  8.07k|    ao->init_flags = flags;
  216|  8.07k|    if (ao->driver->encode != !!ao->encode_lavc_ctx)
  ------------------
  |  Branch (216:9): [True: 0, False: 8.07k]
  ------------------
  217|      0|        goto fail;
  218|       |
  219|  8.07k|    MP_VERBOSE(ao, "requested format: %d Hz, %s channels, %s\n",
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  220|  8.07k|               ao->samplerate, mp_chmap_to_str(&ao->channels),
  221|  8.07k|               af_fmt_to_str(ao->format));
  222|       |
  223|  8.07k|    ao->device = talloc_strdup(ao, dev);
  ------------------
  |  |   50|  8.07k|#define talloc_strdup                   ta_xstrdup
  ------------------
  224|  8.07k|    ao->stream_silence = flags & AO_INIT_STREAM_SILENCE;
  225|       |
  226|  8.07k|    init_buffer_pre(ao);
  227|       |
  228|  8.07k|    int r = ao->driver->init(ao);
  229|  8.07k|    if (r < 0) {
  ------------------
  |  Branch (229:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    ao->driver_initialized = true;
  243|       |
  244|  8.07k|    ao->sstride = af_fmt_to_bytes(ao->format);
  245|  8.07k|    ao->num_planes = 1;
  246|  8.07k|    if (af_fmt_is_planar(ao->format)) {
  ------------------
  |  Branch (246:9): [True: 7.38k, False: 686]
  ------------------
  247|  7.38k|        ao->num_planes = ao->channels.num;
  248|  7.38k|    } else {
  249|    686|        ao->sstride *= ao->channels.num;
  250|    686|    }
  251|  8.07k|    ao->bps = (int64_t)ao->samplerate * ao->sstride;
  252|       |
  253|  8.07k|    if (ao->device_buffer <= 0 && ao->driver->write) {
  ------------------
  |  Branch (253:9): [True: 4, False: 8.07k]
  |  Branch (253:35): [True: 4, False: 0]
  ------------------
  254|      4|        MP_ERR(ao, "Device buffer size not set.\n");
  ------------------
  |  |   89|      4|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  255|      4|        goto fail;
  256|      4|    }
  257|  8.07k|    if (ao->device_buffer)
  ------------------
  |  Branch (257:9): [True: 8.07k, False: 0]
  ------------------
  258|  8.07k|        MP_VERBOSE(ao, "device buffer: %d samples.\n", ao->device_buffer);
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  259|  8.07k|    ao->buffer = MPMAX(ao->device_buffer, ao->def_buffer * ao->samplerate);
  ------------------
  |  |   44|  8.07k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 3, False: 8.06k]
  |  |  ------------------
  ------------------
  260|  8.07k|    ao->buffer = MPMAX(ao->buffer, 1);
  ------------------
  |  |   44|  8.07k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 8.07k, False: 0]
  |  |  ------------------
  ------------------
  261|       |
  262|  8.07k|    int align = af_format_sample_alignment(ao->format);
  263|  8.07k|    ao->buffer = (ao->buffer + align - 1) / align * align;
  264|  8.07k|    MP_VERBOSE(ao, "using soft-buffer of %d samples.\n", ao->buffer);
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  265|       |
  266|  8.07k|    if (!init_buffer_post(ao))
  ------------------
  |  Branch (266:9): [True: 0, False: 8.07k]
  ------------------
  267|      0|        goto fail;
  268|  8.07k|    return ao;
  269|       |
  270|      4|fail:
  271|      4|    ao_uninit(ao);
  272|       |    return NULL;
  273|  8.07k|}
ao.c:ao_alloc:
  167|  8.07k|{
  168|  8.07k|    mp_assert(wakeup_cb);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (168:5): [True: 8.07k, False: 0]
  ------------------
  169|       |
  170|  8.07k|    struct mp_log *log = mp_log_new(NULL, global->log, "ao");
  171|  8.07k|    struct m_obj_desc desc;
  172|  8.07k|    if (!m_obj_list_find(&desc, &ao_obj_list, bstr0(name))) {
  ------------------
  |  Branch (172:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    };
  177|  8.07k|    struct ao_opts *opts = mp_get_config_group(NULL, global, &ao_conf);
  178|  8.07k|    struct ao *ao = talloc_ptrtype(NULL, ao);
  ------------------
  |  |   34|  8.07k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  8.07k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.07k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|  8.07k|    talloc_steal(ao, log);
  ------------------
  |  |   38|  8.07k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  8.07k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  180|  8.07k|    *ao = (struct ao) {
  181|  8.07k|        .driver = desc.p,
  182|  8.07k|        .probing = probing,
  183|  8.07k|        .global = global,
  184|  8.07k|        .wakeup_cb = wakeup_cb,
  185|  8.07k|        .wakeup_ctx = wakeup_ctx,
  186|  8.07k|        .log = mp_log_new(ao, log, name),
  187|  8.07k|        .def_buffer = opts->audio_buffer,
  188|  8.07k|        .client_name = talloc_strdup(ao, opts->audio_client_name),
  ------------------
  |  |   50|  8.07k|#define talloc_strdup                   ta_xstrdup
  ------------------
  189|  8.07k|        .set_media_role = opts->audio_set_media_role
  190|  8.07k|    };
  191|  8.07k|    talloc_free(opts);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  192|  8.07k|    ao->priv = m_config_group_from_desc(ao, ao->log, global, &desc, name);
  193|  8.07k|    if (!ao->priv)
  ------------------
  |  Branch (193:9): [True: 0, False: 8.07k]
  ------------------
  194|      0|        goto error;
  195|  8.07k|    ao_set_gain(ao, 1.0f);
  196|  8.07k|    return ao;
  197|      0|error:
  198|      0|    talloc_free(ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  199|       |    return NULL;
  200|  8.07k|}
ao.c:process_plane:
  629|  1.03M|{
  630|  1.03M|    float gain = atomic_load_explicit(&ao->gain, memory_order_relaxed);
  631|  1.03M|    int gi = lrint(256.0 * gain);
  632|  1.03M|    if (gi == 256)
  ------------------
  |  Branch (632:9): [True: 1.03M, False: 0]
  ------------------
  633|  1.03M|        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|  8.07k|{
   86|  8.07k|    struct priv *priv = ao->priv;
   87|       |
   88|  8.07k|    if (priv->format)
  ------------------
  |  Branch (88:9): [True: 0, False: 8.07k]
  ------------------
   89|      0|        ao->format = priv->format;
   90|       |
   91|  8.07k|    ao->untimed = priv->untimed;
   92|       |
   93|  8.07k|    struct mp_chmap_sel sel = {.tmp = ao};
   94|  8.07k|    if (priv->channel_layouts.num_chmaps) {
  ------------------
  |  Branch (94:9): [True: 0, False: 8.07k]
  ------------------
   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|  8.07k|    } else {
   98|  8.07k|        mp_chmap_sel_add_any(&sel);
   99|  8.07k|    }
  100|  8.07k|    if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
  ------------------
  |  Branch (100:9): [True: 0, False: 8.07k]
  ------------------
  101|      0|        mp_chmap_from_channels(&ao->channels, 2);
  102|       |
  103|  8.07k|    priv->latency = priv->latency_sec * ao->samplerate;
  104|       |
  105|       |    // A "buffer" for this many seconds of audio
  106|  8.07k|    int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
  107|  8.07k|    ao->device_buffer = priv->outburst * bursts + priv->latency;
  108|       |
  109|  8.07k|    priv->last_time = mp_time_sec();
  110|       |
  111|  8.07k|    return 0;
  112|  8.07k|}
ao_null.c:uninit:
  116|  8.07k|{
  117|  8.07k|}
ao_null.c:reset:
  121|  3.81k|{
  122|  3.81k|    struct priv *priv = ao->priv;
  123|  3.81k|    priv->paused = false;
  124|  3.81k|    priv->buffered = 0;
  125|       |    priv->playing = false;
  126|  3.81k|}
ao_null.c:set_pause:
  142|     24|{
  143|     24|    struct priv *priv = ao->priv;
  144|       |
  145|     24|    if (!priv->playing)
  ------------------
  |  Branch (145:9): [True: 0, False: 24]
  ------------------
  146|     24|        MP_ERR(ao, "illegal state: set_pause() while not playing\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__)
  |  |  ------------------
  ------------------
  147|       |
  148|     24|    if (priv->paused != paused) {
  ------------------
  |  Branch (148:9): [True: 24, False: 0]
  ------------------
  149|       |
  150|     24|        drain(ao);
  151|     24|        priv->paused = paused;
  152|     24|        if (!priv->paused)
  ------------------
  |  Branch (152:13): [True: 12, False: 12]
  ------------------
  153|     12|            priv->last_time = mp_time_sec();
  154|     24|    }
  155|       |
  156|       |    return true;
  157|     24|}
ao_null.c:drain:
   64|   626k|{
   65|   626k|    struct priv *priv = ao->priv;
   66|       |
   67|   626k|    if (ao->untimed) {
  ------------------
  |  Branch (67:9): [True: 626k, False: 0]
  ------------------
   68|   626k|        priv->buffered = 0;
   69|   626k|        return;
   70|   626k|    }
   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|   291k|{
  161|   291k|    struct priv *priv = ao->priv;
  162|       |
  163|   291k|    if (priv->buffered <= 0)
  ------------------
  |  Branch (163:9): [True: 291k, False: 0]
  ------------------
  164|   291k|        priv->buffered = priv->latency; // emulate fixed latency
  165|       |
  166|   291k|    priv->buffered += samples;
  167|       |    return true;
  168|   291k|}
ao_null.c:get_state:
  171|   618k|{
  172|   618k|    struct priv *priv = ao->priv;
  173|       |
  174|   618k|    drain(ao);
  175|       |
  176|   618k|    state->free_samples = ao->device_buffer - priv->latency - priv->buffered;
  177|   618k|    state->free_samples = state->free_samples / priv->outburst * priv->outburst;
  178|   618k|    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|   618k|    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|   618k|    if (priv->broken_eof && priv->buffered < priv->latency)
  ------------------
  |  Branch (186:9): [True: 0, False: 618k]
  |  Branch (186:29): [True: 0, False: 0]
  ------------------
  187|      0|        state->delay = priv->latency;
  188|       |
  189|   618k|    state->delay /= ao->samplerate;
  190|       |
  191|   618k|    if (priv->broken_delay) { // Report only multiples of outburst
  ------------------
  |  Branch (191:9): [True: 0, False: 618k]
  ------------------
  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|   618k|    state->playing = priv->playing && priv->buffered > 0;
  ------------------
  |  Branch (197:22): [True: 575k, False: 42.9k]
  |  Branch (197:39): [True: 0, False: 575k]
  ------------------
  198|   618k|}

ao_wakeup:
   86|   317k|{
   87|   317k|    struct buffer_state *p = ao->buffer_state;
   88|   317k|    mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|   317k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   89|   317k|    p->need_wakeup = true;
   90|   317k|    mp_cond_broadcast(&p->pt_wakeup);
   91|   317k|    mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|   317k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   92|   317k|}
ao_get_queue:
  113|  8.07k|{
  114|  8.07k|    struct buffer_state *p = ao->buffer_state;
  115|  8.07k|    return p->queue;
  116|  8.07k|}
ao_control:
  279|  8.07k|{
  280|  8.07k|    struct buffer_state *p = ao->buffer_state;
  281|  8.07k|    int r = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  8.07k|#define CONTROL_UNKNOWN -1
  ------------------
  282|  8.07k|    if (ao->driver->control) {
  ------------------
  |  Branch (282:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    return r;
  293|  8.07k|}
ao_get_delay:
  296|  54.1k|{
  297|  54.1k|    struct buffer_state *p = ao->buffer_state;
  298|       |
  299|  54.1k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  54.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|       |
  301|  54.1k|    double driver_delay;
  302|  54.1k|    if (ao->driver->write) {
  ------------------
  |  Branch (302:9): [True: 54.1k, False: 0]
  ------------------
  303|  54.1k|        struct mp_pcm_state state;
  304|  54.1k|        get_dev_state(ao, &state);
  305|  54.1k|        driver_delay = state.delay;
  306|  54.1k|    } 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|  54.1k|    int64_t pending = mp_async_queue_get_samples(p->queue);
  313|  54.1k|    if (p->pending)
  ------------------
  |  Branch (313:9): [True: 51, False: 54.1k]
  ------------------
  314|     51|        pending += mp_aframe_get_size(p->pending);
  315|       |
  316|  54.1k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  54.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  317|  54.1k|    return driver_delay + pending / (double)ao->samplerate;
  318|  54.1k|}
ao_reset:
  322|  3.81k|{
  323|  3.81k|    struct buffer_state *p = ao->buffer_state;
  324|  3.81k|    bool wakeup = false;
  325|  3.81k|    bool do_reset = false;
  326|       |
  327|  3.81k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  3.81k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  328|       |
  329|  3.81k|    TA_FREEP(&p->pending);
  ------------------
  |  |   81|  3.81k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  3.81k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 3.81k]
  |  |  ------------------
  ------------------
  330|  3.81k|    mp_async_queue_reset(p->queue);
  331|  3.81k|    mp_filter_reset(p->filter_root);
  332|  3.81k|    mp_async_queue_resume_reading(p->queue);
  333|       |
  334|  3.81k|    if (!ao->stream_silence && ao->driver->reset) {
  ------------------
  |  Branch (334:9): [True: 3.81k, False: 0]
  |  Branch (334:32): [True: 3.81k, False: 0]
  ------------------
  335|  3.81k|        if (ao->driver->write) {
  ------------------
  |  Branch (335:13): [True: 3.81k, False: 0]
  ------------------
  336|  3.81k|            ao->driver->reset(ao);
  337|  3.81k|        } 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|  3.81k|        p->streaming = false;
  343|  3.81k|    }
  344|  3.81k|    wakeup = p->playing;
  345|  3.81k|    p->playing = false;
  346|  3.81k|    p->recover_pause = false;
  347|  3.81k|    p->hw_paused = false;
  348|  3.81k|    p->end_time_ns = 0;
  349|       |
  350|  3.81k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  3.81k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  351|       |
  352|  3.81k|    if (do_reset)
  ------------------
  |  Branch (352:9): [True: 0, False: 3.81k]
  ------------------
  353|      0|        ao->driver->reset(ao);
  354|       |
  355|  3.81k|    if (wakeup)
  ------------------
  |  Branch (355:9): [True: 1.56k, False: 2.25k]
  ------------------
  356|  1.56k|        ao_wakeup(ao);
  357|  3.81k|}
ao_start:
  364|  8.16k|{
  365|  8.16k|    struct buffer_state *p = ao->buffer_state;
  366|  8.16k|    bool do_start = false;
  367|       |
  368|  8.16k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  8.16k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  369|       |
  370|  8.16k|    p->playing = true;
  371|       |
  372|  8.16k|    if (!ao->driver->write && !p->paused && !p->streaming) {
  ------------------
  |  Branch (372:9): [True: 0, False: 8.16k]
  |  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|  8.16k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  8.16k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  378|       |
  379|       |    // Pull AOs might call ao_read_data() so do this outside the lock.
  380|  8.16k|    if (do_start)
  ------------------
  |  Branch (380:9): [True: 0, False: 8.16k]
  ------------------
  381|      0|        ao->driver->start(ao);
  382|       |
  383|  8.16k|    ao_wakeup(ao);
  384|  8.16k|}
ao_set_paused:
  387|  8.09k|{
  388|  8.09k|    struct buffer_state *p = ao->buffer_state;
  389|  8.09k|    bool wakeup = false;
  390|  8.09k|    bool do_change_state = false;
  391|  8.09k|    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|  8.09k|    if (eof && paused && ao_is_playing(ao))
  ------------------
  |  Branch (395:9): [True: 0, False: 8.09k]
  |  Branch (395:16): [True: 0, False: 0]
  |  Branch (395:26): [True: 0, False: 0]
  ------------------
  396|      0|        ao_drain(ao);
  397|       |
  398|  8.09k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  8.09k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  399|       |
  400|  8.09k|    if ((p->playing || !ao->driver->write) && !p->paused && paused) {
  ------------------
  |  Branch (400:10): [True: 24, False: 8.07k]
  |  Branch (400:24): [True: 0, False: 8.07k]
  |  Branch (400:47): [True: 12, False: 12]
  |  Branch (400:61): [True: 12, False: 0]
  ------------------
  401|     12|        if (p->streaming && !ao->stream_silence) {
  ------------------
  |  Branch (401:13): [True: 12, False: 0]
  |  Branch (401:29): [True: 12, False: 0]
  ------------------
  402|     12|            if (ao->driver->write) {
  ------------------
  |  Branch (402:17): [True: 12, False: 0]
  ------------------
  403|     12|                if (!p->recover_pause)
  ------------------
  |  Branch (403:21): [True: 12, False: 0]
  ------------------
  404|     12|                    get_dev_state(ao, &p->prepause_state);
  405|     12|                if (ao->driver->set_pause && ao->driver->set_pause(ao, true)) {
  ------------------
  |  Branch (405:21): [True: 12, False: 0]
  |  Branch (405:46): [True: 12, False: 0]
  ------------------
  406|     12|                    p->hw_paused = true;
  407|     12|                } else {
  408|      0|                    ao->driver->reset(ao);
  409|      0|                    p->streaming = false;
  410|      0|                    p->recover_pause = !ao->untimed;
  411|      0|                }
  412|     12|            } 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|     12|        }
  419|     12|        wakeup = true;
  420|  8.08k|    } else if (p->playing && p->paused && !paused) {
  ------------------
  |  Branch (420:16): [True: 12, False: 8.07k]
  |  Branch (420:30): [True: 12, False: 0]
  |  Branch (420:43): [True: 12, False: 0]
  ------------------
  421|     12|        if (ao->driver->write) {
  ------------------
  |  Branch (421:13): [True: 12, False: 0]
  ------------------
  422|     12|            if (p->hw_paused)
  ------------------
  |  Branch (422:17): [True: 12, False: 0]
  ------------------
  423|     12|                ao->driver->set_pause(ao, false);
  424|     12|            p->hw_paused = false;
  425|     12|        } 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|     12|        wakeup = true;
  433|     12|    }
  434|  8.09k|    p->paused = paused;
  435|       |
  436|  8.09k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  8.09k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  437|       |
  438|  8.09k|    if (do_change_state) {
  ------------------
  |  Branch (438:9): [True: 0, False: 8.09k]
  ------------------
  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|  8.09k|    if (wakeup)
  ------------------
  |  Branch (455:9): [True: 24, False: 8.07k]
  ------------------
  456|     24|        ao_wakeup(ao);
  457|  8.09k|}
ao_is_playing:
  464|   173k|{
  465|   173k|    struct buffer_state *p = ao->buffer_state;
  466|       |
  467|   173k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|   173k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  468|   173k|    bool playing = p->playing;
  469|   173k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|   173k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  470|       |
  471|   173k|    return playing;
  472|   173k|}
ao_drain:
  476|  1.49k|{
  477|  1.49k|    struct buffer_state *p = ao->buffer_state;
  478|       |
  479|  1.49k|    mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|  1.49k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  480|  1.73k|    while (!p->paused && p->playing) {
  ------------------
  |  Branch (480:12): [True: 1.73k, False: 0]
  |  Branch (480:26): [True: 1.72k, False: 7]
  ------------------
  481|       |        // Untimed AOs never signal an underrun, they are done once they took
  482|       |        // everything.
  483|  1.72k|        if (ao->untimed && !p->pending && !mp_async_queue_get_samples(p->queue))
  ------------------
  |  Branch (483:13): [True: 1.72k, False: 0]
  |  Branch (483:28): [True: 1.72k, False: 1]
  |  Branch (483:43): [True: 1.44k, False: 285]
  ------------------
  484|  1.44k|            break;
  485|    286|        mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|    286|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  486|    286|        double delay = ao_get_delay(ao);
  487|    286|        mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|    286|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  488|       |
  489|       |        // Wait for buffer + arbitrary ~250ms for EOF signal from AO.
  490|    286|        if (mp_cond_timedwait(&p->wakeup, &p->lock,
  ------------------
  |  Branch (490:13): [True: 47, False: 239]
  ------------------
  491|    286|                              MP_TIME_S_TO_NS(MPMAX(delay, 0) + 0.25)))
  ------------------
  |  |   71|    572|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 283, False: 3]
  |  |  ------------------
  ------------------
  492|     47|        {
  493|     47|            MP_VERBOSE(ao, "drain timeout\n");
  ------------------
  |  |   92|     47|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     47|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  494|     47|            break;
  495|     47|        }
  496|       |
  497|    239|        if (!p->playing && mp_async_queue_get_samples(p->queue)) {
  ------------------
  |  Branch (497:13): [True: 7, False: 232]
  |  Branch (497:28): [True: 0, False: 7]
  ------------------
  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|    239|    }
  504|  1.49k|    mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|  1.49k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|       |
  506|  1.49k|    ao_reset(ao);
  507|  1.49k|}
ao_uninit:
  516|  8.07k|{
  517|  8.07k|    struct buffer_state *p = ao->buffer_state;
  518|       |
  519|  8.07k|    if (p && p->thread_valid) {
  ------------------
  |  Branch (519:9): [True: 8.07k, False: 0]
  |  Branch (519:14): [True: 8.07k, False: 4]
  ------------------
  520|  8.07k|        mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|  8.07k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  521|  8.07k|        p->terminate = true;
  522|  8.07k|        mp_cond_broadcast(&p->pt_wakeup);
  523|  8.07k|        mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|  8.07k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  524|       |
  525|  8.07k|        mp_thread_join(p->thread);
  ------------------
  |  |  215|  8.07k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  526|  8.07k|        p->thread_valid = false;
  527|  8.07k|    }
  528|       |
  529|  8.07k|    if (ao->driver_initialized)
  ------------------
  |  Branch (529:9): [True: 8.07k, False: 0]
  ------------------
  530|  8.07k|        ao->driver->uninit(ao);
  531|       |
  532|  8.07k|    if (p) {
  ------------------
  |  Branch (532:9): [True: 8.07k, False: 0]
  ------------------
  533|  8.07k|        talloc_free(p->filter_root);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  534|  8.07k|        talloc_free(p->queue);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  535|  8.07k|        talloc_free(p->pending);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  536|  8.07k|        talloc_free(p->convert_buffer);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  537|  8.07k|        talloc_free(p->temp_buf);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  538|       |
  539|  8.07k|        mp_cond_destroy(&p->wakeup);
  540|  8.07k|        mp_mutex_destroy(&p->lock);
  ------------------
  |  |  133|  8.07k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  541|       |
  542|  8.07k|        mp_cond_destroy(&p->pt_wakeup);
  543|  8.07k|        mp_mutex_destroy(&p->pt_lock);
  ------------------
  |  |  133|  8.07k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  544|  8.07k|    }
  545|       |
  546|  8.07k|    talloc_free(ao);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
  547|  8.07k|}
init_buffer_pre:
  550|  8.07k|{
  551|  8.07k|    ao->buffer_state = talloc_zero(ao, struct buffer_state);
  ------------------
  |  |   27|  8.07k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  8.07k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.07k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  552|  8.07k|}
init_buffer_post:
  555|  8.07k|{
  556|  8.07k|    struct buffer_state *p = ao->buffer_state;
  557|       |
  558|  8.07k|    mp_assert(ao->driver->start);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (558:5): [True: 8.07k, False: 0]
  ------------------
  559|  8.07k|    if (ao->driver->write) {
  ------------------
  |  Branch (559:9): [True: 8.07k, False: 0]
  ------------------
  560|  8.07k|        mp_assert(ao->driver->reset);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (560:9): [True: 8.07k, False: 0]
  ------------------
  561|  8.07k|        mp_assert(ao->driver->get_state);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (561:9): [True: 8.07k, False: 0]
  ------------------
  562|  8.07k|    }
  563|       |
  564|  8.07k|    mp_mutex_init(&p->lock);
  565|  8.07k|    mp_cond_init(&p->wakeup);
  566|       |
  567|  8.07k|    mp_mutex_init(&p->pt_lock);
  568|  8.07k|    mp_cond_init(&p->pt_wakeup);
  569|       |
  570|  8.07k|    p->queue = mp_async_queue_create();
  571|  8.07k|    p->filter_root = mp_filter_create_root(ao->global);
  572|  8.07k|    p->input = mp_async_queue_create_filter(p->filter_root, MP_PIN_OUT, p->queue);
  573|       |
  574|  8.07k|    mp_async_queue_resume_reading(p->queue);
  575|       |
  576|  8.07k|    struct mp_async_queue_config cfg = {
  577|  8.07k|        .sample_unit = AQUEUE_UNIT_SAMPLES,
  578|  8.07k|        .max_samples = ao->buffer,
  579|  8.07k|        .max_bytes = INT64_MAX,
  580|  8.07k|    };
  581|  8.07k|    mp_async_queue_set_config(p->queue, cfg);
  582|       |
  583|  8.07k|    if (ao->driver->write) {
  ------------------
  |  Branch (583:9): [True: 8.07k, False: 0]
  ------------------
  584|  8.07k|        mp_filter_graph_set_wakeup_cb(p->filter_root, wakeup_filters, ao);
  585|       |
  586|  8.07k|        p->thread_valid = true;
  587|  8.07k|        if (mp_thread_create(&p->thread, ao_thread, ao)) {
  ------------------
  |  |  214|  8.07k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 8.07k]
  |  |  ------------------
  ------------------
  588|      0|            p->thread_valid = false;
  589|      0|            return false;
  590|      0|        }
  591|  8.07k|    } 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|  8.07k|    if (ao->stream_silence) {
  ------------------
  |  Branch (598:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|}
buffer.c:read_buffer:
  121|   564k|{
  122|   564k|    struct buffer_state *p = ao->buffer_state;
  123|   564k|    int pos = 0;
  124|   564k|    *eof = false;
  125|       |
  126|   949k|    while (p->playing && !p->paused && pos < samples) {
  ------------------
  |  Branch (126:12): [True: 949k, False: 0]
  |  Branch (126:26): [True: 949k, False: 0]
  |  Branch (126:40): [True: 941k, False: 7.93k]
  ------------------
  127|   941k|        if (!p->pending || !mp_aframe_get_size(p->pending)) {
  ------------------
  |  Branch (127:13): [True: 562k, False: 378k]
  |  Branch (127:28): [True: 373k, False: 4.82k]
  ------------------
  128|   936k|            TA_FREEP(&p->pending);
  ------------------
  |  |   81|   936k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   936k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 936k]
  |  |  ------------------
  ------------------
  129|   936k|            struct mp_frame frame = mp_pin_out_read(p->input->pins[0]);
  130|   936k|            if (!frame.type)
  ------------------
  |  Branch (130:17): [True: 556k, False: 380k]
  ------------------
  131|   556k|                break; // we can't/don't want to block
  132|   380k|            if (frame.type != MP_FRAME_AUDIO) {
  ------------------
  |  Branch (132:17): [True: 6.61k, False: 373k]
  ------------------
  133|  6.61k|                if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (133:21): [True: 6.61k, False: 0]
  ------------------
  134|  6.61k|                    *eof = true;
  135|  6.61k|                mp_frame_unref(&frame);
  136|  6.61k|                continue;
  137|  6.61k|            }
  138|   373k|            p->pending = frame.data;
  139|   373k|        }
  140|       |
  141|   378k|        if (!data)
  ------------------
  |  Branch (141:13): [True: 0, False: 378k]
  ------------------
  142|      0|            break;
  143|       |
  144|   378k|        int copy = mp_aframe_get_size(p->pending);
  145|   378k|        uint8_t **fdata = mp_aframe_get_data_ro(p->pending);
  146|   378k|        copy = MPMIN(copy, samples - pos);
  ------------------
  |  |   45|   378k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 4.82k, False: 373k]
  |  |  ------------------
  ------------------
  147|  1.06M|        for (int n = 0; n < ao->num_planes; n++) {
  ------------------
  |  Branch (147:25): [True: 687k, False: 378k]
  ------------------
  148|   687k|            memcpy((char *)data[n] + pos * ao->sstride,
  149|   687k|                   fdata[n], copy * ao->sstride);
  150|   687k|        }
  151|   378k|        mp_aframe_skip_samples(p->pending, copy);
  152|   378k|        pos += copy;
  153|   378k|        *eof = false;
  154|   378k|    }
  155|       |
  156|   564k|    if (!data) {
  ------------------
  |  Branch (156:9): [True: 0, False: 564k]
  ------------------
  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|   564k|    if (pad_silence) {
  ------------------
  |  Branch (166:9): [True: 564k, False: 0]
  ------------------
  167|  1.59M|        for (int n = 0; n < ao->num_planes; n++) {
  ------------------
  |  Branch (167:25): [True: 1.03M, False: 564k]
  ------------------
  168|  1.03M|            af_fill_silence((char *)data[n] + pos * ao->sstride,
  169|  1.03M|                    (samples - pos) * ao->sstride,
  170|  1.03M|                    ao->format);
  171|  1.03M|        }
  172|   564k|    }
  173|       |
  174|   564k|    ao_post_process_data(ao, data, pos);
  175|   564k|    return pos;
  176|   564k|}
buffer.c:get_dev_state:
   96|   618k|{
   97|   618k|    struct buffer_state *p = ao->buffer_state;
   98|       |
   99|   618k|    if (p->paused && p->playing && !ao->stream_silence) {
  ------------------
  |  Branch (99:9): [True: 0, False: 618k]
  |  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|   618k|    *state = (struct mp_pcm_state){
  105|   618k|        .free_samples = -1,
  106|   618k|        .queued_samples = -1,
  107|   618k|        .delay = -1,
  108|   618k|    };
  109|   618k|    ao->driver->get_state(ao, state);
  110|   618k|}
buffer.c:wakeup_filters:
  510|   308k|{
  511|   308k|    struct ao *ao = ctx;
  512|   308k|    ao_wakeup(ao);
  513|   308k|}
buffer.c:ao_thread:
  715|  8.07k|{
  716|  8.07k|    struct ao *ao = arg;
  717|  8.07k|    struct buffer_state *p = ao->buffer_state;
  718|  8.07k|    mp_thread_set_name("ao");
  719|   588k|    while (1) {
  ------------------
  |  Branch (719:12): [True: 588k, Folded]
  ------------------
  720|   588k|        mp_mutex_lock(&p->lock);
  ------------------
  |  |  134|   588k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  721|       |
  722|   588k|        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|   588k|        int64_t timeout = INT64_MAX;
  727|   588k|        if (p->streaming && !retry && (!p->paused || ao->stream_silence)) {
  ------------------
  |  Branch (727:13): [True: 556k, False: 32.1k]
  |  Branch (727:29): [True: 268k, False: 288k]
  |  Branch (727:40): [True: 268k, False: 11]
  |  Branch (727:54): [True: 0, False: 11]
  ------------------
  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|   268k|            timeout = MP_TIME_S_TO_NS(ao->device_buffer / (double)ao->samplerate * 0.25);
  ------------------
  |  |   71|   268k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  732|   268k|        }
  733|       |
  734|   588k|        mp_mutex_unlock(&p->lock);
  ------------------
  |  |  136|   588k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  735|       |
  736|   588k|        mp_mutex_lock(&p->pt_lock);
  ------------------
  |  |  134|   588k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  737|   588k|        if (p->terminate) {
  ------------------
  |  Branch (737:13): [True: 8.07k, False: 580k]
  ------------------
  738|  8.07k|            mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|  8.07k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  739|  8.07k|            break;
  740|  8.07k|        }
  741|   580k|        if (!p->need_wakeup && !retry) {
  ------------------
  |  Branch (741:13): [True: 545k, False: 35.6k]
  |  Branch (741:32): [True: 279k, False: 265k]
  ------------------
  742|   279k|            MP_STATS(ao, "start audio wait");
  ------------------
  |  |   99|   279k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   279k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  743|   279k|            mp_cond_timedwait(&p->pt_wakeup, &p->pt_lock, timeout);
  744|   279k|            MP_STATS(ao, "end audio wait");
  ------------------
  |  |   99|   279k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   279k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  745|   279k|        }
  746|   580k|        p->need_wakeup = false;
  747|   580k|        mp_mutex_unlock(&p->pt_lock);
  ------------------
  |  |  136|   580k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  748|   580k|    }
  749|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  8.07k|#define MP_THREAD_RETURN() return NULL
  ------------------
  750|  8.07k|}
buffer.c:ao_play_data:
  630|   588k|{
  631|   588k|    struct buffer_state *p = ao->buffer_state;
  632|       |
  633|   588k|    if ((!p->playing || p->paused) && !ao->stream_silence)
  ------------------
  |  Branch (633:10): [True: 24.6k, False: 564k]
  |  Branch (633:25): [True: 11, False: 564k]
  |  Branch (633:39): [True: 24.6k, False: 0]
  ------------------
  634|  24.6k|        return false;
  635|       |
  636|   564k|    struct mp_pcm_state state;
  637|   564k|    get_dev_state(ao, &state);
  638|       |
  639|   564k|    if (p->streaming && !state.playing && !ao->untimed)
  ------------------
  |  Branch (639:9): [True: 555k, False: 8.95k]
  |  Branch (639:25): [True: 555k, False: 0]
  |  Branch (639:43): [True: 0, False: 555k]
  ------------------
  640|      0|        goto eof;
  641|       |
  642|   564k|    void **planes = NULL;
  643|   564k|    int space = state.free_samples;
  644|   564k|    if (!space)
  ------------------
  |  Branch (644:9): [True: 0, False: 564k]
  ------------------
  645|      0|        return false;
  646|   564k|    mp_assert(space >= 0);
  ------------------
  |  |   41|   564k|#define mp_assert assert
  ------------------
  |  Branch (646:5): [True: 564k, False: 0]
  ------------------
  647|       |
  648|   564k|    int samples = 0;
  649|   564k|    bool got_eof = false;
  650|   564k|    if (ao->driver->write_frames) {
  ------------------
  |  Branch (650:9): [True: 0, False: 564k]
  ------------------
  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|   564k|    } else {
  655|   564k|        if (!realloc_buf(ao, space)) {
  ------------------
  |  Branch (655:13): [True: 58, False: 564k]
  ------------------
  656|     58|            MP_ERR(ao, "Failed to allocate buffer.\n");
  ------------------
  |  |   89|     58|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     58|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  657|     58|            return false;
  658|     58|        }
  659|   564k|        planes = (void **)mp_aframe_get_data_rw(p->temp_buf);
  660|   564k|        mp_assert(planes);
  ------------------
  |  |   41|   564k|#define mp_assert assert
  ------------------
  |  Branch (660:9): [True: 564k, False: 0]
  ------------------
  661|       |
  662|   564k|        if (p->recover_pause) {
  ------------------
  |  Branch (662:13): [True: 0, False: 564k]
  ------------------
  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|   564k|        if (!samples) {
  ------------------
  |  Branch (668:13): [True: 564k, False: 0]
  ------------------
  669|   564k|            samples = read_buffer(ao, planes, space, &got_eof, true);
  670|   564k|            if (p->paused || (ao->stream_silence && !p->playing))
  ------------------
  |  Branch (670:17): [True: 0, False: 564k]
  |  Branch (670:31): [True: 0, False: 564k]
  |  Branch (670:53): [True: 0, False: 0]
  ------------------
  671|      0|                samples = space; // read_buffer() sets remainder to silent
  672|   564k|        }
  673|   564k|    }
  674|       |
  675|   564k|    if (samples) {
  ------------------
  |  Branch (675:9): [True: 291k, False: 272k]
  ------------------
  676|   291k|        MP_STATS(ao, "start ao fill");
  ------------------
  |  |   99|   291k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   291k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  677|   291k|        if (!ao->driver->write(ao, planes, samples))
  ------------------
  |  Branch (677:13): [True: 0, False: 291k]
  ------------------
  678|   291k|            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|   291k|        MP_STATS(ao, "end ao fill");
  ------------------
  |  |   99|   291k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   291k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  680|       |
  681|   291k|        if (!p->streaming) {
  ------------------
  |  Branch (681:13): [True: 7.83k, False: 284k]
  ------------------
  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|   291k|    }
  688|       |
  689|   564k|    MP_TRACE(ao, "in=%d space=%d(%d) pl=%d, eof=%d\n",
  ------------------
  |  |   94|   564k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   564k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  690|   564k|             samples, space, state.free_samples, p->playing, got_eof);
  691|       |
  692|   564k|    if (got_eof)
  ------------------
  |  Branch (692:9): [True: 6.57k, False: 557k]
  ------------------
  693|  6.57k|        goto eof;
  694|       |
  695|       |    // For ao_drain(), an untimed AO took everything.
  696|   557k|    if (ao->untimed && !samples)
  ------------------
  |  Branch (696:9): [True: 557k, False: 0]
  |  Branch (696:24): [True: 269k, False: 288k]
  ------------------
  697|   269k|        mp_cond_broadcast(&p->wakeup);
  698|       |
  699|   557k|    return samples > 0 && (samples < space || ao->untimed);
  ------------------
  |  Branch (699:12): [True: 288k, False: 269k]
  |  Branch (699:28): [True: 280k, False: 7.93k]
  |  Branch (699:47): [True: 7.93k, False: 0]
  ------------------
  700|       |
  701|  6.57k|eof:
  702|  6.57k|    MP_VERBOSE(ao, "audio end or underrun\n");
  ------------------
  |  |   92|  6.57k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.57k|#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|  6.57k|    if (ao->untimed || !state.playing || ao->stream_silence) {
  ------------------
  |  Branch (704:9): [True: 6.57k, False: 0]
  |  Branch (704:24): [True: 0, False: 0]
  |  Branch (704:42): [True: 0, False: 0]
  ------------------
  705|  6.57k|        p->streaming = state.playing && !ao->untimed;
  ------------------
  |  Branch (705:24): [True: 3.09k, False: 3.48k]
  |  Branch (705:41): [True: 0, False: 3.09k]
  ------------------
  706|  6.57k|        p->playing = false;
  707|  6.57k|    }
  708|  6.57k|    ao->wakeup_cb(ao->wakeup_ctx);
  709|       |    // For ao_drain().
  710|  6.57k|    mp_cond_broadcast(&p->wakeup);
  711|       |    return true;
  712|   564k|}
buffer.c:realloc_buf:
  607|   564k|{
  608|   564k|    struct buffer_state *p = ao->buffer_state;
  609|       |
  610|   564k|    samples = MPMAX(1, samples);
  ------------------
  |  |   44|   564k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 564k]
  |  |  ------------------
  ------------------
  611|       |
  612|   564k|    if (!p->temp_buf || samples > mp_aframe_get_size(p->temp_buf)) {
  ------------------
  |  Branch (612:9): [True: 8.06k, False: 556k]
  |  Branch (612:25): [True: 0, False: 556k]
  ------------------
  613|  8.06k|        TA_FREEP(&p->temp_buf);
  ------------------
  |  |   81|  8.06k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  8.06k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 8.06k]
  |  |  ------------------
  ------------------
  614|  8.06k|        p->temp_buf = mp_aframe_create();
  615|  8.06k|        if (!mp_aframe_set_format(p->temp_buf, ao->format) ||
  ------------------
  |  Branch (615:13): [True: 0, False: 8.06k]
  ------------------
  616|  8.06k|            !mp_aframe_set_chmap(p->temp_buf, &ao->channels) ||
  ------------------
  |  Branch (616:13): [True: 0, False: 8.06k]
  ------------------
  617|  8.06k|            !mp_aframe_set_rate(p->temp_buf, ao->samplerate) ||
  ------------------
  |  Branch (617:13): [True: 58, False: 8.00k]
  ------------------
  618|  8.00k|            !mp_aframe_alloc_data(p->temp_buf, samples))
  ------------------
  |  Branch (618:13): [True: 0, False: 8.00k]
  ------------------
  619|     58|        {
  620|     58|            TA_FREEP(&p->temp_buf);
  ------------------
  |  |   81|     58|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     58|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 58]
  |  |  ------------------
  ------------------
  621|     58|            return false;
  622|     58|        }
  623|  8.06k|    }
  624|       |
  625|   564k|    return true;
  626|   564k|}

mp_to_av_stream_type:
   44|  36.4k|{
   45|  36.4k|    switch (type) {
   46|  19.8k|    case STREAM_VIDEO: return AVMEDIA_TYPE_VIDEO;
  ------------------
  |  Branch (46:5): [True: 19.8k, False: 16.6k]
  ------------------
   47|  14.9k|    case STREAM_AUDIO: return AVMEDIA_TYPE_AUDIO;
  ------------------
  |  Branch (47:5): [True: 14.9k, False: 21.4k]
  ------------------
   48|  1.68k|    case STREAM_SUB:   return AVMEDIA_TYPE_SUBTITLE;
  ------------------
  |  Branch (48:5): [True: 1.68k, False: 34.8k]
  ------------------
   49|      0|    default:           return AVMEDIA_TYPE_UNKNOWN;
  ------------------
  |  Branch (49:5): [True: 0, False: 36.4k]
  ------------------
   50|  36.4k|    }
   51|  36.4k|}
mp_codec_params_to_av:
   54|  55.2k|{
   55|  55.2k|    AVCodecParameters *avp = avcodec_parameters_alloc();
   56|  55.2k|    if (!avp)
  ------------------
  |  Branch (56:9): [True: 0, False: 55.2k]
  ------------------
   57|      0|        return NULL;
   58|       |
   59|       |    // If we have lavf demuxer params, they overwrite by definition any others.
   60|  55.2k|    if (c->lav_codecpar) {
  ------------------
  |  Branch (60:9): [True: 18.7k, False: 36.4k]
  ------------------
   61|  18.7k|        if (avcodec_parameters_copy(avp, c->lav_codecpar) < 0)
  ------------------
  |  Branch (61:13): [True: 0, False: 18.7k]
  ------------------
   62|      0|            goto error;
   63|  18.7k|        return avp;
   64|  18.7k|    }
   65|       |
   66|  36.4k|    avp->codec_type = mp_to_av_stream_type(c->type);
   67|  36.4k|    avp->codec_id = mp_codec_to_av_codec_id(c->codec);
   68|  36.4k|    avp->codec_tag = c->codec_tag;
   69|  36.4k|    if (c->extradata_size) {
  ------------------
  |  Branch (69:9): [True: 27.7k, False: 8.72k]
  ------------------
   70|  27.7k|        uint8_t *extradata = c->extradata;
   71|  27.7k|        int size = c->extradata_size;
   72|       |
   73|  27.7k|        if (avp->codec_id == AV_CODEC_ID_FLAC) {
  ------------------
  |  Branch (73:13): [True: 119, False: 27.6k]
  ------------------
   74|       |            // ffmpeg expects FLAC extradata to be just the STREAMINFO,
   75|       |            // so grab only that (and assume it'll be the first block)
   76|    119|            if (size >= 8 && !memcmp(c->extradata, "fLaC", 4)) {
  ------------------
  |  Branch (76:17): [True: 115, False: 4]
  |  Branch (76:30): [True: 115, False: 0]
  ------------------
   77|    115|                extradata += 8;
   78|    115|                size = MPMIN(34, size - 8); // FLAC_STREAMINFO_SIZE
  ------------------
  |  |   45|    115|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 115]
  |  |  ------------------
  ------------------
   79|    115|            }
   80|    119|        }
   81|       |
   82|  27.7k|        avp->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
   83|  27.7k|        if (!avp->extradata)
  ------------------
  |  Branch (83:13): [True: 0, False: 27.7k]
  ------------------
   84|      0|            goto error;
   85|  27.7k|        avp->extradata_size = size;
   86|  27.7k|        memcpy(avp->extradata, extradata, size);
   87|  27.7k|    }
   88|  36.4k|    avp->bits_per_coded_sample = c->bits_per_coded_sample;
   89|       |
   90|       |    // Video only
   91|  36.4k|    avp->width = c->disp_w;
   92|  36.4k|    avp->height = c->disp_h;
   93|       |
   94|       |    // Audio only
   95|  36.4k|    avp->sample_rate = c->samplerate;
   96|  36.4k|    avp->bit_rate = c->bitrate;
   97|  36.4k|    avp->block_align = c->block_align;
   98|       |
   99|  36.4k|    mp_chmap_to_av_layout(&avp->ch_layout, &c->channels);
  100|       |
  101|  36.4k|    return avp;
  102|      0|error:
  103|      0|    avcodec_parameters_free(&avp);
  104|       |    return NULL;
  105|  36.4k|}
mp_set_avctx_codec_headers:
  109|  35.7k|{
  110|  35.7k|    enum AVMediaType codec_type = avctx->codec_type;
  111|  35.7k|    enum AVCodecID codec_id = avctx->codec_id;
  112|  35.7k|    AVCodecParameters *avp = mp_codec_params_to_av(c);
  113|  35.7k|    if (!avp)
  ------------------
  |  Branch (113:9): [True: 0, False: 35.7k]
  ------------------
  114|      0|        return -1;
  115|       |
  116|  35.7k|    int r = avcodec_parameters_to_context(avctx, avp) < 0 ? -1 : 0;
  ------------------
  |  Branch (116:13): [True: 0, False: 35.7k]
  ------------------
  117|  35.7k|    avcodec_parameters_free(&avp);
  118|       |
  119|  35.7k|    if (avctx->codec_type != AVMEDIA_TYPE_UNKNOWN)
  ------------------
  |  Branch (119:9): [True: 35.7k, False: 0]
  ------------------
  120|  35.7k|        avctx->codec_type = codec_type;
  121|  35.7k|    if (avctx->codec_id != AV_CODEC_ID_NONE)
  ------------------
  |  Branch (121:9): [True: 35.7k, False: 0]
  ------------------
  122|  35.7k|        avctx->codec_id = codec_id;
  123|  35.7k|    return r;
  124|  35.7k|}
mp_get_codec_timebase:
  129|  34.3k|{
  130|  34.3k|    AVRational tb = {c->native_tb_num, c->native_tb_den};
  131|  34.3k|    if (tb.num < 1 || tb.den < 1) {
  ------------------
  |  Branch (131:9): [True: 34.3k, False: 0]
  |  Branch (131:23): [True: 0, False: 0]
  ------------------
  132|  34.3k|        if (c->reliable_fps)
  ------------------
  |  Branch (132:13): [True: 0, False: 34.3k]
  ------------------
  133|      0|            tb = av_inv_q(av_d2q(c->fps, 1000000));
  134|  34.3k|        if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (134:13): [True: 34.3k, False: 0]
  |  Branch (134:27): [True: 0, False: 0]
  ------------------
  135|  34.3k|            tb = AV_TIME_BASE_Q;
  136|  34.3k|    }
  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|  34.3k|    int64_t den = tb.den;
  141|  34.3k|    if (av_q2d(tb) > 0.001) {
  ------------------
  |  Branch (141:9): [True: 0, False: 34.3k]
  ------------------
  142|      0|        int64_t scaling_num = tb.num * INT64_C(1000);
  143|      0|        int64_t scaling_den = tb.den;
  144|      0|        den *= (scaling_num + scaling_den - 1) / scaling_den;
  145|      0|    }
  146|       |
  147|  34.3k|    av_reduce(&tb.num, &tb.den, tb.num, den, INT_MAX);
  148|       |
  149|  34.3k|    if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (149:9): [True: 0, False: 34.3k]
  |  Branch (149:23): [True: 0, False: 34.3k]
  ------------------
  150|      0|        tb = AV_TIME_BASE_Q;
  151|       |
  152|  34.3k|    return tb;
  153|  34.3k|}
mp_pts_to_av:
  163|  1.56M|{
  164|  1.56M|    AVRational b = get_def_tb(tb);
  165|  1.56M|    return mp_pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : llrint(mp_pts / av_q2d(b));
  ------------------
  |  |   39|  1.56M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (165:12): [True: 671k, False: 889k]
  ------------------
  166|  1.56M|}
mp_pts_from_av:
  170|   796k|{
  171|   796k|    AVRational b = get_def_tb(tb);
  172|   796k|    return av_pts == AV_NOPTS_VALUE ? MP_NOPTS_VALUE : av_pts * av_q2d(b);
  ------------------
  |  |   39|   410k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (172:12): [True: 410k, False: 386k]
  ------------------
  173|   796k|}
mp_set_av_packet:
  180|   780k|{
  181|   780k|    dst->side_data = NULL;
  182|   780k|    dst->side_data_elems = 0;
  183|   780k|    dst->buf = NULL;
  184|   780k|    av_packet_unref(dst);
  185|       |
  186|   780k|    dst->data = mpkt ? mpkt->buffer : NULL;
  ------------------
  |  Branch (186:17): [True: 755k, False: 25.1k]
  ------------------
  187|   780k|    dst->size = mpkt ? mpkt->len : 0;
  ------------------
  |  Branch (187:17): [True: 755k, False: 25.1k]
  ------------------
  188|       |    /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
  189|       |     * from demuxer. */
  190|   780k|    if (mpkt && mpkt->keyframe)
  ------------------
  |  Branch (190:9): [True: 755k, False: 25.1k]
  |  Branch (190:17): [True: 328k, False: 427k]
  ------------------
  191|   328k|        dst->flags |= AV_PKT_FLAG_KEY;
  192|   780k|    if (mpkt && mpkt->avpacket) {
  ------------------
  |  Branch (192:9): [True: 755k, False: 25.1k]
  |  Branch (192:17): [True: 755k, False: 0]
  ------------------
  193|   755k|        dst->side_data = mpkt->avpacket->side_data;
  194|   755k|        dst->side_data_elems = mpkt->avpacket->side_data_elems;
  195|   755k|        if (dst->data == mpkt->avpacket->data)
  ------------------
  |  Branch (195:13): [True: 755k, False: 0]
  ------------------
  196|   755k|            dst->buf = mpkt->avpacket->buf;
  197|   755k|        dst->flags |= mpkt->avpacket->flags;
  198|   755k|    }
  199|   780k|    if (mpkt && tb && tb->num > 0 && tb->den > 0)
  ------------------
  |  Branch (199:9): [True: 755k, False: 25.1k]
  |  Branch (199:17): [True: 755k, False: 0]
  |  Branch (199:23): [True: 755k, False: 0]
  |  Branch (199:38): [True: 755k, False: 0]
  ------------------
  200|   755k|        dst->duration = mpkt->duration / av_q2d(*tb);
  201|   780k|    dst->pts = mp_pts_to_av(mpkt ? mpkt->pts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  25.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (201:29): [True: 755k, False: 25.1k]
  ------------------
  202|   780k|    dst->dts = mp_pts_to_av(mpkt ? mpkt->dts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  25.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (202:29): [True: 755k, False: 25.1k]
  ------------------
  203|   780k|}
mp_set_avcodec_threads:
  206|  34.0k|{
  207|  34.0k|    if (threads == 0) {
  ------------------
  |  Branch (207:9): [True: 19.0k, False: 14.9k]
  ------------------
  208|  19.0k|        threads = av_cpu_count();
  209|  19.0k|        if (threads < 1) {
  ------------------
  |  Branch (209:13): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|        } else {
  213|  19.0k|            mp_verbose(l, "Detected %d logical cores.\n", threads);
  ------------------
  |  |   79|  19.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  214|  19.0k|            if (threads > 1)
  ------------------
  |  Branch (214:17): [True: 19.0k, False: 0]
  ------------------
  215|  19.0k|                threads += 1; // extra thread for better load balancing
  216|  19.0k|        }
  217|       |        // Apparently some libavcodec versions have or had trouble with more
  218|       |        // than 16 threads, and/or print a warning when using > 16.
  219|  19.0k|        threads = MPMIN(threads, 16);
  ------------------
  |  |   45|  19.0k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 19.0k, False: 0]
  |  |  ------------------
  ------------------
  220|  19.0k|    }
  221|  34.0k|    mp_verbose(l, "Requesting %d threads for decoding.\n", threads);
  ------------------
  |  |   79|  34.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  222|  34.0k|    avctx->thread_count = threads;
  223|  34.0k|}
mp_add_lavc_decoders:
  243|  36.2k|{
  244|       |    add_codecs(list, type, true);
  245|  36.2k|}
mp_codec_to_av_codec_id:
  281|  73.3k|{
  282|  73.3k|    int id = AV_CODEC_ID_NONE;
  283|  73.3k|    if (codec) {
  ------------------
  |  Branch (283:9): [True: 72.3k, False: 1.01k]
  ------------------
  284|  72.3k|        const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
  285|  72.3k|        if (desc)
  ------------------
  |  Branch (285:13): [True: 70.4k, False: 1.87k]
  ------------------
  286|  70.4k|            id = desc->id;
  287|  72.3k|        if (id == AV_CODEC_ID_NONE) {
  ------------------
  |  Branch (287:13): [True: 1.87k, False: 70.4k]
  ------------------
  288|  1.87k|            const AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
  289|  1.87k|            if (avcodec)
  ------------------
  |  Branch (289:17): [True: 0, False: 1.87k]
  ------------------
  290|      0|                id = avcodec->id;
  291|  1.87k|        }
  292|  72.3k|    }
  293|  73.3k|    return id;
  294|  73.3k|}
mp_codec_from_av_codec_id:
  297|  8.81M|{
  298|  8.81M|    const char *name = NULL;
  299|  8.81M|    const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
  300|  8.81M|    if (desc)
  ------------------
  |  Branch (300:9): [True: 8.81M, False: 0]
  ------------------
  301|  8.81M|        name = desc->name;
  302|  8.81M|    if (!name) {
  ------------------
  |  Branch (302:9): [True: 0, False: 8.81M]
  ------------------
  303|      0|        const AVCodec *avcodec = avcodec_find_decoder(codec_id);
  304|      0|        if (avcodec)
  ------------------
  |  Branch (304:13): [True: 0, False: 0]
  ------------------
  305|      0|            name = avcodec->name;
  306|      0|    }
  307|  8.81M|    return name;
  308|  8.81M|}
mp_codec_is_lossless:
  311|  17.5k|{
  312|  17.5k|    const AVCodecDescriptor *desc =
  313|  17.5k|        avcodec_descriptor_get(mp_codec_to_av_codec_id(codec));
  314|  17.5k|    return desc && (desc->props & AV_CODEC_PROP_LOSSLESS);
  ------------------
  |  Branch (314:12): [True: 15.9k, False: 1.68k]
  |  Branch (314:20): [True: 1.06k, False: 14.8k]
  ------------------
  315|  17.5k|}
mp_set_avopts:
  369|  34.4k|{
  370|  34.4k|    return mp_set_avopts_pos(log, avobj, avobj, kv);
  371|  34.4k|}
mp_set_avopts_pos:
  376|  34.4k|{
  377|  34.4k|    int success = 0;
  378|  34.4k|    for (int n = 0; kv && kv[n * 2]; n++) {
  ------------------
  |  Branch (378:21): [True: 0, False: 34.4k]
  |  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|  34.4k|    return success;
  394|  34.4k|}
mp_free_av_packet:
  405|  56.9k|{
  406|  56.9k|    if (*pkt) {
  ------------------
  |  Branch (406:9): [True: 37.0k, False: 19.9k]
  ------------------
  407|  37.0k|        (*pkt)->side_data = NULL;
  408|  37.0k|        (*pkt)->side_data_elems = 0;
  409|       |        (*pkt)->buf = NULL;
  410|  37.0k|    }
  411|  56.9k|    av_packet_free(pkt);
  412|  56.9k|}
mp_codec_info_from_av:
  415|   545k|{
  416|   545k|    c->codec_profile = av_get_profile_name(avctx->codec, avctx->profile);
  417|   545k|    if (!c->codec_profile)
  ------------------
  |  Branch (417:9): [True: 407k, False: 137k]
  ------------------
  418|   407k|        c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile);
  419|   545k|    c->codec = avctx->codec_descriptor->name;
  420|   545k|    c->codec_desc = avctx->codec_descriptor->long_name;
  421|   545k|    c->decoder = avctx->codec->name;
  422|   545k|    c->decoder_desc = avctx->codec->long_name;
  423|   545k|}
av_common.c:get_def_tb:
  156|  2.35M|{
  157|  2.35M|    return tb && tb->num > 0 && tb->den > 0 ? *tb : AV_TIME_BASE_Q;
  ------------------
  |  Branch (157:12): [True: 2.35M, False: 0]
  |  Branch (157:18): [True: 2.35M, False: 0]
  |  Branch (157:33): [True: 2.35M, False: 0]
  ------------------
  158|  2.35M|}
av_common.c:add_codecs:
  227|  36.2k|{
  228|  36.2k|    void *iter = NULL;
  229|  18.2M|    for (;;) {
  230|  18.2M|        const AVCodec *cur = av_codec_iterate(&iter);
  231|  18.2M|        if (!cur)
  ------------------
  |  Branch (231:13): [True: 36.2k, False: 18.1M]
  ------------------
  232|  36.2k|            break;
  233|  18.1M|        if (av_codec_is_decoder(cur) == decoders &&
  ------------------
  |  Branch (233:13): [True: 18.1M, False: 0]
  ------------------
  234|  18.1M|            (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type))
  ------------------
  |  Branch (234:14): [True: 0, False: 18.1M]
  |  Branch (234:46): [True: 8.73M, False: 9.42M]
  ------------------
  235|  8.73M|        {
  236|  8.73M|            mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id),
  237|  8.73M|                           cur->name, cur->long_name);
  238|  8.73M|        }
  239|  18.1M|    }
  240|  36.2k|}

init_libav:
  154|  24.7k|{
  155|  24.7k|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  156|  24.7k|    if (!log_mpv_instance) {
  ------------------
  |  Branch (156:9): [True: 24.7k, False: 0]
  ------------------
  157|  24.7k|        log_mpv_instance = global;
  158|  24.7k|        log_root = mp_log_new(NULL, global->log, "ffmpeg");
  159|  24.7k|        log_decaudio = mp_log_new(log_root, log_root, "audio");
  160|  24.7k|        log_decvideo = mp_log_new(log_root, log_root, "video");
  161|  24.7k|        log_demuxer = mp_log_new(log_root, log_root, "demuxer");
  162|  24.7k|        log_buffer = (bstr){0};
  163|  24.7k|        av_log_set_callback(mp_msg_av_log_callback);
  164|  24.7k|    }
  165|  24.7k|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  166|       |
  167|  24.7k|    avformat_network_init();
  168|       |
  169|  24.7k|#if HAVE_LIBAVDEVICE
  170|  24.7k|    avdevice_register_all();
  171|  24.7k|#endif
  172|  24.7k|}
uninit_libav:
  175|  24.7k|{
  176|  24.7k|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  177|  24.7k|    if (log_mpv_instance == global) {
  ------------------
  |  Branch (177:9): [True: 24.7k, False: 0]
  ------------------
  178|  24.7k|        av_log_set_callback(av_log_default_callback);
  179|  24.7k|        log_mpv_instance = NULL;
  180|  24.7k|        talloc_free(log_root);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  181|  24.7k|    }
  182|  24.7k|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  183|  24.7k|}
check_library_versions:
  196|  49.5k|{
  197|  49.5k|    const struct lib libs[] = {
  198|  49.5k|        {"libavcodec",    LIBAVCODEC_VERSION_INT,    avcodec_version()},
  199|  49.5k|#if HAVE_LIBAVDEVICE
  200|  49.5k|        {"libavdevice",   LIBAVDEVICE_VERSION_INT,   avdevice_version()},
  201|  49.5k|#endif
  202|  49.5k|        {"libavfilter",   LIBAVFILTER_VERSION_INT,   avfilter_version()},
  203|  49.5k|        {"libavformat",   LIBAVFORMAT_VERSION_INT,   avformat_version()},
  204|  49.5k|        {"libavutil",     LIBAVUTIL_VERSION_INT,     avutil_version()},
  205|  49.5k|        {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()},
  206|  49.5k|        {"libswscale",    LIBSWSCALE_VERSION_INT,    swscale_version()},
  207|  49.5k|    };
  208|       |
  209|  49.5k|    const char *runtime_version = av_version_info();
  210|  49.5k|    mp_msg(log, v, "FFmpeg version: %s", FFMPEG_VERSION);
  211|  49.5k|    if (strcmp(runtime_version, FFMPEG_VERSION))
  ------------------
  |  Branch (211:9): [True: 0, False: 49.5k]
  ------------------
  212|      0|        mp_msg(log, v, " (runtime %s)", runtime_version);
  213|  49.5k|    mp_msg(log, v, "\n");
  214|  49.5k|    mp_msg(log, v, "FFmpeg library versions:\n");
  215|       |
  216|   396k|    for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) {
  ------------------
  |  |   49|   396k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (216:21): [True: 346k, False: 49.5k]
  ------------------
  217|   346k|        const struct lib *l = &libs[n];
  218|   346k|        mp_msg(log, v, "   %-15s %d.%d.%d", l->name, V(l->buildv));
  ------------------
  |  |  185|   346k|#define V(x) AV_VERSION_MAJOR(x), \
  |  |  186|   346k|             AV_VERSION_MINOR(x), \
  |  |  187|   346k|             AV_VERSION_MICRO(x)
  ------------------
  219|   346k|        if (l->buildv != l->runv)
  ------------------
  |  Branch (219:13): [True: 0, False: 346k]
  ------------------
  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|   346k|        mp_msg(log, v, "\n");
  222|   346k|        if (l->buildv > l->runv ||
  ------------------
  |  Branch (222:13): [True: 0, False: 346k]
  ------------------
  223|   346k|            AV_VERSION_MAJOR(l->buildv) != AV_VERSION_MAJOR(l->runv))
  ------------------
  |  Branch (223:13): [True: 0, False: 346k]
  ------------------
  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|   346k|    }
  230|  49.5k|}
av_log.c:mp_msg_av_log_callback:
  119|  7.51M|{
  120|  7.51M|    AVClass *avc = ptr ? *(AVClass **)ptr : NULL;
  ------------------
  |  Branch (120:20): [True: 4.49M, False: 3.02M]
  ------------------
  121|  7.51M|    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|  7.51M|    mp_mutex_lock(&log_lock);
  ------------------
  |  |  134|  7.51M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  125|       |
  126|  7.51M|    if (!log_mpv_instance) {
  ------------------
  |  Branch (126:9): [True: 0, False: 7.51M]
  ------------------
  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|  7.51M|    struct mp_log *log = get_av_log(ptr);
  134|       |
  135|  7.52M|    if (mp_msg_test(log, mp_level)) {
  ------------------
  |  Branch (135:9): [True: 7.52M, False: 18.4E]
  ------------------
  136|  7.52M|        log_buffer.len = 0;
  137|  7.52M|        bstr_xappend_vasprintf(log_root, &log_buffer, fmt, vl);
  138|  7.52M|        if (!log_buffer.len)
  ------------------
  |  Branch (138:13): [True: 0, False: 7.52M]
  ------------------
  139|      0|            goto done;
  140|  7.52M|        const char *prefix = avc ? avclass_item_name(ptr, avc) : NULL;
  ------------------
  |  Branch (140:30): [True: 4.49M, False: 3.02M]
  ------------------
  141|  7.52M|        if (log_print_prefix && prefix) {
  ------------------
  |  Branch (141:13): [True: 6.19M, False: 1.32M]
  |  Branch (141:33): [True: 4.46M, False: 1.72M]
  ------------------
  142|  4.46M|            mp_msg(log, mp_level, "%s: %.*s", prefix, BSTR_P(log_buffer));
  ------------------
  |  |  307|  4.46M|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 4.46M, False: 0]
  |  |  ------------------
  ------------------
  143|  4.46M|        } else {
  144|  3.05M|            mp_msg(log, mp_level, "%.*s", BSTR_P(log_buffer));
  ------------------
  |  |  307|  3.05M|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 3.05M, False: 0]
  |  |  ------------------
  ------------------
  145|  3.05M|        }
  146|  7.52M|        log_print_prefix = log_buffer.start[log_buffer.len - 1] == '\n';
  147|  7.52M|    }
  148|       |
  149|  7.52M|done:
  150|  7.52M|    mp_mutex_unlock(&log_lock);
  ------------------
  |  |  136|  7.52M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  151|  7.52M|}
av_log.c:av_log_level_to_mp_level:
   63|  7.51M|{
   64|  7.51M|    if (av_level > AV_LOG_VERBOSE)
  ------------------
  |  Branch (64:9): [True: 4.61M, False: 2.90M]
  ------------------
   65|  4.61M|        return MSGL_TRACE;
   66|  2.90M|    if (av_level > AV_LOG_INFO)
  ------------------
  |  Branch (66:9): [True: 357k, False: 2.54M]
  ------------------
   67|   357k|        return MSGL_DEBUG;
   68|  2.54M|    if (av_level > AV_LOG_WARNING)
  ------------------
  |  Branch (68:9): [True: 116k, False: 2.43M]
  ------------------
   69|   116k|        return MSGL_V;
   70|  2.43M|    if (av_level > AV_LOG_ERROR)
  ------------------
  |  Branch (70:9): [True: 188k, False: 2.24M]
  ------------------
   71|   188k|        return MSGL_WARN;
   72|  2.24M|    if (av_level > AV_LOG_FATAL)
  ------------------
  |  Branch (72:9): [True: 2.24M, False: 160]
  ------------------
   73|  2.24M|        return MSGL_ERR;
   74|    160|    return MSGL_FATAL;
   75|  2.24M|}
av_log.c:get_av_log:
   78|  7.52M|{
   79|  7.52M|    if (!ptr)
  ------------------
  |  Branch (79:9): [True: 3.02M, False: 4.49M]
  ------------------
   80|  3.02M|        return log_root;
   81|       |
   82|  4.49M|    AVClass *avc = *(AVClass **)ptr;
   83|  4.49M|    if (!avc) {
  ------------------
  |  Branch (83:9): [True: 0, False: 4.49M]
  ------------------
   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|  4.49M|    if (!strcmp(avc->class_name, "AVCodecContext")) {
  ------------------
  |  Branch (90:9): [True: 4.48M, False: 8.91k]
  ------------------
   91|  4.48M|        AVCodecContext *s = ptr;
   92|  4.48M|        if (s->codec) {
  ------------------
  |  Branch (92:13): [True: 4.48M, False: 0]
  ------------------
   93|  4.48M|            if (s->codec->type == AVMEDIA_TYPE_AUDIO) {
  ------------------
  |  Branch (93:17): [True: 1.19M, False: 3.29M]
  ------------------
   94|  1.19M|                if (av_codec_is_decoder(s->codec))
  ------------------
  |  Branch (94:21): [True: 1.19M, False: 0]
  ------------------
   95|  1.19M|                    return log_decaudio;
   96|  3.29M|            } else if (s->codec->type == AVMEDIA_TYPE_VIDEO) {
  ------------------
  |  Branch (96:24): [True: 3.28M, False: 5.48k]
  ------------------
   97|  3.28M|                if (av_codec_is_decoder(s->codec))
  ------------------
  |  Branch (97:21): [True: 3.28M, False: 0]
  ------------------
   98|  3.28M|                    return log_decvideo;
   99|  3.28M|            }
  100|  4.48M|        }
  101|  4.48M|    }
  102|       |
  103|  14.4k|    if (!strcmp(avc->class_name, "AVFormatContext")) {
  ------------------
  |  Branch (103:9): [True: 0, False: 14.4k]
  ------------------
  104|      0|        AVFormatContext *s = ptr;
  105|      0|        if (s->iformat)
  ------------------
  |  Branch (105:13): [True: 0, False: 0]
  ------------------
  106|      0|            return log_demuxer;
  107|      0|    }
  108|       |
  109|  14.4k|    return log_root;
  110|  14.4k|}
av_log.c:avclass_item_name:
  113|  4.49M|{
  114|  4.49M|    return (avc->item_name ? avc->item_name : av_default_item_name)(obj);
  ------------------
  |  Branch (114:13): [True: 4.49M, False: 0]
  ------------------
  115|  4.49M|}

mp_add_decoder:
   26|  8.78M|{
   27|  8.78M|    struct mp_decoder_entry entry = {
   28|  8.78M|        .codec = talloc_strdup(list, codec),
  ------------------
  |  |   50|  8.78M|#define talloc_strdup                   ta_xstrdup
  ------------------
   29|  8.78M|        .decoder = talloc_strdup(list, decoder),
  ------------------
  |  |   50|  8.78M|#define talloc_strdup                   ta_xstrdup
  ------------------
   30|  8.78M|        .desc = talloc_strdup(list, desc),
  ------------------
  |  |   50|  8.78M|#define talloc_strdup                   ta_xstrdup
  ------------------
   31|  8.78M|    };
   32|  8.78M|    MP_TARRAY_APPEND(list, list->entries, list->num_entries, entry);
  ------------------
  |  |  105|  8.78M|    do {                                            \
  |  |  106|  8.78M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  8.78M|    do {                                            \
  |  |  |  |   97|  8.78M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  8.78M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  8.78M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  8.78M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 307k, False: 8.47M]
  |  |  |  |  ------------------
  |  |  |  |   99|  8.78M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   307k|    do {                                                        \
  |  |  |  |  |  |   89|   307k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   307k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   307k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   307k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   307k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   307k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   307k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 307k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  8.78M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 8.78M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  8.78M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  8.78M|        (idxvar)++;                                 \
  |  |  109|  8.78M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.78M]
  |  |  ------------------
  ------------------
   33|  8.78M|}
mp_select_decoders:
   60|  36.2k|{
   61|  36.2k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  36.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  36.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  36.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  36.2k|    if (!codec)
  ------------------
  |  Branch (62:9): [True: 0, False: 36.2k]
  ------------------
   63|      0|        codec = "unknown";
   64|  36.2k|    bool stop = false;
   65|  36.2k|    bstr sel = bstr0(selection);
   66|  36.2k|    while (sel.len) {
  ------------------
  |  Branch (66:12): [True: 0, False: 36.2k]
  ------------------
   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|  36.2k|    if (!stop) {
  ------------------
  |  Branch (80:9): [True: 36.2k, False: 0]
  ------------------
   81|       |        // Add the remaining codecs which haven't been added yet
   82|  8.77M|        for (int n = 0; n < all->num_entries; n++)
  ------------------
  |  Branch (82:25): [True: 8.73M, False: 36.2k]
  ------------------
   83|  8.73M|            add_new(list, &all->entries[n], codec);
   84|  36.2k|    }
   85|  36.2k|    return list;
   86|  36.2k|}
mp_print_decoders:
   96|  36.2k|{
   97|  36.2k|    mp_msg(log, msgl, "%s\n", header);
   98|  87.5k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (98:21): [True: 51.2k, False: 36.2k]
  ------------------
   99|  51.2k|        struct mp_decoder_entry *entry = &list->entries[n];
  100|  51.2k|        mp_msg(log, msgl, "    %s", entry->decoder);
  101|  51.2k|        if (strcmp(entry->decoder, entry->codec) != 0)
  ------------------
  |  Branch (101:13): [True: 18.3k, False: 32.9k]
  ------------------
  102|  18.3k|            mp_msg(log, msgl, " (%s)", entry->codec);
  103|  51.2k|        mp_msg(log, msgl, " - %s\n", entry->desc);
  104|  51.2k|    }
  105|  36.2k|    if (list->num_entries == 0)
  ------------------
  |  Branch (105:9): [True: 2.61k, False: 33.6k]
  ------------------
  106|  2.61k|        mp_msg(log, msgl, "    (no decoders)\n");
  107|  36.2k|}
codecs.c:add_new:
   39|  8.73M|{
   40|  8.73M|    if (!entry || (codec && strcmp(entry->codec, codec) != 0))
  ------------------
  |  Branch (40:9): [True: 0, False: 8.73M]
  |  Branch (40:20): [True: 8.73M, False: 0]
  |  Branch (40:29): [True: 8.68M, False: 51.2k]
  ------------------
   41|  8.68M|        return;
   42|  51.2k|    mp_add_decoder(to, entry->codec, entry->decoder, entry->desc);
   43|  51.2k|}

mp_format_double:
   99|  6.83k|{
  100|  6.83k|    bstr str = {0};
  101|  6.83k|    const char *fmt = plus_sign ? "%+.*f" : "%.*f";
  ------------------
  |  Branch (101:23): [True: 0, False: 6.83k]
  ------------------
  102|  6.83k|    bstr_xappend_asprintf(talloc_ctx, &str, fmt, precision, val);
  103|  6.83k|    size_t pos = str.len;
  104|  6.83k|    if (trim) {
  ------------------
  |  Branch (104:9): [True: 6.83k, False: 0]
  ------------------
  105|  19.5k|        while (--pos && str.start[pos] == '0')
  ------------------
  |  Branch (105:16): [True: 19.5k, False: 0]
  |  Branch (105:25): [True: 12.7k, False: 6.83k]
  ------------------
  106|  12.7k|            str.len--;
  107|  6.83k|        if (str.start[pos] == '.')
  ------------------
  |  Branch (107:13): [True: 510, False: 6.32k]
  ------------------
  108|    510|            str.len--;
  109|  6.83k|    }
  110|  6.83k|    if (percent_sign)
  ------------------
  |  Branch (110:9): [True: 0, False: 6.83k]
  ------------------
  111|      0|        bstr_xappend(talloc_ctx, &str, bstr0("%"));
  112|  6.83k|    str.start[str.len] = '\0';
  113|  6.83k|    return str.start;
  114|  6.83k|}
mp_rect_equals:
  144|   890k|{
  145|   890k|    return rc1->x0 == rc2->x0 && rc1->y0 == rc2->y0 &&
  ------------------
  |  Branch (145:12): [True: 890k, False: 1]
  |  Branch (145:34): [True: 890k, False: 4]
  ------------------
  146|   890k|           rc1->x1 == rc2->x1 && rc1->y1 == rc2->y1;
  ------------------
  |  Branch (146:12): [True: 890k, False: 3]
  |  Branch (146:34): [True: 890k, False: 0]
  ------------------
  147|   890k|}
mp_snprintf_cat:
  214|   997k|{
  215|   997k|    size_t len = strnlen(str, size);
  216|   997k|    mp_assert(!size || len < size); // str with no 0-termination is not allowed
  ------------------
  |  |   41|   997k|#define mp_assert assert
  ------------------
  |  Branch (216:5): [True: 0, False: 997k]
  |  Branch (216:5): [True: 997k, False: 0]
  ------------------
  217|   997k|    int r;
  218|   997k|    va_list ap;
  219|   997k|    va_start(ap, format);
  220|   997k|    r = vsnprintf(str + len, size - len, format, ap);
  221|       |    va_end(ap);
  222|   997k|    return r;
  223|   997k|}
mp_append_utf8_bstr:
  229|  8.35k|{
  230|  8.35k|    char data[8];
  231|  8.35k|    uint8_t tmp;
  232|  8.35k|    char *output = data;
  233|       |    PUT_UTF8(codepoint, tmp, *output++ = tmp;);
  ------------------
  |  Branch (233:5): [True: 8.35k, False: 8.35k]
  |  Branch (233:5): [True: 0, False: 8.35k]
  ------------------
  234|  8.35k|    bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
  235|  8.35k|}
mp_tprintf_buf:
  376|  29.5k|{
  377|  29.5k|    va_list ap;
  378|  29.5k|    va_start(ap, format);
  379|  29.5k|    vsnprintf(buf, buf_size, format, ap);
  380|       |    va_end(ap);
  381|  29.5k|    return buf;
  382|  29.5k|}
mp_dup_str_array:
  385|  97.2k|{
  386|  97.2k|    char **r = NULL;
  387|  97.2k|    int num_r = 0;
  388|  97.6k|    for (int n = 0; s && s[n]; n++)
  ------------------
  |  Branch (388:21): [True: 473, False: 97.1k]
  |  Branch (388:26): [True: 360, False: 113]
  ------------------
  389|    360|        MP_TARRAY_APPEND(tctx, r, num_r, talloc_strdup(tctx, s[n]));
  ------------------
  |  |  105|    360|    do {                                            \
  |  |  106|    360|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    360|    do {                                            \
  |  |  |  |   97|    360|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    360|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    360|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    360|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 120, False: 240]
  |  |  |  |  ------------------
  |  |  |  |   99|    360|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    120|    do {                                                        \
  |  |  |  |  |  |   89|    120|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    120|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    120|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    120|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    120|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    120|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    120|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 120]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    360|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 360]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    360|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    360|        (idxvar)++;                                 \
  |  |  109|    360|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 360]
  |  |  ------------------
  ------------------
  390|  97.2k|    if (r)
  ------------------
  |  Branch (390:9): [True: 60, False: 97.1k]
  ------------------
  391|     60|        MP_TARRAY_APPEND(tctx, r, num_r, NULL);
  ------------------
  |  |  105|     60|    do {                                            \
  |  |  106|     60|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     60|    do {                                            \
  |  |  |  |   97|     60|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     60|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     60|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     60|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     60|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     60|    do {                                                        \
  |  |  |  |  |  |   89|     60|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     60|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     60|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     60|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     60|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     60|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     60|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 60]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     60|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     60|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     60|        (idxvar)++;                                 \
  |  |  109|     60|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60]
  |  |  ------------------
  ------------------
  392|  97.2k|    return r;
  393|  97.2k|}
mp_log2:
  401|  3.67M|{
  402|  3.67M|#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
  403|  3.67M|    return v ? 31 - __builtin_clz(v) : 0;
  ------------------
  |  Branch (403:12): [True: 3.66M, False: 12.7k]
  ------------------
  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|  3.67M|}
mp_round_next_power_of_2:
  419|   579k|{
  420|   579k|    if (!v)
  ------------------
  |  Branch (420:9): [True: 0, False: 579k]
  ------------------
  421|      0|        return 1;
  422|   579k|    if (!(v & (v - 1)))
  ------------------
  |  Branch (422:9): [True: 571k, False: 7.69k]
  ------------------
  423|   571k|        return v;
  424|  7.69k|    int l = mp_log2(v) + 1;
  425|  7.69k|    return l == 32 ? 0 : (uint32_t)1 << l;
  ------------------
  |  Branch (425:12): [True: 0, False: 7.69k]
  ------------------
  426|   579k|}
mp_lcm:
  429|   991k|{
  430|   991k|    mp_assert(x && y);
  ------------------
  |  |   41|   991k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 991k, False: 0]
  |  Branch (430:5): [True: 991k, False: 0]
  ------------------
  431|   991k|    return x * (y / av_gcd(x, y));
  432|   991k|}

encode_lavc_free:
  189|  24.7k|{
  190|  24.7k|    bool res = true;
  191|  24.7k|    if (!ctx)
  ------------------
  |  Branch (191:9): [True: 24.7k, False: 0]
  ------------------
  192|  24.7k|        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|  24.7k|}
encode_lavc_discontinuity:
  436|  25.1k|{
  437|  25.1k|    if (!ctx)
  ------------------
  |  Branch (437:9): [True: 25.1k, False: 0]
  ------------------
  438|  25.1k|        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|  24.7k|{
  521|  24.7k|    bool help_output = false;
  522|  24.7k|#define CHECKS(str) ((str) && \
  523|  24.7k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  524|  24.7k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  525|  24.7k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  526|  24.7k|    if (CHECKS(opts->format)) {
  ------------------
  |  |  522|  24.7k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 24.7k]
  |  |  |  Branch (522:22): [True: 0, False: 24.7k]
  |  |  ------------------
  |  |  523|  24.7k|                     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|  24.7k|    if (CHECKV(opts->fopts)) {
  ------------------
  |  |  524|  24.7k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 24.7k]
  |  |  |  Branch (524:23): [True: 0, False: 24.7k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  24.7k|                      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|  24.7k|    if (CHECKV(opts->vopts)) {
  ------------------
  |  |  524|  24.7k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 24.7k]
  |  |  |  Branch (524:23): [True: 0, False: 24.7k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  24.7k|                      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|  24.7k|    if (CHECKV(opts->aopts)) {
  ------------------
  |  |  524|  24.7k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 24.7k]
  |  |  |  Branch (524:23): [True: 0, False: 24.7k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  24.7k|                      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|  24.7k|    if (CHECKS(opts->vcodec)) {
  ------------------
  |  |  522|  24.7k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 24.7k]
  |  |  |  Branch (522:22): [True: 0, False: 24.7k]
  |  |  ------------------
  |  |  523|  24.7k|                     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|  24.7k|    if (CHECKS(opts->acodec)) {
  ------------------
  |  |  522|  24.7k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 24.7k]
  |  |  |  Branch (522:22): [True: 0, False: 24.7k]
  |  |  ------------------
  |  |  523|  24.7k|                     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|  24.7k|    return help_output;
  648|  24.7k|}
encode_lavc_didfail:
  692|   275k|{
  693|   275k|    if (!ctx)
  ------------------
  |  Branch (693:9): [True: 275k, False: 0]
  ------------------
  694|   275k|        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|   275k|}

mp_msg_level:
  184|  31.5M|{
  185|  31.5M|    struct mp_log_root *root = log->root;
  186|  31.5M|    if (!root)
  ------------------
  |  Branch (186:9): [True: 420k, False: 31.1M]
  ------------------
  187|   420k|        return -1;
  188|  31.1M|    if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) !=
  ------------------
  |  Branch (188:9): [True: 507k, False: 30.5M]
  ------------------
  189|  31.1M|        atomic_load_explicit(&root->reload_counter, memory_order_relaxed))
  190|   507k|    {
  191|   507k|        update_loglevel(log);
  192|   507k|    }
  193|       |    return atomic_load_explicit(&log->level, memory_order_relaxed);
  194|  31.5M|}
mp_msg_flush_status_line:
  295|  49.5k|{
  296|  49.5k|    if (!log->root)
  ------------------
  |  Branch (296:9): [True: 0, False: 49.5k]
  ------------------
  297|      0|        return;
  298|       |
  299|  49.5k|    mp_mutex_lock(&log->root->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|  49.5k|    msg_flush_status_line(log->root, clear);
  301|  49.5k|    mp_mutex_unlock(&log->root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  302|  49.5k|}
mp_msg_sanitize:
  576|  19.5M|{
  577|   891M|    for (size_t i = 0; i < text->len; i++) {
  ------------------
  |  Branch (577:24): [True: 871M, False: 19.5M]
  ------------------
  578|   871M|        unsigned char ch = text->start[i];
  579|       |
  580|       |        // Allow SGR escape sequences only, filter anything else.
  581|   871M|        if (allow_sgr && ch == 0x1B && i + 2 < text->len && text->start[i + 1] == '[') {
  ------------------
  |  Branch (581:13): [True: 871M, False: 0]
  |  Branch (581:26): [True: 533, False: 871M]
  |  Branch (581:40): [True: 527, False: 6]
  |  Branch (581:61): [True: 10, False: 517]
  ------------------
  582|     10|            size_t j = i + 2;
  583|     10|            bool sgr = false;
  584|       |
  585|     15|            while (j < text->len) {
  ------------------
  |  Branch (585:20): [True: 15, False: 0]
  ------------------
  586|     15|                unsigned char c = text->start[j];
  587|     15|                if (c == 'm') {
  ------------------
  |  Branch (587:21): [True: 0, False: 15]
  ------------------
  588|      0|                    sgr = true;
  589|      0|                    i = j;
  590|      0|                    break;
  591|     15|                } else if ((c >= '0' && c <= '9') || c == ';' || c == ':') {
  ------------------
  |  Branch (591:29): [True: 13, False: 2]
  |  Branch (591:41): [True: 5, False: 8]
  |  Branch (591:54): [True: 0, False: 10]
  |  Branch (591:66): [True: 0, False: 10]
  ------------------
  592|      5|                    j++;
  593|     10|                } else {
  594|     10|                    break;
  595|     10|                }
  596|     15|            }
  597|       |
  598|       |            // Nuke everything that is not an SGR sequence
  599|     10|            if (!sgr)
  ------------------
  |  Branch (599:17): [True: 10, False: 0]
  ------------------
  600|     10|                text->start[i] = '?';
  601|     10|            continue;
  602|     10|        }
  603|       |
  604|   871M|        int len = bstr_parse_utf8_code_length(ch);
  605|       |
  606|       |        // ASCII: allow only printable plus HT, LF, CR.
  607|   871M|        if (len == 1) {
  ------------------
  |  Branch (607:13): [True: 870M, False: 820k]
  ------------------
  608|   870M|            if (ch == 0x7F || (ch < 0x20 && ch != '\t' && ch != '\n' && ch != '\r'))
  ------------------
  |  Branch (608:17): [True: 1.82k, False: 870M]
  |  Branch (608:32): [True: 15.9M, False: 855M]
  |  Branch (608:45): [True: 15.9M, False: 399]
  |  Branch (608:59): [True: 81.3k, False: 15.8M]
  |  Branch (608:73): [True: 40.0k, False: 41.2k]
  ------------------
  609|  41.8k|                text->start[i] = '?';
  610|   870M|            continue;
  611|   870M|        }
  612|       |
  613|       |        // Block UTF-8 C1 controls (C2 80..C2 9F), except PU1/PU2 used internally.
  614|   820k|        if (ch == 0xC2 && i + 1 < text->len && (text->start[i + 1] & 0xC0) == 0x80) {
  ------------------
  |  Branch (614:13): [True: 37.3k, False: 783k]
  |  Branch (614:27): [True: 37.3k, False: 4]
  |  Branch (614:48): [True: 36.8k, False: 584]
  ------------------
  615|  36.8k|            unsigned char c1 = text->start[i + 1];
  616|  36.8k|            if (c1 >= 0x80 && c1 <= 0x9F && c1 != 0x91 && c1 != 0x92) {
  ------------------
  |  Branch (616:17): [True: 36.8k, False: 0]
  |  Branch (616:31): [True: 5.35k, False: 31.4k]
  |  Branch (616:45): [True: 5.27k, False: 85]
  |  Branch (616:59): [True: 5.17k, False: 96]
  ------------------
  617|  5.17k|                text->start[i] = '?';
  618|  5.17k|                text->start[i + 1] = '?';
  619|  5.17k|            }
  620|  36.8k|            i++;
  621|  36.8k|            continue;
  622|  36.8k|        }
  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|   783k|        if (len >= 2 && ch >= 0xC2 && i + len <= text->len) {
  ------------------
  |  Branch (626:13): [True: 720k, False: 63.1k]
  |  Branch (626:25): [True: 718k, False: 1.65k]
  |  Branch (626:39): [True: 715k, False: 3.04k]
  ------------------
  627|   715k|            bool valid = true;
  628|  2.13M|            for (int n = 1; n < len; n++)
  ------------------
  |  Branch (628:29): [True: 1.41M, False: 715k]
  ------------------
  629|  1.41M|                valid &= (text->start[i + n] & 0xC0) == 0x80;
  630|   715k|            if (valid) {
  ------------------
  |  Branch (630:17): [True: 690k, False: 25.0k]
  ------------------
  631|   690k|                i += len - 1;
  632|   690k|                continue;
  633|   690k|            }
  634|   715k|        }
  635|       |
  636|       |        // Block raw 8-bit C1 (0x80-0x9F); leave other invalid bytes alone.
  637|  92.9k|        if (ch <= 0x9F)
  ------------------
  |  Branch (637:13): [True: 26.1k, False: 66.7k]
  ------------------
  638|  26.1k|            text->start[i] = '?';
  639|  92.9k|    }
  640|  19.5M|}
mp_msg_va:
  654|  23.6M|{
  655|  23.6M|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (655:9): [True: 4.13M, False: 19.5M]
  ------------------
  656|  4.13M|        return; // do not display
  657|       |
  658|  19.5M|    struct mp_log_root *root = log->root;
  659|       |
  660|  19.5M|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  19.5M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  661|       |
  662|  19.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|  19.5M|    size_t sanitized = utf8_tail_start(log->partial[lev]);
  667|  19.5M|    if (log->partial[lev].len)
  ------------------
  |  Branch (667:9): [True: 3.78M, False: 15.7M]
  ------------------
  668|  3.78M|        bstr_xappend(root, &root->buffer, log->partial[lev]);
  669|  19.5M|    log->partial[lev].len = 0;
  670|       |
  671|  19.5M|    if (bstr_xappend_vasprintf(root, &root->buffer, format, va) < 0) {
  ------------------
  |  Branch (671:9): [True: 0, False: 19.5M]
  ------------------
  672|      0|        bstr_xappend(root, &root->buffer, bstr0("format error: "));
  673|      0|        bstr_xappend(root, &root->buffer, bstr0(format));
  674|      0|    }
  675|       |
  676|  19.5M|    bstr text = {root->buffer.start + sanitized, root->buffer.len - sanitized};
  677|  19.5M|    mp_msg_sanitize(&text, true);
  678|       |
  679|       |    // Remember last status message and restore it to ensure that it is
  680|       |    // always displayed
  681|  19.5M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (681:9): [True: 0, False: 19.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|  19.5M|    if (lev == MSGL_STATS) {
  ------------------
  |  Branch (689:9): [True: 0, False: 19.5M]
  ------------------
  690|      0|        dump_stats(log, lev, root->buffer);
  691|  19.5M|    } else if (lev == MSGL_STATUS && !test_terminal_level(log, lev)) {
  ------------------
  |  Branch (691:16): [True: 0, False: 19.5M]
  |  Branch (691:38): [True: 0, False: 0]
  ------------------
  692|       |        /* discard */
  693|  19.5M|    } else {
  694|  19.5M|        write_term_msg(log, lev, root->buffer, &root->term_msg);
  695|       |
  696|  19.5M|        FILE *stream = term_msg_fp(root, lev);
  697|  19.5M|        if (root->term_msg.len) {
  ------------------
  |  Branch (697:13): [True: 0, False: 19.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|  19.5M|    }
  713|       |
  714|  19.5M|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  19.5M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  715|  19.5M|}
mp_log_new:
  737|  1.26M|{
  738|  1.26M|    mp_assert(parent);
  ------------------
  |  |   41|  1.26M|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 1.26M, False: 0]
  ------------------
  739|  1.26M|    struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  1.26M|    if (!parent->root)
  ------------------
  |  Branch (740:9): [True: 0, False: 1.26M]
  ------------------
  741|      0|        return log; // same as null_log
  742|  1.26M|    talloc_set_destructor(log, destroy_log);
  ------------------
  |  |   41|  1.26M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  743|  1.26M|    log->root = parent->root;
  744|  1.26M|    log->max_level = MSGL_MAX;
  745|  1.26M|    if (name) {
  ------------------
  |  Branch (745:9): [True: 1.22M, False: 34.0k]
  ------------------
  746|  1.22M|        if (name[0] == '!') {
  ------------------
  |  Branch (746:13): [True: 181k, False: 1.04M]
  ------------------
  747|   181k|            name = &name[1];
  748|  1.04M|        } else if (name[0] == '/') {
  ------------------
  |  Branch (748:20): [True: 0, False: 1.04M]
  ------------------
  749|      0|            name = &name[1];
  750|      0|            log->prefix = talloc_strdup(log, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  751|  1.04M|        } else {
  752|  1.04M|            log->prefix = parent->prefix
  ------------------
  |  Branch (752:27): [True: 131k, False: 915k]
  ------------------
  753|  1.04M|                    ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   131k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   131k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  754|  1.04M|                    : talloc_strdup(log, name);
  ------------------
  |  |   50|   915k|#define talloc_strdup                   ta_xstrdup
  ------------------
  755|  1.04M|        }
  756|  1.22M|        log->verbose_prefix = parent->prefix
  ------------------
  |  Branch (756:31): [True: 131k, False: 1.09M]
  ------------------
  757|  1.22M|                ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   131k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   131k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  758|  1.22M|                : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.09M|#define talloc_strdup                   ta_xstrdup
  ------------------
  759|  1.22M|        if (log->prefix && !log->prefix[0])
  ------------------
  |  Branch (759:13): [True: 1.04M, False: 181k]
  |  Branch (759:28): [True: 24.7k, False: 1.02M]
  ------------------
  760|  24.7k|            log->prefix = NULL;
  761|  1.22M|        if (!log->verbose_prefix[0])
  ------------------
  |  Branch (761:13): [True: 24.7k, False: 1.20M]
  ------------------
  762|  24.7k|            log->verbose_prefix = "global";
  763|  1.22M|    } else {
  764|  34.0k|        log->prefix = talloc_strdup(log, parent->prefix);
  ------------------
  |  |   50|  34.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|  34.0k|        log->verbose_prefix = talloc_strdup(log, parent->verbose_prefix);
  ------------------
  |  |   50|  34.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  766|  34.0k|    }
  767|  1.26M|    return log;
  768|  1.26M|}
mp_msg_init:
  771|  24.7k|{
  772|  24.7k|    mp_assert(!global->log);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (772:5): [True: 24.7k, False: 0]
  ------------------
  773|       |
  774|  24.7k|    struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  775|  24.7k|    *root = (struct mp_log_root){
  776|  24.7k|        .global = global,
  777|  24.7k|        .reload_counter = 1,
  778|  24.7k|    };
  779|       |
  780|  24.7k|    mp_mutex_init(&root->lock);
  781|  24.7k|    mp_mutex_init(&root->log_file_lock);
  782|  24.7k|    mp_cond_init(&root->log_file_wakeup);
  783|       |
  784|  24.7k|    struct mp_log dummy = { .root = root };
  785|  24.7k|    struct mp_log *log = mp_log_new(root, &dummy, "");
  786|       |
  787|  24.7k|    global->log = log;
  788|  24.7k|}
mp_msg_update_msglevels:
  881|  49.5k|{
  882|  49.5k|    struct mp_log_root *root = global->log->root;
  883|       |
  884|  49.5k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  885|       |
  886|  49.5k|    root->verbose = opts->verbose;
  887|  49.5k|    root->really_quiet = opts->msg_really_quiet;
  888|  49.5k|    root->module = opts->msg_module;
  889|  49.5k|    root->use_terminal = opts->use_terminal;
  890|  49.5k|    root->show_time = opts->msg_time;
  891|       |
  892|  49.5k|    if (root->really_quiet)
  ------------------
  |  Branch (892:9): [True: 0, False: 49.5k]
  ------------------
  893|      0|        root->status_lines = 0;
  894|       |
  895|  49.5k|    for (int i = STDOUT_FILENO; i <= STDERR_FILENO && root->use_terminal; ++i) {
  ------------------
  |  Branch (895:33): [True: 49.5k, False: 0]
  |  Branch (895:55): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|    m_option_type_msglevels.free(&root->msg_levels);
  901|  49.5k|    m_option_type_msglevels.copy(NULL, &root->msg_levels, &opts->msg_levels);
  902|       |
  903|  49.5k|    atomic_fetch_add(&root->reload_counter, 1);
  904|  49.5k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  905|       |
  906|  49.5k|    if (check_new_path(global, opts->log_file, &root->log_path)) {
  ------------------
  |  Branch (906:9): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|    if (check_new_path(global, opts->dump_stats, &root->stats_path)) {
  ------------------
  |  Branch (953:9): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|}
mp_msg_has_log_file:
  984|  99.0k|{
  985|  99.0k|    struct mp_log_root *root = global->log->root;
  986|       |
  987|  99.0k|    return !!root->log_file;
  988|  99.0k|}
mp_msg_uninit:
  991|  24.7k|{
  992|  24.7k|    struct mp_log_root *root = global->log->root;
  993|  24.7k|    mp_msg_flush_status_line(global->log, true);
  994|  24.7k|    if (root->really_quiet && root->isatty[term_msg_fileno(root, MSGL_STATUS)]) {
  ------------------
  |  Branch (994:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    terminate_log_file_thread(root);
 1000|  24.7k|    mp_msg_log_buffer_destroy(root->early_buffer);
 1001|  24.7k|    mp_msg_log_buffer_destroy(root->early_filebuffer);
 1002|  24.7k|    mp_assert(root->num_buffers == 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1002:5): [True: 24.7k, False: 0]
  ------------------
 1003|  24.7k|    if (root->stats_file)
  ------------------
  |  Branch (1003:9): [True: 0, False: 24.7k]
  ------------------
 1004|      0|        fclose(root->stats_file);
 1005|  24.7k|    talloc_free(root->stats_path);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1006|  24.7k|    talloc_free(root->log_path);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1007|  24.7k|    m_option_type_msglevels.free(&root->msg_levels);
 1008|  24.7k|    mp_mutex_destroy(&root->lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1009|  24.7k|    mp_mutex_destroy(&root->log_file_lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1010|  24.7k|    mp_cond_destroy(&root->log_file_wakeup);
 1011|  24.7k|    talloc_free(root);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1012|       |    global->log = NULL;
 1013|  24.7k|}
mp_msg_set_early_logging:
 1061|  49.5k|{
 1062|  49.5k|    struct mp_log_root *root = global->log->root;
 1063|       |
 1064|  49.5k|    mp_msg_set_early_logging_raw(global, enable, &root->early_buffer,
 1065|  49.5k|                                 EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   48|  49.5k|#define EARLY_TERM_BUF 100
  ------------------
                                               EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   27|  49.5k|#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|  49.5k|    mp_msg_set_early_logging_raw(global, enable, &root->early_filebuffer,
 1069|  49.5k|                                 EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   54|  49.5k|#define EARLY_FILE_BUF 5000
  ------------------
                                               EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   29|  49.5k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
 1070|  49.5k|}
mp_msg_log_buffer_new:
 1076|  49.5k|{
 1077|  49.5k|    struct mp_log_root *root = global->log->root;
 1078|       |
 1079|  49.5k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1080|       |
 1081|  49.5k|    if (level == MP_LOG_BUFFER_MSGL_TERM) {
  ------------------
  |  |   27|  49.5k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (1081:9): [True: 24.7k, False: 24.7k]
  ------------------
 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|  24.7k|        if (root->early_buffer) {
  ------------------
  |  Branch (1086:13): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    }
 1096|       |
 1097|  49.5k|    mp_assert(size > 0);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (1097:5): [True: 49.5k, False: 0]
  ------------------
 1098|       |
 1099|  49.5k|    struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer);
  ------------------
  |  |   34|  49.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  49.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|  49.5k|    *buffer = (struct mp_log_buffer) {
 1101|  49.5k|        .root = root,
 1102|  49.5k|        .level = level,
 1103|  49.5k|        .entries = talloc_array(buffer, struct mp_log_buffer_entry *, size),
  ------------------
  |  |   29|  49.5k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  49.5k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|  49.5k|        .capacity = size,
 1105|  49.5k|        .wakeup_cb = wakeup_cb,
 1106|  49.5k|        .wakeup_cb_ctx = wakeup_cb_ctx,
 1107|  49.5k|    };
 1108|       |
 1109|  49.5k|    mp_mutex_init(&buffer->lock);
 1110|       |
 1111|  49.5k|    MP_TARRAY_APPEND(root, root->buffers, root->num_buffers, buffer);
  ------------------
  |  |  105|  49.5k|    do {                                            \
  |  |  106|  49.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  49.5k|    do {                                            \
  |  |  |  |   97|  49.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  49.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  49.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  49.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 24.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  49.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  49.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 49.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  49.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  49.5k|        (idxvar)++;                                 \
  |  |  109|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
 1112|       |
 1113|  49.5k|    atomic_fetch_add(&root->reload_counter, 1);
 1114|  49.5k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|       |
 1116|  49.5k|    return buffer;
 1117|  49.5k|}
mp_msg_log_buffer_destroy:
 1161|   173k|{
 1162|   173k|    if (!buffer)
  ------------------
  |  Branch (1162:9): [True: 123k, False: 49.5k]
  ------------------
 1163|   123k|        return;
 1164|       |
 1165|  49.5k|    struct mp_log_root *root = buffer->root;
 1166|       |
 1167|  49.5k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1168|       |
 1169|  49.5k|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (1169:21): [True: 49.5k, False: 0]
  ------------------
 1170|  49.5k|        if (root->buffers[n] == buffer) {
  ------------------
  |  Branch (1170:13): [True: 49.5k, False: 0]
  ------------------
 1171|  49.5k|            MP_TARRAY_REMOVE_AT(root->buffers, root->num_buffers, n);
  ------------------
  |  |  143|  49.5k|    do {                                            \
  |  |  144|  49.5k|        size_t at_ = (at);                          \
  |  |  145|  49.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  49.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  49.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  49.5k|        (idxvar)--;                                 \
  |  |  149|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
  |  Branch (1171:13): [True: 49.5k, False: 0]
  ------------------
 1172|  49.5k|            goto found;
 1173|  49.5k|        }
 1174|  49.5k|    }
 1175|       |
 1176|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (1176:5): [Folded, False: 0]
  ------------------
 1177|       |
 1178|  49.5k|found:
 1179|       |
 1180|   990k|    while (buffer->num_entries)
  ------------------
  |  Branch (1180:12): [True: 940k, False: 49.5k]
  ------------------
 1181|   940k|        talloc_free(log_buffer_read(buffer));
  ------------------
  |  |   47|   940k|#define talloc_free                     ta_free
  ------------------
 1182|       |
 1183|  49.5k|    mp_mutex_destroy(&buffer->lock);
  ------------------
  |  |  133|  49.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1184|  49.5k|    talloc_free(buffer);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
 1185|       |
 1186|  49.5k|    atomic_fetch_add(&root->reload_counter, 1);
 1187|  49.5k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1188|  49.5k|}
mp_msg:
 1223|  23.6M|{
 1224|  23.6M|    va_list va;
 1225|  23.6M|    va_start(va, format);
 1226|  23.6M|    mp_msg_va(log, lev, format, va);
 1227|       |    va_end(va);
 1228|  23.6M|}
mp_msg_find_level:
 1255|   482k|{
 1256|  3.86M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) {
  ------------------
  |  |   49|  3.86M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (1256:21): [True: 3.86M, False: 0]
  ------------------
 1257|  3.86M|        if (mp_log_levels[n] && !strcasecmp(s, mp_log_levels[n]))
  ------------------
  |  Branch (1257:13): [True: 3.86M, False: 0]
  |  Branch (1257:33): [True: 482k, False: 3.37M]
  ------------------
 1258|   482k|            return n;
 1259|  3.86M|    }
 1260|      0|    return -1;
 1261|   482k|}
msg.c:update_loglevel:
  141|   507k|{
  142|   507k|    struct mp_log_root *root = log->root;
  143|   507k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   507k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  144|   507k|    int level = MSGL_STATUS + root->verbose; // default log level
  145|   507k|    if (root->really_quiet)
  ------------------
  |  Branch (145:9): [True: 0, False: 507k]
  ------------------
  146|      0|        level = -1;
  147|   965k|    for (int n = 0; root->msg_levels && root->msg_levels[n * 2 + 0]; n++) {
  ------------------
  |  Branch (147:21): [True: 915k, False: 49.5k]
  |  Branch (147:41): [True: 457k, False: 457k]
  ------------------
  148|   457k|        if (match_mod(log->verbose_prefix, root->msg_levels[n * 2 + 0]))
  ------------------
  |  Branch (148:13): [True: 457k, False: 0]
  ------------------
  149|   457k|            level = mp_msg_find_level(root->msg_levels[n * 2 + 1]);
  150|   457k|    }
  151|   507k|    log->terminal_level = level;
  152|   755k|    for (int n = 0; n < log->root->num_buffers; n++) {
  ------------------
  |  Branch (152:21): [True: 247k, False: 507k]
  ------------------
  153|   247k|        int buffer_level = log->root->buffers[n]->level;
  154|   247k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   247k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (154:13): [True: 123k, False: 123k]
  ------------------
  155|   123k|            buffer_level = MSGL_DEBUG;
  156|   247k|        if (buffer_level != MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   247k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (156:13): [True: 123k, False: 123k]
  ------------------
  157|   123k|            level = MPMAX(level, buffer_level);
  ------------------
  |  |   44|   123k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 123k, False: 0]
  |  |  ------------------
  ------------------
  158|   247k|    }
  159|   507k|    if (log->root->log_file)
  ------------------
  |  Branch (159:9): [True: 0, False: 507k]
  ------------------
  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|   507k|    if (log->root->stats_file)
  ------------------
  |  Branch (161:9): [True: 0, False: 507k]
  ------------------
  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|   507k|    level = MPMIN(level, log->max_level);
  ------------------
  |  |   45|   507k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 507k]
  |  |  ------------------
  ------------------
  164|   507k|    atomic_store_explicit(&log->level, level, memory_order_relaxed);
  165|   507k|    atomic_store(&log->reload_counter, atomic_load(&log->root->reload_counter));
  166|   507k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|   507k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  167|   507k|}
msg.c:match_mod:
  132|   457k|{
  133|   457k|    if (!strcmp(mod, "all"))
  ------------------
  |  Branch (133:9): [True: 457k, False: 0]
  ------------------
  134|   457k|        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|   457k|}
msg.c:msg_flush_status_line:
  265|  49.5k|{
  266|  49.5k|    if (!root->status_lines)
  ------------------
  |  Branch (266:9): [True: 49.5k, False: 0]
  ------------------
  267|  49.5k|        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|  49.5k|done:
  291|  49.5k|    root->status_line.len = 0;
  292|  49.5k|}
msg.c:term_msg_fp:
  202|  19.5M|{
  203|  19.5M|    return term_msg_fileno(root, lev) == STDERR_FILENO ? stderr : stdout;
  ------------------
  |  Branch (203:12): [True: 0, False: 19.5M]
  ------------------
  204|  19.5M|}
msg.c:utf8_tail_start:
  644|  19.5M|{
  645|  19.5M|    for (size_t n = 1; n <= 4 && n <= str.len; n++) {
  ------------------
  |  Branch (645:24): [True: 19.5M, False: 4]
  |  Branch (645:34): [True: 3.78M, False: 15.7M]
  ------------------
  646|  3.78M|        unsigned char ch = str.start[str.len - n];
  647|  3.78M|        if ((ch & 0xC0) != 0x80)
  ------------------
  |  Branch (647:13): [True: 3.78M, False: 829]
  ------------------
  648|  3.78M|            return ch >= 0xC0 ? str.len - n : str.len;
  ------------------
  |  Branch (648:20): [True: 1.77k, False: 3.78M]
  ------------------
  649|  3.78M|    }
  650|  15.7M|    return str.len;
  651|  19.5M|}
msg.c:test_terminal_level:
  379|  19.5M|{
  380|  19.5M|    return lev <= log->terminal_level && log->root->use_terminal &&
  ------------------
  |  Branch (380:12): [True: 19.5M, False: 0]
  |  Branch (380:42): [True: 0, False: 19.5M]
  ------------------
  381|      0|           !(lev == MSGL_STATUS && terminal_in_background());
  ------------------
  |  Branch (381:14): [True: 0, False: 0]
  |  Branch (381:36): [True: 0, False: 0]
  ------------------
  382|  19.5M|}
msg.c:write_term_msg:
  518|  19.5M|{
  519|  19.5M|    struct mp_log_root *root = log->root;
  520|  19.5M|    bool print_term = test_terminal_level(log, lev);
  521|  19.5M|    int fileno = term_msg_fileno(root, lev);
  522|  19.5M|    int term_w = 0, term_h = 0;
  523|  19.5M|    if (print_term && root->isatty[fileno])
  ------------------
  |  Branch (523:9): [True: 0, False: 19.5M]
  |  Branch (523:23): [True: 0, False: 0]
  ------------------
  524|      0|        terminal_get_size(&term_w, &term_h);
  525|       |
  526|  19.5M|    out->len = 0;
  527|       |
  528|       |    // Split away each line. Normally we require full lines; buffer partial
  529|       |    // lines if they happen.
  530|  19.5M|    root->term_msg_tmp.len = 0;
  531|  19.5M|    int term_msg_lines = 0;
  532|       |
  533|  19.5M|    bstr str = text;
  534|  35.3M|    while (str.len) {
  ------------------
  |  Branch (534:12): [True: 19.6M, False: 15.7M]
  ------------------
  535|  19.6M|        bstr line = bstr_getline(str, &str);
  536|  19.6M|        if (line.start[line.len - 1] != '\n') {
  ------------------
  |  Branch (536:13): [True: 3.78M, False: 15.8M]
  ------------------
  537|  3.78M|            mp_assert(str.len == 0);
  ------------------
  |  |   41|  3.78M|#define mp_assert assert
  ------------------
  |  Branch (537:13): [True: 3.78M, False: 0]
  ------------------
  538|  3.78M|            str = line;
  539|  3.78M|            break;
  540|  3.78M|        }
  541|       |
  542|  19.6M|        bool clip = bstr_eatstart0(&line, TERM_MSG_0);
  ------------------
  |  |   30|  15.8M|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  15.8M|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  543|  15.8M|        if (print_term) {
  ------------------
  |  Branch (543:13): [True: 0, False: 15.8M]
  ------------------
  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|  15.8M|        write_msg_to_buffers(log, lev, line);
  551|  15.8M|    }
  552|       |
  553|  19.5M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (553:9): [True: 0, False: 19.5M]
  ------------------
  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|  19.5M|    } else if (str.len) {
  ------------------
  |  Branch (561:16): [True: 3.78M, False: 15.7M]
  ------------------
  562|  3.78M|        bstr_xappend(NULL, &log->partial[lev], str);
  563|  3.78M|    }
  564|       |
  565|  19.5M|    if (print_term && (root->term_msg_tmp.len || lev == MSGL_STATUS)) {
  ------------------
  |  Branch (565:9): [True: 0, False: 19.5M]
  |  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|  19.5M|}
msg.c:write_msg_to_buffers:
  459|  15.8M|{
  460|  15.8M|    struct mp_log_root *root = log->root;
  461|  16.7M|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (461:21): [True: 940k, False: 15.8M]
  ------------------
  462|   940k|        struct mp_log_buffer *buffer = root->buffers[n];
  463|   940k|        bool wakeup = false;
  464|   940k|        mp_mutex_lock(&buffer->lock);
  ------------------
  |  |  134|   940k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  465|   940k|        int buffer_level = buffer->level;
  466|   940k|        if (buffer_level == MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   940k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (466:13): [True: 470k, False: 470k]
  ------------------
  467|   470k|            buffer_level = log->terminal_level;
  468|   940k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   940k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (468:13): [True: 470k, False: 470k]
  ------------------
  469|   470k|            buffer_level = MPMAX(log->terminal_level, MSGL_DEBUG);
  ------------------
  |  |   44|   470k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 470k, False: 0]
  |  |  ------------------
  ------------------
  470|   940k|        if (lev <= buffer_level && lev != MSGL_STATUS) {
  ------------------
  |  Branch (470:13): [True: 940k, False: 0]
  |  Branch (470:36): [True: 940k, False: 0]
  ------------------
  471|   940k|            if (buffer->level == MP_LOG_BUFFER_MSGL_LOGFILE) {
  ------------------
  |  |   29|   940k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (471:17): [True: 470k, False: 470k]
  ------------------
  472|       |                // If the buffer is full, block until we can write again,
  473|       |                // unless there's no write thread (died, or early filebuffer)
  474|   470k|                if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (474:21): [True: 0, False: 470k]
  ------------------
  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|   470k|            }
  487|   940k|            if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (487:17): [True: 0, False: 940k]
  ------------------
  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|   940k|            struct mp_log_buffer_entry *entry = talloc_ptrtype(NULL, entry);
  ------------------
  |  |   34|   940k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   940k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   940k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|   940k|            *entry = (struct mp_log_buffer_entry) {
  494|   940k|                .prefix = talloc_strdup(entry, log->verbose_prefix),
  ------------------
  |  |   50|   940k|#define talloc_strdup                   ta_xstrdup
  ------------------
  495|   940k|                .level = lev,
  496|   940k|                .text = bstrdup0(entry, text),
  497|   940k|            };
  498|   940k|            int pos = (buffer->entry0 + buffer->num_entries) % buffer->capacity;
  499|   940k|            buffer->entries[pos] = entry;
  500|   940k|            buffer->num_entries += 1;
  501|   940k|            if (buffer->wakeup_cb && !buffer->silent)
  ------------------
  |  Branch (501:17): [True: 0, False: 940k]
  |  Branch (501:38): [True: 0, False: 0]
  ------------------
  502|      0|                wakeup = true;
  503|   940k|        }
  504|   940k|        mp_mutex_unlock(&buffer->lock);
  ------------------
  |  |  136|   940k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|   940k|        if (wakeup)
  ------------------
  |  Branch (505:13): [True: 0, False: 940k]
  ------------------
  506|      0|            buffer->wakeup_cb(buffer->wakeup_cb_ctx);
  507|   940k|    }
  508|  15.8M|}
msg.c:destroy_log:
  718|  1.26M|{
  719|  1.26M|    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|  12.6M|    for (int lvl = 0; lvl <= MSGL_MAX; ++lvl)
  ------------------
  |  Branch (722:23): [True: 11.3M, False: 1.26M]
  ------------------
  723|  11.3M|        talloc_free(log->partial[lvl].start);
  ------------------
  |  |   47|  11.3M|#define talloc_free                     ta_free
  ------------------
  724|  1.26M|}
msg.c:check_new_path:
  858|  99.0k|{
  859|  99.0k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  99.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  99.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  860|  99.0k|    bool res = false;
  861|       |
  862|  99.0k|    char *new_path = mp_get_user_path(tmp, global, opt);
  863|  99.0k|    if (!new_path)
  ------------------
  |  Branch (863:9): [True: 99.0k, False: 0]
  ------------------
  864|  99.0k|        new_path = "";
  865|       |
  866|  99.0k|    char *old_path = *current_path ? *current_path : "";
  ------------------
  |  Branch (866:22): [True: 0, False: 99.0k]
  ------------------
  867|  99.0k|    if (strcmp(old_path, new_path) != 0) {
  ------------------
  |  Branch (867:9): [True: 0, False: 99.0k]
  ------------------
  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|  99.0k|    talloc_free(tmp);
  ------------------
  |  |   47|  99.0k|#define talloc_free                     ta_free
  ------------------
  876|       |
  877|  99.0k|    return res;
  878|  99.0k|}
msg.c:terminate_log_file_thread:
  832|  24.7k|{
  833|  24.7k|    bool wait_terminate = false;
  834|       |
  835|  24.7k|    mp_mutex_lock(&root->log_file_lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  836|  24.7k|    if (root->log_file_thread_active) {
  ------------------
  |  Branch (836:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    mp_mutex_unlock(&root->log_file_lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|       |
  843|  24.7k|    if (wait_terminate)
  ------------------
  |  Branch (843:9): [True: 0, False: 24.7k]
  ------------------
  844|      0|        mp_thread_join(root->log_file_thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  845|       |
  846|  24.7k|    mp_msg_log_buffer_destroy(root->log_file_buffer);
  847|  24.7k|    root->log_file_buffer = NULL;
  848|       |
  849|  24.7k|    if (root->log_file)
  ------------------
  |  Branch (849:9): [True: 0, False: 24.7k]
  ------------------
  850|      0|        fclose(root->log_file);
  851|       |    root->log_file = NULL;
  852|  24.7k|}
msg.c:term_msg_fileno:
  197|  39.0M|{
  198|  39.0M|    return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
  ------------------
  |  Branch (198:12): [True: 0, False: 39.0M]
  ------------------
  199|  39.0M|}
msg.c:mp_msg_set_early_logging_raw:
 1036|  99.0k|{
 1037|  99.0k|    struct mp_log_root *root = global->log->root;
 1038|  99.0k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  99.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1039|       |
 1040|  99.0k|    if (enable != !!*root_logbuf) {
  ------------------
  |  Branch (1040:9): [True: 99.0k, False: 0]
  ------------------
 1041|  99.0k|        if (enable) {
  ------------------
  |  Branch (1041:13): [True: 49.5k, False: 49.5k]
  ------------------
 1042|  49.5k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1043|  49.5k|            struct mp_log_buffer *buf =
 1044|  49.5k|                mp_msg_log_buffer_new(global, size, level, NULL, NULL);
 1045|  49.5k|            mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1046|  49.5k|            mp_assert(!*root_logbuf); // no concurrent calls to this function
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (1046:13): [True: 49.5k, False: 0]
  ------------------
 1047|  49.5k|            *root_logbuf = buf;
 1048|  49.5k|        } else {
 1049|  49.5k|            struct mp_log_buffer *buf = *root_logbuf;
 1050|  49.5k|            *root_logbuf = NULL;
 1051|  49.5k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1052|  49.5k|            mp_msg_log_buffer_destroy(buf);
 1053|  49.5k|            return;
 1054|  49.5k|        }
 1055|  99.0k|    }
 1056|       |
 1057|  49.5k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1058|  49.5k|}
msg.c:log_buffer_read:
  442|   940k|{
  443|   940k|    mp_assert(buffer->num_entries);
  ------------------
  |  |   41|   940k|#define mp_assert assert
  ------------------
  |  Branch (443:5): [True: 940k, False: 0]
  ------------------
  444|   940k|    struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0];
  445|   940k|    buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity;
  446|   940k|    buffer->num_entries -= 1;
  447|   940k|    return res;
  448|   940k|}

av_log.c:mp_msg_test:
   64|  7.52M|{
   65|  7.52M|    return lev <= mp_msg_level(log);
   66|  7.52M|}
msg.c:mp_msg_test:
   64|  23.6M|{
   65|  23.6M|    return lev <= mp_msg_level(log);
   66|  23.6M|}
cmd.c:mp_msg_test:
   64|  74.2k|{
   65|  74.2k|    return lev <= mp_msg_level(log);
   66|  74.2k|}
m_config_frontend.c:mp_msg_test:
   64|   247k|{
   65|   247k|    return lev <= mp_msg_level(log);
   66|   247k|}
chmap_sel.c:mp_msg_test:
   64|  8.07k|{
   65|  8.07k|    return lev <= mp_msg_level(log);
   66|  8.07k|}

playlist_entry_new:
   31|  24.7k|{
   32|  24.7k|    struct playlist_entry *e = talloc_zero(NULL, struct playlist_entry);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   33|  24.7k|    char *local_filename = mp_file_url_to_filename(e, bstr0(filename));
   34|  24.7k|    e->filename = mp_normalize_path(e, local_filename ? local_filename : filename);
  ------------------
  |  Branch (34:40): [True: 0, False: 24.7k]
  ------------------
   35|  24.7k|    talloc_free(local_filename);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
   36|  24.7k|    e->stream_flags = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|  24.7k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
   37|  24.7k|    e->original_index = -1;
   38|  24.7k|    return e;
   39|  24.7k|}
playlist_insert_at:
   77|  24.7k|{
   78|  24.7k|    mp_assert(add->filename);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (78:5): [True: 24.7k, False: 0]
  ------------------
   79|  24.7k|    mp_assert(!at || at->pl == pl);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (79:5): [True: 24.7k, False: 0]
  |  Branch (79:5): [True: 0, False: 0]
  ------------------
   80|       |
   81|  24.7k|    int index = at ? at->pl_index : pl->num_entries;
  ------------------
  |  Branch (81:17): [True: 0, False: 24.7k]
  ------------------
   82|  24.7k|    MP_TARRAY_INSERT_AT(pl, pl->entries, pl->num_entries, index, add);
  ------------------
  |  |  115|  24.7k|    do {                                            \
  |  |  116|  24.7k|        size_t at_ = (at);                          \
  |  |  117|  24.7k|        assert(at_ <= (idxvar));                    \
  |  |  118|  24.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.7k|    do {                                            \
  |  |  |  |   97|  24.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  24.7k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  24.7k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  24.7k|        (idxvar)++;                                 \
  |  |  122|  24.7k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  24.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  |  Branch (82:5): [True: 24.7k, False: 0]
  ------------------
   83|       |
   84|  24.7k|    add->pl = pl;
   85|  24.7k|    add->pl_index = index;
   86|  24.7k|    add->id = ++pl->id_alloc;
   87|       |
   88|  24.7k|    playlist_update_indexes(pl, index, pl->num_entries);
   89|       |
   90|  24.7k|    talloc_steal(pl, add);
  ------------------
  |  |   38|  24.7k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.7k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
   91|  24.7k|}
playlist_entry_unref:
   94|  24.7k|{
   95|  24.7k|    e->reserved--;
   96|  24.7k|    if (e->reserved < 0) {
  ------------------
  |  Branch (96:9): [True: 0, False: 24.7k]
  ------------------
   97|      0|        mp_assert(!e->pl);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (97:9): [True: 0, False: 0]
  ------------------
   98|      0|        talloc_free(e);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   99|      0|    }
  100|  24.7k|}
playlist_clear:
  123|  24.7k|{
  124|  24.7k|    for (int n = pl->num_entries - 1; n >= 0; n--)
  ------------------
  |  Branch (124:39): [True: 0, False: 24.7k]
  ------------------
  125|      0|        playlist_remove(pl, pl->entries[n]);
  126|  24.7k|    mp_assert(!pl->current);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (126:5): [True: 24.7k, False: 0]
  ------------------
  127|  24.7k|    pl->current_was_replaced = false;
  128|  24.7k|    pl->playlist_completed = false;
  129|  24.7k|    pl->playlist_started = false;
  130|       |    TA_FREEP(&pl->playlist_dir);
  ------------------
  |  |   81|  24.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  24.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  131|  24.7k|}
playlist_get_first:
  212|  24.7k|{
  213|  24.7k|    return pl->num_entries ? pl->entries[0] : NULL;
  ------------------
  |  Branch (213:12): [True: 0, False: 24.7k]
  ------------------
  214|  24.7k|}
playlist_get_next:
  223|  24.6k|{
  224|  24.6k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (224:5): [True: 0, False: 24.6k]
  |  Branch (224:5): [True: 24.6k, False: 0]
  ------------------
  225|  24.6k|    if (!pl->current && pl->playlist_completed && direction < 0) {
  ------------------
  |  Branch (225:9): [True: 0, False: 24.6k]
  |  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|  24.6k|    } else if (!pl->current && !pl->playlist_started && direction > 0) {
  ------------------
  |  Branch (227:16): [True: 0, False: 24.6k]
  |  Branch (227:32): [True: 0, False: 0]
  |  Branch (227:57): [True: 0, False: 0]
  ------------------
  228|      0|        return playlist_entry_from_index(pl, 0);
  229|  24.6k|    } else if (!pl->current) {
  ------------------
  |  Branch (229:16): [True: 0, False: 24.6k]
  ------------------
  230|      0|        return NULL;
  231|      0|    }
  232|  24.6k|    mp_assert(pl->current->pl == pl);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (232:5): [True: 24.6k, False: 0]
  ------------------
  233|  24.6k|    if (direction < 0)
  ------------------
  |  Branch (233:9): [True: 0, False: 24.6k]
  ------------------
  234|      0|        return playlist_entry_get_rel(pl->current, -1);
  235|  24.6k|    return pl->current_was_replaced ? pl->current :
  ------------------
  |  Branch (235:12): [True: 0, False: 24.6k]
  ------------------
  236|  24.6k|           playlist_entry_get_rel(pl->current, 1);
  237|  24.6k|}
playlist_entry_get_rel:
  242|  24.6k|{
  243|  24.6k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|  24.6k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 0, False: 24.6k]
  |  Branch (243:5): [True: 24.6k, False: 0]
  ------------------
  244|  24.6k|    if (!e->pl)
  ------------------
  |  Branch (244:9): [True: 0, False: 24.6k]
  ------------------
  245|      0|        return NULL;
  246|  24.6k|    return playlist_entry_from_index(e->pl, e->pl_index + direction);
  247|  24.6k|}
playlist_entry_to_index:
  379|  24.7k|{
  380|  24.7k|    if (!e || e->pl != pl)
  ------------------
  |  Branch (380:9): [True: 0, False: 24.7k]
  |  Branch (380:15): [True: 0, False: 24.7k]
  ------------------
  381|      0|        return -1;
  382|  24.7k|    return e->pl_index;
  383|  24.7k|}
playlist_entry_from_index:
  393|  24.6k|{
  394|  24.6k|    return index >= 0 && index < pl->num_entries ? pl->entries[index] : NULL;
  ------------------
  |  Branch (394:12): [True: 24.6k, False: 0]
  |  Branch (394:26): [True: 0, False: 24.6k]
  ------------------
  395|  24.6k|}
playlist.c:playlist_update_indexes:
   65|  24.7k|{
   66|  24.7k|    start = MPMAX(start, 0);
  ------------------
  |  |   44|  24.7k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
   67|  24.7k|    end = end < 0 ? pl->num_entries : MPMIN(end, pl->num_entries);
  ------------------
  |  |   45|  49.5k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
  |  Branch (67:11): [True: 0, False: 24.7k]
  ------------------
   68|       |
   69|  49.5k|    for (int n = start; n < end; n++)
  ------------------
  |  Branch (69:25): [True: 24.7k, False: 24.7k]
  ------------------
   70|  24.7k|        pl->entries[n]->pl_index = n;
   71|  24.7k|}

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

mp_tags_set_str:
   27|  18.9k|{
   28|  18.9k|    mp_tags_set_bstr(tags, bstr0(key), bstr0(value));
   29|  18.9k|}
mp_tags_set_bstr:
   32|  18.9k|{
   33|  23.5k|    for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (33:21): [True: 4.66k, False: 18.9k]
  ------------------
   34|  4.66k|        if (bstrcasecmp0(key, tags->keys[n]) == 0) {
  ------------------
  |  Branch (34:13): [True: 6, False: 4.65k]
  ------------------
   35|      6|            talloc_free(tags->values[n]);
  ------------------
  |  |   47|      6|#define talloc_free                     ta_free
  ------------------
   36|      6|            tags->values[n] = bstrto0(tags, value);
   37|      6|            return;
   38|      6|        }
   39|  4.66k|    }
   40|       |
   41|  18.9k|    MP_RESIZE_ARRAY(tags, tags->keys,   tags->num_keys + 1);
  ------------------
  |  |   88|  18.9k|    do {                                                        \
  |  |   89|  18.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  18.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  18.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  18.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  18.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  18.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  18.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 18.9k]
  |  |  ------------------
  ------------------
   42|  18.9k|    MP_RESIZE_ARRAY(tags, tags->values, tags->num_keys + 1);
  ------------------
  |  |   88|  18.9k|    do {                                                        \
  |  |   89|  18.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  18.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  18.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  18.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  18.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  18.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  18.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 18.9k]
  |  |  ------------------
  ------------------
   43|  18.9k|    tags->keys[tags->num_keys]   = bstrto0(tags, key);
   44|  18.9k|    tags->values[tags->num_keys] = bstrto0(tags, value);
   45|  18.9k|    tags->num_keys++;
   46|  18.9k|}
mp_tags_get_str:
   67|  4.75M|{
   68|  4.75M|    return mp_tags_get_bstr(tags, bstr0(key));
   69|  4.75M|}
mp_tags_get_bstr:
   72|  4.75M|{
   73|  6.01M|    for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (73:21): [True: 1.33M, False: 4.67M]
  ------------------
   74|  1.33M|        if (bstrcasecmp0(key, tags->keys[n]) == 0)
  ------------------
  |  Branch (74:13): [True: 75.2k, False: 1.25M]
  ------------------
   75|  75.2k|            return tags->values[n];
   76|  1.33M|    }
   77|  4.67M|    return NULL;
   78|  4.75M|}
mp_tags_clear:
   81|  28.4k|{
   82|  28.4k|    *tags = (struct mp_tags){0};
   83|  28.4k|    talloc_free_children(tags);
  ------------------
  |  |   46|  28.4k|#define talloc_free_children            ta_free_children
  ------------------
   84|  28.4k|}
mp_tags_dup:
   89|  28.4k|{
   90|  28.4k|    struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
  ------------------
  |  |   27|  28.4k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  28.4k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  28.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|  28.4k|    mp_tags_replace(new, tags);
   92|  28.4k|    return new;
   93|  28.4k|}
mp_tags_replace:
   96|  28.4k|{
   97|  28.4k|    mp_tags_clear(dst);
   98|  28.4k|    MP_RESIZE_ARRAY(dst, dst->keys,   src->num_keys);
  ------------------
  |  |   88|  28.4k|    do {                                                        \
  |  |   89|  28.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  28.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  28.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  28.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  28.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  28.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  28.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 28.4k]
  |  |  ------------------
  ------------------
   99|  28.4k|    MP_RESIZE_ARRAY(dst, dst->values, src->num_keys);
  ------------------
  |  |   88|  28.4k|    do {                                                        \
  |  |   89|  28.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  28.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  28.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  28.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  28.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  28.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  28.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 28.4k]
  |  |  ------------------
  ------------------
  100|  28.4k|    dst->num_keys = src->num_keys;
  101|  42.0k|    for (int n = 0; n < src->num_keys; n++) {
  ------------------
  |  Branch (101:21): [True: 13.6k, False: 28.4k]
  ------------------
  102|  13.6k|        dst->keys[n] = talloc_strdup(dst, src->keys[n]);
  ------------------
  |  |   50|  13.6k|#define talloc_strdup                   ta_xstrdup
  ------------------
  103|  13.6k|        dst->values[n] = talloc_strdup(dst, src->values[n]);
  ------------------
  |  |   50|  13.6k|#define talloc_strdup                   ta_xstrdup
  ------------------
  104|  13.6k|    }
  105|  28.4k|}
mp_tags_filtered:
  111|  24.2k|{
  112|  24.2k|    struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
  ------------------
  |  |   27|  24.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|   436k|    for (int n = 0; list && list[n]; n++) {
  ------------------
  |  Branch (113:21): [True: 436k, False: 0]
  |  Branch (113:29): [True: 412k, False: 24.2k]
  ------------------
  114|   412k|        char *key = list[n];
  115|   412k|        size_t keylen = strlen(key);
  116|   412k|        if (keylen >= INT_MAX)
  ------------------
  |  Branch (116:13): [True: 0, False: 412k]
  ------------------
  117|      0|            continue;
  118|   412k|        bool prefix = keylen && key[keylen - 1] == '*';
  ------------------
  |  Branch (118:23): [True: 412k, False: 0]
  |  Branch (118:33): [True: 0, False: 412k]
  ------------------
  119|   412k|        int matchlen = prefix ? keylen - 1 : keylen + 1;
  ------------------
  |  Branch (119:24): [True: 0, False: 412k]
  ------------------
  120|   575k|        for (int x = 0; x < tags->num_keys; x++) {
  ------------------
  |  Branch (120:25): [True: 163k, False: 412k]
  ------------------
  121|   163k|            if (strncasecmp(tags->keys[x], key, matchlen) == 0) {
  ------------------
  |  Branch (121:17): [True: 2.01k, False: 161k]
  ------------------
  122|  2.01k|                char skey[320];
  123|  2.01k|                snprintf(skey, sizeof(skey), "%.*s%s", matchlen, key,
  124|  2.01k|                         prefix ? tags->keys[x] + keylen - 1 : "");
  ------------------
  |  Branch (124:26): [True: 0, False: 2.01k]
  ------------------
  125|  2.01k|                mp_tags_set_str(new, skey, tags->values[x]);
  126|  2.01k|            }
  127|   163k|        }
  128|   412k|    }
  129|  24.2k|    return new;
  130|  24.2k|}
mp_tags_merge:
  133|  2.79k|{
  134|  2.87k|    for (int n = 0; n < src->num_keys; n++)
  ------------------
  |  Branch (134:21): [True: 73, False: 2.79k]
  ------------------
  135|     73|        mp_tags_set_str(tags, src->keys[n], src->values[n]);
  136|  2.79k|}

mp_set_codec_from_tag:
  164|  12.6k|{
  165|  12.6k|    c->codec = lookup_tag(c->type, c->codec_tag);
  166|  12.6k|    if (c->type == STREAM_AUDIO)
  ------------------
  |  Branch (166:9): [True: 4.46k, False: 8.17k]
  ------------------
  167|  4.46k|        map_audio_pcm_tag(c);
  168|  12.6k|}
mp_set_pcm_codec:
  172|     44|{
  173|       |    // This uses libavcodec pcm codec names, e.g. "pcm_u16le".
  174|     44|    char codec[64] = "pcm_";
  175|     44|    if (is_float) {
  ------------------
  |  Branch (175:9): [True: 9, False: 35]
  ------------------
  176|      9|        mp_snprintf_cat(codec, sizeof(codec), "f");
  177|     35|    } else {
  178|     35|        mp_snprintf_cat(codec, sizeof(codec), sign ? "s" : "u");
  ------------------
  |  Branch (178:47): [True: 27, False: 8]
  ------------------
  179|     35|    }
  180|     44|    mp_snprintf_cat(codec, sizeof(codec), "%d", bits);
  181|     44|    if (bits != 8)
  ------------------
  |  Branch (181:9): [True: 36, False: 8]
  ------------------
  182|     36|        mp_snprintf_cat(codec, sizeof(codec), is_be ? "be" : "le");
  ------------------
  |  Branch (182:47): [True: 0, False: 36]
  ------------------
  183|     44|    c->codec = talloc_strdup(c, codec);
  ------------------
  |  |   50|     44|#define talloc_strdup                   ta_xstrdup
  ------------------
  184|     44|}
mp_map_mimetype_to_video_codec:
  200|  1.13k|{
  201|  1.13k|    if (mimetype) {
  ------------------
  |  Branch (201:9): [True: 1.13k, False: 0]
  ------------------
  202|  9.86k|        for (int n = 0; mimetype_to_codec[n][0]; n++) {
  ------------------
  |  Branch (202:25): [True: 9.02k, False: 841]
  ------------------
  203|  9.02k|            if (strcasecmp(mimetype_to_codec[n][0], mimetype) == 0)
  ------------------
  |  Branch (203:17): [True: 292, False: 8.73k]
  ------------------
  204|    292|                return mimetype_to_codec[n][1];
  205|  9.02k|        }
  206|  1.13k|    }
  207|    841|    return NULL;
  208|  1.13k|}
codec_tags.c:lookup_tag:
   31|  12.6k|{
   32|  12.6k|    const struct AVCodecTag *av_tags[3] = {0};
   33|  12.6k|    switch (type) {
  ------------------
  |  Branch (33:13): [True: 12.6k, False: 0]
  ------------------
   34|  8.17k|    case STREAM_VIDEO: {
  ------------------
  |  Branch (34:5): [True: 8.17k, False: 4.46k]
  ------------------
   35|  8.17k|        av_tags[0] = avformat_get_riff_video_tags();
   36|  8.17k|        av_tags[1] = avformat_get_mov_video_tags();
   37|  8.17k|        break;
   38|      0|    }
   39|  4.46k|    case STREAM_AUDIO: {
  ------------------
  |  Branch (39:5): [True: 4.46k, False: 8.17k]
  ------------------
   40|  4.46k|        av_tags[0] = avformat_get_riff_audio_tags();
   41|  4.46k|        av_tags[1] = avformat_get_mov_audio_tags();
   42|  4.46k|        break;
   43|      0|    }
   44|  12.6k|    }
   45|       |
   46|  12.6k|    int id = av_codec_get_id(av_tags, tag);
   47|  12.6k|    return id == AV_CODEC_ID_NONE ? NULL : mp_codec_from_av_codec_id(id);
  ------------------
  |  Branch (47:12): [True: 669, False: 11.9k]
  ------------------
   48|  12.6k|}
codec_tags.c:map_audio_pcm_tag:
  105|  4.46k|{
  106|       |    // MS PCM, Extended
  107|  4.46k|    if (c->codec_tag == 0xfffe && c->extradata_size >= 22) {
  ------------------
  |  Branch (107:9): [True: 34, False: 4.42k]
  |  Branch (107:35): [True: 0, False: 34]
  ------------------
  108|       |        // WAVEFORMATEXTENSIBLE.wBitsPerSample
  109|      0|        int bits_per_sample = AV_RL16(c->extradata);
  110|      0|        if (bits_per_sample)
  ------------------
  |  Branch (110:13): [True: 0, False: 0]
  ------------------
  111|      0|            c->bits_per_coded_sample = bits_per_sample;
  112|       |
  113|       |        // WAVEFORMATEXTENSIBLE.dwChannelMask
  114|      0|        uint64_t chmask = AV_RL32(c->extradata + 2);
  115|      0|        struct mp_chmap chmap;
  116|      0|        mp_chmap_from_waveext(&chmap, chmask);
  ------------------
  |  |  175|      0|#define mp_chmap_from_waveext mp_chmap_from_lavc
  ------------------
  117|      0|        if (c->channels.num == chmap.num)
  ------------------
  |  Branch (117:13): [True: 0, False: 0]
  ------------------
  118|      0|            c->channels = chmap;
  119|       |
  120|       |        // WAVEFORMATEXTENSIBLE.SubFormat
  121|      0|        unsigned char *subformat = c->extradata + 6;
  122|      0|        for (int i = 0; i < MP_ARRAY_SIZE(guid_ext_base); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (122:25): [True: 0, False: 0]
  ------------------
  123|      0|            if (memcmp(subformat + 4, guid_ext_base[i] + 4, 12) == 0) {
  ------------------
  |  Branch (123:17): [True: 0, False: 0]
  ------------------
  124|      0|                c->codec_tag = AV_RL32(subformat);
  125|      0|                c->codec = lookup_tag(c->type, c->codec_tag);
  126|      0|                break;
  127|      0|            }
  128|      0|        }
  129|       |
  130|       |        // extra subformat, not a base one
  131|      0|        if (c->codec_tag == 0xfffe) {
  ------------------
  |  Branch (131:13): [True: 0, False: 0]
  ------------------
  132|      0|            for (int i = 0; i < MP_ARRAY_SIZE(guid_ext_other); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (132:29): [True: 0, False: 0]
  ------------------
  133|      0|                if (memcmp(subformat, &guid_ext_other[i].guid, 16) == 0) {
  ------------------
  |  Branch (133:21): [True: 0, False: 0]
  ------------------
  134|      0|                    c->codec = guid_ext_other[i].codec;
  135|      0|                    c->codec_tag = mp_codec_to_av_codec_id(c->codec);
  136|      0|                    break;
  137|      0|                }
  138|      0|            }
  139|      0|        }
  140|       |
  141|       |        // Compressed formats might use this.
  142|      0|        c->extradata += 22;
  143|      0|        c->extradata_size -= 22;
  144|      0|    }
  145|       |
  146|  4.46k|    int bits = c->bits_per_coded_sample;
  147|  4.46k|    if (!bits)
  ------------------
  |  Branch (147:9): [True: 606, False: 3.85k]
  ------------------
  148|    606|        return;
  149|       |
  150|  3.85k|    int bytes = (bits + 7) / 8;
  151|  3.85k|    switch (c->codec_tag) {
  ------------------
  |  Branch (151:13): [True: 47, False: 3.80k]
  ------------------
  152|     22|    case 0x0:       // Microsoft PCM
  ------------------
  |  Branch (152:5): [True: 22, False: 3.83k]
  ------------------
  153|     38|    case 0x1:
  ------------------
  |  Branch (153:5): [True: 16, False: 3.84k]
  ------------------
  154|     38|        if (bytes >= 1 && bytes <= 4)
  ------------------
  |  Branch (154:13): [True: 38, False: 0]
  |  Branch (154:27): [True: 35, False: 3]
  ------------------
  155|     35|            mp_set_pcm_codec(c, bytes > 1, false, bytes * 8, false);
  156|     38|        break;
  157|      9|    case 0x3:       // IEEE float
  ------------------
  |  Branch (157:5): [True: 9, False: 3.84k]
  ------------------
  158|      9|        mp_set_pcm_codec(c, true, true, bits == 64 ? 64 : 32, false);
  ------------------
  |  Branch (158:41): [True: 0, False: 9]
  ------------------
  159|      9|        break;
  160|  3.85k|    }
  161|  3.85k|}

demux_set_ts_offset:
  975|  24.6k|{
  976|  24.6k|    struct demux_internal *in = demuxer->in;
  977|  24.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  978|  24.6k|    in->ts_offset = offset;
  979|  24.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  980|  24.6k|}
demux_alloc_sh_stream:
 1004|  43.1k|{
 1005|  43.1k|    struct sh_stream *sh = talloc_ptrtype(NULL, sh);
  ------------------
  |  |   34|  43.1k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  43.1k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1006|  43.1k|    *sh = (struct sh_stream) {
 1007|  43.1k|        .type = type,
 1008|  43.1k|        .index = -1,
 1009|  43.1k|        .ff_index = -1,     // may be overwritten by demuxer
 1010|  43.1k|        .demuxer_id = -1,   // ... same
 1011|  43.1k|        .codec = talloc_zero(sh, struct mp_codec_params),
  ------------------
  |  |   27|  43.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  43.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|  43.1k|        .tags = talloc_zero(sh, struct mp_tags),
  ------------------
  |  |   27|  43.1k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  43.1k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  43.1k|    };
 1014|  43.1k|    sh->codec->type = type;
 1015|  43.1k|    return sh;
 1016|  43.1k|}
demux_add_sh_stream:
 1086|  42.9k|{
 1087|  42.9k|    struct demux_internal *in = demuxer->in;
 1088|  42.9k|    mp_assert(demuxer == in->d_thread);
  ------------------
  |  |   41|  42.9k|#define mp_assert assert
  ------------------
  |  Branch (1088:5): [True: 42.9k, False: 0]
  ------------------
 1089|  42.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  42.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1090|  42.9k|    demux_add_sh_stream_locked(in, sh);
 1091|  42.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  42.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1092|  42.9k|}
demux_get_stream:
 1099|   101k|{
 1100|   101k|    struct demux_internal *in = demuxer->in;
 1101|   101k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   101k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1102|   101k|    mp_assert(index >= 0 && index < in->num_streams);
  ------------------
  |  |   41|   101k|#define mp_assert assert
  ------------------
  |  Branch (1102:5): [True: 101k, False: 0]
  |  Branch (1102:5): [True: 101k, False: 0]
  ------------------
 1103|   101k|    struct sh_stream *r = in->streams[index];
 1104|   101k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   101k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1105|   101k|    return r;
 1106|   101k|}
demux_get_num_stream:
 1110|   134k|{
 1111|   134k|    struct demux_internal *in = demuxer->in;
 1112|   134k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   134k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1113|   134k|    int r = in->num_streams;
 1114|   134k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   134k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|   134k|    return r;
 1116|   134k|}
demux_free:
 1159|    782|{
 1160|    782|    if (!demuxer)
  ------------------
  |  Branch (1160:9): [True: 0, False: 782]
  ------------------
 1161|      0|        return;
 1162|    782|    struct demux_internal *in = demuxer->in;
 1163|    782|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|    782|#define mp_assert assert
  ------------------
  |  Branch (1163:5): [True: 782, False: 0]
  ------------------
 1164|       |
 1165|    782|    demux_stop_thread(demuxer);
 1166|    782|    demux_shutdown(in);
 1167|    782|    demux_dealloc(in);
 1168|    782|}
demux_free_async:
 1178|  24.2k|{
 1179|  24.2k|    struct demux_internal *in = demuxer->in;
 1180|  24.2k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (1180:5): [True: 24.2k, False: 0]
  ------------------
 1181|       |
 1182|  24.2k|    if (!in->threading)
  ------------------
  |  Branch (1182:9): [True: 0, False: 24.2k]
  ------------------
 1183|      0|        return NULL;
 1184|       |
 1185|  24.2k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1186|  24.2k|    in->thread_terminate = true;
 1187|  24.2k|    in->shutdown_async = true;
 1188|  24.2k|    mp_cond_signal(&in->wakeup);
 1189|  24.2k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1190|       |
 1191|  24.2k|    return (struct demux_free_async_state *)demuxer->in; // lies
 1192|  24.2k|}
demux_free_async_finish:
 1210|  72.4k|{
 1211|  72.4k|    struct demux_internal *in = (struct demux_internal *)state; // reverse lies
 1212|       |
 1213|  72.4k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  72.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1214|  72.4k|    bool busy = in->shutdown_async;
 1215|  72.4k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  72.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1216|       |
 1217|  72.4k|    if (busy)
  ------------------
  |  Branch (1217:9): [True: 48.2k, False: 24.2k]
  ------------------
 1218|  48.2k|        return false;
 1219|       |
 1220|  24.2k|    demux_stop_thread(in->d_user);
 1221|  24.2k|    demux_dealloc(in);
 1222|       |    return true;
 1223|  72.4k|}
demux_cancel_and_free:
 1229|  24.2k|{
 1230|  24.2k|    if (!demuxer)
  ------------------
  |  Branch (1230:9): [True: 24.2k, False: 0]
  ------------------
 1231|  24.2k|        return;
 1232|      0|    mp_cancel_trigger(demuxer->cancel);
 1233|      0|    demux_free(demuxer);
 1234|      0|}
demux_start_thread:
 1238|  24.2k|{
 1239|  24.2k|    struct demux_internal *in = demuxer->in;
 1240|  24.2k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (1240:5): [True: 24.2k, False: 0]
  ------------------
 1241|       |
 1242|  24.2k|    if (!in->threading) {
  ------------------
  |  Branch (1242:9): [True: 24.2k, False: 0]
  ------------------
 1243|  24.2k|        in->threading = true;
 1244|  24.2k|        if (mp_thread_create(&in->thread, demux_thread, in))
  ------------------
  |  |  214|  24.2k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 24.2k]
  |  |  ------------------
  ------------------
 1245|      0|            in->threading = false;
 1246|  24.2k|    }
 1247|  24.2k|}
demux_stop_thread:
 1250|  25.0k|{
 1251|  25.0k|    struct demux_internal *in = demuxer->in;
 1252|  25.0k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (1252:5): [True: 25.0k, False: 0]
  ------------------
 1253|       |
 1254|  25.0k|    if (in->threading) {
  ------------------
  |  Branch (1254:9): [True: 24.2k, False: 782]
  ------------------
 1255|  24.2k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1256|  24.2k|        in->thread_terminate = true;
 1257|  24.2k|        mp_cond_signal(&in->wakeup);
 1258|  24.2k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1259|  24.2k|        mp_thread_join(in->thread);
  ------------------
  |  |  215|  24.2k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1260|  24.2k|        in->threading = false;
 1261|       |        in->thread_terminate = false;
 1262|  24.2k|    }
 1263|  25.0k|}
demux_set_wakeup_cb:
 1267|  48.5k|{
 1268|  48.5k|    struct demux_internal *in = demuxer->in;
 1269|  48.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  48.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1270|  48.5k|    in->wakeup_cb = cb;
 1271|  48.5k|    in->wakeup_cb_ctx = ctx;
 1272|  48.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  48.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1273|  48.5k|}
demux_nav_refresh:
 1300|    374|{
 1301|    374|    struct demux_internal *in = demuxer->in;
 1302|    374|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|    374|#define mp_assert assert
  ------------------
  |  Branch (1302:5): [True: 374, False: 0]
  ------------------
 1303|       |
 1304|    374|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|    374|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1305|    374|    if (in->d_thread->desc->nav_refresh) {
  ------------------
  |  Branch (1305:9): [True: 0, False: 374]
  ------------------
 1306|      0|        in->nav_refresh = true;
 1307|      0|        in->reading = true;
 1308|      0|        mp_cond_signal(&in->wakeup);
 1309|      0|    }
 1310|    374|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|    374|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1311|    374|}
stream_type_name:
 1314|   768k|{
 1315|   768k|    switch (type) {
 1316|   377k|    case STREAM_VIDEO:  return "video";
  ------------------
  |  Branch (1316:5): [True: 377k, False: 390k]
  ------------------
 1317|   384k|    case STREAM_AUDIO:  return "audio";
  ------------------
  |  Branch (1317:5): [True: 384k, False: 384k]
  ------------------
 1318|  6.59k|    case STREAM_SUB:    return "sub";
  ------------------
  |  Branch (1318:5): [True: 6.59k, False: 761k]
  ------------------
 1319|      0|    default:            return "unknown";
  ------------------
  |  Branch (1319:5): [True: 0, False: 768k]
  ------------------
 1320|   768k|    }
 1321|   768k|}
demux_append_codec_desc:
 1333|  43.1k|{
 1334|  43.1k|    struct mp_codec_params *c = sh->codec;
 1335|       |
 1336|  43.1k|    bstr_xappend0(ta_ctx, dst, c->codec ? c->codec : "<unknown>");
  ------------------
  |  Branch (1336:32): [True: 43.1k, False: 0]
  ------------------
 1337|       |
 1338|  43.1k|    if (c->codec_profile)
  ------------------
  |  Branch (1338:9): [True: 707, False: 42.3k]
  ------------------
 1339|    707|        bstr_xappend_asprintf(ta_ctx, dst, " [%s]", c->codec_profile);
 1340|  43.1k|    if (c->disp_w)
  ------------------
  |  Branch (1340:9): [True: 17.2k, False: 25.8k]
  ------------------
 1341|  17.2k|        append_field(ta_ctx, dst, skip_dup,
 1342|  17.2k|                     mp_tprintf(32, "%dx%d", c->disp_w, c->disp_h));
  ------------------
  |  |  195|  17.2k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1343|  43.1k|    if (c->fps && !sh->image) {
  ------------------
  |  Branch (1343:9): [True: 9.00k, False: 34.0k]
  |  Branch (1343:19): [True: 6.83k, False: 2.17k]
  ------------------
 1344|  6.83k|        char *fps = mp_format_double(ta_ctx, c->fps, 4, false, false, true);
 1345|  6.83k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%s fps", fps));
  ------------------
  |  |  195|  6.83k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1346|  6.83k|    }
 1347|  43.1k|    if (c->channels.num)
  ------------------
  |  Branch (1347:9): [True: 15.1k, False: 27.9k]
  ------------------
 1348|  15.1k|        bstr_xappend_asprintf(ta_ctx, dst, " %dch", c->channels.num);
 1349|  43.1k|    if (c->samplerate)
  ------------------
  |  Branch (1349:9): [True: 15.6k, False: 27.4k]
  ------------------
 1350|  15.6k|        bstr_xappend_asprintf(ta_ctx, dst, " %d Hz", c->samplerate);
 1351|  43.1k|    int bitrate = 0;
 1352|  43.1k|    if (c->bitrate > 0 && c->bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1352:9): [True: 5.29k, False: 37.8k]
  |  Branch (1352:27): [True: 5.29k, False: 0]
  ------------------
 1353|  5.29k|        bitrate = (c->bitrate + 500) / 1000;
 1354|  37.8k|    } else if (sh->hls_bitrate > 0 && sh->hls_bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1354:16): [True: 0, False: 37.8k]
  |  Branch (1354:39): [True: 0, False: 0]
  ------------------
 1355|      0|        bitrate = (sh->hls_bitrate + 500) / 1000;
 1356|      0|    }
 1357|  43.1k|    if (bitrate)
  ------------------
  |  Branch (1357:9): [True: 5.29k, False: 37.8k]
  ------------------
 1358|  5.29k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%d kbps", bitrate));
  ------------------
  |  |  195|  5.29k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1359|  43.1k|}
demuxer_feed_caption:
 1415|    536|{
 1416|    536|    struct demux_internal *in = stream->ds->in;
 1417|       |
 1418|    536|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|    536|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1419|    536|    struct sh_stream *sh = demuxer_get_cc_track_locked(stream);
 1420|    536|    if (!sh) {
  ------------------
  |  Branch (1420:9): [True: 0, False: 536]
  ------------------
 1421|      0|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1422|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1423|      0|        return;
 1424|      0|    }
 1425|       |
 1426|    536|    dp->keyframe = true;
 1427|    536|    dp->pts = MP_ADD_PTS(dp->pts, -in->ts_offset);
  ------------------
  |  |   67|    536|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    536|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 271, False: 265]
  |  |  ------------------
  ------------------
 1428|    536|    dp->dts = MP_ADD_PTS(dp->dts, -in->ts_offset);
  ------------------
  |  |   67|    536|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    536|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 433, False: 103]
  |  |  ------------------
  ------------------
 1429|    536|    dp->stream = sh->index;
 1430|    536|    add_packet_locked(sh, dp);
 1431|    536|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|    536|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1432|    536|}
demux_read_packet_async:
 2974|   845k|{
 2975|   845k|    return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt);
  ------------------
  |  |   39|   845k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2976|   845k|}
demux_read_packet_async_until:
 2984|   881k|{
 2985|   881k|    struct demux_stream *ds = sh ? sh->ds : NULL;
  ------------------
  |  Branch (2985:31): [True: 881k, False: 0]
  ------------------
 2986|   881k|    *out_pkt = NULL;
 2987|   881k|    if (!ds)
  ------------------
  |  Branch (2987:9): [True: 0, False: 881k]
  ------------------
 2988|      0|        return -1;
 2989|   881k|    struct demux_internal *in = ds->in;
 2990|       |
 2991|   881k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   881k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2992|   881k|    int r = -1;
 2993|   881k|    while (1) {
  ------------------
  |  Branch (2993:12): [True: 881k, Folded]
  ------------------
 2994|   881k|        r = dequeue_packet(ds, min_pts, out_pkt);
 2995|   881k|        if (in->threading || in->blocked || r != 0)
  ------------------
  |  Branch (2995:13): [True: 881k, False: 0]
  |  Branch (2995:30): [True: 0, False: 0]
  |  Branch (2995:45): [True: 0, False: 0]
  ------------------
 2996|   881k|            break;
 2997|       |        // Needs to actually read packets until we got a packet or EOF.
 2998|      0|        thread_work(in);
 2999|      0|    }
 3000|   881k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   881k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3001|   881k|    return r;
 3002|   881k|}
demux_read_any_packet:
 3009|  8.45k|{
 3010|  8.45k|    struct demux_internal *in = demuxer->in;
 3011|  8.45k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  8.45k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3012|  8.45k|    mp_assert(!in->threading); // doesn't work with threading
  ------------------
  |  |   41|  8.45k|#define mp_assert assert
  ------------------
  |  Branch (3012:5): [True: 8.45k, False: 0]
  ------------------
 3013|  8.45k|    struct demux_packet *out_pkt = NULL;
 3014|  8.45k|    int num_streams = in->num_streams;
 3015|  8.45k|    bool read_more = true;
 3016|  17.2k|    while (read_more && !in->blocked) {
  ------------------
  |  Branch (3016:12): [True: 16.9k, False: 376]
  |  Branch (3016:25): [True: 16.9k, False: 0]
  ------------------
 3017|  16.9k|        bool all_eof = true;
 3018|  41.8k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3018:25): [True: 33.0k, False: 8.83k]
  ------------------
 3019|  33.0k|            int r = dequeue_packet(in->streams[n]->ds, MP_NOPTS_VALUE, &out_pkt);
  ------------------
  |  |   39|  33.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3020|  33.0k|            if (r > 0)
  ------------------
  |  Branch (3020:17): [True: 8.08k, False: 24.9k]
  ------------------
 3021|  8.08k|                goto done;
 3022|  24.9k|            if (r == 0)
  ------------------
  |  Branch (3022:17): [True: 18.7k, False: 6.25k]
  ------------------
 3023|  18.7k|                all_eof = false;
 3024|  24.9k|        }
 3025|       |        // retry after calling this
 3026|  8.83k|        read_more = thread_work(in);
 3027|  8.83k|        read_more &= !all_eof;
 3028|  8.83k|        if (new_streams && in->num_streams > num_streams) {
  ------------------
  |  Branch (3028:13): [True: 0, False: 8.83k]
  |  Branch (3028:28): [True: 0, False: 0]
  ------------------
 3029|      0|            *new_streams = true;
 3030|      0|            break;
 3031|      0|        }
 3032|  8.83k|    }
 3033|  8.45k|done:
 3034|  8.45k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  8.45k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3035|  8.45k|    return out_pkt;
 3036|  8.45k|}
demux_update:
 3400|   299k|{
 3401|   299k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|   299k|#define mp_assert assert
  ------------------
  |  Branch (3401:5): [True: 299k, False: 0]
  ------------------
 3402|   299k|    struct demux_internal *in = demuxer->in;
 3403|       |
 3404|   299k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   299k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3405|       |
 3406|   299k|    if (!in->threading)
  ------------------
  |  Branch (3406:9): [True: 24.5k, False: 274k]
  ------------------
 3407|  24.5k|        update_cache(in);
 3408|       |
 3409|       |    // This implies this function is actually called from "the" user thread.
 3410|   299k|    in->d_user->filesize = in->stream_size;
 3411|       |
 3412|   299k|    pts = MP_ADD_PTS(pts, -in->ts_offset);
  ------------------
  |  |   67|   299k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   299k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 24.5k, False: 274k]
  |  |  ------------------
  ------------------
 3413|       |
 3414|   299k|    struct timed_metadata *prev = lookup_timed_metadata(in, in->last_playback_pts);
 3415|   299k|    struct timed_metadata *cur = lookup_timed_metadata(in, pts);
 3416|   299k|    if (prev != cur || in->force_metadata_update) {
  ------------------
  |  Branch (3416:9): [True: 0, False: 299k]
  |  Branch (3416:24): [True: 24.5k, False: 274k]
  ------------------
 3417|  24.5k|        in->force_metadata_update = false;
 3418|  24.5k|        update_final_metadata(demuxer, cur);
 3419|  24.5k|        demuxer->events |= DEMUX_EVENT_METADATA;
 3420|  24.5k|    }
 3421|       |
 3422|   299k|    in->last_playback_pts = pts;
 3423|       |
 3424|   299k|    demuxer->events |= in->events;
 3425|   299k|    in->events = 0;
 3426|   299k|    if (in->lists_changed) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 299k]
  ------------------
 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|   857k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3434:21): [True: 558k, False: 299k]
  ------------------
 3435|   558k|        struct demux_stream *ds = in->streams[n]->ds;
 3436|   558k|        if (ds->staged_codec) {
  ------------------
  |  Branch (3436:13): [True: 0, False: 558k]
  ------------------
 3437|      0|            in->streams[n]->codec = ds->staged_codec;
 3438|      0|            ds->staged_codec = NULL;
 3439|      0|        }
 3440|   558k|    }
 3441|   299k|    if (demuxer->events & (DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS | DEMUX_EVENT_CODEC))
  ------------------
  |  Branch (3441:9): [True: 49.0k, False: 250k]
  ------------------
 3442|  49.0k|        demux_update_replaygain(demuxer);
 3443|   299k|    if (demuxer->events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (3443:9): [True: 58.9k, False: 240k]
  ------------------
 3444|  58.9k|        demuxer->duration = in->duration;
 3445|       |
 3446|   299k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   299k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3447|   299k|}
demux_open_url:
 3766|  24.7k|{
 3767|  24.7k|    if (!params)
  ------------------
  |  Branch (3767:9): [True: 0, False: 24.7k]
  ------------------
 3768|      0|        return NULL;
 3769|  24.7k|    struct mp_cancel *priv_cancel = mp_cancel_new(NULL);
 3770|  24.7k|    if (cancel)
  ------------------
  |  Branch (3770:9): [True: 24.7k, False: 0]
  ------------------
 3771|  24.7k|        mp_cancel_set_parent(priv_cancel, cancel);
 3772|  24.7k|    struct stream *s = params->external_stream;
 3773|  24.7k|    if (!s) {
  ------------------
  |  Branch (3773:9): [True: 24.7k, False: 0]
  ------------------
 3774|  24.7k|        s = stream_create(url, STREAM_READ | params->stream_flags,
  ------------------
  |  |   41|  24.7k|#define STREAM_READ               0
  ------------------
 3775|  24.7k|                          priv_cancel, global);
 3776|  24.7k|        if (s && params->init_fragment.len) {
  ------------------
  |  Branch (3776:13): [True: 24.7k, False: 0]
  |  Branch (3776:18): [True: 0, False: 24.7k]
  ------------------
 3777|      0|            s = create_webshit_concat_stream(global, priv_cancel,
 3778|      0|                                             params->init_fragment, s);
 3779|      0|        }
 3780|  24.7k|    }
 3781|  24.7k|    if (!s) {
  ------------------
  |  Branch (3781:9): [True: 0, False: 24.7k]
  ------------------
 3782|      0|        talloc_free(priv_cancel);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3783|      0|        return NULL;
 3784|      0|    }
 3785|  24.7k|    struct demuxer *d = demux_open(s, priv_cancel, params, global);
 3786|  24.7k|    if (d) {
  ------------------
  |  Branch (3786:9): [True: 24.2k, False: 496]
  ------------------
 3787|  24.2k|        talloc_steal(d->in, priv_cancel);
  ------------------
  |  |   38|  24.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3788|  24.2k|        mp_assert(d->cancel);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (3788:9): [True: 24.2k, False: 0]
  ------------------
 3789|  24.2k|    } else {
 3790|    496|        params->demuxer_failed = true;
 3791|    496|        if (!params->external_stream)
  ------------------
  |  Branch (3791:13): [True: 496, False: 0]
  ------------------
 3792|    496|            free_stream(s);
 3793|    496|        talloc_free(priv_cancel);
  ------------------
  |  |   47|    496|#define talloc_free                     ta_free
  ------------------
 3794|    496|    }
 3795|  24.7k|    return d;
 3796|  24.7k|}
demux_flush:
 3800|  25.0k|{
 3801|  25.0k|    struct demux_internal *in = demuxer->in;
 3802|  25.0k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (3802:5): [True: 25.0k, False: 0]
  ------------------
 3803|       |
 3804|  25.0k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  25.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3805|  25.0k|    clear_reader_state(in, true);
 3806|  49.5k|    for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (3806:21): [True: 24.5k, False: 25.0k]
  ------------------
 3807|  24.5k|        clear_cached_range(in, in->ranges[n]);
 3808|  25.0k|    free_empty_cached_ranges(in);
 3809|  68.2k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3809:21): [True: 43.1k, False: 25.0k]
  ------------------
 3810|  43.1k|        struct demux_stream *ds = in->streams[n]->ds;
 3811|  43.1k|        ds->refreshing = false;
 3812|  43.1k|        ds->eof = false;
 3813|  43.1k|    }
 3814|  25.0k|    in->eof = false;
 3815|  25.0k|    in->seeking = false;
 3816|  25.0k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  25.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3817|  25.0k|}
demux_seek:
 4076|    384|{
 4077|    384|    struct demux_internal *in = demuxer->in;
 4078|    384|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|    384|#define mp_assert assert
  ------------------
  |  Branch (4078:5): [True: 384, False: 0]
  ------------------
 4079|       |
 4080|    384|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|    384|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4081|       |
 4082|    384|    if (!(flags & SEEK_FACTOR))
  ------------------
  |  |   94|    384|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (4082:9): [True: 384, False: 0]
  ------------------
 4083|    384|        seek_pts = MP_ADD_PTS(seek_pts, -in->ts_offset);
  ------------------
  |  |   67|    384|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    384|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 384]
  |  |  ------------------
  ------------------
 4084|       |
 4085|    384|    int res = queue_seek(in, seek_pts, flags, true);
 4086|       |
 4087|    384|    mp_cond_signal(&in->wakeup);
 4088|    384|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|    384|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4089|       |
 4090|    384|    return res;
 4091|    384|}
demuxer_select_track:
 4325|  52.3k|{
 4326|  52.3k|    struct demux_internal *in = demuxer->in;
 4327|  52.3k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  52.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4328|  52.3k|    bool changed = select_track(in, stream, ref_pts, selected);
 4329|  52.3k|    changed |= select_dependent_tracks(in, stream, ref_pts, selected);
 4330|  52.3k|    if (changed) {
  ------------------
  |  Branch (4330:9): [True: 43.7k, False: 8.57k]
  ------------------
 4331|  43.7k|        if (in->threading) {
  ------------------
  |  Branch (4331:13): [True: 43.2k, False: 468]
  ------------------
 4332|  43.2k|            mp_cond_signal(&in->wakeup);
 4333|  43.2k|        } else {
 4334|    468|            execute_trackswitch(in);
 4335|    468|        }
 4336|  43.7k|    }
 4337|  52.3k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  52.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4338|  52.3k|}
demux_stream_is_selected:
 4390|   479k|{
 4391|   479k|    if (!stream)
  ------------------
  |  Branch (4391:9): [True: 7.57k, False: 472k]
  ------------------
 4392|  7.57k|        return false;
 4393|   479k|    bool r = false;
 4394|   472k|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|   472k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4395|   472k|    r = stream->ds->selected;
 4396|   472k|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|   472k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4397|   472k|    return r;
 4398|   479k|}
demux_stream_eof_is_lazy:
 4405|   348k|{
 4406|   348k|    if (!stream)
  ------------------
  |  Branch (4406:9): [True: 0, False: 348k]
  ------------------
 4407|      0|        return false;
 4408|   348k|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|   348k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4409|   348k|    bool r = stream->ds->lazy_eof;
 4410|   348k|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|   348k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4411|   348k|    return r;
 4412|   348k|}
demux_set_stream_wakeup_cb:
 4427|  75.2k|{
 4428|  75.2k|    mp_mutex_lock(&sh->ds->in->lock);
  ------------------
  |  |  134|  75.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4429|  75.2k|    sh->ds->wakeup_cb = cb;
 4430|  75.2k|    sh->ds->wakeup_cb_ctx = ctx;
 4431|  75.2k|    sh->ds->need_wakeup = true;
 4432|  75.2k|    mp_mutex_unlock(&sh->ds->in->lock);
  ------------------
  |  |  136|  75.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4433|  75.2k|}
demuxer_add_attachment:
 4437|  1.13k|{
 4438|  1.13k|    if (!(demuxer->num_attachments % 32))
  ------------------
  |  Branch (4438:9): [True: 578, False: 555]
  ------------------
 4439|    578|        demuxer->attachments = talloc_realloc(demuxer, demuxer->attachments,
  ------------------
  |  |   33|    578|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|    578|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|    578|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    578|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    578|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    578|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4440|  1.13k|                                              struct demux_attachment,
 4441|  1.13k|                                              demuxer->num_attachments + 32);
 4442|       |
 4443|  1.13k|    struct demux_attachment *att = &demuxer->attachments[demuxer->num_attachments];
 4444|  1.13k|    att->name = talloc_strdup(demuxer->attachments, name);
  ------------------
  |  |   50|  1.13k|#define talloc_strdup                   ta_xstrdup
  ------------------
 4445|  1.13k|    att->type = talloc_strdup(demuxer->attachments, type);
  ------------------
  |  |   50|  1.13k|#define talloc_strdup                   ta_xstrdup
  ------------------
 4446|  1.13k|    att->data = talloc_memdup(demuxer->attachments, data, data_size);
  ------------------
  |  |   49|  1.13k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  1.13k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.13k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  1.13k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  1.13k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4447|  1.13k|    att->data_size = data_size;
 4448|       |
 4449|  1.13k|    return demuxer->num_attachments++;
 4450|  1.13k|}
demuxer_add_chapter:
 4474|  3.91k|{
 4475|  3.91k|    struct demux_chapter new = {
 4476|  3.91k|        .original_index = demuxer->num_chapters,
 4477|  3.91k|        .pts = pts,
 4478|  3.91k|        .metadata = talloc_zero(demuxer, struct mp_tags),
  ------------------
  |  |   27|  3.91k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  3.91k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  3.91k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4479|  3.91k|        .demuxer_id = demuxer_id,
 4480|  3.91k|    };
 4481|  3.91k|    mp_tags_set_str(new.metadata, "TITLE", name);
 4482|  3.91k|    MP_TARRAY_APPEND(demuxer, demuxer->chapters, demuxer->num_chapters, new);
  ------------------
  |  |  105|  3.91k|    do {                                            \
  |  |  106|  3.91k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  3.91k|    do {                                            \
  |  |  |  |   97|  3.91k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  3.91k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.91k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  3.91k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.83k, False: 2.07k]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.91k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.83k|    do {                                                        \
  |  |  |  |  |  |   89|  1.83k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.83k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.83k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.83k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.83k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.83k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.83k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.83k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  3.91k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3.91k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  3.91k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  3.91k|        (idxvar)++;                                 \
  |  |  109|  3.91k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.91k]
  |  |  ------------------
  ------------------
 4483|  3.91k|    talloc_steal(demuxer->chapters, new.metadata);
  ------------------
  |  |   38|  3.91k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  3.91k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4484|  3.91k|    return demuxer->num_chapters - 1;
 4485|  3.91k|}
demux_report_unbuffered_read_bytes:
 4831|  13.8k|{
 4832|  13.8k|    struct demux_internal *in = demuxer->in;
 4833|  13.8k|    mp_assert(demuxer == in->d_thread);
  ------------------
  |  |   41|  13.8k|#define mp_assert assert
  ------------------
  |  Branch (4833:5): [True: 13.8k, False: 0]
  ------------------
 4834|       |
 4835|  13.8k|    in->slave_unbuffered_read_bytes += new;
 4836|  13.8k|}
demux_get_bytes_read_hack:
 4841|  13.8k|{
 4842|  13.8k|    struct demux_internal *in = demuxer->in;
 4843|       |
 4844|       |    // Required because demuxer==in->d_user, and we access in->d_thread.
 4845|       |    // Locking won't solve this, because we also need to access struct stream.
 4846|  13.8k|    mp_assert(!in->threading);
  ------------------
  |  |   41|  13.8k|#define mp_assert assert
  ------------------
  |  Branch (4846:5): [True: 13.8k, False: 0]
  ------------------
 4847|       |
 4848|  13.8k|    update_bytes_read(in);
 4849|       |
 4850|  13.8k|    int64_t res = in->hack_unbuffered_read_bytes;
 4851|  13.8k|    in->hack_unbuffered_read_bytes = 0;
 4852|  13.8k|    return res;
 4853|  13.8k|}
demux_get_reader_state:
 4874|   427k|{
 4875|   427k|    struct demux_internal *in = demuxer->in;
 4876|   427k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   427k|#define mp_assert assert
  ------------------
  |  Branch (4876:5): [True: 427k, False: 0]
  ------------------
 4877|       |
 4878|   427k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   427k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4879|       |
 4880|   427k|    *r = (struct demux_reader_state){
 4881|   427k|        .eof = in->eof,
 4882|   427k|        .ts_info = {
 4883|   427k|            .reader = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   427k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4884|   427k|            .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   427k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4885|   427k|            .duration = -1,
 4886|   427k|        },
 4887|   427k|        .total_bytes = in->total_bytes,
 4888|   427k|        .seeking = in->seeking_in_progress,
 4889|   427k|        .low_level_seeks = in->low_level_seeks,
 4890|   427k|        .ts_last = in->demux_ts,
 4891|   427k|        .bytes_per_second = in->bytes_per_second,
 4892|   427k|        .byte_level_seeks = in->byte_level_seeks,
 4893|   427k|        .file_cache_bytes = in->cache ? demux_cache_get_size(in->cache) : -1,
  ------------------
  |  Branch (4893:29): [True: 0, False: 427k]
  ------------------
 4894|   427k|    };
 4895|   427k|    bool any_packets = false;
 4896|  1.71M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4896:21): [True: 1.28M, False: 427k]
  ------------------
 4897|  1.28M|        r->ts_per_stream[n] = r->ts_info;
 4898|  1.28M|    }
 4899|  1.22M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4899:21): [True: 801k, False: 427k]
  ------------------
 4900|   801k|        struct demux_stream *ds = in->streams[n]->ds;
 4901|   801k|        if (ds->eager && !(!ds->queue->head && ds->eof) && !ds->ignore_eof) {
  ------------------
  |  Branch (4901:13): [True: 561k, False: 240k]
  |  Branch (4901:28): [True: 260k, False: 300k]
  |  Branch (4901:48): [True: 213k, False: 47.4k]
  |  Branch (4901:60): [True: 347k, False: 0]
  ------------------
 4902|   347k|            r->underrun |= !ds->reader_head && !ds->eof && !ds->still_image;
  ------------------
  |  Branch (4902:28): [True: 47.4k, False: 300k]
  |  Branch (4902:48): [True: 47.4k, False: 0]
  |  Branch (4902:60): [True: 47.4k, False: 0]
  ------------------
 4903|   347k|            any_packets |= !!ds->reader_head;
 4904|       |
 4905|   347k|            double ts_reader = ds->base_ts;
 4906|   347k|            double ts_end = ds->queue->last_ts;
 4907|   347k|            double ts_duration = -1;
 4908|   347k|            if (ts_reader != MP_NOPTS_VALUE && ts_reader <= ts_end)
  ------------------
  |  |   39|   695k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4908:17): [True: 315k, False: 32.0k]
  |  Branch (4908:48): [True: 308k, False: 7.71k]
  ------------------
 4909|   308k|                ts_duration = ts_end - ts_reader;
 4910|       |
 4911|   347k|            struct demux_ctrl_ts_info *i = &r->ts_per_stream[ds->type];
 4912|   347k|            i->reader = MP_PTS_MIN(i->reader, ts_reader);
  ------------------
  |  |   64|   347k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   695k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 347k]
  |  |  |  |  |  Branch (45:23): [True: 347k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 32.0k, False: 315k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 347k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4913|   347k|            i->end = MP_PTS_MIN(i->end, ts_end);
  ------------------
  |  |   64|   347k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   695k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 347k]
  |  |  |  |  |  Branch (45:23): [True: 347k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 32.4k, False: 315k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 347k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4914|   347k|            i->duration = ts_duration;
 4915|   347k|        }
 4916|   801k|        r->fw_bytes += get_forward_buffered_bytes(ds);
 4917|   801k|    }
 4918|   427k|    struct demux_ctrl_ts_info *ots = &r->ts_info;
 4919|       |    // find stream type with lowest duration and use its state
 4920|  1.71M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4920:21): [True: 1.28M, False: 427k]
  ------------------
 4921|  1.28M|        struct demux_ctrl_ts_info *ts = &r->ts_per_stream[n];
 4922|  1.28M|        if (r->ts_info.duration != -1) {
  ------------------
  |  Branch (4922:13): [True: 513k, False: 769k]
  ------------------
 4923|       |            // skip if timestamps unknown
 4924|   513k|            if (ts->duration == -1)
  ------------------
  |  Branch (4924:17): [True: 491k, False: 21.9k]
  ------------------
 4925|   491k|                continue;
 4926|       |            // skip if we already know of a smaller cached stream
 4927|  21.9k|            if (ts->duration > ots->duration)
  ------------------
  |  Branch (4927:17): [True: 12.4k, False: 9.44k]
  ------------------
 4928|  12.4k|                continue;
 4929|       |            // skip empty subtitle streams when other streams exist
 4930|  9.44k|            if (n == STREAM_SUB && ts->duration == 0.0)
  ------------------
  |  Branch (4930:17): [True: 0, False: 9.44k]
  |  Branch (4930:36): [True: 0, False: 0]
  ------------------
 4931|      0|                continue;
 4932|  9.44k|        }
 4933|   778k|        ots->duration = ts->duration;
 4934|   778k|        ots->reader = ts->reader;
 4935|   778k|        ots->end = ts->end;
 4936|   778k|    }
 4937|   427k|    r->idle = (!in->reading && !r->underrun) || r->eof;
  ------------------
  |  Branch (4937:16): [True: 374k, False: 53.1k]
  |  Branch (4937:32): [True: 374k, False: 0]
  |  Branch (4937:49): [True: 0, False: 53.1k]
  ------------------
 4938|   427k|    r->underrun &= !r->idle && in->threading;
  ------------------
  |  Branch (4938:20): [True: 53.1k, False: 374k]
  |  Branch (4938:32): [True: 53.1k, False: 0]
  ------------------
 4939|   427k|    ots->reader = MP_ADD_PTS(ots->reader, in->ts_offset);
  ------------------
  |  |   67|   427k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   427k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 141k, False: 286k]
  |  |  ------------------
  ------------------
 4940|   427k|    ots->end = MP_ADD_PTS(ots->end, in->ts_offset);
  ------------------
  |  |   67|   427k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   427k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 141k, False: 286k]
  |  |  ------------------
  ------------------
 4941|   427k|    if (ots->reader != MP_NOPTS_VALUE && ots->reader <= ots->end)
  ------------------
  |  |   39|   855k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4941:9): [True: 286k, False: 141k]
  |  Branch (4941:42): [True: 286k, False: 0]
  ------------------
 4942|   286k|        ots->duration = ots->end - ots->reader;
 4943|   427k|    if (in->seeking || !any_packets)
  ------------------
  |  Branch (4943:9): [True: 3, False: 427k]
  |  Branch (4943:24): [True: 149k, False: 278k]
  ------------------
 4944|   149k|        ots->duration = 0;
 4945|   855k|    for (int n = 0; n < MPMIN(in->num_ranges, MAX_SEEK_RANGES); n++) {
  ------------------
  |  |   45|   855k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 855k]
  |  |  ------------------
  ------------------
  |  Branch (4945:21): [True: 427k, False: 427k]
  ------------------
 4946|   427k|        struct demux_cached_range *range = in->ranges[n];
 4947|   427k|        if (range->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   427k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4947:13): [True: 0, False: 427k]
  ------------------
 4948|      0|            r->seek_ranges[r->num_seek_ranges++] =
 4949|      0|                (struct demux_seek_range){
 4950|      0|                    .start = MP_ADD_PTS(range->seek_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]
  |  |  ------------------
  ------------------
 4951|      0|                    .end = MP_ADD_PTS(range->seek_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]
  |  |  ------------------
  ------------------
 4952|      0|                };
 4953|      0|            r->bof_cached |= range->is_bof;
 4954|      0|            r->eof_cached |= range->is_eof;
 4955|      0|        }
 4956|   427k|    }
 4957|       |
 4958|   427k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   427k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4959|   427k|}
demux_cancel_test:
 4962|  2.68M|{
 4963|  2.68M|    return mp_cancel_test(demuxer->cancel);
 4964|  2.68M|}
demux_read_interrupted:
 4969|   790k|{
 4970|   790k|    struct demux_internal *in = demuxer->in;
 4971|   790k|    return atomic_load_explicit(&in->seeking, memory_order_relaxed) ||
  ------------------
  |  Branch (4971:12): [True: 0, False: 790k]
  ------------------
 4972|   790k|           atomic_load_explicit(&in->thread_terminate, memory_order_relaxed) ||
  ------------------
  |  Branch (4972:12): [True: 0, False: 790k]
  ------------------
 4973|   790k|           demux_cancel_test(demuxer);
  ------------------
  |  Branch (4973:12): [True: 0, False: 790k]
  ------------------
 4974|   790k|}
demux_copy_chapter_data:
 4977|  24.2k|{
 4978|  24.2k|    struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num);
  ------------------
  |  |   29|  24.2k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  24.2k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4979|  28.1k|    for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (4979:21): [True: 3.89k, False: 24.2k]
  ------------------
 4980|  3.89k|        new[n] = c[n];
 4981|  3.89k|        new[n].metadata = mp_tags_dup(new, new[n].metadata);
 4982|  3.89k|    }
 4983|  24.2k|    return new;
 4984|  24.2k|}
demux.c:update_stream_eager_state:
  900|  86.9k|{
  901|  86.9k|    bool any_av_streams = false;
  902|  86.9k|    bool any_streams = false;
  903|       |
  904|   267k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (904:21): [True: 180k, False: 86.9k]
  ------------------
  905|   180k|        struct demux_stream *s = in->streams[n]->ds;
  906|       |
  907|   180k|        s->still_image = s->sh->still_image;
  908|   180k|        s->eager = s->selected && !s->sh->absent && !s->sh->attached_picture;
  ------------------
  |  Branch (908:20): [True: 63.3k, False: 117k]
  |  Branch (908:35): [True: 63.3k, False: 0]
  |  Branch (908:53): [True: 62.9k, False: 351]
  ------------------
  909|   180k|        if (s->eager && !s->still_image)
  ------------------
  |  Branch (909:13): [True: 62.9k, False: 117k]
  |  Branch (909:25): [True: 62.9k, False: 0]
  ------------------
  910|  62.9k|            any_av_streams |= s->type != STREAM_SUB;
  911|   180k|        any_streams |= s->selected;
  912|   180k|    }
  913|       |
  914|       |    // Subtitles and sparse still-image video are only eagerly read if there are
  915|       |    // no other eagerly read streams.
  916|  86.9k|    if (any_av_streams) {
  ------------------
  |  Branch (916:9): [True: 42.9k, False: 44.0k]
  ------------------
  917|   141k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (917:25): [True: 98.1k, False: 42.9k]
  ------------------
  918|  98.1k|            struct demux_stream *s = in->streams[n]->ds;
  919|       |
  920|  98.1k|            if (s->type == STREAM_SUB || s->still_image)
  ------------------
  |  Branch (920:17): [True: 16.9k, False: 81.1k]
  |  Branch (920:42): [True: 0, False: 81.1k]
  ------------------
  921|  16.9k|                s->eager = false;
  922|  98.1k|        }
  923|  42.9k|    }
  924|       |
  925|  86.9k|    if (!any_streams)
  ------------------
  |  Branch (925:9): [True: 43.5k, False: 43.3k]
  ------------------
  926|  43.5k|        in->blocked = false;
  927|  86.9k|}
demux.c:demux_add_sh_stream_locked:
 1023|  43.1k|{
 1024|  43.1k|    mp_assert(!sh->ds); // must not be added yet
  ------------------
  |  |   41|  43.1k|#define mp_assert assert
  ------------------
  |  Branch (1024:5): [True: 43.1k, False: 0]
  ------------------
 1025|       |
 1026|  43.1k|    sh->index = in->num_streams;
 1027|       |
 1028|  43.1k|    sh->ds = talloc(sh, struct demux_stream);
  ------------------
  |  |   26|  43.1k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  43.1k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1029|  43.1k|    *sh->ds = (struct demux_stream) {
 1030|  43.1k|        .in = in,
 1031|  43.1k|        .sh = sh,
 1032|  43.1k|        .type = sh->type,
 1033|  43.1k|        .index = sh->index,
 1034|  43.1k|        .global_correct_dts = true,
 1035|  43.1k|        .global_correct_pos = true,
 1036|  43.1k|    };
 1037|       |
 1038|  43.1k|    struct demux_stream *ds = sh->ds;
 1039|       |
 1040|  43.1k|    if (!sh->codec->codec)
  ------------------
  |  Branch (1040:9): [True: 2.81k, False: 40.3k]
  ------------------
 1041|  2.81k|        sh->codec->codec = "";
 1042|       |
 1043|  43.1k|    MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
  ------------------
  |  |  105|  43.1k|    do {                                            \
  |  |  106|  43.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  43.1k|    do {                                            \
  |  |  |  |   97|  43.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  43.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  43.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  43.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 25.5k, False: 17.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  43.1k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  25.5k|    do {                                                        \
  |  |  |  |  |  |   89|  25.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  25.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  25.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  25.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  25.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  25.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  25.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 25.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  43.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 43.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  43.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  43.1k|        (idxvar)++;                                 \
  |  |  109|  43.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43.1k]
  |  |  ------------------
  ------------------
 1044|  43.1k|    mp_assert(in->streams[sh->index] == sh);
  ------------------
  |  |   41|  43.1k|#define mp_assert assert
  ------------------
  |  Branch (1044:5): [True: 43.1k, False: 0]
  ------------------
 1045|       |
 1046|  43.1k|    if (in->current_range) {
  ------------------
  |  Branch (1046:9): [True: 273, False: 42.9k]
  ------------------
 1047|    546|        for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (1047:25): [True: 273, False: 273]
  ------------------
 1048|    273|            add_missing_streams(in, in->ranges[n]);
 1049|       |
 1050|    273|        sh->ds->queue = in->current_range->streams[sh->ds->index];
 1051|    273|    }
 1052|       |
 1053|  43.1k|    update_stream_selection_state(in, sh->ds);
 1054|       |
 1055|  43.1k|    switch (ds->type) {
  ------------------
  |  Branch (1055:13): [True: 37.6k, False: 5.52k]
  ------------------
 1056|  17.5k|    case STREAM_AUDIO:
  ------------------
  |  Branch (1056:5): [True: 17.5k, False: 25.5k]
  ------------------
 1057|  17.5k|        ds->back_preroll = in->d_user->opts->audio_back_preroll;
 1058|  17.5k|        if (ds->back_preroll < 0) { // auto
  ------------------
  |  Branch (1058:13): [True: 17.5k, False: 0]
  ------------------
 1059|  17.5k|            ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1;
  ------------------
  |  Branch (1059:32): [True: 1.06k, False: 16.5k]
  ------------------
 1060|  17.5k|            if (sh->codec->codec && (strcmp(sh->codec->codec, "opus") == 0 ||
  ------------------
  |  Branch (1060:17): [True: 17.5k, False: 0]
  |  Branch (1060:38): [True: 922, False: 16.6k]
  ------------------
 1061|  16.6k|                                     strcmp(sh->codec->codec, "vorbis") == 0 ||
  ------------------
  |  Branch (1061:38): [True: 531, False: 16.1k]
  ------------------
 1062|  16.1k|                                     strcmp(sh->codec->codec, "mp3") == 0))
  ------------------
  |  Branch (1062:38): [True: 609, False: 15.5k]
  ------------------
 1063|  2.06k|                ds->back_preroll = 2;
 1064|  17.5k|        }
 1065|  17.5k|        break;
 1066|  20.0k|    case STREAM_VIDEO:
  ------------------
  |  Branch (1066:5): [True: 20.0k, False: 23.1k]
  ------------------
 1067|  20.0k|        ds->back_preroll = in->d_user->opts->video_back_preroll;
 1068|  20.0k|        if (ds->back_preroll < 0)
  ------------------
  |  Branch (1068:13): [True: 20.0k, False: 0]
  ------------------
 1069|  20.0k|            ds->back_preroll = 0; // auto
 1070|  20.0k|        break;
 1071|  43.1k|    }
 1072|       |
 1073|  43.1k|    if (!ds->sh->attached_picture) {
  ------------------
  |  Branch (1073:9): [True: 42.9k, False: 293]
  ------------------
 1074|       |        // Typically this is used for webradio, so any stream will do.
 1075|  42.9k|        if (!in->metadata_stream)
  ------------------
  |  Branch (1075:13): [True: 22.5k, False: 20.3k]
  ------------------
 1076|  22.5k|            in->metadata_stream = sh;
 1077|  42.9k|    }
 1078|       |
 1079|  43.1k|    in->events |= DEMUX_EVENT_STREAMS;
 1080|  43.1k|    if (in->wakeup_cb)
  ------------------
  |  Branch (1080:9): [True: 273, False: 42.9k]
  ------------------
 1081|    273|        in->wakeup_cb(in->wakeup_cb_ctx);
 1082|  43.1k|}
demux.c:add_missing_streams:
  984|  24.8k|{
  985|  68.0k|    for (int n = range->num_streams; n < in->num_streams; n++) {
  ------------------
  |  Branch (985:38): [True: 43.1k, False: 24.8k]
  ------------------
  986|  43.1k|        struct demux_stream *ds = in->streams[n]->ds;
  987|       |
  988|  43.1k|        struct demux_queue *queue = talloc_ptrtype(NULL, queue);
  ------------------
  |  |   34|  43.1k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  43.1k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|  43.1k|        *queue = (struct demux_queue){
  990|  43.1k|            .ds = ds,
  991|  43.1k|            .range = range,
  992|  43.1k|        };
  993|  43.1k|        clear_queue(queue);
  994|  43.1k|        MP_TARRAY_APPEND(range, range->streams, range->num_streams, queue);
  ------------------
  |  |  105|  43.1k|    do {                                            \
  |  |  106|  43.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  43.1k|    do {                                            \
  |  |  |  |   97|  43.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  43.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  43.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  43.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 25.5k, False: 17.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  43.1k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  25.5k|    do {                                                        \
  |  |  |  |  |  |   89|  25.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  25.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  25.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  25.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  25.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  25.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  25.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 25.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  43.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 43.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  43.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  43.1k|        (idxvar)++;                                 \
  |  |  109|  43.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43.1k]
  |  |  ------------------
  ------------------
  995|       |        mp_assert(range->streams[ds->index] == queue);
  ------------------
  |  |   41|  43.1k|#define mp_assert assert
  ------------------
  |  Branch (995:9): [True: 43.1k, False: 0]
  ------------------
  996|  43.1k|    }
  997|  24.8k|}
demux.c:clear_queue:
  758|   136k|{
  759|   136k|    struct demux_stream *ds = queue->ds;
  760|   136k|    struct demux_internal *in = ds->in;
  761|       |
  762|   136k|    if (queue->head)
  ------------------
  |  Branch (762:9): [True: 359, False: 136k]
  ------------------
  763|    359|        in->total_bytes -= queue->tail_cum_pos - queue->head->cum_pos;
  764|       |
  765|   136k|    free_index(queue);
  766|       |
  767|   136k|    demux_packet_pool_prepend(in->packet_pool, queue->head, queue->tail);
  768|   136k|    queue->head = queue->tail = NULL;
  769|   136k|    queue->keyframe_first = NULL;
  770|   136k|    queue->keyframe_latest = NULL;
  771|   136k|    queue->seek_start = queue->seek_end = queue->last_pruned = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   136k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  772|       |
  773|   136k|    queue->correct_dts = queue->correct_pos = true;
  774|   136k|    queue->last_pos = -1;
  775|   136k|    queue->last_ts = queue->last_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   136k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  776|   136k|    queue->last_pos_fixup = -1;
  777|       |
  778|   136k|    queue->is_eof = false;
  779|       |    queue->is_bof = false;
  780|   136k|}
demux.c:free_index:
  746|   136k|{
  747|   136k|    struct demux_stream *ds = queue->ds;
  748|   136k|    struct demux_internal *in = ds->in;
  749|       |
  750|   136k|    in->total_bytes -= queue->index_size * sizeof(queue->index[0]);
  751|   136k|    queue->index_size = 0;
  752|   136k|    queue->index0 = 0;
  753|   136k|    queue->num_index = 0;
  754|       |    TA_FREEP(&queue->index);
  ------------------
  |  |   81|   136k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   136k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 136k]
  |  |  ------------------
  ------------------
  755|   136k|}
demux.c:demux_shutdown:
 1120|  25.0k|{
 1121|  25.0k|    struct demuxer *demuxer = in->d_user;
 1122|       |
 1123|  25.0k|    if (in->recorder) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 25.0k]
  ------------------
 1124|      0|        mp_recorder_destroy(in->recorder);
 1125|      0|        in->recorder = NULL;
 1126|      0|    }
 1127|       |
 1128|  25.0k|    dumper_close(in);
 1129|       |
 1130|  25.0k|    if (demuxer->desc->close)
  ------------------
  |  Branch (1130:9): [True: 25.0k, False: 0]
  ------------------
 1131|  25.0k|        demuxer->desc->close(in->d_thread);
 1132|  25.0k|    demuxer->priv = NULL;
 1133|  25.0k|    in->d_thread->priv = NULL;
 1134|       |
 1135|  25.0k|    demux_flush(demuxer);
 1136|  25.0k|    mp_assert(in->total_bytes == 0);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (1136:5): [True: 25.0k, False: 0]
  ------------------
 1137|       |
 1138|  25.0k|    in->current_range = NULL;
 1139|  25.0k|    free_empty_cached_ranges(in);
 1140|       |
 1141|  25.0k|    talloc_free(in->cache);
  ------------------
  |  |   47|  25.0k|#define talloc_free                     ta_free
  ------------------
 1142|  25.0k|    in->cache = NULL;
 1143|       |
 1144|  25.0k|    if (in->owns_stream)
  ------------------
  |  Branch (1144:9): [True: 25.0k, False: 0]
  ------------------
 1145|  25.0k|        free_stream(demuxer->stream);
 1146|       |    demuxer->stream = NULL;
 1147|  25.0k|}
demux.c:demux_dealloc:
 1150|  25.0k|{
 1151|  68.2k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1151:21): [True: 43.1k, False: 25.0k]
  ------------------
 1152|  43.1k|        talloc_free(in->streams[n]);
  ------------------
  |  |   47|  43.1k|#define talloc_free                     ta_free
  ------------------
 1153|  25.0k|    mp_mutex_destroy(&in->lock);
  ------------------
  |  |  133|  25.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1154|  25.0k|    mp_cond_destroy(&in->wakeup);
 1155|  25.0k|    talloc_free(in->d_user);
  ------------------
  |  |   47|  25.0k|#define talloc_free                     ta_free
  ------------------
 1156|  25.0k|}
demux.c:append_field:
 1325|  29.3k|{
 1326|  29.3k|    if (skip_dup && skip_dup[0] && strstr(skip_dup, value))
  ------------------
  |  Branch (1326:9): [True: 0, False: 29.3k]
  |  Branch (1326:21): [True: 0, False: 0]
  |  Branch (1326:36): [True: 0, False: 0]
  ------------------
 1327|      0|        return;
 1328|  29.3k|    bstr_xappend_asprintf(ta_ctx, dst, " %s", value);
 1329|  29.3k|}
demux.c:demuxer_get_cc_track_locked:
 1394|    536|{
 1395|    536|    struct sh_stream *sh = stream->ds->cc;
 1396|       |
 1397|    536|    if (!sh) {
  ------------------
  |  Branch (1397:9): [True: 273, False: 263]
  ------------------
 1398|    273|        sh = demux_alloc_sh_stream(STREAM_SUB);
 1399|    273|        if (!sh)
  ------------------
  |  Branch (1399:13): [True: 0, False: 273]
  ------------------
 1400|      0|            return NULL;
 1401|    273|        sh->codec->codec = "eia_608";
 1402|    273|        sh->default_track = true;
 1403|    273|        sh->hls_bitrate = stream->hls_bitrate;
 1404|    273|        for (int i = 0; i < stream->num_program_ids; i++)
  ------------------
  |  Branch (1404:25): [True: 0, False: 273]
  ------------------
 1405|      0|            MP_TARRAY_APPEND(sh, sh->program_ids, sh->num_program_ids, stream->program_ids[i]);
  ------------------
  |  |  105|    273|    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]
  |  |  ------------------
  ------------------
 1406|    273|        stream->ds->cc = sh;
 1407|    273|        demux_add_sh_stream_locked(stream->ds->in, sh);
 1408|    273|        sh->ds->ignore_eof = true;
 1409|    273|    }
 1410|       |
 1411|    536|    return sh;
 1412|    536|}
demux.c:add_packet_locked:
 2153|   767k|{
 2154|   767k|    struct demux_stream *ds = stream ? stream->ds : NULL;
  ------------------
  |  Branch (2154:31): [True: 767k, False: 0]
  ------------------
 2155|   767k|    mp_assert(ds && ds->in);
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (2155:5): [True: 767k, False: 0]
  |  Branch (2155:5): [True: 767k, False: 0]
  ------------------
 2156|   767k|    if (!dp->len || demux_cancel_test(ds->in->d_thread)) {
  ------------------
  |  Branch (2156:9): [True: 0, False: 767k]
  |  Branch (2156:21): [True: 0, False: 767k]
  ------------------
 2157|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2158|      0|        return;
 2159|      0|    }
 2160|       |
 2161|   767k|    mp_assert(dp->stream == stream->index);
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (2161:5): [True: 767k, False: 0]
  ------------------
 2162|   767k|    mp_assert(!dp->next);
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (2162:5): [True: 767k, False: 0]
  ------------------
 2163|       |
 2164|   767k|    struct demux_internal *in = ds->in;
 2165|       |
 2166|   767k|    in->after_seek = false;
 2167|   767k|    in->after_seek_to_start = false;
 2168|       |
 2169|   767k|    double ts = dp->dts == MP_NOPTS_VALUE ? dp->pts : dp->dts;
  ------------------
  |  |   39|   767k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2169:17): [True: 714k, False: 52.9k]
  ------------------
 2170|   767k|    if (dp->segmented)
  ------------------
  |  Branch (2170:9): [True: 7.41k, False: 760k]
  ------------------
 2171|  7.41k|        ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|  7.41k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  14.8k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 600, False: 6.81k]
  |  |  |  |  |  Branch (45:23): [True: 769, False: 6.64k]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 7.41k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 600]
  |  |  |  |  |  Branch (45:41): [True: 769, False: 6.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2172|       |
 2173|   767k|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   767k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2173:9): [True: 490k, False: 277k]
  ------------------
 2174|   490k|        in->demux_ts = ts;
 2175|       |
 2176|   767k|    struct demux_queue *queue = ds->queue;
 2177|       |
 2178|   767k|    bool drop = !ds->selected || in->seeking || ds->sh->attached_picture;
  ------------------
  |  Branch (2178:17): [True: 273, False: 767k]
  |  Branch (2178:34): [True: 0, False: 767k]
  |  Branch (2178:49): [True: 2, False: 767k]
  ------------------
 2179|       |
 2180|   767k|    if (!drop) {
  ------------------
  |  Branch (2180:9): [True: 767k, False: 275]
  ------------------
 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|   767k|        if ((dp->pos < 0 || dp->pos == queue->last_pos_fixup) &&
  ------------------
  |  Branch (2183:14): [True: 263, False: 766k]
  |  Branch (2183:29): [True: 1.14k, False: 765k]
  ------------------
 2184|  1.40k|            !dp->keyframe && queue->last_pos_fixup >= 0)
  ------------------
  |  Branch (2184:13): [True: 1.14k, False: 263]
  |  Branch (2184:30): [True: 1.14k, False: 0]
  ------------------
 2185|  1.14k|            dp->pos = queue->last_pos_fixup + 1;
 2186|   767k|        queue->last_pos_fixup = dp->pos;
 2187|   767k|    }
 2188|       |
 2189|   767k|    if (!drop && ds->refreshing) {
  ------------------
  |  Branch (2189:9): [True: 767k, False: 275]
  |  Branch (2189:18): [True: 2.31k, False: 764k]
  ------------------
 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|  2.31k|        if (queue->correct_dts) {
  ------------------
  |  Branch (2193:13): [True: 0, False: 2.31k]
  ------------------
 2194|      0|            ds->refreshing = dp->dts < queue->last_dts;
 2195|  2.31k|        } else if (queue->correct_pos) {
  ------------------
  |  Branch (2195:20): [True: 2.31k, False: 0]
  ------------------
 2196|  2.31k|            ds->refreshing = dp->pos < queue->last_pos;
 2197|  2.31k|        } 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|  2.31k|        drop = true;
 2202|  2.31k|    }
 2203|       |
 2204|   767k|    if (drop) {
  ------------------
  |  Branch (2204:9): [True: 2.59k, False: 764k]
  ------------------
 2205|  2.59k|        demux_packet_pool_push(in->packet_pool, dp);
 2206|  2.59k|        return;
 2207|  2.59k|    }
 2208|       |
 2209|   764k|    record_packet(in, dp);
 2210|       |
 2211|   764k|    if (in->cache && in->d_user->opts->disk_cache && !dp->is_wrapped_avframe) {
  ------------------
  |  Branch (2211:9): [True: 0, False: 764k]
  |  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|   764k|    queue->correct_pos &= dp->pos >= 0 && dp->pos > queue->last_pos;
  ------------------
  |  Branch (2220:27): [True: 764k, False: 263]
  |  Branch (2220:43): [True: 763k, False: 1.02k]
  ------------------
 2221|   764k|    queue->correct_dts &= dp->dts != MP_NOPTS_VALUE && dp->dts > queue->last_dts;
  ------------------
  |  |   39|  1.52M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2221:27): [True: 52.8k, False: 712k]
  |  Branch (2221:56): [True: 42.4k, False: 10.3k]
  ------------------
 2222|   764k|    queue->last_pos = dp->pos;
 2223|   764k|    queue->last_dts = dp->dts;
 2224|   764k|    ds->global_correct_pos &= queue->correct_pos;
 2225|   764k|    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|   764k|    if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
  ------------------
  |  Branch (2229:9): [True: 120k, False: 644k]
  |  Branch (2229:30): [True: 120k, False: 0]
  |  Branch (2229:55): [True: 0, False: 0]
  ------------------
 2230|   120k|        ds->reader_head = dp;
 2231|   120k|        ds->skip_to_keyframe = false;
 2232|   120k|    }
 2233|       |
 2234|   764k|    size_t bytes = demux_packet_estimate_total_size(dp);
 2235|   764k|    in->total_bytes += bytes;
 2236|   764k|    dp->cum_pos = queue->tail_cum_pos;
 2237|   764k|    queue->tail_cum_pos += bytes;
 2238|       |
 2239|   764k|    if (queue->tail) {
  ------------------
  |  Branch (2239:9): [True: 644k, False: 120k]
  ------------------
 2240|       |        // next packet in stream
 2241|   644k|        queue->tail->next = dp;
 2242|   644k|        queue->tail = dp;
 2243|   644k|    } else {
 2244|       |        // first packet in stream
 2245|   120k|        queue->head = queue->tail = dp;
 2246|   120k|    }
 2247|       |
 2248|   764k|    if (!ds->ignore_eof) {
  ------------------
  |  Branch (2248:9): [True: 764k, False: 263]
  ------------------
 2249|       |        // obviously not true anymore
 2250|   764k|        ds->eof = false;
 2251|   764k|        in->eof = false;
 2252|   764k|    }
 2253|       |
 2254|       |    // For video, PTS determination is not trivial, but for other media types
 2255|       |    // distinguishing PTS and DTS is not useful.
 2256|   764k|    if (stream->type != STREAM_VIDEO && dp->pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   387k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2256:9): [True: 387k, False: 377k]
  |  Branch (2256:41): [True: 138k, False: 248k]
  ------------------
 2257|   138k|        dp->pts = dp->dts;
 2258|       |
 2259|   764k|    if (ts != MP_NOPTS_VALUE && (ts > queue->last_ts || ts + 10 < queue->last_ts))
  ------------------
  |  |   39|  1.52M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2259:9): [True: 488k, False: 276k]
  |  Branch (2259:34): [True: 130k, False: 357k]
  |  Branch (2259:57): [True: 4.44k, False: 353k]
  ------------------
 2260|   135k|        queue->last_ts = ts;
 2261|   764k|    if (ds->base_ts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   764k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2261:9): [True: 26.0k, False: 738k]
  ------------------
 2262|  26.0k|        ds->base_ts = queue->last_ts;
 2263|       |
 2264|   764k|    const char *num_pkts = queue->head == queue->tail ? "1" : ">1";
  ------------------
  |  Branch (2264:28): [True: 120k, False: 644k]
  ------------------
 2265|   764k|    uint64_t fw_bytes = get_forward_buffered_bytes(ds);
 2266|   764k|    MP_TRACE(in, "append packet to %s: size=%zu pts=%f dts=%f pos=%"PRIi64" "
  ------------------
  |  |   94|   764k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   764k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2267|   764k|             "[num=%s size=%zd]\n", stream_type_name(stream->type),
 2268|   764k|             dp->len, dp->pts, dp->dts, dp->pos, num_pkts, (size_t)fw_bytes);
 2269|       |
 2270|   764k|    adjust_seek_range_on_packet(ds, dp);
 2271|       |
 2272|       |    // May need to reduce backward cache.
 2273|   764k|    prune_old_packets(in);
 2274|       |
 2275|       |    // Possibly update duration based on highest TS demuxed (but ignore subs).
 2276|   764k|    if (stream->type != STREAM_SUB) {
  ------------------
  |  Branch (2276:9): [True: 758k, False: 6.13k]
  ------------------
 2277|   758k|        if (dp->segmented)
  ------------------
  |  Branch (2277:13): [True: 7.34k, False: 751k]
  ------------------
 2278|  7.34k|            ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|  7.34k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  14.6k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 7.34k]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 7.34k]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 7.34k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 7.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2279|   758k|        if (ts > in->highest_av_pts) {
  ------------------
  |  Branch (2279:13): [True: 85.5k, False: 673k]
  ------------------
 2280|  85.5k|            in->highest_av_pts = ts;
 2281|  85.5k|            double duration = in->highest_av_pts - in->d_thread->start_time;
 2282|  85.5k|            if (duration > in->d_thread->duration) {
  ------------------
  |  Branch (2282:17): [True: 23.1k, False: 62.4k]
  ------------------
 2283|  23.1k|                in->d_thread->duration = duration;
 2284|       |                // (Don't wakeup user thread, would be too noisy.)
 2285|  23.1k|                in->events |= DEMUX_EVENT_DURATION;
 2286|  23.1k|                in->duration = duration;
 2287|  23.1k|            }
 2288|  85.5k|        }
 2289|   758k|    }
 2290|       |
 2291|       |    // Don't process the packet further if it's skipped by the previous seek
 2292|       |    // (see reader_head check/assignment above).
 2293|   764k|    if (!ds->reader_head)
  ------------------
  |  Branch (2293:9): [True: 0, False: 764k]
  ------------------
 2294|      0|        return;
 2295|       |
 2296|   764k|    back_demux_see_packets(ds);
 2297|       |
 2298|   764k|    wakeup_ds(ds);
 2299|   764k|}
demux.c:record_packet:
 2122|   764k|{
 2123|       |    // (should preferably be outside of the lock)
 2124|   764k|    if (in->enable_recording && !in->recorder &&
  ------------------
  |  Branch (2124:9): [True: 0, False: 764k]
  |  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|   764k|    if (in->recorder) {
  ------------------
  |  Branch (2136:9): [True: 0, False: 764k]
  ------------------
 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|   764k|    if (in->dumper_status == CONTROL_OK)
  ------------------
  |  |   95|   764k|#define CONTROL_OK 1
  ------------------
  |  Branch (2148:9): [True: 0, False: 764k]
  ------------------
 2149|      0|        write_dump_packet(in, dp);
 2150|   764k|}
demux.c:adjust_seek_range_on_packet:
 2015|   811k|{
 2016|   811k|    struct demux_queue *queue = ds->queue;
 2017|       |
 2018|   811k|    if (!ds->in->seekable_cache)
  ------------------
  |  Branch (2018:9): [True: 811k, False: 0]
  ------------------
 2019|   811k|        return;
 2020|       |
 2021|   811k|    bool new_eof = !dp;
 2022|      0|    bool update_ranges = queue->is_eof != new_eof;
 2023|      0|    queue->is_eof = new_eof;
 2024|       |
 2025|      0|    if (!dp || dp->keyframe) {
  ------------------
  |  Branch (2025:9): [True: 0, False: 0]
  |  Branch (2025:16): [True: 0, False: 0]
  ------------------
 2026|      0|        if (queue->keyframe_latest) {
  ------------------
  |  Branch (2026:13): [True: 0, False: 0]
  ------------------
 2027|      0|            double kf_min, kf_max;
 2028|      0|            compute_keyframe_times(queue->keyframe_latest, &kf_min, &kf_max);
 2029|       |
 2030|      0|            if (kf_min != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2030:17): [True: 0, False: 0]
  ------------------
 2031|      0|                add_index_entry(queue, queue->keyframe_latest, kf_min);
 2032|       |
 2033|       |                // Initialize the queue's start if it's unset.
 2034|      0|                if (queue->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2034:21): [True: 0, False: 0]
  ------------------
 2035|      0|                    update_ranges = true;
 2036|      0|                    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|      0|                    double start_time = ds->in->d_thread->start_time;
 2044|      0|                    if (queue->is_bof && ds->in->d_thread->seekable &&
  ------------------
  |  Branch (2044:25): [True: 0, False: 0]
  |  Branch (2044:42): [True: 0, False: 0]
  ------------------
 2045|      0|                        start_time != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2045:25): [True: 0, False: 0]
  ------------------
 2046|      0|                        queue->seek_start > start_time + BOF_START_TOLERANCE)
  ------------------
  |  |  348|      0|#define BOF_START_TOLERANCE 1.0
  ------------------
  |  Branch (2046:25): [True: 0, False: 0]
  ------------------
 2047|      0|                    {
 2048|      0|                        queue->is_bof = false;
 2049|      0|                    }
 2050|      0|                }
 2051|      0|            }
 2052|       |
 2053|      0|            if (kf_max != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2053:17): [True: 0, False: 0]
  ------------------
 2054|      0|                (queue->seek_end == MP_NOPTS_VALUE || kf_max > queue->seek_end))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2054:18): [True: 0, False: 0]
  |  Branch (2054:55): [True: 0, False: 0]
  ------------------
 2055|      0|            {
 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|      0|                if (queue->range->seek_end == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2061:21): [True: 0, False: 0]
  ------------------
 2062|      0|                    queue->seek_end <= queue->range->seek_end)
  ------------------
  |  Branch (2062:21): [True: 0, False: 0]
  ------------------
 2063|      0|                {
 2064|      0|                    update_ranges = true;
 2065|      0|                }
 2066|       |
 2067|      0|                queue->seek_end = kf_max;
 2068|      0|            }
 2069|      0|        }
 2070|       |
 2071|      0|        queue->keyframe_latest = dp;
 2072|      0|    }
 2073|       |
 2074|       |    // Adding a sparse packet never changes the seek range.
 2075|      0|    if (update_ranges && ds->eager) {
  ------------------
  |  Branch (2075:9): [True: 0, False: 0]
  |  Branch (2075:26): [True: 0, False: 0]
  ------------------
 2076|      0|        update_seek_ranges(queue->range);
 2077|      0|        attempt_range_joining(ds->in);
 2078|      0|    }
 2079|      0|}
demux.c:update_seek_ranges:
  629|   137k|{
  630|   137k|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   137k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  631|   137k|    range->is_bof = true;
  632|   137k|    range->is_eof = true;
  633|       |
  634|   137k|    double min_start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   137k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  635|   137k|    double max_end_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   137k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  636|       |
  637|   162k|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (637:21): [True: 155k, False: 6.22k]
  ------------------
  638|   155k|        struct demux_queue *queue = range->streams[n];
  639|       |
  640|   155k|        if (queue->ds->selected && queue->ds->eager) {
  ------------------
  |  Branch (640:13): [True: 131k, False: 24.0k]
  |  Branch (640:36): [True: 130k, False: 1.02k]
  ------------------
  641|   130k|            if (queue->is_bof) {
  ------------------
  |  Branch (641:17): [True: 3.55k, False: 127k]
  ------------------
  642|  3.55k|                min_start_pts = MP_PTS_MIN(min_start_pts, queue->seek_start);
  ------------------
  |  |   64|  3.55k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  7.10k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 3.55k]
  |  |  |  |  |  Branch (45:23): [True: 3.55k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 3.55k, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 3.55k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|   127k|            } else {
  644|   127k|                range->seek_start =
  645|   127k|                    MP_PTS_MAX(range->seek_start, queue->seek_start);
  ------------------
  |  |   65|   127k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|   254k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 127k]
  |  |  |  |  |  Branch (44:23): [True: 127k, False: 1]
  |  |  |  |  |  Branch (44:29): [True: 126k, False: 546]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 126k, False: 546]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|   127k|            }
  647|       |
  648|   130k|            if (queue->is_eof) {
  ------------------
  |  Branch (648:17): [True: 0, False: 130k]
  ------------------
  649|      0|                max_end_pts = MP_PTS_MAX(max_end_pts, queue->seek_end);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|   130k|            } else {
  651|   130k|                range->seek_end = MP_PTS_MIN(range->seek_end, queue->seek_end);
  ------------------
  |  |   64|   130k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   261k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 130k]
  |  |  |  |  |  Branch (45:23): [True: 130k, False: 1]
  |  |  |  |  |  Branch (45:29): [True: 130k, False: 1]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 130k, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|   130k|            }
  653|       |
  654|   130k|            range->is_eof &= queue->is_eof;
  655|   130k|            range->is_bof &= queue->is_bof;
  656|       |
  657|   130k|            bool empty = queue->is_eof && !queue->head;
  ------------------
  |  Branch (657:26): [True: 0, False: 130k]
  |  Branch (657:43): [True: 0, False: 0]
  ------------------
  658|   130k|            if (queue->seek_start >= queue->seek_end && !empty &&
  ------------------
  |  Branch (658:17): [True: 130k, False: 1]
  |  Branch (658:57): [True: 130k, False: 0]
  ------------------
  659|   130k|                !(queue->seek_start == queue->seek_end &&
  ------------------
  |  Branch (659:19): [True: 130k, False: 545]
  ------------------
  660|   130k|                  queue->seek_start != MP_NOPTS_VALUE))
  ------------------
  |  |   39|   130k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (660:19): [True: 0, False: 130k]
  ------------------
  661|   130k|                goto broken;
  662|   130k|        }
  663|   155k|    }
  664|       |
  665|  6.22k|    if (range->is_eof)
  ------------------
  |  Branch (665:9): [True: 6.22k, False: 1]
  ------------------
  666|  6.22k|        range->seek_end = max_end_pts;
  667|  6.22k|    if (range->is_bof)
  ------------------
  |  Branch (667:9): [True: 6.22k, False: 1]
  ------------------
  668|  6.22k|        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|  9.69k|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (694:21): [True: 3.46k, False: 6.22k]
  ------------------
  695|  3.46k|        struct demux_queue *queue = range->streams[n];
  696|  3.46k|        if (queue->ds->selected && !queue->ds->eager &&
  ------------------
  |  Branch (696:13): [True: 729, False: 2.73k]
  |  Branch (696:36): [True: 729, False: 0]
  ------------------
  697|    729|            queue->last_pruned != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  4.19k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (697:13): [True: 0, False: 729]
  ------------------
  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|  3.46k|    }
  706|       |
  707|  6.22k|    if (range->seek_start >= range->seek_end && !(range->is_bof && range->is_eof))
  ------------------
  |  Branch (707:9): [True: 6.22k, False: 1]
  |  Branch (707:51): [True: 6.22k, False: 0]
  |  Branch (707:68): [True: 6.22k, False: 0]
  ------------------
  708|      0|        goto broken;
  709|       |
  710|  6.22k|    prune_metadata(range);
  711|  6.22k|    return;
  712|       |
  713|   130k|broken:
  714|   130k|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   130k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  715|   130k|    prune_metadata(range);
  716|   130k|}
demux.c:prune_metadata:
  603|   137k|{
  604|   137k|    int first_needed = 0;
  605|       |
  606|   137k|    if (range->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   137k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (606:9): [True: 137k, False: 0]
  ------------------
  607|   137k|        first_needed = range->num_metadata;
  608|   137k|    } else {
  609|      0|        for (int n = 0; n < range->num_metadata ; n++) {
  ------------------
  |  Branch (609:25): [True: 0, False: 0]
  ------------------
  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|      0|    }
  615|       |
  616|       |    // Always preserve the last entry.
  617|   137k|    first_needed = MPMIN(first_needed, range->num_metadata - 1);
  ------------------
  |  |   45|   137k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 137k, 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|   137k|    for (int n = 0; n < first_needed; n++) {
  ------------------
  |  Branch (621:21): [True: 0, False: 137k]
  ------------------
  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|   137k|}
demux.c:remove_head_packet:
  720|   757k|{
  721|   757k|    struct demux_packet *dp = queue->head;
  722|       |
  723|   757k|    mp_assert(queue->ds->reader_head != dp);
  ------------------
  |  |   41|   757k|#define mp_assert assert
  ------------------
  |  Branch (723:5): [True: 757k, False: 0]
  ------------------
  724|   757k|    if (queue->keyframe_first == dp)
  ------------------
  |  Branch (724:9): [True: 294k, False: 462k]
  ------------------
  725|   294k|        queue->keyframe_first = NULL;
  726|   757k|    if (queue->keyframe_latest == dp)
  ------------------
  |  Branch (726:9): [True: 0, False: 757k]
  ------------------
  727|      0|        queue->keyframe_latest = NULL;
  728|   757k|    queue->is_bof = false;
  729|       |
  730|   757k|    uint64_t end_pos = dp->next ? dp->next->cum_pos : queue->tail_cum_pos;
  ------------------
  |  Branch (730:24): [True: 637k, False: 119k]
  ------------------
  731|   757k|    queue->ds->in->total_bytes -= end_pos - dp->cum_pos;
  732|       |
  733|   757k|    if (queue->num_index && queue->index[queue->index0].pkt == dp) {
  ------------------
  |  Branch (733:9): [True: 0, False: 757k]
  |  Branch (733:29): [True: 0, False: 0]
  ------------------
  734|      0|        queue->index0 = (queue->index0 + 1) & QUEUE_INDEX_SIZE_MASK(queue);
  ------------------
  |  |  335|      0|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  ------------------
  735|      0|        queue->num_index -= 1;
  736|      0|    }
  737|       |
  738|   757k|    queue->head = dp->next;
  739|   757k|    if (!queue->head)
  ------------------
  |  Branch (739:9): [True: 119k, False: 637k]
  ------------------
  740|   119k|        queue->tail = NULL;
  741|       |
  742|   757k|    demux_packet_pool_push(queue->ds->in->packet_pool, dp);
  743|   757k|}
demux.c:prune_old_packets:
 2465|  1.54M|{
 2466|  1.54M|    mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|  1.54M|#define mp_assert assert
  ------------------
  |  Branch (2466:5): [True: 1.54M, False: 1]
  ------------------
 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.30M|    while (1) {
  ------------------
  |  Branch (2471:12): [True: 2.30M, Folded]
  ------------------
 2472|  2.30M|        uint64_t fw_bytes = 0;
 2473|  6.67M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2473:25): [True: 4.37M, False: 2.30M]
  ------------------
 2474|  4.37M|            struct demux_stream *ds = in->streams[n]->ds;
 2475|  4.37M|            fw_bytes += get_forward_buffered_bytes(ds);
 2476|  4.37M|        }
 2477|  2.30M|        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.30M|        if (max_avail && in->max_bytes > (fw_bytes + 1) && in->d_user->opts->donate_fw)
  ------------------
  |  Branch (2480:13): [True: 0, False: 2.30M]
  |  Branch (2480:26): [True: 0, False: 0]
  |  Branch (2480:60): [True: 0, False: 0]
  ------------------
 2481|      0|            max_avail += in->max_bytes - (fw_bytes + 1);
 2482|  2.30M|        if (in->total_bytes - fw_bytes <= max_avail)
  ------------------
  |  Branch (2482:13): [True: 1.54M, False: 757k]
  ------------------
 2483|  1.54M|            break;
 2484|       |
 2485|       |        // (Start from least recently used range.)
 2486|   757k|        struct demux_cached_range *range = in->ranges[0];
 2487|   757k|        double earliest_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2488|   757k|        struct demux_stream *earliest_stream = NULL;
 2489|       |
 2490|  1.14M|        for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (2490:25): [True: 1.14M, False: 33]
  ------------------
 2491|  1.14M|            struct demux_queue *queue = range->streams[n];
 2492|  1.14M|            struct demux_stream *ds = queue->ds;
 2493|       |
 2494|  1.14M|            if (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2494:17): [True: 816k, False: 331k]
  |  Branch (2494:32): [True: 757k, False: 59.3k]
  ------------------
 2495|   757k|                struct demux_packet *dp = queue->head;
 2496|   757k|                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|   757k|                bool prune_always =
 2501|   757k|                    !in->seekable_cache || ts == MP_NOPTS_VALUE || !dp->keyframe;
  ------------------
  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2501:21): [True: 757k, False: 0]
  |  Branch (2501:44): [True: 0, False: 0]
  |  Branch (2501:68): [True: 0, False: 0]
  ------------------
 2502|   757k|                if (prune_always || !earliest_stream || ts < earliest_ts) {
  ------------------
  |  Branch (2502:21): [True: 757k, False: 0]
  |  Branch (2502:37): [True: 0, False: 0]
  |  Branch (2502:57): [True: 0, False: 0]
  ------------------
 2503|   757k|                    earliest_ts = ts;
 2504|   757k|                    earliest_stream = ds;
 2505|   757k|                    if (prune_always)
  ------------------
  |  Branch (2505:25): [True: 757k, False: 0]
  ------------------
 2506|   757k|                        break;
 2507|   757k|                }
 2508|   757k|            }
 2509|  1.14M|        }
 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|   757k|        if (!earliest_stream)
  ------------------
  |  Branch (2513:13): [True: 0, False: 757k]
  ------------------
 2514|      0|            break;
 2515|       |
 2516|   757k|        struct demux_stream *ds = earliest_stream;
 2517|   757k|        struct demux_queue *queue = range->streams[ds->index];
 2518|       |
 2519|   757k|        bool non_kf_prune = queue->head && !queue->head->keyframe;
  ------------------
  |  Branch (2519:29): [True: 757k, False: 33]
  |  Branch (2519:44): [True: 422k, False: 334k]
  ------------------
 2520|   757k|        bool kf_was_pruned = false;
 2521|       |
 2522|  1.51M|        while (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2522:16): [True: 1.39M, False: 119k]
  |  Branch (2522:31): [True: 757k, False: 637k]
  ------------------
 2523|   757k|            if (queue->head->keyframe) {
  ------------------
  |  Branch (2523:17): [True: 334k, False: 422k]
  ------------------
 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|   334k|                if ((kf_was_pruned || non_kf_prune) && in->seekable_cache)
  ------------------
  |  Branch (2530:22): [True: 0, False: 334k]
  |  Branch (2530:39): [True: 0, False: 334k]
  |  Branch (2530:56): [True: 0, False: 0]
  ------------------
 2531|      0|                    break;
 2532|   334k|                kf_was_pruned = true;
 2533|   334k|            }
 2534|       |
 2535|   757k|            remove_head_packet(queue);
 2536|   757k|        }
 2537|       |
 2538|       |        // Need to update the seekable time range.
 2539|   757k|        if (kf_was_pruned) {
  ------------------
  |  Branch (2539:13): [True: 334k, False: 422k]
  ------------------
 2540|   334k|            mp_assert(!queue->keyframe_first); // it was just deleted, supposedly
  ------------------
  |  |   41|   334k|#define mp_assert assert
  ------------------
  |  Branch (2540:13): [True: 334k, False: 0]
  ------------------
 2541|       |
 2542|   334k|            queue->keyframe_first = queue->head;
 2543|       |            // (May happen if reader_head stopped pruning the range, and there's
 2544|       |            // no next range.)
 2545|   514k|            while (queue->keyframe_first && !queue->keyframe_first->keyframe)
  ------------------
  |  Branch (2545:20): [True: 474k, False: 39.7k]
  |  Branch (2545:45): [True: 180k, False: 294k]
  ------------------
 2546|   180k|                queue->keyframe_first = queue->keyframe_first->next;
 2547|       |
 2548|   334k|            if (queue->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2548:17): [True: 291k, False: 42.6k]
  ------------------
 2549|   291k|                queue->last_pruned = queue->seek_start;
 2550|       |
 2551|   334k|            double kf_min;
 2552|   334k|            compute_keyframe_times(queue->keyframe_first, &kf_min, NULL);
 2553|       |
 2554|   334k|            bool update_range = true;
 2555|       |
 2556|   334k|            queue->seek_start = kf_min;
 2557|       |
 2558|   334k|            if (queue->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2558:17): [True: 292k, False: 42.4k]
  ------------------
 2559|   292k|                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|   292k|                if (range->seek_start == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|   584k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2563:21): [True: 292k, False: 0]
  ------------------
 2564|      0|                    queue->seek_start <= range->seek_start)
  ------------------
  |  Branch (2564:21): [True: 0, False: 0]
  ------------------
 2565|   292k|                {
 2566|   292k|                    update_range = false;
 2567|   292k|                }
 2568|   292k|            }
 2569|       |
 2570|   334k|            if (update_range)
  ------------------
  |  Branch (2570:17): [True: 42.3k, False: 292k]
  ------------------
 2571|  42.3k|                update_seek_ranges(range);
 2572|   334k|        }
 2573|       |
 2574|   757k|        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: 757k]
  |  Branch (2574:43): [True: 0, False: 0]
  ------------------
 2575|      0|            free_empty_cached_ranges(in);
 2576|   757k|    }
 2577|  1.54M|}
demux.c:back_demux_see_packets:
 1713|   811k|{
 1714|   811k|    struct demux_internal *in = ds->in;
 1715|       |
 1716|   811k|    if (!ds->selected || !in->back_demuxing || !ds->eager)
  ------------------
  |  Branch (1716:9): [True: 7.33k, False: 804k]
  |  Branch (1716:26): [True: 804k, False: 0]
  |  Branch (1716:48): [True: 0, False: 0]
  ------------------
 1717|   811k|        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|   757k|{
 2779|   757k|    struct demux_packet *pkt = ds->reader_head;
 2780|   757k|    if (!pkt)
  ------------------
  |  Branch (2780:9): [True: 0, False: 757k]
  ------------------
 2781|      0|        return NULL;
 2782|       |
 2783|   757k|    ds->reader_head = pkt->next;
 2784|       |
 2785|   757k|    ds->last_ret_pos = pkt->pos;
 2786|   757k|    ds->last_ret_dts = pkt->dts;
 2787|       |
 2788|   757k|    return pkt;
 2789|   757k|}
demux.c:ds_clear_reader_state:
  842|   131k|{
  843|   131k|    ds_clear_reader_queue_state(ds);
  844|       |
  845|   131k|    ds->base_ts = ds->last_br_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  846|   131k|    ds->last_br_bytes = 0;
  847|   131k|    ds->bitrate = -1;
  848|   131k|    ds->skip_to_keyframe = false;
  849|   131k|    ds->attached_picture_added = false;
  850|   131k|    ds->lazy_eof = false;
  851|   131k|    ds->last_ret_pos = -1;
  852|   131k|    ds->last_ret_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  853|   131k|    ds->force_read_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  854|       |
  855|   131k|    if (clear_back_state) {
  ------------------
  |  Branch (855:9): [True: 131k, False: 0]
  ------------------
  856|   131k|        ds->back_restart_pos = -1;
  857|   131k|        ds->back_restart_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  858|   131k|        ds->back_restart_eof = false;
  859|   131k|        ds->back_restart_next = ds->in->back_demuxing;
  860|   131k|        ds->back_restarting = ds->in->back_demuxing && ds->eager;
  ------------------
  |  Branch (860:31): [True: 0, False: 131k]
  |  Branch (860:56): [True: 0, False: 0]
  ------------------
  861|   131k|        ds->back_seek_pos = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  862|   131k|        ds->back_resume_pos = -1;
  863|   131k|        ds->back_resume_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   131k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  864|   131k|        ds->back_resuming = false;
  865|       |        ds->back_range_started = false;
  866|   131k|        ds->back_range_count = 0;
  867|   131k|        ds->back_range_preroll = 0;
  868|   131k|    }
  869|   131k|}
demux.c:ds_clear_reader_queue_state:
  834|   132k|{
  835|   132k|    ds->reader_head = NULL;
  836|   132k|    ds->eof = false;
  837|       |    ds->need_wakeup = true;
  838|   132k|}
demux.c:demux_thread:
 2747|  24.2k|{
 2748|  24.2k|    struct demux_internal *in = pctx;
 2749|  24.2k|    mp_thread_set_name("demux");
 2750|  24.2k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2751|       |
 2752|  24.2k|    stats_register_thread_cputime(in->stats, "thread");
 2753|       |
 2754|  1.04M|    while (!in->thread_terminate) {
  ------------------
  |  Branch (2754:12): [True: 1.02M, False: 24.2k]
  ------------------
 2755|  1.02M|        if (thread_work(in))
  ------------------
  |  Branch (2755:13): [True: 811k, False: 211k]
  ------------------
 2756|   811k|            continue;
 2757|   211k|        mp_cond_signal(&in->wakeup);
 2758|   211k|        mp_cond_timedwait_until(&in->wakeup, &in->lock, in->next_cache_update);
 2759|   211k|    }
 2760|       |
 2761|  24.2k|    if (in->shutdown_async) {
  ------------------
  |  Branch (2761:9): [True: 24.2k, False: 0]
  ------------------
 2762|  24.2k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2763|  24.2k|        demux_shutdown(in);
 2764|  24.2k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2765|  24.2k|        in->shutdown_async = false;
 2766|  24.2k|        if (in->wakeup_cb)
  ------------------
  |  Branch (2766:13): [True: 24.2k, False: 0]
  ------------------
 2767|  24.2k|            in->wakeup_cb(in->wakeup_cb_ctx);
 2768|  24.2k|    }
 2769|       |
 2770|  24.2k|    stats_unregister_thread(in->stats, "thread");
 2771|       |
 2772|  24.2k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2773|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  24.2k|#define MP_THREAD_RETURN() return NULL
  ------------------
 2774|  24.2k|}
demux.c:dequeue_packet:
 2823|   914k|{
 2824|   914k|    struct demux_internal *in = ds->in;
 2825|       |
 2826|   914k|    if (!ds->selected)
  ------------------
  |  Branch (2826:9): [True: 3.51k, False: 910k]
  ------------------
 2827|  3.51k|        return -1;
 2828|   910k|    if (in->blocked)
  ------------------
  |  Branch (2828:9): [True: 0, False: 910k]
  ------------------
 2829|      0|        return 0;
 2830|       |
 2831|   910k|    if (ds->sh->attached_picture) {
  ------------------
  |  Branch (2831:9): [True: 468, False: 910k]
  ------------------
 2832|    468|        ds->eof = true;
 2833|    468|        if (ds->attached_picture_added)
  ------------------
  |  Branch (2833:13): [True: 182, False: 286]
  ------------------
 2834|    182|            return -1;
 2835|    286|        ds->attached_picture_added = true;
 2836|    286|        struct demux_packet *pkt = demux_copy_packet(in->packet_pool,
 2837|    286|                                                     ds->sh->attached_picture);
 2838|    286|        MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|    286|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    286|        void *oom_p_ = (x);     \
  |  |  208|    286|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 286]
  |  |  ------------------
  |  |  209|    286|            abort();            \
  |  |  210|    286|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 286]
  |  |  ------------------
  ------------------
 2839|    286|        pkt->stream = ds->sh->index;
 2840|    286|        *res = pkt;
 2841|    286|        return 1;
 2842|    286|    }
 2843|       |
 2844|   910k|    if (!in->reading && !in->eof) {
  ------------------
  |  Branch (2844:9): [True: 755k, False: 154k]
  |  Branch (2844:25): [True: 160k, False: 595k]
  ------------------
 2845|   160k|        in->reading = true; // enable demuxer thread prefetching
 2846|   160k|        mp_cond_signal(&in->wakeup);
 2847|   160k|    }
 2848|       |
 2849|   910k|    ds->force_read_until = min_pts;
 2850|       |
 2851|   910k|    if (ds->back_resuming || ds->back_restarting) {
  ------------------
  |  Branch (2851:9): [True: 7, False: 910k]
  |  Branch (2851:30): [True: 18.4E, False: 910k]
  ------------------
 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|   910k|    bool eof = !ds->reader_head && ds->eof;
  ------------------
  |  Branch (2856:16): [True: 153k, False: 757k]
  |  Branch (2856:36): [True: 62.9k, False: 90.0k]
  ------------------
 2857|       |
 2858|   910k|    if (in->back_demuxing) {
  ------------------
  |  Branch (2858:9): [True: 0, False: 910k]
  ------------------
 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|   910k|    ds->need_wakeup = !ds->reader_head;
 2881|   910k|    if (!ds->reader_head || eof) {
  ------------------
  |  Branch (2881:9): [True: 153k, False: 757k]
  |  Branch (2881:29): [True: 0, False: 757k]
  ------------------
 2882|   153k|        if (!ds->eager) {
  ------------------
  |  Branch (2882:13): [True: 32.2k, False: 120k]
  ------------------
 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|  32.2k|            if (!lazy_stream_needs_wait(ds))
  ------------------
  |  Branch (2889:17): [True: 32.1k, False: 16]
  ------------------
 2890|  32.1k|                ds->eof = eof = true;
 2891|  32.2k|        }
 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|   153k|        if (eof)
  ------------------
  |  Branch (2895:13): [True: 64.9k, False: 88.1k]
  ------------------
 2896|  64.9k|            ds->lazy_eof = !in->eof && !in->back_demuxing;
  ------------------
  |  Branch (2896:28): [True: 6.76k, False: 58.1k]
  |  Branch (2896:40): [True: 6.76k, False: 0]
  ------------------
 2897|   153k|        return eof ? -1 : 0;
  ------------------
  |  Branch (2897:16): [True: 64.9k, False: 88.1k]
  ------------------
 2898|   153k|    }
 2899|       |
 2900|   757k|    struct demux_packet *pkt = advance_reader_head(ds);
 2901|   757k|    mp_assert(pkt);
  ------------------
  |  |   41|   757k|#define mp_assert assert
  ------------------
  |  Branch (2901:5): [True: 757k, False: 7]
  ------------------
 2902|   757k|    pkt = read_packet_from_cache(in, pkt);
 2903|   757k|    if (!pkt)
  ------------------
  |  Branch (2903:9): [True: 0, False: 757k]
  ------------------
 2904|      0|        return 0;
 2905|   757k|    ds->lazy_eof = false;
 2906|       |
 2907|   757k|    if (in->back_demuxing) {
  ------------------
  |  Branch (2907:9): [True: 0, False: 757k]
  ------------------
 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|   757k|    double ts = MP_PTS_OR_DEF(pkt->dts, pkt->pts);
  ------------------
  |  |   62|   757k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 704k, False: 52.8k]
  |  |  ------------------
  ------------------
 2925|   757k|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2925:9): [True: 480k, False: 276k]
  ------------------
 2926|   480k|        ds->base_ts = ts;
 2927|       |
 2928|   757k|    if (pkt->keyframe && ts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2928:9): [True: 334k, False: 422k]
  |  Branch (2928:26): [True: 333k, False: 948]
  ------------------
 2929|       |        // Update bitrate - only at keyframe points, because we use the
 2930|       |        // (possibly) reordered packet timestamps instead of realtime.
 2931|   333k|        double d = ts - ds->last_br_ts;
 2932|   333k|        if (ds->last_br_ts == MP_NOPTS_VALUE || d < 0) {
  ------------------
  |  |   39|   667k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2932:13): [True: 20.8k, False: 312k]
  |  Branch (2932:49): [True: 6.85k, False: 305k]
  ------------------
 2933|  27.6k|            ds->bitrate = -1;
 2934|  27.6k|            ds->last_br_ts = ts;
 2935|  27.6k|            ds->last_br_bytes = 0;
 2936|   305k|        } else if (d >= 0.5) { // a window of least 500ms for UI purposes
  ------------------
  |  Branch (2936:20): [True: 7.66k, False: 298k]
  ------------------
 2937|  7.66k|            ds->bitrate = ds->last_br_bytes / d;
 2938|  7.66k|            ds->last_br_ts = ts;
 2939|  7.66k|            ds->last_br_bytes = 0;
 2940|  7.66k|        }
 2941|   333k|    }
 2942|   757k|    ds->last_br_bytes += pkt->len;
 2943|       |
 2944|       |    // This implies this function is actually called from "the" user thread.
 2945|   757k|    if (pkt->pos >= in->d_user->filepos)
  ------------------
  |  Branch (2945:9): [True: 596k, False: 160k]
  ------------------
 2946|   596k|        in->d_user->filepos = pkt->pos;
 2947|   757k|    in->d_user->filesize = in->stream_size;
 2948|       |
 2949|   757k|    pkt->pts = MP_ADD_PTS(pkt->pts, in->ts_offset);
  ------------------
  |  |   67|   757k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 329k, False: 427k]
  |  |  ------------------
  ------------------
 2950|   757k|    pkt->dts = MP_ADD_PTS(pkt->dts, in->ts_offset);
  ------------------
  |  |   67|   757k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   757k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 704k, False: 52.8k]
  |  |  ------------------
  ------------------
 2951|       |
 2952|   757k|    if (pkt->segmented) {
  ------------------
  |  Branch (2952:9): [True: 7.38k, False: 749k]
  ------------------
 2953|  7.38k|        pkt->start = MP_ADD_PTS(pkt->start, in->ts_offset);
  ------------------
  |  |   67|  7.38k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  7.38k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 7.38k]
  |  |  ------------------
  ------------------
 2954|  7.38k|        pkt->end = MP_ADD_PTS(pkt->end, in->ts_offset);
  ------------------
  |  |   67|  7.38k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  7.38k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 7.38k]
  |  |  ------------------
  ------------------
 2955|  7.38k|    }
 2956|       |
 2957|   757k|    prune_old_packets(in);
 2958|   757k|    *res = pkt;
 2959|   757k|    return 1;
 2960|   757k|}
demux.c:lazy_stream_needs_wait:
 2312|   450k|{
 2313|   450k|    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|   450k|    return !ds->eager && !in->back_demuxing &&
  ------------------
  |  Branch (2316:12): [True: 450k, False: 0]
  |  Branch (2316:26): [True: 450k, False: 0]
  ------------------
 2317|   450k|           !in->eof && ds->force_read_until != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|   876k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2317:12): [True: 425k, False: 25.4k]
  |  Branch (2317:24): [True: 576, False: 424k]
  ------------------
 2318|    576|           (in->demux_ts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  1.15k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2318:13): [True: 0, False: 576]
  ------------------
 2319|    576|            in->demux_ts <= ds->force_read_until);
  ------------------
  |  Branch (2319:13): [True: 465, False: 111]
  ------------------
 2320|   450k|}
demux.c:read_packet_from_cache:
 2796|   757k|{
 2797|   757k|    if (!pkt)
  ------------------
  |  Branch (2797:9): [True: 0, False: 757k]
  ------------------
 2798|      0|        return NULL;
 2799|       |
 2800|   757k|    if (pkt->is_cached) {
  ------------------
  |  Branch (2800:9): [True: 0, False: 757k]
  ------------------
 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|   757k|    } else {
 2810|       |        // The returned packet is mutated etc. and will be owned by the user.
 2811|   757k|        pkt = demux_copy_packet(in->packet_pool, pkt);
 2812|   757k|    }
 2813|       |
 2814|   757k|    return pkt;
 2815|   757k|}
demux.c:thread_work:
 2708|  1.03M|{
 2709|  1.03M|    struct demux_opts *opts = in->d_user->opts;
 2710|  1.03M|    size_t old_max_bytes = opts->max_bytes;
 2711|  1.03M|    size_t old_max_bytes_bw = opts->max_bytes_bw;
 2712|  1.03M|    if (m_config_cache_update(in->d_user->opts_cache)) {
  ------------------
  |  Branch (2712:9): [True: 0, False: 1.03M]
  ------------------
 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.03M|    if (in->tracks_switched) {
  ------------------
  |  Branch (2717:9): [True: 26.6k, False: 1.00M]
  ------------------
 2718|  26.6k|        execute_trackswitch(in);
 2719|  26.6k|        return true;
 2720|  26.6k|    }
 2721|  1.00M|    if (in->nav_refresh) {
  ------------------
  |  Branch (2721:9): [True: 0, False: 1.00M]
  ------------------
 2722|      0|        execute_nav_refresh(in);
 2723|      0|        return true;
 2724|      0|    }
 2725|  1.00M|    if (in->need_back_seek) {
  ------------------
  |  Branch (2725:9): [True: 0, False: 1.00M]
  ------------------
 2726|      0|        perform_backward_seek(in);
 2727|      0|        return true;
 2728|      0|    }
 2729|  1.00M|    if (in->back_any_need_recheck) {
  ------------------
  |  Branch (2729:9): [True: 0, False: 1.00M]
  ------------------
 2730|      0|        check_backward_seek(in);
 2731|      0|        return true;
 2732|      0|    }
 2733|  1.00M|    if (in->seeking) {
  ------------------
  |  Branch (2733:9): [True: 3.20k, False: 1.00M]
  ------------------
 2734|  3.20k|        execute_seek(in);
 2735|  3.20k|        return true;
 2736|  3.20k|    }
 2737|  1.00M|    if (read_packet(in))
  ------------------
  |  Branch (2737:9): [True: 790k, False: 211k]
  ------------------
 2738|   790k|        return true; // read_packet unlocked, so recheck conditions
 2739|   211k|    if (mp_time_ns() >= in->next_cache_update) {
  ------------------
  |  Branch (2739:9): [True: 3, False: 211k]
  ------------------
 2740|      3|        update_cache(in);
 2741|      3|        return true;
 2742|      3|    }
 2743|   211k|    return false;
 2744|   211k|}
demux.c:update_opts:
 2638|  24.5k|{
 2639|  24.5k|    struct demux_opts *opts = demuxer->opts;
 2640|  24.5k|    struct demux_internal *in = demuxer->in;
 2641|       |
 2642|  24.5k|    in->min_secs = opts->min_secs;
 2643|  24.5k|    in->hyst_secs = opts->hyst_secs;
 2644|  24.5k|    in->hyst_bytes = opts->hyst_bytes;
 2645|  24.5k|    in->max_bytes = opts->max_bytes;
 2646|  24.5k|    in->max_bytes_bw = opts->max_bytes_bw;
 2647|       |
 2648|  24.5k|    int seekable = opts->seekable_cache;
 2649|  24.5k|    bool is_streaming = in->d_thread->is_streaming;
 2650|  24.5k|    bool use_cache = is_streaming;
 2651|  24.5k|    if (opts->enable_cache >= 0)
  ------------------
  |  Branch (2651:9): [True: 0, False: 24.5k]
  ------------------
 2652|      0|        use_cache = opts->enable_cache == 1;
 2653|       |
 2654|  24.5k|    if (use_cache) {
  ------------------
  |  Branch (2654:9): [True: 0, False: 24.5k]
  ------------------
 2655|      0|        in->min_secs = MPMAX(in->min_secs, opts->min_secs_cache);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2656|      0|        if (seekable < 0)
  ------------------
  |  Branch (2656:13): [True: 0, False: 0]
  ------------------
 2657|      0|            seekable = 1;
 2658|      0|    }
 2659|  24.5k|    in->seekable_cache = seekable == 1;
 2660|  24.5k|    if (in->d_thread->no_cache_seeking)
  ------------------
  |  Branch (2660:9): [True: 0, False: 24.5k]
  ------------------
 2661|      0|        in->seekable_cache = false;
 2662|  24.5k|    in->using_network_cache_opts = is_streaming && use_cache;
  ------------------
  |  Branch (2662:36): [True: 0, False: 24.5k]
  |  Branch (2662:52): [True: 0, False: 0]
  ------------------
 2663|       |
 2664|  24.5k|    if (!in->seekable_cache)
  ------------------
  |  Branch (2664:9): [True: 24.5k, False: 0]
  ------------------
 2665|  24.5k|        in->max_bytes_bw = 0;
 2666|       |
 2667|  24.5k|    if (!in->can_cache) {
  ------------------
  |  Branch (2667:9): [True: 286, False: 24.2k]
  ------------------
 2668|    286|        in->seekable_cache = false;
 2669|    286|        in->min_secs = 0;
 2670|    286|        in->max_bytes = 1;
 2671|    286|        in->max_bytes_bw = 0;
 2672|    286|        in->using_network_cache_opts = false;
 2673|    286|    }
 2674|       |
 2675|  24.5k|    if (in->seekable_cache && opts->disk_cache && !in->cache) {
  ------------------
  |  Branch (2675:9): [True: 0, False: 24.5k]
  |  Branch (2675:31): [True: 0, False: 0]
  |  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.5k|    char *old = in->record_filename ? in->record_filename : "";
  ------------------
  |  Branch (2683:17): [True: 0, False: 24.5k]
  ------------------
 2684|  24.5k|    char *new = opts->record_file ? opts->record_file : "";
  ------------------
  |  Branch (2684:17): [True: 0, False: 24.5k]
  ------------------
 2685|  24.5k|    if (strcmp(old, new) != 0) {
  ------------------
  |  Branch (2685:9): [True: 0, False: 24.5k]
  ------------------
 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.5k|    prune_old_packets(in);
 2701|       |
 2702|       |    // In case the seekable cache was disabled.
 2703|  24.5k|    free_empty_cached_ranges(in);
 2704|  24.5k|}
demux.c:execute_seek:
 2604|  3.59k|{
 2605|  3.59k|    int flags = in->seek_flags;
 2606|  3.59k|    double pts = in->seek_pts;
 2607|  3.59k|    in->eof = false;
 2608|  3.59k|    in->seeking = false;
 2609|  3.59k|    in->seeking_in_progress = pts;
 2610|  3.59k|    in->demux_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  3.59k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2611|  3.59k|    in->low_level_seeks += 1;
 2612|  3.59k|    in->after_seek = true;
 2613|  3.59k|    in->after_seek_to_start =
 2614|  3.59k|        !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   95|  3.59k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
                      !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   94|  3.59k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (2614:9): [True: 3.59k, False: 0]
  ------------------
 2615|  3.59k|        pts <= in->d_thread->start_time;
  ------------------
  |  Branch (2615:9): [True: 3.44k, False: 146]
  ------------------
 2616|       |
 2617|  8.84k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2617:21): [True: 5.25k, False: 3.59k]
  ------------------
 2618|  5.25k|        in->streams[n]->ds->queue->last_pos_fixup = -1;
 2619|       |
 2620|  3.59k|    if (in->recorder)
  ------------------
  |  Branch (2620:9): [True: 0, False: 3.59k]
  ------------------
 2621|      0|        mp_recorder_mark_discontinuity(in->recorder);
 2622|       |
 2623|  3.59k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  3.59k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2624|       |
 2625|  3.59k|    MP_VERBOSE(in, "execute seek (to %f flags %d)\n", pts, flags);
  ------------------
  |  |   92|  3.59k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.59k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2626|       |
 2627|  3.59k|    if (in->d_thread->desc->seek)
  ------------------
  |  Branch (2627:9): [True: 3.59k, False: 0]
  ------------------
 2628|  3.59k|        in->d_thread->desc->seek(in->d_thread, pts, flags);
 2629|       |
 2630|  3.59k|    MP_VERBOSE(in, "seek done\n");
  ------------------
  |  |   92|  3.59k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.59k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2631|       |
 2632|  3.59k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  3.59k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2633|       |
 2634|  3.59k|    in->seeking_in_progress = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  3.59k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2635|  3.59k|}
demux.c:read_packet:
 2324|  1.00M|{
 2325|  1.00M|    bool was_reading = in->reading;
 2326|  1.00M|    in->reading = false;
 2327|       |
 2328|  1.00M|    if (!was_reading || in->blocked || demux_cancel_test(in->d_thread))
  ------------------
  |  Branch (2328:9): [True: 73.4k, False: 928k]
  |  Branch (2328:25): [True: 0, False: 928k]
  |  Branch (2328:40): [True: 0, False: 928k]
  ------------------
 2329|  73.4k|        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.00M|    bool read_more = false, prefetch_more = false, refresh_more = false;
 2335|   928k|    uint64_t total_fw_bytes = 0;
 2336|  2.66M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2336:21): [True: 1.73M, False: 928k]
  ------------------
 2337|  1.73M|        total_fw_bytes += get_forward_buffered_bytes(in->streams[n]->ds);
 2338|   928k|    if (in->hyst_bytes > 0 && total_fw_bytes <= in->hyst_bytes)
  ------------------
  |  Branch (2338:9): [True: 0, False: 928k]
  |  Branch (2338:31): [True: 0, False: 0]
  ------------------
 2339|      0|        in->hyst_active = false;
 2340|  2.66M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2340:21): [True: 1.73M, False: 928k]
  ------------------
 2341|  1.73M|        struct demux_stream *ds = in->streams[n]->ds;
 2342|  1.73M|        if (ds->eager) {
  ------------------
  |  Branch (2342:13): [True: 1.31M, False: 418k]
  ------------------
 2343|  1.31M|            read_more |= !ds->reader_head;
 2344|  1.31M|            if (in->back_demuxing)
  ------------------
  |  Branch (2344:17): [True: 0, False: 1.31M]
  ------------------
 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.31M|        } else {
 2347|   418k|            if (lazy_stream_needs_wait(ds)) {
  ------------------
  |  Branch (2347:17): [True: 449, False: 418k]
  ------------------
 2348|    449|                read_more = true;
 2349|   418k|            } else {
 2350|   418k|                mark_stream_eof(ds); // let playback continue
 2351|   418k|            }
 2352|   418k|        }
 2353|  1.73M|        refresh_more |= ds->refreshing;
 2354|  1.73M|        if (ds->eager && ds->queue->last_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  3.05M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2354:13): [True: 1.31M, False: 418k]
  |  Branch (2354:26): [True: 1.19M, False: 123k]
  ------------------
 2355|  1.19M|            in->min_secs > 0 && ds->base_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  2.92M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2355:13): [True: 1.18M, False: 13.1k]
  |  Branch (2355:33): [True: 1.18M, False: 0]
  ------------------
 2356|  1.18M|            ds->queue->last_ts >= ds->base_ts &&
  ------------------
  |  Branch (2356:13): [True: 1.15M, False: 23.6k]
  ------------------
 2357|  1.15M|            !in->back_demuxing)
  ------------------
  |  Branch (2357:13): [True: 1.15M, False: 0]
  ------------------
 2358|  1.15M|        {
 2359|  1.15M|            if (ds->queue->last_ts - ds->base_ts <= in->hyst_secs)
  ------------------
  |  Branch (2359:17): [True: 354k, False: 805k]
  ------------------
 2360|   354k|                in->hyst_active = false;
 2361|  1.15M|            if (!in->hyst_active)
  ------------------
  |  Branch (2361:17): [True: 1.15M, False: 0]
  ------------------
 2362|  1.15M|                prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
 2363|  1.15M|        }
 2364|  1.73M|    }
 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|   928k|    if (in->nav_active)
  ------------------
  |  Branch (2369:9): [True: 0, False: 928k]
  ------------------
 2370|      0|        prefetch_more = false;
 2371|   928k|    prefetch_more |= in->nav_pump;
 2372|       |
 2373|   928k|    MP_TRACE(in, "bytes=%zd, read_more=%d prefetch_more=%d, refresh_more=%d\n",
  ------------------
  |  |   94|   928k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   928k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2374|   928k|             (size_t)total_fw_bytes, read_more, prefetch_more, refresh_more);
 2375|   928k|    if (total_fw_bytes >= in->max_bytes) {
  ------------------
  |  Branch (2375:9): [True: 0, False: 928k]
  ------------------
 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|   928k|    if (!read_more && !prefetch_more && !refresh_more) {
  ------------------
  |  Branch (2410:9): [True: 696k, False: 231k]
  |  Branch (2410:23): [True: 138k, False: 558k]
  |  Branch (2410:41): [True: 138k, False: 0]
  ------------------
 2411|   138k|        in->hyst_active = in->hyst_secs > 0 || in->hyst_bytes > 0;
  ------------------
  |  Branch (2411:27): [True: 0, False: 138k]
  |  Branch (2411:48): [True: 0, False: 138k]
  ------------------
 2412|   138k|        return false;
 2413|   138k|    }
 2414|       |
 2415|   790k|    if (in->after_seek_to_start) {
  ------------------
  |  Branch (2415:9): [True: 22.0k, False: 768k]
  ------------------
 2416|  64.5k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2416:25): [True: 42.4k, False: 22.0k]
  ------------------
 2417|  42.4k|            struct demux_stream *ds = in->streams[n]->ds;
 2418|  42.4k|            in->current_range->streams[n]->is_bof =
 2419|  42.4k|                ds->selected && !ds->refreshing;
  ------------------
  |  Branch (2419:17): [True: 35.3k, False: 7.16k]
  |  Branch (2419:33): [True: 34.8k, False: 441]
  ------------------
 2420|  42.4k|        }
 2421|  22.0k|    }
 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|   790k|    in->reading = true;
 2426|   790k|    in->nav_pump = false;
 2427|   790k|    in->after_seek = false;
 2428|   790k|    in->after_seek_to_start = false;
 2429|   790k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   790k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2430|       |
 2431|   790k|    struct demuxer *demux = in->d_thread;
 2432|   790k|    struct demux_packet *pkt = NULL;
 2433|       |
 2434|   790k|    bool eof = true;
 2435|   790k|    if (demux->desc->read_packet && !demux_read_interrupted(demux))
  ------------------
  |  Branch (2435:9): [True: 790k, False: 0]
  |  Branch (2435:37): [True: 790k, False: 0]
  ------------------
 2436|   790k|        eof = !demux->desc->read_packet(demux, &pkt);
 2437|       |
 2438|   790k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   790k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2439|   790k|    update_cache(in);
 2440|       |
 2441|   790k|    if (pkt) {
  ------------------
  |  Branch (2441:9): [True: 766k, False: 23.2k]
  ------------------
 2442|   766k|        mp_assert(pkt->stream >= 0 && pkt->stream < in->num_streams);
  ------------------
  |  |   41|   766k|#define mp_assert assert
  ------------------
  |  Branch (2442:9): [True: 766k, False: 0]
  |  Branch (2442:9): [True: 766k, False: 0]
  ------------------
 2443|   766k|        add_packet_locked(in->streams[pkt->stream], pkt);
 2444|   766k|    }
 2445|       |
 2446|   790k|    if (!in->seeking) {
  ------------------
  |  Branch (2446:9): [True: 790k, False: 0]
  ------------------
 2447|   790k|        if (eof) {
  ------------------
  |  Branch (2447:13): [True: 22.2k, False: 767k]
  ------------------
 2448|  65.1k|            for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2448:29): [True: 42.9k, False: 22.2k]
  ------------------
 2449|  42.9k|                mark_stream_eof(in->streams[n]->ds);
 2450|       |            // If we had EOF previously, then don't wakeup (avoids wakeup loop)
 2451|  22.2k|            if (!in->eof) {
  ------------------
  |  Branch (2451:17): [True: 22.2k, False: 0]
  ------------------
 2452|  22.2k|                if (in->wakeup_cb)
  ------------------
  |  Branch (2452:21): [True: 21.8k, False: 376]
  ------------------
 2453|  21.8k|                    in->wakeup_cb(in->wakeup_cb_ctx);
 2454|  22.2k|                mp_cond_signal(&in->wakeup);
 2455|  22.2k|                MP_VERBOSE(in, "EOF reached.\n");
  ------------------
  |  |   92|  22.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  22.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2456|  22.2k|            }
 2457|  22.2k|        }
 2458|   790k|        in->eof = eof;
 2459|   790k|        in->reading = !eof;
 2460|   790k|    }
 2461|       |    return true;
 2462|   790k|}
demux.c:mark_stream_eof:
 2302|   461k|{
 2303|   461k|    if (!ds->eof) {
  ------------------
  |  Branch (2303:9): [True: 46.8k, False: 414k]
  ------------------
 2304|  46.8k|        ds->eof = true;
 2305|       |        adjust_seek_range_on_packet(ds, NULL);
 2306|  46.8k|        back_demux_see_packets(ds);
 2307|  46.8k|        wakeup_ds(ds);
 2308|  46.8k|    }
 2309|   461k|}
demux.c:lookup_timed_metadata:
 3374|   598k|{
 3375|   598k|    struct demux_cached_range *r = in->current_range;
 3376|       |
 3377|   598k|    if (!r || !r->num_metadata || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3377:9): [True: 0, False: 598k]
  |  Branch (3377:15): [True: 598k, False: 0]
  |  Branch (3377:35): [True: 0, False: 0]
  ------------------
 3378|   598k|        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|   598k|}
demux.c:update_final_metadata:
 3331|  24.5k|{
 3332|  24.5k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|  24.5k|#define mp_assert assert
  ------------------
  |  Branch (3332:5): [True: 24.5k, False: 0]
  ------------------
 3333|  24.5k|    struct demux_internal *in = demuxer->in;
 3334|       |
 3335|  24.5k|    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.5k|    int astreams = 0;
 3341|  24.5k|    int astream_id = -1;
 3342|  24.5k|    int vstreams = 0;
 3343|  67.4k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3343:21): [True: 42.9k, False: 24.5k]
  ------------------
 3344|  42.9k|        struct sh_stream *sh = in->streams[n];
 3345|  42.9k|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3345:13): [True: 20.0k, False: 22.8k]
  |  Branch (3345:41): [True: 19.7k, False: 293]
  ------------------
 3346|  19.7k|            vstreams += 1;
 3347|  42.9k|        if (sh->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3347:13): [True: 17.5k, False: 25.3k]
  ------------------
 3348|  17.5k|            astreams += 1;
 3349|  17.5k|            astream_id = n;
 3350|  17.5k|        }
 3351|  42.9k|    }
 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.5k|    if (vstreams == 0 && astreams == 1 &&
  ------------------
  |  Branch (3356:9): [True: 4.95k, False: 19.5k]
  |  Branch (3356:26): [True: 2.84k, False: 2.11k]
  ------------------
 3357|  2.84k|        in->streams[astream_id] == in->metadata_stream)
  ------------------
  |  Branch (3357:9): [True: 2.79k, False: 41]
  ------------------
 3358|  2.79k|    {
 3359|  2.79k|        dyn_tags = in->metadata_stream->tags;
 3360|  2.79k|        if (tm && tm->from_stream)
  ------------------
  |  Branch (3360:13): [True: 0, False: 2.79k]
  |  Branch (3360:19): [True: 0, False: 0]
  ------------------
 3361|      0|            dyn_tags = tm->tags;
 3362|  2.79k|    }
 3363|       |
 3364|       |    // Global metadata updates.
 3365|  24.5k|    if (tm && !tm->from_stream)
  ------------------
  |  Branch (3365:9): [True: 0, False: 24.5k]
  |  Branch (3365:15): [True: 0, False: 0]
  ------------------
 3366|      0|        dyn_tags = tm->tags;
 3367|       |
 3368|  24.5k|    if (dyn_tags)
  ------------------
  |  Branch (3368:9): [True: 2.79k, False: 21.7k]
  ------------------
 3369|  2.79k|        mp_tags_merge(demuxer->metadata, dyn_tags);
 3370|  24.5k|}
demux.c:demux_update_replaygain:
 3167|  49.0k|{
 3168|  49.0k|    struct demux_internal *in = demuxer->in;
 3169|   135k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3169:21): [True: 86.0k, False: 49.0k]
  ------------------
 3170|  86.0k|        struct sh_stream *sh = in->streams[n];
 3171|  86.0k|        if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
  ------------------
  |  Branch (3171:13): [True: 35.2k, False: 50.8k]
  |  Branch (3171:41): [True: 35.2k, False: 0]
  ------------------
 3172|  35.2k|            struct replaygain_data *rg = decode_rgain(demuxer->log, sh->tags);
 3173|  35.2k|            if (!rg)
  ------------------
  |  Branch (3173:17): [True: 35.2k, False: 0]
  ------------------
 3174|  35.2k|                rg = decode_rgain(demuxer->log, demuxer->metadata);
 3175|  35.2k|            if (rg)
  ------------------
  |  Branch (3175:17): [True: 0, False: 35.2k]
  ------------------
 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|  35.2k|        }
 3178|  86.0k|    }
 3179|  49.0k|}
demux.c:decode_rgain:
 3117|  70.4k|{
 3118|  70.4k|    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|  70.4k|    if (decode_gain(log, tags, "REPLAYGAIN_TRACK_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3124:9): [True: 0, False: 70.4k]
  ------------------
 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|  70.4k|    if (decode_gain(log, tags, "REPLAYGAIN_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3137:9): [True: 0, False: 70.4k]
  ------------------
 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|  70.4k|    if (decode_gain(log, tags, "R128_TRACK_GAIN", &rg.track_gain) >= 0) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 70.4k]
  ------------------
 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|  70.4k|    return NULL;
 3164|  70.4k|}
demux.c:decode_gain:
 3079|   211k|{
 3080|   211k|    char *tag_val = NULL;
 3081|   211k|    float dec_val;
 3082|       |
 3083|   211k|    tag_val = mp_tags_get_str(tags, tag);
 3084|   211k|    if (!tag_val)
  ------------------
  |  Branch (3084:9): [True: 211k, False: 0]
  ------------------
 3085|   211k|        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|  24.7k|{
 3679|  24.7k|    const int *check_levels = d_normal;
 3680|  24.7k|    const struct demuxer_desc *check_desc = NULL;
 3681|  24.7k|    struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
 3682|  24.7k|    struct demuxer *demuxer = NULL;
 3683|  24.7k|    char *force_format = params->force_format;
 3684|       |
 3685|  24.7k|    struct parent_stream_info sinfo = {
 3686|  24.7k|        .seekable = stream->seekable,
 3687|  24.7k|        .is_network = stream->is_network,
 3688|  24.7k|        .is_streaming = stream->streaming,
 3689|  24.7k|        .stream_origin = stream->stream_origin,
 3690|  24.7k|        .cancel = cancel,
 3691|  24.7k|        .filename = talloc_strdup(NULL, stream->url),
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3692|  24.7k|        .server_filename = stream->server_filename,
 3693|  24.7k|    };
 3694|       |
 3695|  24.7k|    if (!force_format)
  ------------------
  |  Branch (3695:9): [True: 0, False: 24.7k]
  ------------------
 3696|      0|        force_format = stream->demuxer;
 3697|       |
 3698|  24.7k|    if (force_format && force_format[0] && !stream->is_directory) {
  ------------------
  |  Branch (3698:9): [True: 24.7k, False: 0]
  |  Branch (3698:25): [True: 24.7k, False: 0]
  |  Branch (3698:44): [True: 24.7k, False: 0]
  ------------------
 3699|  24.7k|        check_levels = d_request;
 3700|  24.7k|        if (force_format[0] == '+') {
  ------------------
  |  Branch (3700:13): [True: 0, False: 24.7k]
  ------------------
 3701|      0|            force_format += 1;
 3702|      0|            check_levels = d_force;
 3703|      0|        }
 3704|   173k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3704:25): [True: 173k, False: 0]
  ------------------
 3705|   173k|            if (strcmp(demuxer_list[n]->name, force_format) == 0) {
  ------------------
  |  Branch (3705:17): [True: 24.7k, False: 148k]
  ------------------
 3706|  24.7k|                check_desc = demuxer_list[n];
 3707|  24.7k|                break;
 3708|  24.7k|            }
 3709|   173k|        }
 3710|  24.7k|        if (!check_desc) {
  ------------------
  |  Branch (3710:13): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    }
 3715|       |
 3716|       |    // Test demuxers from first to last, one pass for each check_levels[] entry
 3717|  25.2k|    for (int pass = 0; check_levels[pass] != -1; pass++) {
  ------------------
  |  Branch (3717:24): [True: 24.7k, False: 496]
  ------------------
 3718|  24.7k|        enum demux_check level = check_levels[pass];
 3719|  24.7k|        mp_verbose(log, "Trying demuxers for level=%s.\n", d_level(level));
  ------------------
  |  |   79|  24.7k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3720|   176k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3720:25): [True: 175k, False: 496]
  ------------------
 3721|   175k|            const struct demuxer_desc *desc = demuxer_list[n];
 3722|   175k|            if (!check_desc || desc == check_desc) {
  ------------------
  |  Branch (3722:17): [True: 0, False: 175k]
  |  Branch (3722:32): [True: 24.7k, False: 150k]
  ------------------
 3723|  24.7k|                demuxer = open_given_type(global, log, desc, stream, &sinfo,
 3724|  24.7k|                                          params, level);
 3725|  24.7k|                if (demuxer) {
  ------------------
  |  Branch (3725:21): [True: 24.2k, False: 496]
  ------------------
 3726|  24.2k|                    talloc_steal(demuxer, log);
  ------------------
  |  |   38|  24.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3727|  24.2k|                    log = NULL;
 3728|  24.2k|                    goto done;
 3729|  24.2k|                }
 3730|  24.7k|            }
 3731|   175k|        }
 3732|  24.7k|    }
 3733|       |
 3734|  24.7k|done:
 3735|  24.7k|    talloc_free(sinfo.filename);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 3736|  24.7k|    talloc_free(log);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 3737|  24.7k|    return demuxer;
 3738|  24.7k|}
demux.c:d_level:
 3054|  49.7k|{
 3055|  49.7k|    switch (level) {
  ------------------
  |  Branch (3055:13): [True: 49.7k, False: 0]
  ------------------
 3056|    286|    case DEMUX_CHECK_FORCE:  return "force";
  ------------------
  |  Branch (3056:5): [True: 286, False: 49.5k]
  ------------------
 3057|      0|    case DEMUX_CHECK_UNSAFE: return "unsafe";
  ------------------
  |  Branch (3057:5): [True: 0, False: 49.7k]
  ------------------
 3058|  49.5k|    case DEMUX_CHECK_REQUEST:return "request";
  ------------------
  |  Branch (3058:5): [True: 49.5k, False: 286]
  ------------------
 3059|      0|    case DEMUX_CHECK_NORMAL: return "normal";
  ------------------
  |  Branch (3059:5): [True: 0, False: 49.7k]
  ------------------
 3060|  49.7k|    }
 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|  25.0k|{
 3542|  25.0k|    if (mp_cancel_test(sinfo->cancel))
  ------------------
  |  Branch (3542:9): [True: 0, False: 25.0k]
  ------------------
 3543|      0|        return NULL;
 3544|       |
 3545|  25.0k|    if (params->depth > 10) {
  ------------------
  |  Branch (3545:9): [True: 0, False: 25.0k]
  ------------------
 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|  25.0k|    mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
  ------------------
  |  |   80|  25.0k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
 3551|  25.0k|           desc->name, d_level(check));
 3552|       |
 3553|  25.0k|    if (stream && !stream_seek(stream, 0)) {
  ------------------
  |  Branch (3553:9): [True: 24.7k, False: 286]
  |  Branch (3553:19): [True: 0, False: 24.7k]
  ------------------
 3554|      0|        mp_err(log, "Failed to rewind stream to the start.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3555|      0|        return NULL;
 3556|      0|    }
 3557|       |
 3558|  25.0k|    struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
  ------------------
  |  |   34|  25.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  25.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  25.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3559|  25.0k|    struct m_config_cache *opts_cache =
 3560|  25.0k|        m_config_cache_alloc(demuxer, global, &demux_conf);
 3561|  25.0k|    struct demux_opts *opts = opts_cache->opts;
 3562|  25.0k|    *demuxer = (struct demuxer) {
 3563|  25.0k|        .desc = desc,
 3564|  25.0k|        .stream = stream,
 3565|  25.0k|        .cancel = sinfo->cancel,
 3566|  25.0k|        .seekable = sinfo->seekable,
 3567|  25.0k|        .filepos = -1,
 3568|  25.0k|        .global = global,
 3569|  25.0k|        .log = mp_log_new(demuxer, log, desc->name),
 3570|  25.0k|        .packet_pool = demux_packet_pool_get(global),
 3571|  25.0k|        .glog = log,
 3572|  25.0k|        .filename = talloc_strdup(demuxer, sinfo->filename),
  ------------------
  |  |   50|  25.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3573|  25.0k|        .server_filename = talloc_strdup(demuxer, sinfo->server_filename),
  ------------------
  |  |   50|  25.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3574|  25.0k|        .is_network = sinfo->is_network,
 3575|  25.0k|        .is_streaming = sinfo->is_streaming,
 3576|  25.0k|        .stream_origin = sinfo->stream_origin,
 3577|  25.0k|        .access_references = opts->access_references,
 3578|  25.0k|        .opts = opts,
 3579|  25.0k|        .opts_cache = opts_cache,
 3580|  25.0k|        .events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS,
 3581|  25.0k|        .duration = -1,
 3582|  25.0k|        .depth = params->depth,
 3583|  25.0k|    };
 3584|       |
 3585|  25.0k|    struct demux_internal *in = demuxer->in = talloc_ptrtype(demuxer, in);
  ------------------
  |  |   34|  25.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  25.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  25.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3586|  25.0k|    *in = (struct demux_internal){
 3587|  25.0k|        .global = global,
 3588|  25.0k|        .log = demuxer->log,
 3589|  25.0k|        .packet_pool = demux_packet_pool_get(global),
 3590|  25.0k|        .stats = stats_ctx_create(in, global, "demuxer"),
 3591|  25.0k|        .can_cache = params->is_top_level,
 3592|  25.0k|        .can_record = params->stream_record,
 3593|  25.0k|        .d_thread = talloc(demuxer, struct demuxer),
  ------------------
  |  |   26|  25.0k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  25.0k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  25.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3594|  25.0k|        .d_user = demuxer,
 3595|  25.0k|        .after_seek = true, // (assumed identical to initial demuxer state)
 3596|  25.0k|        .after_seek_to_start = true,
 3597|  25.0k|        .highest_av_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  25.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3598|  25.0k|        .seeking_in_progress = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  25.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3599|  25.0k|        .demux_ts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  25.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3600|  25.0k|        .owns_stream = !params->external_stream,
 3601|  25.0k|    };
 3602|  25.0k|    mp_mutex_init(&in->lock);
 3603|  25.0k|    mp_cond_init(&in->wakeup);
 3604|       |
 3605|  25.0k|    *in->d_thread = *demuxer;
 3606|       |
 3607|  25.0k|    in->d_thread->metadata = talloc_zero(in->d_thread, struct mp_tags);
  ------------------
  |  |   27|  25.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  25.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  25.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3608|       |
 3609|  25.0k|    in->d_thread->params = params; // temporary during open()
 3610|  25.0k|    int ret = demuxer->desc->open(in->d_thread, check);
 3611|  25.0k|    if (ret >= 0) {
  ------------------
  |  Branch (3611:9): [True: 24.5k, False: 496]
  ------------------
 3612|  24.5k|        in->d_thread->params = NULL;
 3613|  24.5k|        if (in->d_thread->filetype)
  ------------------
  |  Branch (3613:13): [True: 286, False: 24.2k]
  ------------------
 3614|    286|            mp_verbose(log, "Detected file format: %s (%s)\n",
  ------------------
  |  |   79|    286|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3615|  24.5k|                       in->d_thread->filetype, desc->desc);
 3616|  24.2k|        else
 3617|  24.2k|            mp_verbose(log, "Detected file format: %s\n", desc->desc);
  ------------------
  |  |   79|  24.2k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3618|  24.5k|        if (!in->d_thread->seekable)
  ------------------
  |  Branch (3618:13): [True: 0, False: 24.5k]
  ------------------
 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.5k|        if (!in->d_thread->seekable && opts->force_seekable) {
  ------------------
  |  Branch (3620:13): [True: 0, False: 24.5k]
  |  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.5k|        demux_init_cuesheet(in->d_thread);
 3626|  24.5k|        demux_init_ccs(demuxer, opts);
 3627|  24.5k|        demux_convert_tags_charset(in->d_thread);
 3628|  24.5k|        demux_copy(in->d_user, in->d_thread);
 3629|  24.5k|        in->duration = in->d_thread->duration;
 3630|  24.5k|        demuxer_sort_chapters(demuxer);
 3631|  24.5k|        in->events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS;
 3632|       |
 3633|  24.5k|        struct demuxer *sub = NULL;
 3634|  24.5k|        if (!params->disable_timeline) {
  ------------------
  |  Branch (3634:13): [True: 24.5k, False: 0]
  ------------------
 3635|  24.5k|            struct timeline *tl = timeline_load(global, log, demuxer);
 3636|  24.5k|            if (tl) {
  ------------------
  |  Branch (3636:17): [True: 286, False: 24.2k]
  ------------------
 3637|    286|                struct demuxer_params params2 = {0};
 3638|    286|                params2.timeline = tl;
 3639|    286|                params2.is_top_level = params->is_top_level;
 3640|    286|                params2.stream_record = params->stream_record;
 3641|    286|                params2.depth = params->depth + 1;
 3642|    286|                sub =
 3643|    286|                    open_given_type(global, log, &demuxer_desc_timeline,
 3644|    286|                                    NULL, sinfo, &params2, DEMUX_CHECK_FORCE);
 3645|    286|                if (sub) {
  ------------------
  |  Branch (3645:21): [True: 286, False: 0]
  ------------------
 3646|    286|                    in->can_cache = false;
 3647|    286|                    in->can_record = false;
 3648|    286|                } else {
 3649|      0|                    timeline_destroy(tl);
 3650|      0|                }
 3651|    286|            }
 3652|  24.5k|        }
 3653|       |
 3654|  24.5k|        switch_to_fresh_cache_range(in);
 3655|       |
 3656|  24.5k|        update_opts(demuxer);
 3657|       |
 3658|  24.5k|        demux_update(demuxer, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  24.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3659|       |
 3660|  24.5k|        demuxer = sub ? sub : demuxer;
  ------------------
  |  Branch (3660:19): [True: 286, False: 24.2k]
  ------------------
 3661|  24.5k|        return demuxer;
 3662|  24.5k|    }
 3663|       |
 3664|    496|    demuxer->stream = NULL;
 3665|    496|    demux_free(demuxer);
 3666|       |    return NULL;
 3667|  25.0k|}
demux.c:demux_init_cuesheet:
 3450|  24.5k|{
 3451|  24.5k|    if (demuxer->num_chapters)
  ------------------
  |  Branch (3451:9): [True: 1.24k, False: 23.3k]
  ------------------
 3452|  1.24k|        return;
 3453|       |
 3454|  23.3k|    struct sh_stream *sh = demuxer->in->metadata_stream;
 3455|  23.3k|    char *cue = mp_tags_get_str(demuxer->metadata, "cuesheet");
 3456|  23.3k|    if (!cue && sh)
  ------------------
  |  Branch (3456:9): [True: 23.3k, False: 0]
  |  Branch (3456:17): [True: 21.4k, False: 1.88k]
  ------------------
 3457|  21.4k|        cue = mp_tags_get_str(sh->tags, "cuesheet");
 3458|  23.3k|    if (!cue)
  ------------------
  |  Branch (3458:9): [True: 23.3k, False: 0]
  ------------------
 3459|  23.3k|        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.5k|{
 3499|  24.5k|    struct demux_internal *in = demuxer->in;
 3500|  24.5k|    if (!opts->create_ccs)
  ------------------
  |  Branch (3500:9): [True: 24.5k, False: 0]
  ------------------
 3501|  24.5k|        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.5k|{
 5042|  24.5k|    struct demux_internal *in = demuxer->in;
 5043|       |
 5044|  24.5k|    char *cp = demuxer->opts->meta_cp;
 5045|  24.5k|    if (!cp || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (5045:9): [True: 0, False: 24.5k]
  |  Branch (5045:16): [True: 0, False: 24.5k]
  ------------------
 5046|      0|        return;
 5047|       |
 5048|  24.5k|    char *data = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  24.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 5049|  24.5k|    visit_meta(demuxer, &data, visit_detect);
 5050|       |
 5051|  24.5k|    in->meta_charset = (char *)mp_charset_guess(in, in->log, bstr0(data), cp, 0);
 5052|  24.5k|    if (in->meta_charset && !mp_charset_is_utf8(in->meta_charset)) {
  ------------------
  |  Branch (5052:9): [True: 24.5k, False: 0]
  |  Branch (5052:29): [True: 3.31k, False: 21.2k]
  ------------------
 5053|  3.31k|        MP_INFO(demuxer, "Using tag charset: %s\n", in->meta_charset);
  ------------------
  |  |   91|  3.31k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.31k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 5054|  3.31k|        visit_meta(demuxer, demuxer, visit_convert);
 5055|  3.31k|    }
 5056|       |
 5057|  24.5k|    talloc_free(data);
  ------------------
  |  |   47|  24.5k|#define talloc_free                     ta_free
  ------------------
 5058|  24.5k|}
demux.c:visit_meta:
 4995|  27.8k|{
 4996|  27.8k|    struct demux_internal *in = demuxer->in;
 4997|       |
 4998|  75.8k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4998:21): [True: 48.0k, False: 27.8k]
  ------------------
 4999|  48.0k|        struct sh_stream *sh = in->streams[n];
 5000|       |
 5001|  48.0k|        visit(ctx, sh, &sh->title);
 5002|  48.0k|        visit_tags(ctx, visit, sh->tags);
 5003|  48.0k|    }
 5004|       |
 5005|  33.2k|    for (int n = 0; n < demuxer->num_chapters; n++)
  ------------------
  |  Branch (5005:21): [True: 5.42k, False: 27.8k]
  ------------------
 5006|  5.42k|        visit_tags(ctx, visit, demuxer->chapters[n].metadata);
 5007|       |
 5008|  27.8k|    visit_tags(ctx, visit, demuxer->metadata);
 5009|  27.8k|}
demux.c:visit_tags:
 4988|  81.2k|{
 4989|   103k|    for (int n = 0; n < (tags ? tags->num_keys : 0); n++)
  ------------------
  |  Branch (4989:21): [True: 22.5k, False: 81.2k]
  |  Branch (4989:26): [True: 103k, False: 0]
  ------------------
 4990|  22.5k|        visit(ctx, tags, &tags->values[n]);
 4991|  81.2k|}
demux.c:visit_detect:
 5013|  59.9k|{
 5014|  59.9k|    char **all = ctx;
 5015|       |
 5016|  59.9k|    if (*s)
  ------------------
  |  Branch (5016:9): [True: 29.9k, False: 30.0k]
  ------------------
 5017|  29.9k|        *all = talloc_asprintf_append_buffer(*all, "%s\n", *s);
  ------------------
  |  |   64|  29.9k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
 5018|  59.9k|}
demux.c:visit_convert:
 5021|  10.5k|{
 5022|  10.5k|    struct demuxer *demuxer = ctx;
 5023|  10.5k|    struct demux_internal *in = demuxer->in;
 5024|       |
 5025|  10.5k|    if (!*s)
  ------------------
  |  Branch (5025:9): [True: 1.29k, False: 9.29k]
  ------------------
 5026|  1.29k|        return;
 5027|       |
 5028|  9.29k|    bstr data = bstr0(*s);
 5029|  9.29k|    bstr conv = mp_iconv_to_utf8(in->log, data, in->meta_charset,
 5030|  9.29k|                                 MP_ICONV_VERBOSE);
 5031|  9.29k|    if (conv.start && conv.start != data.start) {
  ------------------
  |  Branch (5031:9): [True: 9.29k, False: 0]
  |  Branch (5031:23): [True: 9.06k, False: 235]
  ------------------
 5032|  9.06k|        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|  9.06k|        *s = ns;
 5036|  9.06k|        talloc_steal(ta, *s);
  ------------------
  |  |   38|  9.06k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  9.06k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5037|  9.06k|    }
 5038|  9.29k|}
demux.c:demux_copy:
 3183|  24.5k|{
 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.5k|    dst->chapters = src->chapters;
 3188|  24.5k|    dst->num_chapters = src->num_chapters;
 3189|  24.5k|    dst->editions = src->editions;
 3190|  24.5k|    dst->num_editions = src->num_editions;
 3191|  24.5k|    dst->edition = src->edition;
 3192|  24.5k|    dst->edition_is_track_mapping = src->edition_is_track_mapping;
 3193|  24.5k|    dst->attachments = src->attachments;
 3194|  24.5k|    dst->num_attachments = src->num_attachments;
 3195|  24.5k|    dst->matroska_data = src->matroska_data;
 3196|  24.5k|    dst->playlist = src->playlist;
 3197|  24.5k|    dst->seekable = src->seekable;
 3198|  24.5k|    dst->partially_seekable = src->partially_seekable;
 3199|  24.5k|    dst->filetype = src->filetype;
 3200|  24.5k|    dst->ts_resets_possible = src->ts_resets_possible;
 3201|  24.5k|    dst->fully_read = src->fully_read;
 3202|  24.5k|    dst->start_time = src->start_time;
 3203|  24.5k|    dst->duration = src->duration;
 3204|  24.5k|    dst->is_network = src->is_network;
 3205|  24.5k|    dst->is_streaming = src->is_streaming;
 3206|  24.5k|    dst->stream_origin = src->stream_origin;
 3207|  24.5k|    dst->priv = src->priv;
 3208|  24.5k|    dst->metadata = mp_tags_dup(dst, src->metadata);
 3209|  24.5k|}
demux.c:demuxer_sort_chapters:
 4465|  24.5k|{
 4466|  24.5k|    if (demuxer->num_chapters) {
  ------------------
  |  Branch (4466:9): [True: 1.24k, False: 23.3k]
  ------------------
 4467|  1.24k|        qsort(demuxer->chapters, demuxer->num_chapters,
 4468|  1.24k|            sizeof(struct demux_chapter), chapter_compare);
 4469|  1.24k|    }
 4470|  24.5k|}
demux.c:chapter_compare:
 4453|  5.04k|{
 4454|  5.04k|    struct demux_chapter *c1 = (void *)p1;
 4455|  5.04k|    struct demux_chapter *c2 = (void *)p2;
 4456|       |
 4457|  5.04k|    if (c1->pts > c2->pts)
  ------------------
  |  Branch (4457:9): [True: 61, False: 4.98k]
  ------------------
 4458|     61|        return 1;
 4459|  4.98k|    else if (c1->pts < c2->pts)
  ------------------
  |  Branch (4459:14): [True: 4.69k, False: 281]
  ------------------
 4460|  4.69k|        return -1;
 4461|    281|    return c1->original_index > c2->original_index ? 1 :-1; // never equal
  ------------------
  |  Branch (4461:12): [True: 0, False: 281]
  ------------------
 4462|  5.04k|}
demux.c:switch_to_fresh_cache_range:
 4058|  24.9k|{
 4059|  24.9k|    if (!in->seekable_cache && in->current_range) {
  ------------------
  |  Branch (4059:9): [True: 24.9k, False: 0]
  |  Branch (4059:32): [True: 384, False: 24.5k]
  ------------------
 4060|    384|        clear_cached_range(in, in->current_range);
 4061|    384|        return;
 4062|    384|    }
 4063|       |
 4064|  24.5k|    struct demux_cached_range *range = talloc_ptrtype(NULL, range);
  ------------------
  |  |   34|  24.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4065|  24.5k|    *range = (struct demux_cached_range){
 4066|  24.5k|        .seek_start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4067|  24.5k|        .seek_end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4068|  24.5k|    };
 4069|  24.5k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  24.5k|    do {                                            \
  |  |  106|  24.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.5k|    do {                                            \
  |  |  |  |   97|  24.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.5k|    do {                                                        \
  |  |  |  |  |  |   89|  24.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.5k|        (idxvar)++;                                 \
  |  |  109|  24.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.5k]
  |  |  ------------------
  ------------------
 4070|  24.5k|    add_missing_streams(in, range);
 4071|       |
 4072|  24.5k|    switch_current_range(in, range);
 4073|  24.5k|}
demux.c:switch_current_range:
 3822|  24.5k|{
 3823|  24.5k|    struct demux_cached_range *old = in->current_range;
 3824|  24.5k|    mp_assert(old != range);
  ------------------
  |  |   41|  24.5k|#define mp_assert assert
  ------------------
  |  Branch (3824:5): [True: 24.5k, False: 0]
  ------------------
 3825|       |
 3826|  24.5k|    set_current_range(in, range);
 3827|       |
 3828|  24.5k|    if (old) {
  ------------------
  |  Branch (3828:9): [True: 0, False: 24.5k]
  ------------------
 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|  67.4k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3853:21): [True: 42.9k, False: 24.5k]
  ------------------
 3854|  42.9k|        struct demux_stream *ds = in->streams[n]->ds;
 3855|       |
 3856|  42.9k|        ds->queue = range->streams[n];
 3857|  42.9k|        ds->refreshing = false;
 3858|  42.9k|        ds->eof = false;
 3859|  42.9k|    }
 3860|       |
 3861|       |    // No point in keeping any junk (especially if old current_range is empty).
 3862|  24.5k|    free_empty_cached_ranges(in);
 3863|       |
 3864|       |    // The change detection doesn't work across ranges.
 3865|       |    in->force_metadata_update = true;
 3866|  24.5k|}
demux.c:set_current_range:
  589|  24.5k|{
  590|  24.5k|    in->current_range = range;
  591|       |
  592|       |    // Move to in->ranges[in->num_ranges-1] (for LRU sorting/invariant)
  593|  24.5k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (593:21): [True: 24.5k, False: 0]
  ------------------
  594|  24.5k|        if (in->ranges[n] == range) {
  ------------------
  |  Branch (594:13): [True: 24.5k, False: 0]
  ------------------
  595|  24.5k|            MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  24.5k|    do {                                            \
  |  |  144|  24.5k|        size_t at_ = (at);                          \
  |  |  145|  24.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  24.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  24.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  24.5k|        (idxvar)--;                                 \
  |  |  149|  24.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 24.5k]
  |  |  ------------------
  ------------------
  |  Branch (595:13): [True: 24.5k, False: 0]
  ------------------
  596|  24.5k|            break;
  597|  24.5k|        }
  598|  24.5k|    }
  599|  24.5k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  24.5k|    do {                                            \
  |  |  106|  24.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.5k|    do {                                            \
  |  |  |  |   97|  24.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 24.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.5k|            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.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.5k|        (idxvar)++;                                 \
  |  |  109|  24.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.5k]
  |  |  ------------------
  ------------------
  600|  24.5k|}
demux.c:clear_reader_state:
  874|  25.4k|{
  875|  69.7k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (875:21): [True: 44.2k, False: 25.4k]
  ------------------
  876|  44.2k|        ds_clear_reader_state(in->streams[n]->ds, clear_back_state);
  877|  25.4k|    in->warned_queue_overflow = false;
  878|  25.4k|    in->d_user->filepos = -1; // implicitly synchronized
  879|  25.4k|    in->blocked = false;
  880|       |    in->need_back_seek = false;
  881|  25.4k|}
demux.c:clear_cached_range:
  784|  49.4k|{
  785|   136k|    for (int n = 0; n < range->num_streams; n++)
  ------------------
  |  Branch (785:21): [True: 87.4k, False: 49.4k]
  ------------------
  786|  87.4k|        clear_queue(range->streams[n]);
  787|       |
  788|  49.4k|    for (int n = 0; n < range->num_metadata; n++)
  ------------------
  |  Branch (788:21): [True: 0, False: 49.4k]
  ------------------
  789|      0|        talloc_free(range->metadata[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  790|  49.4k|    range->num_metadata = 0;
  791|       |
  792|  49.4k|    update_seek_ranges(range);
  793|  49.4k|}
demux.c:free_empty_cached_ranges:
  798|   186k|{
  799|   186k|    while (1) {
  ------------------
  |  Branch (799:12): [True: 186k, Folded]
  ------------------
  800|   186k|        struct demux_cached_range *worst = NULL;
  801|       |
  802|   186k|        int end = in->num_ranges - 1;
  803|       |
  804|       |        // (Not set during early init or late destruction.)
  805|   186k|        if (in->current_range) {
  ------------------
  |  Branch (805:13): [True: 117k, False: 68.4k]
  ------------------
  806|   117k|            mp_assert(in->current_range && in->num_ranges > 0);
  ------------------
  |  |   41|   117k|#define mp_assert assert
  ------------------
  |  Branch (806:13): [True: 117k, False: 0]
  |  Branch (806:13): [True: 117k, False: 0]
  ------------------
  807|   117k|            mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|   117k|#define mp_assert assert
  ------------------
  |  Branch (807:13): [True: 117k, False: 0]
  ------------------
  808|   117k|            end -= 1;
  809|   117k|        }
  810|       |
  811|   210k|        for (int n = end; n >= 0; n--) {
  ------------------
  |  Branch (811:27): [True: 24.5k, False: 186k]
  ------------------
  812|  24.5k|            struct demux_cached_range *range = in->ranges[n];
  813|  24.5k|            if (range->seek_start == MP_NOPTS_VALUE || !in->seekable_cache) {
  ------------------
  |  |   39|  49.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (813:17): [True: 24.5k, False: 0]
  |  Branch (813:56): [True: 0, False: 0]
  ------------------
  814|  24.5k|                clear_cached_range(in, range);
  815|  24.5k|                MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  24.5k|    do {                                            \
  |  |  144|  24.5k|        size_t at_ = (at);                          \
  |  |  145|  24.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  24.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  24.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  24.5k|        (idxvar)--;                                 \
  |  |  149|  24.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 24.5k]
  |  |  ------------------
  ------------------
  |  Branch (815:17): [True: 24.5k, False: 0]
  ------------------
  816|  67.7k|                for (int i = 0; i < range->num_streams; i++)
  ------------------
  |  Branch (816:33): [True: 43.1k, False: 24.5k]
  ------------------
  817|  43.1k|                    talloc_free(range->streams[i]);
  ------------------
  |  |   47|  43.1k|#define talloc_free                     ta_free
  ------------------
  818|  24.5k|                talloc_free(range);
  ------------------
  |  |   47|  24.5k|#define talloc_free                     ta_free
  ------------------
  819|  24.5k|            } 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.5k|        }
  825|       |
  826|   186k|        if (in->num_ranges <= MAX_SEEK_RANGES || !worst)
  ------------------
  |  |   33|   372k|#define MAX_SEEK_RANGES 10
  ------------------
  |  Branch (826:13): [True: 186k, False: 0]
  |  Branch (826:50): [True: 0, False: 0]
  ------------------
  827|   186k|            break;
  828|       |
  829|      0|        clear_cached_range(in, worst);
  830|      0|    }
  831|   186k|}
demux.c:queue_seek:
 4095|    384|{
 4096|    384|    if (seek_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    384|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4096:9): [True: 0, False: 384]
  ------------------
 4097|      0|        return false;
 4098|       |
 4099|    384|    MP_VERBOSE(in, "queuing seek to %f%s\n", seek_pts,
  ------------------
  |  |   92|    384|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    768|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 384]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4100|    384|               in->seeking ? " (cascade)" : "");
 4101|       |
 4102|    384|    bool require_cache = flags & SEEK_CACHED;
  ------------------
  |  |   97|    384|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4103|    384|    flags &= ~(unsigned)SEEK_CACHED;
  ------------------
  |  |   97|    384|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4104|       |
 4105|    384|    bool set_backwards = flags & SEEK_SATAN;
  ------------------
  |  |   98|    384|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4106|    384|    flags &= ~(unsigned)SEEK_SATAN;
  ------------------
  |  |   98|    384|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4107|       |
 4108|    384|    bool block = flags & SEEK_BLOCK;
  ------------------
  |  |  100|    384|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4109|    384|    flags &= ~(unsigned)SEEK_BLOCK;
  ------------------
  |  |  100|    384|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4110|       |
 4111|    384|    struct demux_cached_range *cache_target =
 4112|    384|        find_cache_seek_range(in, seek_pts, flags);
 4113|       |
 4114|    384|    if (!cache_target) {
  ------------------
  |  Branch (4114:9): [True: 384, False: 0]
  ------------------
 4115|    384|        if (require_cache) {
  ------------------
  |  Branch (4115:13): [True: 0, False: 384]
  ------------------
 4116|      0|            MP_VERBOSE(in, "Cached seek not possible.\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__)
  |  |  ------------------
  ------------------
 4117|      0|            return false;
 4118|      0|        }
 4119|    384|        if (!in->d_thread->seekable) {
  ------------------
  |  Branch (4119:13): [True: 0, False: 384]
  ------------------
 4120|      0|            MP_WARN(in, "Cannot seek in this 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__)
  |  |  ------------------
  ------------------
 4121|      0|            return false;
 4122|      0|        }
 4123|    384|    }
 4124|       |
 4125|    384|    in->eof = false;
 4126|    384|    in->reading = false;
 4127|    384|    in->back_demuxing = set_backwards;
 4128|       |
 4129|    384|    clear_reader_state(in, clear_back_state);
 4130|       |
 4131|    384|    in->blocked = block;
 4132|       |
 4133|    384|    if (cache_target) {
  ------------------
  |  Branch (4133:9): [True: 0, False: 384]
  ------------------
 4134|      0|        execute_cache_seek(in, cache_target, seek_pts, flags);
 4135|    384|    } else {
 4136|    384|        switch_to_fresh_cache_range(in);
 4137|       |
 4138|    384|        in->seeking = true;
 4139|    384|        in->seek_flags = flags;
 4140|    384|        in->seek_pts = seek_pts;
 4141|    384|    }
 4142|       |
 4143|  1.47k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4143:21): [True: 1.09k, False: 384]
  ------------------
 4144|  1.09k|        struct demux_stream *ds = in->streams[n]->ds;
 4145|       |
 4146|  1.09k|        if (in->back_demuxing) {
  ------------------
  |  Branch (4146:13): [True: 0, False: 1.09k]
  ------------------
 4147|      0|            if (ds->back_seek_pos == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4147:17): [True: 0, False: 0]
  ------------------
 4148|      0|                ds->back_seek_pos = seek_pts;
 4149|       |            // Process possibly cached packets.
 4150|      0|            back_demux_see_packets(in->streams[n]->ds);
 4151|      0|        }
 4152|       |
 4153|  1.09k|        wakeup_ds(ds);
 4154|  1.09k|    }
 4155|       |
 4156|    384|    if (!in->threading && in->seeking)
  ------------------
  |  Branch (4156:9): [True: 384, False: 0]
  |  Branch (4156:27): [True: 384, False: 0]
  ------------------
 4157|    384|        execute_seek(in);
 4158|       |
 4159|       |    return true;
 4160|    384|}
demux.c:select_track:
 4290|  52.3k|{
 4291|  52.3k|    struct demux_stream *ds = stream->ds;
 4292|  52.3k|    if (ds->selected == selected)
  ------------------
  |  Branch (4292:9): [True: 8.57k, False: 43.7k]
  ------------------
 4293|  8.57k|        return false;
 4294|  43.7k|    MP_VERBOSE(in, "%sselect track %d\n", selected ? "" : "de", stream->index);
  ------------------
  |  |   92|  43.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  87.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 39.4k, False: 4.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4295|  43.7k|    ds->selected = selected;
 4296|  43.7k|    update_stream_selection_state(in, ds);
 4297|  43.7k|    in->tracks_switched = true;
 4298|  43.7k|    if (ds->selected)
  ------------------
  |  Branch (4298:9): [True: 39.4k, False: 4.32k]
  ------------------
 4299|  39.4k|        refresh_track(in, stream, ref_pts);
 4300|       |    return true;
 4301|  52.3k|}
demux.c:select_dependent_tracks:
 4307|  52.3k|{
 4308|  52.3k|    bool changed = false;
 4309|  52.3k|    if (stream->group && !stream->dependent_track) {
  ------------------
  |  Branch (4309:9): [True: 0, False: 52.3k]
  |  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|  52.3k|    return changed;
 4318|  52.3k|}
demux.c:execute_trackswitch:
 2580|  27.0k|{
 2581|  27.0k|    in->tracks_switched = false;
 2582|       |
 2583|  27.0k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  27.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2584|       |
 2585|  27.0k|    if (in->d_thread->desc->switched_tracks)
  ------------------
  |  Branch (2585:9): [True: 304, False: 26.7k]
  ------------------
 2586|    304|        in->d_thread->desc->switched_tracks(in->d_thread);
 2587|       |
 2588|  27.0k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  27.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2589|  27.0k|}
demux.c:update_stream_selection_state:
  948|  86.9k|{
  949|  86.9k|    ds->eof = false;
  950|  86.9k|    ds->refreshing = false;
  951|       |
  952|  86.9k|    update_stream_eager_state(in);
  953|       |
  954|  86.9k|    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|   130k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (960:21): [True: 44.0k, False: 86.9k]
  ------------------
  961|  44.0k|        struct demux_cached_range *range = in->ranges[n];
  962|       |
  963|  44.0k|        if (!ds->selected)
  ------------------
  |  Branch (963:13): [True: 4.59k, False: 39.4k]
  ------------------
  964|  4.59k|            clear_queue(range->streams[ds->index]);
  965|       |
  966|  44.0k|        update_seek_ranges(range);
  967|  44.0k|    }
  968|       |
  969|  86.9k|    free_empty_cached_ranges(in);
  970|       |
  971|  86.9k|    wakeup_ds(ds);
  972|  86.9k|}
demux.c:refresh_track:
 4256|  39.4k|{
 4257|  39.4k|    struct demux_stream *ds = stream->ds;
 4258|  39.4k|    ref_pts = MP_ADD_PTS(ref_pts, -in->ts_offset);
  ------------------
  |  |   67|  39.4k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  39.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 463, False: 38.9k]
  |  |  ------------------
  ------------------
 4259|       |
 4260|  39.4k|    if (in->back_demuxing)
  ------------------
  |  Branch (4260:9): [True: 0, False: 39.4k]
  ------------------
 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|  39.4k|    bool avoid_refresh = false;
 4265|  59.7k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4265:21): [True: 56.5k, False: 3.13k]
  ------------------
 4266|  56.5k|        struct demux_stream *ds_n = in->streams[n]->ds;
 4267|  56.5k|        if (ds_n->type == STREAM_VIDEO && ds_n->selected) {
  ------------------
  |  Branch (4267:13): [True: 36.8k, False: 19.6k]
  |  Branch (4267:43): [True: 36.2k, False: 606]
  ------------------
 4268|  36.2k|            avoid_refresh = true;
 4269|  36.2k|            break;
 4270|  36.2k|        }
 4271|  56.5k|    }
 4272|  39.4k|    avoid_refresh = avoid_refresh && !(in->after_seek && !in->after_seek_to_start);
  ------------------
  |  Branch (4272:21): [True: 36.2k, False: 3.13k]
  |  Branch (4272:40): [True: 36.0k, False: 273]
  |  Branch (4272:58): [True: 0, False: 36.0k]
  ------------------
 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|  39.4k|    if (!in->after_seek || (ds->type != STREAM_VIDEO && !avoid_refresh)) {
  ------------------
  |  Branch (4280:9): [True: 273, False: 39.1k]
  |  Branch (4280:29): [True: 19.2k, False: 19.8k]
  |  Branch (4280:57): [True: 3.13k, False: 16.1k]
  ------------------
 4281|  3.40k|        MP_VERBOSE(in, "refresh track %d (%s)\n", stream->index,
  ------------------
  |  |   92|  3.40k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4282|  3.40k|                   stream_type_name(ds->type));
 4283|  3.40k|        initiate_refresh_seek(in, ds, ref_pts);
 4284|  3.40k|    }
 4285|  39.4k|}
demux.c:initiate_refresh_seek:
 4184|  3.40k|{
 4185|  3.40k|    struct demuxer *demux = in->d_thread;
 4186|  3.40k|    bool seekable = demux->desc->seek && demux->seekable &&
  ------------------
  |  Branch (4186:21): [True: 3.40k, False: 0]
  |  Branch (4186:42): [True: 3.40k, False: 0]
  ------------------
 4187|  3.40k|                    !demux->partially_seekable;
  ------------------
  |  Branch (4187:21): [True: 3.40k, False: 0]
  ------------------
 4188|       |
 4189|  3.40k|    bool normal_seek = true;
 4190|  3.40k|    bool refresh_possible = true;
 4191|  8.16k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4191:21): [True: 4.75k, False: 3.40k]
  ------------------
 4192|  4.75k|        struct demux_stream *ds = in->streams[n]->ds;
 4193|       |
 4194|  4.75k|        if (!ds->selected)
  ------------------
  |  Branch (4194:13): [True: 691, False: 4.06k]
  ------------------
 4195|    691|            continue;
 4196|       |
 4197|  4.06k|        if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
  ------------------
  |  Branch (4197:13): [True: 273, False: 3.79k]
  |  Branch (4197:41): [True: 3.32k, False: 469]
  ------------------
 4198|  3.59k|            start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
  ------------------
  |  |   64|  3.59k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  7.18k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 1, False: 3.59k]
  |  |  |  |  |  Branch (45:23): [True: 128, False: 3.46k]
  |  |  |  |  |  Branch (45:29): [True: 3.15k, False: 441]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 1]
  |  |  |  |  |  Branch (45:41): [True: 128, False: 3.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|       |
 4200|       |        // If there were no other streams selected, we can use a normal seek.
 4201|  4.06k|        normal_seek &= stream == ds;
 4202|       |
 4203|  4.06k|        refresh_possible &= ds->queue->correct_dts || ds->queue->correct_pos;
  ------------------
  |  Branch (4203:29): [True: 3.62k, False: 441]
  |  Branch (4203:55): [True: 441, False: 0]
  ------------------
 4204|  4.06k|    }
 4205|       |
 4206|  3.40k|    if (start_ts == MP_NOPTS_VALUE || !seekable)
  ------------------
  |  |   39|  6.81k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4206:9): [True: 132, False: 3.27k]
  |  Branch (4206:39): [True: 0, False: 3.27k]
  ------------------
 4207|    132|        return;
 4208|       |
 4209|  3.27k|    if (!normal_seek) {
  ------------------
  |  Branch (4209:9): [True: 368, False: 2.90k]
  ------------------
 4210|    368|        if (!refresh_possible) {
  ------------------
  |  Branch (4210:13): [True: 0, False: 368]
  ------------------
 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|  1.52k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4215:25): [True: 1.15k, False: 368]
  ------------------
 4216|  1.15k|            struct demux_stream *ds = in->streams[n]->ds;
 4217|       |
 4218|  1.15k|            bool correct_pos = ds->queue->correct_pos;
 4219|  1.15k|            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|  1.15k|            ds_clear_reader_queue_state(ds);
 4227|  1.15k|            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|  1.15k|            if (ds->selected && (ds->last_ret_pos != -1 ||
  ------------------
  |  Branch (4231:17): [True: 995, False: 162]
  |  Branch (4231:34): [True: 441, False: 554]
  ------------------
 4232|    554|                                 ds->last_ret_dts != MP_NOPTS_VALUE))
  ------------------
  |  |   39|    554|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4232:34): [True: 0, False: 554]
  ------------------
 4233|    441|            {
 4234|    441|                ds->refreshing = true;
 4235|    441|                ds->queue->correct_dts = correct_dts;
 4236|    441|                ds->queue->correct_pos = correct_pos;
 4237|    441|                ds->queue->last_pos = ds->last_ret_pos;
 4238|    441|                ds->queue->last_dts = ds->last_ret_dts;
 4239|    441|            }
 4240|       |
 4241|  1.15k|            update_seek_ranges(in->current_range);
 4242|  1.15k|        }
 4243|       |
 4244|    368|        start_ts -= 1.0; // small offset to get correct overlap
 4245|    368|    }
 4246|       |
 4247|  3.27k|    MP_VERBOSE(in, "refresh seek to %f\n", start_ts);
  ------------------
  |  |   92|  3.27k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.27k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4248|  3.27k|    in->seeking = true;
 4249|  3.27k|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|  3.27k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 4250|  3.27k|    in->seek_pts = start_ts;
 4251|  3.27k|}
demux.c:wakeup_ds:
  887|   899k|{
  888|   899k|    if (ds->need_wakeup) {
  ------------------
  |  Branch (888:9): [True: 167k, False: 732k]
  ------------------
  889|   167k|        if (ds->wakeup_cb) {
  ------------------
  |  Branch (889:13): [True: 70.0k, False: 97.5k]
  ------------------
  890|  70.0k|            ds->wakeup_cb(ds->wakeup_cb_ctx);
  891|  97.5k|        } else if (ds->in->wakeup_cb) {
  ------------------
  |  Branch (891:20): [True: 44.3k, False: 53.1k]
  ------------------
  892|  44.3k|            ds->in->wakeup_cb(ds->in->wakeup_cb_ctx);
  893|  44.3k|        }
  894|       |        ds->need_wakeup = false;
  895|   167k|        mp_cond_signal(&ds->in->wakeup);
  896|   167k|    }
  897|   899k|}
demux.c:update_cache:
 4528|   814k|{
 4529|   814k|    struct demuxer *demuxer = in->d_thread;
 4530|   814k|    struct stream *stream = demuxer->stream;
 4531|       |
 4532|   814k|    int64_t now = mp_time_ns();
 4533|   814k|    int64_t diff = now - in->last_speed_query;
 4534|   814k|    bool do_update = diff >= MP_TIME_S_TO_NS(1) || !in->last_speed_query;
  ------------------
  |  |   71|  1.62M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (4534:22): [True: 24.5k, False: 790k]
  |  Branch (4534:52): [True: 12, False: 790k]
  ------------------
 4535|       |
 4536|       |    // Don't lock while querying the stream.
 4537|   814k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   814k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4538|       |
 4539|   814k|    int64_t stream_size = -1;
 4540|   814k|    struct mp_tags *stream_metadata = NULL;
 4541|   814k|    if (stream) {
  ------------------
  |  Branch (4541:9): [True: 805k, False: 8.97k]
  ------------------
 4542|   805k|        if (do_update)
  ------------------
  |  Branch (4542:13): [True: 24.2k, False: 781k]
  ------------------
 4543|  24.2k|            stream_size = stream_get_size(stream);
 4544|   805k|        stream_control(stream, STREAM_CTRL_GET_METADATA, &stream_metadata);
 4545|   805k|    }
 4546|       |
 4547|   814k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   814k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4548|       |
 4549|   814k|    update_bytes_read(in);
 4550|       |
 4551|   814k|    if (do_update)
  ------------------
  |  Branch (4551:9): [True: 24.5k, False: 790k]
  ------------------
 4552|  24.5k|        in->stream_size = stream_size;
 4553|   814k|    if (stream_metadata) {
  ------------------
  |  Branch (4553:9): [True: 0, False: 814k]
  ------------------
 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|   814k|    in->next_cache_update = INT64_MAX;
 4559|       |
 4560|   814k|    if (do_update) {
  ------------------
  |  Branch (4560:9): [True: 24.5k, False: 790k]
  ------------------
 4561|  24.5k|        uint64_t bytes = in->cache_unbuffered_read_bytes;
 4562|  24.5k|        in->cache_unbuffered_read_bytes = 0;
 4563|  24.5k|        in->last_speed_query = now;
 4564|  24.5k|        double speed = bytes / (diff / (double)MP_TIME_S_TO_NS(1));
  ------------------
  |  |   71|  24.5k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
 4565|  24.5k|        in->bytes_per_second = 0.5 * in->speed_query_prev_sample +
 4566|  24.5k|                               0.5 * speed;
 4567|  24.5k|        in->speed_query_prev_sample = speed;
 4568|  24.5k|    }
 4569|       |    // The idea is to update as long as there is "activity".
 4570|   814k|    if (in->bytes_per_second)
  ------------------
  |  Branch (4570:9): [True: 814k, False: 41]
  ------------------
 4571|   814k|        in->next_cache_update = now + MP_TIME_S_TO_NS(1) + MP_TIME_US_TO_NS(1);
  ------------------
  |  |   71|   814k|#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|   814k|#define MP_TIME_US_TO_NS(us) ((us) * INT64_C(1000))
  ------------------
 4572|   814k|}
demux.c:dumper_close:
 4575|  25.0k|{
 4576|  25.0k|    if (in->dumper)
  ------------------
  |  Branch (4576:9): [True: 0, False: 25.0k]
  ------------------
 4577|      0|        mp_recorder_destroy(in->dumper);
 4578|  25.0k|    in->dumper = NULL;
 4579|  25.0k|    if (in->dumper_status == CONTROL_TRUE)
  ------------------
  |  |   96|  25.0k|#define CONTROL_TRUE 1
  ------------------
  |  Branch (4579:9): [True: 0, False: 25.0k]
  ------------------
 4580|      0|        in->dumper_status = CONTROL_FALSE; // make abort equal to success
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 4581|  25.0k|}
demux.c:find_cache_seek_range:
 3938|    384|{
 3939|       |    // Note about queued low level seeks: in->seeking can be true here, and it
 3940|       |    // might come from a previous resume seek to the current range. If we end
 3941|       |    // up seeking into the current range (i.e. just changing time offset), the
 3942|       |    // seek needs to continue. Otherwise, we override the queued seek anyway.
 3943|    384|    if ((flags & SEEK_FACTOR) || !in->seekable_cache)
  ------------------
  |  |   94|    384|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (3943:9): [True: 0, False: 384]
  |  Branch (3943:34): [True: 384, False: 0]
  ------------------
 3944|    384|        return NULL;
 3945|       |
 3946|      0|    struct demux_cached_range *res = NULL;
 3947|       |
 3948|      0|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (3948:21): [True: 0, False: 0]
  ------------------
 3949|      0|        struct demux_cached_range *r = in->ranges[n];
 3950|      0|        if (r->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3950:13): [True: 0, False: 0]
  ------------------
 3951|      0|            MP_VERBOSE(in, "cached range %d: %f <-> %f (bof=%d, eof=%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__)
  |  |  ------------------
  ------------------
 3952|      0|                       n, r->seek_start, r->seek_end, r->is_bof, r->is_eof);
 3953|       |
 3954|      0|            if ((pts >= r->seek_start || r->is_bof) &&
  ------------------
  |  Branch (3954:18): [True: 0, False: 0]
  |  Branch (3954:42): [True: 0, False: 0]
  ------------------
 3955|      0|                (pts <= r->seek_end || r->is_eof))
  ------------------
  |  Branch (3955:18): [True: 0, False: 0]
  |  Branch (3955:40): [True: 0, False: 0]
  ------------------
 3956|      0|            {
 3957|      0|                MP_VERBOSE(in, "...using this range for in-cache 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__)
  |  |  ------------------
  ------------------
 3958|      0|                res = r;
 3959|      0|                break;
 3960|      0|            }
 3961|      0|        }
 3962|      0|    }
 3963|       |
 3964|      0|    return res;
 3965|    384|}
demux.c:compute_keyframe_times:
 1981|   334k|{
 1982|   334k|    struct demux_packet *start = pkt;
 1983|   334k|    double min = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1984|   334k|    double max = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1985|       |
 1986|   744k|    while (pkt) {
  ------------------
  |  Branch (1986:12): [True: 687k, False: 56.6k]
  ------------------
 1987|   687k|        if (pkt->keyframe && pkt != start)
  ------------------
  |  Branch (1987:13): [True: 572k, False: 114k]
  |  Branch (1987:30): [True: 277k, False: 294k]
  ------------------
 1988|   277k|            break;
 1989|       |
 1990|   409k|        double ts = MP_PTS_OR_DEF(pkt->pts, pkt->dts);
  ------------------
  |  |   62|   409k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   409k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 116k, False: 293k]
  |  |  ------------------
  ------------------
 1991|   409k|        if (pkt->segmented && ((pkt->start != MP_NOPTS_VALUE && ts < pkt->start) ||
  ------------------
  |  |   39|  11.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1991:13): [True: 5.74k, False: 404k]
  |  Branch (1991:33): [True: 5.74k, False: 0]
  |  Branch (1991:65): [True: 1.79k, False: 3.95k]
  ------------------
 1992|  3.95k|                               (pkt->end != MP_NOPTS_VALUE && ts > pkt->end)))
  ------------------
  |  |   39|  7.90k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1992:33): [True: 3.95k, False: 0]
  |  Branch (1992:63): [True: 431, False: 3.52k]
  ------------------
 1993|  2.22k|            ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.22k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1994|       |
 1995|   409k|        min = MP_PTS_MIN(min, ts);
  ------------------
  |  |   64|   409k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   819k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 1.24k, False: 408k]
  |  |  |  |  |  Branch (45:23): [True: 294k, False: 114k]
  |  |  |  |  |  Branch (45:29): [True: 79.1k, False: 330k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 1.24k]
  |  |  |  |  |  Branch (45:41): [True: 294k, False: 113k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1996|   409k|        max = MP_PTS_MAX(max, ts);
  ------------------
  |  |   65|   409k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|   819k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 20.6k, False: 389k]
  |  |  |  |  |  Branch (44:23): [True: 294k, False: 114k]
  |  |  |  |  |  Branch (44:29): [True: 79.1k, False: 330k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 20.6k]
  |  |  |  |  |  Branch (44:41): [True: 79.1k, False: 309k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|   409k|        pkt = pkt->next;
 1999|   409k|    }
 2000|       |
 2001|   334k|    if (out_kf_min)
  ------------------
  |  Branch (2001:9): [True: 334k, False: 3]
  ------------------
 2002|   334k|        *out_kf_min = min;
 2003|   334k|    if (out_kf_max)
  ------------------
  |  Branch (2003:9): [True: 0, False: 334k]
  ------------------
 2004|      0|        *out_kf_max = max;
 2005|   334k|    return pkt;
 2006|   334k|}
demux.c:update_bytes_read:
 4505|   828k|{
 4506|   828k|    struct demuxer *demuxer = in->d_thread;
 4507|       |
 4508|   828k|    int64_t new = in->slave_unbuffered_read_bytes;
 4509|   828k|    in->slave_unbuffered_read_bytes = 0;
 4510|       |
 4511|   828k|    int64_t new_seeks = 0;
 4512|       |
 4513|   828k|    struct stream *stream = demuxer->stream;
 4514|   828k|    if (stream) {
  ------------------
  |  Branch (4514:9): [True: 819k, False: 8.97k]
  ------------------
 4515|   819k|        new += stream->total_unbuffered_read_bytes;
 4516|   819k|        stream->total_unbuffered_read_bytes = 0;
 4517|   819k|        new_seeks += stream->total_stream_seeks;
 4518|   819k|        stream->total_stream_seeks = 0;
 4519|   819k|    }
 4520|       |
 4521|   828k|    in->cache_unbuffered_read_bytes += new;
 4522|   828k|    in->hack_unbuffered_read_bytes += new;
 4523|   828k|    in->byte_level_seeks += new_seeks;
 4524|   828k|}
demux.c:get_forward_buffered_bytes:
  491|  7.67M|{
  492|  7.67M|    if (!ds->reader_head)
  ------------------
  |  Branch (492:9): [True: 2.91M, False: 4.76M]
  ------------------
  493|  2.91M|        return 0;
  494|  4.76M|    return ds->queue->tail_cum_pos - ds->reader_head->cum_pos;
  495|  7.67M|}
demux.c:get_demux_sub_opts:
 5061|   321k|{
 5062|   321k|    if (!demuxer_list[index])
  ------------------
  |  Branch (5062:9): [True: 24.7k, False: 297k]
  ------------------
 5063|  24.7k|        return false;
 5064|   297k|    *sub = demuxer_list[index]->options;
 5065|       |    return true;
 5066|   321k|}

demux_matroska_uid_cmp:
 3811|  1.04k|{
 3812|  1.04k|    return (!memcmp(a->segment, b->segment, 16) &&
  ------------------
  |  Branch (3812:13): [True: 1.04k, False: 0]
  ------------------
 3813|  1.04k|            a->edition == b->edition);
  ------------------
  |  Branch (3813:13): [True: 1.04k, False: 0]
  ------------------
 3814|  1.04k|}
demux_mkv.c:demux_mkv_open:
 2510|  24.7k|{
 2511|  24.7k|    stream_t *s = demuxer->stream;
 2512|  24.7k|    mkv_demuxer_t *mkv_d;
 2513|  24.7k|    int64_t start_pos;
 2514|  24.7k|    int64_t end_pos;
 2515|       |
 2516|  24.7k|    mkv_d = talloc_zero(demuxer, struct mkv_demuxer);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2517|  24.7k|    demuxer->priv = mkv_d;
 2518|  24.7k|    mkv_d->tc_scale = 1000000;
 2519|  24.7k|    mkv_d->a_skip_preroll = 1;
 2520|  24.7k|    mkv_d->skip_to_timecode = INT64_MIN;
 2521|       |
 2522|  24.7k|    if (demuxer->params)
  ------------------
  |  Branch (2522:9): [True: 24.7k, False: 0]
  ------------------
 2523|  24.7k|        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|  24.7k|    if (stream_read_peek(s, &(char[4]){0}, 4) != 4)
  ------------------
  |  Branch (2526:9): [True: 13, False: 24.7k]
  ------------------
 2527|     13|        return -1;
 2528|  24.7k|    if (!read_ebml_header(demuxer))
  ------------------
  |  Branch (2528:9): [True: 222, False: 24.5k]
  ------------------
 2529|    222|        return -1;
 2530|  24.5k|    MP_DBG(demuxer, "Found the head...\n");
  ------------------
  |  |   93|  24.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2531|       |
 2532|  24.5k|    if (!read_mkv_segment_header(demuxer, &end_pos))
  ------------------
  |  Branch (2532:9): [True: 248, False: 24.2k]
  ------------------
 2533|    248|        return -1;
 2534|       |
 2535|  24.2k|    mkv_d->segment_start = stream_tell(s);
 2536|  24.2k|    mkv_d->segment_end = end_pos;
 2537|       |
 2538|  24.2k|    struct MPOpts *mp_opts = mp_get_config_group(mkv_d, demuxer->global, &mp_opt_root);
 2539|  24.2k|    mkv_d->edition_id = mp_opts->edition_id;
 2540|  24.2k|    talloc_free(mp_opts);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
 2541|       |
 2542|  24.2k|    mkv_d->opts = mp_get_config_group(mkv_d, demuxer->global, &demux_mkv_conf);
 2543|       |
 2544|  24.2k|    if (demuxer->params && demuxer->params->matroska_was_valid)
  ------------------
  |  Branch (2544:9): [True: 24.2k, False: 0]
  |  Branch (2544:28): [True: 0, False: 24.2k]
  ------------------
 2545|      0|        *demuxer->params->matroska_was_valid = true;
 2546|       |
 2547|  7.13M|    while (1) {
  ------------------
  |  Branch (2547:12): [True: 7.13M, Folded]
  ------------------
 2548|  7.13M|        start_pos = stream_tell(s);
 2549|  7.13M|        uint32_t id = ebml_read_id(s);
 2550|  7.13M|        if (s->eof) {
  ------------------
  |  Branch (2550:13): [True: 3.29k, False: 7.12M]
  ------------------
 2551|  3.29k|            if (!mkv_d->probably_webm_dash_init)
  ------------------
  |  Branch (2551:17): [True: 3.29k, False: 0]
  ------------------
 2552|  3.29k|                MP_WARN(demuxer, "Unexpected end of file (no clusters found)\n");
  ------------------
  |  |   90|  3.29k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.29k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2553|  3.29k|            break;
 2554|  3.29k|        }
 2555|  7.12M|        if (id == MATROSKA_ID_CLUSTER) {
  ------------------
  |  |   28|  7.12M|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (2555:13): [True: 20.9k, False: 7.10M]
  ------------------
 2556|  20.9k|            MP_DBG(demuxer, "|+ found cluster\n");
  ------------------
  |  |   93|  20.9k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  20.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2557|  20.9k|            mkv_d->first_cluster = start_pos;
 2558|  20.9k|            mkv_d->cluster_start = start_pos;
 2559|  20.9k|            break;
 2560|  20.9k|        }
 2561|  7.10M|        int res = read_header_element(demuxer, id, start_pos);
 2562|  7.10M|        if (res < 0)
  ------------------
  |  Branch (2562:13): [True: 11, False: 7.10M]
  ------------------
 2563|     11|            return -1;
 2564|  7.10M|    }
 2565|       |
 2566|  24.2k|    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|  24.2k|    int only_cue = -1;
 2572|   108k|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2572:21): [True: 83.8k, False: 24.2k]
  ------------------
 2573|  83.8k|        struct header_elem *elem = &mkv_d->headers[n];
 2574|  83.8k|        if (elem->parsed)
  ------------------
  |  Branch (2574:13): [True: 66.7k, False: 17.1k]
  ------------------
 2575|  66.7k|            continue;
 2576|       |        // Warn against incomplete files and skip headers outside of range.
 2577|  17.1k|        if (elem->pos >= end || !s->seekable) {
  ------------------
  |  Branch (2577:13): [True: 11.9k, False: 5.21k]
  |  Branch (2577:33): [True: 0, False: 5.21k]
  ------------------
 2578|  11.9k|            elem->parsed = true; // don't bother if file is incomplete
 2579|  11.9k|            if (end < 0 || !s->seekable) {
  ------------------
  |  Branch (2579:17): [True: 0, False: 11.9k]
  |  Branch (2579:28): [True: 0, False: 11.9k]
  ------------------
 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|  11.9k|            } else if (!mkv_d->eof_warning &&
  ------------------
  |  Branch (2582:24): [True: 7.90k, False: 4.04k]
  ------------------
 2583|  7.90k|                       !(mkv_d->probably_webm_dash_init &&  elem->pos == end))
  ------------------
  |  Branch (2583:26): [True: 0, False: 7.90k]
  |  Branch (2583:61): [True: 0, False: 0]
  ------------------
 2584|  7.90k|            {
 2585|  7.90k|                MP_WARN(demuxer, "mkv metadata beyond end of file - incomplete "
  ------------------
  |  |   90|  7.90k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.90k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2586|  7.90k|                        "file?\n");
 2587|  7.90k|                mkv_d->eof_warning = true;
 2588|  7.90k|            }
 2589|  11.9k|            continue;
 2590|  11.9k|        }
 2591|  5.21k|        only_cue = only_cue < 0 && elem->id == MATROSKA_ID_CUES;
  ------------------
  |  |  130|  9.36k|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (2591:20): [True: 4.15k, False: 1.05k]
  |  Branch (2591:36): [True: 29, False: 4.12k]
  ------------------
 2592|  5.21k|    }
 2593|       |
 2594|       |    // If there's only 1 needed element, and it's the cues, defer reading.
 2595|  24.2k|    if (only_cue == 1) {
  ------------------
  |  Branch (2595:9): [True: 4, False: 24.2k]
  ------------------
 2596|       |        // Read cues when they are needed, to avoid seeking on opening.
 2597|      4|        MP_VERBOSE(demuxer, "Deferring reading cues.\n");
  ------------------
  |  |   92|      4|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2598|  24.2k|    } else {
 2599|       |        // Read them by ascending position to reduce unneeded seeks.
 2600|       |        // O(n^2) because the number of elements is very low.
 2601|  29.4k|        while (1) {
  ------------------
  |  Branch (2601:16): [True: 29.4k, Folded]
  ------------------
 2602|  29.4k|            struct header_elem *lowest = NULL;
 2603|   137k|            for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2603:29): [True: 107k, False: 29.4k]
  ------------------
 2604|   107k|                struct header_elem *elem = &mkv_d->headers[n];
 2605|   107k|                if (elem->parsed)
  ------------------
  |  Branch (2605:21): [True: 101k, False: 6.65k]
  ------------------
 2606|   101k|                    continue;
 2607|  6.65k|                if (!lowest || elem->pos < lowest->pos)
  ------------------
  |  Branch (2607:21): [True: 5.20k, False: 1.44k]
  |  Branch (2607:32): [True: 275, False: 1.16k]
  ------------------
 2608|  5.48k|                    lowest = elem;
 2609|  6.65k|            }
 2610|       |
 2611|  29.4k|            if (!lowest)
  ------------------
  |  Branch (2611:17): [True: 24.2k, False: 5.20k]
  ------------------
 2612|  24.2k|                break;
 2613|       |
 2614|  5.20k|            if (read_deferred_element(demuxer, lowest) < 0)
  ------------------
  |  Branch (2614:17): [True: 2, False: 5.20k]
  ------------------
 2615|      2|                return -1;
 2616|  5.20k|        }
 2617|  24.2k|    }
 2618|       |
 2619|  24.2k|    if (!stream_seek(s, start_pos)) {
  ------------------
  |  Branch (2619:9): [True: 0, False: 24.2k]
  ------------------
 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|  24.2k|    MP_VERBOSE(demuxer, "All headers are parsed!\n");
  ------------------
  |  |   92|  24.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2625|       |
 2626|  24.2k|    display_create_tracks(demuxer);
 2627|  24.2k|    pair_dovi_tracks(demuxer);
 2628|  24.2k|    add_coverart(demuxer);
 2629|  24.2k|    process_tags(demuxer);
 2630|       |
 2631|  24.2k|    probe_first_timestamp(demuxer);
 2632|  24.2k|    if (mkv_d->opts->probe_duration)
  ------------------
  |  Branch (2632:9): [True: 0, False: 24.2k]
  ------------------
 2633|      0|        probe_last_timestamp(demuxer, start_pos);
 2634|  24.2k|    probe_x264_garbage(demuxer);
 2635|  24.2k|    probe_if_image(demuxer);
 2636|       |
 2637|  24.2k|    return 0;
 2638|  24.2k|}
demux_mkv.c:read_ebml_header:
 2423|  24.7k|{
 2424|  24.7k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2425|  24.7k|    stream_t *s = demuxer->stream;
 2426|       |
 2427|  24.7k|    if (ebml_read_id(s) != EBML_ID_EBML)
  ------------------
  |  |    3|  24.7k|#define EBML_ID_EBML                             0x1a45dfa3
  ------------------
  |  Branch (2427:9): [True: 28, False: 24.7k]
  ------------------
 2428|     28|        return 0;
 2429|  24.7k|    struct ebml_ebml ebml_master = {0};
 2430|  24.7k|    struct ebml_parse_ctx parse_ctx = { demuxer->log, .no_error_messages = true };
 2431|  24.7k|    if (ebml_read_element(s, &parse_ctx, &ebml_master, &ebml_ebml_desc) < 0)
  ------------------
  |  Branch (2431:9): [True: 30, False: 24.6k]
  ------------------
 2432|     30|        return 0;
 2433|  24.7k|    bool is_matroska = false, is_webm = false;
 2434|  24.6k|    if (!ebml_master.doc_type) {
  ------------------
  |  Branch (2434:9): [True: 4.71k, False: 19.9k]
  ------------------
 2435|  4.71k|        MP_VERBOSE(demuxer, "File has EBML header but no doctype. "
  ------------------
  |  |   92|  4.71k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.71k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2436|  4.71k|                   "Assuming \"matroska\".\n");
 2437|  4.71k|        is_matroska = true;
 2438|  19.9k|    } else if (strcmp(ebml_master.doc_type, "matroska") == 0) {
  ------------------
  |  Branch (2438:16): [True: 19.9k, False: 21]
  ------------------
 2439|  19.9k|        is_matroska = true;
 2440|  19.9k|    } else if (strcmp(ebml_master.doc_type, "webm") == 0) {
  ------------------
  |  Branch (2440:16): [True: 1, False: 20]
  ------------------
 2441|      1|        is_webm = true;
 2442|      1|    }
 2443|  24.6k|    if (!is_matroska && !is_webm) {
  ------------------
  |  Branch (2443:9): [True: 21, False: 24.6k]
  |  Branch (2443:25): [True: 20, False: 1]
  ------------------
 2444|     20|        MP_TRACE(demuxer, "no head found\n");
  ------------------
  |  |   94|     20|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     20|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2445|     20|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|     20|#define talloc_free                     ta_free
  ------------------
 2446|     20|        return 0;
 2447|     20|    }
 2448|  24.6k|    mkv_d->probably_webm_dash_init &= is_webm;
 2449|  24.6k|    if (ebml_master.doc_type_read_version > 2) {
  ------------------
  |  Branch (2449:9): [True: 44, False: 24.6k]
  ------------------
 2450|     44|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|     44|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     44|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2451|     44|                "but we don't support format version %"PRIu64"\n",
 2452|     44|                ebml_master.doc_type_read_version);
 2453|     44|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|     44|#define talloc_free                     ta_free
  ------------------
 2454|     44|        return 0;
 2455|     44|    }
 2456|  24.6k|    if ((ebml_master.n_ebml_read_version
  ------------------
  |  Branch (2456:10): [True: 16.0k, False: 8.55k]
  ------------------
 2457|  16.0k|         && ebml_master.ebml_read_version != EBML_VERSION)
  ------------------
  |  |   31|  16.0k|#define EBML_VERSION 1
  ------------------
  |  Branch (2457:13): [True: 34, False: 16.0k]
  ------------------
 2458|  24.5k|        || (ebml_master.n_ebml_max_size_length
  ------------------
  |  Branch (2458:13): [True: 14.6k, False: 9.93k]
  ------------------
 2459|  14.6k|            && ebml_master.ebml_max_size_length > 8)
  ------------------
  |  Branch (2459:16): [True: 33, False: 14.6k]
  ------------------
 2460|  24.5k|        || (ebml_master.n_ebml_max_id_length
  ------------------
  |  Branch (2460:13): [True: 15.6k, False: 8.91k]
  ------------------
 2461|  15.6k|            && ebml_master.ebml_max_id_length != 4))
  ------------------
  |  Branch (2461:16): [True: 33, False: 15.5k]
  ------------------
 2462|    100|    {
 2463|    100|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|    100|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    100|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2464|    100|                "but the header has bad parameters\n");
 2465|    100|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    100|#define talloc_free                     ta_free
  ------------------
 2466|    100|        return 0;
 2467|    100|    }
 2468|  24.5k|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  24.5k|#define talloc_free                     ta_free
  ------------------
 2469|       |
 2470|  24.5k|    return 1;
 2471|  24.6k|}
demux_mkv.c:read_mkv_segment_header:
 2474|  24.5k|{
 2475|  24.5k|    stream_t *s = demuxer->stream;
 2476|  24.5k|    int num_skip = 0;
 2477|  24.5k|    if (demuxer->params)
  ------------------
  |  Branch (2477:9): [True: 24.5k, False: 0]
  ------------------
 2478|  24.5k|        num_skip = demuxer->params->matroska_wanted_segment;
 2479|       |
 2480|  24.5k|    while (stream_read_peek(s, &(char){0}, 1)) {
  ------------------
  |  Branch (2480:12): [True: 24.2k, False: 226]
  ------------------
 2481|  24.2k|        if (ebml_read_id(s) != MATROSKA_ID_SEGMENT) {
  ------------------
  |  |   13|  24.2k|#define MATROSKA_ID_SEGMENT                      0x18538067
  ------------------
  |  Branch (2481:13): [True: 22, False: 24.2k]
  ------------------
 2482|     22|            MP_VERBOSE(demuxer, "segment not found\n");
  ------------------
  |  |   92|     22|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     22|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2483|     22|            return 0;
 2484|     22|        }
 2485|  24.2k|        MP_DBG(demuxer, "+ a segment...\n");
  ------------------
  |  |   93|  24.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2486|  24.2k|        uint64_t len = ebml_read_length(s);
 2487|  24.2k|        *segment_end = (len == EBML_UINT_INVALID) ? 0 : stream_tell(s) + len;
  ------------------
  |  |   85|  24.2k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (2487:24): [True: 933, False: 23.3k]
  ------------------
 2488|  24.2k|        if (num_skip <= 0)
  ------------------
  |  Branch (2488:13): [True: 24.2k, False: 0]
  ------------------
 2489|  24.2k|            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|    226|    MP_VERBOSE(demuxer, "End of file, no further segments.\n");
  ------------------
  |  |   92|    226|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    226|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2506|    226|    return 0;
 2507|  24.5k|}
demux_mkv.c:read_header_element:
 1479|  7.10M|{
 1480|  7.10M|    if (id == EBML_ID_INVALID)
  ------------------
  |  |   75|  7.10M|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (1480:9): [True: 6.94M, False: 164k]
  ------------------
 1481|  6.94M|        return 0;
 1482|       |
 1483|   164k|    if (test_header_element(demuxer, id, start_filepos))
  ------------------
  |  Branch (1483:9): [True: 4.20k, False: 160k]
  ------------------
 1484|  4.20k|        goto skip;
 1485|       |
 1486|   160k|    switch(id) {
  ------------------
  |  Branch (1486:12): [True: 66.8k, False: 93.1k]
  ------------------
 1487|  17.4k|    case MATROSKA_ID_INFO:
  ------------------
  |  |   18|  17.4k|#define MATROSKA_ID_INFO                         0x1549a966
  ------------------
  |  Branch (1487:5): [True: 17.4k, False: 142k]
  ------------------
 1488|  17.4k|        return demux_mkv_read_info(demuxer);
 1489|  22.3k|    case MATROSKA_ID_TRACKS:
  ------------------
  |  |   40|  22.3k|#define MATROSKA_ID_TRACKS                       0x1654ae6b
  ------------------
  |  Branch (1489:5): [True: 22.3k, False: 137k]
  ------------------
 1490|  22.3k|        return demux_mkv_read_tracks(demuxer);
 1491|    204|    case MATROSKA_ID_CUES:
  ------------------
  |  |  130|    204|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (1491:5): [True: 204, False: 159k]
  ------------------
 1492|    204|        return demux_mkv_read_cues(demuxer);
 1493|  6.86k|    case MATROSKA_ID_TAGS:
  ------------------
  |  |  164|  6.86k|#define MATROSKA_ID_TAGS                         0x1254c367
  ------------------
  |  Branch (1493:5): [True: 6.86k, False: 153k]
  ------------------
 1494|  6.86k|        return demux_mkv_read_tags(demuxer);
 1495|  18.3k|    case MATROSKA_ID_SEEKHEAD:
  ------------------
  |  |   14|  18.3k|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (1495:5): [True: 18.3k, False: 141k]
  ------------------
 1496|  18.3k|        return demux_mkv_read_seekhead(demuxer);
 1497|    999|    case MATROSKA_ID_CHAPTERS:
  ------------------
  |  |  145|    999|#define MATROSKA_ID_CHAPTERS                     0x1043a770
  ------------------
  |  Branch (1497:5): [True: 999, False: 159k]
  ------------------
 1498|    999|        return demux_mkv_read_chapters(demuxer);
 1499|    604|    case MATROSKA_ID_ATTACHMENTS:
  ------------------
  |  |  138|    604|#define MATROSKA_ID_ATTACHMENTS                  0x1941a469
  ------------------
  |  Branch (1499:5): [True: 604, False: 159k]
  ------------------
 1500|    604|        return demux_mkv_read_attachments(demuxer);
 1501|   160k|    }
 1502|  97.3k|skip:
 1503|  97.3k|    ebml_read_skip(demuxer->log, -1, demuxer->stream);
 1504|  97.3k|    return 0;
 1505|   160k|}
demux_mkv.c:test_header_element:
 1438|   164k|{
 1439|   164k|    struct header_elem *elem = get_header_element(demuxer, id, element_filepos);
 1440|   164k|    if (!elem)
  ------------------
  |  Branch (1440:9): [True: 93.1k, False: 71.0k]
  ------------------
 1441|  93.1k|        return false;
 1442|  71.0k|    if (elem->parsed)
  ------------------
  |  Branch (1442:9): [True: 4.20k, False: 66.8k]
  ------------------
 1443|  4.20k|        return true;
 1444|  66.8k|    elem->parsed = true;
 1445|       |    return false;
 1446|  71.0k|}
demux_mkv.c:get_header_element:
 1411|   232k|{
 1412|   232k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1413|       |
 1414|       |    // Note that some files in fact contain a SEEKHEAD with a list of all
 1415|       |    // clusters - we have no use for that.
 1416|   232k|    if (!ebml_is_mkv_level1_id(id) || id == MATROSKA_ID_CLUSTER)
  ------------------
  |  |   28|   138k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (1416:9): [True: 93.8k, False: 138k]
  |  Branch (1416:39): [True: 24.5k, False: 113k]
  ------------------
 1417|   118k|        return NULL;
 1418|       |
 1419|   304k|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (1419:21): [True: 221k, False: 83.9k]
  ------------------
 1420|   221k|        struct header_elem *elem = &mkv_d->headers[n];
 1421|       |        // SEEKHEAD is the only element that can happen multiple times.
 1422|       |        // Other elements might be duplicated (or attempted to be read twice,
 1423|       |        // even if it's only once in the file), but only the first is used.
 1424|   221k|        if (elem->id == id && (id != MATROSKA_ID_SEEKHEAD ||
  ------------------
  |  |   14|  75.2k|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (1424:13): [True: 37.6k, False: 183k]
  |  Branch (1424:32): [True: 29.8k, False: 7.77k]
  ------------------
 1425|  7.77k|                               elem->pos == element_filepos))
  ------------------
  |  Branch (1425:32): [True: 69, False: 7.70k]
  ------------------
 1426|  29.9k|            return elem;
 1427|   221k|    }
 1428|  83.9k|    struct header_elem elem = { .id = id, .pos = element_filepos };
 1429|  83.9k|    MP_TARRAY_APPEND(mkv_d, mkv_d->headers, mkv_d->num_headers, elem);
  ------------------
  |  |  105|  83.9k|    do {                                            \
  |  |  106|  83.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  83.9k|    do {                                            \
  |  |  |  |   97|  83.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  83.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  83.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  83.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 41.8k, False: 42.0k]
  |  |  |  |  ------------------
  |  |  |  |   99|  83.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  41.8k|    do {                                                        \
  |  |  |  |  |  |   89|  41.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  41.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  41.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  41.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  41.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  41.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  41.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 41.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  83.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 83.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  83.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  83.9k|        (idxvar)++;                                 \
  |  |  109|  83.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 83.9k]
  |  |  ------------------
  ------------------
 1430|  83.9k|    return &mkv_d->headers[mkv_d->num_headers - 1];
 1431|   113k|}
demux_mkv.c:demux_mkv_read_info:
  448|  17.4k|{
  449|  17.4k|    mkv_demuxer_t *mkv_d = demuxer->priv;
  450|  17.4k|    stream_t *s = demuxer->stream;
  451|  17.4k|    int res = 0;
  452|       |
  453|  17.4k|    MP_DBG(demuxer, "|+ segment information...\n");
  ------------------
  |  |   93|  17.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  17.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  454|       |
  455|  17.4k|    mkv_d->tc_scale = 1000000;
  456|  17.4k|    mkv_d->duration = 0;
  457|       |
  458|  17.4k|    struct ebml_info info = {0};
  459|  17.4k|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
  460|  17.4k|    if (ebml_read_element(s, &parse_ctx, &info, &ebml_info_desc) < 0)
  ------------------
  |  Branch (460:9): [True: 2, False: 17.4k]
  ------------------
  461|      2|        return -1;
  462|  17.4k|    if (info.muxing_app)
  ------------------
  |  Branch (462:9): [True: 15.9k, False: 1.49k]
  ------------------
  463|  17.4k|        MP_DBG(demuxer, "| + muxing app: %s\n", info.muxing_app);
  ------------------
  |  |   93|  15.9k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  464|  17.4k|    if (info.writing_app)
  ------------------
  |  Branch (464:9): [True: 15.4k, False: 1.99k]
  ------------------
  465|  17.4k|        MP_DBG(demuxer, "| + writing app: %s\n", info.writing_app);
  ------------------
  |  |   93|  15.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  466|  17.4k|    if (info.n_timecode_scale) {
  ------------------
  |  Branch (466:9): [True: 12.4k, False: 4.94k]
  ------------------
  467|  12.4k|        mkv_d->tc_scale = info.timecode_scale;
  468|  12.4k|        MP_DBG(demuxer, "| + timecode scale: %"PRId64"\n", mkv_d->tc_scale);
  ------------------
  |  |   93|  12.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  469|  12.4k|        if (mkv_d->tc_scale < 1 || mkv_d->tc_scale > INT_MAX) {
  ------------------
  |  Branch (469:13): [True: 1, False: 12.4k]
  |  Branch (469:36): [True: 1, False: 12.4k]
  ------------------
  470|      2|            res = -1;
  471|      2|            goto out;
  472|      2|        }
  473|  12.4k|    }
  474|  17.4k|    if (info.n_duration) {
  ------------------
  |  Branch (474:9): [True: 12.7k, False: 4.70k]
  ------------------
  475|  12.7k|        mkv_d->duration = info.duration * mkv_d->tc_scale / 1e9;
  476|  12.7k|        MP_DBG(demuxer, "| + duration: %.3fs\n",
  ------------------
  |  |   93|  12.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  477|  12.7k|               mkv_d->duration);
  478|  12.7k|        demuxer->duration = mkv_d->duration;
  479|  12.7k|    }
  480|  17.4k|    if (info.title) {
  ------------------
  |  Branch (480:9): [True: 2.01k, False: 15.4k]
  ------------------
  481|  2.01k|        mp_tags_set_str(demuxer->metadata, "TITLE", info.title);
  482|  2.01k|    }
  483|  17.4k|    if (info.n_segment_uid) {
  ------------------
  |  Branch (483:9): [True: 12.4k, False: 5.01k]
  ------------------
  484|  12.4k|        size_t len = info.segment_uid.len;
  485|  12.4k|        memcpy(demuxer->matroska_data.uid.segment, info.segment_uid.start, len);
  486|  12.4k|        MP_DBG(demuxer, "| + segment uid");
  ------------------
  |  |   93|  12.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  487|   210k|        for (size_t i = 0; i < len; i++)
  ------------------
  |  Branch (487:28): [True: 198k, False: 12.4k]
  ------------------
  488|   198k|            MP_DBG(demuxer, " %02x", demuxer->matroska_data.uid.segment[i]);
  ------------------
  |  |   93|   198k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   198k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|  12.4k|        MP_DBG(demuxer, "\n");
  ------------------
  |  |   93|  12.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  12.4k|    }
  491|  17.4k|    if (demuxer->params && demuxer->params->matroska_wanted_uids) {
  ------------------
  |  Branch (491:9): [True: 17.4k, False: 0]
  |  Branch (491:28): [True: 0, False: 17.4k]
  ------------------
  492|      0|        if (info.n_segment_uid) {
  ------------------
  |  Branch (492:13): [True: 0, False: 0]
  ------------------
  493|      0|            for (int i = 0; i < demuxer->params->matroska_num_wanted_uids; i++) {
  ------------------
  |  Branch (493:29): [True: 0, False: 0]
  ------------------
  494|      0|                struct matroska_segment_uid *uid = demuxer->params->matroska_wanted_uids + i;
  495|      0|                if (!memcmp(info.segment_uid.start, uid->segment, 16)) {
  ------------------
  |  Branch (495:21): [True: 0, False: 0]
  ------------------
  496|      0|                    demuxer->matroska_data.uid.edition = uid->edition;
  497|      0|                    goto out;
  498|      0|                }
  499|      0|            }
  500|      0|        }
  501|      0|        MP_VERBOSE(demuxer, "This is not one of the wanted files. "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  502|      0|                "Stopping attempt to open.\n");
  503|      0|        res = -2;
  504|      0|    }
  505|  17.4k| out:
  506|  17.4k|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  17.4k|#define talloc_free                     ta_free
  ------------------
  507|  17.4k|    return res;
  508|  17.4k|}
demux_mkv.c:demux_mkv_read_tracks:
 1029|  22.3k|{
 1030|  22.3k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1031|  22.3k|    stream_t *s = demuxer->stream;
 1032|       |
 1033|  22.3k|    MP_DBG(demuxer, "|+ segment tracks...\n");
  ------------------
  |  |   93|  22.3k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  22.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1034|       |
 1035|  22.3k|    struct ebml_tracks tracks = {0};
 1036|  22.3k|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1037|  22.3k|    if (ebml_read_element(s, &parse_ctx, &tracks, &ebml_tracks_desc) < 0)
  ------------------
  |  Branch (1037:9): [True: 1, False: 22.3k]
  ------------------
 1038|      1|        return -1;
 1039|       |
 1040|  22.3k|    mkv_d->tracks = talloc_zero_array(mkv_d, struct mkv_track*,
  ------------------
  |  |   30|  22.3k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  22.3k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  22.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|  22.3k|                                      tracks.n_track_entry);
 1042|  66.1k|    for (int i = 0; i < tracks.n_track_entry; i++) {
  ------------------
  |  Branch (1042:21): [True: 43.7k, False: 22.3k]
  ------------------
 1043|  43.7k|        MP_DBG(demuxer, "| + a track...\n");
  ------------------
  |  |   93|  43.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1044|  43.7k|        parse_trackentry(demuxer, &tracks.track_entry[i]);
 1045|  43.7k|    }
 1046|  22.3k|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  22.3k|#define talloc_free                     ta_free
  ------------------
 1047|  22.3k|    return 0;
 1048|  22.3k|}
demux_mkv.c:parse_trackentry:
  897|  43.7k|{
  898|  43.7k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
  899|  43.7k|    struct mkv_track *track = talloc_zero(NULL, struct mkv_track);
  ------------------
  |  |   27|  43.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  43.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  43.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  900|  43.7k|    track->last_index_entry = (size_t)-1;
  901|  43.7k|    track->parser_tmp = talloc_new(track);
  ------------------
  |  |   40|  43.7k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  43.7k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  902|       |
  903|  43.7k|    track->tnum = entry->track_number;
  904|  43.7k|    if (track->tnum) {
  ------------------
  |  Branch (904:9): [True: 43.3k, False: 389]
  ------------------
  905|  43.3k|        MP_DBG(demuxer, "|  + Track number: %d\n", track->tnum);
  ------------------
  |  |   93|  43.3k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  906|  43.3k|    } else {
  907|    389|        MP_ERR(demuxer, "Missing track number!\n");
  ------------------
  |  |   89|    389|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    389|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  908|    389|    }
  909|  43.7k|    track->uid = entry->track_uid;
  910|       |
  911|  43.7k|    if (entry->name) {
  ------------------
  |  Branch (911:9): [True: 12.8k, False: 30.9k]
  ------------------
  912|  12.8k|        track->name = talloc_strdup(track, entry->name);
  ------------------
  |  |   50|  12.8k|#define talloc_strdup                   ta_xstrdup
  ------------------
  913|  12.8k|        MP_DBG(demuxer, "|  + Name: %s\n", track->name);
  ------------------
  |  |   93|  12.8k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  914|  12.8k|    }
  915|       |
  916|  43.7k|    track->type = entry->track_type;
  917|  43.7k|    MP_DBG(demuxer, "|  + Track type: ");
  ------------------
  |  |   93|  43.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  918|  43.7k|    switch (track->type) {
  919|  17.3k|    case MATROSKA_TRACK_AUDIO:
  ------------------
  |  |   79|  17.3k|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (919:5): [True: 17.3k, False: 26.4k]
  ------------------
  920|  17.3k|        MP_DBG(demuxer, "Audio\n");
  ------------------
  |  |   93|  17.3k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  17.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  921|  17.3k|        break;
  922|  19.5k|    case MATROSKA_TRACK_VIDEO:
  ------------------
  |  |   78|  19.5k|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (922:5): [True: 19.5k, False: 24.2k]
  ------------------
  923|  19.5k|        MP_DBG(demuxer, "Video\n");
  ------------------
  |  |   93|  19.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  924|  19.5k|        break;
  925|  5.10k|    case MATROSKA_TRACK_SUBTITLE:
  ------------------
  |  |   82|  5.10k|#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
  ------------------
  |  Branch (925:5): [True: 5.10k, False: 38.6k]
  ------------------
  926|  5.10k|        MP_DBG(demuxer, "Subtitle\n");
  ------------------
  |  |   93|  5.10k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.10k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  927|  5.10k|        break;
  928|  1.76k|    default:
  ------------------
  |  Branch (928:5): [True: 1.76k, False: 42.0k]
  ------------------
  929|  1.76k|        MP_DBG(demuxer, "unknown\n");
  ------------------
  |  |   93|  1.76k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.76k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  930|  1.76k|        break;
  931|  43.7k|    }
  932|       |
  933|  43.7k|    if (entry->n_audio) {
  ------------------
  |  Branch (933:9): [True: 15.2k, False: 28.4k]
  ------------------
  934|  15.2k|        MP_DBG(demuxer, "|  + Audio track\n");
  ------------------
  |  |   93|  15.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  935|  15.2k|        parse_trackaudio(demuxer, track, &entry->audio);
  936|  15.2k|    }
  937|       |
  938|  43.7k|    if (entry->n_video) {
  ------------------
  |  Branch (938:9): [True: 14.6k, False: 29.1k]
  ------------------
  939|  14.6k|        MP_DBG(demuxer, "|  + Video track\n");
  ------------------
  |  |   93|  14.6k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  940|  14.6k|        parse_trackvideo(demuxer, track, &entry->video);
  941|  14.6k|    }
  942|       |
  943|  43.7k|    if (entry->codec_id) {
  ------------------
  |  Branch (943:9): [True: 41.4k, False: 2.34k]
  ------------------
  944|  41.4k|        track->codec_id = talloc_strdup(track, entry->codec_id);
  ------------------
  |  |   50|  41.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  945|  41.4k|        MP_DBG(demuxer, "|  + Codec ID: %s\n", track->codec_id);
  ------------------
  |  |   93|  41.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  41.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  946|  41.4k|    } else {
  947|  2.34k|        MP_ERR(demuxer, "Missing codec ID!\n");
  ------------------
  |  |   89|  2.34k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.34k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  948|  2.34k|        track->codec_id = "";
  949|  2.34k|    }
  950|       |
  951|  43.7k|    if (entry->n_codec_private && entry->codec_private.len <= 0x10000000) {
  ------------------
  |  Branch (951:9): [True: 31.8k, False: 11.9k]
  |  Branch (951:35): [True: 31.8k, False: 0]
  ------------------
  952|  31.8k|        int len = entry->codec_private.len;
  953|  31.8k|        track->private_data = talloc_size(track, len + AV_LZO_INPUT_PADDING);
  ------------------
  |  |   43|  31.8k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  31.8k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  31.8k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  31.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  31.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  31.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|  31.8k|        memcpy(track->private_data, entry->codec_private.start, len);
  955|  31.8k|        memset(track->private_data + len, 0, AV_LZO_INPUT_PADDING);
  956|  31.8k|        track->private_size = len;
  957|  31.8k|        MP_DBG(demuxer, "|  + CodecPrivate, length %u\n", track->private_size);
  ------------------
  |  |   93|  31.8k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  31.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  958|  31.8k|    }
  959|       |
  960|  43.7k|    if (entry->language_bcp47) {
  ------------------
  |  Branch (960:9): [True: 8, False: 43.7k]
  ------------------
  961|      8|        track->language = talloc_strdup(track, entry->language_bcp47);
  ------------------
  |  |   50|      8|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|      8|        MP_DBG(demuxer, "|  + LanguageBCP47: %s\n", track->language);
  ------------------
  |  |   93|      8|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      8|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  963|  43.7k|    } else if (entry->language) {
  ------------------
  |  Branch (963:16): [True: 23.4k, False: 20.2k]
  ------------------
  964|  23.4k|        track->language = talloc_strdup(track, entry->language);
  ------------------
  |  |   50|  23.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  965|  23.4k|        MP_DBG(demuxer, "|  + Language: %s\n", track->language);
  ------------------
  |  |   93|  23.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  23.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  966|  23.4k|    } else {
  967|  20.2k|        track->language = talloc_strdup(track, "eng");
  ------------------
  |  |   50|  20.2k|#define talloc_strdup                   ta_xstrdup
  ------------------
  968|  20.2k|    }
  969|       |
  970|  43.7k|    if (entry->n_flag_default) {
  ------------------
  |  Branch (970:9): [True: 34.8k, False: 8.87k]
  ------------------
  971|  34.8k|        track->default_track = entry->flag_default;
  972|  34.8k|        MP_DBG(demuxer, "|  + Default flag: %d\n", track->default_track);
  ------------------
  |  |   93|  34.8k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  34.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  973|  34.8k|    } else {
  974|  8.87k|        track->default_track = 1;
  975|  8.87k|    }
  976|       |
  977|  43.7k|    if (entry->n_flag_forced) {
  ------------------
  |  Branch (977:9): [True: 8.82k, False: 34.9k]
  ------------------
  978|  8.82k|        track->forced_track = entry->flag_forced;
  979|  8.82k|        MP_DBG(demuxer, "|  + Forced flag: %d\n", track->forced_track);
  ------------------
  |  |   93|  8.82k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.82k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  980|  8.82k|    }
  981|       |
  982|  43.7k|    if (entry->n_flag_visual_impaired) {
  ------------------
  |  Branch (982:9): [True: 1, False: 43.7k]
  ------------------
  983|      1|        track->visual_impaired_track = entry->flag_visual_impaired;
  984|      1|        MP_DBG(demuxer, "|  + Visual-Impaired flag: %d\n", track->visual_impaired_track);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  985|      1|    }
  986|       |
  987|  43.7k|    if (entry->n_flag_hearing_impaired) {
  ------------------
  |  Branch (987:9): [True: 4, False: 43.7k]
  ------------------
  988|      4|        track->hearing_impaired_track = entry->flag_hearing_impaired;
  989|      4|        MP_DBG(demuxer, "|  + Hearing-Impaired flag: %d\n", track->hearing_impaired_track);
  ------------------
  |  |   93|      4|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  990|      4|    }
  991|       |
  992|  43.7k|    if (entry->n_flag_original) {
  ------------------
  |  Branch (992:9): [True: 1, False: 43.7k]
  ------------------
  993|      1|        track->original_track = entry->flag_original;
  994|      1|        MP_DBG(demuxer, "|  + Original flag: %d\n", track->original_track);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  995|      1|    }
  996|       |
  997|  43.7k|    if (entry->n_flag_commentary) {
  ------------------
  |  Branch (997:9): [True: 2, False: 43.7k]
  ------------------
  998|      2|        track->commentary_track = entry->flag_commentary;
  999|      2|        MP_DBG(demuxer, "|  + Commentary flag: %d\n", track->commentary_track);
  ------------------
  |  |   93|      2|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1000|      2|    }
 1001|       |
 1002|  43.7k|    if (entry->n_default_duration) {
  ------------------
  |  Branch (1002:9): [True: 11.4k, False: 32.2k]
  ------------------
 1003|  11.4k|        track->default_duration = entry->default_duration / 1e9;
 1004|  11.4k|        if (entry->default_duration == 0) {
  ------------------
  |  Branch (1004:13): [True: 2, False: 11.4k]
  ------------------
 1005|      2|            MP_DBG(demuxer, "|  + Default duration: 0");
  ------------------
  |  |   93|      2|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1006|  11.4k|        } else {
 1007|  11.4k|            track->v_frate = 1e9 / entry->default_duration;
 1008|  11.4k|            MP_DBG(demuxer, "|  + Default duration: %.3fms ( = %.3f fps)\n",
  ------------------
  |  |   93|  11.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1009|  11.4k|                   entry->default_duration / 1000000.0, track->v_frate);
 1010|  11.4k|        }
 1011|  11.4k|    }
 1012|       |
 1013|  43.7k|    if (entry->n_content_encodings)
  ------------------
  |  Branch (1013:9): [True: 1.74k, False: 42.0k]
  ------------------
 1014|  1.74k|        parse_trackencodings(demuxer, track, &entry->content_encodings);
 1015|       |
 1016|  43.7k|    if (entry->n_codec_delay)
  ------------------
  |  Branch (1016:9): [True: 1, False: 43.7k]
  ------------------
 1017|      1|        track->codec_delay = entry->codec_delay / 1e9;
 1018|       |
 1019|  43.7k|    if (entry->n_block_addition_mapping) {
  ------------------
  |  Branch (1019:9): [True: 1, False: 43.7k]
  ------------------
 1020|      1|        parse_block_addition_mapping(demuxer, track,
 1021|      1|                                     entry->block_addition_mapping,
 1022|      1|                                     entry->n_block_addition_mapping);
 1023|      1|    }
 1024|       |
 1025|  43.7k|    mkv_d->tracks[mkv_d->num_tracks++] = track;
 1026|  43.7k|}
demux_mkv.c:parse_trackaudio:
  584|  15.2k|{
  585|  15.2k|    if (audio->n_sampling_frequency && valid_samplerate(audio->sampling_frequency)) {
  ------------------
  |  Branch (585:9): [True: 13.5k, False: 1.74k]
  |  Branch (585:40): [True: 13.4k, False: 52]
  ------------------
  586|  13.4k|        track->a_sfreq = audio->sampling_frequency;
  587|  13.4k|        MP_DBG(demuxer, "|   + Sampling frequency: %f\n", track->a_sfreq);
  ------------------
  |  |   93|  13.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  13.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  588|  13.4k|    } else {
  589|  1.79k|        track->a_sfreq = 8000;
  590|  1.79k|    }
  591|  15.2k|    if (audio->n_output_sampling_frequency && valid_samplerate(audio->output_sampling_frequency)) {
  ------------------
  |  Branch (591:9): [True: 1.03k, False: 14.2k]
  |  Branch (591:47): [True: 1.03k, False: 2]
  ------------------
  592|  1.03k|        track->a_osfreq = audio->output_sampling_frequency;
  593|  1.03k|        MP_DBG(demuxer, "|   + Output sampling frequency: %f\n", track->a_osfreq);
  ------------------
  |  |   93|  1.03k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.03k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  594|  14.2k|    } else {
  595|  14.2k|        track->a_osfreq = track->a_sfreq;
  596|  14.2k|    }
  597|  15.2k|    if (audio->n_bit_depth) {
  ------------------
  |  Branch (597:9): [True: 1.48k, False: 13.7k]
  ------------------
  598|  1.48k|        track->a_bps = audio->bit_depth;
  599|  1.48k|        MP_DBG(demuxer, "|   + Bit depth: %"PRIu32"\n", track->a_bps);
  ------------------
  |  |   93|  1.48k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.48k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  600|  1.48k|    }
  601|  15.2k|    if (audio->n_channels) {
  ------------------
  |  Branch (601:9): [True: 13.8k, False: 1.40k]
  ------------------
  602|  13.8k|        track->a_channels = audio->channels;
  603|  13.8k|        MP_DBG(demuxer, "|   + Channels: %"PRIu32"\n", track->a_channels);
  ------------------
  |  |   93|  13.8k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  13.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  604|  13.8k|    } else {
  605|  1.40k|        track->a_channels = 1;
  606|  1.40k|    }
  607|  15.2k|}
demux_mkv.c:valid_samplerate:
  578|  14.5k|{
  579|  14.5k|    return rate > 0 && rate <= INT_MAX;
  ------------------
  |  Branch (579:12): [True: 14.5k, False: 38]
  |  Branch (579:24): [True: 14.5k, False: 16]
  ------------------
  580|  14.5k|}
demux_mkv.c:parse_trackvideo:
  742|  14.6k|{
  743|  14.6k|    if (video->n_frame_rate) {
  ------------------
  |  Branch (743:9): [True: 193, False: 14.4k]
  ------------------
  744|    193|        MP_DBG(demuxer, "|   + Frame rate: %f (ignored)\n", video->frame_rate);
  ------------------
  |  |   93|    193|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    193|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  745|    193|    }
  746|  14.6k|    if (video->n_display_width) {
  ------------------
  |  Branch (746:9): [True: 12.4k, False: 2.22k]
  ------------------
  747|  12.4k|        track->v_dwidth = video->display_width;
  748|  12.4k|        track->v_dwidth_set = true;
  749|  12.4k|        MP_DBG(demuxer, "|   + Display width: %"PRIu32"\n", track->v_dwidth);
  ------------------
  |  |   93|  12.4k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  750|  12.4k|    }
  751|  14.6k|    if (video->n_display_height) {
  ------------------
  |  Branch (751:9): [True: 11.6k, False: 2.99k]
  ------------------
  752|  11.6k|        track->v_dheight = video->display_height;
  753|  11.6k|        track->v_dheight_set = true;
  754|  11.6k|        MP_DBG(demuxer, "|   + Display height: %"PRIu32"\n", track->v_dheight);
  ------------------
  |  |   93|  11.6k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  755|  11.6k|    }
  756|  14.6k|    if (video->n_pixel_width) {
  ------------------
  |  Branch (756:9): [True: 13.5k, False: 1.11k]
  ------------------
  757|  13.5k|        track->v_width = video->pixel_width;
  758|  13.5k|        MP_DBG(demuxer, "|   + Pixel width: %"PRIu32"\n", track->v_width);
  ------------------
  |  |   93|  13.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  13.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  759|  13.5k|    }
  760|  14.6k|    if (video->n_pixel_height) {
  ------------------
  |  Branch (760:9): [True: 13.6k, False: 990]
  ------------------
  761|  13.6k|        track->v_height = video->pixel_height;
  762|  13.6k|        MP_DBG(demuxer, "|   + Pixel height: %"PRIu32"\n", track->v_height);
  ------------------
  |  |   93|  13.6k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  13.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  763|  13.6k|    }
  764|  14.6k|    if (video->n_colour_space) {
  ------------------
  |  Branch (764:9): [True: 26, False: 14.6k]
  ------------------
  765|     26|        uint8_t *d = (uint8_t *)&video->colour_space.start[0];
  766|     26|        track->colorspace = d[0] | ((uint32_t)d[1] << 8) | ((uint32_t)d[2] << 16) | ((uint32_t)d[3] << 24);
  767|     26|        MP_DBG(demuxer, "|   + Colorspace: %#"PRIx32"\n", track->colorspace);
  ------------------
  |  |   93|     26|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     26|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  768|     26|    }
  769|  14.6k|    if (video->n_stereo_mode) {
  ------------------
  |  Branch (769:9): [True: 2, False: 14.6k]
  ------------------
  770|      2|        const char *name = MP_STEREO3D_NAME_DEF(video->stereo_mode, NULL);
  ------------------
  |  |   75|      2|#define MP_STEREO3D_NAME_DEF(x, def) m_opt_choice_str_def(mp_stereo3d_names, x, def)
  ------------------
  771|      2|        if (name) {
  ------------------
  |  Branch (771:13): [True: 0, False: 2]
  ------------------
  772|      0|            track->stereo_mode = video->stereo_mode;
  773|      0|            MP_DBG(demuxer, "|   + StereoMode: %s\n", name);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  774|      2|        } else {
  775|      2|            MP_WARN(demuxer, "Unknown StereoMode: %"PRIu64"\n",
  ------------------
  |  |   90|      2|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  776|      2|                    video->stereo_mode);
  777|      2|        }
  778|      2|    }
  779|  14.6k|    if (video->n_pixel_crop_top) {
  ------------------
  |  Branch (779:9): [True: 396, False: 14.2k]
  ------------------
  780|    396|        track->v_crop_top = video->pixel_crop_top;
  781|    396|        MP_DBG(demuxer, "|   + Crop top: %"PRIu32"\n", track->v_crop_top);
  ------------------
  |  |   93|    396|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    396|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  782|    396|    }
  783|  14.6k|    if (video->n_pixel_crop_left) {
  ------------------
  |  Branch (783:9): [True: 396, False: 14.2k]
  ------------------
  784|    396|        track->v_crop_left = video->pixel_crop_left;
  785|    396|        MP_DBG(demuxer, "|   + Crop left: %"PRIu32"\n", track->v_crop_left);
  ------------------
  |  |   93|    396|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    396|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  786|    396|    }
  787|  14.6k|    if (video->n_pixel_crop_right) {
  ------------------
  |  Branch (787:9): [True: 396, False: 14.2k]
  ------------------
  788|    396|        track->v_crop_right = video->pixel_crop_right;
  789|    396|        MP_DBG(demuxer, "|   + Crop right: %"PRIu32"\n", track->v_crop_right);
  ------------------
  |  |   93|    396|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    396|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  790|    396|    }
  791|  14.6k|    if (video->n_pixel_crop_bottom) {
  ------------------
  |  Branch (791:9): [True: 399, False: 14.2k]
  ------------------
  792|    399|        track->v_crop_bottom = video->pixel_crop_bottom;
  793|    399|        MP_DBG(demuxer, "|   + Crop bottom: %"PRIu32"\n", track->v_crop_bottom);
  ------------------
  |  |   93|    399|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    399|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  794|    399|    }
  795|  14.6k|    if (video->n_colour)
  ------------------
  |  Branch (795:9): [True: 190, False: 14.4k]
  ------------------
  796|    190|        parse_trackcolour(demuxer, track, &video->colour);
  797|  14.6k|    if (video->n_projection)
  ------------------
  |  Branch (797:9): [True: 2, False: 14.6k]
  ------------------
  798|      2|        parse_trackprojection(demuxer, track, &video->projection);
  799|  14.6k|}
demux_mkv.c:parse_trackcolour:
  626|    190|{
  627|       |    // Note: As per matroska spec, the order is consistent with ISO/IEC
  628|       |    // 23001-8:2013/DCOR1, which is the same order used by libavutil/pixfmt.h,
  629|       |    // so we can just reuse our avcol_ conversion functions.
  630|    190|    if (colour->n_matrix_coefficients) {
  ------------------
  |  Branch (630:9): [True: 138, False: 52]
  ------------------
  631|    138|        track->repr.sys = pl_system_from_av(colour->matrix_coefficients);
  632|    138|        MP_DBG(demuxer, "|    + Matrix: %s\n",
  ------------------
  |  |   93|    138|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    138|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  633|    138|                   m_opt_choice_str(pl_csp_names, track->repr.sys));
  634|    138|    }
  635|    190|    if (colour->n_chroma_siting_horz && colour->n_chroma_siting_vert) {
  ------------------
  |  Branch (635:9): [True: 26, False: 164]
  |  Branch (635:41): [True: 25, False: 1]
  ------------------
  636|     25|        track->chroma_location = chroma_location_from_pos(demuxer,
  637|     25|                                                          colour->chroma_siting_horz,
  638|     25|                                                          colour->chroma_siting_vert);
  639|     25|        MP_DBG(demuxer, "|    + ChromaLocation: %s\n",
  ------------------
  |  |   93|     25|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     25|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  640|     25|                   m_opt_choice_str(pl_chroma_names, track->chroma_location));
  641|     25|    }
  642|    190|    if (colour->n_primaries) {
  ------------------
  |  Branch (642:9): [True: 88, False: 102]
  ------------------
  643|     88|        track->color.primaries = pl_primaries_from_av(colour->primaries);
  644|     88|        MP_DBG(demuxer, "|    + Primaries: %s\n",
  ------------------
  |  |   93|     88|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     88|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  645|     88|                   m_opt_choice_str(pl_csp_prim_names, track->color.primaries));
  646|     88|    }
  647|    190|    if (colour->n_transfer_characteristics) {
  ------------------
  |  Branch (647:9): [True: 91, False: 99]
  ------------------
  648|     91|        track->color.transfer = pl_transfer_from_av(colour->transfer_characteristics);
  649|     91|        MP_DBG(demuxer, "|    + Gamma: %s\n",
  ------------------
  |  |   93|     91|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     91|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  650|     91|                   m_opt_choice_str(pl_csp_trc_names, track->color.transfer));
  651|     91|    }
  652|    190|    if (colour->n_range) {
  ------------------
  |  Branch (652:9): [True: 134, False: 56]
  ------------------
  653|    134|        track->repr.levels = pl_levels_from_av(colour->range);
  654|    134|        MP_DBG(demuxer, "|    + Levels: %s\n",
  ------------------
  |  |   93|    134|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    134|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  655|    134|                   m_opt_choice_str(pl_csp_levels_names, track->repr.levels));
  656|    134|    }
  657|    190|    if (colour->n_max_cll) {
  ------------------
  |  Branch (657:9): [True: 88, False: 102]
  ------------------
  658|     88|        track->color.hdr.max_cll = colour->max_cll;
  659|     88|        MP_DBG(demuxer, "|    + MaxCLL: %"PRIu64"\n", colour->max_cll);
  ------------------
  |  |   93|     88|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     88|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  660|     88|    }
  661|    190|    if (colour->n_max_fall) {
  ------------------
  |  Branch (661:9): [True: 72, False: 118]
  ------------------
  662|     72|        track->color.hdr.max_fall = colour->max_fall;
  663|     72|        MP_DBG(demuxer, "|    + MaxFALL: %"PRIu64"\n", colour->max_cll);
  ------------------
  |  |   93|     72|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     72|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  664|     72|    }
  665|    190|    if (colour->n_mastering_metadata) {
  ------------------
  |  Branch (665:9): [True: 65, False: 125]
  ------------------
  666|     65|        struct ebml_mastering_metadata *mastering = &colour->mastering_metadata;
  667|       |
  668|     65|        if (mastering->n_primary_r_chromaticity_x) {
  ------------------
  |  Branch (668:13): [True: 62, False: 3]
  ------------------
  669|     62|            track->color.hdr.prim.red.x = mastering->primary_r_chromaticity_x;
  670|     62|            MP_DBG(demuxer, "|    + PrimaryRChromaticityX: %f\n", track->color.hdr.prim.red.x);
  ------------------
  |  |   93|     62|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     62|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  671|     62|        }
  672|     65|        if (mastering->n_primary_r_chromaticity_y) {
  ------------------
  |  Branch (672:13): [True: 61, False: 4]
  ------------------
  673|     61|            track->color.hdr.prim.red.y = mastering->primary_r_chromaticity_y;
  674|     61|            MP_DBG(demuxer, "|    + PrimaryRChromaticityY: %f\n", track->color.hdr.prim.red.y);
  ------------------
  |  |   93|     61|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     61|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  675|     61|        }
  676|     65|        if (mastering->n_primary_g_chromaticity_x) {
  ------------------
  |  Branch (676:13): [True: 46, False: 19]
  ------------------
  677|     46|            track->color.hdr.prim.green.x = mastering->primary_g_chromaticity_x;
  678|     46|            MP_DBG(demuxer, "|    + PrimaryGChromaticityX: %f\n", track->color.hdr.prim.green.x);
  ------------------
  |  |   93|     46|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     46|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  679|     46|        }
  680|     65|        if (mastering->n_primary_g_chromaticity_y) {
  ------------------
  |  Branch (680:13): [True: 45, False: 20]
  ------------------
  681|     45|            track->color.hdr.prim.green.y = mastering->primary_g_chromaticity_y;
  682|     45|            MP_DBG(demuxer, "|    + PrimaryGChromaticityY: %f\n", track->color.hdr.prim.green.y);
  ------------------
  |  |   93|     45|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     45|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  683|     45|        }
  684|     65|        if (mastering->n_primary_b_chromaticity_x) {
  ------------------
  |  Branch (684:13): [True: 46, False: 19]
  ------------------
  685|     46|            track->color.hdr.prim.blue.x = mastering->primary_b_chromaticity_x;
  686|     46|            MP_DBG(demuxer, "|    + PrimaryBChromaticityX: %f\n", track->color.hdr.prim.blue.x);
  ------------------
  |  |   93|     46|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     46|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  687|     46|        }
  688|     65|        if (mastering->n_primary_b_chromaticity_y) {
  ------------------
  |  Branch (688:13): [True: 45, False: 20]
  ------------------
  689|     45|            track->color.hdr.prim.blue.y = mastering->primary_b_chromaticity_y;
  690|     45|            MP_DBG(demuxer, "|    + PrimaryBChromaticityY: %f\n", track->color.hdr.prim.blue.y);
  ------------------
  |  |   93|     45|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     45|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  691|     45|        }
  692|     65|        if (mastering->n_white_point_chromaticity_x) {
  ------------------
  |  Branch (692:13): [True: 1, False: 64]
  ------------------
  693|      1|            track->color.hdr.prim.white.x = mastering->white_point_chromaticity_x;
  694|      1|            MP_DBG(demuxer, "|    + WhitePointChromaticityX: %f\n", track->color.hdr.prim.white.x);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  695|      1|        }
  696|     65|        if (mastering->n_white_point_chromaticity_y) {
  ------------------
  |  Branch (696:13): [True: 1, False: 64]
  ------------------
  697|      1|            track->color.hdr.prim.white.y = mastering->white_point_chromaticity_y;
  698|      1|            MP_DBG(demuxer, "|    + WhitePointChromaticityY: %f\n", track->color.hdr.prim.white.y);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  699|      1|        }
  700|     65|        if (mastering->n_luminance_min) {
  ------------------
  |  Branch (700:13): [True: 1, False: 64]
  ------------------
  701|      1|            track->color.hdr.min_luma = mastering->luminance_min;
  702|      1|            MP_DBG(demuxer, "|    + LuminanceMin: %f\n", track->color.hdr.min_luma);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  703|      1|        }
  704|     65|        if (mastering->n_luminance_max) {
  ------------------
  |  Branch (704:13): [True: 1, False: 64]
  ------------------
  705|      1|            track->color.hdr.max_luma = mastering->luminance_max;
  706|      1|            MP_DBG(demuxer, "|    + LuminanceMax: %f\n", track->color.hdr.max_luma);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  707|      1|        }
  708|     65|    }
  709|    190|}
demux_mkv.c:chroma_location_from_pos:
  611|     25|{
  612|     25|    if (h > 2 || v > 2) {
  ------------------
  |  Branch (612:9): [True: 0, False: 25]
  |  Branch (612:18): [True: 0, False: 25]
  ------------------
  613|      0|        MP_WARN(demuxer, "Invalid chroma location: %"PRIu64", %"PRIu64"\n", h, v);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  614|      0|        return PL_CHROMA_UNKNOWN;
  615|      0|    }
  616|     25|    static const enum pl_chroma_location map[3][3] = {
  617|     25|        { PL_CHROMA_UNKNOWN, PL_CHROMA_UNKNOWN, PL_CHROMA_UNKNOWN },
  618|     25|        { PL_CHROMA_UNKNOWN, PL_CHROMA_TOP_LEFT, PL_CHROMA_LEFT },
  619|     25|        { PL_CHROMA_UNKNOWN, PL_CHROMA_TOP_CENTER, PL_CHROMA_CENTER },
  620|     25|    };
  621|     25|    return map[h][v];
  622|     25|}
demux_mkv.c:parse_trackprojection:
  713|      2|{
  714|      2|    if (projection->n_projection_pose_yaw) {
  ------------------
  |  Branch (714:9): [True: 1, False: 1]
  ------------------
  715|      1|        track->v_projection_pose_yaw = projection->projection_pose_yaw;
  716|      1|        MP_DBG(demuxer, "|   + Projection pose yaw: %f\n",
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  717|      1|               track->v_projection_pose_yaw);
  718|      1|    }
  719|       |
  720|      2|    if (projection->n_projection_pose_pitch) {
  ------------------
  |  Branch (720:9): [True: 0, False: 2]
  ------------------
  721|      0|        track->v_projection_pose_pitch = projection->projection_pose_pitch;
  722|      0|        MP_DBG(demuxer, "|   + Projection pose pitch: %f\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__)
  |  |  ------------------
  ------------------
  723|      0|               track->v_projection_pose_pitch);
  724|      0|    }
  725|       |
  726|      2|    if (projection->n_projection_pose_roll) {
  ------------------
  |  Branch (726:9): [True: 1, False: 1]
  ------------------
  727|      1|        track->v_projection_pose_roll = projection->projection_pose_roll;
  728|      1|        MP_DBG(demuxer, "|   + Projection pose roll: %f\n",
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  729|      1|               track->v_projection_pose_roll);
  730|      1|    }
  731|       |
  732|      2|    if (track->v_projection_pose_yaw || track->v_projection_pose_pitch) {
  ------------------
  |  Branch (732:9): [True: 1, False: 1]
  |  Branch (732:41): [True: 0, False: 1]
  ------------------
  733|      1|        MP_WARN(demuxer, "Not supported projection: yaw %f, pitch %f, roll %f\n",
  ------------------
  |  |   90|      1|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  734|      1|                track->v_projection_pose_yaw,
  735|      1|                track->v_projection_pose_pitch,
  736|      1|                track->v_projection_pose_roll);
  737|      1|    }
  738|      2|}
demux_mkv.c:parse_trackencodings:
  513|  1.74k|{
  514|       |    // initial allocation to be a non-NULL context before realloc
  515|  1.74k|    mkv_content_encoding_t *ce = talloc_size(track, 1);
  ------------------
  |  |   43|  1.74k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  1.74k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  1.74k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.74k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.74k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.74k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|       |
  517|  3.47k|    for (int n_enc = 0; n_enc < encodings->n_content_encoding; n_enc++) {
  ------------------
  |  Branch (517:25): [True: 1.72k, False: 1.74k]
  ------------------
  518|  1.72k|        struct ebml_content_encoding *enc = encodings->content_encoding + n_enc;
  519|  1.72k|        struct mkv_content_encoding e = {0};
  520|  1.72k|        e.order = enc->content_encoding_order;
  521|  1.72k|        if (enc->n_content_encoding_scope)
  ------------------
  |  Branch (521:13): [True: 447, False: 1.28k]
  ------------------
  522|    447|            e.scope = enc->content_encoding_scope;
  523|  1.28k|        else
  524|  1.28k|            e.scope = 1;
  525|  1.72k|        e.type = enc->content_encoding_type;
  526|       |
  527|  1.72k|        if (enc->n_content_compression) {
  ------------------
  |  Branch (527:13): [True: 1.66k, False: 60]
  ------------------
  528|  1.66k|            struct ebml_content_compression *z = &enc->content_compression;
  529|  1.66k|            e.comp_algo = z->content_comp_algo;
  530|  1.66k|            if (z->n_content_comp_settings) {
  ------------------
  |  Branch (530:17): [True: 1.12k, False: 544]
  ------------------
  531|  1.12k|                int sz = z->content_comp_settings.len;
  532|  1.12k|                e.comp_settings = talloc_size(ce, sz);
  ------------------
  |  |   43|  1.12k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  1.12k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  1.12k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.12k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.12k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.12k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  533|  1.12k|                memcpy(e.comp_settings, z->content_comp_settings.start, sz);
  534|  1.12k|                e.comp_settings_len = sz;
  535|  1.12k|            }
  536|  1.66k|        }
  537|       |
  538|  1.72k|        if (e.type == 1) {
  ------------------
  |  Branch (538:13): [True: 0, False: 1.72k]
  ------------------
  539|      0|            MP_WARN(demuxer, "Track "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  540|      0|                    "number %d has been encrypted and "
  541|      0|                    "decryption has not yet been\n"
  542|      0|                    "implemented. Skipping track.\n",
  543|      0|                    track->tnum);
  544|  1.72k|        } else if (e.type != 0) {
  ------------------
  |  Branch (544:20): [True: 1, False: 1.72k]
  ------------------
  545|      1|            MP_WARN(demuxer, "Unknown content encoding type for "
  ------------------
  |  |   90|      1|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  546|      1|                    "track %u. Skipping track.\n",
  547|      1|                    track->tnum);
  548|  1.72k|        } else if (e.comp_algo != 0 && e.comp_algo != 2 && e.comp_algo != 3) {
  ------------------
  |  Branch (548:20): [True: 1.15k, False: 575]
  |  Branch (548:40): [True: 1.07k, False: 77]
  |  Branch (548:60): [True: 14, False: 1.06k]
  ------------------
  549|     14|            MP_WARN(demuxer, "Track %d has been compressed with "
  ------------------
  |  |   90|     14|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     14|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  550|     14|                    "an unknown/unsupported compression\n"
  551|     14|                    "algorithm (%"PRIu64"). Skipping track.\n",
  552|     14|                    track->tnum, e.comp_algo);
  553|     14|        }
  554|  1.71k|#if !HAVE_ZLIB
  555|  1.71k|        else if (e.comp_algo == 0) {
  ------------------
  |  Branch (555:18): [True: 575, False: 1.13k]
  ------------------
  556|    575|            MP_WARN(demuxer, "Track %d was compressed with zlib "
  ------------------
  |  |   90|    575|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    575|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  557|    575|                    "but mpv has not been compiled\n"
  558|    575|                    "with support for zlib compression. "
  559|    575|                    "Skipping track.\n",
  560|    575|                    track->tnum);
  561|    575|        }
  562|  1.72k|#endif
  563|  1.72k|        int i;
  564|  1.72k|        for (i = 0; i < n_enc; i++) {
  ------------------
  |  Branch (564:21): [True: 0, False: 1.72k]
  ------------------
  565|      0|            if (e.order >= ce[i].order)
  ------------------
  |  Branch (565:17): [True: 0, False: 0]
  ------------------
  566|      0|                break;
  567|      0|        }
  568|  1.72k|        ce = talloc_realloc(track, ce, mkv_content_encoding_t, n_enc + 1);
  ------------------
  |  |   33|  1.72k|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  1.72k|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  1.72k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.72k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.72k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.72k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|  1.72k|        memmove(ce + i + 1, ce + i, (n_enc - i) * sizeof(*ce));
  570|  1.72k|        memcpy(ce + i, &e, sizeof(e));
  571|  1.72k|    }
  572|       |
  573|  1.74k|    track->encodings = ce;
  574|  1.74k|    track->num_encodings = encodings->n_content_encoding;
  575|  1.74k|}
demux_mkv.c:parse_block_addition_mapping:
  850|      1|{
  851|      2|    for (int i = 0; i < count; ++i) {
  ------------------
  |  Branch (851:21): [True: 1, False: 1]
  ------------------
  852|      1|        if (!block_addition_mapping->n_block_add_id_type)
  ------------------
  |  Branch (852:13): [True: 1, False: 0]
  ------------------
  853|      1|            continue;
  854|      0|        switch (block_addition_mapping->block_add_id_type) {
  855|      0|        case MATROSKA_BLOCK_ADD_ID_TYPE_ITU_T_T35:
  ------------------
  |  |   89|      0|#define MATROSKA_BLOCK_ADD_ID_TYPE_ITU_T_T35 4
  ------------------
  |  Branch (855:9): [True: 0, False: 0]
  ------------------
  856|      0|        break;
  857|      0|        case MKBETAG('h','v','c','E'):
  ------------------
  |  Branch (857:9): [True: 0, False: 0]
  ------------------
  858|      0|            if (block_addition_mapping->n_block_add_id_extra_data)
  ------------------
  |  Branch (858:17): [True: 0, False: 0]
  ------------------
  859|      0|                track->hvce = bstrdup(track, block_addition_mapping->block_add_id_extra_data);
  860|      0|        break;
  861|      0|        case MKBETAG('a','v','c','E'):
  ------------------
  |  Branch (861:9): [True: 0, False: 0]
  ------------------
  862|      0|            MP_WARN(demuxer, "Dolby Vision enhancement-layer playback for AVC "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  863|      0|                    "is not supported.\n");
  864|      0|        break;
  865|      0|        case MKBETAG('d','v','c','C'):
  ------------------
  |  Branch (865:9): [True: 0, False: 0]
  ------------------
  866|      0|        case MKBETAG('d','v','v','C'):
  ------------------
  |  Branch (866:9): [True: 0, False: 0]
  ------------------
  867|      0|            if (block_addition_mapping->n_block_add_id_extra_data) {
  ------------------
  |  Branch (867:17): [True: 0, False: 0]
  ------------------
  868|      0|                bstr data = block_addition_mapping->block_add_id_extra_data;
  869|      0|                parse_dovi_config(demuxer, track, data.start, data.len);
  870|      0|            }
  871|      0|        break;
  872|      0|        case MKBETAG('m','v','c','C'):
  ------------------
  |  Branch (872:9): [True: 0, False: 0]
  ------------------
  873|      0|            MP_WARN(demuxer, "MVC configuration is not supported.\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__)
  |  |  ------------------
  ------------------
  874|      0|        break;
  875|      0|        default:
  ------------------
  |  Branch (875:9): [True: 0, False: 0]
  ------------------
  876|      0|            MP_WARN(demuxer, "Unsupported block addition type: %" PRIx64 "\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__)
  |  |  ------------------
  ------------------
  877|      0|                    block_addition_mapping->block_add_id_type);
  878|      0|        }
  879|      0|        block_addition_mapping++;
  880|      0|    }
  881|      1|}
demux_mkv.c:demux_mkv_read_cues:
 1089|    204|{
 1090|    204|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1091|    204|    stream_t *s = demuxer->stream;
 1092|       |
 1093|    204|    if (demuxer->opts->index_mode != 1 || mkv_d->index_complete) {
  ------------------
  |  Branch (1093:9): [True: 0, False: 204]
  |  Branch (1093:43): [True: 0, False: 204]
  ------------------
 1094|      0|        ebml_read_skip(demuxer->log, -1, s);
 1095|      0|        return 0;
 1096|      0|    }
 1097|       |
 1098|    204|    MP_VERBOSE(demuxer, "Parsing cues...\n");
  ------------------
  |  |   92|    204|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    204|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1099|    204|    struct ebml_cues cues = {0};
 1100|    204|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1101|    204|    if (ebml_read_element(s, &parse_ctx, &cues, &ebml_cues_desc) < 0)
  ------------------
  |  Branch (1101:9): [True: 2, False: 202]
  ------------------
 1102|      2|        return -1;
 1103|       |
 1104|  28.6k|    for (int i = 0; i < cues.n_cue_point; i++) {
  ------------------
  |  Branch (1104:21): [True: 28.5k, False: 50]
  ------------------
 1105|  28.5k|        struct ebml_cue_point *cuepoint = &cues.cue_point[i];
 1106|  28.5k|        if (cuepoint->n_cue_time != 1 || !cuepoint->n_cue_track_positions) {
  ------------------
  |  Branch (1106:13): [True: 138, False: 28.4k]
  |  Branch (1106:42): [True: 12, False: 28.4k]
  ------------------
 1107|    150|            MP_WARN(demuxer, "Malformed CuePoint element\n");
  ------------------
  |  |   90|    150|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    150|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1108|    150|            goto done;
 1109|    150|        }
 1110|  28.4k|        if (cuepoint->cue_time / 1e9 > mkv_d->duration / mkv_d->tc_scale * 10 &&
  ------------------
  |  Branch (1110:13): [True: 25.5k, False: 2.88k]
  ------------------
 1111|  25.5k|            mkv_d->duration != 0)
  ------------------
  |  Branch (1111:13): [True: 2, False: 25.5k]
  ------------------
 1112|      2|            goto done;
 1113|  28.4k|    }
 1114|     50|    if (cues.n_cue_point <= 3) // probably too sparse and will just break seeking
  ------------------
  |  Branch (1114:9): [True: 4, False: 46]
  ------------------
 1115|      4|        goto done;
 1116|       |
 1117|       |    // Discard incremental index.
 1118|     46|    mkv_d->num_indexes = 0;
 1119|     46|    mkv_d->index_has_durations = false;
 1120|       |
 1121|  6.50k|    for (int i = 0; i < cues.n_cue_point; i++) {
  ------------------
  |  Branch (1121:21): [True: 6.46k, False: 46]
  ------------------
 1122|  6.46k|        struct ebml_cue_point *cuepoint = &cues.cue_point[i];
 1123|  6.46k|        uint64_t time = cuepoint->cue_time;
 1124|  12.9k|        for (int c = 0; c < cuepoint->n_cue_track_positions; c++) {
  ------------------
  |  Branch (1124:25): [True: 6.50k, False: 6.46k]
  ------------------
 1125|  6.50k|            struct ebml_cue_track_positions *trackpos =
 1126|  6.50k|                &cuepoint->cue_track_positions[c];
 1127|  6.50k|            uint64_t pos = mkv_d->segment_start + trackpos->cue_cluster_position;
 1128|  6.50k|            cue_index_add(demuxer, trackpos->cue_track, pos,
 1129|  6.50k|                          time, trackpos->cue_duration);
 1130|  6.50k|            mkv_d->index_has_durations |= trackpos->n_cue_duration > 0;
 1131|  6.50k|            MP_TRACE(demuxer, "|+ found cue point for track %"PRIu64": "
  ------------------
  |  |   94|  6.50k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.50k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1132|  6.50k|                     "timecode %"PRIu64", filepos: %"PRIu64" "
 1133|  6.50k|                     "offset %"PRIu64", duration %"PRIu64"\n",
 1134|  6.50k|                     trackpos->cue_track, time, pos,
 1135|  6.50k|                     trackpos->cue_relative_position, trackpos->cue_duration);
 1136|  6.50k|        }
 1137|  6.46k|    }
 1138|       |
 1139|       |    // Do not attempt to create index on the fly.
 1140|     46|    mkv_d->index_complete = true;
 1141|       |
 1142|    202|done:
 1143|    202|    if (!mkv_d->index_complete)
  ------------------
  |  Branch (1143:9): [True: 156, False: 46]
  ------------------
 1144|    202|        MP_WARN(demuxer, "Discarding potentially broken or useless index.\n");
  ------------------
  |  |   90|    156|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    156|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1145|    202|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    202|#define talloc_free                     ta_free
  ------------------
 1146|    202|    return 0;
 1147|     46|}
demux_mkv.c:cue_index_add:
 1052|  76.0k|{
 1053|  76.0k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1054|       |
 1055|  76.0k|    MP_TARRAY_GROW(mkv_d, mkv_d->indexes, mkv_d->num_indexes);
  ------------------
  |  |   96|  76.0k|    do {                                            \
  |  |   97|  76.0k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  76.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  76.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  76.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 26.3k, False: 49.7k]
  |  |  ------------------
  |  |   99|  76.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  26.3k|    do {                                                        \
  |  |  |  |   89|  26.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  26.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  26.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  26.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  26.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  26.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  26.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 26.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  76.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 76.0k]
  |  |  ------------------
  ------------------
 1056|       |
 1057|  76.0k|    mkv_d->indexes[mkv_d->num_indexes] = (mkv_index_t) {
 1058|  76.0k|        .tnum = track_id,
 1059|  76.0k|        .filepos = filepos,
 1060|  76.0k|        .timecode = timecode,
 1061|  76.0k|        .duration = duration,
 1062|  76.0k|    };
 1063|       |
 1064|  76.0k|    mkv_d->num_indexes++;
 1065|  76.0k|}
demux_mkv.c:demux_mkv_read_tags:
 1299|  6.86k|{
 1300|  6.86k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1301|  6.86k|    stream_t *s = demuxer->stream;
 1302|       |
 1303|  6.86k|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1304|  6.86k|    struct ebml_tags           tags = {0};
 1305|  6.86k|    if (ebml_read_element(s, &parse_ctx, &tags, &ebml_tags_desc) < 0)
  ------------------
  |  Branch (1305:9): [True: 3, False: 6.86k]
  ------------------
 1306|      3|        return -1;
 1307|       |
 1308|  6.86k|    mkv_d->tags = talloc_dup(mkv_d, &tags);
  ------------------
  |  |   48|  6.86k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  6.86k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.86k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1309|  6.86k|    talloc_steal(mkv_d->tags, parse_ctx.talloc_ctx);
  ------------------
  |  |   38|  6.86k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  6.86k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1310|  6.86k|    return 0;
 1311|  6.86k|}
demux_mkv.c:demux_mkv_read_seekhead:
 1449|  18.3k|{
 1450|  18.3k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1451|  18.3k|    struct stream *s = demuxer->stream;
 1452|  18.3k|    int res = 0;
 1453|  18.3k|    struct ebml_seek_head seekhead = {0};
 1454|  18.3k|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1455|       |
 1456|  18.3k|    MP_DBG(demuxer, "Parsing seek head...\n");
  ------------------
  |  |   93|  18.3k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1457|  18.3k|    if (ebml_read_element(s, &parse_ctx, &seekhead, &ebml_seek_head_desc) < 0) {
  ------------------
  |  Branch (1457:9): [True: 1, False: 18.3k]
  ------------------
 1458|      1|        res = -1;
 1459|      1|        goto out;
 1460|      1|    }
 1461|  94.2k|    for (int i = 0; i < seekhead.n_seek; i++) {
  ------------------
  |  Branch (1461:21): [True: 75.8k, False: 18.3k]
  ------------------
 1462|  75.8k|        struct ebml_seek *seek = &seekhead.seek[i];
 1463|  75.8k|        if (seek->n_seek_id != 1 || seek->n_seek_position != 1) {
  ------------------
  |  Branch (1463:13): [True: 3.56k, False: 72.2k]
  |  Branch (1463:37): [True: 4.24k, False: 68.0k]
  ------------------
 1464|  7.80k|            MP_WARN(demuxer, "Invalid SeekHead entry\n");
  ------------------
  |  |   90|  7.80k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.80k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1465|  7.80k|            continue;
 1466|  7.80k|        }
 1467|  68.0k|        uint64_t pos = seek->seek_position + mkv_d->segment_start;
 1468|  68.0k|        MP_TRACE(demuxer, "Element 0x%"PRIx32" at %"PRIu64".\n",
  ------------------
  |  |   94|  68.0k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  68.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1469|  68.0k|                 seek->seek_id, pos);
 1470|  68.0k|        get_header_element(demuxer, seek->seek_id, pos);
 1471|  68.0k|    }
 1472|  18.3k| out:
 1473|  18.3k|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  18.3k|#define talloc_free                     ta_free
  ------------------
 1474|  18.3k|    return res;
 1475|  18.3k|}
demux_mkv.c:demux_mkv_read_chapters:
 1150|    999|{
 1151|    999|    mkv_demuxer_t *mkv_d = demuxer->priv;
 1152|    999|    stream_t *s = demuxer->stream;
 1153|    999|    int wanted_edition = mkv_d->edition_id;
 1154|    999|    uint64_t wanted_edition_uid = demuxer->matroska_data.uid.edition;
 1155|       |
 1156|       |    /* A specific edition UID was requested; ignore the user option which is
 1157|       |     * only applicable to the top-level file. */
 1158|    999|    if (wanted_edition_uid)
  ------------------
  |  Branch (1158:9): [True: 0, False: 999]
  ------------------
 1159|      0|        wanted_edition = -1;
 1160|       |
 1161|    999|    MP_DBG(demuxer, "Parsing chapters...\n");
  ------------------
  |  |   93|    999|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    999|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1162|    999|    struct ebml_chapters file_chapters = {0};
 1163|    999|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1164|    999|    if (ebml_read_element(s, &parse_ctx, &file_chapters,
  ------------------
  |  Branch (1164:9): [True: 1, False: 998]
  ------------------
 1165|    999|                          &ebml_chapters_desc) < 0)
 1166|      1|        return -1;
 1167|       |
 1168|    998|    int selected_edition = -1;
 1169|    998|    int num_editions = file_chapters.n_edition_entry;
 1170|    998|    struct ebml_edition_entry *editions = file_chapters.edition_entry;
 1171|  2.24k|    for (int i = 0; i < num_editions; i++) {
  ------------------
  |  Branch (1171:21): [True: 1.25k, False: 998]
  ------------------
 1172|  1.25k|        struct demux_edition new = {
 1173|  1.25k|            .demuxer_id = editions[i].edition_uid,
 1174|  1.25k|            .default_edition = editions[i].edition_flag_default,
 1175|  1.25k|            .metadata = talloc_zero(demuxer, struct mp_tags),
  ------------------
  |  |   27|  1.25k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.25k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.25k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1176|  1.25k|        };
 1177|  1.25k|        MP_TARRAY_APPEND(demuxer, demuxer->editions, demuxer->num_editions, new);
  ------------------
  |  |  105|  1.25k|    do {                                            \
  |  |  106|  1.25k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  1.25k|    do {                                            \
  |  |  |  |   97|  1.25k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  1.25k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.25k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  1.25k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 981, False: 269]
  |  |  |  |  ------------------
  |  |  |  |   99|  1.25k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    981|    do {                                                        \
  |  |  |  |  |  |   89|    981|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    981|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    981|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    981|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    981|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    981|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    981|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 981]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  1.25k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  1.25k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  1.25k|        (idxvar)++;                                 \
  |  |  109|  1.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.25k]
  |  |  ------------------
  ------------------
 1178|  1.25k|    }
 1179|    998|    if (wanted_edition >= 0 && wanted_edition < num_editions) {
  ------------------
  |  Branch (1179:9): [True: 0, False: 998]
  |  Branch (1179:32): [True: 0, False: 0]
  ------------------
 1180|      0|        selected_edition = wanted_edition;
 1181|      0|        MP_VERBOSE(demuxer, "User-specified edition: %d\n", selected_edition);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1182|    998|    } else {
 1183|  1.87k|        for (int i = 0; i < num_editions; i++) {
  ------------------
  |  Branch (1183:25): [True: 1.25k, False: 627]
  ------------------
 1184|  1.25k|            if (wanted_edition_uid &&
  ------------------
  |  Branch (1184:17): [True: 0, False: 1.25k]
  ------------------
 1185|      0|                editions[i].edition_uid == wanted_edition_uid) {
  ------------------
  |  Branch (1185:17): [True: 0, False: 0]
  ------------------
 1186|      0|                selected_edition = i;
 1187|      0|                break;
 1188|  1.25k|            } else if (editions[i].edition_flag_default) {
  ------------------
  |  Branch (1188:24): [True: 371, False: 879]
  ------------------
 1189|    371|                selected_edition = i;
 1190|    371|                MP_VERBOSE(demuxer, "Default edition: %d\n", i);
  ------------------
  |  |   92|    371|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    371|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1191|    371|                break;
 1192|    371|            }
 1193|  1.25k|        }
 1194|    998|    }
 1195|    998|    if (selected_edition < 0) {
  ------------------
  |  Branch (1195:9): [True: 627, False: 371]
  ------------------
 1196|    627|        if (wanted_edition_uid) {
  ------------------
  |  Branch (1196:13): [True: 0, False: 627]
  ------------------
 1197|      0|            MP_ERR(demuxer, "Unable to find expected edition uid: %"PRIu64"\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__)
  |  |  ------------------
  ------------------
 1198|      0|                   wanted_edition_uid);
 1199|      0|            talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1200|      0|            return -1;
 1201|    627|        } else {
 1202|    627|            selected_edition = 0;
 1203|    627|        }
 1204|    627|    }
 1205|       |
 1206|  2.24k|    for (int idx = 0; idx < num_editions; idx++) {
  ------------------
  |  Branch (1206:23): [True: 1.25k, False: 998]
  ------------------
 1207|  1.25k|        MP_VERBOSE(demuxer, "New edition %d\n", idx);
  ------------------
  |  |   92|  1.25k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.25k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1208|  1.25k|        int warn_level = idx == selected_edition ? MSGL_WARN : MSGL_V;
  ------------------
  |  Branch (1208:26): [True: 981, False: 269]
  ------------------
 1209|  1.25k|        if (editions[idx].n_edition_flag_default)
  ------------------
  |  Branch (1209:13): [True: 935, False: 315]
  ------------------
 1210|  1.25k|            MP_VERBOSE(demuxer, "Default edition flag: %"PRIu64"\n",
  ------------------
  |  |   92|    935|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    935|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1211|  1.25k|                       editions[idx].edition_flag_default);
 1212|  1.25k|        if (editions[idx].n_edition_flag_ordered)
  ------------------
  |  Branch (1212:13): [True: 293, False: 957]
  ------------------
 1213|  1.25k|            MP_VERBOSE(demuxer, "Ordered chapter flag: %"PRIu64"\n",
  ------------------
  |  |   92|    293|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    293|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1214|  1.25k|                       editions[idx].edition_flag_ordered);
 1215|       |
 1216|  1.25k|        int chapter_count = editions[idx].n_chapter_atom;
 1217|       |
 1218|  1.25k|        struct matroska_chapter *m_chapters = NULL;
 1219|  1.25k|        if (idx == selected_edition && editions[idx].edition_flag_ordered) {
  ------------------
  |  Branch (1219:13): [True: 981, False: 269]
  |  Branch (1219:40): [True: 293, False: 688]
  ------------------
 1220|    293|            m_chapters = talloc_array_ptrtype(demuxer, m_chapters, chapter_count);
  ------------------
  |  |   36|    293|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|    293|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    293|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1221|    293|            demuxer->matroska_data.ordered_chapters = m_chapters;
 1222|    293|            demuxer->matroska_data.num_ordered_chapters = chapter_count;
 1223|    293|        }
 1224|       |
 1225|  6.95k|        for (int i = 0; i < chapter_count; i++) {
  ------------------
  |  Branch (1225:25): [True: 5.70k, False: 1.25k]
  ------------------
 1226|  5.70k|            struct ebml_chapter_atom *ca = editions[idx].chapter_atom + i;
 1227|  5.70k|            struct matroska_chapter chapter = {0};
 1228|  5.70k|            char *name = "(unnamed)";
 1229|       |
 1230|  5.70k|            chapter.start = ca->chapter_time_start;
 1231|  5.70k|            chapter.end = ca->chapter_time_end;
 1232|       |
 1233|  5.70k|            if (!ca->n_chapter_time_start)
  ------------------
  |  Branch (1233:17): [True: 66, False: 5.63k]
  ------------------
 1234|     66|                MP_MSG(demuxer, warn_level, "Chapter lacks start time\n");
  ------------------
  |  |   86|     66|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
 1235|  5.70k|            if (!ca->n_chapter_time_start || !ca->n_chapter_time_end) {
  ------------------
  |  Branch (1235:17): [True: 66, False: 5.63k]
  |  Branch (1235:46): [True: 3.75k, False: 1.87k]
  ------------------
 1236|  3.82k|                if (demuxer->matroska_data.ordered_chapters) {
  ------------------
  |  Branch (1236:21): [True: 7, False: 3.81k]
  ------------------
 1237|      7|                    MP_MSG(demuxer, warn_level, "Chapter lacks start or end "
  ------------------
  |  |   86|      7|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
 1238|      7|                           "time, disabling ordered chapters.\n");
 1239|      7|                    demuxer->matroska_data.ordered_chapters = NULL;
 1240|      7|                    demuxer->matroska_data.num_ordered_chapters = 0;
 1241|      7|                }
 1242|  3.82k|            }
 1243|       |
 1244|  5.70k|            if (ca->n_chapter_display) {
  ------------------
  |  Branch (1244:17): [True: 5.51k, False: 185]
  ------------------
 1245|  5.51k|                if (ca->n_chapter_display > 1)
  ------------------
  |  Branch (1245:21): [True: 1, False: 5.51k]
  ------------------
 1246|      1|                    MP_MSG(demuxer, warn_level, "Multiple chapter "
  ------------------
  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
 1247|  5.51k|                           "names not supported, picking first\n");
 1248|  5.51k|                if (!ca->chapter_display[0].chap_string)
  ------------------
  |  Branch (1248:21): [True: 78, False: 5.43k]
  ------------------
 1249|     78|                    MP_MSG(demuxer, warn_level, "Malformed chapter name entry\n");
  ------------------
  |  |   86|     78|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
 1250|  5.43k|                else
 1251|  5.43k|                    name = ca->chapter_display[0].chap_string;
 1252|  5.51k|            }
 1253|       |
 1254|  5.70k|            if (ca->n_chapter_segment_uid) {
  ------------------
  |  Branch (1254:17): [True: 0, False: 5.70k]
  ------------------
 1255|      0|                chapter.has_segment_uid = true;
 1256|      0|                int len = ca->chapter_segment_uid.len;
 1257|      0|                memcpy(chapter.uid.segment, ca->chapter_segment_uid.start, len);
 1258|      0|                if (ca->n_chapter_segment_edition_uid)
  ------------------
  |  Branch (1258:21): [True: 0, False: 0]
  ------------------
 1259|      0|                    chapter.uid.edition = ca->chapter_segment_edition_uid;
 1260|      0|                else
 1261|      0|                    chapter.uid.edition = 0;
 1262|      0|                MP_DBG(demuxer, "Chapter segment uid ");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1263|      0|                for (int n = 0; n < len; n++)
  ------------------
  |  Branch (1263:33): [True: 0, False: 0]
  ------------------
 1264|      0|                    MP_DBG(demuxer, "%02x ", chapter.uid.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__)
  |  |  ------------------
  ------------------
 1265|      0|                MP_DBG(demuxer, "\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__)
  |  |  ------------------
  ------------------
 1266|      0|            }
 1267|       |
 1268|  5.70k|            MP_DBG(demuxer, "Chapter %u from %02d:%02d:%02d.%09d "
  ------------------
  |  |   93|  5.70k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.70k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1269|  5.70k|                   "to %02d:%02d:%02d.%09d, %s\n", i,
 1270|  5.70k|                   (int) (chapter.start / 60 / 60 / 1000000000),
 1271|  5.70k|                   (int) ((chapter.start / 60 / 1000000000) % 60),
 1272|  5.70k|                   (int) ((chapter.start / 1000000000) % 60),
 1273|  5.70k|                   (int) (chapter.start % 1000000000),
 1274|  5.70k|                   (int) (chapter.end / 60 / 60 / 1000000000),
 1275|  5.70k|                   (int) ((chapter.end / 60 / 1000000000) % 60),
 1276|  5.70k|                   (int) ((chapter.end / 1000000000) % 60),
 1277|  5.70k|                   (int) (chapter.end % 1000000000),
 1278|  5.70k|                   name);
 1279|       |
 1280|  5.70k|            if (idx == selected_edition) {
  ------------------
  |  Branch (1280:17): [True: 3.91k, False: 1.78k]
  ------------------
 1281|  3.91k|                demuxer_add_chapter(demuxer, name, chapter.start / 1e9,
 1282|  3.91k|                                    ca->chapter_uid);
 1283|  3.91k|            }
 1284|  5.70k|            if (m_chapters) {
  ------------------
  |  Branch (1284:17): [True: 1.09k, False: 4.61k]
  ------------------
 1285|  1.09k|                chapter.name = talloc_strdup(m_chapters, name);
  ------------------
  |  |   50|  1.09k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1286|  1.09k|                m_chapters[i] = chapter;
 1287|  1.09k|            }
 1288|  5.70k|        }
 1289|  1.25k|    }
 1290|       |
 1291|    998|    demuxer->num_editions = num_editions;
 1292|    998|    demuxer->edition = selected_edition;
 1293|       |
 1294|    998|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    998|#define talloc_free                     ta_free
  ------------------
 1295|    998|    return 0;
 1296|    998|}
demux_mkv.c:demux_mkv_read_attachments:
 1378|    604|{
 1379|    604|    stream_t *s = demuxer->stream;
 1380|       |
 1381|    604|    MP_DBG(demuxer, "Parsing attachments...\n");
  ------------------
  |  |   93|    604|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    604|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1382|       |
 1383|    604|    struct ebml_attachments attachments = {0};
 1384|    604|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1385|    604|    if (ebml_read_element(s, &parse_ctx, &attachments,
  ------------------
  |  Branch (1385:9): [True: 1, False: 603]
  ------------------
 1386|    604|                          &ebml_attachments_desc) < 0)
 1387|      1|        return -1;
 1388|       |
 1389|  1.77k|    for (int i = 0; i < attachments.n_attached_file; i++) {
  ------------------
  |  Branch (1389:21): [True: 1.17k, False: 603]
  ------------------
 1390|  1.17k|        struct ebml_attached_file *attachment = &attachments.attached_file[i];
 1391|  1.17k|        if (!attachment->file_name || !attachment->file_mime_type
  ------------------
  |  Branch (1391:13): [True: 1, False: 1.17k]
  |  Branch (1391:39): [True: 2, False: 1.17k]
  ------------------
 1392|  1.17k|            || !attachment->n_file_data) {
  ------------------
  |  Branch (1392:16): [True: 38, False: 1.13k]
  ------------------
 1393|     41|            MP_WARN(demuxer, "Malformed attachment\n");
  ------------------
  |  |   90|     41|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     41|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1394|     41|            continue;
 1395|     41|        }
 1396|  1.13k|        char *name = attachment->file_name;
 1397|  1.13k|        char *mime = attachment->file_mime_type;
 1398|  1.13k|        demuxer_add_attachment(demuxer, name, mime, attachment->file_data.start,
 1399|  1.13k|                               attachment->file_data.len);
 1400|  1.13k|        MP_DBG(demuxer, "Attachment: %s, %s, %zu bytes\n",
  ------------------
  |  |   93|  1.13k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.13k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1401|  1.13k|               name, mime, attachment->file_data.len);
 1402|  1.13k|    }
 1403|       |
 1404|    603|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    603|#define talloc_free                     ta_free
  ------------------
 1405|    603|    return 0;
 1406|    604|}
demux_mkv.c:read_deferred_element:
 1509|  6.08k|{
 1510|  6.08k|    stream_t *s = demuxer->stream;
 1511|       |
 1512|  6.08k|    if (elem->parsed)
  ------------------
  |  Branch (1512:9): [True: 878, False: 5.20k]
  ------------------
 1513|    878|        return 0;
 1514|  5.20k|    elem->parsed = true;
 1515|  5.20k|    MP_VERBOSE(demuxer, "Seeking to %"PRIu64" to read header element "
  ------------------
  |  |   92|  5.20k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.20k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1516|  5.20k|               "0x%"PRIx32".\n",
 1517|  5.20k|               elem->pos, elem->id);
 1518|  5.20k|    if (!stream_seek(s, elem->pos)) {
  ------------------
  |  Branch (1518:9): [True: 0, False: 5.20k]
  ------------------
 1519|      0|        MP_WARN(demuxer, "Failed to seek when reading header element.\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__)
  |  |  ------------------
  ------------------
 1520|      0|        return 0;
 1521|      0|    }
 1522|  5.20k|    if (ebml_read_id(s) != elem->id) {
  ------------------
  |  Branch (1522:9): [True: 5.08k, False: 124]
  ------------------
 1523|  5.08k|        MP_ERR(demuxer, "Expected element 0x%"PRIx32" not found\n",
  ------------------
  |  |   89|  5.08k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.08k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1524|  5.08k|               elem->id);
 1525|  5.08k|        return 0;
 1526|  5.08k|    }
 1527|    124|    elem->parsed = false; // don't make read_header_element skip it
 1528|    124|    return read_header_element(demuxer, elem->id, elem->pos);
 1529|  5.20k|}
demux_mkv.c:display_create_tracks:
 1592|  24.2k|{
 1593|  24.2k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1594|       |
 1595|  68.0k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (1595:21): [True: 43.7k, False: 24.2k]
  ------------------
 1596|  43.7k|        switch (mkv_d->tracks[i]->type) {
  ------------------
  |  Branch (1596:17): [True: 42.0k, False: 1.76k]
  ------------------
 1597|  19.5k|        case MATROSKA_TRACK_VIDEO:
  ------------------
  |  |   78|  19.5k|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (1597:9): [True: 19.5k, False: 24.2k]
  ------------------
 1598|  19.5k|            demux_mkv_open_video(demuxer, mkv_d->tracks[i], i);
 1599|  19.5k|            break;
 1600|  17.3k|        case MATROSKA_TRACK_AUDIO:
  ------------------
  |  |   79|  17.3k|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (1600:9): [True: 17.3k, False: 26.4k]
  ------------------
 1601|  17.3k|            demux_mkv_open_audio(demuxer, mkv_d->tracks[i], i);
 1602|  17.3k|            break;
 1603|  5.10k|        case MATROSKA_TRACK_SUBTITLE:
  ------------------
  |  |   82|  5.10k|#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
  ------------------
  |  Branch (1603:9): [True: 5.10k, False: 38.6k]
  ------------------
 1604|  5.10k|            demux_mkv_open_sub(demuxer, mkv_d->tracks[i], i);
 1605|  5.10k|            break;
 1606|  43.7k|        }
 1607|  43.7k|    }
 1608|  24.2k|}
demux_mkv.c:demux_mkv_open_video:
 1641|  19.5k|{
 1642|  19.5k|    unsigned char *extradata = NULL;
 1643|  19.5k|    unsigned int extradata_size = 0;
 1644|  19.5k|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
 1645|  19.5k|    init_track(demuxer, track, sh, idx);
 1646|  19.5k|    struct mp_codec_params *sh_v = sh->codec;
 1647|       |
 1648|  19.5k|    sh_v->bits_per_coded_sample = 24;
 1649|       |
 1650|  19.5k|    if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")) { /* AVI compatibility mode */
  ------------------
  |  Branch (1650:9): [True: 7.36k, False: 12.1k]
  ------------------
 1651|       |        // The private_data contains a BITMAPINFOHEADER struct
 1652|  7.36k|        if (track->private_data == NULL || track->private_size < 40)
  ------------------
  |  Branch (1652:13): [True: 18, False: 7.34k]
  |  Branch (1652:44): [True: 1, False: 7.34k]
  ------------------
 1653|     19|            goto done;
 1654|       |
 1655|  7.34k|        unsigned char *h = track->private_data;
 1656|  7.34k|        if (track->v_width == 0)
  ------------------
  |  Branch (1656:13): [True: 3.52k, False: 3.82k]
  ------------------
 1657|  3.52k|            track->v_width = AV_RL32(h + 4);        // biWidth
 1658|  7.34k|        if (track->v_height == 0)
  ------------------
  |  Branch (1658:13): [True: 3.23k, False: 4.11k]
  ------------------
 1659|  3.23k|            track->v_height = AV_RL32(h + 8);       // biHeight
 1660|  7.34k|        sh_v->bits_per_coded_sample = AV_RL16(h + 14); // biBitCount
 1661|  7.34k|        sh_v->codec_tag = AV_RL32(h + 16);            // biCompression
 1662|       |
 1663|  7.34k|        extradata = track->private_data + 40;
 1664|  7.34k|        extradata_size = track->private_size - 40;
 1665|  7.34k|        mp_set_codec_from_tag(sh_v);
 1666|       |        // The DTS are the PTS if the codec does not reorder frames.
 1667|  7.34k|        const AVCodecDescriptor *desc = avcodec_descriptor_get(mp_codec_to_av_codec_id(sh_v->codec));
 1668|  7.34k|        track->block_dts = !desc || (desc->props & AV_CODEC_PROP_REORDER);
  ------------------
  |  Branch (1668:28): [True: 88, False: 7.25k]
  |  Branch (1668:37): [True: 5.28k, False: 1.97k]
  ------------------
 1669|  12.1k|    } else if (track->private_size >= RVPROPERTIES_SIZE
  ------------------
  |  |  281|  24.3k|#define RVPROPERTIES_SIZE  34
  ------------------
  |  Branch (1669:16): [True: 11.2k, False: 923]
  ------------------
 1670|  11.2k|               && (!strcmp(track->codec_id, "V_REAL/RV10")
  ------------------
  |  Branch (1670:20): [True: 26, False: 11.2k]
  ------------------
 1671|  11.2k|                || !strcmp(track->codec_id, "V_REAL/RV20")
  ------------------
  |  Branch (1671:20): [True: 258, False: 10.9k]
  ------------------
 1672|  10.9k|                || !strcmp(track->codec_id, "V_REAL/RV30")
  ------------------
  |  Branch (1672:20): [True: 0, False: 10.9k]
  ------------------
 1673|  10.9k|                || !strcmp(track->codec_id, "V_REAL/RV40")))
  ------------------
  |  Branch (1673:20): [True: 1.09k, False: 9.88k]
  ------------------
 1674|  1.37k|    {
 1675|  1.37k|        unsigned char *src;
 1676|  1.37k|        unsigned int cnt;
 1677|       |
 1678|  1.37k|        src = (uint8_t *) track->private_data + RVPROPERTIES_SIZE;
  ------------------
  |  |  281|  1.37k|#define RVPROPERTIES_SIZE  34
  ------------------
 1679|       |
 1680|  1.37k|        cnt = track->private_size - RVPROPERTIES_SIZE;
  ------------------
  |  |  281|  1.37k|#define RVPROPERTIES_SIZE  34
  ------------------
 1681|  1.37k|        uint32_t t2 = AV_RB32(src - 4);
 1682|  1.37k|        switch (t2 == 0x10003000 || t2 == 0x10003001 ? '1' : track->codec_id[9]) {
  ------------------
  |  Branch (1682:17): [True: 0, False: 1.37k]
  |  Branch (1682:17): [True: 1.37k, False: 0]
  |  Branch (1682:37): [True: 0, False: 1.37k]
  ------------------
 1683|     26|        case '1': sh_v->codec = "rv10"; break;
  ------------------
  |  Branch (1683:9): [True: 26, False: 1.35k]
  ------------------
 1684|    258|        case '2': sh_v->codec = "rv20"; break;
  ------------------
  |  Branch (1684:9): [True: 258, False: 1.12k]
  ------------------
 1685|      0|        case '3': sh_v->codec = "rv30"; break;
  ------------------
  |  Branch (1685:9): [True: 0, False: 1.37k]
  ------------------
 1686|  1.09k|        case '4': sh_v->codec = "rv40"; break;
  ------------------
  |  Branch (1686:9): [True: 1.09k, False: 284]
  ------------------
 1687|  1.37k|        }
 1688|       |        // copy type1 and type2 info from rv properties
 1689|  1.37k|        extradata_size = cnt + 8;
 1690|  1.37k|        extradata = src - 8;
 1691|  1.37k|        track->parse = true;
 1692|  1.37k|        track->parse_timebase = 1e3;
 1693|  10.8k|    } else if (strcmp(track->codec_id, "V_UNCOMPRESSED") == 0) {
  ------------------
  |  Branch (1693:16): [True: 28, False: 10.7k]
  ------------------
 1694|       |        // raw video, "like AVI" - this is a FourCC
 1695|     28|        sh_v->codec_tag = track->colorspace;
 1696|     28|        sh_v->codec = "rawvideo";
 1697|  10.7k|    } else if (strcmp(track->codec_id, "V_QUICKTIME") == 0) {
  ------------------
  |  Branch (1697:16): [True: 446, False: 10.3k]
  ------------------
 1698|    446|        if (track->private_size >= 8) {
  ------------------
  |  Branch (1698:13): [True: 445, False: 1]
  ------------------
 1699|    445|            sh_v->codec_tag = AV_RL32(track->private_data + 4);
 1700|    445|            mp_set_codec_from_tag(sh_v);
 1701|       |            // Some non-compliant files have fourcc at offset 0.
 1702|    445|            if (!sh_v->codec) {
  ------------------
  |  Branch (1702:17): [True: 387, False: 58]
  ------------------
 1703|    387|                sh_v->codec_tag = AV_RL32(track->private_data);
 1704|    387|                mp_set_codec_from_tag(sh_v);
 1705|    387|            }
 1706|    445|            extradata = track->private_data;
 1707|    445|            extradata_size = track->private_size;
 1708|    445|        }
 1709|  10.3k|    } else if (strcmp(track->codec_id, "V_VC1") == 0) {
  ------------------
  |  Branch (1709:16): [True: 0, False: 10.3k]
  ------------------
 1710|      0|        if (track->private_size >= 7 && (track->private_data[0] & 0xf0) == 0xc0) {
  ------------------
  |  Branch (1710:13): [True: 0, False: 0]
  |  Branch (1710:41): [True: 0, False: 0]
  ------------------
 1711|      0|            extradata = track->private_data + 7;
 1712|      0|            extradata_size = track->private_size - 7;
 1713|      0|        }
 1714|      0|        sh_v->codec = "vc1";
 1715|  10.3k|    } else {
 1716|  85.8k|        for (int i = 0; mkv_video_tags[i][0]; i++) {
  ------------------
  |  Branch (1716:25): [True: 85.0k, False: 831]
  ------------------
 1717|  85.0k|            if (!strcmp(mkv_video_tags[i][0], track->codec_id)) {
  ------------------
  |  Branch (1717:17): [True: 9.49k, False: 75.5k]
  ------------------
 1718|  9.49k|                sh_v->codec = mkv_video_tags[i][1];
 1719|  9.49k|                break;
 1720|  9.49k|            }
 1721|  85.0k|        }
 1722|  10.3k|        if (track->private_data && track->private_size > 0) {
  ------------------
  |  Branch (1722:13): [True: 9.48k, False: 845]
  |  Branch (1722:36): [True: 9.48k, False: 3]
  ------------------
 1723|  9.48k|            extradata = track->private_data;
 1724|  9.48k|            extradata_size = track->private_size;
 1725|  9.48k|        }
 1726|  10.3k|    }
 1727|       |
 1728|  19.5k|    const char *codec = sh_v->codec ? sh_v->codec : "";
  ------------------
  |  Branch (1728:25): [True: 18.6k, False: 922]
  ------------------
 1729|  19.5k|    if (!strcmp(codec, "mjpeg")) {
  ------------------
  |  Branch (1729:9): [True: 0, False: 19.5k]
  ------------------
 1730|      0|        sh_v->codec_tag = MKTAG('m', 'j', 'p', 'g');
 1731|      0|        track->require_keyframes = true;
 1732|      0|    }
 1733|       |
 1734|  19.5k|    if (extradata_size > 0x1000000) {
  ------------------
  |  Branch (1734:9): [True: 0, False: 19.5k]
  ------------------
 1735|      0|        MP_WARN(demuxer, "Invalid CodecPrivate\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__)
  |  |  ------------------
  ------------------
 1736|      0|        goto done;
 1737|      0|    }
 1738|       |
 1739|  19.5k|    sh_v->extradata = talloc_memdup(sh_v, extradata, extradata_size);
  ------------------
  |  |   49|  19.5k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  19.5k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1740|  19.5k|    sh_v->extradata_size = extradata_size;
 1741|  19.5k|    if (!sh_v->codec) {
  ------------------
  |  Branch (1741:9): [True: 922, False: 18.6k]
  ------------------
 1742|    922|        MP_WARN(demuxer, "Unknown/unsupported CodecID (%s) or missing/bad "
  ------------------
  |  |   90|    922|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    922|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1743|    922|                "CodecPrivate data (track %d).\n",
 1744|    922|                track->codec_id, track->tnum);
 1745|    922|    }
 1746|  19.5k|    sh_v->fps = track->v_frate;
 1747|  19.5k|    sh_v->disp_w = track->v_width;
 1748|  19.5k|    sh_v->disp_h = track->v_height;
 1749|       |
 1750|  19.5k|    struct mp_rect crop;
 1751|  19.5k|    crop.x0 = track->v_crop_left;
 1752|  19.5k|    crop.y0 = track->v_crop_top;
 1753|  19.5k|    crop.x1 = track->v_width - track->v_crop_right;
 1754|  19.5k|    crop.y1 = track->v_height - track->v_crop_bottom;
 1755|       |
 1756|       |    // Keep the codec crop rect as 0s if we have no cropping since the
 1757|       |    // file may have broken width/height tags.
 1758|  19.5k|    if (track->v_crop_left || track->v_crop_top ||
  ------------------
  |  Branch (1758:9): [True: 2, False: 19.5k]
  |  Branch (1758:31): [True: 4, False: 19.5k]
  ------------------
 1759|  19.5k|        track->v_crop_right || track->v_crop_bottom)
  ------------------
  |  Branch (1759:9): [True: 1, False: 19.5k]
  |  Branch (1759:32): [True: 5, False: 19.5k]
  ------------------
 1760|     12|    {
 1761|     12|        sh_v->crop = crop;
 1762|     12|    }
 1763|       |
 1764|  19.5k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 1765|       |
 1766|       |    // The Matroska specification mandates that the PAR is calculated after
 1767|       |    // cropping. However, most files on the internet do not follow this, as it
 1768|       |    // would make them incompatible with crop-unaware players. Additionally,
 1769|       |    // MKVToolNix does not automatically adjust DisplayWidth/DisplayHeight when
 1770|       |    // cropping metadata is added, so most files created with it also do not
 1771|       |    // follow the specification.
 1772|       |    // See the following links for more information:
 1773|       |    // <https://github.com/ietf-wg-cellar/matroska-specification/pull/947>
 1774|       |    // <https://gitlab.com/mbunkus/mkvtoolnix/-/issues/2389>
 1775|       |    // <https://github.com/mpv-player/mpv/pull/13446>
 1776|  19.5k|    int crop_compat_w = mkv_d->opts->crop_compat ? track->v_width : mp_rect_w(crop);
  ------------------
  |  |  157|  19.5k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  |  Branch (1776:25): [True: 19.5k, False: 0]
  ------------------
 1777|  19.5k|    int crop_compat_h = mkv_d->opts->crop_compat ? track->v_height : mp_rect_h(crop);
  ------------------
  |  |  158|  19.5k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (1777:25): [True: 19.5k, False: 0]
  ------------------
 1778|       |
 1779|  19.5k|    int dw = track->v_dwidth_set ? track->v_dwidth : crop_compat_w;
  ------------------
  |  Branch (1779:14): [True: 12.4k, False: 7.10k]
  ------------------
 1780|  19.5k|    int dh = track->v_dheight_set ? track->v_dheight : crop_compat_h;
  ------------------
  |  Branch (1780:14): [True: 11.6k, False: 7.88k]
  ------------------
 1781|  19.5k|    struct mp_image_params p = {.w = crop_compat_w, .h = crop_compat_h};
 1782|  19.5k|    mp_image_params_set_dsize(&p, dw, dh);
 1783|  19.5k|    sh_v->par_w = p.p_w;
 1784|  19.5k|    sh_v->par_h = p.p_h;
 1785|       |
 1786|  19.5k|    sh_v->stereo_mode = track->stereo_mode;
 1787|  19.5k|    sh_v->repr = track->repr;
 1788|  19.5k|    sh_v->color = track->color;
 1789|  19.5k|    sh_v->chroma_location = track->chroma_location;
 1790|       |
 1791|  19.5k|    if (track->v_projection_pose_roll) {
  ------------------
  |  Branch (1791:9): [True: 1, False: 19.5k]
  ------------------
 1792|      1|        int rotate = lrintf(fmodf(fmodf(-1 * track->v_projection_pose_roll, 360) + 360, 360));
 1793|      1|        sh_v->rotate = rotate;
 1794|      1|    }
 1795|       |
 1796|       |    // our vessel to transport global track side data to decoder context;
 1797|       |    // this gets called in all lavc decoders through `mp_set_avctx_codec_headers`
 1798|       |    // and its failure causes decoding failure. Thus if this call fails here, it is
 1799|       |    // likely that decoding of this track would also lead to an error.
 1800|  19.5k|    struct AVCodecParameters **lavp = talloc_ptrtype(track, lavp);
  ------------------
  |  |   34|  19.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  19.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1801|  19.5k|    talloc_set_destructor(lavp, avcodec_par_destructor);
  ------------------
  |  |   41|  19.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1802|  19.5k|    *lavp = sh_v->lav_codecpar = mp_codec_params_to_av(sh_v);
 1803|  19.5k|    if (!sh_v->lav_codecpar) {
  ------------------
  |  Branch (1803:9): [True: 0, False: 19.5k]
  ------------------
 1804|      0|        MP_ERR(demuxer, "Failed to create codec parameters for track %d!",
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1805|      0|               track->tnum);
 1806|      0|        goto done;
 1807|      0|    }
 1808|       |
 1809|  19.5k|    if (track->dovi_config) {
  ------------------
  |  Branch (1809:9): [True: 0, False: 19.5k]
  ------------------
 1810|      0|        size_t dovi_size;
 1811|      0|        AVDOVIDecoderConfigurationRecord *dovi = av_dovi_alloc(&dovi_size);
 1812|      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]
  |  |  ------------------
  ------------------
 1813|       |
 1814|      0|        memcpy(dovi, track->dovi_config, dovi_size);
 1815|       |
 1816|      0|        if (!av_packet_side_data_add(&sh_v->lav_codecpar->coded_side_data,
  ------------------
  |  Branch (1816:13): [True: 0, False: 0]
  ------------------
 1817|      0|                                     &sh_v->lav_codecpar->nb_coded_side_data,
 1818|      0|                                     AV_PKT_DATA_DOVI_CONF,
 1819|      0|                                     dovi, dovi_size, 0))
 1820|      0|        {
 1821|      0|            MP_ERR(demuxer, "Failed to attach Dolby Vision configuration record to "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1822|      0|                   "codec parameters for track %d!\n", track->tnum);
 1823|      0|            av_free(dovi);
 1824|      0|        }
 1825|       |
 1826|      0|        sh_v->dovi = true;
 1827|      0|        sh_v->dv_level = track->dovi_config->dv_level;
 1828|      0|        sh_v->dv_profile = track->dovi_config->dv_profile;
 1829|      0|        sh_v->dv_el_present = track->dovi_config->bl_present_flag &&
  ------------------
  |  Branch (1829:31): [True: 0, False: 0]
  ------------------
 1830|      0|                              track->dovi_config->el_present_flag;
  ------------------
  |  Branch (1830:31): [True: 0, False: 0]
  ------------------
 1831|      0|    }
 1832|       |
 1833|  19.5k|#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(62, 35, 100)
 1834|  19.5k|    if (track->hvce.len > 0) {
  ------------------
  |  Branch (1834:9): [True: 0, False: 19.5k]
  ------------------
 1835|      0|        void *data = av_memdup(track->hvce.start, track->hvce.len);
 1836|      0|        MP_HANDLE_OOM(data);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1837|      0|        if (!av_packet_side_data_add(&sh_v->lav_codecpar->coded_side_data,
  ------------------
  |  Branch (1837:13): [True: 0, False: 0]
  ------------------
 1838|      0|                                     &sh_v->lav_codecpar->nb_coded_side_data,
 1839|      0|                                     AV_PKT_DATA_HEVC_CONF,
 1840|      0|                                     data, track->hvce.len, 0))
 1841|      0|        {
 1842|      0|            MP_ERR(demuxer, "Failed to attach hvcE configuration record to "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1843|      0|                   "codec parameters for track %d!\n", track->tnum);
 1844|      0|            av_free(data);
 1845|      0|        }
 1846|      0|    }
 1847|  19.5k|#endif
 1848|       |
 1849|  19.5k|done:
 1850|  19.5k|    demux_add_sh_stream(demuxer, sh);
 1851|       |
 1852|       |    // Profile 7 NALU-interleaved
 1853|  19.5k|    if (sh_v->dv_el_present)
  ------------------
  |  Branch (1853:9): [True: 0, False: 19.5k]
  ------------------
 1854|      0|        track->dovi_split = mp_dovi_split_create(demuxer, sh);
 1855|       |
 1856|  19.5k|    return 0;
 1857|  19.5k|}
demux_mkv.c:init_track:
 1570|  42.0k|{
 1571|  42.0k|    track->stream = sh;
 1572|       |
 1573|  42.0k|    if (track->language && (strcmp(track->language, "und") != 0))
  ------------------
  |  Branch (1573:9): [True: 42.0k, False: 0]
  |  Branch (1573:28): [True: 34.3k, False: 7.67k]
  ------------------
 1574|  34.3k|        sh->lang = track->language;
 1575|       |
 1576|  42.0k|    sh->ff_index = idx; // Emulate lavf track index. For backward compatibility.
 1577|  42.0k|    sh->demuxer_id = track->tnum;
 1578|  42.0k|    sh->title = track->name;
 1579|  42.0k|    sh->default_track = track->default_track;
 1580|  42.0k|    sh->forced_track = track->forced_track;
 1581|  42.0k|    sh->visual_impaired_track = track->visual_impaired_track;
 1582|  42.0k|    sh->hearing_impaired_track = track->hearing_impaired_track;
 1583|  42.0k|    sh->original_track = track->original_track;
 1584|  42.0k|    sh->commentary_track = track->commentary_track;
 1585|  42.0k|}
demux_mkv.c:avcodec_par_destructor:
 1636|  19.5k|{
 1637|  19.5k|    avcodec_parameters_free(p);
 1638|  19.5k|}
demux_mkv.c:demux_mkv_open_audio:
 1949|  17.3k|{
 1950|  17.3k|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO);
 1951|  17.3k|    init_track(demuxer, track, sh, idx);
 1952|  17.3k|    struct mp_codec_params *sh_a = sh->codec;
 1953|       |
 1954|  17.3k|    if (track->private_size > 0x1000000)
  ------------------
  |  Branch (1954:9): [True: 0, False: 17.3k]
  ------------------
 1955|      0|        goto error;
 1956|       |
 1957|  17.3k|    unsigned char *extradata = track->private_data;
 1958|  17.3k|    unsigned int extradata_len = track->private_size;
 1959|       |
 1960|  17.3k|    if (!track->a_osfreq)
  ------------------
  |  Branch (1960:9): [True: 2.19k, False: 15.1k]
  ------------------
 1961|  2.19k|        track->a_osfreq = track->a_sfreq;
 1962|  17.3k|    sh_a->bits_per_coded_sample = track->a_bps ? track->a_bps : 16;
  ------------------
  |  Branch (1962:35): [True: 1.47k, False: 15.8k]
  ------------------
 1963|  17.3k|    sh_a->samplerate = (uint32_t) track->a_osfreq;
 1964|  17.3k|    mp_chmap_set_unknown(&sh_a->channels, track->a_channels);
 1965|       |
 1966|   223k|    for (int i = 0; mkv_audio_tags[i][0]; i++) {
  ------------------
  |  Branch (1966:21): [True: 214k, False: 8.07k]
  ------------------
 1967|   214k|        if (!strcmp(mkv_audio_tags[i][0], track->codec_id)) {
  ------------------
  |  Branch (1967:13): [True: 9.28k, False: 205k]
  ------------------
 1968|  9.28k|            sh_a->codec = mkv_audio_tags[i][1];
 1969|  9.28k|            break;
 1970|  9.28k|        }
 1971|   214k|    }
 1972|       |
 1973|  17.3k|    if (!strcmp(track->codec_id, "A_MS/ACM")) { /* AVI compatibility mode */
  ------------------
  |  Branch (1973:9): [True: 5.09k, False: 12.2k]
  ------------------
 1974|       |        // The private_data contains a WAVEFORMATEX struct
 1975|  5.09k|        if (track->private_size < 18)
  ------------------
  |  Branch (1975:13): [True: 629, False: 4.46k]
  ------------------
 1976|    629|            goto error;
 1977|  4.46k|        MP_DBG(demuxer, "track with MS compat audio.\n");
  ------------------
  |  |   93|  4.46k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.46k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1978|  4.46k|        unsigned char *h = track->private_data;
 1979|  4.46k|        sh_a->codec_tag = AV_RL16(h + 0);         // wFormatTag
 1980|  4.46k|        if (track->a_channels == 0)
  ------------------
  |  Branch (1980:13): [True: 316, False: 4.14k]
  ------------------
 1981|    316|            track->a_channels = AV_RL16(h + 2); // nChannels
 1982|  4.46k|        if (sh_a->samplerate == 0)
  ------------------
  |  Branch (1982:13): [True: 277, False: 4.18k]
  ------------------
 1983|    277|            sh_a->samplerate = AV_RL32(h + 4);  // nSamplesPerSec
 1984|  4.46k|        sh_a->bitrate = AV_RL32(h + 8) * 8;     // nAvgBytesPerSec
 1985|  4.46k|        sh_a->block_align = AV_RL16(h + 12);    // nBlockAlign
 1986|  4.46k|        if (track->a_bps == 0)
  ------------------
  |  Branch (1986:13): [True: 4.46k, False: 0]
  ------------------
 1987|  4.46k|            track->a_bps = AV_RL16(h + 14);     // wBitsPerSample
 1988|  4.46k|        extradata = track->private_data + 18;
 1989|  4.46k|        extradata_len = track->private_size - 18;
 1990|  4.46k|        sh_a->bits_per_coded_sample = track->a_bps;
 1991|  4.46k|        sh_a->extradata = extradata;
 1992|  4.46k|        sh_a->extradata_size = extradata_len;
 1993|  4.46k|        mp_set_codec_from_tag(sh_a);
 1994|  4.46k|        extradata = sh_a->extradata;
 1995|  4.46k|        extradata_len = sh_a->extradata_size;
 1996|  12.2k|    } else if (!strcmp(track->codec_id, "A_PCM/INT/LIT")) {
  ------------------
  |  Branch (1996:16): [True: 0, False: 12.2k]
  ------------------
 1997|      0|        bool sign = sh_a->bits_per_coded_sample > 8;
 1998|      0|        mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, false);
 1999|  12.2k|    } else if (!strcmp(track->codec_id, "A_PCM/INT/BIG")) {
  ------------------
  |  Branch (1999:16): [True: 0, False: 12.2k]
  ------------------
 2000|      0|        bool sign = sh_a->bits_per_coded_sample > 8;
 2001|      0|        mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, true);
 2002|  12.2k|    } else if (!strcmp(track->codec_id, "A_PCM/FLOAT/IEEE")) {
  ------------------
  |  Branch (2002:16): [True: 0, False: 12.2k]
  ------------------
 2003|      0|        sh_a->codec = sh_a->bits_per_coded_sample == 64 ? "pcm_f64le" : "pcm_f32le";
  ------------------
  |  Branch (2003:23): [True: 0, False: 0]
  ------------------
 2004|  12.2k|    } else if (!strncmp(track->codec_id, "A_REAL/", 7)) {
  ------------------
  |  Branch (2004:16): [True: 1.16k, False: 11.1k]
  ------------------
 2005|  1.16k|        if (track->private_size < RAPROPERTIES4_SIZE)
  ------------------
  |  |  282|  1.16k|#define RAPROPERTIES4_SIZE 56
  ------------------
  |  Branch (2005:13): [True: 28, False: 1.13k]
  ------------------
 2006|     28|            goto error;
 2007|       |        /* Common initialization for all RealAudio codecs */
 2008|  1.13k|        unsigned char *src = track->private_data;
 2009|       |
 2010|  1.13k|        int version = AV_RB16(src + 4);
 2011|  1.13k|        unsigned int flavor = AV_RB16(src + 22);
 2012|  1.13k|        track->coded_framesize = AV_RB32(src + 24);
 2013|  1.13k|        track->sub_packet_h = AV_RB16(src + 40);
 2014|  1.13k|        sh_a->block_align = track->audiopk_size = AV_RB16(src + 42);
 2015|  1.13k|        track->sub_packet_size = AV_RB16(src + 44);
 2016|  1.13k|        int offset = 0;
 2017|  1.13k|        if (version == 4) {
  ------------------
  |  Branch (2017:13): [True: 1, False: 1.13k]
  ------------------
 2018|      1|            offset += RAPROPERTIES4_SIZE;
  ------------------
  |  |  282|      1|#define RAPROPERTIES4_SIZE 56
  ------------------
 2019|      1|            if (offset + 1 > track->private_size)
  ------------------
  |  Branch (2019:17): [True: 0, False: 1]
  ------------------
 2020|      0|                goto error;
 2021|      1|            offset += (src[offset] + 1) * 2 + 3;
 2022|  1.13k|        } else {
 2023|  1.13k|            offset += RAPROPERTIES5_SIZE + 3 + (version == 5 ? 1 : 0);
  ------------------
  |  |  283|  1.13k|#define RAPROPERTIES5_SIZE 70
  ------------------
  |  Branch (2023:49): [True: 1.12k, False: 9]
  ------------------
 2024|  1.13k|        }
 2025|       |
 2026|  1.13k|        if (track->audiopk_size == 0 || track->sub_packet_size == 0 ||
  ------------------
  |  Branch (2026:13): [True: 2, False: 1.13k]
  |  Branch (2026:41): [True: 1, False: 1.13k]
  ------------------
 2027|  1.13k|            track->sub_packet_h == 0 || track->coded_framesize == 0)
  ------------------
  |  Branch (2027:13): [True: 1, False: 1.12k]
  |  Branch (2027:41): [True: 2, False: 1.12k]
  ------------------
 2028|      6|            goto error;
 2029|  1.12k|        if (track->coded_framesize > 0x40000000)
  ------------------
  |  Branch (2029:13): [True: 10, False: 1.11k]
  ------------------
 2030|     10|            goto error;
 2031|       |
 2032|  1.11k|        if (offset + 4 > track->private_size)
  ------------------
  |  Branch (2032:13): [True: 1, False: 1.11k]
  ------------------
 2033|      1|            goto error;
 2034|  1.11k|        uint32_t codecdata_length = AV_RB32(src + offset);
 2035|  1.11k|        offset += 4;
 2036|  1.11k|        if (offset > track->private_size ||
  ------------------
  |  Branch (2036:13): [True: 0, False: 1.11k]
  ------------------
 2037|  1.11k|            codecdata_length > track->private_size - offset)
  ------------------
  |  Branch (2037:13): [True: 8, False: 1.10k]
  ------------------
 2038|      8|            goto error;
 2039|  1.10k|        extradata_len = codecdata_length;
 2040|  1.10k|        extradata = src + offset;
 2041|       |
 2042|  1.10k|        if (!strcmp(track->codec_id, "A_REAL/ATRC")) {
  ------------------
  |  Branch (2042:13): [True: 0, False: 1.10k]
  ------------------
 2043|      0|            sh_a->codec = "atrac3";
 2044|      0|            if (flavor >= MP_ARRAY_SIZE(atrc_fl2bps))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2044:17): [True: 0, False: 0]
  ------------------
 2045|      0|                goto error;
 2046|      0|            sh_a->bitrate = atrc_fl2bps[flavor] * 8;
 2047|      0|            if (!track->sub_packet_size || track->audiopk_size % track->sub_packet_size)
  ------------------
  |  Branch (2047:17): [True: 0, False: 0]
  |  Branch (2047:44): [True: 0, False: 0]
  ------------------
 2048|      0|                goto error;
 2049|      0|            sh_a->block_align = track->sub_packet_size;
 2050|  1.10k|        } else if (!strcmp(track->codec_id, "A_REAL/COOK")) {
  ------------------
  |  Branch (2050:20): [True: 1.09k, False: 10]
  ------------------
 2051|  1.09k|            sh_a->codec = "cook";
 2052|  1.09k|            if (flavor >= MP_ARRAY_SIZE(cook_fl2bps))
  ------------------
  |  |   49|  1.09k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2052:17): [True: 2, False: 1.09k]
  ------------------
 2053|      2|                goto error;
 2054|  1.09k|            sh_a->bitrate = cook_fl2bps[flavor] * 8;
 2055|  1.09k|            if (!track->sub_packet_size || track->audiopk_size % track->sub_packet_size)
  ------------------
  |  Branch (2055:17): [True: 0, False: 1.09k]
  |  Branch (2055:44): [True: 177, False: 919]
  ------------------
 2056|    177|                goto error;
 2057|    919|            sh_a->block_align = track->sub_packet_size;
 2058|    919|        } else if (!strcmp(track->codec_id, "A_REAL/SIPR")) {
  ------------------
  |  Branch (2058:20): [True: 0, False: 10]
  ------------------
 2059|      0|            sh_a->codec = "sipr";
 2060|      0|            if (flavor >= MP_ARRAY_SIZE(sipr_fl2bps))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2060:17): [True: 0, False: 0]
  ------------------
 2061|      0|                goto error;
 2062|      0|            sh_a->bitrate = sipr_fl2bps[flavor] * 8;
 2063|      0|            sh_a->block_align = track->coded_framesize;
 2064|     10|        } else if (!strcmp(track->codec_id, "A_REAL/28_8")) {
  ------------------
  |  Branch (2064:20): [True: 0, False: 10]
  ------------------
 2065|      0|            sh_a->codec = "ra_288";
 2066|      0|            sh_a->bitrate = 3600 * 8;
 2067|      0|            if (track->sub_packet_h & 1)
  ------------------
  |  Branch (2067:17): [True: 0, False: 0]
  ------------------
 2068|      0|                goto error;
 2069|      0|            if (2 * track->audiopk_size != (int64_t)track->sub_packet_h * track->coded_framesize)
  ------------------
  |  Branch (2069:17): [True: 0, False: 0]
  ------------------
 2070|      0|                goto error;
 2071|      0|            sh_a->block_align = track->coded_framesize;
 2072|     10|        } else if (!strcmp(track->codec_id, "A_REAL/DNET")) {
  ------------------
  |  Branch (2072:20): [True: 0, False: 10]
  ------------------
 2073|      0|            sh_a->codec = "ac3";
 2074|     10|        } else {
 2075|     10|            goto error;
 2076|     10|        }
 2077|       |
 2078|       |        // Limit buffer size to 128 MiB to avoid excessive memory allocation on malformed files.
 2079|    919|        if (track->sub_packet_h * track->audiopk_size > (128 << 20)) {
  ------------------
  |  Branch (2079:13): [True: 2, False: 917]
  ------------------
 2080|      2|            MP_WARN(demuxer, "RealAudio packet size too big (%" PRIu32 " MiB) - skipping track\n",
  ------------------
  |  |   90|      2|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2081|      2|                    track->sub_packet_h * track->audiopk_size);
 2082|      2|            goto error;
 2083|      2|        }
 2084|       |
 2085|    917|        track->audio_buf =
 2086|    917|            talloc_array_size(track, track->sub_packet_h, track->audiopk_size);
  ------------------
  |  |   32|    917|#define talloc_array_size               ta_xnew_array_size
  |  |  ------------------
  |  |  |  |  137|    917|#define ta_xnew_array_size(...)         ta_oom_p(ta_new_array_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |   86|    917|    ta_alloc_size(ta_parent, ta_calc_array_size(element_size, count))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  153|    917|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    917|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    917|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    917|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2087|    917|        track->audio_timestamp =
 2088|    917|            talloc_array(track, double, track->sub_packet_h);
  ------------------
  |  |   29|    917|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|    917|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    917|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2089|  11.1k|    } else if (!strncmp(track->codec_id, "A_AAC/", 6)) {
  ------------------
  |  Branch (2089:16): [True: 1.00k, False: 10.1k]
  ------------------
 2090|  1.00k|        sh_a->codec = "aac";
 2091|       |
 2092|       |        /* Recreate the 'private data' (not needed for plain A_AAC) */
 2093|  1.00k|        int srate_idx = aac_get_sample_rate_index(track->a_sfreq);
 2094|  1.00k|        const char *tail = "";
 2095|  1.00k|        if (strlen(track->codec_id) >= 12)
  ------------------
  |  Branch (2095:13): [True: 998, False: 6]
  ------------------
 2096|    998|            tail = &track->codec_id[12];
 2097|  1.00k|        int profile = 3;
 2098|  1.00k|        if (!strncmp(tail, "MAIN", 4))
  ------------------
  |  Branch (2098:13): [True: 0, False: 1.00k]
  ------------------
 2099|      0|            profile = 0;
 2100|  1.00k|        else if (!strncmp(tail, "LC", 2))
  ------------------
  |  Branch (2100:18): [True: 935, False: 69]
  ------------------
 2101|    935|            profile = 1;
 2102|     69|        else if (!strncmp(tail, "SSR", 3))
  ------------------
  |  Branch (2102:18): [True: 0, False: 69]
  ------------------
 2103|      0|            profile = 2;
 2104|  1.00k|        extradata = talloc_size(sh_a, 5);
  ------------------
  |  |   43|  1.00k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  1.00k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  1.00k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2105|  1.00k|        extradata[0] = ((profile + 1) << 3) | ((srate_idx & 0xE) >> 1);
 2106|  1.00k|        extradata[1] = ((srate_idx & 0x1) << 7) | (track->a_channels << 3);
 2107|       |
 2108|  1.00k|        if (strstr(track->codec_id, "SBR") != NULL) {
  ------------------
  |  Branch (2108:13): [True: 625, False: 379]
  ------------------
 2109|       |            /* HE-AAC (aka SBR AAC) */
 2110|    625|            extradata_len = 5;
 2111|       |
 2112|    625|            srate_idx = aac_get_sample_rate_index(sh_a->samplerate);
 2113|    625|            extradata[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
  ------------------
  |  |  305|    625|#define AAC_SYNC_EXTENSION_TYPE 0x02b7
  ------------------
 2114|    625|            extradata[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
  ------------------
  |  |  305|    625|#define AAC_SYNC_EXTENSION_TYPE 0x02b7
  ------------------
 2115|    625|            extradata[4] = (1 << 7) | (srate_idx << 3);
 2116|    625|            track->default_duration = 1024.0 / (sh_a->samplerate / 2);
 2117|    625|        } else {
 2118|    379|            extradata_len = 2;
 2119|    379|            track->default_duration = 1024.0 / sh_a->samplerate;
 2120|    379|        }
 2121|  10.1k|    } else if (!strncmp(track->codec_id, "A_AC3/", 6)) {
  ------------------
  |  Branch (2121:16): [True: 1, False: 10.1k]
  ------------------
 2122|      1|        sh_a->codec = "ac3";
 2123|  10.1k|    } else if (!strncmp(track->codec_id, "A_EAC3/", 7)) {
  ------------------
  |  Branch (2123:16): [True: 0, False: 10.1k]
  ------------------
 2124|      0|        sh_a->codec = "eac3";
 2125|      0|    }
 2126|       |
 2127|  16.4k|    if (!sh_a->codec)
  ------------------
  |  Branch (2127:9): [True: 988, False: 15.4k]
  ------------------
 2128|    988|        goto error;
 2129|       |
 2130|  15.4k|    const char *codec = sh_a->codec;
 2131|  15.4k|    if (!strcmp(codec, "mp1") || !strcmp(codec, "mp2") || !strcmp(codec, "mp3") ||
  ------------------
  |  Branch (2131:9): [True: 452, False: 15.0k]
  |  Branch (2131:34): [True: 25, False: 15.0k]
  |  Branch (2131:59): [True: 594, False: 14.4k]
  ------------------
 2132|  14.4k|        !strcmp(codec, "truehd") || !strcmp(codec, "eac3"))
  ------------------
  |  Branch (2132:9): [True: 0, False: 14.4k]
  |  Branch (2132:37): [True: 1, False: 14.4k]
  ------------------
 2133|  1.07k|    {
 2134|  1.07k|        mkv_demuxer_t *mkv_d = demuxer->priv;
 2135|  1.07k|        int64_t segment_timebase = (1e9 / mkv_d->tc_scale);
 2136|       |
 2137|  1.07k|        track->parse = true;
 2138|  1.07k|        track->parse_timebase = MPMAX(sh_a->samplerate, segment_timebase);
  ------------------
  |  |   44|  1.07k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 343, False: 729]
  |  |  ------------------
  ------------------
 2139|  14.4k|    } else if (!strcmp(codec, "flac")) {
  ------------------
  |  Branch (2139:16): [True: 119, False: 14.3k]
  ------------------
 2140|    119|        unsigned char *ptr = extradata;
 2141|    119|        unsigned int size = extradata_len;
 2142|    119|        if (size < 4 || ptr[0] != 'f' || ptr[1] != 'L' || ptr[2] != 'a'
  ------------------
  |  Branch (2142:13): [True: 1, False: 118]
  |  Branch (2142:25): [True: 0, False: 118]
  |  Branch (2142:42): [True: 1, False: 117]
  |  Branch (2142:59): [True: 2, False: 115]
  ------------------
 2143|    115|            || ptr[3] != 'C') {
  ------------------
  |  Branch (2143:16): [True: 0, False: 115]
  ------------------
 2144|      4|            extradata = talloc_size(sh_a, 4);
  ------------------
  |  |   43|      4|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|      4|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      4|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      4|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      4|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      4|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2145|      4|            extradata_len = 4;
 2146|      4|            memcpy(extradata, "fLaC", 4);
 2147|      4|        }
 2148|    119|        parse_flac_chmap(&sh_a->channels, extradata, extradata_len);
 2149|  14.3k|    } else if (!strcmp(codec, "alac")) {
  ------------------
  |  Branch (2149:16): [True: 0, False: 14.3k]
  ------------------
 2150|      0|        if (track->private_size) {
  ------------------
  |  Branch (2150:13): [True: 0, False: 0]
  ------------------
 2151|      0|            extradata_len = track->private_size + 12;
 2152|      0|            extradata = talloc_size(sh_a, extradata_len);
  ------------------
  |  |   43|      0|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|      0|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      0|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2153|      0|            char *data = extradata;
 2154|      0|            AV_WB32(data + 0, extradata_len);
 2155|      0|            memcpy(data + 4, "alac", 4);
 2156|      0|            AV_WB32(data + 8, 0);
 2157|      0|            memcpy(data + 12, track->private_data, track->private_size);
 2158|      0|        }
 2159|  14.3k|    } else if (!strcmp(codec, "tta")) {
  ------------------
  |  Branch (2159:16): [True: 168, False: 14.1k]
  ------------------
 2160|    168|        extradata_len = 30;
 2161|    168|        extradata = talloc_zero_size(sh_a, extradata_len);
  ------------------
  |  |   44|    168|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|    168|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    168|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    168|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    168|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    168|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2162|    168|        if (!extradata)
  ------------------
  |  Branch (2162:13): [True: 0, False: 168]
  ------------------
 2163|      0|            goto error;
 2164|    168|        char *data = extradata;
 2165|    168|        memcpy(data + 0, "TTA1", 4);
 2166|    168|        AV_WL16(data + 4, 1);
 2167|    168|        AV_WL16(data + 6, sh_a->channels.num);
 2168|    168|        AV_WL16(data + 8, sh_a->bits_per_coded_sample);
 2169|    168|        AV_WL32(data + 10, track->a_osfreq);
 2170|    168|        mkv_demuxer_t *mkv_d = demuxer->priv;
 2171|    168|        double samples = mkv_d->duration * track->a_osfreq;
 2172|    168|        AV_WL32(data + 14, samples > 0 ? MPMIN(samples, UINT32_MAX) : 0);
  ------------------
  |  Branch (2172:9): [True: 1, False: 136]
  |  Branch (2172:9): [True: 137, False: 31]
  ------------------
 2173|  14.1k|    } else if (!strcmp(codec, "opus")) {
  ------------------
  |  Branch (2173:16): [True: 914, False: 13.2k]
  ------------------
 2174|       |        // Hardcode the rate libavcodec's opus decoder outputs, so that
 2175|       |        // AV_PKT_DATA_SKIP_SAMPLES actually works. The Matroska header only
 2176|       |        // has an arbitrary "input" samplerate, while libavcodec is fixed to
 2177|       |        // output 48000.
 2178|    914|        sh_a->samplerate = 48000;
 2179|  13.2k|    } else if (!strcmp(codec, "atrac1")) {
  ------------------
  |  Branch (2179:16): [True: 0, False: 13.2k]
  ------------------
 2180|      0|        if (sh_a->channels.num > 8)
  ------------------
  |  Branch (2180:13): [True: 0, False: 0]
  ------------------
 2181|      0|            goto error;
 2182|       |        // ATRAC1 uses a constant frame size.
 2183|      0|        sh_a->block_align = sh_a->channels.num * 212;
 2184|      0|    }
 2185|       |
 2186|       |    // Some files have broken default DefaultDuration set, which will lead to
 2187|       |    // audio packets with incorrect timestamps. This follows FFmpeg commit
 2188|       |    // 6158a3b, sample see FFmpeg ticket 2508.
 2189|  15.4k|    if (sh_a->samplerate == 8000 && strcmp(codec, "ac3") == 0)
  ------------------
  |  Branch (2189:9): [True: 1.20k, False: 14.2k]
  |  Branch (2189:37): [True: 323, False: 881]
  ------------------
 2190|    323|        track->default_duration = 0;
 2191|       |
 2192|       |    // Deal with some FFmpeg-produced garbage, and assume all audio codecs can
 2193|       |    // start decoding from anywhere.
 2194|  15.4k|    if (strcmp(codec, "truehd") != 0)
  ------------------
  |  Branch (2194:9): [True: 15.4k, False: 0]
  ------------------
 2195|  15.4k|        track->require_keyframes = true;
 2196|       |
 2197|  15.4k|    sh_a->extradata = extradata;
 2198|  15.4k|    sh_a->extradata_size = extradata_len;
 2199|       |
 2200|  15.4k|    sh->seek_preroll = track->codec_delay;
 2201|       |
 2202|  15.4k|    demux_add_sh_stream(demuxer, sh);
 2203|       |
 2204|  15.4k|    return 0;
 2205|       |
 2206|  1.86k| error:
 2207|  1.86k|    MP_WARN(demuxer, "Unknown/unsupported audio "
  ------------------
  |  |   90|  1.86k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.86k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2208|  1.86k|            "codec ID '%s' for track %u or missing/faulty\n"
 2209|  1.86k|            "private codec data.\n", track->codec_id, track->tnum);
 2210|  1.86k|    demux_add_sh_stream(demuxer, sh); // add it anyway
 2211|  1.86k|    return 1;
 2212|  15.4k|}
demux_mkv.c:aac_get_sample_rate_index:
  307|  1.62k|{
  308|  1.62k|    static const int srates[] = {
  309|  1.62k|        92017, 75132, 55426, 46009, 37566, 27713,
  310|  1.62k|        23004, 18783, 13856, 11502, 9391, 0
  311|  1.62k|    };
  312|  1.62k|    int i = 0;
  313|  10.6k|    while (sample_rate < srates[i])
  ------------------
  |  Branch (313:12): [True: 8.97k, False: 1.62k]
  ------------------
  314|  8.97k|        i++;
  315|  1.62k|    return i;
  316|  1.62k|}
demux_mkv.c:parse_flac_chmap:
 1904|    119|{
 1905|       |    // Skip FLAC header.
 1906|    119|    if (size < 4)
  ------------------
  |  Branch (1906:9): [True: 0, False: 119]
  ------------------
 1907|      0|        return;
 1908|    119|    data += 4;
 1909|    119|    size -= 4;
 1910|       |    // Parse FLAC blocks...
 1911|  33.1k|    while (size >= 4) {
  ------------------
  |  Branch (1911:12): [True: 33.1k, False: 16]
  ------------------
 1912|  33.1k|        unsigned btype = data[0] & 0x7F;
 1913|  33.1k|        unsigned bsize = AV_RB24(data + 1);
 1914|  33.1k|        data += 4;
 1915|  33.1k|        size -= 4;
 1916|  33.1k|        if (bsize > size)
  ------------------
  |  Branch (1916:13): [True: 103, False: 33.0k]
  ------------------
 1917|    103|            return;
 1918|  33.0k|        if (btype == 4) // VORBIS_COMMENT
  ------------------
  |  Branch (1918:13): [True: 14, False: 33.0k]
  ------------------
 1919|     14|            parse_vorbis_chmap(channels, data, bsize);
 1920|  33.0k|        data += bsize;
 1921|  33.0k|        size -= bsize;
 1922|  33.0k|    }
 1923|    119|}
demux_mkv.c:parse_vorbis_chmap:
 1863|     14|{
 1864|       |    // Skip the useless vendor string.
 1865|     14|    if (size < 4)
  ------------------
  |  Branch (1865:9): [True: 1, False: 13]
  ------------------
 1866|      1|        return;
 1867|     13|    uint32_t vendor_length = AV_RL32(data);
 1868|     13|    if (vendor_length + 4 > size) // also check for the next AV_RB32 below
  ------------------
  |  Branch (1868:9): [True: 2, False: 11]
  ------------------
 1869|      2|        return;
 1870|     11|    size -= vendor_length + 4;
 1871|     11|    data += vendor_length + 4;
 1872|     11|    uint32_t num_headers = AV_RL32(data);
 1873|     11|    size -= 4;
 1874|     11|    data += 4;
 1875|     13|    for (int n = 0; n < num_headers; n++) {
  ------------------
  |  Branch (1875:21): [True: 6, False: 7]
  ------------------
 1876|      6|        if (size < 4)
  ------------------
  |  Branch (1876:13): [True: 2, False: 4]
  ------------------
 1877|      2|            return;
 1878|      4|        uint32_t len = AV_RL32(data);
 1879|      4|        size -= 4;
 1880|      4|        data += 4;
 1881|      4|        if (len > size)
  ------------------
  |  Branch (1881:13): [True: 2, False: 2]
  ------------------
 1882|      2|            return;
 1883|      2|        if (len > 34 && !memcmp(data, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK=", 34)) {
  ------------------
  |  Branch (1883:13): [True: 1, False: 1]
  |  Branch (1883:25): [True: 1, False: 0]
  ------------------
 1884|      1|            char smask[80];
 1885|      1|            snprintf(smask, sizeof(smask), "%.*s", (int)(len - 34), data + 34);
 1886|      1|            char *end = NULL;
 1887|      1|            uint32_t mask = strtol(smask, &end, 0);
 1888|      1|            if (end[0])
  ------------------
  |  Branch (1888:17): [True: 1, False: 0]
  ------------------
 1889|      1|                mask = 0;
 1890|      1|            struct mp_chmap chmask = {0};
 1891|      1|            mp_chmap_from_waveext(&chmask, mask);
  ------------------
  |  |  175|      1|#define mp_chmap_from_waveext mp_chmap_from_lavc
  ------------------
 1892|      1|            if (mp_chmap_is_valid(&chmask))
  ------------------
  |  Branch (1892:17): [True: 0, False: 1]
  ------------------
 1893|      0|                *channels = chmask;
 1894|      1|        }
 1895|      2|        size -= len;
 1896|      2|        data += len;
 1897|      2|    }
 1898|     11|}
demux_mkv.c:demux_mkv_open_sub:
 2233|  5.10k|{
 2234|  5.10k|    const char *subtitle_type = NULL;
 2235|  25.9k|    for (int n = 0; mkv_sub_tag[n][0]; n++) {
  ------------------
  |  Branch (2235:21): [True: 25.7k, False: 194]
  ------------------
 2236|  25.7k|        if (strcmp(track->codec_id, mkv_sub_tag[n][0]) == 0) {
  ------------------
  |  Branch (2236:13): [True: 4.90k, False: 20.8k]
  ------------------
 2237|  4.90k|            subtitle_type = mkv_sub_tag[n][1];
 2238|  4.90k|            break;
 2239|  4.90k|        }
 2240|  25.7k|    }
 2241|       |
 2242|  5.10k|    if (track->private_size > 0x10000000)
  ------------------
  |  Branch (2242:9): [True: 0, False: 5.10k]
  ------------------
 2243|      0|        return 1;
 2244|       |
 2245|  5.10k|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_SUB);
 2246|  5.10k|    init_track(demuxer, track, sh, idx);
 2247|       |
 2248|  5.10k|    sh->codec->codec = subtitle_type;
 2249|  5.10k|    bstr in = (bstr){track->private_data, track->private_size};
 2250|  5.10k|    bstr buffer = demux_mkv_decode(demuxer->log, track, in, 2);
 2251|  5.10k|    if (buffer.start && buffer.start != track->private_data) {
  ------------------
  |  Branch (2251:9): [True: 2.66k, False: 2.43k]
  |  Branch (2251:25): [True: 0, False: 2.66k]
  ------------------
 2252|      0|        talloc_free(track->private_data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2253|      0|        talloc_steal(track, buffer.start);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 2254|      0|        track->private_data = buffer.start;
 2255|      0|        track->private_size = buffer.len;
 2256|      0|    }
 2257|  5.10k|    sh->codec->extradata = track->private_data;
 2258|  5.10k|    sh->codec->extradata_size = track->private_size;
 2259|       |
 2260|  5.10k|    if (subtitle_type && !strcmp(sh->codec->codec, "arib_caption") && track->private_size >= 3) {
  ------------------
  |  Branch (2260:9): [True: 4.90k, False: 194]
  |  Branch (2260:26): [True: 0, False: 4.90k]
  |  Branch (2260:71): [True: 0, False: 0]
  ------------------
 2261|      0|        struct AVCodecParameters **lavp = talloc_ptrtype(track, lavp);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2262|       |
 2263|      0|        talloc_set_destructor(lavp, avcodec_par_destructor);
  ------------------
  |  |   41|      0|#define talloc_set_destructor           ta_set_destructor
  ------------------
 2264|       |
 2265|      0|        struct AVCodecParameters *lav = *lavp = sh->codec->lav_codecpar = avcodec_parameters_alloc();
 2266|      0|        MP_HANDLE_OOM(lav);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2267|       |
 2268|      0|        lav->codec_type = AVMEDIA_TYPE_SUBTITLE;
 2269|      0|        lav->codec_id = AV_CODEC_ID_ARIB_CAPTION;
 2270|       |
 2271|      0|        int component_tag = track->private_data[0];
 2272|      0|        int data_component_id = AV_RB16(track->private_data + 1);
 2273|      0|        switch (data_component_id) {
  ------------------
  |  Branch (2273:17): [True: 0, False: 0]
  ------------------
 2274|      0|        case 0x0008:
  ------------------
  |  Branch (2274:9): [True: 0, False: 0]
  ------------------
 2275|       |            // [0x30..0x37] are component tags utilized for
 2276|       |            // non-mobile captioning service ("profile A").
 2277|      0|            if (component_tag >= 0x30 && component_tag <= 0x37)
  ------------------
  |  Branch (2277:17): [True: 0, False: 0]
  |  Branch (2277:42): [True: 0, False: 0]
  ------------------
 2278|      0|                lav->profile = AV_PROFILE_ARIB_PROFILE_A;
 2279|      0|            break;
 2280|      0|        case 0x0012:
  ------------------
  |  Branch (2280:9): [True: 0, False: 0]
  ------------------
 2281|       |            // component tag 0x87 signifies a mobile/partial reception
 2282|       |            // (1seg) captioning service ("profile C").
 2283|      0|            if (component_tag == 0x87)
  ------------------
  |  Branch (2283:17): [True: 0, False: 0]
  ------------------
 2284|      0|                lav->profile = AV_PROFILE_ARIB_PROFILE_C;
 2285|      0|            break;
 2286|      0|        }
 2287|      0|        if (lav->profile == AV_PROFILE_UNKNOWN)
  ------------------
  |  Branch (2287:13): [True: 0, False: 0]
  ------------------
 2288|      0|            MP_WARN(demuxer, "ARIB caption profile %02x / %04x not supported.\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__)
  |  |  ------------------
  ------------------
 2289|      0|                    component_tag, data_component_id);
 2290|      0|    }
 2291|       |
 2292|  5.10k|    demux_add_sh_stream(demuxer, sh);
 2293|       |
 2294|  5.10k|    if (!subtitle_type)
  ------------------
  |  Branch (2294:9): [True: 194, False: 4.90k]
  ------------------
 2295|  5.10k|        MP_ERR(demuxer, "Subtitle type '%s' is not supported.\n", track->codec_id);
  ------------------
  |  |   89|    194|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    194|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2296|       |
 2297|  5.10k|    return 0;
 2298|  5.10k|}
demux_mkv.c:demux_mkv_decode:
  320|   778k|{
  321|   778k|    uint8_t *src = data.start;
  322|   778k|    uint8_t *orig_src = src;
  323|   778k|    uint8_t *dest = src;
  324|   778k|    uint32_t size = data.len;
  325|       |
  326|   803k|    for (int i = 0; i < track->num_encodings; i++) {
  ------------------
  |  Branch (326:21): [True: 29.1k, False: 774k]
  ------------------
  327|  29.1k|        struct mkv_content_encoding *enc = track->encodings + i;
  328|  29.1k|        if (!(enc->scope & type))
  ------------------
  |  Branch (328:13): [True: 455, False: 28.6k]
  ------------------
  329|    455|            continue;
  330|       |
  331|  28.6k|        if (src != dest && src != orig_src)
  ------------------
  |  Branch (331:13): [True: 0, False: 28.6k]
  |  Branch (331:28): [True: 0, False: 0]
  ------------------
  332|      0|            talloc_free(src);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  333|  28.6k|        src = dest;  // output from last iteration is new source
  334|       |
  335|  28.6k|        if (enc->comp_algo == 0) {
  ------------------
  |  Branch (335:13): [True: 2.21k, False: 26.4k]
  ------------------
  336|       |#if HAVE_ZLIB
  337|       |            /* zlib encoded track */
  338|       |
  339|       |            if (size == 0)
  340|       |                continue;
  341|       |
  342|       |            z_stream zstream;
  343|       |
  344|       |            zstream.zalloc = (alloc_func) 0;
  345|       |            zstream.zfree = (free_func) 0;
  346|       |            zstream.opaque = (voidpf) 0;
  347|       |            if (inflateInit(&zstream) != Z_OK) {
  348|       |                mp_warn(log, "zlib initialization failed.\n");
  349|       |                goto error;
  350|       |            }
  351|       |            zstream.next_in = (Bytef *) src;
  352|       |            zstream.avail_in = size;
  353|       |
  354|       |            dest = NULL;
  355|       |            zstream.avail_out = size;
  356|       |            int result;
  357|       |            do {
  358|       |                if (size >= INT_MAX - 4000) {
  359|       |                    talloc_free(dest);
  360|       |                    dest = NULL;
  361|       |                    inflateEnd(&zstream);
  362|       |                    goto error;
  363|       |                }
  364|       |                size += 4000;
  365|       |                dest = talloc_realloc_size(track->parser_tmp, dest, size);
  366|       |                zstream.next_out = (Bytef *) (dest + zstream.total_out);
  367|       |                result = inflate(&zstream, Z_NO_FLUSH);
  368|       |                if (result != Z_OK && result != Z_STREAM_END) {
  369|       |                    mp_warn(log, "zlib decompression failed.\n");
  370|       |                    talloc_free(dest);
  371|       |                    dest = NULL;
  372|       |                    inflateEnd(&zstream);
  373|       |                    goto error;
  374|       |                }
  375|       |                zstream.avail_out += 4000;
  376|       |            } while (zstream.avail_out == 4000 && zstream.avail_in != 0
  377|       |                     && result != Z_STREAM_END);
  378|       |
  379|       |            size = zstream.total_out;
  380|       |            inflateEnd(&zstream);
  381|       |            // The output can be the input of a following LZO encoding, so zero
  382|       |            // its input padding.
  383|       |            mp_require(zstream.avail_out >= AV_LZO_INPUT_PADDING);
  384|       |            memset(dest + size, 0, AV_LZO_INPUT_PADDING);
  385|       |#endif
  386|  26.4k|        } else if (enc->comp_algo == 2) {
  ------------------
  |  Branch (386:20): [True: 4.49k, False: 21.9k]
  ------------------
  387|       |            /* lzo encoded track */
  388|  4.49k|            int out_avail;
  389|  4.49k|            int maxlen = INT_MAX - AV_LZO_OUTPUT_PADDING;
  390|  4.49k|            if (size >= maxlen / 3)
  ------------------
  |  Branch (390:17): [True: 0, False: 4.49k]
  ------------------
  391|      0|                goto error;
  392|  4.49k|            int dstlen = size * 3;
  393|       |
  394|  4.49k|            dest = NULL;
  395|  4.49k|            while (1) {
  ------------------
  |  Branch (395:20): [True: 4.49k, Folded]
  ------------------
  396|  4.49k|                int srclen = size;
  397|  4.49k|                dest = talloc_realloc_size(track->parser_tmp, dest,
  ------------------
  |  |   39|  4.49k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  4.49k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.49k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  4.49k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  4.49k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|  4.49k|                                           dstlen + AV_LZO_OUTPUT_PADDING);
  399|  4.49k|                out_avail = dstlen;
  400|  4.49k|                int result = av_lzo1x_decode(dest, &out_avail, src, &srclen);
  401|  4.49k|                if (result == 0)
  ------------------
  |  Branch (401:21): [True: 0, False: 4.49k]
  ------------------
  402|      0|                    break;
  403|  4.49k|                if (!(result & AV_LZO_OUTPUT_FULL)) {
  ------------------
  |  Branch (403:21): [True: 4.49k, False: 0]
  ------------------
  404|  4.49k|                    mp_warn(log, "lzo decompression failed.\n");
  ------------------
  |  |   77|  4.49k|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  405|  4.49k|                    talloc_free(dest);
  ------------------
  |  |   47|  4.49k|#define talloc_free                     ta_free
  ------------------
  406|  4.49k|                    dest = NULL;
  407|  4.49k|                    goto error;
  408|  4.49k|                }
  409|      0|                mp_trace(log, "lzo decompression buffer too small.\n");
  ------------------
  |  |   81|      0|#define mp_trace(log, ...)      mp_msg(log, MSGL_TRACE, __VA_ARGS__)
  ------------------
  410|      0|                if (dstlen >= maxlen / 2) {
  ------------------
  |  Branch (410:21): [True: 0, False: 0]
  ------------------
  411|      0|                    talloc_free(dest);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  412|      0|                    dest = NULL;
  413|      0|                    goto error;
  414|      0|                }
  415|      0|                dstlen = MPMAX(1, 2 * dstlen);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  416|      0|            }
  417|      0|            size = dstlen - out_avail;
  418|       |            // The output can be the input of a following LZO encoding, so zero
  419|       |            // its input padding. The output padding always covers it.
  420|      0|            static_assert(AV_LZO_OUTPUT_PADDING >= AV_LZO_INPUT_PADDING, "");
  421|      0|            memset(dest + size, 0, AV_LZO_INPUT_PADDING);
  422|  21.9k|        } else if (enc->comp_algo == 3) {
  ------------------
  |  Branch (422:20): [True: 21.8k, False: 106]
  ------------------
  423|  21.8k|            if (enc->comp_settings_len == 0 || !enc->comp_settings) {
  ------------------
  |  Branch (423:17): [True: 188, False: 21.6k]
  |  Branch (423:48): [True: 0, False: 21.6k]
  ------------------
  424|    188|                mp_warn(log, "missing comp_settings, unable to reconstruct the data.\n");
  ------------------
  |  |   77|    188|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  425|    188|                goto error;
  426|    188|            }
  427|  21.6k|            dest = talloc_size(track->parser_tmp,
  ------------------
  |  |   43|  21.6k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  21.6k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  21.6k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|  21.6k|                               size + enc->comp_settings_len + AV_LZO_INPUT_PADDING);
  429|  21.6k|            memcpy(dest, enc->comp_settings, enc->comp_settings_len);
  430|  21.6k|            memcpy(dest + enc->comp_settings_len, src, size);
  431|  21.6k|            size += enc->comp_settings_len;
  432|  21.6k|            memset(dest + size, 0, AV_LZO_INPUT_PADDING);
  433|  21.6k|        }
  434|  28.6k|    }
  435|       |
  436|   778k| error:
  437|   778k|    if (src != dest && src != orig_src)
  ------------------
  |  Branch (437:9): [True: 26.1k, False: 752k]
  |  Branch (437:24): [True: 0, False: 26.1k]
  ------------------
  438|      0|        talloc_free(src);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  439|   778k|    if (!size)
  ------------------
  |  Branch (439:9): [True: 3.10k, False: 775k]
  ------------------
  440|  3.10k|        dest = NULL;
  441|   778k|    if (!dest)
  ------------------
  |  Branch (441:9): [True: 7.59k, False: 771k]
  ------------------
  442|  7.59k|        size = 0;
  443|   778k|    return (bstr){dest, size};
  444|   778k|}
demux_mkv.c:pair_dovi_tracks:
 2301|  24.2k|{
 2302|  24.2k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2303|  24.2k|    mkv_track_t *bl_track = NULL, *el_track = NULL;
 2304|       |
 2305|  68.0k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (2305:21): [True: 43.7k, False: 24.2k]
  ------------------
 2306|  43.7k|        mkv_track_t *track = mkv_d->tracks[i];
 2307|  43.7k|        if (!track->stream || track->stream->type != STREAM_VIDEO ||
  ------------------
  |  Branch (2307:13): [True: 1.76k, False: 42.0k]
  |  Branch (2307:31): [True: 22.4k, False: 19.5k]
  ------------------
 2308|  19.5k|            !track->codec_id || strcmp(track->codec_id, "V_MPEGH/ISO/HEVC"))
  ------------------
  |  Branch (2308:13): [True: 0, False: 19.5k]
  |  Branch (2308:33): [True: 19.1k, False: 408]
  ------------------
 2309|  43.3k|            continue;
 2310|       |
 2311|    408|        AVDOVIDecoderConfigurationRecord *dovi = track->dovi_config;
 2312|    408|        if (dovi && dovi->dv_profile == 7 && dovi->el_present_flag) {
  ------------------
  |  Branch (2312:13): [True: 0, False: 408]
  |  Branch (2312:21): [True: 0, False: 0]
  |  Branch (2312:46): [True: 0, False: 0]
  ------------------
 2313|       |            // bl_present_flag is not checked, because the files in the
 2314|       |            // wild set it to 1 for EL stream, while the expectation, based
 2315|       |            // on Dolby spec for MPEG-TS would be that it's set to 0.
 2316|       |            // Ignore this, if we have EL track and single other video track
 2317|       |            // it's safe to assume it's BL.
 2318|      0|            if (el_track)
  ------------------
  |  Branch (2318:17): [True: 0, False: 0]
  ------------------
 2319|      0|                return;
 2320|      0|            el_track = track;
 2321|      0|            continue;
 2322|      0|        }
 2323|       |
 2324|    408|        if (bl_track)
  ------------------
  |  Branch (2324:13): [True: 0, False: 408]
  ------------------
 2325|      0|            return;
 2326|    408|        bl_track = track;
 2327|    408|    }
 2328|       |
 2329|  24.2k|    if (!el_track || !bl_track)
  ------------------
  |  Branch (2329:9): [True: 24.2k, False: 0]
  |  Branch (2329:22): [True: 0, False: 0]
  ------------------
 2330|  24.2k|        return;
 2331|       |
 2332|      0|    struct sh_stream *bl_sh = bl_track->stream;
 2333|      0|    struct sh_stream *el_sh = el_track->stream;
 2334|       |
 2335|       |    // Group storage is attached to the BL so its lifetime tracks the demuxer.
 2336|      0|    struct sh_stream_group *group = talloc_zero(bl_sh, struct sh_stream_group);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2337|      0|    MP_TARRAY_APPEND(group, group->members, group->num_members, bl_sh);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2338|      0|    MP_TARRAY_APPEND(group, group->members, group->num_members, el_sh);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2339|       |
 2340|      0|    bl_sh->group = group;
 2341|      0|    el_sh->group = group;
 2342|       |    el_sh->dependent_track = true;
 2343|      0|}
demux_mkv.c:add_coverart:
 1547|  24.2k|{
 1548|  25.3k|    for (int n = 0; n < demuxer->num_attachments; n++) {
  ------------------
  |  Branch (1548:21): [True: 1.13k, False: 24.2k]
  ------------------
 1549|  1.13k|        struct demux_attachment *att = &demuxer->attachments[n];
 1550|  1.13k|        const char *codec = mp_map_mimetype_to_video_codec(att->type);
 1551|  1.13k|        if (!codec)
  ------------------
  |  Branch (1551:13): [True: 841, False: 292]
  ------------------
 1552|    841|            continue;
 1553|    292|        struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
 1554|    292|        sh->codec->codec = codec;
 1555|    292|        sh->attached_picture = new_demux_packet_from(demuxer->packet_pool,
 1556|    292|                                                     att->data, att->data_size);
 1557|    292|        if (sh->attached_picture) {
  ------------------
  |  Branch (1557:13): [True: 292, False: 0]
  ------------------
 1558|    292|            sh->attached_picture->pts = 0;
 1559|    292|            talloc_steal(sh, sh->attached_picture);
  ------------------
  |  |   38|    292|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    292|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1560|    292|            sh->attached_picture->keyframe = true;
 1561|       |            sh->image = true;
 1562|    292|        }
 1563|    292|        sh->title = att->name;
 1564|    292|        demux_add_sh_stream(demuxer, sh);
 1565|    292|    }
 1566|  24.2k|}
demux_mkv.c:process_tags:
 1314|  24.2k|{
 1315|  24.2k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1316|  24.2k|    struct ebml_tags *tags = mkv_d->tags;
 1317|       |
 1318|  24.2k|    if (!tags)
  ------------------
  |  Branch (1318:9): [True: 17.3k, False: 6.86k]
  ------------------
 1319|  17.3k|        return;
 1320|       |
 1321|  15.9k|    for (int i = 0; i < tags->n_tag; i++) {
  ------------------
  |  Branch (1321:21): [True: 9.11k, False: 6.86k]
  ------------------
 1322|  9.11k|        struct ebml_tag tag = tags->tag[i];
 1323|  9.11k|        struct mp_tags *dst = NULL;
 1324|       |
 1325|  9.11k|        if (tag.targets.target_chapter_uid) {
  ------------------
  |  Branch (1325:13): [True: 11, False: 9.10k]
  ------------------
 1326|     21|            for (int n = 0; n < demuxer->num_chapters; n++) {
  ------------------
  |  Branch (1326:29): [True: 10, False: 11]
  ------------------
 1327|     10|                if (demuxer->chapters[n].demuxer_id ==
  ------------------
  |  Branch (1327:21): [True: 0, False: 10]
  ------------------
 1328|     10|                    tag.targets.target_chapter_uid)
 1329|      0|                {
 1330|      0|                    dst = demuxer->chapters[n].metadata;
 1331|      0|                    break;
 1332|      0|                }
 1333|     10|            }
 1334|  9.10k|        } else if (tag.targets.target_edition_uid) {
  ------------------
  |  Branch (1334:20): [True: 11, False: 9.09k]
  ------------------
 1335|     19|            for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (1335:29): [True: 8, False: 11]
  ------------------
 1336|      8|                if (demuxer->editions[n].demuxer_id ==
  ------------------
  |  Branch (1336:21): [True: 0, False: 8]
  ------------------
 1337|      8|                    tag.targets.target_edition_uid)
 1338|      0|                {
 1339|      0|                    dst = demuxer->editions[n].metadata;
 1340|      0|                    break;
 1341|      0|                }
 1342|      8|            }
 1343|  9.09k|        } else if (tag.targets.target_track_uid) {
  ------------------
  |  Branch (1343:20): [True: 3.63k, False: 5.45k]
  ------------------
 1344|  7.99k|            for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (1344:29): [True: 7.10k, False: 889]
  ------------------
 1345|  7.10k|                if (mkv_d->tracks[n]->uid ==
  ------------------
  |  Branch (1345:21): [True: 2.74k, False: 4.35k]
  ------------------
 1346|  7.10k|                    tag.targets.target_track_uid)
 1347|  2.74k|                {
 1348|  2.74k|                    struct sh_stream *sh = mkv_d->tracks[n]->stream;
 1349|  2.74k|                    if (sh)
  ------------------
  |  Branch (1349:25): [True: 2.69k, False: 49]
  ------------------
 1350|  2.69k|                        dst = sh->tags;
 1351|  2.74k|                    break;
 1352|  2.74k|                }
 1353|  7.10k|            }
 1354|  5.45k|        } else if (tag.targets.target_attachment_uid) {
  ------------------
  |  Branch (1354:20): [True: 9, False: 5.44k]
  ------------------
 1355|       |            /* ignore */
 1356|  5.44k|        } else {
 1357|  5.44k|            dst = demuxer->metadata;
 1358|  5.44k|        }
 1359|       |
 1360|  9.11k|        if (dst) {
  ------------------
  |  Branch (1360:13): [True: 8.14k, False: 969]
  ------------------
 1361|  19.0k|            for (int j = 0; j < tag.n_simple_tag; j++) {
  ------------------
  |  Branch (1361:29): [True: 10.8k, False: 8.14k]
  ------------------
 1362|  10.8k|                if (tag.simple_tag[j].tag_name && tag.simple_tag[j].tag_string) {
  ------------------
  |  Branch (1362:21): [True: 10.3k, False: 482]
  |  Branch (1362:51): [True: 9.85k, False: 531]
  ------------------
 1363|  9.85k|                    char *name = tag.simple_tag[j].tag_name;
 1364|  9.85k|                    char *val = tag.simple_tag[j].tag_string;
 1365|  9.85k|                    char *old = mp_tags_get_str(dst, name);
 1366|  9.85k|                    if (old)
  ------------------
  |  Branch (1366:25): [True: 6, False: 9.84k]
  ------------------
 1367|      6|                        val = talloc_asprintf(NULL, "%s / %s", old, val);
  ------------------
  |  |   52|      6|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      6|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1368|  9.85k|                    mp_tags_set_str(dst, name, val);
 1369|  9.85k|                    if (old)
  ------------------
  |  Branch (1369:25): [True: 6, False: 9.84k]
  ------------------
 1370|      6|                        talloc_free(val);
  ------------------
  |  |   47|      6|#define talloc_free                     ta_free
  ------------------
 1371|  9.85k|                }
 1372|  10.8k|            }
 1373|  8.14k|        }
 1374|  9.11k|    }
 1375|  6.86k|}
demux_mkv.c:probe_first_timestamp:
 3775|  24.2k|{
 3776|  24.2k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 3777|       |
 3778|  24.2k|    if (!mkv_d->opts->probe_start_time)
  ------------------
  |  Branch (3778:9): [True: 0, False: 24.2k]
  ------------------
 3779|      0|        return;
 3780|       |
 3781|  24.2k|    read_next_block_into_queue(demuxer);
 3782|       |
 3783|  24.2k|    demuxer->start_time = mkv_d->cluster_tc / 1e9;
 3784|       |
 3785|  24.2k|    if (demuxer->start_time)
  ------------------
  |  Branch (3785:9): [True: 363, False: 23.8k]
  ------------------
 3786|  24.2k|        MP_VERBOSE(demuxer, "Start PTS: %f\n", demuxer->start_time);
  ------------------
  |  |   92|    363|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    363|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3787|  24.2k|}
demux_mkv.c:read_next_block_into_queue:
 3337|   528k|{
 3338|   528k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3339|   528k|    stream_t *s = demuxer->stream;
 3340|   528k|    struct block_info block = {0};
 3341|       |
 3342|   727k|    while (1) {
  ------------------
  |  Branch (3342:12): [True: 727k, Folded]
  ------------------
 3343|  1.16M|        while (stream_tell(s) < mkv_d->cluster_end) {
  ------------------
  |  Branch (3343:16): [True: 1.12M, False: 42.2k]
  ------------------
 3344|  1.12M|            int64_t start_filepos = stream_tell(s);
 3345|  1.12M|            switch (ebml_read_id(s)) {
 3346|  78.3k|            case MATROSKA_ID_TIMECODE: {
  ------------------
  |  |   29|  78.3k|#define MATROSKA_ID_TIMECODE                     0xe7
  ------------------
  |  Branch (3346:13): [True: 78.3k, False: 1.04M]
  ------------------
 3347|  78.3k|                uint64_t num;
 3348|       |                // Block timestamps add up to INT16_MAX ticks to this.
 3349|  78.3k|                if (!ebml_read_uint(s, &num) || num > INT64_MAX / mkv_d->tc_scale - INT16_MAX)
  ------------------
  |  Branch (3349:21): [True: 888, False: 77.4k]
  |  Branch (3349:49): [True: 430, False: 77.0k]
  ------------------
 3350|  1.31k|                    goto find_next_cluster;
 3351|  77.0k|                mkv_d->cluster_tc = num * mkv_d->tc_scale;
 3352|  77.0k|                break;
 3353|  78.3k|            }
 3354|       |
 3355|   100k|            case MATROSKA_ID_BLOCKGROUP: {
  ------------------
  |  |   30|   100k|#define MATROSKA_ID_BLOCKGROUP                   0xa0
  ------------------
  |  Branch (3355:13): [True: 100k, False: 1.02M]
  ------------------
 3356|   100k|                uint64_t end = ebml_read_length(s);
 3357|   100k|                if (end == EBML_UINT_INVALID)
  ------------------
  |  |   85|   100k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3357:21): [True: 183, False: 99.9k]
  ------------------
 3358|    183|                    goto find_next_cluster;
 3359|  99.9k|                end += stream_tell(s);
 3360|  99.9k|                if (end > mkv_d->cluster_end)
  ------------------
  |  Branch (3360:21): [True: 459, False: 99.4k]
  ------------------
 3361|    459|                    goto find_next_cluster;
 3362|  99.4k|                int res = read_block_group(demuxer, end, &block);
 3363|  99.4k|                if (res > 0)
  ------------------
  |  Branch (3363:21): [True: 65.8k, False: 33.6k]
  ------------------
 3364|  65.8k|                    goto add_block;
 3365|  33.6k|                free_block(&block);
 3366|  33.6k|                if (res < 0)
  ------------------
  |  Branch (3366:21): [True: 26.2k, False: 7.43k]
  ------------------
 3367|  26.2k|                    goto find_next_cluster;
 3368|  7.43k|                break;
 3369|  33.6k|            }
 3370|       |
 3371|   561k|            case MATROSKA_ID_SIMPLEBLOCK: {
  ------------------
  |  |   39|   561k|#define MATROSKA_ID_SIMPLEBLOCK                  0xa3
  ------------------
  |  Branch (3371:13): [True: 561k, False: 561k]
  ------------------
 3372|   561k|                block = (struct block_info){ .simple = true };
 3373|   561k|                int res = read_block(demuxer, mkv_d->cluster_end, &block);
 3374|   561k|                if (res > 0)
  ------------------
  |  Branch (3374:21): [True: 423k, False: 137k]
  ------------------
 3375|   423k|                    goto add_block;
 3376|   137k|                free_block(&block);
 3377|   137k|                if (res < 0)
  ------------------
  |  Branch (3377:21): [True: 33.0k, False: 104k]
  ------------------
 3378|  33.0k|                    goto find_next_cluster;
 3379|   104k|                break;
 3380|   137k|            }
 3381|       |
 3382|   104k|            case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|  12.1k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3382:13): [True: 12.1k, False: 1.11M]
  ------------------
 3383|  12.1k|                mkv_d->cluster_start = start_filepos;
 3384|  12.1k|                goto next_cluster;
 3385|       |
 3386|  58.5k|            case EBML_ID_INVALID:
  ------------------
  |  |   75|  58.5k|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (3386:13): [True: 58.5k, False: 1.06M]
  ------------------
 3387|  58.5k|                goto find_next_cluster;
 3388|       |
 3389|   312k|            default: ;
  ------------------
  |  Branch (3389:13): [True: 312k, False: 810k]
  ------------------
 3390|   312k|                if (ebml_read_skip(demuxer->log, mkv_d->cluster_end, s) != 0)
  ------------------
  |  Branch (3390:21): [True: 64.0k, False: 248k]
  ------------------
 3391|  64.0k|                    goto find_next_cluster;
 3392|   248k|                break;
 3393|  1.12M|            }
 3394|  1.12M|        }
 3395|       |
 3396|   226k|    find_next_cluster:
 3397|   226k|        mkv_d->cluster_end = 0;
 3398|   397k|        for (;;) {
 3399|   397k|            mkv_d->cluster_start = stream_tell(s);
 3400|   397k|            uint32_t id = ebml_read_id(s);
 3401|   397k|            if (id == MATROSKA_ID_CLUSTER)
  ------------------
  |  |   28|   397k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3401:17): [True: 186k, False: 210k]
  ------------------
 3402|   186k|                break;
 3403|   210k|            if (s->eof)
  ------------------
  |  Branch (3403:17): [True: 39.2k, False: 170k]
  ------------------
 3404|  39.2k|                return -1;
 3405|   170k|            if (demux_cancel_test(demuxer))
  ------------------
  |  Branch (3405:17): [True: 0, False: 170k]
  ------------------
 3406|      0|                return -1;
 3407|   170k|            if (id == EBML_ID_EBML && stream_tell(s) >= mkv_d->segment_end) {
  ------------------
  |  |    3|   341k|#define EBML_ID_EBML                             0x1a45dfa3
  ------------------
  |  Branch (3407:17): [True: 1.60k, False: 169k]
  |  Branch (3407:39): [True: 16, False: 1.58k]
  ------------------
 3408|       |                // Appended segment - don't use its clusters, consider this EOF.
 3409|     16|                stream_seek(s, stream_tell(s) - 4);
 3410|     16|                return -1;
 3411|     16|            }
 3412|       |            // For the sake of robustness, consider even unknown level 1
 3413|       |            // elements the same as unknown/broken IDs.
 3414|   170k|            if ((!ebml_is_mkv_level1_id(id) && id != EBML_ID_VOID) ||
  ------------------
  |  |   12|   170k|#define EBML_ID_VOID                             0xec
  ------------------
  |  Branch (3414:18): [True: 170k, False: 425]
  |  Branch (3414:48): [True: 169k, False: 493]
  ------------------
 3415|    918|                ebml_read_skip(demuxer->log, -1, s) != 0)
  ------------------
  |  Branch (3415:17): [True: 501, False: 417]
  ------------------
 3416|   170k|            {
 3417|   170k|                stream_seek(s, mkv_d->cluster_start);
 3418|   170k|                ebml_resync_cluster(demuxer->log, s);
 3419|   170k|            }
 3420|   170k|        }
 3421|   199k|    next_cluster:
 3422|   199k|        mkv_d->cluster_end = ebml_read_length(s);
 3423|       |        // mkv files for "streaming" can have this legally
 3424|   199k|        if (mkv_d->cluster_end != EBML_UINT_INVALID)
  ------------------
  |  |   85|   199k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3424:13): [True: 190k, False: 8.29k]
  ------------------
 3425|   190k|            mkv_d->cluster_end += stream_tell(s);
 3426|   199k|    }
 3427|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (3427:5): [Folded, False: 0]
  ------------------
 3428|       |
 3429|   489k|add_block:
 3430|   489k|    index_block(demuxer, &block);
 3431|   489k|    MP_TARRAY_APPEND(mkv_d, mkv_d->blocks, mkv_d->num_blocks, block);
  ------------------
  |  |  105|   489k|    do {                                            \
  |  |  106|   489k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   489k|    do {                                            \
  |  |  |  |   97|   489k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   489k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   489k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   489k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 31.4k, False: 458k]
  |  |  |  |  ------------------
  |  |  |  |   99|   489k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  31.4k|    do {                                                        \
  |  |  |  |  |  |   89|  31.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  31.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  31.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  31.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  31.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  31.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  31.4k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 31.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   489k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 489k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   489k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   489k|        (idxvar)++;                                 \
  |  |  109|   489k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 489k]
  |  |  ------------------
  ------------------
 3432|   489k|    return 1;
 3433|      0|}
demux_mkv.c:read_block_group:
 3270|  99.4k|{
 3271|  99.4k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3272|  99.4k|    stream_t *s = demuxer->stream;
 3273|  99.4k|    *block = (struct block_info){ .keyframe = true };
 3274|       |
 3275|   231k|    while (stream_tell(s) < end) {
  ------------------
  |  Branch (3275:12): [True: 157k, False: 73.2k]
  ------------------
 3276|   157k|        switch (ebml_read_id(s)) {
 3277|  4.10k|        case MATROSKA_ID_BLOCKDURATION:;
  ------------------
  |  |   32|  4.10k|#define MATROSKA_ID_BLOCKDURATION                0x9b
  ------------------
  |  Branch (3277:9): [True: 4.10k, False: 153k]
  ------------------
 3278|  4.10k|            uint64_t duration;
 3279|  4.10k|            if (!ebml_read_uint(s, &duration))
  ------------------
  |  Branch (3279:17): [True: 1.66k, False: 2.44k]
  ------------------
 3280|  1.66k|                goto error;
 3281|  2.44k|            if (duration <= INT64_MAX / mkv_d->tc_scale) {
  ------------------
  |  Branch (3281:17): [True: 2.40k, False: 35]
  ------------------
 3282|  2.40k|                block->duration = duration * mkv_d->tc_scale;
 3283|  2.40k|                block->duration_known = true;
 3284|  2.40k|            }
 3285|  2.44k|            break;
 3286|       |
 3287|    349|        case MATROSKA_ID_DISCARDPADDING:
  ------------------
  |  |   34|    349|#define MATROSKA_ID_DISCARDPADDING               0x75a2
  ------------------
  |  Branch (3287:9): [True: 349, False: 157k]
  ------------------
 3288|    349|            if (!ebml_read_int(s, &block->discardpadding))
  ------------------
  |  Branch (3288:17): [True: 258, False: 91]
  ------------------
 3289|    258|                goto error;
 3290|     91|            break;
 3291|       |
 3292|  83.0k|        case MATROSKA_ID_BLOCK:
  ------------------
  |  |   31|  83.0k|#define MATROSKA_ID_BLOCK                        0xa1
  ------------------
  |  Branch (3292:9): [True: 83.0k, False: 74.7k]
  ------------------
 3293|  83.0k|            if (read_block(demuxer, end, block) < 0)
  ------------------
  |  Branch (3293:17): [True: 2.68k, False: 80.3k]
  ------------------
 3294|  2.68k|                goto error;
 3295|  80.3k|            break;
 3296|       |
 3297|  80.3k|        case MATROSKA_ID_REFERENCEBLOCK:;
  ------------------
  |  |   33|  36.6k|#define MATROSKA_ID_REFERENCEBLOCK               0xfb
  ------------------
  |  Branch (3297:9): [True: 36.6k, False: 121k]
  ------------------
 3298|  36.6k|            int64_t num;
 3299|  36.6k|            if (!ebml_read_int(s, &num))
  ------------------
  |  Branch (3299:17): [True: 782, False: 35.8k]
  ------------------
 3300|    782|                goto error;
 3301|  35.8k|            block->keyframe = false;
 3302|  35.8k|            break;
 3303|       |
 3304|  3.65k|        case MATROSKA_ID_BLOCKADDITIONS:;
  ------------------
  |  |   35|  3.65k|#define MATROSKA_ID_BLOCKADDITIONS               0x75a1
  ------------------
  |  Branch (3304:9): [True: 3.65k, False: 154k]
  ------------------
 3305|  3.65k|            struct ebml_block_additions additions = {0};
 3306|  3.65k|            struct ebml_parse_ctx parse_ctx = {demuxer->log};
 3307|  3.65k|            if (ebml_read_element(s, &parse_ctx, &additions,
  ------------------
  |  Branch (3307:17): [True: 141, False: 3.51k]
  ------------------
 3308|  3.65k|                                  &ebml_block_additions_desc) < 0)
 3309|    141|                return -1;
 3310|  3.51k|            if (additions.n_block_more > 0 && !block->additions) {
  ------------------
  |  Branch (3310:17): [True: 3.29k, False: 220]
  |  Branch (3310:47): [True: 2.15k, False: 1.13k]
  ------------------
 3311|  2.15k|                block->additions = talloc_dup(NULL, &additions);
  ------------------
  |  |   48|  2.15k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  2.15k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.15k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3312|  2.15k|                talloc_steal(block->additions, parse_ctx.talloc_ctx);
  ------------------
  |  |   38|  2.15k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.15k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3313|  2.15k|                parse_ctx.talloc_ctx = NULL;
 3314|  2.15k|            }
 3315|  3.51k|            talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  3.51k|#define talloc_free                     ta_free
  ------------------
 3316|  3.51k|            break;
 3317|       |
 3318|    612|        case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|    612|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3318:9): [True: 612, False: 157k]
  ------------------
 3319|  16.2k|        case EBML_ID_INVALID:
  ------------------
  |  |   75|  16.2k|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (3319:9): [True: 15.6k, False: 142k]
  ------------------
 3320|  16.2k|            goto error;
 3321|       |
 3322|  13.7k|        default:
  ------------------
  |  Branch (3322:9): [True: 13.7k, False: 144k]
  ------------------
 3323|  13.7k|            if (ebml_read_skip(demuxer->log, end, s) != 0)
  ------------------
  |  Branch (3323:17): [True: 4.41k, False: 9.28k]
  ------------------
 3324|  4.41k|                goto error;
 3325|  9.28k|            break;
 3326|   157k|        }
 3327|   157k|    }
 3328|       |
 3329|  73.2k|    return block->num_laces ? 1 : 0;
  ------------------
  |  Branch (3329:12): [True: 65.8k, False: 7.43k]
  ------------------
 3330|       |
 3331|  26.0k|error:
 3332|  26.0k|    free_block(block);
 3333|  26.0k|    return -1;
 3334|  99.4k|}
demux_mkv.c:free_block:
 3051|  1.47M|{
 3052|  2.81M|    for (int n = 0; n < block->num_laces; n++)
  ------------------
  |  Branch (3052:21): [True: 1.33M, False: 1.47M]
  ------------------
 3053|  1.33M|        av_buffer_unref(&block->laces[n]);
 3054|  1.47M|    block->num_laces = 0;
 3055|       |    TA_FREEP(&block->additions);
  ------------------
  |  |   81|  1.47M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  1.47M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 1.47M]
  |  |  ------------------
  ------------------
 3056|  1.47M|}
demux_mkv.c:read_block:
 3069|   644k|{
 3070|   644k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3071|   644k|    stream_t *s = demuxer->stream;
 3072|   644k|    uint64_t num;
 3073|   644k|    int16_t time;
 3074|   644k|    uint64_t length;
 3075|       |
 3076|   644k|    free_block(block);
 3077|   644k|    length = ebml_read_length(s);
 3078|   644k|    if (!length || length > 500000000 || stream_tell(s) + length > (uint64_t)end)
  ------------------
  |  Branch (3078:9): [True: 428, False: 643k]
  |  Branch (3078:20): [True: 1.14k, False: 642k]
  |  Branch (3078:42): [True: 1.03k, False: 641k]
  ------------------
 3079|  2.60k|        return -1;
 3080|       |
 3081|   641k|    uint64_t endpos = stream_tell(s) + length;
 3082|   641k|    int res = -1;
 3083|       |
 3084|       |    // Parse header of the Block element
 3085|       |    /* first byte(s): track num */
 3086|   641k|    num = ebml_read_length(s);
 3087|   641k|    if (num == EBML_UINT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   85|  1.28M|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3087:9): [True: 6.03k, False: 635k]
  |  Branch (3087:37): [True: 1.57k, False: 633k]
  ------------------
 3088|  7.60k|        goto exit;
 3089|       |
 3090|       |    /* time (relative to cluster time) */
 3091|   633k|    if (stream_tell(s) + 3 > endpos)
  ------------------
  |  Branch (3091:9): [True: 801, False: 633k]
  ------------------
 3092|    801|        goto exit;
 3093|   633k|    uint8_t c1 = stream_read_char(s);
 3094|   633k|    uint8_t c2 = stream_read_char(s);
 3095|   633k|    time = c1 << 8 | c2;
 3096|       |
 3097|   633k|    uint8_t header_flags = stream_read_char(s);
 3098|       |
 3099|   633k|    block->filepos = stream_tell(s);
 3100|       |
 3101|   633k|    int lace_type = (header_flags >> 1) & 0x03;
 3102|   633k|    if (demux_mkv_read_block_lacing(block, lace_type, s, endpos))
  ------------------
  |  Branch (3102:9): [True: 24.7k, False: 608k]
  ------------------
 3103|  24.7k|        goto exit;
 3104|       |
 3105|   608k|    if (block->simple)
  ------------------
  |  Branch (3105:9): [True: 528k, False: 80.3k]
  ------------------
 3106|   528k|        block->keyframe = header_flags & 0x80;
 3107|   608k|    block->timecode = time * mkv_d->tc_scale + mkv_d->cluster_tc;
 3108|   930k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (3108:21): [True: 814k, False: 115k]
  ------------------
 3109|   814k|        if (mkv_d->tracks[i]->tnum == num) {
  ------------------
  |  Branch (3109:13): [True: 492k, False: 321k]
  ------------------
 3110|   492k|            block->track = mkv_d->tracks[i];
 3111|   492k|            break;
 3112|   492k|        }
 3113|   814k|    }
 3114|   608k|    if (!block->track) {
  ------------------
  |  Branch (3114:9): [True: 115k, False: 492k]
  ------------------
 3115|   115k|        res = 0;
 3116|   115k|        goto exit;
 3117|   115k|    }
 3118|       |
 3119|   492k|    if (stream_tell(s) != endpos)
  ------------------
  |  Branch (3119:9): [True: 0, False: 492k]
  ------------------
 3120|      0|        goto exit;
 3121|       |
 3122|   492k|    res = 1;
 3123|   641k|exit:
 3124|   641k|    if (res <= 0)
  ------------------
  |  Branch (3124:9): [True: 149k, False: 492k]
  ------------------
 3125|   149k|        free_block(block);
 3126|   641k|    stream_seek_skip(s, endpos);
 3127|   641k|    return res;
 3128|   492k|}
demux_mkv.c:demux_mkv_read_block_lacing:
 2644|   633k|{
 2645|   633k|    int laces;
 2646|   633k|    uint32_t lace_size[MAX_NUM_LACES];
 2647|       |
 2648|       |
 2649|   633k|    if (type == 0) {           /* no lacing */
  ------------------
  |  Branch (2649:9): [True: 569k, False: 64.0k]
  ------------------
 2650|   569k|        laces = 1;
 2651|   569k|        lace_size[0] = endpos - stream_tell(s);
 2652|   569k|    } else {
 2653|  64.0k|        laces = stream_read_char(s);
 2654|  64.0k|        if (laces < 0 || stream_tell(s) > endpos)
  ------------------
  |  Branch (2654:13): [True: 17, False: 64.0k]
  |  Branch (2654:26): [True: 132, False: 63.8k]
  ------------------
 2655|    149|            goto error;
 2656|  63.8k|        laces += 1;
 2657|       |
 2658|  63.8k|        switch (type) {
 2659|  14.9k|        case 1: {              /* xiph lacing */
  ------------------
  |  Branch (2659:9): [True: 14.9k, False: 48.9k]
  ------------------
 2660|  14.9k|            uint32_t total = 0;
 2661|  89.7k|            for (int i = 0; i < laces - 1; i++) {
  ------------------
  |  Branch (2661:29): [True: 76.2k, False: 13.5k]
  ------------------
 2662|  76.2k|                lace_size[i] = 0;
 2663|  76.2k|                uint8_t t;
 2664|  78.3k|                do {
 2665|  78.3k|                    t = stream_read_char(s);
 2666|  78.3k|                    if (s->eof || stream_tell(s) >= endpos)
  ------------------
  |  Branch (2666:25): [True: 36, False: 78.3k]
  |  Branch (2666:35): [True: 1.40k, False: 76.8k]
  ------------------
 2667|  1.43k|                        goto error;
 2668|  76.8k|                    lace_size[i] += t;
 2669|  76.8k|                } while (t == 0xFF);
  ------------------
  |  Branch (2669:26): [True: 2.11k, False: 74.7k]
  ------------------
 2670|  74.7k|                total += lace_size[i];
 2671|  74.7k|            }
 2672|  13.5k|            uint32_t rest_length = endpos - stream_tell(s);
 2673|  13.5k|            lace_size[laces - 1] = rest_length - total;
 2674|  13.5k|            break;
 2675|  14.9k|        }
 2676|       |
 2677|  15.4k|        case 2: {              /* fixed-size lacing */
  ------------------
  |  Branch (2677:9): [True: 15.4k, False: 48.4k]
  ------------------
 2678|  15.4k|            uint32_t full_length = endpos - stream_tell(s);
 2679|   600k|            for (int i = 0; i < laces; i++)
  ------------------
  |  Branch (2679:29): [True: 584k, False: 15.4k]
  ------------------
 2680|   584k|                lace_size[i] = full_length / laces;
 2681|  15.4k|            break;
 2682|  14.9k|        }
 2683|       |
 2684|  33.5k|        case 3: {              /* EBML lacing */
  ------------------
  |  Branch (2684:9): [True: 33.5k, False: 30.3k]
  ------------------
 2685|  33.5k|            uint64_t num = ebml_read_length(s);
 2686|  33.5k|            if (num == EBML_UINT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   85|  67.0k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (2686:17): [True: 2.28k, False: 31.2k]
  |  Branch (2686:45): [True: 499, False: 30.7k]
  ------------------
 2687|  2.78k|                goto error;
 2688|       |
 2689|  30.7k|            uint32_t total = lace_size[0] = num;
 2690|   184k|            for (int i = 1; i < laces - 1; i++) {
  ------------------
  |  Branch (2690:29): [True: 167k, False: 17.4k]
  ------------------
 2691|   167k|                int64_t snum = ebml_read_signed_length(s);
 2692|   167k|                if (snum == EBML_INT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   86|   334k|#define EBML_INT_INVALID    INT64_MAX
  ------------------
  |  Branch (2692:21): [True: 10.5k, False: 156k]
  |  Branch (2692:49): [True: 2.71k, False: 153k]
  ------------------
 2693|  13.2k|                    goto error;
 2694|   153k|                lace_size[i] = lace_size[i - 1] + snum;
 2695|   153k|                total += lace_size[i];
 2696|   153k|            }
 2697|  17.4k|            uint32_t rest_length = endpos - stream_tell(s);
 2698|  17.4k|            lace_size[laces - 1] = rest_length - total;
 2699|  17.4k|            break;
 2700|  30.7k|        }
 2701|       |
 2702|      0|        default:
  ------------------
  |  Branch (2702:9): [True: 0, False: 63.8k]
  ------------------
 2703|      0|            goto error;
 2704|  63.8k|        }
 2705|  63.8k|    }
 2706|       |
 2707|  1.94M|    for (int i = 0; i < laces; i++) {
  ------------------
  |  Branch (2707:21): [True: 1.33M, False: 610k]
  ------------------
 2708|  1.33M|        uint32_t size = lace_size[i];
 2709|  1.33M|        if (stream_tell(s) + size > endpos || size > (1 << 30))
  ------------------
  |  Branch (2709:13): [True: 651, False: 1.33M]
  |  Branch (2709:47): [True: 0, False: 1.33M]
  ------------------
 2710|    651|            goto error;
 2711|  1.33M|        int pad = MPMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_INPUT_PADDING);
  ------------------
  |  |   44|  1.33M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.33M, Folded]
  |  |  ------------------
  ------------------
 2712|  1.33M|        AVBufferRef *buf = av_buffer_alloc(size + pad);
 2713|  1.33M|        if (!buf)
  ------------------
  |  Branch (2713:13): [True: 0, False: 1.33M]
  ------------------
 2714|      0|            goto error;
 2715|  1.33M|        buf->size = size;
 2716|  1.33M|        if (stream_read(s, buf->data, buf->size) != buf->size) {
  ------------------
  |  Branch (2716:13): [True: 4.70k, False: 1.33M]
  ------------------
 2717|  4.70k|            av_buffer_unref(&buf);
 2718|  4.70k|            goto error;
 2719|  4.70k|        }
 2720|  1.33M|        memset(buf->data + buf->size, 0, pad);
 2721|  1.33M|        block->laces[block->num_laces++] = buf;
 2722|  1.33M|    }
 2723|       |
 2724|   610k|    if (stream_tell(s) != endpos)
  ------------------
  |  Branch (2724:9): [True: 1.76k, False: 608k]
  ------------------
 2725|  1.76k|        goto error;
 2726|       |
 2727|   608k|    return 0;
 2728|       |
 2729|  24.7k| error:
 2730|  24.7k|    return 1;
 2731|   610k|}
demux_mkv.c:index_block:
 3059|   489k|{
 3060|   489k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3061|   489k|    if (block->keyframe) {
  ------------------
  |  Branch (3061:9): [True: 295k, False: 193k]
  ------------------
 3062|   295k|        add_block_position(demuxer, block->track, mkv_d->cluster_start,
 3063|   295k|                           block->timecode / mkv_d->tc_scale,
 3064|   295k|                           block->duration / mkv_d->tc_scale);
 3065|   295k|    }
 3066|   489k|}
demux_mkv.c:add_block_position:
 1070|   295k|{
 1071|   295k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1072|       |
 1073|   295k|    if (mkv_d->index_complete || !track)
  ------------------
  |  Branch (1073:9): [True: 408, False: 295k]
  |  Branch (1073:34): [True: 0, False: 295k]
  ------------------
 1074|    408|        return;
 1075|       |
 1076|   295k|    mkv_d->index_has_durations = true;
 1077|       |
 1078|   295k|    if (track->last_index_entry != (size_t)-1) {
  ------------------
  |  Branch (1078:9): [True: 272k, False: 22.5k]
  ------------------
 1079|   272k|        mkv_index_t *index = &mkv_d->indexes[track->last_index_entry];
 1080|       |        // Never add blocks which are already covered by the index.
 1081|   272k|        if (index->timecode >= timecode)
  ------------------
  |  Branch (1081:13): [True: 225k, False: 46.9k]
  ------------------
 1082|   225k|            return;
 1083|   272k|    }
 1084|  69.5k|    cue_index_add(demuxer, track->tnum, filepos, timecode, duration);
 1085|  69.5k|    track->last_index_entry = mkv_d->num_indexes - 1;
 1086|  69.5k|}
demux_mkv.c:read_deferred_cues:
 1532|  3.56k|{
 1533|  3.56k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 1534|       |
 1535|  3.56k|    if (mkv_d->index_complete || demuxer->opts->index_mode != 1)
  ------------------
  |  Branch (1535:9): [True: 31, False: 3.53k]
  |  Branch (1535:34): [True: 0, False: 3.53k]
  ------------------
 1536|     31|        return;
 1537|       |
 1538|  16.8k|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (1538:21): [True: 13.3k, False: 3.53k]
  ------------------
 1539|  13.3k|        struct header_elem *elem = &mkv_d->headers[n];
 1540|       |
 1541|  13.3k|        if (elem->id == MATROSKA_ID_CUES)
  ------------------
  |  |  130|  13.3k|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (1541:13): [True: 878, False: 12.4k]
  ------------------
 1542|    878|            read_deferred_element(demuxer, elem);
 1543|  13.3k|    }
 1544|  3.53k|}
demux_mkv.c:mkv_seek_reset:
 2837|  28.3k|{
 2838|  28.3k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2839|       |
 2840|  77.4k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (2840:21): [True: 49.1k, False: 28.3k]
  ------------------
 2841|  49.1k|        mkv_track_t *track = mkv_d->tracks[i];
 2842|  49.1k|        if (track->av_parser)
  ------------------
  |  Branch (2842:13): [True: 1.92k, False: 47.2k]
  ------------------
 2843|  1.92k|            av_parser_close(track->av_parser);
 2844|  49.1k|        track->av_parser = NULL;
 2845|  49.1k|        avcodec_free_context(&track->av_parser_codec);
 2846|  49.1k|        mp_dovi_split_reset(track->dovi_split);
 2847|  49.1k|    }
 2848|       |
 2849|  32.2k|    for (int n = 0; n < mkv_d->num_blocks; n++)
  ------------------
  |  Branch (2849:21): [True: 3.88k, False: 28.3k]
  ------------------
 2850|  3.88k|        free_block(&mkv_d->blocks[n]);
 2851|  28.3k|    mkv_d->num_blocks = 0;
 2852|       |
 2853|  28.3k|    for (int n = 0; n < mkv_d->num_packets; n++)
  ------------------
  |  Branch (2853:21): [True: 0, False: 28.3k]
  ------------------
 2854|      0|        talloc_free(mkv_d->packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2855|  28.3k|    mkv_d->num_packets = 0;
 2856|       |
 2857|       |    mkv_d->skip_to_timecode = INT64_MIN;
 2858|  28.3k|}
demux_mkv.c:read_next_block:
 3436|   509k|{
 3437|   509k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 3438|       |
 3439|   509k|    if (!mkv_d->num_blocks) {
  ------------------
  |  Branch (3439:9): [True: 432k, False: 76.5k]
  ------------------
 3440|   432k|        int res = read_next_block_into_queue(demuxer);
 3441|   432k|        if (res < 1)
  ------------------
  |  Branch (3441:13): [True: 23.7k, False: 409k]
  ------------------
 3442|  23.7k|            return res;
 3443|       |
 3444|   409k|        mp_assert(mkv_d->num_blocks);
  ------------------
  |  |   41|   409k|#define mp_assert assert
  ------------------
  |  Branch (3444:9): [True: 409k, False: 0]
  ------------------
 3445|   409k|    }
 3446|       |
 3447|   485k|    *block = mkv_d->blocks[0];
 3448|   485k|    MP_TARRAY_REMOVE_AT(mkv_d->blocks, mkv_d->num_blocks, 0);
  ------------------
  |  |  143|   485k|    do {                                            \
  |  |  144|   485k|        size_t at_ = (at);                          \
  |  |  145|   485k|        assert(at_ < (idxvar));                     \
  |  |  146|   485k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   485k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   485k|        (idxvar)--;                                 \
  |  |  149|   485k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 485k]
  |  |  ------------------
  ------------------
  |  Branch (3448:5): [True: 485k, False: 0]
  ------------------
 3449|   485k|    return 1;
 3450|   485k|}
demux_mkv.c:probe_x264_garbage:
 2379|  24.2k|{
 2380|  24.2k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2381|       |
 2382|  68.0k|    for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (2382:21): [True: 43.7k, False: 24.2k]
  ------------------
 2383|  43.7k|        mkv_track_t *track = mkv_d->tracks[n];
 2384|  43.7k|        struct sh_stream *sh = track->stream;
 2385|       |
 2386|  43.7k|        if (!sh || sh->type != STREAM_VIDEO)
  ------------------
  |  Branch (2386:13): [True: 1.76k, False: 42.0k]
  |  Branch (2386:20): [True: 22.4k, False: 19.5k]
  ------------------
 2387|  24.2k|            continue;
 2388|       |
 2389|  19.5k|        if (sh->codec->codec && strcmp(sh->codec->codec, "h264") != 0)
  ------------------
  |  Branch (2389:13): [True: 19.5k, False: 0]
  |  Branch (2389:33): [True: 12.4k, False: 7.10k]
  ------------------
 2390|  12.4k|            continue;
 2391|       |
 2392|  7.10k|        struct block_info *block = NULL;
 2393|       |
 2394|       |        // Find first block for this track.
 2395|       |        // Restrict reading number of total packets. (Arbitrary to avoid bloat.)
 2396|  10.8k|        for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (2396:25): [True: 10.8k, False: 2]
  ------------------
 2397|  10.8k|            if (i >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) < 1)
  ------------------
  |  Branch (2397:17): [True: 4.50k, False: 6.39k]
  |  Branch (2397:43): [True: 925, False: 3.57k]
  ------------------
 2398|    925|                break;
 2399|  9.97k|            if (mkv_d->blocks[i].track == track) {
  ------------------
  |  Branch (2399:17): [True: 6.18k, False: 3.79k]
  ------------------
 2400|  6.18k|                block = &mkv_d->blocks[i];
 2401|  6.18k|                break;
 2402|  6.18k|            }
 2403|  9.97k|        }
 2404|       |
 2405|  7.10k|        if (!block || block->num_laces < 1)
  ------------------
  |  Branch (2405:13): [True: 927, False: 6.18k]
  |  Branch (2405:23): [True: 0, False: 6.18k]
  ------------------
 2406|    927|            continue;
 2407|       |
 2408|  6.18k|        bstr sblock = {block->laces[0]->data, block->laces[0]->size};
 2409|  6.18k|        bstr nblock = demux_mkv_decode(demuxer->log, track, sblock, 1);
 2410|  6.18k|        if (!nblock.len)
  ------------------
  |  Branch (2410:13): [True: 1, False: 6.18k]
  ------------------
 2411|      1|            continue;
 2412|       |
 2413|  6.18k|        sh->codec->first_packet = new_demux_packet_from(demuxer->packet_pool,
 2414|  6.18k|                                                        nblock.start, nblock.len);
 2415|  6.18k|        talloc_steal(mkv_d, sh->codec->first_packet);
  ------------------
  |  |   38|  6.18k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  6.18k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 2416|       |
 2417|  6.18k|        if (nblock.start != sblock.start)
  ------------------
  |  Branch (2417:13): [True: 1, False: 6.18k]
  ------------------
 2418|      1|            talloc_free(nblock.start);
  ------------------
  |  |   47|      1|#define talloc_free                     ta_free
  ------------------
 2419|  6.18k|    }
 2420|  24.2k|}
demux_mkv.c:probe_if_image:
 2347|  24.2k|{
 2348|  24.2k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2349|       |
 2350|  68.0k|    for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (2350:21): [True: 43.7k, False: 24.2k]
  ------------------
 2351|  43.7k|        int video_blocks = 0;
 2352|  43.7k|        mkv_track_t *track = mkv_d->tracks[n];
 2353|  43.7k|        struct sh_stream *sh = track->stream;
 2354|       |
 2355|  43.7k|        if (!sh || sh->type != STREAM_VIDEO || sh->image)
  ------------------
  |  Branch (2355:13): [True: 1.76k, False: 42.0k]
  |  Branch (2355:20): [True: 22.4k, False: 19.5k]
  |  Branch (2355:48): [True: 0, False: 19.5k]
  ------------------
 2356|  24.2k|            continue;
 2357|       |
 2358|  19.5k|        int64_t timecode = -1;
 2359|       |        // Arbitrary restriction on packet reading.
 2360|  88.8k|        for (size_t block = 0; block < 10000; block++) {
  ------------------
  |  Branch (2360:32): [True: 88.8k, False: 0]
  ------------------
 2361|  88.8k|            if (block >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) != 1)
  ------------------
  |  Branch (2361:17): [True: 67.2k, False: 21.6k]
  |  Branch (2361:47): [True: 10.2k, False: 57.0k]
  ------------------
 2362|  10.2k|                break;
 2363|  78.6k|            if (mkv_d->blocks[block].track != track)
  ------------------
  |  Branch (2363:17): [True: 38.3k, False: 40.2k]
  ------------------
 2364|  38.3k|                continue;
 2365|  40.2k|            if (timecode != mkv_d->blocks[block].timecode)
  ------------------
  |  Branch (2365:17): [True: 25.4k, False: 14.7k]
  ------------------
 2366|  25.4k|                ++video_blocks;
 2367|  40.2k|            timecode = mkv_d->blocks[block].timecode;
 2368|  40.2k|            if (video_blocks > 1)
  ------------------
  |  Branch (2368:17): [True: 9.33k, False: 30.9k]
  ------------------
 2369|  9.33k|                break;
 2370|  40.2k|        }
 2371|       |
 2372|       |        // Assume still image
 2373|  19.5k|        if (video_blocks == 1)
  ------------------
  |  Branch (2373:13): [True: 6.82k, False: 12.7k]
  ------------------
 2374|  6.82k|            sh->image = true;
 2375|  19.5k|    }
 2376|  24.2k|}
demux_mkv.c:demux_mkv_read_packet:
 3454|   781k|{
 3455|   781k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3456|       |
 3457|  1.25M|    for (;;) {
 3458|  1.25M|        if (mkv_d->num_packets) {
  ------------------
  |  Branch (3458:13): [True: 759k, False: 493k]
  ------------------
 3459|   759k|            *pkt = mkv_d->packets[0];
 3460|   759k|            MP_TARRAY_REMOVE_AT(mkv_d->packets, mkv_d->num_packets, 0);
  ------------------
  |  |  143|   759k|    do {                                            \
  |  |  144|   759k|        size_t at_ = (at);                          \
  |  |  145|   759k|        assert(at_ < (idxvar));                     \
  |  |  146|   759k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   759k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   759k|        (idxvar)--;                                 \
  |  |  149|   759k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 759k]
  |  |  ------------------
  ------------------
  |  Branch (3460:13): [True: 759k, False: 0]
  ------------------
 3461|   759k|            return true;
 3462|   759k|        }
 3463|       |
 3464|   493k|        int res;
 3465|   493k|        struct block_info block;
 3466|   493k|        res = read_next_block(demuxer, &block);
 3467|   493k|        if (res < 0)
  ------------------
  |  Branch (3467:13): [True: 21.9k, False: 471k]
  ------------------
 3468|  21.9k|            return false;
 3469|   471k|        if (res > 0) {
  ------------------
  |  Branch (3469:13): [True: 471k, False: 0]
  ------------------
 3470|   471k|            handle_block(demuxer, &block);
 3471|   471k|            free_block(&block);
 3472|   471k|        }
 3473|   471k|    }
 3474|   781k|}
demux_mkv.c:handle_block:
 3131|   471k|{
 3132|   471k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3133|   471k|    double current_pts;
 3134|   471k|    bool keyframe = block_info->keyframe;
 3135|   471k|    uint64_t block_duration = block_info->duration;
 3136|   471k|    int64_t tc = block_info->timecode;
 3137|   471k|    mkv_track_t *track = block_info->track;
 3138|   471k|    struct sh_stream *stream = track->stream;
 3139|   471k|    bool use_this_block = tc >= mkv_d->skip_to_timecode;
 3140|       |
 3141|       |    // Keep BL blocks flowing to feed the Dolby Vision splitter when its
 3142|       |    // virtual EL is selected, even if the BL itself isn't selected.
 3143|   471k|    struct sh_stream *split_el = track->dovi_split
  ------------------
  |  Branch (3143:34): [True: 0, False: 471k]
  ------------------
 3144|   471k|                                    ? mp_dovi_split_el_stream(track->dovi_split)
 3145|   471k|                                    : NULL;
 3146|   471k|    bool need_for_split = split_el && demux_stream_is_selected(split_el);
  ------------------
  |  Branch (3146:27): [True: 0, False: 471k]
  |  Branch (3146:39): [True: 0, False: 0]
  ------------------
 3147|   471k|    if (!demux_stream_is_selected(stream) && !need_for_split)
  ------------------
  |  Branch (3147:9): [True: 24.7k, False: 446k]
  |  Branch (3147:46): [True: 24.7k, False: 0]
  ------------------
 3148|  24.7k|        return 0;
 3149|       |
 3150|   446k|    current_pts = tc / 1e9 - track->codec_delay;
 3151|       |
 3152|   446k|    if (track->require_keyframes && !keyframe) {
  ------------------
  |  Branch (3152:9): [True: 210k, False: 236k]
  |  Branch (3152:37): [True: 35.0k, False: 175k]
  ------------------
 3153|  35.0k|        keyframe = true;
 3154|  35.0k|        if (!mkv_d->keyframe_warning) {
  ------------------
  |  Branch (3154:13): [True: 3.03k, False: 31.9k]
  ------------------
 3155|  3.03k|            MP_WARN(demuxer, "This is a broken file! Packets with incorrect "
  ------------------
  |  |   90|  3.03k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.03k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3156|  3.03k|                    "keyframe flag found. Enabling workaround.\n");
 3157|  3.03k|            mkv_d->keyframe_warning = true;
 3158|  3.03k|        }
 3159|  35.0k|    }
 3160|       |
 3161|   446k|    if (track->type == MATROSKA_TRACK_AUDIO) {
  ------------------
  |  |   79|   446k|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (3161:9): [True: 210k, False: 236k]
  ------------------
 3162|   210k|        if (mkv_d->a_skip_to_keyframe)
  ------------------
  |  Branch (3162:13): [True: 3.66k, False: 206k]
  ------------------
 3163|  3.66k|            use_this_block &= keyframe;
 3164|   236k|    } else if (track->type == MATROSKA_TRACK_SUBTITLE) {
  ------------------
  |  |   82|   236k|#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
  ------------------
  |  Branch (3164:16): [True: 5.91k, False: 231k]
  ------------------
 3165|  5.91k|        if (!use_this_block && mkv_d->subtitle_preroll) {
  ------------------
  |  Branch (3165:13): [True: 41, False: 5.87k]
  |  Branch (3165:32): [True: 41, False: 0]
  ------------------
 3166|     41|            int64_t end_time = block_info->timecode + block_info->duration;
 3167|     41|            if (!block_info->duration)
  ------------------
  |  Branch (3167:17): [True: 35, False: 6]
  ------------------
 3168|     35|                end_time = INT64_MAX;
 3169|     41|            use_this_block = end_time > mkv_d->skip_to_timecode;
 3170|     41|            if (use_this_block) {
  ------------------
  |  Branch (3170:17): [True: 41, False: 0]
  ------------------
 3171|     41|                if (mkv_d->subtitle_preroll) {
  ------------------
  |  Branch (3171:21): [True: 41, False: 0]
  ------------------
 3172|     41|                    mkv_d->subtitle_preroll--;
 3173|     41|                } else {
 3174|       |                    // This could overflow the demuxer queue.
 3175|      0|                    use_this_block = 0;
 3176|      0|                }
 3177|     41|            }
 3178|     41|        }
 3179|  5.91k|        if (use_this_block) {
  ------------------
  |  Branch (3179:13): [True: 5.91k, False: 0]
  ------------------
 3180|  5.91k|            if (block_info->num_laces > 1) {
  ------------------
  |  Branch (3180:17): [True: 105, False: 5.80k]
  ------------------
 3181|    105|                MP_WARN(demuxer, "Subtitles use Matroska "
  ------------------
  |  |   90|    105|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    105|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3182|    105|                       "lacing. This is abnormal and not supported.\n");
 3183|    105|                use_this_block = 0;
 3184|    105|            }
 3185|  5.91k|        }
 3186|   231k|    } else if (track->type == MATROSKA_TRACK_VIDEO) {
  ------------------
  |  |   78|   231k|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (3186:16): [True: 231k, False: 0]
  ------------------
 3187|   231k|        if (mkv_d->v_skip_to_keyframe)
  ------------------
  |  Branch (3187:13): [True: 739, False: 230k]
  ------------------
 3188|    739|            use_this_block &= keyframe;
 3189|   231k|    }
 3190|       |
 3191|   446k|    if (use_this_block) {
  ------------------
  |  Branch (3191:9): [True: 443k, False: 3.48k]
  ------------------
 3192|   443k|        uint64_t filepos = block_info->filepos;
 3193|       |
 3194|  1.20M|        for (int i = 0; i < block_info->num_laces; i++) {
  ------------------
  |  Branch (3194:25): [True: 767k, False: 438k]
  ------------------
 3195|   767k|            AVBufferRef *data = block_info->laces[i];
 3196|   767k|            demux_packet_t *dp = NULL;
 3197|       |
 3198|   767k|            bstr block = {data->data, data->size};
 3199|   767k|            bstr nblock = demux_mkv_decode(demuxer->log, track, block, 1);
 3200|   767k|            if (!nblock.len)
  ------------------
  |  Branch (3200:17): [True: 5.16k, False: 762k]
  ------------------
 3201|  5.16k|                break;
 3202|       |
 3203|   762k|            if (block.start != nblock.start || block.len != nblock.len) {
  ------------------
  |  Branch (3203:17): [True: 21.6k, False: 740k]
  |  Branch (3203:48): [True: 0, False: 740k]
  ------------------
 3204|       |                // (avoidable copy of the entire data)
 3205|  21.6k|                dp = new_demux_packet_from(demuxer->packet_pool, nblock.start, nblock.len);
 3206|   740k|            } else {
 3207|   740k|                dp = new_demux_packet_from_buf(demuxer->packet_pool, data);
 3208|   740k|            }
 3209|   762k|            if (!dp)
  ------------------
  |  Branch (3209:17): [True: 0, False: 762k]
  ------------------
 3210|      0|                break;
 3211|       |
 3212|   762k|            dp->pos = filepos;
 3213|       |            /* If default_duration is 0, assume no pts value is known
 3214|       |             * for packets after the first one (rather than all pts
 3215|       |             * values being the same). Also, don't use it for extra
 3216|       |             * packets resulting from parsing. */
 3217|   762k|            if (i == 0 || track->default_duration) {
  ------------------
  |  Branch (3217:17): [True: 438k, False: 324k]
  |  Branch (3217:27): [True: 60.8k, False: 263k]
  ------------------
 3218|   499k|                dp->pts = current_pts + i * track->default_duration;
 3219|   499k|                dp->keyframe = keyframe;
 3220|   499k|            }
 3221|   762k|            if (track->block_dts)
  ------------------
  |  Branch (3221:17): [True: 146k, False: 615k]
  ------------------
 3222|   146k|                MPSWAP(double, dp->pts, dp->dts);
  ------------------
  |  |   48|   146k|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 146k]
  |  |  ------------------
  ------------------
 3223|   762k|            if (i == 0 && block_info->duration_known)
  ------------------
  |  Branch (3223:17): [True: 438k, False: 324k]
  |  Branch (3223:27): [True: 731, False: 437k]
  ------------------
 3224|    731|                dp->duration = block_duration / 1e9;
 3225|   762k|            if (stream->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3225:17): [True: 380k, False: 381k]
  ------------------
 3226|   380k|                int64_t padding = av_rescale(block_info->discardpadding,
 3227|   380k|                                             stream->codec->samplerate,
 3228|   380k|                                             1000000000);
 3229|   380k|                if (padding < -INT_MAX || padding > INT_MAX)
  ------------------
  |  Branch (3229:21): [True: 0, False: 380k]
  |  Branch (3229:43): [True: 0, False: 380k]
  ------------------
 3230|      0|                    padding = 0;
 3231|   380k|                int start = 0, end = 0;
 3232|   380k|                if (padding < 0 && i == 0)
  ------------------
  |  Branch (3232:21): [True: 0, False: 380k]
  |  Branch (3232:36): [True: 0, False: 0]
  ------------------
 3233|      0|                    start = -padding;
 3234|   380k|                if (padding > 0 && i == block_info->num_laces - 1)
  ------------------
  |  Branch (3234:21): [True: 0, False: 380k]
  |  Branch (3234:36): [True: 0, False: 0]
  ------------------
 3235|      0|                    end = padding;
 3236|   380k|                demux_packet_set_padding(dp, start, end);
 3237|   380k|                mkv_d->a_skip_preroll = 0;
 3238|   380k|            }
 3239|   762k|            if (block_info->additions) {
  ------------------
  |  Branch (3239:17): [True: 0, False: 762k]
  ------------------
 3240|      0|                for (int n = 0; n < block_info->additions->n_block_more; n++) {
  ------------------
  |  Branch (3240:33): [True: 0, False: 0]
  ------------------
 3241|      0|                    struct ebml_block_more *add =
 3242|      0|                        &block_info->additions->block_more[n];
 3243|      0|                    int64_t id = add->n_block_add_id ? add->block_add_id : 1;
  ------------------
  |  Branch (3243:34): [True: 0, False: 0]
  ------------------
 3244|      0|                    demux_packet_add_blockadditional(dp, id,
 3245|      0|                        add->block_additional.start, add->block_additional.len);
 3246|      0|                }
 3247|      0|            }
 3248|       |
 3249|   762k|            mkv_parse_and_add_packet(demuxer, track, dp);
 3250|   762k|            talloc_free_children(track->parser_tmp);
  ------------------
  |  |   46|   762k|#define talloc_free_children            ta_free_children
  ------------------
 3251|   762k|            filepos += data->size;
 3252|   762k|        }
 3253|       |
 3254|   443k|        if (stream->type == STREAM_VIDEO) {
  ------------------
  |  Branch (3254:13): [True: 230k, False: 212k]
  ------------------
 3255|   230k|            mkv_d->v_skip_to_keyframe = 0;
 3256|   230k|            mkv_d->skip_to_timecode = INT64_MIN;
 3257|   230k|            mkv_d->subtitle_preroll = 0;
 3258|   230k|        } else if (stream->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3258:20): [True: 206k, False: 5.80k]
  ------------------
 3259|   206k|            mkv_d->a_skip_to_keyframe = 0;
 3260|   206k|        }
 3261|       |
 3262|   443k|        return 1;
 3263|   443k|    }
 3264|       |
 3265|  3.48k|    return 0;
 3266|   446k|}
demux_mkv.c:mkv_parse_and_add_packet:
 2946|   762k|{
 2947|   762k|    struct sh_stream *stream = track->stream;
 2948|       |
 2949|   762k|    if (stream->type == STREAM_AUDIO && handle_realaudio(demuxer, track, dp))
  ------------------
  |  Branch (2949:9): [True: 380k, False: 381k]
  |  Branch (2949:41): [True: 12.0k, False: 368k]
  ------------------
 2950|  12.0k|        return;
 2951|       |
 2952|   750k|    if (strcmp(stream->codec->codec, "wavpack") == 0) {
  ------------------
  |  Branch (2952:9): [True: 0, False: 750k]
  ------------------
 2953|      0|        int size = dp->len;
 2954|      0|        uint8_t *parsed;
 2955|      0|        if (libav_parse_wavpack(track, dp->buffer, &parsed, &size) >= 0) {
  ------------------
  |  Branch (2955:13): [True: 0, False: 0]
  ------------------
 2956|      0|            struct demux_packet *new = new_demux_packet_from(demuxer->packet_pool,
 2957|      0|                                                             parsed, size);
 2958|      0|            if (new) {
  ------------------
  |  Branch (2958:17): [True: 0, False: 0]
  ------------------
 2959|      0|                demux_packet_copy_attribs(new, dp);
 2960|      0|                talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2961|      0|                add_packet(demuxer, stream, new);
 2962|      0|                return;
 2963|      0|            }
 2964|      0|        }
 2965|      0|    }
 2966|       |
 2967|   750k|    if (strcmp(stream->codec->codec, "prores") == 0) {
  ------------------
  |  Branch (2967:9): [True: 1.87k, False: 748k]
  ------------------
 2968|  1.87k|        size_t newlen = dp->len + 8;
 2969|  1.87k|        struct demux_packet *new = new_demux_packet(demuxer->packet_pool, newlen);
 2970|  1.87k|        if (new) {
  ------------------
  |  Branch (2970:13): [True: 1.87k, False: 0]
  ------------------
 2971|  1.87k|            AV_WB32(new->buffer + 0, newlen);
 2972|  1.87k|            AV_WB32(new->buffer + 4, MKBETAG('i', 'c', 'p', 'f'));
 2973|  1.87k|            memcpy(new->buffer + 8, dp->buffer, dp->len);
 2974|  1.87k|            demux_packet_copy_attribs(new, dp);
 2975|  1.87k|            talloc_free(dp);
  ------------------
  |  |   47|  1.87k|#define talloc_free                     ta_free
  ------------------
 2976|  1.87k|            add_packet(demuxer, stream, new);
 2977|  1.87k|            return;
 2978|  1.87k|        }
 2979|  1.87k|    }
 2980|       |
 2981|   748k|    if (track->parse && !track->av_parser) {
  ------------------
  |  Branch (2981:9): [True: 47.3k, False: 701k]
  |  Branch (2981:25): [True: 7.76k, False: 39.6k]
  ------------------
 2982|  7.76k|        int id = mp_codec_to_av_codec_id(track->stream->codec->codec);
 2983|  7.76k|        const AVCodec *codec = avcodec_find_decoder(id);
 2984|  7.76k|        mp_assert(!track->av_parser_codec);
  ------------------
  |  |   41|  7.76k|#define mp_assert assert
  ------------------
  |  Branch (2984:9): [True: 7.76k, False: 0]
  ------------------
 2985|  7.76k|        if (codec)
  ------------------
  |  Branch (2985:13): [True: 7.76k, False: 0]
  ------------------
 2986|  7.76k|            track->av_parser_codec = avcodec_alloc_context3(codec);
 2987|  7.76k|        if (track->av_parser_codec)
  ------------------
  |  Branch (2987:13): [True: 7.76k, False: 0]
  ------------------
 2988|  7.76k|            track->av_parser = av_parser_init(id);
 2989|  7.76k|        if (!track->av_parser)
  ------------------
  |  Branch (2989:13): [True: 5.84k, False: 1.92k]
  ------------------
 2990|  5.84k|            avcodec_free_context(&track->av_parser_codec);
 2991|  7.76k|    }
 2992|       |
 2993|   748k|    if (!track->parse || !track->av_parser || !track->av_parser_codec) {
  ------------------
  |  Branch (2993:9): [True: 701k, False: 47.3k]
  |  Branch (2993:26): [True: 5.84k, False: 41.5k]
  |  Branch (2993:47): [True: 0, False: 41.5k]
  ------------------
 2994|   706k|        struct demux_packet *el_dp = NULL;
 2995|   706k|        struct sh_stream *el_sh = NULL;
 2996|   706k|        if (track->dovi_split) {
  ------------------
  |  Branch (2996:13): [True: 0, False: 706k]
  ------------------
 2997|      0|            el_sh = mp_dovi_split_el_stream(track->dovi_split);
 2998|      0|            if (el_sh && demux_stream_is_selected(el_sh))
  ------------------
  |  Branch (2998:17): [True: 0, False: 0]
  |  Branch (2998:26): [True: 0, False: 0]
  ------------------
 2999|      0|                el_dp = mp_dovi_split_dispatch(track->dovi_split, dp);
 3000|      0|        }
 3001|   706k|        add_packet(demuxer, stream, dp);
 3002|   706k|        if (el_dp)
  ------------------
  |  Branch (3002:13): [True: 0, False: 706k]
  ------------------
 3003|      0|            add_packet(demuxer, el_sh, el_dp);
 3004|   706k|        return;
 3005|   706k|    }
 3006|       |
 3007|  41.5k|    double tb = track->parse_timebase;
 3008|  41.5k|    int64_t pts = dp->pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : dp->pts * tb;
  ------------------
  |  |   39|  41.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3008:19): [True: 1.14k, False: 40.4k]
  ------------------
 3009|  41.5k|    int64_t dts = dp->dts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : dp->dts * tb;
  ------------------
  |  |   39|  41.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3009:19): [True: 41.5k, False: 0]
  ------------------
 3010|  41.5k|    bool copy_sidedata = true;
 3011|       |
 3012|  92.1k|    while (dp->len) {
  ------------------
  |  Branch (3012:12): [True: 50.6k, False: 41.5k]
  ------------------
 3013|  50.6k|        uint8_t *data = NULL;
 3014|  50.6k|        int size = 0;
 3015|  50.6k|        int len = av_parser_parse2(track->av_parser, track->av_parser_codec,
 3016|  50.6k|                                   &data, &size, dp->buffer, dp->len,
 3017|  50.6k|                                   pts, dts, 0);
 3018|  50.6k|        if (len < 0 || len > dp->len)
  ------------------
  |  Branch (3018:13): [True: 0, False: 50.6k]
  |  Branch (3018:24): [True: 0, False: 50.6k]
  ------------------
 3019|      0|            break;
 3020|  50.6k|        dp->buffer += len;
 3021|  50.6k|        dp->len -= len;
 3022|  50.6k|        dp->pos += len;
 3023|  50.6k|        if (size) {
  ------------------
  |  Branch (3023:13): [True: 33.0k, False: 17.5k]
  ------------------
 3024|  33.0k|            struct demux_packet *new = new_demux_packet_from(demuxer->packet_pool,
 3025|  33.0k|                                                             data, size);
 3026|  33.0k|            if (!new)
  ------------------
  |  Branch (3026:17): [True: 0, False: 33.0k]
  ------------------
 3027|      0|                break;
 3028|  33.0k|            if (copy_sidedata)
  ------------------
  |  Branch (3028:17): [True: 32.3k, False: 700]
  ------------------
 3029|  32.3k|                av_packet_copy_props(new->avpacket, dp->avpacket);
 3030|  33.0k|            copy_sidedata = false;
 3031|  33.0k|            demux_packet_copy_attribs(new, dp);
 3032|  33.0k|            if (track->parse_timebase) {
  ------------------
  |  Branch (3032:17): [True: 33.0k, False: 0]
  ------------------
 3033|  33.0k|                new->pts = track->av_parser->pts == AV_NOPTS_VALUE
  ------------------
  |  Branch (3033:28): [True: 1.42k, False: 31.6k]
  ------------------
 3034|  33.0k|                         ? MP_NOPTS_VALUE : track->av_parser->pts / tb;
  ------------------
  |  |   39|  1.42k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3035|  33.0k|                new->dts = track->av_parser->dts == AV_NOPTS_VALUE
  ------------------
  |  Branch (3035:28): [True: 33.0k, False: 0]
  ------------------
 3036|  33.0k|                         ? MP_NOPTS_VALUE : track->av_parser->dts / tb;
  ------------------
  |  |   39|  33.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3037|  33.0k|            }
 3038|  33.0k|            add_packet(demuxer, stream, new);
 3039|  33.0k|        }
 3040|  50.6k|        pts = dts = AV_NOPTS_VALUE;
 3041|  50.6k|    }
 3042|       |
 3043|  41.5k|    if (dp->len) {
  ------------------
  |  Branch (3043:9): [True: 0, False: 41.5k]
  ------------------
 3044|      0|        add_packet(demuxer, stream, dp);
 3045|  41.5k|    } else {
 3046|  41.5k|        demux_packet_pool_push(demuxer->packet_pool, dp);
 3047|  41.5k|    }
 3048|  41.5k|}
demux_mkv.c:handle_realaudio:
 2736|   380k|{
 2737|   380k|    uint32_t sps = track->sub_packet_size;
 2738|   380k|    uint32_t sph = track->sub_packet_h;
 2739|   380k|    uint32_t cfs = track->coded_framesize; // restricted to [1,0x40000000]
 2740|   380k|    uint32_t w = track->audiopk_size;
 2741|   380k|    uint32_t spc = track->sub_packet_cnt;
 2742|   380k|    uint8_t *buffer = orig->buffer;
 2743|   380k|    uint32_t size = orig->len;
 2744|   380k|    demux_packet_t *dp;
 2745|       |    // track->audio_buf allocation size
 2746|   380k|    size_t audiobuf_size = sph * w;
 2747|       |
 2748|   380k|    if (!track->audio_buf || !track->audio_timestamp || !track->stream)
  ------------------
  |  Branch (2748:9): [True: 368k, False: 12.0k]
  |  Branch (2748:30): [True: 0, False: 12.0k]
  |  Branch (2748:57): [True: 0, False: 12.0k]
  ------------------
 2749|   368k|        return false;
 2750|       |
 2751|  12.0k|    const char *codec = track->stream->codec->codec ? track->stream->codec->codec : "";
  ------------------
  |  Branch (2751:25): [True: 12.0k, False: 0]
  ------------------
 2752|  12.0k|    if (!strcmp(codec, "ra_288")) {
  ------------------
  |  Branch (2752:9): [True: 0, False: 12.0k]
  ------------------
 2753|      0|        for (int x = 0; x < sph / 2; x++) {
  ------------------
  |  Branch (2753:25): [True: 0, False: 0]
  ------------------
 2754|      0|            uint64_t dst_offset = x * 2 * w + spc * (uint64_t)cfs;
 2755|      0|            if (dst_offset + cfs > audiobuf_size)
  ------------------
  |  Branch (2755:17): [True: 0, False: 0]
  ------------------
 2756|      0|                goto error;
 2757|      0|            uint64_t src_offset = x * (uint64_t)cfs;
 2758|      0|            if (src_offset + cfs > size)
  ------------------
  |  Branch (2758:17): [True: 0, False: 0]
  ------------------
 2759|      0|                goto error;
 2760|      0|            memcpy(track->audio_buf + dst_offset, buffer + src_offset, cfs);
 2761|      0|        }
 2762|  12.0k|    } else if (!strcmp(codec, "cook") || !strcmp(codec, "atrac3")) {
  ------------------
  |  Branch (2762:16): [True: 12.0k, False: 0]
  |  Branch (2762:42): [True: 0, False: 0]
  ------------------
 2763|  44.0k|        for (int x = 0; x < w / sps; x++) {
  ------------------
  |  Branch (2763:25): [True: 37.7k, False: 6.26k]
  ------------------
 2764|  37.7k|            uint32_t dst_offset =
 2765|  37.7k|                sps * (sph * x + ((sph + 1) / 2) * (spc & 1) + (spc >> 1));
 2766|  37.7k|            if (dst_offset + sps > audiobuf_size)
  ------------------
  |  Branch (2766:17): [True: 0, False: 37.7k]
  ------------------
 2767|      0|                goto error;
 2768|  37.7k|            uint32_t src_offset = sps * x;
 2769|  37.7k|            if (src_offset + sps > size)
  ------------------
  |  Branch (2769:17): [True: 5.83k, False: 31.9k]
  ------------------
 2770|  5.83k|                goto error;
 2771|  31.9k|            memcpy(track->audio_buf + dst_offset, buffer + src_offset, sps);
 2772|  31.9k|        }
 2773|  12.0k|    } else if (!strcmp(codec, "sipr")) {
  ------------------
  |  Branch (2773:16): [True: 0, False: 0]
  ------------------
 2774|      0|        if (spc * w + w > audiobuf_size || w > size)
  ------------------
  |  Branch (2774:13): [True: 0, False: 0]
  |  Branch (2774:44): [True: 0, False: 0]
  ------------------
 2775|      0|            goto error;
 2776|      0|        memcpy(track->audio_buf + spc * w, buffer, w);
 2777|      0|        if (spc == sph - 1) {
  ------------------
  |  Branch (2777:13): [True: 0, False: 0]
  ------------------
 2778|      0|            int n;
 2779|      0|            int bs = sph * w * 2 / 96;      // nibbles per subpacket
 2780|       |            // Perform reordering
 2781|      0|            for (n = 0; n < 38; n++) {
  ------------------
  |  Branch (2781:25): [True: 0, False: 0]
  ------------------
 2782|      0|                unsigned int i = bs * sipr_swaps[n][0]; // 77 max
 2783|      0|                unsigned int o = bs * sipr_swaps[n][1]; // 95 max
 2784|       |                // swap nibbles of block 'i' with 'o'
 2785|      0|                for (int j = 0; j < bs; j++) {
  ------------------
  |  Branch (2785:33): [True: 0, False: 0]
  ------------------
 2786|      0|                    if (i / 2 >= audiobuf_size || o / 2 >= audiobuf_size)
  ------------------
  |  Branch (2786:25): [True: 0, False: 0]
  |  Branch (2786:51): [True: 0, False: 0]
  ------------------
 2787|      0|                        goto error;
 2788|      0|                    uint8_t iv = track->audio_buf[i / 2];
 2789|      0|                    uint8_t ov = track->audio_buf[o / 2];
 2790|      0|                    int x = (i & 1) ? iv >> 4 : iv & 0x0F;
  ------------------
  |  Branch (2790:29): [True: 0, False: 0]
  ------------------
 2791|      0|                    int y = (o & 1) ? ov >> 4 : ov & 0x0F;
  ------------------
  |  Branch (2791:29): [True: 0, False: 0]
  ------------------
 2792|      0|                    track->audio_buf[o / 2] = (ov & 0x0F) | (o & 1 ? x << 4 : x);
  ------------------
  |  Branch (2792:62): [True: 0, False: 0]
  ------------------
 2793|      0|                    track->audio_buf[i / 2] = (iv & 0x0F) | (i & 1 ? y << 4 : y);
  ------------------
  |  Branch (2793:62): [True: 0, False: 0]
  ------------------
 2794|      0|                    i++;
 2795|      0|                    o++;
 2796|      0|                }
 2797|      0|            }
 2798|      0|        }
 2799|      0|    } else {
 2800|       |        // Not a codec that requires reordering
 2801|      0|        return false;
 2802|      0|    }
 2803|       |
 2804|  6.26k|    track->audio_timestamp[track->sub_packet_cnt] =
 2805|  6.26k|        track->ra_pts == orig->pts ? 0 : orig->pts;
  ------------------
  |  Branch (2805:9): [True: 1.95k, False: 4.30k]
  ------------------
 2806|  6.26k|    track->ra_pts = orig->pts;
 2807|       |
 2808|  6.26k|    if (++(track->sub_packet_cnt) == sph) {
  ------------------
  |  Branch (2808:9): [True: 244, False: 6.01k]
  ------------------
 2809|    244|        track->sub_packet_cnt = 0;
 2810|       |        // apk_usize has same range as coded_framesize in worst case
 2811|    244|        uint32_t apk_usize = track->stream->codec->block_align;
 2812|    244|        if (apk_usize > audiobuf_size)
  ------------------
  |  Branch (2812:13): [True: 0, False: 244]
  ------------------
 2813|      0|            goto error;
 2814|       |        // Release all the audio packets
 2815|  17.9k|        for (int x = 0; x < sph * w / apk_usize; x++) {
  ------------------
  |  Branch (2815:25): [True: 17.7k, False: 244]
  ------------------
 2816|  17.7k|            dp = new_demux_packet_from(demuxer->packet_pool,
 2817|  17.7k|                                       track->audio_buf + x * apk_usize,
 2818|  17.7k|                                       apk_usize);
 2819|  17.7k|            if (!dp)
  ------------------
  |  Branch (2819:17): [True: 0, False: 17.7k]
  ------------------
 2820|      0|                goto error;
 2821|       |            /* Put timestamp only on packets that correspond to original
 2822|       |             * audio packets in file */
 2823|  17.7k|            dp->pts = (x * apk_usize % w) ? MP_NOPTS_VALUE :
  ------------------
  |  |   39|  14.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2823:23): [True: 14.1k, False: 3.54k]
  ------------------
 2824|  17.7k|                track->audio_timestamp[x * apk_usize / w];
 2825|  17.7k|            dp->pos = orig->pos + x;
 2826|  17.7k|            dp->keyframe = !x;   // Mark first packet as keyframe
 2827|  17.7k|            add_packet(demuxer, track->stream, dp);
 2828|  17.7k|        }
 2829|    244|    }
 2830|       |
 2831|  12.0k|error:
 2832|  12.0k|    talloc_free(orig);
  ------------------
  |  |   47|  12.0k|#define talloc_free                     ta_free
  ------------------
 2833|       |    return true;
 2834|  6.26k|}
demux_mkv.c:add_packet:
  296|   759k|{
  297|   759k|    mkv_demuxer_t *mkv_d = demuxer->priv;
  298|   759k|    if (!pkt)
  ------------------
  |  Branch (298:9): [True: 0, False: 759k]
  ------------------
  299|      0|        return;
  300|       |
  301|   759k|    pkt->stream = stream->index;
  302|   759k|    MP_TARRAY_APPEND(mkv_d, mkv_d->packets, mkv_d->num_packets, pkt);
  ------------------
  |  |  105|   759k|    do {                                            \
  |  |  106|   759k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   759k|    do {                                            \
  |  |  |  |   97|   759k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   759k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   759k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   759k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 34.1k, False: 725k]
  |  |  |  |  ------------------
  |  |  |  |   99|   759k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  34.1k|    do {                                                        \
  |  |  |  |  |  |   89|  34.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  34.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  34.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  34.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  34.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  34.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  34.1k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 34.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   759k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 759k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   759k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   759k|        (idxvar)++;                                 \
  |  |  109|   759k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 759k]
  |  |  ------------------
  ------------------
  303|   759k|}
demux_mkv.c:mkv_free:
 3790|  24.7k|{
 3791|  24.7k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3792|  24.7k|    if (!mkv_d)
  ------------------
  |  Branch (3792:9): [True: 0, False: 24.7k]
  ------------------
 3793|      0|        return;
 3794|  24.7k|    mkv_seek_reset(demuxer);
 3795|  68.5k|    for (int i = 0; i < mkv_d->num_tracks; i++)
  ------------------
  |  Branch (3795:21): [True: 43.7k, False: 24.7k]
  ------------------
 3796|  43.7k|        demux_mkv_free_trackentry(mkv_d->tracks[i]);
 3797|  24.7k|}
demux_mkv.c:demux_mkv_free_trackentry:
  888|  43.7k|{
  889|  43.7k|    talloc_free(track->parser_tmp);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
  890|  43.7k|    av_freep(&track->dovi_config);
  891|  43.7k|    TA_FREEP(&track->dovi_split);
  ------------------
  |  |   81|  43.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  43.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 43.7k]
  |  |  ------------------
  ------------------
  892|  43.7k|    talloc_free(track);
  ------------------
  |  |   47|  43.7k|#define talloc_free                     ta_free
  ------------------
  893|  43.7k|}
demux_mkv.c:demux_mkv_seek:
 3612|  3.56k|{
 3613|  3.56k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 3614|  3.56k|    int64_t old_pos = stream_tell(demuxer->stream);
 3615|  3.56k|    uint64_t v_tnum = -1;
 3616|  3.56k|    uint64_t a_tnum = -1;
 3617|  3.56k|    bool st_active[STREAM_TYPE_COUNT] = {0};
 3618|  3.56k|    mkv_seek_reset(demuxer);
 3619|  8.97k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (3619:21): [True: 5.40k, False: 3.56k]
  ------------------
 3620|  5.40k|        mkv_track_t *track = mkv_d->tracks[i];
 3621|  5.40k|        if (demux_stream_is_selected(track->stream)) {
  ------------------
  |  Branch (3621:13): [True: 4.31k, False: 1.09k]
  ------------------
 3622|  4.31k|            st_active[track->stream->type] = true;
 3623|  4.31k|            if (track->type == MATROSKA_TRACK_VIDEO)
  ------------------
  |  |   78|  4.31k|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (3623:17): [True: 565, False: 3.74k]
  ------------------
 3624|    565|                v_tnum = track->tnum;
 3625|  4.31k|            if (track->type == MATROSKA_TRACK_AUDIO)
  ------------------
  |  |   79|  4.31k|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (3625:17): [True: 3.44k, False: 864]
  ------------------
 3626|  3.44k|                a_tnum = track->tnum;
 3627|  4.31k|        }
 3628|  5.40k|    }
 3629|       |
 3630|  3.56k|    mkv_d->subtitle_preroll = NUM_SUB_PREROLL_PACKETS;
  ------------------
  |  |  287|  3.56k|#define NUM_SUB_PREROLL_PACKETS 500
  ------------------
 3631|  3.56k|    int preroll_opt = mkv_d->opts->subtitle_preroll;
 3632|  3.56k|    if (preroll_opt == 1 || (preroll_opt == 2 && mkv_d->index_has_durations))
  ------------------
  |  Branch (3632:9): [True: 0, False: 3.56k]
  |  Branch (3632:30): [True: 3.56k, False: 0]
  |  Branch (3632:50): [True: 3.08k, False: 488]
  ------------------
 3633|  3.08k|        flags |= SEEK_HR;
  ------------------
  |  |   99|  3.08k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 3634|  3.56k|    if (!st_active[STREAM_SUB])
  ------------------
  |  Branch (3634:9): [True: 3.26k, False: 299]
  ------------------
 3635|  3.26k|        flags &= ~SEEK_HR;
  ------------------
  |  |   99|  3.26k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 3636|       |
 3637|       |    // Adjust the target a little bit to catch cases where the target position
 3638|       |    // specifies a keyframe with high, but not perfect, precision.
 3639|  3.56k|    seek_pts += flags & SEEK_FORWARD ? -0.005 : 0.005;
  ------------------
  |  |   95|  3.56k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (3639:17): [True: 0, False: 3.56k]
  ------------------
 3640|       |
 3641|  3.56k|    if (!(flags & SEEK_FACTOR)) {       /* time in secs */
  ------------------
  |  |   94|  3.56k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (3641:9): [True: 3.56k, False: 0]
  ------------------
 3642|  3.56k|        mkv_index_t *index = NULL;
 3643|       |
 3644|  3.56k|        seek_pts = MPMAX(seek_pts, 0);
  ------------------
  |  |   44|  3.56k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 3.13k, False: 436]
  |  |  ------------------
  ------------------
 3645|  3.56k|        int64_t target_timecode = seek_pts * 1e9 + 0.5;
 3646|       |
 3647|  3.56k|        if (create_index_until(demuxer, target_timecode) >= 0) {
  ------------------
  |  Branch (3647:13): [True: 3.13k, False: 436]
  ------------------
 3648|  3.13k|            int seek_id = st_active[STREAM_VIDEO] ? v_tnum : a_tnum;
  ------------------
  |  Branch (3648:27): [True: 535, False: 2.59k]
  ------------------
 3649|  3.13k|            index = seek_with_cues(demuxer, seek_id, target_timecode, flags);
 3650|  3.13k|            if (!index)
  ------------------
  |  Branch (3650:17): [True: 100, False: 3.03k]
  ------------------
 3651|    100|                index = seek_with_cues(demuxer, -1, target_timecode, flags);
 3652|  3.13k|        }
 3653|       |
 3654|  3.56k|        if (!index)
  ------------------
  |  Branch (3654:13): [True: 436, False: 3.13k]
  ------------------
 3655|    436|            stream_seek(demuxer->stream, old_pos);
 3656|       |
 3657|  3.56k|        if (flags & SEEK_FORWARD)
  ------------------
  |  |   95|  3.56k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (3657:13): [True: 0, False: 3.56k]
  ------------------
 3658|      0|            mkv_d->skip_to_timecode = target_timecode;
 3659|  3.56k|    } else {
 3660|      0|        stream_t *s = demuxer->stream;
 3661|       |
 3662|      0|        read_deferred_cues(demuxer);
 3663|       |
 3664|      0|        int64_t size = stream_get_size(s);
 3665|      0|        int64_t target_filepos = size * MPCLAMP(seek_pts, 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]
  |  |  ------------------
  ------------------
 3666|       |
 3667|      0|        mkv_index_t *index = NULL;
 3668|      0|        if (mkv_d->index_complete) {
  ------------------
  |  Branch (3668:13): [True: 0, False: 0]
  ------------------
 3669|      0|            for (size_t i = 0; i < mkv_d->num_indexes; i++) {
  ------------------
  |  Branch (3669:32): [True: 0, False: 0]
  ------------------
 3670|      0|                if (mkv_d->indexes[i].tnum == v_tnum) {
  ------------------
  |  Branch (3670:21): [True: 0, False: 0]
  ------------------
 3671|      0|                    if ((index == NULL)
  ------------------
  |  Branch (3671:25): [True: 0, False: 0]
  ------------------
 3672|      0|                        || ((mkv_d->indexes[i].filepos >= target_filepos)
  ------------------
  |  Branch (3672:29): [True: 0, False: 0]
  ------------------
 3673|      0|                            && ((index->filepos < target_filepos)
  ------------------
  |  Branch (3673:33): [True: 0, False: 0]
  ------------------
 3674|      0|                                || (mkv_d->indexes[i].filepos < index->filepos))))
  ------------------
  |  Branch (3674:36): [True: 0, False: 0]
  ------------------
 3675|      0|                        index = &mkv_d->indexes[i];
 3676|      0|                }
 3677|      0|            }
 3678|      0|        }
 3679|       |
 3680|      0|        mkv_d->cluster_end = 0;
 3681|       |
 3682|      0|        if (index) {
  ------------------
  |  Branch (3682:13): [True: 0, False: 0]
  ------------------
 3683|      0|            stream_seek(s, index->filepos);
 3684|      0|            mkv_d->skip_to_timecode = index->timecode * mkv_d->tc_scale;
 3685|      0|        } else {
 3686|      0|            stream_seek(s, MPMAX(target_filepos, 0));
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3687|      0|            if (ebml_resync_cluster(mp_null_log, s) < 0) {
  ------------------
  |  Branch (3687:17): [True: 0, False: 0]
  ------------------
 3688|       |                // Assume EOF
 3689|      0|                mkv_d->cluster_end = size;
 3690|      0|            }
 3691|      0|        }
 3692|      0|    }
 3693|       |
 3694|  3.56k|    mkv_d->v_skip_to_keyframe = st_active[STREAM_VIDEO];
 3695|  3.56k|    mkv_d->a_skip_to_keyframe = st_active[STREAM_AUDIO];
 3696|  3.56k|    mkv_d->a_skip_preroll = mkv_d->a_skip_to_keyframe;
 3697|  3.56k|}
demux_mkv.c:create_index_until:
 3494|  3.56k|{
 3495|  3.56k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3496|  3.56k|    struct stream *s = demuxer->stream;
 3497|       |
 3498|  3.56k|    read_deferred_cues(demuxer);
 3499|       |
 3500|  3.56k|    if (mkv_d->index_complete)
  ------------------
  |  Branch (3500:9): [True: 31, False: 3.53k]
  ------------------
 3501|     31|        return 0;
 3502|       |
 3503|  3.53k|    mkv_index_t *index = get_highest_index_entry(demuxer);
 3504|       |
 3505|  3.53k|    if (!index || index->timecode * mkv_d->tc_scale < timecode) {
  ------------------
  |  Branch (3505:9): [True: 457, False: 3.08k]
  |  Branch (3505:19): [True: 2.34k, False: 739]
  ------------------
 3506|  2.79k|        stream_seek(s, index ? index->filepos : mkv_d->cluster_start);
  ------------------
  |  Branch (3506:24): [True: 2.34k, False: 457]
  ------------------
 3507|  2.79k|        MP_VERBOSE(demuxer, "creating index until TC %"PRId64"\n", timecode);
  ------------------
  |  |   92|  2.79k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.79k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3508|  15.8k|        for (;;) {
 3509|  15.8k|            int res;
 3510|  15.8k|            struct block_info block;
 3511|  15.8k|            res = read_next_block(demuxer, &block);
 3512|  15.8k|            if (res < 0)
  ------------------
  |  Branch (3512:17): [True: 1.78k, False: 14.0k]
  ------------------
 3513|  1.78k|                break;
 3514|  14.0k|            if (res > 0) {
  ------------------
  |  Branch (3514:17): [True: 14.0k, False: 0]
  ------------------
 3515|  14.0k|                free_block(&block);
 3516|  14.0k|            }
 3517|  14.0k|            index = get_highest_index_entry(demuxer);
 3518|  14.0k|            if (index && index->timecode * mkv_d->tc_scale >= timecode)
  ------------------
  |  Branch (3518:17): [True: 13.4k, False: 626]
  |  Branch (3518:26): [True: 1.01k, False: 12.4k]
  ------------------
 3519|  1.01k|                break;
 3520|  14.0k|        }
 3521|  2.79k|    }
 3522|  3.53k|    if (!mkv_d->indexes) {
  ------------------
  |  Branch (3522:9): [True: 436, False: 3.10k]
  ------------------
 3523|    436|        MP_WARN(demuxer, "no target for seek found\n");
  ------------------
  |  |   90|    436|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    436|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3524|    436|        return -1;
 3525|    436|    }
 3526|  3.10k|    return 0;
 3527|  3.53k|}
demux_mkv.c:get_highest_index_entry:
 3477|  17.6k|{
 3478|  17.6k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3479|  17.6k|    mp_assert(!mkv_d->index_complete); // would require separate code
  ------------------
  |  |   41|  17.6k|#define mp_assert assert
  ------------------
  |  Branch (3479:5): [True: 17.6k, False: 0]
  ------------------
 3480|       |
 3481|  17.6k|    mkv_index_t *index = NULL;
 3482|  50.8k|    for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (3482:21): [True: 33.2k, False: 17.6k]
  ------------------
 3483|  33.2k|        int n_index = mkv_d->tracks[n]->last_index_entry;
 3484|  33.2k|        if (n_index >= 0) {
  ------------------
  |  Branch (3484:13): [True: 25.8k, False: 7.37k]
  ------------------
 3485|  25.8k|            mkv_index_t *index2 = &mkv_d->indexes[n_index];
 3486|  25.8k|            if (!index || index2->filepos > index->filepos)
  ------------------
  |  Branch (3486:17): [True: 16.5k, False: 9.37k]
  |  Branch (3486:27): [True: 2.32k, False: 7.05k]
  ------------------
 3487|  18.8k|                index = index2;
 3488|  25.8k|        }
 3489|  33.2k|    }
 3490|  17.6k|    return index;
 3491|  17.6k|}
demux_mkv.c:seek_with_cues:
 3531|  3.23k|{
 3532|  3.23k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3533|  3.23k|    struct mkv_index *index = NULL;
 3534|  3.23k|    bool covered = false;
 3535|       |
 3536|  3.23k|    int64_t min_diff = INT64_MIN;
 3537|  13.3k|    for (size_t i = 0; i < mkv_d->num_indexes; i++) {
  ------------------
  |  Branch (3537:24): [True: 10.1k, False: 3.23k]
  ------------------
 3538|  10.1k|        if (seek_id < 0 || mkv_d->indexes[i].tnum == seek_id) {
  ------------------
  |  Branch (3538:13): [True: 310, False: 9.81k]
  |  Branch (3538:28): [True: 6.28k, False: 3.53k]
  ------------------
 3539|  6.59k|            int64_t diff =
 3540|  6.59k|                mkv_d->indexes[i].timecode * mkv_d->tc_scale - target_timecode;
 3541|  6.59k|            if (diff <= 0)
  ------------------
  |  Branch (3541:17): [True: 3.66k, False: 2.93k]
  ------------------
 3542|  3.66k|                covered = true;
 3543|  6.59k|            if (flags & SEEK_FORWARD)
  ------------------
  |  |   95|  6.59k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (3543:17): [True: 0, False: 6.59k]
  ------------------
 3544|      0|                diff = -diff;
 3545|  6.59k|            if (min_diff != INT64_MIN) {
  ------------------
  |  Branch (3545:17): [True: 3.46k, False: 3.13k]
  ------------------
 3546|  3.46k|                if (diff <= 0) {
  ------------------
  |  Branch (3546:21): [True: 1.08k, False: 2.38k]
  ------------------
 3547|  1.08k|                    if (min_diff <= 0 && diff <= min_diff)
  ------------------
  |  Branch (3547:25): [True: 1.08k, False: 0]
  |  Branch (3547:42): [True: 9, False: 1.07k]
  ------------------
 3548|      9|                        continue;
 3549|  2.38k|                } else if (diff >= min_diff)
  ------------------
  |  Branch (3549:28): [True: 2.38k, False: 0]
  ------------------
 3550|  2.38k|                    continue;
 3551|  3.46k|            }
 3552|  4.20k|            min_diff = diff;
 3553|  4.20k|            index = mkv_d->indexes + i;
 3554|  4.20k|        }
 3555|  10.1k|    }
 3556|       |
 3557|  3.23k|    if (index) {        /* We've found an entry. */
  ------------------
  |  Branch (3557:9): [True: 3.13k, False: 100]
  ------------------
 3558|  3.13k|        uint64_t seek_pos = index->filepos;
 3559|  3.13k|        mkv_d->skip_to_timecode = index->timecode * mkv_d->tc_scale;
 3560|  3.13k|        if (!covered) {
  ------------------
  |  Branch (3560:13): [True: 547, False: 2.58k]
  ------------------
 3561|       |            // No entry is at or before the target, the start of the file
 3562|       |            // is the only position that is.
 3563|    547|            seek_pos = mkv_d->first_cluster;
 3564|    547|            mkv_d->skip_to_timecode = INT64_MIN;
 3565|  2.58k|        } else if (flags & SEEK_HR) {
  ------------------
  |  |   99|  2.58k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
  |  Branch (3565:20): [True: 171, False: 2.41k]
  ------------------
 3566|       |            // Find the cluster with the highest filepos, that has a timestamp
 3567|       |            // still lower than min_tc.
 3568|    171|            double secs = mkv_d->opts->subtitle_preroll_secs;
 3569|    171|            if (mkv_d->index_has_durations)
  ------------------
  |  Branch (3569:17): [True: 170, False: 1]
  ------------------
 3570|    170|                secs = MPMAX(secs, mkv_d->opts->subtitle_preroll_secs_index);
  ------------------
  |  |   44|    170|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 170]
  |  |  ------------------
  ------------------
 3571|    171|            double pre_f = secs * 1e9 / mkv_d->tc_scale;
 3572|    171|            int64_t pre = pre_f >= (double)INT64_MAX ? INT64_MAX : (int64_t)pre_f;
  ------------------
  |  Branch (3572:27): [True: 0, False: 171]
  ------------------
 3573|    171|            int64_t min_tc = pre < index->timecode ? index->timecode - pre : 0;
  ------------------
  |  Branch (3573:30): [True: 3, False: 168]
  ------------------
 3574|    171|            uint64_t prev_target = mkv_d->first_cluster;
 3575|    171|            int64_t prev_tc = 0;
 3576|  1.84k|            for (size_t i = 0; i < mkv_d->num_indexes; i++) {
  ------------------
  |  Branch (3576:32): [True: 1.67k, False: 171]
  ------------------
 3577|  1.67k|                if (seek_id < 0 || mkv_d->indexes[i].tnum == seek_id) {
  ------------------
  |  Branch (3577:21): [True: 73, False: 1.59k]
  |  Branch (3577:36): [True: 911, False: 686]
  ------------------
 3578|    984|                    struct mkv_index *cur = &mkv_d->indexes[i];
 3579|    984|                    if (cur->timecode <= min_tc && cur->timecode >= prev_tc) {
  ------------------
  |  Branch (3579:25): [True: 232, False: 752]
  |  Branch (3579:52): [True: 232, False: 0]
  ------------------
 3580|    232|                        prev_tc = cur->timecode;
 3581|    232|                        prev_target = cur->filepos;
 3582|    232|                    }
 3583|    984|                }
 3584|  1.67k|            }
 3585|    171|            if (mkv_d->index_has_durations) {
  ------------------
  |  Branch (3585:17): [True: 170, False: 1]
  ------------------
 3586|       |                // Find the earliest cluster that is not before prev_target,
 3587|       |                // but contains subtitle packets overlapping with the cluster
 3588|       |                // at seek_pos.
 3589|    170|                uint64_t target = seek_pos;
 3590|  1.73k|                for (size_t i = 0; i < mkv_d->num_indexes; i++) {
  ------------------
  |  Branch (3590:36): [True: 1.56k, False: 170]
  ------------------
 3591|  1.56k|                    struct mkv_index *cur = &mkv_d->indexes[i];
 3592|  1.56k|                    if (cur->timecode <= index->timecode &&
  ------------------
  |  Branch (3592:25): [True: 980, False: 580]
  ------------------
 3593|    980|                        cur->timecode + cur->duration > index->timecode &&
  ------------------
  |  Branch (3593:25): [True: 6, False: 974]
  ------------------
 3594|      6|                        cur->filepos >= prev_target &&
  ------------------
  |  Branch (3594:25): [True: 6, False: 0]
  ------------------
 3595|      6|                        cur->filepos < target)
  ------------------
  |  Branch (3595:25): [True: 1, False: 5]
  ------------------
 3596|      1|                    {
 3597|      1|                        target = cur->filepos;
 3598|      1|                    }
 3599|  1.56k|                }
 3600|    170|                prev_target = target;
 3601|    170|            }
 3602|    171|            seek_pos = prev_target;
 3603|    171|        }
 3604|       |
 3605|  3.13k|        mkv_d->cluster_end = 0;
 3606|  3.13k|        stream_seek(demuxer->stream, seek_pos);
 3607|  3.13k|    }
 3608|  3.23k|    return index;
 3609|  3.23k|}

build_ordered_chapter_timeline:
  515|  24.2k|{
  516|  24.2k|    struct demuxer *demuxer = tl->demuxer;
  517|       |
  518|  24.2k|    if (!demuxer->matroska_data.ordered_chapters)
  ------------------
  |  Branch (518:9): [True: 23.9k, False: 286]
  ------------------
  519|  23.9k|        return;
  520|       |
  521|    286|    struct tl_ctx *ctx = talloc_ptrtype(tl, ctx);
  ------------------
  |  |   34|    286|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    286|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|    286|    *ctx = (struct tl_ctx){
  523|    286|        .log = tl->log,
  524|    286|        .global = tl->global,
  525|    286|        .tl = tl,
  526|    286|        .demuxer = demuxer,
  527|    286|        .opts = mp_get_config_group(ctx, tl->global, &mp_opt_root),
  528|    286|    };
  529|       |
  530|    286|    if (!ctx->opts->ordered_chapters || !demuxer->access_references) {
  ------------------
  |  Branch (530:9): [True: 0, False: 286]
  |  Branch (530:41): [True: 0, False: 286]
  ------------------
  531|      0|        MP_INFO(demuxer, "File uses ordered chapters, but "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  532|      0|                "you have disabled support for them. Ignoring.\n");
  533|      0|        talloc_free(ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  534|      0|        return;
  535|      0|    }
  536|       |
  537|    286|    MP_INFO(ctx, "File uses ordered chapters, will build edit timeline.\n");
  ------------------
  |  |   91|    286|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    286|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  538|       |
  539|    286|    struct matroska_data *m = &demuxer->matroska_data;
  540|       |
  541|       |    // +1 because sources/uid_map[0] is original file even if all chapters
  542|       |    // actually use other sources and need separate entries
  543|    286|    ctx->sources = talloc_zero_array(tl, struct demuxer *,
  ------------------
  |  |   30|    286|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|    286|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|    286|                                     m->num_ordered_chapters + 1);
  545|    286|    ctx->sources[0] = demuxer;
  546|    286|    ctx->num_sources = 1;
  547|       |
  548|    286|    ctx->uids = talloc_zero_array(NULL, struct matroska_segment_uid,
  ------------------
  |  |   30|    286|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|    286|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  549|    286|                                  m->num_ordered_chapters + 1);
  550|    286|    ctx->uids[0] = m->uid;
  551|    286|    ctx->uids[0].edition = 0;
  552|       |
  553|  1.35k|    for (int i = 0; i < m->num_ordered_chapters; i++) {
  ------------------
  |  Branch (553:21): [True: 1.06k, False: 286]
  ------------------
  554|  1.06k|        struct matroska_chapter *c = m->ordered_chapters + i;
  555|       |        /* If there isn't a segment uid, we are the source. If the segment uid
  556|       |         * is our segment uid and the edition matches. We can't accept the
  557|       |         * "don't care" edition value of 0 since the user may have requested a
  558|       |         * non-default edition. */
  559|  1.06k|        if (!c->has_segment_uid || demux_matroska_uid_cmp(&c->uid, &m->uid))
  ------------------
  |  Branch (559:13): [True: 1.06k, False: 0]
  |  Branch (559:36): [True: 0, False: 0]
  ------------------
  560|  1.06k|            continue;
  561|       |
  562|      0|        if (has_source_request(ctx, &c->uid))
  ------------------
  |  Branch (562:13): [True: 0, False: 0]
  ------------------
  563|      0|            continue;
  564|       |
  565|      0|        ctx->uids[ctx->num_sources] = c->uid;
  566|      0|        ctx->sources[ctx->num_sources] = NULL;
  567|      0|        ctx->num_sources++;
  568|      0|    }
  569|       |
  570|    286|    find_ordered_chapter_sources(ctx);
  571|       |
  572|    286|    talloc_free(ctx->uids);
  ------------------
  |  |   47|    286|#define talloc_free                     ta_free
  ------------------
  573|    286|    ctx->uids = NULL;
  574|       |
  575|    286|    struct demux_chapter *chapters =
  576|    286|        talloc_zero_array(tl, struct demux_chapter, m->num_ordered_chapters);
  ------------------
  |  |   30|    286|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|    286|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|       |
  578|    286|    ctx->timeline = talloc_array_ptrtype(tl, ctx->timeline, 0);
  ------------------
  |  |   36|    286|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|    286|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|    286|    ctx->num_chapters = m->num_ordered_chapters;
  580|       |
  581|    286|    struct inner_timeline_info info = {
  582|    286|        .skip = 0,
  583|    286|        .limit = 0
  584|    286|    };
  585|    286|    build_timeline_loop(ctx, chapters, &info, 0);
  586|       |
  587|       |    // Fuck everything: filter out all "unset" chapters.
  588|  1.35k|    for (int n = m->num_ordered_chapters - 1; n >= 0; n--) {
  ------------------
  |  Branch (588:47): [True: 1.06k, False: 286]
  ------------------
  589|  1.06k|        if (!chapters[n].metadata)
  ------------------
  |  Branch (589:13): [True: 19, False: 1.04k]
  ------------------
  590|     19|            MP_TARRAY_REMOVE_AT(chapters, m->num_ordered_chapters, n);
  ------------------
  |  |  143|     19|    do {                                            \
  |  |  144|     19|        size_t at_ = (at);                          \
  |  |  145|     19|        assert(at_ < (idxvar));                     \
  |  |  146|     19|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|     19|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|     19|        (idxvar)--;                                 \
  |  |  149|     19|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 19]
  |  |  ------------------
  ------------------
  |  Branch (590:13): [True: 19, False: 0]
  ------------------
  591|  1.06k|    }
  592|       |
  593|    286|    if (!ctx->num_parts) {
  ------------------
  |  Branch (593:9): [True: 67, False: 219]
  ------------------
  594|       |        // None of  the parts come from the file itself???
  595|       |        // Broken file, but we need at least 1 valid timeline part - add a dummy.
  596|     67|        MP_WARN(ctx, "Ordered chapters file with no parts?\n");
  ------------------
  |  |   90|     67|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     67|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  597|     67|        struct timeline_part new = {
  598|     67|            .source = demuxer,
  599|     67|        };
  600|     67|        MP_TARRAY_APPEND(NULL, ctx->timeline, ctx->num_parts, new);
  ------------------
  |  |  105|     67|    do {                                            \
  |  |  106|     67|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     67|    do {                                            \
  |  |  |  |   97|     67|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     67|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     67|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     67|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 67, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     67|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     67|    do {                                                        \
  |  |  |  |  |  |   89|     67|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     67|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     67|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     67|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     67|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     67|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     67|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 67]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     67|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     67|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     67|        (idxvar)++;                                 \
  |  |  109|     67|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 67]
  |  |  ------------------
  ------------------
  601|     67|    }
  602|       |
  603|    770|    for (int n = 0; n < ctx->num_parts; n++) {
  ------------------
  |  Branch (603:21): [True: 484, False: 286]
  ------------------
  604|    484|        ctx->timeline[n].end = n == ctx->num_parts - 1
  ------------------
  |  Branch (604:32): [True: 286, False: 198]
  ------------------
  605|    484|            ? ctx->start_time / 1e9
  606|    484|            : ctx->timeline[n + 1].start;
  607|    484|    };
  608|       |
  609|       |    /* Ignore anything less than a millisecond when reporting missing time. If
  610|       |     * users really notice less than a millisecond missing, maybe this can be
  611|       |     * revisited. */
  612|    286|    if (ctx->missing_time >= 1e6) {
  ------------------
  |  Branch (612:9): [True: 175, False: 111]
  ------------------
  613|    175|        MP_ERR(ctx, "There are %.3f seconds missing from the timeline!\n",
  ------------------
  |  |   89|    175|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    175|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  614|    175|               ctx->missing_time / 1e9);
  615|    175|    }
  616|       |
  617|       |    // With Matroska, the "master" file usually dictates track layout etc.,
  618|       |    // except maybe with playlist-like files.
  619|    286|    struct demuxer *track_layout = ctx->timeline[0].source;
  620|    286|    for (int n = 0; n < ctx->num_parts; n++) {
  ------------------
  |  Branch (620:21): [True: 286, False: 0]
  ------------------
  621|    286|        if (ctx->timeline[n].source == ctx->demuxer) {
  ------------------
  |  Branch (621:13): [True: 286, False: 0]
  ------------------
  622|    286|            track_layout = ctx->demuxer;
  623|    286|            break;
  624|    286|        }
  625|    286|    }
  626|       |
  627|    286|    check_track_compatibility(ctx, track_layout);
  628|       |
  629|    286|    tl->sources = ctx->sources;
  630|    286|    tl->num_sources = ctx->num_sources;
  631|       |
  632|    286|    struct timeline_par *par = talloc_ptrtype(tl, par);
  ------------------
  |  |   34|    286|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    286|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|    286|    *par = (struct timeline_par){
  634|    286|        .parts = ctx->timeline,
  635|    286|        .num_parts = ctx->num_parts,
  636|    286|        .track_layout = track_layout,
  637|    286|    };
  638|    286|    MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par);
  ------------------
  |  |  105|    286|    do {                                            \
  |  |  106|    286|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    286|    do {                                            \
  |  |  |  |   97|    286|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    286|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    286|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    286|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 286, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|    286|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    286|    do {                                                        \
  |  |  |  |  |  |   89|    286|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    286|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    286|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    286|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    286|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    286|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    286|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 286]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    286|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 286]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    286|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    286|        (idxvar)++;                                 \
  |  |  109|    286|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 286]
  |  |  ------------------
  ------------------
  639|    286|    tl->chapters = chapters;
  640|    286|    tl->num_chapters = m->num_ordered_chapters;
  641|    286|    tl->meta = track_layout;
  642|    286|    tl->format = "mkv_oc";
  643|    286|}
demux_mkv_timeline.c:find_ordered_chapter_sources:
  245|    286|{
  246|    286|    struct MPOpts *opts = ctx->opts;
  247|    286|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|    286|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|    286|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  248|    286|    int num_filenames = 0;
  249|    286|    char **filenames = NULL;
  250|    286|    if (ctx->num_sources > 1) {
  ------------------
  |  Branch (250:9): [True: 0, False: 286]
  ------------------
  251|      0|        char *main_filename = ctx->demuxer->filename;
  252|      0|        MP_INFO(ctx, "This file references data from other sources.\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__)
  |  |  ------------------
  ------------------
  253|      0|        if (opts->ordered_chapters_files && opts->ordered_chapters_files[0]) {
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  |  Branch (253:45): [True: 0, False: 0]
  ------------------
  254|      0|            MP_INFO(ctx, "Loading references from '%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__)
  |  |  ------------------
  ------------------
  255|      0|                    opts->ordered_chapters_files);
  256|      0|            struct playlist *pl =
  257|      0|                playlist_parse_file(opts->ordered_chapters_files,
  258|      0|                                    ctx->tl->cancel, ctx->global);
  259|      0|            talloc_steal(tmp, pl);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  260|      0|            for (int n = 0; n < pl->num_entries; n++) {
  ------------------
  |  Branch (260:29): [True: 0, False: 0]
  ------------------
  261|      0|                MP_TARRAY_APPEND(tmp, filenames, num_filenames,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  262|      0|                                 pl->entries[n]->filename);
  263|      0|            }
  264|      0|        } else if (!ctx->demuxer->stream->is_local_fs) {
  ------------------
  |  Branch (264:20): [True: 0, False: 0]
  ------------------
  265|      0|            MP_WARN(ctx, "Playback source is not a "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  266|      0|                    "normal disk file. Will not search for related files.\n");
  267|      0|        } else {
  268|      0|            MP_INFO(ctx, "Will scan other files in the "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  269|      0|                    "same directory to find referenced sources.\n");
  270|      0|            filenames = find_files(main_filename);
  271|      0|            num_filenames = MP_TALLOC_AVAIL(filenames);
  ------------------
  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  ------------------
  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  ------------------
  ------------------
  272|      0|            talloc_steal(tmp, filenames);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  273|      0|        }
  274|       |        // Possibly get further segments appended to the first segment
  275|      0|        check_file(ctx, main_filename, 1);
  276|      0|    }
  277|       |
  278|    286|    int old_source_count;
  279|    286|    do {
  280|    286|        old_source_count = ctx->num_sources;
  281|    286|        for (int i = 0; i < num_filenames; i++) {
  ------------------
  |  Branch (281:25): [True: 0, False: 286]
  ------------------
  282|      0|            if (!missing(ctx))
  ------------------
  |  Branch (282:17): [True: 0, False: 0]
  ------------------
  283|      0|                break;
  284|      0|            MP_VERBOSE(ctx, "Checking file %s\n", filenames[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__)
  |  |  ------------------
  ------------------
  285|      0|            check_file(ctx, filenames[i], 0);
  286|      0|        }
  287|    286|    } while (old_source_count != ctx->num_sources);
  ------------------
  |  Branch (287:14): [True: 0, False: 286]
  ------------------
  288|       |
  289|    286|    if (missing(ctx)) {
  ------------------
  |  Branch (289:9): [True: 0, False: 286]
  ------------------
  290|      0|        MP_ERR(ctx, "Failed to find ordered chapter part!\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__)
  |  |  ------------------
  ------------------
  291|      0|        int j = 1;
  292|      0|        for (int i = 1; i < ctx->num_sources; i++) {
  ------------------
  |  Branch (292:25): [True: 0, False: 0]
  ------------------
  293|      0|            if (ctx->sources[i]) {
  ------------------
  |  Branch (293:17): [True: 0, False: 0]
  ------------------
  294|      0|                ctx->sources[j] = ctx->sources[i];
  295|      0|                ctx->uids[j] = ctx->uids[i];
  296|      0|                j++;
  297|      0|            }
  298|      0|        }
  299|      0|        ctx->num_sources = j;
  300|      0|    }
  301|       |
  302|       |    // Copy attachments from referenced sources so fonts are loaded for sub
  303|       |    // rendering.
  304|    286|    for (int i = 1; i < ctx->num_sources; i++) {
  ------------------
  |  Branch (304:21): [True: 0, False: 286]
  ------------------
  305|      0|        for (int j = 0; j < ctx->sources[i]->num_attachments; j++) {
  ------------------
  |  Branch (305:25): [True: 0, False: 0]
  ------------------
  306|      0|            struct demux_attachment *att = &ctx->sources[i]->attachments[j];
  307|      0|            demuxer_add_attachment(ctx->demuxer, att->name, att->type,
  308|      0|                                   att->data, att->data_size);
  309|      0|        }
  310|      0|    }
  311|       |
  312|    286|    talloc_free(tmp);
  ------------------
  |  |   47|    286|#define talloc_free                     ta_free
  ------------------
  313|    286|}
demux_mkv_timeline.c:missing:
  236|    286|{
  237|    572|    for (int i = 0; i < ctx->num_sources; i++) {
  ------------------
  |  Branch (237:21): [True: 286, False: 286]
  ------------------
  238|    286|        if (!ctx->sources[i])
  ------------------
  |  Branch (238:13): [True: 0, False: 286]
  ------------------
  239|      0|            return true;
  240|    286|    }
  241|    286|    return false;
  242|    286|}
demux_mkv_timeline.c:build_timeline_loop:
  353|    286|{
  354|    286|    uint64_t local_starttime = 0;
  355|    286|    struct demuxer *source = ctx->sources[current_source];
  356|    286|    struct matroska_data *m = &source->matroska_data;
  357|       |
  358|  1.35k|    for (int i = 0; i < m->num_ordered_chapters; i++) {
  ------------------
  |  Branch (358:21): [True: 1.06k, False: 286]
  ------------------
  359|  1.06k|        struct matroska_chapter *c = m->ordered_chapters + i;
  360|  1.06k|        uint64_t chapter_length = c->end - c->start;
  361|       |
  362|  1.06k|        if (!c->has_segment_uid)
  ------------------
  |  Branch (362:13): [True: 1.06k, False: 0]
  ------------------
  363|  1.06k|            c->uid = m->uid;
  364|       |
  365|  1.06k|        local_starttime += chapter_length;
  366|       |
  367|       |        // If we're before the start time for the chapter, skip to the next one.
  368|  1.06k|        if (local_starttime <= info->skip)
  ------------------
  |  Branch (368:13): [True: 19, False: 1.04k]
  ------------------
  369|     19|            continue;
  370|       |
  371|       |        /* Look for the source for this chapter. */
  372|  1.04k|        for (int j = 0; j < ctx->num_sources; j++) {
  ------------------
  |  Branch (372:25): [True: 1.04k, False: 0]
  ------------------
  373|  1.04k|            struct demuxer *linked_source = ctx->sources[j];
  374|  1.04k|            struct matroska_data *linked_m = &linked_source->matroska_data;
  375|       |
  376|  1.04k|            if (!demux_matroska_uid_cmp(&c->uid, &linked_m->uid))
  ------------------
  |  Branch (376:17): [True: 0, False: 1.04k]
  ------------------
  377|      0|                continue;
  378|       |
  379|  1.04k|            if (!info->limit) {
  ------------------
  |  Branch (379:17): [True: 1.04k, False: 0]
  ------------------
  380|  1.04k|                if (i >= ctx->num_chapters)
  ------------------
  |  Branch (380:21): [True: 0, False: 1.04k]
  ------------------
  381|      0|                    break; // malformed files can cause this to happen.
  382|       |
  383|  1.04k|                chapters[i].pts = ctx->start_time / 1e9;
  384|  1.04k|                chapters[i].metadata = talloc_zero(chapters, struct mp_tags);
  ------------------
  |  |   27|  1.04k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.04k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.04k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  385|  1.04k|                mp_tags_set_str(chapters[i].metadata, "title", c->name);
  386|  1.04k|            }
  387|       |
  388|       |            /* If we're the source or it's a non-ordered edition reference,
  389|       |             * just add a timeline part from the source. */
  390|  1.04k|            if (current_source == j || !linked_m->uid.edition) {
  ------------------
  |  Branch (390:17): [True: 1.04k, False: 0]
  |  Branch (390:40): [True: 0, False: 0]
  ------------------
  391|  1.04k|                double source_ns = MP_TIME_S_TO_NS(linked_source->duration);
  ------------------
  |  |   71|  1.04k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  392|  1.04k|                uint64_t source_full_length = source_ns >= 0 && source_ns < 0x1p64 ?
  ------------------
  |  Branch (392:47): [True: 769, False: 280]
  |  Branch (392:65): [True: 769, False: 0]
  ------------------
  393|  1.04k|                                              (uint64_t)source_ns : UINT64_MAX;
  394|  1.04k|                uint64_t source_length = source_full_length - c->start;
  395|  1.04k|                int64_t join_diff = 0;
  396|       |
  397|       |                /* If the chapter starts after the end of a source, there's
  398|       |                 * nothing we can get from it. Instead, mark the entire chapter
  399|       |                 * as missing and make the chapter length 0. */
  400|  1.04k|                if (source_full_length <= c->start) {
  ------------------
  |  Branch (400:21): [True: 276, False: 773]
  ------------------
  401|    276|                    ctx->missing_time += chapter_length;
  402|    276|                    chapter_length = 0;
  403|    276|                    goto found;
  404|    276|                }
  405|       |
  406|       |                /* If the source length starting at the chapter start is
  407|       |                 * shorter than the chapter it is supposed to fill, add the gap
  408|       |                 * to missing_time. Also, modify the chapter length to be what
  409|       |                 * we actually have to avoid playing off the end of the file
  410|       |                 * and not switching to the next source. */
  411|    773|                if (source_length < chapter_length) {
  ------------------
  |  Branch (411:21): [True: 119, False: 654]
  ------------------
  412|    119|                    ctx->missing_time += chapter_length - source_length;
  413|    119|                    chapter_length = source_length;
  414|    119|                }
  415|       |
  416|    773|                join_diff = add_timeline_part(ctx, linked_source, c->start);
  417|       |
  418|       |                /* If we merged two chapters into a single part due to them
  419|       |                 * being off by a few frames, we need to change the limit to
  420|       |                 * avoid chopping the end of the intended chapter (the adding
  421|       |                 * frames case) or showing extra content (the removing frames
  422|       |                 * case). Also update chapter_length to incorporate the extra
  423|       |                 * time. */
  424|    773|                if (info->limit) {
  ------------------
  |  Branch (424:21): [True: 0, False: 773]
  ------------------
  425|      0|                    info->limit += join_diff;
  426|      0|                    chapter_length += join_diff;
  427|      0|                }
  428|    773|            } else {
  429|       |                /* We have an ordered edition as the source. Since this
  430|       |                 * can jump around all over the place, we need to build up the
  431|       |                 * timeline parts for each of its chapters, but not add them as
  432|       |                 * chapters. */
  433|      0|                struct inner_timeline_info new_info = {
  434|      0|                    .skip = c->start,
  435|      0|                    .limit = c->end
  436|      0|                };
  437|      0|                build_timeline_loop(ctx, chapters, &new_info, j);
  438|       |                // Already handled by the loop call.
  439|      0|                chapter_length = 0;
  440|      0|            }
  441|    773|            ctx->last_end_time = c->end;
  442|    773|            goto found;
  443|  1.04k|        }
  444|       |
  445|      0|        ctx->missing_time += chapter_length;
  446|      0|        chapter_length = 0;
  447|  1.04k|    found:;
  448|  1.04k|        ctx->start_time += chapter_length;
  449|       |        /* If we're after the limit on this chapter, stop here. */
  450|  1.04k|        if (info->limit && local_starttime >= info->limit) {
  ------------------
  |  Branch (450:13): [True: 0, False: 1.04k]
  |  Branch (450:28): [True: 0, False: 0]
  ------------------
  451|       |            /* Back up the global start time by the overflow. */
  452|      0|            ctx->start_time -= local_starttime - info->limit;
  453|      0|            break;
  454|      0|        }
  455|  1.04k|    }
  456|       |
  457|       |    /* If we stopped before the limit, add up the missing time. */
  458|    286|    if (local_starttime < info->limit)
  ------------------
  |  Branch (458:9): [True: 0, False: 286]
  ------------------
  459|      0|        ctx->missing_time += info->limit - local_starttime;
  460|    286|}
demux_mkv_timeline.c:add_timeline_part:
  323|    773|{
  324|       |    /* Merge directly adjacent parts. We allow for a configurable fudge factor
  325|       |     * because of files which specify chapter end times that are one frame too
  326|       |     * early; we don't want to try seeking over a one frame gap. */
  327|    773|    int64_t join_diff = start - ctx->last_end_time;
  328|    773|    if (ctx->num_parts == 0
  ------------------
  |  Branch (328:9): [True: 219, False: 554]
  ------------------
  329|    773|        || FFABS(join_diff) > ctx->opts->chapter_merge_threshold * 1e6
  ------------------
  |  Branch (329:12): [True: 434, False: 120]
  |  Branch (329:12): [True: 198, False: 356]
  ------------------
  330|    356|        || source != ctx->timeline[ctx->num_parts - 1].source)
  ------------------
  |  Branch (330:12): [True: 0, False: 356]
  ------------------
  331|    417|    {
  332|    417|        struct timeline_part new = {
  333|    417|            .start = ctx->start_time / 1e9,
  334|    417|            .source_start = start / 1e9,
  335|    417|            .source = source,
  336|    417|        };
  337|    417|        MP_TARRAY_APPEND(NULL, ctx->timeline, ctx->num_parts, new);
  ------------------
  |  |  105|    417|    do {                                            \
  |  |  106|    417|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    417|    do {                                            \
  |  |  |  |   97|    417|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    417|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    417|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    417|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 255, False: 162]
  |  |  |  |  ------------------
  |  |  |  |   99|    417|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    255|    do {                                                        \
  |  |  |  |  |  |   89|    255|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    255|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    255|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    255|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    255|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    255|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    255|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 255]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    417|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 417]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    417|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    417|        (idxvar)++;                                 \
  |  |  109|    417|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 417]
  |  |  ------------------
  ------------------
  338|    417|    } else if (ctx->num_parts > 0 && join_diff) {
  ------------------
  |  Branch (338:16): [True: 356, False: 0]
  |  Branch (338:38): [True: 9, False: 347]
  ------------------
  339|       |        // Chapter was merged at an inexact boundary; adjust timestamps to match.
  340|      9|        MP_VERBOSE(ctx, "Merging timeline part %d with offset %g ms.\n",
  ------------------
  |  |   92|      9|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      9|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  341|      9|                   ctx->num_parts, join_diff / 1e6);
  342|      9|        ctx->start_time += join_diff;
  343|      9|        return join_diff;
  344|      9|    }
  345|       |
  346|    764|    return 0;
  347|    773|}
demux_mkv_timeline.c:check_track_compatibility:
  463|    286|{
  464|    770|    for (int n = 0; n < tl->num_parts; n++) {
  ------------------
  |  Branch (464:21): [True: 484, False: 286]
  ------------------
  465|    484|        struct timeline_part *p = &tl->timeline[n];
  466|    484|        if (p->source == mainsrc)
  ------------------
  |  Branch (466:13): [True: 484, False: 0]
  ------------------
  467|    484|            continue;
  468|       |
  469|      0|        int num_source_streams = demux_get_num_stream(p->source);
  470|      0|        for (int i = 0; i < num_source_streams; i++) {
  ------------------
  |  Branch (470:25): [True: 0, False: 0]
  ------------------
  471|      0|            struct sh_stream *s = demux_get_stream(p->source, i);
  472|      0|            if (s->attached_picture)
  ------------------
  |  Branch (472:17): [True: 0, False: 0]
  ------------------
  473|      0|                continue;
  474|       |
  475|      0|            if (!demuxer_stream_by_demuxer_id(mainsrc, s->type, s->demuxer_id)) {
  ------------------
  |  Branch (475:17): [True: 0, False: 0]
  ------------------
  476|      0|                MP_WARN(tl, "Source %s has %s stream with TID=%d, which "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  477|      0|                            "is not present in the ordered chapters main "
  478|      0|                            "file. This is a broken file. "
  479|      0|                            "The additional stream is ignored.\n",
  480|      0|                            p->source->filename, stream_type_name(s->type),
  481|      0|                            s->demuxer_id);
  482|      0|            }
  483|      0|        }
  484|       |
  485|      0|        int num_main_streams = demux_get_num_stream(mainsrc);
  486|      0|        for (int i = 0; i < num_main_streams; i++) {
  ------------------
  |  Branch (486:25): [True: 0, False: 0]
  ------------------
  487|      0|            struct sh_stream *m = demux_get_stream(mainsrc, i);
  488|      0|            if (m->attached_picture)
  ------------------
  |  Branch (488:17): [True: 0, False: 0]
  ------------------
  489|      0|                continue;
  490|       |
  491|      0|            struct sh_stream *s =
  492|      0|                demuxer_stream_by_demuxer_id(p->source, m->type, m->demuxer_id);
  493|      0|            if (s) {
  ------------------
  |  Branch (493:17): [True: 0, False: 0]
  ------------------
  494|       |                // There are actually many more things that in theory have to
  495|       |                // match (though mpv's implementation doesn't care).
  496|      0|                if (strcmp(s->codec->codec, m->codec->codec) != 0)
  ------------------
  |  Branch (496:21): [True: 0, False: 0]
  ------------------
  497|      0|                    MP_WARN(tl, "Timeline segments have mismatching codec.\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__)
  |  |  ------------------
  ------------------
  498|      0|                if (s->codec->extradata_size != m->codec->extradata_size ||
  ------------------
  |  Branch (498:21): [True: 0, False: 0]
  ------------------
  499|      0|                    (s->codec->extradata_size &&
  ------------------
  |  Branch (499:22): [True: 0, False: 0]
  ------------------
  500|      0|                        memcmp(s->codec->extradata, m->codec->extradata,
  ------------------
  |  Branch (500:25): [True: 0, False: 0]
  ------------------
  501|      0|                               s->codec->extradata_size) != 0))
  502|      0|                    MP_WARN(tl, "Timeline segments have mismatching codec info.\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__)
  |  |  ------------------
  ------------------
  503|      0|            } else {
  504|      0|                MP_WARN(tl, "Source %s lacks %s stream with TID=%d, which "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  505|      0|                            "is present in the ordered chapters main "
  506|      0|                            "file. This is a broken file.\n",
  507|      0|                            p->source->filename, stream_type_name(m->type),
  508|      0|                            m->demuxer_id);
  509|      0|            }
  510|      0|        }
  511|      0|    }
  512|    286|}

demux_timeline.c:d_open:
  771|    286|{
  772|    286|    struct priv *p = demuxer->priv = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|    286|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    286|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|    286|    p->tl = demuxer->params ? demuxer->params->timeline : NULL;
  ------------------
  |  Branch (773:13): [True: 286, False: 0]
  ------------------
  774|    286|    if (!p->tl || p->tl->num_pars < 1)
  ------------------
  |  Branch (774:9): [True: 0, False: 286]
  |  Branch (774:19): [True: 0, False: 286]
  ------------------
  775|      0|        return -1;
  776|       |
  777|    286|    demuxer->chapters = p->tl->chapters;
  778|    286|    demuxer->num_chapters = p->tl->num_chapters;
  779|       |
  780|    286|    struct demuxer *meta = p->tl->meta;
  781|    286|    if (meta) {
  ------------------
  |  Branch (781:9): [True: 286, False: 0]
  ------------------
  782|    286|        demuxer->metadata = meta->metadata;
  783|    286|        demuxer->attachments = meta->attachments;
  784|    286|        demuxer->num_attachments = meta->num_attachments;
  785|    286|        demuxer->editions = meta->editions;
  786|    286|        demuxer->num_editions = meta->num_editions;
  787|    286|        demuxer->edition = meta->edition;
  788|    286|    }
  789|       |
  790|    572|    for (int n = 0; n < p->tl->num_pars; n++) {
  ------------------
  |  Branch (790:21): [True: 286, False: 286]
  ------------------
  791|    286|        if (!add_tl(demuxer, p->tl->pars[n]))
  ------------------
  |  Branch (791:13): [True: 0, False: 286]
  ------------------
  792|      0|            return -1;
  793|    286|    }
  794|       |
  795|    286|    if (!p->num_sources)
  ------------------
  |  Branch (795:9): [True: 0, False: 286]
  ------------------
  796|      0|        return -1;
  797|       |
  798|    286|    build_editions(demuxer);
  799|       |
  800|    286|    demuxer->is_network |= p->tl->is_network;
  801|    286|    demuxer->is_streaming |= p->tl->is_streaming;
  802|       |
  803|    286|    demuxer->duration = p->duration;
  804|       |
  805|    286|    print_timeline(demuxer);
  806|       |
  807|    286|    demuxer->seekable = true;
  808|    286|    demuxer->partially_seekable = false;
  809|       |
  810|    286|    const char *format_name = "unknown";
  811|    286|    if (meta)
  ------------------
  |  Branch (811:9): [True: 286, False: 0]
  ------------------
  812|    286|        format_name = meta->filetype ? meta->filetype : meta->desc->name;
  ------------------
  |  Branch (812:23): [True: 0, False: 286]
  ------------------
  813|    286|    demuxer->filetype = talloc_asprintf(p, "%s/%s", p->tl->format, format_name);
  ------------------
  |  |   52|    286|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|    286|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  814|       |
  815|    286|    reselect_streams(demuxer);
  816|       |
  817|       |    p->owns_tl = true;
  818|    286|    return 0;
  819|    286|}
demux_timeline.c:add_tl:
  552|    286|{
  553|    286|    struct priv *p = demuxer->priv;
  554|       |
  555|    286|    struct MPOpts *mp_opts = mp_get_config_group(NULL, demuxer->global, &mp_opt_root);
  556|    286|    struct virtual_source *src = talloc_ptrtype(p, src);
  ------------------
  |  |   34|    286|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    286|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    286|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|    286|    *src = (struct virtual_source){
  558|    286|        .tl = tl,
  559|    286|        .dash = tl->dash,
  560|    286|        .delay_open = tl->delay_open,
  561|    286|        .no_clip = tl->no_clip || tl->dash,
  ------------------
  |  Branch (561:20): [True: 0, False: 286]
  |  Branch (561:35): [True: 0, False: 286]
  ------------------
  562|    286|        .dts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|    286|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  563|    286|        .rebase = tl->delay_open && mp_opts->rebase_start_time,
  ------------------
  |  Branch (563:19): [True: 0, False: 286]
  |  Branch (563:37): [True: 0, False: 0]
  ------------------
  564|    286|    };
  565|    286|    TA_FREEP(&mp_opts);
  ------------------
  |  |   81|    286|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    286|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 286]
  |  |  ------------------
  ------------------
  566|       |
  567|    286|    if (!tl->num_parts)
  ------------------
  |  Branch (567:9): [True: 0, False: 286]
  ------------------
  568|      0|        return false;
  569|       |
  570|    286|    MP_TARRAY_APPEND(p, p->sources, p->num_sources, src);
  ------------------
  |  |  105|    286|    do {                                            \
  |  |  106|    286|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    286|    do {                                            \
  |  |  |  |   97|    286|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    286|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    286|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    286|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 286, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|    286|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    286|    do {                                                        \
  |  |  |  |  |  |   89|    286|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    286|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    286|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    286|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    286|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    286|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    286|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 286]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    286|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 286]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    286|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    286|        (idxvar)++;                                 \
  |  |  109|    286|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 286]
  |  |  ------------------
  ------------------
  571|       |
  572|    286|    p->duration = MPMAX(p->duration, tl->parts[tl->num_parts - 1].end);
  ------------------
  |  |   44|    286|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 286]
  |  |  ------------------
  ------------------
  573|       |
  574|    286|    struct demuxer *meta = tl->track_layout;
  575|       |
  576|       |    // delay_open streams normally have meta==NULL, and 1 virtual stream
  577|    286|    int num_streams = 0;
  578|    286|    if (tl->delay_open) {
  ------------------
  |  Branch (578:9): [True: 0, False: 286]
  ------------------
  579|      0|        num_streams = tl->num_sh_meta;
  580|    286|    } else if (meta) {
  ------------------
  |  Branch (580:16): [True: 286, False: 0]
  ------------------
  581|    286|        num_streams = demux_get_num_stream(meta);
  582|    286|    }
  583|    914|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (583:21): [True: 628, False: 286]
  ------------------
  584|    628|        struct sh_stream *new = NULL;
  585|       |
  586|    628|        if (tl->delay_open) {
  ------------------
  |  Branch (586:13): [True: 0, False: 628]
  ------------------
  587|      0|            struct sh_stream *tsh = tl->sh_meta[n];
  588|      0|            new = demux_alloc_sh_stream(tsh->type);
  589|      0|            new->codec = tsh->codec;
  590|      0|            apply_meta(new, tsh);
  591|      0|            demuxer->is_network = true;
  592|      0|            demuxer->is_streaming = true;
  593|    628|        } else {
  594|    628|            struct sh_stream *sh = demux_get_stream(meta, n);
  595|    628|            new = demux_alloc_sh_stream(sh->type);
  596|    628|            apply_meta(new, sh);
  597|    628|            new->codec = sh->codec;
  598|    628|            struct sh_stream *tsh = find_matching_meta(tl, n);
  599|    628|            if (tsh)
  ------------------
  |  Branch (599:17): [True: 0, False: 628]
  ------------------
  600|      0|                apply_meta(new, tsh);
  601|    628|        }
  602|       |
  603|    628|        demux_add_sh_stream(demuxer, new);
  604|    628|        struct virtual_stream *vs = talloc_ptrtype(p, vs);
  ------------------
  |  |   34|    628|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    628|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    628|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  605|    628|        *vs = (struct virtual_stream){
  606|    628|            .src = src,
  607|    628|            .sh = new,
  608|    628|        };
  609|    628|        MP_TARRAY_APPEND(p, p->streams, p->num_streams, vs);
  ------------------
  |  |  105|    628|    do {                                            \
  |  |  106|    628|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    628|    do {                                            \
  |  |  |  |   97|    628|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    628|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    628|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    628|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 319, False: 309]
  |  |  |  |  ------------------
  |  |  |  |   99|    628|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    319|    do {                                                        \
  |  |  |  |  |  |   89|    319|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    319|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    319|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    319|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    319|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    319|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    319|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 319]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    628|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    628|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    628|        (idxvar)++;                                 \
  |  |  109|    628|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 628]
  |  |  ------------------
  ------------------
  610|    628|        mp_assert(demux_get_stream(demuxer, p->num_streams - 1) == new);
  ------------------
  |  |   41|    628|#define mp_assert assert
  ------------------
  |  Branch (610:9): [True: 628, False: 0]
  ------------------
  611|    628|        MP_TARRAY_APPEND(src, src->streams, src->num_streams, vs);
  ------------------
  |  |  105|    628|    do {                                            \
  |  |  106|    628|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    628|    do {                                            \
  |  |  |  |   97|    628|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    628|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    628|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    628|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 319, False: 309]
  |  |  |  |  ------------------
  |  |  |  |   99|    628|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    319|    do {                                                        \
  |  |  |  |  |  |   89|    319|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    319|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    319|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    319|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    319|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    319|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    319|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 319]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    628|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    628|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    628|        (idxvar)++;                                 \
  |  |  109|    628|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 628]
  |  |  ------------------
  ------------------
  612|    628|    }
  613|       |
  614|    770|    for (int n = 0; n < tl->num_parts; n++) {
  ------------------
  |  Branch (614:21): [True: 484, False: 286]
  ------------------
  615|    484|        struct timeline_part *part = &tl->parts[n];
  616|       |
  617|       |        // demux_timeline already does caching, doing it for the sub-demuxers
  618|       |        // would be pointless and wasteful.
  619|    484|        if (part->source) {
  ------------------
  |  Branch (619:13): [True: 484, False: 0]
  ------------------
  620|    484|            demuxer->is_network |= part->source->is_network;
  621|    484|            demuxer->is_streaming |= part->source->is_streaming;
  622|    484|        }
  623|       |
  624|    484|        if (!part->source)
  ------------------
  |  Branch (624:13): [True: 0, False: 484]
  ------------------
  625|    484|            mp_assert(tl->dash || tl->delay_open);
  ------------------
  |  |   41|    484|#define mp_assert assert
  ------------------
  |  Branch (625:13): [True: 0, False: 0]
  |  Branch (625:13): [True: 0, False: 0]
  ------------------
  626|       |
  627|    484|        struct segment *seg = talloc_ptrtype(src, seg);
  ------------------
  |  |   34|    484|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    484|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    484|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|    484|        *seg = (struct segment){
  629|    484|            .d = part->source,
  630|    484|            .url = part->source ? part->source->filename : part->url,
  ------------------
  |  Branch (630:20): [True: 484, False: 0]
  ------------------
  631|    484|            .lazy = !part->source,
  632|    484|            .d_start = part->source_start,
  633|    484|            .start = part->start,
  634|    484|            .end = part->end,
  635|    484|        };
  636|       |
  637|    484|        associate_streams(demuxer, src, seg);
  638|       |
  639|    484|        seg->index = n;
  640|    484|        MP_TARRAY_APPEND(src, src->segments, src->num_segments, seg);
  ------------------
  |  |  105|    484|    do {                                            \
  |  |  106|    484|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    484|    do {                                            \
  |  |  |  |   97|    484|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    484|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    484|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    484|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 322, False: 162]
  |  |  |  |  ------------------
  |  |  |  |   99|    484|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    322|    do {                                                        \
  |  |  |  |  |  |   89|    322|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    322|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    322|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    322|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    322|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    322|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    322|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 322]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    484|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 484]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    484|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    484|        (idxvar)++;                                 \
  |  |  109|    484|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 484]
  |  |  ------------------
  ------------------
  641|    484|    }
  642|       |
  643|    286|    if (tl->track_layout) {
  ------------------
  |  Branch (643:9): [True: 286, False: 0]
  ------------------
  644|    286|        demuxer->is_network |= tl->track_layout->is_network;
  645|    286|        demuxer->is_streaming |= tl->track_layout->is_streaming;
  646|    286|    }
  647|       |    return true;
  648|    286|}
demux_timeline.c:apply_meta:
  521|    628|{
  522|    628|    if (src->demuxer_id >= 0)
  ------------------
  |  Branch (522:9): [True: 627, False: 1]
  ------------------
  523|    627|        dst->demuxer_id = src->demuxer_id;
  524|    628|    if (src->title)
  ------------------
  |  Branch (524:9): [True: 58, False: 570]
  ------------------
  525|     58|        dst->title = src->title;
  526|    628|    if (src->lang)
  ------------------
  |  Branch (526:9): [True: 556, False: 72]
  ------------------
  527|    556|        dst->lang = src->lang;
  528|    628|    dst->default_track = src->default_track;
  529|    628|    dst->forced_track = src->forced_track;
  530|    628|    if (src->hls_bitrate)
  ------------------
  |  Branch (530:9): [True: 0, False: 628]
  ------------------
  531|      0|        dst->hls_bitrate = src->hls_bitrate;
  532|    628|    for (int i = 0; i < src->num_program_ids; i++)
  ------------------
  |  Branch (532:21): [True: 0, False: 628]
  ------------------
  533|      0|        MP_TARRAY_APPEND(dst, dst->program_ids, dst->num_program_ids, src->program_ids[i]);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  534|    628|    dst->missing_timestamps = src->missing_timestamps;
  535|    628|    if (src->attached_picture)
  ------------------
  |  Branch (535:9): [True: 1, False: 627]
  ------------------
  536|      1|        dst->attached_picture = src->attached_picture;
  537|    628|    dst->image = src->image;
  538|    628|}
demux_timeline.c:find_matching_meta:
  542|    628|{
  543|    628|    for (int n = 0; n < tl->num_sh_meta; n++) {
  ------------------
  |  Branch (543:21): [True: 0, False: 628]
  ------------------
  544|      0|        struct sh_stream *sh = tl->sh_meta[n];
  545|      0|        if (sh->index == index || sh->index < 0)
  ------------------
  |  Branch (545:13): [True: 0, False: 0]
  |  Branch (545:35): [True: 0, False: 0]
  ------------------
  546|      0|            return sh;
  547|      0|    }
  548|    628|    return NULL;
  549|    628|}
demux_timeline.c:associate_streams:
  115|    484|{
  116|    484|    if (!seg->d || seg->stream_map)
  ------------------
  |  Branch (116:9): [True: 0, False: 484]
  |  Branch (116:20): [True: 0, False: 484]
  ------------------
  117|      0|        return;
  118|       |
  119|    484|    int num_streams = demux_get_num_stream(seg->d);
  120|  1.64k|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (120:21): [True: 1.16k, False: 484]
  ------------------
  121|  1.16k|        struct sh_stream *sh = demux_get_stream(seg->d, n);
  122|  1.16k|        struct virtual_stream *other = NULL;
  123|       |
  124|  5.32k|        for (int i = 0; i < src->num_streams; i++) {
  ------------------
  |  Branch (124:25): [True: 4.16k, False: 1.16k]
  ------------------
  125|  4.16k|            struct virtual_stream *vs = src->streams[i];
  126|       |
  127|       |            // The stream must always have the same media type. Also, a stream
  128|       |            // can't be assigned multiple times.
  129|  4.16k|            if (sh->type != vs->sh->type || target_stream_used(seg, vs))
  ------------------
  |  Branch (129:17): [True: 2.44k, False: 1.71k]
  |  Branch (129:45): [True: 278, False: 1.44k]
  ------------------
  130|  2.72k|                continue;
  131|       |
  132|       |            // By default pick the first matching stream.
  133|  1.44k|            if (!other)
  ------------------
  |  Branch (133:17): [True: 1.16k, False: 278]
  ------------------
  134|  1.16k|                other = vs;
  135|       |
  136|       |            // Matching by demuxer ID is supposedly useful and preferable for
  137|       |            // ordered chapters.
  138|  1.44k|            if (sh->demuxer_id >= 0 && sh->demuxer_id == vs->sh->demuxer_id)
  ------------------
  |  Branch (138:17): [True: 1.43k, False: 2]
  |  Branch (138:40): [True: 1.16k, False: 278]
  ------------------
  139|  1.16k|                other = vs;
  140|  1.44k|        }
  141|       |
  142|  1.16k|        if (!other) {
  ------------------
  |  Branch (142:13): [True: 0, False: 1.16k]
  ------------------
  143|      0|            MP_WARN(demuxer, "Source stream %d (%s) unused and hidden.\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__)
  |  |  ------------------
  ------------------
  144|      0|                    n, stream_type_name(sh->type));
  145|      0|        }
  146|       |
  147|  1.16k|        MP_TARRAY_APPEND(seg, seg->stream_map, seg->num_stream_map, other);
  ------------------
  |  |  105|  1.16k|    do {                                            \
  |  |  106|  1.16k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  1.16k|    do {                                            \
  |  |  |  |   97|  1.16k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  1.16k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.16k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  1.16k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 574, False: 589]
  |  |  |  |  ------------------
  |  |  |  |   99|  1.16k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    574|    do {                                                        \
  |  |  |  |  |  |   89|    574|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    574|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    574|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    574|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    574|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    574|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    574|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 574]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  1.16k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  1.16k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  1.16k|        (idxvar)++;                                 \
  |  |  109|  1.16k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.16k]
  |  |  ------------------
  ------------------
  148|  1.16k|    }
  149|    484|}
demux_timeline.c:target_stream_used:
  103|  1.71k|{
  104|  4.40k|    for (int n = 0; n < seg->num_stream_map; n++) {
  ------------------
  |  Branch (104:21): [True: 2.96k, False: 1.44k]
  ------------------
  105|  2.96k|        if (seg->stream_map[n] == vs)
  ------------------
  |  Branch (105:13): [True: 278, False: 2.68k]
  ------------------
  106|    278|            return true;
  107|  2.96k|    }
  108|  1.44k|    return false;
  109|  1.71k|}
demux_timeline.c:build_editions:
  660|    286|{
  661|       |    // Don't override editions from the underlying demuxer.
  662|    286|    if (demuxer->num_editions > 0)
  ------------------
  |  Branch (662:9): [True: 286, False: 0]
  ------------------
  663|    286|        return;
  664|       |
  665|      0|    struct MPOpts *mp_opts = mp_get_config_group(NULL, demuxer->global, &mp_opt_root);
  666|      0|    int hls_bitrate = mp_opts->hls_bitrate;
  667|      0|    int edition_id = mp_opts->edition_id;
  668|      0|    bool flatten_editions = mp_opts->flatten_editions;
  669|      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]
  |  |  ------------------
  ------------------
  670|      0|    if (flatten_editions) {
  ------------------
  |  Branch (670:9): [True: 0, False: 0]
  ------------------
  671|      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__)
  |  |  ------------------
  ------------------
  672|      0|        return;
  673|      0|    }
  674|       |
  675|      0|    int num_streams = demux_get_num_stream(demuxer);
  676|      0|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (676:21): [True: 0, False: 0]
  ------------------
  677|      0|        struct sh_stream *sh = demux_get_stream(demuxer, n);
  678|      0|        for (int pi = 0; pi < sh->num_program_ids; pi++) {
  ------------------
  |  Branch (678:26): [True: 0, False: 0]
  ------------------
  679|      0|            int program_id = sh->program_ids[pi];
  680|      0|            if (find_edition(demuxer, program_id) >= 0)
  ------------------
  |  Branch (680:17): [True: 0, False: 0]
  ------------------
  681|      0|                continue;
  682|       |
  683|      0|            struct demux_edition ed = {
  684|      0|                .demuxer_id = program_id,
  685|      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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|      0|            };
  687|       |
  688|      0|            const char *prefix = NULL;
  689|      0|            bool prefix_is_video = false;
  690|      0|            for (int i = 0; i < num_streams; i++) {
  ------------------
  |  Branch (690:29): [True: 0, False: 0]
  ------------------
  691|      0|                struct sh_stream *s = demux_get_stream(demuxer, i);
  692|      0|                if (!sh_stream_has_program(s, program_id) || !s->title)
  ------------------
  |  Branch (692:21): [True: 0, False: 0]
  |  Branch (692:62): [True: 0, False: 0]
  ------------------
  693|      0|                    continue;
  694|      0|                if (!prefix || (!prefix_is_video && s->type == STREAM_VIDEO)) {
  ------------------
  |  Branch (694:21): [True: 0, False: 0]
  |  Branch (694:33): [True: 0, False: 0]
  |  Branch (694:53): [True: 0, False: 0]
  ------------------
  695|      0|                    prefix = s->title;
  696|      0|                    prefix_is_video = s->type == STREAM_VIDEO;
  697|      0|                }
  698|      0|            }
  699|      0|            char *title = demux_compose_edition_title(demuxer, demuxer,
  700|      0|                                                      program_id, prefix);
  701|      0|            if (title)
  ------------------
  |  Branch (701:17): [True: 0, False: 0]
  ------------------
  702|      0|                mp_tags_set_str(ed.metadata, "title", title);
  703|       |
  704|      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]
  |  |  ------------------
  ------------------
  705|      0|        }
  706|      0|    }
  707|       |
  708|      0|    if (demuxer->num_editions <= 1) {
  ------------------
  |  Branch (708:9): [True: 0, False: 0]
  ------------------
  709|      0|        demuxer->num_editions = 0;
  710|      0|        return;
  711|      0|    }
  712|       |
  713|      0|    demuxer->edition_is_track_mapping = true;
  714|       |
  715|      0|    int selected = -1;
  716|      0|    if (edition_id >= 0 && edition_id < demuxer->num_editions)
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  |  Branch (716:28): [True: 0, False: 0]
  ------------------
  717|      0|        selected = edition_id;
  718|       |
  719|       |    // Select initial edition by best variant bitrate, preferring editions
  720|       |    // whose video stream is marked as default. Audio streams are considered
  721|       |    // too so that audio-only variants (e.g. HLS/DASH audio-only renditions)
  722|       |    // still get picked, but video always wins over audio.
  723|      0|    if (selected < 0) {
  ------------------
  |  Branch (723:9): [True: 0, False: 0]
  ------------------
  724|      0|        int best = -1;
  725|      0|        int best_bitrate = 0;
  726|      0|        bool best_ok = false;
  727|      0|        bool best_default = false;
  728|      0|        bool best_video = false;
  729|      0|        for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (729:25): [True: 0, False: 0]
  ------------------
  730|      0|            struct sh_stream *sh = demux_get_stream(demuxer, n);
  731|      0|            if (sh->type != STREAM_VIDEO && sh->type != STREAM_AUDIO)
  ------------------
  |  Branch (731:17): [True: 0, False: 0]
  |  Branch (731:45): [True: 0, False: 0]
  ------------------
  732|      0|                continue;
  733|      0|            if (!sh->default_track && (hls_bitrate < 0 || sh->hls_bitrate <= 0))
  ------------------
  |  Branch (733:17): [True: 0, False: 0]
  |  Branch (733:40): [True: 0, False: 0]
  |  Branch (733:59): [True: 0, False: 0]
  ------------------
  734|      0|                continue;
  735|      0|            for (int pi = 0; pi < sh->num_program_ids; pi++) {
  ------------------
  |  Branch (735:30): [True: 0, False: 0]
  ------------------
  736|      0|                int e = find_edition(demuxer, sh->program_ids[pi]);
  737|      0|                if (e < 0)
  ------------------
  |  Branch (737:21): [True: 0, False: 0]
  ------------------
  738|      0|                    continue;
  739|      0|                bool ok = hls_bitrate < 0 || sh->hls_bitrate <= hls_bitrate;
  ------------------
  |  Branch (739:27): [True: 0, False: 0]
  |  Branch (739:46): [True: 0, False: 0]
  ------------------
  740|      0|                bool is_video = sh->type == STREAM_VIDEO;
  741|      0|                bool better;
  742|      0|                if (best < 0) {
  ------------------
  |  Branch (742:21): [True: 0, False: 0]
  ------------------
  743|      0|                    better = true;
  744|      0|                } else if (is_video != best_video) {
  ------------------
  |  Branch (744:28): [True: 0, False: 0]
  ------------------
  745|      0|                    better = is_video;
  746|      0|                } else if (sh->default_track != best_default) {
  ------------------
  |  Branch (746:28): [True: 0, False: 0]
  ------------------
  747|      0|                    better = sh->default_track;
  748|      0|                } else if (ok != best_ok) {
  ------------------
  |  Branch (748:28): [True: 0, False: 0]
  ------------------
  749|      0|                    better = ok;
  750|      0|                } else {
  751|      0|                    better = ok ? sh->hls_bitrate > best_bitrate
  ------------------
  |  Branch (751:30): [True: 0, False: 0]
  ------------------
  752|      0|                                : sh->hls_bitrate < best_bitrate;
  753|      0|                }
  754|      0|                if (better) {
  ------------------
  |  Branch (754:21): [True: 0, False: 0]
  ------------------
  755|      0|                    best = e;
  756|      0|                    best_bitrate = sh->hls_bitrate;
  757|      0|                    best_ok = ok;
  758|      0|                    best_default = sh->default_track;
  759|      0|                    best_video = is_video;
  760|      0|                }
  761|      0|            }
  762|      0|        }
  763|      0|        if (best >= 0)
  ------------------
  |  Branch (763:13): [True: 0, False: 0]
  ------------------
  764|      0|            selected = best;
  765|      0|    }
  766|       |
  767|      0|    demuxer->edition = selected >= 0 ? selected : 0;
  ------------------
  |  Branch (767:24): [True: 0, False: 0]
  ------------------
  768|      0|}
demux_timeline.c:print_timeline:
  481|    286|{
  482|    286|    struct priv *p = demuxer->priv;
  483|       |
  484|    286|    MP_VERBOSE(demuxer, "Timeline segments:\n");
  ------------------
  |  |   92|    286|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    286|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  485|    572|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (485:21): [True: 286, False: 286]
  ------------------
  486|    286|        struct virtual_source *src = p->sources[x];
  487|       |
  488|    286|        if (x >= 1)
  ------------------
  |  Branch (488:13): [True: 0, False: 286]
  ------------------
  489|    286|            MP_VERBOSE(demuxer, " --- new parallel 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__)
  |  |  ------------------
  ------------------
  490|       |
  491|    770|        for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (491:25): [True: 484, False: 286]
  ------------------
  492|    484|            struct segment *seg = src->segments[n];
  493|    484|            int src_num = n;
  494|    484|            for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (494:29): [True: 198, False: 286]
  ------------------
  495|    198|                if (seg->d && src->segments[i]->d == seg->d) {
  ------------------
  |  Branch (495:21): [True: 198, False: 0]
  |  Branch (495:31): [True: 198, False: 0]
  ------------------
  496|    198|                    src_num = i;
  497|    198|                    break;
  498|    198|                }
  499|    198|            }
  500|    484|            MP_VERBOSE(demuxer, " %2d: %12f - %12f [%12f] (",
  ------------------
  |  |   92|    484|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    484|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  501|    484|                       n, seg->start, seg->end, seg->d_start);
  502|  1.64k|            for (int i = 0; i < seg->num_stream_map; i++) {
  ------------------
  |  Branch (502:29): [True: 1.16k, False: 484]
  ------------------
  503|  1.16k|                struct virtual_stream *vs = seg->stream_map[i];
  504|  1.16k|                MP_VERBOSE(demuxer, "%s%d", i ? " " : "",
  ------------------
  |  |   92|  1.16k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.65k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 753, False: 410]
  |  |  |  |  |  Branch (86:57): [True: 1.16k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|  1.16k|                           vs ? vs->sh->index : -1);
  506|  1.16k|            }
  507|    484|            MP_VERBOSE(demuxer, ")\n  source %d:'%s'\n", src_num, seg->url);
  ------------------
  |  |   92|    484|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    484|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  508|    484|        }
  509|       |
  510|    286|        if (src->dash)
  ------------------
  |  Branch (510:13): [True: 0, False: 286]
  ------------------
  511|    286|            MP_VERBOSE(demuxer, " (Using pseudo-DASH mode.)\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__)
  |  |  ------------------
  ------------------
  512|    286|    }
  513|    286|    MP_VERBOSE(demuxer, "Total duration: %f\n", p->duration);
  ------------------
  |  |   92|    286|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    286|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  514|    286|}
demux_timeline.c:reselect_streams:
  152|    974|{
  153|    974|    struct priv *p = demuxer->priv;
  154|       |
  155|  3.53k|    for (int n = 0; n < p->num_streams; n++) {
  ------------------
  |  Branch (155:21): [True: 2.56k, False: 974]
  ------------------
  156|  2.56k|        struct virtual_stream *vs = p->streams[n];
  157|  2.56k|        vs->selected = demux_stream_is_selected(vs->sh);
  158|  2.56k|    }
  159|       |
  160|  1.94k|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (160:21): [True: 974, False: 974]
  ------------------
  161|    974|        struct virtual_source *src = p->sources[x];
  162|       |
  163|  2.77k|        for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (163:25): [True: 1.79k, False: 974]
  ------------------
  164|  1.79k|            struct segment *seg = src->segments[n];
  165|       |
  166|  1.79k|            if (!seg->d)
  ------------------
  |  Branch (166:17): [True: 0, False: 1.79k]
  ------------------
  167|      0|                continue;
  168|       |
  169|  7.00k|            for (int i = 0; i < seg->num_stream_map; i++) {
  ------------------
  |  Branch (169:29): [True: 5.20k, False: 1.79k]
  ------------------
  170|  5.20k|                bool selected =
  171|  5.20k|                    seg->stream_map[i] && seg->stream_map[i]->selected;
  ------------------
  |  Branch (171:21): [True: 5.20k, False: 0]
  |  Branch (171:43): [True: 2.75k, False: 2.45k]
  ------------------
  172|       |
  173|       |                // This stops demuxer readahead for inactive segments.
  174|  5.20k|                if (!src->current || seg->d != src->current->d)
  ------------------
  |  Branch (174:21): [True: 2.75k, False: 2.45k]
  |  Branch (174:38): [True: 0, False: 2.45k]
  ------------------
  175|  2.75k|                    selected = false;
  176|  5.20k|                struct sh_stream *sh = demux_get_stream(seg->d, i);
  177|  5.20k|                demuxer_select_track(seg->d, sh, MP_NOPTS_VALUE, selected);
  ------------------
  |  |   39|  5.20k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  178|       |
  179|  5.20k|                update_slave_stats(demuxer, seg->d);
  180|  5.20k|            }
  181|  1.79k|        }
  182|       |
  183|    974|        bool was_selected = src->any_selected;
  184|    974|        src->any_selected = false;
  185|       |
  186|  3.53k|        for (int n = 0; n < src->num_streams; n++)
  ------------------
  |  Branch (186:25): [True: 2.56k, False: 974]
  ------------------
  187|  2.56k|            src->any_selected |= src->streams[n]->selected;
  188|       |
  189|    974|        if (!was_selected && src->any_selected) {
  ------------------
  |  Branch (189:13): [True: 531, False: 443]
  |  Branch (189:30): [True: 245, False: 286]
  ------------------
  190|    245|            src->eof_reached = false;
  191|    245|            src->dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    245|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  192|       |            TA_FREEP(&src->next);
  ------------------
  |  |   81|    245|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    245|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 245]
  |  |  ------------------
  ------------------
  193|    245|        }
  194|    974|    }
  195|    974|}
demux_timeline.c:update_slave_stats:
   98|  13.8k|{
   99|  13.8k|    demux_report_unbuffered_read_bytes(demuxer, demux_get_bytes_read_hack(slave));
  100|  13.8k|}
demux_timeline.c:d_read_packet:
  377|  8.68k|{
  378|  8.68k|    struct priv *p = demuxer->priv;
  379|  8.68k|    struct virtual_source *src = NULL;
  380|       |
  381|  17.3k|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (381:21): [True: 8.68k, False: 8.68k]
  ------------------
  382|  8.68k|        struct virtual_source *cur = p->sources[x];
  383|       |
  384|  8.68k|        if (!cur->any_selected || cur->eof_reached)
  ------------------
  |  Branch (384:13): [True: 0, False: 8.68k]
  |  Branch (384:35): [True: 230, False: 8.45k]
  ------------------
  385|    230|            continue;
  386|       |
  387|  8.45k|        if (!cur->current)
  ------------------
  |  Branch (387:13): [True: 215, False: 8.24k]
  ------------------
  388|    215|            switch_segment(demuxer, cur, cur->segments[0], 0, 0, true);
  389|       |
  390|  8.45k|        if (!cur->any_selected || !cur->current || !cur->current->d)
  ------------------
  |  Branch (390:13): [True: 0, False: 8.45k]
  |  Branch (390:35): [True: 0, False: 8.45k]
  |  Branch (390:52): [True: 0, False: 8.45k]
  ------------------
  391|      0|            continue;
  392|       |
  393|  8.45k|        if (!src || cur->dts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  8.45k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (393:13): [True: 8.45k, False: 0]
  |  Branch (393:21): [True: 0, False: 0]
  ------------------
  394|      0|            (src->dts != MP_NOPTS_VALUE && cur->dts < src->dts))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (394:14): [True: 0, False: 0]
  |  Branch (394:44): [True: 0, False: 0]
  ------------------
  395|  8.45k|            src = cur;
  396|  8.45k|    }
  397|       |
  398|  8.68k|    if (!src)
  ------------------
  |  Branch (398:9): [True: 230, False: 8.45k]
  ------------------
  399|    230|        return false;
  400|       |
  401|  8.45k|    do_read_next_packet(demuxer, src);
  402|  8.45k|    *out_pkt = src->next;
  403|  8.45k|    src->next = NULL;
  404|       |    return true;
  405|  8.68k|}
demux_timeline.c:switch_segment:
  241|    384|{
  242|    384|    if (!(flags & SEEK_FORWARD))
  ------------------
  |  |   95|    384|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (242:9): [True: 384, False: 0]
  ------------------
  243|    384|        flags |= SEEK_HR;
  ------------------
  |  |   99|    384|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
  244|       |
  245|    384|    MP_VERBOSE(demuxer, "switch to segment %d\n", new->index);
  ------------------
  |  |   92|    384|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    384|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  246|       |
  247|    384|    if (src->current && src->current->d)
  ------------------
  |  Branch (247:9): [True: 147, False: 237]
  |  Branch (247:25): [True: 147, False: 0]
  ------------------
  248|    147|        update_slave_stats(demuxer, src->current->d);
  249|       |
  250|    384|    src->current = new;
  251|    384|    reopen_lazy_segments(demuxer, src);
  252|    384|    if (!new->d)
  ------------------
  |  Branch (252:9): [True: 0, False: 384]
  ------------------
  253|      0|        return;
  254|    384|    reselect_streams(demuxer);
  255|    384|    if (!src->no_clip)
  ------------------
  |  Branch (255:9): [True: 384, False: 0]
  ------------------
  256|    384|        demux_set_ts_offset(new->d, new->start - new->d_start);
  257|      0|    else if (src->rebase)
  ------------------
  |  Branch (257:14): [True: 0, False: 0]
  ------------------
  258|      0|        demux_set_ts_offset(new->d, new->start - new->d->start_time);
  259|    384|    if (!src->no_clip || !init)
  ------------------
  |  Branch (259:9): [True: 384, False: 0]
  |  Branch (259:26): [True: 0, False: 0]
  ------------------
  260|    384|        demux_seek(new->d, start_pts, flags);
  261|       |
  262|  1.47k|    for (int n = 0; n < src->num_streams; n++) {
  ------------------
  |  Branch (262:21): [True: 1.09k, False: 384]
  ------------------
  263|  1.09k|        struct virtual_stream *vs = src->streams[n];
  264|  1.09k|        vs->eos_packets = 0;
  265|  1.09k|    }
  266|       |
  267|       |    src->eof_reached = false;
  268|    384|    src->eos_packets = 0;
  269|    384|}
demux_timeline.c:reopen_lazy_segments:
  213|    384|{
  214|    384|    if (src->current->d || src->current->load_failed)
  ------------------
  |  Branch (214:9): [True: 384, False: 0]
  |  Branch (214:28): [True: 0, False: 0]
  ------------------
  215|    384|        return;
  216|       |
  217|       |    // Note: we must _not_ close segments during demuxing,
  218|       |    // because demuxed packets have demux_packet.codec set to objects owned
  219|       |    // by the segments. Closing them would create dangling pointers.
  220|       |
  221|      0|    struct demuxer_params params = {
  222|      0|        .init_fragment = src->tl->init_fragment,
  223|      0|        .skip_lavf_probing = src->tl->dash,
  224|      0|        .stream_flags = demuxer->stream_origin,
  225|      0|        .depth = demuxer->depth + 1,
  226|      0|    };
  227|      0|    src->current->d = demux_open_url(src->current->url, &params,
  228|      0|                                     demuxer->cancel, demuxer->global);
  229|      0|    if (!src->current->d && !demux_cancel_test(demuxer)) {
  ------------------
  |  Branch (229:9): [True: 0, False: 0]
  |  Branch (229:29): [True: 0, False: 0]
  ------------------
  230|      0|        MP_ERR(demuxer, "failed to load segment\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__)
  |  |  ------------------
  ------------------
  231|      0|        src->current->load_failed = true;
  232|      0|    }
  233|      0|    if (src->current->d)
  ------------------
  |  Branch (233:9): [True: 0, False: 0]
  ------------------
  234|      0|        update_slave_stats(demuxer, src->current->d);
  235|      0|    associate_streams(demuxer, src, src->current);
  236|      0|}
demux_timeline.c:do_read_next_packet:
  273|  8.45k|{
  274|  8.45k|    if (src->next)
  ------------------
  |  Branch (274:9): [True: 0, False: 8.45k]
  ------------------
  275|      0|        return;
  276|       |
  277|  8.45k|    struct segment *seg = src->current;
  278|  8.45k|    if (!seg || !seg->d) {
  ------------------
  |  Branch (278:9): [True: 0, False: 8.45k]
  |  Branch (278:17): [True: 0, False: 8.45k]
  ------------------
  279|      0|        src->eof_reached = true;
  280|      0|        return;
  281|      0|    }
  282|       |
  283|  8.45k|    struct demux_packet *pkt = demux_read_any_packet(seg->d, NULL);
  284|  8.45k|    if (!pkt || (!src->no_clip && pkt->pts >= seg->end))
  ------------------
  |  Branch (284:9): [True: 376, False: 8.08k]
  |  Branch (284:18): [True: 8.08k, False: 0]
  |  Branch (284:35): [True: 669, False: 7.41k]
  ------------------
  285|  1.04k|        src->eos_packets += 1;
  286|       |
  287|  8.45k|    update_slave_stats(demuxer, seg->d);
  288|       |
  289|       |    // Test for EOF. Do this here to properly run into EOF even if other
  290|       |    // streams are disabled etc. If it somehow doesn't manage to reach the end
  291|       |    // after demuxing a high (bit arbitrary) number of packets, assume one of
  292|       |    // the streams went EOF early.
  293|  8.45k|    bool eos_reached = src->eos_packets > 0;
  294|  8.45k|    if (eos_reached && src->eos_packets < 100) {
  ------------------
  |  Branch (294:9): [True: 1.32k, False: 7.13k]
  |  Branch (294:24): [True: 1.32k, False: 1]
  ------------------
  295|  4.29k|        for (int n = 0; n < src->num_streams; n++) {
  ------------------
  |  Branch (295:25): [True: 2.97k, False: 1.32k]
  ------------------
  296|  2.97k|            struct virtual_stream *vs = src->streams[n];
  297|  2.97k|            if (vs->selected) {
  ------------------
  |  Branch (297:17): [True: 2.66k, False: 311]
  ------------------
  298|  2.66k|                int max_packets = 0;
  299|  2.66k|                if (vs->sh->type == STREAM_AUDIO)
  ------------------
  |  Branch (299:21): [True: 1.28k, False: 1.37k]
  ------------------
  300|  1.28k|                    max_packets = 1;
  301|  2.66k|                if (vs->sh->type == STREAM_VIDEO)
  ------------------
  |  Branch (301:21): [True: 1.23k, False: 1.42k]
  ------------------
  302|  1.23k|                    max_packets = 16;
  303|  2.66k|                eos_reached &= vs->eos_packets >= max_packets;
  304|  2.66k|            }
  305|  2.97k|        }
  306|  1.32k|    }
  307|       |
  308|  8.45k|    src->eof_reached = false;
  309|       |
  310|  8.45k|    if (eos_reached || !pkt) {
  ------------------
  |  Branch (310:9): [True: 1, False: 8.45k]
  |  Branch (310:24): [True: 375, False: 8.08k]
  ------------------
  311|    376|        talloc_free(pkt);
  ------------------
  |  |   47|    376|#define talloc_free                     ta_free
  ------------------
  312|       |
  313|    376|        struct segment *next = NULL;
  314|    567|        for (int n = 0; n < src->num_segments - 1; n++) {
  ------------------
  |  Branch (314:25): [True: 337, False: 230]
  ------------------
  315|    337|            if (src->segments[n] == seg) {
  ------------------
  |  Branch (315:17): [True: 146, False: 191]
  ------------------
  316|    146|                next = src->segments[n + 1];
  317|    146|                break;
  318|    146|            }
  319|    337|        }
  320|    376|        if (!next) {
  ------------------
  |  Branch (320:13): [True: 230, False: 146]
  ------------------
  321|    230|            src->eof_reached = true;
  322|    230|            return;
  323|    230|        }
  324|    146|        switch_segment(demuxer, src, next, next->start, 0, true);
  325|    146|        return; // reader will retry
  326|    376|    }
  327|       |
  328|  8.08k|    if (pkt->stream < 0 || pkt->stream >= seg->num_stream_map)
  ------------------
  |  Branch (328:9): [True: 0, False: 8.08k]
  |  Branch (328:28): [True: 0, False: 8.08k]
  ------------------
  329|      0|        goto drop;
  330|       |
  331|  8.08k|    if (!src->no_clip || src->delay_open) {
  ------------------
  |  Branch (331:9): [True: 8.08k, False: 0]
  |  Branch (331:26): [True: 0, False: 0]
  ------------------
  332|  8.08k|        pkt->segmented = true;
  333|  8.08k|        if (!pkt->codec)
  ------------------
  |  Branch (333:13): [True: 8.08k, False: 0]
  ------------------
  334|  8.08k|            pkt->codec = demux_get_stream(seg->d, pkt->stream)->codec;
  335|  8.08k|    }
  336|  8.08k|    if (!src->no_clip) {
  ------------------
  |  Branch (336:9): [True: 8.08k, False: 0]
  ------------------
  337|  8.08k|        if (pkt->start == MP_NOPTS_VALUE || pkt->start < seg->start)
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (337:13): [True: 8.08k, False: 0]
  |  Branch (337:45): [True: 0, False: 0]
  ------------------
  338|  8.08k|            pkt->start = seg->start;
  339|  8.08k|        if (pkt->end == MP_NOPTS_VALUE || pkt->end > seg->end)
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (339:13): [True: 8.08k, False: 0]
  |  Branch (339:43): [True: 0, False: 0]
  ------------------
  340|  8.08k|            pkt->end = seg->end;
  341|  8.08k|    }
  342|       |
  343|  8.08k|    struct virtual_stream *vs = seg->stream_map[pkt->stream];
  344|  8.08k|    if (!vs)
  ------------------
  |  Branch (344:9): [True: 0, False: 8.08k]
  ------------------
  345|      0|        goto drop;
  346|       |
  347|       |    // for refresh seeks, demux.c prefers monotonically increasing packet pos
  348|       |    // since the packet pos is meaningless anyway for timeline, use it
  349|  8.08k|    if (pkt->pos >= 0)
  ------------------
  |  Branch (349:9): [True: 8.07k, False: 2]
  ------------------
  350|  8.07k|        pkt->pos |= (seg->index & 0x7FFFULL) << 48;
  351|       |
  352|  8.08k|    if (pkt->pts != MP_NOPTS_VALUE && !src->no_clip && pkt->pts >= seg->end) {
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (352:9): [True: 6.06k, False: 2.01k]
  |  Branch (352:39): [True: 6.06k, False: 0]
  |  Branch (352:56): [True: 669, False: 5.39k]
  ------------------
  353|       |        // Trust the keyframe flag. Might not always be a good idea, but will
  354|       |        // be sufficient at least with mkv. The problem is that this flag is
  355|       |        // not well-defined in libavformat and is container-dependent.
  356|    669|        if (pkt->keyframe || vs->eos_packets == INT_MAX) {
  ------------------
  |  Branch (356:13): [True: 669, False: 0]
  |  Branch (356:30): [True: 0, False: 0]
  ------------------
  357|    669|            vs->eos_packets = INT_MAX;
  358|    669|            goto drop;
  359|    669|        } else {
  360|      0|            vs->eos_packets += 1;
  361|      0|        }
  362|    669|    }
  363|       |
  364|  7.41k|    double dts = pkt->dts != MP_NOPTS_VALUE ? pkt->dts : pkt->pts;
  ------------------
  |  |   39|  7.41k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (364:18): [True: 1.24k, False: 6.16k]
  ------------------
  365|  7.41k|    if (src->dts == MP_NOPTS_VALUE || (dts != MP_NOPTS_VALUE && dts > src->dts))
  ------------------
  |  |   39|  14.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (src->dts == MP_NOPTS_VALUE || (dts != MP_NOPTS_VALUE && dts > src->dts))
  ------------------
  |  |   39|  14.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (365:9): [True: 173, False: 7.23k]
  |  Branch (365:40): [True: 6.47k, False: 769]
  |  Branch (365:65): [True: 1.09k, False: 5.38k]
  ------------------
  366|  1.26k|        src->dts = dts;
  367|       |
  368|  7.41k|    pkt->stream = vs->sh->index;
  369|  7.41k|    src->next = pkt;
  370|  7.41k|    return;
  371|       |
  372|    669|drop:
  373|    669|    talloc_free(pkt);
  ------------------
  |  |   47|    669|#define talloc_free                     ta_free
  ------------------
  374|    669|}
demux_timeline.c:d_close:
  822|    286|{
  823|    286|    struct priv *p = demuxer->priv;
  824|       |
  825|    572|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (825:21): [True: 286, False: 286]
  ------------------
  826|    286|        struct virtual_source *src = p->sources[x];
  827|       |
  828|    286|        src->current = NULL;
  829|    286|        TA_FREEP(&src->next);
  ------------------
  |  |   81|    286|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    286|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 286]
  |  |  ------------------
  ------------------
  830|    286|        close_lazy_segments(demuxer, src);
  831|    286|    }
  832|       |
  833|    286|    if (p->owns_tl) {
  ------------------
  |  Branch (833:9): [True: 286, False: 0]
  ------------------
  834|    286|        struct demuxer *master = p->tl->demuxer;
  835|    286|        timeline_destroy(p->tl);
  836|    286|        demux_free(master);
  837|    286|    }
  838|    286|}
demux_timeline.c:close_lazy_segments:
  199|    286|{
  200|       |    // unload previous segment
  201|    770|    for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (201:21): [True: 484, False: 286]
  ------------------
  202|    484|        struct segment *seg = src->segments[n];
  203|    484|        if (seg != src->current && seg->d && seg->lazy) {
  ------------------
  |  Branch (203:13): [True: 484, False: 0]
  |  Branch (203:36): [True: 484, False: 0]
  |  Branch (203:46): [True: 0, False: 484]
  ------------------
  204|      0|            TA_FREEP(&src->next); // might depend on one of the sub-demuxers
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  205|      0|            demux_free(seg->d);
  206|       |            seg->d = NULL;
  207|      0|        }
  208|    484|    }
  209|    286|}
demux_timeline.c:d_seek:
  425|     23|{
  426|     23|    struct priv *p = demuxer->priv;
  427|       |
  428|     23|    seek_pts = seek_pts * ((flags & SEEK_FACTOR) ? p->duration : 1);
  ------------------
  |  |   94|     23|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (428:28): [True: 0, False: 23]
  ------------------
  429|     23|    flags &= SEEK_FORWARD | SEEK_HR;
  ------------------
  |  |   95|     23|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
                  flags &= SEEK_FORWARD | SEEK_HR;
  ------------------
  |  |   99|     23|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
  430|       |
  431|       |    // The intention is to seek audio streams to the same target as video
  432|       |    // streams if they are separate streams. Video streams usually have more
  433|       |    // coarse keyframe snapping, which could leave video without audio.
  434|     23|    struct virtual_source *master = NULL;
  435|     23|    bool has_slaves = false;
  436|     46|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (436:21): [True: 23, False: 23]
  ------------------
  437|     23|        struct virtual_source *src = p->sources[x];
  438|       |
  439|     23|        bool any_audio = false, any_video = false;
  440|     57|        for (int i = 0; i < src->num_streams; i++) {
  ------------------
  |  Branch (440:25): [True: 34, False: 23]
  ------------------
  441|     34|            struct virtual_stream *str = src->streams[i];
  442|     34|            if (str->selected) {
  ------------------
  |  Branch (442:17): [True: 26, False: 8]
  ------------------
  443|     26|                if (str->sh->type == STREAM_VIDEO)
  ------------------
  |  Branch (443:21): [True: 0, False: 26]
  ------------------
  444|      0|                    any_video = true;
  445|     26|                if (str->sh->type == STREAM_AUDIO)
  ------------------
  |  Branch (445:21): [True: 19, False: 7]
  ------------------
  446|     19|                    any_audio = true;
  447|     26|            }
  448|     34|        }
  449|       |
  450|     23|        if (any_video)
  ------------------
  |  Branch (450:13): [True: 0, False: 23]
  ------------------
  451|      0|            master = src;
  452|       |        // A true slave stream is audio-only; this also prevents that the master
  453|       |        // stream is considered a slave stream.
  454|     23|        if (any_audio && !any_video)
  ------------------
  |  Branch (454:13): [True: 19, False: 4]
  |  Branch (454:26): [True: 19, False: 0]
  ------------------
  455|     19|            has_slaves = true;
  456|     23|    }
  457|       |
  458|     23|    if (!has_slaves)
  ------------------
  |  Branch (458:9): [True: 4, False: 19]
  ------------------
  459|      4|        master = NULL;
  460|       |
  461|     23|    if (master) {
  ------------------
  |  Branch (461:9): [True: 0, False: 23]
  ------------------
  462|      0|        seek_source(demuxer, master, seek_pts, flags);
  463|      0|        do_read_next_packet(demuxer, master);
  464|      0|        if (master->next && master->next->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (464:13): [True: 0, False: 0]
  |  Branch (464:29): [True: 0, False: 0]
  ------------------
  465|       |            // Assume we got a seek target. Actually apply the heuristic.
  466|      0|            MP_VERBOSE(demuxer, "adjust seek target from %f to %f\n", seek_pts,
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  467|      0|                       master->next->pts);
  468|      0|            seek_pts = master->next->pts;
  469|      0|            flags &= ~(unsigned)SEEK_FORWARD;
  ------------------
  |  |   95|      0|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  470|      0|        }
  471|      0|    }
  472|       |
  473|     46|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (473:21): [True: 23, False: 23]
  ------------------
  474|     23|        struct virtual_source *src = p->sources[x];
  475|     23|        if (src != master && src->any_selected)
  ------------------
  |  Branch (475:13): [True: 23, False: 0]
  |  Branch (475:30): [True: 23, False: 0]
  ------------------
  476|     23|            seek_source(demuxer, src, seek_pts, flags);
  477|     23|    }
  478|     23|}
demux_timeline.c:seek_source:
  409|     23|{
  410|     23|    struct segment *new = src->segments[src->num_segments - 1];
  411|     25|    for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (411:21): [True: 23, False: 2]
  ------------------
  412|     23|        if (pts < src->segments[n]->end) {
  ------------------
  |  Branch (412:13): [True: 21, False: 2]
  ------------------
  413|     21|            new = src->segments[n];
  414|     21|            break;
  415|     21|        }
  416|     23|    }
  417|       |
  418|     23|    switch_segment(demuxer, src, new, pts, flags, false);
  419|       |
  420|     23|    src->dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|     23|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  421|       |    TA_FREEP(&src->next);
  ------------------
  |  |   81|     23|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     23|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 23]
  |  |  ------------------
  ------------------
  422|     23|}
demux_timeline.c:d_switched_tracks:
  841|    304|{
  842|    304|    reselect_streams(demuxer);
  843|    304|}

mp_dovi_split_reset:
  143|  49.1k|{
  144|  49.1k|    if (!s || !s->bsf)
  ------------------
  |  Branch (144:9): [True: 49.1k, False: 0]
  |  Branch (144:15): [True: 0, False: 0]
  ------------------
  145|  49.1k|        return;
  146|      0|    av_bsf_flush(s->bsf);
  147|      0|}

ebml_is_mkv_level1_id:
   41|   403k|{
   42|   403k|    switch (id) {
   43|  21.9k|    case MATROSKA_ID_SEEKHEAD:
  ------------------
  |  |   14|  21.9k|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (43:5): [True: 21.9k, False: 381k]
  ------------------
   44|  55.4k|    case MATROSKA_ID_INFO:
  ------------------
  |  |   18|  55.4k|#define MATROSKA_ID_INFO                         0x1549a966
  ------------------
  |  Branch (44:5): [True: 33.4k, False: 369k]
  ------------------
   45|  79.9k|    case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|  79.9k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (45:5): [True: 24.5k, False: 378k]
  ------------------
   46|   114k|    case MATROSKA_ID_TRACKS:
  ------------------
  |  |   40|   114k|#define MATROSKA_ID_TRACKS                       0x1654ae6b
  ------------------
  |  Branch (46:5): [True: 34.8k, False: 368k]
  ------------------
   47|   122k|    case MATROSKA_ID_CUES:
  ------------------
  |  |  130|   122k|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (47:5): [True: 8.05k, False: 395k]
  ------------------
   48|   124k|    case MATROSKA_ID_ATTACHMENTS:
  ------------------
  |  |  138|   124k|#define MATROSKA_ID_ATTACHMENTS                  0x1941a469
  ------------------
  |  Branch (48:5): [True: 1.32k, False: 401k]
  ------------------
   49|   126k|    case MATROSKA_ID_CHAPTERS:
  ------------------
  |  |  145|   126k|#define MATROSKA_ID_CHAPTERS                     0x1043a770
  ------------------
  |  Branch (49:5): [True: 2.71k, False: 400k]
  ------------------
   50|   138k|    case MATROSKA_ID_TAGS:
  ------------------
  |  |  164|   138k|#define MATROSKA_ID_TAGS                         0x1254c367
  ------------------
  |  Branch (50:5): [True: 11.8k, False: 391k]
  ------------------
   51|   138k|        return true;
   52|   264k|    default:
  ------------------
  |  Branch (52:5): [True: 264k, False: 138k]
  ------------------
   53|       |        return false;
   54|   403k|    }
   55|   403k|}
ebml_read_id:
   62|  8.86M|{
   63|  8.86M|    int i, len_mask = 0x80;
   64|  8.86M|    uint32_t id;
   65|       |
   66|  38.8M|    for (i = 0, id = stream_read_char(s); i < 4 && !(id & len_mask); i++)
  ------------------
  |  Branch (66:43): [True: 31.7M, False: 7.13M]
  |  Branch (66:52): [True: 30.0M, False: 1.72M]
  ------------------
   67|  30.0M|        len_mask >>= 1;
   68|  8.86M|    if (i >= 4)
  ------------------
  |  Branch (68:9): [True: 7.13M, False: 1.72M]
  ------------------
   69|  7.13M|        return EBML_ID_INVALID;
  ------------------
  |  |   75|  7.13M|#define EBML_ID_INVALID 0xffffffff
  ------------------
   70|  3.17M|    while (i--)
  ------------------
  |  Branch (70:12): [True: 1.45M, False: 1.72M]
  ------------------
   71|  1.45M|        id = (id << 8) | stream_read_char(s);
   72|  1.72M|    return id;
   73|  8.86M|}
ebml_read_length:
   79|  2.44M|{
   80|  2.44M|    int byte = stream_read_char(s);
   81|  2.44M|    if (byte == STREAM_EOF || byte < 1)
  ------------------
  |  |   71|  4.89M|#define STREAM_EOF (-256)
  ------------------
  |  Branch (81:9): [True: 643, False: 2.44M]
  |  Branch (81:31): [True: 47.3k, False: 2.40M]
  ------------------
   82|  48.0k|        return EBML_UINT_INVALID;
  ------------------
  |  |   85|  48.0k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   83|       |
   84|  2.40M|    uint8_t leading_zeros = 7 - mp_log2((uint8_t)byte);
   85|  2.40M|    uint64_t len = (uint8_t)byte & ((1 << (8 - leading_zeros - 1)) - 1);
   86|  4.36M|    for (uint8_t i = 0; i < leading_zeros; ++i) {
  ------------------
  |  Branch (86:25): [True: 1.96M, False: 2.40M]
  ------------------
   87|  1.96M|        byte = stream_read_char(s);
   88|  1.96M|        if (byte == STREAM_EOF)
  ------------------
  |  |   71|  1.96M|#define STREAM_EOF (-256)
  ------------------
  |  Branch (88:13): [True: 249, False: 1.96M]
  ------------------
   89|    249|            return EBML_UINT_INVALID;
  ------------------
  |  |   85|    249|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   90|  1.96M|        len = (len << 8) | (uint8_t)byte;
   91|  1.96M|    }
   92|       |
   93|  2.40M|    return len;
   94|  2.40M|}
ebml_read_signed_length:
  100|   167k|{
  101|   167k|    uint64_t unum;
  102|   167k|    int l;
  103|       |
  104|       |    /* read as unsigned number first */
  105|   167k|    uint64_t offset = stream_tell(s);
  106|   167k|    unum = ebml_read_length(s);
  107|   167k|    if (unum == EBML_UINT_INVALID)
  ------------------
  |  |   85|   167k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (107:9): [True: 10.5k, False: 156k]
  ------------------
  108|  10.5k|        return EBML_INT_INVALID;
  ------------------
  |  |   86|  10.5k|#define EBML_INT_INVALID    INT64_MAX
  ------------------
  109|   156k|    l = stream_tell(s) - offset;
  110|       |
  111|   156k|    return unum - ((1LL << ((7 * l) - 1)) - 1);
  112|   167k|}
ebml_read_uint:
  118|  82.4k|{
  119|  82.4k|    uint64_t len, value = 0;
  120|       |
  121|  82.4k|    len = ebml_read_length(s);
  122|  82.4k|    if (len == EBML_UINT_INVALID || len > 8)
  ------------------
  |  |   85|   164k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (122:9): [True: 255, False: 82.2k]
  |  Branch (122:37): [True: 2.29k, False: 79.9k]
  ------------------
  123|  2.55k|        return false;
  124|       |
  125|   168k|    while (len--)
  ------------------
  |  Branch (125:12): [True: 88.9k, False: 79.9k]
  ------------------
  126|  88.9k|        value = (value << 8) | stream_read_char(s);
  127|       |
  128|  79.9k|    *out = value;
  129|       |    return true;
  130|  82.4k|}
ebml_read_int:
  136|  36.9k|{
  137|  36.9k|    uint64_t value = 0;
  138|  36.9k|    uint64_t len;
  139|  36.9k|    int l;
  140|       |
  141|  36.9k|    len = ebml_read_length(s);
  142|  36.9k|    if (len == EBML_UINT_INVALID || len > 8)
  ------------------
  |  |   85|  73.9k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (142:9): [True: 61, False: 36.9k]
  |  Branch (142:37): [True: 979, False: 35.9k]
  ------------------
  143|  1.04k|        return false;
  144|  35.9k|    if (!len) {
  ------------------
  |  Branch (144:9): [True: 534, False: 35.4k]
  ------------------
  145|    534|        *out = 0;
  146|    534|        return true;
  147|    534|    }
  148|       |
  149|  35.4k|    len--;
  150|  35.4k|    l = stream_read_char(s);
  151|  35.4k|    if (l & 0x80)
  ------------------
  |  Branch (151:9): [True: 32.1k, False: 3.24k]
  ------------------
  152|  32.1k|        value = -1;
  153|  35.4k|    value = (value << 8) | l;
  154|  49.6k|    while (len--)
  ------------------
  |  Branch (154:12): [True: 14.2k, False: 35.4k]
  ------------------
  155|  14.2k|        value = (value << 8) | stream_read_char(s);
  156|       |
  157|  35.4k|    *out = (int64_t)value; // assume complement of 2
  158|       |    return true;
  159|  35.9k|}
ebml_read_skip:
  166|   424k|{
  167|   424k|    uint64_t len;
  168|       |
  169|   424k|    int64_t pos = stream_tell(s);
  170|       |
  171|   424k|    len = ebml_read_length(s);
  172|   424k|    if (len == EBML_UINT_INVALID)
  ------------------
  |  |   85|   424k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (172:9): [True: 18.6k, False: 405k]
  ------------------
  173|  18.6k|        goto invalid;
  174|       |
  175|   405k|    int64_t pos2 = stream_tell(s);
  176|   405k|    if (len >= INT64_MAX - pos2 || (end > 0 && pos2 + len > end))
  ------------------
  |  Branch (176:9): [True: 0, False: 405k]
  |  Branch (176:37): [True: 314k, False: 91.1k]
  |  Branch (176:48): [True: 45.5k, False: 269k]
  ------------------
  177|  45.5k|        goto invalid;
  178|       |
  179|   360k|    if (!stream_seek_skip(s, pos2 + len))
  ------------------
  |  Branch (179:9): [True: 25.5k, False: 334k]
  ------------------
  180|  25.5k|        goto invalid;
  181|       |
  182|   334k|    return 0;
  183|       |
  184|  89.7k|invalid:
  185|  89.7k|    mp_err(log, "Invalid EBML length at position %"PRId64"\n", pos);
  ------------------
  |  |   76|  89.7k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  186|  89.7k|    stream_seek_skip(s, pos);
  187|  89.7k|    return 1;
  188|   360k|}
ebml_resync_cluster:
  194|   170k|{
  195|   170k|    int64_t pos = stream_tell(s);
  196|   170k|    uint32_t last_4_bytes = 0;
  197|   170k|    stream_read_peek(s, &(char){0}, 1);
  198|   170k|    if (!s->eof) {
  ------------------
  |  Branch (198:9): [True: 170k, False: 0]
  ------------------
  199|   170k|        mp_err(log, "Corrupt file detected. "
  ------------------
  |  |   76|   170k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  200|   170k|               "Trying to resync starting from position %"PRId64"...\n", pos);
  201|   170k|    }
  202|   145M|    while (!s->eof) {
  ------------------
  |  Branch (202:12): [True: 145M, False: 16.2k]
  ------------------
  203|       |        // Assumes MATROSKA_ID_CLUSTER is 4 bytes, with no 0 bytes.
  204|   145M|        if (last_4_bytes == MATROSKA_ID_CLUSTER) {
  ------------------
  |  |   28|   145M|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (204:13): [True: 154k, False: 145M]
  ------------------
  205|   154k|            mp_err(log, "Cluster found at %"PRId64".\n", pos - 4);
  ------------------
  |  |   76|   154k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  206|   154k|            stream_seek(s, pos - 4);
  207|   154k|            return 0;
  208|   154k|        }
  209|   145M|        last_4_bytes = (last_4_bytes << 8) | stream_read_char(s);
  210|   145M|        pos++;
  211|   145M|    }
  212|  16.2k|    return -1;
  213|   170k|}
ebml_read_element:
  613|  95.2k|{
  614|  95.2k|    ctx->has_errors = false;
  615|  95.2k|    int msglevel = ctx->no_error_messages ? MSGL_DEBUG : MSGL_WARN;
  ------------------
  |  Branch (615:20): [True: 24.7k, False: 70.5k]
  ------------------
  616|  95.2k|    uint64_t length = ebml_read_length(s);
  617|  95.2k|    if (s->eof) {
  ------------------
  |  Branch (617:9): [True: 13, False: 95.2k]
  ------------------
  618|     13|        MP_MSG(ctx, msglevel, "Unexpected end of file "
  ------------------
  |  |   86|     13|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  619|     13|                   "- partial or corrupt file?\n");
  620|     13|        return -1;
  621|     13|    }
  622|  95.2k|    if (length == EBML_UINT_INVALID) {
  ------------------
  |  |   85|  95.2k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (622:9): [True: 68, False: 95.1k]
  ------------------
  623|     68|        MP_MSG(ctx, msglevel, "EBML element with unknown length - unsupported\n");
  ------------------
  |  |   86|     68|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  624|     68|        return -1;
  625|     68|    }
  626|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  627|       |    if (length > (512 << 20)) {
  628|       |#else
  629|  95.1k|    if (length > (64 << 20)) {
  ------------------
  |  Branch (629:9): [True: 101, False: 95.0k]
  ------------------
  630|    101|#endif
  631|    101|        MP_MSG(ctx, msglevel, "Element too big (%" PRIu64 " MiB) - skipping\n", length >> 20);
  ------------------
  |  |   86|    101|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  632|    101|        return -1;
  633|    101|    }
  634|  95.0k|    ctx->talloc_ctx = talloc_size(NULL, length);
  ------------------
  |  |   43|  95.0k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  95.0k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  95.0k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  95.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  95.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  95.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|  95.0k|    int read_len = stream_read(s, ctx->talloc_ctx, length);
  636|  95.0k|    if (read_len < length)
  ------------------
  |  Branch (636:9): [True: 2.28k, False: 92.7k]
  ------------------
  637|  2.28k|        MP_MSG(ctx, msglevel, "Unexpected end of file - partial or corrupt file?\n");
  ------------------
  |  |   86|  2.28k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  638|  95.0k|    ebml_parse_element(ctx, target, ctx->talloc_ctx, read_len, desc, 0);
  639|  95.0k|    if (ctx->has_errors)
  ------------------
  |  Branch (639:9): [True: 45.2k, False: 49.8k]
  ------------------
  640|  45.2k|        MP_MSG(ctx, msglevel, "Error parsing element %s\n", desc->name);
  ------------------
  |  |   86|  45.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  641|  95.0k|    return 0;
  642|  95.1k|}
ebml.c:ebml_parse_element:
  327|   440k|{
  328|   440k|    mp_assert(type->type == EBML_TYPE_SUBELEMENTS);
  ------------------
  |  |   41|   440k|#define mp_assert assert
  ------------------
  |  Branch (328:5): [True: 440k, False: 0]
  ------------------
  329|   440k|    mp_assert(level < 8);
  ------------------
  |  |   41|   440k|#define mp_assert assert
  ------------------
  |  Branch (329:5): [True: 440k, False: 0]
  ------------------
  330|   440k|    MP_TRACE(ctx, "%.*sParsing element %s\n", level, "       ", type->name);
  ------------------
  |  |   94|   440k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   440k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  331|       |
  332|   440k|    char *s = target;
  333|   440k|    uint8_t *end = data + size;
  334|   440k|    uint8_t *p = data;
  335|   440k|    int num_elems[MAX_EBML_SUBELEMENTS] = {0};
  336|  2.05M|    while (p < end) {
  ------------------
  |  Branch (336:12): [True: 1.64M, False: 411k]
  ------------------
  337|  1.64M|        uint8_t *startp = p;
  338|  1.64M|        int len;
  339|  1.64M|        uint32_t id = ebml_parse_id(p, end - p, &len);
  340|  1.64M|        if (len > end - p)
  ------------------
  |  Branch (340:13): [True: 723, False: 1.64M]
  ------------------
  341|    723|            goto past_end_error;
  342|  1.64M|        if (len < 0) {
  ------------------
  |  Branch (342:13): [True: 9.80k, False: 1.63M]
  ------------------
  343|  9.80k|            MP_ERR(ctx, "Error parsing subelement id\n");
  ------------------
  |  |   89|  9.80k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.80k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  344|  9.80k|            goto other_error;
  345|  9.80k|        }
  346|  1.63M|        p += len;
  347|  1.63M|        uint64_t length = ebml_parse_length(p, end - p, &len);
  348|  1.63M|        if (len > end - p)
  ------------------
  |  Branch (348:13): [True: 0, False: 1.63M]
  ------------------
  349|      0|            goto past_end_error;
  350|  1.63M|        if (len < 0) {
  ------------------
  |  Branch (350:13): [True: 11.9k, False: 1.62M]
  ------------------
  351|  11.9k|            MP_ERR(ctx, "Error parsing subelement length\n");
  ------------------
  |  |   89|  11.9k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  352|  11.9k|            goto other_error;
  353|  11.9k|        }
  354|  1.62M|        p += len;
  355|       |
  356|  1.62M|        int field_idx = -1;
  357|  8.31M|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (357:25): [True: 8.17M, False: 145k]
  ------------------
  358|  8.17M|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (358:17): [True: 1.47M, False: 6.69M]
  ------------------
  359|  1.47M|                field_idx = i;
  360|  1.47M|                num_elems[i]++;
  361|  1.47M|                if (num_elems[i] >= 0x70000000) {
  ------------------
  |  Branch (361:21): [True: 0, False: 1.47M]
  ------------------
  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|  1.47M|                break;
  366|  1.47M|            }
  367|       |
  368|  1.62M|        if (length > end - p) {
  ------------------
  |  Branch (368:13): [True: 44.0k, False: 1.57M]
  ------------------
  369|  44.0k|            if (field_idx >= 0 && type->fields[field_idx].desc->type
  ------------------
  |  Branch (369:17): [True: 16.8k, False: 27.2k]
  |  Branch (369:35): [True: 6.41k, False: 10.4k]
  ------------------
  370|  16.8k|                != EBML_TYPE_SUBELEMENTS) {
  371|  6.41k|                MP_ERR(ctx, "Subelement content goes "
  ------------------
  |  |   89|  6.41k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.41k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  372|  6.41k|                       "past end of containing element\n");
  373|  6.41k|                goto other_error;
  374|  6.41k|            }
  375|       |            // Try to parse what is possible from inside this partial element
  376|  37.6k|            ctx->has_errors = true;
  377|  37.6k|            length = end - p;
  378|  37.6k|        }
  379|  1.61M|        p += length;
  380|       |
  381|  1.61M|        continue;
  382|       |
  383|    723|    past_end_error:
  384|    723|        MP_ERR(ctx, "Subelement headers go past end of containing element\n");
  ------------------
  |  |   89|    723|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    723|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  385|  28.9k|    other_error:
  386|  28.9k|        ctx->has_errors = true;
  387|  28.9k|        end = startp;
  388|  28.9k|        break;
  389|    723|    }
  390|       |
  391|  3.18M|    for (int i = 0; i < type->field_count; i++) {
  ------------------
  |  Branch (391:21): [True: 2.74M, False: 440k]
  ------------------
  392|  2.74M|        if (num_elems[i] && type->fields[i].multiple) {
  ------------------
  |  Branch (392:13): [True: 1.29M, False: 1.45M]
  |  Branch (392:29): [True: 143k, False: 1.14M]
  ------------------
  393|   143k|            char *ptr = s + type->fields[i].offset;
  394|   143k|            switch (type->fields[i].desc->type) {
  395|   137k|            case EBML_TYPE_SUBELEMENTS: {
  ------------------
  |  Branch (395:13): [True: 137k, False: 5.34k]
  ------------------
  396|   137k|                size_t max = 1000000000 / type->fields[i].desc->size;
  397|   137k|                if (num_elems[i] > max) {
  ------------------
  |  Branch (397:21): [True: 0, False: 137k]
  ------------------
  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|   137k|                int sz = num_elems[i] * type->fields[i].desc->size;
  402|   137k|                *(generic_struct **) ptr = talloc_zero_size(ctx->talloc_ctx, sz);
  ------------------
  |  |   44|   137k|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|   137k|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   137k|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|   137k|                break;
  404|      0|            }
  405|      0|            case EBML_TYPE_UINT:
  ------------------
  |  Branch (405:13): [True: 0, False: 143k]
  ------------------
  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: 143k]
  ------------------
  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: 143k]
  ------------------
  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|  5.34k|            case EBML_TYPE_STR:
  ------------------
  |  Branch (417:13): [True: 5.34k, False: 137k]
  ------------------
  418|  5.34k|                *(char ***) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|  5.34k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  5.34k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  5.34k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|  5.34k|                                                    char *, num_elems[i]);
  420|  5.34k|                break;
  421|      0|            case EBML_TYPE_BINARY:
  ------------------
  |  Branch (421:13): [True: 0, False: 143k]
  ------------------
  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: 143k]
  ------------------
  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: 143k]
  ------------------
  431|   143k|                MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (431:17): [Folded, False: 0]
  ------------------
  432|   143k|            }
  433|   143k|        }
  434|  2.74M|    }
  435|       |
  436|  2.05M|    while (data < end) {
  ------------------
  |  Branch (436:12): [True: 1.61M, False: 440k]
  ------------------
  437|  1.61M|        int len;
  438|  1.61M|        uint32_t id = ebml_parse_id(data, end - data, &len);
  439|  1.61M|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (439:13): [True: 0, False: 1.61M]
  |  Branch (439:24): [True: 0, False: 1.61M]
  ------------------
  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.61M|        data += len;
  444|  1.61M|        uint64_t length = ebml_parse_length(data, end - data, &len);
  445|  1.61M|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (445:13): [True: 0, False: 1.61M]
  |  Branch (445:24): [True: 0, False: 1.61M]
  ------------------
  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.61M|        data += len;
  450|  1.61M|        if (length > end - data) {
  ------------------
  |  Branch (450:13): [True: 37.6k, False: 1.57M]
  ------------------
  451|       |            // Try to parse what is possible from inside this partial element
  452|  37.6k|            length = end - data;
  453|  37.6k|            MP_ERR(ctx, "Next subelement content goes "
  ------------------
  |  |   89|  37.6k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  37.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  454|  37.6k|                   "past end of containing element, will be truncated\n");
  455|  37.6k|        }
  456|  1.61M|        int field_idx = -1;
  457|  8.27M|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (457:25): [True: 8.12M, False: 145k]
  ------------------
  458|  8.12M|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (458:17): [True: 1.47M, False: 6.65M]
  ------------------
  459|  1.47M|                field_idx = i;
  460|  1.47M|                break;
  461|  1.47M|            }
  462|  1.61M|        if (field_idx < 0) {
  ------------------
  |  Branch (462:13): [True: 145k, False: 1.47M]
  ------------------
  463|   145k|            if (id == 0xec) {
  ------------------
  |  Branch (463:17): [True: 1.29k, False: 144k]
  ------------------
  464|  1.29k|                MP_TRACE(ctx, "%.*sIgnoring Void element "
  ------------------
  |  |   94|  1.29k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.29k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  465|  1.29k|                         "size: %"PRIu64"\n", level+1, "        ", length);
  466|   144k|            } else if (id == 0xbf) {
  ------------------
  |  Branch (466:24): [True: 25.3k, False: 118k]
  ------------------
  467|  25.3k|                MP_TRACE(ctx, "%.*sIgnoring CRC-32 "
  ------------------
  |  |   94|  25.3k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  25.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  468|  25.3k|                         "element size: %"PRIu64"\n", level+1, "        ",
  469|  25.3k|                         length);
  470|   118k|            } else {
  471|   118k|                MP_DBG(ctx, "Ignoring unrecognized "
  ------------------
  |  |   93|   118k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   118k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  472|   118k|                       "subelement. ID: %x size: %"PRIu64"\n", id, length);
  473|   118k|            }
  474|   145k|            data += length;
  475|   145k|            continue;
  476|   145k|        }
  477|  1.47M|        const struct ebml_field_desc *fd = &type->fields[field_idx];
  478|  1.47M|        const struct ebml_elem_desc *ed = fd->desc;
  479|  1.47M|        bool multiple = fd->multiple;
  480|  1.47M|        int *countptr = (int *) (s + fd->count_offset);
  481|  1.47M|        if (*countptr >= num_elems[field_idx]) {
  ------------------
  |  Branch (481:13): [True: 0, False: 1.47M]
  ------------------
  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|  1.47M|        if (*countptr > 0 && !multiple) {
  ------------------
  |  Branch (488:13): [True: 183k, False: 1.28M]
  |  Branch (488:30): [True: 18.8k, False: 164k]
  ------------------
  489|  18.8k|            MP_WARN(ctx, "Another subelement of type "
  ------------------
  |  |   90|  18.8k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  18.8k|                    "%x %s (size: %"PRIu64"). Only one allowed. Ignoring.\n",
  491|  18.8k|                    id, ed->name, length);
  492|  18.8k|            ctx->has_errors = true;
  493|  18.8k|            data += length;
  494|  18.8k|            continue;
  495|  18.8k|        }
  496|  1.45M|        MP_TRACE(ctx, "%.*sParsing %x %s size: %"PRIu64
  ------------------
  |  |   94|  1.45M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.45M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|  1.45M|                 " value: ", level+1, "        ", id, ed->name, length);
  498|       |
  499|  1.45M|        char *fieldptr = s + fd->offset;
  500|  1.45M|        switch (ed->type) {
  501|   345k|        case EBML_TYPE_SUBELEMENTS:
  ------------------
  |  Branch (501:9): [True: 345k, False: 1.10M]
  ------------------
  502|   345k|            MP_TRACE(ctx, "subelements\n");
  ------------------
  |  |   94|   345k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   345k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  503|   345k|            char *subelptr;
  504|   345k|            if (multiple) {
  ------------------
  |  Branch (504:17): [True: 302k, False: 42.5k]
  ------------------
  505|   302k|                char *array_start = (char *) *(generic_struct **) fieldptr;
  506|   302k|                subelptr = array_start + *countptr * ed->size;
  507|   302k|            } else
  508|  42.5k|                subelptr = fieldptr;
  509|   345k|            ebml_parse_element(ctx, subelptr, data, length, ed, level + 1);
  510|   345k|            break;
  511|       |
  512|   767k|        case EBML_TYPE_UINT:;
  ------------------
  |  Branch (512:9): [True: 767k, False: 683k]
  ------------------
  513|   767k|            uint64_t *uintptr;
  514|   767k|#define GETPTR(subelptr, fieldtype)                                     \
  515|   767k|            if (multiple)                                               \
  516|   767k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  517|   767k|            else                                                        \
  518|   767k|                subelptr = (fieldtype *) fieldptr
  519|   767k|            GETPTR(uintptr, uint64_t);
  ------------------
  |  |  515|   767k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 767k]
  |  |  ------------------
  |  |  516|   767k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|   767k|            else                                                        \
  |  |  518|   767k|                subelptr = (fieldtype *) fieldptr
  ------------------
  520|   767k|            if (length > 8) {
  ------------------
  |  Branch (520:17): [True: 537, False: 766k]
  ------------------
  521|    537|                MP_ERR(ctx, "uint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|    537|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    537|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  522|    537|                goto error;
  523|    537|            }
  524|   766k|            if (!length && ed->context_default)
  ------------------
  |  Branch (524:17): [True: 286, False: 766k]
  |  Branch (524:28): [True: 2, False: 284]
  ------------------
  525|      2|                goto skip;
  526|   766k|            *uintptr = length ? ebml_parse_uint(data, length) : ed->defval.u;
  ------------------
  |  Branch (526:24): [True: 766k, False: 284]
  ------------------
  527|   766k|            MP_TRACE(ctx, "uint %"PRIu64"\n", *uintptr);
  ------------------
  |  |   94|   766k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   766k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  528|   766k|            break;
  529|       |
  530|  11.4k|        case EBML_TYPE_SINT:;
  ------------------
  |  Branch (530:9): [True: 11.4k, False: 1.43M]
  ------------------
  531|  11.4k|            int64_t *sintptr;
  532|  11.4k|            GETPTR(sintptr, int64_t);
  ------------------
  |  |  515|  11.4k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 11.4k]
  |  |  ------------------
  |  |  516|  11.4k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  11.4k|            else                                                        \
  |  |  518|  11.4k|                subelptr = (fieldtype *) fieldptr
  ------------------
  533|  11.4k|            if (length > 8) {
  ------------------
  |  Branch (533:17): [True: 12, False: 11.4k]
  ------------------
  534|     12|                MP_ERR(ctx, "sint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|     12|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     12|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  535|     12|                goto error;
  536|     12|            }
  537|  11.4k|            if (!length && ed->context_default)
  ------------------
  |  Branch (537:17): [True: 1, False: 11.4k]
  |  Branch (537:28): [True: 0, False: 1]
  ------------------
  538|      0|                goto skip;
  539|  11.4k|            *sintptr = length ? ebml_parse_sint(data, length) : ed->defval.i;
  ------------------
  |  Branch (539:24): [True: 11.4k, False: 1]
  ------------------
  540|  11.4k|            MP_TRACE(ctx, "sint %"PRId64"\n", *sintptr);
  ------------------
  |  |   94|  11.4k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  541|  11.4k|            break;
  542|       |
  543|  40.8k|        case EBML_TYPE_FLOAT:;
  ------------------
  |  Branch (543:9): [True: 40.8k, False: 1.41M]
  ------------------
  544|  40.8k|            double *floatptr;
  545|  40.8k|            GETPTR(floatptr, double);
  ------------------
  |  |  515|  40.8k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 40.8k]
  |  |  ------------------
  |  |  516|  40.8k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  40.8k|            else                                                        \
  |  |  518|  40.8k|                subelptr = (fieldtype *) fieldptr
  ------------------
  546|  40.8k|            if (length != 0 && length != 4 && length != 8) {
  ------------------
  |  Branch (546:17): [True: 40.7k, False: 146]
  |  Branch (546:32): [True: 7.65k, False: 33.0k]
  |  Branch (546:47): [True: 90, False: 7.56k]
  ------------------
  547|     90|                MP_ERR(ctx, "float invalid length %"PRIu64"\n", length);
  ------------------
  |  |   89|     90|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     90|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  548|     90|                goto error;
  549|     90|            }
  550|  40.7k|            if (!length && ed->context_default)
  ------------------
  |  Branch (550:17): [True: 146, False: 40.6k]
  |  Branch (550:28): [True: 0, False: 146]
  ------------------
  551|      0|                goto skip;
  552|  40.7k|            *floatptr = length ? ebml_parse_float(data, length) : ed->defval.f;
  ------------------
  |  Branch (552:25): [True: 40.6k, False: 146]
  ------------------
  553|  40.7k|            MP_DBG(ctx, "float %f\n", *floatptr);
  ------------------
  |  |   93|  40.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  40.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  554|  40.7k|            break;
  555|       |
  556|   166k|        case EBML_TYPE_STR:
  ------------------
  |  Branch (556:9): [True: 166k, False: 1.28M]
  ------------------
  557|   166k|            if (length > 1024 * 1024) {
  ------------------
  |  Branch (557:17): [True: 0, False: 166k]
  ------------------
  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|   166k|            char **strptr;
  562|   166k|            GETPTR(strptr, char *);
  ------------------
  |  |  515|   166k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 5.34k, False: 161k]
  |  |  ------------------
  |  |  516|   166k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|   166k|            else                                                        \
  |  |  518|   166k|                subelptr = (fieldtype *) fieldptr
  ------------------
  563|   166k|            if (!length && ed->context_default)
  ------------------
  |  Branch (563:17): [True: 397, False: 165k]
  |  Branch (563:28): [True: 0, False: 397]
  ------------------
  564|      0|                goto skip;
  565|   166k|            if (!length && ed->defval.s) {
  ------------------
  |  Branch (565:17): [True: 397, False: 165k]
  |  Branch (565:28): [True: 2, False: 395]
  ------------------
  566|      2|                *strptr = talloc_strdup(ctx->talloc_ctx, ed->defval.s);
  ------------------
  |  |   50|      2|#define talloc_strdup                   ta_xstrdup
  ------------------
  567|   166k|            } else {
  568|   166k|                *strptr = talloc_strndup(ctx->talloc_ctx, data, length);
  ------------------
  |  |   51|   166k|#define talloc_strndup                  ta_xstrndup
  ------------------
  569|   166k|            }
  570|   166k|            MP_TRACE(ctx, "string \"%s\"\n", *strptr);
  ------------------
  |  |   94|   166k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   166k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  571|   166k|            break;
  572|       |
  573|  47.1k|        case EBML_TYPE_BINARY:;
  ------------------
  |  Branch (573:9): [True: 47.1k, False: 1.40M]
  ------------------
  574|  47.1k|            if (length > 0x80000000) {
  ------------------
  |  Branch (574:17): [True: 0, False: 47.1k]
  ------------------
  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|  47.1k|            if (ed->size && length != ed->size) {
  ------------------
  |  Branch (578:17): [True: 12.4k, False: 34.6k]
  |  Branch (578:29): [True: 37, False: 12.4k]
  ------------------
  579|     37|                MP_WARN(ctx, "%s invalid length %"PRIu64", ignoring\n",
  ------------------
  |  |   90|     37|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     37|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  580|     37|                        ed->name, length);
  581|     37|                goto error;
  582|     37|            }
  583|  47.0k|            struct bstr *binptr;
  584|  47.0k|            GETPTR(binptr, struct bstr);
  ------------------
  |  |  515|  47.0k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 47.0k]
  |  |  ------------------
  |  |  516|  47.0k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  47.0k|            else                                                        \
  |  |  518|  47.0k|                subelptr = (fieldtype *) fieldptr
  ------------------
  585|  47.0k|            binptr->start = data;
  586|  47.0k|            binptr->len = length;
  587|  47.0k|            MP_TRACE(ctx, "binary %zd bytes\n", binptr->len);
  ------------------
  |  |   94|  47.0k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  47.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  588|  47.0k|            break;
  589|       |
  590|  72.9k|        case EBML_TYPE_EBML_ID:;
  ------------------
  |  Branch (590:9): [True: 72.9k, False: 1.37M]
  ------------------
  591|  72.9k|            uint32_t *idptr;
  592|  72.9k|            GETPTR(idptr, uint32_t);
  ------------------
  |  |  515|  72.9k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 72.9k]
  |  |  ------------------
  |  |  516|  72.9k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  72.9k|            else                                                        \
  |  |  518|  72.9k|                subelptr = (fieldtype *) fieldptr
  ------------------
  593|  72.9k|            *idptr = ebml_parse_id(data, end - data, &len);
  594|  72.9k|            if (len != length) {
  ------------------
  |  Branch (594:17): [True: 681, False: 72.2k]
  ------------------
  595|    681|                MP_ERR(ctx, "ebml_id broken value\n");
  ------------------
  |  |   89|    681|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    681|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  596|    681|                goto error;
  597|    681|            }
  598|  72.2k|            MP_TRACE(ctx, "ebml_id %x\n", (unsigned)*idptr);
  ------------------
  |  |   94|  72.2k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  72.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  599|  72.2k|            break;
  600|      0|        default:
  ------------------
  |  Branch (600:9): [True: 0, False: 1.45M]
  ------------------
  601|  1.45M|            MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (601:13): [Folded, False: 0]
  ------------------
  602|  1.45M|        }
  603|  1.44M|        *countptr += 1;
  604|  1.45M|    error:
  605|  1.45M|    skip:
  606|  1.45M|        data += length;
  607|  1.45M|    }
  608|   440k|}
ebml.c:ebml_parse_id:
  238|  3.33M|{
  239|  3.33M|    *length = -1;
  240|  3.33M|    uint8_t *end = data + data_len;
  241|  3.33M|    if (data == end)
  ------------------
  |  Branch (241:9): [True: 11, False: 3.33M]
  ------------------
  242|     11|        return EBML_ID_INVALID;
  ------------------
  |  |   75|     11|#define EBML_ID_INVALID 0xffffffff
  ------------------
  243|  3.33M|    int len = 1;
  244|  3.33M|    uint32_t id = *data++;
  245|  5.40M|    for (int len_mask = 0x80; !(id & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (245:31): [True: 2.07M, False: 3.32M]
  ------------------
  246|  2.07M|        len++;
  247|  2.07M|        if (len > 4)
  ------------------
  |  Branch (247:13): [True: 9.97k, False: 2.06M]
  ------------------
  248|  9.97k|            return EBML_ID_INVALID;
  ------------------
  |  |   75|  9.97k|#define EBML_ID_INVALID 0xffffffff
  ------------------
  249|  2.07M|    }
  250|  3.32M|    *length = len;
  251|  5.35M|    while (--len && data < end)
  ------------------
  |  Branch (251:12): [True: 2.03M, False: 3.32M]
  |  Branch (251:21): [True: 2.03M, False: 723]
  ------------------
  252|  2.03M|        id = (id << 8) | *data++;
  253|  3.32M|    return id;
  254|  3.33M|}
ebml.c:ebml_parse_length:
  257|  3.24M|{
  258|  3.24M|    *length = -1;
  259|  3.24M|    uint8_t *end = data + data_len;
  260|  3.24M|    if (data == end)
  ------------------
  |  Branch (260:9): [True: 580, False: 3.24M]
  ------------------
  261|    580|        return -1;
  262|  3.24M|    uint64_t r = *data++;
  263|  3.24M|    int len = 1;
  264|  3.24M|    int len_mask;
  265|  4.15M|    for (len_mask = 0x80; !(r & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (265:27): [True: 912k, False: 3.24M]
  ------------------
  266|   912k|        len++;
  267|   912k|        if (len > 8)
  ------------------
  |  Branch (267:13): [True: 4.88k, False: 908k]
  ------------------
  268|  4.88k|            return -1;
  269|   912k|    }
  270|  3.24M|    r &= len_mask - 1;
  271|       |
  272|  3.24M|    int num_allones = 0;
  273|  3.24M|    if (r == len_mask - 1)
  ------------------
  |  Branch (273:9): [True: 112k, False: 3.13M]
  ------------------
  274|   112k|        num_allones++;
  275|  4.11M|    for (int i = 1; i < len; i++) {
  ------------------
  |  Branch (275:21): [True: 872k, False: 3.24M]
  ------------------
  276|   872k|        if (data == end)
  ------------------
  |  Branch (276:13): [True: 1.89k, False: 870k]
  ------------------
  277|  1.89k|            return -1;
  278|   870k|        if (*data == 255)
  ------------------
  |  Branch (278:13): [True: 7.69k, False: 863k]
  ------------------
  279|  7.69k|            num_allones++;
  280|   870k|        r = (r << 8) | *data++;
  281|   870k|    }
  282|       |    // According to Matroska specs this means "unknown length"
  283|       |    // Could be supported if there are any actual files using it
  284|  3.24M|    if (num_allones == len)
  ------------------
  |  Branch (284:9): [True: 4.59k, False: 3.23M]
  ------------------
  285|  4.59k|        return -1;
  286|  3.23M|    *length = len;
  287|  3.23M|    return r;
  288|  3.24M|}
ebml.c:ebml_parse_uint:
  291|   807k|{
  292|   807k|    mp_assert(length >= 0 && length <= 8);
  ------------------
  |  |   41|   807k|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 807k, False: 0]
  |  Branch (292:5): [True: 807k, False: 0]
  ------------------
  293|   807k|    uint64_t r = 0;
  294|  2.41M|    while (length--)
  ------------------
  |  Branch (294:12): [True: 1.61M, False: 807k]
  ------------------
  295|  1.61M|        r = (r << 8) + *data++;
  296|   807k|    return r;
  297|   807k|}
ebml.c:ebml_parse_sint:
  300|  11.4k|{
  301|  11.4k|    mp_assert(length >= 0 && length <= 8);
  ------------------
  |  |   41|  11.4k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 11.4k, False: 0]
  |  Branch (301:5): [True: 11.4k, False: 0]
  ------------------
  302|  11.4k|    if (!length)
  ------------------
  |  Branch (302:9): [True: 0, False: 11.4k]
  ------------------
  303|      0|        return 0;
  304|  11.4k|    uint64_t r = 0;
  305|  11.4k|    if (*data & 0x80)
  ------------------
  |  Branch (305:9): [True: 3, False: 11.4k]
  ------------------
  306|      3|        r = -1;
  307|   102k|    while (length--)
  ------------------
  |  Branch (307:12): [True: 91.4k, False: 11.4k]
  ------------------
  308|  91.4k|        r = (r << 8) | *data++;
  309|  11.4k|    return (int64_t)r; // assume complement of 2
  310|  11.4k|}
ebml.c:ebml_parse_float:
  313|  40.6k|{
  314|  40.6k|    mp_assert(length == 0 || length == 4 || length == 8);
  ------------------
  |  |   41|  40.6k|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 0, False: 40.6k]
  |  Branch (314:5): [True: 33.0k, False: 7.56k]
  |  Branch (314:5): [True: 7.56k, False: 0]
  ------------------
  315|  40.6k|    uint64_t i = ebml_parse_uint(data, length);
  316|  40.6k|    if (length == 4)
  ------------------
  |  Branch (316:9): [True: 33.0k, False: 7.56k]
  ------------------
  317|  33.0k|        return av_int2float(i);
  318|  7.56k|    else
  319|  7.56k|        return av_int2double(i);
  320|  40.6k|}

demux_packet_unref_contents:
   48|   682k|{
   49|   682k|    if (dp->avpacket) {
  ------------------
  |  Branch (49:9): [True: 682k, False: 0]
  ------------------
   50|   682k|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|   682k|#define mp_assert assert
  ------------------
  |  Branch (50:9): [True: 682k, False: 0]
  ------------------
   51|   682k|        av_packet_free(&dp->avpacket);
   52|   682k|        dp->buffer = NULL;
   53|   682k|        dp->len = 0;
   54|       |        dp->is_wrapped_avframe = false;
   55|   682k|    }
   56|   682k|}
demux_packet_unref:
   81|  3.12M|{
   82|  3.12M|    if (!dp)
  ------------------
  |  Branch (82:9): [True: 682k, False: 2.44M]
  ------------------
   83|   682k|        return;
   84|  2.44M|    struct AVPacket *avpkt = dp->avpacket;
   85|  2.44M|    if (avpkt)
  ------------------
  |  Branch (85:9): [True: 2.44M, False: 18.4E]
  ------------------
   86|  2.44M|        av_packet_unref(avpkt);
   87|  2.44M|    ta_free_children(dp);
   88|  2.44M|    set_packet_defaults(dp);
   89|  2.44M|    dp->avpacket = avpkt;
   90|  2.44M|}
new_demux_packet_from_avpacket:
  111|   757k|{
  112|   757k|    if (avpkt->size > 1000000000)
  ------------------
  |  Branch (112:9): [True: 0, False: 757k]
  ------------------
  113|      0|        return NULL;
  114|   757k|    struct demux_packet *dp = packet_create(pool);
  115|   757k|    int r = -1;
  116|   757k|    if (avpkt->data) {
  ------------------
  |  Branch (116:9): [True: 757k, 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|   757k|        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|   757k|    if (r < 0) {
  ------------------
  |  Branch (123:9): [True: 0, False: 757k]
  ------------------
  124|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  125|      0|        return NULL;
  126|      0|    }
  127|   757k|    dp->buffer = dp->avpacket->data;
  128|   757k|    dp->len = dp->avpacket->size;
  129|   757k|    return dp;
  130|   757k|}
new_demux_packet_from_buf:
  135|   861k|{
  136|   861k|    if (!buf)
  ------------------
  |  Branch (136:9): [True: 120k, False: 741k]
  ------------------
  137|   120k|        return NULL;
  138|   741k|    if (buf->size > 1000000000)
  ------------------
  |  Branch (138:9): [True: 0, False: 741k]
  ------------------
  139|      0|        return NULL;
  140|       |
  141|   741k|    struct demux_packet *dp = packet_create(pool);
  142|   741k|    dp->avpacket->buf = av_buffer_ref(buf);
  143|   741k|    if (!dp->avpacket->buf) {
  ------------------
  |  Branch (143:9): [True: 0, False: 741k]
  ------------------
  144|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        return NULL;
  146|      0|    }
  147|   741k|    dp->avpacket->data = dp->buffer = buf->data;
  148|   741k|    dp->avpacket->size = dp->len = buf->size;
  149|   741k|    return dp;
  150|   741k|}
new_demux_packet_from:
  154|  78.8k|{
  155|  78.8k|    struct demux_packet *dp = new_demux_packet(pool, len);
  156|  78.8k|    if (!dp)
  ------------------
  |  Branch (156:9): [True: 0, False: 78.8k]
  ------------------
  157|      0|        return NULL;
  158|  78.8k|    memcpy(dp->avpacket->data, data, len);
  159|  78.8k|    return dp;
  160|  78.8k|}
new_demux_packet:
  163|  80.7k|{
  164|  80.7k|    if (len > INT_MAX)
  ------------------
  |  Branch (164:9): [True: 0, False: 80.7k]
  ------------------
  165|      0|        return NULL;
  166|       |
  167|  80.7k|    struct demux_packet *dp = packet_create(pool);
  168|  80.7k|    int r = av_new_packet(dp->avpacket, len);
  169|  80.7k|    if (r < 0) {
  ------------------
  |  Branch (169:9): [True: 0, False: 80.7k]
  ------------------
  170|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  171|      0|        return NULL;
  172|      0|    }
  173|  80.7k|    dp->buffer = dp->avpacket->data;
  174|  80.7k|    dp->len = len;
  175|  80.7k|    return dp;
  176|  80.7k|}
free_demux_packet:
  188|   661k|{
  189|   661k|    talloc_free(dp);
  ------------------
  |  |   47|   661k|#define talloc_free                     ta_free
  ------------------
  190|   661k|}
demux_packet_copy_attribs:
  193|   792k|{
  194|   792k|    dst->pts = src->pts;
  195|   792k|    dst->dts = src->dts;
  196|   792k|    dst->duration = src->duration;
  197|   792k|    dst->pos = src->pos;
  198|   792k|    dst->is_wrapped_avframe = src->is_wrapped_avframe;
  199|   792k|    dst->segmented = src->segmented;
  200|   792k|    dst->start = src->start;
  201|   792k|    dst->end = src->end;
  202|   792k|    dst->codec = src->codec;
  203|   792k|    dst->back_restart = src->back_restart;
  204|   792k|    dst->back_preroll = src->back_preroll;
  205|   792k|    dst->keyframe = src->keyframe;
  206|   792k|    dst->stream = src->stream;
  207|   792k|}
demux_copy_packet:
  210|   757k|{
  211|   757k|    struct demux_packet *new = NULL;
  212|   757k|    if (dp->avpacket) {
  ------------------
  |  Branch (212:9): [True: 757k, False: 0]
  ------------------
  213|   757k|        new = new_demux_packet_from_avpacket(pool, dp->avpacket);
  214|   757k|    } 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|   757k|    if (!new)
  ------------------
  |  Branch (218:9): [True: 0, False: 757k]
  ------------------
  219|      0|        return NULL;
  220|   757k|    demux_packet_copy_attribs(new, dp);
  221|   757k|    return new;
  222|   757k|}
demux_packet_estimate_total_size:
  235|   764k|{
  236|   764k|    size_t size = ROUND_ALLOC(sizeof(struct demux_packet));
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  237|   764k|    size += 8 * sizeof(void *); // ta  overhead
  238|   764k|    size += 10 * sizeof(void *); // additional estimate for ta_ext_header
  239|   764k|    if (dp->avpacket) {
  ------------------
  |  Branch (239:9): [True: 764k, False: 0]
  ------------------
  240|   764k|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|   764k|#define mp_assert assert
  ------------------
  |  Branch (240:9): [True: 764k, False: 0]
  ------------------
  241|   764k|        size += ROUND_ALLOC(dp->len);
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  242|   764k|        if (dp->is_wrapped_avframe) {
  ------------------
  |  Branch (242:13): [True: 0, False: 764k]
  ------------------
  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|   764k|        size += ROUND_ALLOC(sizeof(AVPacket));
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  268|   764k|        size += 8 * sizeof(void *); // ta  overhead
  269|   764k|        size += ROUND_ALLOC(sizeof(AVBufferRef));
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  270|   764k|        size += ROUND_ALLOC(64); // upper bound estimate on sizeof(AVBuffer)
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  271|   764k|        size += ROUND_ALLOC(dp->avpacket->side_data_elems *
  ------------------
  |  |  224|   764k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  272|   764k|                            sizeof(dp->avpacket->side_data[0]));
  273|   764k|        for (int n = 0; n < dp->avpacket->side_data_elems; n++)
  ------------------
  |  Branch (273:25): [True: 0, False: 764k]
  ------------------
  274|   764k|            size += ROUND_ALLOC(dp->avpacket->side_data[n].size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   764k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  275|   764k|    }
  276|   764k|    return size;
  277|   764k|}
demux_packet_set_padding:
  280|   380k|{
  281|   380k|    if (!start && !end)
  ------------------
  |  Branch (281:9): [True: 380k, False: 0]
  |  Branch (281:19): [True: 380k, False: 0]
  ------------------
  282|   380k|        return 0;
  283|      0|    if (!dp->avpacket)
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|        return -1;
  285|      0|    uint8_t *p = av_packet_new_side_data(dp->avpacket, AV_PKT_DATA_SKIP_SAMPLES, 10);
  286|      0|    if (!p)
  ------------------
  |  Branch (286:9): [True: 0, False: 0]
  ------------------
  287|      0|        return -1;
  288|       |
  289|      0|    AV_WL32(p + 0, start);
  290|       |    AV_WL32(p + 4, end);
  291|      0|    return 0;
  292|      0|}
packet.c:set_packet_defaults:
   65|  3.12M|{
   66|  3.12M|    *dp = (struct demux_packet) {
   67|  3.12M|        .pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  3.12M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   68|  3.12M|        .dts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  3.12M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   69|  3.12M|        .duration = -1,
   70|  3.12M|        .pos = -1,
   71|  3.12M|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  3.12M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   72|  3.12M|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  3.12M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   73|  3.12M|        .stream = -1,
   74|  3.12M|        .animated = -1,
   75|  3.12M|    };
   76|  3.12M|}
packet.c:packet_create:
   93|  1.57M|{
   94|  1.57M|    struct demux_packet *dp = pool ? demux_packet_pool_pop(pool) : NULL;
  ------------------
  |  Branch (94:31): [True: 1.57M, False: 1]
  ------------------
   95|  1.57M|    if (!dp) {
  ------------------
  |  Branch (95:9): [True: 682k, False: 896k]
  ------------------
   96|   682k|        dp = talloc(NULL, struct demux_packet);
  ------------------
  |  |   26|   682k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   682k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   682k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   97|   682k|        talloc_set_destructor(dp, packet_destroy);
  ------------------
  |  |   41|   682k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   98|   682k|        set_packet_defaults(dp);
   99|   682k|    }
  100|  1.57M|    if (!dp->avpacket)
  ------------------
  |  Branch (100:9): [True: 682k, False: 896k]
  ------------------
  101|   682k|        dp->avpacket = av_packet_alloc();
  102|  1.57M|    MP_HANDLE_OOM(dp->avpacket);
  ------------------
  |  |  206|  1.57M|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.57M|        void *oom_p_ = (x);     \
  |  |  208|  1.57M|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.57M]
  |  |  ------------------
  |  |  209|  1.57M|            abort();            \
  |  |  210|  1.57M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.57M]
  |  |  ------------------
  ------------------
  103|  1.57M|    return dp;
  104|  1.57M|}
packet.c:packet_destroy:
   59|   682k|{
   60|   682k|    struct demux_packet *dp = ptr;
   61|   682k|    demux_packet_unref_contents(dp);
   62|   682k|}

demux_packet_pool_init:
   50|  24.7k|{
   51|  24.7k|    struct demux_packet_pool *pool = talloc(global, struct demux_packet_pool);
  ------------------
  |  |   26|  24.7k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.7k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   52|  24.7k|    talloc_set_destructor(pool, uninit);
  ------------------
  |  |   41|  24.7k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   53|  24.7k|    mp_mutex_init(&pool->lock);
   54|  24.7k|    pool->packets = NULL;
   55|       |
   56|  24.7k|    mp_assert(!global->packet_pool);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 24.7k, False: 0]
  ------------------
   57|  24.7k|    global->packet_pool = pool;
   58|  24.7k|}
demux_packet_pool_get:
   61|   720k|{
   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|   720k|    return global->packet_pool;
   65|   720k|}
demux_packet_pool_clear:
   68|  74.1k|{
   69|  74.1k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  74.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   70|  74.1k|    struct demux_packet *dp = pool->packets;
   71|  74.1k|    pool->packets = NULL;
   72|  74.1k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  74.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   73|  74.1k|    free_demux_packets(dp);
   74|  74.1k|}
demux_packet_pool_push:
   78|  1.58M|{
   79|  1.58M|    if (!dp)
  ------------------
  |  Branch (79:9): [True: 31.0k, False: 1.55M]
  ------------------
   80|  31.0k|        return;
   81|  1.55M|    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.55M|    demux_packet_unref(dp);
   86|  1.55M|    demux_packet_pool_prepend(pool, dp, dp);
   87|  1.55M|}
demux_packet_pool_prepend:
   91|  1.68M|{
   92|  1.68M|    if (!head)
  ------------------
  |  Branch (92:9): [True: 136k, False: 1.55M]
  ------------------
   93|   136k|        return;
   94|  1.55M|    mp_assert(tail);
  ------------------
  |  |   41|  1.55M|#define mp_assert assert
  ------------------
  |  Branch (94:5): [True: 1.55M, False: 0]
  ------------------
   95|  1.55M|    mp_assert(head != tail ? !!head->next : !head->next);
  ------------------
  |  |   41|  1.55M|#define mp_assert assert
  ------------------
  |  Branch (95:5): [True: 312, False: 1.55M]
  |  Branch (95:5): [True: 1.55M, False: 18.4E]
  ------------------
   96|       |
   97|  1.55M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  1.55M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   98|  1.55M|    tail->next = pool->packets;
   99|  1.55M|    pool->packets = head;
  100|       |#if HAVE_DISABLE_PACKET_POOL
  101|       |    struct demux_packet *dp = pool->packets;
  102|       |    pool->packets = NULL;
  103|       |#endif
  104|  1.55M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  1.55M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  105|       |
  106|       |#if HAVE_DISABLE_PACKET_POOL
  107|       |    free_demux_packets(dp);
  108|       |#endif
  109|  1.55M|}
demux_packet_pool_pop:
  145|  1.57M|{
  146|  1.57M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  1.57M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  147|  1.57M|    struct demux_packet *dp = pool->packets;
  148|  1.57M|    if (dp) {
  ------------------
  |  Branch (148:9): [True: 896k, False: 682k]
  ------------------
  149|   896k|        pool->packets = dp->next;
  150|   896k|        dp->next = NULL;
  151|   896k|    }
  152|  1.57M|    struct demux_packet *gc = pool_gc_detach(pool);
  153|  1.57M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  1.57M|#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|  1.57M|    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|  1.57M|    free_demux_packets(gc);
  162|       |
  163|  1.57M|    return dp;
  164|  1.57M|}
packet_pool.c:uninit:
   34|  24.7k|{
   35|  24.7k|    struct demux_packet_pool *pool = p;
   36|  24.7k|    demux_packet_pool_clear(pool);
   37|  24.7k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   38|  24.7k|}
packet_pool.c:free_demux_packets:
   41|  1.65M|{
   42|  2.31M|    while (dp) {
  ------------------
  |  Branch (42:12): [True: 661k, False: 1.65M]
  ------------------
   43|   661k|        struct demux_packet *next = dp->next;
   44|   661k|        free_demux_packet(dp);
   45|   661k|        dp = next;
   46|   661k|    }
   47|  1.65M|}
packet_pool.c:pool_gc_detach:
  126|  1.57M|{
  127|  1.57M|    struct demux_packet *cat_reserve = pool->packets;
  128|  10.7M|    for (int i = 1; cat_reserve && i < POOL_HOT_RESERVE; i++)
  ------------------
  |  |  114|  9.63M|#define POOL_HOT_RESERVE 16
  ------------------
  |  Branch (128:21): [True: 9.63M, False: 1.11M]
  |  Branch (128:36): [True: 9.17M, False: 462k]
  ------------------
  129|  9.17M|        cat_reserve = cat_reserve->next;
  130|       |
  131|  1.57M|    if (!cat_reserve || !cat_reserve->next)
  ------------------
  |  Branch (131:9): [True: 1.11M, False: 462k]
  |  Branch (131:25): [True: 12.5k, False: 450k]
  ------------------
  132|  1.12M|        return NULL;
  133|       |
  134|   450k|    struct demux_packet *gc = cat_reserve->next;
  135|   450k|    struct demux_packet *cut_rest = gc;
  136|   453k|    for (int i = 1; cut_rest->next && i < POOL_GC_BATCH; i++)
  ------------------
  |  |  121|  3.54k|#define POOL_GC_BATCH 64
  ------------------
  |  Branch (136:21): [True: 3.54k, False: 450k]
  |  Branch (136:39): [True: 3.52k, False: 18]
  ------------------
  137|  3.52k|        cut_rest = cut_rest->next;
  138|       |
  139|   450k|    cat_reserve->next = cut_rest->next;
  140|       |    cut_rest->next = NULL;
  141|   450k|    return gc;
  142|  1.57M|}

loadfile.c:sh_stream_dependent_sibling:
  107|   248k|{
  108|   248k|    if (!bl || !bl->group || bl->dependent_track)
  ------------------
  |  Branch (108:9): [True: 0, False: 248k]
  |  Branch (108:16): [True: 248k, False: 0]
  |  Branch (108:30): [True: 0, False: 0]
  ------------------
  109|   248k|        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|  19.6k|{
  108|  19.6k|    if (!bl || !bl->group || bl->dependent_track)
  ------------------
  |  Branch (108:9): [True: 0, False: 19.6k]
  |  Branch (108:16): [True: 19.6k, False: 0]
  |  Branch (108:30): [True: 0, False: 0]
  ------------------
  109|  19.6k|        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.5k|{
   10|  24.5k|    if (!demuxer->desc->load_timeline)
  ------------------
  |  Branch (10:9): [True: 286, False: 24.2k]
  ------------------
   11|    286|        return NULL;
   12|       |
   13|  24.2k|    struct timeline *tl = talloc_ptrtype(NULL, tl);
  ------------------
  |  |   34|  24.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   14|  24.2k|    *tl = (struct timeline){
   15|  24.2k|        .global = global,
   16|  24.2k|        .log = log,
   17|  24.2k|        .cancel = demuxer->cancel,
   18|  24.2k|        .demuxer = demuxer,
   19|  24.2k|        .format = "unknown",
   20|  24.2k|        .stream_origin = demuxer->stream_origin,
   21|  24.2k|    };
   22|       |
   23|  24.2k|    demuxer->desc->load_timeline(tl);
   24|       |
   25|  24.2k|    if (tl->num_pars)
  ------------------
  |  Branch (25:9): [True: 286, False: 23.9k]
  ------------------
   26|    286|        return tl;
   27|  23.9k|    timeline_destroy(tl);
   28|       |    return NULL;
   29|  24.2k|}
timeline_destroy:
   32|  24.2k|{
   33|  24.2k|    if (!tl)
  ------------------
  |  Branch (33:9): [True: 0, False: 24.2k]
  ------------------
   34|      0|        return;
   35|  24.5k|    for (int n = 0; n < tl->num_sources; n++) {
  ------------------
  |  Branch (35:21): [True: 286, False: 24.2k]
  ------------------
   36|    286|        struct demuxer *d = tl->sources[n];
   37|    286|        if (d != tl->demuxer)
  ------------------
  |  Branch (37:13): [True: 0, False: 286]
  ------------------
   38|      0|            demux_free(d);
   39|    286|    }
   40|  24.2k|    talloc_free(tl);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
   41|  24.2k|}

mp_async_queue_create:
   72|  8.07k|{
   73|  8.07k|    struct mp_async_queue *r = talloc_zero(NULL, struct mp_async_queue);
  ------------------
  |  |   27|  8.07k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  8.07k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.07k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   74|  8.07k|    r->q = talloc_zero(NULL, struct async_queue);
  ------------------
  |  |   27|  8.07k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  8.07k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.07k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|  8.07k|    *r->q = (struct async_queue){
   76|  8.07k|        .refcount = 1,
   77|  8.07k|    };
   78|  8.07k|    mp_mutex_init(&r->q->lock);
   79|  8.07k|    talloc_set_destructor(r, on_free_queue);
  ------------------
  |  |   41|  8.07k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   80|  8.07k|    mp_async_queue_set_config(r, (struct mp_async_queue_config){0});
   81|  8.07k|    return r;
   82|  8.07k|}
mp_async_queue_set_config:
  135|  16.1k|{
  136|  16.1k|    struct async_queue *q = queue->q;
  137|       |
  138|  16.1k|    cfg.max_bytes = MPCLAMP(cfg.max_bytes, 1, (size_t)-1 / 2);
  ------------------
  |  |   46|  16.1k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 8.07k, False: 8.07k]
  |  |  |  Branch (46:56): [True: 0, False: 8.07k]
  |  |  ------------------
  ------------------
  139|       |
  140|  16.1k|    mp_assert(cfg.sample_unit == AQUEUE_UNIT_FRAME ||
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 8.07k, False: 8.07k]
  |  Branch (140:5): [True: 8.07k, False: 0]
  ------------------
  141|  16.1k|           cfg.sample_unit == AQUEUE_UNIT_SAMPLES);
  142|       |
  143|  16.1k|    cfg.max_samples = MPMAX(cfg.max_samples, 1);
  ------------------
  |  |   44|  16.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 8.07k, False: 8.07k]
  |  |  ------------------
  ------------------
  144|       |
  145|  16.1k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  16.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  146|  16.1k|    bool recompute = q->cfg.sample_unit != cfg.sample_unit;
  147|  16.1k|    q->cfg = cfg;
  148|  16.1k|    if (recompute)
  ------------------
  |  Branch (148:9): [True: 8.07k, False: 8.07k]
  ------------------
  149|  8.07k|        recompute_sizes(q);
  150|  16.1k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  16.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  151|  16.1k|}
mp_async_queue_reset:
  154|  3.81k|{
  155|  3.81k|    reset_queue(queue->q);
  156|  3.81k|}
mp_async_queue_is_full:
  168|   222k|{
  169|   222k|    struct async_queue *q = queue->q;
  170|   222k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|   222k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  171|   222k|    bool res = is_full(q);
  172|   222k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|   222k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  173|   222k|    return res;
  174|   222k|}
mp_async_queue_resume_reading:
  191|  11.8k|{
  192|  11.8k|    struct async_queue *q = queue->q;
  193|       |
  194|  11.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  11.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  195|  11.8k|    if (!q->active || !q->reading) {
  ------------------
  |  Branch (195:9): [True: 11.8k, False: 0]
  |  Branch (195:23): [True: 0, False: 0]
  ------------------
  196|  11.8k|        q->active = true;
  197|  11.8k|        q->reading = true;
  198|       |        // Possibly start producer/consumer.
  199|  35.6k|        for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (199:25): [True: 23.7k, False: 11.8k]
  ------------------
  200|  23.7k|            if (q->conn[n])
  ------------------
  |  Branch (200:17): [True: 14.1k, False: 9.56k]
  ------------------
  201|  14.1k|                mp_filter_wakeup(q->conn[n]);
  202|  23.7k|        }
  203|  11.8k|    }
  204|  11.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  11.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  205|  11.8k|}
mp_async_queue_get_samples:
  208|  55.8k|{
  209|  55.8k|    struct async_queue *q = queue->q;
  210|  55.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  55.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  211|  55.8k|    int64_t res = q->samples_size;
  212|  55.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  55.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  213|  55.8k|    return res;
  214|  55.8k|}
mp_async_queue_get_frames:
  217|  4.13k|{
  218|  4.13k|    struct async_queue *q = queue->q;
  219|  4.13k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  4.13k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  220|  4.13k|    int res = q->num_frames;
  221|  4.13k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  4.13k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  222|  4.13k|    return res;
  223|  4.13k|}
mp_async_queue_set_notifier:
  338|  8.07k|{
  339|  8.07k|    mp_assert(mp_filter_get_info(f) == &info_in);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (339:5): [True: 8.07k, False: 0]
  ------------------
  340|  8.07k|    struct priv *p = f->priv;
  341|  8.07k|    if (p->notify != notify) {
  ------------------
  |  Branch (341:9): [True: 8.07k, False: 0]
  ------------------
  342|  8.07k|        p->notify = notify;
  343|  8.07k|        if (notify)
  ------------------
  |  Branch (343:13): [True: 8.07k, False: 0]
  ------------------
  344|  8.07k|            mp_filter_wakeup(notify);
  345|  8.07k|    }
  346|  8.07k|}
mp_async_queue_create_filter:
  351|  16.1k|{
  352|  16.1k|    bool is_in = dir == MP_PIN_IN;
  353|  16.1k|    mp_assert(queue);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (353:5): [True: 16.1k, False: 0]
  ------------------
  354|       |
  355|  16.1k|    struct mp_filter *f = mp_filter_create(parent, is_in ? &info_in : &info_out);
  ------------------
  |  Branch (355:52): [True: 8.07k, False: 8.07k]
  ------------------
  356|  16.1k|    if (!f)
  ------------------
  |  Branch (356:9): [True: 0, False: 16.1k]
  ------------------
  357|      0|        return NULL;
  358|       |
  359|  16.1k|    struct priv *p = f->priv;
  360|       |
  361|  16.1k|    struct async_queue *q = queue->q;
  362|       |
  363|  16.1k|    mp_filter_add_pin(f, dir, is_in ? "in" : "out");
  ------------------
  |  Branch (363:31): [True: 8.07k, False: 8.07k]
  ------------------
  364|       |
  365|  16.1k|    atomic_fetch_add(&q->refcount, 1);
  366|  16.1k|    p->q = q;
  367|       |
  368|  16.1k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  16.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  369|  16.1k|    int slot = is_in ? 0 : 1;
  ------------------
  |  Branch (369:16): [True: 8.07k, False: 8.07k]
  ------------------
  370|  16.1k|    mp_assert(!q->conn[slot]); // fails if already connected on this end
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (370:5): [True: 16.1k, False: 0]
  ------------------
  371|  16.1k|    q->conn[slot] = f;
  372|  16.1k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  16.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  373|       |
  374|  16.1k|    return f;
  375|  16.1k|}
f_async_queue.c:on_free_queue:
   66|  8.07k|{
   67|  8.07k|    struct mp_async_queue *q = p;
   68|  8.07k|    unref_queue(q->q);
   69|  8.07k|}
f_async_queue.c:unref_queue:
   53|  24.2k|{
   54|  24.2k|    if (!q)
  ------------------
  |  Branch (54:9): [True: 0, False: 24.2k]
  ------------------
   55|      0|        return;
   56|  24.2k|    int count = atomic_fetch_add(&q->refcount, -1) - 1;
   57|  24.2k|    mp_assert(count >= 0);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (57:5): [True: 24.2k, False: 0]
  ------------------
   58|  24.2k|    if (count == 0) {
  ------------------
  |  Branch (58:9): [True: 8.07k, False: 16.1k]
  ------------------
   59|  8.07k|        reset_queue(q);
   60|  8.07k|        mp_mutex_destroy(&q->lock);
  ------------------
  |  |  133|  8.07k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   61|  8.07k|        talloc_free(q);
  ------------------
  |  |   47|  8.07k|#define talloc_free                     ta_free
  ------------------
   62|  8.07k|    }
   63|  24.2k|}
f_async_queue.c:recompute_sizes:
  125|  8.07k|{
  126|  8.07k|    q->eof_count = 0;
  127|  8.07k|    q->samples_size = 0;
  128|  8.07k|    q->byte_size = 0;
  129|  8.07k|    for (int n = 0; n < q->num_frames; n++)
  ------------------
  |  Branch (129:21): [True: 0, False: 8.07k]
  ------------------
  130|      0|        account_frame(q, q->frames[n], 1);
  131|  8.07k|}
f_async_queue.c:account_frame:
  114|   784k|{
  115|   784k|    mp_assert(dir == 1 || dir == -1);
  ------------------
  |  |   41|   784k|#define mp_assert assert
  ------------------
  |  Branch (115:5): [True: 403k, False: 380k]
  |  Branch (115:5): [True: 380k, False: 0]
  ------------------
  116|       |
  117|   784k|    q->samples_size += dir * frame_get_samples(q, frame);
  118|   784k|    q->byte_size += dir * mp_frame_approx_size(frame);
  119|       |
  120|   784k|    if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (120:9): [True: 13.2k, False: 770k]
  ------------------
  121|  13.2k|        q->eof_count += dir;
  122|   784k|}
f_async_queue.c:frame_get_samples:
   85|   784k|{
   86|   784k|    int64_t res = 1;
   87|   784k|    if (frame.type == MP_FRAME_AUDIO && q->cfg.sample_unit == AQUEUE_UNIT_SAMPLES) {
  ------------------
  |  Branch (87:9): [True: 770k, False: 13.2k]
  |  Branch (87:41): [True: 770k, False: 0]
  ------------------
   88|   770k|        struct mp_aframe *aframe = frame.data;
   89|   770k|        res = mp_aframe_get_size(aframe);
   90|   770k|    }
   91|   784k|    if (mp_frame_is_signaling(frame))
  ------------------
  |  Branch (91:9): [True: 13.2k, False: 770k]
  ------------------
   92|  13.2k|        return 0;
   93|   770k|    return res;
   94|   784k|}
f_async_queue.c:reset_queue:
   36|  11.8k|{
   37|  11.8k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  11.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   38|  11.8k|    q->active = q->reading = false;
   39|  35.1k|    for (int n = 0; n < q->num_frames; n++)
  ------------------
  |  Branch (39:21): [True: 23.3k, False: 11.8k]
  ------------------
   40|  23.3k|        mp_frame_unref(&q->frames[n]);
   41|  11.8k|    q->num_frames = 0;
   42|  11.8k|    q->eof_count = 0;
   43|  11.8k|    q->samples_size = 0;
   44|  11.8k|    q->byte_size = 0;
   45|  35.6k|    for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (45:21): [True: 23.7k, False: 11.8k]
  ------------------
   46|  23.7k|        if (q->conn[n])
  ------------------
  |  Branch (46:13): [True: 6.12k, False: 17.6k]
  ------------------
   47|  6.12k|            mp_filter_wakeup(q->conn[n]);
   48|  23.7k|    }
   49|  11.8k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  11.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   50|  11.8k|}
f_async_queue.c:is_full:
   97|  1.05M|{
   98|  1.05M|    if (q->samples_size >= q->cfg.max_samples || q->byte_size >= q->cfg.max_bytes)
  ------------------
  |  Branch (98:9): [True: 10.6k, False: 1.04M]
  |  Branch (98:50): [True: 0, False: 1.04M]
  ------------------
   99|  10.6k|        return true;
  100|  1.04M|    if (q->num_frames >= 2 && q->cfg.max_duration > 0) {
  ------------------
  |  Branch (100:9): [True: 312k, False: 731k]
  |  Branch (100:31): [True: 0, False: 312k]
  ------------------
  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.04M|    return false;
  108|  1.04M|}
f_async_queue.c:destroy:
  231|  16.1k|{
  232|  16.1k|    struct priv *p = f->priv;
  233|  16.1k|    struct async_queue *q = p->q;
  234|       |
  235|  16.1k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|  16.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  236|  48.4k|    for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (236:21): [True: 32.2k, False: 16.1k]
  ------------------
  237|  32.2k|        if (q->conn[n] == f)
  ------------------
  |  Branch (237:13): [True: 16.1k, False: 16.1k]
  ------------------
  238|  16.1k|            q->conn[n] = NULL;
  239|  32.2k|    }
  240|  16.1k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|  16.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  241|       |
  242|  16.1k|    unref_queue(q);
  243|  16.1k|}
f_async_queue.c:process_in:
  246|   428k|{
  247|   428k|    struct priv *p = f->priv;
  248|   428k|    struct async_queue *q = p->q;
  249|   428k|    mp_assert(q->conn[0] == f);
  ------------------
  |  |   41|   428k|#define mp_assert assert
  ------------------
  |  Branch (249:5): [True: 428k, False: 0]
  ------------------
  250|       |
  251|   428k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|   428k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  252|   428k|    if (!q->reading) {
  ------------------
  |  Branch (252:9): [True: 0, False: 428k]
  ------------------
  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|   428k|    } else if (!is_full(q) && mp_pin_out_request_data(f->ppins[0])) {
  ------------------
  |  Branch (262:16): [True: 427k, False: 538]
  |  Branch (262:31): [True: 403k, False: 23.8k]
  ------------------
  263|   403k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  264|   403k|        account_frame(q, frame, 1);
  265|   403k|        MP_TARRAY_INSERT_AT(q, q->frames, q->num_frames, 0, frame);
  ------------------
  |  |  115|   403k|    do {                                            \
  |  |  116|   403k|        size_t at_ = (at);                          \
  |  |  117|   403k|        assert(at_ <= (idxvar));                    \
  |  |  118|   403k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   403k|    do {                                            \
  |  |  |  |   97|   403k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   403k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   403k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   403k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 17.4k, False: 386k]
  |  |  |  |  ------------------
  |  |  |  |   99|   403k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  17.4k|    do {                                                        \
  |  |  |  |  |  |   89|  17.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  17.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  17.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  17.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  17.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  17.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  17.4k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 17.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   403k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 403k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   403k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   403k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   403k|        (idxvar)++;                                 \
  |  |  122|   403k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   403k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 403k]
  |  |  ------------------
  ------------------
  |  Branch (265:9): [True: 403k, False: 0]
  ------------------
  266|       |        // Notify reader that we have new frames.
  267|   403k|        if (q->conn[1])
  ------------------
  |  Branch (267:13): [True: 403k, False: 0]
  ------------------
  268|   403k|            mp_filter_wakeup(q->conn[1]);
  269|   403k|        bool full = is_full(q);
  270|   403k|        if (!full)
  ------------------
  |  Branch (270:13): [True: 399k, False: 3.82k]
  ------------------
  271|   399k|            mp_pin_out_request_data_next(f->ppins[0]);
  272|   403k|        if (p->notify && full)
  ------------------
  |  Branch (272:13): [True: 403k, False: 0]
  |  Branch (272:26): [True: 3.82k, False: 399k]
  ------------------
  273|  3.82k|            mp_filter_wakeup(p->notify);
  274|   403k|    }
  275|   428k|    if (p->notify && !q->num_frames)
  ------------------
  |  Branch (275:9): [True: 428k, False: 0]
  |  Branch (275:22): [True: 20.5k, False: 407k]
  ------------------
  276|  20.5k|        mp_filter_wakeup(p->notify);
  277|   428k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|   428k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  278|   428k|}
f_async_queue.c:reset:
  308|    374|{
  309|    374|    struct priv *p = f->priv;
  310|    374|    struct async_queue *q = p->q;
  311|       |
  312|    374|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|    374|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  313|       |    // If the queue is in reading state, it is logical that it should request
  314|       |    // input immediately.
  315|    374|    if (mp_pin_get_dir(f->pins[0]) == MP_PIN_IN && q->reading)
  ------------------
  |  Branch (315:9): [True: 374, False: 0]
  |  Branch (315:52): [True: 374, False: 0]
  ------------------
  316|    374|        mp_filter_wakeup(f);
  317|    374|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|    374|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  318|    374|}
f_async_queue.c:process_out:
  281|   675k|{
  282|   675k|    struct priv *p = f->priv;
  283|   675k|    struct async_queue *q = p->q;
  284|   675k|    mp_assert(q->conn[1] == f);
  ------------------
  |  |   41|   675k|#define mp_assert assert
  ------------------
  |  Branch (284:5): [True: 675k, False: 0]
  ------------------
  285|       |
  286|   675k|    if (!mp_pin_in_needs_data(f->ppins[0]))
  ------------------
  |  Branch (286:9): [True: 5.23k, False: 670k]
  ------------------
  287|  5.23k|        return;
  288|       |
  289|   670k|    mp_mutex_lock(&q->lock);
  ------------------
  |  |  134|   670k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  290|   670k|    if (q->active && !q->reading) {
  ------------------
  |  Branch (290:9): [True: 670k, False: 0]
  |  Branch (290:22): [True: 0, False: 670k]
  ------------------
  291|      0|        q->reading = true;
  292|      0|        mp_filter_wakeup(q->conn[0]);
  293|      0|    }
  294|   670k|    if (q->active && q->num_frames) {
  ------------------
  |  Branch (294:9): [True: 670k, False: 0]
  |  Branch (294:22): [True: 380k, False: 290k]
  ------------------
  295|   380k|        struct mp_frame frame = q->frames[q->num_frames - 1];
  296|   380k|        q->num_frames -= 1;
  297|   380k|        account_frame(q, frame, -1);
  298|   380k|        mp_assert(q->samples_size >= 0);
  ------------------
  |  |   41|   380k|#define mp_assert assert
  ------------------
  |  Branch (298:9): [True: 380k, False: 0]
  ------------------
  299|   380k|        mp_pin_in_write(f->ppins[0], frame);
  300|       |        // Notify writer that we need new frames.
  301|   380k|        if (q->conn[0])
  ------------------
  |  Branch (301:13): [True: 377k, False: 3.31k]
  ------------------
  302|   377k|            mp_filter_wakeup(q->conn[0]);
  303|   380k|    }
  304|   670k|    mp_mutex_unlock(&q->lock);
  ------------------
  |  |  136|   670k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  305|   670k|}

mp_deint_create:
  211|  19.6k|{
  212|  19.6k|    struct mp_filter *f = mp_filter_create(parent, &deint_filter);
  213|  19.6k|    if (!f)
  ------------------
  |  Branch (213:9): [True: 0, False: 19.6k]
  ------------------
  214|      0|        return NULL;
  215|       |
  216|  19.6k|    struct deint_priv *p = f->priv;
  217|       |
  218|  19.6k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  219|  19.6k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  220|       |
  221|  19.6k|    p->opts = m_config_cache_alloc(f, f->global, &filter_conf);
  222|       |
  223|  19.6k|    return f;
  224|  19.6k|}
mp_autorotate_create:
  337|  19.6k|{
  338|  19.6k|    struct mp_filter *f = mp_filter_create(parent, &rotate_filter);
  339|  19.6k|    if (!f)
  ------------------
  |  Branch (339:9): [True: 0, False: 19.6k]
  ------------------
  340|      0|        return NULL;
  341|       |
  342|  19.6k|    struct rotate_priv *p = f->priv;
  343|  19.6k|    p->prev_rotate = -1;
  344|       |
  345|  19.6k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  346|  19.6k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  347|       |
  348|  19.6k|    return f;
  349|  19.6k|}
mp_autovflip_create:
  458|  19.6k|{
  459|  19.6k|    struct mp_filter *f = mp_filter_create(parent, &vflip_filter);
  460|  19.6k|    if (!f)
  ------------------
  |  Branch (460:9): [True: 0, False: 19.6k]
  ------------------
  461|      0|        return NULL;
  462|       |
  463|  19.6k|    struct vflip_priv *p = f->priv;
  464|  19.6k|    p->prev_vflip = -1;
  465|       |
  466|  19.6k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  467|  19.6k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  468|       |
  469|  19.6k|    return f;
  470|  19.6k|}
mp_autoaspeed_create:
  581|  16.5k|{
  582|  16.5k|    struct mp_filter *f = mp_filter_create(parent, &aspeed_filter);
  583|  16.5k|    if (!f)
  ------------------
  |  Branch (583:9): [True: 0, False: 16.5k]
  ------------------
  584|      0|        return NULL;
  585|       |
  586|  16.5k|    struct aspeed_priv *p = f->priv;
  587|  16.5k|    p->cur_speed = 1.0;
  588|  16.5k|    p->cur_speed_drop = 1.0;
  589|       |
  590|  16.5k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  591|  16.5k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  592|       |
  593|  16.5k|    return f;
  594|  16.5k|}
f_auto_filters.c:deint_destroy:
  176|  19.6k|{
  177|  19.6k|    struct deint_priv *p = f->priv;
  178|       |
  179|  19.6k|    mp_subfilter_reset(&p->sub);
  180|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  19.6k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  19.6k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  181|  19.6k|}
f_auto_filters.c:deint_process:
   30|   296k|{
   31|   296k|    struct deint_priv *p = f->priv;
   32|       |
   33|   296k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (33:9): [True: 157k, False: 139k]
  ------------------
   34|   157k|        return;
   35|       |
   36|   139k|    struct mp_frame frame = p->sub.frame;
   37|       |
   38|   139k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (38:9): [True: 18.4k, False: 120k]
  ------------------
   39|  18.4k|        mp_subfilter_continue(&p->sub);
   40|  18.4k|        return;
   41|  18.4k|    }
   42|       |
   43|   120k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (43:9): [True: 0, False: 120k]
  ------------------
   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|   120k|    struct mp_image *img = frame.data;
   50|   120k|    p->interlaced_frame = img->fields & MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|   120k|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
   51|       |
   52|   120k|    m_config_cache_update(p->opts);
   53|   120k|    struct filter_opts *opts = p->opts->opts;
   54|       |
   55|       |    // Handle deinterlace=0 case by destroying any existing filter immediately.
   56|   120k|    if (!opts->deinterlace)
  ------------------
  |  Branch (56:9): [True: 120k, False: 0]
  ------------------
   57|   120k|        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|   120k|    bool filter_needed = opts->deinterlace == 1 ||
  ------------------
  |  Branch (63:26): [True: 0, False: 120k]
  ------------------
   64|   120k|                         (opts->deinterlace == -1 && (p->interlaced_frame || p->sub.filter));
  ------------------
  |  Branch (64:27): [True: 0, False: 120k]
  |  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|   120k|    if (img->imgfmt != p->prev_imgfmt) {
  ------------------
  |  Branch (69:9): [True: 10.5k, False: 110k]
  ------------------
   70|  10.5k|        mp_subfilter_destroy(&p->sub);
   71|  10.5k|        p->prev_imgfmt = img->imgfmt;
   72|   110k|    } else if (p->sub.filter && !filter_needed) {
  ------------------
  |  Branch (72:16): [True: 0, False: 110k]
  |  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|   120k|    if (!filter_needed || p->sub.filter) {
  ------------------
  |  Branch (79:9): [True: 120k, False: 0]
  |  Branch (79:27): [True: 0, False: 0]
  ------------------
   80|   120k|        mp_subfilter_continue(&p->sub);
   81|   120k|        return;
   82|   120k|    }
   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_reset:
  169|    374|{
  170|    374|    struct deint_priv *p = f->priv;
  171|       |
  172|    374|    mp_subfilter_reset(&p->sub);
  173|    374|}
f_auto_filters.c:deint_command:
  184|   139k|{
  185|   139k|    struct deint_priv *p = f->priv;
  186|       |
  187|   139k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (187:9): [True: 139k, False: 0]
  ------------------
  188|   139k|        cmd->is_active = !!p->sub.filter;
  189|   139k|        return true;
  190|   139k|    }
  191|      0|    return false;
  192|   139k|}
f_auto_filters.c:rotate_destroy:
  309|  19.6k|{
  310|  19.6k|    struct rotate_priv *p = f->priv;
  311|       |
  312|  19.6k|    mp_subfilter_reset(&p->sub);
  313|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  19.6k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  19.6k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  314|  19.6k|}
f_auto_filters.c:rotate_process:
  234|   296k|{
  235|   296k|    struct rotate_priv *p = f->priv;
  236|       |
  237|   296k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (237:9): [True: 157k, False: 139k]
  ------------------
  238|   157k|        return;
  239|       |
  240|   139k|    struct mp_frame frame = p->sub.frame;
  241|       |
  242|   139k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (242:9): [True: 18.4k, False: 120k]
  ------------------
  243|  18.4k|        mp_subfilter_continue(&p->sub);
  244|  18.4k|        return;
  245|  18.4k|    }
  246|       |
  247|   120k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (247:9): [True: 0, False: 120k]
  ------------------
  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|   120k|    struct mp_image *img = frame.data;
  253|       |
  254|   120k|    if (img->params.rotate == p->prev_rotate &&
  ------------------
  |  Branch (254:9): [True: 109k, False: 10.6k]
  ------------------
  255|   109k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (255:9): [True: 109k, False: 1]
  ------------------
  256|   109k|    {
  257|   109k|        img->params.rotate = p->target_rotate;
  258|   109k|        mp_subfilter_continue(&p->sub);
  259|   109k|        return;
  260|   109k|    }
  261|       |
  262|  10.6k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (262:9): [True: 0, False: 10.6k]
  ------------------
  263|      0|        return;
  264|       |
  265|  10.6k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  10.6k|#define mp_assert assert
  ------------------
  |  Branch (265:5): [True: 10.6k, False: 0]
  ------------------
  266|       |
  267|  10.6k|    int rotate = p->prev_rotate = img->params.rotate;
  268|  10.6k|    p->target_rotate = rotate;
  269|  10.6k|    p->prev_imgfmt = img->imgfmt;
  270|       |
  271|  10.6k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  272|  10.6k|    if (rotate == 0 || (info && info->rotate90 && !(rotate % 90))) {
  ------------------
  |  Branch (272:9): [True: 10.6k, False: 60]
  |  Branch (272:25): [True: 60, False: 0]
  |  Branch (272:33): [True: 0, False: 60]
  |  Branch (272:51): [True: 0, False: 0]
  ------------------
  273|  10.6k|        mp_subfilter_continue(&p->sub);
  274|  10.6k|        return;
  275|  10.6k|    }
  276|       |
  277|     60|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (277:9): [True: 0, False: 60]
  ------------------
  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|     60|    double angle = rotate / 360.0 * M_PI * 2;
  284|     60|    char *args[] = {"angle", mp_tprintf(30, "%f", angle),
  ------------------
  |  |  195|     60|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  285|     60|                    "ow", mp_tprintf(30, "rotw(%f)", angle),
  ------------------
  |  |  195|     60|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  286|     60|                    "oh", mp_tprintf(30, "roth(%f)", angle),
  ------------------
  |  |  195|     60|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  287|     60|                    NULL};
  288|     60|    p->sub.filter =
  289|     60|        mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "rotate", args);
  290|       |
  291|     60|    if (p->sub.filter) {
  ------------------
  |  Branch (291:9): [True: 0, False: 60]
  ------------------
  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|     60|    } else {
  295|     60|        MP_ERR(f, "could not create rotation filter\n");
  ------------------
  |  |   89|     60|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     60|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  296|     60|    }
  297|       |
  298|     60|    mp_subfilter_continue(&p->sub);
  299|     60|}
f_auto_filters.c:rotate_reset:
  302|    374|{
  303|    374|    struct rotate_priv *p = f->priv;
  304|       |
  305|    374|    mp_subfilter_reset(&p->sub);
  306|    374|}
f_auto_filters.c:rotate_command:
  317|   139k|{
  318|   139k|    struct rotate_priv *p = f->priv;
  319|       |
  320|   139k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (320:9): [True: 139k, False: 0]
  ------------------
  321|   139k|        cmd->is_active = !!p->sub.filter;
  322|   139k|        return true;
  323|   139k|    }
  324|      0|    return false;
  325|   139k|}
f_auto_filters.c:vflip_destroy:
  430|  19.6k|{
  431|  19.6k|    struct vflip_priv *p = f->priv;
  432|       |
  433|  19.6k|    mp_subfilter_reset(&p->sub);
  434|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  19.6k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  19.6k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  435|  19.6k|}
f_auto_filters.c:vflip_process:
  359|   296k|{
  360|   296k|    struct vflip_priv *p = f->priv;
  361|       |
  362|   296k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (362:9): [True: 157k, False: 139k]
  ------------------
  363|   157k|        return;
  364|       |
  365|   139k|    struct mp_frame frame = p->sub.frame;
  366|       |
  367|   139k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (367:9): [True: 18.4k, False: 120k]
  ------------------
  368|  18.4k|        mp_subfilter_continue(&p->sub);
  369|  18.4k|        return;
  370|  18.4k|    }
  371|       |
  372|   120k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (372:9): [True: 0, False: 120k]
  ------------------
  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|   120k|    struct mp_image *img = frame.data;
  378|       |
  379|   120k|    if (img->params.vflip == p->prev_vflip &&
  ------------------
  |  Branch (379:9): [True: 109k, False: 10.6k]
  ------------------
  380|   109k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (380:9): [True: 109k, False: 1]
  ------------------
  381|   109k|    {
  382|   109k|        img->params.vflip = p->target_vflip;
  383|   109k|        mp_subfilter_continue(&p->sub);
  384|   109k|        return;
  385|   109k|    }
  386|       |
  387|  10.6k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (387:9): [True: 0, False: 10.6k]
  ------------------
  388|      0|        return;
  389|       |
  390|  10.6k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  10.6k|#define mp_assert assert
  ------------------
  |  Branch (390:5): [True: 10.6k, False: 0]
  ------------------
  391|       |
  392|  10.6k|    int vflip = p->prev_vflip = img->params.vflip;
  393|  10.6k|    p->target_vflip = vflip;
  394|  10.6k|    p->prev_imgfmt = img->imgfmt;
  395|       |
  396|  10.6k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  397|  10.6k|    if (!vflip || (info && info->vflip)) {
  ------------------
  |  Branch (397:9): [True: 10.6k, False: 53]
  |  Branch (397:20): [True: 53, False: 0]
  |  Branch (397:28): [True: 0, False: 53]
  ------------------
  398|  10.6k|        mp_subfilter_continue(&p->sub);
  399|  10.6k|        return;
  400|  10.6k|    }
  401|       |
  402|     53|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (402:9): [True: 0, False: 53]
  ------------------
  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|     53|    char *args[] = {NULL};
  409|       |
  410|     53|    p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vflip", args);
  411|       |
  412|     53|    if (p->sub.filter) {
  ------------------
  |  Branch (412:9): [True: 0, False: 53]
  ------------------
  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|     53|    } else {
  416|     53|        MP_ERR(f, "could not create vflip filter\n");
  ------------------
  |  |   89|     53|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     53|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  417|     53|    }
  418|       |
  419|     53|    mp_subfilter_continue(&p->sub);
  420|     53|}
f_auto_filters.c:vflip_reset:
  423|    374|{
  424|    374|    struct vflip_priv *p = f->priv;
  425|       |
  426|    374|    mp_subfilter_reset(&p->sub);
  427|    374|}
f_auto_filters.c:vflip_command:
  438|   139k|{
  439|   139k|    struct vflip_priv *p = f->priv;
  440|       |
  441|   139k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (441:9): [True: 139k, False: 0]
  ------------------
  442|   139k|        cmd->is_active = !!p->sub.filter;
  443|   139k|        return true;
  444|   139k|    }
  445|      0|    return false;
  446|   139k|}
f_auto_filters.c:aspeed_destroy:
  564|  16.5k|{
  565|  16.5k|    struct aspeed_priv *p = f->priv;
  566|       |
  567|  16.5k|    mp_subfilter_reset(&p->sub);
  568|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  16.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  16.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 16.5k]
  |  |  ------------------
  ------------------
  569|  16.5k|}
f_auto_filters.c:aspeed_process:
  479|   885k|{
  480|   885k|    struct aspeed_priv *p = f->priv;
  481|       |
  482|   885k|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (482:9): [True: 449k, False: 435k]
  ------------------
  483|   449k|        return;
  484|       |
  485|   435k|    if (!p->sub.filter)
  ------------------
  |  Branch (485:9): [True: 435k, False: 0]
  ------------------
  486|   435k|        p->current_filter = 0;
  487|       |
  488|   435k|    double speed = p->cur_speed * p->cur_speed_drop;
  489|       |
  490|   435k|    int req_filter = 0;
  491|   435k|    if (fabs(speed - 1.0) >= 1e-8) {
  ------------------
  |  Branch (491:9): [True: 0, False: 435k]
  ------------------
  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|   435k|    if (req_filter != p->current_filter) {
  ------------------
  |  Branch (498:9): [True: 0, False: 435k]
  ------------------
  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|   435k|    if (p->sub.filter) {
  ------------------
  |  Branch (523:9): [True: 0, False: 435k]
  ------------------
  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|   435k|    mp_subfilter_continue(&p->sub);
  532|   435k|}
f_auto_filters.c:aspeed_reset:
  557|    374|{
  558|    374|    struct aspeed_priv *p = f->priv;
  559|       |
  560|    374|    mp_subfilter_reset(&p->sub);
  561|    374|}
f_auto_filters.c:aspeed_command:
  535|   476k|{
  536|   476k|    struct aspeed_priv *p = f->priv;
  537|       |
  538|   476k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED) {
  ------------------
  |  Branch (538:9): [True: 13.7k, False: 463k]
  ------------------
  539|  13.7k|        p->cur_speed = cmd->speed;
  540|  13.7k|        return true;
  541|  13.7k|    }
  542|       |
  543|   463k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_DROP) {
  ------------------
  |  Branch (543:9): [True: 13.7k, False: 449k]
  ------------------
  544|  13.7k|        p->cur_speed_drop = cmd->speed;
  545|  13.7k|        return true;
  546|  13.7k|    }
  547|       |
  548|   449k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (548:9): [True: 435k, False: 13.7k]
  ------------------
  549|   435k|        cmd->is_active = !!p->sub.filter;
  550|   435k|        return true;
  551|   435k|    }
  552|       |
  553|  13.7k|    return false;
  554|   449k|}

mp_autoconvert_clear:
   61|  56.8k|{
   62|  56.8k|    struct priv *p = c->f->priv;
   63|       |
   64|  56.8k|    p->num_imgfmts = 0;
   65|  56.8k|    p->imgparams_set = false;
   66|  56.8k|    p->num_afmts = 0;
   67|  56.8k|    p->num_srates = 0;
   68|  56.8k|    p->chmaps = (struct mp_chmap_sel){0};
   69|       |    p->force_update = true;
   70|  56.8k|}
mp_autoconvert_add_imgfmt:
   73|  27.2M|{
   74|  27.2M|    struct priv *p = c->f->priv;
   75|       |
   76|  27.2M|    MP_TARRAY_GROW(p, p->imgfmts, p->num_imgfmts);
  ------------------
  |  |   96|  27.2M|    do {                                            \
  |  |   97|  27.2M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  27.2M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  27.2M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  27.2M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 177k, False: 27.0M]
  |  |  ------------------
  |  |   99|  27.2M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   177k|    do {                                                        \
  |  |  |  |   89|   177k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   177k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   177k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   177k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   177k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   177k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   177k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 177k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  27.2M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 27.2M]
  |  |  ------------------
  ------------------
   77|  27.2M|    MP_TARRAY_GROW(p, p->subfmts, p->num_imgfmts);
  ------------------
  |  |   96|  27.2M|    do {                                            \
  |  |   97|  27.2M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  27.2M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  27.2M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  27.2M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 177k, False: 27.0M]
  |  |  ------------------
  |  |   99|  27.2M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   177k|    do {                                                        \
  |  |  |  |   89|   177k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   177k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   177k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   177k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   177k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   177k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   177k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 177k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  27.2M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 27.2M]
  |  |  ------------------
  ------------------
   78|       |
   79|  27.2M|    p->imgfmts[p->num_imgfmts] = imgfmt;
   80|  27.2M|    p->subfmts[p->num_imgfmts] = subfmt;
   81|       |
   82|  27.2M|    p->num_imgfmts += 1;
   83|       |    p->force_update = true;
   84|  27.2M|}
mp_autoconvert_add_afmt:
  112|  8.07k|{
  113|  8.07k|    struct priv *p = c->f->priv;
  114|       |
  115|  8.07k|    MP_TARRAY_APPEND(p, p->afmts, p->num_afmts, afmt);
  ------------------
  |  |  105|  8.07k|    do {                                            \
  |  |  106|  8.07k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  8.07k|    do {                                            \
  |  |  |  |   97|  8.07k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  8.07k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  8.07k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  8.07k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.63k, False: 1.43k]
  |  |  |  |  ------------------
  |  |  |  |   99|  8.07k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.63k|    do {                                                        \
  |  |  |  |  |  |   89|  6.63k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.63k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.63k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.63k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.63k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.63k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.63k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.63k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  8.07k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 8.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  8.07k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  8.07k|        (idxvar)++;                                 \
  |  |  109|  8.07k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.07k]
  |  |  ------------------
  ------------------
  116|       |    p->force_update = true;
  117|  8.07k|}
mp_autoconvert_add_chmap:
  120|  8.07k|{
  121|  8.07k|    struct priv *p = c->f->priv;
  122|       |
  123|  8.07k|    mp_chmap_sel_add_map(&p->chmaps, chmap);
  124|       |    p->force_update = true;
  125|  8.07k|}
mp_autoconvert_add_srate:
  128|  8.07k|{
  129|  8.07k|    struct priv *p = c->f->priv;
  130|       |
  131|  8.07k|    MP_TARRAY_APPEND(p, p->srates, p->num_srates, rate);
  ------------------
  |  |  105|  8.07k|    do {                                            \
  |  |  106|  8.07k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  8.07k|    do {                                            \
  |  |  |  |   97|  8.07k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  8.07k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  8.07k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  8.07k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.63k, False: 1.43k]
  |  |  |  |  ------------------
  |  |  |  |   99|  8.07k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.63k|    do {                                                        \
  |  |  |  |  |  |   89|  6.63k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.63k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.63k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.63k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.63k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.63k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.63k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.63k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  8.07k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 8.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  8.07k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  8.07k|        (idxvar)++;                                 \
  |  |  109|  8.07k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.07k]
  |  |  ------------------
  ------------------
  132|       |    // Some other API we call expects a 0-terminated sample rates array.
  133|  8.07k|    MP_TARRAY_GROW(p, p->srates, p->num_srates);
  ------------------
  |  |   96|  8.07k|    do {                                            \
  |  |   97|  8.07k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  8.07k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  8.07k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  8.07k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 8.07k]
  |  |  ------------------
  |  |   99|  8.07k|            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|  8.07k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 8.07k]
  |  |  ------------------
  ------------------
  134|  8.07k|    p->srates[p->num_srates] = 0;
  135|       |    p->force_update = true;
  136|  8.07k|}
mp_autoconvert_format_change_continue:
  507|  8.07k|{
  508|  8.07k|    struct priv *p = c->f->priv;
  509|       |
  510|  8.07k|    if (p->format_change_blocked) {
  ------------------
  |  Branch (510:9): [True: 8.07k, False: 0]
  ------------------
  511|  8.07k|        p->format_change_cont = true;
  512|       |        p->format_change_blocked = false;
  513|  8.07k|        mp_filter_wakeup(c->f);
  514|  8.07k|    }
  515|  8.07k|}
mp_autoconvert_create:
  566|  36.2k|{
  567|  36.2k|    struct mp_filter *f = mp_filter_create(parent, &autoconvert_filter);
  568|  36.2k|    if (!f)
  ------------------
  |  Branch (568:9): [True: 0, False: 36.2k]
  ------------------
  569|      0|        return NULL;
  570|       |
  571|  36.2k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  572|  36.2k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  573|       |
  574|  36.2k|    struct priv *p = f->priv;
  575|  36.2k|    p->public.f = f;
  576|  36.2k|    p->log = f->log;
  577|  36.2k|    p->audio_speed = 1.0;
  578|  36.2k|    p->sub.in = f->ppins[0];
  579|  36.2k|    p->sub.out = f->ppins[1];
  580|       |
  581|  36.2k|    return &p->public;
  582|  36.2k|}
f_autoconvert.c:build_image_converter:
  141|  10.7k|{
  142|  10.7k|    struct mp_filter *f = c->f;
  143|  10.7k|    struct priv *p = f->priv;
  144|       |
  145|  10.7k|    *f_out = NULL;
  146|       |
  147|  10.7k|    if (!p->num_imgfmts)
  ------------------
  |  Branch (147:9): [True: 0, False: 10.7k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  85.2k|    for (int n = 0; n < p->num_imgfmts; n++) {
  ------------------
  |  Branch (150:21): [True: 85.2k, False: 0]
  ------------------
  151|  85.2k|        bool samefmt = img->params.imgfmt == p->imgfmts[n];
  152|  85.2k|        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|  85.2k|        if (samefmt && samesubffmt) {
  ------------------
  |  Branch (158:13): [True: 10.7k, False: 74.4k]
  |  Branch (158:24): [True: 10.7k, False: 0]
  ------------------
  159|  10.7k|            if (p->imgparams_set) {
  ------------------
  |  Branch (159:17): [True: 0, False: 10.7k]
  ------------------
  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|  10.7k|            return true;
  164|  10.7k|        }
  165|  85.2k|    }
  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|  36.2k|{
  550|  36.2k|    struct priv *p = f->priv;
  551|       |
  552|  36.2k|    mp_subfilter_reset(&p->sub);
  553|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  36.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  36.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 36.2k]
  |  |  ------------------
  ------------------
  554|  36.2k|}
f_autoconvert.c:autoconvert_process:
  487|  1.18M|{
  488|  1.18M|    struct priv *p = f->priv;
  489|       |
  490|  1.18M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (490:9): [True: 606k, False: 582k]
  ------------------
  491|   606k|        return;
  492|       |
  493|   582k|    if (p->sub.frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (493:9): [True: 120k, False: 462k]
  ------------------
  494|   120k|        handle_video_frame(f);
  495|   120k|        return;
  496|   120k|    }
  497|       |
  498|   462k|    if (p->sub.frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (498:9): [True: 429k, False: 32.2k]
  ------------------
  499|   429k|        handle_audio_frame(f);
  500|   429k|        return;
  501|   429k|    }
  502|       |
  503|  32.2k|    mp_subfilter_continue(&p->sub);
  504|  32.2k|}
f_autoconvert.c:handle_video_frame:
  350|   120k|{
  351|   120k|    struct priv *p = f->priv;
  352|       |
  353|   120k|    struct mp_image *img = p->sub.frame.data;
  354|       |
  355|   120k|    if (p->force_update)
  ------------------
  |  Branch (355:9): [True: 10.7k, False: 109k]
  ------------------
  356|  10.7k|        p->in_imgfmt = p->in_subfmt = 0;
  357|       |
  358|   120k|    if (img->imgfmt == p->in_imgfmt && img->params.hw_subfmt == p->in_subfmt) {
  ------------------
  |  Branch (358:9): [True: 109k, False: 10.7k]
  |  Branch (358:40): [True: 109k, False: 0]
  ------------------
  359|   109k|        mp_subfilter_continue(&p->sub);
  360|   109k|        return;
  361|   109k|    }
  362|       |
  363|  10.7k|    if (!mp_subfilter_drain_destroy(&p->sub)) {
  ------------------
  |  Branch (363:9): [True: 0, False: 10.7k]
  ------------------
  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|  10.7k|    p->in_imgfmt = img->params.imgfmt;
  369|  10.7k|    p->in_subfmt = img->params.hw_subfmt;
  370|  10.7k|    p->force_update = false;
  371|       |
  372|  10.7k|    struct mp_filter *conv = NULL;
  373|  10.7k|    if (build_image_converter(&p->public, p->log, img, &conv)) {
  ------------------
  |  Branch (373:9): [True: 10.7k, False: 0]
  ------------------
  374|  10.7k|        p->sub.filter = conv;
  375|  10.7k|        mp_subfilter_continue(&p->sub);
  376|  10.7k|    } else {
  377|      0|        mp_filter_internal_mark_failed(f);
  378|      0|    }
  379|  10.7k|}
f_autoconvert.c:handle_audio_frame:
  382|   429k|{
  383|   429k|    struct priv *p = f->priv;
  384|       |
  385|   429k|    struct mp_aframe *aframe = p->sub.frame.data;
  386|       |
  387|   429k|    int afmt = mp_aframe_get_format(aframe);
  388|   429k|    int srate = mp_aframe_get_rate(aframe);
  389|   429k|    struct mp_chmap chmap = {0};
  390|   429k|    mp_aframe_get_chmap(aframe, &chmap);
  391|       |
  392|   429k|    if (p->resampling_forced && !af_fmt_is_pcm(afmt)) {
  ------------------
  |  Branch (392:9): [True: 0, False: 429k]
  |  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|   429k|    bool format_change = afmt != p->in_afmt ||
  ------------------
  |  Branch (397:26): [True: 13.2k, False: 416k]
  ------------------
  398|   416k|                         srate != p->in_srate ||
  ------------------
  |  Branch (398:26): [True: 633, False: 415k]
  ------------------
  399|   415k|                         !mp_chmap_equals(&chmap, &p->in_chmap) ||
  ------------------
  |  Branch (399:26): [True: 2.17k, False: 413k]
  ------------------
  400|   413k|                         p->force_update;
  ------------------
  |  Branch (400:26): [True: 92, False: 413k]
  ------------------
  401|       |
  402|   429k|    if (!format_change && (!p->resampling_forced || p->sub.filter))
  ------------------
  |  Branch (402:9): [True: 413k, False: 16.1k]
  |  Branch (402:28): [True: 413k, False: 0]
  |  Branch (402:53): [True: 0, False: 0]
  ------------------
  403|   413k|        goto cont;
  404|       |
  405|  16.1k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (405:9): [True: 0, False: 16.1k]
  ------------------
  406|      0|        return;
  407|       |
  408|  16.1k|    if (format_change && p->public.on_audio_format_change) {
  ------------------
  |  Branch (408:9): [True: 16.1k, False: 0]
  |  Branch (408:26): [True: 16.1k, False: 0]
  ------------------
  409|  16.1k|        if (p->format_change_blocked)
  ------------------
  |  Branch (409:13): [True: 0, False: 16.1k]
  ------------------
  410|      0|            return;
  411|       |
  412|  16.1k|        if (!p->format_change_cont) {
  ------------------
  |  Branch (412:13): [True: 8.18k, False: 7.99k]
  ------------------
  413|  8.18k|            p->format_change_blocked = true;
  414|  8.18k|            p->public.
  415|  8.18k|                on_audio_format_change(p->public.on_audio_format_change_opaque);
  416|  8.18k|            return;
  417|  8.18k|        }
  418|  7.99k|        p->format_change_cont = false;
  419|  7.99k|    }
  420|       |
  421|  7.99k|    p->in_afmt = afmt;
  422|  7.99k|    p->in_srate = srate;
  423|  7.99k|    p->in_chmap = chmap;
  424|  7.99k|    p->force_update = false;
  425|       |
  426|  7.99k|    int out_afmt = 0;
  427|  7.99k|    int best_score = 0;
  428|  15.9k|    for (int n = 0; n < p->num_afmts; n++) {
  ------------------
  |  Branch (428:21): [True: 7.99k, False: 7.99k]
  ------------------
  429|  7.99k|        int score = af_format_conversion_score(p->afmts[n], afmt);
  430|  7.99k|        if (!out_afmt || score > best_score) {
  ------------------
  |  Branch (430:13): [True: 7.99k, False: 0]
  |  Branch (430:26): [True: 0, False: 0]
  ------------------
  431|  7.99k|            best_score = score;
  432|  7.99k|            out_afmt = p->afmts[n];
  433|  7.99k|        }
  434|  7.99k|    }
  435|  7.99k|    if (!out_afmt)
  ------------------
  |  Branch (435:9): [True: 0, False: 7.99k]
  ------------------
  436|      0|        out_afmt = afmt;
  437|       |
  438|       |    // Raw DSD can only be converted to PCM, not resampled.
  439|  7.99k|    if (p->resampling_forced && out_afmt == AF_FORMAT_DSD) {
  ------------------
  |  Branch (439:9): [True: 0, False: 7.99k]
  |  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.99k|    int out_srate = af_select_best_samplerate(srate, p->srates);
  446|  7.99k|    if (out_srate <= 0)
  ------------------
  |  Branch (446:9): [True: 0, False: 7.99k]
  ------------------
  447|      0|        out_srate = p->num_srates ? p->srates[0] : srate;
  ------------------
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|       |
  449|  7.99k|    struct mp_chmap out_chmap = chmap;
  450|  7.99k|    if (p->chmaps.num_chmaps) {
  ------------------
  |  Branch (450:9): [True: 7.99k, False: 0]
  ------------------
  451|  7.99k|        if (!mp_chmap_sel_adjust(&p->chmaps, &out_chmap))
  ------------------
  |  Branch (451:13): [True: 0, False: 7.99k]
  ------------------
  452|      0|            out_chmap = p->chmaps.chmaps[0]; // violently force fallback
  453|  7.99k|    }
  454|       |
  455|  7.99k|    if (out_afmt == p->in_afmt && out_srate == p->in_srate &&
  ------------------
  |  Branch (455:9): [True: 7.99k, False: 0]
  |  Branch (455:35): [True: 7.99k, False: 0]
  ------------------
  456|  7.99k|        mp_chmap_equals(&out_chmap, &p->in_chmap) && !p->resampling_forced)
  ------------------
  |  Branch (456:9): [True: 7.99k, False: 0]
  |  Branch (456:54): [True: 7.99k, False: 0]
  ------------------
  457|  7.99k|    {
  458|  7.99k|        goto cont;
  459|  7.99k|    }
  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|   421k|cont:
  474|       |
  475|   421k|    if (p->sub.filter) {
  ------------------
  |  Branch (475:9): [True: 0, False: 421k]
  ------------------
  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|   421k|    mp_subfilter_continue(&p->sub);
  484|   421k|}
f_autoconvert.c:autoconvert_reset:
  539|    748|{
  540|    748|    struct priv *p = f->priv;
  541|       |
  542|    748|    mp_subfilter_reset(&p->sub);
  543|       |
  544|    748|    p->format_change_cont = false;
  545|       |    p->format_change_blocked = false;
  546|    748|}
f_autoconvert.c:autoconvert_command:
  518|   615k|{
  519|   615k|    struct priv *p = f->priv;
  520|       |
  521|   615k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_RESAMPLE) {
  ------------------
  |  Branch (521:9): [True: 13.7k, False: 602k]
  ------------------
  522|  13.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|  13.7k|        if (p->audio_speed != 1.0)
  ------------------
  |  Branch (525:13): [True: 0, False: 13.7k]
  ------------------
  526|      0|            p->resampling_forced = true;
  527|  13.7k|        return true;
  528|  13.7k|    }
  529|       |
  530|   602k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (530:9): [True: 574k, False: 27.4k]
  ------------------
  531|   574k|        cmd->is_active = !!p->sub.filter;
  532|   574k|        return true;
  533|   574k|    }
  534|       |
  535|  27.4k|    return false;
  536|   602k|}

mp_decoder_wrapper_control:
  363|  33.1k|{
  364|  33.1k|    struct priv *p = d->f->priv;
  365|  33.1k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  33.1k|#define CONTROL_UNKNOWN -1
  ------------------
  366|  33.1k|    if (p->is_group) {
  ------------------
  |  Branch (366:9): [True: 0, False: 33.1k]
  ------------------
  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|  33.1k|    thread_lock(p);
  379|  33.1k|    if (cmd == VDCTRL_GET_HWDEC) {
  ------------------
  |  Branch (379:9): [True: 0, False: 33.1k]
  ------------------
  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|  33.1k|    } else {
  385|  33.1k|        if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (385:13): [True: 33.1k, False: 0]
  |  Branch (385:27): [True: 33.1k, False: 0]
  ------------------
  386|  33.1k|            res = p->decoder->control(p->decoder->f, cmd, arg);
  387|  33.1k|        update_cached_values(p);
  388|  33.1k|    }
  389|  33.1k|    thread_unlock(p);
  390|  33.1k|    return res;
  391|  33.1k|}
mp_decoder_wrapper_reinit:
  532|  36.2k|{
  533|  36.2k|    struct priv *p = d->f->priv;
  534|  36.2k|    if (p->is_group) {
  ------------------
  |  Branch (534:9): [True: 0, False: 36.2k]
  ------------------
  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|  36.2k|    thread_lock(p);
  542|       |    bool res = reinit_decoder(p);
  543|  36.2k|    thread_unlock(p);
  544|  36.2k|    return res;
  545|  36.2k|}
mp_decoder_wrapper_get_container_fps:
  578|  18.3k|{
  579|  18.3k|    struct priv *p = d->f->priv;
  580|  18.3k|    thread_lock(p);
  581|  18.3k|    double res = p->fps;
  582|  18.3k|    thread_unlock(p);
  583|  18.3k|    return res;
  584|  18.3k|}
mp_decoder_wrapper_set_spdif_flag:
  587|  16.5k|{
  588|  16.5k|    struct priv *p = d->f->priv;
  589|  16.5k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  16.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  590|  16.5k|    p->try_spdif = spdif;
  591|  16.5k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  16.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  592|  16.5k|}
mp_decoder_wrapper_set_coverart_flag:
  595|    284|{
  596|    284|    struct priv *p = d->f->priv;
  597|    284|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|    284|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  598|    284|    p->attached_picture = c;
  599|    284|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|    284|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  600|    284|}
mp_decoder_wrapper_get_pts_reset:
  603|  98.3k|{
  604|  98.3k|    struct priv *p = d->f->priv;
  605|  98.3k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  98.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  606|  98.3k|    bool res = p->pts_reset;
  607|  98.3k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  98.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  608|  98.3k|    return res;
  609|  98.3k|}
mp_decoder_wrapper_set_play_dir:
  612|  53.2k|{
  613|  53.2k|    struct priv *p = d->f->priv;
  614|  53.2k|    if (p->is_group) {
  ------------------
  |  Branch (614:9): [True: 0, False: 53.2k]
  ------------------
  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|  53.2k|    thread_lock(p);
  621|  53.2k|    p->play_dir = dir;
  622|  53.2k|    thread_unlock(p);
  623|  53.2k|}
mp_decoder_wrapper_create:
 1378|  36.2k|{
 1379|  36.2k|    struct mp_filter *public_f = mp_filter_create(parent, &decode_wrapper_filter);
 1380|  36.2k|    if (!public_f)
  ------------------
  |  Branch (1380:9): [True: 0, False: 36.2k]
  ------------------
 1381|      0|        return NULL;
 1382|       |
 1383|  36.2k|    struct priv *p = public_f->priv;
 1384|  36.2k|    p->public.f = public_f;
 1385|       |
 1386|  36.2k|    mp_mutex_init(&p->cache_lock);
 1387|  36.2k|    p->opt_cache = m_config_cache_alloc(p, public_f->global, &dec_wrapper_conf);
 1388|  36.2k|    p->opts = p->opt_cache->opts;
 1389|  36.2k|    p->header = src;
 1390|  36.2k|    p->codec = p->header->codec;
 1391|  36.2k|    p->play_dir = 1;
 1392|  36.2k|    mp_filter_add_pin(public_f, MP_PIN_OUT, "out");
 1393|       |
 1394|  36.2k|    if (src->group && src->group->lavfi_graph) {
  ------------------
  |  Branch (1394:9): [True: 0, False: 36.2k]
  |  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|  36.2k|    if (p->header->type == STREAM_VIDEO) {
  ------------------
  |  Branch (1404:9): [True: 19.6k, False: 16.5k]
  ------------------
 1405|  19.6k|        p->log = mp_log_new(p, parent->global->log, "!vd");
 1406|       |
 1407|  19.6k|        p->fps = src->codec->fps;
 1408|       |
 1409|  19.6k|        MP_VERBOSE(p, "Container reported FPS: %f\n", p->fps);
  ------------------
  |  |   92|  19.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1410|       |
 1411|  19.6k|        if (p->opts->fps_override) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 19.6k]
  ------------------
 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|  19.6k|        p->queue_opts = p->opts->vdec_queue_opts;
 1418|  19.6k|    } else if (p->header->type == STREAM_AUDIO) {
  ------------------
  |  Branch (1418:16): [True: 16.5k, False: 0]
  ------------------
 1419|  16.5k|        p->log = mp_log_new(p, parent->global->log, "!ad");
 1420|  16.5k|        p->queue_opts = p->opts->adec_queue_opts;
 1421|  16.5k|    } else {
 1422|      0|        goto error;
 1423|      0|    }
 1424|       |
 1425|  36.2k|    if (p->queue_opts && p->queue_opts->use_queue) {
  ------------------
  |  Branch (1425:9): [True: 36.2k, False: 0]
  |  Branch (1425:26): [True: 0, False: 36.2k]
  ------------------
 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|  36.2k|    p->decf = mp_filter_create(p->dec_root_filter ? p->dec_root_filter : public_f,
  ------------------
  |  Branch (1444:32): [True: 0, False: 36.2k]
  ------------------
 1445|  36.2k|                               &decf_filter);
 1446|  36.2k|    if (!p->decf)
  ------------------
  |  Branch (1446:9): [True: 0, False: 36.2k]
  ------------------
 1447|      0|        goto error;
 1448|  36.2k|    p->decf->priv = p;
 1449|  36.2k|    p->decf->log = public_f->log = p->log;
 1450|  36.2k|    mp_filter_add_pin(p->decf, MP_PIN_OUT, "out");
 1451|       |
 1452|  36.2k|    struct mp_filter *demux = mp_demux_in_create(p->decf, p->header);
 1453|  36.2k|    if (!demux)
  ------------------
  |  Branch (1453:9): [True: 0, False: 36.2k]
  ------------------
 1454|      0|        goto error;
 1455|  36.2k|    p->demux = demux->pins[0];
 1456|       |
 1457|  36.2k|    decf_reset(p->decf);
 1458|       |
 1459|  36.2k|    struct mp_pin *out_pin;
 1460|  36.2k|    if (p->queue) {
  ------------------
  |  Branch (1460:9): [True: 0, False: 36.2k]
  ------------------
 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|  36.2k|    } else {
 1474|  36.2k|        out_pin = p->decf->pins[0];
 1475|  36.2k|    }
 1476|       |
 1477|  36.2k|    mp_pin_connect(public_f->ppins[0], out_pin);
 1478|       |
 1479|  36.2k|    public_f_reset(public_f);
 1480|       |
 1481|  36.2k|    return &p->public;
 1482|      0|error:
 1483|      0|    talloc_free(public_f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1484|       |    return NULL;
 1485|  36.2k|}
lavc_process:
 1490|  2.19M|{
 1491|  2.19M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (1491:9): [True: 32.0k, False: 2.15M]
  ------------------
 1492|  32.0k|        return;
 1493|       |
 1494|  2.15M|    struct mp_frame frame = {0};
 1495|  2.15M|    int ret_recv = receive(f, &frame);
 1496|  2.15M|    if (frame.type) {
  ------------------
  |  Branch (1496:9): [True: 543k, False: 1.61M]
  ------------------
 1497|   543k|        state->eof_returned = false;
 1498|   543k|        mp_pin_in_write(f->ppins[1], frame);
 1499|  1.61M|    } else if (ret_recv == AVERROR_EOF) {
  ------------------
  |  Branch (1499:16): [True: 25.1k, False: 1.59M]
  ------------------
 1500|  25.1k|        if (!state->eof_returned)
  ------------------
  |  Branch (1500:13): [True: 25.1k, False: 0]
  ------------------
 1501|  25.1k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  25.1k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  25.1k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1502|  25.1k|        state->eof_returned = true;
 1503|  25.1k|        state->packets_sent = false;
 1504|  1.59M|    } else if (ret_recv == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1504:16): [True: 1.55M, False: 38.2k]
  ------------------
 1505|       |        // Need to feed a packet.
 1506|  1.55M|        frame = mp_pin_out_read(f->ppins[0]);
 1507|  1.55M|        struct demux_packet *pkt = NULL;
 1508|  1.55M|        if (frame.type == MP_FRAME_PACKET) {
  ------------------
  |  Branch (1508:13): [True: 743k, False: 808k]
  ------------------
 1509|   743k|            pkt = frame.data;
 1510|   808k|        } else if (frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1510:20): [True: 775k, False: 32.6k]
  ------------------
 1511|   775k|            if (frame.type) {
  ------------------
  |  Branch (1511:17): [True: 0, False: 775k]
  ------------------
 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|   775k|            return;
 1517|   775k|        } else if (!state->packets_sent) {
  ------------------
  |  Branch (1517:20): [True: 7.41k, False: 25.1k]
  ------------------
 1518|       |            // EOF only; just return it, without requiring send/receive to
 1519|       |            // pass it through properly.
 1520|  7.41k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  7.41k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  7.41k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1521|  7.41k|            return;
 1522|  7.41k|        }
 1523|   768k|        int ret_send = send(f, pkt);
 1524|   768k|        if (ret_send == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1524:13): [True: 0, False: 768k]
  ------------------
 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|   768k|        state->packets_sent = true;
 1532|   768k|        demux_packet_pool_push(f->packet_pool, pkt);
 1533|   768k|        mp_filter_internal_mark_progress(f);
 1534|   768k|    } else {
 1535|       |        // Decoding error, or hwdec fallback recovery. Just try again.
 1536|  38.2k|        mp_filter_internal_mark_progress(f);
 1537|  38.2k|    }
 1538|  2.15M|}
f_decoder_wrapper.c:thread_lock:
  292|   140k|{
  293|   140k|    if (p->dec_dispatch)
  ------------------
  |  Branch (293:9): [True: 0, False: 140k]
  ------------------
  294|      0|        mp_dispatch_lock(p->dec_dispatch);
  295|       |
  296|   140k|    mp_assert(!p->dec_thread_lock);
  ------------------
  |  |   41|   140k|#define mp_assert assert
  ------------------
  |  Branch (296:5): [True: 140k, False: 0]
  ------------------
  297|   140k|    p->dec_thread_lock = true;
  298|   140k|}
f_decoder_wrapper.c:update_cached_values:
  275|  69.4k|{
  276|  69.4k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  69.4k|#define CONTROL_UNKNOWN -1
  ------------------
  277|  69.4k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  69.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  278|       |
  279|  69.4k|    p->cur_hwdec = NULL;
  280|  69.4k|    if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (280:9): [True: 65.1k, False: 4.21k]
  |  Branch (280:23): [True: 51.4k, False: 13.7k]
  ------------------
  281|  51.4k|        res = p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
  282|       |
  283|  69.4k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  69.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  284|  69.4k|    return res;
  285|  69.4k|}
f_decoder_wrapper.c:thread_unlock:
  302|   140k|{
  303|   140k|    mp_assert(p->dec_thread_lock);
  ------------------
  |  |   41|   140k|#define mp_assert assert
  ------------------
  |  Branch (303:5): [True: 140k, False: 0]
  ------------------
  304|   140k|    p->dec_thread_lock = false;
  305|       |
  306|   140k|    if (p->dec_dispatch)
  ------------------
  |  Branch (306:9): [True: 0, False: 140k]
  ------------------
  307|      0|        mp_dispatch_unlock(p->dec_dispatch);
  308|   140k|}
f_decoder_wrapper.c:reinit_decoder:
  425|  36.2k|{
  426|  36.2k|    if (p->decoder)
  ------------------
  |  Branch (426:9): [True: 0, False: 36.2k]
  ------------------
  427|      0|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  428|  36.2k|    p->decoder = NULL;
  429|       |
  430|  36.2k|    reset_decoder(p);
  431|  36.2k|    p->has_broken_packet_pts = -10; // needs 10 packets to reach decision
  432|       |
  433|  36.2k|    const struct mp_decoder_fns *driver = NULL;
  434|  36.2k|    struct mp_decoder_list *list = NULL;
  435|  36.2k|    char *user_list = NULL;
  436|  36.2k|    char *fallback = NULL;
  437|       |
  438|  36.2k|    if (p->codec->type == STREAM_VIDEO) {
  ------------------
  |  Branch (438:9): [True: 19.6k, False: 16.5k]
  ------------------
  439|  19.6k|        driver = &vd_lavc;
  440|  19.6k|        user_list = p->opts->video_decoders;
  441|  19.6k|        fallback = "h264";
  442|  19.6k|    } else if (p->codec->type == STREAM_AUDIO) {
  ------------------
  |  Branch (442:16): [True: 16.5k, False: 0]
  ------------------
  443|  16.5k|        driver = &ad_lavc;
  444|  16.5k|        user_list = p->opts->audio_decoders;
  445|  16.5k|        fallback = "aac";
  446|       |
  447|  16.5k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  16.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  448|  16.5k|        bool try_spdif = p->try_spdif;
  449|  16.5k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  16.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  450|       |
  451|  16.5k|        if (try_spdif && p->codec->codec) {
  ------------------
  |  Branch (451:13): [True: 16.5k, False: 0]
  |  Branch (451:26): [True: 16.5k, False: 0]
  ------------------
  452|  16.5k|            struct mp_decoder_list *spdif =
  453|  16.5k|                select_spdif_codec(p->codec->codec, p->opts->audio_spdif);
  454|  16.5k|            if (spdif->num_entries) {
  ------------------
  |  Branch (454:17): [True: 0, False: 16.5k]
  ------------------
  455|      0|                driver = &ad_spdif;
  456|      0|                list = spdif;
  457|  16.5k|            } else {
  458|  16.5k|                talloc_free(spdif);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  459|  16.5k|                struct mp_decoder_list *dsd =
  460|  16.5k|                    select_dsd_codec(p->codec->codec, p->opts->audio_spdif);
  461|  16.5k|                if (dsd->num_entries) {
  ------------------
  |  Branch (461:21): [True: 0, False: 16.5k]
  ------------------
  462|      0|                    driver = &ad_dsd;
  463|      0|                    list = dsd;
  464|  16.5k|                } else {
  465|  16.5k|                    talloc_free(dsd);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  466|  16.5k|                }
  467|  16.5k|            }
  468|  16.5k|        }
  469|  16.5k|    }
  470|       |
  471|  36.2k|    if (!driver)
  ------------------
  |  Branch (471:9): [True: 0, False: 36.2k]
  ------------------
  472|      0|        return false;
  473|       |
  474|  36.2k|    if (!list) {
  ------------------
  |  Branch (474:9): [True: 36.2k, False: 0]
  ------------------
  475|  36.2k|        struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  36.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  36.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  36.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|  36.2k|        driver->add_decoders(full);
  477|  36.2k|        const char *codec = p->codec->codec;
  478|  36.2k|        if (codec && strcmp(codec, "null") == 0)
  ------------------
  |  Branch (478:13): [True: 36.2k, False: 0]
  |  Branch (478:22): [True: 0, False: 36.2k]
  ------------------
  479|      0|            codec = fallback;
  480|  36.2k|        list = mp_select_decoders(p->log, full, codec, user_list);
  481|  36.2k|        talloc_free(full);
  ------------------
  |  |   47|  36.2k|#define talloc_free                     ta_free
  ------------------
  482|  36.2k|    }
  483|       |
  484|  36.2k|    mp_print_decoders(p->log, MSGL_V, "Codec list:", list);
  485|       |
  486|  38.2k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (486:21): [True: 34.0k, False: 4.21k]
  ------------------
  487|  34.0k|        struct mp_decoder_entry *sel = &list->entries[n];
  488|  34.0k|        MP_VERBOSE(p, "Opening decoder %s\n", sel->decoder);
  ------------------
  |  |   92|  34.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  34.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|       |
  490|  34.0k|        p->decoder = driver->create(p->decf, p->codec, sel->decoder);
  491|  34.0k|        if (p->decoder) {
  ------------------
  |  Branch (491:13): [True: 32.0k, False: 1.97k]
  ------------------
  492|  32.0k|            p->codec->decoder = talloc_strdup(p->codec, sel->decoder);
  ------------------
  |  |   50|  32.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  493|  32.0k|            p->codec->decoder_desc = talloc_strdup(p->codec, sel->desc && sel->desc[0] ? sel->desc : NULL);
  ------------------
  |  |   50|  32.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (493:62): [True: 32.0k, False: 0]
  |  Branch (493:75): [True: 32.0k, False: 0]
  ------------------
  494|  32.0k|            MP_VERBOSE(p, "Selected decoder: %s", sel->decoder);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  495|  32.0k|            if (p->codec->decoder_desc)
  ------------------
  |  Branch (495:17): [True: 32.0k, False: 0]
  ------------------
  496|  32.0k|                MP_VERBOSE(p, " - %s", p->codec->decoder_desc);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  497|  32.0k|            MP_VERBOSE(p, "\n");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  498|  32.0k|            break;
  499|  32.0k|        }
  500|       |
  501|  1.97k|        MP_WARN(p, "Decoder init failed for %s\n", sel->decoder);
  ------------------
  |  |   90|  1.97k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.97k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  502|  1.97k|    }
  503|       |
  504|  36.2k|    if (!p->decoder) {
  ------------------
  |  Branch (504:9): [True: 4.21k, False: 32.0k]
  ------------------
  505|  4.21k|        MP_ERR(p, "Failed to initialize a decoder for codec '%s'.\n",
  ------------------
  |  |   89|  4.21k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.42k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 4.21k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|  4.21k|               p->codec->codec ? p->codec->codec : "<?>");
  507|  4.21k|    }
  508|       |
  509|  36.2k|    if (p->decoder && p->decoder->control) {
  ------------------
  |  Branch (509:9): [True: 32.0k, False: 4.21k]
  |  Branch (509:23): [True: 18.3k, False: 13.7k]
  ------------------
  510|  18.3k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  18.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  511|  18.3k|        int extra_hw_frames = p->extra_hw_frames;
  512|  18.3k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  18.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  513|  18.3k|        if (extra_hw_frames > 0) {
  ------------------
  |  Branch (513:13): [True: 0, False: 18.3k]
  ------------------
  514|      0|            p->decoder->control(p->decoder->f, VDCTRL_SET_EXTRA_HW_FRAMES,
  515|      0|                                &extra_hw_frames);
  516|      0|        }
  517|  18.3k|    }
  518|       |
  519|  36.2k|    update_cached_values(p);
  520|       |
  521|  36.2k|    talloc_free(list);
  ------------------
  |  |   47|  36.2k|#define talloc_free                     ta_free
  ------------------
  522|  36.2k|    return !!p->decoder;
  523|  36.2k|}
f_decoder_wrapper.c:reset_decoder:
  315|   109k|{
  316|   109k|    p->first_packet_pdts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   109k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  317|   109k|    p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   109k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  318|   109k|    p->codec_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   109k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  319|   109k|    p->codec_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   109k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  320|   109k|    p->num_codec_pts_problems = 0;
  321|   109k|    p->num_codec_dts_problems = 0;
  322|   109k|    p->has_broken_decoded_pts = 0;
  323|   109k|    p->packets_without_output = 0;
  324|   109k|    mp_frame_unref(&p->packet);
  325|   109k|    p->packet_fed = false;
  326|   109k|    p->preroll_discard = false;
  327|   109k|    talloc_free(p->new_segment);
  ------------------
  |  |   47|   109k|#define talloc_free                     ta_free
  ------------------
  328|   109k|    p->new_segment = NULL;
  329|   109k|    p->start = p->end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   109k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  330|       |
  331|   109k|    if (p->decoder)
  ------------------
  |  Branch (331:9): [True: 1.08k, False: 108k]
  ------------------
  332|  1.08k|        mp_filter_reset(p->decoder->f);
  333|   109k|}
f_decoder_wrapper.c:public_f_destroy:
 1252|  36.2k|{
 1253|  36.2k|    struct priv *p = f->priv;
 1254|  36.2k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  36.2k|#define mp_assert assert
  ------------------
  |  Branch (1254:5): [True: 36.2k, False: 0]
  ------------------
 1255|       |
 1256|  36.2k|    if (p->dec_thread_valid) {
  ------------------
  |  Branch (1256:9): [True: 0, False: 36.2k]
  ------------------
 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|  36.2k|    mp_filter_free_children(f);
 1267|       |
 1268|  36.2k|    talloc_free(p->dec_root_filter);
  ------------------
  |  |   47|  36.2k|#define talloc_free                     ta_free
  ------------------
 1269|  36.2k|    talloc_free(p->queue);
  ------------------
  |  |   47|  36.2k|#define talloc_free                     ta_free
  ------------------
 1270|  36.2k|    mp_mutex_destroy(&p->cache_lock);
  ------------------
  |  |  133|  36.2k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1271|  36.2k|}
f_decoder_wrapper.c:public_f_reset:
 1237|  37.0k|{
 1238|  37.0k|    struct priv *p = f->priv;
 1239|  37.0k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  37.0k|#define mp_assert assert
  ------------------
  |  Branch (1239:5): [True: 37.0k, False: 0]
  ------------------
 1240|       |
 1241|  37.0k|    if (p->queue) {
  ------------------
  |  Branch (1241:9): [True: 0, False: 37.0k]
  ------------------
 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|  37.0k|}
f_decoder_wrapper.c:decf_destroy:
  394|  36.2k|{
  395|  36.2k|    struct priv *p = f->priv;
  396|  36.2k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  36.2k|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 36.2k, False: 0]
  ------------------
  397|       |
  398|  36.2k|    if (p->decoder) {
  ------------------
  |  Branch (398:9): [True: 32.0k, False: 4.21k]
  ------------------
  399|  32.0k|        MP_DBG(f, "Uninit decoder.\n");
  ------------------
  |  |   93|  32.0k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  400|  32.0k|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|  32.0k|#define talloc_free                     ta_free
  ------------------
  401|  32.0k|        p->decoder = NULL;
  402|  32.0k|        p->codec->decoder = NULL;
  403|  32.0k|        p->codec->decoder_desc = NULL;
  404|  32.0k|    }
  405|       |
  406|  36.2k|    decf_reset(f);
  407|  36.2k|    mp_frame_unref(&p->decoded_coverart);
  408|  36.2k|}
f_decoder_wrapper.c:decf_process:
 1205|  2.73M|{
 1206|  2.73M|    struct priv *p = f->priv;
 1207|  2.73M|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  2.73M|#define mp_assert assert
  ------------------
  |  Branch (1207:5): [True: 2.73M, False: 0]
  ------------------
 1208|       |
 1209|  2.73M|    if (m_config_cache_update(p->opt_cache))
  ------------------
  |  Branch (1209:9): [True: 0, False: 2.73M]
  ------------------
 1210|      0|        update_queue_config(p);
 1211|       |
 1212|  2.73M|    feed_packet(p);
 1213|  2.73M|    read_frame(p);
 1214|  2.73M|}
f_decoder_wrapper.c:feed_packet:
  967|  2.73M|{
  968|  2.73M|    if (!p->decoder || !mp_pin_in_needs_data(p->decoder->f->pins[0]))
  ------------------
  |  Branch (968:9): [True: 0, False: 2.73M]
  |  Branch (968:24): [True: 1.18M, False: 1.55M]
  ------------------
  969|  1.18M|        return;
  970|       |
  971|  1.55M|    if (p->decoded_coverart.type)
  ------------------
  |  Branch (971:9): [True: 0, False: 1.55M]
  ------------------
  972|      0|        return;
  973|       |
  974|       |    // Don't read after EOF was output. If the stream continues, the player
  975|       |    // creates a new decoder.
  976|  1.55M|    if (p->eof_output)
  ------------------
  |  Branch (976:9): [True: 0, False: 1.55M]
  ------------------
  977|      0|        return;
  978|       |
  979|  1.55M|    if (!p->packet.type && !p->new_segment) {
  ------------------
  |  Branch (979:9): [True: 1.55M, False: 337]
  |  Branch (979:28): [True: 1.55M, False: 0]
  ------------------
  980|  1.55M|        p->packet = mp_pin_out_read(p->demux);
  981|  1.55M|        if (!p->packet.type)
  ------------------
  |  Branch (981:13): [True: 775k, False: 775k]
  ------------------
  982|   775k|            return;
  983|   775k|        if (p->packet.type != MP_FRAME_EOF && p->packet.type != MP_FRAME_PACKET) {
  ------------------
  |  Branch (983:13): [True: 743k, False: 32.2k]
  |  Branch (983:47): [True: 0, False: 743k]
  ------------------
  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|   775k|    }
  990|       |
  991|   775k|    if (!p->packet.type)
  ------------------
  |  Branch (991:9): [True: 0, False: 775k]
  ------------------
  992|      0|        return;
  993|       |
  994|       |    // Flush current data if the packet is a new segment.
  995|   775k|    if (is_new_segment(p, p->packet)) {
  ------------------
  |  Branch (995:9): [True: 337, False: 775k]
  ------------------
  996|    337|        mp_assert(!p->new_segment);
  ------------------
  |  |   41|    337|#define mp_assert assert
  ------------------
  |  Branch (996:9): [True: 337, False: 0]
  ------------------
  997|    337|        p->new_segment = p->packet.data;
  998|    337|        p->packet = MP_EOF_FRAME;
  ------------------
  |  |   59|    337|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|    337|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  999|    337|    }
 1000|       |
 1001|   775k|    mp_assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF);
  ------------------
  |  |   41|   775k|#define mp_assert assert
  ------------------
  |  Branch (1001:5): [True: 743k, False: 32.6k]
  |  Branch (1001:5): [True: 32.6k, False: 0]
  ------------------
 1002|   775k|    struct demux_packet *packet =
 1003|   775k|        p->packet.type == MP_FRAME_PACKET ? p->packet.data : NULL;
  ------------------
  |  Branch (1003:9): [True: 743k, False: 32.6k]
  ------------------
 1004|       |
 1005|       |    // For video framedropping, including parts of the hr-seek logic.
 1006|   775k|    if (p->decoder->control) {
  ------------------
  |  Branch (1006:9): [True: 392k, False: 383k]
  ------------------
 1007|   392k|        double start_pts = p->start_pts;
 1008|   392k|        if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|   784k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  7.80k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1008:13): [True: 3.90k, False: 388k]
  |  Branch (1008:44): [True: 3.90k, False: 0]
  ------------------
 1009|      0|                                           p->start > start_pts))
  ------------------
  |  Branch (1009:44): [True: 0, False: 0]
  ------------------
 1010|  3.90k|            start_pts = p->start;
 1011|       |
 1012|   392k|        int framedrop_type = 0;
 1013|       |
 1014|   392k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   392k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1015|   392k|        if (p->attempt_framedrops)
  ------------------
  |  Branch (1015:13): [True: 0, False: 392k]
  ------------------
 1016|      0|            framedrop_type = 1;
 1017|   392k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   392k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1018|       |
 1019|   392k|        if (start_pts != MP_NOPTS_VALUE && packet && p->play_dir > 0 &&
  ------------------
  |  |   39|   784k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1019:13): [True: 3.90k, False: 388k]
  |  Branch (1019:44): [True: 3.68k, False: 215]
  |  Branch (1019:54): [True: 3.68k, False: 0]
  ------------------
 1020|  3.68k|            packet->pts < start_pts - .005 && !p->has_broken_packet_pts)
  ------------------
  |  Branch (1020:13): [True: 2.29k, False: 1.39k]
  |  Branch (1020:47): [True: 0, False: 2.29k]
  ------------------
 1021|      0|            framedrop_type = 2;
 1022|       |
 1023|   392k|        p->decoder->control(p->decoder->f, VDCTRL_SET_FRAMEDROP, &framedrop_type);
 1024|   392k|    }
 1025|       |
 1026|   775k|    if (!p->dec_dispatch && p->public.recorder_sink)
  ------------------
  |  Branch (1026:9): [True: 775k, False: 0]
  |  Branch (1026:29): [True: 0, False: 775k]
  ------------------
 1027|      0|        mp_recorder_feed_packet(p->public.recorder_sink, packet);
 1028|       |
 1029|   775k|    double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  32.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1029:22): [True: 743k, False: 32.6k]
  ------------------
 1030|   775k|    double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  32.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1030:22): [True: 743k, False: 32.6k]
  ------------------
 1031|       |
 1032|   775k|    if (pkt_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   775k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1032:9): [True: 360k, False: 415k]
  ------------------
 1033|   360k|        p->has_broken_packet_pts = 1;
 1034|       |
 1035|   775k|    if (packet && packet->dts == MP_NOPTS_VALUE && !p->codec->avi_dts)
  ------------------
  |  |   39|  1.51M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1035:9): [True: 743k, False: 32.6k]
  |  Branch (1035:19): [True: 691k, False: 51.5k]
  |  Branch (1035:52): [True: 691k, False: 0]
  ------------------
 1036|   691k|        packet->dts = packet->pts;
 1037|       |
 1038|   775k|    double pkt_pdts = pkt_pts == MP_NOPTS_VALUE ? pkt_dts : pkt_pts;
  ------------------
  |  |   39|   775k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1038:23): [True: 360k, False: 415k]
  ------------------
 1039|   775k|    if (p->first_packet_pdts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   775k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1039:9): [True: 33.3k, False: 742k]
  ------------------
 1040|  33.3k|        p->first_packet_pdts = pkt_pdts;
 1041|       |
 1042|   775k|    if (packet && packet->back_preroll) {
  ------------------
  |  Branch (1042:9): [True: 743k, False: 32.6k]
  |  Branch (1042:19): [True: 0, False: 743k]
  ------------------
 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|   775k|    mp_pin_in_write(p->decoder->f->pins[0], p->packet);
 1048|   775k|    p->packet_fed = true;
 1049|   775k|    p->packet = MP_NO_FRAME;
  ------------------
  |  |   58|   775k|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|   775k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1050|       |
 1051|   775k|    p->packets_without_output += 1;
 1052|   775k|}
f_decoder_wrapper.c:is_new_segment:
  957|   775k|{
  958|   775k|    if (frame.type != MP_FRAME_PACKET)
  ------------------
  |  Branch (958:9): [True: 32.2k, False: 743k]
  ------------------
  959|  32.2k|        return false;
  960|   743k|    struct demux_packet *pkt = frame.data;
  961|   743k|    return (pkt->segmented && (pkt->start != p->start || pkt->end != p->end ||
  ------------------
  |  Branch (961:13): [True: 7.68k, False: 735k]
  |  Branch (961:32): [True: 337, False: 7.34k]
  |  Branch (961:58): [True: 0, False: 7.34k]
  ------------------
  962|  7.34k|                               pkt->codec != p->codec)) ||
  ------------------
  |  Branch (962:32): [True: 0, False: 7.34k]
  ------------------
  963|   743k|           (p->play_dir < 0 && pkt->back_restart && p->packet_fed);
  ------------------
  |  Branch (963:13): [True: 0, False: 743k]
  |  Branch (963:32): [True: 0, False: 0]
  |  Branch (963:53): [True: 0, False: 0]
  ------------------
  964|   775k|}
f_decoder_wrapper.c:read_frame:
 1084|  2.73M|{
 1085|  2.73M|    struct mp_pin *pin = p->decf->ppins[0];
 1086|  2.73M|    struct mp_frame frame = {0};
 1087|       |
 1088|  2.73M|    if (!p->decoder) {
  ------------------
  |  Branch (1088:9): [True: 0, False: 2.73M]
  ------------------
 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|  2.73M|    if (!mp_pin_in_needs_data(pin))
  ------------------
  |  Branch (1093:9): [True: 32.0k, False: 2.70M]
  ------------------
 1094|  32.0k|        return;
 1095|       |
 1096|  2.70M|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1096:9): [True: 106, False: 2.70M]
  ------------------
 1097|    106|        if (p->coverart_returned == 0) {
  ------------------
  |  Branch (1097:13): [True: 106, False: 0]
  ------------------
 1098|    106|            frame = mp_frame_ref(p->decoded_coverart);
 1099|    106|            p->coverart_returned = 1;
 1100|    106|            goto output_frame;
 1101|    106|        } 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|    106|    }
 1108|       |
 1109|  2.70M|    if (p->reverse_queue_complete && p->num_reverse_queue) {
  ------------------
  |  Branch (1109:9): [True: 0, False: 2.70M]
  |  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|  2.70M|    p->reverse_queue_complete = false;
 1115|       |
 1116|  2.70M|    frame = mp_pin_out_read(p->decoder->f->pins[1]);
 1117|  2.70M|    if (!frame.type)
  ------------------
  |  Branch (1117:9): [True: 2.12M, False: 576k]
  ------------------
 1118|  2.12M|        return;
 1119|       |
 1120|   576k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   576k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1121|   576k|    if (p->attached_picture && frame.type == MP_FRAME_VIDEO)
  ------------------
  |  Branch (1121:9): [True: 284, False: 576k]
  |  Branch (1121:32): [True: 106, False: 178]
  ------------------
 1122|    106|        p->decoded_coverart = frame;
 1123|   576k|    if (p->attempt_framedrops) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 576k]
  ------------------
 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|   576k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   576k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1129|       |
 1130|   576k|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1130:9): [True: 106, False: 576k]
  ------------------
 1131|    106|        mp_filter_internal_mark_progress(p->decf);
 1132|    106|        return;
 1133|    106|    }
 1134|       |
 1135|   576k|    p->packets_without_output = 0;
 1136|       |
 1137|   576k|    if (p->preroll_discard && frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 576k]
  |  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|   576k|    bool segment_ended = process_decoded_frame(p, &frame);
 1148|       |
 1149|   576k|    if (p->play_dir < 0 && frame.type) {
  ------------------
  |  Branch (1149:9): [True: 0, False: 576k]
  |  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|   576k|    if (segment_ended && p->new_segment) {
  ------------------
  |  Branch (1155:9): [True: 32.6k, False: 543k]
  |  Branch (1155:26): [True: 337, False: 32.3k]
  ------------------
 1156|    337|        struct demux_packet *new_segment = p->new_segment;
 1157|    337|        p->new_segment = NULL;
 1158|       |
 1159|    337|        reset_decoder(p);
 1160|       |
 1161|    337|        if (new_segment->segmented) {
  ------------------
  |  Branch (1161:13): [True: 337, False: 0]
  ------------------
 1162|    337|            if (p->codec != new_segment->codec) {
  ------------------
  |  Branch (1162:17): [True: 0, False: 337]
  ------------------
 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|    337|            p->start = new_segment->start;
 1169|    337|            p->end = new_segment->end;
 1170|    337|        }
 1171|       |
 1172|    337|        p->reverse_queue_byte_size = 0;
 1173|    337|        p->reverse_queue_complete = p->num_reverse_queue > 0;
 1174|       |
 1175|    337|        p->packet = MAKE_FRAME(MP_FRAME_PACKET, new_segment);
  ------------------
  |  |   57|    337|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1176|    337|        mp_filter_internal_mark_progress(p->decf);
 1177|    337|    }
 1178|       |
 1179|   576k|    if (!frame.type) {
  ------------------
  |  Branch (1179:9): [True: 1.65k, False: 574k]
  ------------------
 1180|  1.65k|        mp_filter_internal_mark_progress(p->decf); // make it retry
 1181|  1.65k|        return;
 1182|  1.65k|    }
 1183|       |
 1184|   574k|output_frame:
 1185|   574k|    process_output_frame(p, frame);
 1186|   574k|    p->eof_output = frame.type == MP_FRAME_EOF;
 1187|   574k|    mp_pin_in_write(pin, frame);
 1188|   574k|}
f_decoder_wrapper.c:process_decoded_frame:
  786|   576k|{
  787|   576k|    if (frame->type == MP_FRAME_EOF) {
  ------------------
  |  Branch (787:9): [True: 32.5k, False: 543k]
  ------------------
  788|       |        // if we were just draining current segment, don't propagate EOF
  789|  32.5k|        if (p->new_segment)
  ------------------
  |  Branch (789:13): [True: 337, False: 32.2k]
  ------------------
  790|    337|            mp_frame_unref(frame);
  791|  32.5k|        return true;
  792|  32.5k|    }
  793|       |
  794|   576k|    bool segment_ended = false;
  795|       |
  796|   543k|    if (frame->type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (796:9): [True: 120k, False: 422k]
  ------------------
  797|   120k|        struct mp_image *mpi = frame->data;
  798|       |
  799|   120k|        crazy_video_pts_stuff(p, mpi);
  800|       |
  801|   120k|        struct demux_packet *ccpkt = new_demux_packet_from_buf(p->public.f->packet_pool,
  802|   120k|                                                               mpi->a53_cc);
  803|   120k|        if (ccpkt) {
  ------------------
  |  Branch (803:13): [True: 536, False: 120k]
  ------------------
  804|    536|            av_buffer_unref(&mpi->a53_cc);
  805|    536|            ccpkt->pts = mpi->pts;
  806|    536|            ccpkt->dts = mpi->dts;
  807|    536|            demuxer_feed_caption(p->header, ccpkt);
  808|    536|        }
  809|       |
  810|       |        // Stop hr-seek logic.
  811|   120k|        if (mpi->pts == MP_NOPTS_VALUE || mpi->pts >= p->start_pts)
  ------------------
  |  |   39|   241k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (811:13): [True: 45.9k, False: 74.8k]
  |  Branch (811:43): [True: 74.8k, False: 0]
  ------------------
  812|   120k|            p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  813|       |
  814|   120k|        if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (814:13): [True: 74.8k, False: 45.9k]
  ------------------
  815|  74.8k|            segment_ended = p->end != MP_NOPTS_VALUE && mpi->pts >= p->end;
  ------------------
  |  |   39|   149k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (815:29): [True: 1.07k, False: 73.8k]
  |  Branch (815:57): [True: 59, False: 1.01k]
  ------------------
  816|  74.8k|            if ((p->start != MP_NOPTS_VALUE && mpi->pts < p->start) ||
  ------------------
  |  |   39|   149k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (816:18): [True: 1.07k, False: 73.8k]
  |  Branch (816:48): [True: 211, False: 863]
  ------------------
  817|  74.6k|                segment_ended)
  ------------------
  |  Branch (817:17): [True: 59, False: 74.6k]
  ------------------
  818|    270|            {
  819|    270|                mp_frame_unref(frame);
  820|    270|                goto done;
  821|    270|            }
  822|  74.8k|        }
  823|   422k|    } else if (frame->type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (823:16): [True: 422k, False: 0]
  ------------------
  824|   422k|        struct mp_aframe *aframe = frame->data;
  825|       |
  826|   422k|        mp_aframe_clip_timestamps(aframe, p->start, p->end);
  827|   422k|        double pts = mp_aframe_get_pts(aframe);
  828|   422k|        if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   845k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   420k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (828:13): [True: 420k, False: 2.38k]
  |  Branch (828:38): [True: 2.40k, False: 418k]
  ------------------
  829|  2.40k|            segment_ended = pts >= p->end;
  830|       |
  831|   422k|        if (mp_aframe_get_size(aframe) == 0) {
  ------------------
  |  Branch (831:13): [True: 1.05k, False: 421k]
  ------------------
  832|  1.05k|            mp_frame_unref(frame);
  833|  1.05k|            goto done;
  834|  1.05k|        }
  835|   422k|    } 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|   543k|done:
  840|   543k|    return segment_ended;
  841|   543k|}
f_decoder_wrapper.c:crazy_video_pts_stuff:
  749|   120k|{
  750|       |    // Note: the PTS is reordered, but the DTS is not. Both must be monotonic.
  751|       |
  752|   120k|    if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (752:9): [True: 49.2k, False: 71.6k]
  ------------------
  753|  49.2k|        if (mpi->pts < p->codec_pts)
  ------------------
  |  Branch (753:13): [True: 6.26k, False: 42.9k]
  ------------------
  754|  6.26k|            p->num_codec_pts_problems++;
  755|  49.2k|        p->codec_pts = mpi->pts;
  756|  49.2k|    }
  757|       |
  758|   120k|    if (mpi->dts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (758:9): [True: 70.1k, False: 50.6k]
  ------------------
  759|  70.1k|        if (mpi->dts <= p->codec_dts)
  ------------------
  |  Branch (759:13): [True: 29.8k, False: 40.2k]
  ------------------
  760|  29.8k|            p->num_codec_dts_problems++;
  761|  70.1k|        p->codec_dts = mpi->dts;
  762|  70.1k|    }
  763|       |
  764|   120k|    if (p->has_broken_packet_pts < 0)
  ------------------
  |  Branch (764:9): [True: 8.52k, False: 112k]
  ------------------
  765|  8.52k|        p->has_broken_packet_pts++;
  766|   120k|    if (p->num_codec_pts_problems)
  ------------------
  |  Branch (766:9): [True: 25.8k, False: 94.9k]
  ------------------
  767|  25.8k|        p->has_broken_packet_pts = 1;
  768|       |
  769|       |    // If PTS is unset, or non-monotonic, fall back to DTS.
  770|   120k|    if ((p->num_codec_pts_problems > p->num_codec_dts_problems ||
  ------------------
  |  Branch (770:10): [True: 583, False: 120k]
  ------------------
  771|   120k|        mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  72.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (771:9): [True: 71.6k, False: 48.6k]
  |  Branch (771:40): [True: 26.0k, False: 46.1k]
  ------------------
  772|  26.0k|        mpi->pts = mpi->dts;
  773|       |
  774|       |    // Compensate for incorrectly using mpeg-style DTS for avi timestamps.
  775|   120k|    if (p->decoder && p->decoder->control && p->codec->avi_dts &&
  ------------------
  |  Branch (775:9): [True: 120k, False: 0]
  |  Branch (775:23): [True: 120k, False: 0]
  |  Branch (775:46): [True: 0, False: 120k]
  ------------------
  776|      0|        mpi->pts != MP_NOPTS_VALUE && p->fps > 0)
  ------------------
  |  |   39|   120k|#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|   120k|}
f_decoder_wrapper.c:process_output_frame:
  922|   574k|{
  923|   574k|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (923:9): [True: 120k, False: 454k]
  ------------------
  924|   120k|        struct mp_image *mpi = frame.data;
  925|       |
  926|   120k|        correct_video_pts(p, mpi);
  927|       |
  928|   120k|        if (!mp_image_params_equal(&p->last_format, &mpi->params)) {
  ------------------
  |  Branch (928:13): [True: 10.8k, False: 109k]
  ------------------
  929|  10.8k|            fix_image_params(p, &mpi->params,
  930|  10.8k|                mp_image_params_static_equal(&p->last_format, &mpi->params));
  931|  10.8k|        }
  932|       |
  933|   120k|        mpi->params = p->fixed_format;
  934|   120k|        mpi->nominal_fps = p->fps;
  935|   454k|    } else if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (935:16): [True: 421k, False: 32.2k]
  ------------------
  936|   421k|        struct mp_aframe *aframe = frame.data;
  937|       |
  938|   421k|        if (p->play_dir < 0 && !mp_aframe_reverse(aframe))
  ------------------
  |  Branch (938:13): [True: 0, False: 421k]
  |  Branch (938:32): [True: 0, False: 0]
  ------------------
  939|   421k|            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|   421k|        correct_audio_pts(p, aframe);
  942|   421k|    }
  943|   574k|}
f_decoder_wrapper.c:correct_video_pts:
  844|   120k|{
  845|   120k|    mpi->pts *= p->play_dir;
  846|       |
  847|   120k|    if (!p->opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (847:9): [True: 0, False: 120k]
  |  Branch (847:34): [True: 45.9k, False: 74.7k]
  ------------------
  848|  45.9k|        double fps = p->fps > 0 ? p->fps : 25;
  ------------------
  |  Branch (848:22): [True: 324, False: 45.6k]
  ------------------
  849|       |
  850|  45.9k|        if (p->opts->correct_pts) {
  ------------------
  |  Branch (850:13): [True: 45.9k, False: 0]
  ------------------
  851|  45.9k|            if (p->has_broken_decoded_pts <= 1) {
  ------------------
  |  Branch (851:17): [True: 7.27k, False: 38.6k]
  ------------------
  852|  7.27k|                MP_WARN(p, "No video PTS! Making something up. Using "
  ------------------
  |  |   90|  7.27k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.27k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  853|  7.27k|                        "%f FPS.\n", fps);
  854|  7.27k|                if (p->has_broken_decoded_pts == 1)
  ------------------
  |  Branch (854:21): [True: 2.98k, False: 4.29k]
  ------------------
  855|  7.27k|                    MP_WARN(p, "Ignoring further missing PTS warnings.\n");
  ------------------
  |  |   90|  2.98k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.98k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  856|  7.27k|                p->has_broken_decoded_pts++;
  857|  7.27k|            }
  858|  45.9k|        }
  859|       |
  860|  45.9k|        double frame_time = 1.0f / fps;
  861|  45.9k|        double base = p->first_packet_pdts;
  862|  45.9k|        mpi->pts = p->pts;
  863|  45.9k|        if (mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  45.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (863:13): [True: 1.38k, False: 44.5k]
  ------------------
  864|  1.38k|            mpi->pts = base == MP_NOPTS_VALUE ? 0 : base;
  ------------------
  |  |   39|  1.38k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:24): [True: 14, False: 1.36k]
  ------------------
  865|  44.5k|        } else {
  866|  44.5k|            mpi->pts += frame_time;
  867|  44.5k|        }
  868|  45.9k|    }
  869|       |
  870|   120k|    p->pts = mpi->pts;
  871|   120k|}
f_decoder_wrapper.c:fix_image_params:
  628|  10.8k|{
  629|  10.8k|    struct mp_image_params m = *params;
  630|  10.8k|    struct mp_codec_params *c = p->codec;
  631|  10.8k|    struct dec_wrapper_opts *opts = p->opts;
  632|       |
  633|  10.8k|    if (!quiet)
  ------------------
  |  Branch (633:9): [True: 10.8k, False: 0]
  ------------------
  634|  10.8k|        MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  10.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  635|  10.8k|    p->dec_format = *params;
  636|       |
  637|  10.8k|    if (!quiet && opts->movie_aspect == 0)
  ------------------
  |  Branch (637:9): [True: 10.8k, False: 0]
  |  Branch (637:19): [True: 0, False: 10.8k]
  ------------------
  638|  10.8k|        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|  10.8k|                   "Use --video-aspect-override=no --video-aspect-mode=ignore instead.\n");
  640|  10.8k|    if (!quiet && opts->movie_aspect == -1)
  ------------------
  |  Branch (640:9): [True: 10.8k, False: 0]
  |  Branch (640:19): [True: 0, False: 10.8k]
  ------------------
  641|  10.8k|        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|  10.8k|                   "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|  10.8k|    bool use_container = true;
  647|  10.8k|    if (opts->aspect_method == 1 && m.p_w > 0 && m.p_h > 0 &&
  ------------------
  |  Branch (647:9): [True: 0, False: 10.8k]
  |  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|  10.8k|    if (opts->aspect_method == 3 && opts->movie_aspect != -1) {
  ------------------
  |  Branch (654:9): [True: 0, False: 10.8k]
  |  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|  10.8k|    if (use_container && c->dar_w > 0 && c->dar_h > 0) {
  ------------------
  |  Branch (661:9): [True: 10.8k, False: 0]
  |  Branch (661:26): [True: 0, False: 10.8k]
  |  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|  10.8k|    } else if (use_container && c->par_w > 0 && c->par_h) {
  ------------------
  |  Branch (665:16): [True: 10.8k, False: 0]
  |  Branch (665:33): [True: 10.1k, False: 734]
  |  Branch (665:49): [True: 10.1k, False: 18]
  ------------------
  666|  10.1k|        if (!quiet)
  ------------------
  |  Branch (666:13): [True: 10.1k, False: 0]
  ------------------
  667|  10.1k|            MP_VERBOSE(p, "Using container aspect ratio.\n");
  ------------------
  |  |   92|  10.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  668|  10.1k|        m.p_w = c->par_w;
  669|  10.1k|        m.p_h = c->par_h;
  670|  10.1k|    }
  671|       |
  672|  10.8k|    if (opts->movie_aspect >= 0) {
  ------------------
  |  Branch (672:9): [True: 0, False: 10.8k]
  ------------------
  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|  10.8k|    if (m.p_w <= 0 || m.p_h <= 0)
  ------------------
  |  Branch (684:9): [True: 626, False: 10.2k]
  |  Branch (684:23): [True: 0, False: 10.2k]
  ------------------
  685|    626|        m.p_w = m.p_h = 1;
  686|       |
  687|  10.8k|    if (!m.stereo3d)
  ------------------
  |  Branch (687:9): [True: 10.8k, False: 0]
  ------------------
  688|  10.8k|        m.stereo3d = p->codec->stereo_mode;
  689|       |
  690|  10.8k|    if (!mp_rect_equals(&p->codec->crop, &(struct mp_rect){0})) {
  ------------------
  |  Branch (690:9): [True: 8, False: 10.8k]
  ------------------
  691|      8|        struct mp_rect crop = p->codec->crop;
  692|       |        // Offset to respect existing decoder crop.
  693|      8|        crop.x0 += m.crop.x0;
  694|      8|        crop.x1 += m.crop.x0;
  695|      8|        crop.y0 += m.crop.y0;
  696|      8|        crop.y1 += m.crop.y0;
  697|       |        // Crop has to be inside existing image bounds.
  698|      8|        if (mp_image_crop_valid(&(struct mp_image_params) {
  ------------------
  |  Branch (698:13): [True: 2, False: 6]
  ------------------
  699|      8|            .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  157|      8|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                          .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  158|      8|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  700|      2|        {
  701|      2|            m.crop = crop;
  702|      6|        } else {
  703|      6|            MP_WARN(p, "Invalid container crop %dx%d+%d+%d for %dx%d image\n",
  ------------------
  |  |   90|      6|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      6|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  704|      6|            mp_rect_w(crop), mp_rect_h(crop), crop.x0, crop.y0,
  705|      6|            mp_rect_w(m.crop), mp_rect_h(m.crop));
  706|      6|        }
  707|      8|    }
  708|       |
  709|  10.8k|    if (opts->video_rotate < 0) {
  ------------------
  |  Branch (709:9): [True: 0, False: 10.8k]
  ------------------
  710|      0|        m.rotate = 0;
  711|  10.8k|    } else {
  712|       |        // ffmpeg commit 535a835e51 says that frame rotate takes priority
  713|  10.8k|        if (!m.rotate)
  ------------------
  |  Branch (713:13): [True: 10.8k, False: 60]
  ------------------
  714|  10.8k|            m.rotate = p->codec->rotate;
  715|  10.8k|        m.rotate = (m.rotate + opts->video_rotate) % 360;
  716|  10.8k|    }
  717|       |
  718|  10.8k|    pl_color_space_merge(&m.color, &c->color);
  719|  10.8k|    pl_color_repr_merge(&m.repr, &c->repr);
  720|       |
  721|  10.8k|    if (m.chroma_location == PL_CHROMA_UNKNOWN)
  ------------------
  |  Branch (721:9): [True: 3.68k, False: 7.18k]
  ------------------
  722|  3.68k|        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|  10.8k|    mp_image_params_guess_csp(&m);
  727|       |
  728|  10.8k|    p->last_format = *params;
  729|  10.8k|    p->fixed_format = m;
  730|  10.8k|}
f_decoder_wrapper.c:correct_audio_pts:
  874|   421k|{
  875|   421k|    double dir = p->play_dir;
  876|       |
  877|   421k|    double frame_pts = mp_aframe_get_pts(aframe);
  878|   421k|    double frame_len = mp_aframe_duration(aframe);
  879|       |
  880|   421k|    if (frame_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   421k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (880:9): [True: 419k, False: 2.38k]
  ------------------
  881|   419k|        if (dir < 0)
  ------------------
  |  Branch (881:13): [True: 0, False: 419k]
  ------------------
  882|      0|            frame_pts = -(frame_pts + frame_len);
  883|       |
  884|   419k|        if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   419k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (884:13): [True: 412k, False: 6.85k]
  ------------------
  885|   419k|            MP_STATS(p, "value %f audio-pts-err", p->pts - frame_pts);
  ------------------
  |  |   99|   412k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   412k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  886|       |
  887|   419k|        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|   419k|        if (p->pts != MP_NOPTS_VALUE && diff > 0.1) {
  ------------------
  |  |   39|   838k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (892:13): [True: 412k, False: 6.85k]
  |  Branch (892:41): [True: 19.0k, False: 393k]
  ------------------
  893|  19.0k|            MP_WARN(p, "Invalid audio PTS: %f -> %f\n", p->pts, frame_pts);
  ------------------
  |  |   90|  19.0k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  894|  19.0k|            if (diff >= 5) {
  ------------------
  |  Branch (894:17): [True: 1.93k, False: 17.1k]
  ------------------
  895|  1.93k|                mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  1.93k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  896|  1.93k|                p->pts_reset = true;
  897|  1.93k|                mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  1.93k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  898|  1.93k|            }
  899|  19.0k|        }
  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|   419k|        if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   39|   838k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|   412k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (906:13): [True: 6.85k, False: 412k]
  |  Branch (906:41): [True: 42.1k, False: 370k]
  ------------------
  907|  48.9k|            p->pts = frame_pts;
  908|   370k|        else
  909|   370k|            p->pts += (frame_pts - p->pts) * frame_len;
  910|   419k|    }
  911|       |
  912|   421k|    if (p->pts == MP_NOPTS_VALUE && p->header->missing_timestamps)
  ------------------
  |  |   39|   843k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (912:9): [True: 2.38k, False: 419k]
  |  Branch (912:37): [True: 0, False: 2.38k]
  ------------------
  913|      0|        p->pts = 0;
  914|       |
  915|   421k|    mp_aframe_set_pts(aframe, p->pts);
  916|       |
  917|   421k|    if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   421k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (917:9): [True: 419k, False: 2.38k]
  ------------------
  918|   419k|        p->pts += frame_len;
  919|   421k|}
f_decoder_wrapper.c:decf_reset:
  336|  73.2k|{
  337|  73.2k|    struct priv *p = f->priv;
  338|  73.2k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  73.2k|#define mp_assert assert
  ------------------
  |  Branch (338:5): [True: 73.2k, False: 0]
  ------------------
  339|       |
  340|  73.2k|    p->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  73.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  341|  73.2k|    p->last_format = p->fixed_format = (struct mp_image_params){0};
  342|       |
  343|  73.2k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  73.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  344|  73.2k|    p->pts_reset = false;
  345|  73.2k|    p->attempt_framedrops = 0;
  346|  73.2k|    p->dropped_frames = 0;
  347|  73.2k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  73.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  348|       |
  349|  73.2k|    p->coverart_returned = 0;
  350|  73.2k|    p->eof_output = false;
  351|       |
  352|  73.2k|    for (int n = 0; n < p->num_reverse_queue; n++)
  ------------------
  |  Branch (352:21): [True: 0, False: 73.2k]
  ------------------
  353|      0|        mp_frame_unref(&p->reverse_queue[n]);
  354|  73.2k|    p->num_reverse_queue = 0;
  355|  73.2k|    p->reverse_queue_byte_size = 0;
  356|  73.2k|    p->reverse_queue_complete = false;
  357|       |
  358|  73.2k|    reset_decoder(p);
  359|  73.2k|}

mp_demux_in_create:
   72|  36.2k|{
   73|  36.2k|    struct mp_filter *f = mp_filter_create(parent, &demux_filter);
   74|  36.2k|    if (!f)
  ------------------
  |  Branch (74:9): [True: 0, False: 36.2k]
  ------------------
   75|      0|        return NULL;
   76|       |
   77|  36.2k|    struct priv *p = f->priv;
   78|  36.2k|    p->src = src;
   79|       |
   80|  36.2k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
   81|       |
   82|  36.2k|    demux_set_stream_wakeup_cb(p->src, wakeup, f);
   83|       |
   84|  36.2k|    return f;
   85|  36.2k|}
f_demux_in.c:demux_destroy:
   56|  36.2k|{
   57|  36.2k|    struct priv *p = f->priv;
   58|       |
   59|  36.2k|    demux_set_stream_wakeup_cb(p->src, NULL, NULL);
   60|  36.2k|}
f_demux_in.c:demux_process:
   21|   877k|{
   22|   877k|    struct priv *p = f->priv;
   23|       |
   24|   877k|    if (!mp_pin_in_needs_data(f->ppins[0]))
  ------------------
  |  Branch (24:9): [True: 32.6k, False: 845k]
  ------------------
   25|  32.6k|        return;
   26|       |
   27|   845k|    struct demux_packet *pkt = NULL;
   28|   845k|    if (demux_read_packet_async(p->src, &pkt) == 0)
  ------------------
  |  Branch (28:9): [True: 69.4k, False: 775k]
  ------------------
   29|  69.4k|        return; // wait
   30|       |
   31|   775k|    struct mp_frame frame = {MP_FRAME_PACKET, pkt};
   32|   775k|    if (pkt) {
  ------------------
  |  Branch (32:9): [True: 743k, False: 32.2k]
  ------------------
   33|   743k|        if (p->eof_returned)
  ------------------
  |  Branch (33:13): [True: 0, False: 743k]
  ------------------
   34|   743k|            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|   743k|        p->eof_returned = false;
   36|   743k|    } else {
   37|  32.2k|        frame.type = MP_FRAME_EOF;
   38|       |
   39|       |        // While the demuxer will repeat EOFs, filters never do that.
   40|  32.2k|        if (p->eof_returned)
  ------------------
  |  Branch (40:13): [True: 0, False: 32.2k]
  ------------------
   41|      0|            return;
   42|  32.2k|        p->eof_returned = true;
   43|  32.2k|    }
   44|       |
   45|   775k|    mp_pin_in_write(f->ppins[0], frame);
   46|   775k|}
f_demux_in.c:demux_reset:
   49|    748|{
   50|    748|    struct priv *p = f->priv;
   51|       |
   52|       |    p->eof_returned = false;
   53|    748|}
f_demux_in.c:wakeup:
   14|  70.0k|{
   15|  70.0k|    struct mp_filter *f = ctx;
   16|       |
   17|  70.0k|    mp_filter_wakeup(f);
   18|  70.0k|}

mp_lavfi_create_filter:
  943|    113|{
  944|    113|    struct lavfi *c = lavfi_alloc(parent);
  945|    113|    if (!c)
  ------------------
  |  Branch (945:9): [True: 0, False: 113]
  ------------------
  946|      0|        return NULL;
  947|       |
  948|    113|    c->force_type = type;
  949|    113|    c->force_bidir = bidir;
  950|    113|    c->hwdec_interop = talloc_strdup(c, hwdec_interop);
  ------------------
  |  |   50|    113|#define talloc_strdup                   ta_xstrdup
  ------------------
  951|    113|    c->graph_opts = mp_dup_str_array(c, graph_opts);
  952|    113|    c->graph_string = talloc_strdup(c, filter);
  ------------------
  |  |   50|    113|#define talloc_strdup                   ta_xstrdup
  ------------------
  953|    113|    c->direct_filter_opts = mp_dup_str_array(c, filter_opts);
  954|    113|    c->direct_filter = true;
  955|       |
  956|    113|    return do_init(c);
  957|    113|}
f_lavfi.c:lavfi_alloc:
  860|    113|{
  861|    113|    struct mp_filter *f = mp_filter_create(parent, &lavfi_filter);
  862|    113|    if (!f)
  ------------------
  |  Branch (862:9): [True: 0, False: 113]
  ------------------
  863|      0|        return NULL;
  864|       |
  865|    113|    struct lavfi *c = f->priv;
  866|       |
  867|    113|    c->f = f;
  868|    113|    c->log = f->log;
  869|    113|    c->public.f = f;
  870|    113|    c->tmp_frame = av_frame_alloc();
  871|    113|    MP_HANDLE_OOM(c->tmp_frame);
  ------------------
  |  |  206|    113|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    113|        void *oom_p_ = (x);     \
  |  |  208|    113|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 113]
  |  |  ------------------
  |  |  209|    113|            abort();            \
  |  |  210|    113|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 113]
  |  |  ------------------
  ------------------
  872|       |
  873|    113|    return c;
  874|    113|}
f_lavfi.c:lavfi_destroy:
  817|    113|{
  818|    113|    struct lavfi *c = f->priv;
  819|       |
  820|    113|    lavfi_reset(f);
  821|    113|    av_frame_free(&c->tmp_frame);
  822|    113|}
f_lavfi.c:precreate_graph:
  258|    113|{
  259|    113|    mp_assert(!c->graph);
  ------------------
  |  |   41|    113|#define mp_assert assert
  ------------------
  |  Branch (259:5): [True: 113, False: 0]
  ------------------
  260|       |
  261|    113|    c->failed = false;
  262|       |
  263|    113|    c->graph = avfilter_graph_alloc();
  264|    113|    MP_HANDLE_OOM(c->graph);
  ------------------
  |  |  206|    113|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    113|        void *oom_p_ = (x);     \
  |  |  208|    113|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 113]
  |  |  ------------------
  |  |  209|    113|            abort();            \
  |  |  210|    113|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 113]
  |  |  ------------------
  ------------------
  265|       |
  266|    113|    if (mp_set_avopts(c->log, c->graph, c->graph_opts) < 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 113]
  ------------------
  267|      0|        goto error;
  268|       |
  269|    113|    if (c->direct_filter) {
  ------------------
  |  Branch (269:9): [True: 113, False: 0]
  ------------------
  270|    113|        AVFilterContext *filter = avfilter_graph_alloc_filter(c->graph,
  271|    113|                            avfilter_get_by_name(c->graph_string), "filter");
  272|    113|        if (!filter) {
  ------------------
  |  Branch (272:13): [True: 113, False: 0]
  ------------------
  273|    113|            MP_FATAL(c, "filter '%s' not found or failed to allocate\n",
  ------------------
  |  |   88|    113|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    113|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  274|    113|                     c->graph_string);
  275|    113|            goto error;
  276|    113|        }
  277|       |
  278|      0|        if (mp_set_avopts_pos(c->log, filter, filter->priv,
  ------------------
  |  Branch (278:13): [True: 0, False: 0]
  ------------------
  279|      0|                              c->direct_filter_opts) < 0)
  280|      0|            goto error;
  281|       |
  282|      0|        if (avfilter_init_str(filter, NULL) < 0) {
  ------------------
  |  Branch (282:13): [True: 0, False: 0]
  ------------------
  283|      0|            MP_FATAL(c, "filter failed to initialize\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__)
  |  |  ------------------
  ------------------
  284|      0|            goto error;
  285|      0|        }
  286|       |
  287|      0|        add_pads_direct(c, MP_PIN_IN, filter, filter->input_pads,
  288|      0|                        filter->nb_inputs, first_init);
  289|      0|        add_pads_direct(c, MP_PIN_OUT, filter, filter->output_pads,
  290|      0|                        filter->nb_outputs, first_init);
  291|      0|    } else {
  292|      0|        AVFilterInOut *in = NULL, *out = NULL;
  293|      0|        if (avfilter_graph_parse2(c->graph, c->graph_string, &in, &out) < 0) {
  ------------------
  |  Branch (293:13): [True: 0, False: 0]
  ------------------
  294|      0|            MP_FATAL(c, "parsing the filter graph failed\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__)
  |  |  ------------------
  ------------------
  295|      0|            goto error;
  296|      0|        }
  297|      0|        add_pads(c, MP_PIN_IN, in, first_init);
  298|      0|        add_pads(c, MP_PIN_OUT, out, first_init);
  299|      0|        avfilter_inout_free(&in);
  300|      0|        avfilter_inout_free(&out);
  301|      0|    }
  302|       |
  303|      0|    for (int n = 0; n < c->num_all_pads; n++)
  ------------------
  |  Branch (303:21): [True: 0, False: 0]
  ------------------
  304|      0|        c->failed |= !c->all_pads[n]->filter;
  305|       |
  306|      0|    if (c->failed)
  ------------------
  |  Branch (306:9): [True: 0, False: 0]
  ------------------
  307|      0|        goto error;
  308|       |
  309|      0|    return;
  310|       |
  311|    113|error:
  312|    113|    free_graph(c);
  313|       |    c->failed = true;
  314|    113|}
f_lavfi.c:free_graph:
  137|    226|{
  138|    226|    avfilter_graph_free(&c->graph);
  139|    226|    for (int n = 0; n < c->num_all_pads; n++) {
  ------------------
  |  Branch (139:21): [True: 0, False: 226]
  ------------------
  140|      0|        struct lavfi_pad *pad = c->all_pads[n];
  141|       |
  142|      0|        pad->filter = NULL;
  143|      0|        pad->filter_pad = -1;
  144|      0|        pad->buffer = NULL;
  145|      0|        mp_frame_unref(&pad->in_fmt);
  146|      0|        pad->buffer_is_eof = false;
  147|      0|        pad->got_eagain = false;
  148|      0|    }
  149|    226|    c->initialized = false;
  150|    226|    c->draining_recover = false;
  151|    226|    c->in_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    226|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  152|    226|    c->in_samples = 0;
  153|    226|    c->delay = 0;
  154|    226|}
f_lavfi.c:lavfi_reset:
  807|    113|{
  808|    113|    struct lavfi *c = f->priv;
  809|       |
  810|    113|    free_graph(c);
  811|       |
  812|    113|    for (int n = 0; n < c->num_in_pads; n++)
  ------------------
  |  Branch (812:21): [True: 0, False: 113]
  ------------------
  813|      0|        mp_frame_unref(&c->in_pads[n]->pending);
  814|    113|}
f_lavfi.c:do_init:
  877|    113|{
  878|    113|    precreate_graph(c, true);
  879|       |
  880|    113|    if (c->failed)
  ------------------
  |  Branch (880:9): [True: 113, False: 0]
  ------------------
  881|    113|        goto error;
  882|       |
  883|      0|    for (int n = 0; n < c->num_in_pads + c->num_out_pads; n++) {
  ------------------
  |  Branch (883:21): [True: 0, False: 0]
  ------------------
  884|       |        // First add input pins to satisfy order for bidir graph types.
  885|      0|        struct lavfi_pad *pad =
  886|      0|            n < c->num_in_pads ? c->in_pads[n] : c->out_pads[n - c->num_in_pads];
  ------------------
  |  Branch (886:13): [True: 0, False: 0]
  ------------------
  887|       |
  888|      0|        pad->pin_index = c->f->num_pins;
  889|      0|        pad->pin = mp_filter_add_pin(c->f, pad->dir, pad->name);
  890|       |
  891|      0|        if (c->force_type && c->force_type != pad->type) {
  ------------------
  |  Branch (891:13): [True: 0, False: 0]
  |  Branch (891:30): [True: 0, False: 0]
  ------------------
  892|      0|            MP_FATAL(c, "mismatching media type\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__)
  |  |  ------------------
  ------------------
  893|      0|            goto error;
  894|      0|        }
  895|      0|    }
  896|       |
  897|      0|    if (c->force_bidir) {
  ------------------
  |  Branch (897:9): [True: 0, False: 0]
  ------------------
  898|      0|        if (c->f->num_pins != 2) {
  ------------------
  |  Branch (898:13): [True: 0, False: 0]
  ------------------
  899|      0|            MP_FATAL(c, "exactly 2 pads required\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__)
  |  |  ------------------
  ------------------
  900|      0|            goto error;
  901|      0|        }
  902|      0|        if (mp_pin_get_dir(c->f->ppins[0]) != MP_PIN_OUT ||
  ------------------
  |  Branch (902:13): [True: 0, False: 0]
  ------------------
  903|      0|            mp_pin_get_dir(c->f->ppins[1]) != MP_PIN_IN)
  ------------------
  |  Branch (903:13): [True: 0, False: 0]
  ------------------
  904|      0|        {
  905|      0|            MP_FATAL(c, "1 input and 1 output pad required\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__)
  |  |  ------------------
  ------------------
  906|      0|            goto error;
  907|      0|        }
  908|      0|    }
  909|       |
  910|      0|    return &c->public;
  911|       |
  912|    113|error:
  913|    113|    talloc_free(c->f);
  ------------------
  |  |   47|    113|#define talloc_free                     ta_free
  ------------------
  914|       |    return NULL;
  915|      0|}

mp_output_chain_set_vo:
  393|  19.6k|{
  394|  19.6k|    struct chain *p = c->f->priv;
  395|       |
  396|  19.6k|    p->stream_info.hwdec_devs = vo ? vo->hwdec_devs : NULL;
  ------------------
  |  Branch (396:33): [True: 19.6k, False: 0]
  ------------------
  397|  19.6k|    p->stream_info.osd = vo ? vo->osd : NULL;
  ------------------
  |  Branch (397:26): [True: 19.6k, False: 0]
  ------------------
  398|  19.6k|    p->stream_info.vflip = vo ? vo->driver->caps & VO_CAP_VFLIP : false;
  ------------------
  |  Branch (398:28): [True: 19.6k, False: 0]
  ------------------
  399|  19.6k|    p->stream_info.rotate90 = vo ? vo->driver->caps & VO_CAP_ROTATE90 : false;
  ------------------
  |  Branch (399:31): [True: 19.6k, False: 0]
  ------------------
  400|  19.6k|    p->stream_info.dr_vo = vo;
  401|  19.6k|    p->vo = vo;
  402|  19.6k|    update_output_caps(p);
  403|  19.6k|}
mp_output_chain_set_el_stream:
  407|   248k|{
  408|   248k|    struct chain *p = c->f->priv;
  409|       |
  410|   248k|    mp_assert(p->type == MP_OUTPUT_CHAIN_VIDEO);
  ------------------
  |  |   41|   248k|#define mp_assert assert
  ------------------
  |  Branch (410:5): [True: 248k, False: 0]
  ------------------
  411|       |
  412|   248k|    if (p->el_sh == el_sh && (!el_sh || p->el_pair))
  ------------------
  |  Branch (412:9): [True: 248k, False: 0]
  |  Branch (412:31): [True: 248k, False: 0]
  |  Branch (412:41): [True: 0, False: 0]
  ------------------
  413|   248k|        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|  8.07k|{
  446|  8.07k|    struct chain *p = c->f->priv;
  447|       |
  448|  8.07k|    mp_assert(p->public.ao_needs_update); // can't just call it any time
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (448:5): [True: 8.07k, False: 0]
  ------------------
  449|  8.07k|    mp_assert(!p->ao);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (449:5): [True: 8.07k, False: 0]
  ------------------
  450|       |
  451|  8.07k|    p->public.ao_needs_update = false;
  452|       |
  453|  8.07k|    p->ao = ao;
  454|       |
  455|  8.07k|    int out_format = 0;
  456|  8.07k|    int out_rate = 0;
  457|  8.07k|    struct mp_chmap out_channels = {0};
  458|  8.07k|    ao_get_format(p->ao, &out_rate, &out_format, &out_channels);
  459|       |
  460|  8.07k|    mp_autoconvert_clear(p->convert);
  461|  8.07k|    mp_autoconvert_add_afmt(p->convert, out_format);
  462|  8.07k|    mp_autoconvert_add_srate(p->convert, out_rate);
  463|  8.07k|    mp_autoconvert_add_chmap(p->convert, &out_channels);
  464|       |
  465|  8.07k|    mp_autoconvert_format_change_continue(p->convert);
  466|       |
  467|       |    // Just to get the format change logged again.
  468|  8.07k|    mp_aframe_reset(p->public.output_aformat);
  469|  8.07k|}
mp_output_chain_set_audio_speed:
  544|  13.7k|{
  545|  13.7k|    struct chain *p = c->f->priv;
  546|       |
  547|       |    // We always resample with the final libavresample instance.
  548|  13.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  549|  13.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|  13.7k|    set_speed_any(p->user_filters, p->num_user_filters,
  554|  13.7k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  555|  13.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  556|  13.7k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  557|  13.7k|    set_speed_any(p->user_filters, p->num_user_filters,
  558|  13.7k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  559|  13.7k|    set_speed_any(p->post_filters, p->num_post_filters,
  560|  13.7k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  561|  13.7k|}
mp_output_chain_update_filters:
  595|  32.0k|{
  596|  32.0k|    struct chain *p = c->f->priv;
  597|       |
  598|  32.0k|    struct mp_user_filter **add = NULL;      // new filters
  599|  32.0k|    int num_add = 0;
  600|  32.0k|    struct mp_user_filter **res = NULL;      // new final list
  601|  32.0k|    int num_res = 0;
  602|  32.0k|    bool *used = talloc_zero_array(NULL, bool, p->num_user_filters);
  ------------------
  |  |   30|  32.0k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  32.0k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|       |
  604|  32.0k|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (604:21): [True: 0, False: 32.0k]
  |  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|  32.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (645:21): [True: 0, False: 32.0k]
  ------------------
  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|  32.0k|    talloc_free(p->user_filters);
  ------------------
  |  |   47|  32.0k|#define talloc_free                     ta_free
  ------------------
  651|  32.0k|    p->user_filters = res;
  652|  32.0k|    p->num_user_filters = num_res;
  653|       |
  654|  32.0k|    relink_filter_list(p);
  655|       |
  656|  32.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (656:21): [True: 0, False: 32.0k]
  ------------------
  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|  32.0k|    MP_VERBOSE(p, "User filter list:\n");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  673|  32.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (673:21): [True: 0, False: 32.0k]
  ------------------
  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|  32.0k|    if (!p->num_user_filters)
  ------------------
  |  Branch (677:9): [True: 32.0k, False: 0]
  ------------------
  678|  32.0k|        MP_VERBOSE(p, "  (empty)\n");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  679|       |
  680|       |    // Filters can load hwdec interops, which might add new formats.
  681|  32.0k|    update_output_caps(p);
  682|       |
  683|  32.0k|    mp_filter_wakeup(p->f);
  684|       |
  685|  32.0k|    talloc_free(add);
  ------------------
  |  |   47|  32.0k|#define talloc_free                     ta_free
  ------------------
  686|  32.0k|    talloc_free(used);
  ------------------
  |  |   47|  32.0k|#define talloc_free                     ta_free
  ------------------
  687|  32.0k|    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|  32.0k|}
mp_output_chain_create:
  743|  36.2k|{
  744|  36.2k|    struct mp_filter *f = mp_filter_create(parent, &output_chain_filter);
  745|  36.2k|    if (!f)
  ------------------
  |  Branch (745:9): [True: 0, False: 36.2k]
  ------------------
  746|      0|        return NULL;
  747|       |
  748|  36.2k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  749|  36.2k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  750|       |
  751|  36.2k|    const char *log_name = NULL;
  752|  36.2k|    switch (type) {
  ------------------
  |  Branch (752:13): [True: 36.2k, False: 0]
  ------------------
  753|  19.6k|    case MP_OUTPUT_CHAIN_VIDEO: log_name = "!vf"; break;
  ------------------
  |  Branch (753:5): [True: 19.6k, False: 16.5k]
  ------------------
  754|  16.5k|    case MP_OUTPUT_CHAIN_AUDIO: log_name = "!af"; break;
  ------------------
  |  Branch (754:5): [True: 16.5k, False: 19.6k]
  ------------------
  755|  36.2k|    }
  756|  36.2k|    if (log_name)
  ------------------
  |  Branch (756:9): [True: 36.2k, False: 0]
  ------------------
  757|  36.2k|        f->log = mp_log_new(f, parent->global->log, log_name);
  758|       |
  759|  36.2k|    struct chain *p = f->priv;
  760|  36.2k|    p->f = f;
  761|  36.2k|    p->log = f->log;
  762|  36.2k|    p->type = type;
  763|       |
  764|  36.2k|    struct mp_output_chain *c = &p->public;
  765|  36.2k|    c->f = f;
  766|  36.2k|    c->input_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  36.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  36.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  767|  36.2k|    c->output_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  36.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  36.2k|#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|  36.2k|    p->input = create_wrapper_filter(p);
  771|  36.2k|    p->input->f = mp_bidir_nop_filter_create(p->input->wrapper);
  772|  36.2k|    if (!p->input->f)
  ------------------
  |  Branch (772:9): [True: 0, False: 36.2k]
  ------------------
  773|      0|        abort();
  774|  36.2k|    p->input->name = "in";
  775|  36.2k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, p->input);
  ------------------
  |  |  105|  36.2k|    do {                                            \
  |  |  106|  36.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  36.2k|    do {                                            \
  |  |  |  |   97|  36.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  36.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  36.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  36.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 36.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  36.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  36.2k|    do {                                                        \
  |  |  |  |  |  |   89|  36.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  36.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  36.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  36.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  36.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  36.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  36.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 36.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  36.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 36.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  36.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  36.2k|        (idxvar)++;                                 \
  |  |  109|  36.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 36.2k]
  |  |  ------------------
  ------------------
  776|       |
  777|  36.2k|    switch (type) {
  ------------------
  |  Branch (777:13): [True: 36.2k, False: 0]
  ------------------
  778|  19.6k|    case MP_OUTPUT_CHAIN_VIDEO: create_video_things(p); break;
  ------------------
  |  Branch (778:5): [True: 19.6k, False: 16.5k]
  ------------------
  779|  16.5k|    case MP_OUTPUT_CHAIN_AUDIO: create_audio_things(p); break;
  ------------------
  |  Branch (779:5): [True: 16.5k, False: 19.6k]
  ------------------
  780|  36.2k|    }
  781|       |
  782|  36.2k|    p->convert_wrapper = create_wrapper_filter(p);
  783|  36.2k|    p->convert = mp_autoconvert_create(p->convert_wrapper->wrapper);
  784|  36.2k|    if (!p->convert)
  ------------------
  |  Branch (784:9): [True: 0, False: 36.2k]
  ------------------
  785|      0|        abort();
  786|  36.2k|    p->convert_wrapper->name = "convert";
  787|  36.2k|    p->convert_wrapper->f = p->convert->f;
  788|  36.2k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->convert_wrapper);
  ------------------
  |  |  105|  36.2k|    do {                                            \
  |  |  106|  36.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  36.2k|    do {                                            \
  |  |  |  |   97|  36.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  36.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  36.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  36.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.6k, False: 16.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  36.2k|            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|  36.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 36.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  36.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  36.2k|        (idxvar)++;                                 \
  |  |  109|  36.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 36.2k]
  |  |  ------------------
  ------------------
  789|       |
  790|  36.2k|    if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (790:9): [True: 16.5k, False: 19.6k]
  ------------------
  791|  16.5k|        p->convert->on_audio_format_change = on_audio_format_change;
  792|  16.5k|        p->convert->on_audio_format_change_opaque = p;
  793|  16.5k|    }
  794|       |
  795|       |    // Dummy filter for reporting and logging the output format.
  796|  36.2k|    p->output = create_wrapper_filter(p);
  797|  36.2k|    p->output->f = mp_bidir_nop_filter_create(p->output->wrapper);
  798|  36.2k|    if (!p->output->f)
  ------------------
  |  Branch (798:9): [True: 0, False: 36.2k]
  ------------------
  799|      0|        abort();
  800|  36.2k|    p->output->name = "out";
  801|  36.2k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->output);
  ------------------
  |  |  105|  36.2k|    do {                                            \
  |  |  106|  36.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  36.2k|    do {                                            \
  |  |  |  |   97|  36.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  36.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  36.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  36.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 16.5k, False: 19.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  36.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  16.5k|    do {                                                        \
  |  |  |  |  |  |   89|  16.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  16.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  16.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  16.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  16.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  16.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  16.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 16.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  36.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 36.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  36.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  36.2k|        (idxvar)++;                                 \
  |  |  109|  36.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 36.2k]
  |  |  ------------------
  ------------------
  802|       |
  803|  36.2k|    relink_filter_list(p);
  804|       |
  805|  36.2k|    output_chain_reset(f);
  806|       |
  807|  36.2k|    return c;
  808|  36.2k|}
f_output_chain.c:update_output_caps:
   85|  62.5k|{
   86|  62.5k|    if (p->type != MP_OUTPUT_CHAIN_VIDEO)
  ------------------
  |  Branch (86:9): [True: 13.7k, False: 48.7k]
  ------------------
   87|  13.7k|        return;
   88|       |
   89|  48.7k|    mp_autoconvert_clear(p->convert);
   90|       |
   91|  48.7k|    if (p->vo) {
  ------------------
  |  Branch (91:9): [True: 48.7k, False: 0]
  ------------------
   92|  48.7k|        uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START] = {0};
   93|  48.7k|        vo_query_formats(p->vo, allowed_output_formats);
   94|       |
   95|  27.3M|        for (int n = 0; n < MP_ARRAY_SIZE(allowed_output_formats); n++) {
  ------------------
  |  |   49|  27.3M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (95:25): [True: 27.2M, False: 48.7k]
  ------------------
   96|  27.2M|            if (allowed_output_formats[n])
  ------------------
  |  Branch (96:17): [True: 27.2M, False: 0]
  ------------------
   97|  27.2M|                mp_autoconvert_add_imgfmt(p->convert, IMGFMT_START + n, 0);
   98|  27.2M|        }
   99|  48.7k|    }
  100|  48.7k|}
f_output_chain.c:create_wrapper_filter:
  258|   184k|{
  259|   184k|    struct mp_filter *f = mp_filter_create(p->f, &user_wrapper_filter);
  260|   184k|    if (!f)
  ------------------
  |  Branch (260:9): [True: 0, False: 184k]
  ------------------
  261|      0|        abort();
  262|   184k|    struct mp_user_filter *wrapper = f->priv;
  263|   184k|    wrapper->wrapper = f;
  264|   184k|    wrapper->p = p;
  265|   184k|    wrapper->last_in_aformat = talloc_steal(wrapper, mp_aframe_create());
  ------------------
  |  |   38|   184k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   184k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  266|       |    wrapper->last_is_active = true;
  267|   184k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  268|   184k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  269|   184k|    return wrapper;
  270|   184k|}
f_output_chain.c:user_wrapper_destroy:
  240|   184k|{
  241|   184k|    struct mp_user_filter *u = f->priv;
  242|       |
  243|   184k|    struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  244|   184k|    m_option_free(&dummy, &u->args);
  245|       |
  246|   184k|    mp_filter_free_children(f);
  247|   184k|}
f_output_chain.c:user_wrapper_process:
  157|  9.66M|{
  158|  9.66M|    struct mp_user_filter *u = f->priv;
  159|  9.66M|    struct chain *p = u->p;
  160|       |
  161|  9.66M|    mp_filter_set_error_handler(u->f, f);
  162|  9.66M|    const char *name = u->label ? u->label : u->name;
  ------------------
  |  Branch (162:24): [True: 0, False: 9.66M]
  ------------------
  163|  9.66M|    mp_assert(u->name);
  ------------------
  |  |   41|  9.66M|#define mp_assert assert
  ------------------
  |  Branch (163:5): [True: 9.66M, False: 0]
  ------------------
  164|       |
  165|  9.66M|    if (!u->failed && mp_filter_has_failed(u->f)) {
  ------------------
  |  Branch (165:9): [True: 9.66M, False: 0]
  |  Branch (165:23): [True: 0, False: 9.66M]
  ------------------
  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|  9.66M|    if (u->failed) {
  ------------------
  |  Branch (179:9): [True: 0, False: 9.66M]
  ------------------
  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|  9.66M|    if (mp_pin_can_transfer_data(u->f->pins[0], f->ppins[0])) {
  ------------------
  |  Branch (197:9): [True: 2.57M, False: 7.08M]
  ------------------
  198|  2.57M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  199|       |
  200|  2.57M|        check_in_format_change(u, frame);
  201|       |
  202|  2.57M|        double pts = mp_frame_get_pts(frame);
  203|  2.57M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.57M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (203:13): [True: 2.40M, False: 175k]
  ------------------
  204|  2.40M|            u->last_in_pts = pts;
  205|       |
  206|  2.57M|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (206:13): [True: 165k, False: 2.41M]
  ------------------
  207|   165k|            u->in_eof = true;
  208|       |
  209|  2.57M|        mp_pin_in_write(u->f->pins[0], frame);
  210|  2.57M|    }
  211|       |
  212|  9.66M|    if (mp_pin_can_transfer_data(f->ppins[1], u->f->pins[1])) {
  ------------------
  |  Branch (212:9): [True: 2.57M, False: 7.08M]
  ------------------
  213|  2.57M|        struct mp_frame frame = mp_pin_out_read(u->f->pins[1]);
  214|       |
  215|  2.57M|        double pts = mp_frame_get_pts(frame);
  216|  2.57M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.57M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (216:13): [True: 2.40M, False: 175k]
  ------------------
  217|  2.40M|            u->last_out_pts = pts;
  218|       |
  219|  2.57M|        mp_pin_in_write(f->ppins[1], frame);
  220|       |
  221|  2.57M|        struct mp_filter_command cmd = {.type = MP_FILTER_COMMAND_IS_ACTIVE};
  222|  2.57M|        if (mp_filter_command(u->f, &cmd) && u->last_is_active != cmd.is_active) {
  ------------------
  |  Branch (222:13): [True: 1.42M, False: 1.14M]
  |  Branch (222:46): [True: 100k, False: 1.32M]
  ------------------
  223|   100k|            u->last_is_active = cmd.is_active;
  224|   100k|            MP_VERBOSE(p, "[%s] (%sabled)\n", u->name,
  ------------------
  |  |   92|   100k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   201k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 100k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|   100k|                       u->last_is_active ? "en" : "dis");
  226|   100k|        }
  227|  2.57M|    }
  228|  9.66M|}
f_output_chain.c:check_in_format_change:
  104|  2.57M|{
  105|  2.57M|    struct chain *p = u->p;
  106|       |
  107|  2.57M|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (107:9): [True: 723k, False: 1.85M]
  ------------------
  108|   723k|        struct mp_image *img = frame.data;
  109|       |
  110|   723k|        if (!mp_image_params_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (110:13): [True: 64.7k, False: 659k]
  ------------------
  111|  64.7k|            if (u == p->input) {
  ------------------
  |  Branch (111:17): [True: 10.7k, False: 53.9k]
  ------------------
  112|  10.7k|                p->public.input_params = img->params;
  113|  53.9k|            } else if (u == p->output) {
  ------------------
  |  Branch (113:24): [True: 10.7k, False: 43.1k]
  ------------------
  114|  10.7k|                p->public.output_params = img->params;
  115|  10.7k|            }
  116|       |
  117|  64.7k|            if (!mp_image_params_static_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (117:17): [True: 64.7k, False: 0]
  ------------------
  118|  64.7k|                MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  64.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  64.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  119|  64.7k|                           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|  64.7k|                if (strcmp(u->name, "convert") == 0)
  ------------------
  |  Branch (128:21): [True: 10.7k, False: 53.9k]
  ------------------
  129|  10.7k|                    update_output_caps(p);
  130|       |
  131|  64.7k|                p->public.reconfig_happened = true;
  132|  64.7k|            }
  133|  64.7k|            u->last_in_vformat = img->params;
  134|  64.7k|        }
  135|   723k|    }
  136|       |
  137|  2.57M|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (137:9): [True: 1.68M, False: 889k]
  ------------------
  138|  1.68M|        struct mp_aframe *aframe = frame.data;
  139|       |
  140|  1.68M|        if (!mp_aframe_config_equals(aframe, u->last_in_aformat)) {
  ------------------
  |  Branch (140:13): [True: 32.5k, False: 1.65M]
  ------------------
  141|  32.5k|            MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  142|  32.5k|                       mp_aframe_format_str(aframe));
  143|  32.5k|            mp_aframe_config_copy(u->last_in_aformat, aframe);
  144|       |
  145|  32.5k|            if (u == p->input) {
  ------------------
  |  Branch (145:17): [True: 8.21k, False: 24.3k]
  ------------------
  146|  8.21k|                mp_aframe_config_copy(p->public.input_aformat, aframe);
  147|  24.3k|            } else if (u == p->output) {
  ------------------
  |  Branch (147:24): [True: 7.95k, False: 16.4k]
  ------------------
  148|  7.95k|                mp_aframe_config_copy(p->public.output_aformat, aframe);
  149|  7.95k|            }
  150|       |
  151|       |            p->public.reconfig_happened = true;
  152|  32.5k|        }
  153|  1.68M|    }
  154|  2.57M|}
f_output_chain.c:user_wrapper_reset:
  231|  3.74k|{
  232|  3.74k|    struct mp_user_filter *u = f->priv;
  233|       |
  234|  3.74k|    u->error_eof_sent = false;
  235|  3.74k|    u->in_eof = false;
  236|  3.74k|    u->last_in_pts = u->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  3.74k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  237|  3.74k|}
f_output_chain.c:relink_filter_list:
  274|  68.2k|{
  275|  68.2k|    struct mp_user_filter **all_filters[3] =
  276|  68.2k|        {p->pre_filters, p->user_filters, p->post_filters};
  277|  68.2k|    int all_filters_num[3] =
  278|  68.2k|        {p->num_pre_filters, p->num_user_filters, p->num_post_filters};
  279|  68.2k|    p->num_all_filters = 0;
  280|   273k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (280:21): [True: 204k, False: 68.2k]
  ------------------
  281|   204k|        struct mp_user_filter **filters = all_filters[n];
  282|   204k|        int filters_num = all_filters_num[n];
  283|   554k|        for (int i = 0; i < filters_num; i++)
  ------------------
  |  Branch (283:25): [True: 349k, False: 204k]
  ------------------
  284|   349k|            MP_TARRAY_APPEND(p, p->all_filters, p->num_all_filters, filters[i]);
  ------------------
  |  |  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: 72.5k, False: 276k]
  |  |  |  |  ------------------
  |  |  |  |   99|   349k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  72.5k|    do {                                                        \
  |  |  |  |  |  |   89|  72.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  72.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  72.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  72.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  72.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  72.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  72.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 72.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  ------------------
  ------------------
  285|   204k|    }
  286|       |
  287|  68.2k|    mp_assert(p->num_all_filters > 0);
  ------------------
  |  |   41|  68.2k|#define mp_assert assert
  ------------------
  |  Branch (287:5): [True: 68.2k, False: 0]
  ------------------
  288|       |
  289|  68.2k|    p->filters_in = NULL;
  290|  68.2k|    p->filters_out = NULL;
  291|   417k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (291:21): [True: 349k, False: 68.2k]
  ------------------
  292|   349k|        struct mp_filter *f = p->all_filters[n]->wrapper;
  293|   349k|        if (n == 0)
  ------------------
  |  Branch (293:13): [True: 68.2k, False: 280k]
  ------------------
  294|  68.2k|            p->filters_in = f->pins[0];
  295|   349k|        if (p->filters_out)
  ------------------
  |  Branch (295:13): [True: 280k, False: 68.2k]
  ------------------
  296|   280k|            mp_pin_connect(f->pins[0], p->filters_out);
  297|   349k|        p->filters_out = f->pins[1];
  298|   349k|    }
  299|       |
  300|  68.2k|    mp_pin_set_manual_connection_for(p->filters_in, p->f);
  301|  68.2k|    mp_pin_set_manual_connection_for(p->filters_out, p->f);
  302|  68.2k|}
f_output_chain.c:set_speed_any:
  530|  68.7k|{
  531|   192k|    for (int n = num_filters - 1; n >= 0; n--) {
  ------------------
  |  Branch (531:35): [True: 123k, False: 68.7k]
  ------------------
  532|   123k|        mp_assert(*speed);
  ------------------
  |  |   41|   123k|#define mp_assert assert
  ------------------
  |  Branch (532:9): [True: 123k, False: 0]
  ------------------
  533|   123k|        struct mp_filter_command cmd = {
  534|   123k|            .type = command,
  535|   123k|            .speed = *speed,
  536|   123k|        };
  537|   123k|        if (mp_filter_command(filters[n]->f, &cmd))
  ------------------
  |  Branch (537:13): [True: 41.2k, False: 82.4k]
  ------------------
  538|  41.2k|            *speed = 1.0;
  539|   123k|    }
  540|  68.7k|}
f_output_chain.c:output_chain_destroy:
  364|  36.2k|{
  365|  36.2k|    output_chain_reset(f);
  366|  36.2k|}
f_output_chain.c:output_chain_process:
  305|  2.30M|{
  306|  2.30M|    struct chain *p = f->priv;
  307|       |
  308|  2.30M|    if (mp_pin_can_transfer_data(p->filters_in, f->ppins[0])) {
  ------------------
  |  Branch (308:9): [True: 574k, False: 1.73M]
  ------------------
  309|   574k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  310|       |
  311|   574k|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (311:13): [True: 32.2k, False: 542k]
  ------------------
  312|   574k|            MP_VERBOSE(p, "filter input EOF\n");
  ------------------
  |  |   92|  32.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  313|       |
  314|   574k|        if (frame.type == MP_FRAME_VIDEO && p->public.update_subtitles) {
  ------------------
  |  Branch (314:13): [True: 120k, False: 454k]
  |  Branch (314:45): [True: 120k, False: 0]
  ------------------
  315|   120k|            p->public.update_subtitles(p->public.update_subtitles_ctx,
  316|   120k|                                       mp_frame_get_pts(frame));
  317|   120k|        }
  318|       |
  319|   574k|        mp_pin_in_write(p->filters_in, frame);
  320|   574k|    }
  321|       |
  322|  2.30M|    if (mp_pin_can_transfer_data(f->ppins[1], p->filters_out)) {
  ------------------
  |  Branch (322:9): [True: 574k, False: 1.73M]
  ------------------
  323|   574k|        struct mp_frame frame = mp_pin_out_read(p->filters_out);
  324|       |
  325|   574k|        p->public.got_output_eof = frame.type == MP_FRAME_EOF;
  326|   574k|        if (p->public.got_output_eof)
  ------------------
  |  Branch (326:13): [True: 32.2k, False: 542k]
  ------------------
  327|   574k|            MP_VERBOSE(p, "filter output EOF\n");
  ------------------
  |  |   92|  32.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  328|       |
  329|   574k|        mp_pin_in_write(f->ppins[1], frame);
  330|   574k|    }
  331|  2.30M|}
f_output_chain.c:create_video_things:
  698|  19.6k|{
  699|  19.6k|    p->frame_type = MP_FRAME_VIDEO;
  700|       |
  701|  19.6k|    p->stream_info.priv = p;
  702|  19.6k|    p->stream_info.get_display_fps = get_display_fps;
  703|  19.6k|    p->stream_info.get_display_res = get_display_res;
  704|       |
  705|  19.6k|    p->f->stream_info = &p->stream_info;
  706|       |
  707|  19.6k|    struct mp_user_filter *f = create_wrapper_filter(p);
  708|  19.6k|    f->name = "userdeint";
  709|  19.6k|    f->f = mp_deint_create(f->wrapper);
  710|  19.6k|    if (!f->f)
  ------------------
  |  Branch (710:9): [True: 0, False: 19.6k]
  ------------------
  711|      0|        abort();
  712|  19.6k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, f);
  ------------------
  |  |  105|  19.6k|    do {                                            \
  |  |  106|  19.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.6k|    do {                                            \
  |  |  |  |   97|  19.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 19.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.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|  19.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.6k|        (idxvar)++;                                 \
  |  |  109|  19.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  713|       |
  714|  19.6k|    f = create_wrapper_filter(p);
  715|  19.6k|    f->name = "autovflip";
  716|  19.6k|    f->f = mp_autovflip_create(f->wrapper);
  717|  19.6k|    if (!f->f)
  ------------------
  |  Branch (717:9): [True: 0, False: 19.6k]
  ------------------
  718|      0|        abort();
  719|  19.6k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  19.6k|    do {                                            \
  |  |  106|  19.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.6k|    do {                                            \
  |  |  |  |   97|  19.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.6k|            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.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.6k|        (idxvar)++;                                 \
  |  |  109|  19.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  720|       |
  721|  19.6k|    f = create_wrapper_filter(p);
  722|  19.6k|    f->name = "autorotate";
  723|  19.6k|    f->f = mp_autorotate_create(f->wrapper);
  724|  19.6k|    if (!f->f)
  ------------------
  |  Branch (724:9): [True: 0, False: 19.6k]
  ------------------
  725|      0|        abort();
  726|  19.6k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  19.6k|    do {                                            \
  |  |  106|  19.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.6k|    do {                                            \
  |  |  |  |   97|  19.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 19.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.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|  19.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.6k|        (idxvar)++;                                 \
  |  |  109|  19.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
  727|  19.6k|}
f_output_chain.c:create_audio_things:
  730|  16.5k|{
  731|  16.5k|    p->frame_type = MP_FRAME_AUDIO;
  732|       |
  733|  16.5k|    struct mp_user_filter *f = create_wrapper_filter(p);
  734|  16.5k|    f->name = "userspeed";
  735|  16.5k|    f->f = mp_autoaspeed_create(f->wrapper);
  736|  16.5k|    if (!f->f)
  ------------------
  |  Branch (736:9): [True: 0, False: 16.5k]
  ------------------
  737|      0|        abort();
  738|  16.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  16.5k|    do {                                            \
  |  |  106|  16.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  16.5k|    do {                                            \
  |  |  |  |   97|  16.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  16.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  16.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  16.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 16.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  16.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  16.5k|    do {                                                        \
  |  |  |  |  |  |   89|  16.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  16.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  16.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  16.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  16.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  16.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  16.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 16.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  16.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 16.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  16.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  16.5k|        (idxvar)++;                                 \
  |  |  109|  16.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 16.5k]
  |  |  ------------------
  ------------------
  739|  16.5k|}
f_output_chain.c:on_audio_format_change:
  472|  8.18k|{
  473|  8.18k|    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.18k|    mp_aframe_config_copy(p->public.output_aformat,
  481|  8.18k|                          p->convert_wrapper->last_in_aformat);
  482|       |
  483|       |    // Ask for calling mp_output_chain_set_ao().
  484|  8.18k|    p->public.ao_needs_update = true;
  485|  8.18k|    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.18k|    mp_filter_wakeup(p->f);
  491|  8.18k|}
f_output_chain.c:output_chain_reset:
  334|  73.2k|{
  335|  73.2k|    struct chain *p = f->priv;
  336|       |
  337|  73.2k|    p->public.ao_needs_update = false;
  338|       |
  339|       |    p->public.got_output_eof = false;
  340|  73.2k|}

mp_sws_supports_input:
   67|    113|{
   68|    113|    return sws_isSupportedInput(imgfmt2pixfmt(imgfmt));
   69|    113|}

mp_subfilter_read:
   94|  2.96M|{
   95|  2.96M|    if (sub->filter) {
  ------------------
  |  Branch (95:9): [True: 0, False: 2.96M]
  ------------------
   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|  2.96M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (111:26): [True: 0, False: 2.96M]
  ------------------
  112|       |
  113|  2.96M|    if (sub->frame.type)
  ------------------
  |  Branch (113:9): [True: 7.99k, False: 2.95M]
  ------------------
  114|  7.99k|        return mp_pin_in_needs_data(out);
  115|       |
  116|  2.95M|    if (!mp_pin_can_transfer_data(out, sub->in))
  ------------------
  |  Branch (116:9): [True: 1.52M, False: 1.42M]
  ------------------
  117|  1.52M|        return false;
  118|       |
  119|  1.42M|    sub->frame = mp_pin_out_read(sub->in);
  120|       |    return true;
  121|  2.95M|}
mp_subfilter_reset:
  124|   114k|{
  125|   114k|    if (sub->filter && sub->draining)
  ------------------
  |  Branch (125:9): [True: 0, False: 114k]
  |  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|   114k|    mp_frame_unref(&sub->frame);
  129|   114k|}
mp_subfilter_continue:
  132|  1.42M|{
  133|  1.42M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (133:26): [True: 0, False: 1.42M]
  ------------------
  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.42M|    if (!mp_pin_in_needs_data(out)) {
  ------------------
  |  Branch (138:9): [True: 0, False: 1.42M]
  ------------------
  139|      0|        mark_progress(sub);
  140|      0|        return;
  141|      0|    }
  142|  1.42M|    mp_pin_in_write(out, sub->frame);
  143|  1.42M|    sub->frame = MP_NO_FRAME;
  ------------------
  |  |   58|  1.42M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  1.42M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  144|  1.42M|}
mp_subfilter_destroy:
  147|   131k|{
  148|   131k|    TA_FREEP(&sub->filter);
  ------------------
  |  |   81|   131k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   131k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 131k]
  |  |  ------------------
  ------------------
  149|       |    sub->draining = false;
  150|   131k|}
mp_subfilter_drain_destroy:
  153|  48.3k|{
  154|  48.3k|    if (!sub->draining && sub->filter) {
  ------------------
  |  Branch (154:9): [True: 48.3k, False: 0]
  |  Branch (154:27): [True: 0, False: 48.3k]
  ------------------
  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|  48.3k|    return !sub->filter;
  161|  48.3k|}
mp_bidir_nop_filter_create:
  168|  72.5k|{
  169|  72.5k|    struct mp_filter *f = mp_filter_create(parent, &bidir_nop_filter);
  170|  72.5k|    if (!f)
  ------------------
  |  Branch (170:9): [True: 0, False: 72.5k]
  ------------------
  171|      0|        return NULL;
  172|       |
  173|  72.5k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  174|  72.5k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  175|       |
  176|  72.5k|    mp_pin_connect(f->ppins[1], f->ppins[0]);
  177|       |
  178|  72.5k|    return f;
  179|  72.5k|}

mp_filter_internal_mark_progress:
  190|   840k|{
  191|   840k|    struct filter_runner *r = f->in->runner;
  192|   840k|    mp_assert(r->filtering); // only call from f's process()
  ------------------
  |  |   41|   840k|#define mp_assert assert
  ------------------
  |  Branch (192:5): [True: 840k, False: 0]
  ------------------
  193|   840k|    add_pending(f);
  194|   840k|}
mp_filter_graph_run:
  212|  1.35M|{
  213|  1.35M|    struct filter_runner *r = filter->in->runner;
  214|  1.35M|    mp_assert(filter == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  1.35M|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 1.35M, False: 0]
  ------------------
  215|       |
  216|  1.35M|    int64_t end_time = 0;
  217|  1.35M|    if (isfinite(r->max_run_time))
  ------------------
  |  Branch (217:9): [True: 418k, False: 936k]
  ------------------
  218|   418k|        end_time = mp_time_ns_add(mp_time_ns(), MPMAX(r->max_run_time, 0));
  ------------------
  |  |   44|   418k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 418k, 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|  1.35M|    mp_assert(!r->filtering);
  ------------------
  |  |   41|  1.35M|#define mp_assert assert
  ------------------
  |  Branch (222:5): [True: 1.35M, False: 2]
  ------------------
  223|       |
  224|  1.35M|    r->filtering = true;
  225|       |
  226|  1.35M|    flush_async_notifications(r);
  227|       |
  228|  1.35M|    bool exit_req = false;
  229|       |
  230|  24.7M|    while (1) {
  ------------------
  |  Branch (230:12): [True: 24.7M, Folded]
  ------------------
  231|  24.7M|        if (atomic_exchange_explicit(&r->interrupt_flag, false,
  ------------------
  |  Branch (231:13): [True: 209, False: 24.7M]
  ------------------
  232|  24.7M|                                     memory_order_acq_rel))
  233|    209|        {
  234|    209|            mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|    209|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  235|    209|            if (!r->async_wakeup_sent && r->wakeup_cb)
  ------------------
  |  Branch (235:17): [True: 198, False: 11]
  |  Branch (235:42): [True: 198, False: 0]
  ------------------
  236|    198|                r->wakeup_cb(r->wakeup_ctx);
  237|    209|            r->async_wakeup_sent = true;
  238|    209|            mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|    209|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  239|    209|            exit_req = true;
  240|    209|        }
  241|       |
  242|  24.7M|        if (!r->num_pending) {
  ------------------
  |  Branch (242:13): [True: 1.40M, False: 23.3M]
  ------------------
  243|  1.40M|            flush_async_notifications(r);
  244|  1.40M|            if (!r->num_pending)
  ------------------
  |  Branch (244:17): [True: 1.35M, False: 45.7k]
  ------------------
  245|  1.35M|                break;
  246|  1.40M|        }
  247|       |
  248|  23.3M|        struct mp_filter *next = NULL;
  249|       |
  250|  23.3M|        if (r->pending[0]->in->high_priority) {
  ------------------
  |  Branch (250:13): [True: 420k, False: 22.9M]
  ------------------
  251|   420k|            next = r->pending[0];
  252|   420k|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, 0);
  ------------------
  |  |  143|   420k|    do {                                            \
  |  |  144|   420k|        size_t at_ = (at);                          \
  |  |  145|   420k|        assert(at_ < (idxvar));                     \
  |  |  146|   420k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   420k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   420k|        (idxvar)--;                                 \
  |  |  149|   420k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 420k]
  |  |  ------------------
  ------------------
  |  Branch (252:13): [True: 420k, False: 0]
  ------------------
  253|  22.9M|        } else if (!exit_req) {
  ------------------
  |  Branch (253:20): [True: 22.9M, False: 18.4E]
  ------------------
  254|  22.9M|            next = r->pending[r->num_pending - 1];
  255|  22.9M|            r->num_pending -= 1;
  256|  22.9M|        }
  257|       |
  258|  23.3M|        if (!next)
  ------------------
  |  Branch (258:13): [True: 209, False: 23.3M]
  ------------------
  259|    209|            break;
  260|       |
  261|  23.3M|        next->in->pending = false;
  262|  23.3M|        if (next->in->info->process)
  ------------------
  |  Branch (262:13): [True: 22.7M, False: 639k]
  ------------------
  263|  22.7M|            next->in->info->process(next);
  264|       |
  265|  23.3M|        if (end_time && mp_time_ns() >= end_time)
  ------------------
  |  Branch (265:13): [True: 22.3M, False: 1.05M]
  |  Branch (265:25): [True: 209, False: 22.3M]
  ------------------
  266|    209|            mp_filter_graph_interrupt(r->root_filter);
  267|  23.3M|    }
  268|       |
  269|  1.35M|    r->filtering = false;
  270|       |
  271|  1.35M|    bool externals = r->external_pending;
  272|       |    r->external_pending = false;
  273|  1.35M|    return externals;
  274|  1.35M|}
mp_pin_can_transfer_data:
  277|  27.7M|{
  278|  27.7M|    return mp_pin_in_needs_data(dst) && mp_pin_out_request_data(src);
  ------------------
  |  Branch (278:12): [True: 21.4M, False: 6.27M]
  |  Branch (278:41): [True: 8.15M, False: 13.3M]
  ------------------
  279|  27.7M|}
mp_pin_in_needs_data:
  290|  49.6M|{
  291|  49.6M|    mp_assert(p->dir == MP_PIN_IN);
  ------------------
  |  |   41|  49.6M|#define mp_assert assert
  ------------------
  |  Branch (291:5): [True: 49.6M, False: 18.4E]
  ------------------
  292|  49.6M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  49.6M|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 49.6M, False: 18.4E]
  ------------------
  293|  49.6M|    return p->conn && p->conn->manual_connection && p->conn->data_requested;
  ------------------
  |  Branch (293:12): [True: 49.6M, False: 18.4E]
  |  Branch (293:23): [True: 49.6M, False: 18.4E]
  |  Branch (293:53): [True: 42.0M, False: 7.56M]
  ------------------
  294|  49.6M|}
mp_pin_in_write:
  297|  11.2M|{
  298|  11.2M|    if (!mp_pin_in_needs_data(p) || frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (298:9): [True: 18.4E, False: 11.2M]
  |  Branch (298:37): [True: 18.4E, False: 11.2M]
  ------------------
  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|  11.2M|    mp_assert(p->conn->data.type == MP_FRAME_NONE);
  ------------------
  |  |   41|  11.2M|#define mp_assert assert
  ------------------
  |  Branch (304:5): [True: 11.2M, False: 18.4E]
  ------------------
  305|  11.2M|    p->conn->data = frame;
  306|  11.2M|    p->conn->data_requested = false;
  307|  11.2M|    add_pending_pin(p->conn);
  308|  11.2M|    filter_recursive(p);
  309|       |    return true;
  310|  11.2M|}
mp_pin_out_has_data:
  313|  56.4M|{
  314|  56.4M|    mp_assert(p->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  56.4M|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 56.4M, False: 18.4E]
  ------------------
  315|  56.4M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  56.4M|#define mp_assert assert
  ------------------
  |  Branch (315:5): [True: 56.4M, False: 18.4E]
  ------------------
  316|  56.4M|    return p->conn && p->conn->manual_connection && p->data.type != MP_FRAME_NONE;
  ------------------
  |  Branch (316:12): [True: 56.4M, False: 1.19k]
  |  Branch (316:23): [True: 56.4M, False: 18.4E]
  |  Branch (316:53): [True: 19.7M, False: 36.6M]
  ------------------
  317|  56.4M|}
mp_pin_out_request_data:
  320|  37.8M|{
  321|  37.8M|    if (mp_pin_out_has_data(p))
  ------------------
  |  Branch (321:9): [True: 19.2M, False: 18.5M]
  ------------------
  322|  19.2M|        return true;
  323|  18.5M|    if (p->conn && p->conn->manual_connection) {
  ------------------
  |  Branch (323:9): [True: 18.5M, False: 18.4E]
  |  Branch (323:20): [True: 18.5M, False: 18.4E]
  ------------------
  324|  18.5M|        if (!p->data_requested) {
  ------------------
  |  Branch (324:13): [True: 11.2M, False: 7.33M]
  ------------------
  325|       |            p->data_requested = true;
  326|  11.2M|            add_pending_pin(p->conn);
  327|  11.2M|        }
  328|  18.5M|        filter_recursive(p);
  329|  18.5M|    }
  330|  18.5M|    return mp_pin_out_has_data(p);
  331|  37.8M|}
mp_pin_out_request_data_next:
  334|   399k|{
  335|   399k|    if (mp_pin_out_request_data(p))
  ------------------
  |  Branch (335:9): [True: 0, False: 399k]
  ------------------
  336|      0|        add_pending_pin(p->conn);
  337|   399k|}
mp_pin_out_read:
  340|  15.5M|{
  341|  15.5M|    if (!mp_pin_out_request_data(p))
  ------------------
  |  Branch (341:9): [True: 4.30M, False: 11.2M]
  ------------------
  342|  4.30M|        return MP_NO_FRAME;
  ------------------
  |  |   58|  4.30M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  4.30M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  343|  11.2M|    struct mp_frame res = p->data;
  344|  11.2M|    p->data = MP_NO_FRAME;
  ------------------
  |  |   58|  11.2M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  11.2M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  345|  11.2M|    return res;
  346|  15.5M|}
mp_pin_connect:
  438|   438k|{
  439|   438k|    mp_assert(src->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   438k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 438k, False: 0]
  ------------------
  440|   438k|    mp_assert(dst->dir == MP_PIN_IN);
  ------------------
  |  |   41|   438k|#define mp_assert assert
  ------------------
  |  Branch (440:5): [True: 438k, False: 0]
  ------------------
  441|       |
  442|   438k|    if (dst->user_conn == src) {
  ------------------
  |  Branch (442:9): [True: 132k, False: 305k]
  ------------------
  443|   132k|        mp_assert(src->user_conn == dst);
  ------------------
  |  |   41|   132k|#define mp_assert assert
  ------------------
  |  Branch (443:9): [True: 132k, False: 0]
  ------------------
  444|   132k|        return;
  445|   132k|    }
  446|       |
  447|   305k|    mp_pin_disconnect(src);
  448|   305k|    mp_pin_disconnect(dst);
  449|       |
  450|   305k|    src->user_conn = dst;
  451|   305k|    dst->user_conn = src;
  452|       |
  453|   305k|    init_connection(src);
  454|   305k|}
mp_pin_set_manual_connection_for:
  462|   136k|{
  463|   136k|    if (p->manual_connection == f)
  ------------------
  |  Branch (463:9): [True: 136k, False: 0]
  ------------------
  464|   136k|        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|  2.64M|{
  500|  2.64M|    if (!mp_pin_is_connected(p))
  ------------------
  |  Branch (500:9): [True: 305k, False: 2.34M]
  ------------------
  501|   305k|        return;
  502|       |
  503|  2.34M|    p->manual_connection = NULL;
  504|       |
  505|  2.34M|    struct mp_pin *conn = p->user_conn;
  506|  2.34M|    if (conn) {
  ------------------
  |  Branch (506:9): [True: 305k, False: 2.03M]
  ------------------
  507|   305k|        p->user_conn = NULL;
  508|   305k|        conn->user_conn = NULL;
  509|   305k|        deinit_connection(conn);
  510|   305k|    }
  511|       |
  512|  2.34M|    deinit_connection(p);
  513|  2.34M|}
mp_pin_is_connected:
  516|  2.64M|{
  517|  2.64M|    return p->user_conn || p->manual_connection;
  ------------------
  |  Branch (517:12): [True: 305k, False: 2.34M]
  |  Branch (517:28): [True: 2.03M, False: 305k]
  ------------------
  518|  2.64M|}
mp_pin_get_dir:
  526|    374|{
  527|    374|    return p->dir;
  528|    374|}
mp_filter_get_info:
  536|  8.07k|{
  537|  8.07k|    return f->in->info;
  538|  8.07k|}
mp_filter_set_high_priority:
  541|  8.07k|{
  542|  8.07k|    f->in->high_priority = pri;
  543|  8.07k|}
mp_filter_get_named_pin:
  552|  1.01M|{
  553|  1.45M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (553:21): [True: 438k, False: 1.01M]
  ------------------
  554|   438k|        if (name && strcmp(f->pins[n]->name, name) == 0)
  ------------------
  |  Branch (554:13): [True: 438k, False: 0]
  |  Branch (554:21): [True: 0, False: 438k]
  ------------------
  555|      0|            return f->pins[n];
  556|   438k|    }
  557|  1.01M|    return NULL;
  558|  1.01M|}
mp_filter_set_error_handler:
  561|  9.66M|{
  562|  9.66M|    f->in->error_handler = handler;
  563|  9.66M|}
mp_filter_has_failed:
  578|  9.66M|{
  579|  9.66M|    bool failed = filter->in->failed;
  580|       |    filter->in->failed = false;
  581|  9.66M|    return failed;
  582|  9.66M|}
mp_filter_reset:
  595|  45.7k|{
  596|  45.7k|    if (!filter)
  ------------------
  |  Branch (596:9): [True: 0, False: 45.7k]
  ------------------
  597|      0|        return;
  598|       |
  599|  61.5k|    for (int n = 0; n < filter->in->num_children; n++)
  ------------------
  |  Branch (599:21): [True: 15.7k, False: 45.7k]
  ------------------
  600|  15.7k|        mp_filter_reset(filter->in->children[n]);
  601|       |
  602|  72.7k|    for (int n = 0; n < filter->num_pins; n++) {
  ------------------
  |  Branch (602:21): [True: 26.9k, False: 45.7k]
  ------------------
  603|  26.9k|        struct mp_pin *p = filter->ppins[n];
  604|  26.9k|        reset_pin(p);
  605|  26.9k|        reset_pin(p->other);
  606|  26.9k|    }
  607|       |
  608|  45.7k|    if (filter->in->info->reset)
  ------------------
  |  Branch (608:9): [True: 11.1k, False: 34.6k]
  ------------------
  609|  11.1k|        filter->in->info->reset(filter);
  610|  45.7k|}
mp_filter_add_pin:
  614|  1.01M|{
  615|  1.01M|    mp_assert(dir == MP_PIN_IN || dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.01M|#define mp_assert assert
  ------------------
  |  Branch (615:5): [True: 463k, False: 555k]
  |  Branch (615:5): [True: 555k, False: 0]
  ------------------
  616|  1.01M|    mp_assert(name && name[0]);
  ------------------
  |  |   41|  1.01M|#define mp_assert assert
  ------------------
  |  Branch (616:5): [True: 1.01M, False: 0]
  |  Branch (616:5): [True: 1.01M, False: 0]
  ------------------
  617|  1.01M|    mp_assert(!mp_filter_get_named_pin(f, name));
  ------------------
  |  |   41|  1.01M|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 1.01M, False: 0]
  ------------------
  618|       |
  619|       |    // "Public" pin
  620|  1.01M|    struct mp_pin *p = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.01M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.01M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.01M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|  1.01M|    *p = (struct mp_pin){
  622|  1.01M|        .name = talloc_strdup(p, name),
  ------------------
  |  |   50|  1.01M|#define talloc_strdup                   ta_xstrdup
  ------------------
  623|  1.01M|        .dir = dir,
  624|  1.01M|        .owner = f,
  625|  1.01M|        .manual_connection = f->in->parent,
  626|  1.01M|    };
  627|       |
  628|       |    // "Private" paired pin
  629|  1.01M|    p->other = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.01M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.01M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.01M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|  1.01M|    *p->other = (struct mp_pin){
  631|  1.01M|        .name = p->name,
  632|  1.01M|        .dir = p->dir == MP_PIN_IN ? MP_PIN_OUT : MP_PIN_IN,
  ------------------
  |  Branch (632:16): [True: 463k, False: 555k]
  ------------------
  633|  1.01M|        .owner = f,
  634|  1.01M|        .other = p,
  635|  1.01M|        .manual_connection = f,
  636|  1.01M|    };
  637|       |
  638|  1.01M|    MP_TARRAY_GROW(f, f->pins, f->num_pins);
  ------------------
  |  |   96|  1.01M|    do {                                            \
  |  |   97|  1.01M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.01M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.01M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.01M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 580k, False: 438k]
  |  |  ------------------
  |  |   99|  1.01M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   580k|    do {                                                        \
  |  |  |  |   89|   580k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   580k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   580k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   580k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   580k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   580k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   580k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 580k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.01M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.01M]
  |  |  ------------------
  ------------------
  639|  1.01M|    MP_TARRAY_GROW(f, f->ppins, f->num_pins);
  ------------------
  |  |   96|  1.01M|    do {                                            \
  |  |   97|  1.01M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.01M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.01M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.01M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 580k, False: 438k]
  |  |  ------------------
  |  |   99|  1.01M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   580k|    do {                                                        \
  |  |  |  |   89|   580k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   580k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   580k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   580k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   580k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   580k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   580k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 580k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.01M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.01M]
  |  |  ------------------
  ------------------
  640|  1.01M|    f->pins[f->num_pins] = p;
  641|  1.01M|    f->ppins[f->num_pins] = p->other;
  642|  1.01M|    f->num_pins += 1;
  643|       |
  644|  1.01M|    init_connection(p);
  645|       |
  646|  1.01M|    return p->other;
  647|  1.01M|}
mp_filter_remove_pin:
  650|  1.01M|{
  651|  1.01M|    if (!p)
  ------------------
  |  Branch (651:9): [True: 0, False: 1.01M]
  ------------------
  652|      0|        return;
  653|       |
  654|  1.01M|    mp_assert(p->owner == f);
  ------------------
  |  |   41|  1.01M|#define mp_assert assert
  ------------------
  |  Branch (654:5): [True: 1.01M, False: 0]
  ------------------
  655|  1.01M|    mp_pin_disconnect(p);
  656|  1.01M|    mp_pin_disconnect(p->other);
  657|       |
  658|  1.01M|    int index = -1;
  659|  1.01M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (659:21): [True: 1.01M, False: 0]
  ------------------
  660|  1.01M|        if (f->ppins[n] == p) {
  ------------------
  |  Branch (660:13): [True: 1.01M, False: 0]
  ------------------
  661|  1.01M|            index = n;
  662|  1.01M|            break;
  663|  1.01M|        }
  664|  1.01M|    }
  665|  1.01M|    mp_assert(index >= 0);
  ------------------
  |  |   41|  1.01M|#define mp_assert assert
  ------------------
  |  Branch (665:5): [True: 1.01M, False: 0]
  ------------------
  666|       |
  667|  1.01M|    talloc_free(f->pins[index]);
  ------------------
  |  |   47|  1.01M|#define talloc_free                     ta_free
  ------------------
  668|  1.01M|    talloc_free(f->ppins[index]);
  ------------------
  |  |   47|  1.01M|#define talloc_free                     ta_free
  ------------------
  669|       |
  670|  1.01M|    int count = f->num_pins;
  671|  1.01M|    MP_TARRAY_REMOVE_AT(f->pins, count, index);
  ------------------
  |  |  143|  1.01M|    do {                                            \
  |  |  144|  1.01M|        size_t at_ = (at);                          \
  |  |  145|  1.01M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.01M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.01M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.01M|        (idxvar)--;                                 \
  |  |  149|  1.01M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.01M]
  |  |  ------------------
  ------------------
  |  Branch (671:5): [True: 1.01M, False: 0]
  ------------------
  672|  1.01M|    count = f->num_pins;
  673|  1.01M|    MP_TARRAY_REMOVE_AT(f->ppins, count, index);
  ------------------
  |  |  143|  1.01M|    do {                                            \
  |  |  144|  1.01M|        size_t at_ = (at);                          \
  |  |  145|  1.01M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.01M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.01M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.01M|        (idxvar)--;                                 \
  |  |  149|  1.01M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.01M]
  |  |  ------------------
  ------------------
  |  Branch (673:5): [True: 1.01M, False: 0]
  ------------------
  674|  1.01M|    f->num_pins -= 1;
  675|  1.01M|}
mp_filter_command:
  678|  2.70M|{
  679|  2.70M|    return f->in->info->command ? f->in->info->command(f, cmd) : false;
  ------------------
  |  Branch (679:12): [True: 1.51M, False: 1.19M]
  ------------------
  680|  2.70M|}
mp_filter_find_stream_info:
  683|  40.3k|{
  684|   140k|    while (f) {
  ------------------
  |  Branch (684:12): [True: 140k, False: 0]
  ------------------
  685|   140k|        if (f->stream_info)
  ------------------
  |  Branch (685:13): [True: 40.3k, False: 99.7k]
  ------------------
  686|  40.3k|            return f->stream_info;
  687|  99.7k|        f = f->in->parent;
  688|  99.7k|    }
  689|      0|    return NULL;
  690|  40.3k|}
mp_filter_wakeup:
  726|   980k|{
  727|       |    filter_wakeup(f, false);
  728|   980k|}
mp_filter_graph_set_max_run_time:
  736|  24.7k|{
  737|  24.7k|    struct filter_runner *r = f->in->runner;
  738|  24.7k|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 24.7k, False: 0]
  ------------------
  739|  24.7k|    r->max_run_time = seconds;
  740|  24.7k|}
mp_filter_graph_interrupt:
  743|    209|{
  744|    209|    struct filter_runner *r = f->in->runner;
  745|    209|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|    209|#define mp_assert assert
  ------------------
  |  Branch (745:5): [True: 209, False: 0]
  ------------------
  746|    209|    atomic_store(&r->interrupt_flag, true);
  747|    209|}
mp_filter_free_children:
  750|   834k|{
  751|  1.28M|    while(f->in->num_children)
  ------------------
  |  Branch (751:11): [True: 455k, False: 834k]
  ------------------
  752|   455k|        talloc_free(f->in->children[0]);
  ------------------
  |  |   47|   455k|#define talloc_free                     ta_free
  ------------------
  753|   834k|}
mp_filter_create_with_params:
  800|   613k|{
  801|   613k|    struct mp_filter *f = talloc(NULL, struct mp_filter);
  ------------------
  |  |   26|   613k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   613k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   613k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|   613k|    talloc_set_destructor(f, filter_destructor);
  ------------------
  |  |   41|   613k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  803|   613k|    *f = (struct mp_filter){
  804|   613k|        .priv = params->info->priv_size ?
  ------------------
  |  Branch (804:17): [True: 455k, False: 158k]
  ------------------
  805|   613k|                    talloc_zero_size(f, params->info->priv_size) : NULL,
  ------------------
  |  |   44|   455k|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|   455k|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   455k|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   455k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   455k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   455k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|   613k|        .global = params->global,
  807|   613k|        .packet_pool = demux_packet_pool_get(params->parent ? params->parent->global : params->global),
  ------------------
  |  Branch (807:46): [True: 580k, False: 32.8k]
  ------------------
  808|   613k|        .in = talloc(f, struct mp_filter_internal),
  ------------------
  |  |   26|   613k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   613k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   613k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|   613k|    };
  810|   613k|    *f->in = (struct mp_filter_internal){
  811|   613k|        .info = params->info,
  812|   613k|        .parent = params->parent,
  813|   613k|        .runner = params->parent ? params->parent->in->runner : NULL,
  ------------------
  |  Branch (813:19): [True: 580k, False: 32.8k]
  ------------------
  814|   613k|    };
  815|       |
  816|   613k|    if (!f->in->runner) {
  ------------------
  |  Branch (816:9): [True: 32.8k, False: 580k]
  ------------------
  817|  32.8k|        mp_assert(params->global);
  ------------------
  |  |   41|  32.8k|#define mp_assert assert
  ------------------
  |  Branch (817:9): [True: 32.8k, False: 0]
  ------------------
  818|       |
  819|  32.8k|        f->in->runner = talloc(NULL, struct filter_runner);
  ------------------
  |  |   26|  32.8k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  32.8k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|  32.8k|        *f->in->runner = (struct filter_runner){
  821|  32.8k|            .global = params->global,
  822|  32.8k|            .root_filter = f,
  823|  32.8k|            .max_run_time = INFINITY,
  824|  32.8k|        };
  825|  32.8k|        mp_mutex_init(&f->in->runner->async_lock);
  826|  32.8k|    }
  827|       |
  828|   613k|    if (!f->global)
  ------------------
  |  Branch (828:9): [True: 580k, False: 32.8k]
  ------------------
  829|   580k|        f->global = f->in->runner->global;
  830|       |
  831|   613k|    if (f->in->parent) {
  ------------------
  |  Branch (831:9): [True: 580k, False: 32.8k]
  ------------------
  832|   580k|        struct mp_filter_internal *parent = f->in->parent->in;
  833|   580k|        MP_TARRAY_APPEND(parent, parent->children, parent->num_children, f);
  ------------------
  |  |  105|   580k|    do {                                            \
  |  |  106|   580k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   580k|    do {                                            \
  |  |  |  |   97|   580k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   580k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   580k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   580k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 402k, False: 177k]
  |  |  |  |  ------------------
  |  |  |  |   99|   580k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   402k|    do {                                                        \
  |  |  |  |  |  |   89|   402k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   402k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   402k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   402k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   402k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   402k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   402k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 402k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   580k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 580k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   580k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   580k|        (idxvar)++;                                 \
  |  |  109|   580k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 580k]
  |  |  ------------------
  ------------------
  834|   580k|        f->log = mp_log_new(f, f->global->log, params->info->name);
  835|   580k|    } else {
  836|  32.8k|        f->log = mp_log_new(f, f->global->log, "!root");
  837|  32.8k|    }
  838|       |
  839|   613k|    if (f->in->info->init) {
  ------------------
  |  Branch (839:9): [True: 0, False: 613k]
  ------------------
  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|   613k|    return f;
  847|   613k|}
mp_filter_create:
  851|   580k|{
  852|   580k|    mp_assert(parent);
  ------------------
  |  |   41|   580k|#define mp_assert assert
  ------------------
  |  Branch (852:5): [True: 580k, False: 0]
  ------------------
  853|   580k|    mp_assert(info);
  ------------------
  |  |   41|   580k|#define mp_assert assert
  ------------------
  |  Branch (853:5): [True: 580k, False: 0]
  ------------------
  854|   580k|    struct mp_filter_params params = {
  855|   580k|        .info = info,
  856|   580k|        .parent = parent,
  857|   580k|    };
  858|   580k|    return mp_filter_create_with_params(&params);
  859|   580k|}
mp_filter_create_root:
  868|  32.8k|{
  869|  32.8k|    struct mp_filter_params params = {
  870|  32.8k|        .info = &filter_root,
  871|  32.8k|        .global = global,
  872|  32.8k|    };
  873|  32.8k|    return mp_filter_create_with_params(&params);
  874|  32.8k|}
mp_filter_graph_set_wakeup_cb:
  878|  32.8k|{
  879|  32.8k|    struct filter_runner *r = root->in->runner;
  880|  32.8k|    mp_assert(root == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  32.8k|#define mp_assert assert
  ------------------
  |  Branch (880:5): [True: 32.8k, False: 0]
  ------------------
  881|  32.8k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  32.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  882|  32.8k|    r->wakeup_cb = wakeup_cb;
  883|  32.8k|    r->wakeup_ctx = ctx;
  884|  32.8k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  32.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  885|  32.8k|}
filter.c:add_pending:
  131|  25.5M|{
  132|  25.5M|    struct filter_runner *r = f->in->runner;
  133|       |
  134|  25.5M|    if (f->in->pending)
  ------------------
  |  Branch (134:9): [True: 2.10M, False: 23.4M]
  ------------------
  135|  2.10M|        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|  23.4M|    f->in->pending = true;
  140|  23.4M|    if (f->in->high_priority) {
  ------------------
  |  Branch (140:9): [True: 425k, False: 23.0M]
  ------------------
  141|   425k|        MP_TARRAY_INSERT_AT(r, r->pending, r->num_pending, 0, f);
  ------------------
  |  |  115|   425k|    do {                                            \
  |  |  116|   425k|        size_t at_ = (at);                          \
  |  |  117|   425k|        assert(at_ <= (idxvar));                    \
  |  |  118|   425k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   425k|    do {                                            \
  |  |  |  |   97|   425k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   425k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   425k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   425k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 425k]
  |  |  |  |  ------------------
  |  |  |  |   99|   425k|            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|   425k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 425k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   425k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   425k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   425k|        (idxvar)++;                                 \
  |  |  122|   425k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   425k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 425k]
  |  |  ------------------
  ------------------
  |  Branch (141:9): [True: 425k, False: 0]
  ------------------
  142|  23.0M|    } else {
  143|  23.0M|        MP_TARRAY_APPEND(r, r->pending, r->num_pending, f);
  ------------------
  |  |  105|  23.0M|    do {                                            \
  |  |  106|  23.0M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  23.0M|    do {                                            \
  |  |  |  |   97|  23.0M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  23.0M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  23.0M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  23.0M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 110k, False: 22.9M]
  |  |  |  |  ------------------
  |  |  |  |   99|  23.0M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   110k|    do {                                                        \
  |  |  |  |  |  |   89|   110k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   110k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   110k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   110k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   110k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   110k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   110k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 110k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  23.0M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 23.0M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  23.0M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  23.0M|        (idxvar)++;                                 \
  |  |  109|  23.0M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 23.0M]
  |  |  ------------------
  ------------------
  144|  23.0M|    }
  145|  23.4M|}
filter.c:flush_async_notifications:
  199|  3.36M|{
  200|  3.36M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  3.36M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  201|  3.87M|    for (int n = 0; n < r->num_async_pending; n++) {
  ------------------
  |  Branch (201:21): [True: 503k, False: 3.36M]
  ------------------
  202|   503k|        struct mp_filter *f = r->async_pending[n];
  203|   503k|        add_pending(f);
  204|   503k|        f->in->async_pending = false;
  205|   503k|    }
  206|  3.36M|    r->num_async_pending = 0;
  207|  3.36M|    r->async_wakeup_sent = false;
  208|  3.36M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  3.36M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  209|  3.36M|}
filter.c:add_pending_pin:
  148|  22.4M|{
  149|  22.4M|    struct mp_filter *f = p->manual_connection;
  150|  22.4M|    mp_assert(f);
  ------------------
  |  |   41|  22.4M|#define mp_assert assert
  ------------------
  |  Branch (150:5): [True: 22.4M, False: 18.4E]
  ------------------
  151|       |
  152|  22.4M|    if (f->in->pending)
  ------------------
  |  Branch (152:9): [True: 872k, False: 21.5M]
  ------------------
  153|   872k|        return;
  154|       |
  155|  21.5M|    add_pending(f);
  156|       |
  157|       |    // Need to tell user that something changed.
  158|  21.5M|    if (f == f->in->runner->root_filter && p != f->in->runner->recursive)
  ------------------
  |  Branch (158:9): [True: 519k, False: 21.0M]
  |  Branch (158:44): [True: 2.23k, False: 516k]
  ------------------
  159|  2.23k|        f->in->runner->external_pending = true;
  160|  21.5M|}
filter.c:filter_recursive:
  169|  29.7M|{
  170|  29.7M|    struct mp_filter *f = p->conn->manual_connection;
  171|  29.7M|    mp_assert(f);
  ------------------
  |  |   41|  29.7M|#define mp_assert assert
  ------------------
  |  Branch (171:5): [True: 29.7M, False: 531]
  ------------------
  172|  29.7M|    struct filter_runner *r = f->in->runner;
  173|       |
  174|       |    // Never do internal filtering recursively.
  175|  29.7M|    if (r->filtering)
  ------------------
  |  Branch (175:9): [True: 28.6M, False: 1.11M]
  ------------------
  176|  28.6M|        return;
  177|       |
  178|  1.11M|    mp_assert(!r->recursive);
  ------------------
  |  |   41|  1.11M|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 1.12M, False: 18.4E]
  ------------------
  179|  1.12M|    r->recursive = p;
  180|       |
  181|       |    // Also don't lose the pending state, which the user may or may not
  182|       |    // care about.
  183|  1.12M|    r->external_pending |= mp_filter_graph_run(r->root_filter);
  184|       |
  185|  1.12M|    mp_assert(r->recursive == p);
  ------------------
  |  |   41|  1.12M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 1.12M, False: 1]
  ------------------
  186|  1.12M|    r->recursive = NULL;
  187|  1.12M|}
filter.c:init_connection:
  385|  1.32M|{
  386|  1.32M|    struct filter_runner *runner = p->owner->in->runner;
  387|       |
  388|  1.32M|    if (p->dir == MP_PIN_IN)
  ------------------
  |  Branch (388:9): [True: 463k, False: 861k]
  ------------------
  389|   463k|        p = p->other;
  390|       |
  391|  1.32M|    struct mp_pin *in = find_connected_end(p);
  392|  1.32M|    struct mp_pin *out = find_connected_end(p->other);
  393|       |
  394|       |    // These are the "outer" pins by definition, they have no user connections.
  395|  1.32M|    mp_assert(!in->user_conn);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (395:5): [True: 1.32M, False: 0]
  ------------------
  396|  1.32M|    mp_assert(!out->user_conn);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 1.32M, False: 0]
  ------------------
  397|       |
  398|       |    // This and similar checks enforce the same root filter requirement.
  399|  1.32M|    if (in->manual_connection)
  ------------------
  |  Branch (399:9): [True: 1.32M, False: 0]
  ------------------
  400|  1.32M|        mp_assert(in->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (400:9): [True: 1.32M, False: 0]
  ------------------
  401|  1.32M|    if (out->manual_connection)
  ------------------
  |  Branch (401:9): [True: 1.32M, False: 0]
  ------------------
  402|  1.32M|        mp_assert(out->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (402:9): [True: 1.32M, 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|  1.32M|    if (!in->manual_connection || !out->manual_connection)
  ------------------
  |  Branch (408:9): [True: 0, False: 1.32M]
  |  Branch (408:35): [True: 0, False: 1.32M]
  ------------------
  409|      0|        return;
  410|       |
  411|  1.32M|    mp_assert(in->dir == MP_PIN_IN);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (411:5): [True: 1.32M, False: 0]
  ------------------
  412|  1.32M|    mp_assert(out->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.32M|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 1.32M, False: 0]
  ------------------
  413|       |
  414|  1.32M|    struct mp_pin *cur = in;
  415|  2.98M|    while (cur) {
  ------------------
  |  Branch (415:12): [True: 1.66M, False: 1.32M]
  ------------------
  416|  1.66M|        mp_assert(!cur->within_conn && !cur->other->within_conn);
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (416:9): [True: 1.66M, False: 0]
  |  Branch (416:9): [True: 1.66M, False: 0]
  ------------------
  417|  1.66M|        mp_assert(!cur->conn && !cur->other->conn);
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (417:9): [True: 1.66M, False: 0]
  |  Branch (417:9): [True: 1.66M, False: 0]
  ------------------
  418|  1.66M|        mp_assert(!cur->data_requested); // unused for in pins
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (418:9): [True: 1.66M, False: 0]
  ------------------
  419|  1.66M|        mp_assert(!cur->data.type); // unused for in pins
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (419:9): [True: 1.66M, False: 0]
  ------------------
  420|  1.66M|        mp_assert(!cur->other->data_requested); // unset for unconnected out pins
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (420:9): [True: 1.66M, False: 0]
  ------------------
  421|  1.66M|        mp_assert(!cur->other->data.type); // unset for unconnected out pins
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (421:9): [True: 1.66M, False: 0]
  ------------------
  422|  1.66M|        mp_assert(cur->owner->in->runner == runner);
  ------------------
  |  |   41|  1.66M|#define mp_assert assert
  ------------------
  |  Branch (422:9): [True: 1.66M, False: 0]
  ------------------
  423|  1.66M|        cur->within_conn = cur->other->within_conn = true;
  424|  1.66M|        cur = cur->other->user_conn;
  425|  1.66M|    }
  426|       |
  427|  1.32M|    in->conn = out;
  428|  1.32M|    in->within_conn = false;
  429|  1.32M|    out->conn = in;
  430|  1.32M|    out->within_conn = false;
  431|       |
  432|       |    // Scheduling so far will be messed up.
  433|  1.32M|    add_pending(in->manual_connection);
  434|  1.32M|    add_pending(out->manual_connection);
  435|  1.32M|}
filter.c:find_connected_end:
  372|  5.29M|{
  373|  5.90M|    while (1) {
  ------------------
  |  Branch (373:12): [True: 5.90M, Folded]
  ------------------
  374|  5.90M|        struct mp_pin *other = p->other;
  375|  5.90M|        if (!other->user_conn)
  ------------------
  |  Branch (375:13): [True: 5.29M, False: 602k]
  ------------------
  376|  5.29M|            return other;
  377|   602k|        p = other->user_conn;
  378|   602k|    }
  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|  2.64M|{
  478|  2.64M|    if (p->dir == MP_PIN_OUT)
  ------------------
  |  Branch (478:9): [True: 1.32M, False: 1.32M]
  ------------------
  479|  1.32M|        p = p->other;
  480|       |
  481|  2.64M|    p = find_connected_end(p);
  482|       |
  483|  5.59M|    while (p) {
  ------------------
  |  Branch (483:12): [True: 2.94M, False: 2.64M]
  ------------------
  484|  2.94M|        p->conn = p->other->conn = NULL;
  485|  2.94M|        p->within_conn = p->other->within_conn = false;
  486|  2.94M|        mp_assert(!p->other->data_requested); // unused for in pins
  ------------------
  |  |   41|  2.94M|#define mp_assert assert
  ------------------
  |  Branch (486:9): [True: 2.94M, False: 0]
  ------------------
  487|  2.94M|        mp_assert(!p->other->data.type); // unused for in pins
  ------------------
  |  |   41|  2.94M|#define mp_assert assert
  ------------------
  |  Branch (487:9): [True: 2.94M, False: 0]
  ------------------
  488|  2.94M|        if (p->data.type)
  ------------------
  |  Branch (488:13): [True: 0, False: 2.94M]
  ------------------
  489|  2.94M|            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|  2.94M|        if (p->data_requested)
  ------------------
  |  Branch (490:13): [True: 12.6k, False: 2.93M]
  ------------------
  491|  2.94M|            MP_VERBOSE(p->owner, "dropping request due to pin disconnect\n");
  ------------------
  |  |   92|  12.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  492|       |        p->data_requested = false;
  493|  2.94M|        mp_frame_unref(&p->data);
  494|  2.94M|        p = p->other->user_conn;
  495|  2.94M|    }
  496|  2.64M|}
filter.c:reset_pin:
  585|  53.8k|{
  586|  53.8k|    if (!p->conn || p->dir != MP_PIN_OUT) {
  ------------------
  |  Branch (586:9): [True: 12.7k, False: 41.1k]
  |  Branch (586:21): [True: 20.5k, False: 20.5k]
  ------------------
  587|  33.2k|        mp_assert(!p->data.type);
  ------------------
  |  |   41|  33.2k|#define mp_assert assert
  ------------------
  |  Branch (587:9): [True: 33.2k, False: 0]
  ------------------
  588|  33.2k|        mp_assert(!p->data_requested);
  ------------------
  |  |   41|  33.2k|#define mp_assert assert
  ------------------
  |  Branch (588:9): [True: 33.2k, False: 0]
  ------------------
  589|  33.2k|    }
  590|  53.8k|    mp_frame_unref(&p->data);
  591|       |    p->data_requested = false;
  592|  53.8k|}
filter.c:filter_wakeup:
  709|   980k|{
  710|   980k|    struct filter_runner *r = f->in->runner;
  711|   980k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|   980k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  712|   980k|    if (!f->in->async_pending) {
  ------------------
  |  Branch (712:9): [True: 503k, False: 477k]
  ------------------
  713|   503k|        f->in->async_pending = true;
  714|       |        // (not using a talloc parent for thread safety reasons)
  715|   503k|        MP_TARRAY_APPEND(NULL, r->async_pending, r->num_async_pending, f);
  ------------------
  |  |  105|   503k|    do {                                            \
  |  |  106|   503k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   503k|    do {                                            \
  |  |  |  |   97|   503k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   503k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   503k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   503k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 30.5k, False: 473k]
  |  |  |  |  ------------------
  |  |  |  |   99|   503k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  30.5k|    do {                                                        \
  |  |  |  |  |  |   89|  30.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  30.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  30.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  30.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  30.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  30.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  30.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 30.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   503k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 503k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   503k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   503k|        (idxvar)++;                                 \
  |  |  109|   503k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 503k]
  |  |  ------------------
  ------------------
  716|   503k|    }
  717|   980k|    if (!mark_only && !r->async_wakeup_sent) {
  ------------------
  |  Branch (717:9): [True: 980k, False: 0]
  |  Branch (717:23): [True: 464k, False: 516k]
  ------------------
  718|   464k|        if (r->wakeup_cb)
  ------------------
  |  Branch (718:13): [True: 456k, False: 8.07k]
  ------------------
  719|   456k|            r->wakeup_cb(r->wakeup_ctx);
  720|   464k|        r->async_wakeup_sent = true;
  721|   464k|    }
  722|   980k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|   980k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  723|   980k|}
filter.c:filter_destructor:
  756|   613k|{
  757|   613k|    struct mp_filter *f = p;
  758|   613k|    struct filter_runner *r = f->in->runner;
  759|       |
  760|   613k|    if (f->in->info->destroy)
  ------------------
  |  Branch (760:9): [True: 491k, False: 121k]
  ------------------
  761|   491k|        f->in->info->destroy(f);
  762|       |
  763|       |    // For convenience, free child filters.
  764|   613k|    mp_filter_free_children(f);
  765|       |
  766|  1.63M|    while (f->num_pins)
  ------------------
  |  Branch (766:12): [True: 1.01M, False: 613k]
  ------------------
  767|  1.01M|        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|   613k|    flush_async_notifications(r);
  772|       |
  773|  1.56M|    for (int n = 0; n < r->num_pending; n++) {
  ------------------
  |  Branch (773:21): [True: 1.02M, False: 542k]
  ------------------
  774|  1.02M|        if (r->pending[n] == f) {
  ------------------
  |  Branch (774:13): [True: 71.0k, False: 950k]
  ------------------
  775|  71.0k|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, n);
  ------------------
  |  |  143|  71.0k|    do {                                            \
  |  |  144|  71.0k|        size_t at_ = (at);                          \
  |  |  145|  71.0k|        assert(at_ < (idxvar));                     \
  |  |  146|  71.0k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  71.0k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  71.0k|        (idxvar)--;                                 \
  |  |  149|  71.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 71.0k]
  |  |  ------------------
  ------------------
  |  Branch (775:13): [True: 71.0k, False: 0]
  ------------------
  776|  71.0k|            break;
  777|  71.0k|        }
  778|  1.02M|    }
  779|       |
  780|   613k|    if (f->in->parent) {
  ------------------
  |  Branch (780:9): [True: 580k, False: 32.8k]
  ------------------
  781|   580k|        struct mp_filter_internal *p_in = f->in->parent->in;
  782|   804k|        for (int n = 0; n < p_in->num_children; n++) {
  ------------------
  |  Branch (782:25): [True: 804k, False: 0]
  ------------------
  783|   804k|            if (p_in->children[n] == f) {
  ------------------
  |  Branch (783:17): [True: 580k, False: 223k]
  ------------------
  784|   580k|                MP_TARRAY_REMOVE_AT(p_in->children, p_in->num_children, n);
  ------------------
  |  |  143|   580k|    do {                                            \
  |  |  144|   580k|        size_t at_ = (at);                          \
  |  |  145|   580k|        assert(at_ < (idxvar));                     \
  |  |  146|   580k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   580k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   580k|        (idxvar)--;                                 \
  |  |  149|   580k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 580k]
  |  |  ------------------
  ------------------
  |  Branch (784:17): [True: 580k, False: 0]
  ------------------
  785|   580k|                break;
  786|   580k|            }
  787|   804k|        }
  788|   580k|    }
  789|       |
  790|   613k|    if (r->root_filter == f) {
  ------------------
  |  Branch (790:9): [True: 32.8k, False: 580k]
  ------------------
  791|  32.8k|        mp_assert(!f->in->parent);
  ------------------
  |  |   41|  32.8k|#define mp_assert assert
  ------------------
  |  Branch (791:9): [True: 32.8k, False: 0]
  ------------------
  792|  32.8k|        mp_mutex_destroy(&r->async_lock);
  ------------------
  |  |  133|  32.8k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  793|  32.8k|        talloc_free(r->async_pending);
  ------------------
  |  |   47|  32.8k|#define talloc_free                     ta_free
  ------------------
  794|  32.8k|        talloc_free(r);
  ------------------
  |  |   47|  32.8k|#define talloc_free                     ta_free
  ------------------
  795|  32.8k|    }
  796|   613k|}

mp_frame_is_signaling:
  137|  1.20M|{
  138|  1.20M|    return frame_handlers[frame.type].is_signaling;
  139|  1.20M|}
mp_frame_unref:
  142|  3.31M|{
  143|  3.31M|    if (!frame)
  ------------------
  |  Branch (143:9): [True: 0, False: 3.31M]
  ------------------
  144|      0|        return;
  145|       |
  146|  3.31M|    if (frame_handlers[frame->type].free)
  ------------------
  |  Branch (146:9): [True: 49.4k, False: 3.26M]
  ------------------
  147|  49.4k|        frame_handlers[frame->type].free(frame->data);
  148|       |
  149|  3.31M|    *frame = (struct mp_frame){0};
  150|  3.31M|}
mp_frame_ref:
  153|    106|{
  154|    106|    if (frame_handlers[frame.type].new_ref) {
  ------------------
  |  Branch (154:9): [True: 106, False: 0]
  ------------------
  155|    106|        mp_assert(frame.data);
  ------------------
  |  |   41|    106|#define mp_assert assert
  ------------------
  |  Branch (155:9): [True: 106, False: 0]
  ------------------
  156|    106|        frame.data = frame_handlers[frame.type].new_ref(frame.data);
  157|    106|        if (!frame.data)
  ------------------
  |  Branch (157:13): [True: 0, False: 106]
  ------------------
  158|      0|            frame.type = MP_FRAME_NONE;
  159|    106|    }
  160|    106|    return frame;
  161|    106|}
mp_frame_get_pts:
  164|  5.27M|{
  165|  5.27M|    if (frame_handlers[frame.type].get_pts)
  ------------------
  |  Branch (165:9): [True: 4.94M, False: 331k]
  ------------------
  166|  4.94M|        return frame_handlers[frame.type].get_pts(frame.data);
  167|   331k|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|   331k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  5.27M|}
mp_frame_approx_size:
  177|   784k|{
  178|   784k|    if (frame_handlers[frame.type].approx_size)
  ------------------
  |  Branch (178:9): [True: 770k, False: 13.2k]
  ------------------
  179|   770k|        return frame_handlers[frame.type].approx_size(frame.data);
  180|  13.2k|    return 0;
  181|   784k|}
frame.c:video_ref:
   24|    106|{
   25|    106|    return mp_image_new_ref(data);
   26|    106|}
frame.c:video_get_pts:
   29|  1.56M|{
   30|  1.56M|    return ((struct mp_image *)data)->pts;
   31|  1.56M|}
frame.c:audio_get_pts:
   59|  3.37M|{
   60|  3.37M|    return mp_aframe_get_pts(data);
   61|  3.37M|}
frame.c:audio_approx_size:
   69|   770k|{
   70|   770k|    return mp_aframe_approx_byte_size(data);
   71|   770k|}

mp_create_user_filter:
  151|    113|{
  152|    113|    const struct m_obj_list *obj_list = NULL;
  153|    113|    enum mp_frame_type frame_type = 0;
  154|    113|    if (type == MP_OUTPUT_CHAIN_VIDEO) {
  ------------------
  |  Branch (154:9): [True: 113, False: 0]
  ------------------
  155|    113|        frame_type = MP_FRAME_VIDEO;
  156|    113|        obj_list = &vf_obj_list;
  157|    113|    } else if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (157:16): [True: 0, False: 0]
  ------------------
  158|      0|        frame_type = MP_FRAME_AUDIO;
  159|      0|        obj_list = &af_obj_list;
  160|      0|    }
  161|    113|    mp_assert(frame_type && obj_list);
  ------------------
  |  |   41|    113|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 113, False: 0]
  |  Branch (161:5): [True: 113, False: 0]
  ------------------
  162|       |
  163|    113|    struct mp_filter *f = NULL;
  164|       |
  165|    113|    struct m_obj_desc desc;
  166|    113|    if (!m_obj_list_find(&desc, obj_list, bstr0(name))) {
  ------------------
  |  Branch (166:9): [True: 113, False: 0]
  ------------------
  167|       |        // Generic lavfi bridge.
  168|    113|        if (strncmp(name, "lavfi-", 6) == 0)
  ------------------
  |  Branch (168:13): [True: 0, False: 113]
  ------------------
  169|      0|            name += 6;
  170|    113|        struct mp_lavfi *l =
  171|    113|            mp_lavfi_create_filter(parent, frame_type, true, NULL, NULL, name, args);
  172|    113|        if (l)
  ------------------
  |  Branch (172:13): [True: 0, False: 113]
  ------------------
  173|      0|            f = l->f;
  174|    113|        goto done;
  175|    113|    }
  176|       |
  177|      0|    void *options = NULL;
  178|      0|    if (desc.options) {
  ------------------
  |  Branch (178:9): [True: 0, False: 0]
  ------------------
  179|      0|        struct m_config *config =
  180|      0|            m_config_from_obj_desc_and_args(NULL, parent->log, parent->global,
  181|      0|                                            &desc, args);
  182|       |
  183|      0|        if (!config)
  ------------------
  |  Branch (183:13): [True: 0, False: 0]
  ------------------
  184|      0|            goto done;
  185|       |
  186|      0|        options = config->optstruct;
  187|       |        // Free config when options is freed.
  188|      0|        ta_set_parent(options, NULL);
  189|      0|        ta_set_parent(config, options);
  190|      0|    }
  191|       |
  192|      0|    const struct mp_user_filter_entry *entry = desc.p;
  193|      0|    f = entry->create(parent, options);
  194|       |
  195|    113|done:
  196|    113|    if (!f) {
  ------------------
  |  Branch (196:9): [True: 113, False: 0]
  ------------------
  197|    113|        MP_ERR(parent, "Creating filter '%s' failed.\n", name);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  198|    113|        return NULL;
  199|    113|    }
  200|      0|    return f;
  201|    113|}
user_filters.c:get_af_desc:
   48|   222k|{
   49|   222k|    return get_desc_from(af_list, MP_ARRAY_SIZE(af_list), dst, index);
  ------------------
  |  |   49|   222k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
   50|   222k|}
user_filters.c:get_desc_from:
   14|   347k|{
   15|   347k|    if (index >= num)
  ------------------
  |  Branch (15:9): [True: 49.6k, False: 297k]
  ------------------
   16|  49.6k|        return false;
   17|   297k|    const struct mp_user_filter_entry *entry = list[index];
   18|   297k|    *dst = entry->desc;
   19|   297k|    dst->p = entry;
   20|       |    return true;
   21|   347k|}
user_filters.c:get_vf_desc:
  113|   124k|{
  114|   124k|    return get_desc_from(vf_list, MP_ARRAY_SIZE(vf_list), dst, index);
  ------------------
  |  |   49|   124k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  115|   124k|}

fuzzer_load.c:set_fontconfig_sysroot:
   54|  24.7k|{
   55|  24.7k|#ifdef MPV_FONTCONFIG_SYSROOT
   56|  24.7k|    const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT);
  ------------------
  |  |   35|  24.7k|#define MPV_STRINGIFY(X) MPV_STRINGIFY_(X)
  |  |  ------------------
  |  |  |  |   34|  24.7k|#define MPV_STRINGIFY_(X) #X
  |  |  ------------------
  ------------------
   57|  24.7k|    char path[PATH_MAX];
   58|  24.7k|    if (sysroot[0] != '/') {
  ------------------
  |  Branch (58:9): [True: 24.7k, False: 0]
  ------------------
   59|  24.7k|        ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);
   60|  24.7k|        if (len < 0)
  ------------------
  |  Branch (60:13): [True: 0, False: 24.7k]
  ------------------
   61|      0|            exit(1);
   62|  24.7k|        path[len] = '\0';
   63|  24.7k|        char *name = strrchr(path, '/') + 1;
   64|  24.7k|        snprintf(name, path + sizeof(path) - name, "%s", sysroot);
   65|  24.7k|        sysroot = path;
   66|  24.7k|    }
   67|  24.7k|    setenv("FONTCONFIG_SYSROOT", sysroot, 1);
   68|  24.7k|#endif
   69|  24.7k|}
fuzzer_load.c:check_error:
   38|   297k|{
   39|   297k|    if (status < 0) {
  ------------------
  |  Branch (39:9): [True: 0, False: 297k]
  ------------------
   40|       |        fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status));
   41|      0|        exit(1);
   42|      0|    }
   43|   297k|}
fuzzer_load.c:initialize:
  100|  24.7k|{
  101|  24.7k|    check_error(mpv_initialize(ctx));
  102|  24.7k|    if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx))
  ------------------
  |  Branch (102:9): [True: 0, False: 24.7k]
  |  Branch (102:45): [True: 0, False: 24.7k]
  ------------------
  103|      0|        exit(1);
  104|  24.7k|}
fuzzer_load.c:wait_event:
   72|  24.7k|{
   73|  24.7k|    while (1) {
  ------------------
  |  Branch (73:12): [True: 24.7k, Folded]
  ------------------
   74|  24.7k|        mpv_event *event = mpv_wait_event(ctx, -1);
   75|  24.7k|        if (event->event_id == id)
  ------------------
  |  Branch (75:13): [True: 24.7k, False: 0]
  ------------------
   76|  24.7k|            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|  24.7k|}
fuzzer_load.c:sync_core:
   84|  49.5k|{
   85|  49.5k|    uint64_t sync_id = 1;
   86|  49.5k|    mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE);
   87|  49.5k|    bool ok;
   88|  49.7k|    while (1) {
  ------------------
  |  Branch (88:12): [True: 49.7k, Folded]
  ------------------
   89|  49.7k|        mpv_event *event = mpv_wait_event(ctx, -1);
   90|  49.7k|        ok = event->event_id != MPV_EVENT_SHUTDOWN;
   91|  49.7k|        if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE &&
  ------------------
  |  Branch (91:13): [True: 24.6k, False: 25.1k]
  |  Branch (91:21): [True: 24.8k, False: 240]
  ------------------
   92|  24.8k|                    event->reply_userdata == sync_id))
  ------------------
  |  Branch (92:21): [True: 24.8k, False: 0]
  ------------------
   93|  49.5k|            break;
   94|  49.7k|    }
   95|  49.5k|    mpv_unobserve_property(ctx, sync_id);
   96|  49.5k|    return ok;
   97|  49.5k|}
fuzzer_load.c:player_loop:
  122|  24.7k|{
  123|  24.7k|    bool playing = false;
  124|  24.7k|    bool loaded = false;
  125|  24.7k|    int timeout = -1;
  126|  24.7k|    int events_limit_after_restart = EVENTS_LIMIT;
  ------------------
  |  |  118|  24.7k|#define EVENTS_LIMIT 10
  ------------------
  127|   241k|    while (1) {
  ------------------
  |  Branch (127:12): [True: 241k, Folded]
  ------------------
  128|   241k|        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|   241k|        if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0)
  ------------------
  |  |  114|   482k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  |  Branch (131:13): [True: 64.7k, False: 176k]
  |  Branch (131:47): [True: 143, False: 64.5k]
  ------------------
  132|    143|            break;
  133|   241k|        if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE)
  ------------------
  |  |  114|   482k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  |  Branch (133:13): [True: 64.5k, False: 176k]
  |  Branch (133:47): [True: 3, False: 64.5k]
  ------------------
  134|      3|            break;
  135|   241k|        if (event->event_id == MPV_EVENT_START_FILE)
  ------------------
  |  Branch (135:13): [True: 24.7k, False: 216k]
  ------------------
  136|  24.7k|            loaded = playing = true;
  137|   241k|        if (event->event_id == MPV_EVENT_END_FILE) {
  ------------------
  |  Branch (137:13): [True: 24.6k, False: 216k]
  ------------------
  138|  24.6k|            playing = false;
  139|  24.6k|            events_limit_after_restart = EVENTS_LIMIT;
  ------------------
  |  |  118|  24.6k|#define EVENTS_LIMIT 10
  ------------------
  140|  24.6k|            timeout = -1;
  141|  24.6k|        }
  142|   241k|        if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART)
  ------------------
  |  Branch (142:13): [True: 167k, False: 73.9k]
  |  Branch (142:24): [True: 21.9k, False: 145k]
  ------------------
  143|  21.9k|            timeout = PLAYBACK_TIME_LIMIT;
  ------------------
  |  |  114|  21.9k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  144|   241k|        if (loaded && event->event_id == MPV_EVENT_IDLE)
  ------------------
  |  Branch (144:13): [True: 241k, False: 0]
  |  Branch (144:23): [True: 24.6k, False: 216k]
  ------------------
  145|  24.6k|            break;
  146|   241k|    }
  147|  24.7k|}
fuzzer_load.c:destroy:
  107|  24.7k|{
  108|  24.7k|    if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED)
  ------------------
  |  Branch (108:9): [True: 24.7k, False: 0]
  ------------------
  109|  24.7k|        sync_core(ctx);
  110|  24.7k|    mpv_terminate_destroy(ctx);
  111|  24.7k|}

LLVMFuzzerTestOneInput:
   29|  24.7k|{
   30|  24.7k|    if (size > MAX_FUZZ_SIZE)
  ------------------
  |  |   30|  24.7k|#define MAX_FUZZ_SIZE (100 << 10) // 100 KiB
  ------------------
  |  Branch (30:9): [True: 4, False: 24.7k]
  ------------------
   31|      4|        return 0;
   32|       |
   33|       |#ifdef MPV_LOAD_CONFIG_FILE
   34|       |    // config file size limit, see m_config_parse_config_file()
   35|       |    if (size > 1000000000)
   36|       |        return 0;
   37|       |#endif
   38|       |
   39|       |#ifdef MPV_LOAD_INPUT_CONF
   40|       |    // input config file size limit, see parse_config_file() in input.c
   41|       |    if (size > 1000000)
   42|       |        return 0;
   43|       |#endif
   44|       |
   45|       |    // fmemopen doesn't have associated file descriptor, so we do copy.
   46|  24.7k|    int fd = memfd_create("fuzz_mpv_load", MFD_CLOEXEC | MFD_ALLOW_SEALING);
   47|  24.7k|    if (fd == -1)
  ------------------
  |  Branch (47:9): [True: 0, False: 24.7k]
  ------------------
   48|      0|        exit(1);
   49|  24.7k|    if (fd != 42 && (dup3(fd, 42, O_CLOEXEC) != 42 || close(fd)))
  ------------------
  |  Branch (49:9): [True: 24.7k, False: 0]
  |  Branch (49:22): [True: 0, False: 24.7k]
  |  Branch (49:55): [True: 0, False: 24.7k]
  ------------------
   50|      0|        exit(1);
   51|  24.7k|    fd = 42;
   52|  24.7k|    ssize_t written = 0;
   53|  49.5k|    while (written < size) {
  ------------------
  |  Branch (53:12): [True: 24.7k, False: 24.7k]
  ------------------
   54|  24.7k|        ssize_t result = write(fd, data + written, size - written);
   55|  24.7k|        if (result == -1)
  ------------------
  |  Branch (55:13): [True: 0, False: 24.7k]
  ------------------
   56|      0|            exit(1);
   57|  24.7k|        written += result;
   58|  24.7k|    }
   59|  24.7k|    if (fcntl(fd, F_ADD_SEALS, F_SEAL_WRITE | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_SEAL) != 0)
  ------------------
  |  Branch (59:9): [True: 0, False: 24.7k]
  ------------------
   60|      0|        exit(1);
   61|  24.7k|    if (lseek(fd, 0, SEEK_SET) != 0)
  ------------------
  |  Branch (61:9): [True: 0, False: 24.7k]
  ------------------
   62|      0|        exit(1);
   63|  24.7k|    char filename[5 + 10 + 1];
   64|  24.7k|    if (sprintf(filename, "fd://%d", fd) <= 5)
  ------------------
  |  Branch (64:9): [True: 0, False: 24.7k]
  ------------------
   65|      0|        exit(1);
   66|       |
   67|  24.7k|    set_fontconfig_sysroot();
   68|       |
   69|  24.7k|    mpv_handle *ctx = mpv_create();
   70|  24.7k|    if (!ctx)
  ------------------
  |  Branch (70:9): [True: 0, False: 24.7k]
  ------------------
   71|      0|        exit(1);
   72|       |
   73|  24.7k|    check_error(mpv_set_option_string(ctx, "vo", "null"));
   74|  24.7k|    check_error(mpv_set_option_string(ctx, "ao", "null"));
   75|  24.7k|    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
   76|  24.7k|    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
   77|  24.7k|    check_error(mpv_set_option_string(ctx, "image-display-duration", "0"));
   78|  24.7k|    check_error(mpv_set_option_string(ctx, "video-osd", "no"));
   79|  24.7k|    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
   80|  24.7k|    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
   81|  24.7k|    check_error(mpv_set_option_string(ctx, "input-builtin-bindings", "no"));
   82|  24.7k|#ifdef MPV_DEMUXER
   83|  24.7k|    check_error(mpv_set_option_string(ctx, "demuxer", MPV_DEMUXER));
   84|  24.7k|#endif
   85|       |
   86|  24.7k|    const char *url = filename;
   87|       |#ifdef MPV_SUB_FILE
   88|       |    mpv_node node = {
   89|       |        .format = MPV_FORMAT_NODE_ARRAY,
   90|       |        .u.list = &(mpv_node_list) {
   91|       |            .num = 1,
   92|       |            .values = &(mpv_node) {
   93|       |                .format = MPV_FORMAT_STRING,
   94|       |                .u.string = filename,
   95|       |            },
   96|       |        },
   97|       |    };
   98|       |    check_error(mpv_set_option(ctx, "sub-files", MPV_FORMAT_NODE, &node));
   99|       |    check_error(mpv_set_option_string(ctx, "sub-filter-sdh", "yes"));
  100|       |    check_error(mpv_set_option_string(ctx, "vf", "sub"));
  101|       |    url = "av://lavfi:yuvtestsrc=d=1";
  102|       |#endif
  103|       |
  104|  24.7k|    initialize(ctx);
  105|       |
  106|  24.7k|    const char *cmd[] = {"load" MPV_LOAD, url, NULL};
  107|  24.7k|    check_error(mpv_command(ctx, cmd));
  108|       |
  109|  24.7k|#ifdef MPV_LOADFILE
  110|  24.7k|    player_loop(ctx);
  111|  24.7k|#endif
  112|       |
  113|  24.7k|    destroy(ctx);
  114|       |
  115|  24.7k|    if (close(fd))
  ------------------
  |  Branch (115:9): [True: 0, False: 24.7k]
  ------------------
  116|      0|        exit(1);
  117|       |
  118|  24.7k|    return 0;
  119|  24.7k|}

mp_input_parse_cmd_node:
  293|  74.2k|{
  294|  74.2k|    struct mp_cmd *cmd = talloc_ptrtype(NULL, cmd);
  ------------------
  |  |   34|  74.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  74.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  74.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  74.2k|    talloc_set_destructor(cmd, destroy_cmd);
  ------------------
  |  |   41|  74.2k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  296|  74.2k|    *cmd = (struct mp_cmd) { .scale = 1, .scale_units = 1 };
  297|       |
  298|  74.2k|    bool res = false;
  299|  74.2k|    if (node->format == MPV_FORMAT_NODE_ARRAY) {
  ------------------
  |  Branch (299:9): [True: 74.2k, False: 0]
  ------------------
  300|  74.2k|        res = cmd_node_array(log, cmd, node);
  301|  74.2k|    } 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|  74.2k|    res = res && finish_cmd(log, cmd);
  ------------------
  |  Branch (305:11): [True: 74.2k, False: 0]
  |  Branch (305:18): [True: 74.2k, False: 0]
  ------------------
  306|       |
  307|  74.2k|    if (!res)
  ------------------
  |  Branch (307:9): [True: 0, False: 74.2k]
  ------------------
  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|  74.2k|    return cmd;
  311|  74.2k|}
mp_input_parse_cmd_strv:
  513|  74.2k|{
  514|  74.2k|    int count = 0;
  515|   173k|    while (argv[count])
  ------------------
  |  Branch (515:12): [True: 99.0k, False: 74.2k]
  ------------------
  516|  99.0k|        count++;
  517|  74.2k|    mpv_node *items = talloc_zero_array(NULL, mpv_node, count);
  ------------------
  |  |   30|  74.2k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  74.2k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  74.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|  74.2k|    mpv_node_list list = {.values = items, .num = count};
  519|  74.2k|    mpv_node node = {.format = MPV_FORMAT_NODE_ARRAY, .u = {.list = &list}};
  520|   173k|    for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (520:21): [True: 99.0k, False: 74.2k]
  ------------------
  521|  99.0k|        items[n] = (mpv_node){.format = MPV_FORMAT_STRING,
  522|  99.0k|                              .u = {.string = (char *)argv[n]}};
  523|  99.0k|    }
  524|  74.2k|    struct mp_cmd *res = mp_input_parse_cmd_node(log, &node);
  525|  74.2k|    talloc_free(items);
  ------------------
  |  |   47|  74.2k|#define talloc_free                     ta_free
  ------------------
  526|  74.2k|    return res;
  527|  74.2k|}
mp_cmd_dump:
  582|  74.2k|{
  583|  74.2k|    if (!mp_msg_test(log, msgl))
  ------------------
  |  Branch (583:9): [True: 0, False: 74.2k]
  ------------------
  584|      0|        return;
  585|  74.2k|    if (header)
  ------------------
  |  Branch (585:9): [True: 74.2k, False: 0]
  ------------------
  586|  74.2k|        mp_msg(log, msgl, "%s ", header);
  587|  74.2k|    if (!cmd) {
  ------------------
  |  Branch (587:9): [True: 0, False: 74.2k]
  ------------------
  588|      0|        mp_msg(log, msgl, "(NULL)\n");
  589|      0|        return;
  590|      0|    }
  591|  74.2k|    mp_msg(log, msgl, "%s, flags=%d, args=[", cmd->name, cmd->flags);
  592|  74.2k|    int argc = get_arg_count(cmd->def);
  593|   222k|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (593:21): [True: 148k, False: 74.2k]
  ------------------
  594|   148k|        const char *argname = cmd->def->args[MPMIN(n, argc - 1)].name;
  ------------------
  |  |   45|   148k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 148k]
  |  |  ------------------
  ------------------
  595|   148k|        char *s = m_option_print(cmd->args[n].type, &cmd->args[n].v);
  596|   148k|        if (n)
  ------------------
  |  Branch (596:13): [True: 74.2k, False: 74.2k]
  ------------------
  597|  74.2k|            mp_msg(log, msgl, ", ");
  598|   148k|        struct mpv_node node = {
  599|   148k|            .format = MPV_FORMAT_STRING,
  600|   148k|            .u.string = s ? s : "(NULL)",
  ------------------
  |  Branch (600:25): [True: 148k, False: 0]
  ------------------
  601|   148k|        };
  602|   148k|        char *esc = NULL;
  603|   148k|        json_write(&esc, &node);
  604|   148k|        mp_msg(log, msgl, "%s=%s", argname, esc ? esc : "<error>");
  ------------------
  |  Branch (604:45): [True: 148k, False: 0]
  ------------------
  605|   148k|        talloc_free(esc);
  ------------------
  |  |   47|   148k|#define talloc_free                     ta_free
  ------------------
  606|   148k|        talloc_free(s);
  ------------------
  |  |   47|   148k|#define talloc_free                     ta_free
  ------------------
  607|   148k|    }
  608|  74.2k|    mp_msg(log, msgl, "]\n");
  609|  74.2k|}
cmd.c:destroy_cmd:
   33|  74.2k|{
   34|  74.2k|    struct mp_cmd *cmd = ptr;
   35|   222k|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (35:21): [True: 148k, False: 74.2k]
  ------------------
   36|   148k|        if (cmd->args[n].type)
  ------------------
  |  Branch (36:13): [True: 148k, False: 0]
  ------------------
   37|   148k|            m_option_free(cmd->args[n].type, &cmd->args[n].v);
   38|   148k|    }
   39|  74.2k|}
cmd.c:cmd_node_array:
  200|  74.2k|{
  201|  74.2k|    mp_assert(node->format == MPV_FORMAT_NODE_ARRAY);
  ------------------
  |  |   41|  74.2k|#define mp_assert assert
  ------------------
  |  Branch (201:5): [True: 74.2k, False: 0]
  ------------------
  202|  74.2k|    mpv_node_list *args = node->u.list;
  203|  74.2k|    int cur = 0;
  204|       |
  205|  74.2k|    while (cur < args->num) {
  ------------------
  |  Branch (205:12): [True: 74.2k, False: 0]
  ------------------
  206|  74.2k|        if (args->values[cur].format != MPV_FORMAT_STRING)
  ------------------
  |  Branch (206:13): [True: 0, False: 74.2k]
  ------------------
  207|      0|            break;
  208|  74.2k|        if (!apply_flag(cmd, bstr0(args->values[cur].u.string)))
  ------------------
  |  Branch (208:13): [True: 74.2k, False: 0]
  ------------------
  209|  74.2k|            break;
  210|      0|        cur++;
  211|      0|    }
  212|       |
  213|  74.2k|    bstr cmd_name = {0};
  214|  74.2k|    if (cur < args->num && args->values[cur].format == MPV_FORMAT_STRING)
  ------------------
  |  Branch (214:9): [True: 74.2k, False: 0]
  |  Branch (214:28): [True: 74.2k, False: 0]
  ------------------
  215|  74.2k|        cmd_name = bstr0(args->values[cur++].u.string);
  216|  74.2k|    if (!find_cmd(log, cmd, cmd_name))
  ------------------
  |  Branch (216:9): [True: 0, False: 74.2k]
  ------------------
  217|      0|        return false;
  218|       |
  219|  74.2k|    int first = cur;
  220|  99.0k|    for (int i = 0; i < args->num - first; i++) {
  ------------------
  |  Branch (220:21): [True: 24.7k, False: 74.2k]
  ------------------
  221|  24.7k|        if (!set_node_arg(log, cmd, cmd->nargs, &args->values[cur++]))
  ------------------
  |  Branch (221:13): [True: 0, False: 24.7k]
  ------------------
  222|      0|            return false;
  223|  24.7k|    }
  224|       |
  225|  74.2k|    return true;
  226|  74.2k|}
cmd.c:apply_flag:
   63|  74.2k|{
   64|   965k|    for (int n = 0; cmd_flags[n].name; n++) {
  ------------------
  |  Branch (64:21): [True: 891k, False: 74.2k]
  ------------------
   65|   891k|        if (bstr_equals0(str, cmd_flags[n].name)) {
  ------------------
  |  Branch (65:13): [True: 0, False: 891k]
  ------------------
   66|      0|            cmd->flags = (cmd->flags & ~cmd_flags[n].remove) | cmd_flags[n].add;
   67|      0|            return true;
   68|      0|        }
   69|   891k|    }
   70|  74.2k|    return false;
   71|  74.2k|}
cmd.c:find_cmd:
   74|  74.2k|{
   75|  74.2k|    if (name.len == 0) {
  ------------------
  |  Branch (75:9): [True: 0, False: 74.2k]
  ------------------
   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|  74.2k|    char nname[80];
   81|  74.2k|    snprintf(nname, sizeof(nname), "%.*s", BSTR_P(name));
  ------------------
  |  |  307|  74.2k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 74.2k, False: 0]
  |  |  ------------------
  ------------------
   82|   470k|    for (int n = 0; nname[n]; n++) {
  ------------------
  |  Branch (82:21): [True: 396k, False: 74.2k]
  ------------------
   83|   396k|        if (nname[n] == '_')
  ------------------
  |  Branch (83:13): [True: 0, False: 396k]
  ------------------
   84|      0|            nname[n] = '-';
   85|   396k|    }
   86|       |
   87|  1.13M|    for (int n = 0; mp_cmds[n].name; n++) {
  ------------------
  |  Branch (87:21): [True: 1.13M, False: 0]
  ------------------
   88|  1.13M|        if (strcmp(nname, mp_cmds[n].name) == 0) {
  ------------------
  |  Branch (88:13): [True: 74.2k, False: 1.06M]
  ------------------
   89|  74.2k|            cmd->def = &mp_cmds[n];
   90|  74.2k|            cmd->name = (char *)cmd->def->name;
   91|  74.2k|            return true;
   92|  74.2k|        }
   93|  1.13M|    }
   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|  74.2k|}
cmd.c:set_node_arg:
  161|  24.7k|{
  162|  24.7k|    const char *name = get_arg_name(cmd->def, i);
  ------------------
  |  |  123|  24.7k|    ((i) < MP_CMD_DEF_MAX_ARGS && (cmd)->args[(i)].name &&      \
  |  |  ------------------
  |  |  |  |   26|  49.5k|#define MP_CMD_DEF_MAX_ARGS 15
  |  |  ------------------
  |  |  |  Branch (123:6): [True: 24.7k, False: 0]
  |  |  |  Branch (123:35): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |  124|  24.7k|     (cmd)->args[(i)].name[0]                                   \
  |  |  ------------------
  |  |  |  Branch (124:6): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |  125|  24.7k|     ? (cmd)->args[(i)].name : mp_tprintf(10, "%d", (i) + 1))
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  163|       |
  164|  24.7k|    const struct m_option *opt = get_arg_type(cmd->def, i);
  165|  24.7k|    if (!opt) {
  ------------------
  |  Branch (165:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if (i < cmd->nargs && cmd->args[i].type) {
  ------------------
  |  Branch (170:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    struct mp_cmd_arg arg = {.type = opt};
  176|  24.7k|    void *dst = &arg.v;
  177|  24.7k|    int r = m_option_set_node_or_string(log, opt, bstr0(cmd->name), dst, val);
  178|  24.7k|    if (r < 0) {
  ------------------
  |  Branch (178:9): [True: 0, False: 24.7k]
  ------------------
  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|  49.5k|    while (i >= cmd->nargs) {
  ------------------
  |  Branch (190:12): [True: 24.7k, False: 24.7k]
  ------------------
  191|  24.7k|        struct mp_cmd_arg t = {0};
  192|  24.7k|        MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, t);
  ------------------
  |  |  105|  24.7k|    do {                                            \
  |  |  106|  24.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.7k|    do {                                            \
  |  |  |  |   97|  24.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.7k|        (idxvar)++;                                 \
  |  |  109|  24.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  193|  24.7k|    }
  194|       |
  195|  24.7k|    cmd->args[i] = arg;
  196|       |    return true;
  197|  24.7k|}
cmd.c:get_arg_type:
  104|   222k|{
  105|   222k|    const struct m_option *opt = NULL;
  106|   222k|    if (is_vararg(cmd, i)) {
  ------------------
  |  Branch (106:9): [True: 0, False: 222k]
  ------------------
  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|   222k|    } else if (i < MP_CMD_DEF_MAX_ARGS) {
  ------------------
  |  |   26|   222k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (114:16): [True: 222k, False: 0]
  ------------------
  115|   222k|        opt = &cmd->args[i];
  116|   222k|    }
  117|   222k|    return opt && opt->type ? opt : NULL;
  ------------------
  |  Branch (117:12): [True: 222k, False: 0]
  |  Branch (117:19): [True: 148k, False: 74.2k]
  ------------------
  118|   222k|}
cmd.c:is_vararg:
   99|   346k|{
  100|   346k|    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: 346k]
  |  Branch (100:26): [True: 0, False: 0]
  |  Branch (100:58): [True: 0, False: 0]
  ------------------
  101|   346k|}
cmd.c:finish_cmd:
  129|  74.2k|{
  130|   222k|    for (int i = 0; i < MP_CMD_DEF_MAX_ARGS; i++) {
  ------------------
  |  |   26|   222k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (130:21): [True: 222k, False: 0]
  ------------------
  131|       |        // (type==NULL is used for yet unset arguments)
  132|   222k|        if (i < cmd->nargs && cmd->args[i].type)
  ------------------
  |  Branch (132:13): [True: 24.7k, False: 198k]
  |  Branch (132:31): [True: 24.7k, False: 0]
  ------------------
  133|  24.7k|            continue;
  134|   198k|        const struct m_option *opt = get_arg_type(cmd->def, i);
  135|   198k|        if (i >= cmd->nargs && (!opt || is_vararg(cmd->def, i)))
  ------------------
  |  Branch (135:13): [True: 198k, False: 0]
  |  Branch (135:33): [True: 74.2k, False: 123k]
  |  Branch (135:41): [True: 0, False: 123k]
  ------------------
  136|  74.2k|            break;
  137|   123k|        if (!opt->defval && !(opt->flags & MP_CMD_OPT_ARG)) {
  ------------------
  |  |   27|  99.0k|#define MP_CMD_OPT_ARG M_OPT_OPTIONAL_PARAM
  |  |  ------------------
  |  |  |  |  497|  99.0k|#define M_OPT_OPTIONAL_PARAM    (UINT64_C(1) << 54)
  |  |  ------------------
  ------------------
  |  Branch (137:13): [True: 99.0k, False: 24.7k]
  |  Branch (137:29): [True: 0, False: 99.0k]
  ------------------
  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|   123k|        struct mp_cmd_arg arg = {.type = opt};
  143|   123k|        if (opt->defval)
  ------------------
  |  Branch (143:13): [True: 24.7k, False: 99.0k]
  ------------------
  144|  24.7k|            m_option_copy(opt, &arg.v, opt->defval);
  145|   123k|        mp_assert(i <= cmd->nargs);
  ------------------
  |  |   41|   123k|#define mp_assert assert
  ------------------
  |  Branch (145:9): [True: 123k, False: 0]
  ------------------
  146|   123k|        if (i == cmd->nargs) {
  ------------------
  |  Branch (146:13): [True: 123k, False: 0]
  ------------------
  147|   123k|            MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, arg);
  ------------------
  |  |  105|   123k|    do {                                            \
  |  |  106|   123k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   123k|    do {                                            \
  |  |  |  |   97|   123k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   123k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   123k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   123k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 74.2k, False: 49.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|   123k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  74.2k|    do {                                                        \
  |  |  |  |  |  |   89|  74.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  74.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  74.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  74.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  74.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  74.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  74.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 74.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   123k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 123k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   123k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   123k|        (idxvar)++;                                 \
  |  |  109|   123k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 123k]
  |  |  ------------------
  ------------------
  148|   123k|        } else {
  149|      0|            cmd->args[i] = arg;
  150|      0|        }
  151|   123k|    }
  152|       |
  153|  74.2k|    if (!(cmd->flags & (MP_ASYNC_CMD | MP_SYNC_CMD)))
  ------------------
  |  Branch (153:9): [True: 74.2k, False: 0]
  ------------------
  154|  74.2k|        cmd->flags |= cmd->def->default_async ? MP_ASYNC_CMD : MP_SYNC_CMD;
  ------------------
  |  Branch (154:23): [True: 0, False: 74.2k]
  ------------------
  155|       |
  156|       |    return true;
  157|  74.2k|}
cmd.c:get_arg_count:
  573|  74.2k|{
  574|  1.03M|    for (int i = MP_CMD_DEF_MAX_ARGS - 1; i >= 0; i--) {
  ------------------
  |  |   26|  74.2k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (574:43): [True: 1.03M, False: 0]
  ------------------
  575|  1.03M|        if (cmd->args[i].type)
  ------------------
  |  Branch (575:13): [True: 74.2k, False: 965k]
  ------------------
  576|  74.2k|            return i + 1;
  577|  1.03M|    }
  578|      0|    return 0;
  579|  74.2k|}

mp_dnd_init:
  148|  24.7k|{
  149|  24.7k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  150|       |    // Nothing drops files here, the thread only makes coverage timing dependent.
  151|  24.7k|    mpv_destroy(mpv);
  152|  24.7k|    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|  19.6k|{
  887|  19.6k|    input_lock(ictx);
  ------------------
  |  |   58|  19.6k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  19.6k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  888|  19.6k|    ictx->mouse_mangle = dst || src;
  ------------------
  |  Branch (888:26): [True: 0, False: 19.6k]
  |  Branch (888:33): [True: 0, False: 19.6k]
  ------------------
  889|  19.6k|    if (ictx->mouse_mangle) {
  ------------------
  |  Branch (889:9): [True: 0, False: 19.6k]
  ------------------
  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|  19.6k|    input_unlock(ictx);
  ------------------
  |  |   59|  19.6k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  19.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  896|  19.6k|}
mp_input_get_mouse_event_counter:
 1321|   248k|{
 1322|       |    // Make the frontend always display the mouse cursor (as long as it's not
 1323|       |    // forced invisible) if mouse input is desired.
 1324|   248k|    input_lock(ictx);
  ------------------
  |  |   58|   248k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|   248k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1325|   248k|    if (test_mouse_active(ictx, ictx->mouse_x, ictx->mouse_y))
  ------------------
  |  Branch (1325:9): [True: 0, False: 248k]
  ------------------
 1326|      0|        ictx->mouse_event_counter++;
 1327|   248k|    int ret = ictx->mouse_event_counter;
 1328|   248k|    input_unlock(ictx);
  ------------------
  |  |   59|   248k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|   248k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1329|   248k|    return ret;
 1330|   248k|}
mp_input_get_delay:
 1387|   504k|{
 1388|   504k|    input_lock(ictx);
  ------------------
  |  |   58|   504k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|   504k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1389|   504k|    double seconds = INFINITY;
 1390|   504k|    adjust_max_wait_time(ictx, &seconds);
 1391|   504k|    input_unlock(ictx);
  ------------------
  |  |   59|   504k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|   504k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1392|   504k|    return seconds;
 1393|   504k|}
mp_input_read_cmd:
 1401|   504k|{
 1402|   504k|    input_lock(ictx);
  ------------------
  |  |   58|   504k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|   504k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1403|   504k|    struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue);
 1404|   504k|    if (!ret)
  ------------------
  |  Branch (1404:9): [True: 504k, False: 0]
  ------------------
 1405|   504k|        ret = check_autorepeat(ictx);
 1406|   504k|    if (ret && ret->mouse_move) {
  ------------------
  |  Branch (1406:9): [True: 0, False: 504k]
  |  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|   504k|    input_unlock(ictx);
  ------------------
  |  |   59|   504k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|   504k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1411|   504k|    return ret;
 1412|   504k|}
mp_input_enable_section:
 1453|  24.7k|{
 1454|  24.7k|    bstr bname = bstr0(name);
 1455|  24.7k|    input_lock(ictx);
  ------------------
  |  |   58|  24.7k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1456|  24.7k|    bname = normalize_section(ictx, bname);
 1457|       |
 1458|  24.7k|    disable_section(ictx, bname);
 1459|       |
 1460|  24.7k|    MP_TRACE(ictx, "enable section '%.*s'\n", BSTR_P(bname));
  ------------------
  |  |   94|  24.7k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  49.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1461|       |
 1462|  24.7k|    int top = ictx->num_active_sections;
 1463|  24.7k|    if (!(flags & MP_INPUT_ON_TOP)) {
  ------------------
  |  Branch (1463:9): [True: 24.7k, False: 0]
  ------------------
 1464|       |        // insert before the first top entry
 1465|  24.7k|        for (top = 0; top < ictx->num_active_sections; top++) {
  ------------------
  |  Branch (1465:23): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    }
 1470|  24.7k|    MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,
  ------------------
  |  |  115|  24.7k|    do {                                            \
  |  |  116|  24.7k|        size_t at_ = (at);                          \
  |  |  117|  24.7k|        assert(at_ <= (idxvar));                    \
  |  |  118|  24.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.7k|    do {                                            \
  |  |  |  |   97|  24.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  24.7k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  24.7k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  24.7k|        (idxvar)++;                                 \
  |  |  122|  24.7k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  24.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  |  Branch (1470:5): [True: 24.7k, False: 0]
  ------------------
 1471|  24.7k|                        top, (struct active_section){bname, flags});
 1472|       |
 1473|  24.7k|    MP_TRACE(ictx, "active section stack:\n");
  ------------------
  |  |   94|  24.7k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1474|  49.5k|    for (int n = 0; n < ictx->num_active_sections; n++) {
  ------------------
  |  Branch (1474:21): [True: 24.7k, False: 24.7k]
  ------------------
 1475|  24.7k|        MP_TRACE(ictx, " %.*s %d\n", BSTR_P(ictx->active_sections[n].name),
  ------------------
  |  |   94|  24.7k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  49.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|  24.7k|                 ictx->active_sections[n].flags);
 1477|  24.7k|    }
 1478|       |
 1479|  24.7k|    input_unlock(ictx);
  ------------------
  |  |   59|  24.7k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1480|  24.7k|}
mp_input_remove_sections_by_owner:
 1545|  49.5k|{
 1546|  49.5k|    input_lock(ictx);
  ------------------
  |  |   58|  49.5k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1547|  99.0k|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (1547:21): [True: 49.5k, False: 49.5k]
  ------------------
 1548|  49.5k|        struct cmd_bind_section *bs = ictx->sections[n];
 1549|  49.5k|        if (bs->owner && owner && strcmp(bs->owner, owner) == 0) {
  ------------------
  |  Branch (1549:13): [True: 0, False: 49.5k]
  |  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|  49.5k|    }
 1555|  49.5k|    input_unlock(ictx);
  ------------------
  |  |   59|  49.5k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1556|  49.5k|}
mp_input_init:
 1717|  24.7k|{
 1718|       |
 1719|  24.7k|    struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
  ------------------
  |  |   34|  24.7k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.7k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1720|  24.7k|    *ictx = (struct input_ctx){
 1721|  24.7k|        .global = global,
 1722|  24.7k|        .ar_state = -1,
 1723|  24.7k|        .log = mp_log_new(ictx, global->log, "input"),
 1724|  24.7k|        .mouse_section = bstr0("default"),
 1725|  24.7k|        .opts_cache = m_config_cache_alloc(ictx, global, &input_config),
 1726|  24.7k|        .wakeup_cb = wakeup_cb,
 1727|  24.7k|        .wakeup_ctx = wakeup_ctx,
 1728|  24.7k|        .active_sections = talloc_array(ictx, struct active_section, 0),
  ------------------
  |  |   29|  24.7k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  24.7k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1729|  24.7k|        .touch_points = talloc_array(ictx, struct touch_point, 0),
  ------------------
  |  |   29|  24.7k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  24.7k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|  24.7k|        .dnd_action = DND_NONE,
 1731|  24.7k|    };
 1732|       |
 1733|  24.7k|    ictx->opts = ictx->opts_cache->opts;
 1734|       |
 1735|  24.7k|    mp_mutex_init(&ictx->mutex);
 1736|       |
 1737|       |    // Setup default section, so that it does nothing.
 1738|  24.7k|    mp_input_enable_section(ictx, NULL, MP_INPUT_ALLOW_VO_DRAGGING |
 1739|  24.7k|                                        MP_INPUT_ALLOW_HIDE_CURSOR);
 1740|       |
 1741|  24.7k|    return ictx;
 1742|  24.7k|}
mp_input_update_opts:
 1763|  24.7k|{
 1764|  24.7k|    input_lock(ictx);
  ------------------
  |  |   58|  24.7k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1765|  24.7k|    reload_opts(ictx, false);
 1766|  24.7k|    input_unlock(ictx);
  ------------------
  |  |   59|  24.7k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1767|  24.7k|}
mp_input_load_config:
 1770|  24.7k|{
 1771|  24.7k|    input_lock(ictx);
  ------------------
  |  |   58|  24.7k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1772|       |
 1773|  24.7k|    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|  24.7k|    bstr builtin = bstr0(builtin_input_conf);
 1778|  24.7k|    while (ictx->opts->builtin_bindings && builtin.len) {
  ------------------
  |  Branch (1778:12): [True: 0, False: 24.7k]
  |  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|  24.7k|    bool config_ok = false;
 1786|  24.7k|    if (ictx->opts->config_file && ictx->opts->config_file[0])
  ------------------
  |  Branch (1786:9): [True: 0, False: 24.7k]
  |  Branch (1786:36): [True: 0, False: 0]
  ------------------
 1787|      0|        config_ok = parse_config_file(ictx, ictx->opts->config_file);
 1788|  24.7k|    if (!config_ok) {
  ------------------
  |  Branch (1788:9): [True: 24.7k, False: 0]
  ------------------
 1789|       |        // Try global conf dir
 1790|  24.7k|        void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  24.7k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.7k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1791|  24.7k|        char **files = mp_find_all_config_files(tmp, ictx->global, "input.conf");
 1792|  24.7k|        for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1792:25): [True: 24.7k, False: 0]
  |  Branch (1792:34): [True: 0, False: 24.7k]
  ------------------
 1793|      0|            parse_config_file(ictx, files[n]);
 1794|  24.7k|        talloc_free(tmp);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1795|  24.7k|    }
 1796|       |
 1797|  24.7k|    bool use_gamepad = ictx->opts->use_gamepad;
 1798|  24.7k|    input_unlock(ictx);
  ------------------
  |  |   59|  24.7k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  24.7k|#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|  24.7k|    (void)use_gamepad;
 1805|  24.7k|#endif
 1806|  24.7k|}
mp_input_uninit:
 1826|  24.7k|{
 1827|  24.7k|    if (!ictx)
  ------------------
  |  Branch (1827:9): [True: 0, False: 24.7k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  24.7k|    input_lock(ictx);
  ------------------
  |  |   58|  24.7k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1831|  24.7k|    reload_opts(ictx, true);
 1832|  24.7k|    input_unlock(ictx);
  ------------------
  |  |   59|  24.7k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1833|       |
 1834|  24.7k|    close_input_sources(ictx);
 1835|  24.7k|    clear_queue(&ictx->cmd_queue);
 1836|  24.7k|    talloc_free(ictx->current_down_cmd);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1837|  24.7k|    mp_mutex_destroy(&ictx->mutex);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1838|  24.7k|    talloc_free(ictx);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 1839|  24.7k|}
input.c:test_mouse_active:
 1266|   248k|{
 1267|   248k|    return test_mouse(ictx, x, y, MP_INPUT_ALLOW_HIDE_CURSOR);
 1268|   248k|}
input.c:test_mouse:
 1250|   248k|{
 1251|   248k|    bool res = false;
 1252|   496k|    for (int i = 0; i < ictx->num_active_sections; i++) {
  ------------------
  |  Branch (1252:21): [True: 248k, False: 248k]
  ------------------
 1253|   248k|        struct active_section *as = &ictx->active_sections[i];
 1254|   248k|        if (as->flags & rej_flags)
  ------------------
  |  Branch (1254:13): [True: 248k, False: 0]
  ------------------
 1255|   248k|            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|   248k|    return res;
 1263|   248k|}
input.c:adjust_max_wait_time:
 1334|   504k|{
 1335|   504k|    struct input_opts *opts = ictx->opts;
 1336|   504k|    if (ictx->last_key_down && opts->ar_rate > 0 && ictx->ar_state >= 0) {
  ------------------
  |  Branch (1336:9): [True: 0, False: 504k]
  |  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|   504k|}
input.c:queue_remove_head:
  301|   504k|{
  302|   504k|    struct mp_cmd *ret = queue->first;
  303|   504k|    if (ret)
  ------------------
  |  Branch (303:9): [True: 0, False: 504k]
  ------------------
  304|      0|        queue_remove(queue, ret);
  305|   504k|    return ret;
  306|   504k|}
input.c:check_autorepeat:
 1353|   504k|{
 1354|   504k|    struct input_opts *opts = ictx->opts;
 1355|       |
 1356|       |    // No input : autorepeat ?
 1357|   504k|    if (opts->ar_rate <= 0 || !ictx->current_down_cmd || !ictx->last_key_down ||
  ------------------
  |  Branch (1357:9): [True: 0, False: 504k]
  |  Branch (1357:31): [True: 504k, 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|   504k|        ictx->ar_state = -1; // disable
 1361|       |
 1362|   504k|    if (ictx->ar_state >= 0) {
  ------------------
  |  Branch (1362:9): [True: 0, False: 504k]
  ------------------
 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|   504k|    return NULL;
 1384|   504k|}
input.c:disable_section:
 1432|  24.7k|{
 1433|  24.7k|    name = normalize_section(ictx, name);
 1434|       |
 1435|       |    // Remove old section, or make sure it's on top if re-enabled
 1436|  24.7k|    for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
  ------------------
  |  Branch (1436:49): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|}
input.c:normalize_section:
 1427|  49.5k|{
 1428|  49.5k|    return get_bind_section(ictx, name)->section;
 1429|  49.5k|}
input.c:get_bind_section:
  406|  49.5k|{
  407|  49.5k|    if (section.len == 0)
  ------------------
  |  Branch (407:9): [True: 24.7k, False: 24.7k]
  ------------------
  408|  24.7k|        section = bstr0("default");
  409|  49.5k|    struct cmd_bind_section *bind_section = find_section(ictx, section);
  410|  49.5k|    if (bind_section)
  ------------------
  |  Branch (410:9): [True: 24.7k, False: 24.7k]
  ------------------
  411|  24.7k|        return bind_section;
  412|  24.7k|    bind_section = talloc_ptrtype(ictx, bind_section);
  ------------------
  |  |   34|  24.7k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.7k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|  24.7k|    *bind_section = (struct cmd_bind_section) {
  414|  24.7k|        .section = bstrdup(bind_section, section),
  415|  24.7k|        .mouse_area = {INT_MIN, INT_MIN, INT_MAX, INT_MAX},
  416|  24.7k|        .mouse_area_set = true,
  417|  24.7k|    };
  418|  24.7k|    MP_TARRAY_APPEND(ictx, ictx->sections, ictx->num_sections, bind_section);
  ------------------
  |  |  105|  24.7k|    do {                                            \
  |  |  106|  24.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.7k|    do {                                            \
  |  |  |  |   97|  24.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.7k|        (idxvar)++;                                 \
  |  |  109|  24.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  419|  24.7k|    return bind_section;
  420|  49.5k|}
input.c:find_section:
  395|  49.5k|{
  396|  49.5k|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (396:21): [True: 24.7k, False: 24.7k]
  ------------------
  397|  24.7k|        struct cmd_bind_section *bs = ictx->sections[n];
  398|  24.7k|        if (bstr_equals(section, bs->section))
  ------------------
  |  Branch (398:13): [True: 24.7k, False: 0]
  ------------------
  399|  24.7k|            return bs;
  400|  24.7k|    }
  401|  24.7k|    return NULL;
  402|  49.5k|}
input.c:reload_opts:
 1745|  74.2k|{
 1746|  74.2k|    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|  74.2k|}
input.c:clear_queue:
 1817|  24.7k|{
 1818|  24.7k|    while (queue->first) {
  ------------------
  |  Branch (1818:12): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|}
input.c:close_input_sources:
 1976|  24.7k|{
 1977|       |    // To avoid lock-order issues, we first remove each source from the context,
 1978|       |    // and then destroy it.
 1979|  24.7k|    while (1) {
  ------------------
  |  Branch (1979:12): [True: 24.7k, Folded]
  ------------------
 1980|  24.7k|        input_lock(ictx);
  ------------------
  |  |   58|  24.7k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1981|  24.7k|        struct mp_input_src *src = ictx->num_sources ? ictx->sources[0] : NULL;
  ------------------
  |  Branch (1981:36): [True: 0, False: 24.7k]
  ------------------
 1982|  24.7k|        input_unlock(ictx);
  ------------------
  |  |   59|  24.7k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1983|  24.7k|        if (!src)
  ------------------
  |  Branch (1983:13): [True: 24.7k, False: 0]
  ------------------
 1984|  24.7k|            break;
 1985|      0|        input_src_kill(src);
 1986|      0|    }
 1987|  24.7k|}

mp_init_ipc:
  408|  24.7k|{
  409|  24.7k|    struct MPOpts *opts = mp_get_config_group(NULL, global, &mp_opt_root);
  410|       |
  411|  24.7k|    struct mp_ipc_ctx *arg = talloc_ptrtype(NULL, arg);
  ------------------
  |  |   34|  24.7k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.7k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|  24.7k|    *arg = (struct mp_ipc_ctx){
  413|  24.7k|        .log        = mp_log_new(arg, global->log, "ipc"),
  414|  24.7k|        .client_api = client_api,
  415|  24.7k|        .path       = mp_get_user_path(arg, global, opts->ipc_path),
  416|  24.7k|        .death_pipe = {-1, -1},
  417|  24.7k|    };
  418|       |
  419|  24.7k|    if (opts->ipc_client && opts->ipc_client[0]) {
  ------------------
  |  Branch (419:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    talloc_free(opts);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  436|       |
  437|  24.7k|    if (!arg->path || !arg->path[0])
  ------------------
  |  Branch (437:9): [True: 24.7k, False: 0]
  |  Branch (437:23): [True: 0, False: 0]
  ------------------
  438|  24.7k|        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|  24.7k|out:
  449|  24.7k|    if (arg->death_pipe[0] >= 0) {
  ------------------
  |  Branch (449:9): [True: 0, False: 24.7k]
  ------------------
  450|      0|        close(arg->death_pipe[0]);
  451|      0|        close(arg->death_pipe[1]);
  452|      0|    }
  453|  24.7k|    talloc_free(arg);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  454|       |    return NULL;
  455|      0|}
mp_uninit_ipc:
  458|  24.7k|{
  459|  24.7k|    if (!arg)
  ------------------
  |  Branch (459:9): [True: 24.7k, False: 0]
  ------------------
  460|  24.7k|        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|  35.8M|{
   32|  35.8M|    int ret = 0;
   33|  35.8M|    if (str1.len && str2.len)
  ------------------
  |  Branch (33:9): [True: 35.8M, False: 0]
  |  Branch (33:21): [True: 35.8M, False: 24.7k]
  ------------------
   34|  35.8M|        ret = memcmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  35.8M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 10.9M, False: 24.8M]
  |  |  ------------------
  ------------------
   35|       |
   36|  35.8M|    if (!ret) {
  ------------------
  |  Branch (36:9): [True: 6.07M, False: 29.8M]
  ------------------
   37|  6.07M|        if (str1.len == str2.len)
  ------------------
  |  Branch (37:13): [True: 4.83M, False: 1.23M]
  ------------------
   38|  4.83M|            return 0;
   39|  1.23M|        else if (str1.len > str2.len)
  ------------------
  |  Branch (39:18): [True: 123k, False: 1.11M]
  ------------------
   40|   123k|            return 1;
   41|  1.11M|        else
   42|  1.11M|            return -1;
   43|  6.07M|    }
   44|  29.8M|    return ret;
   45|  35.8M|}
bstrcasecmp:
   48|  1.54M|{
   49|  1.54M|    int ret = 0;
   50|  1.54M|    if (str1.len && str2.len)
  ------------------
  |  Branch (50:9): [True: 1.54M, False: 8]
  |  Branch (50:21): [True: 1.54M, False: 220]
  ------------------
   51|  1.54M|        ret = strncasecmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  1.54M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 573k, False: 966k]
  |  |  ------------------
  ------------------
   52|       |
   53|  1.54M|    if (!ret) {
  ------------------
  |  Branch (53:9): [True: 133k, False: 1.40M]
  ------------------
   54|   133k|        if (str1.len == str2.len)
  ------------------
  |  Branch (54:13): [True: 101k, False: 31.5k]
  ------------------
   55|   101k|            return 0;
   56|  31.5k|        else if (str1.len > str2.len)
  ------------------
  |  Branch (56:18): [True: 5.74k, False: 25.8k]
  ------------------
   57|  5.74k|            return 1;
   58|  25.8k|        else
   59|  25.8k|            return -1;
   60|   133k|    }
   61|  1.40M|    return ret;
   62|  1.54M|}
bstrchr:
   65|  23.8M|{
   66|  23.8M|    if (!str.len)
  ------------------
  |  Branch (66:9): [True: 0, False: 23.8M]
  ------------------
   67|      0|        return -1;
   68|  23.8M|    unsigned char *pos = memchr(str.start, c, str.len);
   69|  23.8M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (69:12): [True: 18.5M, False: 5.26M]
  ------------------
   70|  23.8M|}
bstrrchr:
   73|  1.72M|{
   74|  1.72M|    if (!str.len)
  ------------------
  |  Branch (74:9): [True: 0, False: 1.72M]
  ------------------
   75|      0|        return -1;
   76|  1.72M|#if HAVE_MEMRCHR
   77|  1.72M|    unsigned char *pos = memrchr(str.start, c, str.len);
   78|  1.72M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (78:12): [True: 1.64M, False: 73.2k]
  ------------------
   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|  1.72M|}
bstrcspn:
   88|   689k|{
   89|   689k|    int i;
   90|  10.0M|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (90:17): [True: 9.97M, False: 42.1k]
  ------------------
   91|  9.97M|        if (strchr(reject, str.start[i]))
  ------------------
  |  Branch (91:13): [True: 647k, False: 9.32M]
  ------------------
   92|   647k|            break;
   93|   689k|    return i;
   94|   689k|}
bstrspn:
   97|   148k|{
   98|   148k|    int i;
   99|   544k|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (99:17): [True: 445k, False: 99.0k]
  ------------------
  100|   445k|        if (!strchr(accept, str.start[i]))
  ------------------
  |  Branch (100:13): [True: 49.0k, False: 396k]
  ------------------
  101|  49.0k|            break;
  102|   148k|    return i;
  103|   148k|}
bstr_find:
  106|  2.91M|{
  107|  13.6M|    for (int i = 0; i < haystack.len; i++)
  ------------------
  |  Branch (107:21): [True: 13.1M, False: 511k]
  ------------------
  108|  13.1M|        if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle))
  ------------------
  |  Branch (108:13): [True: 2.40M, False: 10.7M]
  ------------------
  109|  2.40M|            return i;
  110|   511k|    return -1;
  111|  2.91M|}
bstr_lstrip:
  114|  9.73M|{
  115|  9.73M|    while (str.len && mp_isspace(*str.start)) {
  ------------------
  |  Branch (115:12): [True: 7.52M, False: 2.20M]
  |  Branch (115:23): [True: 0, False: 7.52M]
  ------------------
  116|      0|        str.start++;
  117|      0|        str.len--;
  118|      0|    }
  119|  9.73M|    return str;
  120|  9.73M|}
bstr_strip:
  123|  1.60M|{
  124|  1.60M|    str = bstr_lstrip(str);
  125|  2.96M|    while (str.len && mp_isspace(str.start[str.len - 1]))
  ------------------
  |  Branch (125:12): [True: 2.96M, False: 0]
  |  Branch (125:23): [True: 1.36M, False: 1.60M]
  ------------------
  126|  1.36M|        str.len--;
  127|  1.60M|    return str;
  128|  1.60M|}
bstr_split:
  131|  17.4k|{
  132|  17.4k|    int start;
  133|  17.4k|    for (start = 0; start < str.len; start++)
  ------------------
  |  Branch (133:21): [True: 17.4k, False: 1]
  ------------------
  134|  17.4k|        if (!strchr(sep, str.start[start]))
  ------------------
  |  Branch (134:13): [True: 17.4k, False: 5]
  ------------------
  135|  17.4k|            break;
  136|  17.4k|    str = bstr_cut(str, start);
  137|  17.4k|    int end = bstrcspn(str, sep);
  138|  17.4k|    if (rest) {
  ------------------
  |  Branch (138:9): [True: 17.4k, False: 0]
  ------------------
  139|  17.4k|        *rest = bstr_cut(str, end);
  140|  17.4k|    }
  141|  17.4k|    return bstr_splice(str, 0, end);
  142|  17.4k|}
bstr_split_tok:
  148|  1.34M|{
  149|  1.34M|    bstr bsep = bstr0(tok);
  150|  1.34M|    int pos = bstr_find(str, bsep);
  151|  1.34M|    if (pos < 0)
  ------------------
  |  Branch (151:9): [True: 511k, False: 830k]
  ------------------
  152|   511k|        pos = str.len;
  153|  1.34M|    *out_left = bstr_splice(str, 0, pos);
  154|  1.34M|    *out_right = bstr_cut(str, pos + bsep.len);
  155|  1.34M|    return pos != str.len;
  156|  1.34M|}
bstr_splice:
  159|  41.7M|{
  160|  41.7M|    if (!str.len)
  ------------------
  |  Branch (160:9): [True: 1, False: 41.7M]
  ------------------
  161|      1|        return str;
  162|       |
  163|  41.7M|    if (start < 0)
  ------------------
  |  Branch (163:9): [True: 0, False: 41.7M]
  ------------------
  164|      0|        start += str.len;
  165|  41.7M|    if (end < 0)
  ------------------
  |  Branch (165:9): [True: 0, False: 41.7M]
  ------------------
  166|      0|        end += str.len;
  167|  41.7M|    end = MPMIN(end, str.len);
  ------------------
  |  |   45|  41.7M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 3.78M, False: 38.0M]
  |  |  ------------------
  ------------------
  168|  41.7M|    start = MPMAX(start, 0);
  ------------------
  |  |   44|  41.7M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 11.6M, False: 30.1M]
  |  |  ------------------
  ------------------
  169|  41.7M|    end = MPMAX(end, start);
  ------------------
  |  |   44|  41.7M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 41.4M, False: 321k]
  |  |  ------------------
  ------------------
  170|  41.7M|    str.start += start;
  171|  41.7M|    str.len = end - start;
  172|  41.7M|    return str;
  173|  41.7M|}
bstrtoll:
  176|   302k|{
  177|   302k|    str = bstr_lstrip(str);
  178|   302k|    char buf[51];
  179|   302k|    int len = MPMIN(str.len, 50);
  ------------------
  |  |   45|   302k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 302k]
  |  |  ------------------
  ------------------
  180|   302k|    memcpy(buf, str.start, len);
  181|   302k|    buf[len] = 0;
  182|   302k|    char *endptr;
  183|   302k|    long long r = strtoll(buf, &endptr, base);
  184|   302k|    if (rest)
  ------------------
  |  Branch (184:9): [True: 302k, False: 0]
  ------------------
  185|   302k|        *rest = bstr_cut(str, endptr - buf);
  186|   302k|    return r;
  187|   302k|}
bstrtod:
  190|   272k|{
  191|   272k|    str = bstr_lstrip(str);
  192|   272k|    char buf[101];
  193|   272k|    int len = MPMIN(str.len, 100);
  ------------------
  |  |   45|   272k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 272k]
  |  |  ------------------
  ------------------
  194|   272k|    memcpy(buf, str.start, len);
  195|   272k|    buf[len] = 0;
  196|   272k|    char *endptr;
  197|   272k|    double r = strtod(buf, &endptr);
  198|   272k|    if (rest)
  ------------------
  |  Branch (198:9): [True: 272k, False: 0]
  ------------------
  199|   272k|        *rest = bstr_cut(str, endptr - buf);
  200|   272k|    return r;
  201|   272k|}
bstr_splitchar:
  204|  22.1M|{
  205|  22.1M|    int pos = bstrchr(str, c);
  206|  22.1M|    if (pos < 0)
  ------------------
  |  Branch (206:9): [True: 3.78M, False: 18.3M]
  ------------------
  207|  3.78M|        pos = str.len;
  208|  22.1M|    if (rest)
  ------------------
  |  Branch (208:9): [True: 22.1M, False: 0]
  ------------------
  209|  22.1M|        *rest = bstr_cut(str, pos + 1);
  210|  22.1M|    return bstr_splice(str, 0, pos + 1);
  211|  22.1M|}
bstr_strip_linebreaks:
  214|  2.49M|{
  215|  2.49M|    if (bstr_endswith0(str, "\r\n")) {
  ------------------
  |  Branch (215:9): [True: 0, False: 2.49M]
  ------------------
  216|      0|        str = bstr_splice(str, 0, str.len - 2);
  217|  2.49M|    } else if (bstr_endswith0(str, "\n")) {
  ------------------
  |  Branch (217:16): [True: 2.49M, False: 0]
  ------------------
  218|  2.49M|        str = bstr_splice(str, 0, str.len - 1);
  219|  2.49M|    }
  220|  2.49M|    return str;
  221|  2.49M|}
bstr_eatstart:
  224|  33.8M|{
  225|  33.8M|    if (!bstr_startswith(*s, prefix))
  ------------------
  |  Branch (225:9): [True: 30.6M, False: 3.22M]
  ------------------
  226|  30.6M|        return false;
  227|  3.22M|    *s = bstr_cut(*s, prefix.len);
  228|       |    return true;
  229|  33.8M|}
bstr_eatend:
  232|    124|{
  233|    124|    if (!bstr_endswith(*s, prefix))
  ------------------
  |  Branch (233:9): [True: 83, False: 41]
  ------------------
  234|     83|        return false;
  235|     41|    s->len -= prefix.len;
  236|       |    return true;
  237|    124|}
bstr_parse_utf8_code_length:
  257|   871M|{
  258|   871M|    if (b < 128)
  ------------------
  |  Branch (258:9): [True: 870M, False: 836k]
  ------------------
  259|   870M|        return 1;
  260|   836k|    int bytes = 7 - mp_log2(b ^ 255);
  261|   836k|    return (bytes >= 2 && bytes <= 4) ? bytes : -1;
  ------------------
  |  Branch (261:13): [True: 783k, False: 53.7k]
  |  Branch (261:27): [True: 761k, False: 21.4k]
  ------------------
  262|   871M|}
bstr_decode_partial_utf8:
  265|   465k|{
  266|   465k|    if (s->len == 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 465k]
  ------------------
  267|      0|        return -1;
  268|   465k|    unsigned int codepoint = s->start[0];
  269|   465k|    s->start++; s->len--;
  270|   465k|    if (codepoint >= 128) {
  ------------------
  |  Branch (270:9): [True: 13.1k, False: 452k]
  ------------------
  271|  13.1k|        int bytes = bstr_parse_utf8_code_length(codepoint);
  272|  13.1k|        if (bytes < 1)
  ------------------
  |  Branch (272:13): [True: 9.03k, False: 4.08k]
  ------------------
  273|  9.03k|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|  9.03k|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  274|  4.08k|        codepoint &= 127 >> bytes;
  275|  6.43k|        for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (275:25): [True: 5.03k, False: 1.39k]
  ------------------
  276|  5.03k|            if (!s->len)
  ------------------
  |  Branch (276:17): [True: 43, False: 4.98k]
  ------------------
  277|     43|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|     43|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  278|  4.98k|            int tmp = (unsigned char)s->start[0];
  279|  4.98k|            if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (279:17): [True: 2.64k, False: 2.34k]
  ------------------
  280|  2.64k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|  2.64k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  281|  2.34k|            codepoint = (codepoint << 6) | (tmp & ~0xC0);
  282|  2.34k|            s->start++; s->len--;
  283|  2.34k|        }
  284|  1.39k|        if (codepoint > 0x10FFFF || (codepoint >= 0xD800 && codepoint <= 0xDFFF))
  ------------------
  |  Branch (284:13): [True: 8, False: 1.39k]
  |  Branch (284:38): [True: 53, False: 1.33k]
  |  Branch (284:61): [True: 3, False: 50]
  ------------------
  285|     11|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|     11|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  286|       |
  287|       |        // Overlong sequences - check taken from libavcodec.
  288|  1.38k|        unsigned int min = bytes == 2 ? 0x80 : 1 << (5 * bytes - 4);
  ------------------
  |  Branch (288:28): [True: 1.05k, False: 338]
  ------------------
  289|  1.38k|        if (codepoint < min)
  ------------------
  |  Branch (289:13): [True: 15, False: 1.37k]
  ------------------
  290|     15|            return BSTR_DECODE_OVERLONG_ENCODING;
  ------------------
  |  |   93|     15|#define BSTR_DECODE_OVERLONG_ENCODING -3
  ------------------
  291|  1.38k|    }
  292|   454k|    return codepoint;
  293|   465k|}
bstr_decode_utf8:
  296|   465k|{
  297|   465k|    int res = bstr_decode_partial_utf8(&s);
  298|   465k|    if (res >= 0 && out_next)
  ------------------
  |  Branch (298:9): [True: 454k, False: 11.7k]
  |  Branch (298:21): [True: 454k, False: 0]
  ------------------
  299|   454k|        *out_next = s;
  300|   465k|    return res;
  301|   465k|}
bstr_validate_utf8:
  315|  24.5k|{
  316|   459k|    while (s.len) {
  ------------------
  |  Branch (316:12): [True: 438k, False: 21.1k]
  ------------------
  317|   438k|        if (bstr_decode_utf8(s, &s) < 0) {
  ------------------
  |  Branch (317:13): [True: 3.39k, False: 435k]
  ------------------
  318|       |            // Try to guess whether the sequence was just cut-off.
  319|  3.39k|            unsigned int codepoint = (unsigned char)s.start[0];
  320|  3.39k|            int bytes = bstr_parse_utf8_code_length(codepoint);
  321|  3.39k|            if (bytes > 1 && s.len < 6) {
  ------------------
  |  Branch (321:17): [True: 402, False: 2.99k]
  |  Branch (321:30): [True: 74, False: 328]
  ------------------
  322|       |                // Manually check validity of left bytes
  323|     78|                for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (323:33): [True: 77, False: 1]
  ------------------
  324|     77|                    if (n >= s.len) {
  ------------------
  |  Branch (324:25): [True: 0, False: 77]
  ------------------
  325|       |                        // Everything valid until now - just cut off.
  326|      0|                        return -(bytes - s.len);
  327|      0|                    }
  328|     77|                    int tmp = (unsigned char)s.start[n];
  329|     77|                    if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (329:25): [True: 73, False: 4]
  ------------------
  330|     73|                        break;
  331|     77|                }
  332|     74|            }
  333|  3.39k|            return -8;
  334|  3.39k|        }
  335|   438k|    }
  336|  21.1k|    return 0;
  337|  24.5k|}
bstr_sanitize_utf8_latin1:
  340|    602|{
  341|    602|    bstr new = {0};
  342|    602|    bstr left = s;
  343|    602|    unsigned char *first_ok = s.start;
  344|  27.7k|    while (left.len) {
  ------------------
  |  Branch (344:12): [True: 27.1k, False: 602]
  ------------------
  345|  27.1k|        int r = bstr_decode_utf8(left, &left);
  346|  27.1k|        if (r < 0) {
  ------------------
  |  Branch (346:13): [True: 8.35k, False: 18.7k]
  ------------------
  347|  8.35k|            bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  348|  8.35k|            mp_append_utf8_bstr(talloc_ctx, &new, (unsigned char)left.start[0]);
  349|  8.35k|            left.start += 1;
  350|  8.35k|            left.len -= 1;
  351|  8.35k|            first_ok = left.start;
  352|  8.35k|        }
  353|  27.1k|    }
  354|    602|    if (!new.start)
  ------------------
  |  Branch (354:9): [True: 233, False: 369]
  ------------------
  355|    233|        return s;
  356|    369|    if (first_ok != left.start)
  ------------------
  |  Branch (356:9): [True: 273, False: 96]
  ------------------
  357|    273|        bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  358|    369|    return new;
  359|    602|}
bstr_xappend:
  375|  8.20M|{
  376|  8.20M|    if (!append.len)
  ------------------
  |  Branch (376:9): [True: 57.9k, False: 8.14M]
  ------------------
  377|  57.9k|        return;
  378|  8.14M|    resize_append(talloc_ctx, s, append.len + 1);
  379|  8.14M|    memmove(s->start + s->len, append.start, append.len);
  380|  8.14M|    s->len += append.len;
  381|  8.14M|    s->start[s->len] = '\0';
  382|  8.14M|}
bstr_xappend_asprintf:
  385|   503k|{
  386|   503k|    va_list ap;
  387|   503k|    va_start(ap, fmt);
  388|   503k|    int ret = bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap);
  389|       |    va_end(ap);
  390|   503k|    return ret;
  391|   503k|}
bstr_xappend_vasprintf:
  395|  27.5M|{
  396|  27.5M|    int size;
  397|  27.5M|    va_list copy;
  398|  27.5M|    va_copy(copy, ap);
  399|  27.5M|    size_t avail = talloc_get_size(s->start) - s->len;
  ------------------
  |  |   45|  27.5M|#define talloc_get_size                 ta_get_size
  ------------------
  400|  27.5M|    char *dest = s->start ? s->start + s->len : NULL;
  ------------------
  |  Branch (400:18): [True: 27.4M, False: 90.8k]
  ------------------
  401|  27.5M|    size = vsnprintf(dest, avail, fmt, copy);
  402|  27.5M|    va_end(copy);
  403|       |
  404|  27.5M|    if (size < 0)
  ------------------
  |  Branch (404:9): [True: 0, False: 27.5M]
  ------------------
  405|      0|        return size;
  406|       |
  407|  27.5M|    if (avail < 1 || size + 1 > avail) {
  ------------------
  |  Branch (407:9): [True: 90.5k, False: 27.4M]
  |  Branch (407:22): [True: 236k, False: 27.2M]
  ------------------
  408|   327k|        resize_append(talloc_ctx, s, size + 1);
  409|   327k|        vsnprintf(s->start + s->len, size + 1, fmt, ap);
  410|   327k|    }
  411|  27.5M|    s->len += size;
  412|  27.5M|    return size;
  413|  27.5M|}
bstr.c:resize_append:
  362|  8.47M|{
  363|  8.47M|    size_t size = talloc_get_size(s->start);
  ------------------
  |  |   45|  8.47M|#define talloc_get_size                 ta_get_size
  ------------------
  364|  8.47M|    mp_assert(s->len <= size);
  ------------------
  |  |   41|  8.47M|#define mp_assert assert
  ------------------
  |  Branch (364:5): [True: 8.47M, False: 0]
  ------------------
  365|  8.47M|    if (append_min > size - s->len) {
  ------------------
  |  Branch (365:9): [True: 1.03M, False: 7.43M]
  ------------------
  366|  1.03M|        if (append_min < size)
  ------------------
  |  Branch (366:13): [True: 133k, False: 903k]
  ------------------
  367|   133k|            append_min = size; // preallocate in power of 2s
  368|  1.03M|        if (size >= SIZE_MAX / 2 || append_min >= SIZE_MAX / 2)
  ------------------
  |  Branch (368:13): [True: 0, False: 1.03M]
  |  Branch (368:37): [True: 0, False: 1.03M]
  ------------------
  369|      0|            abort(); // oom
  370|  1.03M|        s->start = talloc_realloc_size(talloc_ctx, s->start, size + append_min);
  ------------------
  |  |   39|  1.03M|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  1.03M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.03M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  1.03M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  1.03M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|  1.03M|    }
  372|  8.47M|}

client.c:bstr0:
   62|   247k|{
   63|   247k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 247k, False: 0]
  ------------------
   64|   247k|}
command.c:bstr0:
   62|  1.99M|{
   63|  1.99M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.99M, False: 0]
  ------------------
   64|  1.99M|}
configfiles.c:bstr0:
   62|  49.5k|{
   63|  49.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 49.5k, False: 0]
  ------------------
   64|  49.5k|}
main.c:bstr0:
   62|  24.7k|{
   63|  24.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 24.7k, False: 0]
  ------------------
   64|  24.7k|}
misc.c:bstr0:
   62|   112k|{
   63|   112k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 112k, False: 0]
  ------------------
   64|   112k|}
misc.c:bstr_xappend0:
  180|   112k|{
  181|   112k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|   112k|}
misc.c:bstrto0:
   46|  43.1k|{
   47|  43.1k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 43.1k, False: 0]
  ------------------
   48|  43.1k|}
misc.c:bstrdup0:
   40|  43.1k|{
   41|  43.1k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  43.1k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  43.1k|}
scripting.c:bstr0:
   62|  24.7k|{
   63|  24.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 24.7k, False: 0]
  ------------------
   64|  24.7k|}
stream.c:bstr0:
   62|  24.7k|{
   63|  24.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 24.7k, False: 0]
  ------------------
   64|  24.7k|}
stream_file.c:bstrcasecmp0:
  281|  49.5k|{
  282|  49.5k|    return bstrcasecmp(str1, bstr0(str2));
  283|  49.5k|}
stream_file.c:bstr0:
   62|  74.2k|{
   63|  74.2k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 74.2k, False: 0]
  ------------------
   64|  74.2k|}
sd_ass.c:bstr0:
   62|      2|{
   63|      2|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 2, False: 0]
  ------------------
   64|      2|}
sd_ass.c:bstrto0:
   46|    611|{
   47|    611|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|    487|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 124, False: 487]
  ------------------
   48|    611|}
sd_ass.c:bstrdup0:
   40|    124|{
   41|    124|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|    124|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|    124|}
sd_ass.c:bstr_cut:
  227|    745|{
  228|    745|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 745]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|    745|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 745]
  ------------------
  234|      0|        n = str.len;
  235|    745|    return (struct bstr){str.start + n, str.len - n};
  236|    745|}
vo.c:bstr0:
   62|  19.6k|{
   63|  19.6k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 19.6k, False: 0]
  ------------------
   64|  19.6k|}
chmap.c:bstr_eatstart0:
  291|   253k|{
  292|   253k|    return bstr_eatstart(s, bstr0(prefix));
  293|   253k|}
chmap.c:bstr_equals0:
  276|  4.54M|{
  277|  4.54M|    return bstr_equals(str1, bstr0(str2));
  278|  4.54M|}
chmap.c:bstr_equals:
  268|  4.54M|{
  269|  4.54M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 2.04M, False: 2.49M]
  ------------------
  270|  2.04M|        return false;
  271|       |
  272|  2.49M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 397k, False: 2.10M]
  |  Branch (272:40): [True: 477k, False: 1.62M]
  ------------------
  273|  4.54M|}
chmap.c:bstr0:
   62|  5.30M|{
   63|  5.30M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 5.30M, False: 0]
  ------------------
   64|  5.30M|}
ao.c:bstr0:
   62|  8.07k|{
   63|  8.07k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 8.07k, False: 0]
  ------------------
   64|  8.07k|}
codecs.c:bstr0:
   62|  36.2k|{
   63|  36.2k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 36.2k]
  ------------------
   64|  36.2k|}
msg.c:bstr_eatstart0:
  291|  15.8M|{
  292|  15.8M|    return bstr_eatstart(s, bstr0(prefix));
  293|  15.8M|}
msg.c:bstr0:
   62|  15.8M|{
   63|  15.8M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 15.8M, False: 0]
  ------------------
   64|  15.8M|}
msg.c:bstr_getline:
  156|  19.6M|{
  157|  19.6M|    return bstr_splitchar(str, rest, '\n');
  158|  19.6M|}
msg.c:bstrdup0:
   40|   940k|{
   41|   940k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   940k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   940k|}
playlist.c:bstr0:
   62|  24.7k|{
   63|  24.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 24.7k, False: 0]
  ------------------
   64|  24.7k|}
tags.c:bstr0:
   62|  6.12M|{
   63|  6.12M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 6.12M, False: 0]
  ------------------
   64|  6.12M|}
tags.c:bstrcasecmp0:
  281|  1.33M|{
  282|  1.33M|    return bstrcasecmp(str1, bstr0(str2));
  283|  1.33M|}
tags.c:bstrto0:
   46|  37.8k|{
   47|  37.8k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 37.8k, False: 0]
  ------------------
   48|  37.8k|}
tags.c:bstrdup0:
   40|  37.8k|{
   41|  37.8k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  37.8k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  37.8k|}
demux.c:bstr_xappend0:
  180|  43.1k|{
  181|  43.1k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|  43.1k|}
demux.c:bstr0:
   62|  76.9k|{
   63|  76.9k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 76.9k, False: 0]
  ------------------
   64|  76.9k|}
user_filters.c:bstr0:
   62|    113|{
   63|    113|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 113, False: 0]
  ------------------
   64|    113|}
cmd.c:bstr_equals0:
  276|   891k|{
  277|   891k|    return bstr_equals(str1, bstr0(str2));
  278|   891k|}
cmd.c:bstr_equals:
  268|   891k|{
  269|   891k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 816k, False: 74.2k]
  ------------------
  270|   816k|        return false;
  271|       |
  272|  74.2k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 74.2k]
  |  Branch (272:40): [True: 0, False: 74.2k]
  ------------------
  273|   891k|}
cmd.c:bstr0:
   62|  1.06M|{
   63|  1.06M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.06M, False: 0]
  ------------------
   64|  1.06M|}
input.c:bstrdup:
   52|  24.7k|{
   53|  24.7k|    struct bstr r = { NULL, str.len };
   54|  24.7k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 24.7k, False: 0]
  ------------------
   55|  24.7k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  24.7k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  24.7k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  24.7k|    return r;
   57|  24.7k|}
input.c:bstr0:
   62|  99.0k|{
   63|  99.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 74.2k, False: 24.7k]
  ------------------
   64|  99.0k|}
input.c:bstr_equals:
  268|  24.7k|{
  269|  24.7k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 0, False: 24.7k]
  ------------------
  270|      0|        return false;
  271|       |
  272|  24.7k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 24.7k, False: 0]
  |  Branch (272:40): [True: 0, False: 0]
  ------------------
  273|  24.7k|}
bstr.c:bstr_startswith:
  239|  46.9M|{
  240|  46.9M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 2.12M, False: 44.8M]
  ------------------
  241|  2.12M|        return false;
  242|  44.8M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  46.9M|}
bstr.c:bstr_cut:
  227|  27.2M|{
  228|  27.2M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 27.2M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  27.2M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 4.29M, False: 23.0M]
  ------------------
  234|  4.29M|        n = str.len;
  235|  27.2M|    return (struct bstr){str.start + n, str.len - n};
  236|  27.2M|}
bstr.c:bstr0:
   62|  6.34M|{
   63|  6.34M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 6.34M, False: 0]
  ------------------
   64|  6.34M|}
bstr.c:bstr_endswith0:
  258|  4.99M|{
  259|  4.99M|    return bstr_endswith(str, bstr0(suffix));
  260|  4.99M|}
bstr.c:bstr_endswith:
  251|  4.99M|{
  252|  4.99M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 321k, False: 4.67M]
  ------------------
  253|   321k|        return false;
  254|  4.67M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  4.99M|}
charset_conv.c:bstr0:
   62|  73.6k|{
   63|  73.6k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 73.6k, False: 0]
  ------------------
   64|  73.6k|}
charset_conv.c:bstr_startswith0:
  246|  73.6k|{
  247|  73.6k|    return bstr_startswith(str, bstr0(prefix));
  248|  73.6k|}
charset_conv.c:bstr_startswith:
  239|  73.6k|{
  240|  73.6k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 43.0k, False: 30.5k]
  ------------------
  241|  43.0k|        return false;
  242|  30.5k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  73.6k|}
json.c:bstr0:
   62|   594k|{
   63|   594k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 445k, False: 148k]
  ------------------
   64|   594k|}
language.c:bstr0:
   62|  17.4k|{
   63|  17.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 17.4k, False: 0]
  ------------------
   64|  17.4k|}
node.c:bstr0:
   62|  24.7k|{
   63|  24.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 24.7k, False: 0]
  ------------------
   64|  24.7k|}
node.c:bstrdup0:
   40|  24.7k|{
   41|  24.7k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  24.7k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  24.7k|}
path_utils.c:bstr0:
   62|  3.06M|{
   63|  3.06M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 3.06M, False: 0]
  ------------------
   64|  3.06M|}
path_utils.c:bstrdup0:
   40|  49.5k|{
   41|  49.5k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  49.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  49.5k|}
path_utils.c:bstr_find0:
  286|  1.57M|{
  287|  1.57M|    return bstr_find(haystack, bstr0(needle));
  288|  1.57M|}
m_config_frontend.c:bstr0:
   62|   138M|{
   63|   138M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 138M, False: 0]
  ------------------
   64|   138M|}
m_config_frontend.c:bstrcmp0:
  263|  26.4M|{
  264|  26.4M|    return bstrcmp(str1, bstr0(str2));
  265|  26.4M|}
m_config_frontend.c:bstr_eatstart0:
  291|   297k|{
  292|   297k|    return bstr_eatstart(s, bstr0(prefix));
  293|   297k|}
m_config_frontend.c:bstr_startswith:
  239|   102M|{
  240|   102M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 71.1M, False: 30.9M]
  ------------------
  241|  71.1M|        return false;
  242|  30.9M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   102M|}
m_config_frontend.c:bstr_endswith:
  251|   346k|{
  252|   346k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 0, False: 346k]
  ------------------
  253|      0|        return false;
  254|   346k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|   346k|}
m_config_frontend.c:bstr_equals0:
  276|  7.89M|{
  277|  7.89M|    return bstr_equals(str1, bstr0(str2));
  278|  7.89M|}
m_config_frontend.c:bstr_equals:
  268|  7.89M|{
  269|  7.89M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 7.20M, False: 693k]
  ------------------
  270|  7.20M|        return false;
  271|       |
  272|   693k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 24.7k, False: 668k]
  |  Branch (272:40): [True: 49.5k, False: 618k]
  ------------------
  273|  7.89M|}
m_config_frontend.c:bstrto0:
   46|  2.92M|{
   47|  2.92M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 2.92M, False: 0]
  ------------------
   48|  2.92M|}
m_config_frontend.c:bstrdup0:
   40|  2.92M|{
   41|  2.92M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  2.92M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  2.92M|}
m_option.c:bstr_equals0:
  276|  3.77M|{
  277|  3.77M|    return bstr_equals(str1, bstr0(str2));
  278|  3.77M|}
m_option.c:bstr_equals:
  268|  3.82M|{
  269|  3.82M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 2.78M, False: 1.04M]
  ------------------
  270|  2.78M|        return false;
  271|       |
  272|  1.04M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 173k, False: 869k]
  |  Branch (272:40): [True: 695k, False: 173k]
  ------------------
  273|  3.82M|}
m_option.c:bstr0:
   62|  10.2M|{
   63|  10.2M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 10.1M, False: 74.2k]
  ------------------
   64|  10.2M|}
m_option.c:bstrcasecmp0:
  281|  74.2k|{
  282|  74.2k|    return bstrcasecmp(str1, bstr0(str2));
  283|  74.2k|}
m_option.c:bstrcmp0:
  263|  1.70M|{
  264|  1.70M|    return bstrcmp(str1, bstr0(str2));
  265|  1.70M|}
m_option.c:bstr_eatstart0:
  291|  2.10M|{
  292|  2.10M|    return bstr_eatstart(s, bstr0(prefix));
  293|  2.10M|}
m_option.c:bstrdup0:
   40|   742k|{
   41|   742k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   742k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   742k|}
m_option.c:bstr_endswith0:
  258|  2.20M|{
  259|  2.20M|    return bstr_endswith(str, bstr0(suffix));
  260|  2.20M|}
m_option.c:bstr_endswith:
  251|  2.20M|{
  252|  2.20M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 792k, False: 1.41M]
  ------------------
  253|   792k|        return false;
  254|  1.41M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  2.20M|}
m_option.c:bstr_cut:
  227|   544k|{
  228|   544k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 544k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   544k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 74.2k, False: 470k]
  ------------------
  234|  74.2k|        n = str.len;
  235|   544k|    return (struct bstr){str.start + n, str.len - n};
  236|   544k|}
m_option.c:bstrdup:
   52|  74.2k|{
   53|  74.2k|    struct bstr r = { NULL, str.len };
   54|  74.2k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 74.2k, False: 0]
  ------------------
   55|  74.2k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  74.2k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  74.2k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  74.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  74.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  74.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  74.2k|    return r;
   57|  74.2k|}
m_option.c:bstrto0:
   46|   495k|{
   47|   495k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 495k, False: 0]
  ------------------
   48|   495k|}
m_property.c:bstrcmp0:
  263|  4.04M|{
  264|  4.04M|    return bstrcmp(str1, bstr0(str2));
  265|  4.04M|}
m_property.c:bstr0:
   62|  15.7M|{
   63|  15.7M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 15.7M, False: 0]
  ------------------
   64|  15.7M|}
m_property.c:bstr_eatstart0:
  291|  8.53M|{
  292|  8.53M|    return bstr_eatstart(s, bstr0(prefix));
  293|  8.53M|}
m_property.c:bstr_startswith0:
  246|  2.39M|{
  247|  2.39M|    return bstr_startswith(str, bstr0(prefix));
  248|  2.39M|}
m_property.c:bstr_startswith:
  239|  2.39M|{
  240|  2.39M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 149k, False: 2.24M]
  ------------------
  241|   149k|        return false;
  242|  2.24M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  2.39M|}
m_property.c:bstr_cut:
  227|  2.84M|{
  228|  2.84M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 2.84M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  2.84M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 2.84M]
  ------------------
  234|      0|        n = str.len;
  235|  2.84M|    return (struct bstr){str.start + n, str.len - n};
  236|  2.84M|}
m_property.c:bstrdup0:
   40|   449k|{
   41|   449k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   449k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   449k|}
parse_configfile.c:bstr_eatstart0:
  291|  6.65M|{
  292|  6.65M|    return bstr_eatstart(s, bstr0(prefix));
  293|  6.65M|}
parse_configfile.c:bstr0:
   62|  14.2M|{
   63|  14.2M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 14.2M, False: 0]
  ------------------
   64|  14.2M|}
parse_configfile.c:bstr_getline:
  156|  2.49M|{
  157|  2.49M|    return bstr_splitchar(str, rest, '\n');
  158|  2.49M|}
parse_configfile.c:bstr_startswith0:
  246|  7.54M|{
  247|  7.54M|    return bstr_startswith(str, bstr0(prefix));
  248|  7.54M|}
parse_configfile.c:bstr_startswith:
  239|  7.54M|{
  240|  7.54M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 2.20M, False: 5.34M]
  ------------------
  241|  2.20M|        return false;
  242|  5.34M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  7.54M|}
parse_configfile.c:bstrto0:
   46|   297k|{
   47|   297k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 297k, False: 0]
  ------------------
   48|   297k|}
parse_configfile.c:bstrdup0:
   40|   297k|{
   41|   297k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   297k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   297k|}
parse_configfile.c:bstr_cut:
  227|  19.7M|{
  228|  19.7M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 19.7M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  19.7M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 19.7M]
  ------------------
  234|      0|        n = str.len;
  235|  19.7M|    return (struct bstr){str.start + n, str.len - n};
  236|  19.7M|}
path.c:bstr0:
   62|  1.04M|{
   63|  1.04M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 997k, False: 49.5k]
  ------------------
   64|  1.04M|}
path.c:bstr_eatstart0:
  291|   148k|{
  292|   148k|    return bstr_eatstart(s, bstr0(prefix));
  293|   148k|}
path.c:bstr_equals0:
  276|  99.0k|{
  277|  99.0k|    return bstr_equals(str1, bstr0(str2));
  278|  99.0k|}
path.c:bstr_equals:
  268|  99.0k|{
  269|  99.0k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 99.0k, False: 0]
  ------------------
  270|  99.0k|        return false;
  271|       |
  272|      0|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 0]
  |  Branch (272:40): [True: 0, False: 0]
  ------------------
  273|  99.0k|}
external_files.c:bstr0:
   62|  48.5k|{
   63|  48.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 48.5k, False: 0]
  ------------------
   64|  48.5k|}
external_files.c:bstrdup:
   52|  24.2k|{
   53|  24.2k|    struct bstr r = { NULL, str.len };
   54|  24.2k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 24.2k, False: 0]
  ------------------
   55|  24.2k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  24.2k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  24.2k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  24.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  24.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  24.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  24.2k|    return r;
   57|  24.2k|}
external_files.c:bstrdup0:
   40|  24.2k|{
   41|  24.2k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  24.2k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  24.2k|}
vd_lavc.c:bstr0:
   62|   228k|{
   63|   228k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 228k, False: 0]
  ------------------
   64|   228k|}
vd_lavc.c:bstr_equals0:
  276|   209k|{
  277|   209k|    return bstr_equals(str1, bstr0(str2));
  278|   209k|}
vd_lavc.c:bstr_equals:
  268|   209k|{
  269|   209k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 190k, False: 19.0k]
  ------------------
  270|   190k|        return false;
  271|       |
  272|  19.0k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 19.0k]
  |  Branch (272:40): [True: 19.0k, False: 0]
  ------------------
  273|   209k|}
ad_spdif.c:bstr0:
   62|  7.00k|{
   63|  7.00k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 7.00k]
  ------------------
   64|  7.00k|}

mp_charset_is_utf8:
   42|  82.6k|{
   43|  82.6k|    return user_cp && (strcasecmp(user_cp, "utf8") == 0 ||
  ------------------
  |  Branch (43:12): [True: 82.6k, False: 0]
  |  Branch (43:24): [True: 0, False: 82.6k]
  ------------------
   44|  82.6k|                       strcasecmp(user_cp, "utf-8") == 0);
  ------------------
  |  Branch (44:24): [True: 21.2k, False: 61.4k]
  ------------------
   45|  82.6k|}
mp_charset_guess:
  103|  24.5k|{
  104|  24.5k|    if (user_cp[0] == '+') {
  ------------------
  |  Branch (104:9): [True: 0, False: 24.5k]
  ------------------
  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|  24.5k|    const char *bom_cp = ms_bom_guess(buf);
  110|  24.5k|    if (bom_cp) {
  ------------------
  |  Branch (110:9): [True: 7, False: 24.5k]
  ------------------
  111|      7|        mp_verbose(log, "Data has a BOM, assuming %s as charset.\n", bom_cp);
  ------------------
  |  |   79|      7|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  112|      7|        return bom_cp;
  113|      7|    }
  114|       |
  115|  24.5k|    int r = bstr_validate_utf8(buf);
  116|  24.5k|    if (r >= 0 || (r > -8 && (flags & MP_ICONV_ALLOW_CUTOFF))) {
  ------------------
  |  Branch (116:9): [True: 21.1k, False: 3.39k]
  |  Branch (116:20): [True: 0, False: 3.39k]
  |  Branch (116:30): [True: 0, False: 0]
  ------------------
  117|  21.1k|        if (strcmp(user_cp, "auto") != 0 && !mp_charset_is_utf8(user_cp))
  ------------------
  |  Branch (117:13): [True: 0, False: 21.1k]
  |  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|  21.1k|        return "utf-8";
  120|  21.1k|    }
  121|       |
  122|  3.39k|    const char *res = NULL;
  123|  3.39k|    if (strcasecmp(user_cp, "auto") == 0) {
  ------------------
  |  Branch (123:9): [True: 3.39k, False: 0]
  ------------------
  124|  3.39k|#if HAVE_UCHARDET
  125|  3.39k|        res = mp_uchardet(talloc_ctx, log, buf);
  126|  3.39k|#endif
  127|  3.39k|        if (!res) {
  ------------------
  |  Branch (127:13): [True: 258, False: 3.13k]
  ------------------
  128|    258|            mp_verbose(log, "Charset auto-detection failed.\n");
  ------------------
  |  |   79|    258|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  129|    258|            res = "UTF-8-BROKEN";
  130|    258|        }
  131|  3.39k|    } else {
  132|      0|        res = user_cp;
  133|      0|    }
  134|       |
  135|  3.39k|    mp_verbose(log, "Using charset '%s'.\n", res);
  ------------------
  |  |   79|  3.39k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  136|  3.39k|    return res;
  137|  24.5k|}
mp_iconv_to_utf8:
  151|  33.5k|{
  152|  33.5k|#if HAVE_ICONV
  153|  33.5k|    if (!buf.len)
  ------------------
  |  Branch (153:9): [True: 2, False: 33.5k]
  ------------------
  154|      2|        return buf;
  155|       |
  156|  33.5k|    if (!cp || !cp[0] || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (156:9): [True: 0, False: 33.5k]
  |  Branch (156:16): [True: 0, False: 33.5k]
  |  Branch (156:26): [True: 0, False: 33.5k]
  ------------------
  157|      0|        return buf;
  158|       |
  159|  33.5k|    if (strcasecmp(cp, "ASCII") == 0)
  ------------------
  |  Branch (159:9): [True: 0, False: 33.5k]
  ------------------
  160|      0|        return buf;
  161|       |
  162|  33.5k|    if (strcasecmp(cp, "UTF-8-BROKEN") == 0)
  ------------------
  |  Branch (162:9): [True: 508, False: 33.0k]
  ------------------
  163|    508|        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|  33.0k|    if (strcasecmp(cp, "EUC-KR") == 0)
  ------------------
  |  Branch (167:9): [True: 0, False: 33.0k]
  ------------------
  168|      0|        cp = "CP949";
  169|       |
  170|  33.0k|    iconv_t icdsc;
  171|  33.0k|    if ((icdsc = iconv_open("UTF-8", cp)) == (iconv_t) (-1)) {
  ------------------
  |  Branch (171:9): [True: 24.2k, False: 8.78k]
  ------------------
  172|  24.2k|        if (flags & MP_ICONV_VERBOSE)
  ------------------
  |  Branch (172:13): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|        goto failure;
  175|  24.2k|    }
  176|       |
  177|  8.78k|    size_t size = buf.len;
  178|  8.78k|    size_t osize = size;
  179|  8.78k|    size_t ileft = size;
  180|  8.78k|    size_t oleft = size - 1;
  181|       |
  182|  8.78k|    char *outbuf = talloc_size(NULL, osize);
  ------------------
  |  |   43|  8.78k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  8.78k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  8.78k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  8.78k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  8.78k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  8.78k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|  8.78k|    char *ip = buf.start;
  184|  8.78k|    char *op = outbuf;
  185|       |
  186|  26.2k|    while (1) {
  ------------------
  |  Branch (186:12): [True: 26.2k, Folded]
  ------------------
  187|  26.2k|        int clear = 0;
  188|  26.2k|        size_t rc;
  189|  26.2k|        if (ileft)
  ------------------
  |  Branch (189:13): [True: 17.5k, False: 8.70k]
  ------------------
  190|  17.5k|            rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
  191|  8.70k|        else {
  192|  8.70k|            clear = 1; // clear the conversion state and leave
  193|  8.70k|            rc = iconv(icdsc, NULL, NULL, &op, &oleft);
  194|  8.70k|        }
  195|  26.2k|        if (rc == (size_t) (-1)) {
  ------------------
  |  Branch (195:13): [True: 8.86k, False: 17.3k]
  ------------------
  196|  8.86k|            if (errno == E2BIG) {
  ------------------
  |  Branch (196:17): [True: 8.77k, False: 94]
  ------------------
  197|  8.77k|                size_t offset = op - outbuf;
  198|  8.77k|                outbuf = talloc_realloc_size(NULL, outbuf, osize + size);
  ------------------
  |  |   39|  8.77k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  8.77k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  8.77k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  8.77k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  8.77k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|  8.77k|                op = outbuf + offset;
  200|  8.77k|                osize += size;
  201|  8.77k|                oleft += size;
  202|  8.77k|            } else {
  203|     94|                if (errno == EINVAL && (flags & MP_ICONV_ALLOW_CUTOFF)) {
  ------------------
  |  Branch (203:21): [True: 17, False: 77]
  |  Branch (203:40): [True: 0, False: 17]
  ------------------
  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|     94|                if (flags & MP_ICONV_VERBOSE) {
  ------------------
  |  Branch (211:21): [True: 94, False: 0]
  ------------------
  212|     94|                    mp_err(log, "Error recoding text with codepage '%s'\n", cp);
  ------------------
  |  |   76|     94|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  213|     94|                }
  214|     94|                talloc_free(outbuf);
  ------------------
  |  |   47|     94|#define talloc_free                     ta_free
  ------------------
  215|     94|                iconv_close(icdsc);
  216|     94|                goto failure;
  217|     94|            }
  218|  17.3k|        } else if (clear)
  ------------------
  |  Branch (218:20): [True: 8.69k, False: 8.69k]
  ------------------
  219|  8.69k|            break;
  220|  26.2k|    }
  221|       |
  222|  8.69k|    iconv_close(icdsc);
  223|       |
  224|  8.69k|    outbuf[osize - oleft - 1] = 0;
  225|  8.69k|    return (bstr){outbuf, osize - oleft - 1};
  226|       |
  227|  24.3k|failure:
  228|  24.3k|#endif
  229|       |
  230|  24.3k|    if (flags & MP_NO_LATIN1_FALLBACK) {
  ------------------
  |  Branch (230:9): [True: 24.2k, False: 94]
  ------------------
  231|  24.2k|        return buf;
  232|  24.2k|    } else {
  233|       |        return bstr_sanitize_utf8_latin1(NULL, buf);
  234|     94|    }
  235|  24.3k|}
charset_conv.c:ms_bom_guess:
   58|  24.5k|{
   59|  98.1k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (59:21): [True: 73.6k, False: 24.5k]
  ------------------
   60|  73.6k|        if (bstr_startswith0(buf, utf_bom[n]))
  ------------------
  |  Branch (60:13): [True: 7, False: 73.6k]
  ------------------
   61|      7|            return utf_enc[n];
   62|  73.6k|    }
   63|  24.5k|    return NULL;
   64|  24.5k|}
charset_conv.c:mp_uchardet:
   68|  3.39k|{
   69|  3.39k|    uchardet_t det = uchardet_new();
   70|  3.39k|    if (!det)
  ------------------
  |  Branch (70:9): [True: 0, False: 3.39k]
  ------------------
   71|      0|        return NULL;
   72|  3.39k|    if (uchardet_handle_data(det, buf.start, buf.len) != 0) {
  ------------------
  |  Branch (72:9): [True: 0, False: 3.39k]
  ------------------
   73|      0|        uchardet_delete(det);
   74|      0|        return NULL;
   75|      0|    }
   76|  3.39k|    uchardet_data_end(det);
   77|  3.39k|    char *res = talloc_strdup(talloc_ctx, uchardet_get_charset(det));
  ------------------
  |  |   50|  3.39k|#define talloc_strdup                   ta_xstrdup
  ------------------
   78|  3.39k|    if (res && !res[0])
  ------------------
  |  Branch (78:9): [True: 3.39k, False: 0]
  |  Branch (78:16): [True: 258, False: 3.13k]
  ------------------
   79|    258|        res = NULL;
   80|  3.39k|    if (res) {
  ------------------
  |  Branch (80:9): [True: 3.13k, False: 258]
  ------------------
   81|  3.13k|        mp_verbose(log, "libuchardet detected charset as %s\n", res);
  ------------------
  |  |   79|  3.13k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   82|  3.13k|        iconv_t icdsc = iconv_open("UTF-8", res);
   83|  3.13k|        if (icdsc == (iconv_t)(-1)) {
  ------------------
  |  Branch (83:13): [True: 0, False: 3.13k]
  ------------------
   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|  3.13k|        } else {
   87|  3.13k|            iconv_close(icdsc);
   88|  3.13k|        }
   89|  3.13k|    }
   90|  3.39k|    uchardet_delete(det);
   91|  3.39k|    return res;
   92|  3.39k|}

client.c:mp_isalnum:
   14|   173k|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 173k, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
client.c:mp_isalpha:
   13|   173k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 173k]
  |  Branch (13:64): [True: 173k, False: 0]
  ------------------
client.c:mp_isupper:
   10|   173k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 173k, False: 0]
  |  Branch (10:59): [True: 0, False: 173k]
  ------------------
client.c:mp_islower:
   11|   173k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 173k, False: 0]
  |  Branch (11:59): [True: 173k, False: 0]
  ------------------
bstr.c:mp_isspace:
    8|  10.4M|static inline int mp_isspace(char c) { return c == ' ' || c == '\f' || c == '\n' ||
  ------------------
  |  Branch (8:47): [True: 1.36M, False: 9.13M]
  |  Branch (8:59): [True: 0, False: 9.13M]
  |  Branch (8:72): [True: 0, False: 9.13M]
  ------------------
    9|  9.13M|                                              c == '\r' || c == '\t' || c =='\v'; }
  ------------------
  |  Branch (9:47): [True: 0, False: 9.13M]
  |  Branch (9:60): [True: 0, False: 9.13M]
  |  Branch (9:73): [True: 0, False: 9.13M]
  ------------------
path_utils.c:mp_isalpha:
   13|  4.71M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 4.71M]
  |  Branch (13:64): [True: 4.71M, False: 0]
  ------------------
path_utils.c:mp_isupper:
   10|  4.71M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 4.71M, False: 0]
  |  Branch (10:59): [True: 0, False: 4.71M]
  ------------------
path_utils.c:mp_islower:
   11|  4.71M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 4.71M, False: 0]
  |  Branch (11:59): [True: 4.71M, False: 0]
  ------------------
path_utils.c:mp_isalnum:
   14|  3.14M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 3.14M, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
parse_configfile.c:mp_isalnum:
   14|  21.3M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 18.0M, False: 3.29M]
  |  Branch (14:64): [True: 0, False: 3.29M]
  ------------------
parse_configfile.c:mp_isalpha:
   13|  21.3M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 21.3M]
  |  Branch (13:64): [True: 18.0M, False: 3.29M]
  ------------------
parse_configfile.c:mp_isupper:
   10|  21.3M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 18.0M, False: 3.29M]
  |  Branch (10:59): [True: 0, False: 18.0M]
  ------------------
parse_configfile.c:mp_islower:
   11|  21.3M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 18.0M, False: 3.29M]
  |  Branch (11:59): [True: 18.0M, False: 0]
  ------------------
parse_configfile.c:mp_isdigit:
   12|  3.29M|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 1.58M, False: 1.70M]
  |  Branch (12:59): [True: 0, False: 1.58M]
  ------------------

mp_dispatch_create:
   84|  44.3k|{
   85|  44.3k|    struct mp_dispatch_queue *queue = talloc_ptrtype(ta_parent, queue);
  ------------------
  |  |   34|  44.3k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  44.3k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  44.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|  44.3k|    *queue = (struct mp_dispatch_queue){0};
   87|  44.3k|    talloc_set_destructor(queue, queue_dtor);
  ------------------
  |  |   41|  44.3k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   88|  44.3k|    mp_mutex_init(&queue->lock);
   89|  44.3k|    mp_cond_init(&queue->cond);
   90|  44.3k|    return queue;
   91|  44.3k|}
mp_dispatch_set_wakeup_fn:
  105|  19.6k|{
  106|  19.6k|    queue->wakeup_fn = wakeup_fn;
  107|  19.6k|    queue->wakeup_ctx = wakeup_ctx;
  108|  19.6k|}
mp_dispatch_enqueue_autofree:
  186|  78.6k|{
  187|  78.6k|    struct mp_dispatch_item *item = talloc_ptrtype(NULL, item);
  ------------------
  |  |   34|  78.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  78.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  78.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|  78.6k|    *item = (struct mp_dispatch_item){
  189|  78.6k|        .fn = fn,
  190|  78.6k|        .fn_data = talloc_steal(item, fn_data),
  ------------------
  |  |   38|  78.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  78.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  191|       |        .asynchronous = true,
  192|  78.6k|    };
  193|  78.6k|    mp_dispatch_append(queue, item);
  194|  78.6k|}
mp_dispatch_cancel_fn:
  220|  44.3k|{
  221|  44.3k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  44.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  222|  44.3k|    struct mp_dispatch_item **pcur = &queue->head;
  223|  44.3k|    queue->tail = NULL;
  224|  44.3k|    while (*pcur) {
  ------------------
  |  Branch (224:12): [True: 0, False: 44.3k]
  ------------------
  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|  44.3k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  44.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  235|  44.3k|}
mp_dispatch_run:
  243|   140k|{
  244|   140k|    struct mp_dispatch_item item = {
  245|   140k|        .fn = fn,
  246|   140k|        .fn_data = fn_data,
  247|   140k|    };
  248|   140k|    mp_dispatch_append(queue, &item);
  249|       |
  250|   140k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   140k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  251|   280k|    while (!item.completed)
  ------------------
  |  Branch (251:12): [True: 140k, False: 140k]
  ------------------
  252|   140k|        mp_cond_wait(&queue->cond, &queue->lock);
  253|   140k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   140k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  254|   140k|}
mp_dispatch_queue_process:
  273|  1.96M|{
  274|  1.96M|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  1.96M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  275|  1.96M|    queue->wait = timeout > 0 ? mp_time_ns_add(mp_time_ns(), timeout) : 0;
  ------------------
  |  Branch (275:19): [True: 518k, False: 1.44M]
  ------------------
  276|  1.96M|    mp_assert(!queue->in_process); // recursion not allowed
  ------------------
  |  |   41|  1.96M|#define mp_assert assert
  ------------------
  |  Branch (276:5): [True: 1.96M, False: 16]
  ------------------
  277|  1.96M|    queue->in_process = true;
  278|  1.96M|    queue->in_process_thread_id = mp_thread_current_id();
  ------------------
  |  |  217|  1.96M|#define mp_thread_current_id      pthread_self
  ------------------
  279|       |    // Wake up thread which called mp_dispatch_lock().
  280|  1.96M|    if (queue->lock_requests)
  ------------------
  |  Branch (280:9): [True: 40.4k, False: 1.92M]
  ------------------
  281|  40.4k|        mp_cond_broadcast(&queue->cond);
  282|  2.59M|    while (1) {
  ------------------
  |  Branch (282:12): [True: 2.59M, Folded]
  ------------------
  283|  2.59M|        if (queue->lock_requests) {
  ------------------
  |  Branch (283:13): [True: 130k, False: 2.46M]
  ------------------
  284|       |            // Block due to something having called mp_dispatch_lock().
  285|   130k|            mp_cond_wait(&queue->cond, &queue->lock);
  286|  2.46M|        } else if (queue->head) {
  ------------------
  |  Branch (286:20): [True: 219k, False: 2.24M]
  ------------------
  287|   219k|            struct mp_dispatch_item *item = queue->head;
  288|   219k|            queue->head = item->next;
  289|   219k|            if (!queue->head)
  ------------------
  |  Branch (289:17): [True: 201k, False: 17.6k]
  ------------------
  290|   201k|                queue->tail = NULL;
  291|   219k|            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|   219k|            mp_assert(!queue->locked);
  ------------------
  |  |   41|   219k|#define mp_assert assert
  ------------------
  |  Branch (296:13): [True: 219k, False: 0]
  ------------------
  297|   219k|            queue->locked = true;
  298|   219k|            mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   219k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  299|       |
  300|   219k|            item->fn(item->fn_data);
  301|       |
  302|   219k|            mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   219k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  303|   219k|            mp_assert(queue->locked);
  ------------------
  |  |   41|   219k|#define mp_assert assert
  ------------------
  |  Branch (303:13): [True: 219k, False: 0]
  ------------------
  304|   219k|            queue->locked = false;
  305|       |            // Wakeup mp_dispatch_run(), also mp_dispatch_lock().
  306|   219k|            mp_cond_broadcast(&queue->cond);
  307|   219k|            if (item->asynchronous) {
  ------------------
  |  Branch (307:17): [True: 78.6k, False: 140k]
  ------------------
  308|  78.6k|                talloc_free(item);
  ------------------
  |  |   47|  78.6k|#define talloc_free                     ta_free
  ------------------
  309|   140k|            } else {
  310|   140k|                item->completed = true;
  311|   140k|            }
  312|  2.24M|        } else if (queue->wait > 0 && !queue->interrupted) {
  ------------------
  |  Branch (312:20): [True: 804k, False: 1.44M]
  |  Branch (312:39): [True: 285k, False: 518k]
  ------------------
  313|   285k|            if (mp_cond_timedwait_until(&queue->cond, &queue->lock, queue->wait))
  ------------------
  |  Branch (313:17): [True: 9, False: 285k]
  ------------------
  314|      9|                queue->wait = 0;
  315|  1.96M|        } else {
  316|  1.96M|            break;
  317|  1.96M|        }
  318|  2.59M|    }
  319|  1.96M|    mp_assert(!queue->locked);
  ------------------
  |  |   41|  1.96M|#define mp_assert assert
  ------------------
  |  Branch (319:5): [True: 1.96M, False: 18.4E]
  ------------------
  320|  1.96M|    queue->in_process = false;
  321|  1.96M|    queue->interrupted = false;
  322|  1.96M|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  1.96M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  323|  1.96M|}
mp_dispatch_interrupt:
  332|  1.12M|{
  333|  1.12M|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  1.12M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  334|  1.12M|    queue->interrupted = true;
  335|  1.12M|    mp_cond_broadcast(&queue->cond);
  336|  1.12M|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  1.12M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  337|  1.12M|}
mp_dispatch_adjust_timeout:
  348|   890k|{
  349|   890k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   890k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  350|   890k|    if (queue->in_process && queue->wait > until) {
  ------------------
  |  Branch (350:9): [True: 0, False: 890k]
  |  Branch (350:30): [True: 0, False: 0]
  ------------------
  351|      0|        queue->wait = until;
  352|      0|        mp_cond_broadcast(&queue->cond);
  353|      0|    }
  354|   890k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   890k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  355|   890k|}
mp_dispatch_lock:
  365|   395k|{
  366|   395k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   395k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  367|       |    // Must not be called recursively from dispatched callbacks.
  368|   395k|    if (queue->in_process)
  ------------------
  |  Branch (368:9): [True: 355k, False: 40.4k]
  ------------------
  369|   395k|        mp_assert(!mp_thread_id_equal(queue->in_process_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (369:9): [True: 355k, False: 0]
  ------------------
  370|       |    // Must not be called recursively at all.
  371|   395k|    if (queue->locked_explicit)
  ------------------
  |  Branch (371:9): [True: 0, False: 395k]
  ------------------
  372|   395k|        mp_assert(!mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (372:9): [True: 0, False: 0]
  ------------------
  373|   395k|    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|   395k|    if (queue->onlock_fn)
  ------------------
  |  Branch (377:9): [True: 0, False: 395k]
  ------------------
  378|      0|        queue->onlock_fn(queue->onlock_ctx);
  379|   435k|    while (!queue->in_process) {
  ------------------
  |  Branch (379:12): [True: 40.5k, False: 395k]
  ------------------
  380|  40.5k|        mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|  40.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  381|  40.5k|        if (queue->wakeup_fn)
  ------------------
  |  Branch (381:13): [True: 0, False: 40.5k]
  ------------------
  382|      0|            queue->wakeup_fn(queue->wakeup_ctx);
  383|  40.5k|        mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|  40.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  384|  40.5k|        if (queue->in_process)
  ------------------
  |  Branch (384:13): [True: 110, False: 40.4k]
  ------------------
  385|    110|            break;
  386|  40.4k|        mp_cond_wait(&queue->cond, &queue->lock);
  387|  40.4k|    }
  388|       |    // Wait until we can get the lock.
  389|   395k|    while (!queue->in_process || queue->locked)
  ------------------
  |  Branch (389:12): [True: 0, False: 395k]
  |  Branch (389:34): [True: 0, False: 395k]
  ------------------
  390|      0|        mp_cond_wait(&queue->cond, &queue->lock);
  391|       |    // "Lock".
  392|   395k|    mp_assert(queue->lock_requests);
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (392:5): [True: 395k, False: 0]
  ------------------
  393|   395k|    mp_assert(!queue->locked);
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (393:5): [True: 395k, False: 0]
  ------------------
  394|   395k|    mp_assert(!queue->locked_explicit);
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (394:5): [True: 395k, False: 0]
  ------------------
  395|   395k|    queue->locked = true;
  396|   395k|    queue->locked_explicit = true;
  397|   395k|    queue->locked_explicit_thread_id = mp_thread_current_id();
  ------------------
  |  |  217|   395k|#define mp_thread_current_id      pthread_self
  ------------------
  398|   395k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   395k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  399|   395k|}
mp_dispatch_unlock:
  403|   395k|{
  404|   395k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   395k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  405|   395k|    mp_assert(queue->locked);
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (405:5): [True: 395k, False: 0]
  ------------------
  406|       |    // Must be called after a mp_dispatch_lock(), from the same thread.
  407|   395k|    mp_assert(queue->locked_explicit);
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (407:5): [True: 395k, False: 0]
  ------------------
  408|   395k|    mp_assert(mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id()));
  ------------------
  |  |   41|   395k|#define mp_assert assert
  ------------------
  |  Branch (408:5): [True: 395k, False: 0]
  ------------------
  409|       |    // "Unlock".
  410|   395k|    queue->locked = false;
  411|   395k|    queue->locked_explicit = false;
  412|   395k|    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|   395k|    mp_cond_broadcast(&queue->cond);
  416|   395k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   395k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  417|   395k|}
dispatch.c:queue_dtor:
   64|  44.3k|{
   65|  44.3k|    struct mp_dispatch_queue *queue = p;
   66|  44.3k|    mp_assert(!queue->head);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (66:5): [True: 44.3k, False: 0]
  ------------------
   67|  44.3k|    mp_assert(!queue->in_process);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (67:5): [True: 44.3k, False: 0]
  ------------------
   68|  44.3k|    mp_assert(!queue->lock_requests);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (68:5): [True: 44.3k, False: 0]
  ------------------
   69|  44.3k|    mp_assert(!queue->locked);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (69:5): [True: 44.3k, False: 0]
  ------------------
   70|  44.3k|    mp_cond_destroy(&queue->cond);
   71|  44.3k|    mp_mutex_destroy(&queue->lock);
  ------------------
  |  |  133|  44.3k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   72|  44.3k|}
dispatch.c:mp_dispatch_append:
  128|   219k|{
  129|   219k|    mp_mutex_lock(&queue->lock);
  ------------------
  |  |  134|   219k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  130|   219k|    if (item->mergeable) {
  ------------------
  |  Branch (130:9): [True: 0, False: 219k]
  ------------------
  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|   219k|    if (queue->tail) {
  ------------------
  |  Branch (142:9): [True: 17.6k, False: 201k]
  ------------------
  143|  17.6k|        queue->tail->next = item;
  144|   201k|    } else {
  145|   201k|        queue->head = item;
  146|   201k|    }
  147|   219k|    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|   219k|    mp_cond_broadcast(&queue->cond);
  152|       |    // No wakeup callback -> assume mp_dispatch_queue_process() needs to be
  153|       |    // interrupted instead.
  154|   219k|    if (!queue->wakeup_fn)
  ------------------
  |  Branch (154:9): [True: 0, False: 219k]
  ------------------
  155|      0|        queue->interrupted = true;
  156|   219k|    mp_mutex_unlock(&queue->lock);
  ------------------
  |  |  136|   219k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  157|       |
  158|   219k|    if (queue->wakeup_fn)
  ------------------
  |  Branch (158:9): [True: 219k, False: 0]
  ------------------
  159|   219k|        queue->wakeup_fn(queue->wakeup_ctx);
  160|   219k|}

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

json_append:
  295|   148k|{
  296|   148k|    switch (src->format) {
  ------------------
  |  Branch (296:13): [True: 148k, False: 0]
  ------------------
  297|      0|    case MPV_FORMAT_NONE:
  ------------------
  |  Branch (297:5): [True: 0, False: 148k]
  ------------------
  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: 148k]
  ------------------
  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: 148k]
  ------------------
  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: 148k]
  ------------------
  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|   148k|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (311:5): [True: 148k, False: 0]
  ------------------
  312|   148k|        if (indent == 0)
  ------------------
  |  Branch (312:13): [True: 0, False: 148k]
  ------------------
  313|      0|            APPEND(b, src->u.string);
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  314|   148k|        else
  315|   148k|            write_json_str(b, src->u.string);
  316|   148k|        return 0;
  317|      0|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (317:5): [True: 0, False: 148k]
  ------------------
  318|      0|    case MPV_FORMAT_NODE_MAP: {
  ------------------
  |  Branch (318:5): [True: 0, False: 148k]
  ------------------
  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|   148k|    }
  338|      0|    return -1; // unknown format
  339|   148k|}
json_write:
  355|   148k|{
  356|   148k|    return json_append_str(dst, src, -1);
  357|   148k|}
json.c:write_json_str:
  259|   148k|{
  260|   148k|    mp_assert(str);
  ------------------
  |  |   41|   148k|#define mp_assert assert
  ------------------
  |  Branch (260:5): [True: 148k, False: 0]
  ------------------
  261|       |
  262|   148k|    APPEND(b, "\"");
  ------------------
  |  |  248|   148k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  263|   148k|    while (1) {
  ------------------
  |  Branch (263:12): [True: 148k, Folded]
  ------------------
  264|   148k|        unsigned char *cur = str;
  265|   420k|        while (cur[0] >= 32 && cur[0] != '"' && cur[0] != '\\')
  ------------------
  |  Branch (265:16): [True: 272k, False: 148k]
  |  Branch (265:32): [True: 272k, False: 0]
  |  Branch (265:49): [True: 272k, False: 0]
  ------------------
  266|   272k|            cur++;
  267|   148k|        if (!cur[0])
  ------------------
  |  Branch (267:13): [True: 148k, False: 0]
  ------------------
  268|   148k|            break;
  269|      0|        bstr_xappend(NULL, b, (bstr){str, cur - str});
  270|      0|        if (cur[0] == '\"') {
  ------------------
  |  Branch (270:13): [True: 0, False: 0]
  ------------------
  271|      0|            bstr_xappend(NULL, b, (bstr){"\\\"", 2});
  272|      0|        } else if (cur[0] == '\\') {
  ------------------
  |  Branch (272:20): [True: 0, False: 0]
  ------------------
  273|      0|            bstr_xappend(NULL, b, (bstr){"\\\\", 2});
  274|      0|        } else if (cur[0] < sizeof(special_escape) && special_escape[cur[0]]) {
  ------------------
  |  Branch (274:20): [True: 0, False: 0]
  |  Branch (274:55): [True: 0, False: 0]
  ------------------
  275|      0|            bstr_xappend_asprintf(NULL, b, "\\%c", special_escape[cur[0]]);
  276|      0|        } else {
  277|      0|            bstr_xappend_asprintf(NULL, b, "\\u%04x", (unsigned char)cur[0]);
  278|      0|        }
  279|      0|        str = cur + 1;
  280|      0|    }
  281|   148k|    APPEND(b, str);
  ------------------
  |  |  248|   148k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  282|       |    APPEND(b, "\"");
  ------------------
  |  |  248|   148k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  283|   148k|}
json.c:json_append_str:
  342|   148k|{
  343|   148k|    bstr buffer = bstr0(*dst);
  344|   148k|    int r = json_append(&buffer, src, indent);
  345|   148k|    *dst = buffer.start;
  346|   148k|    return r;
  347|   148k|}

mp_match_lang:
  255|  13.8k|{
  256|  13.8k|    if (!lang)
  ------------------
  |  Branch (256:9): [True: 1.17k, False: 12.6k]
  ------------------
  257|  1.17k|        return 0;
  258|       |
  259|  12.6k|    void *ta_ctx = talloc_new(NULL);
  ------------------
  |  |   40|  12.6k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  12.6k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  260|  12.6k|    int lang_parts_n = 0;
  261|  12.6k|    bstr *lang_parts = NULL;
  262|  12.6k|    bstr rest = bstr0(lang);
  263|  25.3k|    while (rest.len) {
  ------------------
  |  Branch (263:12): [True: 12.6k, False: 12.6k]
  ------------------
  264|  12.6k|        bstr s = bstr_split(rest, "-", &rest);
  265|  12.6k|        MP_TARRAY_APPEND(ta_ctx, lang_parts, lang_parts_n, s);
  ------------------
  |  |  105|  12.6k|    do {                                            \
  |  |  106|  12.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  12.6k|    do {                                            \
  |  |  |  |   97|  12.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  12.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  12.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  12.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 12.6k, False: 4]
  |  |  |  |  ------------------
  |  |  |  |   99|  12.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  12.6k|    do {                                                        \
  |  |  |  |  |  |   89|  12.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  12.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  12.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  12.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  12.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  12.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  12.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 12.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  12.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 12.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  12.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  12.6k|        (idxvar)++;                                 \
  |  |  109|  12.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 12.6k]
  |  |  ------------------
  ------------------
  266|  12.6k|    }
  267|       |
  268|  12.6k|    int best_score = 0;
  269|  12.6k|    if (!lang_parts_n)
  ------------------
  |  Branch (269:9): [True: 8, False: 12.6k]
  ------------------
  270|      8|        goto done;
  271|       |
  272|  17.4k|    for (int idx = 0; langs && langs[idx]; idx++) {
  ------------------
  |  Branch (272:23): [True: 9.74k, False: 7.67k]
  |  Branch (272:32): [True: 4.73k, False: 5.01k]
  ------------------
  273|  4.73k|        rest = bstr0(langs[idx]);
  274|  4.73k|        int part = 0;
  275|  4.73k|        int score = 0;
  276|  6.64k|        while (rest.len) {
  ------------------
  |  Branch (276:16): [True: 4.73k, False: 1.91k]
  ------------------
  277|  4.73k|            bstr s = bstr_split(rest, "-", &rest);
  278|  4.73k|            if (!part) {
  ------------------
  |  Branch (278:17): [True: 4.73k, False: 0]
  ------------------
  279|  4.73k|                if (bstrcasecmp(canonicalize(lang_parts[0]), canonicalize(s)))
  ------------------
  |  Branch (279:21): [True: 2.82k, False: 1.90k]
  ------------------
  280|  2.82k|                    break;
  281|  1.90k|                score = INT_MAX - idx;
  282|  1.90k|                part++;
  283|  1.90k|                continue;
  284|  4.73k|            }
  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|  4.73k|        score -= (lang_parts_n - part) * 1000;
  295|  4.73k|        best_score = MPMAX(best_score, score);
  ------------------
  |  |   44|  4.73k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 2.82k, False: 1.90k]
  |  |  ------------------
  ------------------
  296|  4.73k|    }
  297|       |
  298|  12.6k|done:
  299|  12.6k|    talloc_free(ta_ctx);
  ------------------
  |  |   47|  12.6k|#define talloc_free                     ta_free
  ------------------
  300|  12.6k|    return best_score;
  301|  12.6k|}
language.c:canonicalize:
  248|  9.46k|{
  249|  9.46k|    const struct lang *l = bsearch(&lang, langmap, MP_ARRAY_SIZE(langmap),
  ------------------
  |  |   49|  9.46k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  250|  9.46k|                                   sizeof(langmap[0]), &lang_compare);
  251|  9.46k|    return l ? (bstr){(unsigned char *)l->canonical.s, l->canonical.l} : lang;
  ------------------
  |  Branch (251:12): [True: 5, False: 9.45k]
  ------------------
  252|  9.46k|}
language.c:lang_compare:
  242|  75.6k|{
  243|  75.6k|    const struct lang *l = lang;
  244|  75.6k|    return bstrcasecmp(*(const bstr*)key, (bstr){(unsigned char *)l->match.s, l->match.l});
  245|  75.6k|}

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

mp_basename_bstr:
   43|  1.52M|{
   44|  1.52M|    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|  1.52M|    separator_pos = bstrrchr(path, '/');
   57|  1.52M|    if (separator_pos < 0)
  ------------------
  |  Branch (57:9): [True: 24.2k, False: 1.49M]
  ------------------
   58|  24.2k|        return path;
   59|  1.49M|    return bstr_splice(path, separator_pos + 1, path.len);
   60|  1.52M|}
mp_basename:
   63|  1.47M|{
   64|  1.47M|    return mp_basename_bstr(bstr0(path)).start;
   65|  1.47M|}
mp_dirname:
   68|  24.2k|{
   69|  24.2k|    struct bstr ret = {
   70|  24.2k|        (uint8_t *)path, mp_basename(path) - path
   71|  24.2k|    };
   72|  24.2k|    if (ret.len == 0)
  ------------------
  |  Branch (72:9): [True: 0, False: 24.2k]
  ------------------
   73|      0|        return bstr0(".");
   74|  24.2k|    return ret;
   75|  24.2k|}
mp_strip_ext:
  114|  24.2k|{
  115|  24.2k|    bstr root = {0};
  116|  24.2k|    split_ext(path, &root);
  117|  24.2k|    return root.len ? root : path;
  ------------------
  |  Branch (117:12): [True: 0, False: 24.2k]
  ------------------
  118|  24.2k|}
mp_get_ext:
  121|  24.7k|{
  122|       |    return split_ext(path, NULL);
  123|  24.7k|}
mp_path_join_bstr:
  143|  49.5k|{
  144|  49.5k|    if (p1.len == 0)
  ------------------
  |  Branch (144:9): [True: 49.5k, False: 0]
  ------------------
  145|  49.5k|        return bstrdup0(talloc_ctx, p2);
  146|      0|    if (p2.len == 0)
  ------------------
  |  Branch (146:9): [True: 0, False: 0]
  ------------------
  147|      0|        return bstrdup0(talloc_ctx, p1);
  148|       |
  149|      0|    if (mp_path_is_absolute(p2))
  ------------------
  |  Branch (149:9): [True: 0, False: 0]
  ------------------
  150|      0|        return bstrdup0(talloc_ctx, p2);
  151|       |
  152|      0|    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|      0|    return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1),
  ------------------
  |  |   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]
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|      0|                           have_separator ? "" : "/", BSTR_P(p2));
  161|      0|}
mp_normalize_path:
  191|  24.7k|{
  192|  24.7k|    if (!path)
  ------------------
  |  Branch (192:9): [True: 0, False: 24.7k]
  ------------------
  193|      0|        return NULL;
  194|       |
  195|  24.7k|    if (!path[0] || mp_is_url(bstr0(path)) || !strcmp(path, "-"))
  ------------------
  |  Branch (195:9): [True: 0, False: 24.7k]
  |  Branch (195:21): [True: 24.7k, False: 0]
  |  Branch (195:47): [True: 0, False: 0]
  ------------------
  196|  24.7k|        return talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
  197|       |
  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|    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|      0|    if (!mp_path_is_absolute(bstr0(path))) {
  ------------------
  |  Branch (218:9): [True: 0, False: 0]
  ------------------
  219|      0|        char *cwd = mp_getcwd(tmp);
  220|      0|        if (!cwd) {
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|      0|            result = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  222|      0|            goto exit;
  223|      0|        }
  224|      0|        path = mp_path_join(tmp, cwd, path);
  225|      0|    }
  226|       |
  227|      0|    result = talloc_strdup(tmp, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  228|      0|    const char *next;
  229|      0|    const char *end = path + strlen(path);
  230|       |
  231|      0|    for (const char *ptr = path; ptr < end; ptr = next + 1) {
  ------------------
  |  Branch (231:34): [True: 0, False: 0]
  ------------------
  232|      0|        next = memchr(ptr, '/', end - ptr);
  233|      0|        if (next == NULL)
  ------------------
  |  Branch (233:13): [True: 0, False: 0]
  ------------------
  234|      0|            next = end;
  235|       |
  236|      0|        switch (next - ptr) {
  ------------------
  |  Branch (236:17): [True: 0, False: 0]
  ------------------
  237|      0|            case 0:
  ------------------
  |  Branch (237:13): [True: 0, False: 0]
  ------------------
  238|      0|                continue;
  239|      0|            case 1:
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  ------------------
  240|      0|                if (ptr[0] == '.')
  ------------------
  |  Branch (240:21): [True: 0, False: 0]
  ------------------
  241|      0|                    continue;
  242|      0|                break;
  243|      0|            case 2:
  ------------------
  |  Branch (243:13): [True: 0, False: 0]
  ------------------
  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|      0|                if (ptr[0] == '.' && ptr[1] == '.') {
  ------------------
  |  Branch (252:21): [True: 0, False: 0]
  |  Branch (252:38): [True: 0, False: 0]
  ------------------
  253|      0|                    char *tmp_result = realpath(path, NULL);
  254|      0|                    result = talloc_strdup(talloc_ctx,
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  255|      0|                                           tmp_result ? tmp_result : path);
  ------------------
  |  Branch (255:44): [True: 0, False: 0]
  ------------------
  256|      0|                    free(tmp_result);
  257|      0|                    goto exit;
  258|      0|                }
  259|      0|        }
  260|       |
  261|      0|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|      0|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  262|      0|        result = talloc_strndup_append_buffer(result, ptr, next - ptr);
  ------------------
  |  |   60|      0|#define talloc_strndup_append_buffer    ta_talloc_strndup_append_buffer
  ------------------
  263|      0|    }
  264|       |
  265|      0|    if (!result[0])
  ------------------
  |  Branch (265:9): [True: 0, False: 0]
  ------------------
  266|      0|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|      0|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  267|       |
  268|      0|    result = talloc_steal(talloc_ctx, result);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  269|      0|#endif
  270|       |
  271|      0|exit:
  272|      0|    talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  273|      0|    return result;
  274|      0|}
mp_is_url:
  290|  1.57M|{
  291|  1.57M|    int proto = bstr_find0(path, "://");
  292|  1.57M|    if (proto < 1)
  ------------------
  |  Branch (292:9): [True: 0, False: 1.57M]
  ------------------
  293|      0|        return false;
  294|       |    // Per RFC3986, the first character of the protocol must be alphabetic.
  295|       |    // The rest must be alphanumeric plus -, + and .
  296|  4.71M|    for (int i = 0; i < proto; i++) {
  ------------------
  |  Branch (296:21): [True: 3.14M, False: 1.57M]
  ------------------
  297|  3.14M|        unsigned char c = path.start[i];
  298|  3.14M|        if ((i == 0 && !mp_isalpha(c)) ||
  ------------------
  |  Branch (298:14): [True: 1.57M, False: 1.57M]
  |  Branch (298:24): [True: 0, False: 1.57M]
  ------------------
  299|  3.14M|            (!mp_isalnum(c) && c != '.' && c != '-' && c != '+'))
  ------------------
  |  Branch (299:14): [True: 0, False: 3.14M]
  |  Branch (299:32): [True: 0, False: 0]
  |  Branch (299:44): [True: 0, False: 0]
  |  Branch (299:56): [True: 0, False: 0]
  ------------------
  300|      0|        {
  301|      0|            return false;
  302|      0|        }
  303|  3.14M|    }
  304|  1.57M|    return true;
  305|  1.57M|}
mp_split_proto:
  310|  74.2k|{
  311|  74.2k|    if (!mp_is_url(path))
  ------------------
  |  Branch (311:9): [True: 0, False: 74.2k]
  ------------------
  312|      0|        return (bstr){0};
  313|  74.2k|    bstr r;
  314|  74.2k|    bstr_split_tok(path, "://", &r, out_url ? out_url : &(bstr){0});
  ------------------
  |  Branch (314:37): [True: 49.5k, False: 24.7k]
  ------------------
  315|  74.2k|    return r;
  316|  74.2k|}
path_utils.c:split_ext:
   97|  49.0k|{
   98|  49.0k|    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|  49.0k|    basename = bstr_splice(basename, bstrspn(basename, "."), basename.len);
  103|       |
  104|  49.0k|    int dot_pos = bstrrchr(basename, '.');
  105|  49.0k|    if (dot_pos < 0 || dot_pos == basename.len - 1)
  ------------------
  |  Branch (105:9): [True: 49.0k, False: 0]
  |  Branch (105:24): [True: 0, False: 0]
  ------------------
  106|  49.0k|        return (bstr){0};
  107|      0|    bstr ext = bstr_splice(basename, dot_pos + 1, basename.len);
  108|      0|    if (root)
  ------------------
  |  Branch (108:9): [True: 0, False: 0]
  ------------------
  109|      0|        *root = (bstr){path.start, ext.start - 1 - path.start};
  110|      0|    return ext;
  111|  49.0k|}

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

mp_thread_pool_create:
  155|  24.7k|{
  156|  24.7k|    mp_assert(min_threads >= 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (156:5): [True: 24.7k, False: 0]
  ------------------
  157|  24.7k|    mp_assert(init_threads <= min_threads);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (157:5): [True: 24.7k, False: 0]
  ------------------
  158|  24.7k|    mp_assert(max_threads > 0 && max_threads >= min_threads);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (158:5): [True: 24.7k, False: 0]
  |  Branch (158:5): [True: 24.7k, False: 0]
  ------------------
  159|       |
  160|  24.7k|    struct mp_thread_pool *pool = talloc_zero(ta_parent, struct mp_thread_pool);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|  24.7k|    talloc_set_destructor(pool, thread_pool_dtor);
  ------------------
  |  |   41|  24.7k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  162|       |
  163|  24.7k|    mp_mutex_init(&pool->lock);
  164|  24.7k|    mp_cond_init(&pool->wakeup);
  165|       |
  166|  24.7k|    pool->min_threads = min_threads;
  167|  24.7k|    pool->max_threads = max_threads;
  168|       |
  169|  24.7k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  170|  24.7k|    for (int n = 0; n < init_threads; n++)
  ------------------
  |  Branch (170:21): [True: 0, False: 24.7k]
  ------------------
  171|      0|        add_thread(pool);
  172|  24.7k|    bool ok = pool->num_threads >= init_threads;
  173|  24.7k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  174|       |
  175|  24.7k|    if (!ok)
  ------------------
  |  Branch (175:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    return pool;
  179|  24.7k|}
mp_thread_pool_queue:
  215|  24.2k|{
  216|       |    return thread_pool_add(pool, fn, fn_ctx, true);
  217|  24.2k|}
thread_pool.c:thread_pool_dtor:
  116|  24.7k|{
  117|  24.7k|    struct mp_thread_pool *pool = ctx;
  118|       |
  119|       |
  120|  24.7k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  121|       |
  122|  24.7k|    pool->terminate = true;
  123|  24.7k|    mp_cond_broadcast(&pool->wakeup);
  124|       |
  125|  24.7k|    mp_thread *threads = pool->threads;
  126|  24.7k|    int num_threads = pool->num_threads;
  127|       |
  128|  24.7k|    pool->threads = NULL;
  129|  24.7k|    pool->num_threads = 0;
  130|       |
  131|  24.7k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  132|       |
  133|  49.0k|    for (int n = 0; n < num_threads; n++)
  ------------------
  |  Branch (133:21): [True: 24.2k, False: 24.7k]
  ------------------
  134|  24.2k|        mp_thread_join(threads[n]);
  ------------------
  |  |  215|  24.2k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  135|       |
  136|  24.7k|    mp_assert(pool->num_work == 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (136:5): [True: 24.7k, False: 0]
  ------------------
  137|  24.7k|    mp_assert(pool->num_threads == 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (137:5): [True: 24.7k, False: 0]
  ------------------
  138|  24.7k|    mp_cond_destroy(&pool->wakeup);
  139|  24.7k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  140|  24.7k|}
thread_pool.c:add_thread:
  143|  24.2k|{
  144|  24.2k|    mp_thread thread;
  145|       |
  146|  24.2k|    if (mp_thread_create(&thread, worker_thread, pool) != 0)
  ------------------
  |  |  214|  24.2k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (146:9): [True: 0, False: 24.2k]
  ------------------
  147|      0|        return false;
  148|       |
  149|  24.2k|    MP_TARRAY_APPEND(pool, pool->threads, pool->num_threads, thread);
  ------------------
  |  |  105|  24.2k|    do {                                            \
  |  |  106|  24.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.2k|    do {                                            \
  |  |  |  |   97|  24.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.2k|    do {                                                        \
  |  |  |  |  |  |   89|  24.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.2k|        (idxvar)++;                                 \
  |  |  109|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  150|       |    return true;
  151|  24.2k|}
thread_pool.c:worker_thread:
   52|  24.2k|{
   53|  24.2k|    struct mp_thread_pool *pool = arg;
   54|       |
   55|  24.2k|    mp_thread_set_name("worker");
   56|       |
   57|  24.2k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   58|       |
   59|  24.2k|    int64_t destroy_deadline = 0;
   60|  24.2k|    bool got_timeout = false;
   61|  72.7k|    while (1) {
  ------------------
  |  Branch (61:12): [True: 72.7k, Folded]
  ------------------
   62|  72.7k|        struct work work = {0};
   63|  72.7k|        if (pool->num_work > 0) {
  ------------------
  |  Branch (63:13): [True: 24.2k, False: 48.5k]
  ------------------
   64|  24.2k|            work = pool->work[pool->num_work - 1];
   65|  24.2k|            pool->num_work -= 1;
   66|  24.2k|        }
   67|       |
   68|  72.7k|        if (!work.fn) {
  ------------------
  |  Branch (68:13): [True: 48.5k, False: 24.2k]
  ------------------
   69|  48.5k|            if (got_timeout || pool->terminate)
  ------------------
  |  Branch (69:17): [True: 0, False: 48.5k]
  |  Branch (69:32): [True: 24.2k, False: 24.2k]
  ------------------
   70|  24.2k|                break;
   71|       |
   72|  24.2k|            if (pool->num_threads > pool->min_threads) {
  ------------------
  |  Branch (72:17): [True: 0, False: 24.2k]
  ------------------
   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|  24.2k|            } else {
   78|  24.2k|                mp_cond_wait(&pool->wakeup, &pool->lock);
   79|  24.2k|            }
   80|  24.2k|            continue;
   81|  48.5k|        }
   82|       |
   83|  24.2k|        pool->busy_threads += 1;
   84|  24.2k|        mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|       |
   86|  24.2k|        work.fn(work.fn_ctx);
   87|       |
   88|  24.2k|        mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   89|  24.2k|        pool->busy_threads -= 1;
   90|       |
   91|  24.2k|        destroy_deadline = 0;
   92|  24.2k|        got_timeout = false;
   93|  24.2k|    }
   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|  24.2k|    if (!pool->terminate) {
  ------------------
  |  Branch (97:9): [True: 0, False: 24.2k]
  ------------------
   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|  24.2k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  112|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  24.2k|#define MP_THREAD_RETURN() return NULL
  ------------------
  113|  24.2k|}
thread_pool.c:thread_pool_add:
  183|  24.2k|{
  184|  24.2k|    bool ok = true;
  185|       |
  186|  24.2k|    mp_assert(fn);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (186:5): [True: 24.2k, False: 0]
  ------------------
  187|       |
  188|  24.2k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  24.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  189|  24.2k|    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|  24.2k|    if (pool->busy_threads + pool->num_work + 1 > pool->num_threads &&
  ------------------
  |  Branch (195:9): [True: 24.2k, False: 0]
  ------------------
  196|  24.2k|        pool->num_threads < pool->max_threads)
  ------------------
  |  Branch (196:9): [True: 24.2k, False: 0]
  ------------------
  197|  24.2k|    {
  198|  24.2k|        if (!add_thread(pool)) {
  ------------------
  |  Branch (198:13): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|    }
  203|       |
  204|  24.2k|    if (ok) {
  ------------------
  |  Branch (204:9): [True: 24.2k, False: 0]
  ------------------
  205|  24.2k|        MP_TARRAY_INSERT_AT(pool, pool->work, pool->num_work, 0, work);
  ------------------
  |  |  115|  24.2k|    do {                                            \
  |  |  116|  24.2k|        size_t at_ = (at);                          \
  |  |  117|  24.2k|        assert(at_ <= (idxvar));                    \
  |  |  118|  24.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.2k|    do {                                            \
  |  |  |  |   97|  24.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.2k|    do {                                                        \
  |  |  |  |  |  |   89|  24.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  24.2k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  24.2k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  24.2k|        (idxvar)++;                                 \
  |  |  122|  24.2k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  |  Branch (205:9): [True: 24.2k, False: 0]
  ------------------
  206|  24.2k|        mp_cond_signal(&pool->wakeup);
  207|  24.2k|    }
  208|       |
  209|  24.2k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  24.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  210|  24.2k|    return ok;
  211|  24.2k|}

mp_waiter_wait:
   36|  98.5k|{
   37|  98.5k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|  98.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   38|  98.5k|    while (!waiter->done)
  ------------------
  |  Branch (38:12): [True: 0, False: 98.5k]
  ------------------
   39|      0|        mp_cond_wait(&waiter->wakeup, &waiter->lock);
   40|  98.5k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|  98.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   41|       |
   42|  98.5k|    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|  98.5k|    mp_mutex_destroy(&waiter->lock);
  ------------------
  |  |  133|  98.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   53|  98.5k|    mp_cond_destroy(&waiter->wakeup);
   54|       |
   55|  98.5k|    memset(waiter, 0xCA, sizeof(*waiter)); // for debugging
   56|       |
   57|  98.5k|    return ret;
   58|  98.5k|}
mp_waiter_wakeup:
   61|  98.5k|{
   62|  98.5k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|  98.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   63|  98.5k|    mp_assert(!waiter->done);
  ------------------
  |  |   41|  98.5k|#define mp_assert assert
  ------------------
  |  Branch (63:5): [True: 98.5k, False: 0]
  ------------------
   64|  98.5k|    waiter->done = true;
   65|  98.5k|    waiter->value = value;
   66|  98.5k|    mp_cond_signal(&waiter->wakeup);
   67|  98.5k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|  98.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   68|  98.5k|}
mp_waiter_poll:
   71|  48.5k|{
   72|  48.5k|    mp_mutex_lock(&waiter->lock);
  ------------------
  |  |  134|  48.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   73|  48.5k|    bool r = waiter->done;
   74|  48.5k|    mp_mutex_unlock(&waiter->lock);
  ------------------
  |  |  136|  48.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   75|  48.5k|    return r;
   76|  48.5k|}
mp_cancel_new:
  124|  99.0k|{
  125|  99.0k|    struct mp_cancel *c = talloc_ptrtype(talloc_ctx, c);
  ------------------
  |  |   34|  99.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  99.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  99.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  126|  99.0k|    talloc_set_destructor(c, cancel_destroy);
  ------------------
  |  |   41|  99.0k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  127|  99.0k|    *c = (struct mp_cancel){
  128|       |        .triggered = false,
  129|  99.0k|        .wakeup_pipe = {-1, -1},
  130|  99.0k|    };
  131|  99.0k|    mp_mutex_init(&c->lock);
  132|  99.0k|    mp_cond_init(&c->wakeup);
  133|  99.0k|    return c;
  134|  99.0k|}
mp_cancel_trigger:
  158|  74.2k|{
  159|  74.2k|    mp_mutex_lock(&c->lock);
  ------------------
  |  |  134|  74.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  160|  74.2k|    trigger_locked(c);
  161|  74.2k|    mp_mutex_unlock(&c->lock);
  ------------------
  |  |  136|  74.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  162|  74.2k|}
mp_cancel_reset:
  165|  24.7k|{
  166|  24.7k|    mp_mutex_lock(&c->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  167|       |
  168|  24.7k|    atomic_store(&c->triggered, false);
  169|       |
  170|  24.7k|    if (c->wakeup_pipe[0] >= 0) {
  ------------------
  |  Branch (170:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    mp_mutex_unlock(&c->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  185|  24.7k|}
mp_cancel_test:
  188|  2.92M|{
  189|  2.92M|    return c ? atomic_load_explicit(&c->triggered, memory_order_relaxed) : false;
  ------------------
  |  Branch (189:12): [True: 2.92M, False: 0]
  ------------------
  190|  2.92M|}
mp_cancel_set_parent:
  223|   197k|{
  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|   197k|    if (slave->parent == parent)
  ------------------
  |  Branch (227:9): [True: 24.7k, False: 172k]
  ------------------
  228|  24.7k|        return;
  229|   172k|    if (slave->parent) {
  ------------------
  |  Branch (229:9): [True: 98.5k, False: 74.2k]
  ------------------
  230|  98.5k|        mp_mutex_lock(&slave->parent->lock);
  ------------------
  |  |  134|  98.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|  98.5k|        LL_REMOVE(siblings, &slave->parent->slaves, slave);
  ------------------
  |  |   78|  98.5k|#define LL_REMOVE(field, list, item) do {                               \
  |  |   79|  98.5k|    if ((item)->field.prev) {                                           \
  |  |  ------------------
  |  |  |  Branch (79:9): [True: 0, False: 98.5k]
  |  |  ------------------
  |  |   80|      0|        (item)->field.prev->field.next = (item)->field.next;            \
  |  |   81|  98.5k|    } else {                                                            \
  |  |   82|  98.5k|        (list)->head = (item)->field.next;                              \
  |  |   83|  98.5k|    }                                                                   \
  |  |   84|  98.5k|    if ((item)->field.next) {                                           \
  |  |  ------------------
  |  |  |  Branch (84:9): [True: 24.2k, False: 74.2k]
  |  |  ------------------
  |  |   85|  24.2k|        (item)->field.next->field.prev = (item)->field.prev;            \
  |  |   86|  74.2k|    } else {                                                            \
  |  |   87|  74.2k|        (list)->tail = (item)->field.prev;                              \
  |  |   88|  74.2k|    }                                                                   \
  |  |   89|  98.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (89:10): [Folded, False: 98.5k]
  |  |  ------------------
  ------------------
  232|  98.5k|        mp_mutex_unlock(&slave->parent->lock);
  ------------------
  |  |  136|  98.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|  98.5k|    }
  234|   172k|    slave->parent = parent;
  235|   172k|    if (slave->parent) {
  ------------------
  |  Branch (235:9): [True: 98.5k, False: 74.2k]
  ------------------
  236|  98.5k|        mp_mutex_lock(&slave->parent->lock);
  ------------------
  |  |  134|  98.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  237|  98.5k|        LL_APPEND(siblings, &slave->parent->slaves, slave);
  ------------------
  |  |   44|  98.5k|#define LL_APPEND(field, list, item)  do {                              \
  |  |   45|  98.5k|    (item)->field.prev = (list)->tail;                                  \
  |  |   46|  98.5k|    (item)->field.next = NULL;                                          \
  |  |   47|  98.5k|    LL_RELINK_(field, list, item)                                       \
  |  |  ------------------
  |  |  |  |   98|  98.5k|    if ((item)->field.prev) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:9): [True: 24.2k, False: 74.2k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|        (item)->field.prev->field.next = (item);                        \
  |  |  |  |  100|  74.2k|    } else {                                                            \
  |  |  |  |  101|  74.2k|        (list)->head = (item);                                          \
  |  |  |  |  102|  74.2k|    }                                                                   \
  |  |  |  |  103|  98.5k|    if ((item)->field.next) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:9): [True: 0, False: 98.5k]
  |  |  |  |  ------------------
  |  |  |  |  104|      0|        (item)->field.next->field.prev = (item);                        \
  |  |  |  |  105|  98.5k|    } else {                                                            \
  |  |  |  |  106|  98.5k|        (list)->tail = (item);                                          \
  |  |  |  |  107|  98.5k|    }
  |  |  ------------------
  |  |   48|  98.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (48:10): [Folded, False: 98.5k]
  |  |  ------------------
  ------------------
  238|  98.5k|        retrigger_locked(slave->parent);
  239|  98.5k|        mp_mutex_unlock(&slave->parent->lock);
  ------------------
  |  |  136|  98.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  240|  98.5k|    }
  241|   172k|}
thread_tools.c:cancel_destroy:
  102|  99.0k|{
  103|  99.0k|    struct mp_cancel *c = p;
  104|       |
  105|  99.0k|    mp_assert(!c->slaves.head); // API user error
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (105:5): [True: 99.0k, False: 0]
  ------------------
  106|       |
  107|  99.0k|    mp_cancel_set_parent(c, NULL);
  108|       |
  109|  99.0k|    if (c->wakeup_pipe[0] >= 0) {
  ------------------
  |  Branch (109:9): [True: 0, False: 99.0k]
  ------------------
  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|  99.0k|    mp_mutex_destroy(&c->lock);
  ------------------
  |  |  133|  99.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  120|  99.0k|    mp_cond_destroy(&c->wakeup);
  121|  99.0k|}
thread_tools.c:trigger_locked:
  137|  74.2k|{
  138|  74.2k|    atomic_store(&c->triggered, true);
  139|       |
  140|  74.2k|    mp_cond_broadcast(&c->wakeup); // condition bound to c->triggered
  141|       |
  142|  74.2k|    if (c->cb)
  ------------------
  |  Branch (142:9): [True: 0, False: 74.2k]
  ------------------
  143|      0|        c->cb(c->cb_ctx);
  144|       |
  145|  74.2k|    for (struct mp_cancel *sub = c->slaves.head; sub; sub = sub->siblings.next)
  ------------------
  |  Branch (145:50): [True: 0, False: 74.2k]
  ------------------
  146|      0|        mp_cancel_trigger(sub);
  147|       |
  148|  74.2k|    if (c->wakeup_pipe[1] >= 0)
  ------------------
  |  Branch (148:9): [True: 0, False: 74.2k]
  ------------------
  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|  74.2k|}
thread_tools.c:retrigger_locked:
  208|  98.5k|{
  209|  98.5k|    if (mp_cancel_test(c))
  ------------------
  |  Branch (209:9): [True: 0, False: 98.5k]
  ------------------
  210|      0|        trigger_locked(c);
  211|  98.5k|}

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

m_config_restore_backups:
  235|  49.5k|{
  236|  49.5k|    restore_backups(&config->backup_opts, config);
  237|  49.5k|}
m_config_backup_watch_later_opts:
  276|  24.7k|{
  277|       |    // Runs once on the empty list, which is looked up by name.
  278|  24.7k|    mp_assert(!config->watch_later_backup_opts);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (278:5): [True: 24.7k, False: 0]
  ------------------
  279|  19.4M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (279:21): [True: 19.4M, False: 24.7k]
  ------------------
  280|  19.4M|        if (config->opts[n].data)
  ------------------
  |  Branch (280:13): [True: 18.1M, False: 1.23M]
  ------------------
  281|  18.1M|            add_backup(&config->watch_later_backup_opts, 0, &config->opts[n]);
  282|  19.4M|    }
  283|  24.7k|}
m_config_get_co_raw:
  300|  2.94M|{
  301|  2.94M|    struct m_config_option **co =
  302|  2.94M|        bsearch(&name, config->sorted_opts, config->num_opts,
  303|  2.94M|                sizeof(config->sorted_opts[0]), search_opt_name);
  304|  2.94M|    return co ? *co : NULL;
  ------------------
  |  Branch (304:12): [True: 2.67M, False: 272k]
  ------------------
  305|  2.94M|}
m_config_get_co:
  359|  2.07M|{
  360|  2.07M|    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.07M|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (363:9): [True: 1.93M, False: 148k]
  |  Branch (363:15): [True: 173k, False: 1.75M]
  ------------------
  364|   173k|        co = NULL;
  365|  2.07M|    return co;
  366|  2.07M|}
m_config_get_co_count:
  369|  24.7k|{
  370|  24.7k|    return config->num_opts;
  371|  24.7k|}
m_config_get_co_index:
  374|  19.4M|{
  375|  19.4M|    return &config->opts[index];
  376|  19.4M|}
m_config_mark_co_flags:
  431|   470k|{
  432|   470k|    if (flags & M_SETOPT_FROM_CMDLINE)
  ------------------
  |  Branch (432:9): [True: 0, False: 470k]
  ------------------
  433|      0|        co->is_set_from_cmdline = true;
  434|       |
  435|   470k|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (435:9): [True: 222k, False: 247k]
  ------------------
  436|   222k|        co->is_set_from_config = true;
  437|   470k|}
m_config_set_update_dispatch_queue:
  530|  24.7k|{
  531|  24.7k|    m_config_cache_set_dispatch_change_cb(config->cache, dispatch,
  532|  24.7k|                                          async_change_cb, config);
  533|  24.7k|}
m_config_new:
  554|  24.7k|{
  555|  24.7k|    struct m_config *config = talloc(talloc_ctx, struct m_config);
  ------------------
  |  |   26|  24.7k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.7k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  24.7k|    talloc_set_destructor(config, config_destroy);
  ------------------
  |  |   41|  24.7k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  557|  24.7k|    *config = (struct m_config){.log = log,};
  558|       |
  559|  24.7k|    config->shadow = m_config_shadow_new(root);
  560|       |
  561|  24.7k|    if (root->size) {
  ------------------
  |  Branch (561:9): [True: 24.7k, False: 0]
  ------------------
  562|  24.7k|        config->cache = m_config_cache_from_shadow(config, config->shadow, root);
  563|  24.7k|        config->optstruct = config->cache->opts;
  564|  24.7k|    }
  565|       |
  566|  24.7k|    int32_t optid = -1;
  567|  19.4M|    while (m_config_shadow_get_next_opt(config->shadow, &optid)) {
  ------------------
  |  Branch (567:12): [True: 19.4M, False: 24.7k]
  ------------------
  568|  19.4M|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  569|  19.4M|        const char *opt_name =
  570|  19.4M|            m_config_shadow_get_opt_name(config->shadow, optid, buf, sizeof(buf));
  571|       |
  572|  19.4M|        struct m_config_option co = {
  573|  19.4M|            .name = talloc_strdup(config, opt_name),
  ------------------
  |  |   50|  19.4M|#define talloc_strdup                   ta_xstrdup
  ------------------
  574|  19.4M|            .opt = m_config_shadow_get_opt(config->shadow, optid),
  575|  19.4M|            .opt_id = optid,
  576|  19.4M|        };
  577|       |
  578|  19.4M|        if (config->cache)
  ------------------
  |  Branch (578:13): [True: 19.4M, False: 0]
  ------------------
  579|  19.4M|            co.data = m_config_cache_get_opt_data(config->cache, optid);
  580|       |
  581|  19.4M|        MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
  ------------------
  |  |  105|  19.4M|    do {                                            \
  |  |  106|  19.4M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  19.4M|    do {                                            \
  |  |  |  |   97|  19.4M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  19.4M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  19.4M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  19.4M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 222k, False: 19.1M]
  |  |  |  |  ------------------
  |  |  |  |   99|  19.4M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   222k|    do {                                                        \
  |  |  |  |  |  |   89|   222k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   222k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   222k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   222k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   222k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   222k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   222k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 222k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  19.4M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 19.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  19.4M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  19.4M|        (idxvar)++;                                 \
  |  |  109|  19.4M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 19.4M]
  |  |  ------------------
  ------------------
  582|  19.4M|    }
  583|       |
  584|  24.7k|    config->sorted_opts = talloc_array(config, struct m_config_option *, config->num_opts);
  ------------------
  |  |   29|  24.7k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  24.7k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|  19.4M|    for (int n = 0; n < config->num_opts; n++)
  ------------------
  |  Branch (585:21): [True: 19.4M, False: 24.7k]
  ------------------
  586|  19.4M|        config->sorted_opts[n] = &config->opts[n];
  587|  24.7k|    qsort(config->sorted_opts, config->num_opts, sizeof(config->sorted_opts[0]), compare_opt_name);
  588|       |
  589|  24.7k|    return config;
  590|  24.7k|}
m_config_notify_change_opt_ptr:
  623|  52.1k|{
  624|       |    notify_opt(config, ptr, true);
  625|  52.1k|}
m_config_set_option_raw:
  637|  1.93M|{
  638|  1.93M|    if (!co)
  ------------------
  |  Branch (638:9): [True: 0, False: 1.93M]
  ------------------
  639|      0|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  640|       |
  641|  1.93M|    int r = handle_set_opt_flags(config, co, flags);
  642|  1.93M|    if (r <= 1)
  ------------------
  |  Branch (642:9): [True: 1.46M, False: 470k]
  ------------------
  643|  1.46M|        return r;
  644|       |
  645|   470k|    r = m_config_handle_special_options(config, co, data, flags);
  646|   470k|    if (r != M_OPT_UNKNOWN)
  ------------------
  |  |  529|   470k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (646:9): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (!co->data)
  ------------------
  |  Branch (651:9): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (config->profile_backup_tmp)
  ------------------
  |  Branch (654:9): [True: 0, False: 470k]
  ------------------
  655|      0|        ensure_backup(config->profile_backup_tmp, config->profile_backup_flags, co);
  656|       |
  657|   470k|    m_config_mark_co_flags(co, flags);
  658|       |
  659|   470k|    m_option_copy(co->opt, co->data, data);
  660|   470k|    if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (660:9): [True: 470k, False: 0]
  ------------------
  661|   470k|        force_self_notify_change_opt(config, co, false);
  662|       |
  663|   470k|    return 0;
  664|   470k|}
m_config_set_option_cli:
  739|  1.80M|{
  740|  1.80M|    int r;
  741|  1.80M|    mp_assert(config != NULL);
  ------------------
  |  |   41|  1.80M|#define mp_assert assert
  ------------------
  |  Branch (741:5): [True: 1.80M, False: 0]
  ------------------
  742|       |
  743|  1.80M|    bool negate;
  744|  1.80M|    struct m_config_option *co =
  745|  1.80M|        m_config_mogrify_cli_opt(config, &name, &negate, &(int){0});
  746|       |
  747|  1.80M|    if (!co) {
  ------------------
  |  Branch (747:9): [True: 123k, False: 1.68M]
  ------------------
  748|   123k|        r = M_OPT_UNKNOWN;
  ------------------
  |  |  529|   123k|#define M_OPT_UNKNOWN           -1
  ------------------
  749|   123k|        goto done;
  750|   123k|    }
  751|       |
  752|  1.68M|    if (negate) {
  ------------------
  |  Branch (752:9): [True: 0, False: 1.68M]
  ------------------
  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.68M|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (761:9): [True: 1.68M, False: 0]
  ------------------
  762|  1.68M|        co->coalesce = true;
  763|       |
  764|       |    // This is the only mandatory function
  765|  1.68M|    mp_assert(co->opt->type->parse);
  ------------------
  |  |   41|  1.68M|#define mp_assert assert
  ------------------
  |  Branch (765:5): [True: 1.68M, False: 0]
  ------------------
  766|       |
  767|  1.68M|    r = handle_set_opt_flags(config, co, flags);
  768|  1.68M|    if (r <= 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 1.68M]
  ------------------
  769|      0|        goto done;
  770|       |
  771|  1.68M|    if (r == 2) {
  ------------------
  |  Branch (771:9): [True: 222k, False: 1.46M]
  ------------------
  772|   222k|        MP_VERBOSE(config, "Setting option '%.*s' = '%.*s' (flags = %d)\n",
  ------------------
  |  |   92|   222k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   891k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 222k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 222k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|   222k|                   BSTR_P(name), BSTR_P(param), flags);
  774|   222k|    }
  775|       |
  776|  1.68M|    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.68M|    if (co->data)
  ------------------
  |  Branch (780:9): [True: 1.60M, False: 74.2k]
  ------------------
  781|  1.60M|        m_option_copy(co->opt, &val, co->data);
  782|       |
  783|  1.68M|    r = m_option_parse(config->log, co->opt, name, param, &val);
  784|       |
  785|  1.68M|    if (r >= 0)
  ------------------
  |  Branch (785:9): [True: 1.68M, False: 0]
  ------------------
  786|  1.68M|        r = m_config_set_option_raw(config, co, &val, flags);
  787|       |
  788|  1.68M|    m_option_free(co->opt, &val);
  789|       |
  790|  1.80M|done:
  791|  1.80M|    if (r < 0 && r != M_OPT_EXIT) {
  ------------------
  |  |  545|   123k|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (791:9): [True: 123k, False: 1.68M]
  |  Branch (791:18): [True: 123k, False: 0]
  ------------------
  792|   123k|        MP_ERR(config, "Error parsing option %.*s (%s)\n",
  ------------------
  |  |   89|   123k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   247k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 123k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|   123k|               BSTR_P(name), m_option_strerror(r));
  794|   123k|        r = M_OPT_INVALID;
  ------------------
  |  |  535|   123k|#define M_OPT_INVALID           -3
  ------------------
  795|   123k|    }
  796|  1.80M|    return r;
  797|  1.68M|}
m_config_set_option_node:
  801|   247k|{
  802|   247k|    int r;
  803|       |
  804|   247k|    struct m_config_option *co = m_config_get_co(config, name);
  805|   247k|    if (!co)
  ------------------
  |  Branch (805:9): [True: 0, False: 247k]
  ------------------
  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|   247k|    union m_option_value val = m_option_value_default;
  811|       |
  812|   247k|    r = m_option_set_node_or_string(mp_null_log, co->opt, name, &val, data);
  813|   247k|    if (r >= 0)
  ------------------
  |  Branch (813:9): [True: 247k, False: 0]
  ------------------
  814|   247k|        r = m_config_set_option_raw(config, co, &val, flags);
  815|       |
  816|   247k|    if (mp_msg_test(config->log, MSGL_V)) {
  ------------------
  |  Branch (816:9): [True: 0, False: 247k]
  ------------------
  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|   247k|    m_option_free(co->opt, &val);
  824|   247k|    return r;
  825|   247k|}
m_config_get_profile:
  939|   420k|{
  940|  3.48M|    for (struct m_profile *p = config->profiles; p; p = p->next) {
  ------------------
  |  Branch (940:50): [True: 3.14M, False: 346k]
  ------------------
  941|  3.14M|        if (bstr_equals0(name, p->name))
  ------------------
  |  Branch (941:13): [True: 74.2k, False: 3.06M]
  ------------------
  942|  74.2k|            return p;
  943|  3.14M|    }
  944|   346k|    return NULL;
  945|   420k|}
m_config_get_profile0:
  949|   420k|{
  950|   420k|    return m_config_get_profile(config, bstr0(name));
  951|   420k|}
m_config_add_profile:
  954|   346k|{
  955|   346k|    if (!name || !name[0])
  ------------------
  |  Branch (955:9): [True: 49.5k, False: 297k]
  |  Branch (955:18): [True: 0, False: 297k]
  ------------------
  956|  49.5k|        name = "default";
  957|   346k|    struct m_profile *p = m_config_get_profile0(config, name);
  958|   346k|    if (p)
  ------------------
  |  Branch (958:9): [True: 24.7k, False: 321k]
  ------------------
  959|  24.7k|        return p;
  960|   321k|    p = talloc_zero(config, struct m_profile);
  ------------------
  |  |   27|   321k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   321k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   321k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|   321k|    p->name = talloc_strdup(p, name);
  ------------------
  |  |   50|   321k|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|   321k|    p->next = config->profiles;
  963|   321k|    config->profiles = p;
  964|   321k|    return p;
  965|   346k|}
m_config_set_profile_option:
  969|  1.58M|{
  970|  1.58M|    if (bstr_equals0(name, "profile-desc")) {
  ------------------
  |  Branch (970:9): [True: 0, False: 1.58M]
  ------------------
  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.58M|    if (bstr_equals0(name, "profile-cond")) {
  ------------------
  |  Branch (975:9): [True: 0, False: 1.58M]
  ------------------
  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.58M|    if (bstr_equals0(name, profile_restore_mode_opt.name)) {
  ------------------
  |  Branch (982:9): [True: 0, False: 1.58M]
  ------------------
  983|      0|        return m_option_parse(config->log, &profile_restore_mode_opt, name, val,
  984|      0|                              &p->restore_mode);
  985|      0|    }
  986|       |
  987|  1.58M|    int i = m_config_set_option_cli(config, name, val,
  988|  1.58M|                                    M_SETOPT_CHECK_ONLY |
  989|  1.58M|                                    M_SETOPT_FROM_CONFIG_FILE);
  990|  1.58M|    if (i < 0)
  ------------------
  |  Branch (990:9): [True: 123k, False: 1.46M]
  ------------------
  991|   123k|        return i;
  992|  1.46M|    p->opts = talloc_realloc(p, p->opts, char *, 2 * (p->num_opts + 2));
  ------------------
  |  |   33|  1.46M|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  1.46M|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  1.46M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.46M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.46M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.46M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|  1.46M|    p->opts[p->num_opts * 2] = bstrto0(p, name);
  994|  1.46M|    p->opts[p->num_opts * 2 + 1] = bstrto0(p, val);
  995|  1.46M|    p->num_opts++;
  996|       |    p->opts[p->num_opts * 2] = p->opts[p->num_opts * 2 + 1] = NULL;
  997|  1.46M|    return 1;
  998|  1.58M|}
m_config_set_profile:
 1021|  49.5k|{
 1022|  49.5k|    MP_VERBOSE(config, "Applying profile '%s'...\n", name);
  ------------------
  |  |   92|  49.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  49.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1023|  49.5k|    struct m_profile *p = find_check_profile(config, name);
 1024|  49.5k|    if (!p)
  ------------------
  |  Branch (1024:9): [True: 0, False: 49.5k]
  ------------------
 1025|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1026|       |
 1027|  49.5k|    if (!config->profile_backup_tmp && p->restore_mode) {
  ------------------
  |  Branch (1027:9): [True: 49.5k, False: 0]
  |  Branch (1027:40): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|    char *profile_name = talloc_strdup(NULL, name);
  ------------------
  |  |   50|  49.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1033|       |    // Note that we don't check if profile applied correctly, it doesn't matter.
 1034|  49.5k|    MP_TARRAY_APPEND(config, config->profile_stack, config->profile_stack_depth, profile_name);
  ------------------
  |  |  105|  49.5k|    do {                                            \
  |  |  106|  49.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  49.5k|    do {                                            \
  |  |  |  |   97|  49.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  49.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  49.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  49.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 24.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  49.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  49.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 49.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  49.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  49.5k|        (idxvar)++;                                 \
  |  |  109|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
 1035|  49.5k|    talloc_steal(config->profile_stack, profile_name);
  ------------------
  |  |   38|  49.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  49.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1036|   272k|    for (int i = 0; i < p->num_opts; i++) {
  ------------------
  |  Branch (1036:21): [True: 222k, False: 49.5k]
  ------------------
 1037|   222k|        m_config_set_option_cli(config,
 1038|   222k|                                bstr0(p->opts[2 * i]),
 1039|   222k|                                bstr0(p->opts[2 * i + 1]),
 1040|   222k|                                flags | M_SETOPT_FROM_CONFIG_FILE);
 1041|   222k|    }
 1042|  49.5k|    if (MP_TARRAY_POP(config->profile_stack, config->profile_stack_depth, &profile_name))
  ------------------
  |  |  153|  49.5k|    ((idxvar) > 0                                   \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 49.5k, False: 0]
  |  |  |  Branch (153:6): [True: 49.5k, False: 0]
  |  |  ------------------
  |  |  154|  49.5k|        ? (*(out) = (p)[--(idxvar)], true)          \
  |  |  155|  49.5k|        : false                                     \
  |  |  156|  49.5k|    )
  ------------------
 1043|  49.5k|        talloc_free(profile_name);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
 1044|       |
 1045|  49.5k|    if (config->profile_backup_tmp == &p->backups) {
  ------------------
  |  Branch (1045:9): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|    return 0;
 1056|  49.5k|}
m_config_finish_default_profile:
 1074|  24.7k|{
 1075|       |    struct m_profile *p = m_config_add_profile(config, NULL);
 1076|  24.7k|    m_config_set_profile(config, p->name, flags & ~M_SETOPT_FROM_CONFIG_FILE);
 1077|  24.7k|    p->num_opts = 0;
 1078|  24.7k|}
m_config_frontend.c:restore_backups:
  220|  49.5k|{
  221|  49.5k|    while (*list) {
  ------------------
  |  Branch (221:12): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|}
m_config_frontend.c:add_backup:
  190|  18.1M|{
  191|  18.1M|    struct m_opt_backup *bc = talloc_ptrtype(NULL, bc);
  ------------------
  |  |   34|  18.1M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  18.1M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  18.1M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  18.1M|    talloc_set_destructor(bc, backup_dtor);
  ------------------
  |  |   41|  18.1M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  193|  18.1M|    *bc = (struct m_opt_backup) {
  194|  18.1M|        .co = co,
  195|  18.1M|        .backup = talloc_zero_size(bc, co->opt->type->size),
  ------------------
  |  |   44|  18.1M|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|  18.1M|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.1M|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  18.1M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  18.1M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  18.1M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  18.1M|        .nval = flags & BACKUP_NVAL
  ------------------
  |  |  187|  18.1M|#define BACKUP_NVAL 2
  ------------------
  |  Branch (196:17): [True: 0, False: 18.1M]
  ------------------
  197|  18.1M|            ? 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|  18.1M|        .flags = flags,
  199|  18.1M|    };
  200|  18.1M|    m_option_copy(co->opt, bc->backup, co->data);
  201|  18.1M|    bc->next = *list;
  202|  18.1M|    *list = bc;
  203|  18.1M|    if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|  18.1M|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (203:9): [True: 0, False: 18.1M]
  ------------------
  204|      0|        co->is_set_locally = true;
  205|  18.1M|}
m_config_frontend.c:backup_dtor:
  179|  18.1M|{
  180|  18.1M|    struct m_opt_backup *bc = p;
  181|  18.1M|    m_option_free(bc->co->opt, bc->backup);
  182|  18.1M|    if (bc->nval)
  ------------------
  |  Branch (182:9): [True: 0, False: 18.1M]
  ------------------
  183|      0|        m_option_free(bc->co->opt, bc->nval);
  184|  18.1M|}
m_config_frontend.c:search_opt_name:
  293|  26.4M|{
  294|  26.4M|    const struct m_config_option *co = *(const struct m_config_option **)pelem;
  295|  26.4M|    return bstrcmp0(*(const bstr *)pkey, co->name);
  296|  26.4M|}
m_config_frontend.c:m_config_get_co_any:
  310|  2.37M|{
  311|  2.37M|    struct m_config_option *co = m_config_get_co_raw(config, name);
  312|  2.37M|    if (!co)
  ------------------
  |  Branch (312:9): [True: 272k, False: 2.10M]
  ------------------
  313|   272k|        return NULL;
  314|       |
  315|  2.10M|    const char *prefix = config->is_toplevel ? "--" : "";
  ------------------
  |  Branch (315:26): [True: 2.10M, False: 0]
  ------------------
  316|  2.10M|    if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (316:9): [True: 0, False: 2.10M]
  ------------------
  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.10M|    } else if (co->opt->type == &m_option_type_removed) {
  ------------------
  |  Branch (333:16): [True: 0, False: 2.10M]
  ------------------
  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.10M|    } else if (co->opt->deprecation_message) {
  ------------------
  |  Branch (346:16): [True: 0, False: 2.10M]
  ------------------
  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.10M|    return co;
  355|  2.10M|}
m_config_frontend.c:config_destroy:
  536|  24.7k|{
  537|  24.7k|    struct m_config *config = p;
  538|  24.7k|    config->option_change_callback = NULL;
  539|  24.7k|    m_config_restore_backups(config);
  540|       |
  541|  24.7k|    struct m_opt_backup **list = &config->watch_later_backup_opts;
  542|  18.1M|    while (*list) {
  ------------------
  |  Branch (542:12): [True: 18.1M, False: 24.7k]
  ------------------
  543|  18.1M|        struct m_opt_backup *bc = *list;
  544|  18.1M|        *list = bc->next;
  545|  18.1M|        talloc_free(bc);
  ------------------
  |  |   47|  18.1M|#define talloc_free                     ta_free
  ------------------
  546|  18.1M|    }
  547|       |
  548|  24.7k|    talloc_free(config->cache);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  549|  24.7k|    talloc_free(config->shadow);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  550|  24.7k|}
m_config_frontend.c:compare_opt_name:
  286|   152M|{
  287|   152M|    const struct m_config_option *a = *(const struct m_config_option **)pa;
  288|   152M|    const struct m_config_option *b = *(const struct m_config_option **)pb;
  289|   152M|    return strcmp(a->name, b->name);
  290|   152M|}
m_config_frontend.c:notify_opt:
  608|  52.1k|{
  609|  2.46M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (609:21): [True: 2.46M, False: 0]
  ------------------
  610|  2.46M|        struct m_config_option *co = &config->opts[n];
  611|  2.46M|        if (co->data == ptr) {
  ------------------
  |  Branch (611:13): [True: 52.1k, False: 2.41M]
  ------------------
  612|  52.1k|            if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (612:17): [True: 0, False: 52.1k]
  ------------------
  613|      0|                force_self_notify_change_opt(config, co, self_notification);
  614|  52.1k|            return;
  615|  52.1k|        }
  616|  2.46M|    }
  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|  3.61M|{
  402|  3.61M|    uint64_t optflags = co->opt->flags;
  403|  3.61M|    bool set = !(flags & M_SETOPT_CHECK_ONLY);
  404|       |
  405|  3.61M|    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: 3.61M]
  |  Branch (405:46): [True: 0, False: 0]
  ------------------
  406|      0|        return 0;
  407|       |
  408|  3.61M|    if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline)
  ------------------
  |  Branch (408:9): [True: 0, False: 3.61M]
  |  Branch (408:48): [True: 0, False: 0]
  ------------------
  409|      0|        set = false;
  410|       |
  411|  3.61M|    if ((flags & M_SETOPT_NO_OVERWRITE) &&
  ------------------
  |  Branch (411:9): [True: 0, False: 3.61M]
  ------------------
  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|  3.61M|    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: 3.61M]
  |  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|  3.61M|    if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
  ------------------
  |  |  468|  3.36M|#define M_OPT_NOCFG             (UINT64_C(1) << 63)
  ------------------
  |  Branch (419:9): [True: 3.36M, False: 247k]
  |  Branch (419:48): [True: 0, False: 3.36M]
  ------------------
  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|  3.61M|    if ((flags & M_SETOPT_BACKUP) && set)
  ------------------
  |  Branch (424:9): [True: 0, False: 3.61M]
  |  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|  3.61M|    return set ? 2 : 1;
  ------------------
  |  Branch (427:12): [True: 693k, False: 2.92M]
  ------------------
  428|  3.61M|}
m_config_frontend.c:m_config_handle_special_options:
  446|   470k|{
  447|   470k|    if (config->use_profiles && strcmp(co->name, "profile") == 0) {
  ------------------
  |  Branch (447:9): [True: 470k, False: 0]
  |  Branch (447:33): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (config->includefunc && strcmp(co->name, "include") == 0) {
  ------------------
  |  Branch (467:9): [True: 470k, False: 0]
  |  Branch (467:32): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (config->use_profiles && strcmp(co->name, "show-profile") == 0)
  ------------------
  |  Branch (483:9): [True: 470k, False: 0]
  |  Branch (483:33): [True: 0, False: 470k]
  ------------------
  484|      0|        return show_profile(config, bstr0(*(char **)data), 0);
  485|       |
  486|   470k|    if (config->is_toplevel && (strcmp(co->name, "h") == 0 ||
  ------------------
  |  Branch (486:9): [True: 470k, False: 0]
  |  Branch (486:33): [True: 0, False: 470k]
  ------------------
  487|   470k|                                strcmp(co->name, "help") == 0))
  ------------------
  |  Branch (487:33): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (strcmp(co->name, "list-options") == 0) {
  ------------------
  |  Branch (496:9): [True: 0, False: 470k]
  ------------------
  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|   470k|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|   470k|#define M_OPT_UNKNOWN           -1
  ------------------
  502|   470k|}
m_config_frontend.c:force_self_notify_change_opt:
  597|   470k|{
  598|   470k|    int changed =
  599|   470k|        m_config_cache_get_option_change_mask(config->cache, co->opt_id);
  600|       |
  601|   470k|    if (config->option_change_callback) {
  ------------------
  |  Branch (601:9): [True: 0, False: 470k]
  ------------------
  602|      0|        config->option_change_callback(config->option_change_callback_ctx, co,
  603|      0|                                       changed, self_notification);
  604|      0|    }
  605|   470k|}
m_config_frontend.c:m_config_mogrify_cli_opt:
  673|  1.80M|{
  674|  1.80M|    *out_negate = false;
  675|  1.80M|    *out_add_flags = 0;
  676|       |
  677|  1.80M|    struct m_config_option *co = m_config_get_co(config, *name);
  678|  1.80M|    if (co)
  ------------------
  |  Branch (678:9): [True: 1.50M, False: 297k]
  ------------------
  679|  1.50M|        return co;
  680|       |
  681|       |    // Turn "--no-foo" into "foo" + set *out_negate.
  682|   297k|    bstr no_name = *name;
  683|   297k|    if (!co && bstr_eatstart0(&no_name, "no-")) {
  ------------------
  |  Branch (683:9): [True: 297k, False: 0]
  |  Branch (683:16): [True: 0, False: 297k]
  ------------------
  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|   297k|    co = m_config_get_co_any(config, *name);
  701|   297k|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (701:9): [True: 173k, False: 123k]
  |  Branch (701:15): [True: 173k, False: 0]
  ------------------
  702|   173k|        *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|   102M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (706:21): [True: 102M, False: 123k]
  ------------------
  707|   102M|        co = &config->opts[n];
  708|   102M|        struct bstr basename = bstr0(co->name);
  709|       |
  710|   102M|        if (!bstr_startswith(*name, basename))
  ------------------
  |  Branch (710:13): [True: 101M, False: 420k]
  ------------------
  711|   101M|            continue;
  712|       |
  713|       |        // Aliased option + a suffix action, e.g. --opengl-shaders-append
  714|   420k|        if (co->opt->type == &m_option_type_alias)
  ------------------
  |  Branch (714:13): [True: 0, False: 420k]
  ------------------
  715|      0|            co = m_config_get_co_any(config, basename);
  716|   420k|        if (!co)
  ------------------
  |  Branch (716:13): [True: 0, False: 420k]
  ------------------
  717|      0|            continue;
  718|       |
  719|   420k|        const struct m_option_type *type = co->opt->type;
  720|   594k|        for (int i = 0; type->actions && type->actions[i].name; i++) {
  ------------------
  |  Branch (720:25): [True: 346k, False: 247k]
  |  Branch (720:42): [True: 346k, False: 0]
  ------------------
  721|   346k|            const struct m_option_action *action = &type->actions[i];
  722|   346k|            bstr suffix = bstr0(action->name);
  723|       |
  724|   346k|            if (bstr_endswith(*name, suffix) &&
  ------------------
  |  Branch (724:17): [True: 173k, False: 173k]
  ------------------
  725|   173k|                (name->len == basename.len + 1 + suffix.len) &&
  ------------------
  |  Branch (725:17): [True: 173k, False: 0]
  ------------------
  726|   173k|                name->start[basename.len] == '-')
  ------------------
  |  Branch (726:17): [True: 173k, False: 0]
  ------------------
  727|   173k|            {
  728|   173k|                *out_add_flags = action->flags;
  729|   173k|                return co;
  730|   173k|            }
  731|   346k|        }
  732|   420k|    }
  733|       |
  734|   123k|    return NULL;
  735|   297k|}
m_config_frontend.c:find_check_profile:
 1001|  49.5k|{
 1002|  49.5k|    struct m_profile *p = m_config_get_profile0(config, name);
 1003|  49.5k|    if (!p) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|    for (size_t i = 0; i < config->profile_stack_depth; ++i) {
  ------------------
  |  Branch (1007:24): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|    if (config->profile_stack_depth > MAX_PROFILE_DEPTH) {
  ------------------
  |  |   43|  49.5k|#define MAX_PROFILE_DEPTH 20
  ------------------
  |  Branch (1013:9): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|    return p;
 1018|  49.5k|}

m_option_parse:
   65|  1.95M|{
   66|  1.95M|    int r = M_OPT_INVALID;
  ------------------
  |  |  535|  1.95M|#define M_OPT_INVALID           -3
  ------------------
   67|  1.95M|    if (bstr_equals0(param, "help") && opt->help) {
  ------------------
  |  Branch (67:9): [True: 0, False: 1.95M]
  |  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|  1.95M|    r = opt->type->parse(log, opt, name, param, dst);
   74|  1.95M|    if (r < 0)
  ------------------
  |  Branch (74:9): [True: 0, False: 1.95M]
  ------------------
   75|      0|        return r;
   76|       |
   77|  1.95M|    if (opt->validate) {
  ------------------
  |  Branch (77:9): [True: 0, False: 1.95M]
  ------------------
   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|  1.95M|    return 1;
   86|  1.95M|}
m_option_strerror:
   89|   123k|{
   90|   123k|    switch (code) {
   91|   123k|    case M_OPT_UNKNOWN:
  ------------------
  |  |  529|   123k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (91:5): [True: 123k, False: 0]
  ------------------
   92|   123k|        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: 123k]
  ------------------
   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: 123k]
  ------------------
   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: 123k]
  ------------------
   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: 123k]
  ------------------
  100|      0|        return "option doesn't take a parameter";
  101|      0|    default:
  ------------------
  |  Branch (101:5): [True: 0, False: 123k]
  ------------------
  102|      0|        return "parser error";
  103|   123k|    }
  104|   123k|}
m_option_set_node_or_string:
  124|   272k|{
  125|   272k|    if (src->format == MPV_FORMAT_STRING) {
  ------------------
  |  Branch (125:9): [True: 272k, False: 0]
  ------------------
  126|   272k|        return m_option_parse(log, opt, name, bstr0(src->u.string), dst);
  127|   272k|    } else {
  128|      0|        return m_option_set_node(opt, dst, src);
  129|      0|    }
  130|   272k|}
m_opt_choice_str:
  608|   605k|{
  609|   605k|    const char *val = m_opt_choice_str_def(choices, value, NULL);
  610|   605k|    if (val)
  ------------------
  |  Branch (610:9): [True: 605k, False: 0]
  ------------------
  611|   605k|        return val;
  612|      0|    return "<unknown>";
  613|   605k|}
m_opt_choice_str_def:
  617|   605k|{
  618|  1.57M|    for (const struct m_opt_choice_alternatives *c = choices; c->name; c++) {
  ------------------
  |  Branch (618:63): [True: 1.57M, False: 2]
  ------------------
  619|  1.57M|        if (c->value == value)
  ------------------
  |  Branch (619:13): [True: 605k, False: 970k]
  ------------------
  620|   605k|            return c->name;
  621|  1.57M|    }
  622|      2|    return def;
  623|   605k|}
m_obj_list_find:
 3045|   126k|{
 3046|   483k|    for (int i = 0; ; i++) {
 3047|   483k|        if (!l->get_desc(dst, i))
  ------------------
  |  Branch (3047:13): [True: 113, False: 483k]
  ------------------
 3048|    113|            break;
 3049|   483k|        if (bstr_equals0(name, dst->name))
  ------------------
  |  Branch (3049:13): [True: 126k, False: 356k]
  ------------------
 3050|   126k|            return true;
 3051|   483k|    }
 3052|    113|    for (int i = 0; l->aliases[i][0]; i++) {
  ------------------
  |  Branch (3052:21): [True: 0, False: 113]
  ------------------
 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|    113|    return false;
 3062|    113|}
node_get_alloc:
 4018|  74.2k|{
 4019|       |    // Assume it was allocated with copy_node(), which allocates all
 4020|       |    // sub-nodes with the parent node as talloc parent.
 4021|  74.2k|    switch (node->format) {
 4022|      0|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (4022:5): [True: 0, False: 74.2k]
  ------------------
 4023|      0|        return node->u.string;
 4024|      0|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (4024:5): [True: 0, False: 74.2k]
  ------------------
 4025|  24.7k|    case MPV_FORMAT_NODE_MAP:
  ------------------
  |  Branch (4025:5): [True: 24.7k, False: 49.5k]
  ------------------
 4026|  24.7k|        return node->u.list;
 4027|  49.5k|    default:
  ------------------
  |  Branch (4027:5): [True: 49.5k, False: 24.7k]
  ------------------
 4028|       |        return NULL;
 4029|  74.2k|    }
 4030|  74.2k|}
m_option.c:parse_bool:
  146|   717k|{
  147|   717k|    if (bstr_equals0(param, "yes") || !param.len) {
  ------------------
  |  Branch (147:9): [True: 123k, False: 594k]
  |  Branch (147:39): [True: 0, False: 594k]
  ------------------
  148|   123k|        if (dst)
  ------------------
  |  Branch (148:13): [True: 123k, False: 0]
  ------------------
  149|   123k|            VAL(dst) = 1;
  ------------------
  |  |  142|   123k|#define VAL(x) (*(bool *)(x))
  ------------------
  150|   123k|        return 1;
  151|   123k|    }
  152|   594k|    if (bstr_equals0(param, "no")) {
  ------------------
  |  Branch (152:9): [True: 594k, False: 0]
  ------------------
  153|   594k|        if (dst)
  ------------------
  |  Branch (153:13): [True: 594k, False: 0]
  ------------------
  154|   594k|            VAL(dst) = 0;
  ------------------
  |  |  142|   594k|#define VAL(x) (*(bool *)(x))
  ------------------
  155|   594k|        return 1;
  156|   594k|    }
  157|   594k|    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|   594k|}
m_option.c:copy_opt:
  135|  17.1M|{
  136|  17.1M|    if (dst && src)
  ------------------
  |  Branch (136:9): [True: 17.1M, False: 0]
  |  Branch (136:16): [True: 17.1M, False: 0]
  ------------------
  137|  17.1M|        memcpy(dst, src, opt->type->size);
  138|  17.1M|}
m_option.c:bool_equal:
  202|   617k|{
  203|   617k|    return VAL(a) == VAL(b);
  ------------------
  |  |  142|   617k|#define VAL(x) (*(bool *)(x))
  ------------------
                  return VAL(a) == VAL(b);
  ------------------
  |  |  142|   617k|#define VAL(x) (*(bool *)(x))
  ------------------
  204|   617k|}
m_option.c:parse_int:
  352|  24.7k|{
  353|  24.7k|    long long tmp;
  354|  24.7k|    int r = parse_longlong(log, opt, INT_MIN, INT_MAX, name, param, &tmp);
  355|  24.7k|    if (r >= 0 && dst)
  ------------------
  |  Branch (355:9): [True: 24.7k, False: 0]
  |  Branch (355:19): [True: 24.7k, False: 0]
  ------------------
  356|  24.7k|        *(int *)dst = tmp;
  357|  24.7k|    return r;
  358|  24.7k|}
m_option.c:parse_longlong:
  308|  24.7k|{
  309|  24.7k|    if (param.len == 0)
  ------------------
  |  Branch (309:9): [True: 0, False: 24.7k]
  ------------------
  310|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  311|       |
  312|  24.7k|    struct bstr rest;
  313|  24.7k|    long long tmp_int = bstrtoll(param, &rest, 10);
  314|  24.7k|    if (rest.len)
  ------------------
  |  Branch (314:9): [True: 0, False: 24.7k]
  ------------------
  315|      0|        tmp_int = bstrtoll(param, &rest, 0);
  316|  24.7k|    if (rest.len) {
  ------------------
  |  Branch (316:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    long long min = OPT_INT_MIN(opt, long long, i_min);
  ------------------
  |  |   58|  24.7k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |   59|  24.7k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
  323|  24.7k|    if (tmp_int < min) {
  ------------------
  |  Branch (323:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    long long max = OPT_INT_MAX(opt, long long, i_max);
  ------------------
  |  |   60|  24.7k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |   61|  24.7k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 24.7k, False: 0]
  |  |  ------------------
  ------------------
  330|  24.7k|    if (tmp_int > max) {
  ------------------
  |  Branch (330:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if (dst)
  ------------------
  |  Branch (336:9): [True: 24.7k, False: 0]
  ------------------
  337|  24.7k|        *(long long *)dst = tmp_int;
  338|       |
  339|  24.7k|    return 1;
  340|  24.7k|}
m_option.c:print_int:
  371|  74.2k|{
  372|  74.2k|    if (opt->type->size == sizeof(int64_t))
  ------------------
  |  Branch (372:9): [True: 0, False: 74.2k]
  ------------------
  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|  74.2k|    return talloc_asprintf(NULL, "%d", *(const int *)val);
  ------------------
  |  |   52|  74.2k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  74.2k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  375|  74.2k|}
m_option.c:int_equal:
  468|   152k|{
  469|   152k|    return *(int *)a == *(int *)b;
  470|   152k|}
m_option.c:parse_byte_size:
  507|  24.7k|{
  508|  24.7k|    if (param.len == 0)
  ------------------
  |  Branch (508:9): [True: 0, False: 24.7k]
  ------------------
  509|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  510|       |
  511|  24.7k|    struct bstr r;
  512|  24.7k|    long long tmp_int = bstrtoll(param, &r, 0);
  513|  24.7k|    int64_t unit = 1;
  514|  24.7k|    if (r.len) {
  ------------------
  |  Branch (514:9): [True: 24.7k, False: 0]
  ------------------
  515|  24.7k|        if (bstrcasecmp0(r, "b") == 0) {
  ------------------
  |  Branch (515:13): [True: 0, False: 24.7k]
  ------------------
  516|      0|            unit = 1;
  517|  24.7k|        } else if (bstrcasecmp0(r, "kib") == 0 || bstrcasecmp0(r, "k") == 0) {
  ------------------
  |  Branch (517:20): [True: 0, False: 24.7k]
  |  Branch (517:51): [True: 24.7k, False: 0]
  ------------------
  518|  24.7k|            unit = 1024;
  519|  24.7k|        } 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|  24.7k|    }
  533|       |
  534|  24.7k|    if (tmp_int < 0) {
  ------------------
  |  Branch (534:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if (INT64_MAX / unit < tmp_int) {
  ------------------
  |  Branch (540:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    tmp_int *= unit;
  547|       |
  548|  24.7k|    int64_t min = OPT_INT_MIN(opt, int64_t, INT64_MIN);
  ------------------
  |  |   58|  24.7k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |   59|  24.7k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
  549|  24.7k|    if (tmp_int < min) {
  ------------------
  |  Branch (549:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    int64_t max = OPT_INT_MAX(opt, int64_t, INT64_MAX);
  ------------------
  |  |   60|  24.7k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 24.7k, False: 0]
  |  |  ------------------
  |  |   61|  24.7k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
  556|  24.7k|    if (tmp_int > max) {
  ------------------
  |  Branch (556:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if (dst)
  ------------------
  |  Branch (562:9): [True: 24.7k, False: 0]
  ------------------
  563|  24.7k|        *(int64_t *)dst = tmp_int;
  564|       |
  565|  24.7k|    return 1;
  566|  24.7k|}
m_option.c:parse_choice:
  636|   470k|{
  637|   470k|    const struct m_opt_choice_alternatives *alt = opt->priv;
  638|  1.60M|    for ( ; alt->name; alt++) {
  ------------------
  |  Branch (638:13): [True: 1.60M, False: 0]
  ------------------
  639|  1.60M|        if (!bstrcmp0(param, alt->name))
  ------------------
  |  Branch (639:13): [True: 470k, False: 1.13M]
  ------------------
  640|   470k|            break;
  641|  1.60M|    }
  642|   470k|    if (!alt->name && param.len == 0) {
  ------------------
  |  Branch (642:9): [True: 0, False: 470k]
  |  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|   470k|    if (!alt->name) {
  ------------------
  |  Branch (649:9): [True: 0, False: 470k]
  ------------------
  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|   470k|    if (dst)
  ------------------
  |  Branch (673:9): [True: 470k, False: 0]
  ------------------
  674|   470k|        *(int *)dst = alt->value;
  675|       |
  676|   470k|    return 1;
  677|   470k|}
m_option.c:print_flags:
  933|  24.7k|{
  934|  24.7k|    int value = *(int *)val;
  935|  24.7k|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
  936|  24.7k|    while (1) {
  ------------------
  |  Branch (936:12): [True: 24.7k, Folded]
  ------------------
  937|  24.7k|        const char *flag = find_next_flag(opt, &value);
  938|  24.7k|        if (!flag)
  ------------------
  |  Branch (938:13): [True: 24.7k, False: 0]
  ------------------
  939|  24.7k|            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|  24.7k|    return res;
  944|  24.7k|}
m_option.c:find_next_flag:
  849|  24.7k|{
  850|  24.7k|    const struct m_opt_choice_alternatives *best = NULL;
  851|  24.7k|    const struct m_opt_choice_alternatives *alt;
  852|   222k|    for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (852:27): [True: 198k, False: 24.7k]
  ------------------
  853|   198k|        if (alt->value && (alt->value & (*val)) == alt->value) {
  ------------------
  |  Branch (853:13): [True: 198k, False: 0]
  |  Branch (853:27): [True: 0, False: 198k]
  ------------------
  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|   198k|    }
  858|  24.7k|    if (best) {
  ------------------
  |  Branch (858:9): [True: 0, False: 24.7k]
  ------------------
  859|      0|        *val = *val & ~(unsigned)best->value;
  860|      0|        return best->name;
  861|      0|    }
  862|  24.7k|    *val = 0; // if there are still flags left, there's not much we can do
  863|       |    return NULL;
  864|  24.7k|}
m_option.c:parse_double:
 1021|  74.2k|{
 1022|  74.2k|    double tmp;
 1023|  74.2k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_double);
 1024|  74.2k|    if (r == 1 && dst)
  ------------------
  |  Branch (1024:9): [True: 74.2k, False: 0]
  |  Branch (1024:19): [True: 74.2k, False: 0]
  ------------------
 1025|  74.2k|        VAL(dst) = tmp;
  ------------------
  |  |  960|  74.2k|#define VAL(x) (*(double *)(x))
  ------------------
 1026|  74.2k|    return r;
 1027|  74.2k|}
m_option.c:parse_numeric:
  988|   272k|{
  989|   272k|    if (param.len == 0)
  ------------------
  |  Branch (989:9): [True: 0, False: 272k]
  ------------------
  990|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  991|       |
  992|   272k|    struct bstr rest;
  993|   272k|    *out = bstrtod(param, &rest);
  994|       |
  995|   272k|    if (bstr_eatstart0(&rest, ":") || bstr_eatstart0(&rest, "/"))
  ------------------
  |  Branch (995:9): [True: 0, False: 272k]
  |  Branch (995:39): [True: 0, False: 272k]
  ------------------
  996|      0|        *out /= bstrtod(rest, &rest);
  997|       |
  998|   272k|    if ((opt->flags & M_OPT_DEFAULT_NAN) && bstr_equals0(param, "default")) {
  ------------------
  |  |  483|   272k|#define M_OPT_DEFAULT_NAN       (UINT64_C(1) << 58)
  ------------------
  |  Branch (998:9): [True: 0, False: 272k]
  |  Branch (998:45): [True: 0, False: 0]
  ------------------
  999|      0|        *out = NAN;
 1000|      0|        return 1;
 1001|      0|    }
 1002|       |
 1003|   272k|    if (rest.len) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 272k]
  ------------------
 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|   272k|    if (clamp(opt, out) < 0) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 272k]
  ------------------
 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|   272k|    return 1;
 1017|   272k|}
m_option.c:clamp_double:
  963|   272k|{
  964|   272k|    double v = *val;
  965|   272k|    int r = 0;
  966|   272k|    if (opt->min < opt->max) {
  ------------------
  |  Branch (966:9): [True: 173k, False: 99.0k]
  ------------------
  967|   173k|        if (v > opt->max) {
  ------------------
  |  Branch (967:13): [True: 0, False: 173k]
  ------------------
  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|   173k|        if (v < opt->min) {
  ------------------
  |  Branch (971:13): [True: 0, False: 173k]
  ------------------
  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|   173k|    }
  976|       |    // (setting max/min to INFINITY/-INFINITY is allowed)
  977|   272k|    if (!isfinite(v) && v != opt->max && v != opt->min) {
  ------------------
  |  Branch (977:9): [True: 0, False: 272k]
  |  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|   272k|    *val = v;
  982|   272k|    return r;
  983|   272k|}
m_option.c:double_equal:
 1100|  49.5k|{
 1101|  49.5k|    double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  49.5k|#define VAL(x) (*(double *)(x))
  ------------------
                  double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  49.5k|#define VAL(x) (*(double *)(x))
  ------------------
 1102|  49.5k|    if (isnan(fa) || isnan(fb))
  ------------------
  |  Branch (1102:9): [True: 0, False: 49.5k]
  |  Branch (1102:22): [True: 0, False: 49.5k]
  ------------------
 1103|      0|        return isnan(fa) == isnan(fb);
 1104|  49.5k|    return fa == fb;
 1105|  49.5k|}
m_option.c:parse_float:
 1172|   198k|{
 1173|   198k|    double tmp;
 1174|   198k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_float);
 1175|   198k|    if (r == 1 && dst)
  ------------------
  |  Branch (1175:9): [True: 198k, False: 0]
  |  Branch (1175:19): [True: 198k, False: 0]
  ------------------
 1176|   198k|        VAL(dst) = tmp;
  ------------------
  |  | 1150|   198k|#define VAL(x) (*(float *)(x))
  ------------------
 1177|   198k|    return r;
 1178|   198k|}
m_option.c:clamp_float:
 1153|   198k|{
 1154|   198k|    double v = *val;
 1155|   198k|    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|   198k|    if (isfinite(v) && v > FLT_MAX) {
  ------------------
  |  Branch (1158:9): [True: 198k, False: 0]
  |  Branch (1158:24): [True: 0, False: 198k]
  ------------------
 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|   198k|    if (isfinite(v) && v < -FLT_MAX) {
  ------------------
  |  Branch (1162:9): [True: 198k, False: 0]
  |  Branch (1162:24): [True: 0, False: 198k]
  ------------------
 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|   198k|    *val = v;
 1167|   198k|    return r;
 1168|   198k|}
m_option.c:parse_str:
 1254|  74.2k|{
 1255|  74.2k|    if (dst) {
  ------------------
  |  Branch (1255:9): [True: 74.2k, False: 0]
  ------------------
 1256|  74.2k|        talloc_free(VAL(dst));
  ------------------
  |  |   47|  74.2k|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(dst));
  ------------------
  |  | 1250|  74.2k|#define VAL(x) (*(char **)(x))
  ------------------
 1257|  74.2k|        VAL(dst) = bstrdup0(NULL, param);
  ------------------
  |  | 1250|  74.2k|#define VAL(x) (*(char **)(x))
  ------------------
 1258|  74.2k|    }
 1259|       |
 1260|  74.2k|    return 0;
 1261|  74.2k|}
m_option.c:print_str:
 1264|   473k|{
 1265|   473k|    return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  |   50|   473k|#define talloc_strdup                   ta_xstrdup
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|   473k|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 473k, False: 0]
  |  |  ------------------
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|   473k|#define VAL(x) (*(char **)(x))
  ------------------
 1266|   473k|}
m_option.c:copy_str:
 1269|  11.4M|{
 1270|  11.4M|    if (dst && src)
  ------------------
  |  Branch (1270:9): [True: 11.4M, False: 0]
  |  Branch (1270:16): [True: 11.4M, False: 0]
  ------------------
 1271|  11.4M|        talloc_replace(NULL, VAL(dst), VAL(src));
  ------------------
  |  |   54|  11.4M|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  11.4M|    do {                                                \
  |  |  |  |  107|  11.4M|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 11.4M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|  11.4M|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  11.4M|        } 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|  11.4M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 11.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1272|  11.4M|}
m_option.c:free_str:
 1299|  11.8M|{
 1300|  11.8M|    if (src && VAL(src)) {
  ------------------
  |  | 1250|  11.8M|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 3.50M, False: 8.38M]
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 11.8M, False: 0]
  ------------------
 1301|  3.50M|        talloc_free(VAL(src));
  ------------------
  |  |   47|  3.50M|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(src));
  ------------------
  |  | 1250|  3.50M|#define VAL(x) (*(char **)(x))
  ------------------
 1302|  3.50M|        VAL(src) = NULL;
  ------------------
  |  | 1250|  3.50M|#define VAL(x) (*(char **)(x))
  ------------------
 1303|  3.50M|    }
 1304|  11.8M|}
m_option.c:str_equal:
 1294|  49.5k|{
 1295|  49.5k|    return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  49.5k|#define VAL(x) (*(char **)(x))
  ------------------
                  return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  49.5k|#define VAL(x) (*(char **)(x))
  ------------------
 1296|  49.5k|}
m_option.c:parse_str_list:
 1622|  74.2k|{
 1623|  74.2k|    return parse_str_list_impl(log, opt, name, param, dst, OP_NONE);
  ------------------
  |  | 1323|  74.2k|#define OP_NONE 0
  ------------------
 1624|  74.2k|}
m_option.c:parse_str_list_impl:
 1467|  74.2k|{
 1468|  74.2k|    char **res;
 1469|  74.2k|    int op = default_op;
 1470|       |
 1471|  74.2k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1471:9): [True: 0, False: 74.2k]
  ------------------
 1472|      0|        op = OP_ADD;
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
 1473|  74.2k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1473:16): [True: 0, False: 74.2k]
  ------------------
 1474|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 1475|  74.2k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (1475:16): [True: 0, False: 74.2k]
  ------------------
 1476|      0|        op = OP_PRE;
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
 1477|  74.2k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1477:16): [True: 0, False: 74.2k]
  ------------------
 1478|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 1479|  74.2k|    } else if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1479:16): [True: 0, False: 74.2k]
  ------------------
 1480|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1481|  74.2k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (1481:16): [True: 0, False: 74.2k]
  ------------------
 1482|      0|        op = OP_NONE;
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
 1483|  74.2k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (1483:16): [True: 0, False: 74.2k]
  ------------------
 1484|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 1485|  74.2k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1485:16): [True: 0, False: 74.2k]
  ------------------
 1486|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1487|      0|    }
 1488|       |
 1489|  74.2k|    if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1328|   148k|#define OP_TOGGLE 5
  ------------------
                  if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1330|  74.2k|#define OP_REMOVE 7
  ------------------
  |  Branch (1489:9): [True: 0, False: 74.2k]
  |  Branch (1489:28): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|  74.2k|#define OP_CLR 3
  ------------------
  |  Branch (1504:9): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    if (param.len == 0 && op != OP_NONE)
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
  |  Branch (1511:9): [True: 0, False: 74.2k]
  |  Branch (1511:27): [True: 0, False: 0]
  ------------------
 1512|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 1513|       |
 1514|  74.2k|    if (!dst)
  ------------------
  |  Branch (1514:9): [True: 0, False: 74.2k]
  ------------------
 1515|      0|        return 1;
 1516|       |
 1517|  74.2k|    int n = 0;
 1518|  74.2k|    res = separate_input_param(opt, param, &n, op);
 1519|  74.2k|    if (!res)
  ------------------
  |  Branch (1519:9): [True: 0, False: 74.2k]
  ------------------
 1520|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1521|       |
 1522|  74.2k|    switch (op) {
  ------------------
  |  Branch (1522:13): [True: 0, False: 74.2k]
  ------------------
 1523|      0|    case OP_ADD:
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
  |  Branch (1523:5): [True: 0, False: 74.2k]
  ------------------
 1524|      0|    case OP_APPEND:
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
  |  Branch (1524:5): [True: 0, False: 74.2k]
  ------------------
 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: 74.2k]
  ------------------
 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: 74.2k]
  ------------------
 1529|      0|        return str_list_remove(res, n, dst);
 1530|  74.2k|    }
 1531|       |
 1532|  74.2k|    if (VAL(dst))
  ------------------
  |  | 1321|  74.2k|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 0, False: 74.2k]
  |  |  ------------------
  ------------------
 1533|      0|        free_str_list(dst);
 1534|  74.2k|    VAL(dst) = res;
  ------------------
  |  | 1321|  74.2k|#define VAL(x) (*(char ***)(x))
  ------------------
 1535|       |
 1536|  74.2k|    if (!res[0])
  ------------------
  |  Branch (1536:9): [True: 0, False: 74.2k]
  ------------------
 1537|      0|        free_str_list(dst);
 1538|       |
 1539|  74.2k|    return 1;
 1540|  74.2k|}
m_option.c:separate_input_param:
 1405|  74.2k|{
 1406|  74.2k|    char separator = opt->priv ? *(char *)opt->priv : OPTION_LIST_SEPARATOR;
  ------------------
  |  |  644|   148k|#define OPTION_LIST_SEPARATOR ','
  ------------------
  |  Branch (1406:22): [True: 0, False: 74.2k]
  ------------------
 1407|  74.2k|    if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1329|   148k|#define OP_APPEND 6
  ------------------
                  if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1330|  74.2k|#define OP_REMOVE 7
  ------------------
  |  Branch (1407:9): [True: 0, False: 74.2k]
  |  Branch (1407:28): [True: 0, False: 74.2k]
  ------------------
 1408|      0|        separator = 0; // specially handled
 1409|  74.2k|    struct bstr str = param;
 1410|  74.2k|    int n = *len;
 1411|   148k|    while (str.len) {
  ------------------
  |  Branch (1411:12): [True: 74.2k, False: 74.2k]
  ------------------
 1412|  74.2k|        get_nextsep(&str, separator, 0);
 1413|  74.2k|        str = bstr_cut(str, 1);
 1414|  74.2k|        n++;
 1415|  74.2k|    }
 1416|  74.2k|    if (n == 0 && op != OP_NONE)
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
  |  Branch (1416:9): [True: 0, False: 74.2k]
  |  Branch (1416:19): [True: 0, False: 0]
  ------------------
 1417|      0|        return NULL;
 1418|       |
 1419|  74.2k|    char **list = talloc_array(NULL, char *, n + 2);
  ------------------
  |  |   29|  74.2k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  74.2k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  74.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|  74.2k|    str = bstrdup(NULL, param);
 1421|  74.2k|    char *ptr = str.start;
 1422|  74.2k|    n = 0;
 1423|       |
 1424|  74.2k|    while (1) {
  ------------------
  |  Branch (1424:12): [True: 74.2k, Folded]
  ------------------
 1425|  74.2k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1426|  74.2k|        if (n >= 100)
  ------------------
  |  Branch (1426:13): [True: 0, False: 74.2k]
  ------------------
 1427|      0|            break;
 1428|  74.2k|#endif
 1429|  74.2k|        struct bstr el = get_nextsep(&str, separator, 1);
 1430|  74.2k|        list[n] = bstrdup0(NULL, el);
 1431|  74.2k|        n++;
 1432|  74.2k|        if (!str.len)
  ------------------
  |  Branch (1432:13): [True: 74.2k, False: 0]
  ------------------
 1433|  74.2k|            break;
 1434|      0|        str = bstr_cut(str, 1);
 1435|      0|    }
 1436|  74.2k|    list[n] = NULL;
 1437|  74.2k|    *len = n;
 1438|  74.2k|    talloc_free(ptr);
  ------------------
  |  |   47|  74.2k|#define talloc_free                     ta_free
  ------------------
 1439|  74.2k|    return list;
 1440|  74.2k|}
m_option.c:get_nextsep:
 1382|   148k|{
 1383|   148k|    struct bstr str = *ptr;
 1384|   148k|    struct bstr orig = str;
 1385|   148k|    for (;;) {
 1386|   148k|        int idx = sep ? bstrchr(str, sep) : -1;
  ------------------
  |  Branch (1386:19): [True: 148k, False: 0]
  ------------------
 1387|   148k|        if (idx > 0 && str.start[idx - 1] == '\\') {
  ------------------
  |  Branch (1387:13): [True: 0, False: 148k]
  |  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|   148k|        } else {
 1395|   148k|            str = bstr_cut(str, idx < 0 ? str.len : idx);
  ------------------
  |  Branch (1395:33): [True: 148k, False: 0]
  ------------------
 1396|   148k|            break;
 1397|   148k|        }
 1398|   148k|    }
 1399|   148k|    *ptr = str;
 1400|   148k|    return bstr_splice(orig, 0, str.start - orig.start);
 1401|   148k|}
m_option.c:copy_str_list:
 1543|  7.76M|{
 1544|  7.76M|    int n;
 1545|  7.76M|    char **d, **s;
 1546|       |
 1547|  7.76M|    if (!(dst && src))
  ------------------
  |  Branch (1547:11): [True: 7.76M, False: 0]
  |  Branch (1547:18): [True: 7.76M, False: 0]
  ------------------
 1548|      0|        return;
 1549|  7.76M|    s = VAL(src);
  ------------------
  |  | 1321|  7.76M|#define VAL(x) (*(char ***)(x))
  ------------------
 1550|       |
 1551|  7.76M|    if (VAL(dst))
  ------------------
  |  | 1321|  7.76M|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 0, False: 7.76M]
  |  |  ------------------
  ------------------
 1552|      0|        free_str_list(dst);
 1553|       |
 1554|  7.76M|    if (!s) {
  ------------------
  |  Branch (1554:9): [True: 5.35M, False: 2.40M]
  ------------------
 1555|  5.35M|        VAL(dst) = NULL;
  ------------------
  |  | 1321|  5.35M|#define VAL(x) (*(char ***)(x))
  ------------------
 1556|  5.35M|        return;
 1557|  5.35M|    }
 1558|       |
 1559|  29.5M|    for (n = 0; s[n] != NULL; n++)
  ------------------
  |  Branch (1559:17): [True: 27.1M, False: 2.40M]
  ------------------
 1560|  27.1M|        /* NOTHING */;
 1561|  2.40M|    d = talloc_array(NULL, char *, n + 1);
  ------------------
  |  |   29|  2.40M|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  2.40M|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.40M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1562|  32.0M|    for (; n >= 0; n--)
  ------------------
  |  Branch (1562:12): [True: 29.5M, False: 2.40M]
  ------------------
 1563|  29.5M|        d[n] = talloc_strdup(NULL, s[n]);
  ------------------
  |  |   50|  29.5M|#define talloc_strdup                   ta_xstrdup
  ------------------
 1564|       |
 1565|  2.40M|    VAL(dst) = d;
  ------------------
  |  | 1321|  2.40M|#define VAL(x) (*(char ***)(x))
  ------------------
 1566|  2.40M|}
m_option.c:free_str_list:
 1333|  7.96M|{
 1334|  7.96M|    char **d;
 1335|  7.96M|    int i;
 1336|       |
 1337|  7.96M|    if (!dst || !VAL(dst))
  ------------------
  |  | 1321|  7.96M|#define VAL(x) (*(char ***)(x))
  ------------------
  |  Branch (1337:9): [True: 0, False: 7.96M]
  |  Branch (1337:17): [True: 5.28M, False: 2.68M]
  ------------------
 1338|  5.28M|        return;
 1339|  2.68M|    d = VAL(dst);
  ------------------
  |  | 1321|  2.68M|#define VAL(x) (*(char ***)(x))
  ------------------
 1340|       |
 1341|  30.3M|    for (i = 0; d[i] != NULL; i++)
  ------------------
  |  Branch (1341:17): [True: 27.6M, False: 2.68M]
  ------------------
 1342|  27.6M|        talloc_free(d[i]);
  ------------------
  |  |   47|  27.6M|#define talloc_free                     ta_free
  ------------------
 1343|  2.68M|    talloc_free(d);
  ------------------
  |  |   47|  2.68M|#define talloc_free                     ta_free
  ------------------
 1344|  2.68M|    VAL(dst) = NULL;
  ------------------
  |  | 1321|  2.68M|#define VAL(x) (*(char ***)(x))
  ------------------
 1345|  2.68M|}
m_option.c:str_list_equal:
 1627|  49.5k|{
 1628|  49.5k|    char **la = VAL(a);
  ------------------
  |  | 1321|  49.5k|#define VAL(x) (*(char ***)(x))
  ------------------
 1629|  49.5k|    char **lb = VAL(b);
  ------------------
  |  | 1321|  49.5k|#define VAL(x) (*(char ***)(x))
  ------------------
 1630|       |
 1631|  49.5k|    bool a_empty = !la || !la[0];
  ------------------
  |  Branch (1631:20): [True: 49.5k, False: 0]
  |  Branch (1631:27): [True: 0, False: 0]
  ------------------
 1632|  49.5k|    bool b_empty = !lb || !lb[0];
  ------------------
  |  Branch (1632:20): [True: 0, False: 49.5k]
  |  Branch (1632:27): [True: 0, False: 49.5k]
  ------------------
 1633|  49.5k|    if (a_empty || b_empty)
  ------------------
  |  Branch (1633:9): [True: 49.5k, False: 0]
  |  Branch (1633:20): [True: 0, False: 0]
  ------------------
 1634|  49.5k|        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|   198k|{
 1800|   198k|    char **lst = NULL;
 1801|   198k|    int num = 0;
 1802|   198k|    int r = 0;
 1803|   198k|    bool append = false;
 1804|   198k|    bool full_value = false;
 1805|       |
 1806|   198k|    if ((opt->flags & M_OPT_HAVE_HELP) && bstr_equals0(param, "help"))
  ------------------
  |  |  480|   198k|#define M_OPT_HAVE_HELP         (UINT64_C(1) << 59)
  ------------------
  |  Branch (1806:9): [True: 0, False: 198k]
  |  Branch (1806:43): [True: 0, False: 0]
  ------------------
 1807|      0|        param = bstr0("help=");
 1808|       |
 1809|   198k|    int op = 0;
 1810|   198k|    if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1810:9): [True: 0, False: 198k]
  ------------------
 1811|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1812|   198k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1812:16): [True: 0, False: 198k]
  ------------------
 1813|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1814|      0|    }
 1815|       |
 1816|   198k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1816:9): [True: 0, False: 198k]
  ------------------
 1817|      0|        append = true;
 1818|   198k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1818:16): [True: 173k, False: 24.7k]
  ------------------
 1819|   173k|        append = full_value = true;
 1820|   173k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1820:16): [True: 0, False: 24.7k]
  ------------------
 1821|      0|        if (dst)
  ------------------
  |  Branch (1821:13): [True: 0, False: 0]
  ------------------
 1822|      0|            free_str_list(dst);
 1823|      0|        return 0;
 1824|  24.7k|    } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1327|  49.5k|#define OP_DEL 4
  ------------------
                  } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1330|  24.7k|#define OP_REMOVE 7
  ------------------
  |  Branch (1824:16): [True: 0, False: 24.7k]
  |  Branch (1824:32): [True: 0, False: 24.7k]
  ------------------
 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|   198k|    if (append && dst) {
  ------------------
  |  Branch (1842:9): [True: 173k, False: 24.7k]
  |  Branch (1842:19): [True: 173k, False: 0]
  ------------------
 1843|   173k|        lst = VAL(dst);
  ------------------
  |  | 1321|   173k|#define VAL(x) (*(char ***)(x))
  ------------------
 1844|   173k|        for (int n = 0; lst && lst[n]; n++)
  ------------------
  |  Branch (1844:25): [True: 0, False: 173k]
  |  Branch (1844:32): [True: 0, False: 0]
  ------------------
 1845|      0|            num++;
 1846|   173k|    }
 1847|       |
 1848|   198k|    while (param.len) {
  ------------------
  |  Branch (1848:12): [True: 198k, False: 0]
  ------------------
 1849|   198k|        bstr key, val;
 1850|   198k|        r = read_subparam(log, name, "=", &param, &key);
 1851|   198k|        if (r < 0)
  ------------------
  |  Branch (1851:13): [True: 0, False: 198k]
  ------------------
 1852|      0|            break;
 1853|   198k|        if (!bstr_eatstart0(&param, "=")) {
  ------------------
  |  Branch (1853:13): [True: 0, False: 198k]
  ------------------
 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|   198k|        if (full_value) {
  ------------------
  |  Branch (1858:13): [True: 173k, False: 24.7k]
  ------------------
 1859|   173k|            val = param;
 1860|   173k|            param.len = 0;
 1861|   173k|        } else {
 1862|  24.7k|            r = read_subparam(log, name, ",", &param, &val);
 1863|  24.7k|            if (r < 0)
  ------------------
  |  Branch (1863:17): [True: 0, False: 24.7k]
  ------------------
 1864|      0|                break;
 1865|  24.7k|        }
 1866|   198k|        if (dst) {
  ------------------
  |  Branch (1866:13): [True: 198k, False: 0]
  ------------------
 1867|   198k|            int index = keyvalue_list_find_key(lst, key);
 1868|   198k|            if (index >= 0) {
  ------------------
  |  Branch (1868:17): [True: 0, False: 198k]
  ------------------
 1869|      0|                keyvalue_list_del_key(lst, index);
 1870|      0|                num -= 2;
 1871|      0|            }
 1872|   198k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, key));
  ------------------
  |  |  105|   198k|    do {                                            \
  |  |  106|   198k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   198k|    do {                                            \
  |  |  |  |   97|   198k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   198k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   198k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   198k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 198k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|   198k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   198k|    do {                                                        \
  |  |  |  |  |  |   89|   198k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   198k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   198k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   198k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   198k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   198k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   198k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 198k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   198k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 198k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   198k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   198k|        (idxvar)++;                                 \
  |  |  109|   198k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 198k]
  |  |  ------------------
  ------------------
 1873|   198k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, val));
  ------------------
  |  |  105|   198k|    do {                                            \
  |  |  106|   198k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   198k|    do {                                            \
  |  |  |  |   97|   198k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   198k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   198k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   198k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 198k]
  |  |  |  |  ------------------
  |  |  |  |   99|   198k|            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|   198k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 198k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   198k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   198k|        (idxvar)++;                                 \
  |  |  109|   198k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 198k]
  |  |  ------------------
  ------------------
 1874|   198k|            MP_TARRAY_APPEND(NULL, lst, num, NULL);
  ------------------
  |  |  105|   198k|    do {                                            \
  |  |  106|   198k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   198k|    do {                                            \
  |  |  |  |   97|   198k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   198k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   198k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   198k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 198k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|   198k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   198k|    do {                                                        \
  |  |  |  |  |  |   89|   198k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   198k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   198k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   198k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   198k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   198k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   198k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 198k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   198k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 198k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   198k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   198k|        (idxvar)++;                                 \
  |  |  109|   198k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 198k]
  |  |  ------------------
  ------------------
 1875|   198k|            num -= 1;
 1876|   198k|        }
 1877|       |
 1878|   198k|        if (!bstr_eatstart0(&param, ",") && !bstr_eatstart0(&param, ":"))
  ------------------
  |  Branch (1878:13): [True: 198k, False: 0]
  |  Branch (1878:45): [True: 198k, False: 0]
  ------------------
 1879|   198k|            break;
 1880|   198k|    }
 1881|       |
 1882|   198k|    if (param.len) {
  ------------------
  |  Branch (1882:9): [True: 0, False: 198k]
  ------------------
 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|   198k|    if (dst) {
  ------------------
  |  Branch (1888:9): [True: 198k, False: 0]
  ------------------
 1889|   198k|        if (!append)
  ------------------
  |  Branch (1889:13): [True: 24.7k, False: 173k]
  ------------------
 1890|  24.7k|            free_str_list(dst);
 1891|   198k|        VAL(dst) = lst;
  ------------------
  |  | 1321|   198k|#define VAL(x) (*(char ***)(x))
  ------------------
 1892|   198k|        if (r < 0)
  ------------------
  |  Branch (1892:13): [True: 0, False: 198k]
  ------------------
 1893|      0|            free_str_list(dst);
 1894|   198k|    } else {
 1895|      0|        free_str_list(&lst);
 1896|      0|    }
 1897|   198k|    return r;
 1898|   198k|}
m_option.c:keyvalue_list_find_key:
 1776|   198k|{
 1777|   198k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1777:21): [True: 0, False: 198k]
  |  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|   198k|    return -1;
 1782|   198k|}
m_option.c:read_subparam:
 2081|   222k|{
 2082|   222k|    bstr p = *str;
 2083|   222k|    bstr subparam = {0};
 2084|       |
 2085|   222k|    if (bstr_eatstart0(&p, "\"")) {
  ------------------
  |  Branch (2085:9): [True: 0, False: 222k]
  ------------------
 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|   222k|    } else if (bstr_eatstart0(&p, "[")) {
  ------------------
  |  Branch (2095:16): [True: 0, False: 222k]
  ------------------
 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|   222k|    } else if (bstr_eatstart0(&p, "%")) {
  ------------------
  |  Branch (2112:16): [True: 0, False: 222k]
  ------------------
 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|   222k|    } else {
 2122|       |        // Skip until the next character that could possibly be a meta
 2123|       |        // character in option parsing.
 2124|   222k|        int optlen = bstrcspn(p, termset);
 2125|   222k|        subparam = bstr_splice(p, 0, optlen);
 2126|   222k|        p = bstr_cut(p, optlen);
 2127|   222k|    }
 2128|       |
 2129|   222k|    *str = p;
 2130|   222k|    *out_subparam = subparam;
 2131|   222k|    return 0;
 2132|   222k|}
m_option.c:print_keyvalue_list:
 1901|  24.7k|{
 1902|  24.7k|    char **lst = VAL(src);
  ------------------
  |  | 1321|  24.7k|#define VAL(x) (*(char ***)(x))
  ------------------
 1903|  24.7k|    char *ret = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1904|  24.7k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1904:21): [True: 0, False: 24.7k]
  |  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|  24.7k|    return ret;
 1910|  24.7k|}
m_option.c:parse_msglevels:
 1993|  24.7k|{
 1994|  24.7k|    if (bstr_equals0(param, "help")) {
  ------------------
  |  Branch (1994:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    char **dst_copy = NULL;
 2006|  24.7k|    int r = m_option_type_keyvalue_list.parse(log, opt, name, param, &dst_copy);
 2007|  24.7k|    if (r >= 0)
  ------------------
  |  Branch (2007:9): [True: 24.7k, False: 0]
  ------------------
 2008|  24.7k|        r = check_msg_levels(log, dst_copy);
 2009|       |
 2010|  24.7k|    if (r >= 0)
  ------------------
  |  Branch (2010:9): [True: 24.7k, False: 0]
  ------------------
 2011|  24.7k|        m_option_type_keyvalue_list.copy(opt, dst, &dst_copy);
 2012|  24.7k|    m_option_type_keyvalue_list.free(&dst_copy);
 2013|  24.7k|    return r;
 2014|  24.7k|}
m_option.c:check_msg_levels:
 1980|  24.7k|{
 1981|  49.5k|    for (int n = 0; list && list[n * 2 + 0]; n++) {
  ------------------
  |  Branch (1981:21): [True: 49.5k, False: 0]
  |  Branch (1981:29): [True: 24.7k, False: 24.7k]
  ------------------
 1982|  24.7k|        char *level = list[n * 2 + 1];
 1983|  24.7k|        if (mp_msg_find_level(level) < 0 && strcmp(level, "no") != 0) {
  ------------------
  |  Branch (1983:13): [True: 0, False: 24.7k]
  |  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|  24.7k|    }
 1988|  24.7k|    return 1;
 1989|  24.7k|}
m_option.c:copy_channels:
 2801|   440k|{
 2802|   440k|    if (!(dst && src))
  ------------------
  |  Branch (2802:11): [True: 440k, False: 0]
  |  Branch (2802:18): [True: 440k, False: 0]
  ------------------
 2803|      0|        return;
 2804|       |
 2805|   440k|    struct m_channels *ch = dst;
 2806|   440k|    free_channels(dst);
 2807|   440k|    *ch = *(struct m_channels *)src;
 2808|   440k|    ch->chmaps =
 2809|   440k|        talloc_memdup(NULL, ch->chmaps, sizeof(ch->chmaps[0]) * ch->num_chmaps);
  ------------------
  |  |   49|   440k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   440k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   440k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   440k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   440k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2810|   440k|}
m_option.c:free_channels:
 2791|   881k|{
 2792|   881k|    if (!src)
  ------------------
  |  Branch (2792:9): [True: 0, False: 881k]
  ------------------
 2793|      0|        return;
 2794|       |
 2795|   881k|    struct m_channels *ch = src;
 2796|   881k|    talloc_free(ch->chmaps);
  ------------------
  |  |   47|   881k|#define talloc_free                     ta_free
  ------------------
 2797|   881k|    *ch = (struct m_channels){0};
 2798|   881k|}
m_option.c:parse_obj_settings_list:
 3510|  99.0k|{
 3511|  99.0k|    m_obj_settings_t *res = NULL;
 3512|  99.0k|    int op = OP_NONE;
  ------------------
  |  | 1323|  99.0k|#define OP_NONE 0
  ------------------
 3513|  99.0k|    bool *mark_del = NULL;
 3514|  99.0k|    int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0);
  ------------------
  |  | 3041|  99.0k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3514:49): [True: 99.0k, False: 0]
  ------------------
 3515|  99.0k|    const struct m_obj_list *ol = opt->priv;
 3516|  99.0k|    int ret = 1;
 3517|       |
 3518|  99.0k|    mp_assert(opt->priv);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (3518:5): [True: 99.0k, False: 0]
  ------------------
 3519|       |
 3520|  99.0k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (3520:9): [True: 0, False: 99.0k]
  ------------------
 3521|      0|        op = OP_ADD;
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
 3522|  99.0k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (3522:16): [True: 0, False: 99.0k]
  ------------------
 3523|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 3524|  99.0k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (3524:16): [True: 0, False: 99.0k]
  ------------------
 3525|      0|        op = OP_NONE;
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
 3526|  99.0k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (3526:16): [True: 0, False: 99.0k]
  ------------------
 3527|      0|        op = OP_PRE;
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
 3528|  99.0k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (3528:16): [True: 0, False: 99.0k]
  ------------------
 3529|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 3530|  99.0k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (3530:16): [True: 0, False: 99.0k]
  ------------------
 3531|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 3532|  99.0k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (3532:16): [True: 0, False: 99.0k]
  ------------------
 3533|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 3534|  99.0k|    } else if (bstr_endswith0(name, "-help")) {
  ------------------
  |  Branch (3534:16): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (3558:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|  99.0k|#define OP_CLR 3
  ------------------
  |  Branch (3580:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|  99.0k|#define OP_REMOVE 7
  ------------------
  |  Branch (3591:16): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (op != OP_NONE && param.len == 0) {
  ------------------
  |  | 1323|   198k|#define OP_NONE 0
  ------------------
  |  Branch (3595:9): [True: 0, False: 99.0k]
  |  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|   198k|    while (param.len > 0) {
  ------------------
  |  Branch (3600:12): [True: 99.0k, False: 99.0k]
  ------------------
 3601|  99.0k|        int r = 0;
 3602|  99.0k|        if (op == OP_REMOVE)
  ------------------
  |  | 1330|  99.0k|#define OP_REMOVE 7
  ------------------
  |  Branch (3602:13): [True: 0, False: 99.0k]
  ------------------
 3603|      0|            r = parse_obj_settings_del(log, name, &param, dst, mark_del);
 3604|  99.0k|        if (r == 0) {
  ------------------
  |  Branch (3604:13): [True: 99.0k, False: 0]
  ------------------
 3605|  99.0k|            r = parse_obj_settings(log, name, op, &param, ol, dst ? &res : NULL);
  ------------------
  |  Branch (3605:63): [True: 99.0k, False: 0]
  ------------------
 3606|  99.0k|        }
 3607|  99.0k|        if (r < 0) {
  ------------------
  |  Branch (3607:13): [True: 0, False: 99.0k]
  ------------------
 3608|      0|            free_obj_settings_list(&res);
 3609|      0|            ret = r;
 3610|      0|            goto done;
 3611|      0|        }
 3612|  99.0k|        if (param.len > 0) {
  ------------------
  |  Branch (3612:13): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    }
 3635|       |
 3636|  99.0k|    if (op != OP_NONE && res && res[0].name && res[1].name) {
  ------------------
  |  | 1323|   198k|#define OP_NONE 0
  ------------------
  |  Branch (3636:9): [True: 0, False: 99.0k]
  |  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|  99.0k|    if (dst) {
  ------------------
  |  Branch (3646:9): [True: 99.0k, False: 0]
  ------------------
 3647|  99.0k|        m_obj_settings_t *list = VAL(dst);
  ------------------
  |  | 3041|  99.0k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3648|  99.0k|        if (op == OP_PRE) {
  ------------------
  |  | 1325|  99.0k|#define OP_PRE 2
  ------------------
  |  Branch (3648:13): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|        } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1324|   198k|#define OP_ADD 1
  ------------------
                      } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1329|  99.0k|#define OP_APPEND 6
  ------------------
  |  Branch (3664:20): [True: 0, False: 99.0k]
  |  Branch (3664:36): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|        } else if (op == OP_TOGGLE) {
  ------------------
  |  | 1328|  99.0k|#define OP_TOGGLE 5
  ------------------
  |  Branch (3678:20): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|        } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|  99.0k|#define OP_REMOVE 7
  ------------------
  |  Branch (3703:20): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|        } else {
 3715|  99.0k|            mp_assert(op == OP_NONE);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (3715:13): [True: 99.0k, False: 0]
  ------------------
 3716|  99.0k|            free_obj_settings_list(&list);
 3717|  99.0k|            list = res;
 3718|  99.0k|        }
 3719|  99.0k|        VAL(dst) = list;
  ------------------
  |  | 3041|  99.0k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3720|  99.0k|    }
 3721|       |
 3722|  99.0k|done:
 3723|  99.0k|    talloc_free(mark_del);
  ------------------
  |  |   47|  99.0k|#define talloc_free                     ta_free
  ------------------
 3724|  99.0k|    return ret;
 3725|  99.0k|}
m_option.c:obj_settings_list_num_items:
 3082|   198k|{
 3083|   198k|    int num = 0;
 3084|   198k|    while (obj_list && obj_list[num].name)
  ------------------
  |  Branch (3084:12): [True: 0, False: 198k]
  |  Branch (3084:24): [True: 0, False: 0]
  ------------------
 3085|      0|        num++;
 3086|   198k|    return num;
 3087|   198k|}
m_option.c:parse_obj_settings:
 3389|  99.0k|{
 3390|  99.0k|    int r;
 3391|  99.0k|    char **plist = NULL;
 3392|  99.0k|    struct m_obj_desc desc;
 3393|  99.0k|    bstr str = {0};
 3394|  99.0k|    bstr label = {0};
 3395|  99.0k|    bool nopos = list->disallow_positional_parameters;
 3396|  99.0k|    bool enabled = true;
 3397|       |
 3398|  99.0k|    if (bstr_eatstart0(pstr, "@")) {
  ------------------
  |  Branch (3398:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (list->allow_disable_entries && bstr_eatstart0(pstr, "!"))
  ------------------
  |  Branch (3420:9): [True: 0, False: 99.0k]
  |  Branch (3420:40): [True: 0, False: 0]
  ------------------
 3421|      0|        enabled = false;
 3422|       |
 3423|  99.0k|    bool has_param = false;
 3424|  99.0k|    int idx = bstrspn(*pstr, NAMECH);
  ------------------
  |  | 3383|  99.0k|#define NAMECH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  ------------------
 3425|  99.0k|    str = bstr_splice(*pstr, 0, idx);
 3426|  99.0k|    if (!str.len) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    *pstr = bstr_cut(*pstr, idx);
 3431|       |    // video filters use "=", VOs use ":"
 3432|  99.0k|    if (bstr_eatstart0(pstr, "=") || bstr_eatstart0(pstr, ":"))
  ------------------
  |  Branch (3432:9): [True: 0, False: 99.0k]
  |  Branch (3432:38): [True: 0, False: 99.0k]
  ------------------
 3433|      0|        has_param = true;
 3434|       |
 3435|  99.0k|    bool skip = false;
 3436|  99.0k|    if (m_obj_list_find(&desc, list, str)) {
  ------------------
  |  Branch (3436:9): [True: 99.0k, False: 0]
  ------------------
 3437|  99.0k|        if (desc.replaced_name)
  ------------------
  |  Branch (3437:13): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|                   desc.replaced_name, desc.name);
 3440|  99.0k|    } 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|  99.0k|    if (has_param) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (!_ret)
  ------------------
  |  Branch (3463:9): [True: 0, False: 99.0k]
  ------------------
 3464|      0|        return 1;
 3465|       |
 3466|  99.0k|done: ;
 3467|  99.0k|    m_obj_settings_t item = {
 3468|  99.0k|        .name = bstrto0(NULL, str),
 3469|  99.0k|        .label = bstrdup0(NULL, label),
 3470|  99.0k|        .enabled = enabled,
 3471|  99.0k|        .attribs = plist,
 3472|  99.0k|    };
 3473|  99.0k|    if (!obj_settings_list_insert_at(log, _ret, -1, &item))
  ------------------
  |  Branch (3473:9): [True: 0, False: 99.0k]
  ------------------
 3474|      0|        obj_setting_free(&item);
 3475|  99.0k|    return 1;
 3476|  99.0k|}
m_option.c:obj_settings_list_insert_at:
 3117|  99.0k|{
 3118|  99.0k|    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|  99.0k|    if (num >= OBJ_SETTINGS_LIST_MAX) {
  ------------------
  |  | 3106|  99.0k|#define OBJ_SETTINGS_LIST_MAX 8
  ------------------
  |  Branch (3121:9): [True: 0, False: 99.0k]
  ------------------
 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|  99.0k|    if (idx < 0)
  ------------------
  |  Branch (3127:9): [True: 99.0k, False: 0]
  ------------------
 3128|  99.0k|        idx = num + idx + 1;
 3129|  99.0k|    mp_assert(idx >= 0 && idx <= num);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (3129:5): [True: 99.0k, False: 0]
  |  Branch (3129:5): [True: 99.0k, False: 0]
  ------------------
 3130|  99.0k|    *p_obj_list = talloc_realloc(NULL, *p_obj_list, struct m_obj_settings,
  ------------------
  |  |   33|  99.0k|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  99.0k|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  99.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  99.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  99.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  99.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3131|  99.0k|                                 num + 2);
 3132|  99.0k|    memmove(*p_obj_list + idx + 1, *p_obj_list + idx,
 3133|  99.0k|            (num - idx) * sizeof(m_obj_settings_t));
 3134|  99.0k|    (*p_obj_list)[idx] = *item;
 3135|  99.0k|    (*p_obj_list)[num + 1] = (m_obj_settings_t){0};
 3136|       |    return true;
 3137|  99.0k|}
m_option.c:obj_setting_free:
 3065|  1.25M|{
 3066|  1.25M|    talloc_free(item->name);
  ------------------
  |  |   47|  1.25M|#define talloc_free                     ta_free
  ------------------
 3067|  1.25M|    talloc_free(item->label);
  ------------------
  |  |   47|  1.25M|#define talloc_free                     ta_free
  ------------------
 3068|  1.25M|    free_str_list(&(item->attribs));
 3069|  1.25M|}
m_option.c:copy_obj_settings_list:
 3182|  1.20M|{
 3183|  1.20M|    m_obj_settings_t *d, *s;
 3184|  1.20M|    int n;
 3185|       |
 3186|  1.20M|    if (!(dst && src))
  ------------------
  |  Branch (3186:11): [True: 1.20M, False: 0]
  |  Branch (3186:18): [True: 1.20M, False: 0]
  ------------------
 3187|      0|        return;
 3188|       |
 3189|  1.20M|    s = VAL(src);
  ------------------
  |  | 3041|  1.20M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3190|       |
 3191|  1.20M|    if (VAL(dst))
  ------------------
  |  | 3041|  1.20M|#define VAL(x) (*(m_obj_settings_t **)(x))
  |  |  ------------------
  |  |  |  Branch (3041:16): [True: 0, False: 1.20M]
  |  |  ------------------
  ------------------
 3192|      0|        free_obj_settings_list(dst);
 3193|  1.20M|    if (!s)
  ------------------
  |  Branch (3193:9): [True: 703k, False: 496k]
  ------------------
 3194|   703k|        return;
 3195|       |
 3196|  1.64M|    for (n = 0; s[n].name; n++)
  ------------------
  |  Branch (3196:17): [True: 1.15M, False: 496k]
  ------------------
 3197|  1.15M|        /* NOP */;
 3198|   496k|    d = talloc_array(NULL, struct m_obj_settings, n + 1);
  ------------------
  |  |   29|   496k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|   496k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   496k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3199|  1.64M|    for (n = 0; s[n].name; n++) {
  ------------------
  |  Branch (3199:17): [True: 1.15M, False: 496k]
  ------------------
 3200|  1.15M|        d[n].name = talloc_strdup(NULL, s[n].name);
  ------------------
  |  |   50|  1.15M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3201|  1.15M|        d[n].label = talloc_strdup(NULL, s[n].label);
  ------------------
  |  |   50|  1.15M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3202|  1.15M|        d[n].enabled = s[n].enabled;
 3203|  1.15M|        d[n].attribs = NULL;
 3204|  1.15M|        copy_str_list(NULL, &(d[n].attribs), &(s[n].attribs));
 3205|  1.15M|    }
 3206|   496k|    d[n].name = NULL;
 3207|   496k|    d[n].label = NULL;
 3208|   496k|    d[n].attribs = NULL;
 3209|   496k|    VAL(dst) = d;
  ------------------
  |  | 3041|   496k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3210|   496k|}
m_option.c:free_obj_settings_list:
 3166|  1.43M|{
 3167|  1.43M|    int n;
 3168|  1.43M|    m_obj_settings_t *d;
 3169|       |
 3170|  1.43M|    if (!dst || !VAL(dst))
  ------------------
  |  | 3041|  1.43M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3170:9): [True: 0, False: 1.43M]
  |  Branch (3170:17): [True: 838k, False: 595k]
  ------------------
 3171|   838k|        return;
 3172|       |
 3173|   595k|    d = VAL(dst);
  ------------------
  |  | 3041|   595k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3174|  1.84M|    for (n = 0; d[n].name; n++)
  ------------------
  |  Branch (3174:17): [True: 1.25M, False: 595k]
  ------------------
 3175|  1.25M|        obj_setting_free(&d[n]);
 3176|   595k|    talloc_free(d);
  ------------------
  |  |   47|   595k|#define talloc_free                     ta_free
  ------------------
 3177|   595k|    VAL(dst) = NULL;
  ------------------
  |  | 3041|   595k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3178|   595k|}
m_option.c:obj_settings_list_equal:
 3873|  49.5k|{
 3874|  49.5k|    struct m_obj_settings *a = VAL(pa);
  ------------------
  |  | 3041|  49.5k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3875|  49.5k|    struct m_obj_settings *b = VAL(pb);
  ------------------
  |  | 3041|  49.5k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3876|       |
 3877|  49.5k|    if (a == b || !a || !b)
  ------------------
  |  Branch (3877:9): [True: 0, False: 49.5k]
  |  Branch (3877:19): [True: 49.5k, False: 0]
  |  Branch (3877:25): [True: 0, False: 0]
  ------------------
 3878|  49.5k|        return a == b || (!a && !b[0].name) || (!b && !a[0].name);
  ------------------
  |  Branch (3878:16): [True: 0, False: 49.5k]
  |  Branch (3878:27): [True: 49.5k, False: 0]
  |  Branch (3878:33): [True: 0, False: 49.5k]
  |  Branch (3878:49): [True: 0, False: 49.5k]
  |  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|  74.2k|{
 4034|  74.2k|    if (src) {
  ------------------
  |  Branch (4034:9): [True: 74.2k, False: 0]
  ------------------
 4035|  74.2k|        struct mpv_node *node = &VAL(src);
  ------------------
  |  | 3928|  74.2k|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4036|  74.2k|        talloc_free(node_get_alloc(node));
  ------------------
  |  |   47|  74.2k|#define talloc_free                     ta_free
  ------------------
 4037|  74.2k|        *node = (struct mpv_node){{0}};
 4038|  74.2k|    }
 4039|  74.2k|}

client.c:m_option_free:
  589|  74.2k|{
  590|  74.2k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 74.2k, False: 0]
  ------------------
  591|  74.2k|        opt->type->free(dst);
  592|  74.2k|}
command.c:m_option_free:
  589|  24.7k|{
  590|  24.7k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 24.7k, False: 0]
  ------------------
  591|  24.7k|        opt->type->free(dst);
  592|  24.7k|}
f_output_chain.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|}
cmd.c:m_option_free:
  589|   148k|{
  590|   148k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 49.5k, False: 99.0k]
  ------------------
  591|  49.5k|        opt->type->free(dst);
  592|   148k|}
cmd.c:m_option_copy:
  582|  24.7k|{
  583|  24.7k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 24.7k, False: 0]
  ------------------
  584|  24.7k|        opt->type->copy(opt, dst, src);
  585|  24.7k|}
cmd.c:m_option_print:
  559|   148k|{
  560|   148k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 148k, False: 0]
  ------------------
  561|   148k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|   148k|}
m_config_core.c:m_option_free:
  589|  91.8M|{
  590|  91.8M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 15.8M, False: 75.9M]
  ------------------
  591|  15.8M|        opt->type->free(dst);
  592|  91.8M|}
m_config_core.c:m_option_equal:
  617|   967k|{
  618|       |    // Handle trivial equivalence.
  619|       |    // If not implemented, assume this type has no actual values => always equal.
  620|   967k|    if (a == b || !opt->type->equal)
  ------------------
  |  Branch (620:9): [True: 0, False: 967k]
  |  Branch (620:19): [True: 0, False: 967k]
  ------------------
  621|      0|        return true;
  622|   967k|    return opt->type->equal(opt, a, b);
  623|   967k|}
m_config_core.c:m_option_copy:
  582|  16.4M|{
  583|  16.4M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 16.4M, False: 0]
  ------------------
  584|  16.4M|        opt->type->copy(opt, dst, src);
  585|  16.4M|}
m_config_frontend.c:m_option_copy:
  582|  20.2M|{
  583|  20.2M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 20.2M, False: 0]
  ------------------
  584|  20.2M|        opt->type->copy(opt, dst, src);
  585|  20.2M|}
m_config_frontend.c:m_option_free:
  589|  20.0M|{
  590|  20.0M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 3.66M, False: 16.4M]
  ------------------
  591|  3.66M|        opt->type->free(dst);
  592|  20.0M|}
m_property.c:m_option_pretty_print:
  569|   149k|{
  570|   149k|    m_option_t o = *opt;
  571|   149k|    if (fixed_len)
  ------------------
  |  Branch (571:9): [True: 0, False: 149k]
  ------------------
  572|      0|        o.flags |= M_OPT_FIXED_LEN_PRINT;
  ------------------
  |  |  494|      0|#define M_OPT_FIXED_LEN_PRINT   (UINT64_C(1) << 55)
  ------------------
  573|   149k|    if (opt->type->pretty_print)
  ------------------
  |  Branch (573:9): [True: 0, False: 149k]
  ------------------
  574|      0|        return opt->type->pretty_print(&o, val_ptr);
  575|   149k|    else
  576|   149k|        return m_option_print(&o, val_ptr);
  577|   149k|}
m_property.c:m_option_free:
  589|   449k|{
  590|   449k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 449k, False: 0]
  ------------------
  591|   449k|        opt->type->free(dst);
  592|   449k|}
m_property.c:m_option_print:
  559|   449k|{
  560|   449k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 449k, False: 0]
  ------------------
  561|   449k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|   449k|}

m_property_list_sort:
   45|  24.7k|{
   46|  24.7k|    qsort(list->props, list->num, sizeof(list->props[0]), compare_prop_name);
   47|  24.7k|}
m_property_do:
  142|   449k|{
  143|   449k|    union m_option_value val = m_option_value_default;
  144|   449k|    int r;
  145|       |
  146|   449k|    const char *key;
  147|   449k|    struct m_property *prop = resolve_name(prop_list, name, &key);
  148|   449k|    if (!prop)
  ------------------
  |  Branch (148:9): [True: 0, False: 449k]
  ------------------
  149|      0|        return M_PROPERTY_UNKNOWN;
  150|       |
  151|   449k|    struct m_option opt = {0};
  152|   449k|    bool get_opt_required[M_PROPERTY_MAX_ACTION] = {
  153|   449k|        [M_PROPERTY_FIXED_LEN_PRINT] = true, [M_PROPERTY_PRINT] = true,
  154|   449k|        [M_PROPERTY_PRINT_UNCUT] = true, [M_PROPERTY_GET_STRING] = true,
  155|   449k|        [M_PROPERTY_MULTIPLY] = true, [M_PROPERTY_SWITCH] = true,
  156|   449k|        [M_PROPERTY_GET_NODE] = true, [M_PROPERTY_SET_NODE] = true,
  157|   449k|    };
  158|   449k|    if (get_opt_required[action]) {
  ------------------
  |  Branch (158:9): [True: 449k, False: 0]
  ------------------
  159|   449k|        r = do_action(prop, key, M_PROPERTY_GET_TYPE, &opt, ctx);
  160|   449k|        if (r <= 0)
  ------------------
  |  Branch (160:13): [True: 0, False: 449k]
  ------------------
  161|      0|            return r;
  162|   449k|        mp_assert(opt.type);
  ------------------
  |  |   41|   449k|#define mp_assert assert
  ------------------
  |  Branch (162:9): [True: 449k, False: 0]
  ------------------
  163|       |        // Make sure dynamic range from properties with M_PROPERTY_GET_CONSTRICTED_TYPE is applied
  164|   449k|        struct m_option copt = {0};
  165|   449k|        r = do_action(prop, key, M_PROPERTY_GET_CONSTRICTED_TYPE, &copt, ctx);
  166|   449k|        if (r == M_PROPERTY_OK) {
  ------------------
  |  Branch (166:13): [True: 0, False: 449k]
  ------------------
  167|      0|            opt.min = copt.min;
  168|      0|            opt.max = copt.max;
  169|      0|        }
  170|   449k|    }
  171|       |
  172|   449k|    switch (action) {
  173|      0|    case M_PROPERTY_PRINT_UNCUT:
  ------------------
  |  Branch (173:5): [True: 0, False: 449k]
  ------------------
  174|      0|    case M_PROPERTY_FIXED_LEN_PRINT:
  ------------------
  |  Branch (174:5): [True: 0, False: 449k]
  ------------------
  175|   149k|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (175:5): [True: 149k, False: 299k]
  ------------------
  176|   149k|        if ((r = do_action(prop, key, action, arg, ctx)) >= 0)
  ------------------
  |  Branch (176:13): [True: 0, False: 149k]
  ------------------
  177|      0|            return r;
  178|   149k|        if (action == M_PROPERTY_PRINT_UNCUT &&
  ------------------
  |  Branch (178:13): [True: 0, False: 149k]
  ------------------
  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|   149k|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (182:13): [True: 0, False: 149k]
  ------------------
  183|      0|            return r;
  184|   149k|        char *str = m_option_pretty_print(&opt, &val, action == M_PROPERTY_FIXED_LEN_PRINT);
  185|   149k|        m_option_free(&opt, &val);
  186|   149k|        *(char **)arg = str;
  187|   149k|        return str != NULL;
  188|   149k|    }
  189|   299k|    case M_PROPERTY_GET_STRING: {
  ------------------
  |  Branch (189:5): [True: 299k, False: 149k]
  ------------------
  190|   299k|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (190:13): [True: 0, False: 299k]
  ------------------
  191|      0|            return r;
  192|   299k|        char *str = m_option_print(&opt, &val);
  193|   299k|        m_option_free(&opt, &val);
  194|   299k|        *(char **)arg = str;
  195|   299k|        return str != NULL;
  196|   299k|    }
  197|      0|    case M_PROPERTY_SET_STRING: {
  ------------------
  |  Branch (197:5): [True: 0, False: 449k]
  ------------------
  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|   299k|    }
  201|      0|    case M_PROPERTY_MULTIPLY: {
  ------------------
  |  Branch (201:5): [True: 0, False: 449k]
  ------------------
  202|      0|        return m_property_multiply(log, prop, key, *(double *)arg, ctx, &opt);
  203|   299k|    }
  204|      0|    case M_PROPERTY_SWITCH: {
  ------------------
  |  Branch (204:5): [True: 0, False: 449k]
  ------------------
  205|      0|        return m_property_switch(log, prop, key, arg, ctx, &opt);
  206|   299k|    }
  207|      0|    case M_PROPERTY_GET_CONSTRICTED_TYPE: {
  ------------------
  |  Branch (207:5): [True: 0, False: 449k]
  ------------------
  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: 449k]
  ------------------
  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: 449k]
  ------------------
  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: 449k]
  ------------------
  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: 449k]
  ------------------
  254|      0|        return do_action(prop, key, action, arg, ctx);
  255|   449k|    }
  256|   449k|}
m_properties_expand_string:
  338|   149k|{
  339|   149k|    char *ret = NULL;
  340|   149k|    int ret_len = 0;
  341|   149k|    bool skip = false;
  342|   149k|    int level = 0, skip_level = 0;
  343|   149k|    bstr str = bstr0(str0);
  344|   149k|    int last_brace = bstrrchr(str, '}');
  345|   149k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  346|   149k|    int n = 0;
  347|   149k|#endif
  348|       |
  349|  2.99M|    while (str.len) {
  ------------------
  |  Branch (349:12): [True: 2.84M, False: 149k]
  ------------------
  350|  2.84M|        if (level > 0 && bstr_eatstart0(&str, "}")) {
  ------------------
  |  Branch (350:13): [True: 1.64M, False: 1.19M]
  |  Branch (350:26): [True: 449k, False: 1.19M]
  ------------------
  351|   449k|            if (skip && level <= skip_level)
  ------------------
  |  Branch (351:17): [True: 299k, False: 149k]
  |  Branch (351:25): [True: 299k, False: 0]
  ------------------
  352|   299k|                skip = false;
  353|   449k|            level--;
  354|  2.39M|        } else if (bstr_startswith0(str, "${") && str.start - (unsigned char *)str0 < last_brace) {
  ------------------
  |  Branch (354:20): [True: 449k, False: 1.94M]
  |  Branch (354:51): [True: 449k, False: 0]
  ------------------
  355|   449k|            str = bstr_cut(str, 2);
  356|   449k|            level++;
  357|       |
  358|       |            // Assume ":" and "}" can't be part of the property name
  359|       |            // => if ":" comes before "}", it must be for the fallback
  360|   449k|            int term_pos = bstrcspn(str, ":}");
  361|   449k|            bstr name = bstr_splice(str, 0, term_pos < 0 ? str.len : term_pos);
  ------------------
  |  Branch (361:45): [True: 0, False: 449k]
  ------------------
  362|   449k|            str = bstr_cut(str, term_pos);
  363|   449k|            bool have_fallback = bstr_eatstart0(&str, ":");
  364|       |
  365|   449k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  366|   449k|            if (n++ > 10)
  ------------------
  |  Branch (366:17): [True: 0, False: 449k]
  ------------------
  367|      0|                break;
  368|   449k|#endif
  369|       |
  370|   449k|            if (!skip) {
  ------------------
  |  Branch (370:17): [True: 449k, False: 0]
  ------------------
  371|   449k|                skip = expand_property(prop_list, &ret, &ret_len, name,
  372|   449k|                                       have_fallback, ctx, print_action);
  373|   449k|                if (skip)
  ------------------
  |  Branch (373:21): [True: 299k, False: 149k]
  ------------------
  374|   299k|                    skip_level = level;
  375|   449k|            }
  376|  1.94M|        } else if (level == 0 && bstr_eatstart0(&str, "$>")) {
  ------------------
  |  Branch (376:20): [True: 898k, False: 1.04M]
  |  Branch (376:34): [True: 0, False: 898k]
  ------------------
  377|      0|            append_str(&ret, &ret_len, str);
  378|      0|            break;
  379|  1.94M|        } else {
  380|  1.94M|            char c;
  381|       |
  382|       |            // Other combinations, e.g. "$x", are added verbatim
  383|  1.94M|            if (bstr_eatstart0(&str, "$$")) {
  ------------------
  |  Branch (383:17): [True: 0, False: 1.94M]
  ------------------
  384|      0|                c = '$';
  385|  1.94M|            } else if (bstr_eatstart0(&str, "$}")) {
  ------------------
  |  Branch (385:24): [True: 0, False: 1.94M]
  ------------------
  386|      0|                c = '}';
  387|  1.94M|            } else {
  388|  1.94M|                c = str.start[0];
  389|  1.94M|                str = bstr_cut(str, 1);
  390|  1.94M|            }
  391|       |
  392|  1.94M|            if (!skip)
  ------------------
  |  Branch (392:17): [True: 898k, False: 1.04M]
  ------------------
  393|   898k|                MP_TARRAY_APPEND(NULL, ret, ret_len, c);
  ------------------
  |  |  105|   898k|    do {                                            \
  |  |  106|   898k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   898k|    do {                                            \
  |  |  |  |   97|   898k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   898k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   898k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   898k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 142k, False: 755k]
  |  |  |  |  ------------------
  |  |  |  |   99|   898k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   142k|    do {                                                        \
  |  |  |  |  |  |   89|   142k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   142k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   142k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   142k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   142k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   142k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   142k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 142k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   898k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 898k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   898k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   898k|        (idxvar)++;                                 \
  |  |  109|   898k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 898k]
  |  |  ------------------
  ------------------
  394|  1.94M|        }
  395|  2.84M|    }
  396|       |
  397|   149k|    MP_TARRAY_APPEND(NULL, ret, ret_len, '\0');
  ------------------
  |  |  105|   149k|    do {                                            \
  |  |  106|   149k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   149k|    do {                                            \
  |  |  |  |   97|   149k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   149k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   149k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   149k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 37, False: 149k]
  |  |  |  |  ------------------
  |  |  |  |   99|   149k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     37|    do {                                                        \
  |  |  |  |  |  |   89|     37|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     37|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     37|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     37|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     37|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     37|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     37|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 37]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   149k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 149k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   149k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   149k|        (idxvar)++;                                 \
  |  |  109|   149k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 149k]
  |  |  ------------------
  ------------------
  398|   149k|    return ret;
  399|   149k|}
m_property_strdup_ro:
  476|  1.49M|{
  477|  1.49M|    if (!var)
  ------------------
  |  Branch (477:9): [True: 0, False: 1.49M]
  ------------------
  478|      0|        return M_PROPERTY_UNAVAILABLE;
  479|  1.49M|    switch (action) {
  ------------------
  |  Branch (479:13): [True: 898k, False: 598k]
  ------------------
  480|   449k|    case M_PROPERTY_GET:
  ------------------
  |  Branch (480:5): [True: 449k, False: 1.04M]
  ------------------
  481|   449k|        *(char **)arg = talloc_strdup(NULL, var);
  ------------------
  |  |   50|   449k|#define talloc_strdup                   ta_xstrdup
  ------------------
  482|   449k|        return M_PROPERTY_OK;
  483|   449k|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (483:5): [True: 449k, False: 1.04M]
  ------------------
  484|   449k|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|   449k|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  485|   449k|        return M_PROPERTY_OK;
  486|  1.49M|    }
  487|   598k|    return M_PROPERTY_NOT_IMPLEMENTED;
  488|  1.49M|}
m_property.c:compare_prop_name:
   39|   188M|{
   40|   188M|    const struct m_property *a = pa, *b = pb;
   41|   188M|    return strcmp(a->name, b->name);
   42|   188M|}
m_property.c:find_prop:
   57|   449k|{
   58|   449k|    return bsearch(&name, list->props, list->num, sizeof(list->props[0]),
   59|   449k|                   search_prop_name);
   60|   449k|}
m_property.c:search_prop_name:
   50|  4.04M|{
   51|  4.04M|    const struct m_property *prop = pelem;
   52|  4.04M|    return bstrcmp0(*(const bstr *)pkey, prop->name);
   53|  4.04M|}
m_property.c:resolve_name:
   72|   449k|{
   73|   449k|    *key = NULL;
   74|   449k|    const char *sep = strchr(name, '/');
   75|   449k|    if (sep && sep[1]) {
  ------------------
  |  Branch (75:9): [True: 0, False: 449k]
  |  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|   449k|    return find_prop(list, bstr0(name));
   80|   449k|}
m_property.c:do_action:
   84|  1.49M|{
   85|  1.49M|    if (key) {
  ------------------
  |  Branch (85:9): [True: 0, False: 1.49M]
  ------------------
   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|  1.49M|    return prop->call(ctx, prop, action, arg);
   94|  1.49M|}
m_property.c:expand_property:
  305|   449k|{
  306|   449k|    bool cond_yes = bstr_eatstart0(&prop, "?");
  307|   449k|    bool cond_no = !cond_yes && bstr_eatstart0(&prop, "!");
  ------------------
  |  Branch (307:20): [True: 299k, False: 149k]
  |  Branch (307:33): [True: 149k, False: 149k]
  ------------------
  308|   449k|    bool test = cond_yes || cond_no;
  ------------------
  |  Branch (308:17): [True: 149k, False: 299k]
  |  Branch (308:29): [True: 149k, False: 149k]
  ------------------
  309|   449k|    bool raw = bstr_eatstart0(&prop, "=");
  310|   449k|    bool fixed_len = !raw && bstr_eatstart0(&prop, ">");
  ------------------
  |  Branch (310:22): [True: 449k, False: 0]
  |  Branch (310:30): [True: 0, False: 449k]
  ------------------
  311|   449k|    bstr comp_with = {0};
  312|   449k|    bool comp = test && bstr_split_tok(prop, "==", &prop, &comp_with);
  ------------------
  |  Branch (312:17): [True: 299k, False: 149k]
  |  Branch (312:25): [True: 0, False: 299k]
  ------------------
  313|   449k|    if (test && !comp)
  ------------------
  |  Branch (313:9): [True: 299k, False: 149k]
  |  Branch (313:17): [True: 299k, False: 0]
  ------------------
  314|   299k|        raw = true;
  315|   449k|    int method = raw ? M_PROPERTY_GET_STRING : print_action;
  ------------------
  |  Branch (315:18): [True: 299k, False: 149k]
  ------------------
  316|   449k|    method = fixed_len ? M_PROPERTY_FIXED_LEN_PRINT : method;
  ------------------
  |  Branch (316:14): [True: 0, False: 449k]
  ------------------
  317|       |
  318|   449k|    char *s = NULL;
  319|   449k|    int r = m_property_do_bstr(prop_list, prop, method, &s, ctx);
  320|   449k|    bool skip;
  321|   449k|    if (comp) {
  ------------------
  |  Branch (321:9): [True: 0, False: 449k]
  ------------------
  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|   449k|    } else if (test) {
  ------------------
  |  Branch (323:16): [True: 299k, False: 149k]
  ------------------
  324|   299k|        skip = (!!s != cond_yes);
  325|   299k|    } else {
  326|   149k|        skip = !!s;
  327|   149k|        char *append = s;
  328|   149k|        if (!s && !silent_error && !raw)
  ------------------
  |  Branch (328:13): [True: 0, False: 149k]
  |  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|   149k|        append_str(ret, ret_len, bstr0(append));
  331|   149k|    }
  332|   449k|    talloc_free(s);
  ------------------
  |  |   47|   449k|#define talloc_free                     ta_free
  ------------------
  333|   449k|    return skip;
  334|   449k|}
m_property.c:m_property_do_bstr:
  287|   449k|{
  288|   449k|    char *name0 = bstrdup0(NULL, name);
  289|   449k|    int ret = m_property_do(NULL, prop_list, name0, action, arg, ctx);
  290|   449k|    talloc_free(name0);
  ------------------
  |  |   47|   449k|#define talloc_free                     ta_free
  ------------------
  291|   449k|    return ret;
  292|   449k|}
m_property.c:append_str:
  295|   149k|{
  296|   149k|    MP_TARRAY_GROW(NULL, *s, *len + append.len);
  ------------------
  |  |   96|   149k|    do {                                            \
  |  |   97|   149k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   149k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   149k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   149k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 149k, False: 0]
  |  |  ------------------
  |  |   99|   149k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   149k|    do {                                                        \
  |  |  |  |   89|   149k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   149k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   149k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   149k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   149k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   149k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   149k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 149k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   149k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 149k]
  |  |  ------------------
  ------------------
  297|   149k|    if (append.len)
  ------------------
  |  Branch (297:9): [True: 149k, False: 0]
  ------------------
  298|   149k|        memcpy(*s + *len, append.start, append.len);
  299|   149k|    *len = *len + append.len;
  300|   149k|}

m_config_parse:
   45|  24.7k|{
   46|  24.7k|    m_profile_t *profile = m_config_add_profile(config, initial_section);
   47|  24.7k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  24.7k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.7k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   48|  24.7k|    int line_no = 0;
   49|  24.7k|    int errors = 0;
   50|       |
   51|  24.7k|    bstr_eatstart0(&data, "\xEF\xBB\xBF"); // skip BOM
   52|       |
   53|  2.52M|    while (data.len) {
  ------------------
  |  Branch (53:12): [True: 2.49M, False: 24.7k]
  ------------------
   54|  2.49M|        talloc_free_children(tmp);
  ------------------
  |  |   46|  2.49M|#define talloc_free_children            ta_free_children
  ------------------
   55|  2.49M|        bool ok = false;
   56|       |
   57|  2.49M|        line_no++;
   58|  2.49M|        char loc[512];
   59|  2.49M|        snprintf(loc, sizeof(loc), "%s:%d:", location, line_no);
   60|       |
   61|  2.49M|        bstr line = bstr_strip_linebreaks(bstr_getline(data, &data));
   62|  2.49M|        if (!skip_ws(&line))
  ------------------
  |  Branch (62:13): [True: 618k, False: 1.88M]
  ------------------
   63|   618k|            continue;
   64|       |
   65|       |        // Profile declaration
   66|  1.88M|        if (bstr_eatstart0(&line, "[")) {
  ------------------
  |  Branch (66:13): [True: 297k, False: 1.58M]
  ------------------
   67|   297k|            bstr profilename;
   68|   297k|            if (!bstr_split_tok(line, "]", &profilename, &line)) {
  ------------------
  |  Branch (68:17): [True: 0, False: 297k]
  ------------------
   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|   297k|            if (skip_ws(&line)) {
  ------------------
  |  Branch (72:17): [True: 0, False: 297k]
  ------------------
   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|   297k|            profile = m_config_add_profile(config, bstrto0(tmp, profilename));
   78|   297k|            continue;
   79|   297k|        }
   80|       |
   81|  1.58M|        bstr_eatstart0(&line, "--");
   82|       |
   83|  1.58M|        bstr option = line;
   84|  21.3M|        while (line.len && (mp_isalnum(line.start[0]) || line.start[0] == '_' ||
  ------------------
  |  Branch (84:16): [True: 21.3M, False: 0]
  |  Branch (84:29): [True: 18.0M, False: 3.29M]
  |  Branch (84:58): [True: 0, False: 3.29M]
  ------------------
   85|  3.29M|                            line.start[0] == '-'))
  ------------------
  |  Branch (85:29): [True: 1.70M, False: 1.58M]
  ------------------
   86|  19.7M|            line = bstr_cut(line, 1);
   87|  1.58M|        option.len = option.len - line.len;
   88|  1.58M|        skip_ws(&line);
   89|       |
   90|  1.58M|        bstr value = {0};
   91|  1.58M|        if (bstr_eatstart0(&line, "=")) {
  ------------------
  |  Branch (91:13): [True: 1.58M, False: 0]
  ------------------
   92|  1.58M|            skip_ws(&line);
   93|  1.58M|            if (line.len && (line.start[0] == '"' || line.start[0] == '\'')) {
  ------------------
  |  Branch (93:17): [True: 1.58M, False: 0]
  |  Branch (93:30): [True: 0, False: 1.58M]
  |  Branch (93:54): [True: 0, False: 1.58M]
  ------------------
   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.58M|            } else if (bstr_eatstart0(&line, "%")) {
  ------------------
  |  Branch (101:24): [True: 0, False: 1.58M]
  ------------------
  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.58M|            } else {
  117|       |                // No quoting; take everything until the comment or end of line
  118|  1.58M|                int end = bstrchr(line, '#');
  119|  1.58M|                value = bstr_strip(end < 0 ? line : bstr_splice(line, 0, end));
  ------------------
  |  Branch (119:36): [True: 1.33M, False: 247k]
  ------------------
  120|  1.58M|                line.len = 0;
  121|  1.58M|            }
  122|  1.58M|        }
  123|  1.58M|        if (skip_ws(&line)) {
  ------------------
  |  Branch (123:13): [True: 0, False: 1.58M]
  ------------------
  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.58M|        int res = m_config_set_profile_option(config, profile, option, value);
  130|  1.58M|        if (res < 0) {
  ------------------
  |  Branch (130:13): [True: 123k, False: 1.46M]
  ------------------
  131|   123k|            MP_ERR(config, "%s setting option %.*s='%.*s' failed.\n",
  ------------------
  |  |   89|   123k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   495k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 123k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 123k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|   123k|                   loc, BSTR_P(option), BSTR_P(value));
  133|   123k|            goto error;
  134|   123k|        }
  135|       |
  136|  1.46M|        ok = true;
  137|  1.58M|    error:
  138|  1.58M|        if (!ok)
  ------------------
  |  Branch (138:13): [True: 123k, False: 1.46M]
  ------------------
  139|   123k|            errors++;
  140|  1.58M|        if (errors > 16) {
  ------------------
  |  Branch (140:13): [True: 0, False: 1.58M]
  ------------------
  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.58M|    }
  145|       |
  146|  24.7k|    if (config->recursion_depth == 0)
  ------------------
  |  Branch (146:9): [True: 24.7k, False: 0]
  ------------------
  147|  24.7k|        m_config_finish_default_profile(config, flags);
  148|       |
  149|  24.7k|    talloc_free(tmp);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  150|  24.7k|    return 1;
  151|  24.7k|}
parse_configfile.c:skip_ws:
   36|  7.54M|{
   37|  7.54M|    *s = bstr_lstrip(*s);
   38|  7.54M|    if (bstr_startswith0(*s, "#"))
  ------------------
  |  Branch (38:9): [True: 297k, False: 7.25M]
  ------------------
   39|   297k|        s->len = 0;
   40|  7.54M|    return s->len;
   41|  7.54M|}

mp_init_paths:
  109|  24.7k|{
  110|  24.7k|    TA_FREEP(&global->configdir);
  ------------------
  |  |   81|  24.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  24.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
  111|       |
  112|  24.7k|    const char *force_configdir = getenv("MPV_HOME");
  113|  24.7k|    if (opts->force_configdir && opts->force_configdir[0])
  ------------------
  |  Branch (113:9): [True: 0, False: 24.7k]
  |  Branch (113:34): [True: 0, False: 0]
  ------------------
  114|      0|        force_configdir = opts->force_configdir;
  115|  24.7k|    if (!opts->load_config)
  ------------------
  |  Branch (115:9): [True: 24.7k, False: 0]
  ------------------
  116|  24.7k|        force_configdir = "";
  117|       |
  118|  24.7k|    global->configdir = mp_get_user_path(global, global, force_configdir);
  119|  24.7k|}
mp_find_user_file:
  123|  49.5k|{
  124|  49.5k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  49.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  49.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  125|  49.5k|    char *res = (char *)mp_get_platform_path(tmp, global, type);
  126|  49.5k|    if (res)
  ------------------
  |  Branch (126:9): [True: 0, False: 49.5k]
  ------------------
  127|      0|        res = mp_path_join(talloc_ctx, res, filename);
  128|  49.5k|    talloc_free(tmp);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
  129|  49.5k|    MP_DBG(global, "%s path: '%s' -> '%s'\n", type, filename, res ? res : "-");
  ------------------
  |  |   93|  49.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  99.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 49.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|  49.5k|    return res;
  131|  49.5k|}
mp_find_all_config_files:
  170|  99.0k|{
  171|  99.0k|    return mp_find_all_config_files_limited(talloc_ctx, global, 64, filename);
  172|  99.0k|}
mp_find_config_file:
  176|  31.1k|{
  177|  31.1k|    char **l = mp_find_all_config_files_limited(talloc_ctx, global, 1, filename);
  178|  31.1k|    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: 31.1k, False: 0]
  |  Branch (178:20): [True: 0, False: 31.1k]
  ------------------
  179|  31.1k|    talloc_free(l);
  ------------------
  |  |   47|  31.1k|#define talloc_free                     ta_free
  ------------------
  180|  31.1k|    return r;
  181|  31.1k|}
mp_get_user_path:
  185|   222k|{
  186|   222k|    if (!path)
  ------------------
  |  Branch (186:9): [True: 123k, False: 99.0k]
  ------------------
  187|   123k|        return NULL;
  188|  99.0k|    char *res = NULL;
  189|  99.0k|    bstr bpath = bstr0(path);
  190|  99.0k|    if (bstr_eatstart0(&bpath, "~")) {
  ------------------
  |  Branch (190:9): [True: 49.5k, False: 49.5k]
  ------------------
  191|       |        // parse to "~" <prefix> "/" <rest>
  192|  49.5k|        bstr prefix, rest;
  193|  49.5k|        if (bstr_split_tok(bpath, "/", &prefix, &rest)) {
  ------------------
  |  Branch (193:13): [True: 49.5k, False: 0]
  ------------------
  194|  49.5k|            const char *rest0 = rest.start; // ok in this case
  195|  49.5k|            if (bstr_equals0(prefix, "~")) {
  ------------------
  |  Branch (195:17): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|            } else if (bstr_equals0(prefix, "")) {
  ------------------
  |  Branch (203:24): [True: 0, False: 49.5k]
  ------------------
  204|      0|                char *home = getenv("HOME");
  205|      0|                if (!home)
  ------------------
  |  Branch (205:21): [True: 0, False: 0]
  ------------------
  206|      0|                    home = getenv("USERPROFILE");
  207|      0|                res = mp_path_join_bstr(talloc_ctx, bstr0(home), rest);
  208|  49.5k|            } else if (bstr_eatstart0(&prefix, "~")) {
  ------------------
  |  Branch (208:24): [True: 49.5k, False: 0]
  ------------------
  209|  49.5k|                void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  49.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  49.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  210|  49.5k|                char type[80];
  211|  49.5k|                snprintf(type, sizeof(type), "%.*s", BSTR_P(prefix));
  ------------------
  |  |  307|  49.5k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 49.5k, False: 0]
  |  |  ------------------
  ------------------
  212|  49.5k|                const char *p = mp_get_platform_path(tmp, global, type);
  213|  49.5k|                res = mp_path_join_bstr(talloc_ctx, bstr0(p), rest);
  214|  49.5k|                talloc_free(tmp);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
  215|  49.5k|            }
  216|  49.5k|        }
  217|  49.5k|    }
  218|  99.0k|    if (!res) {
  ------------------
  |  Branch (218:9): [True: 49.5k, False: 49.5k]
  ------------------
  219|  49.5k|        res = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|  49.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  220|  49.5k|    } else {
  221|  49.5k|        MP_DBG(global, "user path: '%s' -> '%s'\n", path, res);
  ------------------
  |  |   93|  49.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  49.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  222|  49.5k|    }
  223|  99.0k|    return res;
  224|   222k|}
mp_mk_user_dir:
  236|  24.7k|{
  237|  24.7k|    char *dir = mp_find_user_file(NULL, global, type, subdir);
  238|  24.7k|    if (dir)
  ------------------
  |  Branch (238:9): [True: 0, False: 24.7k]
  ------------------
  239|      0|        mp_mkdirp(dir);
  240|  24.7k|    talloc_free(dir);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  241|  24.7k|}
path.c:mp_get_platform_path:
   74|   749k|{
   75|   749k|    mp_assert(talloc_ctx);
  ------------------
  |  |   41|   749k|#define mp_assert assert
  ------------------
  |  Branch (75:5): [True: 749k, False: 0]
  ------------------
   76|       |
   77|   749k|    if (global->configdir) {
  ------------------
  |  Branch (77:9): [True: 749k, False: 0]
  ------------------
   78|       |        // Return NULL for all platform paths if --no-config is passed
   79|   749k|        if (!global->configdir[0])
  ------------------
  |  Branch (79:13): [True: 749k, False: 0]
  ------------------
   80|   749k|            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|   130k|{
  138|   130k|    char **ret = talloc_array(talloc_ctx, char*, 2); // 2 preallocated
  ------------------
  |  |   29|   130k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|   130k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   130k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  139|   130k|    int num_ret = 0;
  140|       |
  141|   780k|    for (int i = 0; i < MP_ARRAY_SIZE(config_dirs); i++) {
  ------------------
  |  |   49|   780k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (141:21): [True: 650k, False: 130k]
  ------------------
  142|   650k|        const char *dir = mp_get_platform_path(ret, global, config_dirs[i]);
  143|   650k|        bstr s = bstr0(filename);
  144|   650k|        while (dir && num_ret < max_files && s.len) {
  ------------------
  |  Branch (144:16): [True: 0, False: 650k]
  |  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|   650k|    }
  159|       |
  160|   130k|    MP_TARRAY_GROW(NULL, ret, num_ret);
  ------------------
  |  |   96|   130k|    do {                                            \
  |  |   97|   130k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   130k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   130k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   130k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 130k]
  |  |  ------------------
  |  |   99|   130k|            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|   130k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 130k]
  |  |  ------------------
  ------------------
  161|   130k|    ret[num_ret] = NULL;
  162|       |
  163|   130k|    for (int n = 0; n < num_ret / 2; n++)
  ------------------
  |  Branch (163:21): [True: 0, False: 130k]
  ------------------
  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|   130k|    return ret;
  166|   130k|}

mp_get_user_langs:
   26|  24.6k|{
   27|  24.6k|    static const char *const list[] = {
   28|  24.6k|        "LC_ALL",
   29|  24.6k|        "LC_MESSAGES",
   30|  24.6k|        "LANG",
   31|  24.6k|        NULL
   32|  24.6k|    };
   33|       |
   34|  24.6k|    size_t nb = 0;
   35|  24.6k|    char **ret = NULL;
   36|  24.6k|    bool has_c = false;
   37|       |
   38|       |    // Prefer anything we get from LANGUAGE first
   39|  24.6k|    for (const char *langList = getenv("LANGUAGE"); langList && *langList;) {
  ------------------
  |  Branch (39:53): [True: 0, False: 24.6k]
  |  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|  98.5k|    for (int i = 0; list[i]; i++) {
  ------------------
  |  Branch (54:21): [True: 73.8k, False: 24.6k]
  ------------------
   55|  73.8k|        const char *envval = getenv(list[i]);
   56|  73.8k|        if (envval && *envval) {
  ------------------
  |  Branch (56:13): [True: 0, False: 73.8k]
  |  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|  73.8k|    }
   73|       |
   74|  24.6k|    if (has_c && !nb) {
  ------------------
  |  Branch (74:9): [True: 0, False: 24.6k]
  |  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|  24.6k|    MP_TARRAY_APPEND(NULL, ret, nb, NULL);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   81|       |
   82|  24.6k|    return ret;
   83|  24.6k|}

client.c:mp_mutex_init:
  113|   123k|{
  114|   123k|#ifndef NDEBUG
  115|   123k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   123k|    int ret = 0;
  121|   123k|    pthread_mutexattr_t attr;
  122|   123k|    ret = pthread_mutexattr_init(&attr);
  123|   123k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 123k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   123k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   123k|    ret = pthread_mutex_init(mutex, &attr);
  128|   123k|    pthread_mutexattr_destroy(&attr);
  129|   123k|    mp_assert(!ret);
  ------------------
  |  |   41|   123k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 123k, False: 0]
  ------------------
  130|   123k|    return ret;
  131|   123k|}
client.c:mp_cond_init:
  139|  49.5k|{
  140|  49.5k|    mp_assert(cond);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 49.5k, False: 0]
  ------------------
  141|       |
  142|  49.5k|    int ret = 0;
  143|  49.5k|    pthread_condattr_t attr;
  144|  49.5k|    ret = pthread_condattr_init(&attr);
  145|  49.5k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 49.5k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  49.5k|    cond->clk_id = CLOCK_REALTIME;
  149|  49.5k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  49.5k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 49.5k, False: 0]
  ------------------
  151|  49.5k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  49.5k|#endif
  153|       |
  154|  49.5k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  49.5k|    pthread_condattr_destroy(&attr);
  156|  49.5k|    return ret;
  157|  49.5k|}
client.c:mp_cond_timedwait_until:
  205|   271k|{
  206|   271k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   271k|}
client.c:mp_cond_timedwait:
  184|   271k|{
  185|   271k|    mp_assert(cond);
  ------------------
  |  |   41|   271k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 271k, False: 0]
  ------------------
  186|       |
  187|   271k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   271k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 271k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   271k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   271k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 210k, False: 61.1k]
  ------------------
  190|   210k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  61.1k|    struct timespec ts;
  193|  61.1k|    clock_gettime(cond->clk_id, &ts);
  194|  61.1k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  61.1k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  61.1k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  61.1k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  61.1k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  61.1k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 61.1k, False: 0]
  ------------------
  197|  61.1k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  61.1k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  61.1k|        ts.tv_sec++;
  199|  61.1k|    }
  200|       |
  201|  61.1k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   271k|}
client.c:mp_cond_destroy:
  160|  49.5k|{
  161|  49.5k|    mp_assert(cond);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 49.5k, False: 0]
  ------------------
  162|  49.5k|    return pthread_cond_destroy(&cond->cond);
  163|  49.5k|}
client.c:mp_thread_set_name:
  222|  24.7k|{
  223|  24.7k|#if HAVE_GLIBC_THREAD_NAME
  224|  24.7k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 24.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|  24.7k|}
client.c:mp_cond_broadcast:
  166|   272k|{
  167|   272k|    mp_assert(cond);
  ------------------
  |  |   41|   272k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 272k, False: 0]
  ------------------
  168|   272k|    return pthread_cond_broadcast(&cond->cond);
  169|   272k|}
loadfile.c:mp_thread_set_name:
  222|  24.7k|{
  223|  24.7k|#if HAVE_GLIBC_THREAD_NAME
  224|  24.7k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 24.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|  24.7k|}
main.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
osd.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
clipboard.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
dec_sub.c:mp_mutex_init:
  113|  2.70k|{
  114|  2.70k|#ifndef NDEBUG
  115|  2.70k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  2.70k|    int ret = 0;
  121|  2.70k|    pthread_mutexattr_t attr;
  122|  2.70k|    ret = pthread_mutexattr_init(&attr);
  123|  2.70k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 2.70k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  2.70k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  2.70k|    ret = pthread_mutex_init(mutex, &attr);
  128|  2.70k|    pthread_mutexattr_destroy(&attr);
  129|  2.70k|    mp_assert(!ret);
  ------------------
  |  |   41|  2.70k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 2.70k, False: 0]
  ------------------
  130|  2.70k|    return ret;
  131|  2.70k|}
vo.c:mp_mutex_init:
  113|  39.2k|{
  114|  39.2k|#ifndef NDEBUG
  115|  39.2k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  39.2k|    int ret = 0;
  121|  39.2k|    pthread_mutexattr_t attr;
  122|  39.2k|    ret = pthread_mutexattr_init(&attr);
  123|  39.2k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 39.2k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  39.2k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  39.2k|    ret = pthread_mutex_init(mutex, &attr);
  128|  39.2k|    pthread_mutexattr_destroy(&attr);
  129|  39.2k|    mp_assert(!ret);
  ------------------
  |  |   41|  39.2k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 39.2k, False: 0]
  ------------------
  130|  39.2k|    return ret;
  131|  39.2k|}
vo.c:mp_cond_init:
  139|  19.6k|{
  140|  19.6k|    mp_assert(cond);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 19.6k, False: 0]
  ------------------
  141|       |
  142|  19.6k|    int ret = 0;
  143|  19.6k|    pthread_condattr_t attr;
  144|  19.6k|    ret = pthread_condattr_init(&attr);
  145|  19.6k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 19.6k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  19.6k|    cond->clk_id = CLOCK_REALTIME;
  149|  19.6k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  19.6k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 19.6k, False: 0]
  ------------------
  151|  19.6k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  19.6k|#endif
  153|       |
  154|  19.6k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  19.6k|    pthread_condattr_destroy(&attr);
  156|  19.6k|    return ret;
  157|  19.6k|}
vo.c:mp_thread_set_name:
  222|  19.6k|{
  223|  19.6k|#if HAVE_GLIBC_THREAD_NAME
  224|  19.6k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 19.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|  19.6k|}
vo.c:mp_thread_set_min_timer_slack:
  237|  19.6k|{
  238|  19.6k|#if HAVE_PR_SET_TIMERSLACK
  239|       |    prctl(PR_SET_TIMERSLACK, 1UL);
  240|  19.6k|#endif
  241|  19.6k|}
vo.c:mp_cond_broadcast:
  166|   524k|{
  167|   524k|    mp_assert(cond);
  ------------------
  |  |   41|   524k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 524k, False: 0]
  ------------------
  168|   524k|    return pthread_cond_broadcast(&cond->cond);
  169|   524k|}
vo.c:mp_cond_destroy:
  160|  19.6k|{
  161|  19.6k|    mp_assert(cond);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 19.6k, False: 0]
  ------------------
  162|  19.6k|    return pthread_cond_destroy(&cond->cond);
  163|  19.6k|}
vo.c:mp_cond_timedwait_until:
  205|   328k|{
  206|   328k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   328k|}
vo.c:mp_cond_timedwait:
  184|   328k|{
  185|   328k|    mp_assert(cond);
  ------------------
  |  |   41|   328k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 328k, False: 0]
  ------------------
  186|       |
  187|   328k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   328k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 328k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   328k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   328k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 0, False: 328k]
  ------------------
  190|      0|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   328k|    struct timespec ts;
  193|   328k|    clock_gettime(cond->clk_id, &ts);
  194|   328k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   328k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   328k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   328k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   328k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   328k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 328k, False: 0]
  ------------------
  197|   328k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   328k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|   328k|        ts.tv_sec++;
  199|   328k|    }
  200|       |
  201|   328k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   328k|}
vo.c:mp_cond_wait:
  178|  10.6k|{
  179|  10.6k|    mp_assert(cond);
  ------------------
  |  |   41|  10.6k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 10.6k, False: 0]
  ------------------
  180|  10.6k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  10.6k|}
buffer.c:mp_cond_broadcast:
  166|   602k|{
  167|   602k|    mp_assert(cond);
  ------------------
  |  |   41|   602k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 602k, False: 0]
  ------------------
  168|   602k|    return pthread_cond_broadcast(&cond->cond);
  169|   602k|}
buffer.c:mp_cond_timedwait:
  184|   279k|{
  185|   279k|    mp_assert(cond);
  ------------------
  |  |   41|   279k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 279k, False: 0]
  ------------------
  186|       |
  187|   279k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   279k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 279k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   279k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   279k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 17.3k, False: 262k]
  ------------------
  190|  17.3k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   262k|    struct timespec ts;
  193|   262k|    clock_gettime(cond->clk_id, &ts);
  194|   262k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   262k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   262k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   262k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   262k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   262k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 13.5k, False: 249k]
  ------------------
  197|  13.5k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  13.5k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  13.5k|        ts.tv_sec++;
  199|  13.5k|    }
  200|       |
  201|   262k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   279k|}
buffer.c:mp_cond_destroy:
  160|  16.1k|{
  161|  16.1k|    mp_assert(cond);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 16.1k, False: 0]
  ------------------
  162|  16.1k|    return pthread_cond_destroy(&cond->cond);
  163|  16.1k|}
buffer.c:mp_mutex_init:
  113|  16.1k|{
  114|  16.1k|#ifndef NDEBUG
  115|  16.1k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  16.1k|    int ret = 0;
  121|  16.1k|    pthread_mutexattr_t attr;
  122|  16.1k|    ret = pthread_mutexattr_init(&attr);
  123|  16.1k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 16.1k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  16.1k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  16.1k|    ret = pthread_mutex_init(mutex, &attr);
  128|  16.1k|    pthread_mutexattr_destroy(&attr);
  129|  16.1k|    mp_assert(!ret);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 16.1k, False: 0]
  ------------------
  130|  16.1k|    return ret;
  131|  16.1k|}
buffer.c:mp_cond_init:
  139|  16.1k|{
  140|  16.1k|    mp_assert(cond);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 16.1k, False: 0]
  ------------------
  141|       |
  142|  16.1k|    int ret = 0;
  143|  16.1k|    pthread_condattr_t attr;
  144|  16.1k|    ret = pthread_condattr_init(&attr);
  145|  16.1k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 16.1k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  16.1k|    cond->clk_id = CLOCK_REALTIME;
  149|  16.1k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  16.1k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 16.1k, False: 0]
  ------------------
  151|  16.1k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  16.1k|#endif
  153|       |
  154|  16.1k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  16.1k|    pthread_condattr_destroy(&attr);
  156|  16.1k|    return ret;
  157|  16.1k|}
buffer.c:mp_thread_set_name:
  222|  8.07k|{
  223|  8.07k|#if HAVE_GLIBC_THREAD_NAME
  224|  8.07k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|}
msg.c:mp_mutex_init:
  113|  99.0k|{
  114|  99.0k|#ifndef NDEBUG
  115|  99.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  99.0k|    int ret = 0;
  121|  99.0k|    pthread_mutexattr_t attr;
  122|  99.0k|    ret = pthread_mutexattr_init(&attr);
  123|  99.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 99.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  99.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  99.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  99.0k|    pthread_mutexattr_destroy(&attr);
  129|  99.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 99.0k, False: 0]
  ------------------
  130|  99.0k|    return ret;
  131|  99.0k|}
msg.c:mp_cond_init:
  139|  24.7k|{
  140|  24.7k|    mp_assert(cond);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 24.7k, False: 0]
  ------------------
  141|       |
  142|  24.7k|    int ret = 0;
  143|  24.7k|    pthread_condattr_t attr;
  144|  24.7k|    ret = pthread_condattr_init(&attr);
  145|  24.7k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 24.7k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  24.7k|    cond->clk_id = CLOCK_REALTIME;
  149|  24.7k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  24.7k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 24.7k, False: 0]
  ------------------
  151|  24.7k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  24.7k|#endif
  153|       |
  154|  24.7k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  24.7k|    pthread_condattr_destroy(&attr);
  156|  24.7k|    return ret;
  157|  24.7k|}
msg.c:mp_cond_destroy:
  160|  24.7k|{
  161|  24.7k|    mp_assert(cond);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 24.7k, False: 0]
  ------------------
  162|  24.7k|    return pthread_cond_destroy(&cond->cond);
  163|  24.7k|}
stats.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
demux.c:mp_cond_destroy:
  160|  25.0k|{
  161|  25.0k|    mp_assert(cond);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 25.0k, False: 0]
  ------------------
  162|  25.0k|    return pthread_cond_destroy(&cond->cond);
  163|  25.0k|}
demux.c:mp_cond_signal:
  172|   654k|{
  173|   654k|    mp_assert(cond);
  ------------------
  |  |   41|   654k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 654k, False: 0]
  ------------------
  174|   654k|    return pthread_cond_signal(&cond->cond);
  175|   654k|}
demux.c:mp_thread_set_name:
  222|  24.2k|{
  223|  24.2k|#if HAVE_GLIBC_THREAD_NAME
  224|  24.2k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|}
demux.c:mp_cond_timedwait_until:
  205|   211k|{
  206|   211k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   211k|}
demux.c:mp_cond_timedwait:
  184|   211k|{
  185|   211k|    mp_assert(cond);
  ------------------
  |  |   41|   211k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 211k, False: 0]
  ------------------
  186|       |
  187|   211k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   211k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 211k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   211k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   211k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 40, False: 211k]
  ------------------
  190|     40|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   211k|    struct timespec ts;
  193|   211k|    clock_gettime(cond->clk_id, &ts);
  194|   211k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   211k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   211k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   211k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   211k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   211k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 210k, False: 837]
  ------------------
  197|   210k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   210k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|   210k|        ts.tv_sec++;
  199|   210k|    }
  200|       |
  201|   211k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   211k|}
demux.c:mp_mutex_init:
  113|  25.0k|{
  114|  25.0k|#ifndef NDEBUG
  115|  25.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  25.0k|    int ret = 0;
  121|  25.0k|    pthread_mutexattr_t attr;
  122|  25.0k|    ret = pthread_mutexattr_init(&attr);
  123|  25.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 25.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  25.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  25.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  25.0k|    pthread_mutexattr_destroy(&attr);
  129|  25.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 25.0k, False: 0]
  ------------------
  130|  25.0k|    return ret;
  131|  25.0k|}
demux.c:mp_cond_init:
  139|  25.0k|{
  140|  25.0k|    mp_assert(cond);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 25.0k, False: 0]
  ------------------
  141|       |
  142|  25.0k|    int ret = 0;
  143|  25.0k|    pthread_condattr_t attr;
  144|  25.0k|    ret = pthread_condattr_init(&attr);
  145|  25.0k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 25.0k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  25.0k|    cond->clk_id = CLOCK_REALTIME;
  149|  25.0k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  25.0k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 25.0k, False: 0]
  ------------------
  151|  25.0k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  25.0k|#endif
  153|       |
  154|  25.0k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  25.0k|    pthread_condattr_destroy(&attr);
  156|  25.0k|    return ret;
  157|  25.0k|}
packet_pool.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
f_async_queue.c:mp_mutex_init:
  113|  8.07k|{
  114|  8.07k|#ifndef NDEBUG
  115|  8.07k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  8.07k|    int ret = 0;
  121|  8.07k|    pthread_mutexattr_t attr;
  122|  8.07k|    ret = pthread_mutexattr_init(&attr);
  123|  8.07k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 8.07k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  8.07k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  8.07k|    ret = pthread_mutex_init(mutex, &attr);
  128|  8.07k|    pthread_mutexattr_destroy(&attr);
  129|  8.07k|    mp_assert(!ret);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 8.07k, False: 0]
  ------------------
  130|  8.07k|    return ret;
  131|  8.07k|}
f_decoder_wrapper.c:mp_mutex_init:
  113|  36.2k|{
  114|  36.2k|#ifndef NDEBUG
  115|  36.2k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  36.2k|    int ret = 0;
  121|  36.2k|    pthread_mutexattr_t attr;
  122|  36.2k|    ret = pthread_mutexattr_init(&attr);
  123|  36.2k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 36.2k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  36.2k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  36.2k|    ret = pthread_mutex_init(mutex, &attr);
  128|  36.2k|    pthread_mutexattr_destroy(&attr);
  129|  36.2k|    mp_assert(!ret);
  ------------------
  |  |   41|  36.2k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 36.2k, False: 0]
  ------------------
  130|  36.2k|    return ret;
  131|  36.2k|}
filter.c:mp_mutex_init:
  113|  32.8k|{
  114|  32.8k|#ifndef NDEBUG
  115|  32.8k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.8k|    int ret = 0;
  121|  32.8k|    pthread_mutexattr_t attr;
  122|  32.8k|    ret = pthread_mutexattr_init(&attr);
  123|  32.8k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.8k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.8k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.8k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.8k|    pthread_mutexattr_destroy(&attr);
  129|  32.8k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.8k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.8k, False: 0]
  ------------------
  130|  32.8k|    return ret;
  131|  32.8k|}
input.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
dispatch.c:mp_cond_destroy:
  160|  44.3k|{
  161|  44.3k|    mp_assert(cond);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 44.3k, False: 0]
  ------------------
  162|  44.3k|    return pthread_cond_destroy(&cond->cond);
  163|  44.3k|}
dispatch.c:mp_mutex_init:
  113|  44.3k|{
  114|  44.3k|#ifndef NDEBUG
  115|  44.3k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  44.3k|    int ret = 0;
  121|  44.3k|    pthread_mutexattr_t attr;
  122|  44.3k|    ret = pthread_mutexattr_init(&attr);
  123|  44.3k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 44.3k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  44.3k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  44.3k|    ret = pthread_mutex_init(mutex, &attr);
  128|  44.3k|    pthread_mutexattr_destroy(&attr);
  129|  44.3k|    mp_assert(!ret);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 44.3k, False: 0]
  ------------------
  130|  44.3k|    return ret;
  131|  44.3k|}
dispatch.c:mp_cond_init:
  139|  44.3k|{
  140|  44.3k|    mp_assert(cond);
  ------------------
  |  |   41|  44.3k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 44.3k, False: 0]
  ------------------
  141|       |
  142|  44.3k|    int ret = 0;
  143|  44.3k|    pthread_condattr_t attr;
  144|  44.3k|    ret = pthread_condattr_init(&attr);
  145|  44.3k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 44.3k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  44.3k|    cond->clk_id = CLOCK_REALTIME;
  149|  44.3k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  44.3k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 44.3k, False: 0]
  ------------------
  151|  44.3k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  44.3k|#endif
  153|       |
  154|  44.3k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  44.3k|    pthread_condattr_destroy(&attr);
  156|  44.3k|    return ret;
  157|  44.3k|}
dispatch.c:mp_cond_wait:
  178|   310k|{
  179|   310k|    mp_assert(cond);
  ------------------
  |  |   41|   310k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 310k, False: 0]
  ------------------
  180|   310k|    return pthread_cond_wait(&cond->cond, mutex);
  181|   310k|}
dispatch.c:mp_cond_broadcast:
  166|  2.00M|{
  167|  2.00M|    mp_assert(cond);
  ------------------
  |  |   41|  2.00M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 2.00M, False: 0]
  ------------------
  168|  2.00M|    return pthread_cond_broadcast(&cond->cond);
  169|  2.00M|}
dispatch.c:mp_cond_timedwait_until:
  205|   285k|{
  206|   285k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   285k|}
dispatch.c:mp_cond_timedwait:
  184|   285k|{
  185|   285k|    mp_assert(cond);
  ------------------
  |  |   41|   285k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 285k, False: 0]
  ------------------
  186|       |
  187|   285k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   285k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 285k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   285k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   285k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 745, False: 285k]
  ------------------
  190|    745|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   285k|    struct timespec ts;
  193|   285k|    clock_gettime(cond->clk_id, &ts);
  194|   285k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   285k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   285k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   285k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   285k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   285k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 37.8k, False: 247k]
  ------------------
  197|  37.8k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  37.8k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  37.8k|        ts.tv_sec++;
  199|  37.8k|    }
  200|       |
  201|   285k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   285k|}
rendezvous.c:mp_cond_broadcast:
  166|  19.6k|{
  167|  19.6k|    mp_assert(cond);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 19.6k, False: 0]
  ------------------
  168|  19.6k|    return pthread_cond_broadcast(&cond->cond);
  169|  19.6k|}
rendezvous.c:mp_cond_wait:
  178|  19.6k|{
  179|  19.6k|    mp_assert(cond);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 19.6k, False: 0]
  ------------------
  180|  19.6k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  19.6k|}
thread_pool.c:mp_cond_broadcast:
  166|  24.7k|{
  167|  24.7k|    mp_assert(cond);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 24.7k, False: 0]
  ------------------
  168|  24.7k|    return pthread_cond_broadcast(&cond->cond);
  169|  24.7k|}
thread_pool.c:mp_cond_destroy:
  160|  24.7k|{
  161|  24.7k|    mp_assert(cond);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 24.7k, False: 0]
  ------------------
  162|  24.7k|    return pthread_cond_destroy(&cond->cond);
  163|  24.7k|}
thread_pool.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
thread_pool.c:mp_cond_init:
  139|  24.7k|{
  140|  24.7k|    mp_assert(cond);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 24.7k, False: 0]
  ------------------
  141|       |
  142|  24.7k|    int ret = 0;
  143|  24.7k|    pthread_condattr_t attr;
  144|  24.7k|    ret = pthread_condattr_init(&attr);
  145|  24.7k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 24.7k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  24.7k|    cond->clk_id = CLOCK_REALTIME;
  149|  24.7k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  24.7k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 24.7k, False: 0]
  ------------------
  151|  24.7k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  24.7k|#endif
  153|       |
  154|  24.7k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  24.7k|    pthread_condattr_destroy(&attr);
  156|  24.7k|    return ret;
  157|  24.7k|}
thread_pool.c:mp_thread_set_name:
  222|  24.2k|{
  223|  24.2k|#if HAVE_GLIBC_THREAD_NAME
  224|  24.2k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|}
thread_pool.c:mp_cond_wait:
  178|  24.2k|{
  179|  24.2k|    mp_assert(cond);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 24.2k, False: 0]
  ------------------
  180|  24.2k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  24.2k|}
thread_pool.c:mp_cond_signal:
  172|  24.2k|{
  173|  24.2k|    mp_assert(cond);
  ------------------
  |  |   41|  24.2k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 24.2k, False: 0]
  ------------------
  174|  24.2k|    return pthread_cond_signal(&cond->cond);
  175|  24.2k|}
thread_tools.c:mp_cond_destroy:
  160|   197k|{
  161|   197k|    mp_assert(cond);
  ------------------
  |  |   41|   197k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 197k, False: 0]
  ------------------
  162|   197k|    return pthread_cond_destroy(&cond->cond);
  163|   197k|}
thread_tools.c:mp_cond_signal:
  172|  98.5k|{
  173|  98.5k|    mp_assert(cond);
  ------------------
  |  |   41|  98.5k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 98.5k, False: 0]
  ------------------
  174|  98.5k|    return pthread_cond_signal(&cond->cond);
  175|  98.5k|}
thread_tools.c:mp_mutex_init:
  113|  99.0k|{
  114|  99.0k|#ifndef NDEBUG
  115|  99.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  99.0k|    int ret = 0;
  121|  99.0k|    pthread_mutexattr_t attr;
  122|  99.0k|    ret = pthread_mutexattr_init(&attr);
  123|  99.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 99.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  99.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  99.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  99.0k|    pthread_mutexattr_destroy(&attr);
  129|  99.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 99.0k, False: 0]
  ------------------
  130|  99.0k|    return ret;
  131|  99.0k|}
thread_tools.c:mp_cond_init:
  139|  99.0k|{
  140|  99.0k|    mp_assert(cond);
  ------------------
  |  |   41|  99.0k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 99.0k, False: 0]
  ------------------
  141|       |
  142|  99.0k|    int ret = 0;
  143|  99.0k|    pthread_condattr_t attr;
  144|  99.0k|    ret = pthread_condattr_init(&attr);
  145|  99.0k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 99.0k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  99.0k|    cond->clk_id = CLOCK_REALTIME;
  149|  99.0k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  99.0k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 99.0k, False: 0]
  ------------------
  151|  99.0k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  99.0k|#endif
  153|       |
  154|  99.0k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  99.0k|    pthread_condattr_destroy(&attr);
  156|  99.0k|    return ret;
  157|  99.0k|}
thread_tools.c:mp_cond_broadcast:
  166|  74.2k|{
  167|  74.2k|    mp_assert(cond);
  ------------------
  |  |   41|  74.2k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 74.2k, False: 0]
  ------------------
  168|  74.2k|    return pthread_cond_broadcast(&cond->cond);
  169|  74.2k|}
m_config_core.c:mp_mutex_init:
  113|  24.7k|{
  114|  24.7k|#ifndef NDEBUG
  115|  24.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  24.7k|    int ret = 0;
  121|  24.7k|    pthread_mutexattr_t attr;
  122|  24.7k|    ret = pthread_mutexattr_init(&attr);
  123|  24.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 24.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  24.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  24.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  24.7k|    pthread_mutexattr_destroy(&attr);
  129|  24.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 24.7k, False: 0]
  ------------------
  130|  24.7k|    return ret;
  131|  24.7k|}
vd_lavc.c:mp_mutex_init:
  113|  19.0k|{
  114|  19.0k|#ifndef NDEBUG
  115|  19.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  19.0k|    int ret = 0;
  121|  19.0k|    pthread_mutexattr_t attr;
  122|  19.0k|    ret = pthread_mutexattr_init(&attr);
  123|  19.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 19.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  19.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  19.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  19.0k|    pthread_mutexattr_destroy(&attr);
  129|  19.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  19.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 19.0k, False: 0]
  ------------------
  130|  19.0k|    return ret;
  131|  19.0k|}

mp_sleep_ns:
   31|   120k|{
   32|   120k|    if (ns < 0)
  ------------------
  |  Branch (32:9): [True: 120k, False: 0]
  ------------------
   33|   120k|        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|  35.2k|{
   42|  35.2k|}
mp_raw_time_ns:
   45|  31.0M|{
   46|  31.0M|    struct timespec tp = {0};
   47|  31.0M|    clock_gettime(clk_id, &tp);
   48|       |    return MP_TIME_S_TO_NS(tp.tv_sec) + tp.tv_nsec;
  ------------------
  |  |   71|  31.0M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   49|  31.0M|}
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|  24.7k|{
   40|  24.7k|    mp_exec_once(&timer_init_once, do_timer_init);
  ------------------
  |  |  209|  24.7k|#define mp_exec_once pthread_once
  ------------------
   41|  24.7k|}
mp_time_ns:
   44|  31.0M|{
   45|  31.0M|    return mp_time_ns_from_raw_time(mp_raw_time_ns());
   46|  31.0M|}
mp_time_ns_from_raw_time:
   49|  31.0M|{
   50|  31.0M|    return raw_time - raw_time_offset;
   51|  31.0M|}
mp_time_sec:
   54|  1.99M|{
   55|  1.99M|    return mp_time_ns() / 1e9;
   56|  1.99M|}
mp_time_ns_add:
   59|  2.14M|{
   60|  2.14M|    mp_assert(time_ns > 0); // mp_time_ns() returns strictly positive values
  ------------------
  |  |   41|  2.14M|#define mp_assert assert
  ------------------
  |  Branch (60:5): [True: 2.14M, False: 18.4E]
  ------------------
   61|  2.14M|    double t = MPCLAMP(timeout_sec * 1e9, -0x1p63, 0x1p63);
  ------------------
  |  |   46|  2.14M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 2.14M]
  |  |  |  Branch (46:56): [True: 281k, False: 1.86M]
  |  |  ------------------
  ------------------
   62|  2.14M|    int64_t ti = t == 0x1p63 ? INT64_MAX : (int64_t)t;
  ------------------
  |  Branch (62:18): [True: 281k, False: 1.86M]
  ------------------
   63|  2.14M|    if (ti > INT64_MAX - time_ns)
  ------------------
  |  Branch (63:9): [True: 281k, False: 1.86M]
  ------------------
   64|   281k|        return INT64_MAX;
   65|  1.86M|    if (ti <= -time_ns)
  ------------------
  |  Branch (65:9): [True: 0, False: 1.86M]
  ------------------
   66|      0|        return 1;
   67|  1.86M|    return time_ns + ti;
   68|  1.86M|}
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|  16.1k|{
  175|  16.1k|    struct MPOpts *opts = mpctx->opts;
  176|  16.1k|    float gain = MPMAX(opts->softvol_volume / 100.0, 0);
  ------------------
  |  |   44|  16.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 16.1k, False: 0]
  |  |  ------------------
  ------------------
  177|  16.1k|    gain = pow(gain, 3);
  178|  16.1k|    gain *= compute_replaygain(mpctx);
  179|  16.1k|    gain *= db_gain(opts->softvol_gain);
  180|  16.1k|    if (opts->softvol_mute)
  ------------------
  |  Branch (180:9): [True: 0, False: 16.1k]
  ------------------
  181|      0|        gain = 0.0;
  182|  16.1k|    return gain;
  183|  16.1k|}
audio_update_volume:
  187|  40.8k|{
  188|  40.8k|    struct ao_chain *ao_c = mpctx->ao_chain;
  189|  40.8k|    if (!ao_c || !ao_c->ao)
  ------------------
  |  Branch (189:9): [True: 24.7k, False: 16.1k]
  |  Branch (189:18): [True: 0, False: 16.1k]
  ------------------
  190|  24.7k|        return;
  191|       |
  192|  16.1k|    float gain = audio_get_gain(mpctx);
  193|  16.1k|    ao_set_gain(ao_c->ao, gain);
  194|  16.1k|}
update_playback_speed:
  198|  24.2k|{
  199|  24.2k|    mpctx->audio_speed = mpctx->opts->playback_speed * mpctx->speed_factor_a;
  200|  24.2k|    mpctx->video_speed = mpctx->opts->playback_speed * mpctx->speed_factor_v;
  201|       |
  202|  24.2k|    update_speed_filters(mpctx);
  203|  24.2k|}
reset_audio_state:
  231|  38.8k|{
  232|  38.8k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (232:9): [True: 14.1k, False: 24.7k]
  ------------------
  233|  14.1k|        ao_chain_reset_state(mpctx->ao_chain);
  234|  14.1k|        struct track *t = mpctx->ao_chain->track;
  235|  14.1k|        if (t && t->dec)
  ------------------
  |  Branch (235:13): [True: 14.1k, False: 0]
  |  Branch (235:18): [True: 14.1k, False: 0]
  ------------------
  236|  14.1k|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  237|  14.1k|    }
  238|  38.8k|    mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (238:27): [True: 14.1k, False: 24.7k]
  ------------------
  239|  38.8k|    mpctx->delay = 0;
  240|  38.8k|}
uninit_audio_out:
  243|  98.2k|{
  244|  98.2k|    struct ao_chain *ao_c = mpctx->ao_chain;
  245|  98.2k|    if (ao_c) {
  ------------------
  |  Branch (245:9): [True: 8.07k, False: 90.1k]
  ------------------
  246|  8.07k|        ao_c->ao_queue = NULL;
  247|  8.07k|        TA_FREEP(&ao_c->queue_filter);
  ------------------
  |  |   81|  8.07k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  8.07k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 8.07k]
  |  |  ------------------
  ------------------
  248|  8.07k|        ao_c->ao = NULL;
  249|  8.07k|    }
  250|  98.2k|    if (mpctx->ao) {
  ------------------
  |  Branch (250:9): [True: 8.07k, False: 90.1k]
  ------------------
  251|       |        // Note: with gapless_audio, stop_play is not correctly set
  252|  8.07k|        if ((mpctx->opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) &&
  ------------------
  |  Branch (252:14): [True: 8.07k, False: 0]
  |  Branch (252:44): [True: 0, False: 0]
  ------------------
  253|  8.07k|            ao_is_playing(mpctx->ao) && !get_internal_paused(mpctx))
  ------------------
  |  Branch (253:13): [True: 1.49k, False: 6.57k]
  |  Branch (253:41): [True: 1.49k, False: 0]
  ------------------
  254|  1.49k|        {
  255|  1.49k|            MP_VERBOSE(mpctx, "draining left over audio\n");
  ------------------
  |  |   92|  1.49k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.49k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  256|  1.49k|            ao_drain(mpctx->ao);
  257|  1.49k|        }
  258|  8.07k|        ao_uninit(mpctx->ao);
  259|       |
  260|  8.07k|        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  261|  8.07k|    }
  262|  98.2k|    mpctx->ao = NULL;
  263|       |    TA_FREEP(&mpctx->ao_filter_fmt);
  ------------------
  |  |   81|  98.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  98.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 98.2k]
  |  |  ------------------
  ------------------
  264|  98.2k|}
uninit_audio_chain:
  289|  30.4k|{
  290|  30.4k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (290:9): [True: 16.5k, False: 13.8k]
  ------------------
  291|  16.5k|        ao_chain_uninit(mpctx->ao_chain);
  292|  16.5k|        mpctx->ao_chain = NULL;
  293|       |
  294|  16.5k|        mpctx->audio_status = STATUS_EOF;
  295|       |
  296|       |        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  297|  16.5k|    }
  298|  30.4k|}
init_audio_decoder:
  522|  16.5k|{
  523|  16.5k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  16.5k|#define mp_assert assert
  ------------------
  |  Branch (523:5): [True: 16.5k, False: 0]
  ------------------
  524|  16.5k|    if (!track->stream)
  ------------------
  |  Branch (524:9): [True: 0, False: 16.5k]
  ------------------
  525|      0|        goto init_error;
  526|       |
  527|  16.5k|    track->dec = mp_decoder_wrapper_create(mpctx->filter_root, track->stream);
  528|  16.5k|    if (!track->dec)
  ------------------
  |  Branch (528:9): [True: 0, False: 16.5k]
  ------------------
  529|      0|        goto init_error;
  530|       |
  531|  16.5k|    if (track->ao_c)
  ------------------
  |  Branch (531:9): [True: 16.5k, False: 0]
  ------------------
  532|  16.5k|        mp_decoder_wrapper_set_spdif_flag(track->dec, true);
  533|       |
  534|  16.5k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (534:9): [True: 2.84k, False: 13.7k]
  ------------------
  535|  2.84k|        goto init_error;
  536|       |
  537|  13.7k|    return 1;
  538|       |
  539|  2.84k|init_error:
  540|  2.84k|    if (track->sink)
  ------------------
  |  Branch (540:9): [True: 0, False: 2.84k]
  ------------------
  541|      0|        mp_pin_disconnect(track->sink);
  542|  2.84k|    track->sink = NULL;
  543|       |    track->dec_failed = true;
  544|  2.84k|    return 0;
  545|  16.5k|}
reinit_audio_chain:
  548|  27.1k|{
  549|  27.1k|    struct track *track = NULL;
  550|  27.1k|    track = mpctx->current_track[0][STREAM_AUDIO];
  551|  27.1k|    if (!track || !track->stream) {
  ------------------
  |  Branch (551:9): [True: 10.5k, False: 16.5k]
  |  Branch (551:19): [True: 0, False: 16.5k]
  ------------------
  552|  10.5k|        if (!mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (552:13): [True: 10.5k, False: 0]
  ------------------
  553|  10.5k|            uninit_audio_out(mpctx);
  554|  10.5k|        error_on_track(mpctx, track);
  555|  10.5k|        return;
  556|  10.5k|    }
  557|  16.5k|    reinit_audio_chain_src(mpctx, track);
  558|  16.5k|}
reinit_audio_chain_src:
  603|  16.5k|{
  604|  16.5k|    mp_assert(!mpctx->ao_chain);
  ------------------
  |  |   41|  16.5k|#define mp_assert assert
  ------------------
  |  Branch (604:5): [True: 16.5k, False: 0]
  ------------------
  605|       |
  606|  16.5k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  607|       |
  608|  16.5k|    struct ao_chain *ao_c = talloc_zero(NULL, struct ao_chain);
  ------------------
  |  |   27|  16.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  16.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  16.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|  16.5k|    mpctx->ao_chain = ao_c;
  610|  16.5k|    ao_c->mpctx = mpctx;
  611|  16.5k|    ao_c->log = mpctx->log;
  612|  16.5k|    ao_c->filter =
  613|  16.5k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_AUDIO);
  614|  16.5k|    ao_c->spdif_passthrough = true;
  615|  16.5k|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  16.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  616|  16.5k|    ao_c->delay = mpctx->opts->audio_delay;
  617|       |
  618|  16.5k|    ao_c->ao_filter = mp_filter_create(mpctx->filter_root, &ao_filter);
  619|  16.5k|    if (!ao_c->filter || !ao_c->ao_filter)
  ------------------
  |  Branch (619:9): [True: 0, False: 16.5k]
  |  Branch (619:26): [True: 0, False: 16.5k]
  ------------------
  620|      0|        goto init_error;
  621|  16.5k|    ao_c->ao_filter->priv = ao_c;
  622|       |
  623|  16.5k|    mp_filter_add_pin(ao_c->ao_filter, MP_PIN_IN, "in");
  624|  16.5k|    mp_pin_connect(ao_c->ao_filter->pins[0], ao_c->filter->f->pins[1]);
  625|       |
  626|  16.5k|    if (track) {
  ------------------
  |  Branch (626:9): [True: 16.5k, False: 0]
  ------------------
  627|  16.5k|        ao_c->track = track;
  628|  16.5k|        track->ao_c = ao_c;
  629|  16.5k|        if (!ao_chain_init_decoder(mpctx, ao_c))
  ------------------
  |  Branch (629:13): [True: 2.84k, False: 13.7k]
  ------------------
  630|  2.84k|            goto init_error;
  631|  16.5k|    }
  632|       |
  633|  13.7k|    reset_audio_state(mpctx);
  634|       |
  635|  13.7k|    if (recreate_audio_filters(mpctx) < 0)
  ------------------
  |  Branch (635:9): [True: 0, False: 13.7k]
  ------------------
  636|      0|        goto init_error;
  637|       |
  638|  13.7k|    if (mpctx->ao)
  ------------------
  |  Branch (638:9): [True: 0, False: 13.7k]
  ------------------
  639|      0|        audio_update_volume(mpctx);
  640|       |
  641|  13.7k|    mp_wakeup_core(mpctx);
  642|  13.7k|    return;
  643|       |
  644|  2.84k|init_error:
  645|  2.84k|    uninit_audio_chain(mpctx);
  646|  2.84k|    uninit_audio_out(mpctx);
  647|  2.84k|    error_on_track(mpctx, track);
  648|  2.84k|}
written_audio_pts:
  653|  88.9k|{
  654|  88.9k|    return mpctx->ao_chain ? mpctx->ao_chain->last_out_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  11.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:12): [True: 77.4k, False: 11.5k]
  ------------------
  655|  88.9k|}
playing_audio_pts:
  660|  78.6k|{
  661|  78.6k|    double pts = written_audio_pts(mpctx);
  662|  78.6k|    if (pts == MP_NOPTS_VALUE || !mpctx->ao)
  ------------------
  |  |   39|   157k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (662:9): [True: 24.7k, False: 53.8k]
  |  Branch (662:34): [True: 0, False: 53.8k]
  ------------------
  663|  24.7k|        return pts;
  664|  53.8k|    return pts - mpctx->audio_speed * ao_get_delay(mpctx->ao);
  665|  78.6k|}
reload_audio_output:
  787|  24.7k|{
  788|  24.7k|    if (!mpctx->ao)
  ------------------
  |  Branch (788:9): [True: 24.7k, False: 0]
  ------------------
  789|  24.7k|        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|  80.7k|{
  855|  80.7k|    struct ao_chain *ao_c = mpctx->ao_chain;
  856|  80.7k|    if (!ao_c || !ao_c->ao || mpctx->audio_status != STATUS_READY)
  ------------------
  |  Branch (856:9): [True: 0, False: 80.7k]
  |  Branch (856:18): [True: 31.2k, False: 49.5k]
  |  Branch (856:31): [True: 31.7k, False: 17.8k]
  ------------------
  857|  62.9k|        return;
  858|  17.8k|    double pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  17.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  859|  17.8k|    if (!get_sync_pts(mpctx, &pts))
  ------------------
  |  Branch (859:9): [True: 0, False: 17.8k]
  ------------------
  860|      0|        return;
  861|  17.8k|    double apts = playing_audio_pts(mpctx);
  862|  17.8k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (862:9): [True: 12.3k, False: 5.41k]
  ------------------
  863|  12.3k|        double speed = mpctx->opts->playback_speed;
  864|  12.3k|        if (!ao_c->delaying_audio_start && pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  14.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:13): [True: 1.99k, False: 10.4k]
  |  Branch (864:44): [True: 1.99k, False: 0]
  ------------------
  865|  1.99k|            apts != MP_NOPTS_VALUE && pts < apts)
  ------------------
  |  |   39|  14.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (865:13): [True: 1.82k, False: 165]
  |  Branch (865:39): [True: 779, False: 1.04k]
  ------------------
  866|    779|        {
  867|    779|            MP_VERBOSE(mpctx, "delaying audio start %f vs. %f, diff=%f\n",
  ------------------
  |  |   92|    779|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    779|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  868|    779|                       apts, pts, (apts - pts) / speed);
  869|    779|            ao_c->delaying_audio_start = true;
  870|    779|            ao_c->delayed_start_gap = apts - pts;
  871|    779|            mpctx->delay += apts - pts;
  872|    779|            ao_c->delayed_start_speed = 0;
  873|    779|        }
  874|  12.3k|        if (ao_c->delaying_audio_start) {
  ------------------
  |  Branch (874:13): [True: 11.1k, False: 1.21k]
  ------------------
  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|  11.1k|            int64_t now = mp_time_ns();
  880|  11.1k|            double passed = MP_TIME_NS_TO_S(now - ao_c->delayed_start_last);
  ------------------
  |  |   76|  11.1k|#define MP_TIME_NS_TO_S(ns) ((ns) / (double)1000000000)
  ------------------
  881|  11.1k|            ao_c->delayed_start_gap -= passed * ao_c->delayed_start_speed;
  882|  11.1k|            ao_c->delayed_start_last = now;
  883|  11.1k|            ao_c->delayed_start_speed = get_internal_paused(mpctx) ? 0 : speed;
  ------------------
  |  Branch (883:41): [True: 0, False: 11.1k]
  ------------------
  884|  11.1k|            if (ao_c->delayed_start_gap > 0) {
  ------------------
  |  Branch (884:17): [True: 11.0k, False: 167]
  ------------------
  885|  11.0k|                if (ao_c->delayed_start_speed > 0)
  ------------------
  |  Branch (885:21): [True: 11.0k, False: 0]
  ------------------
  886|  11.0k|                    mp_set_timeout(mpctx, ao_c->delayed_start_gap / speed);
  887|  11.0k|                return;
  888|  11.0k|            }
  889|  11.1k|        }
  890|  12.3k|    }
  891|       |
  892|  6.79k|    MP_VERBOSE(mpctx, "starting audio playback\n");
  ------------------
  |  |   92|  6.79k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.79k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  893|  6.79k|    ao_c->delaying_audio_start = false;
  894|  6.79k|    ao_start(ao_c->ao);
  895|  6.79k|    mpctx->audio_status = STATUS_PLAYING;
  896|  6.79k|    if (ao_c->out_eof) {
  ------------------
  |  Branch (896:9): [True: 3.30k, False: 3.48k]
  ------------------
  897|  3.30k|        mpctx->audio_status = STATUS_DRAINING;
  898|  3.30k|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|  3.30k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.30k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  899|  3.30k|    }
  900|       |    ao_c->underrun = false;
  901|  6.79k|    mp_wakeup_core(mpctx);
  902|  6.79k|}
fill_audio_out_buffers:
  905|   250k|{
  906|   250k|    struct MPOpts *opts = mpctx->opts;
  907|       |
  908|   250k|    if (mpctx->ao && ao_query_and_reset_events(mpctx->ao, AO_EVENT_RELOAD))
  ------------------
  |  Branch (908:9): [True: 57.9k, False: 192k]
  |  Branch (908:22): [True: 0, False: 57.9k]
  ------------------
  909|      0|        reload_audio_output(mpctx);
  910|       |
  911|   250k|    update_throttle(mpctx);
  912|       |
  913|   250k|    struct ao_chain *ao_c = mpctx->ao_chain;
  914|   250k|    if (!ao_c)
  ------------------
  |  Branch (914:9): [True: 113k, False: 136k]
  ------------------
  915|   113k|        return;
  916|       |
  917|   136k|    if (ao_c->filter->failed_output_conversion) {
  ------------------
  |  Branch (917:9): [True: 0, False: 136k]
  ------------------
  918|      0|        error_on_track(mpctx, ao_c->track);
  919|      0|        return;
  920|      0|    }
  921|       |
  922|   136k|    if (ao_c->filter->ao_needs_update) {
  ------------------
  |  Branch (922:9): [True: 8.55k, False: 128k]
  ------------------
  923|  8.55k|        if (reinit_audio_filters_and_output(mpctx) < 0)
  ------------------
  |  Branch (923:13): [True: 4, False: 8.54k]
  ------------------
  924|      4|            return;
  925|  8.55k|    }
  926|       |
  927|   136k|    if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
  ------------------
  |  Branch (927:9): [True: 98.3k, False: 38.6k]
  |  Branch (927:28): [True: 98.3k, False: 0]
  |  Branch (927:43): [True: 98.3k, False: 0]
  ------------------
  928|  98.3k|        mp_decoder_wrapper_get_pts_reset(ao_c->track->dec))
  ------------------
  |  Branch (928:9): [True: 374, False: 97.9k]
  ------------------
  929|    374|    {
  930|    374|        MP_WARN(mpctx, "Reset playback due to audio timestamp reset.\n");
  ------------------
  |  |   90|    374|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    374|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  931|    374|        reset_playback_state(mpctx);
  932|    374|        mp_wakeup_core(mpctx);
  933|    374|    }
  934|       |
  935|   136k|    if (mpctx->audio_status == STATUS_SYNCING) {
  ------------------
  |  Branch (935:9): [True: 66.2k, False: 70.7k]
  ------------------
  936|  66.2k|        double pts;
  937|  66.2k|        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|  66.2k|        if (mpctx->ao && ao_is_playing(mpctx->ao) &&
  ------------------
  |  Branch (944:13): [True: 27.0k, False: 39.2k]
  |  Branch (944:26): [True: 236, False: 26.7k]
  ------------------
  945|    236|            mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (945:13): [True: 127, False: 109]
  ------------------
  946|    127|            MP_VERBOSE(mpctx, "blocked, waiting for old audio to play\n");
  ------------------
  |  |   92|    127|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    127|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  947|    127|            ok = false;
  948|    127|        }
  949|       |
  950|  66.2k|        if (ao_c->start_pts_known != ok || ao_c->start_pts != pts) {
  ------------------
  |  Branch (950:13): [True: 8.09k, False: 58.1k]
  |  Branch (950:44): [True: 3, False: 58.1k]
  ------------------
  951|  8.09k|            ao_c->start_pts_known = ok;
  952|  8.09k|            ao_c->start_pts = pts;
  953|  8.09k|            mp_filter_wakeup(ao_c->ao_filter);
  954|  8.09k|        }
  955|       |
  956|  66.2k|        if (ao_c->ao && mp_async_queue_is_full(ao_c->ao_queue)) {
  ------------------
  |  Branch (956:13): [True: 27.0k, False: 39.2k]
  |  Branch (956:25): [True: 3.15k, False: 23.8k]
  ------------------
  957|  3.15k|            mpctx->audio_status = STATUS_READY;
  958|  3.15k|            mp_wakeup_core(mpctx);
  959|  3.15k|            MP_VERBOSE(mpctx, "audio ready\n");
  ------------------
  |  |   92|  3.15k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.15k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  960|  63.0k|        } else if (ao_c->out_eof) {
  ------------------
  |  Branch (960:20): [True: 3.30k, False: 59.7k]
  ------------------
  961|       |            // Force playback start early.
  962|  3.30k|            mpctx->audio_status = STATUS_READY;
  963|  3.30k|            mp_wakeup_core(mpctx);
  964|  3.30k|            MP_VERBOSE(mpctx, "audio ready (and EOF)\n");
  ------------------
  |  |   92|  3.30k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.30k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  965|  3.30k|        }
  966|  66.2k|    }
  967|       |
  968|   136k|    if (ao_c->ao && !ao_is_playing(ao_c->ao) && !ao_c->underrun &&
  ------------------
  |  Branch (968:9): [True: 64.6k, False: 72.3k]
  |  Branch (968:21): [True: 39.2k, False: 25.4k]
  |  Branch (968:49): [True: 39.2k, False: 0]
  ------------------
  969|  39.2k|        (mpctx->audio_status == STATUS_PLAYING ||
  ------------------
  |  Branch (969:10): [True: 1.46k, False: 37.7k]
  ------------------
  970|  37.7k|         mpctx->audio_status == STATUS_DRAINING))
  ------------------
  |  Branch (970:10): [True: 764, False: 36.9k]
  ------------------
  971|  2.22k|    {
  972|       |        // Should be playing, but somehow isn't.
  973|       |
  974|  2.22k|        if (ao_c->out_eof && !mp_async_queue_get_frames(ao_c->ao_queue)) {
  ------------------
  |  Branch (974:13): [True: 2.22k, False: 0]
  |  Branch (974:30): [True: 2.22k, False: 0]
  ------------------
  975|  2.22k|            MP_VERBOSE(mpctx, "AO signaled EOF (while in state %s)\n",
  ------------------
  |  |   92|  2.22k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.22k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  976|  2.22k|                       mp_status_str(mpctx->audio_status));
  977|  2.22k|            mpctx->audio_status = STATUS_EOF;
  978|  2.22k|            mp_wakeup_core(mpctx);
  979|       |            // stops untimed AOs, stops pull AOs from streaming silence
  980|  2.22k|            ao_reset(ao_c->ao);
  981|  2.22k|        } 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.22k|    }
  999|       |
 1000|   136k|    if (mpctx->audio_status == STATUS_PLAYING && ao_c->out_eof) {
  ------------------
  |  Branch (1000:9): [True: 22.6k, False: 114k]
  |  Branch (1000:50): [True: 1.78k, False: 20.8k]
  ------------------
 1001|  1.78k|        mpctx->audio_status = STATUS_DRAINING;
 1002|  1.78k|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|  1.78k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.78k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1003|  1.78k|        mp_wakeup_core(mpctx);
 1004|  1.78k|    }
 1005|       |
 1006|   136k|    if (mpctx->audio_status == STATUS_DRAINING) {
  ------------------
  |  Branch (1006:9): [True: 11.4k, False: 125k]
  ------------------
 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|  11.4k|        if (!ao_c->ao || (!ao_is_playing(ao_c->ao) || opts->gapless_audio))
  ------------------
  |  Branch (1009:13): [True: 7.09k, False: 4.32k]
  |  Branch (1009:27): [True: 81, False: 4.24k]
  |  Branch (1009:55): [True: 4.24k, False: 0]
  ------------------
 1010|  11.4k|        {
 1011|  11.4k|            MP_VERBOSE(mpctx, "audio EOF reached\n");
  ------------------
  |  |   92|  11.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1012|  11.4k|            mpctx->audio_status = STATUS_EOF;
 1013|  11.4k|            mp_wakeup_core(mpctx);
 1014|  11.4k|        }
 1015|  11.4k|    }
 1016|       |
 1017|   136k|    if (mpctx->restart_complete)
  ------------------
  |  Branch (1017:9): [True: 68.4k, False: 68.5k]
  ------------------
 1018|  68.4k|        audio_start_ao(mpctx); // in case it got delayed
 1019|   136k|}
clear_audio_output_buffers:
 1023|  5.89k|{
 1024|  5.89k|    if (mpctx->ao)
  ------------------
  |  Branch (1024:9): [True: 89, False: 5.80k]
  ------------------
 1025|     89|        ao_reset(mpctx->ao);
 1026|  5.89k|}
audio.c:recreate_audio_filters:
   89|  13.7k|{
   90|  13.7k|    struct ao_chain *ao_c = mpctx->ao_chain;
   91|  13.7k|    mp_assert(ao_c);
  ------------------
  |  |   41|  13.7k|#define mp_assert assert
  ------------------
  |  Branch (91:5): [True: 13.7k, False: 0]
  ------------------
   92|       |
   93|  13.7k|    if (!mp_output_chain_update_filters(ao_c->filter, mpctx->opts->af_settings))
  ------------------
  |  Branch (93:9): [True: 0, False: 13.7k]
  ------------------
   94|      0|        goto fail;
   95|       |
   96|  13.7k|    update_speed_filters(mpctx);
   97|       |
   98|  13.7k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
   99|       |
  100|  13.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|  13.7k|}
audio.c:compute_replaygain:
  133|  16.1k|{
  134|  16.1k|    struct MPOpts *opts = mpctx->opts;
  135|       |
  136|  16.1k|    float rgain = 1.0;
  137|       |
  138|  16.1k|    struct replaygain_data *rg = NULL;
  139|  16.1k|    struct track *track = mpctx->current_track[0][STREAM_AUDIO];
  140|  16.1k|    if (track)
  ------------------
  |  Branch (140:9): [True: 16.1k, False: 0]
  ------------------
  141|  16.1k|        rg = track->stream->codec->replaygain_data;
  142|  16.1k|    if (opts->rgain_mode && rg) {
  ------------------
  |  Branch (142:9): [True: 0, False: 16.1k]
  |  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|  16.1k|    } else if (opts->rgain_fallback) {
  ------------------
  |  Branch (165:16): [True: 0, False: 16.1k]
  ------------------
  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|  16.1k|    return rgain;
  171|  16.1k|}
audio.c:db_gain:
  128|  16.1k|{
  129|  16.1k|    return pow(10.0, db/20.0);
  130|  16.1k|}
audio.c:update_speed_filters:
   52|  37.9k|{
   53|  37.9k|    struct ao_chain *ao_c = mpctx->ao_chain;
   54|  37.9k|    if (!ao_c)
  ------------------
  |  Branch (54:9): [True: 24.2k, False: 13.7k]
  ------------------
   55|  24.2k|        return;
   56|       |
   57|  13.7k|    double pitch = mpctx->opts->playback_pitch;
   58|  13.7k|    double speed = mpctx->opts->playback_speed;
   59|  13.7k|    double resample = mpctx->speed_factor_a;
   60|  13.7k|    double drop = 1.0;
   61|       |
   62|  13.7k|    if (!mpctx->opts->pitch_correction) {
  ------------------
  |  Branch (62:9): [True: 0, False: 13.7k]
  ------------------
   63|      0|        resample *= speed;
   64|      0|        speed = 1.0;
   65|      0|    }
   66|       |
   67|  13.7k|    int video_sync = mpctx->display_sync_active ?
  ------------------
  |  Branch (67:22): [True: 0, False: 13.7k]
  ------------------
   68|  13.7k|        mpctx->video_out->opts->video_sync : VS_NONE;
   69|  13.7k|    switch (video_sync) {
   70|      0|        case VS_DISP_ADROP:
  ------------------
  |  Branch (70:9): [True: 0, False: 13.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: 13.7k]
  ------------------
   76|      0|            speed = mpctx->audio_speed / pitch;
   77|      0|            resample = pitch;
   78|      0|            break;
   79|  13.7k|        default:
  ------------------
  |  Branch (79:9): [True: 13.7k, False: 0]
  ------------------
   80|  13.7k|            resample *= pitch;
   81|  13.7k|            speed /= pitch;
   82|  13.7k|            break;
   83|  13.7k|    }
   84|       |
   85|  13.7k|    mp_output_chain_set_audio_speed(ao_c->filter, speed, resample, drop);
   86|  13.7k|}
audio.c:ao_chain_reset_state:
  220|  14.1k|{
  221|  14.1k|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  14.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  222|  14.1k|    ao_c->out_eof = false;
  223|  14.1k|    ao_c->start_pts_known = false;
  224|  14.1k|    ao_c->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  14.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  225|  14.1k|    ao_c->untimed_throttle = false;
  226|  14.1k|    ao_c->underrun = false;
  227|       |    ao_c->delaying_audio_start = false;
  228|  14.1k|}
audio.c:ao_chain_uninit:
  267|  16.5k|{
  268|  16.5k|    struct track *track = ao_c->track;
  269|  16.5k|    if (track) {
  ------------------
  |  Branch (269:9): [True: 16.5k, False: 0]
  ------------------
  270|  16.5k|        mp_assert(track->ao_c == ao_c);
  ------------------
  |  |   41|  16.5k|#define mp_assert assert
  ------------------
  |  Branch (270:9): [True: 16.5k, False: 0]
  ------------------
  271|  16.5k|        track->ao_c = NULL;
  272|  16.5k|        if (ao_c->dec_src)
  ------------------
  |  Branch (272:13): [True: 13.7k, False: 2.84k]
  ------------------
  273|  16.5k|            mp_assert(track->dec->f->pins[0] == ao_c->dec_src);
  ------------------
  |  |   41|  16.5k|#define mp_assert assert
  ------------------
  |  Branch (273:13): [True: 13.7k, False: 0]
  ------------------
  274|  16.5k|        if (track->dec) {
  ------------------
  |  Branch (274:13): [True: 16.5k, False: 0]
  ------------------
  275|  16.5k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  276|  16.5k|            track->dec = NULL;
  277|  16.5k|        }
  278|  16.5k|    }
  279|       |
  280|  16.5k|    if (ao_c->filter_src)
  ------------------
  |  Branch (280:9): [True: 0, False: 16.5k]
  ------------------
  281|      0|        mp_pin_disconnect(ao_c->filter_src);
  282|       |
  283|  16.5k|    talloc_free(ao_c->filter->f);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  284|  16.5k|    talloc_free(ao_c->ao_filter);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  285|  16.5k|    talloc_free(ao_c);
  ------------------
  |  |   47|  16.5k|#define talloc_free                     ta_free
  ------------------
  286|  16.5k|}
audio.c:ao_chain_init_decoder:
  567|  16.5k|{
  568|  16.5k|    struct track *track = ao_c->track;
  569|  16.5k|    if (!init_audio_decoder(mpctx, track))
  ------------------
  |  Branch (569:9): [True: 2.84k, False: 13.7k]
  ------------------
  570|  2.84k|        return false;
  571|  13.7k|    ao_c->dec_src = track->dec->f->pins[0];
  572|  13.7k|    mp_pin_connect(ao_c->filter->f->pins[0], ao_c->dec_src);
  573|       |    return true;
  574|  16.5k|}
audio.c:ao_process:
  684|   911k|{
  685|   911k|    struct ao_chain *ao_c = f->priv;
  686|   911k|    struct MPContext *mpctx = ao_c->mpctx;
  687|       |
  688|       |    // Once the chain reached EOF nothing is read from it again.
  689|   911k|    if (ao_c->out_eof)
  ------------------
  |  Branch (689:9): [True: 13.7k, False: 898k]
  ------------------
  690|  13.7k|        return;
  691|       |
  692|   898k|    if (!ao_c->queue_filter) {
  ------------------
  |  Branch (692:9): [True: 20.8k, False: 877k]
  ------------------
  693|       |        // This will eventually lead to the creation of the AO + queue, due
  694|       |        // to how f_output_chain and AO management works.
  695|  20.8k|        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|  20.8k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  699|  20.8k|        if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (699:13): [True: 7.09k, False: 13.7k]
  ------------------
  700|  7.09k|            MP_VERBOSE(mpctx, "got EOF with no data before it\n");
  ------------------
  |  |   92|  7.09k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  7.09k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  701|  7.09k|            ao_c->out_eof = true;
  702|  7.09k|            mpctx->audio_status = STATUS_DRAINING;
  703|  7.09k|            mp_wakeup_core(mpctx);
  704|  13.7k|        } else if (frame.type) {
  ------------------
  |  Branch (704:20): [True: 0, False: 13.7k]
  ------------------
  705|      0|            mp_pin_out_unread(f->ppins[0], frame);
  706|      0|        }
  707|  20.8k|        return;
  708|  20.8k|    }
  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|   877k|    if (mpctx->audio_status != STATUS_PLAYING &&
  ------------------
  |  Branch (713:9): [True: 195k, False: 681k]
  ------------------
  714|   195k|        mp_async_queue_is_full(ao_c->ao_queue))
  ------------------
  |  Branch (714:9): [True: 3.16k, False: 192k]
  ------------------
  715|  3.16k|        mp_wakeup_core(mpctx);
  716|       |
  717|   877k|    if (mpctx->audio_status == STATUS_SYNCING && !ao_c->start_pts_known)
  ------------------
  |  Branch (717:9): [True: 193k, False: 683k]
  |  Branch (717:50): [True: 1.80k, False: 191k]
  ------------------
  718|  1.80k|        return;
  719|       |
  720|   875k|    if (ao_c->untimed_throttle)
  ------------------
  |  Branch (720:9): [True: 18.2k, False: 857k]
  ------------------
  721|  18.2k|        return;
  722|       |
  723|   857k|    if (!mp_pin_can_transfer_data(ao_c->queue_filter->pins[0], f->ppins[0]))
  ------------------
  |  Branch (723:9): [True: 428k, False: 428k]
  ------------------
  724|   428k|        return;
  725|       |
  726|   428k|    struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  727|   428k|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (727:9): [True: 421k, False: 6.67k]
  ------------------
  728|   421k|        struct mp_aframe *af = frame.data;
  729|       |
  730|   421k|        double endpts = get_play_end_pts(mpctx);
  731|   421k|        if (endpts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   421k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (731:13): [True: 0, False: 421k]
  ------------------
  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|   421k|        double startpts = mpctx->audio_status == STATUS_SYNCING ?
  ------------------
  |  Branch (743:27): [True: 93.8k, False: 327k]
  ------------------
  744|   327k|                                            ao_c->start_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|   327k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  745|   421k|        mp_aframe_clip_timestamps(af, startpts, endpts);
  746|       |
  747|   421k|        int samples = mp_aframe_get_size(af);
  748|   421k|        if (!samples) {
  ------------------
  |  Branch (748:13): [True: 24.5k, False: 397k]
  ------------------
  749|  24.5k|            mp_filter_internal_mark_progress(f);
  750|  24.5k|            mp_frame_unref(&frame);
  751|  24.5k|            return;
  752|  24.5k|        }
  753|       |
  754|   397k|        mpctx->shown_aframes += samples;
  755|   397k|        double real_samplerate = mp_aframe_get_rate(af) / mpctx->audio_speed;
  756|   397k|        if (mpctx->video_status != STATUS_EOF)
  ------------------
  |  Branch (756:13): [True: 37.7k, False: 359k]
  ------------------
  757|  37.7k|            mpctx->delay += samples / real_samplerate;
  758|   397k|        ao_c->last_out_pts = mp_aframe_end_pts(af);
  759|   397k|        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|   397k|        if (mpctx->audio_status == STATUS_SYNCING && ao_is_playing(ao_c->ao)) {
  ------------------
  |  Branch (766:13): [True: 69.3k, False: 327k]
  |  Branch (766:54): [True: 28, False: 69.2k]
  ------------------
  767|     28|            mpctx->audio_status = STATUS_READY;
  768|     28|            mp_wakeup_core(mpctx);
  769|     28|            MP_VERBOSE(mpctx, "previous audio still playing; continuing\n");
  ------------------
  |  |   92|     28|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     28|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  770|     28|        }
  771|       |
  772|   397k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  773|   397k|    } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (773:16): [True: 6.67k, False: 0]
  ------------------
  774|  6.67k|        MP_VERBOSE(mpctx, "audio filter EOF\n");
  ------------------
  |  |   92|  6.67k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.67k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  775|       |
  776|  6.67k|        ao_c->out_eof = true;
  777|  6.67k|        mp_wakeup_core(mpctx);
  778|       |
  779|  6.67k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  780|  6.67k|        mp_filter_internal_mark_progress(f);
  781|  6.67k|    } else {
  782|      0|        mp_frame_unref(&frame);
  783|      0|    }
  784|   428k|}
audio.c:get_sync_pts:
  824|  84.0k|{
  825|  84.0k|    struct MPOpts *opts = mpctx->opts;
  826|       |
  827|  84.0k|    *pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  84.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  828|       |
  829|  84.0k|    if (!opts->initial_audio_sync)
  ------------------
  |  Branch (829:9): [True: 0, False: 84.0k]
  ------------------
  830|      0|        return true;
  831|       |
  832|  84.0k|    bool sync_to_video = mpctx->vo_chain && mpctx->video_status != STATUS_EOF &&
  ------------------
  |  Branch (832:26): [True: 52.9k, False: 31.1k]
  |  Branch (832:45): [True: 45.2k, False: 7.70k]
  ------------------
  833|  45.2k|                         !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (833:26): [True: 45.1k, False: 62]
  ------------------
  834|       |
  835|  84.0k|    if (sync_to_video) {
  ------------------
  |  Branch (835:9): [True: 45.1k, False: 38.8k]
  ------------------
  836|  45.1k|        if (mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (836:13): [True: 28.1k, False: 16.9k]
  ------------------
  837|  28.1k|            return false; // wait until we know a video PTS
  838|  16.9k|        if (mpctx->video_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  16.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (838:13): [True: 16.9k, False: 0]
  ------------------
  839|  16.9k|            *pts = mpctx->video_pts - opts->audio_delay;
  840|  38.8k|    } else if (mpctx->hrseek_active) {
  ------------------
  |  Branch (840:16): [True: 0, False: 38.8k]
  ------------------
  841|      0|        *pts = mpctx->hrseek_pts;
  842|  38.8k|    } else {
  843|       |        // If audio-only is enabled mid-stream during playback, sync accordingly.
  844|  38.8k|        *pts = mpctx->playback_pts;
  845|  38.8k|    }
  846|       |
  847|  55.8k|    return true;
  848|  84.0k|}
audio.c:update_throttle:
  670|   647k|{
  671|   647k|    struct ao_chain *ao_c = mpctx->ao_chain;
  672|   647k|    bool new_throttle = mpctx->audio_status == STATUS_PLAYING &&
  ------------------
  |  Branch (672:25): [True: 351k, False: 296k]
  ------------------
  673|   351k|                        mpctx->delay > 0 && ao_c && ao_c->ao &&
  ------------------
  |  Branch (673:25): [True: 10.8k, False: 340k]
  |  Branch (673:45): [True: 10.8k, False: 0]
  |  Branch (673:53): [True: 10.8k, False: 0]
  ------------------
  674|  10.8k|                        ao_untimed(ao_c->ao) &&
  ------------------
  |  Branch (674:25): [True: 10.8k, False: 0]
  ------------------
  675|  10.8k|                        mpctx->video_status != STATUS_EOF;
  ------------------
  |  Branch (675:25): [True: 10.8k, False: 0]
  ------------------
  676|   647k|    if (ao_c && new_throttle != ao_c->untimed_throttle) {
  ------------------
  |  Branch (676:9): [True: 534k, False: 113k]
  |  Branch (676:17): [True: 12.3k, False: 521k]
  ------------------
  677|  12.3k|        ao_c->untimed_throttle = new_throttle;
  678|  12.3k|        mp_wakeup_core(mpctx);
  679|  12.3k|        mp_filter_wakeup(ao_c->ao_filter);
  680|  12.3k|    }
  681|   647k|}
audio.c:reinit_audio_filters_and_output:
  360|  8.55k|{
  361|  8.55k|    struct MPOpts *opts = mpctx->opts;
  362|  8.55k|    struct ao_chain *ao_c = mpctx->ao_chain;
  363|  8.55k|    mp_assert(ao_c);
  ------------------
  |  |   41|  8.55k|#define mp_assert assert
  ------------------
  |  Branch (363:5): [True: 8.55k, False: 0]
  ------------------
  364|  8.55k|    struct track *track = ao_c->track;
  365|       |
  366|  8.55k|    mp_assert(ao_c->filter->ao_needs_update);
  ------------------
  |  |   41|  8.55k|#define mp_assert assert
  ------------------
  |  Branch (366:5): [True: 8.55k, False: 0]
  ------------------
  367|       |
  368|       |    // The "ideal" filter output format
  369|  8.55k|    struct mp_aframe *out_fmt = mp_aframe_new_ref(ao_c->filter->output_aformat);
  370|  8.55k|    MP_HANDLE_OOM(out_fmt);
  ------------------
  |  |  206|  8.55k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  8.55k|        void *oom_p_ = (x);     \
  |  |  208|  8.55k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 8.55k]
  |  |  ------------------
  |  |  209|  8.55k|            abort();            \
  |  |  210|  8.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 8.55k]
  |  |  ------------------
  ------------------
  371|       |
  372|  8.55k|    if (!mp_aframe_config_is_valid(out_fmt)) {
  ------------------
  |  Branch (372:9): [True: 0, False: 8.55k]
  ------------------
  373|      0|        talloc_free(out_fmt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  374|      0|        goto init_error;
  375|      0|    }
  376|       |
  377|  8.55k|    if (af_fmt_is_pcm(mp_aframe_get_format(out_fmt))) {
  ------------------
  |  Branch (377:9): [True: 8.55k, False: 0]
  ------------------
  378|  8.55k|        if (opts->force_srate)
  ------------------
  |  Branch (378:13): [True: 0, False: 8.55k]
  ------------------
  379|      0|            mp_aframe_set_rate(out_fmt, opts->force_srate);
  380|  8.55k|        if (opts->audio_output_format)
  ------------------
  |  Branch (380:13): [True: 0, False: 8.55k]
  ------------------
  381|      0|            mp_aframe_set_format(out_fmt, opts->audio_output_format);
  382|  8.55k|        if (opts->audio_output_channels.num_chmaps == 1)
  ------------------
  |  Branch (382:13): [True: 0, False: 8.55k]
  ------------------
  383|      0|            mp_aframe_set_chmap(out_fmt, &opts->audio_output_channels.chmaps[0]);
  384|  8.55k|    }
  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|  8.55k|    if ((mpctx->ao_filter_fmt && mpctx->ao && opts->gapless_audio < 0 &&
  ------------------
  |  Branch (389:10): [True: 1.91k, False: 6.64k]
  |  Branch (389:34): [True: 1.91k, False: 0]
  |  Branch (389:47): [True: 1.91k, False: 0]
  ------------------
  390|  1.91k|         keep_weak_gapless_format(mpctx->ao_filter_fmt, out_fmt)) ||
  ------------------
  |  Branch (390:10): [True: 3, False: 1.90k]
  ------------------
  391|  8.55k|        (mpctx->ao && opts->gapless_audio > 0))
  ------------------
  |  Branch (391:10): [True: 1.90k, False: 6.64k]
  |  Branch (391:23): [True: 0, False: 1.90k]
  ------------------
  392|      3|    {
  393|      3|        ao_chain_set_ao(ao_c, mpctx->ao);
  394|      3|        talloc_free(out_fmt);
  ------------------
  |  |   47|      3|#define talloc_free                     ta_free
  ------------------
  395|      3|        return 0;
  396|      3|    }
  397|       |
  398|       |    // Format change during syncing. Force playback start early, then wait.
  399|  8.55k|    if (ao_c->ao_queue && mp_async_queue_get_frames(ao_c->ao_queue) &&
  ------------------
  |  Branch (399:9): [True: 1.90k, False: 6.64k]
  |  Branch (399:27): [True: 794, False: 1.11k]
  ------------------
  400|    794|        mpctx->audio_status == STATUS_SYNCING)
  ------------------
  |  Branch (400:9): [True: 362, False: 432]
  ------------------
  401|    362|    {
  402|    362|        mpctx->audio_status = STATUS_READY;
  403|    362|        mp_wakeup_core(mpctx);
  404|    362|        talloc_free(out_fmt);
  ------------------
  |  |   47|    362|#define talloc_free                     ta_free
  ------------------
  405|    362|        return 0;
  406|    362|    }
  407|  8.18k|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (407:9): [True: 114, False: 8.07k]
  ------------------
  408|    114|        talloc_free(out_fmt);
  ------------------
  |  |   47|    114|#define talloc_free                     ta_free
  ------------------
  409|    114|        return 0;
  410|    114|    }
  411|       |
  412|  8.07k|    uninit_audio_out(mpctx);
  413|       |
  414|  8.07k|    int out_rate = mp_aframe_get_rate(out_fmt);
  415|  8.07k|    int out_format = mp_aframe_get_format(out_fmt);
  416|  8.07k|    struct mp_chmap out_channels = {0};
  417|  8.07k|    mp_aframe_get_chmap(out_fmt, &out_channels);
  418|       |
  419|  8.07k|    int ao_flags = 0;
  420|  8.07k|    bool spdif_fallback = !af_fmt_is_pcm(out_format) &&
  ------------------
  |  Branch (420:27): [True: 0, False: 8.07k]
  ------------------
  421|      0|                          ao_c->spdif_passthrough;
  ------------------
  |  Branch (421:27): [True: 0, False: 0]
  ------------------
  422|       |
  423|  8.07k|    if (opts->ao_null_fallback && !spdif_fallback)
  ------------------
  |  Branch (423:9): [True: 0, False: 8.07k]
  |  Branch (423:35): [True: 0, False: 0]
  ------------------
  424|      0|        ao_flags |= AO_INIT_NULL_FALLBACK;
  425|       |
  426|  8.07k|    if (opts->audio_stream_silence)
  ------------------
  |  Branch (426:9): [True: 0, False: 8.07k]
  ------------------
  427|      0|        ao_flags |= AO_INIT_STREAM_SILENCE;
  428|       |
  429|  8.07k|    if (opts->audio_exclusive)
  ------------------
  |  Branch (429:9): [True: 0, False: 8.07k]
  ------------------
  430|      0|        ao_flags |= AO_INIT_EXCLUSIVE;
  431|       |
  432|  8.07k|    if (af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (432:9): [True: 8.07k, False: 0]
  ------------------
  433|  8.07k|        if (!opts->audio_output_channels.set ||
  ------------------
  |  Branch (433:13): [True: 0, False: 8.07k]
  ------------------
  434|  8.07k|            opts->audio_output_channels.auto_safe)
  ------------------
  |  Branch (434:13): [True: 8.07k, False: 0]
  ------------------
  435|  8.07k|            ao_flags |= AO_INIT_SAFE_MULTICHANNEL_ONLY;
  436|       |
  437|  8.07k|        mp_chmap_sel_list(&out_channels,
  438|  8.07k|                          opts->audio_output_channels.chmaps,
  439|  8.07k|                          opts->audio_output_channels.num_chmaps);
  440|  8.07k|    }
  441|       |
  442|  8.07k|    if (!has_video_track(mpctx))
  ------------------
  |  Branch (442:9): [True: 3.90k, False: 4.17k]
  ------------------
  443|  3.90k|        ao_flags |= AO_INIT_MEDIA_ROLE_MUSIC;
  444|       |
  445|  8.07k|    mpctx->ao_filter_fmt = out_fmt;
  446|       |
  447|  8.07k|    mpctx->ao = ao_init_best(mpctx->global, ao_flags, mp_wakeup_core_cb,
  448|  8.07k|                             mpctx, mpctx->encode_lavc_ctx, out_rate,
  449|  8.07k|                             out_format, out_channels);
  450|       |
  451|  8.07k|    int ao_rate = 0;
  452|  8.07k|    int ao_format = 0;
  453|  8.07k|    struct mp_chmap ao_channels = {0};
  454|  8.07k|    if (mpctx->ao)
  ------------------
  |  Branch (454:9): [True: 8.07k, False: 4]
  ------------------
  455|  8.07k|        ao_get_format(mpctx->ao, &ao_rate, &ao_format, &ao_channels);
  456|       |
  457|       |    // Verify passthrough format was not changed.
  458|  8.07k|    if (mpctx->ao && !af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (458:9): [True: 8.07k, False: 4]
  |  Branch (458:22): [True: 0, False: 8.07k]
  ------------------
  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|  8.07k|    if (!mpctx->ao) {
  ------------------
  |  Branch (468:9): [True: 4, False: 8.07k]
  ------------------
  469|       |        // If spdif was used, try to fallback to PCM.
  470|      4|        if (spdif_fallback && ao_c->track && ao_c->track->dec) {
  ------------------
  |  Branch (470:13): [True: 0, False: 4]
  |  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|      4|        MP_ERR(mpctx, "Could not open/initialize audio device -> no sound.\n");
  ------------------
  |  |   89|      4|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|      4|        mpctx->error_playing = MPV_ERROR_AO_INIT_FAILED;
  485|      4|        goto init_error;
  486|      4|    }
  487|       |
  488|  8.07k|    char tmp[192];
  489|  8.07k|    MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(mpctx->ao),
  ------------------
  |  |   91|  8.07k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  8.07k|            audio_config_to_str_buf(tmp, sizeof(tmp), ao_rate, ao_format,
  491|  8.07k|                                    ao_channels));
  492|  8.07k|    MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(mpctx->ao));
  ------------------
  |  |   92|  8.07k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.07k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  493|  8.07k|    update_window_title(mpctx, true);
  494|       |
  495|  8.07k|    ao_c->ao_resume_time =
  496|  8.07k|        opts->audio_wait_open > 0 ? mp_time_sec() + opts->audio_wait_open : 0;
  ------------------
  |  Branch (496:9): [True: 0, False: 8.07k]
  ------------------
  497|       |
  498|  8.07k|    bool eof = mpctx->audio_status == STATUS_EOF;
  499|  8.07k|    ao_set_paused(mpctx->ao, get_internal_paused(mpctx), eof);
  500|       |
  501|  8.07k|    ao_chain_set_ao(ao_c, mpctx->ao);
  502|       |
  503|  8.07k|    audio_update_volume(mpctx);
  504|       |
  505|       |    // Almost nonsensical hack to deal with certain format change scenarios.
  506|  8.07k|    if (mpctx->audio_status == STATUS_PLAYING)
  ------------------
  |  Branch (506:9): [True: 1.36k, False: 6.70k]
  ------------------
  507|  1.36k|        ao_start(mpctx->ao);
  508|       |
  509|  8.07k|    mp_wakeup_core(mpctx);
  510|  8.07k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  511|       |
  512|  8.07k|    return 0;
  513|       |
  514|      4|init_error:
  515|      4|    uninit_audio_chain(mpctx);
  516|      4|    uninit_audio_out(mpctx);
  517|      4|    error_on_track(mpctx, track);
  518|      4|    return -1;
  519|  8.07k|}
audio.c:keep_weak_gapless_format:
  315|  1.91k|{
  316|  1.91k|    bool res = false;
  317|  1.91k|    struct mp_aframe *new_mod = mp_aframe_new_ref(new);
  318|  1.91k|    MP_HANDLE_OOM(new_mod);
  ------------------
  |  |  206|  1.91k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.91k|        void *oom_p_ = (x);     \
  |  |  208|  1.91k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.91k]
  |  |  ------------------
  |  |  209|  1.91k|            abort();            \
  |  |  210|  1.91k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.91k]
  |  |  ------------------
  ------------------
  319|       |
  320|       |    // If the sample formats are compatible (== libswresample generally can
  321|       |    // convert them), keep the AO. On other changes, recreate it.
  322|       |
  323|  1.91k|    int old_fmt = mp_aframe_get_format(old);
  324|  1.91k|    int new_fmt = mp_aframe_get_format(new);
  325|       |
  326|  1.91k|    if (af_format_conversion_score(old_fmt, new_fmt) == INT_MIN)
  ------------------
  |  Branch (326:9): [True: 0, False: 1.91k]
  ------------------
  327|      0|        goto done; // completely incompatible formats
  328|       |
  329|  1.91k|    if (!mp_aframe_set_format(new_mod, old_fmt))
  ------------------
  |  Branch (329:9): [True: 0, False: 1.91k]
  ------------------
  330|      0|        goto done;
  331|       |
  332|  1.91k|    res = mp_aframe_config_equals(old, new_mod);
  333|       |
  334|  1.91k|done:
  335|  1.91k|    talloc_free(new_mod);
  ------------------
  |  |   47|  1.91k|#define talloc_free                     ta_free
  ------------------
  336|  1.91k|    return res;
  337|  1.91k|}
audio.c:ao_chain_set_ao:
  340|  8.07k|{
  341|  8.07k|    if (ao_c->ao != ao) {
  ------------------
  |  Branch (341:9): [True: 8.07k, False: 3]
  ------------------
  342|  8.07k|        mp_assert(!ao_c->ao);
  ------------------
  |  |   41|  8.07k|#define mp_assert assert
  ------------------
  |  Branch (342:9): [True: 8.07k, False: 0]
  ------------------
  343|  8.07k|        ao_c->ao = ao;
  344|  8.07k|        ao_c->ao_queue = ao_get_queue(ao_c->ao);
  345|  8.07k|        ao_c->queue_filter = mp_async_queue_create_filter(ao_c->ao_filter,
  346|  8.07k|                                                          MP_PIN_IN, ao_c->ao_queue);
  347|  8.07k|        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|  8.07k|        mp_filter_set_high_priority(ao_c->queue_filter, true);
  350|  8.07k|        audio_update_volume(ao_c->mpctx);
  351|  8.07k|    }
  352|       |
  353|  8.07k|    if (ao_c->filter->ao_needs_update)
  ------------------
  |  Branch (353:9): [True: 8.07k, False: 0]
  ------------------
  354|  8.07k|        mp_output_chain_set_ao(ao_c->filter, ao_c->ao);
  355|       |
  356|  8.07k|    mp_filter_wakeup(ao_c->ao_filter);
  357|  8.07k|}
audio.c:has_video_track:
  206|  8.07k|{
  207|  8.07k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart)
  ------------------
  |  Branch (207:9): [True: 5.02k, False: 3.05k]
  |  Branch (207:28): [True: 10, False: 5.01k]
  ------------------
  208|     10|        return false;
  209|       |
  210|  16.1k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (210:21): [True: 12.3k, False: 3.89k]
  ------------------
  211|  12.3k|        struct track *track = mpctx->tracks[n];
  212|  12.3k|        if (track->type == STREAM_VIDEO && !track->attached_picture && !track->image)
  ------------------
  |  Branch (212:13): [True: 5.51k, False: 6.79k]
  |  Branch (212:44): [True: 5.51k, False: 0]
  |  Branch (212:72): [True: 4.17k, False: 1.34k]
  ------------------
  213|  4.17k|            return true;
  214|  12.3k|    }
  215|       |
  216|  3.89k|    return false;
  217|  8.06k|}
audio.c:audio_config_to_str_buf:
  302|  8.07k|{
  303|  8.07k|    char ch[128];
  304|  8.07k|    mp_chmap_to_str_buf(ch, sizeof(ch), &channels);
  305|  8.07k|    char *hr_ch = mp_chmap_to_str_hr(&channels);
  ------------------
  |  |  153|  8.07k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  8.07k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  306|  8.07k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (306:9): [True: 82, False: 7.98k]
  ------------------
  307|     82|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  308|  8.07k|    snprintf(buf, buf_sz, "%dHz %s %dch %s", rate,
  309|  8.07k|             ch, channels.num, af_fmt_to_str(format));
  310|  8.07k|    return buf;
  311|  8.07k|}

mp_clients_init:
  180|  24.7k|{
  181|  24.7k|    mpctx->clients = talloc_ptrtype(NULL, mpctx->clients);
  ------------------
  |  |   34|  24.7k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.7k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|  24.7k|    *mpctx->clients = (struct mp_client_api) {
  183|  24.7k|        .mpctx = mpctx,
  184|  24.7k|    };
  185|  24.7k|    mpctx->global->client_api = mpctx->clients;
  186|  24.7k|    mp_mutex_init(&mpctx->clients->lock);
  187|  24.7k|}
mp_clients_destroy:
  190|  24.7k|{
  191|  24.7k|    if (!mpctx->clients)
  ------------------
  |  Branch (191:9): [True: 0, False: 24.7k]
  ------------------
  192|      0|        return;
  193|  24.7k|    mp_assert(mpctx->clients->num_clients == 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (193:5): [True: 24.7k, 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|  24.7k|    if (mpctx->clients->render_context) {
  ------------------
  |  Branch (197:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    mp_mutex_destroy(&mpctx->clients->lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  203|  24.7k|    talloc_free(mpctx->clients);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  204|       |    mpctx->clients = NULL;
  205|  24.7k|}
mp_clients_all_initialized:
  210|  24.7k|{
  211|  24.7k|    bool all_ok = true;
  212|  24.7k|    mp_mutex_lock(&mpctx->clients->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  213|  49.5k|    for (int n = 0; n < mpctx->clients->num_clients; n++) {
  ------------------
  |  Branch (213:21): [True: 24.7k, False: 24.7k]
  ------------------
  214|  24.7k|        struct mpv_handle *ctx = mpctx->clients->clients[n];
  215|  24.7k|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  216|  24.7k|        all_ok &= ctx->fuzzy_initialized;
  217|  24.7k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  218|  24.7k|    }
  219|  24.7k|    mp_mutex_unlock(&mpctx->clients->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  220|  24.7k|    return all_ok;
  221|  24.7k|}
mp_new_weak_client:
  324|  24.7k|{
  325|       |    return new_client(clients, name, true);
  326|  24.7k|}
mpv_wait_async_requests:
  398|  49.5k|{
  399|  49.5k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  400|  49.5k|    while (ctx->reserved_events || ctx->async_counter)
  ------------------
  |  Branch (400:12): [True: 0, False: 49.5k]
  |  Branch (400:36): [True: 0, False: 49.5k]
  ------------------
  401|      0|        wait_wakeup(ctx, INT64_MAX);
  402|  49.5k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  403|  49.5k|}
mpv_destroy:
  537|  24.7k|{
  538|       |    mp_destroy_client(ctx, false);
  539|  24.7k|}
mpv_terminate_destroy:
  542|  24.7k|{
  543|       |    mp_destroy_client(ctx, true);
  544|  24.7k|}
mp_shutdown_clients:
  549|  49.5k|{
  550|  49.5k|    struct mp_client_api *clients = mpctx->clients;
  551|       |
  552|       |    // Forcefully abort async work after 2 seconds of waiting.
  553|  49.5k|    double abort_time = mp_time_sec() + 2;
  554|       |
  555|  49.5k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  556|       |
  557|       |    // Prevent that new clients can appear.
  558|  49.5k|    clients->shutting_down = true;
  559|       |
  560|       |    // Wait until we can terminate.
  561|   107k|    while (clients->num_clients || mpctx->outstanding_async ||
  ------------------
  |  Branch (561:12): [True: 49.4k, False: 58.0k]
  |  Branch (561:36): [True: 0, False: 58.0k]
  ------------------
  562|  58.0k|           !(mpctx->is_cli || clients->terminate_core_thread))
  ------------------
  |  Branch (562:14): [True: 0, False: 58.0k]
  |  Branch (562:31): [True: 49.5k, False: 8.55k]
  ------------------
  563|  57.9k|    {
  564|  57.9k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  57.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  565|       |
  566|  57.9k|        double left = abort_time - mp_time_sec();
  567|  57.9k|        if (left >= 0) {
  ------------------
  |  Branch (567:13): [True: 57.9k, False: 0]
  ------------------
  568|  57.9k|            mp_set_timeout(mpctx, left);
  569|  57.9k|        } 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|  57.9k|        mp_client_broadcast_event(mpctx, MPV_EVENT_SHUTDOWN, NULL);
  577|  57.9k|        mp_wait_events(mpctx);
  578|       |
  579|  57.9k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  57.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  580|  57.9k|    }
  581|       |
  582|  49.5k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  583|  49.5k|}
mpv_create:
  639|  24.7k|{
  640|       |    return create_core(false);
  641|  24.7k|}
mpv_initialize_opts:
  669|  24.7k|{
  670|  24.7k|    lock_core(ctx);
  671|  24.7k|    int res = mp_initialize(ctx->mpctx, options) ? MPV_ERROR_INVALID_PARAMETER : 0;
  ------------------
  |  Branch (671:15): [True: 0, False: 24.7k]
  ------------------
  672|  24.7k|#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|  24.7k|    if (options)
  ------------------
  |  Branch (675:9): [True: 0, False: 24.7k]
  ------------------
  676|      0|        ctx->mpctx->stop_play = PT_QUIT;
  677|  24.7k|#endif
  678|  24.7k|    mp_wakeup_core(ctx->mpctx);
  679|  24.7k|    unlock_core(ctx);
  680|  24.7k|    return res;
  681|  24.7k|}
mpv_initialize:
  684|  24.7k|{
  685|       |    return mpv_initialize_opts(ctx, NULL);
  686|  24.7k|}
mp_client_broadcast_event:
  786|   728k|{
  787|   728k|    struct mp_client_api *clients = mpctx->clients;
  788|       |
  789|   728k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   728k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  790|       |
  791|  1.44M|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (791:21): [True: 719k, False: 728k]
  ------------------
  792|   719k|        struct mpv_event event_data = {
  793|   719k|            .event_id = event,
  794|   719k|            .data = data,
  795|   719k|        };
  796|   719k|        send_event(clients->clients[n], &event_data, true);
  797|   719k|    }
  798|       |
  799|   728k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   728k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  800|   728k|}
mpv_request_event:
  872|  49.5k|{
  873|  49.5k|    if (!mpv_event_name(event) || enable < 0 || enable > 1)
  ------------------
  |  Branch (873:9): [True: 0, False: 49.5k]
  |  Branch (873:35): [True: 0, False: 49.5k]
  |  Branch (873:49): [True: 0, False: 49.5k]
  ------------------
  874|      0|        return MPV_ERROR_INVALID_PARAMETER;
  875|  49.5k|    if (event == MPV_EVENT_SHUTDOWN && !enable)
  ------------------
  |  Branch (875:9): [True: 0, False: 49.5k]
  |  Branch (875:40): [True: 0, False: 0]
  ------------------
  876|      0|        return MPV_ERROR_INVALID_PARAMETER;
  877|  49.5k|    mp_assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (877:5): [True: 49.5k, False: 0]
  ------------------
  878|  49.5k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  879|  49.5k|    uint64_t bit = 1ULL << event;
  880|  49.5k|    ctx->event_mask = enable ? ctx->event_mask | bit : ctx->event_mask & ~bit;
  ------------------
  |  Branch (880:23): [True: 0, False: 49.5k]
  ------------------
  881|  49.5k|    if (enable && event < MP_ARRAY_SIZE(deprecated_events) &&
  ------------------
  |  |   49|  49.5k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (881:9): [True: 0, False: 49.5k]
  |  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|  49.5k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  888|  49.5k|    return 0;
  889|  49.5k|}
mpv_wait_event:
  913|   315k|{
  914|   315k|    mpv_event *event = ctx->cur_event;
  915|       |
  916|   315k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   315k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  917|       |
  918|   315k|    if (!ctx->fuzzy_initialized)
  ------------------
  |  Branch (918:9): [True: 0, False: 315k]
  ------------------
  919|      0|        mp_wakeup_core(ctx->clients->mpctx);
  920|   315k|    ctx->fuzzy_initialized = true;
  921|       |
  922|   315k|    if (timeout < 0)
  ------------------
  |  Branch (922:9): [True: 251k, False: 64.7k]
  ------------------
  923|   251k|        timeout = 1e20;
  924|       |
  925|   315k|    int64_t deadline = mp_time_ns_add(mp_time_ns(), timeout);
  926|       |
  927|   315k|    *event = (mpv_event){0};
  928|   315k|    talloc_free_children(event);
  ------------------
  |  |   46|   315k|#define talloc_free_children            ta_free_children
  ------------------
  929|       |
  930|   587k|    while (1) {
  ------------------
  |  Branch (930:12): [True: 587k, Folded]
  ------------------
  931|   587k|        if (ctx->queued_wakeup)
  ------------------
  |  Branch (931:13): [True: 0, False: 587k]
  ------------------
  932|      0|            deadline = 0;
  933|       |        // Recover from overflow.
  934|   587k|        if (ctx->choked && !ctx->num_events) {
  ------------------
  |  Branch (934:13): [True: 0, False: 587k]
  |  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|   587k|        struct mpv_event *ev =
  940|   587k|            ctx->num_events ? &ctx->events[ctx->first_event] : NULL;
  ------------------
  |  Branch (940:13): [True: 290k, False: 296k]
  ------------------
  941|   587k|        if (ev && ev->event_id == MPV_EVENT_HOOK) {
  ------------------
  |  Branch (941:13): [True: 290k, False: 296k]
  |  Branch (941:19): [True: 0, False: 290k]
  ------------------
  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|   587k|        if (ev) {
  ------------------
  |  Branch (955:13): [True: 290k, False: 296k]
  ------------------
  956|   290k|            *event = *ev;
  957|   290k|            ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  958|   290k|            ctx->num_events--;
  959|   290k|            talloc_steal(event, event->data);
  ------------------
  |  |   38|   290k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   290k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  960|   290k|            break;
  961|   290k|        }
  962|       |        // If there's a changed property, generate change event (never queued).
  963|   296k|        if (gen_property_change_event(ctx))
  ------------------
  |  Branch (963:13): [True: 24.8k, False: 271k]
  ------------------
  964|  24.8k|            break;
  965|       |        // Pop item from message queue, and return as event.
  966|   271k|        if (gen_log_message_event(ctx))
  ------------------
  |  Branch (966:13): [True: 0, False: 271k]
  ------------------
  967|      0|            break;
  968|   271k|        int r = wait_wakeup(ctx, deadline);
  969|   271k|        if (r == ETIMEDOUT)
  ------------------
  |  Branch (969:13): [True: 3, False: 271k]
  ------------------
  970|      3|            break;
  971|   271k|    }
  972|   315k|    ctx->queued_wakeup = false;
  973|       |
  974|   315k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   315k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  975|       |
  976|   315k|    return event;
  977|   315k|}
mpv_free_node_contents:
 1038|  74.2k|{
 1039|  74.2k|    static const struct m_option type = { .type = CONF_TYPE_NODE };
  ------------------
  |  |  253|  74.2k|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 1040|  74.2k|    m_option_free(&type, node);
 1041|  74.2k|}
mpv_set_option:
 1045|   247k|{
 1046|   247k|    const struct m_option *type = get_mp_type(format);
 1047|   247k|    if (!type)
  ------------------
  |  Branch (1047:9): [True: 0, False: 247k]
  ------------------
 1048|      0|        return MPV_ERROR_OPTION_FORMAT;
 1049|   247k|    struct mpv_node tmp;
 1050|   247k|    if (format != MPV_FORMAT_NODE) {
  ------------------
  |  Branch (1050:9): [True: 247k, False: 0]
  ------------------
 1051|   247k|        tmp.format = format;
 1052|   247k|        memcpy(&tmp.u, data, type->type->size);
 1053|   247k|        data = &tmp;
 1054|   247k|    }
 1055|   247k|    lock_core(ctx);
 1056|   247k|    int err = m_config_set_option_node(ctx->mpctx->mconfig, bstr0(name), data, 0);
 1057|   247k|    unlock_core(ctx);
 1058|   247k|    switch (err) {
 1059|      0|    case M_OPT_MISSING_PARAM:
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (1059:5): [True: 0, False: 247k]
  ------------------
 1060|      0|    case M_OPT_INVALID:
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (1060:5): [True: 0, False: 247k]
  ------------------
 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: 247k]
  ------------------
 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: 247k]
  ------------------
 1065|      0|        return MPV_ERROR_OPTION_NOT_FOUND;
 1066|   247k|    default:
  ------------------
  |  Branch (1066:5): [True: 247k, False: 0]
  ------------------
 1067|   247k|        if (err >= 0)
  ------------------
  |  Branch (1067:13): [True: 247k, False: 0]
  ------------------
 1068|   247k|            return 0;
 1069|      0|        return MPV_ERROR_OPTION_ERROR;
 1070|   247k|    }
 1071|   247k|}
mpv_set_option_string:
 1074|   247k|{
 1075|   247k|    return mpv_set_option(ctx, name, MPV_FORMAT_STRING, &data);
 1076|   247k|}
mpv_command:
 1165|  74.2k|{
 1166|       |    return run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), NULL);
 1167|  74.2k|}
mpv_observe_property:
 1558|  49.5k|{
 1559|  49.5k|    const struct m_option *type = get_mp_type_get(format);
 1560|  49.5k|    if (format != MPV_FORMAT_NONE && !type)
  ------------------
  |  Branch (1560:9): [True: 0, False: 49.5k]
  |  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|  49.5k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1563:9): [True: 0, False: 49.5k]
  ------------------
 1564|      0|        return MPV_ERROR_PROPERTY_FORMAT;
 1565|       |
 1566|  49.5k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1567|  49.5k|    mp_assert(!ctx->destroying);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (1567:5): [True: 49.5k, False: 0]
  ------------------
 1568|  49.5k|    struct observe_property *prop = talloc_ptrtype(ctx, prop);
  ------------------
  |  |   34|  49.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  49.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|  49.5k|    talloc_set_destructor(prop, property_free);
  ------------------
  |  |   41|  49.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1570|  49.5k|    *prop = (struct observe_property){
 1571|  49.5k|        .owner = ctx,
 1572|  49.5k|        .name = talloc_strdup(prop, name),
  ------------------
  |  |   50|  49.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1573|  49.5k|        .id = mp_get_property_id(ctx->mpctx, name),
 1574|  49.5k|        .event_mask = mp_get_property_event_mask(name),
 1575|  49.5k|        .reply_id = userdata,
 1576|  49.5k|        .format = format,
 1577|  49.5k|        .type = type,
 1578|  49.5k|        .change_ts = 1, // force initial event
 1579|  49.5k|        .refcount = 1,
 1580|  49.5k|        .value = m_option_value_default,
 1581|  49.5k|        .value_ret = m_option_value_default,
 1582|  49.5k|    };
 1583|  49.5k|    ctx->properties_change_ts += 1;
 1584|  49.5k|    MP_TARRAY_APPEND(ctx, ctx->properties, ctx->num_properties, prop);
  ------------------
  |  |  105|  49.5k|    do {                                            \
  |  |  106|  49.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  49.5k|    do {                                            \
  |  |  |  |   97|  49.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  49.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  49.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  49.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 24.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  49.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  49.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 49.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  49.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  49.5k|        (idxvar)++;                                 \
  |  |  109|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
 1585|  49.5k|    ctx->property_event_masks |= prop->event_mask;
 1586|  49.5k|    ctx->new_property_events = true;
 1587|  49.5k|    ctx->cur_property_index = 0;
 1588|  49.5k|    ctx->has_pending_properties = true;
 1589|  49.5k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1590|  49.5k|    mp_wakeup_core(ctx->mpctx);
 1591|  49.5k|    return 0;
 1592|  49.5k|}
mpv_unobserve_property:
 1595|  49.5k|{
 1596|  49.5k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1597|  49.5k|    int count = 0;
 1598|  99.0k|    for (int n = ctx->num_properties - 1; n >= 0; n--) {
  ------------------
  |  Branch (1598:43): [True: 49.5k, False: 49.5k]
  ------------------
 1599|  49.5k|        struct observe_property *prop = ctx->properties[n];
 1600|       |        // Perform actual removal of the property lazily to avoid creating
 1601|       |        // dangling pointers and such.
 1602|  49.5k|        if (prop->reply_id == userdata) {
  ------------------
  |  Branch (1602:13): [True: 49.5k, False: 0]
  ------------------
 1603|  49.5k|            prop_unref(prop);
 1604|  49.5k|            ctx->properties_change_ts += 1;
 1605|  49.5k|            MP_TARRAY_REMOVE_AT(ctx->properties, ctx->num_properties, n);
  ------------------
  |  |  143|  49.5k|    do {                                            \
  |  |  144|  49.5k|        size_t at_ = (at);                          \
  |  |  145|  49.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  49.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  49.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  49.5k|        (idxvar)--;                                 \
  |  |  149|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
  |  Branch (1605:13): [True: 49.5k, False: 0]
  ------------------
 1606|  49.5k|            ctx->cur_property_index = 0;
 1607|  49.5k|            count++;
 1608|  49.5k|        }
 1609|  49.5k|    }
 1610|  49.5k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1611|  49.5k|    return count;
 1612|  49.5k|}
mp_client_property_change:
 1640|  51.5k|{
 1641|  51.5k|    struct mp_client_api *clients = mpctx->clients;
 1642|  51.5k|    int id = mp_get_property_id(mpctx, name);
 1643|  51.5k|    bool any_pending = false;
 1644|       |
 1645|  51.5k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  51.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1646|       |
 1647|   103k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1647:21): [True: 51.5k, False: 51.5k]
  ------------------
 1648|  51.5k|        struct mpv_handle *client = clients->clients[n];
 1649|  51.5k|        mp_mutex_lock(&client->lock);
  ------------------
  |  |  134|  51.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1650|  51.5k|        for (int i = 0; i < client->num_properties; i++) {
  ------------------
  |  Branch (1650:25): [True: 0, False: 51.5k]
  ------------------
 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|  51.5k|        mp_mutex_unlock(&client->lock);
  ------------------
  |  |  136|  51.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1659|  51.5k|    }
 1660|       |
 1661|  51.5k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  51.5k|#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|  51.5k|    if (any_pending)
  ------------------
  |  Branch (1667:9): [True: 0, False: 51.5k]
  ------------------
 1668|      0|        mp_dispatch_adjust_timeout(mpctx->dispatch, 0);
 1669|  51.5k|}
mp_client_send_property_changes:
 1774|   562k|{
 1775|   562k|    struct mp_client_api *clients = mpctx->clients;
 1776|       |
 1777|   562k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   562k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1778|   562k|    uint64_t cur_ts = clients->clients_list_change_ts;
 1779|       |
 1780|  1.11M|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1780:21): [True: 553k, False: 562k]
  ------------------
 1781|   553k|        struct mpv_handle *ctx = clients->clients[n];
 1782|       |
 1783|   553k|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   553k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1784|   553k|        if (!ctx->has_pending_properties || ctx->destroying) {
  ------------------
  |  Branch (1784:13): [True: 503k, False: 49.4k]
  |  Branch (1784:45): [True: 1, False: 49.4k]
  ------------------
 1785|   503k|            mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   503k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1786|   503k|            continue;
 1787|   503k|        }
 1788|       |        // Keep ctx->lock locked (unlock order does not matter).
 1789|  49.4k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  49.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1790|  49.4k|        send_client_property_changes(ctx);
 1791|  49.4k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1792|  49.4k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  49.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1793|  49.4k|        if (cur_ts != clients->clients_list_change_ts) {
  ------------------
  |  Branch (1793:13): [True: 0, False: 49.4k]
  ------------------
 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|  49.4k|    }
 1799|       |
 1800|   562k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   562k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1801|   562k|}
mpv_error_string:
 2107|  24.7k|{
 2108|  24.7k|    error = -error;
 2109|  24.7k|    if (error < 0)
  ------------------
  |  Branch (2109:9): [True: 0, False: 24.7k]
  ------------------
 2110|      0|        error = 0;
 2111|  24.7k|    const char *name = NULL;
 2112|  24.7k|    if (error < MP_ARRAY_SIZE(err_table))
  ------------------
  |  |   49|  24.7k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2112:9): [True: 24.7k, False: 0]
  ------------------
 2113|  24.7k|        name = err_table[error];
 2114|  24.7k|    return name ? name : "unknown error";
  ------------------
  |  Branch (2114:12): [True: 24.7k, False: 0]
  ------------------
 2115|  24.7k|}
mpv_event_name:
 2140|  49.5k|{
 2141|  49.5k|    if ((unsigned)event >= MP_ARRAY_SIZE(event_table))
  ------------------
  |  |   49|  49.5k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2141:9): [True: 0, False: 49.5k]
  ------------------
 2142|      0|        return NULL;
 2143|  49.5k|    return event_table[event];
 2144|  49.5k|}
client.c:new_client:
  262|  49.5k|{
  263|  49.5k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  264|       |
  265|  49.5k|    char nname[MAX_CLIENT_NAME];
  266|  49.5k|    for (int n = 1; n < 1000; n++) {
  ------------------
  |  Branch (266:21): [True: 49.5k, False: 0]
  ------------------
  267|  49.5k|        if (!name)
  ------------------
  |  Branch (267:13): [True: 0, False: 49.5k]
  ------------------
  268|      0|            name = "client";
  269|  49.5k|        snprintf(nname, sizeof(nname) - 3, "%s", name); // - space for number
  270|   222k|        for (int i = 0; nname[i]; i++)
  ------------------
  |  Branch (270:25): [True: 173k, False: 49.5k]
  ------------------
  271|   173k|            nname[i] = mp_isalnum(nname[i]) ? nname[i] : '_';
  ------------------
  |  Branch (271:24): [True: 173k, False: 0]
  ------------------
  272|  49.5k|        if (n > 1)
  ------------------
  |  Branch (272:13): [True: 0, False: 49.5k]
  ------------------
  273|      0|            mp_snprintf_cat(nname, sizeof(nname), "%d", n);
  274|  49.5k|        if (!find_client(clients, nname))
  ------------------
  |  Branch (274:13): [True: 49.5k, False: 0]
  ------------------
  275|  49.5k|            break;
  276|      0|        nname[0] = '\0';
  277|      0|    }
  278|       |
  279|  49.5k|    if (!nname[0] || clients->shutting_down) {
  ------------------
  |  Branch (279:9): [True: 0, False: 49.5k]
  |  Branch (279:22): [True: 0, False: 49.5k]
  ------------------
  280|      0|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  281|      0|        return NULL;
  282|      0|    }
  283|       |
  284|  49.5k|    int num_events = 1000;
  285|       |
  286|  49.5k|    struct mpv_handle *client = talloc_ptrtype(NULL, client);
  ------------------
  |  |   34|  49.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  49.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|  49.5k|    *client = (struct mpv_handle){
  288|  49.5k|        .log = mp_log_new(client, clients->mpctx->log, nname),
  289|  49.5k|        .mpctx = clients->mpctx,
  290|  49.5k|        .clients = clients,
  291|  49.5k|        .id = ++(clients->id_alloc),
  292|  49.5k|        .cur_event = talloc_zero(client, struct mpv_event),
  ------------------
  |  |   27|  49.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  49.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|  49.5k|        .events = talloc_array(client, mpv_event, num_events),
  ------------------
  |  |   29|  49.5k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  49.5k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  49.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|  49.5k|        .max_events = num_events,
  295|  49.5k|        .event_mask = (1ULL << INTERNAL_EVENT_BASE) - 1, // exclude internal events
  296|  49.5k|        .wakeup_pipe = {-1, -1},
  297|  49.5k|        .is_weak = weak,
  298|  49.5k|    };
  299|  49.5k|    mp_mutex_init(&client->lock);
  300|  49.5k|    mp_mutex_init(&client->wakeup_lock);
  301|  49.5k|    mp_cond_init(&client->wakeup);
  302|       |
  303|  49.5k|    snprintf(client->name, sizeof(client->name), "%s", nname);
  304|       |
  305|  49.5k|    clients->clients_list_change_ts += 1;
  306|  49.5k|    MP_TARRAY_APPEND(clients, clients->clients, clients->num_clients, client);
  ------------------
  |  |  105|  49.5k|    do {                                            \
  |  |  106|  49.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  49.5k|    do {                                            \
  |  |  |  |   97|  49.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  49.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  49.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  49.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 24.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  49.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  49.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 49.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  49.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  49.5k|        (idxvar)++;                                 \
  |  |  109|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
  307|       |
  308|  49.5k|    if (clients->num_clients == 1 && !clients->mpctx->is_cli)
  ------------------
  |  Branch (308:9): [True: 24.7k, False: 24.7k]
  |  Branch (308:38): [True: 24.7k, False: 0]
  ------------------
  309|  24.7k|        client->fuzzy_initialized = true;
  310|       |
  311|  49.5k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  312|       |
  313|  49.5k|    mpv_request_event(client, MPV_EVENT_TICK, 0);
  314|       |
  315|  49.5k|    return client;
  316|  49.5k|}
client.c:wait_wakeup:
  364|   271k|{
  365|   271k|    int r = 0;
  366|   271k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   271k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  367|   271k|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|   271k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  368|   271k|    if (!ctx->need_wakeup)
  ------------------
  |  Branch (368:9): [True: 271k, False: 756]
  ------------------
  369|   271k|        r = mp_cond_timedwait_until(&ctx->wakeup, &ctx->wakeup_lock, end);
  370|   271k|    if (r == 0)
  ------------------
  |  Branch (370:9): [True: 271k, False: 3]
  ------------------
  371|   271k|        ctx->need_wakeup = false;
  372|   271k|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|   271k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  373|   271k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   271k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  374|   271k|    return r;
  375|   271k|}
client.c:mp_destroy_client:
  430|  49.5k|{
  431|  49.5k|    if (!ctx)
  ------------------
  |  Branch (431:9): [True: 0, False: 49.5k]
  ------------------
  432|      0|        return;
  433|       |
  434|  49.5k|    struct MPContext *mpctx = ctx->mpctx;
  435|  49.5k|    struct mp_client_api *clients = ctx->clients;
  436|       |
  437|  49.5k|    MP_DBG(ctx, "Destroying client handle...\n");
  ------------------
  |  |   93|  49.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  49.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|  49.5k|    if (terminate)
  ------------------
  |  Branch (439:9): [True: 24.7k, False: 24.7k]
  ------------------
  440|  24.7k|        mpv_command(ctx, (const char*[]){"quit", NULL});
  441|       |
  442|  49.5k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  443|       |
  444|  49.5k|    ctx->destroying = true;
  445|       |
  446|  49.5k|    for (int n = 0; n < ctx->num_properties; n++)
  ------------------
  |  Branch (446:21): [True: 0, False: 49.5k]
  ------------------
  447|      0|        prop_unref(ctx->properties[n]);
  448|  49.5k|    ctx->num_properties = 0;
  449|  49.5k|    ctx->properties_change_ts += 1;
  450|       |
  451|  49.5k|    prop_unref(ctx->cur_property);
  452|  49.5k|    ctx->cur_property = NULL;
  453|       |
  454|  49.5k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  455|       |
  456|  49.5k|    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|  49.5k|    mpv_wait_async_requests(ctx);
  462|       |
  463|  49.5k|    osd_set_external_remove_owner(mpctx->osd, ctx);
  464|  49.5k|    mp_input_remove_sections_by_owner(mpctx->input, ctx->name);
  465|       |
  466|  49.5k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  467|       |
  468|  74.2k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (468:21): [True: 74.2k, False: 0]
  ------------------
  469|  74.2k|        if (clients->clients[n] == ctx) {
  ------------------
  |  Branch (469:13): [True: 49.5k, False: 24.7k]
  ------------------
  470|  49.5k|            clients->clients_list_change_ts += 1;
  471|  49.5k|            MP_TARRAY_REMOVE_AT(clients->clients, clients->num_clients, n);
  ------------------
  |  |  143|  49.5k|    do {                                            \
  |  |  144|  49.5k|        size_t at_ = (at);                          \
  |  |  145|  49.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  49.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  49.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  49.5k|        (idxvar)--;                                 \
  |  |  149|  49.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 49.5k]
  |  |  ------------------
  ------------------
  |  Branch (471:13): [True: 49.5k, False: 0]
  ------------------
  472|  49.5k|            while (ctx->num_events) {
  ------------------
  |  Branch (472:20): [True: 42, False: 49.5k]
  ------------------
  473|     42|                talloc_free(ctx->events[ctx->first_event].data);
  ------------------
  |  |   47|     42|#define talloc_free                     ta_free
  ------------------
  474|     42|                ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  475|     42|                ctx->num_events--;
  476|     42|            }
  477|  49.5k|            mp_msg_log_buffer_destroy(ctx->messages);
  478|  49.5k|            mp_cond_destroy(&ctx->wakeup);
  479|  49.5k|            mp_mutex_destroy(&ctx->wakeup_lock);
  ------------------
  |  |  133|  49.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  480|  49.5k|            mp_mutex_destroy(&ctx->lock);
  ------------------
  |  |  133|  49.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  481|  49.5k|            if (ctx->wakeup_pipe[0] != -1) {
  ------------------
  |  Branch (481:17): [True: 0, False: 49.5k]
  ------------------
  482|      0|                close(ctx->wakeup_pipe[0]);
  483|      0|                close(ctx->wakeup_pipe[1]);
  484|      0|            }
  485|  49.5k|            talloc_free(ctx);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
  486|  49.5k|            ctx = NULL;
  487|  49.5k|            break;
  488|  49.5k|        }
  489|  74.2k|    }
  490|  49.5k|    mp_assert(!ctx);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (490:5): [True: 49.5k, False: 0]
  ------------------
  491|       |
  492|  49.5k|    if (mpctx->is_cli) {
  ------------------
  |  Branch (492:9): [True: 0, False: 49.5k]
  ------------------
  493|      0|        terminate = false;
  494|  49.5k|    } else {
  495|       |        // If the last strong mpv_handle got destroyed, destroy the core.
  496|  49.5k|        bool has_strong_ref = false;
  497|  74.2k|        for (int n = 0; n < clients->num_clients; n++)
  ------------------
  |  Branch (497:25): [True: 24.7k, False: 49.5k]
  ------------------
  498|  24.7k|            has_strong_ref |= !clients->clients[n]->is_weak;
  499|  49.5k|        if (!has_strong_ref)
  ------------------
  |  Branch (499:13): [True: 24.7k, False: 24.7k]
  ------------------
  500|  24.7k|            terminate = true;
  501|       |
  502|       |        // Reserve the right to destroy mpctx for us.
  503|  49.5k|        if (clients->have_terminator)
  ------------------
  |  Branch (503:13): [True: 0, False: 49.5k]
  ------------------
  504|      0|            terminate = false;
  505|  49.5k|        clients->have_terminator |= terminate;
  506|  49.5k|    }
  507|       |
  508|       |    // mp_shutdown_clients() sleeps to avoid wasting CPU.
  509|       |    // mp_hook_test_completion() also relies on this a bit.
  510|  49.5k|    mp_wakeup_core(mpctx);
  511|       |
  512|  49.5k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  49.5k|#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|  49.5k|    if (terminate) {
  ------------------
  |  Branch (516:9): [True: 24.7k, False: 24.7k]
  ------------------
  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|  24.7k|        mp_dispatch_lock(mpctx->dispatch);
  520|  24.7k|        mpctx->stop_play = PT_QUIT;
  521|  24.7k|        mp_dispatch_unlock(mpctx->dispatch);
  522|       |
  523|       |        // Ask the core thread to stop.
  524|  24.7k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  525|  24.7k|        clients->terminate_core_thread = true;
  526|  24.7k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  527|  24.7k|        mp_wakeup_core(mpctx);
  528|       |
  529|       |        // Blocking wait for all clients and core thread to terminate.
  530|  24.7k|        mp_thread_join(mpctx->core_thread);
  ------------------
  |  |  215|  24.7k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  531|       |
  532|  24.7k|        mp_destroy(mpctx);
  533|  24.7k|    }
  534|  49.5k|}
client.c:abort_async:
  410|  49.5k|{
  411|  49.5k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  412|       |
  413|       |    // Destroy all => ensure any newly appearing work is aborted immediately.
  414|  49.5k|    if (ctx == NULL)
  ------------------
  |  Branch (414:9): [True: 0, False: 49.5k]
  ------------------
  415|      0|        mpctx->abort_all = true;
  416|       |
  417|  49.5k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (417:21): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  427|  49.5k|}
client.c:create_core:
  615|  24.7k|{
  616|  24.7k|    struct MPContext *mpctx = mp_create();
  617|  24.7k|    if (!mpctx)
  ------------------
  |  Branch (617:9): [True: 0, False: 24.7k]
  ------------------
  618|      0|        return NULL;
  619|       |
  620|  24.7k|    m_config_set_profile(mpctx->mconfig, "libmpv", 0);
  621|       |
  622|  24.7k|    mpv_handle *ctx = new_client(mpctx->clients, "main", weak);
  623|  24.7k|    if (!ctx) {
  ------------------
  |  Branch (623:9): [True: 0, False: 24.7k]
  ------------------
  624|      0|        mp_destroy(mpctx);
  625|      0|        return NULL;
  626|      0|    }
  627|       |
  628|  24.7k|    if (mp_thread_create(&mpctx->core_thread, core_thread, mpctx) != 0) {
  ------------------
  |  |  214|  24.7k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (628:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    return ctx;
  636|  24.7k|}
client.c:core_thread:
  595|  24.7k|{
  596|  24.7k|    struct MPContext *mpctx = p;
  597|       |
  598|  24.7k|    mp_thread_set_name("core");
  599|       |
  600|  55.1k|    while (!mpctx->initialized && mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (600:12): [True: 30.3k, False: 24.7k]
  |  Branch (600:35): [True: 30.3k, False: 0]
  ------------------
  601|  30.3k|        mp_idle(mpctx);
  602|       |
  603|  24.7k|    if (mpctx->initialized)
  ------------------
  |  Branch (603:9): [True: 24.7k, False: 0]
  ------------------
  604|  24.7k|        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|  24.7k|    mp_shutdown_clients(mpctx);
  610|       |
  611|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  24.7k|#define MP_THREAD_RETURN() return NULL
  ------------------
  612|  24.7k|}
client.c:lock_core:
  388|   346k|{
  389|   346k|    mp_dispatch_lock(ctx->mpctx->dispatch);
  390|   346k|}
client.c:unlock_core:
  393|   346k|{
  394|   346k|    mp_dispatch_unlock(ctx->mpctx->dispatch);
  395|   346k|}
client.c:send_event:
  749|   719k|{
  750|   719k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|   719k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  751|   719k|    uint64_t mask = 1ULL << event->event_id;
  752|   719k|    if (ctx->property_event_masks & mask)
  ------------------
  |  Branch (752:9): [True: 95.8k, False: 623k]
  ------------------
  753|  95.8k|        notify_property_events(ctx, event->event_id);
  754|   719k|    int r;
  755|   719k|    if (!(ctx->event_mask & mask)) {
  ------------------
  |  Branch (755:9): [True: 428k, False: 290k]
  ------------------
  756|   428k|        r = 0;
  757|   428k|    } else if (ctx->choked) {
  ------------------
  |  Branch (757:16): [True: 0, False: 290k]
  ------------------
  758|      0|        r = -1;
  759|   290k|    } else {
  760|   290k|        r = append_event(ctx, *event, copy);
  761|   290k|        if (r < 0) {
  ------------------
  |  Branch (761:13): [True: 0, False: 290k]
  ------------------
  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|   290k|    }
  766|   719k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|   719k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  767|   719k|    return r;
  768|   719k|}
client.c:notify_property_events:
 1674|  95.8k|{
 1675|  95.8k|    uint64_t mask = 1ULL << event;
 1676|  95.8k|    for (int i = 0; i < ctx->num_properties; i++) {
  ------------------
  |  Branch (1676:21): [True: 13, False: 95.8k]
  ------------------
 1677|     13|        if (ctx->properties[i]->event_mask & mask) {
  ------------------
  |  Branch (1677:13): [True: 13, False: 0]
  ------------------
 1678|     13|            ctx->properties[i]->change_ts += 1;
 1679|     13|            ctx->has_pending_properties = true;
 1680|     13|        }
 1681|     13|    }
 1682|       |
 1683|       |    // Same as in mp_client_property_change().
 1684|  95.8k|    if (ctx->has_pending_properties)
  ------------------
  |  Branch (1684:9): [True: 13, False: 95.8k]
  ------------------
 1685|     13|        mp_dispatch_adjust_timeout(ctx->mpctx->dispatch, 0);
 1686|  95.8k|}
client.c:append_event:
  735|   290k|{
  736|   290k|    if (ctx->num_events + ctx->reserved_events >= ctx->max_events)
  ------------------
  |  Branch (736:9): [True: 0, False: 290k]
  ------------------
  737|      0|        return -1;
  738|   290k|    if (copy)
  ------------------
  |  Branch (738:9): [True: 290k, False: 0]
  ------------------
  739|   290k|        dup_event_data(&event);
  740|   290k|    ctx->events[(ctx->first_event + ctx->num_events) % ctx->max_events] = event;
  741|   290k|    ctx->num_events++;
  742|   290k|    wakeup_client(ctx);
  743|   290k|    if (event.event_id == MPV_EVENT_SHUTDOWN)
  ------------------
  |  Branch (743:9): [True: 24.6k, False: 266k]
  ------------------
  744|  24.6k|        ctx->event_mask &= ctx->event_mask & ~(1ULL << MPV_EVENT_SHUTDOWN);
  745|   290k|    return 0;
  746|   290k|}
client.c:find_client:
  234|  49.5k|{
  235|  49.5k|    if (name[0] == '@') {
  ------------------
  |  Branch (235:9): [True: 0, False: 49.5k]
  ------------------
  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|  74.2k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (244:21): [True: 24.7k, False: 49.5k]
  ------------------
  245|  24.7k|        if (strcmp(clients->clients[n]->name, name) == 0)
  ------------------
  |  Branch (245:13): [True: 0, False: 24.7k]
  ------------------
  246|      0|            return clients->clients[n];
  247|  24.7k|    }
  248|       |
  249|  49.5k|    return NULL;
  250|  49.5k|}
client.c:dup_event_data:
  691|   290k|{
  692|   290k|    switch (ev->event_id) {
  693|      0|    case MPV_EVENT_CLIENT_MESSAGE: {
  ------------------
  |  Branch (693:5): [True: 0, False: 290k]
  ------------------
  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|  24.7k|    case MPV_EVENT_START_FILE:
  ------------------
  |  Branch (704:5): [True: 24.7k, False: 266k]
  ------------------
  705|  24.7k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_start_file));
  ------------------
  |  |   49|  24.7k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  24.7k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  706|  24.7k|        break;
  707|  24.6k|    case MPV_EVENT_END_FILE:
  ------------------
  |  Branch (707:5): [True: 24.6k, False: 266k]
  ------------------
  708|  24.6k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_end_file));
  ------------------
  |  |   49|  24.6k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  24.6k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|  24.6k|        break;
  710|   241k|    default:
  ------------------
  |  Branch (710:5): [True: 241k, False: 49.4k]
  ------------------
  711|       |        // Doesn't use events with memory allocation.
  712|   241k|        if (ev->data)
  ------------------
  |  Branch (712:13): [True: 0, False: 241k]
  ------------------
  713|      0|            abort();
  714|   290k|    }
  715|   290k|}
client.c:wakeup_client:
  349|   340k|{
  350|   340k|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|   340k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  351|   340k|    if (!ctx->need_wakeup) {
  ------------------
  |  Branch (351:9): [True: 272k, False: 68.1k]
  ------------------
  352|   272k|        ctx->need_wakeup = true;
  353|   272k|        mp_cond_broadcast(&ctx->wakeup);
  354|   272k|        if (ctx->wakeup_cb)
  ------------------
  |  Branch (354:13): [True: 0, False: 272k]
  ------------------
  355|      0|            ctx->wakeup_cb(ctx->wakeup_cb_ctx);
  356|   272k|        if (ctx->wakeup_pipe[0] != -1)
  ------------------
  |  Branch (356:13): [True: 0, False: 272k]
  ------------------
  357|      0|            (void)write(ctx->wakeup_pipe[1], &(char){0}, 1);
  358|   272k|    }
  359|   340k|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|   340k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  360|   340k|}
client.c:get_mp_type:
  997|   297k|{
  998|   297k|    if ((unsigned)format >= MP_ARRAY_SIZE(type_conv))
  ------------------
  |  |   49|   297k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (998:9): [True: 0, False: 297k]
  ------------------
  999|      0|        return NULL;
 1000|   297k|    if (!type_conv[format].type)
  ------------------
  |  Branch (1000:9): [True: 49.5k, False: 247k]
  ------------------
 1001|  49.5k|        return NULL;
 1002|   247k|    return &type_conv[format];
 1003|   297k|}
client.c:run_client_command:
 1126|  74.2k|{
 1127|  74.2k|    if (!cmd)
  ------------------
  |  Branch (1127:9): [True: 0, False: 74.2k]
  ------------------
 1128|      0|        return MPV_ERROR_INVALID_PARAMETER;
 1129|  74.2k|    if (!ctx->mpctx->initialized) {
  ------------------
  |  Branch (1129:9): [True: 0, False: 74.2k]
  ------------------
 1130|      0|        talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1131|      0|        return MPV_ERROR_UNINITIALIZED;
 1132|      0|    }
 1133|       |
 1134|  74.2k|    cmd->sender = ctx->name;
 1135|       |
 1136|  74.2k|    struct cmd_request req = {
 1137|  74.2k|        .mpctx = ctx->mpctx,
 1138|  74.2k|        .cmd = cmd,
 1139|  74.2k|        .res = res,
 1140|  74.2k|        .completion = MP_WAITER_INITIALIZER,
  ------------------
  |  |   19|  74.2k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  74.2k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  74.2k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  74.2k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  74.2k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  74.2k|    }
  ------------------
 1141|  74.2k|    };
 1142|       |
 1143|  74.2k|    bool async = cmd->flags & MP_ASYNC_CMD;
 1144|       |
 1145|  74.2k|    lock_core(ctx);
 1146|  74.2k|    if (async) {
  ------------------
  |  Branch (1146:9): [True: 0, False: 74.2k]
  ------------------
 1147|      0|        run_command(ctx->mpctx, cmd, NULL, NULL, NULL);
 1148|  74.2k|    } else {
 1149|  74.2k|        struct mp_abort_entry *abort = NULL;
 1150|  74.2k|        if (cmd->def->can_abort) {
  ------------------
  |  Branch (1150:13): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|        run_command(ctx->mpctx, cmd, abort, cmd_complete, &req);
 1155|  74.2k|    }
 1156|  74.2k|    unlock_core(ctx);
 1157|       |
 1158|  74.2k|    if (!async)
  ------------------
  |  Branch (1158:9): [True: 74.2k, False: 0]
  ------------------
 1159|  74.2k|        mp_waiter_wait(&req.completion);
 1160|       |
 1161|  74.2k|    return req.status;
 1162|  74.2k|}
client.c:cmd_complete:
 1112|  74.2k|{
 1113|  74.2k|    struct cmd_request *req = cmd->on_completion_priv;
 1114|       |
 1115|  74.2k|    req->status = cmd->success ? 0 : MPV_ERROR_COMMAND;
  ------------------
  |  Branch (1115:19): [True: 74.2k, False: 0]
  ------------------
 1116|  74.2k|    if (req->res) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    mp_waiter_wakeup(&req->completion, 0);
 1123|  74.2k|}
client.c:get_mp_type_get:
 1007|  49.5k|{
 1008|  49.5k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1008:9): [True: 0, False: 49.5k]
  ------------------
 1009|      0|        format = MPV_FORMAT_STRING; // it's string data, just other semantics
 1010|  49.5k|    return get_mp_type(format);
 1011|  49.5k|}
client.c:property_free:
 1545|  49.5k|{
 1546|  49.5k|    struct observe_property *prop = p;
 1547|       |
 1548|  49.5k|    mp_assert(prop->refcount == 0);
  ------------------
  |  |   41|  49.5k|#define mp_assert assert
  ------------------
  |  Branch (1548:5): [True: 49.5k, False: 0]
  ------------------
 1549|       |
 1550|  49.5k|    if (prop->type) {
  ------------------
  |  Branch (1550:9): [True: 0, False: 49.5k]
  ------------------
 1551|      0|        m_option_free(prop->type, &prop->value);
 1552|      0|        m_option_free(prop->type, &prop->value_ret);
 1553|      0|    }
 1554|  49.5k|}
client.c:prop_unref:
  169|   123k|{
  170|   123k|    if (!prop)
  ------------------
  |  Branch (170:9): [True: 49.5k, False: 74.3k]
  ------------------
  171|  49.5k|        return;
  172|       |
  173|  74.3k|    mp_assert(prop->refcount > 0);
  ------------------
  |  |   41|  74.3k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 74.3k, False: 0]
  ------------------
  174|  74.3k|    prop->refcount -= 1;
  175|  74.3k|    if (!prop->refcount)
  ------------------
  |  Branch (175:9): [True: 49.5k, False: 24.8k]
  ------------------
  176|  49.5k|        talloc_free(prop);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
  177|  74.3k|}
client.c:send_client_property_changes:
 1690|  49.4k|{
 1691|  49.4k|    uint64_t cur_ts = ctx->properties_change_ts;
 1692|       |
 1693|  49.4k|    ctx->has_pending_properties = false;
 1694|       |
 1695|  98.8k|    for (int n = 0; n < ctx->num_properties; n++) {
  ------------------
  |  Branch (1695:21): [True: 49.3k, False: 49.4k]
  ------------------
 1696|  49.3k|        struct observe_property *prop = ctx->properties[n];
 1697|       |
 1698|  49.3k|        if (prop->value_ts == prop->change_ts)
  ------------------
  |  Branch (1698:13): [True: 0, False: 49.3k]
  ------------------
 1699|      0|            continue;
 1700|       |
 1701|  49.3k|        bool changed = false;
 1702|  49.3k|        if (prop->format) {
  ------------------
  |  Branch (1702:13): [True: 0, False: 49.3k]
  ------------------
 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|  49.3k|        } else {
 1751|  49.3k|            changed = true;
 1752|  49.3k|        }
 1753|       |
 1754|  49.3k|        if (prop->waiting_for_hook)
  ------------------
  |  Branch (1754:13): [True: 0, False: 49.3k]
  ------------------
 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|  49.3k|        if (!changed && prop->value_ret_ts == prop->value_ts) {
  ------------------
  |  Branch (1759:13): [True: 0, False: 49.3k]
  |  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|  49.3k|        } else {
 1763|  49.3k|            ctx->new_property_events = true;
 1764|  49.3k|        }
 1765|       |
 1766|  49.3k|        prop->value_ts = prop->change_ts;
 1767|  49.3k|    }
 1768|       |
 1769|  49.4k|    if (ctx->destroying || ctx->new_property_events)
  ------------------
  |  Branch (1769:9): [True: 0, False: 49.4k]
  |  Branch (1769:28): [True: 49.3k, False: 115]
  ------------------
 1770|  49.3k|        wakeup_client(ctx);
 1771|  49.4k|}
client.c:gen_property_change_event:
 1806|   296k|{
 1807|   296k|    if (!ctx->mpctx->initialized)
  ------------------
  |  Branch (1807:9): [True: 0, False: 296k]
  ------------------
 1808|      0|        return false;
 1809|       |
 1810|   395k|    while (1) {
  ------------------
  |  Branch (1810:12): [True: 395k, Folded]
  ------------------
 1811|   395k|        if (ctx->cur_property_index >= ctx->num_properties) {
  ------------------
  |  Branch (1811:13): [True: 346k, False: 49.4k]
  ------------------
 1812|   346k|            ctx->new_property_events &= ctx->num_properties > 0;
 1813|   346k|            if (!ctx->new_property_events)
  ------------------
  |  Branch (1813:17): [True: 271k, False: 74.2k]
  ------------------
 1814|   271k|                break;
 1815|  74.2k|            ctx->new_property_events = false;
 1816|  74.2k|            ctx->cur_property_index = 0;
 1817|  74.2k|        }
 1818|       |
 1819|   123k|        struct observe_property *prop = ctx->properties[ctx->cur_property_index++];
 1820|       |
 1821|   123k|        if (prop->value_ts == prop->change_ts &&    // not a stale value?
  ------------------
  |  Branch (1821:13): [True: 24.8k, False: 98.8k]
  ------------------
 1822|  24.8k|            prop->value_ret_ts != prop->value_ts)   // other value than last time?
  ------------------
  |  Branch (1822:13): [True: 24.8k, False: 0]
  ------------------
 1823|  24.8k|        {
 1824|  24.8k|            prop->value_ret_ts = prop->value_ts;
 1825|  24.8k|            prop->waiting_for_hook = false;
 1826|  24.8k|            prop_unref(ctx->cur_property);
 1827|  24.8k|            ctx->cur_property = prop;
 1828|  24.8k|            prop->refcount += 1;
 1829|       |
 1830|  24.8k|            if (prop->value_valid)
  ------------------
  |  Branch (1830:17): [True: 0, False: 24.8k]
  ------------------
 1831|      0|                m_option_copy(prop->type, &prop->value_ret, &prop->value);
 1832|       |
 1833|  24.8k|            ctx->cur_property_event = (struct mpv_event_property){
 1834|  24.8k|                .name = prop->name,
 1835|  24.8k|                .format = prop->value_valid ? prop->format : 0,
  ------------------
  |  Branch (1835:27): [True: 0, False: 24.8k]
  ------------------
 1836|  24.8k|                .data = prop->value_valid ? &prop->value_ret : NULL,
  ------------------
  |  Branch (1836:25): [True: 0, False: 24.8k]
  ------------------
 1837|  24.8k|            };
 1838|  24.8k|            *ctx->cur_event = (struct mpv_event){
 1839|  24.8k|                .event_id = MPV_EVENT_PROPERTY_CHANGE,
 1840|  24.8k|                .reply_userdata = prop->reply_id,
 1841|  24.8k|                .data = &ctx->cur_property_event,
 1842|  24.8k|            };
 1843|  24.8k|            return true;
 1844|  24.8k|        }
 1845|   123k|    }
 1846|       |
 1847|   271k|    return false;
 1848|   296k|}
client.c:gen_log_message_event:
 1928|   271k|{
 1929|   271k|    if (ctx->messages) {
  ------------------
  |  Branch (1929:9): [True: 0, False: 271k]
  ------------------
 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|   271k|    return false;
 1950|   271k|}

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

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

mp_hook_test_completion:
  204|   148k|{
  205|   148k|    struct command_ctx *cmd = mpctx->command_ctx;
  206|   148k|    for (int n = 0; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (206:21): [True: 0, False: 148k]
  ------------------
  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|   148k|    return true;
  219|   148k|}
mp_hook_start:
  269|   148k|{
  270|   148k|    run_next_hook_handler(mpctx, type, 0);
  271|   148k|}
mp_get_property_event_mask:
 5025|  49.5k|{
 5026|  49.5k|    uint64_t mask = 0;
 5027|  2.17M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_event_property_change); n++) {
  ------------------
  |  |   49|  2.17M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (5027:21): [True: 2.12M, False: 49.5k]
  ------------------
 5028|  2.12M|        const char *const *const list = mp_event_property_change[n];
 5029|  8.71M|        for (int i = 0; list && list[i]; i++) {
  ------------------
  |  Branch (5029:25): [True: 7.82M, False: 891k]
  |  Branch (5029:33): [True: 6.58M, False: 1.23M]
  ------------------
 5030|  6.58M|            if (match_property(list[i], name))
  ------------------
  |  Branch (5030:17): [True: 247k, False: 6.33M]
  ------------------
 5031|   247k|                mask |= 1ULL << n;
 5032|  6.58M|        }
 5033|  2.12M|    }
 5034|  49.5k|    return mask;
 5035|  49.5k|}
mp_get_property_id:
 5040|   101k|{
 5041|   101k|    struct command_ctx *ctx = mpctx->command_ctx;
 5042|  67.9M|    for (int n = 0; n < ctx->properties.num; n++) {
  ------------------
  |  Branch (5042:21): [True: 67.9M, False: 0]
  ------------------
 5043|  67.9M|        if (match_property(ctx->properties.props[n].name, name))
  ------------------
  |  Branch (5043:13): [True: 101k, False: 67.8M]
  ------------------
 5044|   101k|            return n;
 5045|  67.9M|    }
 5046|      0|    return -1;
 5047|   101k|}
mp_property_expand_string:
 5098|   149k|{
 5099|   149k|    struct command_ctx *ctx = mpctx->command_ctx;
 5100|   149k|    return m_properties_expand_string(&ctx->properties, str, mpctx,
 5101|   149k|                                      M_PROPERTY_PRINT);
 5102|   149k|}
mp_cmd_ctx_complete:
 5933|  74.2k|{
 5934|  74.2k|    cmd->completed = true;
 5935|  74.2k|    if (!cmd->success)
  ------------------
  |  Branch (5935:9): [True: 0, False: 74.2k]
  ------------------
 5936|      0|        mpv_free_node_contents(&cmd->result);
 5937|  74.2k|    if (cmd->on_completion)
  ------------------
  |  Branch (5937:9): [True: 74.2k, False: 0]
  ------------------
 5938|  74.2k|        cmd->on_completion(cmd);
 5939|  74.2k|    if (cmd->abort)
  ------------------
  |  Branch (5939:9): [True: 0, False: 74.2k]
  ------------------
 5940|      0|        mp_abort_remove(cmd->mpctx, cmd->abort);
 5941|  74.2k|    mpv_free_node_contents(&cmd->result);
 5942|  74.2k|    talloc_free(cmd);
  ------------------
  |  |   47|  74.2k|#define talloc_free                     ta_free
  ------------------
 5943|  74.2k|}
run_command:
 5980|  74.2k|{
 5981|  74.2k|    struct mp_cmd_ctx *ctx = talloc(NULL, struct mp_cmd_ctx);
  ------------------
  |  |   26|  74.2k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  74.2k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  74.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5982|  74.2k|    *ctx = (struct mp_cmd_ctx){
 5983|  74.2k|        .mpctx = mpctx,
 5984|  74.2k|        .cmd = talloc_steal(ctx, cmd),
  ------------------
  |  |   38|  74.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  74.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5985|  74.2k|        .args = cmd->args,
 5986|  74.2k|        .num_args = cmd->nargs,
 5987|  74.2k|        .priv = cmd->def->priv,
 5988|  74.2k|        .abort = talloc_steal(ctx, abort),
  ------------------
  |  |   38|  74.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  74.2k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5989|  74.2k|        .success = true,
 5990|  74.2k|        .completed = true,
 5991|  74.2k|        .on_completion = on_completion,
 5992|  74.2k|        .on_completion_priv = on_completion_priv,
 5993|  74.2k|    };
 5994|       |
 5995|  74.2k|    if (!ctx->abort && cmd->def->can_abort)
  ------------------
  |  Branch (5995:9): [True: 74.2k, False: 0]
  |  Branch (5995:24): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    mp_assert(cmd->def->can_abort == !!ctx->abort);
  ------------------
  |  |   41|  74.2k|#define mp_assert assert
  ------------------
  |  Branch (5998:5): [True: 74.2k, False: 0]
  ------------------
 5999|       |
 6000|  74.2k|    if (ctx->abort) {
  ------------------
  |  Branch (6000:9): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    struct MPOpts *opts = mpctx->opts;
 6006|  74.2k|    ctx->on_osd = cmd->flags & MP_ON_OSD_FLAGS;
 6007|  74.2k|    bool auto_osd = ctx->on_osd == MP_ON_OSD_AUTO;
 6008|  74.2k|    ctx->msg_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_MSG);
  ------------------
  |  Branch (6008:20): [True: 0, False: 74.2k]
  |  Branch (6008:32): [True: 0, False: 74.2k]
  ------------------
 6009|  74.2k|    ctx->bar_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_BAR);
  ------------------
  |  Branch (6009:20): [True: 0, False: 74.2k]
  |  Branch (6009:32): [True: 0, False: 74.2k]
  ------------------
 6010|  74.2k|    ctx->seek_msg_osd = auto_osd ? opts->osd_on_seek & 2 : ctx->msg_osd;
  ------------------
  |  Branch (6010:25): [True: 0, False: 74.2k]
  ------------------
 6011|  74.2k|    ctx->seek_bar_osd = auto_osd ? opts->osd_on_seek & 1 : ctx->bar_osd;
  ------------------
  |  Branch (6011:25): [True: 0, False: 74.2k]
  ------------------
 6012|       |
 6013|  74.2k|    bool noise = cmd->def->is_noisy || cmd->mouse_move;
  ------------------
  |  Branch (6013:18): [True: 0, False: 74.2k]
  |  Branch (6013:40): [True: 0, False: 74.2k]
  ------------------
 6014|  74.2k|    mp_cmd_dump(mpctx->log, noise ? MSGL_TRACE : MSGL_DEBUG, "Run command:", cmd);
  ------------------
  |  Branch (6014:29): [True: 0, False: 74.2k]
  ------------------
 6015|       |
 6016|  74.2k|    if (cmd->flags & MP_EXPAND_PROPERTIES) {
  ------------------
  |  Branch (6016:9): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    if (cmd->def->spawn_thread) {
  ------------------
  |  Branch (6039:9): [True: 0, False: 74.2k]
  ------------------
 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|  74.2k|    } else {
 6049|  74.2k|        bool exec_async = cmd->def->exec_async;
 6050|  74.2k|        cmd->def->handler(ctx);
 6051|  74.2k|        if (!exec_async)
  ------------------
  |  Branch (6051:13): [True: 74.2k, False: 0]
  ------------------
 6052|  74.2k|            mp_cmd_ctx_complete(ctx);
 6053|  74.2k|    }
 6054|  74.2k|}
mp_abort_cache_dumping:
 7482|  24.7k|{
 7483|  24.7k|    struct command_ctx *ctx = mpctx->command_ctx;
 7484|       |
 7485|  24.7k|    if (ctx->cache_dump_cmd)
  ------------------
  |  Branch (7485:9): [True: 0, False: 24.7k]
  ------------------
 7486|      0|        mp_cancel_trigger(ctx->cache_dump_cmd->abort->cancel);
 7487|  24.7k|    cache_dump_poll(mpctx);
 7488|       |    mp_assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (7488:5): [True: 24.7k, False: 0]
  ------------------
 7489|  24.7k|}
command_uninit:
 8218|  24.7k|{
 8219|  24.7k|    struct command_ctx *ctx = mpctx->command_ctx;
 8220|       |
 8221|  24.7k|    mp_assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (8221:5): [True: 24.7k, False: 0]
  ------------------
 8222|       |
 8223|  24.7k|    overlay_uninit(mpctx);
 8224|  24.7k|    ao_hotplug_destroy(ctx->hotplug);
 8225|       |
 8226|  24.7k|    m_option_free(&script_props_type, &ctx->script_props);
 8227|       |
 8228|  24.7k|    talloc_free(mpctx->command_ctx);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 8229|       |    mpctx->command_ctx = NULL;
 8230|  24.7k|}
command_init:
 8238|  24.7k|{
 8239|  24.7k|    struct command_ctx *ctx = talloc(NULL, struct command_ctx);
  ------------------
  |  |   26|  24.7k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.7k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8240|  24.7k|    *ctx = (struct command_ctx){
 8241|  24.7k|        .last_seek_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8242|  24.7k|    };
 8243|  24.7k|    mpctx->command_ctx = ctx;
 8244|       |
 8245|  24.7k|    int num_base = MP_ARRAY_SIZE(mp_properties_base);
  ------------------
  |  |   49|  24.7k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 8246|  24.7k|    int num_opts = m_config_get_co_count(mpctx->mconfig);
 8247|  24.7k|    struct m_property *props =
 8248|  24.7k|        talloc_zero_array(ctx, struct m_property, num_base + num_opts);
  ------------------
  |  |   30|  24.7k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  24.7k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8249|  24.7k|    memcpy(props, mp_properties_base, sizeof(mp_properties_base));
 8250|       |
 8251|  24.7k|    const char **prop_names = talloc_array(NULL, const char *, num_base);
  ------------------
  |  |   29|  24.7k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  24.7k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8252|  4.85M|    for (int i = 0; i < num_base; ++i)
  ------------------
  |  Branch (8252:21): [True: 4.82M, False: 24.7k]
  ------------------
 8253|  4.82M|        prop_names[i] = mp_properties_base[i].name;
 8254|  24.7k|    qsort(prop_names, num_base, sizeof(const char *), str_compare);
 8255|       |
 8256|  24.7k|    int count = num_base;
 8257|  19.4M|    for (int n = 0; n < num_opts; n++) {
  ------------------
  |  Branch (8257:21): [True: 19.4M, False: 24.7k]
  ------------------
 8258|  19.4M|        struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n);
 8259|  19.4M|        mp_assert(co->name[0]);
  ------------------
  |  |   41|  19.4M|#define mp_assert assert
  ------------------
  |  Branch (8259:9): [True: 19.4M, False: 0]
  ------------------
 8260|  19.4M|        if (co->opt->flags & M_OPT_NOPROP)
  ------------------
  |  |  477|  19.4M|#define M_OPT_NOPROP            (UINT64_C(1) << 60)
  ------------------
  |  Branch (8260:13): [True: 693k, False: 18.7M]
  ------------------
 8261|   693k|            continue;
 8262|       |
 8263|  18.7M|        struct m_property prop = {
 8264|  18.7M|            .name = co->name,
 8265|  18.7M|            .call = mp_property_generic_option,
 8266|  18.7M|            .priv = co,
 8267|  18.7M|            .is_option = true,
 8268|  18.7M|        };
 8269|       |
 8270|  18.7M|        if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8270:13): [True: 569k, False: 18.1M]
  ------------------
 8271|   569k|            char buf[M_CONFIG_MAX_OPT_NAME_LEN];
 8272|   569k|            const char *alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co->opt_id,
 8273|   569k|                                                                   buf, sizeof(buf));
 8274|   569k|            prop.priv = talloc_strdup(ctx, alias);
  ------------------
  |  |   50|   569k|#define talloc_strdup                   ta_xstrdup
  ------------------
 8275|       |
 8276|   569k|            prop.call = co->opt->deprecation_message ?
  ------------------
  |  Branch (8276:25): [True: 173k, False: 396k]
  ------------------
 8277|   396k|                            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|   569k|            struct m_config_option *co2 = co;
 8284|  1.13M|            while (co2 && co2->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8284:20): [True: 1.13M, False: 0]
  |  Branch (8284:27): [True: 569k, False: 569k]
  ------------------
 8285|   569k|                const char *co2_alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co2->opt_id,
 8286|   569k|                                                                           buf, sizeof(buf));
 8287|   569k|                co2 = m_config_get_co_raw(mpctx->mconfig, bstr0(co2_alias));
 8288|   569k|            }
 8289|   569k|            if (!co2)
  ------------------
  |  Branch (8289:17): [True: 0, False: 569k]
  ------------------
 8290|      0|                continue;
 8291|   569k|        }
 8292|       |
 8293|       |        // The option might be covered by a manual property already.
 8294|  18.7M|        if (bsearch(&prop.name, prop_names, num_base, sizeof(const char *), str_compare))
  ------------------
  |  Branch (8294:13): [True: 594k, False: 18.1M]
  ------------------
 8295|   594k|            continue;
 8296|       |
 8297|  18.1M|        props[count++] = prop;
 8298|  18.1M|    }
 8299|       |
 8300|  24.7k|    ctx->properties = (struct m_property_list){props, count};
 8301|  24.7k|    m_property_list_sort(&ctx->properties);
 8302|       |
 8303|  24.7k|    node_init(&ctx->mdata, MPV_FORMAT_NODE_ARRAY, NULL);
 8304|  24.7k|    talloc_steal(ctx, ctx->mdata.u.list);
  ------------------
  |  |   38|  24.7k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.7k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8305|       |
 8306|  24.7k|    node_init(&ctx->udata, MPV_FORMAT_NODE_MAP, NULL);
 8307|  24.7k|    talloc_steal(ctx, ctx->udata.u.list);
  ------------------
  |  |   38|  24.7k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.7k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8308|  24.7k|    talloc_free(prop_names);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 8309|  24.7k|}
handle_command_updates:
 8357|   525k|{
 8358|   525k|    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|   525k|    if (ctx->hotplug && ao_hotplug_check_update(ctx->hotplug))
  ------------------
  |  Branch (8362:9): [True: 0, False: 525k]
  |  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|   525k|    cache_dump_poll(mpctx);
 8367|   525k|}
run_command_opts:
 8370|  71.3k|{
 8371|  71.3k|    struct MPOpts *opts = mpctx->opts;
 8372|  71.3k|    struct command_ctx *ctx = mpctx->command_ctx;
 8373|       |
 8374|  71.3k|    if (!opts->input_commands || ctx->command_opts_processed)
  ------------------
  |  Branch (8374:9): [True: 71.3k, False: 0]
  |  Branch (8374:34): [True: 0, False: 0]
  ------------------
 8375|  71.3k|        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|   670k|{
 8391|       |    // The OSD can implicitly reference some properties.
 8392|   670k|    mpctx->osd_idle_update = true;
 8393|       |
 8394|   670k|    command_event(mpctx, event, arg);
 8395|       |
 8396|   670k|    mp_client_broadcast_event(mpctx, event, arg);
 8397|   670k|}
mp_option_change_callback:
 8429|  24.7k|{
 8430|  24.7k|    struct MPContext *mpctx = ctx;
 8431|  24.7k|    struct MPOpts *opts = mpctx->opts;
 8432|  24.7k|    void *opt_ptr = !co ? NULL : co->data; // NULL on start
  ------------------
  |  Branch (8432:21): [True: 24.7k, False: 0]
  ------------------
 8433|       |
 8434|  24.7k|    if (co)
  ------------------
  |  Branch (8434:9): [True: 0, False: 24.7k]
  ------------------
 8435|      0|        mp_notify_property(mpctx, co->name);
 8436|  24.7k|    if (opt_ptr == &opts->media_title)
  ------------------
  |  Branch (8436:9): [True: 0, False: 24.7k]
  ------------------
 8437|      0|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
 8438|       |
 8439|  24.7k|    if (self_update)
  ------------------
  |  Branch (8439:9): [True: 0, False: 24.7k]
  ------------------
 8440|      0|        return;
 8441|       |
 8442|       |    // Run these immediately.
 8443|  24.7k|    if (co && !co->coalesce) {
  ------------------
  |  Branch (8443:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    bool drop = false;
 8451|  24.7k|    for (int i = 0; i < mpctx->num_option_callbacks; i++) {
  ------------------
  |  Branch (8451:21): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (!drop) {
  ------------------
  |  Branch (8465:9): [True: 24.7k, False: 0]
  ------------------
 8466|  24.7k|        struct mp_option_callback callback = {.co = co, .flags = flags};
 8467|  24.7k|        MP_TARRAY_APPEND(mpctx, mpctx->option_callbacks, mpctx->num_option_callbacks, callback);
  ------------------
  |  |  105|  24.7k|    do {                                            \
  |  |  106|  24.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.7k|    do {                                            \
  |  |  |  |   97|  24.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.7k|    do {                                                        \
  |  |  |  |  |  |   89|  24.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.7k|        (idxvar)++;                                 \
  |  |  109|  24.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
 8468|  24.7k|    }
 8469|  24.7k|}
mp_option_run_callback:
 8472|  24.7k|{
 8473|  24.7k|    struct MPOpts *opts = mpctx->opts;
 8474|  24.7k|    struct m_config_option *co = callback->co;
 8475|  24.7k|    void *opt_ptr = co ? co->data : NULL;
  ------------------
  |  Branch (8475:21): [True: 0, False: 24.7k]
  ------------------
 8476|  24.7k|    uint64_t flags = callback->flags;
 8477|       |
 8478|  24.7k|    if (flags & UPDATE_TERM)
  ------------------
  |  |  442|  24.7k|#define UPDATE_TERM             (UINT64_C(1) << 0)   // terminal options
  ------------------
  |  Branch (8478:9): [True: 24.7k, False: 0]
  ------------------
 8479|  24.7k|        mp_update_logging(mpctx, false);
 8480|       |
 8481|  24.7k|    if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  444|  24.7k|#define UPDATE_OSD              (UINT64_C(1) << 2)   // related to OSD rendering
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  443|  24.7k|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  455|  24.7k|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (8481:9): [True: 24.7k, False: 0]
  ------------------
 8482|  74.2k|        for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (8482:25): [True: 49.5k, False: 24.7k]
  ------------------
 8483|  49.5k|            struct track *track = mpctx->current_track[n][STREAM_SUB];
 8484|  49.5k|            struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (8484:35): [True: 0, False: 49.5k]
  ------------------
 8485|  49.5k|            if (sub) {
  ------------------
  |  Branch (8485:17): [True: 0, False: 49.5k]
  ------------------
 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|  49.5k|        }
 8492|       |        // For subs on a still image.
 8493|  24.7k|        redraw_subs(mpctx);
 8494|  24.7k|        osd_changed(mpctx->osd);
 8495|  24.7k|    }
 8496|       |
 8497|  24.7k|    if (flags & UPDATE_BUILTIN_SCRIPTS)
  ------------------
  |  |  445|  24.7k|#define UPDATE_BUILTIN_SCRIPTS  (UINT64_C(1) << 3)   // osc/ytdl/stats
  ------------------
  |  Branch (8497:9): [True: 24.7k, False: 0]
  ------------------
 8498|  24.7k|        mp_load_builtin_scripts(mpctx);
 8499|       |
 8500|  24.7k|    if (flags & UPDATE_IMGPAR) {
  ------------------
  |  |  446|  24.7k|#define UPDATE_IMGPAR           (UINT64_C(1) << 4)   // video image params overrides
  ------------------
  |  Branch (8500:9): [True: 24.7k, False: 0]
  ------------------
 8501|  24.7k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8502|  24.7k|        if (track && track->dec) {
  ------------------
  |  Branch (8502:13): [True: 0, False: 24.7k]
  |  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|  24.7k|    }
 8507|       |
 8508|  24.7k|    if (flags & UPDATE_INPUT)
  ------------------
  |  |  447|  24.7k|#define UPDATE_INPUT            (UINT64_C(1) << 5)   // mostly --input-* options
  ------------------
  |  Branch (8508:9): [True: 24.7k, False: 0]
  ------------------
 8509|  24.7k|        mp_input_update_opts(mpctx->input);
 8510|       |
 8511|  24.7k|    if (flags & UPDATE_CLIPBOARD)
  ------------------
  |  |  458|  24.7k|#define UPDATE_CLIPBOARD        (UINT64_C(1) << 17)  // reinit the clipboard
  ------------------
  |  Branch (8511:9): [True: 24.7k, False: 0]
  ------------------
 8512|  24.7k|        reinit_clipboard(mpctx);
 8513|       |
 8514|  24.7k|    if (opt_ptr == &opts->ipc_path || opt_ptr == &opts->ipc_client) {
  ------------------
  |  Branch (8514:9): [True: 0, False: 24.7k]
  |  Branch (8514:39): [True: 0, False: 24.7k]
  ------------------
 8515|      0|        mp_uninit_ipc(mpctx->ipc_ctx);
 8516|      0|        mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
 8517|      0|    }
 8518|       |
 8519|  24.7k|    if (flags & UPDATE_VO && mpctx->video_out) {
  ------------------
  |  |  457|  49.5k|#define UPDATE_VO               (UINT64_C(1) << 16)  // reinit the VO
  ------------------
  |  Branch (8519:9): [True: 24.7k, False: 0]
  |  Branch (8519:30): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (flags & UPDATE_AUDIO)
  ------------------
  |  |  448|  24.7k|#define UPDATE_AUDIO            (UINT64_C(1) << 6)   // --audio-channels etc.
  ------------------
  |  Branch (8541:9): [True: 24.7k, False: 0]
  ------------------
 8542|  24.7k|        reload_audio_output(mpctx);
 8543|       |
 8544|  24.7k|    if (flags & UPDATE_PRIORITY)
  ------------------
  |  |  449|  24.7k|#define UPDATE_PRIORITY         (UINT64_C(1) << 7)   // --priority (Windows-only)
  ------------------
  |  Branch (8544:9): [True: 24.7k, False: 0]
  ------------------
 8545|  24.7k|        update_priority(mpctx);
 8546|       |
 8547|  24.7k|    if (flags & UPDATE_SCREENSAVER)
  ------------------
  |  |  450|  24.7k|#define UPDATE_SCREENSAVER      (UINT64_C(1) << 8)   // --stop-screensaver
  ------------------
  |  Branch (8547:9): [True: 24.7k, False: 0]
  ------------------
 8548|  24.7k|        update_screensaver_state(mpctx);
 8549|       |
 8550|  24.7k|    if (flags & UPDATE_VOL)
  ------------------
  |  |  451|  24.7k|#define UPDATE_VOL              (UINT64_C(1) << 9)   // softvol related options
  ------------------
  |  Branch (8550:9): [True: 24.7k, False: 0]
  ------------------
 8551|  24.7k|        audio_update_volume(mpctx);
 8552|       |
 8553|  24.7k|    if (flags & UPDATE_LAVFI_COMPLEX)
  ------------------
  |  |  452|  24.7k|#define UPDATE_LAVFI_COMPLEX    (UINT64_C(1) << 10)  // --lavfi-complex
  ------------------
  |  Branch (8553:9): [True: 24.7k, False: 0]
  ------------------
 8554|  24.7k|        update_lavfi_complex(mpctx);
 8555|       |
 8556|  24.7k|    if (flags & UPDATE_VIDEO) {
  ------------------
  |  |  456|  24.7k|#define UPDATE_VIDEO            (UINT64_C(1) << 15)  // force redraw if needed
  ------------------
  |  Branch (8556:9): [True: 24.7k, False: 0]
  ------------------
 8557|  24.7k|        if (mpctx->video_out) {
  ------------------
  |  Branch (8557:13): [True: 0, False: 24.7k]
  ------------------
 8558|      0|            vo_control(mpctx->video_out, VOCTRL_UPDATE_RENDER_OPTS, NULL);
 8559|      0|            mp_wakeup_core(mpctx);
 8560|      0|        }
 8561|  24.7k|    }
 8562|       |
 8563|  24.7k|    if (flags & UPDATE_HWDEC) {
  ------------------
  |  |  453|  24.7k|#define UPDATE_HWDEC            (UINT64_C(1) << 11)  // --hwdec
  ------------------
  |  Branch (8563:9): [True: 24.7k, False: 0]
  ------------------
 8564|  24.7k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8565|  24.7k|        struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
  ------------------
  |  Branch (8565:42): [True: 0, False: 24.7k]
  ------------------
 8566|  24.7k|        if (dec) {
  ------------------
  |  Branch (8566:13): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    }
 8576|       |
 8577|  24.7k|    if (flags & UPDATE_DVB_PROG) {
  ------------------
  |  |  454|  24.7k|#define UPDATE_DVB_PROG         (UINT64_C(1) << 12)  // some --dvbin-...
  ------------------
  |  Branch (8577:9): [True: 24.7k, False: 0]
  ------------------
 8578|  24.7k|        if (!mpctx->stop_play)
  ------------------
  |  Branch (8578:13): [True: 0, False: 24.7k]
  ------------------
 8579|      0|            mpctx->stop_play = PT_CURRENT_ENTRY;
 8580|  24.7k|    }
 8581|       |
 8582|  24.7k|    if (flags & UPDATE_DEMUXER)
  ------------------
  |  |  459|  24.7k|#define UPDATE_DEMUXER          (UINT64_C(1) << 18)  // invalidate --prefetch-playlist's data
  ------------------
  |  Branch (8582:9): [True: 24.7k, False: 0]
  ------------------
 8583|  24.7k|        mpctx->demuxer_changed = true;
 8584|       |
 8585|  24.7k|    if (flags & UPDATE_AD && mpctx->ao_chain) {
  ------------------
  |  |  460|  49.5k|#define UPDATE_AD               (UINT64_C(1) << 19)  // reinit audio chain and decoder
  ------------------
  |  Branch (8585:9): [True: 24.7k, False: 0]
  |  Branch (8585:30): [True: 0, False: 24.7k]
  ------------------
 8586|      0|        uninit_audio_chain(mpctx);
 8587|      0|        reinit_audio_chain(mpctx);
 8588|      0|    }
 8589|       |
 8590|  24.7k|    if (flags & UPDATE_VD && mpctx->vo_chain) {
  ------------------
  |  |  461|  49.5k|#define UPDATE_VD               (UINT64_C(1) << 20)  // reinit video chain and decoder
  ------------------
  |  Branch (8590:9): [True: 24.7k, False: 0]
  |  Branch (8590:30): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->vo->android_surface_size || opt_ptr == &opts->vo->d3d11_composition_size) {
  ------------------
  |  Branch (8598:9): [True: 0, False: 24.7k]
  |  Branch (8598:55): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->input_commands) {
  ------------------
  |  Branch (8603:9): [True: 0, False: 24.7k]
  ------------------
 8604|      0|        mpctx->command_ctx->command_opts_processed = false;
 8605|      0|        run_command_opts(mpctx);
 8606|      0|    }
 8607|       |
 8608|  24.7k|    if (opt_ptr == &opts->playback_speed || opt_ptr == &opts->playback_pitch ||
  ------------------
  |  Branch (8608:9): [True: 0, False: 24.7k]
  |  Branch (8608:45): [True: 0, False: 24.7k]
  ------------------
 8609|  24.7k|        opt_ptr == &opts->pitch_correction) {
  ------------------
  |  Branch (8609:9): [True: 0, False: 24.7k]
  ------------------
 8610|      0|        update_playback_speed(mpctx);
 8611|      0|        mp_wakeup_core(mpctx);
 8612|      0|    }
 8613|       |
 8614|  24.7k|    if (opt_ptr == &opts->play_dir) {
  ------------------
  |  Branch (8614:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->edition_id) {
  ------------------
  |  Branch (8624:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->pause)
  ------------------
  |  Branch (8684:9): [True: 0, False: 24.7k]
  ------------------
 8685|      0|        set_pause_state(mpctx, opts->pause);
 8686|       |
 8687|  24.7k|    if (opt_ptr == &opts->audio_delay) {
  ------------------
  |  Branch (8687:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->vo->window_scale)
  ------------------
  |  Branch (8697:9): [True: 0, False: 24.7k]
  ------------------
 8698|      0|        update_window_scale(mpctx);
 8699|       |
 8700|  24.7k|    if (opt_ptr == &opts->vo->hidpi_window_scale)
  ------------------
  |  Branch (8700:9): [True: 0, False: 24.7k]
  ------------------
 8701|      0|        update_hidpi_window_scale(mpctx, opts->vo->hidpi_window_scale);
 8702|       |
 8703|  24.7k|    if (opt_ptr == &opts->cursor_autohide_delay)
  ------------------
  |  Branch (8703:9): [True: 0, False: 24.7k]
  ------------------
 8704|      0|        mpctx->mouse_timer = 0;
 8705|       |
 8706|  24.7k|    if (opt_ptr == &opts->loop_file) {
  ------------------
  |  Branch (8706:9): [True: 0, False: 24.7k]
  ------------------
 8707|      0|        mpctx->remaining_file_loops = opts->loop_file;
 8708|      0|        mp_notify_property(mpctx, "remaining-file-loops");
 8709|      0|    }
 8710|       |
 8711|  24.7k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1] ||
  ------------------
  |  Branch (8711:9): [True: 0, False: 24.7k]
  |  Branch (8711:41): [True: 0, False: 24.7k]
  ------------------
 8712|  24.7k|        opt_ptr == &opts->ab_loop_count) {
  ------------------
  |  Branch (8712:9): [True: 0, False: 24.7k]
  ------------------
 8713|      0|        mpctx->remaining_ab_loops = opts->ab_loop_count;
 8714|      0|        mp_notify_property(mpctx, "remaining-ab-loops");
 8715|      0|    }
 8716|       |
 8717|  24.7k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) {
  ------------------
  |  Branch (8717:9): [True: 0, False: 24.7k]
  |  Branch (8717:41): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (opt_ptr == &opts->vf_settings)
  ------------------
  |  Branch (8724:9): [True: 0, False: 24.7k]
  ------------------
 8725|      0|        set_filters(mpctx, STREAM_VIDEO, opts->vf_settings);
 8726|       |
 8727|  24.7k|    if (opt_ptr == &opts->af_settings)
  ------------------
  |  Branch (8727:9): [True: 0, False: 24.7k]
  ------------------
 8728|      0|        set_filters(mpctx, STREAM_AUDIO, opts->af_settings);
 8729|       |
 8730|  99.0k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (8730:24): [True: 74.2k, False: 24.7k]
  ------------------
 8731|   173k|        for (int order = 0; order < num_ptracks[type]; order++) {
  ------------------
  |  Branch (8731:29): [True: 99.0k, False: 74.2k]
  ------------------
 8732|  99.0k|            if (opt_ptr == &opts->stream_id[order][type])
  ------------------
  |  Branch (8732:17): [True: 0, False: 99.0k]
  ------------------
 8733|      0|                update_track_switch(mpctx, order, type);
 8734|  99.0k|        }
 8735|  74.2k|    }
 8736|       |
 8737|  24.7k|    if (opt_ptr == &opts->vo->fullscreen && !opts->vo->fullscreen)
  ------------------
  |  Branch (8737:9): [True: 0, False: 24.7k]
  |  Branch (8737:45): [True: 0, False: 0]
  ------------------
 8738|      0|        mpctx->mouse_event_ts--; // Show mouse cursor
 8739|       |
 8740|  24.7k|    if (opt_ptr == &opts->vo->taskbar_progress)
  ------------------
  |  Branch (8740:9): [True: 0, False: 24.7k]
  ------------------
 8741|      0|        update_vo_playback_state(mpctx);
 8742|       |
 8743|  24.7k|    if (opt_ptr == &opts->force_vo)
  ------------------
  |  Branch (8743:9): [True: 0, False: 24.7k]
  ------------------
 8744|      0|        handle_force_window(mpctx, false);
 8745|       |
 8746|  24.7k|    if (opt_ptr == &opts->image_display_duration && mpctx->vo_chain
  ------------------
  |  Branch (8746:9): [True: 0, False: 24.7k]
  |  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|  24.7k|}
mp_notify_property:
 8753|  51.5k|{
 8754|  51.5k|    mp_client_property_change(mpctx, property);
 8755|  51.5k|}
command.c:run_next_hook_handler:
  246|   148k|{
  247|   148k|    struct command_ctx *cmd = mpctx->command_ctx;
  248|       |
  249|   148k|    for (int n = start; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (249:25): [True: 0, False: 148k]
  ------------------
  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|   148k|    mp_wakeup_core(mpctx); // finished hook
  263|   148k|    return 0;
  264|   148k|}
command.c:match_property:
 5009|  74.4M|{
 5010|  74.4M|    if (strcmp(a, "*") == 0)
  ------------------
  |  Branch (5010:9): [True: 247k, False: 74.2M]
  ------------------
 5011|   247k|        return true;
 5012|       |    // Give options and properties the same ID each, so change notifications
 5013|       |    // work both way.
 5014|  74.2M|    if (strncmp(a, "options/", 8) == 0)
  ------------------
  |  Branch (5014:9): [True: 0, False: 74.2M]
  ------------------
 5015|      0|        a += 8;
 5016|  74.2M|    if (strncmp(b, "options/", 8) == 0)
  ------------------
  |  Branch (5016:9): [True: 0, False: 74.2M]
  ------------------
 5017|      0|        b += 8;
 5018|  74.2M|    int len_a = prefix_len(a);
 5019|  74.2M|    int len_b = prefix_len(b);
 5020|  74.2M|    return strncmp(a, b, MPMIN(len_a, len_b)) == 0;
  ------------------
  |  |   45|  74.2M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 45.7M, False: 28.4M]
  |  |  ------------------
  ------------------
 5021|  74.4M|}
command.c:prefix_len:
 5003|   148M|{
 5004|   148M|    const char *end = strchr(p, '/');
 5005|   148M|    return end ? end - p : strlen(p) + 1;
  ------------------
  |  Branch (5005:12): [True: 46.2M, False: 102M]
  ------------------
 5006|   148M|}
command.c:cache_dump_poll:
 7450|   550k|{
 7451|   550k|    struct command_ctx *ctx = mpctx->command_ctx;
 7452|   550k|    struct mp_cmd_ctx *cmd = ctx->cache_dump_cmd;
 7453|       |
 7454|   550k|    if (!cmd)
  ------------------
  |  Branch (7454:9): [True: 550k, False: 0]
  ------------------
 7455|   550k|        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|  49.5k|{
 6328|  49.5k|    struct mp_cmd_ctx *cmd = p;
 6329|  49.5k|    struct MPContext *mpctx = cmd->mpctx;
 6330|  49.5k|    bool write_watch_later = *(bool *)cmd->priv;
 6331|  49.5k|    if (write_watch_later || mpctx->opts->position_save_on_quit)
  ------------------
  |  Branch (6331:9): [True: 0, False: 49.5k]
  |  Branch (6331:30): [True: 0, False: 49.5k]
  ------------------
 6332|      0|        mp_write_watch_later_conf(mpctx);
 6333|  49.5k|    mpctx->stop_play = PT_QUIT;
 6334|  49.5k|    mpctx->quit_custom_rc = cmd->args[0].v.i;
 6335|       |    mpctx->has_quit_custom_rc = true;
 6336|  49.5k|    mp_wakeup_core(mpctx);
 6337|  49.5k|}
command.c:cmd_loadfile:
 6569|  24.7k|{
 6570|  24.7k|    struct mp_cmd_ctx *cmd = p;
 6571|  24.7k|    struct MPContext *mpctx = cmd->mpctx;
 6572|  24.7k|    char *filename = cmd->args[0].v.s;
 6573|  24.7k|    int action_flag = cmd->args[1].v.i;
 6574|  24.7k|    int insert_at_idx = cmd->args[2].v.i;
 6575|       |
 6576|  24.7k|    struct load_action action = get_load_action(mpctx, action_flag);
 6577|       |
 6578|  24.7k|    if (action.type == LOAD_TYPE_REPLACE)
  ------------------
  |  Branch (6578:9): [True: 24.7k, False: 0]
  ------------------
 6579|  24.7k|        playlist_clear(mpctx->playlist);
 6580|       |
 6581|  24.7k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 6582|  24.7k|    struct playlist_entry *entry = playlist_entry_new(path);
 6583|  24.7k|    talloc_free(path);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 6584|  24.7k|    if (cmd->args[3].v.str_list) {
  ------------------
  |  Branch (6584:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    struct playlist_entry *at = get_insert_entry(mpctx, &action, insert_at_idx);
 6591|  24.7k|    playlist_insert_at(mpctx->playlist, entry, at);
 6592|       |
 6593|  24.7k|    struct mpv_node *res = &cmd->result;
 6594|  24.7k|    node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 6595|  24.7k|    node_map_add_int64(res, "playlist_entry_id", entry->id);
 6596|       |
 6597|  24.7k|    if (action.type == LOAD_TYPE_REPLACE || (action.play && !mpctx->playlist->current)) {
  ------------------
  |  Branch (6597:9): [True: 24.7k, False: 0]
  |  Branch (6597:46): [True: 0, False: 0]
  |  Branch (6597:61): [True: 0, False: 0]
  ------------------
 6598|  24.7k|        if (mpctx->opts->position_save_on_quit) // requested in issue #1148
  ------------------
  |  Branch (6598:13): [True: 0, False: 24.7k]
  ------------------
 6599|      0|            mp_write_watch_later_conf(mpctx);
 6600|  24.7k|        mp_set_playlist_entry(mpctx, entry);
 6601|  24.7k|    }
 6602|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6603|  24.7k|    mp_wakeup_core(mpctx);
 6604|  24.7k|}
command.c:get_load_action:
 6536|  24.7k|{
 6537|  24.7k|    int type = action_flag & 3;
 6538|  24.7k|    bool play = (action_flag >> 3) & 1;
 6539|  24.7k|    switch (type) {
 6540|  24.7k|    case 0:
  ------------------
  |  Branch (6540:5): [True: 24.7k, False: 0]
  ------------------
 6541|  24.7k|        return (struct load_action){LOAD_TYPE_REPLACE, .play = play};
 6542|      0|    case 1:
  ------------------
  |  Branch (6542:5): [True: 0, False: 24.7k]
  ------------------
 6543|      0|        return (struct load_action){LOAD_TYPE_APPEND, .play = play};
 6544|      0|    case 2:
  ------------------
  |  Branch (6544:5): [True: 0, False: 24.7k]
  ------------------
 6545|      0|        return (struct load_action){LOAD_TYPE_INSERT_NEXT, .play = play};
 6546|      0|    case 3:
  ------------------
  |  Branch (6546:5): [True: 0, False: 24.7k]
  ------------------
 6547|      0|        return (struct load_action){LOAD_TYPE_INSERT_AT, .play = play};
 6548|      0|    default: // default: replace
  ------------------
  |  Branch (6548:5): [True: 0, False: 24.7k]
  ------------------
 6549|       |        return (struct load_action){LOAD_TYPE_REPLACE, .play = true};
 6550|  24.7k|    }
 6551|  24.7k|}
command.c:get_insert_entry:
 6555|  24.7k|{
 6556|  24.7k|    switch (action->type) {
 6557|      0|    case LOAD_TYPE_INSERT_NEXT:
  ------------------
  |  Branch (6557:5): [True: 0, False: 24.7k]
  ------------------
 6558|      0|        return playlist_get_next(mpctx->playlist, +1);
 6559|      0|    case LOAD_TYPE_INSERT_AT:
  ------------------
  |  Branch (6559:5): [True: 0, False: 24.7k]
  ------------------
 6560|      0|        return playlist_entry_from_index(mpctx->playlist, insert_at_idx);
 6561|  24.7k|    case LOAD_TYPE_REPLACE:
  ------------------
  |  Branch (6561:5): [True: 24.7k, False: 0]
  ------------------
 6562|  24.7k|    case LOAD_TYPE_APPEND:
  ------------------
  |  Branch (6562:5): [True: 0, False: 24.7k]
  ------------------
 6563|  24.7k|    default:
  ------------------
  |  Branch (6563:5): [True: 0, False: 24.7k]
  ------------------
 6564|       |        return NULL;
 6565|  24.7k|    }
 6566|  24.7k|}
command.c:overlay_uninit:
 5652|  24.7k|{
 5653|  24.7k|    struct command_ctx *cmd = mpctx->command_ctx;
 5654|  24.7k|    if (!mpctx->osd)
  ------------------
  |  Branch (5654:9): [True: 0, False: 24.7k]
  ------------------
 5655|      0|        return;
 5656|  24.7k|    for (int id = 0; id < cmd->num_overlays; id++)
  ------------------
  |  Branch (5656:22): [True: 0, False: 24.7k]
  ------------------
 5657|      0|        replace_overlay(mpctx, id, &(struct overlay){0});
 5658|  24.7k|    osd_set_bitmaps(mpctx->osd, OSDTYPE_EXTERNAL2, NULL);
 5659|  74.2k|    for (int n = 0; n < 2; n++)
  ------------------
  |  Branch (5659:21): [True: 49.5k, False: 24.7k]
  ------------------
 5660|  49.5k|        mp_image_unrefp(&cmd->overlay_osd[n].packed);
 5661|  24.7k|}
command.c:mp_property_filename:
  534|  1.42M|{
  535|  1.42M|    MPContext *mpctx = ctx;
  536|  1.42M|    if (!mpctx->filename)
  ------------------
  |  Branch (536:9): [True: 0, False: 1.42M]
  ------------------
  537|      0|        return M_PROPERTY_UNAVAILABLE;
  538|  1.42M|    const char *name = mpctx->demuxer ? mpctx->demuxer->server_filename : NULL;
  ------------------
  |  Branch (538:24): [True: 1.42M, False: 330]
  ------------------
  539|  1.42M|    char *filename = talloc_strdup(NULL, name ? name : mpctx->filename);
  ------------------
  |  |   50|  1.42M|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (539:42): [True: 0, False: 1.42M]
  ------------------
  540|  1.42M|    char *f = filename;
  541|  1.42M|    if (!name) {
  ------------------
  |  Branch (541:9): [True: 1.42M, False: 0]
  ------------------
  542|  1.42M|        if (mp_is_url(bstr0(filename)))
  ------------------
  |  Branch (542:13): [True: 1.42M, False: 0]
  ------------------
  543|  1.42M|            mp_url_unescape_inplace(filename);
  544|  1.42M|        f = (char *)mp_basename(filename);
  545|  1.42M|        if (!f[0])
  ------------------
  |  Branch (545:13): [True: 0, False: 1.42M]
  ------------------
  546|      0|            f = filename;
  547|  1.42M|    }
  548|  1.42M|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (548:9): [True: 0, False: 1.42M]
  ------------------
  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|  1.42M|    int r = m_property_strdup_ro(action, arg, f);
  557|  1.42M|    talloc_free(filename);
  ------------------
  |  |   47|  1.42M|#define talloc_free                     ta_free
  ------------------
  558|  1.42M|    return r;
  559|  1.42M|}
command.c:mp_property_media_title:
  635|  1.49M|{
  636|  1.49M|    MPContext *mpctx = ctx;
  637|  1.49M|    const char *name = mp_find_non_filename_media_title(mpctx);
  638|  1.49M|    if (name && name[0])
  ------------------
  |  Branch (638:9): [True: 73.1k, False: 1.42M]
  |  Branch (638:17): [True: 73.1k, False: 0]
  ------------------
  639|  73.1k|        return m_property_strdup_ro(action, arg, name);
  640|  1.42M|    return mp_property_filename(ctx, prop, action, arg);
  641|  1.49M|}
command.c:str_compare:
 8233|   173M|{
 8234|   173M|    return strcmp(*(const char **)a, *(const char **)b);
 8235|   173M|}
command.c:command_event:
 8312|   670k|{
 8313|   670k|    struct command_ctx *ctx = mpctx->command_ctx;
 8314|       |
 8315|   670k|    if (event == MPV_EVENT_START_FILE) {
  ------------------
  |  Branch (8315:9): [True: 24.7k, False: 645k]
  ------------------
 8316|  24.7k|        ctx->last_seek_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  24.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8317|  24.7k|        ctx->marked_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  24.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8318|  24.7k|        ctx->marked_permanent = false;
 8319|  24.7k|    }
 8320|       |
 8321|   670k|    if (event == MPV_EVENT_PLAYBACK_RESTART) {
  ------------------
  |  Branch (8321:9): [True: 21.9k, False: 648k]
  ------------------
 8322|  21.9k|        ctx->last_seek_time = mp_time_sec();
 8323|  21.9k|        run_command_opts(mpctx);
 8324|  21.9k|    }
 8325|       |
 8326|   670k|    if (event == MPV_EVENT_VIDEO_RECONFIG && ctx->hwdec_osd_mode) {
  ------------------
  |  Branch (8326:9): [True: 60.9k, False: 609k]
  |  Branch (8326:46): [True: 0, False: 60.9k]
  ------------------
 8327|      0|        show_property_osd(mpctx, "hwdec", ctx->hwdec_osd_mode);
 8328|      0|        ctx->hwdec_osd_mode = 0;
 8329|      0|    }
 8330|       |
 8331|   670k|    if (event == MPV_EVENT_IDLE)
  ------------------
  |  Branch (8331:9): [True: 49.3k, False: 620k]
  ------------------
 8332|  49.3k|        run_command_opts(mpctx);
 8333|       |
 8334|   670k|    if (event == MPV_EVENT_END_FILE)
  ------------------
  |  Branch (8334:9): [True: 24.7k, False: 645k]
  ------------------
 8335|  24.7k|        mp_msg_flush_status_line(mpctx->log, false);
 8336|       |
 8337|   670k|    if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
  ------------------
  |  Branch (8337:9): [True: 24.7k, False: 645k]
  |  Branch (8337:40): [True: 21.7k, False: 623k]
  ------------------
 8338|       |        // Update chapters - does nothing if something else is visible.
 8339|  46.5k|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
 8340|  46.5k|    }
 8341|   670k|    if (event == MP_EVENT_WIN_STATE2)
  ------------------
  |  Branch (8341:9): [True: 0, False: 670k]
  ------------------
 8342|      0|        ctx->cached_window_scale = 0;
 8343|       |
 8344|   670k|    if (event == MP_EVENT_METADATA_UPDATE) {
  ------------------
  |  Branch (8344:9): [True: 24.2k, False: 646k]
  ------------------
 8345|  24.2k|        struct playlist_entry *const pe = mpctx->playing;
 8346|  24.2k|        if (pe && !pe->title) {
  ------------------
  |  Branch (8346:13): [True: 24.2k, False: 0]
  |  Branch (8346:19): [True: 24.2k, False: 0]
  ------------------
 8347|  24.2k|            const char *const name = mp_find_non_filename_media_title(mpctx);
 8348|  24.2k|            if (name && name[0]) {
  ------------------
  |  Branch (8348:17): [True: 2.00k, False: 22.2k]
  |  Branch (8348:25): [True: 2.00k, False: 0]
  ------------------
 8349|  2.00k|                pe->title = talloc_strdup(pe, name);
  ------------------
  |  |   50|  2.00k|#define talloc_strdup                   ta_xstrdup
  ------------------
 8350|  2.00k|                mp_notify_property(mpctx, "playlist");
 8351|  2.00k|            }
 8352|  24.2k|        }
 8353|  24.2k|    }
 8354|   670k|}
command.c:update_priority:
 8400|  24.7k|{
 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|  24.7k|}

mp_parse_cfgfiles:
   69|  24.7k|{
   70|  24.7k|    struct MPOpts *opts = mpctx->opts;
   71|       |
   72|  24.7k|    mp_mk_user_dir(mpctx->global, "home", "");
   73|       |
   74|  24.7k|    char *p1 = mp_get_user_path(NULL, mpctx->global, "~~home/");
   75|  24.7k|    char *p2 = mp_get_user_path(NULL, mpctx->global, "~~old_home/");
   76|  24.7k|    if (strcmp(p1, p2) != 0 && mp_path_exists(p2)) {
  ------------------
  |  Branch (76:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    talloc_free(p1);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
   82|  24.7k|    talloc_free(p2);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
   83|       |
   84|  24.7k|    char *section = NULL;
   85|  24.7k|    bool encoding = opts->encode_opts->file && opts->encode_opts->file[0];
  ------------------
  |  Branch (85:21): [True: 0, False: 24.7k]
  |  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|  24.7k|    if (encoding)
  ------------------
  |  Branch (90:9): [True: 0, False: 24.7k]
  ------------------
   91|      0|        section = "playback-default";
   92|       |
   93|  24.7k|    load_all_cfgfiles(mpctx, NULL, "encoding-profiles.conf");
   94|       |
   95|  24.7k|    load_all_cfgfiles(mpctx, section, "mpv.conf|config");
   96|       |
   97|  24.7k|    if (encoding) {
  ------------------
  |  Branch (97:9): [True: 0, False: 24.7k]
  ------------------
   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|  24.7k|}
mp_load_auto_profiles:
  165|  24.7k|{
  166|  24.7k|    mp_auto_load_profile(mpctx, "protocol",
  167|  24.7k|                         mp_split_proto(bstr0(mpctx->filename), NULL));
  168|  24.7k|    mp_auto_load_profile(mpctx, "extension",
  169|  24.7k|                         mp_get_ext(bstr0(mpctx->filename)));
  170|       |
  171|  24.7k|    mp_load_per_file_config(mpctx);
  172|  24.7k|}
mp_get_playback_resume_dir:
  203|  24.7k|{
  204|  24.7k|    char *wl_dir = mpctx->opts->watch_later_dir;
  205|  24.7k|    if (wl_dir && wl_dir[0]) {
  ------------------
  |  Branch (205:9): [True: 0, False: 24.7k]
  |  Branch (205:19): [True: 0, False: 0]
  ------------------
  206|      0|        wl_dir = mp_get_user_path(NULL, mpctx->global, wl_dir);
  207|  24.7k|    } else {
  208|  24.7k|        wl_dir = mp_find_user_file(NULL, mpctx->global, "state", MP_WATCH_LATER_CONF);
  ------------------
  |  |  174|  24.7k|#define MP_WATCH_LATER_CONF "watch_later"
  ------------------
  209|  24.7k|    }
  210|  24.7k|    return wl_dir;
  211|  24.7k|}
mp_load_playback_resume:
  418|  24.7k|{
  419|  24.7k|    bool resume = false;
  420|  24.7k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (420:9): [True: 0, False: 24.7k]
  ------------------
  421|      0|        return resume;
  422|  24.7k|    char *fname = mp_get_playback_resume_config_filename(mpctx, file);
  423|  24.7k|    if (fname && mp_path_exists(fname)) {
  ------------------
  |  Branch (423:9): [True: 0, False: 24.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|  24.7k|    talloc_free(fname);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  439|  24.7k|    return resume;
  440|  24.7k|}
mp_check_playlist_resume:
  449|  24.7k|{
  450|  24.7k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (450:9): [True: 0, False: 24.7k]
  ------------------
  451|      0|        return NULL;
  452|  24.7k|    for (int n = 0; n < playlist->num_entries; n++) {
  ------------------
  |  Branch (452:21): [True: 0, False: 24.7k]
  ------------------
  453|      0|        struct playlist_entry *e = playlist->entries[n];
  454|      0|        char *conf = mp_get_playback_resume_config_filename(mpctx, e->filename);
  455|      0|        bool exists = conf && mp_path_exists(conf);
  ------------------
  |  Branch (455:23): [True: 0, False: 0]
  |  Branch (455:31): [True: 0, False: 0]
  ------------------
  456|      0|        talloc_free(conf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  457|      0|        if (exists)
  ------------------
  |  Branch (457:13): [True: 0, False: 0]
  ------------------
  458|      0|            return e;
  459|      0|    }
  460|  24.7k|    return NULL;
  461|  24.7k|}
configfiles.c:load_all_cfgfiles:
   58|  49.5k|{
   59|  49.5k|    char **cf = mp_find_all_config_files(NULL, mpctx->global, filename);
   60|  49.5k|    for (int i = 0; cf && cf[i]; i++)
  ------------------
  |  Branch (60:21): [True: 49.5k, False: 0]
  |  Branch (60:27): [True: 0, False: 49.5k]
  ------------------
   61|      0|        m_config_parse_config_file(mpctx->mconfig, mpctx->global, cf[i], section, 0);
   62|  49.5k|    talloc_free(cf);
  ------------------
  |  |   47|  49.5k|#define talloc_free                     ta_free
  ------------------
   63|  49.5k|}
configfiles.c:mp_auto_load_profile:
  151|  49.5k|{
  152|  49.5k|    if (!item.len)
  ------------------
  |  Branch (152:9): [True: 24.7k, False: 24.7k]
  ------------------
  153|  24.7k|        return;
  154|       |
  155|  24.7k|    char t[512];
  156|  24.7k|    snprintf(t, sizeof(t), "%s.%.*s", category, BSTR_P(item));
  ------------------
  |  |  307|  24.7k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 24.7k, False: 0]
  |  |  ------------------
  ------------------
  157|  24.7k|    m_profile_t *p = m_config_get_profile0(mpctx->mconfig, t);
  158|  24.7k|    if (p) {
  ------------------
  |  Branch (158:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|}
configfiles.c:mp_load_per_file_config:
  118|  24.7k|{
  119|  24.7k|    struct MPOpts *opts = mpctx->opts;
  120|  24.7k|    char *confpath;
  121|  24.7k|    char cfg[512];
  122|  24.7k|    const char *file = mpctx->filename;
  123|       |
  124|  24.7k|    if (opts->use_filedir_conf) {
  ------------------
  |  Branch (124:9): [True: 0, False: 24.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|  24.7k|}
configfiles.c:mp_get_playback_resume_config_filename:
  215|  24.7k|{
  216|  24.7k|    struct MPOpts *opts = mpctx->opts;
  217|  24.7k|    char *res = NULL;
  218|  24.7k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  24.7k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.7k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  219|  24.7k|    if (opts->ignore_path_in_watch_later_config && !mp_is_url(bstr0(path)))
  ------------------
  |  Branch (219:9): [True: 0, False: 24.7k]
  |  Branch (219:52): [True: 0, False: 0]
  ------------------
  220|      0|        path = mp_basename(path);
  221|       |
  222|  24.7k|    bstr hashstr = mp_hash_to_bstr(tmp, path, strlen(path), "MD5");
  223|  24.7k|    char *wl_dir = mp_get_playback_resume_dir(mpctx);
  224|  24.7k|    if (wl_dir && wl_dir[0])
  ------------------
  |  Branch (224:9): [True: 0, False: 24.7k]
  |  Branch (224:19): [True: 0, False: 0]
  ------------------
  225|      0|        res = mp_path_join_bstr(NULL, bstr0(wl_dir), hashstr);
  226|  24.7k|    talloc_free(wl_dir);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  227|  24.7k|    talloc_free(tmp);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  228|  24.7k|    return res;
  229|  24.7k|}

disc_nav_reset:
  100|  49.5k|{
  101|  49.5k|    struct disc_nav_state *st = mpctx->disc_nav;
  102|  49.5k|    if (!st)
  ------------------
  |  Branch (102:9): [True: 49.5k, False: 0]
  ------------------
  103|  49.5k|        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|  24.7k|{
  114|  24.7k|    if (!mpctx->disc_nav)
  ------------------
  |  Branch (114:9): [True: 24.7k, False: 0]
  ------------------
  115|  24.7k|        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|   250k|{
  122|   250k|    if (!mpctx->demuxer || !mpctx->demuxer->stream)
  ------------------
  |  Branch (122:9): [True: 0, False: 250k]
  |  Branch (122:28): [True: 1.99k, False: 248k]
  ------------------
  123|  1.99k|        return NULL;
  124|   248k|    struct stream *s = mpctx->demuxer->stream;
  125|   248k|    if (!s->info || !s->info->name)
  ------------------
  |  Branch (125:9): [True: 0, False: 248k]
  |  Branch (125:21): [True: 0, False: 248k]
  ------------------
  126|      0|        return NULL;
  127|   248k|    const char *n = s->info->name;
  128|   248k|    if (strcmp(n, "dvdnav") == 0 || strcmp(n, "ifo_dvdnav") == 0 ||
  ------------------
  |  Branch (128:9): [True: 0, False: 248k]
  |  Branch (128:37): [True: 0, False: 248k]
  ------------------
  129|   248k|        strcmp(n, "bd") == 0 || strcmp(n, "bdmv/bluray") == 0)
  ------------------
  |  Branch (129:9): [True: 0, False: 248k]
  |  Branch (129:33): [True: 0, False: 248k]
  ------------------
  130|      0|    {
  131|      0|        return s;
  132|      0|    }
  133|   248k|    return NULL;
  134|   248k|}
disc_nav_update:
  516|   250k|{
  517|   250k|    struct stream *s = disc_nav_get_stream(mpctx);
  518|   250k|    if (!s && !mpctx->disc_nav)
  ------------------
  |  Branch (518:9): [True: 250k, False: 0]
  |  Branch (518:15): [True: 250k, False: 0]
  ------------------
  519|   250k|        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|  24.2k|{
  255|  24.2k|    struct subfn *slist = talloc_array_ptrtype(NULL, slist, 1);
  ------------------
  |  |   36|  24.2k|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|  24.2k|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|  24.2k|    int n = 0;
  257|       |
  258|       |    // Load subtitles from current media directory
  259|  24.2k|    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|  24.2k|    if (opts->sub_auto >= 0) {
  ------------------
  |  Branch (262:9): [True: 24.2k, False: 0]
  ------------------
  263|  24.2k|        load_paths(global, opts, &slist, &n, fname, opts->sub_paths, "sub",
  264|  24.2k|                   STREAM_SUB);
  265|  24.2k|    }
  266|       |
  267|  24.2k|    if (opts->audiofile_auto >= 0) {
  ------------------
  |  Branch (267:9): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|    qsort(slist, n, sizeof(*slist), compare_filename);
  274|       |
  275|  24.2k|    filter_subidx(&slist, &n);
  276|       |
  277|       |    // Sort subs by priority and append them
  278|  24.2k|    qsort(slist, n, sizeof(*slist), compare_priority);
  279|       |
  280|  24.2k|    struct subfn z = {0};
  281|  24.2k|    MP_TARRAY_APPEND(NULL, slist, n, z);
  ------------------
  |  |  105|  24.2k|    do {                                            \
  |  |  106|  24.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.2k|    do {                                            \
  |  |  |  |   97|  24.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 24.2k]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|            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.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.2k|        (idxvar)++;                                 \
  |  |  109|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  282|       |
  283|  24.2k|    return slist;
  284|  24.2k|}
external_files.c:append_dir_external_files:
   75|  24.2k|{
   76|  24.2k|    void *tmpmem = talloc_new(NULL);
  ------------------
  |  |   40|  24.2k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.2k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   77|  24.2k|    struct mp_log *log = mp_log_new(tmpmem, global->log, "find_files");
   78|       |
   79|  24.2k|    struct bstr f_fbname = bstr0(mp_basename(fname));
   80|  24.2k|    struct bstr f_fname = mp_iconv_to_utf8(log, f_fbname,
   81|  24.2k|                                           "UTF-8-MAC", MP_NO_LATIN1_FALLBACK);
   82|  24.2k|    struct bstr f_fname_noext = bstrdup(tmpmem, mp_strip_ext(f_fname));
   83|  24.2k|    struct bstr f_fname_trim = bstr_strip(f_fname_noext);
   84|       |
   85|  24.2k|    if (f_fbname.start != f_fname.start)
  ------------------
  |  Branch (85:9): [True: 0, False: 24.2k]
  ------------------
   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|  24.2k|    char *path0 = bstrdup0(tmpmem, path);
   89|       |
   90|  24.2k|    if (mp_is_url(bstr0(path0)))
  ------------------
  |  Branch (90:9): [True: 24.2k, False: 0]
  ------------------
   91|  24.2k|        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|  24.2k| out:
  197|  24.2k|    talloc_free(tmpmem);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
  198|  24.2k|}
external_files.c:load_paths:
  230|  24.2k|{
  231|  24.2k|    for (int i = 0; paths && paths[i]; i++) {
  ------------------
  |  Branch (231:21): [True: 0, False: 24.2k]
  |  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|  24.2k|    char *mp_subdir = mp_find_config_file(NULL, global, cfg_path);
  243|  24.2k|    if (mp_subdir) {
  ------------------
  |  Branch (243:9): [True: 0, False: 24.2k]
  ------------------
  244|      0|        append_dir_external_files(global, opts, slist, nsubs, bstr0(mp_subdir),
  245|      0|                                  fname, 1, type);
  246|      0|    }
  247|  24.2k|    talloc_free(mp_subdir);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
  248|  24.2k|}
external_files.c:filter_subidx:
  210|  24.2k|{
  211|  24.2k|    const char *prev = NULL;
  212|  24.2k|    for (int n = 0; n < *nsub; n++) {
  ------------------
  |  Branch (212:21): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|    for (int n = *nsub - 1; n >= 0; n--) {
  ------------------
  |  Branch (221:29): [True: 0, False: 24.2k]
  ------------------
  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|  24.2k|}

mp_abort_playback_async:
   73|  24.7k|{
   74|  24.7k|    mp_cancel_trigger(mpctx->playback_abort);
   75|       |
   76|  24.7k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   77|       |
   78|  24.7k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (78:21): [True: 0, False: 24.7k]
  ------------------
   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|  24.7k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|  24.7k|}
track_is_visible:
  318|  90.6k|{
  319|  90.6k|    if (!track_in_current_edition(mpctx, track))
  ------------------
  |  Branch (319:9): [True: 0, False: 90.6k]
  ------------------
  320|      0|        return false;
  321|  90.6k|    if (track->dependent_track && !mpctx->opts->show_dependent_tracks)
  ------------------
  |  Branch (321:9): [True: 0, False: 90.6k]
  |  Branch (321:35): [True: 0, False: 0]
  ------------------
  322|      0|        return false;
  323|  90.6k|    return true;
  324|  90.6k|}
print_track_list:
  327|  24.5k|{
  328|  24.5k|    if (mpctx->opts->term_show_tracks == 2)
  ------------------
  |  Branch (328:9): [True: 0, False: 24.5k]
  ------------------
  329|      0|        return;
  330|  24.5k|    if (msg)
  ------------------
  |  Branch (330:9): [True: 0, False: 24.5k]
  ------------------
  331|  24.5k|        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|  98.1k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (332:21): [True: 73.5k, False: 24.5k]
  ------------------
  333|   202k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (333:25): [True: 129k, False: 73.5k]
  ------------------
  334|   129k|            struct track *track = mpctx->tracks[n];
  335|   129k|            if (track->type != t || !track_is_visible(mpctx, track))
  ------------------
  |  Branch (335:17): [True: 86.2k, False: 43.1k]
  |  Branch (335:37): [True: 0, False: 43.1k]
  ------------------
  336|  86.2k|                continue;
  337|  43.1k|            if (mpctx->opts->term_show_tracks == 1 && !track->selected)
  ------------------
  |  Branch (337:17): [True: 0, False: 43.1k]
  |  Branch (337:55): [True: 0, False: 0]
  ------------------
  338|      0|                continue;
  339|       |            // Indent tracks after messages like "Tracks switched" and
  340|       |            // "Playing:".
  341|  43.1k|            print_stream(mpctx, track, msg ||
  ------------------
  |  Branch (341:40): [True: 0, False: 43.1k]
  ------------------
  342|  43.1k|                         mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (342:26): [True: 0, False: 43.1k]
  ------------------
  343|  43.1k|                         mpctx->playing->playlist_path);
  ------------------
  |  Branch (343:26): [True: 0, False: 43.1k]
  ------------------
  344|  43.1k|        }
  345|  73.5k|    }
  346|  24.5k|}
update_demuxer_properties:
  349|   274k|{
  350|   274k|    struct demuxer *demuxer = mpctx->demuxer;
  351|   274k|    if (!demuxer)
  ------------------
  |  Branch (351:9): [True: 0, False: 274k]
  ------------------
  352|      0|        return;
  353|   274k|    demux_update(demuxer, get_current_time(mpctx));
  354|   274k|    int events = demuxer->events;
  355|   274k|    if ((events & DEMUX_EVENT_INIT) && demuxer->num_editions > 1 &&
  ------------------
  |  Branch (355:9): [True: 24.2k, False: 250k]
  |  Branch (355:40): [True: 269, False: 23.9k]
  ------------------
  356|    269|        mpctx->opts->term_show_editions != 2)
  ------------------
  |  Branch (356:9): [True: 269, False: 0]
  ------------------
  357|    269|    {
  358|    807|        for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (358:25): [True: 538, False: 269]
  ------------------
  359|    538|            if (mpctx->opts->term_show_editions == 1 && n != demuxer->edition)
  ------------------
  |  Branch (359:17): [True: 0, False: 538]
  |  Branch (359:57): [True: 0, False: 0]
  ------------------
  360|      0|                continue;
  361|    538|            struct demux_edition *edition = &demuxer->editions[n];
  362|    538|            char b[128] = {0};
  363|    538|            if (mpctx->playlist->num_entries > 1 || mpctx->playing->playlist_path)
  ------------------
  |  Branch (363:17): [True: 0, False: 538]
  |  Branch (363:53): [True: 0, False: 538]
  ------------------
  364|      0|                APPEND(b, " ");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  365|    538|            APPEND(b, "%s --edition=%d", n == demuxer->edition ?
  ------------------
  |  |  240|  1.07k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 269, False: 269]
  |  |  ------------------
  ------------------
  366|    538|                   BLACK_CIRCLE : WHITE_CIRCLE, n);
  367|    538|            char *name = mp_tags_get_str(edition->metadata, "title");
  368|    538|            if (name)
  ------------------
  |  Branch (368:17): [True: 0, False: 538]
  ------------------
  369|      0|                APPEND(b, " '%s'", name);
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  370|    538|            if (edition->default_edition)
  ------------------
  |  Branch (370:17): [True: 1, False: 537]
  ------------------
  371|      1|                APPEND(b, " [default]");
  ------------------
  |  |  240|      1|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  372|    538|            MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|    538|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    538|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  373|    538|        }
  374|    269|    }
  375|   274k|    struct demuxer *tracks = mpctx->demuxer;
  376|   274k|    if (tracks->events & DEMUX_EVENT_STREAMS) {
  ------------------
  |  Branch (376:9): [True: 24.5k, False: 250k]
  ------------------
  377|  24.5k|        int num_old_tracks = mpctx->num_tracks;
  378|  24.5k|        add_demuxer_tracks(mpctx, tracks);
  379|  24.5k|        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|  24.5k|        if (mpctx->playback_initialized && mpctx->opts->stream_auto_sel) {
  ------------------
  |  Branch (386:13): [True: 273, False: 24.2k]
  |  Branch (386:44): [True: 273, False: 0]
  ------------------
  387|  1.09k|            for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (387:29): [True: 819, False: 273]
  ------------------
  388|  1.91k|                for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (388:33): [True: 1.09k, False: 819]
  ------------------
  389|  1.09k|                    if (mpctx->current_track[i][t])
  ------------------
  |  Branch (389:25): [True: 532, False: 560]
  ------------------
  390|    532|                        continue;
  391|       |                    // The output belongs to a complex filter.
  392|    560|                    if ((t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (392:26): [True: 0, False: 560]
  |  Branch (392:47): [True: 0, False: 0]
  ------------------
  393|    560|                        (t == STREAM_AUDIO && mpctx->ao_chain))
  ------------------
  |  Branch (393:26): [True: 14, False: 546]
  |  Branch (393:47): [True: 0, False: 14]
  ------------------
  394|      0|                        continue;
  395|    560|                    if (mpctx->opts->stream_id[i][t] == -2)
  ------------------
  |  Branch (395:25): [True: 273, False: 287]
  ------------------
  396|    273|                        continue;
  397|    287|                    struct track *sel = select_default_track(mpctx, i, t);
  398|    287|                    bool is_new = false;
  399|    574|                    for (int n = num_old_tracks; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (399:50): [True: 287, False: 287]
  ------------------
  400|    287|                        is_new |= mpctx->tracks[n] == sel;
  401|    287|                    if (is_new)
  ------------------
  |  Branch (401:25): [True: 273, False: 14]
  ------------------
  402|    273|                        mp_switch_track_n(mpctx, i, t, sel, 0);
  403|    287|                }
  404|    819|            }
  405|    273|        }
  406|  24.5k|        print_track_list(mpctx, NULL);
  407|  24.5k|    }
  408|   274k|    if (events & DEMUX_EVENT_METADATA) {
  ------------------
  |  Branch (408:9): [True: 24.2k, False: 250k]
  ------------------
  409|  24.2k|        struct mp_tags *info =
  410|  24.2k|            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|  24.2k|        struct mp_tags *prev = mpctx->filtered_tags;
  413|  24.2k|        int n_prev = 0;
  414|  24.2k|        bool had_output = false;
  415|  26.2k|        for (int n = 0; n < info->num_keys; n++) {
  ------------------
  |  Branch (415:25): [True: 2.01k, False: 24.2k]
  ------------------
  416|  2.01k|            if (prev && n_prev < prev->num_keys) {
  ------------------
  |  Branch (416:17): [True: 0, False: 2.01k]
  |  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|  2.01k|            struct mp_log *log = mp_log_new(NULL, mpctx->log, "!display-tags");
  424|  2.01k|            if (!had_output)
  ------------------
  |  Branch (424:17): [True: 2.01k, False: 0]
  ------------------
  425|  2.01k|                mp_info(log, "File tags:\n");
  ------------------
  |  |   78|  2.01k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  426|  2.01k|            mp_info(log, " %s: ", info->keys[n]);
  ------------------
  |  |   78|  2.01k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  427|  2.01k|            const char *p = info->values[n];
  428|  4.81k|            while (*p) {
  ------------------
  |  Branch (428:20): [True: 2.80k, False: 2.01k]
  ------------------
  429|  2.80k|                int len = strcspn(p, "\x8\xa\xb\xc\xd");
  430|  2.80k|                mp_info(log, "%.*s", len, p);
  ------------------
  |  |   78|  2.80k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  431|  2.80k|                p += len;
  432|  2.80k|                if (*p == '\r')
  ------------------
  |  Branch (432:21): [True: 110, False: 2.69k]
  ------------------
  433|    110|                    mp_info(log, " ");
  ------------------
  |  |   78|    110|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  434|       |                // Align continued lines with header
  435|  2.80k|                if (*p == '\n')
  ------------------
  |  Branch (435:21): [True: 352, False: 2.45k]
  ------------------
  436|    352|                    mp_info(log, "\n %-*s  ", (int)strlen(info->keys[n]), "");
  ------------------
  |  |   78|    352|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  437|  2.80k|                if (*p)
  ------------------
  |  Branch (437:21): [True: 815, False: 1.99k]
  ------------------
  438|    815|                    p++;
  439|  2.80k|            }
  440|  2.01k|            mp_info(log, "\n");
  ------------------
  |  |   78|  2.01k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  441|  2.01k|            had_output = true;
  442|  2.01k|            talloc_free(log);
  ------------------
  |  |   47|  2.01k|#define talloc_free                     ta_free
  ------------------
  443|  2.01k|        }
  444|  24.2k|        talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
  445|  24.2k|        mpctx->filtered_tags = info;
  446|  24.2k|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
  447|  24.2k|    }
  448|   274k|    if (events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (448:9): [True: 34.3k, False: 240k]
  ------------------
  449|  34.3k|        mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL);
  450|   274k|    if (events & DEMUX_EVENT_CODEC)
  ------------------
  |  Branch (450:9): [True: 0, False: 274k]
  ------------------
  451|      0|        mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  452|   274k|    if (events & DEMUX_EVENT_LISTS) {
  ------------------
  |  Branch (452:9): [True: 0, False: 274k]
  ------------------
  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|   274k|    demuxer->events = 0;
  476|   274k|}
reselect_demux_stream:
  483|  47.1k|{
  484|  47.1k|    if (!track->stream)
  ------------------
  |  Branch (484:9): [True: 0, False: 47.1k]
  ------------------
  485|      0|        return;
  486|  47.1k|    double pts = get_current_time(mpctx);
  487|  47.1k|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  47.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (487:9): [True: 47.1k, False: 0]
  ------------------
  488|  47.1k|        pts += get_track_seek_offset(mpctx, track);
  489|  47.1k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (489:13): [True: 5.48k, False: 41.6k]
  ------------------
  490|  5.48k|            pts -= 10.0;
  491|  47.1k|    }
  492|  47.1k|    if (refresh_only)
  ------------------
  |  Branch (492:9): [True: 0, False: 47.1k]
  ------------------
  493|      0|        demuxer_refresh_track(track->demuxer, track->stream, pts);
  494|  47.1k|    else
  495|  47.1k|        demuxer_select_track(track->demuxer, track->stream, pts, track->selected);
  496|  47.1k|}
add_demuxer_tracks:
  556|  48.7k|{
  557|   134k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++)
  ------------------
  |  Branch (557:21): [True: 85.3k, False: 48.7k]
  ------------------
  558|  85.3k|        add_stream_track(mpctx, demuxer, demux_get_stream(demuxer, n));
  559|  48.7k|}
select_default_track:
  677|   101k|{
  678|   101k|    struct MPOpts *opts = mpctx->opts;
  679|   101k|    int tid = opts->stream_id[order][type];
  680|   101k|    const struct demuxer *demuxer = mpctx->demuxer;
  681|   101k|    if (tid == -2)
  ------------------
  |  Branch (681:9): [True: 24.2k, False: 77.3k]
  ------------------
  682|  24.2k|        return NULL;
  683|  77.3k|    char **langs = process_langs(opts->stream_lang[type]);
  684|  77.3k|    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|  77.3k|    if (type == STREAM_SUB && (!langs || !strcmp(langs[0], "")) && opts->subs_match_os_language) {
  ------------------
  |  Branch (686:9): [True: 24.6k, False: 52.7k]
  |  Branch (686:32): [True: 24.6k, False: 0]
  |  Branch (686:42): [True: 0, False: 0]
  |  Branch (686:68): [True: 24.6k, False: 0]
  ------------------
  687|  24.6k|        talloc_free(langs);
  ------------------
  |  |   47|  24.6k|#define talloc_free                     ta_free
  ------------------
  688|  24.6k|        langs = add_os_langs();
  689|  24.6k|        os_langs = true;
  690|  24.6k|    }
  691|  77.3k|    const char *audio_lang = mpctx->current_track[0][STREAM_AUDIO] ?
  ------------------
  |  Branch (691:30): [True: 20.4k, False: 56.8k]
  ------------------
  692|  20.4k|                             mpctx->current_track[0][STREAM_AUDIO]->lang :
  693|  77.3k|                             NULL;
  694|  77.3k|    bool sub = type == STREAM_SUB;
  695|  77.3k|    int *preferred_programs = NULL;
  696|  77.3k|    int num_preferred_programs = 0;
  697|  77.3k|    struct track *cvt = mpctx->current_track[0][STREAM_VIDEO];
  698|  77.3k|    bool video_has_programs = cvt && cvt->stream && cvt->stream->num_program_ids;
  ------------------
  |  Branch (698:31): [True: 43.5k, False: 33.8k]
  |  Branch (698:38): [True: 43.5k, False: 0]
  |  Branch (698:53): [True: 0, False: 43.5k]
  ------------------
  699|  77.3k|    bool no_edition_mapping = !demuxer || !demuxer->edition_is_track_mapping ||
  ------------------
  |  Branch (699:31): [True: 0, False: 77.3k]
  |  Branch (699:43): [True: 77.3k, False: 0]
  ------------------
  700|      0|                              demuxer->num_editions <= 1;
  ------------------
  |  Branch (700:31): [True: 0, False: 0]
  ------------------
  701|  77.3k|    if (type != STREAM_VIDEO && video_has_programs && no_edition_mapping) {
  ------------------
  |  Branch (701:9): [True: 51.7k, False: 25.6k]
  |  Branch (701:33): [True: 0, False: 51.7k]
  |  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|  77.3k|    struct track *pick = NULL;
  706|   215k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (706:21): [True: 137k, False: 77.3k]
  ------------------
  707|   137k|        struct track *track = mpctx->tracks[n];
  708|   137k|        if (track->type != type)
  ------------------
  |  Branch (708:13): [True: 90.3k, False: 47.5k]
  ------------------
  709|  90.3k|            continue;
  710|  47.5k|        if (!track_is_visible(mpctx, track))
  ------------------
  |  Branch (710:13): [True: 0, False: 47.5k]
  ------------------
  711|      0|            continue;
  712|  47.5k|        if (track->user_tid == tid) {
  ------------------
  |  Branch (712:13): [True: 0, False: 47.5k]
  ------------------
  713|      0|            pick = track;
  714|      0|            goto cleanup;
  715|      0|        }
  716|  47.5k|        if (track->no_auto_select || track->dec_failed)
  ------------------
  |  Branch (716:13): [True: 0, False: 47.5k]
  |  Branch (716:38): [True: 4.61k, False: 42.9k]
  ------------------
  717|  4.61k|            continue;
  718|  42.9k|        if (!opts->autoload_files && track->is_external)
  ------------------
  |  Branch (718:13): [True: 0, False: 42.9k]
  |  Branch (718:38): [True: 0, False: 0]
  ------------------
  719|      0|            continue;
  720|       |        // Prefer tracks from the same programs as the selected video.
  721|  42.9k|        bool in_program = !num_preferred_programs || track->is_external ||
  ------------------
  |  Branch (721:27): [True: 42.9k, 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|  42.9k|        for (int i = 0; i < num_preferred_programs && !in_program; i++)
  ------------------
  |  Branch (723:25): [True: 0, False: 42.9k]
  |  Branch (723:55): [True: 0, False: 0]
  ------------------
  724|      0|            in_program = track_has_program(track, preferred_programs[i]);
  725|  42.9k|        if (!in_program)
  ------------------
  |  Branch (725:13): [True: 0, False: 42.9k]
  ------------------
  726|      0|            continue;
  727|  42.9k|        if (duplicate_track(mpctx, order, type, track))
  ------------------
  |  Branch (727:13): [True: 0, False: 42.9k]
  ------------------
  728|      0|            continue;
  729|  42.9k|        if (sub) {
  ------------------
  |  Branch (729:13): [True: 5.42k, False: 37.5k]
  ------------------
  730|       |            // Subtitle specific auto-selecting crap.
  731|  5.42k|            bool audio_matches = mp_match_lang((char *[]){ (char *)audio_lang, NULL }, track->lang) > 0;
  732|  5.42k|            bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
  ------------------
  |  Branch (732:27): [True: 16, False: 5.41k]
  |  Branch (732:51): [True: 0, False: 16]
  ------------------
  733|     16|                          (audio_matches && opts->subs_fallback_forced == 1));
  ------------------
  |  Branch (733:28): [True: 5, False: 11]
  |  Branch (733:45): [True: 5, False: 0]
  ------------------
  734|  5.42k|            bool lang_match = !os_langs && mp_match_lang(langs, track->lang) > 0;
  ------------------
  |  Branch (734:31): [True: 0, False: 5.42k]
  |  Branch (734:44): [True: 0, False: 0]
  ------------------
  735|  5.42k|            bool subs_fallback = (track->is_external && !track->no_default) || opts->subs_fallback == 2 ||
  ------------------
  |  Branch (735:35): [True: 0, False: 5.42k]
  |  Branch (735:57): [True: 0, False: 0]
  |  Branch (735:80): [True: 0, False: 5.42k]
  ------------------
  736|  5.42k|                                 (opts->subs_fallback == 1 && track->default_track);
  ------------------
  |  Branch (736:35): [True: 5.42k, False: 0]
  |  Branch (736:63): [True: 2.91k, False: 2.51k]
  ------------------
  737|  5.42k|            bool subs_matching_audio = (!mp_match_lang(langs, audio_lang) || opts->subs_with_matching_audio == 2 ||
  ------------------
  |  Branch (737:41): [True: 5.42k, 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|  5.42k|            if (!subs_matching_audio)
  ------------------
  |  Branch (739:17): [True: 0, False: 5.42k]
  ------------------
  740|      0|                continue;
  741|  5.42k|            if (!forced && !lang_match && !subs_fallback)
  ------------------
  |  Branch (741:17): [True: 5.42k, False: 5]
  |  Branch (741:28): [True: 5.42k, False: 0]
  |  Branch (741:43): [True: 2.50k, False: 2.91k]
  ------------------
  742|  2.50k|                continue;
  743|  2.92k|            track->forced_select = forced;
  744|  2.92k|        }
  745|  40.4k|        if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts)) {
  ------------------
  |  Branch (745:13): [True: 38.9k, False: 1.50k]
  |  Branch (745:22): [True: 312, False: 1.19k]
  ------------------
  746|  39.2k|            pick = track;
  747|  39.2k|        }
  748|  40.4k|    }
  749|       |
  750|  77.3k|    if (pick && pick->attached_picture && !mpctx->opts->audio_display)
  ------------------
  |  Branch (750:9): [True: 38.9k, False: 38.4k]
  |  Branch (750:17): [True: 284, False: 38.6k]
  |  Branch (750:43): [True: 0, False: 284]
  ------------------
  751|      0|        pick = NULL;
  752|  77.3k|cleanup:
  753|  77.3k|    talloc_free(langs);
  ------------------
  |  |   47|  77.3k|#define talloc_free                     ta_free
  ------------------
  754|  77.3k|    return pick;
  755|  77.3k|}
mark_track_selection:
  801|  4.07k|{
  802|  4.07k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  4.07k|#define mp_assert assert
  ------------------
  |  Branch (802:5): [True: 4.07k, False: 0]
  |  Branch (802:5): [True: 4.07k, False: 0]
  ------------------
  803|  4.07k|    mpctx->opts->stream_id[order][type] = value;
  804|  4.07k|    m_config_notify_change_opt_ptr(mpctx->mconfig,
  805|  4.07k|                                   &mpctx->opts->stream_id[order][type]);
  806|  4.07k|}
mp_switch_track_n:
  810|  4.59k|{
  811|  4.59k|    mp_assert(!track || track->type == type);
  ------------------
  |  |   41|  4.59k|#define mp_assert assert
  ------------------
  |  Branch (811:5): [True: 4.07k, False: 511]
  |  Branch (811:5): [True: 511, False: 0]
  ------------------
  812|  4.59k|    mp_assert(type >= 0 && type < STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  4.59k|#define mp_assert assert
  ------------------
  |  Branch (812:5): [True: 4.59k, False: 0]
  |  Branch (812:5): [True: 4.59k, False: 0]
  ------------------
  813|  4.59k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  4.59k|#define mp_assert assert
  ------------------
  |  Branch (813:5): [True: 4.59k, False: 0]
  |  Branch (813:5): [True: 4.59k, 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|  4.59k|    if (flags & FLAG_MARK_SELECTION)
  ------------------
  |  |  559|  4.59k|#define FLAG_MARK_SELECTION 1
  ------------------
  |  Branch (817:9): [True: 0, False: 4.59k]
  ------------------
  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|  4.59k|    if (!mpctx->demuxer)
  ------------------
  |  Branch (821:9): [True: 0, False: 4.59k]
  ------------------
  822|      0|        return;
  823|       |
  824|  4.59k|    struct track *current = mpctx->current_track[order][type];
  825|  4.59k|    if (track == current)
  ------------------
  |  Branch (825:9): [True: 0, False: 4.59k]
  ------------------
  826|      0|        return;
  827|       |
  828|  4.59k|    if (current && current->sink) {
  ------------------
  |  Branch (828:9): [True: 4.31k, False: 273]
  |  Branch (828:20): [True: 0, False: 4.31k]
  ------------------
  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|  4.59k|    if ((type == STREAM_VIDEO && mpctx->vo_chain && !mpctx->vo_chain->track) ||
  ------------------
  |  Branch (832:10): [True: 1.37k, False: 3.22k]
  |  Branch (832:34): [True: 0, False: 1.37k]
  |  Branch (832:53): [True: 0, False: 0]
  ------------------
  833|  4.59k|        (type == STREAM_AUDIO && mpctx->ao_chain && !mpctx->ao_chain->track))
  ------------------
  |  Branch (833:10): [True: 2.84k, False: 1.74k]
  |  Branch (833:34): [True: 0, False: 2.84k]
  |  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|  4.59k|    if (track && track->selected) {
  ------------------
  |  Branch (839:9): [True: 511, False: 4.07k]
  |  Branch (839:18): [True: 0, False: 511]
  ------------------
  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|  4.59k|    if (order == 0) {
  ------------------
  |  Branch (845:9): [True: 4.59k, False: 0]
  ------------------
  846|  4.59k|        if (type == STREAM_VIDEO) {
  ------------------
  |  Branch (846:13): [True: 1.37k, False: 3.22k]
  ------------------
  847|  1.37k|            uninit_video_chain(mpctx);
  848|  1.37k|            if (!track)
  ------------------
  |  Branch (848:17): [True: 1.34k, False: 23]
  ------------------
  849|  1.34k|                handle_force_window(mpctx, true);
  850|  3.22k|        } else if (type == STREAM_AUDIO) {
  ------------------
  |  Branch (850:20): [True: 2.84k, False: 373]
  ------------------
  851|  2.84k|            clear_audio_output_buffers(mpctx);
  852|  2.84k|            uninit_audio_chain(mpctx);
  853|  2.84k|            if (!track)
  ------------------
  |  Branch (853:17): [True: 2.64k, False: 201]
  ------------------
  854|  2.64k|                uninit_audio_out(mpctx);
  855|  2.84k|        }
  856|  4.59k|    }
  857|  4.59k|    if (type == STREAM_SUB)
  ------------------
  |  Branch (857:9): [True: 373, False: 4.21k]
  ------------------
  858|    373|        uninit_sub(mpctx, current);
  859|       |
  860|  4.59k|    if (current) {
  ------------------
  |  Branch (860:9): [True: 4.31k, False: 273]
  ------------------
  861|  4.31k|        current->selected = false;
  862|  4.31k|        reselect_demux_stream(mpctx, current, false);
  863|  4.31k|    }
  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|  4.59k|    if (type == STREAM_VIDEO && order == 0 && !current && track->image) {
  ------------------
  |  Branch (867:9): [True: 1.37k, False: 3.22k]
  |  Branch (867:33): [True: 1.37k, False: 0]
  |  Branch (867:47): [True: 0, False: 1.37k]
  |  Branch (867:59): [True: 0, False: 0]
  ------------------
  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|  4.59k|    mpctx->current_track[order][type] = track;
  880|       |
  881|  4.59k|    if (track) {
  ------------------
  |  Branch (881:9): [True: 511, False: 4.07k]
  ------------------
  882|    511|        track->selected = true;
  883|    511|        reselect_demux_stream(mpctx, track, false);
  884|    511|    }
  885|       |
  886|  4.59k|    if (type == STREAM_VIDEO && order == 0) {
  ------------------
  |  Branch (886:9): [True: 1.37k, False: 3.22k]
  |  Branch (886:33): [True: 1.37k, False: 0]
  ------------------
  887|  1.37k|        reinit_video_chain(mpctx);
  888|  3.22k|    } else if (type == STREAM_AUDIO && order == 0) {
  ------------------
  |  Branch (888:16): [True: 2.84k, False: 373]
  |  Branch (888:40): [True: 2.84k, False: 0]
  ------------------
  889|  2.84k|        reinit_audio_chain(mpctx);
  890|  2.84k|    } else if (type == STREAM_SUB && order >= 0 && order <= 2) {
  ------------------
  |  Branch (890:16): [True: 373, False: 0]
  |  Branch (890:38): [True: 373, False: 0]
  |  Branch (890:52): [True: 373, False: 0]
  ------------------
  891|    373|        reinit_sub(mpctx, track);
  892|    373|    }
  893|       |
  894|  4.59k|    mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL);
  895|  4.59k|    mp_wakeup_core(mpctx);
  896|       |
  897|  4.59k|    talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|  4.59k|#define talloc_free                     ta_free
  ------------------
  898|  4.59k|    mpctx->track_layout_hash = talloc_steal(mpctx, track_layout_hash(mpctx));
  ------------------
  |  |   38|  4.59k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  4.59k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  899|       |
  900|  4.59k|    return;
  901|      0|error:
  902|      0|    mark_track_selection(mpctx, order, type, -1);
  903|      0|}
mp_deselect_track:
  912|  4.07k|{
  913|  4.07k|    if (track && track->selected) {
  ------------------
  |  Branch (913:9): [True: 4.07k, False: 0]
  |  Branch (913:18): [True: 4.07k, False: 0]
  ------------------
  914|  8.24k|        for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (914:25): [True: 4.16k, False: 4.07k]
  ------------------
  915|  4.16k|            if (mpctx->current_track[t][track->type] != track)
  ------------------
  |  Branch (915:17): [True: 86, False: 4.07k]
  ------------------
  916|     86|                continue;
  917|  4.07k|            mp_switch_track_n(mpctx, t, track->type, NULL, 0);
  918|  4.07k|            mark_track_selection(mpctx, t, track->type, -1); // default
  919|  4.07k|        }
  920|  4.07k|    }
  921|  4.07k|}
autoload_external_files:
 1105|  24.2k|{
 1106|  24.2k|    struct MPOpts *opts = mpctx->opts;
 1107|       |
 1108|  24.2k|    if (opts->sub_auto < 0 && opts->audiofile_auto < 0 && opts->coverart_auto < 0)
  ------------------
  |  Branch (1108:9): [True: 0, False: 24.2k]
  |  Branch (1108:31): [True: 0, False: 0]
  |  Branch (1108:59): [True: 0, False: 0]
  ------------------
 1109|      0|        return;
 1110|  24.2k|    if (!opts->autoload_files || strcmp(mpctx->filename, "-") == 0)
  ------------------
  |  Branch (1110:9): [True: 0, False: 24.2k]
  |  Branch (1110:34): [True: 0, False: 24.2k]
  ------------------
 1111|      0|        return;
 1112|       |
 1113|  24.2k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  24.2k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.2k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1114|  24.2k|    struct subfn *list = find_external_files(mpctx->global, mpctx->filename, opts);
 1115|  24.2k|    talloc_steal(tmp, list);
  ------------------
  |  |   38|  24.2k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.2k|#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|  24.2k|    int sc[STREAM_TYPE_COUNT + 1] = {0};
 1120|  66.5k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1120:21): [True: 42.2k, False: 24.2k]
  ------------------
 1121|  42.2k|        mp_assert(mpctx->tracks[n]->type >= 0);
  ------------------
  |  |   41|  42.2k|#define mp_assert assert
  ------------------
  |  Branch (1121:9): [True: 42.2k, False: 0]
  ------------------
 1122|  42.2k|        mp_assert(mpctx->tracks[n]->type <= STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  42.2k|#define mp_assert assert
  ------------------
  |  Branch (1122:9): [True: 42.2k, False: 0]
  ------------------
 1123|  42.2k|        if (!mpctx->tracks[n]->attached_picture)
  ------------------
  |  Branch (1123:13): [True: 42.0k, False: 292]
  ------------------
 1124|  42.0k|            sc[mpctx->tracks[n]->type]++;
 1125|  42.2k|    }
 1126|       |
 1127|  24.2k|    for (int i = 0; list && list[i].fname; i++) {
  ------------------
  |  Branch (1127:21): [True: 24.2k, False: 0]
  |  Branch (1127:29): [True: 0, False: 24.2k]
  ------------------
 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|  24.2k|    talloc_free(tmp);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
 1159|  24.2k|}
prepare_playlist:
 1164|  24.7k|{
 1165|  24.7k|    struct MPOpts *opts = mpctx->opts;
 1166|  24.7k|    struct playlist_entry *entry = NULL;
 1167|       |
 1168|  24.7k|    if (overwrite_current)
  ------------------
  |  Branch (1168:9): [True: 0, False: 24.7k]
  ------------------
 1169|      0|        pl->current = NULL;
 1170|       |
 1171|  24.7k|    pl->playlist_completed = false;
 1172|  24.7k|    pl->playlist_started = false;
 1173|       |
 1174|  24.7k|    if (opts->playlist_pos >= 0) {
  ------------------
  |  Branch (1174:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    if (pl->playlist_dir)
  ------------------
  |  Branch (1179:9): [True: 0, False: 24.7k]
  ------------------
 1180|      0|        playlist_set_current(pl);
 1181|       |
 1182|  24.7k|    if (opts->shuffle)
  ------------------
  |  Branch (1182:9): [True: 0, False: 24.7k]
  ------------------
 1183|      0|        playlist_shuffle(pl);
 1184|       |
 1185|  24.7k|    if (opts->merge_files)
  ------------------
  |  Branch (1185:9): [True: 0, False: 24.7k]
  ------------------
 1186|      0|        merge_playlist_files(pl);
 1187|       |
 1188|  24.7k|    if (!pl->current || (!overwrite_current && !entry)) {
  ------------------
  |  Branch (1188:9): [True: 24.7k, False: 0]
  |  Branch (1188:26): [True: 0, False: 0]
  |  Branch (1188:48): [True: 0, False: 0]
  ------------------
 1189|  24.7k|        entry = mp_check_playlist_resume(mpctx, pl);
 1190|  24.7k|        pl->current = overwrite_current || entry ? entry : pl->current;
  ------------------
  |  Branch (1190:23): [True: 0, False: 24.7k]
  |  Branch (1190:44): [True: 0, False: 24.7k]
  ------------------
 1191|  24.7k|    }
 1192|       |
 1193|  24.7k|    if (!pl->current)
  ------------------
  |  Branch (1193:9): [True: 24.7k, False: 0]
  ------------------
 1194|  24.7k|        pl->current = playlist_get_first(pl);
 1195|  24.7k|}
prefetch_next:
 1440|  55.9k|{
 1441|  55.9k|    if (!mpctx->opts->prefetch_open || mpctx->open_active)
  ------------------
  |  Branch (1441:9): [True: 55.9k, False: 0]
  |  Branch (1441:40): [True: 0, False: 0]
  ------------------
 1442|  55.9k|        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|   293k|{
 1673|   293k|    if (!mpctx->vo_chain || !mpctx->vo_chain->filter)
  ------------------
  |  Branch (1673:9): [True: 44.5k, False: 248k]
  |  Branch (1673:29): [True: 0, False: 248k]
  ------------------
 1674|  44.5k|        return;
 1675|   248k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1676|   248k|    mp_output_chain_set_el_stream(mpctx->vo_chain->filter,
 1677|   248k|        track ? sh_stream_dependent_sibling(track->stream) : NULL);
  ------------------
  |  Branch (1677:9): [True: 248k, False: 0]
  ------------------
 1678|   248k|}
update_lavfi_complex:
 1681|  24.7k|{
 1682|  24.7k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1682:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|}
mp_next_file:
 2250|  24.6k|{
 2251|  24.6k|    struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
 2252|  24.6k|    if (next && direction < 0 && !force)
  ------------------
  |  Branch (2252:9): [True: 0, False: 24.6k]
  |  Branch (2252:17): [True: 0, False: 0]
  |  Branch (2252:34): [True: 0, False: 0]
  ------------------
 2253|      0|        next->playlist_prev_attempt = true;
 2254|  24.6k|    if (!next && mpctx->opts->loop_times != 1) {
  ------------------
  |  Branch (2254:9): [True: 24.6k, False: 0]
  |  Branch (2254:18): [True: 0, False: 24.6k]
  ------------------
 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|  24.6k|    return next;
 2284|  24.6k|}
mp_play_files:
 2289|  24.7k|{
 2290|  24.7k|    stats_register_thread_cputime(mpctx->stats, "thread");
 2291|       |
 2292|       |    // Wait for all scripts to load before possibly starting playback.
 2293|  24.7k|    if (!mp_clients_all_initialized(mpctx)) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|    mp_msg_set_early_logging(mpctx->global, false);
 2302|       |
 2303|  24.7k|    prepare_playlist(mpctx, mpctx->playlist, false);
 2304|       |
 2305|  49.3k|    for (;;) {
 2306|  49.3k|        idle_loop(mpctx);
 2307|       |
 2308|  49.3k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2308:13): [True: 24.6k, False: 24.7k]
  ------------------
 2309|  24.6k|            break;
 2310|       |
 2311|  24.7k|        if (mpctx->playlist->current)
  ------------------
  |  Branch (2311:13): [True: 24.7k, False: 0]
  ------------------
 2312|  24.7k|            play_current_file(mpctx);
 2313|       |
 2314|  24.7k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2314:13): [True: 122, False: 24.6k]
  ------------------
 2315|    122|            break;
 2316|       |
 2317|  24.6k|        struct playlist_entry *new_entry = NULL;
 2318|  24.6k|        if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR ||
  ------------------
  |  Branch (2318:13): [True: 0, False: 24.6k]
  |  Branch (2318:50): [True: 2.95k, False: 21.6k]
  ------------------
 2319|  21.6k|            mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (2319:13): [True: 21.6k, False: 0]
  ------------------
 2320|  24.6k|        {
 2321|  24.6k|            new_entry = mp_next_file(mpctx, +1, false, true);
 2322|  24.6k|        } else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
  ------------------
  |  Branch (2322:20): [True: 0, False: 0]
  ------------------
 2323|      0|            new_entry = mpctx->playlist->current;
 2324|      0|        }
 2325|       |
 2326|  24.6k|        if (!new_entry)
  ------------------
  |  Branch (2326:13): [True: 24.6k, False: 0]
  ------------------
 2327|  24.6k|            mpctx->playlist->playlist_completed = true;
 2328|       |
 2329|  24.6k|        mpctx->playlist->current = new_entry;
 2330|  24.6k|        mpctx->playlist->current_was_replaced = false;
 2331|  24.6k|        mpctx->stop_play = new_entry ? PT_NEXT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2331:28): [True: 0, False: 24.6k]
  ------------------
 2332|       |
 2333|  24.6k|        if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2)
  ------------------
  |  Branch (2333:13): [True: 24.6k, False: 0]
  |  Branch (2333:42): [True: 0, False: 24.6k]
  ------------------
 2334|      0|            break;
 2335|  24.6k|    }
 2336|       |
 2337|  24.7k|    cancel_open(mpctx);
 2338|       |
 2339|  24.7k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2339:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|}
mp_set_playlist_entry:
 2354|  24.7k|{
 2355|  24.7k|    mp_assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (2355:5): [True: 0, False: 24.7k]
  |  Branch (2355:5): [True: 24.7k, False: 0]
  ------------------
 2356|  24.7k|    mpctx->playlist->current = e;
 2357|  24.7k|    mpctx->playlist->current_was_replaced = false;
 2358|  24.7k|    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 2359|       |    // Make it pick up the new entry.
 2360|  24.7k|    if (mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (2360:9): [True: 24.7k, False: 0]
  ------------------
 2361|  24.7k|        mpctx->stop_play = e ? PT_CURRENT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2361:28): [True: 24.7k, False: 0]
  ------------------
 2362|  24.7k|    mp_wakeup_core(mpctx);
 2363|  24.7k|}
loadfile.c:track_in_current_edition:
  301|  90.6k|{
  302|  90.6k|    struct demuxer *demuxer = mpctx->demuxer;
  303|  90.6k|    if (!demuxer || !demuxer->edition_is_track_mapping || demuxer->num_editions <= 1)
  ------------------
  |  Branch (303:9): [True: 0, False: 90.6k]
  |  Branch (303:21): [True: 90.6k, False: 0]
  |  Branch (303:59): [True: 0, False: 0]
  ------------------
  304|  90.6k|        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|  43.1k|{
  245|  43.1k|    const char *tname = "?";
  246|  43.1k|    const char *selopt = "?";
  247|  43.1k|    const char *langopt = "?";
  248|  43.1k|    switch (t->type) {
  ------------------
  |  Branch (248:13): [True: 43.1k, False: 0]
  ------------------
  249|  20.1k|    case STREAM_VIDEO:
  ------------------
  |  Branch (249:5): [True: 20.1k, False: 22.9k]
  ------------------
  250|  20.1k|        tname = t->image ? "Image" : "Video"; selopt = "vid"; langopt = "vlang";
  ------------------
  |  Branch (250:17): [True: 7.28k, False: 12.8k]
  ------------------
  251|  20.1k|        break;
  252|  17.6k|    case STREAM_AUDIO:
  ------------------
  |  Branch (252:5): [True: 17.6k, False: 25.4k]
  ------------------
  253|  17.6k|        tname = "Audio"; selopt = "aid"; langopt = "alang";
  254|  17.6k|        break;
  255|  5.37k|    case STREAM_SUB:
  ------------------
  |  Branch (255:5): [True: 5.37k, False: 37.7k]
  ------------------
  256|  5.37k|        tname = "Subs"; selopt = "sid"; langopt = "slang";
  257|  5.37k|        break;
  258|  43.1k|    }
  259|  43.1k|    char b[2048] = {0};
  260|       |
  261|  43.1k|    int max_lang_length = 0;
  262|   161k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (262:21): [True: 118k, False: 43.1k]
  ------------------
  263|   118k|        if (mpctx->tracks[n]->lang)
  ------------------
  |  Branch (263:13): [True: 101k, False: 17.2k]
  ------------------
  264|   101k|            max_lang_length = MPMAX(strlen(mpctx->tracks[n]->lang), max_lang_length);
  ------------------
  |  |   44|   101k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 38.9k, False: 62.1k]
  |  |  ------------------
  ------------------
  265|   118k|    }
  266|       |
  267|  43.1k|    if (indent)
  ------------------
  |  Branch (267:9): [True: 0, False: 43.1k]
  ------------------
  268|      0|        APPEND(b, " ");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  269|  43.1k|    APPEND(b, "%s %-5s  --%s=%-2d", t->selected ? BLACK_CIRCLE : WHITE_CIRCLE,
  ------------------
  |  |  240|  86.2k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 39.2k, False: 3.84k]
  |  |  ------------------
  ------------------
  270|  43.1k|           tname, selopt, t->user_tid);
  271|  43.1k|    if (t->lang) {
  ------------------
  |  Branch (271:9): [True: 34.8k, False: 8.23k]
  ------------------
  272|  34.8k|        APPEND(b, " --%s=%-*s ", langopt, max_lang_length, t->lang);
  ------------------
  |  |  240|  34.8k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  273|  34.8k|    } else if (max_lang_length) {
  ------------------
  |  Branch (273:16): [True: 4.05k, False: 4.18k]
  ------------------
  274|  4.05k|        FILL(b, (int) strlen(" --alang= ") + max_lang_length);
  ------------------
  |  |  241|  4.05k|#define FILL(s, n) mp_snprintf_cat(s, sizeof(s), "%*s", n, "")
  ------------------
  275|  4.05k|    }
  276|       |
  277|  43.1k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|  43.1k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  43.1k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  278|  43.1k|    APPEND(b, " %s", mp_format_track_metadata(ctx, t, false));
  ------------------
  |  |  240|  43.1k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  279|  43.1k|    talloc_free(ctx);
  ------------------
  |  |   47|  43.1k|#define talloc_free                     ta_free
  ------------------
  280|       |
  281|  43.1k|    MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|  43.1k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  282|  43.1k|}
loadfile.c:add_stream_track:
  520|  85.3k|{
  521|   159k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (521:21): [True: 117k, False: 42.5k]
  ------------------
  522|   117k|        struct track *track = mpctx->tracks[i];
  523|   117k|        if (track->stream == stream)
  ------------------
  |  Branch (523:13): [True: 42.8k, False: 74.4k]
  ------------------
  524|  42.8k|            return track;
  525|   117k|    }
  526|       |
  527|  42.5k|    struct track *track = talloc_ptrtype(NULL, track);
  ------------------
  |  |   34|  42.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  42.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  42.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|  42.5k|    *track = (struct track) {
  529|  42.5k|        .type = stream->type,
  530|  42.5k|        .user_tid = find_new_tid(mpctx, stream->type),
  531|  42.5k|        .demuxer_id = stream->demuxer_id,
  532|  42.5k|        .ff_index = stream->ff_index,
  533|  42.5k|        .hls_bitrate = stream->hls_bitrate,
  534|  42.5k|        .title = stream->title,
  535|  42.5k|        .default_track = stream->default_track,
  536|  42.5k|        .forced_track = stream->forced_track,
  537|  42.5k|        .dependent_track = stream->dependent_track,
  538|  42.5k|        .visual_impaired_track = stream->visual_impaired_track,
  539|  42.5k|        .hearing_impaired_track = stream->hearing_impaired_track,
  540|  42.5k|        .original_track = stream->original_track,
  541|  42.5k|        .commentary_track = stream->commentary_track,
  542|  42.5k|        .image = stream->image,
  543|  42.5k|        .attached_picture = stream->attached_picture != NULL,
  544|  42.5k|        .lang = stream->lang,
  545|  42.5k|        .demuxer = demuxer,
  546|  42.5k|        .stream = stream,
  547|  42.5k|    };
  548|  42.5k|    MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
  ------------------
  |  |  105|  42.5k|    do {                                            \
  |  |  106|  42.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  42.5k|    do {                                            \
  |  |  |  |   97|  42.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  42.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  42.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  42.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 25.2k, False: 17.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  42.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  25.2k|    do {                                                        \
  |  |  |  |  |  |   89|  25.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  25.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  25.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  25.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  25.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  25.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  25.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 25.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  42.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 42.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  42.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  42.5k|        (idxvar)++;                                 \
  |  |  109|  42.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 42.5k]
  |  |  ------------------
  ------------------
  549|       |
  550|  42.5k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  551|       |
  552|  42.5k|    return track;
  553|  85.3k|}
loadfile.c:find_new_tid:
  507|  42.5k|{
  508|  42.5k|    int new_id = 0;
  509|  79.9k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (509:21): [True: 37.3k, False: 42.5k]
  ------------------
  510|  37.3k|        struct track *track = mpctx->tracks[i];
  511|  37.3k|        if (track->type == t)
  ------------------
  |  Branch (511:13): [True: 10.1k, False: 27.2k]
  ------------------
  512|  10.1k|            new_id = MPMAX(new_id, track->user_tid);
  ------------------
  |  |   44|  10.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 10.1k]
  |  |  ------------------
  ------------------
  513|  37.3k|    }
  514|  42.5k|    return new_id + 1;
  515|  42.5k|}
loadfile.c:process_langs:
  665|  77.3k|{
  666|  77.3k|    size_t nb = 0;
  667|  77.3k|    char **out = NULL;
  668|  77.3k|    for (int i = 0; in && in[i]; i++) {
  ------------------
  |  Branch (668:21): [True: 0, False: 77.3k]
  |  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|  77.3k|    return out;
  673|  77.3k|}
loadfile.c:add_os_langs:
  650|  24.6k|{
  651|  24.6k|    size_t nb = 0;
  652|  24.6k|    char **out = NULL;
  653|  24.6k|    char **autos = mp_get_user_langs();
  654|  24.6k|    for (int i = 0; autos && autos[i]; i++) {
  ------------------
  |  Branch (654:21): [True: 24.6k, False: 0]
  |  Branch (654:30): [True: 0, False: 24.6k]
  ------------------
  655|      0|        if (!append_lang(&nb, &out, autos[i]))
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            goto cleanup;
  657|      0|    }
  658|       |
  659|  24.6k|cleanup:
  660|  24.6k|    talloc_free(autos);
  ------------------
  |  |   47|  24.6k|#define talloc_free                     ta_free
  ------------------
  661|  24.6k|    return out;
  662|  24.6k|}
loadfile.c:duplicate_track:
  630|  42.9k|{
  631|  42.9k|    for (int i = 0; i < order; i++) {
  ------------------
  |  Branch (631:21): [True: 0, False: 42.9k]
  ------------------
  632|      0|        if (mpctx->current_track[i][type] == track)
  ------------------
  |  Branch (632:13): [True: 0, False: 0]
  ------------------
  633|      0|            return true;
  634|      0|    }
  635|  42.9k|    return false;
  636|  42.9k|}
loadfile.c:compare_track:
  585|  1.50k|{
  586|  1.50k|    bool sub = t2->type == STREAM_SUB;
  587|  1.50k|    bool ext1 = t1->is_external && !t1->no_default;
  ------------------
  |  Branch (587:17): [True: 0, False: 1.50k]
  |  Branch (587:36): [True: 0, False: 0]
  ------------------
  588|  1.50k|    bool ext2 = t2->is_external && !t2->no_default;
  ------------------
  |  Branch (588:17): [True: 0, False: 1.50k]
  |  Branch (588:36): [True: 0, False: 0]
  ------------------
  589|  1.50k|    if (ext1 != ext2 && t1->image == t2->image) {
  ------------------
  |  Branch (589:9): [True: 0, False: 1.50k]
  |  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|  1.50k|    if (t1->auto_loaded != t2->auto_loaded)
  ------------------
  |  Branch (595:9): [True: 0, False: 1.50k]
  ------------------
  596|      0|        return !t1->auto_loaded;
  597|  1.50k|    int l1 = mp_match_lang(langs, t1->lang), l2 = mp_match_lang(langs, t2->lang);
  598|  1.50k|    if (!os_langs && l1 != l2)
  ------------------
  |  Branch (598:9): [True: 1.29k, False: 213]
  |  Branch (598:22): [True: 0, False: 1.29k]
  ------------------
  599|      0|        return l1 > l2;
  600|  1.50k|    if (t1->forced_select != t2->forced_select)
  ------------------
  |  Branch (600:9): [True: 6, False: 1.50k]
  ------------------
  601|      6|        return t1->forced_select;
  602|  1.50k|    if (t1->default_track != t2->default_track)
  ------------------
  |  Branch (602:9): [True: 1.04k, False: 452]
  ------------------
  603|  1.04k|        return t1->default_track;
  604|    452|    if (sub && t1->forced_track != t2->forced_track)
  ------------------
  |  Branch (604:9): [True: 207, False: 245]
  |  Branch (604:16): [True: 3, False: 204]
  ------------------
  605|      3|        return !t1->forced_track;
  606|    449|    if (os_langs && l1 != l2)
  ------------------
  |  Branch (606:9): [True: 204, False: 245]
  |  Branch (606:21): [True: 0, False: 204]
  ------------------
  607|      0|        return l1 > l2;
  608|    449|    if (t1->attached_picture != t2->attached_picture)
  ------------------
  |  Branch (608:9): [True: 1, False: 448]
  ------------------
  609|      1|        return !t1->attached_picture;
  610|    448|    if (t1->image != t2->image)
  ------------------
  |  Branch (610:9): [True: 1, False: 447]
  ------------------
  611|      1|        return !t1->image;
  612|    447|    if (t1->dependent_track != t2->dependent_track)
  ------------------
  |  Branch (612:9): [True: 0, False: 447]
  ------------------
  613|      0|        return !t1->dependent_track;
  614|    447|    if (t1->stream && t2->stream && opts->hls_bitrate >= 0 &&
  ------------------
  |  Branch (614:9): [True: 447, False: 0]
  |  Branch (614:23): [True: 447, False: 0]
  |  Branch (614:37): [True: 447, False: 0]
  ------------------
  615|    447|        t1->stream->hls_bitrate != t2->stream->hls_bitrate)
  ------------------
  |  Branch (615:9): [True: 0, False: 447]
  ------------------
  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|    447|    return t1->user_tid <= t2->user_tid;
  626|    447|}
loadfile.c:track_layout_hash:
  758|  4.59k|{
  759|  4.59k|    char *h = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  4.59k|#define talloc_strdup                   ta_xstrdup
  ------------------
  760|  18.3k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (760:24): [True: 13.7k, False: 4.59k]
  ------------------
  761|  46.7k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (761:25): [True: 33.0k, False: 13.7k]
  ------------------
  762|  33.0k|            struct track *track = mpctx->tracks[n];
  763|  33.0k|            if (track->type != type)
  ------------------
  |  Branch (763:17): [True: 22.0k, False: 11.0k]
  ------------------
  764|  22.0k|                continue;
  765|  11.0k|            h = talloc_asprintf_append_buffer(h, "%d-%d-%d-%d-%s\n", type,
  ------------------
  |  |   64|  11.0k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  766|  11.0k|                    track->user_tid, track->default_track, track->is_external,
  767|  11.0k|                    track->lang ? track->lang : "");
  ------------------
  |  Branch (767:21): [True: 9.94k, False: 1.06k]
  ------------------
  768|  11.0k|        }
  769|  13.7k|    }
  770|  4.59k|    return h;
  771|  4.59k|}
loadfile.c:enable_demux_thread:
  499|  24.2k|{
  500|  24.2k|    if (mpctx->opts->demuxer_thread && !demux->fully_read) {
  ------------------
  |  Branch (500:9): [True: 24.2k, False: 0]
  |  Branch (500:40): [True: 24.2k, False: 0]
  ------------------
  501|  24.2k|        demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
  502|  24.2k|        demux_start_thread(demux);
  503|  24.2k|    }
  504|  24.2k|}
loadfile.c:wakeup_demux:
   66|  90.7k|{
   67|  90.7k|    struct MPContext *mpctx = pctx;
   68|  90.7k|    mp_wakeup_core(mpctx);
   69|  90.7k|}
loadfile.c:start_open:
 1356|  24.7k|{
 1357|  24.7k|    cancel_open(mpctx);
 1358|       |
 1359|  24.7k|    mp_assert(!mpctx->open_active);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1359:5): [True: 24.7k, False: 0]
  ------------------
 1360|  24.7k|    mp_assert(!mpctx->open_cancel);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1360:5): [True: 24.7k, False: 0]
  ------------------
 1361|  24.7k|    mp_assert(!mpctx->open_res_demuxer);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1361:5): [True: 24.7k, False: 0]
  ------------------
 1362|  24.7k|    mp_assert(!atomic_load(&mpctx->open_done));
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1362:5): [True: 24.7k, False: 0]
  ------------------
 1363|       |
 1364|  24.7k|    mpctx->open_cancel = mp_cancel_new(NULL);
 1365|  24.7k|    mpctx->open_url = talloc_strdup(NULL, url);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1366|  24.7k|    mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1367|  24.7k|    mpctx->open_url_flags = url_flags;
 1368|  24.7k|    mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
  ------------------
  |  Branch (1368:32): [True: 0, False: 24.7k]
  |  Branch (1368:48): [True: 0, False: 0]
  ------------------
 1369|  24.7k|    mpctx->demuxer_changed = false;
 1370|       |
 1371|  24.7k|    if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
  ------------------
  |  |  214|  24.7k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 24.7k]
  |  |  ------------------
  ------------------
 1372|      0|        cancel_open(mpctx);
 1373|      0|        return;
 1374|      0|    }
 1375|       |
 1376|  24.7k|    mpctx->open_active = true;
 1377|  24.7k|}
loadfile.c:open_demux_thread:
 1287|  24.7k|{
 1288|  24.7k|    struct MPContext *mpctx = ctx;
 1289|       |
 1290|  24.7k|    mp_thread_set_name("opener");
 1291|       |
 1292|  24.7k|    struct demuxer_params p = {
 1293|  24.7k|        .force_format = mpctx->open_format,
 1294|  24.7k|        .stream_flags = mpctx->open_url_flags,
 1295|  24.7k|        .stream_record = true,
 1296|  24.7k|        .is_top_level = true,
 1297|  24.7k|        .allow_playlist_create = mpctx->playlist->num_entries <= 1 &&
  ------------------
  |  Branch (1297:34): [True: 24.7k, False: 0]
  ------------------
 1298|  24.7k|                                 !mpctx->playlist->playlist_dir,
  ------------------
  |  Branch (1298:34): [True: 24.7k, False: 0]
  ------------------
 1299|  24.7k|    };
 1300|  24.7k|    struct demuxer *demux =
 1301|  24.7k|        demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);
 1302|  24.7k|    mpctx->open_res_demuxer = demux;
 1303|       |
 1304|  24.7k|    if (demux) {
  ------------------
  |  Branch (1304:9): [True: 24.2k, False: 496]
  ------------------
 1305|  24.2k|        MP_VERBOSE(mpctx, "Opening done: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  24.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1306|       |
 1307|  24.2k|        if (mpctx->open_for_prefetch && !demux->fully_read) {
  ------------------
  |  Branch (1307:13): [True: 0, False: 24.2k]
  |  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.2k|    } else {
 1319|    496|        MP_VERBOSE(mpctx, "Opening failed or was aborted: %s\n", mpctx->open_url);
  ------------------
  |  |   92|    496|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    496|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1320|       |
 1321|    496|        if (p.demuxer_failed) {
  ------------------
  |  Branch (1321:13): [True: 496, False: 0]
  ------------------
 1322|    496|            mpctx->open_res_error = MPV_ERROR_UNKNOWN_FORMAT;
 1323|    496|        } else {
 1324|      0|            mpctx->open_res_error = MPV_ERROR_LOADING_FAILED;
 1325|      0|        }
 1326|    496|    }
 1327|       |
 1328|  24.7k|    atomic_store(&mpctx->open_done, true);
 1329|  24.7k|    mp_wakeup_core(mpctx);
 1330|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  24.7k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1331|  24.7k|}
loadfile.c:reinit_complex_filters:
 1533|  49.0k|{
 1534|  49.0k|    char *graph = mpctx->opts->lavfi_complex;
 1535|  49.0k|    bool have_graph = graph && graph[0] && !force_uninit;
  ------------------
  |  Branch (1535:23): [True: 0, False: 49.0k]
  |  Branch (1535:32): [True: 0, False: 0]
  |  Branch (1535:44): [True: 0, False: 0]
  ------------------
 1536|  49.0k|    if (have_graph && mpctx->lavfi &&
  ------------------
  |  Branch (1536:9): [True: 0, False: 49.0k]
  |  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|  49.0k|    if (!mpctx->lavfi && !have_graph)
  ------------------
  |  Branch (1540:9): [True: 49.0k, False: 0]
  |  Branch (1540:26): [True: 49.0k, False: 0]
  ------------------
 1541|  49.0k|        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|  24.7k|{
 1821|  24.7k|    struct MPOpts *opts = mpctx->opts;
 1822|       |
 1823|  24.7k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1823:5): [True: 24.7k, False: 0]
  ------------------
 1824|  24.7k|    mpctx->stop_play = 0;
 1825|       |
 1826|  24.7k|    process_hooks(mpctx, "on_before_start_file");
 1827|  24.7k|    if (mpctx->stop_play || !mpctx->playlist->current)
  ------------------
  |  Branch (1827:9): [True: 0, False: 24.7k]
  |  Branch (1827:29): [True: 0, False: 24.7k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  24.7k|    mpv_event_start_file start_event = {
 1831|  24.7k|        .playlist_entry_id = mpctx->playlist->current->id,
 1832|  24.7k|    };
 1833|  24.7k|    mpv_event_end_file end_event = {
 1834|  24.7k|        .playlist_entry_id = start_event.playlist_entry_id,
 1835|  24.7k|    };
 1836|       |
 1837|  24.7k|    mp_notify(mpctx, MPV_EVENT_START_FILE, &start_event);
 1838|       |
 1839|  24.7k|    mp_cancel_reset(mpctx->playback_abort);
 1840|       |
 1841|  24.7k|    mpctx->error_playing = MPV_ERROR_LOADING_FAILED;
 1842|  24.7k|    mpctx->filename = NULL;
 1843|  24.7k|    mpctx->shown_aframes = 0;
 1844|  24.7k|    mpctx->shown_vframes = 0;
 1845|  24.7k|    mpctx->last_chapter_seek = -2;
 1846|  24.7k|    mpctx->last_chapter_flag = false;
 1847|  24.7k|    mpctx->last_chapter = -2;
 1848|  24.7k|    mpctx->paused = false;
 1849|  24.7k|    mpctx->playing_msg_shown = false;
 1850|  24.7k|    mpctx->max_frames = -1;
 1851|  24.7k|    mpctx->video_speed = mpctx->audio_speed = opts->playback_speed;
 1852|  24.7k|    mpctx->speed_factor_a = mpctx->speed_factor_v = 1.0;
 1853|  24.7k|    mpctx->display_sync_error = 0.0;
 1854|  24.7k|    mpctx->display_sync_active = false;
 1855|       |    // let get_current_time() show 0 as start time (before playback_pts is set)
 1856|  24.7k|    mpctx->last_seek_pts = 0.0;
 1857|  24.7k|    mpctx->seek = (struct seek_params){ 0 };
 1858|  24.7k|    disc_nav_reset(mpctx);
 1859|  24.7k|    mpctx->filter_root = mp_filter_create_root(mpctx->global);
 1860|  24.7k|    mp_filter_graph_set_wakeup_cb(mpctx->filter_root, mp_wakeup_core_cb, mpctx);
 1861|  24.7k|    mp_filter_graph_set_max_run_time(mpctx->filter_root, 0.1);
 1862|       |
 1863|  24.7k|    reset_playback_state(mpctx);
 1864|       |
 1865|  24.7k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1866|  24.7k|    if (mpctx->playlist->num_entries > 3)
  ------------------
  |  Branch (1866:9): [True: 0, False: 24.7k]
  ------------------
 1867|      0|        goto terminate_playback;
 1868|  24.7k|#endif
 1869|       |
 1870|  24.7k|    mpctx->playing = mpctx->playlist->current;
 1871|  24.7k|    mp_assert(mpctx->playing);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1871:5): [True: 24.7k, False: 0]
  ------------------
 1872|  24.7k|    mp_assert(mpctx->playing->filename);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1872:5): [True: 24.7k, False: 0]
  ------------------
 1873|  24.7k|    mpctx->playing->reserved += 1;
 1874|       |
 1875|  24.7k|    mpctx->filename = talloc_strdup(NULL, mpctx->playing->filename);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1876|  24.7k|    mpctx->stream_open_filename = mpctx->filename;
 1877|       |
 1878|  24.7k|    mpctx->add_osd_seek_info &= OSD_SEEK_INFO_CURRENT_FILE;
 1879|       |
 1880|  24.7k|    if (opts->reset_options) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 24.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|  24.7k|    mp_load_auto_profiles(mpctx);
 1894|       |
 1895|  24.7k|    bool watch_later = mp_load_playback_resume(mpctx, mpctx->filename);
 1896|       |
 1897|  24.7k|    load_per_file_options(mpctx->mconfig, mpctx->playing->params,
 1898|  24.7k|                          mpctx->playing->num_params);
 1899|       |
 1900|  24.7k|    mpctx->remaining_file_loops = mpctx->opts->loop_file;
 1901|  24.7k|    mp_notify_property(mpctx, "remaining-file-loops");
 1902|  24.7k|    mpctx->remaining_ab_loops = mpctx->opts->ab_loop_count;
 1903|  24.7k|    mp_notify_property(mpctx, "remaining-ab-loops");
 1904|       |
 1905|  24.7k|    mpctx->max_frames = opts->play_frames;
 1906|       |
 1907|  24.7k|    handle_force_window(mpctx, false);
 1908|       |
 1909|  24.7k|    if (mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (1909:9): [True: 0, False: 24.7k]
  ------------------
 1910|  24.7k|        mpctx->playing->playlist_path)
  ------------------
  |  Branch (1910:9): [True: 0, False: 24.7k]
  ------------------
 1911|  24.7k|        MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1912|       |
 1913|  24.7k|    mp_assert(mpctx->demuxer == NULL);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (1913:5): [True: 24.7k, False: 0]
  ------------------
 1914|       |
 1915|  24.7k|    process_hooks(mpctx, "on_load");
 1916|  24.7k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1916:9): [True: 0, False: 24.7k]
  ------------------
 1917|      0|        goto terminate_playback;
 1918|       |
 1919|  24.7k|    if (opts->stream_dump && opts->stream_dump[0]) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 24.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|  24.7k|    open_demux_reentrant(mpctx);
 1926|  24.7k|    if (!mpctx->stop_play && !mpctx->demuxer) {
  ------------------
  |  Branch (1926:9): [True: 24.7k, False: 0]
  |  Branch (1926:30): [True: 496, False: 24.2k]
  ------------------
 1927|    496|        process_hooks(mpctx, "on_load_fail");
 1928|    496|        if (strcmp(mpctx->stream_open_filename, mpctx->filename) != 0 &&
  ------------------
  |  Branch (1928:13): [True: 0, False: 496]
  ------------------
 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|    496|    }
 1935|  24.7k|    if (!mpctx->demuxer || mpctx->stop_play)
  ------------------
  |  Branch (1935:9): [True: 496, False: 24.2k]
  |  Branch (1935:28): [True: 0, False: 24.2k]
  ------------------
 1936|    496|        goto terminate_playback;
 1937|       |
 1938|  24.2k|    struct playlist *pl = mpctx->demuxer->playlist;
 1939|  24.2k|    if (pl) {
  ------------------
  |  Branch (1939:9): [True: 0, False: 24.2k]
  ------------------
 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|      0|        if (watch_later && !pl->playlist_dir)
  ------------------
  |  Branch (1942:13): [True: 0, False: 0]
  |  Branch (1942:28): [True: 0, False: 0]
  ------------------
 1943|      0|            mp_delete_watch_later_conf(mpctx, mpctx->filename);
 1944|      0|        playlist_populate_playlist_path(pl, mpctx->filename);
 1945|      0|        if (infinite_playlist_loading_loop(mpctx, pl)) {
  ------------------
  |  Branch (1945:13): [True: 0, False: 0]
  ------------------
 1946|      0|            mpctx->stop_play = PT_STOP;
 1947|      0|            MP_ERR(mpctx, "Infinite playlist loading loop detected.\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__)
  |  |  ------------------
  ------------------
 1948|      0|            goto terminate_playback;
 1949|      0|        }
 1950|      0|        transfer_playlist(mpctx, pl, &end_event.playlist_insert_id,
 1951|      0|                          &end_event.playlist_insert_num_entries);
 1952|      0|        mp_notify_property(mpctx, "playlist");
 1953|      0|        mpctx->error_playing = 2;
 1954|      0|        goto terminate_playback;
 1955|      0|    }
 1956|       |
 1957|  24.2k|    if (mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (1957:9): [True: 24.2k, False: 0]
  ------------------
 1958|  24.2k|        demux_set_ts_offset(mpctx->demuxer, -mpctx->demuxer->start_time);
 1959|  24.2k|    enable_demux_thread(mpctx, mpctx->demuxer);
 1960|       |
 1961|  24.2k|    add_demuxer_tracks(mpctx, mpctx->demuxer);
 1962|       |
 1963|  24.2k|    load_external_opts(mpctx);
 1964|  24.2k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1964:9): [True: 0, False: 24.2k]
  ------------------
 1965|      0|        goto terminate_playback;
 1966|       |
 1967|  24.2k|    check_previous_track_selection(mpctx);
 1968|       |
 1969|  24.2k|    process_hooks(mpctx, "on_preloaded");
 1970|  24.2k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1970:9): [True: 0, False: 24.2k]
  ------------------
 1971|      0|        goto terminate_playback;
 1972|       |
 1973|  24.2k|    if (reinit_complex_filters(mpctx, false) < 0)
  ------------------
  |  Branch (1973:9): [True: 0, False: 24.2k]
  ------------------
 1974|      0|        goto terminate_playback;
 1975|       |
 1976|  97.0k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1976:21): [True: 72.7k, False: 24.2k]
  ------------------
 1977|   169k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1977:25): [True: 97.0k, False: 72.7k]
  ------------------
 1978|  97.0k|            struct track *sel = NULL;
 1979|  97.0k|            bool taken = (t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (1979:27): [True: 24.2k, False: 72.7k]
  |  Branch (1979:48): [True: 0, False: 24.2k]
  ------------------
 1980|  97.0k|                         (t == STREAM_AUDIO && mpctx->ao_chain);
  ------------------
  |  Branch (1980:27): [True: 24.2k, False: 72.7k]
  |  Branch (1980:48): [True: 0, False: 24.2k]
  ------------------
 1981|  97.0k|            if (!taken && opts->stream_auto_sel)
  ------------------
  |  Branch (1981:17): [True: 97.0k, False: 0]
  |  Branch (1981:27): [True: 97.0k, False: 0]
  ------------------
 1982|  97.0k|                sel = select_default_track(mpctx, i, t);
 1983|  97.0k|            mpctx->current_track[i][t] = sel;
 1984|  97.0k|        }
 1985|  72.7k|    }
 1986|  97.0k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1986:21): [True: 72.7k, False: 24.2k]
  ------------------
 1987|   169k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1987:25): [True: 97.0k, False: 72.7k]
  ------------------
 1988|       |            // One track can strictly feed at most 1 decoder
 1989|  97.0k|            struct track *track = mpctx->current_track[i][t];
 1990|  97.0k|            if (track) {
  ------------------
  |  Branch (1990:17): [True: 38.4k, False: 58.5k]
  ------------------
 1991|  38.4k|                if (track->type != STREAM_SUB &&
  ------------------
  |  Branch (1991:21): [True: 36.0k, False: 2.42k]
  ------------------
 1992|  36.0k|                    mpctx->encode_lavc_ctx &&
  ------------------
  |  Branch (1992:21): [True: 0, False: 36.0k]
  ------------------
 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|  38.4k|                } else if (track->selected) {
  ------------------
  |  Branch (2000:28): [True: 0, False: 38.4k]
  ------------------
 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|  38.4k|                } else {
 2006|  38.4k|                    track->selected = true;
 2007|  38.4k|                }
 2008|  38.4k|            }
 2009|       |
 2010|       |            // Revert selection of unselected tracks to default. This is needed
 2011|       |            // because track properties have inconsistent behavior.
 2012|  97.0k|            if (!track && opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (2012:17): [True: 58.5k, False: 38.4k]
  |  Branch (2012:27): [True: 0, False: 58.5k]
  ------------------
 2013|      0|                mark_track_selection(mpctx, i, t, -1); // default
 2014|  97.0k|        }
 2015|  72.7k|    }
 2016|       |
 2017|  24.2k|    process_hooks(mpctx, "on_loaded");
 2018|  97.0k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (2018:21): [True: 72.7k, False: 24.2k]
  ------------------
 2019|   199k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2019:25): [True: 126k, False: 72.7k]
  ------------------
 2020|   126k|            struct track *track = mpctx->tracks[n];
 2021|   126k|            if (track->type != t)
  ------------------
  |  Branch (2021:17): [True: 84.5k, False: 42.2k]
  ------------------
 2022|  84.5k|                continue;
 2023|       |            // Only reselect dependent tracks when explicitly selected by user
 2024|  42.2k|            if (track->stream && track->stream->dependent_track &&
  ------------------
  |  Branch (2024:17): [True: 42.2k, False: 0]
  |  Branch (2024:34): [True: 0, False: 42.2k]
  ------------------
 2025|      0|                !track->selected)
  ------------------
  |  Branch (2025:17): [True: 0, False: 0]
  ------------------
 2026|      0|                continue;
 2027|  42.2k|            reselect_demux_stream(mpctx, track, false);
 2028|  42.2k|        }
 2029|  72.7k|    }
 2030|       |
 2031|  24.2k|    update_demuxer_properties(mpctx);
 2032|       |
 2033|  24.2k|    update_playback_speed(mpctx);
 2034|       |
 2035|  24.2k|    reinit_video_chain(mpctx);
 2036|  24.2k|    reinit_audio_chain(mpctx);
 2037|  24.2k|    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|  24.2k|    update_vo_chain_el_pair(mpctx);
 2041|       |
 2042|  24.2k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2042:9): [True: 0, False: 24.2k]
  ------------------
 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|  24.2k|    if (!mpctx->vo_chain && !mpctx->ao_chain && opts->stream_auto_sel) {
  ------------------
  |  Branch (2051:9): [True: 5.95k, False: 18.3k]
  |  Branch (2051:29): [True: 2.45k, False: 3.49k]
  |  Branch (2051:49): [True: 2.45k, False: 0]
  ------------------
 2052|  2.45k|        MP_FATAL(mpctx, "No video or audio streams selected.\n");
  ------------------
  |  |   88|  2.45k|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2053|  2.45k|        mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2054|  2.45k|        goto terminate_playback;
 2055|  2.45k|    }
 2056|       |
 2057|  21.7k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart) {
  ------------------
  |  Branch (2057:9): [True: 18.3k, False: 3.49k]
  |  Branch (2057:28): [True: 284, False: 18.0k]
  ------------------
 2058|    284|        MP_INFO(mpctx,
  ------------------
  |  |   91|    284|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    284|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2059|    284|            "Displaying cover art. Use --no-audio-display to prevent this.\n");
 2060|    284|    }
 2061|       |
 2062|  21.7k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2062:9): [True: 3.49k, False: 18.3k]
  ------------------
 2063|  3.49k|        handle_force_window(mpctx, true);
 2064|       |
 2065|  21.7k|    MP_VERBOSE(mpctx, "Starting playback...\n");
  ------------------
  |  |   92|  21.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  21.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2066|       |
 2067|  21.7k|    mpctx->playback_initialized = true;
 2068|  21.7k|    mpctx->playing->playlist_prev_attempt = false;
 2069|  21.7k|    mpctx->playlist->playlist_completed = false;
 2070|  21.7k|    mpctx->playlist->playlist_started = true;
 2071|  21.7k|    mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
 2072|  21.7k|    update_screensaver_state(mpctx);
 2073|  21.7k|    clear_playlist_paths(mpctx);
 2074|       |
 2075|       |    // Clear out subs from the previous file if the video track is a still image.
 2076|  21.7k|    redraw_subs(mpctx);
 2077|       |
 2078|  21.7k|    if (watch_later)
  ------------------
  |  Branch (2078:9): [True: 0, False: 21.7k]
  ------------------
 2079|      0|        mp_delete_watch_later_conf(mpctx, mpctx->filename);
 2080|       |
 2081|  21.7k|    append_to_watch_history(mpctx);
 2082|       |
 2083|  21.7k|    if (mpctx->max_frames == 0) {
  ------------------
  |  Branch (2083:9): [True: 0, False: 21.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|  21.7k|    if (opts->demuxer_cache_wait) {
  ------------------
  |  Branch (2090:9): [True: 0, False: 21.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|  21.7k|    double play_start_pts = rel_time_to_abs(mpctx, opts->play_start);
 2105|       |
 2106|       |    // Backward playback -> start from end by default.
 2107|  21.7k|    if (play_start_pts == MP_NOPTS_VALUE && opts->play_dir < 0)
  ------------------
  |  |   39|  43.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2107:9): [True: 21.7k, False: 0]
  |  Branch (2107:45): [True: 0, False: 21.7k]
  ------------------
 2108|      0|        play_start_pts = get_start_time(mpctx, -1);
 2109|       |
 2110|  21.7k|    if (play_start_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  21.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2110:9): [True: 0, False: 21.7k]
  ------------------
 2111|      0|        queue_seek(mpctx, MPSEEK_ABSOLUTE, play_start_pts, MPSEEK_DEFAULT, 0);
 2112|      0|        execute_queued_seek(mpctx);
 2113|      0|    }
 2114|       |
 2115|  21.7k|    update_internal_pause_state(mpctx);
 2116|       |
 2117|  21.7k|    mpctx->error_playing = 0;
 2118|  21.7k|    mpctx->in_playloop = true;
 2119|   272k|    while (!mpctx->stop_play)
  ------------------
  |  Branch (2119:12): [True: 250k, False: 21.7k]
  ------------------
 2120|   250k|        run_playloop(mpctx);
 2121|  21.7k|    mpctx->in_playloop = false;
 2122|       |
 2123|  21.7k|    MP_VERBOSE(mpctx, "EOF code: %d\n", mpctx->stop_play);
  ------------------
  |  |   92|  21.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  21.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2124|       |
 2125|  24.7k|terminate_playback:
 2126|       |
 2127|  24.7k|    if (!mpctx->stop_play)
  ------------------
  |  Branch (2127:9): [True: 2.29k, False: 22.4k]
  ------------------
 2128|  2.29k|        mpctx->stop_play = PT_ERROR;
 2129|       |
 2130|  24.7k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (2130:9): [True: 3.04k, False: 21.7k]
  ------------------
 2131|  3.04k|        clear_audio_output_buffers(mpctx);
 2132|       |
 2133|  24.7k|    update_core_idle_state(mpctx);
 2134|       |
 2135|  24.7k|    if (mpctx->step_frames) {
  ------------------
  |  Branch (2135:9): [True: 0, False: 24.7k]
  ------------------
 2136|      0|        opts->pause = true;
 2137|      0|        m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
 2138|      0|    }
 2139|       |
 2140|  24.7k|    process_hooks(mpctx, "on_unload");
 2141|       |
 2142|       |    // time to uninit all, except global stuff:
 2143|  24.7k|    reinit_complex_filters(mpctx, true);
 2144|  24.7k|    uninit_audio_chain(mpctx);
 2145|  24.7k|    uninit_video_chain(mpctx);
 2146|  24.7k|    uninit_sub_all(mpctx);
 2147|  24.7k|    if (!opts->gapless_audio && !mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (2147:9): [True: 0, False: 24.7k]
  |  Branch (2147:33): [True: 0, False: 0]
  ------------------
 2148|      0|        uninit_audio_out(mpctx);
 2149|       |
 2150|  24.7k|    mpctx->playback_initialized = false;
 2151|       |
 2152|  24.7k|    uninit_demuxer(mpctx);
 2153|       |
 2154|       |    // Possibly stop ongoing async commands.
 2155|  24.7k|    mp_abort_playback_async(mpctx);
 2156|       |
 2157|  24.7k|    struct playlist_entry *current = mpctx->playlist->current;
 2158|  24.7k|    bool reloading = mpctx->stop_play == PT_CURRENT_ENTRY &&
  ------------------
  |  Branch (2158:22): [True: 0, False: 24.7k]
  ------------------
 2159|      0|                     current && current->reloading;
  ------------------
  |  Branch (2159:22): [True: 0, False: 0]
  |  Branch (2159:33): [True: 0, False: 0]
  ------------------
 2160|  24.7k|    if (current)
  ------------------
  |  Branch (2160:9): [True: 24.7k, False: 0]
  ------------------
 2161|  24.7k|        current->reloading = false;
 2162|  24.7k|    if (!reloading)
  ------------------
  |  Branch (2162:9): [True: 24.7k, False: 0]
  ------------------
 2163|  24.7k|        m_config_restore_backups(mpctx->mconfig);
 2164|       |
 2165|  24.7k|    TA_FREEP(&mpctx->filter_root);
  ------------------
  |  |   81|  24.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  24.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 24.7k]
  |  |  ------------------
  ------------------
 2166|  24.7k|    talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 2167|  24.7k|    mpctx->filtered_tags = NULL;
 2168|       |
 2169|  24.7k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 2170|       |
 2171|  24.7k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx))
  ------------------
  |  Branch (2171:9): [True: 0, False: 24.7k]
  ------------------
 2172|      0|        mpctx->stop_play = PT_ERROR;
 2173|       |
 2174|  24.7k|    if (mpctx->stop_play == PT_ERROR && !mpctx->error_playing)
  ------------------
  |  Branch (2174:9): [True: 2.95k, False: 21.7k]
  |  Branch (2174:41): [True: 0, False: 2.95k]
  ------------------
 2175|      0|        mpctx->error_playing = MPV_ERROR_GENERIC;
 2176|       |
 2177|  24.7k|    bool nothing_played = !mpctx->shown_aframes && !mpctx->shown_vframes &&
  ------------------
  |  Branch (2177:27): [True: 18.2k, False: 6.52k]
  |  Branch (2177:52): [True: 9.53k, False: 8.69k]
  ------------------
 2178|  9.53k|                          mpctx->error_playing <= 0;
  ------------------
  |  Branch (2178:27): [True: 9.53k, False: 0]
  ------------------
 2179|  24.7k|    bool playlist_prev_continue = false;
 2180|  24.7k|    switch (mpctx->stop_play) {
  ------------------
  |  Branch (2180:13): [True: 24.7k, False: 0]
  ------------------
 2181|  2.95k|    case PT_ERROR:
  ------------------
  |  Branch (2181:5): [True: 2.95k, False: 21.7k]
  ------------------
 2182|  24.6k|    case AT_END_OF_FILE:
  ------------------
  |  Branch (2182:5): [True: 21.6k, False: 3.07k]
  ------------------
 2183|  24.6k|    {
 2184|  24.6k|        if (mpctx->error_playing == 0 && nothing_played)
  ------------------
  |  Branch (2184:13): [True: 21.6k, False: 2.95k]
  |  Branch (2184:42): [True: 6.58k, False: 15.0k]
  ------------------
 2185|  6.58k|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2186|  24.6k|        if (mpctx->error_playing < 0) {
  ------------------
  |  Branch (2186:13): [True: 9.53k, False: 15.0k]
  ------------------
 2187|  9.53k|            end_event.error = mpctx->error_playing;
 2188|  9.53k|            end_event.reason = MPV_END_FILE_REASON_ERROR;
 2189|  15.0k|        } else if (mpctx->error_playing == 2) {
  ------------------
  |  Branch (2189:20): [True: 0, False: 15.0k]
  ------------------
 2190|      0|            end_event.reason = MPV_END_FILE_REASON_REDIRECT;
 2191|  15.0k|        } else {
 2192|  15.0k|            end_event.reason = MPV_END_FILE_REASON_EOF;
 2193|  15.0k|        }
 2194|  24.6k|        if (mpctx->playing) {
  ------------------
  |  Branch (2194:13): [True: 24.6k, False: 0]
  ------------------
 2195|  24.6k|            mpctx->playing->init_failed = nothing_played;
 2196|  24.6k|            playlist_prev_continue = mpctx->playing->playlist_prev_attempt &&
  ------------------
  |  Branch (2196:38): [True: 0, False: 24.6k]
  ------------------
 2197|      0|                                     nothing_played;
  ------------------
  |  Branch (2197:38): [True: 0, False: 0]
  ------------------
 2198|  24.6k|            mpctx->playing->playlist_prev_attempt = false;
 2199|  24.6k|        }
 2200|  24.6k|        break;
 2201|  2.95k|    }
 2202|       |    // Note that error_playing is meaningless in these cases.
 2203|      0|    case PT_NEXT_ENTRY:
  ------------------
  |  Branch (2203:5): [True: 0, False: 24.7k]
  ------------------
 2204|      0|    case PT_CURRENT_ENTRY:
  ------------------
  |  Branch (2204:5): [True: 0, False: 24.7k]
  ------------------
 2205|      0|    case PT_STOP:           end_event.reason = MPV_END_FILE_REASON_STOP; break;
  ------------------
  |  Branch (2205:5): [True: 0, False: 24.7k]
  ------------------
 2206|    122|    case PT_QUIT:           end_event.reason = MPV_END_FILE_REASON_QUIT; break;
  ------------------
  |  Branch (2206:5): [True: 122, False: 24.6k]
  ------------------
 2207|  24.7k|    };
 2208|  24.7k|    mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event);
 2209|       |
 2210|  24.7k|    MP_VERBOSE(mpctx, "finished playback, %s (reason %d)\n",
  ------------------
  |  |   92|  24.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2211|  24.7k|               mpv_error_string(end_event.error), end_event.reason);
 2212|  24.7k|    if (end_event.error == MPV_ERROR_UNKNOWN_FORMAT)
  ------------------
  |  Branch (2212:9): [True: 496, False: 24.2k]
  ------------------
 2213|  24.7k|        MP_ERR(mpctx, "Failed to recognize file format.\n");
  ------------------
  |  |   89|    496|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    496|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2214|       |
 2215|  24.7k|    if (mpctx->playing)
  ------------------
  |  Branch (2215:9): [True: 24.7k, False: 0]
  ------------------
 2216|  24.7k|        playlist_entry_unref(mpctx->playing);
 2217|  24.7k|    mpctx->playing = NULL;
 2218|  24.7k|    talloc_free(mpctx->filename);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
 2219|  24.7k|    mpctx->filename = NULL;
 2220|  24.7k|    mpctx->stream_open_filename = NULL;
 2221|       |
 2222|  24.7k|    if (end_event.error < 0 && nothing_played) {
  ------------------
  |  Branch (2222:9): [True: 9.53k, False: 15.2k]
  |  Branch (2222:32): [True: 9.53k, False: 2]
  ------------------
 2223|  9.53k|        mpctx->files_broken++;
 2224|  15.2k|    } else if (end_event.error < 0) {
  ------------------
  |  Branch (2224:16): [True: 2, False: 15.2k]
  ------------------
 2225|      2|        mpctx->files_errored++;
 2226|  15.2k|    } else {
 2227|  15.2k|        mpctx->files_played++;
 2228|  15.2k|    }
 2229|       |
 2230|  24.7k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (2230:5): [True: 24.7k, False: 0]
  ------------------
 2231|       |
 2232|  24.7k|    process_hooks(mpctx, "on_after_end_file");
 2233|       |
 2234|  24.7k|    if (playlist_prev_continue) {
  ------------------
  |  Branch (2234:9): [True: 0, False: 24.7k]
  ------------------
 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|  24.7k|}
loadfile.c:process_hooks:
 1225|   148k|{
 1226|   148k|    mp_hook_start(mpctx, name);
 1227|       |
 1228|   148k|    while (!mp_hook_test_completion(mpctx, name)) {
  ------------------
  |  Branch (1228:12): [True: 0, False: 148k]
  ------------------
 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|   148k|}
loadfile.c:load_per_file_options:
 1279|  24.7k|{
 1280|  24.7k|    for (int n = 0; n < params_count; n++) {
  ------------------
  |  Branch (1280:21): [True: 0, False: 24.7k]
  ------------------
 1281|      0|        m_config_set_option_cli(conf, params[n].name, params[n].value,
 1282|      0|                                M_SETOPT_BACKUP);
 1283|      0|    }
 1284|  24.7k|}
loadfile.c:open_demux_reentrant:
 1380|  24.7k|{
 1381|  24.7k|    char *url = mpctx->stream_open_filename;
 1382|       |
 1383|  24.7k|    if (mpctx->open_active) {
  ------------------
  |  Branch (1383:9): [True: 0, False: 24.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|  24.7k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1410:9): [True: 24.7k, False: 0]
  ------------------
 1411|  24.7k|        start_open(mpctx, url, mpctx->playing->stream_flags, false);
 1412|       |
 1413|       |    // If thread failed to start, cancel the playback
 1414|  24.7k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1414:9): [True: 0, False: 24.7k]
  ------------------
 1415|      0|        goto cancel;
 1416|       |
 1417|       |    // User abort should cancel the opener now.
 1418|  24.7k|    mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort);
 1419|       |
 1420|  74.2k|    while (!atomic_load(&mpctx->open_done)) {
  ------------------
  |  Branch (1420:12): [True: 49.5k, False: 24.7k]
  ------------------
 1421|  49.5k|        mp_idle(mpctx);
 1422|       |
 1423|  49.5k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1423:13): [True: 0, False: 49.5k]
  ------------------
 1424|      0|            mp_abort_playback_async(mpctx);
 1425|  49.5k|    }
 1426|       |
 1427|  24.7k|    if (mpctx->open_res_demuxer) {
  ------------------
  |  Branch (1427:9): [True: 24.2k, False: 496]
  ------------------
 1428|  24.2k|        mpctx->demuxer = mpctx->open_res_demuxer;
 1429|  24.2k|        mpctx->open_res_demuxer = NULL;
 1430|  24.2k|        mp_cancel_set_parent(mpctx->demuxer->cancel, mpctx->playback_abort);
 1431|  24.2k|    } else {
 1432|    496|        mpctx->error_playing = mpctx->open_res_error;
 1433|    496|    }
 1434|       |
 1435|  24.7k|cancel:
 1436|  24.7k|    cancel_open(mpctx); // cleanup
 1437|  24.7k|}
loadfile.c:load_external_opts:
 1715|  24.2k|{
 1716|  24.2k|    struct mp_waiter wait = MP_WAITER_INITIALIZER;
  ------------------
  |  |   19|  24.2k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  24.2k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  24.2k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  24.2k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  24.2k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  24.2k|    }
  ------------------
 1717|       |
 1718|  24.2k|    void *a[] = {mpctx, &wait};
 1719|  24.2k|    if (!mp_thread_pool_queue(mpctx->thread_pool, load_external_opts_thread, a)) {
  ------------------
  |  Branch (1719:9): [True: 0, False: 24.2k]
  ------------------
 1720|      0|        mpctx->stop_play = PT_ERROR;
 1721|      0|        return;
 1722|      0|    }
 1723|       |
 1724|  48.5k|    while (!mp_waiter_poll(&wait)) {
  ------------------
  |  Branch (1724:12): [True: 24.2k, False: 24.2k]
  ------------------
 1725|  24.2k|        mp_idle(mpctx);
 1726|       |
 1727|  24.2k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1727:13): [True: 0, False: 24.2k]
  ------------------
 1728|      0|            mp_abort_playback_async(mpctx);
 1729|  24.2k|    }
 1730|       |
 1731|  24.2k|    mp_waiter_wait(&wait);
 1732|  24.2k|}
loadfile.c:load_external_opts_thread:
 1695|  24.2k|{
 1696|  24.2k|    void **a = p;
 1697|  24.2k|    struct MPContext *mpctx = a[0];
 1698|  24.2k|    struct mp_waiter *waiter = a[1];
 1699|       |
 1700|  24.2k|    mp_core_lock(mpctx);
 1701|       |
 1702|  24.2k|    load_chapters(mpctx);
 1703|  24.2k|    open_external_files(mpctx, mpctx->opts->audio_files, STREAM_AUDIO);
 1704|  24.2k|    open_external_files(mpctx, mpctx->opts->sub_name, STREAM_SUB);
 1705|  24.2k|    open_external_files(mpctx, mpctx->opts->coverart_files, STREAM_VIDEO);
 1706|  24.2k|    open_external_files(mpctx, mpctx->opts->external_files, STREAM_TYPE_COUNT);
 1707|  24.2k|    autoload_external_files(mpctx, mpctx->playback_abort);
 1708|       |
 1709|  24.2k|    mp_waiter_wakeup(waiter, 0);
 1710|  24.2k|    mp_wakeup_core(mpctx);
 1711|  24.2k|    mp_core_unlock(mpctx);
 1712|  24.2k|}
loadfile.c:load_chapters:
 1240|  24.2k|{
 1241|  24.2k|    struct demuxer *src = mpctx->demuxer;
 1242|  24.2k|    bool free_src = false;
 1243|  24.2k|    char *chapter_file = mpctx->opts->chapter_file;
 1244|  24.2k|    if (chapter_file && chapter_file[0]) {
  ------------------
  |  Branch (1244:9): [True: 0, False: 24.2k]
  |  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|  24.2k|    if (src && !mpctx->chapters) {
  ------------------
  |  Branch (1263:9): [True: 24.2k, False: 0]
  |  Branch (1263:16): [True: 24.2k, False: 0]
  ------------------
 1264|  24.2k|        talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
 1265|  24.2k|        mpctx->num_chapters = src->num_chapters;
 1266|  24.2k|        mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters);
 1267|  24.2k|        if (mpctx->opts->rebase_start_time) {
  ------------------
  |  Branch (1267:13): [True: 24.2k, False: 0]
  ------------------
 1268|  28.1k|            for (int n = 0; n < mpctx->num_chapters; n++)
  ------------------
  |  Branch (1268:29): [True: 3.89k, False: 24.2k]
  ------------------
 1269|  3.89k|                mpctx->chapters[n].pts -= src->start_time;
 1270|  24.2k|        }
 1271|  24.2k|    }
 1272|  24.2k|    if (free_src)
  ------------------
  |  Branch (1272:9): [True: 0, False: 24.2k]
  ------------------
 1273|      0|        demux_cancel_and_free(src);
 1274|  24.2k|}
loadfile.c:open_external_files:
 1090|  97.0k|{
 1091|       |    // Need a copy, because the option value could be mutated during iteration.
 1092|  97.0k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  97.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  97.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1093|  97.0k|    files = mp_dup_str_array(tmp, files);
 1094|       |
 1095|  97.0k|    for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1095:21): [True: 0, False: 97.0k]
  |  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|  97.0k|    talloc_free(tmp);
  ------------------
  |  |   47|  97.0k|#define talloc_free                     ta_free
  ------------------
 1101|  97.0k|}
loadfile.c:check_previous_track_selection:
  776|  24.2k|{
  777|  24.2k|    struct MPOpts *opts = mpctx->opts;
  778|       |
  779|  24.2k|    if (!mpctx->track_layout_hash)
  ------------------
  |  Branch (779:9): [True: 24.2k, False: 0]
  ------------------
  780|  24.2k|        return;
  781|       |
  782|      0|    char *h = track_layout_hash(mpctx);
  783|      0|    if (strcmp(h, mpctx->track_layout_hash) != 0) {
  ------------------
  |  Branch (783:9): [True: 0, False: 0]
  ------------------
  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|      0|        for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (786:25): [True: 0, False: 0]
  ------------------
  787|      0|            for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (787:29): [True: 0, False: 0]
  ------------------
  788|      0|                if (opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (788:21): [True: 0, False: 0]
  ------------------
  789|      0|                    mark_track_selection(mpctx, i, t, i == 0 ? -1 : -2);
  ------------------
  |  Branch (789:55): [True: 0, False: 0]
  ------------------
  790|      0|            }
  791|      0|        }
  792|      0|        talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  793|      0|        mpctx->track_layout_hash = NULL;
  794|      0|    }
  795|      0|    talloc_free(h);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  796|      0|}
loadfile.c:clear_playlist_paths:
 1452|  21.7k|{
 1453|       |    TA_FREEP(&mpctx->playlist_paths);
  ------------------
  |  |   81|  21.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  21.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 21.7k]
  |  |  ------------------
  ------------------
 1454|  21.7k|    mpctx->playlist_paths_len = 0;
 1455|  21.7k|}
loadfile.c:append_to_watch_history:
 1735|  21.7k|{
 1736|  21.7k|    if (!mpctx->opts->save_watch_history)
  ------------------
  |  Branch (1736:9): [True: 21.7k, False: 0]
  ------------------
 1737|  21.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|  24.7k|{
  194|  99.0k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (194:21): [True: 74.2k, False: 24.7k]
  ------------------
  195|   173k|        for (int r = 0; r < num_ptracks[t]; r++)
  ------------------
  |  Branch (195:25): [True: 99.0k, False: 74.2k]
  ------------------
  196|  99.0k|            mpctx->current_track[r][t] = NULL;
  197|  74.2k|    }
  198|       |
  199|  24.7k|    talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  200|  24.7k|    mpctx->chapters = NULL;
  201|  24.7k|    mpctx->num_chapters = 0;
  202|       |
  203|  24.7k|    mp_abort_cache_dumping(mpctx);
  204|       |
  205|  24.7k|    struct demuxer **demuxers = NULL;
  206|  24.7k|    int num_demuxers = 0;
  207|       |
  208|  24.7k|    if (mpctx->demuxer)
  ------------------
  |  Branch (208:9): [True: 24.2k, False: 496]
  ------------------
  209|  24.2k|        MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, mpctx->demuxer);
  ------------------
  |  |  105|  24.2k|    do {                                            \
  |  |  106|  24.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.2k|    do {                                            \
  |  |  |  |   97|  24.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.2k|    do {                                                        \
  |  |  |  |  |  |   89|  24.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.2k|        (idxvar)++;                                 \
  |  |  109|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  210|  24.7k|    mpctx->demuxer = NULL;
  211|       |
  212|  67.3k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (212:21): [True: 42.5k, False: 24.7k]
  ------------------
  213|  42.5k|        struct track *track = mpctx->tracks[i];
  214|       |
  215|  42.5k|        mp_assert(!track->dec && !track->d_sub);
  ------------------
  |  |   41|  42.5k|#define mp_assert assert
  ------------------
  |  Branch (215:9): [True: 42.5k, False: 0]
  |  Branch (215:9): [True: 42.5k, False: 0]
  ------------------
  216|  42.5k|        mp_assert(!track->vo_c && !track->ao_c);
  ------------------
  |  |   41|  42.5k|#define mp_assert assert
  ------------------
  |  Branch (216:9): [True: 42.5k, False: 0]
  |  Branch (216:9): [True: 42.5k, False: 0]
  ------------------
  217|  42.5k|        mp_assert(!track->sink);
  ------------------
  |  |   41|  42.5k|#define mp_assert assert
  ------------------
  |  Branch (217:9): [True: 42.5k, 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|  42.5k|        for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (221:25): [True: 42.5k, False: 0]
  ------------------
  222|  42.5k|            if (demuxers[n] == track->demuxer) {
  ------------------
  |  Branch (222:17): [True: 42.5k, False: 0]
  ------------------
  223|  42.5k|                track->demuxer = NULL;
  224|  42.5k|                break;
  225|  42.5k|            }
  226|  42.5k|        }
  227|  42.5k|        if (track->demuxer)
  ------------------
  |  Branch (227:13): [True: 0, False: 42.5k]
  ------------------
  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|  42.5k|        talloc_free(track);
  ------------------
  |  |   47|  42.5k|#define talloc_free                     ta_free
  ------------------
  231|  42.5k|    }
  232|  24.7k|    mpctx->num_tracks = 0;
  233|       |
  234|  24.7k|    kill_demuxers_reentrant(mpctx, demuxers, num_demuxers);
  235|  24.7k|    talloc_free(demuxers);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  236|       |
  237|  24.7k|    disc_nav_reset(mpctx);
  238|  24.7k|}
loadfile.c:kill_demuxers_reentrant:
  135|  24.7k|{
  136|  24.7k|    struct demux_free_async_state **items = NULL;
  137|  24.7k|    int num_items = 0;
  138|       |
  139|  49.0k|    for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (139:21): [True: 24.2k, False: 24.7k]
  ------------------
  140|  24.2k|        struct demuxer *d = demuxers[n];
  141|       |
  142|  24.2k|        if (!demux_cancel_test(d)) {
  ------------------
  |  Branch (142:13): [True: 24.2k, False: 0]
  ------------------
  143|       |            // Make sure it is set if it wasn't yet.
  144|  24.2k|            demux_set_wakeup_cb(d, wakeup_demux, mpctx);
  145|       |
  146|  24.2k|            struct demux_free_async_state *item = demux_free_async(d);
  147|  24.2k|            if (item) {
  ------------------
  |  Branch (147:17): [True: 24.2k, False: 0]
  ------------------
  148|  24.2k|                MP_TARRAY_APPEND(NULL, items, num_items, item);
  ------------------
  |  |  105|  24.2k|    do {                                            \
  |  |  106|  24.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  24.2k|    do {                                            \
  |  |  |  |   97|  24.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  24.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  24.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  24.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 24.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  24.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  24.2k|    do {                                                        \
  |  |  |  |  |  |   89|  24.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  24.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  24.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  24.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  24.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  24.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  24.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 24.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  24.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 24.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  24.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  24.2k|        (idxvar)++;                                 \
  |  |  109|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  149|  24.2k|                d = NULL;
  150|  24.2k|            }
  151|  24.2k|        }
  152|       |
  153|  24.2k|        demux_cancel_and_free(d);
  154|  24.2k|    }
  155|       |
  156|  24.7k|    if (!num_items)
  ------------------
  |  Branch (156:9): [True: 496, False: 24.2k]
  ------------------
  157|    496|        return;
  158|       |
  159|  24.2k|    MP_DBG(mpctx, "Terminating demuxers...\n");
  ------------------
  |  |   93|  24.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|       |
  161|  24.2k|    double end = mp_time_sec() + mpctx->opts->demux_termination_timeout;
  162|  24.2k|    bool force = false;
  163|  96.7k|    while (num_items) {
  ------------------
  |  Branch (163:12): [True: 72.4k, False: 24.2k]
  ------------------
  164|  72.4k|        double wait = end - mp_time_sec();
  165|       |
  166|   120k|        for (int n = 0; n < num_items; n++) {
  ------------------
  |  Branch (166:25): [True: 72.4k, False: 48.2k]
  ------------------
  167|  72.4k|            struct demux_free_async_state *item = items[n];
  168|  72.4k|            if (demux_free_async_finish(item)) {
  ------------------
  |  Branch (168:17): [True: 24.2k, False: 48.2k]
  ------------------
  169|  24.2k|                items[n] = items[num_items - 1];
  170|  24.2k|                num_items -= 1;
  171|  24.2k|                n--;
  172|  24.2k|                goto repeat;
  173|  48.2k|            } else if (wait < 0) {
  ------------------
  |  Branch (173:24): [True: 0, False: 48.2k]
  ------------------
  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|  72.4k|        }
  180|       |
  181|  48.2k|        if (wait >= 0)
  ------------------
  |  Branch (181:13): [True: 48.2k, False: 0]
  ------------------
  182|  48.2k|            mp_set_timeout(mpctx, wait);
  183|  48.2k|        mp_idle(mpctx);
  184|  72.4k|    repeat:;
  185|  72.4k|    }
  186|       |
  187|  24.2k|    talloc_free(items);
  ------------------
  |  |   47|  24.2k|#define talloc_free                     ta_free
  ------------------
  188|       |
  189|  24.2k|    MP_DBG(mpctx, "Done terminating demuxers.\n");
  ------------------
  |  |   93|  24.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  190|  24.2k|}
loadfile.c:cancel_open:
 1334|  74.2k|{
 1335|  74.2k|    if (mpctx->open_cancel)
  ------------------
  |  Branch (1335:9): [True: 24.7k, False: 49.5k]
  ------------------
 1336|  24.7k|        mp_cancel_trigger(mpctx->open_cancel);
 1337|       |
 1338|  74.2k|    if (mpctx->open_active)
  ------------------
  |  Branch (1338:9): [True: 24.7k, False: 49.5k]
  ------------------
 1339|  24.7k|        mp_thread_join(mpctx->open_thread);
  ------------------
  |  |  215|  24.7k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1340|  74.2k|    mpctx->open_active = false;
 1341|       |
 1342|  74.2k|    if (mpctx->open_res_demuxer)
  ------------------
  |  Branch (1342:9): [True: 0, False: 74.2k]
  ------------------
 1343|      0|        demux_cancel_and_free(mpctx->open_res_demuxer);
 1344|  74.2k|    mpctx->open_res_demuxer = NULL;
 1345|       |
 1346|  74.2k|    TA_FREEP(&mpctx->open_cancel);
  ------------------
  |  |   81|  74.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  74.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 74.2k]
  |  |  ------------------
  ------------------
 1347|  74.2k|    TA_FREEP(&mpctx->open_url);
  ------------------
  |  |   81|  74.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  74.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 74.2k]
  |  |  ------------------
  ------------------
 1348|  74.2k|    TA_FREEP(&mpctx->open_format);
  ------------------
  |  |   81|  74.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  74.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 74.2k]
  |  |  ------------------
  ------------------
 1349|       |
 1350|       |    atomic_store(&mpctx->open_done, false);
 1351|  74.2k|}

mp_update_logging:
  129|  49.5k|{
  130|  49.5k|    bool had_log_file = mp_msg_has_log_file(mpctx->global);
  131|       |
  132|  49.5k|    mp_msg_update_msglevels(mpctx->global, mpctx->opts);
  133|       |
  134|  49.5k|    bool enable = mpctx->opts->use_terminal;
  135|  49.5k|    bool enabled = cas_terminal_owner(mpctx, mpctx);
  136|  49.5k|    if (enable != enabled) {
  ------------------
  |  Branch (136:9): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|    if (mp_msg_has_log_file(mpctx->global) && !had_log_file) {
  ------------------
  |  Branch (146:9): [True: 0, False: 49.5k]
  |  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|  49.5k|    if (enabled && !preinit && mpctx->opts->consolecontrols)
  ------------------
  |  Branch (153:9): [True: 0, False: 49.5k]
  |  Branch (153:20): [True: 0, False: 0]
  |  Branch (153:32): [True: 0, False: 0]
  ------------------
  154|      0|        terminal_setup_getch(mpctx->input);
  155|       |
  156|  49.5k|    if (enabled)
  ------------------
  |  Branch (156:9): [True: 0, False: 49.5k]
  ------------------
  157|      0|        mp_encoder_update_log(mpctx->global);
  158|  49.5k|}
mp_print_version:
  161|  24.7k|{
  162|  24.7k|    int v = always ? MSGL_INFO : MSGL_V;
  ------------------
  |  Branch (162:13): [True: 0, False: 24.7k]
  ------------------
  163|  24.7k|    mp_msg(log, v, "%s %s\n", mpv_version, mpv_copyright);
  164|  24.7k|    if (strcmp(mpv_builddate, "UNKNOWN"))
  ------------------
  |  Branch (164:9): [True: 24.7k, False: 0]
  ------------------
  165|  24.7k|        mp_msg(log, v, " built on %s\n", mpv_builddate);
  166|  24.7k|    mp_msg(log, v, "libplacebo version: %s\n", PL_VERSION);
  ------------------
  |  |   32|  24.7k|#define PL_VERSION (pl_version())
  ------------------
  167|  24.7k|    check_library_versions(log, v);
  168|       |    // Only in verbose mode.
  169|  24.7k|    if (!always) {
  ------------------
  |  Branch (169:9): [True: 24.7k, False: 0]
  ------------------
  170|  24.7k|        mp_msg(log, MSGL_V, "Configuration: " CONFIGURATION "\n");
  171|  24.7k|        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|  24.7k|    }
  176|  24.7k|}
mp_destroy:
  179|  24.7k|{
  180|  24.7k|    mp_shutdown_clients(mpctx);
  181|       |
  182|  24.7k|    mp_uninit_ipc(mpctx->ipc_ctx);
  183|  24.7k|    mpctx->ipc_ctx = NULL;
  184|       |
  185|  24.7k|    uninit_audio_out(mpctx);
  186|  24.7k|    uninit_video_out(mpctx);
  187|       |
  188|       |    // If it's still set here, it's an error.
  189|  24.7k|    encode_lavc_free(mpctx->encode_lavc_ctx);
  190|  24.7k|    mpctx->encode_lavc_ctx = NULL;
  191|       |
  192|  24.7k|    command_uninit(mpctx);
  193|  24.7k|    disc_nav_destroy(mpctx);
  194|       |
  195|  24.7k|    mp_clients_destroy(mpctx);
  196|       |
  197|  24.7k|    osd_free(mpctx->osd);
  198|       |
  199|       |#if HAVE_COCOA
  200|       |    cocoa_set_input_context(NULL);
  201|       |#endif
  202|       |
  203|  24.7k|    if (cas_terminal_owner(mpctx, mpctx)) {
  ------------------
  |  Branch (203:9): [True: 0, False: 24.7k]
  ------------------
  204|      0|        terminal_uninit();
  205|      0|        cas_terminal_owner(mpctx, NULL);
  206|      0|    }
  207|       |
  208|  24.7k|    mp_input_uninit(mpctx->input);
  209|  24.7k|    mp_clipboard_destroy(mpctx->clipboard);
  210|       |
  211|  24.7k|    uninit_libav(mpctx->global);
  212|       |
  213|  24.7k|    mp_msg_uninit(mpctx->global);
  214|  24.7k|    mp_assert(!mpctx->num_abort_list);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 24.7k, False: 0]
  ------------------
  215|  24.7k|    talloc_free(mpctx->abort_list);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  216|  24.7k|    mp_mutex_destroy(&mpctx->abort_lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  217|  24.7k|    talloc_free(mpctx->mconfig); // destroy before dispatch
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  218|  24.7k|    talloc_free(mpctx);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  219|  24.7k|}
mp_create:
  261|  24.7k|{
  262|  24.7k|    if (!check_locale()) {
  ------------------
  |  Branch (262:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    char *enable_talloc = getenv("MPV_LEAK_REPORT");
  271|  24.7k|    if (enable_talloc && strcmp(enable_talloc, "1") == 0)
  ------------------
  |  Branch (271:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    mp_time_init();
  275|       |
  276|  24.7k|    struct MPContext *mpctx = talloc(NULL, MPContext);
  ------------------
  |  |   26|  24.7k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.7k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|  24.7k|    *mpctx = (struct MPContext){
  278|  24.7k|        .last_chapter = -2,
  279|  24.7k|        .term_osd_contents = talloc_strdup(mpctx, ""),
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
  280|  24.7k|        .osd_progbar = { .type = -1 },
  281|  24.7k|        .playlist = talloc_zero(mpctx, struct playlist),
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  282|  24.7k|        .dispatch = mp_dispatch_create(mpctx),
  283|  24.7k|        .playback_abort = mp_cancel_new(mpctx),
  284|  24.7k|        .thread_pool = mp_thread_pool_create(mpctx, 0, 1, 30),
  285|  24.7k|        .stop_play = PT_NEXT_ENTRY,
  286|  24.7k|        .play_dir = 1,
  287|  24.7k|    };
  288|       |
  289|  24.7k|    mp_mutex_init(&mpctx->abort_lock);
  290|       |
  291|  24.7k|    mpctx->global = talloc_zero(mpctx, struct mpv_global);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|  24.7k|    demux_packet_pool_init(mpctx->global);
  294|  24.7k|    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|  24.7k|    mp_msg_init(mpctx->global);
  301|  24.7k|    mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer");
  302|  24.7k|    mpctx->statusline = mp_log_new(mpctx, mpctx->log, "!statusline");
  303|       |
  304|  24.7k|    mpctx->stats = stats_ctx_create(mpctx, mpctx->global, "main");
  305|       |
  306|       |    // Create the config context and register the options
  307|  24.7k|    mpctx->mconfig = m_config_new(mpctx, mpctx->log, &mp_opt_root);
  308|  24.7k|    mpctx->opts = mpctx->mconfig->optstruct;
  309|  24.7k|    mpctx->global->config = mpctx->mconfig->shadow;
  310|  24.7k|    mpctx->mconfig->includefunc = cfg_include;
  311|  24.7k|    mpctx->mconfig->includefunc_ctx = mpctx;
  312|  24.7k|    mpctx->mconfig->use_profiles = true;
  313|  24.7k|    mpctx->mconfig->is_toplevel = true;
  314|  24.7k|    mpctx->mconfig->global = mpctx->global;
  315|  24.7k|    m_config_parse(mpctx->mconfig, "", bstr0(def_config), NULL, 0);
  316|       |
  317|  24.7k|    mpctx->input = mp_input_init(mpctx->global, mp_wakeup_core_cb, mpctx);
  318|  24.7k|    clipboard_init(mpctx);
  319|  24.7k|    screenshot_init(mpctx);
  320|  24.7k|    command_init(mpctx);
  321|  24.7k|    init_libav(mpctx->global);
  322|  24.7k|    mp_clients_init(mpctx);
  323|  24.7k|    mpctx->osd = osd_create(mpctx->global);
  324|       |
  325|       |#if HAVE_COCOA
  326|       |    cocoa_set_input_context(mpctx->input);
  327|       |#endif
  328|       |
  329|  24.7k|    char *verbose_env = getenv("MPV_VERBOSE");
  330|  24.7k|    if (verbose_env)
  ------------------
  |  Branch (330:9): [True: 0, False: 24.7k]
  ------------------
  331|      0|        mpctx->opts->verbose = strtol(verbose_env, NULL, 10);
  332|       |
  333|  24.7k|    mp_cancel_trigger(mpctx->playback_abort);
  334|       |
  335|  24.7k|    return mpctx;
  336|  24.7k|}
mp_initialize:
  344|  24.7k|{
  345|  24.7k|    struct MPOpts *opts = mpctx->opts;
  346|       |
  347|  24.7k|    mp_assert(!mpctx->initialized);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (347:5): [True: 24.7k, False: 0]
  ------------------
  348|       |
  349|       |    // Preparse the command line, so we can init the terminal early.
  350|  24.7k|    if (options) {
  ------------------
  |  Branch (350:9): [True: 0, False: 24.7k]
  ------------------
  351|      0|        m_config_preparse_command_line(mpctx->mconfig, mpctx->global,
  352|      0|                                       &opts->verbose, options);
  353|      0|    }
  354|       |
  355|  24.7k|    mp_init_paths(mpctx->global, opts);
  356|  24.7k|    mp_msg_set_early_logging(mpctx->global, true);
  357|  24.7k|    mp_update_logging(mpctx, true);
  358|       |
  359|  24.7k|    if (options) {
  ------------------
  |  Branch (359:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    mp_print_version(mpctx->log, false);
  367|       |
  368|  24.7k|    mp_parse_cfgfiles(mpctx);
  369|       |
  370|  24.7k|    if (options) {
  ------------------
  |  Branch (370:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if (opts->operation_mode == 1) {
  ------------------
  |  Branch (377:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    m_config_backup_watch_later_opts(mpctx->mconfig);
  387|       |
  388|  24.7k|    mp_input_load_config(mpctx->input);
  389|       |
  390|       |    // From this point on, all mpctx members are initialized.
  391|  24.7k|    mpctx->initialized = true;
  392|  24.7k|    mpctx->mconfig->option_change_callback = mp_option_change_callback;
  393|  24.7k|    mpctx->mconfig->option_change_callback_ctx = mpctx;
  394|  24.7k|    m_config_set_update_dispatch_queue(mpctx->mconfig, mpctx->dispatch);
  395|       |    // Run all update handlers.
  396|  24.7k|    mp_option_change_callback(mpctx, NULL, UPDATE_OPTS_MASK, false);
  ------------------
  |  |  465|  24.7k|#define UPDATE_OPTS_MASK        ((UPDATE_OPT_LAST << 1) - 1)
  |  |  ------------------
  |  |  |  |  462|  24.7k|#define UPDATE_OPT_LAST         (UINT64_C(1) << 20)
  |  |  ------------------
  ------------------
  397|  24.7k|    handle_option_callbacks(mpctx);
  398|       |
  399|  24.7k|    if (handle_help_options(mpctx))
  ------------------
  |  Branch (399:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    check_library_versions(mp_null_log, 0);
  408|       |
  409|  24.7k|    if (!mpctx->playlist->num_entries && !opts->player_idle_mode &&
  ------------------
  |  Branch (409:9): [True: 24.7k, False: 0]
  |  Branch (409:42): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    MP_STATS(mpctx, "start init");
  ------------------
  |  |   99|  24.7k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#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|  24.7k|    mp_dnd_init(mp_new_weak_client(mpctx->clients, "dnd"));
  430|       |
  431|  24.7k|    mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
  432|       |
  433|  24.7k|    if (opts->encode_opts->file && opts->encode_opts->file[0]) {
  ------------------
  |  Branch (433:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    mp_load_scripts(mpctx);
  442|       |
  443|  24.7k|    if (opts->force_vo == 2 && handle_force_window(mpctx, false) < 0)
  ------------------
  |  Branch (443:9): [True: 0, False: 24.7k]
  |  Branch (443:32): [True: 0, False: 0]
  ------------------
  444|      0|        return -1;
  445|       |
  446|       |    // Needed to properly enter _initial_ idle mode if playlist empty.
  447|  24.7k|    if (mpctx->opts->player_idle_mode && !mpctx->playlist->num_entries)
  ------------------
  |  Branch (447:9): [True: 24.7k, False: 0]
  |  Branch (447:42): [True: 24.7k, False: 0]
  ------------------
  448|  24.7k|        mpctx->stop_play = PT_STOP;
  449|       |
  450|  24.7k|    MP_STATS(mpctx, "end init");
  ------------------
  |  |   99|  24.7k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  451|       |
  452|  24.7k|    return 0;
  453|  24.7k|}
main.c:cas_terminal_owner:
  119|  74.2k|{
  120|  74.2k|    mp_mutex_lock(&terminal_owner_lock);
  ------------------
  |  |  134|  74.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  121|  74.2k|    bool r = terminal_owner == old;
  122|  74.2k|    if (r)
  ------------------
  |  Branch (122:9): [True: 0, False: 74.2k]
  ------------------
  123|      0|        terminal_owner = new;
  124|  74.2k|    mp_mutex_unlock(&terminal_owner_lock);
  ------------------
  |  |  136|  74.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  125|  74.2k|    return r;
  126|  74.2k|}
main.c:check_locale:
  255|  24.7k|{
  256|  24.7k|    char *name = setlocale(LC_NUMERIC, NULL);
  257|  24.7k|    return !name || strcmp(name, "C") == 0 || strcmp(name, "C.UTF-8") == 0;
  ------------------
  |  Branch (257:12): [True: 0, False: 24.7k]
  |  Branch (257:21): [True: 24.7k, False: 0]
  |  Branch (257:47): [True: 0, False: 0]
  ------------------
  258|  24.7k|}
main.c:handle_help_options:
  222|  24.7k|{
  223|  24.7k|    struct MPOpts *opts = mpctx->opts;
  224|  24.7k|    struct mp_log *log = mpctx->log;
  225|  24.7k|    if (opts->ao_opts->audio_device &&
  ------------------
  |  Branch (225:9): [True: 24.7k, False: 0]
  ------------------
  226|  24.7k|        strcmp(opts->ao_opts->audio_device, "help") == 0)
  ------------------
  |  Branch (226:9): [True: 0, False: 24.7k]
  ------------------
  227|      0|    {
  228|      0|        ao_print_devices(mpctx->global, log, mpctx->ao);
  229|      0|        return true;
  230|      0|    }
  231|  24.7k|    if (opts->property_print_help) {
  ------------------
  |  Branch (231:9): [True: 0, False: 24.7k]
  ------------------
  232|      0|        property_print_help(mpctx);
  233|      0|        return true;
  234|      0|    }
  235|  24.7k|    if (encode_lavc_showhelp(log, opts->encode_opts))
  ------------------
  |  Branch (235:9): [True: 0, False: 24.7k]
  ------------------
  236|      0|        return true;
  237|  24.7k|    return false;
  238|  24.7k|}

rel_time_to_abs:
   55|  1.10M|{
   56|  1.10M|    double length = get_time_length(mpctx);
   57|       |    // Relative times are an offset to the start of the file.
   58|  1.10M|    double start = 0;
   59|  1.10M|    if (mpctx->demuxer && !mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (59:9): [True: 1.10M, False: 0]
  |  Branch (59:27): [True: 0, False: 1.10M]
  ------------------
   60|      0|        start = mpctx->demuxer->start_time;
   61|       |
   62|  1.10M|    switch (t.type) {
  ------------------
  |  Branch (62:13): [True: 0, False: 1.10M]
  ------------------
   63|      0|    case REL_TIME_ABSOLUTE:
  ------------------
  |  Branch (63:5): [True: 0, False: 1.10M]
  ------------------
   64|      0|        return t.pos;
   65|      0|    case REL_TIME_RELATIVE:
  ------------------
  |  Branch (65:5): [True: 0, False: 1.10M]
  ------------------
   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.10M]
  ------------------
   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.10M]
  ------------------
   78|      0|        return chapter_start_time(mpctx, t.pos); // already absolute time
   79|  1.10M|    }
   80|       |
   81|  1.10M|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.10M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   82|  1.10M|}
get_play_end_pts:
  100|   542k|{
  101|   542k|    double end = get_play_end_pts_setting(mpctx);
  102|   542k|    double ab[2];
  103|   542k|    if (mpctx->ab_loop_clip && get_ab_loop_times(mpctx, ab)) {
  ------------------
  |  Branch (103:9): [True: 105k, False: 436k]
  |  Branch (103:32): [True: 0, False: 105k]
  ------------------
  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|   542k|    return end;
  108|   542k|}
get_ab_loop_times:
  125|   149k|{
  126|   149k|    struct MPOpts *opts = mpctx->opts;
  127|   149k|    int dir = mpctx->play_dir;
  128|       |
  129|   149k|    t[0] = opts->ab_loop[0];
  130|   149k|    t[1] = opts->ab_loop[1];
  131|       |
  132|   149k|    if (!mpctx->remaining_ab_loops)
  ------------------
  |  Branch (132:9): [True: 0, False: 149k]
  ------------------
  133|      0|        return false;
  134|       |
  135|   149k|    if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|   298k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|   149k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (135:9): [True: 149k, False: 0]
  |  Branch (135:35): [True: 0, False: 0]
  |  Branch (135:61): [True: 0, False: 0]
  ------------------
  136|   149k|        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|   149k|}
get_track_seek_offset:
  145|  47.1k|{
  146|  47.1k|    struct MPOpts *opts = mpctx->opts;
  147|  47.1k|    if (track->selected) {
  ------------------
  |  Branch (147:9): [True: 38.9k, False: 8.15k]
  ------------------
  148|  38.9k|        if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (148:13): [True: 16.5k, False: 22.3k]
  ------------------
  149|  16.5k|            return -opts->audio_delay;
  150|  22.3k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (150:13): [True: 2.70k, False: 19.6k]
  ------------------
  151|  2.70k|        {
  152|  2.70k|            for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (152:29): [True: 2.70k, False: 0]
  ------------------
  153|  2.70k|                if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (153:21): [True: 2.70k, False: 0]
  ------------------
  154|  2.70k|                    return -opts->subs_shared->sub_delay[n];
  155|  2.70k|            }
  156|  2.70k|        }
  157|  22.3k|    }
  158|  27.8k|    return 0;
  159|  47.1k|}
update_content_type:
  178|  18.3k|{
  179|  18.3k|    enum mp_content_type content_type;
  180|  18.3k|    if (!track || !track->vo_c) {
  ------------------
  |  Branch (180:9): [True: 0, False: 18.3k]
  |  Branch (180:19): [True: 0, False: 18.3k]
  ------------------
  181|      0|        content_type = MP_CONTENT_NONE;
  182|  18.3k|    } else if (track->image) {
  ------------------
  |  Branch (182:16): [True: 6.81k, False: 11.4k]
  ------------------
  183|  6.81k|        content_type = MP_CONTENT_IMAGE;
  184|  11.4k|    } else {
  185|  11.4k|        content_type = MP_CONTENT_VIDEO;
  186|  11.4k|    }
  187|  18.3k|    if (mpctx->video_out)
  ------------------
  |  Branch (187:9): [True: 18.3k, False: 0]
  ------------------
  188|  18.3k|        vo_control(mpctx->video_out, VOCTRL_CONTENT_TYPE, &content_type);
  189|  18.3k|}
update_vo_playback_state:
  192|   146k|{
  193|   146k|    if (mpctx->video_out && mpctx->video_out->config_ok) {
  ------------------
  |  Branch (193:9): [True: 121k, False: 24.8k]
  |  Branch (193:29): [True: 121k, False: 453]
  ------------------
  194|   121k|        struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
  195|   121k|        double pos = get_current_pos_ratio(mpctx, false);
  196|   121k|        struct voctrl_playback_state newstate = {
  197|   121k|            .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
  ------------------
  |  Branch (197:33): [True: 121k, False: 0]
  |  Branch (197:70): [True: 121k, False: 150]
  ------------------
  198|   121k|            .playing = mpctx->playing,
  199|   121k|            .paused = mpctx->paused,
  200|   121k|            .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
  ------------------
  |  Branch (200:25): [True: 90.3k, False: 31.1k]
  ------------------
  201|   121k|        };
  202|       |
  203|   121k|        bool state_changed = oldstate.taskbar_progress != newstate.taskbar_progress ||
  ------------------
  |  Branch (203:30): [True: 10.4k, False: 111k]
  ------------------
  204|   111k|                             oldstate.playing != newstate.playing ||
  ------------------
  |  Branch (204:30): [True: 145, False: 110k]
  ------------------
  205|   110k|                             oldstate.paused != newstate.paused;
  ------------------
  |  Branch (205:30): [True: 1.15k, False: 109k]
  ------------------
  206|   121k|        if (state_changed || oldstate.position != newstate.position) {
  ------------------
  |  Branch (206:13): [True: 11.7k, False: 109k]
  |  Branch (206:30): [True: 57.3k, False: 52.3k]
  ------------------
  207|       |            // Don't update progress bar if it was and still is hidden
  208|  69.1k|            if ((oldstate.playing && oldstate.taskbar_progress) ||
  ------------------
  |  Branch (208:18): [True: 58.5k, False: 10.5k]
  |  Branch (208:38): [True: 58.5k, False: 0]
  ------------------
  209|  10.5k|                (newstate.playing && newstate.taskbar_progress))
  ------------------
  |  Branch (209:18): [True: 10.5k, False: 0]
  |  Branch (209:38): [True: 10.4k, False: 145]
  ------------------
  210|  68.9k|            {
  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|  68.9k|                int64_t now = mp_time_ns();
  218|  68.9k|                int64_t elapsed = now - mpctx->vo_playback_state_time;
  219|  68.9k|                if (!state_changed && elapsed < MP_TIME_MS_TO_NS(1000))
  ------------------
  |  |   72|  57.3k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  |  Branch (219:21): [True: 57.3k, False: 11.6k]
  |  Branch (219:39): [True: 57.3k, False: 0]
  ------------------
  220|  57.3k|                    return;
  221|  11.6k|                mpctx->vo_playback_state_time = now;
  222|  11.6k|                vo_control_async(mpctx->video_out,
  223|  11.6k|                                 VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
  224|  11.6k|            }
  225|  11.7k|            mpctx->vo_playback_state = newstate;
  226|  11.7k|        }
  227|   121k|    } else {
  228|  25.2k|        mpctx->vo_playback_state = (struct voctrl_playback_state){ 0 };
  229|  25.2k|    }
  230|   146k|}
update_window_title:
  233|   174k|{
  234|   174k|    if (!mpctx->video_out && !mpctx->ao) {
  ------------------
  |  Branch (234:9): [True: 27.8k, False: 146k]
  |  Branch (234:30): [True: 24.7k, False: 3.09k]
  ------------------
  235|  24.7k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  236|  24.7k|        mpctx->last_window_title = NULL;
  237|  24.7k|        return;
  238|  24.7k|    }
  239|   149k|    char *title = mp_property_expand_string(mpctx, mpctx->opts->wintitle);
  240|   149k|    if (!mpctx->last_window_title || force ||
  ------------------
  |  Branch (240:9): [True: 21.6k, False: 128k]
  |  Branch (240:38): [True: 6.05k, False: 121k]
  ------------------
  241|   121k|        strcmp(title, mpctx->last_window_title) != 0)
  ------------------
  |  Branch (241:9): [True: 0, False: 121k]
  ------------------
  242|  27.7k|    {
  243|  27.7k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  27.7k|#define talloc_free                     ta_free
  ------------------
  244|  27.7k|        mpctx->last_window_title = talloc_steal(mpctx, title);
  ------------------
  |  |   38|  27.7k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  27.7k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  245|       |
  246|  27.7k|        if (mpctx->video_out)
  ------------------
  |  Branch (246:13): [True: 24.6k, False: 3.05k]
  ------------------
  247|  24.6k|            vo_control(mpctx->video_out, VOCTRL_UPDATE_WINDOW_TITLE, title);
  248|       |
  249|  27.7k|        if (mpctx->ao) {
  ------------------
  |  Branch (249:13): [True: 8.07k, False: 19.6k]
  ------------------
  250|  8.07k|            ao_control(mpctx->ao, AOCONTROL_UPDATE_STREAM_TITLE, title);
  251|  8.07k|        }
  252|   121k|    } else {
  253|   121k|        talloc_free(title);
  ------------------
  |  |   47|   121k|#define talloc_free                     ta_free
  ------------------
  254|   121k|    }
  255|   149k|}
error_on_track:
  258|  20.7k|{
  259|  20.7k|    if (!track || !track->selected)
  ------------------
  |  Branch (259:9): [True: 16.4k, False: 4.31k]
  |  Branch (259:19): [True: 0, False: 4.31k]
  ------------------
  260|  16.4k|        return;
  261|  4.31k|    int order = -1;
  262|  4.31k|    for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (262:21): [True: 4.31k, False: 0]
  ------------------
  263|  4.31k|        if (mpctx->current_track[t][track->type] == track) {
  ------------------
  |  Branch (263:13): [True: 4.31k, False: 0]
  ------------------
  264|  4.31k|            order = t;
  265|  4.31k|            break;
  266|  4.31k|        }
  267|  4.31k|    }
  268|       |    // Select the next best track, if the current one failed to initialize.
  269|  4.31k|    if (order >= 0 && track->dec_failed && mpctx->opts->stream_auto_sel &&
  ------------------
  |  Branch (269:9): [True: 4.31k, False: 0]
  |  Branch (269:23): [True: 4.31k, False: 4]
  |  Branch (269:44): [True: 4.31k, False: 0]
  ------------------
  270|  4.31k|        mpctx->opts->stream_id[order][track->type] == -1)
  ------------------
  |  Branch (270:9): [True: 4.31k, False: 0]
  ------------------
  271|  4.31k|    {
  272|  4.31k|        struct track *next = select_default_track(mpctx, order, track->type);
  273|  4.31k|        if (next) {
  ------------------
  |  Branch (273:13): [True: 238, False: 4.07k]
  ------------------
  274|    238|            MP_WARN(mpctx, "Falling back to %s track %d.\n",
  ------------------
  |  |   90|    238|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    238|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  275|    238|                    stream_type_name(track->type), next->user_tid);
  276|    238|            mp_switch_track_n(mpctx, order, track->type, next, 0);
  277|    238|            if (mpctx->current_track[order][track->type] != track)
  ------------------
  |  Branch (277:17): [True: 238, False: 0]
  ------------------
  278|    238|                return;
  279|    238|        }
  280|  4.31k|    }
  281|  4.07k|    mp_deselect_track(mpctx, track);
  282|  4.07k|    if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (282:9): [True: 2.64k, False: 1.43k]
  ------------------
  283|  4.07k|        MP_INFO(mpctx, "Audio: no audio\n");
  ------------------
  |  |   91|  2.64k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.64k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  284|  4.07k|    if (track->type == STREAM_VIDEO)
  ------------------
  |  Branch (284:9): [True: 1.34k, False: 2.73k]
  ------------------
  285|  4.07k|        MP_INFO(mpctx, "Video: no video\n");
  ------------------
  |  |   91|  1.34k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.34k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|  4.07k|    if (mpctx->opts->stop_playback_on_init_failure ||
  ------------------
  |  Branch (286:9): [True: 0, False: 4.07k]
  ------------------
  287|  4.07k|        (!mpctx->current_track[0][STREAM_AUDIO] &&
  ------------------
  |  Branch (287:10): [True: 3.10k, False: 971]
  ------------------
  288|  3.10k|         !mpctx->current_track[0][STREAM_VIDEO]))
  ------------------
  |  Branch (288:10): [True: 676, False: 2.43k]
  ------------------
  289|    676|    {
  290|    676|        if (!mpctx->stop_play)
  ------------------
  |  Branch (290:13): [True: 655, False: 21]
  ------------------
  291|    655|            mpctx->stop_play = PT_ERROR;
  292|    676|        if (mpctx->error_playing >= 0)
  ------------------
  |  Branch (292:13): [True: 0, False: 676]
  ------------------
  293|      0|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
  294|    676|    }
  295|  4.07k|    mp_wakeup_core(mpctx);
  296|  4.07k|}
mp_status_str:
  375|   253k|{
  376|   253k|    switch (st) {
  377|  58.5k|    case STATUS_SYNCING:    return "syncing";
  ------------------
  |  Branch (377:5): [True: 58.5k, False: 194k]
  ------------------
  378|    779|    case STATUS_READY:      return "ready";
  ------------------
  |  Branch (378:5): [True: 779, False: 252k]
  ------------------
  379|   148k|    case STATUS_PLAYING:    return "playing";
  ------------------
  |  Branch (379:5): [True: 148k, False: 104k]
  ------------------
  380|  10.1k|    case STATUS_DRAINING:   return "draining";
  ------------------
  |  Branch (380:5): [True: 10.1k, False: 242k]
  ------------------
  381|  34.7k|    case STATUS_EOF:        return "eof";
  ------------------
  |  Branch (381:5): [True: 34.7k, False: 218k]
  ------------------
  382|      0|    default:                return "bug";
  ------------------
  |  Branch (382:5): [True: 0, False: 253k]
  ------------------
  383|   253k|    }
  384|   253k|}
mp_format_track_metadata:
  392|  43.1k|{
  393|  43.1k|    struct sh_stream *s = t->stream;
  394|  43.1k|    bstr dst = {0};
  395|       |
  396|  43.1k|    if (t->title)
  ------------------
  |  Branch (396:9): [True: 12.8k, False: 30.2k]
  ------------------
  397|  12.8k|        bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title);
  398|       |
  399|  43.1k|    bstr_xappend0(ctx, &dst, "(");
  400|       |
  401|  43.1k|    if (add_lang && t->lang)
  ------------------
  |  Branch (401:9): [True: 0, False: 43.1k]
  |  Branch (401:21): [True: 0, False: 0]
  ------------------
  402|      0|        bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang);
  403|       |
  404|  43.1k|    if (s) {
  ------------------
  |  Branch (404:9): [True: 43.1k, False: 0]
  ------------------
  405|  43.1k|        demux_append_codec_desc(ctx, &dst, s, NULL);
  406|  43.1k|    } else {
  407|      0|        bstr_xappend0(ctx, &dst, "<unknown>");
  408|      0|    }
  409|  43.1k|    bstr_xappend0(ctx, &dst, ")");
  410|       |
  411|  43.1k|    bool first = true;
  412|  43.1k|    if (t->default_track)
  ------------------
  |  Branch (412:9): [True: 26.5k, False: 16.5k]
  ------------------
  413|  26.5k|        ADD_FLAG(ctx, dst, "default", first);
  ------------------
  |  |  386|  26.5k|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|  26.5k|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 26.5k, False: 0]
  |  |  ------------------
  |  |  388|  26.5k|    first = false;                                                     \
  |  |  389|  26.5k|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 26.5k]
  |  |  ------------------
  ------------------
  414|  43.1k|    if (t->forced_track)
  ------------------
  |  Branch (414:9): [True: 25, False: 43.0k]
  ------------------
  415|     25|        ADD_FLAG(ctx, dst, "forced", first);
  ------------------
  |  |  386|     25|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|     25|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 9, False: 16]
  |  |  ------------------
  |  |  388|     25|    first = false;                                                     \
  |  |  389|     25|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 25]
  |  |  ------------------
  ------------------
  416|  43.1k|    if (t->dependent_track)
  ------------------
  |  Branch (416:9): [True: 0, False: 43.1k]
  ------------------
  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|  43.1k|    if (t->visual_impaired_track)
  ------------------
  |  Branch (418:9): [True: 1, False: 43.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: 0, False: 1]
  |  |  ------------------
  |  |  388|      1|    first = false;                                                     \
  |  |  389|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 1]
  |  |  ------------------
  ------------------
  420|  43.1k|    if (t->hearing_impaired_track)
  ------------------
  |  Branch (420:9): [True: 1, False: 43.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: 0, False: 1]
  |  |  ------------------
  |  |  388|      1|    first = false;                                                     \
  |  |  389|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 1]
  |  |  ------------------
  ------------------
  422|  43.1k|    if (t->original_track)
  ------------------
  |  Branch (422:9): [True: 0, False: 43.1k]
  ------------------
  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|  43.1k|    if (t->commentary_track)
  ------------------
  |  Branch (424:9): [True: 1, False: 43.0k]
  ------------------
  425|      1|        ADD_FLAG(ctx, dst, "commentary", 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]
  |  |  ------------------
  ------------------
  426|  43.1k|    if (t->is_external)
  ------------------
  |  Branch (426:9): [True: 0, False: 43.1k]
  ------------------
  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|  43.1k|    if (!first)
  ------------------
  |  Branch (428:9): [True: 26.5k, False: 16.5k]
  ------------------
  429|  26.5k|        bstr_xappend0(ctx, &dst, "]");
  430|       |
  431|  43.1k|    return bstrto0(ctx, dst);
  432|  43.1k|}
mp_find_non_filename_media_title:
  435|  1.52M|{
  436|  1.52M|    const char *name = mpctx->opts->media_title;
  437|  1.52M|    if (name && name[0])
  ------------------
  |  Branch (437:9): [True: 0, False: 1.52M]
  |  Branch (437:17): [True: 0, False: 0]
  ------------------
  438|      0|        return name;
  439|  1.52M|    if (mpctx->demuxer) {
  ------------------
  |  Branch (439:9): [True: 1.52M, False: 350]
  ------------------
  440|  1.52M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
  441|  1.52M|        if (name && name[0])
  ------------------
  |  Branch (441:13): [True: 0, False: 1.52M]
  |  Branch (441:21): [True: 0, False: 0]
  ------------------
  442|      0|            return name;
  443|  1.52M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
  444|  1.52M|        if (name && name[0])
  ------------------
  |  Branch (444:13): [True: 75.2k, False: 1.44M]
  |  Branch (444:21): [True: 75.1k, False: 135]
  ------------------
  445|  75.1k|            return name;
  446|  1.44M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
  447|  1.44M|        if (name && name[0])
  ------------------
  |  Branch (447:13): [True: 0, False: 1.44M]
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|      0|            return name;
  449|  1.44M|    }
  450|  1.44M|    if (mpctx->playing && mpctx->playing->title)
  ------------------
  |  Branch (450:9): [True: 1.44M, False: 0]
  |  Branch (450:27): [True: 20, False: 1.44M]
  ------------------
  451|     20|        return mpctx->playing->title;
  452|  1.44M|    if (mpctx->demuxer && mpctx->demuxer->server_filename)
  ------------------
  |  Branch (452:9): [True: 1.44M, False: 330]
  |  Branch (452:27): [True: 0, False: 1.44M]
  ------------------
  453|      0|        return mpctx->demuxer->server_filename;
  454|  1.44M|    return NULL;
  455|  1.44M|}
misc.c:get_play_end_pts_setting:
   85|   542k|{
   86|   542k|    struct MPOpts *opts = mpctx->opts;
   87|   542k|    double end = rel_time_to_abs(mpctx, opts->play_end);
   88|   542k|    double length = rel_time_to_abs(mpctx, opts->play_length);
   89|   542k|    if (length != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   542k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (89:9): [True: 0, False: 542k]
  ------------------
   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|   542k|    return end;
   95|   542k|}

term_osd_clear_subs:
  123|  43.4k|{
  124|  43.4k|    term_osd_set_subs(mpctx, NULL, 0);
  125|       |    term_osd_set_subs(mpctx, NULL, 1);
  126|  43.4k|}
term_osd_set_subs:
  129|  90.5k|{
  130|  90.5k|    if (mpctx->video_out || !text || !mpctx->opts->subs_shared->sub_visibility[order])
  ------------------
  |  Branch (130:9): [True: 39.6k, False: 50.9k]
  |  Branch (130:29): [True: 50.2k, False: 611]
  |  Branch (130:38): [True: 0, False: 611]
  ------------------
  131|  89.9k|        text = ""; // disable
  132|  90.5k|    if (strcmp(mpctx->term_osd_subs[order] ? mpctx->term_osd_subs[order] : "", text) == 0)
  ------------------
  |  Branch (132:9): [True: 90.5k, False: 34]
  |  Branch (132:16): [True: 41, False: 90.5k]
  ------------------
  133|  90.5k|        return;
  134|     34|    talloc_replace(mpctx, mpctx->term_osd_subs[order], text);
  ------------------
  |  |   54|     34|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|     34|    do {                                                \
  |  |  |  |  107|     34|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 17, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  108|     17|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|     17|        } else {                                        \
  |  |  |  |  110|     17|            *(str) = '\0';                              \
  |  |  |  |  111|     17|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|     17|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|     17|        }                                               \
  |  |  |  |  113|     34|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|     34|    term_osd_update(mpctx);
  136|     34|}
set_osd_bar_chapters:
  377|  46.5k|{
  378|  46.5k|    if (mpctx->osd_progbar.type != type)
  ------------------
  |  Branch (378:9): [True: 46.5k, False: 0]
  ------------------
  379|  46.5k|        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|   646k|{
  504|   646k|    struct MPOpts *opts = mpctx->opts;
  505|   646k|    struct osd_state *osd = mpctx->osd;
  506|       |
  507|   646k|    double now = mp_time_sec();
  508|       |
  509|   646k|    if (!mpctx->osd_force_update) {
  ------------------
  |  Branch (509:9): [True: 525k, False: 121k]
  ------------------
  510|       |        // Assume nothing is going on at all.
  511|   525k|        if (!mpctx->osd_idle_update)
  ------------------
  |  Branch (511:13): [True: 27.2k, False: 497k]
  ------------------
  512|  27.2k|            return;
  513|       |
  514|   497k|        double delay = 0.050; // update the OSD at most this often
  515|   497k|        double diff = now - mpctx->osd_last_update;
  516|   497k|        if (diff < delay) {
  ------------------
  |  Branch (516:13): [True: 472k, False: 25.3k]
  ------------------
  517|   472k|            mp_set_timeout(mpctx, delay - diff);
  518|   472k|            return;
  519|   472k|        }
  520|   497k|    }
  521|   146k|    mpctx->osd_force_update = false;
  522|   146k|    mpctx->osd_idle_update = false;
  523|   146k|    mpctx->osd_last_update = now;
  524|       |
  525|   146k|    if (mpctx->osd_visible) {
  ------------------
  |  Branch (525:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->osd_function_visible) {
  ------------------
  |  Branch (537:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->osd_msg_next_duration > 0) {
  ------------------
  |  Branch (548:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->osd_msg_visible) {
  ------------------
  |  Branch (555:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    add_seek_osd_messages(mpctx);
  569|       |
  570|   146k|    if (mpctx->osd_progbar.type == OSD_BAR_SEEK) {
  ------------------
  |  Branch (570:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    term_osd_set_text_lazy(mpctx, mpctx->osd_msg_text);
  576|   146k|    term_osd_print_status_lazy(mpctx);
  577|   146k|    term_osd_update(mpctx);
  578|       |
  579|   146k|    if (!opts->video_osd)
  ------------------
  |  Branch (579:9): [True: 144k, False: 1.77k]
  ------------------
  580|   144k|        return;
  581|       |
  582|  1.77k|    int osd_level = opts->osd_level;
  583|  1.77k|    if (mpctx->osd_show_pos)
  ------------------
  |  Branch (583:9): [True: 0, False: 1.77k]
  ------------------
  584|      0|        osd_level = 3;
  585|       |
  586|  1.77k|    char *text = NULL;
  587|  1.77k|    sadd_osd_status(&text, mpctx, osd_level);
  588|  1.77k|    if (mpctx->osd_msg_text && mpctx->osd_msg_text[0]) {
  ------------------
  |  Branch (588:9): [True: 0, False: 1.77k]
  |  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|  1.77k|    osd_set_text(osd, text);
  593|  1.77k|    talloc_free(text);
  ------------------
  |  |   47|  1.77k|#define talloc_free                     ta_free
  ------------------
  594|  1.77k|}
osd.c:term_osd_update:
   76|   146k|{
   77|   146k|    int num_parts = 0;
   78|   146k|    char *parts[4] = {0};
   79|       |
   80|   146k|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (80:9): [True: 146k, False: 0]
  ------------------
   81|   146k|        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|   146k|{
  473|   146k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
  ------------------
  |  Branch (473:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
  ------------------
  |  Branch (478:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) {
  ------------------
  |  Branch (486:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CURRENT_FILE) {
  ------------------
  |  Branch (492:9): [True: 0, False: 146k]
  ------------------
  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|   146k|    mpctx->add_osd_seek_info = 0;
  499|   146k|}
osd.c:term_osd_set_text_lazy:
  139|   146k|{
  140|   146k|    bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (140:22): [True: 121k, False: 24.8k]
  |  Branch (140:42): [True: 0, False: 121k]
  ------------------
  141|   146k|    if ((video_osd && mpctx->opts->term_osd != 1) || !text)
  ------------------
  |  Branch (141:10): [True: 0, False: 146k]
  |  Branch (141:23): [True: 0, False: 0]
  |  Branch (141:54): [True: 146k, False: 0]
  ------------------
  142|   146k|        text = ""; // disable
  143|   146k|    talloc_replace(mpctx, mpctx->term_osd_text, text);
  ------------------
  |  |   54|   146k|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|   146k|    do {                                                \
  |  |  |  |  107|   146k|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 24.7k, False: 122k]
  |  |  |  |  ------------------
  |  |  |  |  108|  24.7k|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|   122k|        } else {                                        \
  |  |  |  |  110|   122k|            *(str) = '\0';                              \
  |  |  |  |  111|   122k|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|   122k|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|   122k|        }                                               \
  |  |  |  |  113|   146k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 146k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|   146k|}
osd.c:term_osd_print_status_lazy:
  281|   146k|{
  282|   146k|    struct MPOpts *opts = mpctx->opts;
  283|       |
  284|   146k|    term_osd_update_title(mpctx);
  285|   146k|    update_window_title(mpctx, false);
  286|   146k|    update_vo_playback_state(mpctx);
  287|       |
  288|   146k|    if (!opts->use_terminal)
  ------------------
  |  Branch (288:9): [True: 146k, False: 0]
  ------------------
  289|   146k|        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|   146k|{
  107|   146k|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (107:9): [True: 146k, False: 0]
  ------------------
  108|   146k|        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|  1.77k|{
  439|  1.77k|    mp_assert(level >= 0 && level <= 3);
  ------------------
  |  |   41|  1.77k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 1.77k, False: 0]
  |  Branch (439:5): [True: 1.77k, False: 0]
  ------------------
  440|  1.77k|    if (level == 0)
  ------------------
  |  Branch (440:9): [True: 0, False: 1.77k]
  ------------------
  441|      0|        return;
  442|  1.77k|    char *msg = mpctx->opts->osd_msg[level - 1];
  443|       |
  444|  1.77k|    if (msg && msg[0]) {
  ------------------
  |  Branch (444:9): [True: 0, False: 1.77k]
  |  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|  1.77k|    } else if (level >= 2) {
  ------------------
  |  Branch (448:16): [True: 0, False: 1.77k]
  ------------------
  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|  1.77k|}

mp_wait_events:
   55|   562k|{
   56|   562k|    mp_client_send_property_changes(mpctx);
   57|       |
   58|   562k|    stats_event(mpctx->stats, "iterations");
   59|       |
   60|   562k|    bool sleeping = mpctx->sleeptime > 0;
   61|   562k|    if (sleeping)
  ------------------
  |  Branch (61:9): [True: 518k, False: 43.2k]
  ------------------
   62|   562k|        MP_STATS(mpctx, "start sleep");
  ------------------
  |  |   99|   518k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   518k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   63|       |
   64|   562k|    mp_dispatch_queue_process(mpctx->dispatch, mpctx->sleeptime);
   65|       |
   66|   562k|    mpctx->sleeptime = INFINITY;
   67|       |
   68|   562k|    if (sleeping)
  ------------------
  |  Branch (68:9): [True: 518k, False: 43.2k]
  ------------------
   69|   562k|        MP_STATS(mpctx, "end sleep");
  ------------------
  |  |   99|   518k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   518k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   70|   562k|}
mp_set_timeout:
   76|  1.51M|{
   77|  1.51M|    if (mpctx->sleeptime > sleeptime) {
  ------------------
  |  Branch (77:9): [True: 890k, False: 622k]
  ------------------
   78|   890k|        mpctx->sleeptime = sleeptime;
   79|   890k|        int64_t abstime = mp_time_ns_add(mp_time_ns(), sleeptime);
   80|   890k|        mp_dispatch_adjust_timeout(mpctx->dispatch, abstime);
   81|   890k|    }
   82|  1.51M|}
mp_wakeup_core:
   88|  1.12M|{
   89|  1.12M|    mp_dispatch_interrupt(mpctx->dispatch);
   90|  1.12M|}
mp_wakeup_core_cb:
   94|   416k|{
   95|   416k|    struct MPContext *mpctx = ctx;
   96|   416k|    mp_wakeup_core(mpctx);
   97|   416k|}
mp_core_lock:
  100|  24.2k|{
  101|  24.2k|    mp_dispatch_lock(mpctx->dispatch);
  102|  24.2k|}
mp_core_unlock:
  105|  24.2k|{
  106|  24.2k|    mp_dispatch_unlock(mpctx->dispatch);
  107|  24.2k|}
handle_option_callbacks:
  128|   528k|{
  129|   553k|    for (int i = 0; i < mpctx->num_option_callbacks; i++)
  ------------------
  |  Branch (129:21): [True: 24.7k, False: 528k]
  ------------------
  130|  24.7k|        mp_option_run_callback(mpctx, &mpctx->option_callbacks[i]);
  131|   528k|    mpctx->num_option_callbacks = 0;
  132|   528k|}
get_relative_time:
  135|   170k|{
  136|   170k|    int64_t new_time = mp_time_ns();
  137|   170k|    int64_t delta = new_time - mpctx->last_time;
  138|   170k|    mpctx->last_time = new_time;
  139|   170k|    return delta * 1e-9;
  140|   170k|}
update_core_idle_state:
  143|   370k|{
  144|   370k|    bool eof = mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (144:16): [True: 159k, False: 210k]
  ------------------
  145|   159k|               mpctx->audio_status == STATUS_EOF;
  ------------------
  |  Branch (145:16): [True: 100k, False: 58.8k]
  ------------------
  146|   370k|    bool active = !mpctx->paused && mpctx->restart_complete &&
  ------------------
  |  Branch (146:19): [True: 369k, False: 1.44k]
  |  Branch (146:37): [True: 217k, False: 151k]
  ------------------
  147|   217k|                  !mpctx->stop_play && mpctx->in_playloop && !eof;
  ------------------
  |  Branch (147:19): [True: 174k, False: 43.4k]
  |  Branch (147:40): [True: 174k, False: 0]
  |  Branch (147:62): [True: 169k, False: 4.91k]
  ------------------
  148|       |
  149|   370k|    if (mpctx->playback_active != active) {
  ------------------
  |  Branch (149:9): [True: 35.2k, False: 335k]
  ------------------
  150|  35.2k|        mpctx->playback_active = active;
  151|       |
  152|  35.2k|        update_screensaver_state(mpctx);
  153|  35.2k|        mp_set_idle_power_mode(!active);
  154|       |
  155|       |        mp_notify(mpctx, MP_EVENT_CORE_IDLE, NULL);
  156|  35.2k|    }
  157|   370k|}
get_internal_paused:
  160|   109k|{
  161|   109k|    return mpctx->opts->pause || mpctx->paused_for_cache;
  ------------------
  |  Branch (161:12): [True: 0, False: 109k]
  |  Branch (161:34): [True: 579, False: 108k]
  ------------------
  162|   109k|}
set_pause_state:
  166|  48.0k|{
  167|  48.0k|    struct MPOpts *opts = mpctx->opts;
  168|       |
  169|  48.0k|    opts->pause = user_pause;
  170|       |
  171|  48.0k|    bool internal_paused = get_internal_paused(mpctx);
  172|  48.0k|    if (internal_paused != mpctx->paused) {
  ------------------
  |  Branch (172:9): [True: 1.15k, False: 46.9k]
  ------------------
  173|  1.15k|        mpctx->paused = internal_paused;
  174|       |
  175|  1.15k|        if (mpctx->ao) {
  ------------------
  |  Branch (175:13): [True: 24, False: 1.13k]
  ------------------
  176|     24|            bool eof = mpctx->audio_status == STATUS_EOF;
  177|     24|            ao_set_paused(mpctx->ao, internal_paused, eof);
  178|     24|        }
  179|       |
  180|  1.15k|        if (mpctx->video_out)
  ------------------
  |  Branch (180:13): [True: 1.15k, False: 0]
  ------------------
  181|  1.15k|            vo_set_paused(mpctx->video_out, internal_paused);
  182|       |
  183|  1.15k|        mpctx->osd_function = 0;
  184|  1.15k|        mpctx->osd_force_update = true;
  185|       |
  186|  1.15k|        mp_wakeup_core(mpctx);
  187|       |
  188|  1.15k|        if (internal_paused) {
  ------------------
  |  Branch (188:13): [True: 579, False: 579]
  ------------------
  189|    579|            mpctx->step_frames = 0;
  190|    579|            mpctx->time_frame -= get_relative_time(mpctx);
  191|    579|        } else {
  192|    579|            (void)get_relative_time(mpctx); // ignore time that passed during pause
  193|    579|        }
  194|  1.15k|    }
  195|       |
  196|  48.0k|    update_core_idle_state(mpctx);
  197|       |
  198|  48.0k|    m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
  199|  48.0k|}
update_internal_pause_state:
  202|  48.0k|{
  203|  48.0k|    set_pause_state(mpctx, mpctx->opts->pause);
  204|  48.0k|}
update_screensaver_state:
  207|   100k|{
  208|   100k|    if (!mpctx->video_out)
  ------------------
  |  Branch (208:9): [True: 33.0k, False: 67.0k]
  ------------------
  209|  33.0k|        return;
  210|       |
  211|   100k|    bool saver_state = (!mpctx->playback_active || !mpctx->opts->stop_screensaver) &&
  ------------------
  |  Branch (211:25): [True: 51.8k, False: 15.2k]
  |  Branch (211:52): [True: 0, False: 15.2k]
  ------------------
  212|  51.8k|                       mpctx->opts->stop_screensaver != 2;
  ------------------
  |  Branch (212:24): [True: 51.8k, False: 0]
  ------------------
  213|  67.0k|    vo_control_async(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
  ------------------
  |  Branch (213:40): [True: 51.8k, False: 15.2k]
  ------------------
  214|  67.0k|                                                   : VOCTRL_KILL_SCREENSAVER, NULL);
  215|  67.0k|}
reset_playback_state:
  243|  25.1k|{
  244|  25.1k|    mp_filter_reset(mpctx->filter_root);
  245|       |
  246|  25.1k|    reset_video_state(mpctx);
  247|  25.1k|    reset_audio_state(mpctx);
  248|  25.1k|    reset_subtitle_state(mpctx);
  249|       |
  250|  25.1k|    if (mpctx->demuxer)
  ------------------
  |  Branch (250:9): [True: 374, False: 24.7k]
  ------------------
  251|    374|        demux_nav_refresh(mpctx->demuxer);
  252|       |
  253|  25.9k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (253:21): [True: 815, False: 25.1k]
  ------------------
  254|    815|        struct track *t = mpctx->tracks[n];
  255|       |        // (Often, but not always, this is redundant and also done elsewhere.)
  256|    815|        if (t->dec)
  ------------------
  |  Branch (256:13): [True: 748, False: 67]
  ------------------
  257|    748|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  258|    815|        if (t->d_sub)
  ------------------
  |  Branch (258:13): [True: 21, False: 794]
  ------------------
  259|     21|            sub_set_play_dir(t->d_sub, mpctx->play_dir);
  260|    815|    }
  261|       |
  262|       |    // May need unpause first
  263|  25.1k|    if (mpctx->paused_for_cache)
  ------------------
  |  Branch (263:9): [True: 0, False: 25.1k]
  ------------------
  264|      0|        update_internal_pause_state(mpctx);
  265|       |
  266|  25.1k|    mpctx->hrseek_active = false;
  267|  25.1k|    mpctx->hrseek_lastframe = false;
  268|  25.1k|    mpctx->hrseek_backstep = false;
  269|  25.1k|    mpctx->current_seek = (struct seek_params){0};
  270|  25.1k|    mpctx->playback_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  25.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  271|  25.1k|    mpctx->step_frames = 0;
  272|  25.1k|    mpctx->ab_loop_clip = true;
  273|  25.1k|    mpctx->restart_complete = false;
  274|  25.1k|    mpctx->paused_for_cache = false;
  275|  25.1k|    mpctx->cache_buffer = 100;
  276|  25.1k|    mpctx->cache_update_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  25.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  277|       |
  278|  25.1k|    encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
  279|       |
  280|  25.1k|    update_internal_pause_state(mpctx);
  281|  25.1k|    update_core_idle_state(mpctx);
  282|  25.1k|}
execute_queued_seek:
  502|   250k|{
  503|   250k|    if (mpctx->seek.type) {
  ------------------
  |  Branch (503:9): [True: 0, False: 250k]
  ------------------
  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|   250k|}
get_time_length:
  531|  1.24M|{
  532|  1.24M|    struct demuxer *demuxer = mpctx->demuxer;
  533|  1.24M|    return demuxer && demuxer->duration >= 0 ? demuxer->duration : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  52.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (533:12): [True: 1.24M, False: 0]
  |  Branch (533:23): [True: 1.19M, False: 52.1k]
  ------------------
  534|  1.24M|}
get_current_time:
  551|   473k|{
  552|   473k|    if (!mpctx->demuxer)
  ------------------
  |  Branch (552:9): [True: 0, False: 473k]
  ------------------
  553|      0|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  554|   473k|    if (mpctx->playback_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   473k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (554:9): [True: 281k, False: 192k]
  ------------------
  555|   281k|        return mpctx->playback_pts * mpctx->play_dir;
  556|   192k|    return mpctx->last_seek_pts;
  557|   473k|}
get_current_pos_ratio:
  577|   121k|{
  578|   121k|    struct demuxer *demuxer = mpctx->demuxer;
  579|   121k|    if (!demuxer)
  ------------------
  |  Branch (579:9): [True: 5, False: 121k]
  ------------------
  580|      5|        return -1;
  581|   121k|    double ret = -1;
  582|   121k|    double start = 0;
  583|   121k|    double len = get_time_length(mpctx);
  584|   121k|    if (use_range) {
  ------------------
  |  Branch (584:9): [True: 0, False: 121k]
  ------------------
  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|   121k|    double pos = get_current_time(mpctx);
  595|   121k|    if (len > 0)
  ------------------
  |  Branch (595:9): [True: 106k, False: 15.1k]
  ------------------
  596|   106k|        ret = MPCLAMP((pos - start) / len, 0, 1);
  ------------------
  |  |   46|   106k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 12.4k, False: 93.8k]
  |  |  |  Branch (46:56): [True: 6.85k, False: 86.9k]
  |  |  ------------------
  ------------------
  597|   121k|    if (ret < 0) {
  ------------------
  |  Branch (597:9): [True: 15.1k, False: 106k]
  ------------------
  598|  15.1k|        int64_t size = demuxer->filesize;
  599|  15.1k|        if (size > 0 && demuxer->filepos >= 0)
  ------------------
  |  Branch (599:13): [True: 15.1k, False: 50]
  |  Branch (599:25): [True: 15.0k, False: 95]
  ------------------
  600|  15.0k|            ret = MPCLAMP(demuxer->filepos / (double)size, 0, 1);
  ------------------
  |  |   46|  15.0k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 15.0k]
  |  |  |  Branch (46:56): [True: 0, False: 15.0k]
  |  |  ------------------
  ------------------
  601|  15.1k|    }
  602|   121k|    if (use_range) {
  ------------------
  |  Branch (602:9): [True: 0, False: 121k]
  ------------------
  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|   121k|    return ret;
  608|   121k|}
get_current_chapter:
  612|   228k|{
  613|   228k|    if (!mpctx->num_chapters)
  ------------------
  |  Branch (613:9): [True: 220k, False: 8.23k]
  ------------------
  614|   220k|        return -2;
  615|  8.23k|    double current_pts = get_current_time(mpctx);
  616|  8.23k|    int i;
  617|  16.9k|    for (i = 0; i < mpctx->num_chapters; i++)
  ------------------
  |  Branch (617:17): [True: 15.1k, False: 1.89k]
  ------------------
  618|  15.1k|        if (current_pts < mpctx->chapters[i].pts)
  ------------------
  |  Branch (618:13): [True: 6.33k, False: 8.76k]
  ------------------
  619|  6.33k|            break;
  620|  8.23k|    return mpctx->last_chapter_flag ?
  ------------------
  |  Branch (620:12): [True: 0, False: 8.23k]
  ------------------
  621|  8.23k|        mpctx->last_chapter_seek : MPMAX(mpctx->last_chapter_seek, i - 1);
  ------------------
  |  |   44|  8.23k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 8.23k]
  |  |  ------------------
  ------------------
  622|   228k|}
update_ab_loop_clip:
  670|  21.9k|{
  671|  21.9k|    double pts = get_current_time(mpctx);
  672|  21.9k|    double ab[2];
  673|  21.9k|    mpctx->ab_loop_clip = pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  43.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (673:27): [True: 21.9k, False: 0]
  ------------------
  674|  21.9k|                          get_ab_loop_times(mpctx, ab) &&
  ------------------
  |  Branch (674:27): [True: 0, False: 21.9k]
  ------------------
  675|      0|                          pts * mpctx->play_dir <= ab[1] * mpctx->play_dir;
  ------------------
  |  Branch (675:27): [True: 0, False: 0]
  ------------------
  676|  21.9k|}
handle_force_window:
 1032|   309k|{
 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|   309k|    bool act = mpctx->stop_play || mpctx->playback_initialized || force;
  ------------------
  |  Branch (1035:16): [True: 49.8k, False: 259k]
  |  Branch (1035:36): [True: 228k, False: 30.5k]
  |  Branch (1035:67): [True: 5.79k, False: 24.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|   309k|    bool stalled_video = mpctx->playback_initialized && mpctx->restart_complete &&
  ------------------
  |  Branch (1039:26): [True: 228k, False: 80.3k]
  |  Branch (1039:57): [True: 152k, False: 76.0k]
  ------------------
 1040|   152k|                         mpctx->video_status == STATUS_EOF && mpctx->vo_chain &&
  ------------------
  |  Branch (1040:26): [True: 17.3k, False: 135k]
  |  Branch (1040:63): [True: 8.64k, False: 8.72k]
  ------------------
 1041|  8.64k|                         !mpctx->video_out->config_ok;
  ------------------
  |  Branch (1041:26): [True: 6.24k, False: 2.39k]
  ------------------
 1042|       |
 1043|       |    // Don't interfere with real video playback
 1044|   309k|    if (mpctx->vo_chain && !stalled_video)
  ------------------
  |  Branch (1044:9): [True: 193k, False: 115k]
  |  Branch (1044:28): [True: 187k, False: 6.24k]
  ------------------
 1045|   187k|        return 0;
 1046|       |
 1047|   121k|    if (!mpctx->opts->force_vo) {
  ------------------
  |  Branch (1047:9): [True: 121k, False: 0]
  ------------------
 1048|   121k|        if (act && !mpctx->vo_chain)
  ------------------
  |  Branch (1048:13): [True: 97.0k, False: 24.7k]
  |  Branch (1048:20): [True: 90.7k, False: 6.24k]
  ------------------
 1049|  90.7k|            uninit_video_out(mpctx);
 1050|   121k|        return 0;
 1051|   121k|    }
 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|   250k|{
 1330|   250k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) {
  ------------------
  |  Branch (1330:9): [True: 0, False: 250k]
  ------------------
 1331|      0|        mpctx->stop_play = PT_ERROR;
 1332|      0|        return;
 1333|      0|    }
 1334|       |
 1335|   250k|    update_demuxer_properties(mpctx);
 1336|       |
 1337|   250k|    update_vo_chain_el_pair(mpctx);
 1338|       |
 1339|   250k|    handle_cursor_autohide(mpctx);
 1340|   250k|    handle_vo_events(mpctx);
 1341|   250k|    handle_command_updates(mpctx);
 1342|       |
 1343|   250k|    if (mpctx->lavfi && mp_filter_has_failed(mpctx->lavfi))
  ------------------
  |  Branch (1343:9): [True: 0, False: 250k]
  |  Branch (1343:25): [True: 0, False: 0]
  ------------------
 1344|      0|        mpctx->stop_play = AT_END_OF_FILE;
 1345|       |
 1346|   250k|    fill_audio_out_buffers(mpctx);
 1347|   250k|    write_video(mpctx);
 1348|       |
 1349|   250k|    handle_lazy_streams(mpctx);
 1350|       |
 1351|   250k|    handle_playback_restart(mpctx);
 1352|       |
 1353|   250k|    handle_playback_time(mpctx);
 1354|       |
 1355|   250k|    handle_dummy_ticks(mpctx);
 1356|       |
 1357|   250k|    handle_clipboard_updates(mpctx);
 1358|       |
 1359|   250k|    update_osd_msg(mpctx);
 1360|       |
 1361|   250k|    handle_update_subtitles(mpctx);
 1362|       |
 1363|   250k|    disc_nav_update(mpctx);
 1364|       |
 1365|   250k|    handle_each_frame_screenshot(mpctx);
 1366|       |
 1367|   250k|    handle_eof(mpctx);
 1368|       |
 1369|   250k|    handle_loop_file(mpctx);
 1370|       |
 1371|   250k|    handle_keep_open(mpctx);
 1372|       |
 1373|   250k|    handle_sstep(mpctx);
 1374|       |
 1375|   250k|    update_core_idle_state(mpctx);
 1376|       |
 1377|   250k|    execute_queued_seek(mpctx);
 1378|       |
 1379|   250k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1379:9): [True: 21.7k, False: 228k]
  ------------------
 1380|  21.7k|        return;
 1381|       |
 1382|   228k|    handle_osd_redraw(mpctx);
 1383|       |
 1384|   228k|    if (mp_filter_graph_run(mpctx->filter_root))
  ------------------
  |  Branch (1384:9): [True: 2.23k, False: 226k]
  ------------------
 1385|  2.23k|        mp_wakeup_core(mpctx);
 1386|       |
 1387|   228k|    mp_wait_events(mpctx);
 1388|       |
 1389|   228k|    handle_update_cache(mpctx);
 1390|       |
 1391|   228k|    mp_process_input(mpctx);
 1392|       |
 1393|   228k|    handle_option_callbacks(mpctx);
 1394|       |
 1395|   228k|    handle_chapter_change(mpctx);
 1396|       |
 1397|       |    handle_force_window(mpctx, false);
 1398|   228k|}
mp_idle:
 1401|   275k|{
 1402|   275k|    handle_dummy_ticks(mpctx);
 1403|   275k|    handle_clipboard_updates(mpctx);
 1404|   275k|    mp_wait_events(mpctx);
 1405|   275k|    mp_process_input(mpctx);
 1406|   275k|    handle_option_callbacks(mpctx);
 1407|   275k|    handle_command_updates(mpctx);
 1408|   275k|    handle_update_cache(mpctx);
 1409|   275k|    handle_cursor_autohide(mpctx);
 1410|   275k|    handle_vo_events(mpctx);
 1411|   275k|    update_osd_msg(mpctx);
 1412|   275k|    handle_osd_redraw(mpctx);
 1413|   275k|}
idle_loop:
 1417|  49.3k|{
 1418|       |    // ================= idle loop (STOP state) =========================
 1419|  49.3k|    bool need_reinit = true;
 1420|   172k|    while (mpctx->opts->player_idle_mode && mpctx->stop_play == PT_STOP) {
  ------------------
  |  Branch (1420:12): [True: 172k, False: 0]
  |  Branch (1420:45): [True: 122k, False: 49.3k]
  ------------------
 1421|   122k|        if (need_reinit) {
  ------------------
  |  Branch (1421:13): [True: 49.3k, False: 73.4k]
  ------------------
 1422|  49.3k|            uninit_audio_out(mpctx);
 1423|  49.3k|            handle_force_window(mpctx, true);
 1424|  49.3k|            mp_wakeup_core(mpctx);
 1425|  49.3k|            mp_notify(mpctx, MPV_EVENT_IDLE, NULL);
 1426|  49.3k|            demux_packet_pool_clear(demux_packet_pool_get(mpctx->global));
 1427|       |            need_reinit = false;
 1428|  49.3k|        }
 1429|   122k|        mp_idle(mpctx);
 1430|   122k|    }
 1431|  49.3k|}
playloop.c:handle_cursor_autohide:
  850|   525k|{
  851|   525k|    struct MPOpts *opts = mpctx->opts;
  852|   525k|    struct vo *vo = mpctx->video_out;
  853|       |
  854|   525k|    if (!vo)
  ------------------
  |  Branch (854:9): [True: 277k, False: 248k]
  ------------------
  855|   277k|        return;
  856|       |
  857|   525k|    bool mouse_cursor_visible = mpctx->mouse_cursor_visible;
  858|   248k|    double now = mp_time_sec();
  859|       |
  860|   248k|    unsigned mouse_event_ts = mp_input_get_mouse_event_counter(mpctx->input);
  861|   248k|    if (mpctx->mouse_event_ts != mouse_event_ts) {
  ------------------
  |  Branch (861:9): [True: 0, False: 248k]
  ------------------
  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|   248k|    if (mpctx->mouse_timer > now) {
  ------------------
  |  Branch (867:9): [True: 0, False: 248k]
  ------------------
  868|      0|        mp_set_timeout(mpctx, mpctx->mouse_timer - now);
  869|   248k|    } else {
  870|   248k|        mouse_cursor_visible = false;
  871|   248k|    }
  872|       |
  873|   248k|    if (opts->cursor_autohide_delay == -1)
  ------------------
  |  Branch (873:9): [True: 0, False: 248k]
  ------------------
  874|      0|        mouse_cursor_visible = true;
  875|       |
  876|   248k|    if (opts->cursor_autohide_delay == -2)
  ------------------
  |  Branch (876:9): [True: 0, False: 248k]
  ------------------
  877|      0|        mouse_cursor_visible = false;
  878|       |
  879|   248k|    if (opts->cursor_autohide_fs && !opts->vo->fullscreen)
  ------------------
  |  Branch (879:9): [True: 0, False: 248k]
  |  Branch (879:37): [True: 0, False: 0]
  ------------------
  880|      0|        mouse_cursor_visible = true;
  881|       |
  882|   248k|    if (mouse_cursor_visible != mpctx->mouse_cursor_visible)
  ------------------
  |  Branch (882:9): [True: 18.3k, False: 229k]
  ------------------
  883|  18.3k|        vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &mouse_cursor_visible);
  884|   248k|    mpctx->mouse_cursor_visible = mouse_cursor_visible;
  885|   248k|}
playloop.c:handle_vo_events:
  888|   525k|{
  889|   525k|    struct vo *vo = mpctx->video_out;
  890|   525k|    int events = vo ? vo_query_and_reset_events(vo, VO_EVENTS_USER) : 0;
  ------------------
  |  Branch (890:18): [True: 248k, False: 277k]
  ------------------
  891|   525k|    if (events & VO_EVENT_RESIZE)
  ------------------
  |  Branch (891:9): [True: 0, False: 525k]
  ------------------
  892|      0|        mp_notify(mpctx, MP_EVENT_WIN_RESIZE, NULL);
  893|   525k|    if (events & VO_EVENT_WIN_STATE)
  ------------------
  |  Branch (893:9): [True: 18.3k, False: 507k]
  ------------------
  894|  18.3k|        mp_notify(mpctx, MP_EVENT_WIN_STATE, NULL);
  895|   525k|    if (events & VO_EVENT_DPI)
  ------------------
  |  Branch (895:9): [True: 0, False: 525k]
  ------------------
  896|      0|        mp_notify(mpctx, MP_EVENT_WIN_STATE2, NULL);
  897|   525k|    if (events & VO_EVENT_FOCUS)
  ------------------
  |  Branch (897:9): [True: 0, False: 525k]
  ------------------
  898|      0|        mp_notify(mpctx, MP_EVENT_FOCUS, NULL);
  899|   525k|    if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED)
  ------------------
  |  Branch (899:9): [True: 0, False: 525k]
  ------------------
  900|      0|        mp_notify(mpctx, MP_EVENT_AMBIENT_LIGHTING_CHANGED, NULL);
  901|   525k|    if (events & VO_EVENT_PRESENTATION_DELAY)
  ------------------
  |  Branch (901:9): [True: 0, False: 525k]
  ------------------
  902|      0|        mp_notify(mpctx, MP_EVENT_PRESENTATION_DELAY, NULL);
  903|   525k|}
playloop.c:handle_lazy_streams:
 1242|   250k|{
 1243|   250k|    struct track *track = mpctx->vo_chain ? mpctx->vo_chain->track : NULL;
  ------------------
  |  Branch (1243:27): [True: 211k, False: 38.6k]
  ------------------
 1244|   250k|    if (track) {
  ------------------
  |  Branch (1244:9): [True: 211k, False: 38.6k]
  ------------------
 1245|   211k|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1246|   211k|        if (!track->dec) {
  ------------------
  |  Branch (1246:13): [True: 0, False: 211k]
  ------------------
 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|   211k|        } else if (mpctx->video_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1257:20): [True: 31.8k, False: 180k]
  |  Branch (1257:57): [True: 0, False: 31.8k]
  ------------------
 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|   211k|    }
 1262|       |
 1263|   250k|    track = mpctx->ao_chain ? mpctx->ao_chain->track : NULL;
  ------------------
  |  Branch (1263:13): [True: 136k, False: 113k]
  ------------------
 1264|   250k|    if (track) {
  ------------------
  |  Branch (1264:9): [True: 136k, False: 113k]
  ------------------
 1265|   136k|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1266|   136k|        if (!track->dec) {
  ------------------
  |  Branch (1266:13): [True: 0, False: 136k]
  ------------------
 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|   136k|        } else if (mpctx->audio_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1274:20): [True: 44.0k, False: 92.9k]
  |  Branch (1274:57): [True: 0, False: 44.0k]
  ------------------
 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|   136k|    }
 1279|   250k|}
playloop.c:handle_playback_restart:
 1160|   250k|{
 1161|   250k|    struct MPOpts *opts = mpctx->opts;
 1162|       |
 1163|   250k|    if (mpctx->audio_status < STATUS_READY ||
  ------------------
  |  Branch (1163:9): [True: 54.6k, False: 196k]
  ------------------
 1164|   196k|        mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (1164:9): [True: 21.4k, False: 174k]
  ------------------
 1165|  76.0k|        return;
 1166|       |
 1167|   174k|    handle_update_cache(mpctx);
 1168|       |
 1169|   174k|    if (mpctx->video_status == STATUS_READY) {
  ------------------
  |  Branch (1169:9): [True: 10.5k, False: 164k]
  ------------------
 1170|  10.5k|        mpctx->video_status = STATUS_PLAYING;
 1171|  10.5k|        get_relative_time(mpctx);
 1172|  10.5k|        mp_wakeup_core(mpctx);
 1173|  10.5k|        MP_DBG(mpctx, "starting video playback\n");
  ------------------
  |  |   93|  10.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1174|  10.5k|    }
 1175|       |
 1176|   174k|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (1176:9): [True: 12.2k, False: 162k]
  ------------------
 1177|       |        // If a new seek is queued while the current one finishes, don't
 1178|       |        // actually play the audio, but resume seeking immediately.
 1179|  12.2k|        if (mpctx->seek.type && mpctx->video_status == STATUS_PLAYING) {
  ------------------
  |  Branch (1179:13): [True: 0, False: 12.2k]
  |  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|  12.2k|        audio_start_ao(mpctx);
 1187|  12.2k|    }
 1188|       |
 1189|   174k|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (1189:9): [True: 21.9k, False: 152k]
  ------------------
 1190|  21.9k|        mpctx->hrseek_active = false;
 1191|  21.9k|        mpctx->restart_complete = true;
 1192|  21.9k|        mpctx->current_seek = (struct seek_params){0};
 1193|  21.9k|        handle_playback_time(mpctx);
 1194|  21.9k|        mp_notify(mpctx, MPV_EVENT_PLAYBACK_RESTART, NULL);
 1195|  21.9k|        update_core_idle_state(mpctx);
 1196|  21.9k|        if (!mpctx->playing_msg_shown) {
  ------------------
  |  Branch (1196:13): [True: 21.7k, False: 155]
  ------------------
 1197|  21.7k|            if (opts->playing_msg && opts->playing_msg[0]) {
  ------------------
  |  Branch (1197:17): [True: 0, False: 21.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|  21.7k|            if (opts->osd_playing_msg && opts->osd_playing_msg[0]) {
  ------------------
  |  Branch (1205:17): [True: 0, False: 21.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|  21.7k|        }
 1214|  21.9k|        mpctx->playing_msg_shown = true;
 1215|  21.9k|        mp_wakeup_core(mpctx);
 1216|  21.9k|        update_ab_loop_clip(mpctx);
 1217|  21.9k|        MP_VERBOSE(mpctx, "playback restart complete @ %f, audio=%s, video=%s%s\n",
  ------------------
  |  |   92|  21.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  43.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 21.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|  21.9k|                   mpctx->playback_pts, mp_status_str(mpctx->audio_status),
 1219|  21.9k|                   mp_status_str(mpctx->video_status),
 1220|  21.9k|                   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|  21.9k|        double length = get_time_length(mpctx);
 1225|  21.9k|        if (mpctx->last_seek_pts != MP_NOPTS_VALUE && length >= 0)
  ------------------
  |  |   39|  43.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1225:13): [True: 21.9k, False: 0]
  |  Branch (1225:55): [True: 20.7k, False: 1.19k]
  ------------------
 1226|  20.7k|            mpctx->last_seek_pts = MPCLAMP(mpctx->last_seek_pts, 0, length);
  ------------------
  |  |   46|  20.7k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 20.7k]
  |  |  |  Branch (46:56): [True: 0, False: 20.7k]
  |  |  ------------------
  ------------------
 1227|       |
 1228|       |        // Continuous seeks past EOF => treat as EOF instead of repeating seek.
 1229|  21.9k|        if (mpctx->seek.type == MPSEEK_RELATIVE && mpctx->seek.amount > 0 &&
  ------------------
  |  Branch (1229:13): [True: 0, False: 21.9k]
  |  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|  21.9k|    }
 1234|   174k|}
playloop.c:handle_playback_time:
 1135|   272k|{
 1136|   272k|    if (mpctx->vo_chain &&
  ------------------
  |  Branch (1136:9): [True: 230k, False: 42.1k]
  ------------------
 1137|   230k|        !mpctx->vo_chain->is_sparse &&
  ------------------
  |  Branch (1137:9): [True: 229k, False: 736]
  ------------------
 1138|   229k|        mpctx->video_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1138:9): [True: 185k, False: 44.6k]
  ------------------
 1139|   185k|        mpctx->video_status < STATUS_EOF)
  ------------------
  |  Branch (1139:9): [True: 145k, False: 39.2k]
  ------------------
 1140|   145k|    {
 1141|   145k|        mpctx->playback_pts = mpctx->video_pts;
 1142|   145k|    } else if (mpctx->audio_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1142:16): [True: 72.1k, False: 54.6k]
  ------------------
 1143|  72.1k|               mpctx->audio_status < STATUS_EOF)
  ------------------
  |  Branch (1143:16): [True: 23.8k, False: 48.2k]
  ------------------
 1144|  23.8k|    {
 1145|  23.8k|        mpctx->playback_pts = playing_audio_pts(mpctx);
 1146|   102k|    } else if (mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1146:16): [True: 58.0k, False: 44.7k]
  ------------------
 1147|  58.0k|               mpctx->audio_status == STATUS_EOF)
  ------------------
  |  Branch (1147:16): [True: 26.6k, False: 31.4k]
  ------------------
 1148|  26.6k|    {
 1149|  26.6k|        double apts = playing_audio_pts(mpctx);
 1150|  26.6k|        double vpts = mpctx->video_pts;
 1151|  26.6k|        double mpts = MP_PTS_MAX(apts, vpts);
  ------------------
  |  |   65|  26.6k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  53.2k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 1.11k, False: 25.5k]
  |  |  |  |  |  Branch (44:23): [True: 20.3k, False: 6.28k]
  |  |  |  |  |  Branch (44:29): [True: 16.0k, False: 10.5k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 1.11k]
  |  |  |  |  |  Branch (44:41): [True: 16.0k, False: 9.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|  26.6k|        if (mpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  26.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1152:13): [True: 15.0k, False: 11.6k]
  ------------------
 1153|  15.0k|            mpctx->playback_pts = mpts;
 1154|  26.6k|    }
 1155|   272k|}
playloop.c:handle_dummy_ticks:
 1121|   525k|{
 1122|   525k|    if ((mpctx->video_status != STATUS_PLAYING &&
  ------------------
  |  Branch (1122:10): [True: 391k, False: 134k]
  ------------------
 1123|   391k|         mpctx->video_status != STATUS_DRAINING) ||
  ------------------
  |  Branch (1123:10): [True: 390k, False: 1.31k]
  ------------------
 1124|   135k|         mpctx->paused)
  ------------------
  |  Branch (1124:10): [True: 866, False: 134k]
  ------------------
 1125|   391k|    {
 1126|   391k|        if (mp_time_sec() - mpctx->last_idle_tick > 0.050) {
  ------------------
  |  Branch (1126:13): [True: 26.0k, False: 365k]
  ------------------
 1127|  26.0k|            mpctx->last_idle_tick = mp_time_sec();
 1128|       |            mp_notify(mpctx, MPV_EVENT_TICK, NULL);
 1129|  26.0k|        }
 1130|   391k|    }
 1131|   525k|}
playloop.c:handle_clipboard_updates:
 1323|   525k|{
 1324|   525k|    if (mp_clipboard_data_changed(mpctx->clipboard))
  ------------------
  |  Branch (1324:9): [True: 0, False: 525k]
  ------------------
 1325|      0|        mp_notify_property(mpctx, "clipboard");
 1326|   525k|}
playloop.c:handle_update_subtitles:
  834|   250k|{
  835|   250k|    if (mpctx->video_status == STATUS_EOF) {
  ------------------
  |  Branch (835:9): [True: 70.5k, False: 180k]
  ------------------
  836|  70.5k|        update_subtitles(mpctx, mpctx->playback_pts);
  837|  70.5k|        return;
  838|  70.5k|    }
  839|       |
  840|   492k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (840:21): [True: 327k, False: 165k]
  ------------------
  841|   327k|        struct track *track = mpctx->tracks[n];
  842|   327k|        if (track->type == STREAM_SUB && !track->demuxer_ready) {
  ------------------
  |  Branch (842:13): [True: 15.8k, False: 311k]
  |  Branch (842:42): [True: 14.9k, False: 919]
  ------------------
  843|  14.9k|            update_subtitles(mpctx, mpctx->playback_pts);
  844|  14.9k|            break;
  845|  14.9k|        }
  846|   327k|    }
  847|   180k|}
playloop.c:handle_eof:
 1282|   250k|{
 1283|   250k|    if (mpctx->seek.type)
  ------------------
  |  Branch (1283:9): [True: 0, False: 250k]
  ------------------
 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|   250k|    bool prevent_eof =
 1290|   250k|        mpctx->paused && mpctx->video_out && vo_has_frame(mpctx->video_out) &&
  ------------------
  |  Branch (1290:9): [True: 866, False: 249k]
  |  Branch (1290:26): [True: 866, False: 0]
  |  Branch (1290:46): [True: 866, False: 0]
  ------------------
 1291|    866|        !mpctx->vo_chain->is_coverart;
  ------------------
  |  Branch (1291:9): [True: 866, 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|   250k|    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|   250k|    if ((mpctx->ao_chain || mpctx->vo_chain) && !prevent_eof &&
  ------------------
  |  Branch (1300:10): [True: 136k, False: 113k]
  |  Branch (1300:29): [True: 113k, False: 1]
  |  Branch (1300:49): [True: 249k, False: 866]
  ------------------
 1301|   249k|        mpctx->audio_status == STATUS_EOF &&
  ------------------
  |  Branch (1301:9): [True: 156k, False: 92.9k]
  ------------------
 1302|   156k|        mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1302:9): [True: 21.7k, False: 135k]
  ------------------
 1303|  21.7k|        !mpctx->stop_play)
  ------------------
  |  Branch (1303:9): [True: 21.7k, False: 0]
  ------------------
 1304|  21.7k|    {
 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|  21.7k|        bool waiting = (mpctx->vo_chain && mpctx->vo_chain->track &&
  ------------------
  |  Branch (1308:25): [True: 18.2k, False: 3.46k]
  |  Branch (1308:44): [True: 18.2k, False: 0]
  ------------------
 1309|  18.2k|                        !mpctx->vo_chain->track->dec) ||
  ------------------
  |  Branch (1309:25): [True: 0, False: 18.2k]
  ------------------
 1310|  21.7k|                       (mpctx->ao_chain && mpctx->ao_chain->track &&
  ------------------
  |  Branch (1310:25): [True: 13.6k, False: 8.05k]
  |  Branch (1310:44): [True: 13.6k, False: 0]
  ------------------
 1311|  13.6k|                        !mpctx->ao_chain->track->dec);
  ------------------
  |  Branch (1311:25): [True: 0, False: 13.6k]
  ------------------
 1312|  21.7k|        if (waiting) {
  ------------------
  |  Branch (1312:13): [True: 0, False: 21.7k]
  ------------------
 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|  21.7k|        mpctx->stop_play = AT_END_OF_FILE;
 1319|  21.7k|    }
 1320|   250k|}
playloop.c:handle_loop_file:
  925|   250k|{
  926|   250k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (926:9): [True: 228k, False: 21.7k]
  ------------------
  927|   228k|        return;
  928|       |
  929|  21.7k|    double target = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  21.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  930|  21.7k|    enum seek_precision prec = MPSEEK_DEFAULT;
  931|       |
  932|  21.7k|    double ab[2];
  933|  21.7k|    if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) {
  ------------------
  |  Branch (933:9): [True: 0, False: 21.7k]
  |  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|  21.7k|    } else if (mpctx->remaining_file_loops) {
  ------------------
  |  Branch (940:16): [True: 0, False: 21.7k]
  ------------------
  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|  21.7k|    if (target != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  21.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (948:9): [True: 0, False: 21.7k]
  ------------------
  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|  21.7k|}
playloop.c:handle_keep_open:
  994|   250k|{
  995|   250k|    struct MPOpts *opts = mpctx->opts;
  996|   250k|    if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE &&
  ------------------
  |  Branch (996:9): [True: 0, False: 250k]
  |  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|   250k|}
playloop.c:handle_sstep:
  906|   250k|{
  907|   250k|    struct MPOpts *opts = mpctx->opts;
  908|   250k|    if (mpctx->stop_play || !mpctx->restart_complete)
  ------------------
  |  Branch (908:9): [True: 21.7k, False: 228k]
  |  Branch (908:29): [True: 76.0k, False: 152k]
  ------------------
  909|  97.7k|        return;
  910|       |
  911|   152k|    if (opts->step_sec > 0 && !mpctx->paused) {
  ------------------
  |  Branch (911:9): [True: 0, False: 152k]
  |  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|   152k|    if (mpctx->video_status >= STATUS_EOF) {
  ------------------
  |  Branch (916:9): [True: 17.3k, False: 135k]
  ------------------
  917|  17.3k|        if (mpctx->max_frames >= 0 && !mpctx->stop_play)
  ------------------
  |  Branch (917:13): [True: 0, False: 17.3k]
  |  Branch (917:39): [True: 0, False: 0]
  ------------------
  918|      0|            mpctx->stop_play = AT_END_OF_FILE; // force EOF even if audio left
  919|  17.3k|        if (mpctx->step_frames > 0 && !mpctx->paused)
  ------------------
  |  Branch (919:13): [True: 0, False: 17.3k]
  |  Branch (919:39): [True: 0, False: 0]
  ------------------
  920|      0|            set_pause_state(mpctx, true);
  921|  17.3k|    }
  922|   152k|}
playloop.c:handle_osd_redraw:
  679|   504k|{
  680|   504k|    if (!mpctx->video_out || !mpctx->video_out->config_ok || (mpctx->playing && mpctx->stop_play))
  ------------------
  |  Branch (680:9): [True: 274k, False: 230k]
  |  Branch (680:30): [True: 66.2k, False: 163k]
  |  Branch (680:63): [True: 163k, False: 0]
  |  Branch (680:81): [True: 21.0k, False: 142k]
  ------------------
  681|   361k|        return;
  682|       |    // If we're playing normally, let OSD be redrawn naturally as part of
  683|       |    // video display.
  684|   142k|    if (!mpctx->paused) {
  ------------------
  |  Branch (684:9): [True: 141k, False: 866]
  ------------------
  685|   141k|        if (mpctx->sleeptime < 0.1 && mpctx->video_status == STATUS_PLAYING)
  ------------------
  |  Branch (685:13): [True: 135k, False: 6.63k]
  |  Branch (685:39): [True: 126k, False: 8.60k]
  ------------------
  686|   126k|            return;
  687|   141k|    }
  688|       |    // Don't redraw immediately during a seek (makes it significantly slower).
  689|   142k|    bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (689:22): [True: 16.1k, False: 0]
  |  Branch (689:41): [True: 16.0k, False: 40]
  ------------------
  690|  16.1k|    if (use_video && mp_time_sec() - mpctx->start_timestamp < 0.1) {
  ------------------
  |  Branch (690:9): [True: 16.0k, False: 40]
  |  Branch (690:22): [True: 0, False: 16.0k]
  ------------------
  691|      0|        mp_set_timeout(mpctx, 0.1);
  692|      0|        return;
  693|      0|    }
  694|  16.1k|    bool want_redraw = osd_query_and_reset_want_redraw(mpctx->osd) ||
  ------------------
  |  Branch (694:24): [True: 3.26k, False: 12.8k]
  ------------------
  695|  12.8k|                       vo_want_redraw(mpctx->video_out);
  ------------------
  |  Branch (695:24): [True: 0, False: 12.8k]
  ------------------
  696|  16.1k|    if (!want_redraw)
  ------------------
  |  Branch (696:9): [True: 12.8k, False: 3.26k]
  ------------------
  697|  12.8k|        return;
  698|  3.26k|    vo_redraw(mpctx->video_out);
  699|  3.26k|}
playloop.c:handle_update_cache:
  715|   678k|{
  716|   678k|    bool force_update = false;
  717|   678k|    struct MPOpts *opts = mpctx->opts;
  718|       |
  719|   678k|    if (!mpctx->demuxer || mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (719:9): [True: 250k, False: 427k]
  |  Branch (719:28): [True: 0, False: 427k]
  ------------------
  720|   250k|        clear_underruns(mpctx);
  721|   250k|        return;
  722|   250k|    }
  723|       |
  724|   427k|    double now = mp_time_sec();
  725|       |
  726|   427k|    struct demux_reader_state s;
  727|   427k|    demux_get_reader_state(mpctx->demuxer, &s);
  728|       |
  729|   427k|    mpctx->demux_underrun |= s.underrun;
  730|       |
  731|   427k|    int cache_buffer = 100;
  732|   427k|    bool use_pause_on_low_cache = opts->cache_pause && mpctx->play_dir > 0;
  ------------------
  |  Branch (732:35): [True: 427k, False: 0]
  |  Branch (732:56): [True: 427k, False: 0]
  ------------------
  733|       |
  734|   427k|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (734:9): [True: 122k, False: 305k]
  ------------------
  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|   122k|        use_pause_on_low_cache &= opts->cache_pause_initial &&
  ------------------
  |  Branch (738:35): [True: 0, False: 122k]
  ------------------
  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|   122k|    }
  742|       |
  743|   427k|    bool is_low = use_pause_on_low_cache && !s.idle &&
  ------------------
  |  Branch (743:19): [True: 305k, False: 122k]
  |  Branch (743:45): [True: 15.3k, False: 290k]
  ------------------
  744|  15.3k|                  s.ts_info.duration < opts->cache_pause_wait;
  ------------------
  |  Branch (744:19): [True: 15.0k, False: 278]
  ------------------
  745|       |
  746|       |    // Enter buffering state only if there actually was an underrun (or if
  747|       |    // initial caching before playback restart is used).
  748|   427k|    bool need_wait = is_low;
  749|   427k|    if (is_low && !mpctx->paused_for_cache && mpctx->restart_complete) {
  ------------------
  |  Branch (749:9): [True: 15.0k, False: 412k]
  |  Branch (749:19): [True: 14.4k, False: 632]
  |  Branch (749:47): [True: 14.4k, False: 0]
  ------------------
  750|       |        // Wait only if an output underrun was registered. (Or if there is no
  751|       |        // underrun detection.)
  752|  14.4k|        bool output_underrun = false;
  753|       |
  754|  14.4k|        if (mpctx->ao_chain)
  ------------------
  |  Branch (754:13): [True: 1.33k, False: 13.1k]
  ------------------
  755|  1.33k|            output_underrun |= mpctx->ao_chain->underrun;
  756|  14.4k|        if (mpctx->vo_chain)
  ------------------
  |  Branch (756:13): [True: 13.2k, False: 1.21k]
  ------------------
  757|  13.2k|            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|  14.4k|        need_wait = mpctx->demux_underrun && output_underrun;
  ------------------
  |  Branch (763:21): [True: 13.5k, False: 929]
  |  Branch (763:46): [True: 579, False: 12.9k]
  ------------------
  764|  14.4k|    }
  765|       |
  766|       |    // Let the underrun flag "stick" around until the cache has fully recovered.
  767|       |    // See logic where demux_underrun is used.
  768|   427k|    if (!is_low)
  ------------------
  |  Branch (768:9): [True: 412k, False: 15.0k]
  ------------------
  769|   412k|        mpctx->demux_underrun = false;
  770|       |
  771|   427k|    if (mpctx->paused_for_cache != need_wait) {
  ------------------
  |  Branch (771:9): [True: 1.15k, False: 426k]
  ------------------
  772|  1.15k|        mpctx->paused_for_cache = need_wait;
  773|  1.15k|        update_internal_pause_state(mpctx);
  774|  1.15k|        force_update = true;
  775|  1.15k|        if (mpctx->paused_for_cache)
  ------------------
  |  Branch (775:13): [True: 579, False: 579]
  ------------------
  776|    579|            mpctx->cache_stop_time = now;
  777|  1.15k|    }
  778|       |
  779|   427k|    if (!mpctx->paused_for_cache)
  ------------------
  |  Branch (779:9): [True: 426k, False: 1.21k]
  ------------------
  780|   426k|        clear_underruns(mpctx);
  781|       |
  782|   427k|    if (mpctx->paused_for_cache) {
  ------------------
  |  Branch (782:9): [True: 1.21k, False: 426k]
  ------------------
  783|  1.21k|        cache_buffer =
  784|  1.21k|            100 * MPCLAMP(s.ts_info.duration / opts->cache_pause_wait, 0, 0.99);
  ------------------
  |  |   46|  1.21k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 52, False: 1.15k]
  |  |  |  Branch (46:56): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
  785|  1.21k|        mp_set_timeout(mpctx, 0.2);
  786|  1.21k|    }
  787|       |
  788|       |    // Also update cache properties.
  789|   427k|    bool busy = !s.idle;
  790|   427k|    if (fabs(mpctx->cache_update_pts - mpctx->playback_pts) >= 1.0)
  ------------------
  |  Branch (790:9): [True: 267k, False: 160k]
  ------------------
  791|   267k|        busy = true;
  792|   427k|    if (busy || mpctx->next_cache_update > 0) {
  ------------------
  |  Branch (792:9): [True: 312k, False: 115k]
  |  Branch (792:17): [True: 86.5k, False: 28.4k]
  ------------------
  793|   399k|        if (mpctx->next_cache_update <= now) {
  ------------------
  |  Branch (793:13): [True: 21.2k, False: 377k]
  ------------------
  794|  21.2k|            mpctx->next_cache_update = busy ? now + 0.25 : 0;
  ------------------
  |  Branch (794:40): [True: 21.2k, False: 43]
  ------------------
  795|  21.2k|            force_update = true;
  796|  21.2k|        }
  797|   399k|        if (mpctx->next_cache_update > 0)
  ------------------
  |  Branch (797:13): [True: 399k, False: 43]
  ------------------
  798|   399k|            mp_set_timeout(mpctx, mpctx->next_cache_update - now);
  799|   399k|    }
  800|       |
  801|   427k|    if (mpctx->cache_buffer != cache_buffer) {
  ------------------
  |  Branch (801:9): [True: 1.19k, False: 426k]
  ------------------
  802|  1.19k|        if ((mpctx->cache_buffer == 100) != (cache_buffer == 100)) {
  ------------------
  |  Branch (802:13): [True: 1.15k, False: 40]
  ------------------
  803|  1.15k|            if (cache_buffer < 100) {
  ------------------
  |  Branch (803:17): [True: 579, False: 579]
  ------------------
  804|    579|                MP_VERBOSE(mpctx, "Enter buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|    579|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    579|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  805|    579|                           mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  806|    579|            } else {
  807|    579|                double t = now - mpctx->cache_stop_time;
  808|    579|                MP_VERBOSE(mpctx, "End buffering (waited %f secs) [%fs].\n",
  ------------------
  |  |   92|    579|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    579|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  809|    579|                           t, s.ts_info.duration);
  810|    579|            }
  811|  1.15k|        } else {
  812|     40|            MP_VERBOSE(mpctx, "Still buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|     40|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     40|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  813|     40|                       mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  814|     40|        }
  815|  1.19k|        mpctx->cache_buffer = cache_buffer;
  816|  1.19k|        force_update = true;
  817|  1.19k|    }
  818|       |
  819|   427k|    if (s.eof && !busy)
  ------------------
  |  Branch (819:9): [True: 290k, False: 136k]
  |  Branch (819:18): [True: 55.9k, False: 235k]
  ------------------
  820|  55.9k|        prefetch_next(mpctx);
  821|       |
  822|   427k|    if (force_update) {
  ------------------
  |  Branch (822:9): [True: 22.4k, False: 405k]
  ------------------
  823|  22.4k|        mpctx->cache_update_pts = mpctx->playback_pts;
  824|       |        mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
  825|  22.4k|    }
  826|   427k|}
playloop.c:clear_underruns:
  702|   677k|{
  703|   677k|    if (mpctx->ao_chain && mpctx->ao_chain->underrun) {
  ------------------
  |  Branch (703:9): [True: 205k, False: 471k]
  |  Branch (703:28): [True: 0, False: 205k]
  ------------------
  704|      0|        mpctx->ao_chain->underrun = false;
  705|      0|        mp_wakeup_core(mpctx);
  706|      0|    }
  707|       |
  708|   677k|    if (mpctx->vo_chain && mpctx->vo_chain->underrun) {
  ------------------
  |  Branch (708:9): [True: 354k, False: 322k]
  |  Branch (708:28): [True: 702, False: 354k]
  ------------------
  709|       |        mpctx->vo_chain->underrun = false;
  710|    702|        mp_wakeup_core(mpctx);
  711|    702|    }
  712|   677k|}
playloop.c:mp_process_input:
  111|   504k|{
  112|   504k|    bool notify = false;
  113|   504k|    for (;;) {
  114|   504k|        mp_cmd_t *cmd = mp_input_read_cmd(mpctx->input);
  115|   504k|        if (!cmd)
  ------------------
  |  Branch (115:13): [True: 504k, False: 0]
  ------------------
  116|   504k|            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|   504k|    mp_set_timeout(mpctx, mp_input_get_delay(mpctx->input));
  122|   504k|    if (notify)
  ------------------
  |  Branch (122:9): [True: 0, False: 504k]
  ------------------
  123|      0|        mp_notify(mpctx, MP_EVENT_INPUT_PROCESSED, NULL);
  124|   504k|}
playloop.c:handle_chapter_change:
 1017|   228k|{
 1018|   228k|    int chapter = get_current_chapter(mpctx);
 1019|   228k|    if (chapter != mpctx->last_chapter) {
  ------------------
  |  Branch (1019:9): [True: 934, False: 227k]
  ------------------
 1020|    934|        mpctx->last_chapter = chapter;
 1021|       |        mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
 1022|    934|    }
 1023|   228k|}

screenshot_init:
   64|  24.7k|{
   65|  24.7k|    mpctx->screenshot_ctx = talloc(mpctx, screenshot_ctx);
  ------------------
  |  |   26|  24.7k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  24.7k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|  24.7k|    *mpctx->screenshot_ctx = (screenshot_ctx) {
   67|  24.7k|        .mpctx = mpctx,
   68|  24.7k|        .frameno = 1,
   69|  24.7k|        .log = mp_log_new(mpctx, mpctx->log, "screenshot")
   70|  24.7k|    };
   71|  24.7k|}
handle_each_frame_screenshot:
  607|   250k|{
  608|   250k|    screenshot_ctx *ctx = mpctx->screenshot_ctx;
  609|       |
  610|   250k|    if (!ctx->each_frame)
  ------------------
  |  Branch (610:9): [True: 250k, False: 0]
  ------------------
  611|   250k|        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|  24.7k|{
  263|  24.7k|    load_builtin_script(mpctx, 0, mpctx->opts->lua_load_osc, "@osc.lua");
  264|  24.7k|    load_builtin_script(mpctx, 1, mpctx->opts->lua_load_ytdl, "@ytdl_hook.lua");
  265|  24.7k|    load_builtin_script(mpctx, 2, mpctx->opts->lua_load_stats, "@stats.lua");
  266|  24.7k|    load_builtin_script(mpctx, 3, mpctx->opts->lua_load_console, "@console.lua");
  267|  24.7k|    load_builtin_script(mpctx, 4, mpctx->opts->lua_load_auto_profiles,
  268|  24.7k|                        "@auto_profiles.lua");
  269|  24.7k|    load_builtin_script(mpctx, 5, mpctx->opts->lua_load_select, "@select.lua");
  270|  24.7k|    load_builtin_script(mpctx, 6, mpctx->opts->lua_load_positioning, "@positioning.lua");
  271|  24.7k|    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|  24.7k|    struct m_config_option *co = m_config_get_co(mpctx->mconfig, bstr0("d3d11-exclusive-fs"));
  275|  24.7k|    bool context_menu = mpctx->opts->lua_load_context_menu || (co && *(bool *)co->data);
  ------------------
  |  Branch (275:25): [True: 0, False: 24.7k]
  |  Branch (275:64): [True: 0, False: 24.7k]
  |  Branch (275:70): [True: 0, False: 0]
  ------------------
  276|  24.7k|    load_builtin_script(mpctx, 8, context_menu, "@context_menu.lua");
  277|  24.7k|}
mp_load_scripts:
  280|  24.7k|{
  281|  24.7k|    bool ok = true;
  282|       |
  283|       |    // Load scripts from options
  284|  24.7k|    char **files = mpctx->opts->script_files;
  285|  24.7k|    for (int n = 0; files && files[n]; n++) {
  ------------------
  |  Branch (285:21): [True: 0, False: 24.7k]
  |  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|  24.7k|    if (!mpctx->opts->auto_load_scripts)
  ------------------
  |  Branch (289:9): [True: 0, False: 24.7k]
  ------------------
  290|      0|        return ok;
  291|       |
  292|       |    // Load all scripts
  293|  24.7k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  24.7k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  24.7k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  294|  24.7k|    char **scriptsdir = mp_find_all_config_files(tmp, mpctx->global, "scripts");
  295|  24.7k|    for (int i = 0; scriptsdir && scriptsdir[i]; i++) {
  ------------------
  |  Branch (295:21): [True: 24.7k, False: 0]
  |  Branch (295:35): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    talloc_free(tmp);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  301|       |
  302|  24.7k|    return ok;
  303|  24.7k|}
scripting.c:load_builtin_script:
  242|   222k|{
  243|   222k|    mp_assert(slot < MP_ARRAY_SIZE(mpctx->builtin_script_ids));
  ------------------
  |  |   41|   222k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 222k, False: 0]
  ------------------
  244|   222k|    int64_t *pid = &mpctx->builtin_script_ids[slot];
  245|   222k|    if (*pid > 0 && !mp_client_id_exists(mpctx, *pid)) {
  ------------------
  |  Branch (245:9): [True: 0, False: 222k]
  |  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|   222k|    if ((*pid > 0) != enable) {
  ------------------
  |  Branch (249:9): [True: 0, False: 222k]
  ------------------
  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|   222k|}

redraw_subs:
   57|  46.5k|{
   58|   139k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (58:21): [True: 93.1k, False: 46.5k]
  ------------------
   59|  93.1k|        if (mpctx->current_track[n][STREAM_SUB] &&
  ------------------
  |  Branch (59:13): [True: 2.23k, False: 90.8k]
  ------------------
   60|  2.23k|            mpctx->current_track[n][STREAM_SUB]->d_sub)
  ------------------
  |  Branch (60:13): [True: 2.23k, False: 0]
  ------------------
   61|  2.23k|        {
   62|       |            mpctx->current_track[n][STREAM_SUB]->redraw_subs = true;
   63|  2.23k|        }
   64|  93.1k|    }
   65|  46.5k|}
reset_subtitle_state:
   68|  25.1k|{
   69|  25.9k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (69:21): [True: 815, False: 25.1k]
  ------------------
   70|    815|        reset_subtitles(mpctx, mpctx->tracks[n]);
   71|  25.1k|    term_osd_clear_subs(mpctx);
   72|  25.1k|}
uninit_sub:
   75|  42.9k|{
   76|  42.9k|    if (track && track->d_sub) {
  ------------------
  |  Branch (76:9): [True: 42.6k, False: 273]
  |  Branch (76:18): [True: 2.60k, False: 40.0k]
  ------------------
   77|  2.60k|        int order = get_order(mpctx, track);
   78|  2.60k|        reset_subtitles(mpctx, track);
   79|  2.60k|        sub_select(track->d_sub, false);
   80|  2.60k|        if (order >= 0) {
  ------------------
  |  Branch (80:13): [True: 2.60k, False: 0]
  ------------------
   81|  2.60k|            term_osd_set_subs(mpctx, NULL, order);
   82|  2.60k|            osd_set_sub(mpctx->osd, order, NULL);
   83|  2.60k|        }
   84|  2.60k|        sub_destroy(track->d_sub);
   85|       |        track->d_sub = NULL;
   86|  2.60k|    }
   87|  42.9k|}
uninit_sub_all:
   90|  24.7k|{
   91|  67.3k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (91:21): [True: 42.5k, False: 24.7k]
  ------------------
   92|  42.5k|        uninit_sub(mpctx, mpctx->tracks[n]);
   93|  24.7k|}
update_subtitles:
  166|   207k|{
  167|   207k|    bool ok = true;
  168|   621k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (168:21): [True: 414k, False: 207k]
  ------------------
  169|   414k|        ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
  170|   207k|    return ok;
  171|   207k|}
reinit_sub:
  219|  48.8k|{
  220|  48.8k|    if (!track || !track->stream || track->stream->type != STREAM_SUB)
  ------------------
  |  Branch (220:9): [True: 46.1k, False: 2.70k]
  |  Branch (220:19): [True: 0, False: 2.70k]
  |  Branch (220:37): [True: 0, False: 2.70k]
  ------------------
  221|  46.1k|        return;
  222|       |
  223|  2.70k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  2.70k|#define mp_assert assert
  ------------------
  |  Branch (223:5): [True: 2.70k, False: 0]
  ------------------
  224|       |
  225|  2.70k|    if (!init_subdec(mpctx, track)) {
  ------------------
  |  Branch (225:9): [True: 100, False: 2.60k]
  ------------------
  226|    100|        track->dec_failed = true;
  227|    100|        error_on_track(mpctx, track);
  228|    100|        return;
  229|    100|    }
  230|       |
  231|  2.60k|    sub_select(track->d_sub, true);
  232|  2.60k|    int order = get_order(mpctx, track);
  233|  2.60k|    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|  2.60k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (238:9): [True: 273, False: 2.33k]
  ------------------
  239|    273|        track->demuxer_ready = false;
  240|    273|        int64_t end = mp_time_ns() + MP_TIME_MS_TO_NS(50);
  ------------------
  |  |   72|    273|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  241|    546|        while (!track->demuxer_ready && mp_time_ns() < end)
  ------------------
  |  Branch (241:16): [True: 273, False: 273]
  |  Branch (241:41): [True: 273, False: 0]
  ------------------
  242|    273|            track->demuxer_ready = update_subtitles(mpctx, mpctx->playback_pts) ||
  ------------------
  |  Branch (242:36): [True: 273, False: 0]
  ------------------
  243|      0|                                  !mpctx->paused;
  ------------------
  |  Branch (243:35): [True: 0, False: 0]
  ------------------
  244|    273|        if (!track->demuxer_ready)
  ------------------
  |  Branch (244:13): [True: 0, False: 273]
  ------------------
  245|      0|            mp_wakeup_core(mpctx);
  246|       |
  247|    273|    }
  248|  2.60k|}
reinit_sub_all:
  251|  24.2k|{
  252|  72.7k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (252:21): [True: 48.5k, False: 24.2k]
  ------------------
  253|  48.5k|        reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
  254|  24.2k|}
sub.c:reset_subtitles:
   48|  3.42k|{
   49|  3.42k|    if (track->d_sub) {
  ------------------
  |  Branch (49:9): [True: 2.62k, False: 794]
  ------------------
   50|  2.62k|        sub_reset(track->d_sub);
   51|  2.62k|        sub_set_play_dir(track->d_sub, mpctx->play_dir);
   52|  2.62k|    }
   53|  3.42k|}
sub.c:get_order:
   39|  9.02k|{
   40|  9.02k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (40:21): [True: 9.02k, False: 0]
  ------------------
   41|  9.02k|        if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (41:13): [True: 9.02k, False: 0]
  ------------------
   42|  9.02k|            return n;
   43|  9.02k|    }
   44|      0|    return -1;
   45|  9.02k|}
sub.c:update_subtitle:
   97|   414k|{
   98|   414k|    struct dec_sub *dec_sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (98:31): [True: 30.2k, False: 384k]
  ------------------
   99|       |
  100|   414k|    if (!dec_sub)
  ------------------
  |  Branch (100:9): [True: 384k, False: 30.2k]
  ------------------
  101|   384k|        return true;
  102|       |
  103|  30.2k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (103:9): [True: 29.1k, False: 1.10k]
  ------------------
  104|  29.1k|        struct mp_image_params params = mpctx->vo_chain->filter->input_params;
  105|  29.1k|        if (params.imgfmt)
  ------------------
  |  Branch (105:13): [True: 24.2k, False: 4.94k]
  ------------------
  106|  24.2k|            sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
  107|  29.1k|    }
  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|  30.2k|    bool still_image = mpctx->video_out && ((mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (112:24): [True: 29.1k, False: 1.10k]
  |  Branch (112:46): [True: 3.91k, False: 25.2k]
  ------------------
  113|  3.91k|                       mpctx->opts->subs_rend->sub_past_video_end) ||
  ------------------
  |  Branch (113:24): [True: 0, False: 3.91k]
  ------------------
  114|  29.1k|                       !mpctx->current_track[0][STREAM_VIDEO] ||
  ------------------
  |  Branch (114:24): [True: 0, False: 29.1k]
  ------------------
  115|  29.1k|                       mpctx->current_track[0][STREAM_VIDEO]->image);
  ------------------
  |  Branch (115:24): [True: 5.80k, False: 23.3k]
  ------------------
  116|  30.2k|    sub_control(dec_sub, SD_CTRL_SET_ANIMATED_CHECK, &still_image);
  117|       |
  118|  30.2k|    if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
  ------------------
  |  Branch (118:9): [True: 0, False: 30.2k]
  |  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|  30.2k|    bool packets_read = false;
  126|  30.2k|    bool sub_updated = false;
  127|  30.2k|    sub_read_packets(dec_sub, video_pts, mpctx->paused, &packets_read, &sub_updated);
  128|       |
  129|  30.2k|    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|  30.2k|    if (sub_updated || track->redraw_subs || osd_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  26.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (133:9): [True: 1.86k, False: 28.4k]
  |  Branch (133:24): [True: 2.23k, False: 26.1k]
  |  Branch (133:46): [True: 23.5k, False: 2.66k]
  ------------------
  134|       |        // Always force a redecode of all packets if we seek on a still image.
  135|  27.6k|        if (track->redraw_subs && still_image)
  ------------------
  |  Branch (135:13): [True: 2.23k, False: 25.3k]
  |  Branch (135:35): [True: 724, False: 1.51k]
  ------------------
  136|    724|            sub_redecode_cached_packets(dec_sub);
  137|       |
  138|       |        // Handle displaying subtitles on terminal.
  139|  27.6k|        if (track->selected && track->type == STREAM_SUB && !mpctx->video_out) {
  ------------------
  |  Branch (139:13): [True: 27.6k, False: 0]
  |  Branch (139:32): [True: 27.6k, False: 0]
  |  Branch (139:61): [True: 1.10k, False: 26.4k]
  ------------------
  140|  1.10k|            char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
  141|  1.10k|            int order = get_order(mpctx, track);
  142|  1.10k|            if (order >= 0)
  ------------------
  |  Branch (142:17): [True: 1.10k, False: 0]
  ------------------
  143|  1.10k|                term_osd_set_subs(mpctx, text, order);
  144|  1.10k|            talloc_free(text);
  ------------------
  |  |   47|  1.10k|#define talloc_free                     ta_free
  ------------------
  145|  1.10k|        }
  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|  27.6k|        if (still_image) {
  ------------------
  |  Branch (150:13): [True: 3.14k, False: 24.4k]
  ------------------
  151|  3.14k|            if (osd_pts != video_pts) {
  ------------------
  |  Branch (151:17): [True: 1.68k, False: 1.46k]
  ------------------
  152|  1.68k|                osd_set_force_video_pts(mpctx->osd, video_pts);
  153|  1.68k|                osd_query_and_reset_want_redraw(mpctx->osd);
  154|  1.68k|                vo_redraw(mpctx->video_out);
  155|  1.68k|            }
  156|  3.14k|        }
  157|  27.6k|    }
  158|       |
  159|       |    track->redraw_subs = false;
  160|  30.2k|    return packets_read;
  161|   414k|}
sub.c:init_subdec:
  197|  2.70k|{
  198|  2.70k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  2.70k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 2.70k, False: 0]
  ------------------
  199|       |
  200|  2.70k|    if (!track->demuxer || !track->stream)
  ------------------
  |  Branch (200:9): [True: 0, False: 2.70k]
  |  Branch (200:28): [True: 0, False: 2.70k]
  ------------------
  201|      0|        return false;
  202|       |
  203|  2.70k|    track->d_sub = sub_create(mpctx->global, track,
  204|  2.70k|                              get_all_attachments(mpctx),
  205|  2.70k|                              get_order(mpctx, track));
  206|  2.70k|    if (!track->d_sub)
  ------------------
  |  Branch (206:9): [True: 100, False: 2.60k]
  ------------------
  207|    100|        return false;
  208|       |
  209|  2.60k|    struct track *vtrack = mpctx->current_track[0][STREAM_VIDEO];
  210|  2.60k|    struct mp_codec_params *v_c =
  211|  2.60k|        vtrack && vtrack->stream ? vtrack->stream->codec : NULL;
  ------------------
  |  Branch (211:9): [True: 2.30k, False: 304]
  |  Branch (211:19): [True: 2.30k, False: 0]
  ------------------
  212|  2.60k|    double fps = v_c ? v_c->fps : 25;
  ------------------
  |  Branch (212:18): [True: 2.30k, False: 304]
  ------------------
  213|  2.60k|    sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps);
  214|       |
  215|       |    return true;
  216|  2.70k|}
sub.c:get_all_attachments:
  174|  2.70k|{
  175|  2.70k|    struct attachment_list *list = talloc_zero(NULL, struct attachment_list);
  ------------------
  |  |   27|  2.70k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.70k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.70k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|  2.70k|    struct demuxer *prev_demuxer = NULL;
  177|  14.1k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (177:21): [True: 11.4k, False: 2.70k]
  ------------------
  178|  11.4k|        struct track *t = mpctx->tracks[n];
  179|  11.4k|        if (!t->demuxer || prev_demuxer == t->demuxer)
  ------------------
  |  Branch (179:13): [True: 0, False: 11.4k]
  |  Branch (179:28): [True: 8.69k, False: 2.70k]
  ------------------
  180|  8.69k|            continue;
  181|  2.70k|        prev_demuxer = t->demuxer;
  182|  3.00k|        for (int i = 0; i < t->demuxer->num_attachments; i++) {
  ------------------
  |  Branch (182:25): [True: 300, False: 2.70k]
  ------------------
  183|    300|            struct demux_attachment *att = &t->demuxer->attachments[i];
  184|    300|            struct demux_attachment copy = {
  185|    300|                .name = talloc_strdup(list, att->name),
  ------------------
  |  |   50|    300|#define talloc_strdup                   ta_xstrdup
  ------------------
  186|    300|                .type = talloc_strdup(list, att->type),
  ------------------
  |  |   50|    300|#define talloc_strdup                   ta_xstrdup
  ------------------
  187|    300|                .data = talloc_memdup(list, att->data, att->data_size),
  ------------------
  |  |   49|    300|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|    300|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|    300|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|    300|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|    300|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|    300|                .data_size = att->data_size,
  189|    300|            };
  190|    300|            MP_TARRAY_APPEND(list, list->entries, list->num_entries, copy);
  ------------------
  |  |  105|    300|    do {                                            \
  |  |  106|    300|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    300|    do {                                            \
  |  |  |  |   97|    300|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    300|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    300|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    300|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 294, False: 6]
  |  |  |  |  ------------------
  |  |  |  |   99|    300|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    294|    do {                                                        \
  |  |  |  |  |  |   89|    294|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    294|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    294|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    294|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    294|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    294|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    294|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 294]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    300|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 300]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    300|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    300|        (idxvar)++;                                 \
  |  |  109|    300|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 300]
  |  |  ------------------
  ------------------
  191|    300|        }
  192|  2.70k|    }
  193|  2.70k|    return list;
  194|  2.70k|}

reset_video_state:
  100|  63.0k|{
  101|  63.0k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (101:9): [True: 38.3k, False: 24.7k]
  ------------------
  102|  38.3k|        vo_chain_reset_state(mpctx->vo_chain);
  103|  38.3k|        struct track *t = mpctx->vo_chain->track;
  104|  38.3k|        if (t && t->dec)
  ------------------
  |  Branch (104:13): [True: 38.3k, False: 0]
  |  Branch (104:18): [True: 38.3k, False: 0]
  ------------------
  105|  38.3k|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  106|  38.3k|    }
  107|       |
  108|  63.0k|    for (int n = 0; n < mpctx->num_next_frames; n++)
  ------------------
  |  Branch (108:21): [True: 0, False: 63.0k]
  ------------------
  109|      0|        mp_image_unrefp(&mpctx->next_frames[n]);
  110|  63.0k|    mpctx->num_next_frames = 0;
  111|  63.0k|    mp_image_unrefp(&mpctx->saved_frame);
  112|       |
  113|  63.0k|    mpctx->delay = 0;
  114|  63.0k|    mpctx->time_frame = 0;
  115|  63.0k|    mpctx->video_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  63.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  116|  63.0k|    mpctx->last_frame_duration = 0;
  117|  63.0k|    mpctx->num_past_frames = 0;
  118|  63.0k|    mpctx->total_avsync_change = 0;
  119|  63.0k|    mpctx->last_av_difference = 0;
  120|  63.0k|    mpctx->mistimed_frames_total = 0;
  121|  63.0k|    mpctx->drop_message_shown = 0;
  122|  63.0k|    mpctx->audio_drift_compensation = 0;
  123|  63.0k|    mpctx->avd_filtered = 0;
  124|  63.0k|    mpctx->display_sync_error = 0;
  125|  63.0k|    mpctx->display_sync_active = 0;
  126|       |
  127|  63.0k|    mpctx->video_status = mpctx->vo_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (127:27): [True: 38.3k, False: 24.7k]
  ------------------
  128|  63.0k|}
uninit_video_out:
  131|   115k|{
  132|   115k|    uninit_video_chain(mpctx);
  133|   115k|    if (mpctx->video_out) {
  ------------------
  |  Branch (133:9): [True: 19.6k, False: 95.8k]
  ------------------
  134|  19.6k|        vo_destroy(mpctx->video_out);
  135|  19.6k|        mpctx->video_out = NULL;
  136|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  137|  19.6k|    }
  138|   115k|}
uninit_video_chain:
  164|   143k|{
  165|   143k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (165:9): [True: 19.6k, False: 123k]
  ------------------
  166|  19.6k|        reset_video_state(mpctx);
  167|  19.6k|        vo_chain_uninit(mpctx->vo_chain);
  168|  19.6k|        mpctx->vo_chain = NULL;
  169|       |
  170|  19.6k|        mpctx->video_status = STATUS_EOF;
  171|       |
  172|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  173|  19.6k|    }
  174|   143k|}
init_video_decoder:
  177|  19.6k|{
  178|  19.6k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 19.6k, False: 0]
  ------------------
  179|  19.6k|    if (!track->stream)
  ------------------
  |  Branch (179:9): [True: 0, False: 19.6k]
  ------------------
  180|      0|        goto err_out;
  181|       |
  182|  19.6k|    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|  19.6k|    if (track->vo_c)
  ------------------
  |  Branch (189:9): [True: 19.6k, False: 0]
  ------------------
  190|  19.6k|        parent = track->vo_c->filter->f;
  191|       |
  192|  19.6k|    track->dec = mp_decoder_wrapper_create(parent, track->stream);
  193|  19.6k|    if (!track->dec)
  ------------------
  |  Branch (193:9): [True: 0, False: 19.6k]
  ------------------
  194|      0|        goto err_out;
  195|       |
  196|  19.6k|    if (sh_stream_dependent_sibling(track->stream))
  ------------------
  |  Branch (196:9): [True: 0, False: 19.6k]
  ------------------
  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|  19.6k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (199:9): [True: 1.37k, False: 18.3k]
  ------------------
  200|  1.37k|        goto err_out;
  201|       |
  202|  18.3k|    return 1;
  203|       |
  204|  1.37k|err_out:
  205|  1.37k|    if (track->sink)
  ------------------
  |  Branch (205:9): [True: 0, False: 1.37k]
  ------------------
  206|      0|        mp_pin_disconnect(track->sink);
  207|  1.37k|    track->sink = NULL;
  208|       |    track->dec_failed = true;
  209|  1.37k|    return 0;
  210|  19.6k|}
reinit_video_chain:
  213|  25.6k|{
  214|  25.6k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
  215|  25.6k|    if (!track || !track->stream) {
  ------------------
  |  Branch (215:9): [True: 5.95k, False: 19.6k]
  |  Branch (215:19): [True: 0, False: 19.6k]
  ------------------
  216|  5.95k|        error_on_track(mpctx, track);
  217|  5.95k|        return;
  218|  5.95k|    }
  219|  19.6k|    reinit_video_chain_src(mpctx, track);
  220|  19.6k|}
reinit_video_chain_src:
  272|  19.6k|{
  273|  19.6k|    mp_assert(!mpctx->vo_chain);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (273:5): [True: 19.6k, False: 0]
  ------------------
  274|       |
  275|  19.6k|    if (!mpctx->video_out) {
  ------------------
  |  Branch (275:9): [True: 19.6k, False: 23]
  ------------------
  276|  19.6k|        struct vo_extra ex = {
  277|  19.6k|            .input_ctx = mpctx->input,
  278|  19.6k|            .osd = mpctx->osd,
  279|  19.6k|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
  280|  19.6k|            .wakeup_cb = mp_wakeup_core_cb,
  281|  19.6k|            .wakeup_ctx = mpctx,
  282|  19.6k|        };
  283|  19.6k|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
  284|  19.6k|        if (!mpctx->video_out) {
  ------------------
  |  Branch (284:13): [True: 0, False: 19.6k]
  ------------------
  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|  19.6k|        mpctx->mouse_cursor_visible = true;
  291|  19.6k|    }
  292|       |
  293|  19.6k|    update_window_title(mpctx, true);
  294|       |
  295|  19.6k|    struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain);
  ------------------
  |  |   27|  19.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  19.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|  19.6k|    mpctx->vo_chain = vo_c;
  297|  19.6k|    vo_c->log = mpctx->log;
  298|  19.6k|    vo_c->vo = mpctx->video_out;
  299|  19.6k|    vo_c->filter =
  300|  19.6k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_VIDEO);
  301|  19.6k|    mp_output_chain_set_vo(vo_c->filter, vo_c->vo);
  302|  19.6k|    vo_c->filter->update_subtitles = filter_update_subtitles;
  303|  19.6k|    vo_c->filter->update_subtitles_ctx = mpctx;
  304|       |
  305|  19.6k|    if (track) {
  ------------------
  |  Branch (305:9): [True: 19.6k, False: 0]
  ------------------
  306|  19.6k|        vo_c->track = track;
  307|  19.6k|        track->vo_c = vo_c;
  308|  19.6k|        vo_c->is_coverart = !!track->attached_picture;
  309|  19.6k|        vo_c->is_sparse = track->stream->still_image || vo_c->is_coverart;
  ------------------
  |  Branch (309:27): [True: 0, False: 19.6k]
  |  Branch (309:57): [True: 284, False: 19.3k]
  ------------------
  310|  19.6k|        if (!vo_chain_init_decoder(mpctx, vo_c))
  ------------------
  |  Branch (310:13): [True: 1.37k, False: 18.3k]
  ------------------
  311|  1.37k|            goto err_out;
  312|  19.6k|    }
  313|       |
  314|  18.3k|    update_vo_chain_el_pair(mpctx);
  315|       |
  316|  18.3k|    if (!recreate_video_filters(mpctx))
  ------------------
  |  Branch (316:9): [True: 0, False: 18.3k]
  ------------------
  317|      0|        goto err_out;
  318|       |
  319|  18.3k|    update_content_type(mpctx, track);
  320|  18.3k|    update_screensaver_state(mpctx);
  321|       |
  322|  18.3k|    vo_set_paused(vo_c->vo, get_internal_paused(mpctx));
  323|       |
  324|  18.3k|    reset_video_state(mpctx);
  325|  18.3k|    term_osd_clear_subs(mpctx);
  326|       |
  327|  18.3k|    return;
  328|       |
  329|  1.37k|err_out:
  330|  1.37k|    uninit_video_chain(mpctx);
  331|  1.37k|    error_on_track(mpctx, track);
  332|       |    handle_force_window(mpctx, true);
  333|  1.37k|}
write_video:
 1109|   250k|{
 1110|   250k|    struct MPOpts *opts = mpctx->opts;
 1111|       |
 1112|   250k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (1112:9): [True: 38.6k, False: 211k]
  ------------------
 1113|  38.6k|        return;
 1114|   211k|    struct track *track = mpctx->vo_chain->track;
 1115|   211k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1116|   211k|    struct vo *vo = vo_c->vo;
 1117|       |
 1118|   211k|    if (vo_c->filter->reconfig_happened) {
  ------------------
  |  Branch (1118:9): [True: 10.7k, False: 201k]
  ------------------
 1119|  10.7k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1120|  10.7k|        vo_c->filter->reconfig_happened = false;
 1121|  10.7k|    }
 1122|       |
 1123|       |    // Actual playback starts when both audio and video are ready.
 1124|   211k|    if (mpctx->video_status == STATUS_READY)
  ------------------
  |  Branch (1124:9): [True: 4.69k, False: 207k]
  ------------------
 1125|  4.69k|        return;
 1126|       |
 1127|   207k|    if (mpctx->paused && mpctx->video_status >= STATUS_READY)
  ------------------
  |  Branch (1127:9): [True: 345, False: 206k]
  |  Branch (1127:26): [True: 345, False: 0]
  ------------------
 1128|    345|        return;
 1129|       |
 1130|       |    // Once the chain reached EOF nothing is read from it again.
 1131|   207k|    bool logical_eof = false;
 1132|   206k|    int r = VD_EOF;
 1133|   206k|    if (mpctx->video_status < STATUS_DRAINING)
  ------------------
  |  Branch (1133:9): [True: 192k, False: 14.6k]
  ------------------
 1134|   192k|        r = video_output_image(mpctx, &logical_eof);
 1135|   206k|    MP_TRACE(mpctx, "video_output_image: r=%d/eof=%d/st=%s\n", r, logical_eof,
  ------------------
  |  |   94|   206k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   206k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|   206k|             mp_status_str(mpctx->video_status));
 1137|       |
 1138|   206k|    if (r < 0)
  ------------------
  |  Branch (1138:9): [True: 0, False: 206k]
  ------------------
 1139|      0|        goto error;
 1140|       |
 1141|   206k|    if (r == VD_WAIT) {
  ------------------
  |  Branch (1141:9): [True: 52.2k, False: 154k]
  ------------------
 1142|       |        // Heuristic to detect underruns.
 1143|  52.2k|        if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo) &&
  ------------------
  |  Branch (1143:13): [True: 12.3k, False: 39.8k]
  |  Branch (1143:54): [True: 12.2k, False: 130]
  ------------------
 1144|  12.2k|            !vo_c->underrun_signaled)
  ------------------
  |  Branch (1144:13): [True: 702, False: 11.5k]
  ------------------
 1145|    702|        {
 1146|    702|            vo_c->underrun = true;
 1147|    702|            vo_c->underrun_signaled = true;
 1148|    702|        }
 1149|       |        // Demuxer will wake us up for more packets to decode.
 1150|  52.2k|        return;
 1151|  52.2k|    }
 1152|       |
 1153|   154k|    if (r == VD_EOF) {
  ------------------
  |  Branch (1153:9): [True: 33.1k, False: 121k]
  ------------------
 1154|  33.1k|        if (check_for_hwdec_fallback(mpctx))
  ------------------
  |  Branch (1154:13): [True: 0, False: 33.1k]
  ------------------
 1155|      0|            return;
 1156|  33.1k|        if (check_for_forced_eof(mpctx)) {
  ------------------
  |  Branch (1156:13): [True: 0, False: 33.1k]
  ------------------
 1157|      0|            uninit_video_chain(mpctx);
 1158|      0|            handle_force_window(mpctx, true);
 1159|      0|            return;
 1160|      0|        }
 1161|  33.1k|        if (vo_c->filter->failed_output_conversion)
  ------------------
  |  Branch (1161:13): [True: 0, False: 33.1k]
  ------------------
 1162|      0|            goto error;
 1163|       |
 1164|  33.1k|        mpctx->delay = 0;
 1165|  33.1k|        mpctx->last_av_difference = 0;
 1166|       |
 1167|  33.1k|        if (mpctx->video_status <= STATUS_PLAYING) {
  ------------------
  |  Branch (1167:13): [True: 18.5k, False: 14.6k]
  ------------------
 1168|  18.5k|            mpctx->video_status = STATUS_DRAINING;
 1169|  18.5k|            get_relative_time(mpctx);
 1170|  18.5k|            if (vo_c->is_sparse && !mpctx->ao_chain) {
  ------------------
  |  Branch (1170:17): [True: 255, False: 18.2k]
  |  Branch (1170:36): [True: 222, False: 33]
  ------------------
 1171|    222|                MP_VERBOSE(mpctx, "assuming this is an image\n");
  ------------------
  |  |   92|    222|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    222|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1172|    222|                mpctx->time_frame += opts->image_display_duration / opts->playback_speed;
 1173|  18.3k|            } else if (mpctx->last_frame_duration > 0 && !opts->untimed &&
  ------------------
  |  Branch (1173:24): [True: 0, False: 18.3k]
  |  Branch (1173:58): [True: 0, False: 0]
  ------------------
 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|  18.3k|            } else {
 1179|  18.3k|                mpctx->time_frame = 0;
 1180|  18.3k|            }
 1181|       |            // Encode mode can't honor this; it'll only delay finishing.
 1182|  18.5k|            if (mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (1182:17): [True: 0, False: 18.5k]
  ------------------
 1183|      0|                mpctx->time_frame = 0;
 1184|  18.5k|        }
 1185|       |
 1186|       |        // Wait for the VO to signal actual EOF, then exit if the frame timer
 1187|       |        // has expired.
 1188|  33.1k|        bool has_frame = vo_has_frame(vo); // maybe not configured
 1189|  33.1k|        if (mpctx->video_status == STATUS_DRAINING &&
  ------------------
  |  Branch (1189:13): [True: 19.8k, False: 13.2k]
  ------------------
 1190|  19.8k|            (vo_is_ready_for_frame(vo, -1) || !has_frame))
  ------------------
  |  Branch (1190:14): [True: 10.6k, False: 9.24k]
  |  Branch (1190:47): [True: 7.93k, False: 1.31k]
  ------------------
 1191|  18.5k|        {
 1192|  18.5k|            mpctx->time_frame -= get_relative_time(mpctx);
 1193|  18.5k|            mp_set_timeout(mpctx, mpctx->time_frame);
 1194|  18.5k|            if (mpctx->time_frame <= 0 || !has_frame) {
  ------------------
  |  Branch (1194:17): [True: 18.5k, False: 0]
  |  Branch (1194:43): [True: 0, False: 0]
  ------------------
 1195|  18.5k|                MP_VERBOSE(mpctx, "video EOF reached\n");
  ------------------
  |  |   92|  18.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1196|  18.5k|                mpctx->video_status = STATUS_EOF;
 1197|  18.5k|            }
 1198|  18.5k|        }
 1199|       |
 1200|       |        // Avoid pointlessly spamming the logs every frame.
 1201|  33.1k|        if (!vo_c->is_sparse || !vo_c->sparse_eof_signalled) {
  ------------------
  |  Branch (1201:13): [True: 32.8k, False: 346]
  |  Branch (1201:33): [True: 284, False: 62]
  ------------------
 1202|  33.0k|            MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status);
  ------------------
  |  |   93|  33.0k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  33.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1203|  33.0k|            vo_c->sparse_eof_signalled = vo_c->is_sparse;
 1204|  33.0k|        }
 1205|  33.1k|        return;
 1206|  33.1k|    }
 1207|       |
 1208|   121k|    if (r != VD_NEW_FRAME) {
  ------------------
  |  Branch (1208:9): [True: 0, False: 121k]
  ------------------
 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|   121k|    if (vo_c->is_sparse && mpctx->video_status < STATUS_READY) {
  ------------------
  |  Branch (1215:9): [True: 106, False: 121k]
  |  Branch (1215:28): [True: 106, False: 0]
  ------------------
 1216|    106|        double ref = mpctx->playback_pts != MP_NOPTS_VALUE
  ------------------
  |  |   39|    106|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1216:22): [True: 0, False: 106]
  ------------------
 1217|    106|                        ? mpctx->playback_pts : mpctx->last_seek_pts;
 1218|    106|        if (ref != MP_NOPTS_VALUE && mpctx->next_frames[0]->pts > ref + 1.0) {
  ------------------
  |  |   39|    212|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1218:13): [True: 106, False: 0]
  |  Branch (1218:38): [True: 0, False: 106]
  ------------------
 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|    106|    }
 1226|       |
 1227|   121k|    if (logical_eof && !mpctx->num_past_frames && mpctx->num_next_frames == 1 &&
  ------------------
  |  Branch (1227:9): [True: 106, False: 121k]
  |  Branch (1227:24): [True: 106, False: 0]
  |  Branch (1227:51): [True: 106, False: 0]
  ------------------
 1228|    106|        use_video_lookahead(mpctx) && !vo_c->is_sparse)
  ------------------
  |  Branch (1228:9): [True: 0, False: 106]
  |  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|   121k|    apply_video_crop(mpctx, vo);
 1243|       |
 1244|       |    // Filter output is different from VO input?
 1245|   121k|    struct mp_image_params *p = &mpctx->next_frames[0]->params;
 1246|   121k|    if (!vo->params || !mp_image_params_static_equal(p, vo->params)) {
  ------------------
  |  Branch (1246:9): [True: 10.5k, False: 110k]
  |  Branch (1246:24): [True: 195, False: 110k]
  ------------------
 1247|       |        // Changing config deletes the current frame; wait until it's finished.
 1248|  10.7k|        if (vo_still_displaying(vo)) {
  ------------------
  |  Branch (1248:13): [True: 0, False: 10.7k]
  ------------------
 1249|      0|            vo_request_wakeup_on_done(vo);
 1250|      0|            return;
 1251|      0|        }
 1252|       |
 1253|  10.7k|        const struct vo_driver *info = mpctx->video_out->driver;
 1254|  10.7k|        char extra[20] = {0};
 1255|  10.7k|        if (p->p_w != p->p_h) {
  ------------------
  |  Branch (1255:13): [True: 3.90k, False: 6.89k]
  ------------------
 1256|  3.90k|            int d_w, d_h;
 1257|  3.90k|            mp_image_params_get_dsize(p, &d_w, &d_h);
 1258|  3.90k|            snprintf(extra, sizeof(extra), " => %dx%d", d_w, d_h);
 1259|  3.90k|        }
 1260|  10.7k|        char sfmt[20] = {0};
 1261|  10.7k|        if (p->hw_subfmt)
  ------------------
  |  Branch (1261:13): [True: 0, False: 10.7k]
  ------------------
 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|  10.7k|        MP_INFO(mpctx, "VO: [%s] %dx%d%s %s%s\n",
  ------------------
  |  |   91|  10.7k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1264|  10.7k|                info->name, p->w, p->h, extra, mp_imgfmt_to_name(p->imgfmt), sfmt);
 1265|  10.7k|        MP_VERBOSE(mpctx, "VO: Description: %s\n", info->description);
  ------------------
  |  |   92|  10.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1266|       |
 1267|  10.7k|        int vo_r = vo_reconfig2(vo, mpctx->next_frames[0]);
 1268|  10.7k|        if (vo_r < 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 10.7k]
  ------------------
 1269|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
 1270|      0|            goto error;
 1271|      0|        }
 1272|  10.7k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1273|   110k|    } else {
 1274|       |        // Update parameters that don't require reconfiguring the VO.
 1275|   110k|        mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|   110k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1276|   110k|        mp_image_params_update_dynamic(vo->params, p, vo->has_peak_detect_values);
 1277|   110k|        mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|   110k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1278|   110k|    }
 1279|       |
 1280|   121k|    mpctx->time_frame -= get_relative_time(mpctx);
 1281|   121k|    update_avsync_before_frame(mpctx);
 1282|       |
 1283|       |    // Enforce timing subtitles to video frames.
 1284|   121k|    osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE);
  ------------------
  |  |   39|   121k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1285|       |
 1286|   121k|    if (!update_subtitles(mpctx, mpctx->next_frames[0]->pts)) {
  ------------------
  |  Branch (1286:9): [True: 0, False: 121k]
  ------------------
 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|   121k|    double time_frame = MPMAX(mpctx->time_frame, -1);
  ------------------
  |  |   44|   121k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 121k, False: 0]
  |  |  ------------------
  ------------------
 1292|   121k|    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|   121k|    if (!vo_is_ready_for_frame(vo, mpctx->display_sync_active ? -1 : pts))
  ------------------
  |  Branch (1297:9): [True: 879, False: 120k]
  |  Branch (1297:36): [True: 0, False: 121k]
  ------------------
 1298|    879|        return;
 1299|       |
 1300|       |    // In encoding mode, wait for the ao to finish initializing.
 1301|   120k|    if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_AUDIO] && !mpctx->ao)
  ------------------
  |  Branch (1301:9): [True: 0, False: 120k]
  |  Branch (1301:35): [True: 0, False: 0]
  |  Branch (1301:76): [True: 0, False: 0]
  ------------------
 1302|      0|        return;
 1303|       |
 1304|   120k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (1304:5): [True: 120k, False: 0]
  ------------------
 1305|       |
 1306|   120k|    if (mpctx->num_past_frames >= MAX_NUM_VO_PTS)
  ------------------
  |  Branch (1306:9): [True: 20.9k, False: 99.7k]
  ------------------
 1307|  20.9k|        mpctx->num_past_frames--;
 1308|   120k|    MP_TARRAY_INSERT_AT(mpctx, mpctx->past_frames, mpctx->num_past_frames, 0,
  ------------------
  |  |  115|   120k|    do {                                            \
  |  |  116|   120k|        size_t at_ = (at);                          \
  |  |  117|   120k|        assert(at_ <= (idxvar));                    \
  |  |  118|   120k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   120k|    do {                                            \
  |  |  |  |   97|   120k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   120k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   120k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   120k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 22.9k, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|   120k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  22.9k|    do {                                                        \
  |  |  |  |  |  |   89|  22.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  22.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  22.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  22.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  22.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  22.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  22.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 22.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   120k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 120k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   120k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   120k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   120k|        (idxvar)++;                                 \
  |  |  122|   120k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   120k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 120k]
  |  |  ------------------
  ------------------
  |  Branch (1308:5): [True: 120k, False: 0]
  ------------------
 1309|   120k|                        (struct frame_info){0});
 1310|   120k|    mpctx->past_frames[0] = (struct frame_info){
 1311|   120k|        .pts = mpctx->next_frames[0]->pts,
 1312|   120k|        .num_vsyncs = -1,
 1313|   120k|    };
 1314|   120k|    calculate_frame_duration(mpctx);
 1315|       |
 1316|   120k|    int req = vo_get_num_req_frames(mpctx->video_out);
 1317|   120k|    mp_assert(req >= 1 && req <= VO_MAX_REQ_FRAMES);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 120k, False: 0]
  |  Branch (1317:5): [True: 120k, False: 0]
  ------------------
 1318|   120k|    struct vo_frame dummy = {
 1319|   120k|        .pts = pts,
 1320|   120k|        .duration = -1,
 1321|   120k|        .still = mpctx->step_frames > 0,
 1322|   120k|        .can_drop = opts->frame_dropping & 1,
 1323|   120k|        .num_frames = MPMIN(mpctx->num_next_frames, req),
  ------------------
  |  |   45|   120k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 120k]
  |  |  ------------------
  ------------------
 1324|   120k|        .num_vsyncs = 1,
 1325|   120k|    };
 1326|   241k|    for (int n = 0; n < dummy.num_frames; n++)
  ------------------
  |  Branch (1326:21): [True: 120k, False: 120k]
  ------------------
 1327|   120k|        dummy.frames[n] = mpctx->next_frames[n];
 1328|   120k|    struct vo_frame *frame = vo_frame_ref(&dummy);
 1329|       |
 1330|   120k|    double diff = mpctx->past_frames[0].approx_duration;
 1331|   120k|    if (opts->untimed || (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1331:9): [True: 120k, False: 0]
  |  Branch (1331:26): [True: 0, False: 0]
  ------------------
 1332|   120k|        diff = -1; // disable frame dropping and aspects of frame timing
 1333|   120k|    if (diff >= 0) {
  ------------------
  |  Branch (1333:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    mpctx->video_pts = mpctx->next_frames[0]->pts;
 1339|   120k|    mpctx->video_pts_unrounded = mpctx->next_pts_unrounded;
 1340|   120k|    mpctx->last_frame_duration =
 1341|   120k|        mpctx->next_frames[0]->pkt_duration / mpctx->video_speed;
 1342|       |
 1343|   120k|    shift_frames(mpctx);
 1344|       |
 1345|   120k|    schedule_frame(mpctx, frame);
 1346|       |
 1347|   120k|    mpctx->osd_force_update = true;
 1348|   120k|    update_osd_msg(mpctx);
 1349|       |
 1350|   120k|    vo_queue_frame(vo, frame);
 1351|       |
 1352|   120k|    check_framedrop(mpctx, vo_c);
 1353|       |
 1354|       |    // The frames were shifted down; "initialize" the new first entry.
 1355|   120k|    if (mpctx->num_next_frames >= 1)
  ------------------
  |  Branch (1355:9): [True: 0, False: 120k]
  ------------------
 1356|      0|        handle_new_frame(mpctx);
 1357|       |
 1358|   120k|    mpctx->shown_vframes++;
 1359|   120k|    if (mpctx->video_status < STATUS_PLAYING) {
  ------------------
  |  Branch (1359:9): [True: 10.6k, False: 110k]
  ------------------
 1360|  10.6k|        mpctx->video_status = STATUS_READY;
 1361|       |        // After a seek, make sure to wait until the first frame is visible.
 1362|  10.6k|        if (!opts->video_latency_hacks) {
  ------------------
  |  Branch (1362:13): [True: 10.6k, False: 0]
  ------------------
 1363|  10.6k|            vo_wait_frame(vo);
 1364|  10.6k|            MP_VERBOSE(mpctx, "first video frame after restart shown\n");
  ------------------
  |  |   92|  10.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1365|  10.6k|        }
 1366|  10.6k|    }
 1367|       |
 1368|   120k|    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|   120k|    if (logical_eof && !mpctx->num_next_frames && mpctx->ao_chain)
  ------------------
  |  Branch (1373:9): [True: 106, False: 120k]
  |  Branch (1373:24): [True: 106, False: 0]
  |  Branch (1373:51): [True: 29, False: 77]
  ------------------
 1374|     29|        mpctx->video_status = STATUS_EOF;
 1375|       |
 1376|   120k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (1376:9): [True: 120k, False: 29]
  ------------------
 1377|   120k|        if (mpctx->step_frames > 0) {
  ------------------
  |  Branch (1377:13): [True: 0, False: 120k]
  ------------------
 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|   120k|        if (mpctx->max_frames == 0 && !mpctx->stop_play)
  ------------------
  |  Branch (1384:13): [True: 0, False: 120k]
  |  Branch (1384:39): [True: 0, False: 0]
  ------------------
 1385|      0|            mpctx->stop_play = AT_END_OF_FILE;
 1386|   120k|        if (mpctx->max_frames > 0)
  ------------------
  |  Branch (1386:13): [True: 0, False: 120k]
  ------------------
 1387|      0|            mpctx->max_frames--;
 1388|   120k|    }
 1389|       |
 1390|   120k|    vo_c->underrun_signaled = false;
 1391|       |
 1392|   120k|    if (mpctx->video_status == STATUS_EOF || mpctx->stop_play)
  ------------------
  |  Branch (1392:9): [True: 29, False: 120k]
  |  Branch (1392:46): [True: 0, False: 120k]
  ------------------
 1393|     29|        mp_wakeup_core(mpctx);
 1394|   120k|    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|  18.3k|{
   68|  18.3k|    struct MPOpts *opts = mpctx->opts;
   69|  18.3k|    struct vo_chain *vo_c = mpctx->vo_chain;
   70|  18.3k|    mp_assert(vo_c);
  ------------------
  |  |   41|  18.3k|#define mp_assert assert
  ------------------
  |  Branch (70:5): [True: 18.3k, False: 0]
  ------------------
   71|       |
   72|  18.3k|    return mp_output_chain_update_filters(vo_c->filter, opts->vf_settings);
   73|  18.3k|}
video.c:vo_chain_reset_state:
   93|  38.3k|{
   94|  38.3k|    vo_seek_reset(vo_c->vo);
   95|  38.3k|    vo_c->underrun = false;
   96|       |    vo_c->underrun_signaled = false;
   97|  38.3k|}
video.c:vo_chain_uninit:
  141|  19.6k|{
  142|  19.6k|    struct track *track = vo_c->track;
  143|  19.6k|    if (track) {
  ------------------
  |  Branch (143:9): [True: 19.6k, False: 0]
  ------------------
  144|  19.6k|        mp_assert(track->vo_c == vo_c);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (144:9): [True: 19.6k, False: 0]
  ------------------
  145|  19.6k|        track->vo_c = NULL;
  146|  19.6k|        if (vo_c->dec_src)
  ------------------
  |  Branch (146:13): [True: 18.3k, False: 1.37k]
  ------------------
  147|  19.6k|            mp_assert(track->dec->f->pins[0] == vo_c->dec_src);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (147:13): [True: 18.3k, False: 0]
  ------------------
  148|       |        // This is NULL if a sh_stream_group's filter fails.
  149|  19.6k|        if (track->dec) {
  ------------------
  |  Branch (149:13): [True: 19.6k, False: 0]
  ------------------
  150|  19.6k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  151|  19.6k|            track->dec = NULL;
  152|  19.6k|        }
  153|  19.6k|    }
  154|       |
  155|  19.6k|    if (vo_c->filter_src)
  ------------------
  |  Branch (155:9): [True: 0, False: 19.6k]
  ------------------
  156|      0|        mp_pin_disconnect(vo_c->filter_src);
  157|       |
  158|  19.6k|    talloc_free(vo_c->filter->f);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  159|  19.6k|    talloc_free(vo_c);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  160|       |    // this does not free the VO
  161|  19.6k|}
video.c:vo_chain_init_decoder:
  232|  19.6k|{
  233|  19.6k|    struct track *track = vo_c->track;
  234|  19.6k|    if (!init_video_decoder(mpctx, track))
  ------------------
  |  Branch (234:9): [True: 1.37k, False: 18.3k]
  ------------------
  235|  1.37k|        return false;
  236|  18.3k|    vo_c->dec_src = track->dec->f->pins[0];
  237|  18.3k|    vo_c->filter->container_fps =
  238|  18.3k|        mp_decoder_wrapper_get_container_fps(track->dec);
  239|  18.3k|    if (vo_c->is_coverart)
  ------------------
  |  Branch (239:9): [True: 284, False: 18.0k]
  ------------------
  240|    284|        mp_decoder_wrapper_set_coverart_flag(track->dec, true);
  241|  18.3k|    mp_pin_connect(vo_c->filter->f->pins[0], vo_c->dec_src);
  242|       |    return true;
  243|  19.6k|}
video.c:filter_update_subtitles:
  223|   120k|{
  224|   120k|    struct MPContext *mpctx = ctx;
  225|       |
  226|   120k|    if (osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  Branch (226:9): [True: 0, False: 120k]
  ------------------
  227|      0|        update_subtitles(mpctx, pts);
  228|   120k|}
video.c:video_output_image:
  520|   192k|{
  521|   192k|    struct vo_chain *vo_c = mpctx->vo_chain;
  522|   192k|    bool hrseek = false;
  523|   192k|    double hrseek_pts = mpctx->hrseek_pts;
  524|   192k|    double tolerance = mpctx->hrseek_backstep ? 0 : .005;
  ------------------
  |  Branch (524:24): [True: 0, False: 192k]
  ------------------
  525|   192k|    if (mpctx->video_status == STATUS_SYNCING) {
  ------------------
  |  Branch (525:9): [True: 58.5k, False: 133k]
  ------------------
  526|  58.5k|        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|  58.5k|        if (!hrseek && mpctx->playback_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  58.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (530:13): [True: 58.5k, False: 0]
  |  Branch (530:24): [True: 0, False: 58.5k]
  ------------------
  531|      0|            hrseek = true;
  532|      0|            hrseek_pts = mpctx->playback_pts;
  533|      0|        }
  534|  58.5k|    }
  535|       |
  536|   192k|    if (vo_c->is_coverart) {
  ------------------
  |  Branch (536:9): [True: 361, False: 191k]
  ------------------
  537|    361|        *logical_eof = true;
  538|    361|        if (vo_has_frame(mpctx->video_out))
  ------------------
  |  Branch (538:13): [True: 77, False: 284]
  ------------------
  539|     77|            return VD_EOF;
  540|    361|    }
  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|   192k|    if (vo_c->is_sparse)
  ------------------
  |  Branch (545:9): [True: 284, False: 191k]
  ------------------
  546|    284|        hrseek = false;
  547|       |
  548|   192k|    if (have_new_frame(mpctx, false))
  ------------------
  |  Branch (548:9): [True: 879, False: 191k]
  ------------------
  549|    879|        return VD_NEW_FRAME;
  550|       |
  551|       |    // Get a new frame if we need one.
  552|   191k|    int r = VD_PROGRESS;
  553|   191k|    if (needs_new_frame(mpctx)) {
  ------------------
  |  Branch (553:9): [True: 191k, False: 0]
  ------------------
  554|       |        // Filter a new frame.
  555|   191k|        struct mp_image *img = NULL;
  556|   191k|        struct mp_frame frame = mp_pin_out_read(vo_c->filter->f->pins[1]);
  557|   191k|        if (frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (557:13): [True: 52.2k, False: 139k]
  ------------------
  558|  52.2k|            r = vo_c->filter->got_output_eof ? VD_EOF : VD_WAIT;
  ------------------
  |  Branch (558:17): [True: 0, False: 52.2k]
  ------------------
  559|   139k|        } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (559:20): [True: 18.4k, False: 120k]
  ------------------
  560|  18.4k|            r = VD_EOF;
  561|   120k|        } else if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (561:20): [True: 120k, False: 0]
  ------------------
  562|   120k|            img = frame.data;
  563|   120k|        } 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|   191k|        if (img) {
  ------------------
  |  Branch (569:13): [True: 120k, False: 70.7k]
  ------------------
  570|   120k|            double endpts = get_play_end_pts(mpctx);
  571|   120k|            if (endpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (571:17): [True: 0, False: 120k]
  ------------------
  572|      0|                endpts *= mpctx->play_dir;
  573|   120k|            if ((endpts != MP_NOPTS_VALUE && img->pts >= endpts) ||
  ------------------
  |  |   39|   241k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (573:18): [True: 0, False: 120k]
  |  Branch (573:46): [True: 0, False: 0]
  ------------------
  574|   120k|                mpctx->max_frames == 0)
  ------------------
  |  Branch (574:17): [True: 0, False: 120k]
  ------------------
  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|   120k|            } else if (hrseek && (img->pts < hrseek_pts - tolerance ||
  ------------------
  |  Branch (579:24): [True: 0, False: 120k]
  |  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|   120k|            } else {
  585|   120k|                if (hrseek && mpctx->hrseek_backstep) {
  ------------------
  |  Branch (585:21): [True: 0, False: 120k]
  |  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|   120k|                mp_image_unrefp(&mpctx->saved_frame);
  595|   120k|                add_new_frame(mpctx, img);
  596|   120k|                img = NULL;
  597|   120k|            }
  598|   120k|            talloc_free(img);
  ------------------
  |  |   47|   120k|#define talloc_free                     ta_free
  ------------------
  599|   120k|        }
  600|   191k|    }
  601|       |
  602|   191k|    if (!hrseek)
  ------------------
  |  Branch (602:9): [True: 191k, False: 0]
  ------------------
  603|   191k|        mp_image_unrefp(&mpctx->saved_frame);
  604|       |
  605|   191k|    if (r == VD_EOF) {
  ------------------
  |  Branch (605:9): [True: 18.4k, False: 172k]
  ------------------
  606|       |        // If hr-seek went past EOF, use the last frame.
  607|  18.4k|        if (mpctx->saved_frame)
  ------------------
  |  Branch (607:13): [True: 0, False: 18.4k]
  ------------------
  608|      0|            add_new_frame(mpctx, mpctx->saved_frame);
  609|  18.4k|        mpctx->saved_frame = NULL;
  610|  18.4k|        *logical_eof = true;
  611|  18.4k|    }
  612|       |
  613|   191k|    return have_new_frame(mpctx, r <= 0) ? VD_NEW_FRAME : r;
  ------------------
  |  Branch (613:12): [True: 120k, False: 70.7k]
  ------------------
  614|   191k|}
video.c:have_new_frame:
  512|   383k|{
  513|   383k|    return mpctx->num_next_frames >= get_req_frames(mpctx, eof);
  514|   383k|}
video.c:get_req_frames:
  471|   575k|{
  472|       |    // On EOF, drain all frames.
  473|   575k|    if (eof)
  ------------------
  |  Branch (473:9): [True: 18.4k, False: 556k]
  ------------------
  474|  18.4k|        return 1;
  475|       |
  476|   556k|    if (!use_video_lookahead(mpctx))
  ------------------
  |  Branch (476:9): [True: 556k, False: 0]
  ------------------
  477|   556k|        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|   191k|{
  496|       |    return mpctx->num_next_frames < get_req_frames(mpctx, false);
  497|   191k|}
video.c:add_new_frame:
  501|   120k|{
  502|   120k|    mp_assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames));
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (502:5): [True: 120k, False: 0]
  ------------------
  503|   120k|    mp_assert(frame);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (503:5): [True: 120k, False: 0]
  ------------------
  504|   120k|    mpctx->next_frames[mpctx->num_next_frames++] = frame;
  505|   120k|    if (mpctx->num_next_frames == 1)
  ------------------
  |  Branch (505:9): [True: 120k, False: 0]
  ------------------
  506|   120k|        handle_new_frame(mpctx);
  507|   120k|}
video.c:check_for_hwdec_fallback:
  617|  33.1k|{
  618|  33.1k|    struct vo_chain *vo_c = mpctx->vo_chain;
  619|       |
  620|  33.1k|    if (!vo_c->filter->failed_output_conversion || !vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (620:9): [True: 33.1k, False: 0]
  |  Branch (620:52): [True: 0, False: 0]
  |  Branch (620:68): [True: 0, False: 0]
  ------------------
  621|  33.1k|        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|  33.1k|{
  633|  33.1k|    struct vo_chain *vo_c = mpctx->vo_chain;
  634|       |
  635|  33.1k|    if (!vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (635:9): [True: 0, False: 33.1k]
  |  Branch (635:25): [True: 0, False: 33.1k]
  ------------------
  636|      0|        return false;
  637|       |
  638|  33.1k|    struct mp_decoder_wrapper *dec = vo_c->track->dec;
  639|  33.1k|    bool forced_eof = false;
  640|       |
  641|  33.1k|    mp_decoder_wrapper_control(dec, VDCTRL_CHECK_FORCED_EOF, &forced_eof);
  642|  33.1k|    return forced_eof;
  643|  33.1k|}
video.c:use_video_lookahead:
  463|   556k|{
  464|   556k|    return mpctx->video_out &&
  ------------------
  |  Branch (464:12): [True: 556k, False: 0]
  ------------------
  465|   556k|           !(mpctx->video_out->driver->caps & VO_CAP_NORETAIN) &&
  ------------------
  |  Branch (465:12): [True: 556k, False: 0]
  ------------------
  466|   556k|           !(mpctx->opts->untimed || (mpctx->video_out->driver->caps & VO_CAP_UNTIMED)) &&
  ------------------
  |  Branch (466:14): [True: 556k, False: 0]
  |  Branch (466:38): [True: 0, False: 0]
  ------------------
  467|      0|           !mpctx->opts->video_latency_hacks;
  ------------------
  |  Branch (467:12): [True: 0, False: 0]
  ------------------
  468|   556k|}
video.c:apply_video_crop:
 1083|   121k|{
 1084|   243k|    for (int n = 0; n < mpctx->num_next_frames; n++) {
  ------------------
  |  Branch (1084:21): [True: 121k, False: 121k]
  ------------------
 1085|   121k|        struct m_geometry *gm = &vo->opts->video_crop;
 1086|   121k|        struct mp_image_params p = mpctx->next_frames[n]->params;
 1087|   121k|        if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
  ------------------
  |  Branch (1087:13): [True: 0, False: 121k]
  |  Branch (1087:30): [True: 0, False: 121k]
  |  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|   121k|        if (p.crop.x1 == 0 && p.crop.y1 == 0)
  ------------------
  |  Branch (1092:13): [True: 0, False: 121k]
  |  Branch (1092:31): [True: 0, False: 0]
  ------------------
 1093|      0|            return;
 1094|       |
 1095|   121k|        if (!mp_image_crop_valid(&p)) {
  ------------------
  |  Branch (1095:13): [True: 0, False: 121k]
  ------------------
 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|   121k|        mpctx->next_frames[n]->params.crop = p.crop;
 1105|   121k|    }
 1106|   121k|}
video.c:update_avsync_before_frame:
  649|   121k|{
  650|   121k|    struct MPOpts *opts = mpctx->opts;
  651|   121k|    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|   121k|    bool first_frame = mpctx->video_pts == MP_NOPTS_VALUE;
  ------------------
  |  |   39|   121k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  660|   121k|    if (first_frame && mpctx->audio_status == STATUS_PLAYING) {
  ------------------
  |  Branch (660:9): [True: 10.6k, False: 110k]
  |  Branch (660:24): [True: 0, False: 10.6k]
  ------------------
  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|   121k|    if (mpctx->video_status < STATUS_READY && mpctx->audio_status != STATUS_PLAYING) {
  ------------------
  |  Branch (667:9): [True: 10.6k, False: 110k]
  |  Branch (667:47): [True: 10.6k, False: 0]
  ------------------
  668|  10.6k|        mpctx->time_frame = 0;
  669|   110k|    } else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
  ------------------
  |  Branch (669:16): [True: 0, False: 110k]
  |  Branch (669:46): [True: 0, False: 110k]
  ------------------
  670|       |        // don't touch the timing
  671|   110k|    } else if (mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao)) {
  ------------------
  |  Branch (671:16): [True: 10.4k, False: 100k]
  |  Branch (671:57): [True: 0, False: 10.4k]
  ------------------
  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|   110k|    } 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|   110k|        if (mpctx->time_frame < -0.2 || opts->untimed ||
  ------------------
  |  Branch (699:13): [True: 1, False: 110k]
  |  Branch (699:41): [True: 110k, False: 0]
  ------------------
  700|      0|            (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (700:13): [True: 0, False: 0]
  ------------------
  701|   110k|            mpctx->time_frame = 0;
  702|   110k|    }
  703|   121k|}
video.c:calculate_frame_duration:
 1032|   120k|{
 1033|   120k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1034|   120k|    mp_assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (1034:5): [True: 120k, False: 0]
  |  Branch (1034:5): [True: 120k, False: 0]
  ------------------
 1035|       |
 1036|   120k|    double demux_duration = vo_c->filter->container_fps > 0
  ------------------
  |  Branch (1036:29): [True: 29.8k, False: 90.8k]
  ------------------
 1037|   120k|                            ? 1.0 / vo_c->filter->container_fps : -1;
 1038|   120k|    double duration = demux_duration;
 1039|       |
 1040|   120k|    if (mpctx->num_next_frames >= 2) {
  ------------------
  |  Branch (1040:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    double tolerance = MP_PTS_ROUNDING_TOLERANCE;
  ------------------
  |  |   72|   120k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
 1050|       |
 1051|   120k|    double total = 0;
 1052|   120k|    int num_dur = 0;
 1053|   705k|    for (int n = 1; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (1053:21): [True: 668k, False: 36.7k]
  ------------------
 1054|       |        // Eliminate likely outliers using a really dumb heuristic.
 1055|   668k|        double dur = mpctx->past_frames[n].duration;
 1056|   668k|        if (dur <= 0 || fabs(dur - duration) >= tolerance)
  ------------------
  |  Branch (1056:13): [True: 83.9k, False: 585k]
  |  Branch (1056:25): [True: 0, False: 585k]
  ------------------
 1057|  83.9k|            break;
 1058|   585k|        total += dur;
 1059|   585k|        num_dur += 1;
 1060|   585k|    }
 1061|   120k|    double approx_duration = num_dur > 0 ? total / num_dur : duration;
  ------------------
  |  Branch (1061:30): [True: 26.1k, False: 94.5k]
  ------------------
 1062|       |
 1063|       |    // Try if the demuxer frame rate fits - if so, just take it.
 1064|   120k|    if (demux_duration > 0) {
  ------------------
  |  Branch (1064:9): [True: 29.8k, False: 90.8k]
  ------------------
 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|  29.8k|        if (fabs(duration - demux_duration) < tolerance &&
  ------------------
  |  Branch (1067:13): [True: 29.8k, False: 0]
  ------------------
 1068|  29.8k|            fabs(total - demux_duration * num_dur) < tolerance &&
  ------------------
  |  Branch (1068:13): [True: 29.8k, False: 0]
  ------------------
 1069|  29.8k|            (num_dur >= 16 || num_dur >= mpctx->num_past_frames - 4))
  ------------------
  |  Branch (1069:14): [True: 10.4k, False: 19.3k]
  |  Branch (1069:31): [True: 19.3k, False: 0]
  ------------------
 1070|  29.8k|        {
 1071|  29.8k|            approx_duration = demux_duration;
 1072|  29.8k|        }
 1073|  29.8k|    }
 1074|       |
 1075|   120k|    mpctx->past_frames[0].duration = duration;
 1076|   120k|    mpctx->past_frames[0].approx_duration = approx_duration;
 1077|       |
 1078|   120k|    MP_STATS(mpctx, "value %f frame-duration", MPMAX(0, duration));
  ------------------
  |  |   99|   120k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   241k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 90.8k, False: 29.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1079|   120k|    MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
  ------------------
  |  |   99|   120k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   241k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 90.8k, False: 29.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|   120k|}
video.c:shift_frames:
  453|   120k|{
  454|   120k|    if (mpctx->num_next_frames < 1)
  ------------------
  |  Branch (454:9): [True: 0, False: 120k]
  ------------------
  455|      0|        return;
  456|   120k|    talloc_free(mpctx->next_frames[0]);
  ------------------
  |  |   47|   120k|#define talloc_free                     ta_free
  ------------------
  457|   120k|    for (int n = 0; n < mpctx->num_next_frames - 1; n++)
  ------------------
  |  Branch (457:21): [True: 0, False: 120k]
  ------------------
  458|      0|        mpctx->next_frames[n] = mpctx->next_frames[n + 1];
  459|   120k|    mpctx->num_next_frames -= 1;
  460|   120k|}
video.c:schedule_frame:
 1008|   120k|{
 1009|   120k|    handle_display_sync_frame(mpctx, frame);
 1010|       |
 1011|   120k|    if (mpctx->num_past_frames > 1 &&
  ------------------
  |  Branch (1011:9): [True: 110k, False: 10.6k]
  ------------------
 1012|   110k|        ((mpctx->past_frames[1].num_vsyncs >= 0) != mpctx->display_sync_active))
  ------------------
  |  Branch (1012:9): [True: 0, False: 110k]
  ------------------
 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|   120k|    if (!mpctx->display_sync_active) {
  ------------------
  |  Branch (1018:9): [True: 120k, False: 0]
  ------------------
 1019|   120k|        if (mpctx->num_past_frames > 1 && mpctx->past_frames[1].num_vsyncs >= 0) {
  ------------------
  |  Branch (1019:13): [True: 110k, False: 10.6k]
  |  Branch (1019:43): [True: 0, False: 110k]
  ------------------
 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|   120k|        update_av_diff(mpctx, mpctx->time_frame > 0 ?
  ------------------
  |  Branch (1025:31): [True: 0, False: 120k]
  ------------------
 1026|   120k|            mpctx->time_frame * mpctx->video_speed : 0);
 1027|   120k|    }
 1028|   120k|}
video.c:handle_display_sync_frame:
  861|   120k|{
  862|   120k|    struct MPOpts *opts = mpctx->opts;
  863|   120k|    struct vo *vo = mpctx->video_out;
  864|   120k|    int mode = vo->opts->video_sync;
  865|       |
  866|   120k|    bool sync_start = !mpctx->display_sync_active;
  867|   120k|    if (sync_start) {
  ------------------
  |  Branch (867:9): [True: 120k, False: 0]
  ------------------
  868|   120k|        mpctx->display_sync_error = 0.0;
  869|   120k|        mpctx->audio_drift_compensation = 0.0;
  870|   120k|        mpctx->avd_filtered = 0;
  871|   120k|    }
  872|       |
  873|   120k|    mpctx->display_sync_active = false;
  874|       |
  875|   120k|    if (!VS_IS_DISP(mode) || !vo_is_visible(vo) || mpctx->vo_chain->is_sparse ||
  ------------------
  |  |  131|   241k|#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE ||       \
  |  |  ------------------
  |  |  |  Branch (131:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  132|   120k|                       (x) == VS_DISP_RESAMPLE_VDROP || \
  |  |  ------------------
  |  |  |  Branch (132:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  133|   120k|                       (x) == VS_DISP_RESAMPLE_NONE ||  \
  |  |  ------------------
  |  |  |  Branch (133:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  134|   120k|                       (x) == VS_DISP_TEMPO ||          \
  |  |  ------------------
  |  |  |  Branch (134:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  135|   120k|                       (x) == VS_DISP_ADROP ||          \
  |  |  ------------------
  |  |  |  Branch (135:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  136|   120k|                       (x) == VS_DISP_VDROP ||          \
  |  |  ------------------
  |  |  |  Branch (136:24): [True: 0, False: 120k]
  |  |  ------------------
  |  |  137|   241k|                       (x) == VS_DISP_NONE)
  |  |  ------------------
  |  |  |  Branch (137:24): [True: 0, False: 120k]
  |  |  ------------------
  ------------------
  |  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|   120k|        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|   120k|{
  708|   120k|    struct MPOpts *opts = mpctx->opts;
  709|       |
  710|   120k|    mpctx->last_av_difference = 0;
  711|       |
  712|   120k|    if (mpctx->audio_status != STATUS_PLAYING ||
  ------------------
  |  Branch (712:9): [True: 110k, False: 10.3k]
  ------------------
  713|  10.3k|        mpctx->video_status != STATUS_PLAYING)
  ------------------
  |  Branch (713:9): [True: 0, False: 10.3k]
  ------------------
  714|   110k|        return;
  715|       |
  716|  10.3k|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (716:9): [True: 10.3k, False: 0]
  |  Branch (716:28): [True: 0, False: 10.3k]
  ------------------
  717|      0|        return;
  718|       |
  719|  10.3k|    double a_pos = playing_audio_pts(mpctx);
  720|  10.3k|    if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  20.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  10.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (720:9): [True: 10.2k, False: 89]
  |  Branch (720:36): [True: 10.2k, False: 0]
  ------------------
  721|  10.2k|        mpctx->last_av_difference = a_pos - mpctx->video_pts_unrounded
  722|  10.2k|                                  + opts->audio_delay + offset;
  723|  10.2k|    }
  724|       |
  725|  10.3k|    if (fabs(mpctx->last_av_difference) > 0.5 && !mpctx->drop_message_shown) {
  ------------------
  |  Branch (725:9): [True: 927, False: 9.40k]
  |  Branch (725:50): [True: 96, False: 831]
  ------------------
  726|     96|        MP_WARN(mpctx, "%s", av_desync_help_text);
  ------------------
  |  |   90|     96|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     96|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  727|       |        mpctx->drop_message_shown = true;
  728|     96|    }
  729|  10.3k|}
video.c:check_framedrop:
  355|   120k|{
  356|   120k|    struct MPOpts *opts = mpctx->opts;
  357|       |    // check for frame-drop:
  358|   120k|    if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
  ------------------
  |  Branch (358:9): [True: 110k, False: 10.6k]
  |  Branch (358:50): [True: 110k, False: 0]
  ------------------
  359|   110k|        mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao) &&
  ------------------
  |  Branch (359:9): [True: 10.3k, False: 99.6k]
  |  Branch (359:50): [True: 0, False: 10.3k]
  ------------------
  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|   120k|}
video.c:handle_new_frame:
  411|   120k|{
  412|   120k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 120k, False: 0]
  ------------------
  413|       |
  414|   120k|    double frame_time = 0;
  415|   120k|    double pts = mpctx->next_frames[0]->pts;
  416|   120k|    bool is_sparse = mpctx->vo_chain && mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (416:22): [True: 120k, False: 0]
  |  Branch (416:41): [True: 106, False: 120k]
  ------------------
  417|       |
  418|   120k|    mpctx->next_pts_unrounded = pts;
  419|   120k|    if (mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   120k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (419:9): [True: 110k, False: 10.6k]
  ------------------
  420|   110k|        frame_time = pts - mpctx->video_pts;
  421|   110k|        double tolerance = mpctx->demuxer->ts_resets_possible &&
  ------------------
  |  Branch (421:28): [True: 0, False: 110k]
  ------------------
  422|   110k|                           !is_sparse ? 5 : 1e4;
  ------------------
  |  Branch (422:28): [True: 0, False: 0]
  ------------------
  423|   110k|        if (frame_time <= 0 || frame_time >= tolerance) {
  ------------------
  |  Branch (423:13): [True: 26.5k, False: 83.4k]
  |  Branch (423:32): [True: 1, False: 83.4k]
  ------------------
  424|       |            // Assume a discontinuity.
  425|  26.5k|            MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n",
  ------------------
  |  |   90|  26.5k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  26.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  426|  26.5k|                    mpctx->video_pts, pts);
  427|  26.5k|            frame_time = 0;
  428|  83.4k|        } 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|  83.4k|            double duration = mpctx->past_frames[0].approx_duration;
  437|  83.4k|            double unrounded = mpctx->video_pts_unrounded + duration;
  438|  83.4k|            if (duration > 0 && fabs(pts - unrounded) < MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|  17.4k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (438:17): [True: 17.4k, False: 65.9k]
  |  Branch (438:33): [True: 1.93k, False: 15.5k]
  ------------------
  439|  1.93k|                mpctx->next_pts_unrounded = unrounded + (pts - unrounded) / 64;
  440|  83.4k|            frame_time = mpctx->next_pts_unrounded - mpctx->video_pts_unrounded;
  441|  83.4k|        }
  442|   110k|    }
  443|   120k|    mpctx->time_frame += frame_time / mpctx->video_speed;
  444|   120k|    if (mpctx->ao_chain)
  ------------------
  |  Branch (444:9): [True: 49.3k, False: 71.3k]
  ------------------
  445|  49.3k|        mpctx->delay -= frame_time;
  446|   120k|    if (mpctx->video_status >= STATUS_PLAYING)
  ------------------
  |  Branch (446:9): [True: 110k, False: 10.6k]
  ------------------
  447|   110k|        adjust_sync(mpctx, mpctx->next_pts_unrounded, frame_time);
  448|   120k|    MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
  ------------------
  |  |   94|   120k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   120k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  449|   120k|}
video.c:adjust_sync:
  383|   110k|{
  384|   110k|    struct MPOpts *opts = mpctx->opts;
  385|       |
  386|   110k|    if (mpctx->audio_status != STATUS_PLAYING)
  ------------------
  |  Branch (386:9): [True: 99.6k, False: 10.3k]
  ------------------
  387|  99.6k|        return;
  388|       |
  389|  10.3k|    double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay;
  390|  10.3k|    double av_delay = a_pts - v_pts;
  391|       |
  392|  10.3k|    double change = av_delay * 0.1;
  393|  10.3k|    double factor = fabs(av_delay) < 0.3 ? 0.1 : 0.4;
  ------------------
  |  Branch (393:21): [True: 8.94k, False: 1.39k]
  ------------------
  394|  10.3k|    double max_change = opts->default_max_pts_correction >= 0 ?
  ------------------
  |  Branch (394:25): [True: 0, False: 10.3k]
  ------------------
  395|  10.3k|                        opts->default_max_pts_correction : frame_time * factor;
  396|  10.3k|    if (change < -max_change)
  ------------------
  |  Branch (396:9): [True: 3.01k, False: 7.31k]
  ------------------
  397|  3.01k|        change = -max_change;
  398|  7.31k|    else if (change > max_change)
  ------------------
  |  Branch (398:14): [True: 3.86k, False: 3.45k]
  ------------------
  399|  3.86k|        change = max_change;
  400|  10.3k|    mpctx->delay += change;
  401|  10.3k|    mpctx->total_avsync_change += change;
  402|       |
  403|  10.3k|    if (mpctx->display_sync_active)
  ------------------
  |  Branch (403:9): [True: 0, False: 10.3k]
  ------------------
  404|      0|        mpctx->total_avsync_change = 0;
  405|  10.3k|}

mp_url_unescape_inplace:
  152|  1.42M|{
  153|  12.8M|    for (int len = strlen(url), i = 0, o = 0; i <= len;) {
  ------------------
  |  Branch (153:47): [True: 11.3M, False: 1.42M]
  ------------------
  154|  11.3M|        if ((url[i] != '%') || (i > len - 3)) {  // %NN can't start after len-3
  ------------------
  |  Branch (154:13): [True: 11.3M, False: 0]
  |  Branch (154:32): [True: 0, False: 0]
  ------------------
  155|  11.3M|            url[o++] = url[i++];
  156|  11.3M|            continue;
  157|  11.3M|        }
  158|       |
  159|      0|        int msd = hex2dec(url[i + 1]),
  160|      0|            lsd = hex2dec(url[i + 2]);
  161|       |
  162|      0|        if (msd >= 0 && lsd >= 0) {
  ------------------
  |  Branch (162:13): [True: 0, False: 0]
  |  Branch (162:25): [True: 0, False: 0]
  ------------------
  163|      0|            url[o++] = 16 * msd + lsd;
  164|      0|            i += 3;
  165|      0|        } else {
  166|      0|            url[o++] = url[i++];
  167|      0|            url[o++] = url[i++];
  168|      0|            url[o++] = url[i++];
  169|      0|        }
  170|      0|    }
  171|  1.42M|}
stream_create_with_args:
  444|  24.7k|{
  445|  24.7k|    mp_assert(args->url);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (445:5): [True: 24.7k, False: 0]
  ------------------
  446|       |
  447|  24.7k|    int r = STREAM_NO_MATCH;
  ------------------
  |  |   65|  24.7k|#define STREAM_NO_MATCH -2
  ------------------
  448|  24.7k|    *ret = NULL;
  449|       |
  450|       |    // Open stream proper
  451|  24.7k|    if (args->sinfo) {
  ------------------
  |  Branch (451:9): [True: 0, False: 24.7k]
  ------------------
  452|      0|        r = stream_create_instance(args->sinfo, args, ret);
  453|  24.7k|    } else {
  454|   272k|        for (int i = 0; i < MP_ARRAY_SIZE(stream_list); i++) {
  ------------------
  |  |   49|   272k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (454:25): [True: 272k, False: 0]
  ------------------
  455|   272k|            r = stream_create_instance(stream_list[i], args, ret);
  456|   272k|            if (r == STREAM_OK)
  ------------------
  |  |   68|   272k|#define STREAM_OK    1
  ------------------
  |  Branch (456:17): [True: 24.7k, False: 247k]
  ------------------
  457|  24.7k|                break;
  458|   247k|            if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   65|   495k|#define STREAM_NO_MATCH -2
  ------------------
                          if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   66|      0|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (458:17): [True: 247k, False: 0]
  |  Branch (458:41): [True: 0, False: 0]
  ------------------
  459|   247k|                continue;
  460|      0|            if (r == STREAM_UNSAFE)
  ------------------
  |  |   64|      0|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (460:17): [True: 0, False: 0]
  ------------------
  461|      0|                continue;
  462|      0|            break;
  463|      0|        }
  464|  24.7k|    }
  465|       |
  466|  24.7k|    if (!*ret && !(args->flags & STREAM_SILENT) && !mp_cancel_test(args->cancel))
  ------------------
  |  |   44|      0|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (466:9): [True: 0, False: 24.7k]
  |  Branch (466:18): [True: 0, False: 0]
  |  Branch (466:52): [True: 0, False: 0]
  ------------------
  467|      0|    {
  468|      0|        struct mp_log *log = mp_log_new(NULL, args->global->log, "!stream");
  469|       |
  470|      0|        if (r == STREAM_UNSAFE) {
  ------------------
  |  |   64|      0|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (470:13): [True: 0, False: 0]
  ------------------
  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|      0|        } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   65|      0|#define STREAM_NO_MATCH -2
  ------------------
                      } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   66|      0|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (473:20): [True: 0, False: 0]
  |  Branch (473:44): [True: 0, False: 0]
  ------------------
  474|      0|            mp_err(log, "No protocol handler found to open URL %s\n", args->url);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  475|      0|            mp_err(log, "The protocol is either unsupported, or was disabled "
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  476|      0|                        "at compile-time.\n");
  477|      0|        } else {
  478|      0|            mp_err(log, "Failed to open %s.\n", args->url);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  479|      0|        }
  480|       |
  481|      0|        talloc_free(log);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  482|      0|    }
  483|       |
  484|  24.7k|    return r;
  485|  24.7k|}
stream_create:
  489|  24.7k|{
  490|  24.7k|    struct stream_open_args args = {
  491|  24.7k|        .global = global,
  492|  24.7k|        .cancel = c,
  493|  24.7k|        .flags = flags,
  494|  24.7k|        .url = url,
  495|  24.7k|    };
  496|  24.7k|    struct stream *s;
  497|  24.7k|    stream_create_with_args(&args, &s);
  498|  24.7k|    return s;
  499|  24.7k|}
stream_read_partial:
  616|  1.16M|{
  617|  1.16M|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|  1.16M|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 1.16M, False: 0]
  ------------------
  618|  1.16M|    mp_assert(buf_size >= 0);
  ------------------
  |  |   41|  1.16M|#define mp_assert assert
  ------------------
  |  Branch (618:5): [True: 1.16M, False: 0]
  ------------------
  619|  1.16M|    if (s->buf_cur == s->buf_end && buf_size > 0) {
  ------------------
  |  Branch (619:9): [True: 68.9k, False: 1.09M]
  |  Branch (619:37): [True: 68.9k, False: 0]
  ------------------
  620|  68.9k|        if (buf_size > (s->buffer_mask + 1) / 2) {
  ------------------
  |  Branch (620:13): [True: 277, False: 68.7k]
  ------------------
  621|       |            // Direct read if the buffer is too small anyway.
  622|    277|            stream_drop_buffers(s);
  623|    277|            return stream_read_unbuffered(s, buf, buf_size);
  624|    277|        }
  625|  68.7k|        stream_read_more(s, 1);
  626|  68.7k|    }
  627|  1.16M|    int res = ring_copy(s, buf, buf_size, s->buf_cur);
  628|  1.16M|    s->buf_cur += res;
  629|  1.16M|    return res;
  630|  1.16M|}
stream_read_char_fallback:
  634|  61.9k|{
  635|  61.9k|    uint8_t c;
  636|  61.9k|    return stream_read_partial(s, &c, 1) ? c : STREAM_EOF;
  ------------------
  |  |   71|  61.5k|#define STREAM_EOF (-256)
  ------------------
  |  Branch (636:12): [True: 422, False: 61.5k]
  ------------------
  637|  61.9k|}
stream_read:
  640|  1.43M|{
  641|  1.43M|    int len = total;
  642|  2.52M|    while (len > 0) {
  ------------------
  |  Branch (642:12): [True: 1.09M, False: 1.42M]
  ------------------
  643|  1.09M|        int read = stream_read_partial(s, mem, len);
  644|  1.09M|        if (read <= 0)
  ------------------
  |  Branch (644:13): [True: 6.99k, False: 1.09M]
  ------------------
  645|  6.99k|            break; // EOF
  646|  1.09M|        mem = (char *)mem + read;
  647|  1.09M|        len -= read;
  648|  1.09M|    }
  649|  1.43M|    total -= len;
  650|  1.43M|    return total;
  651|  1.43M|}
stream_peek:
  656|   219k|{
  657|   244k|    while (stream_read_more(s, forward_size)) {}
  ------------------
  |  Branch (657:12): [True: 24.7k, False: 219k]
  ------------------
  658|   219k|    return s->buf_end - s->buf_cur;
  659|   219k|}
stream_read_peek:
  664|   219k|{
  665|   219k|    stream_peek(s, buf_size);
  666|   219k|    return ring_copy(s, buf, buf_size, s->buf_cur);
  667|   219k|}
stream_drop_buffers:
  708|  2.78k|{
  709|  2.78k|    s->pos = stream_tell(s);
  710|  2.78k|    s->buf_start = s->buf_cur = s->buf_end = 0;
  711|  2.78k|    s->eof = 0;
  712|  2.78k|    stream_resize_buffer(s, 0, 0);
  713|  2.78k|}
stream_seek:
  754|   848k|{
  755|   848k|    MP_TRACE(s, "seek request from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   94|   848k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   848k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  756|   848k|             stream_tell(s), pos);
  757|       |
  758|   848k|    s->eof = 0; // eof should be set only on read; seeking always clears it
  759|       |
  760|   848k|    if (pos < 0) {
  ------------------
  |  Branch (760:9): [True: 1, False: 848k]
  ------------------
  761|      1|        MP_ERR(s, "Invalid seek to negative position %lld!\n", (long long)pos);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  762|      1|        pos = 0;
  763|      1|    }
  764|       |
  765|   848k|    if (pos <= s->pos) {
  ------------------
  |  Branch (765:9): [True: 816k, False: 32.5k]
  ------------------
  766|   816k|        int64_t x = pos - (s->pos - (int)s->buf_end);
  767|   816k|        if (x >= (int)s->buf_start) {
  ------------------
  |  Branch (767:13): [True: 815k, False: 422]
  ------------------
  768|   815k|            s->buf_cur = x;
  769|   815k|            mp_assert(s->buf_cur >= s->buf_start);
  ------------------
  |  |   41|   815k|#define mp_assert assert
  ------------------
  |  Branch (769:13): [True: 815k, False: 0]
  ------------------
  770|   815k|            mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   815k|#define mp_assert assert
  ------------------
  |  Branch (770:13): [True: 815k, False: 0]
  ------------------
  771|   815k|            return true;
  772|   815k|        }
  773|   816k|    }
  774|       |
  775|  32.9k|    if (s->mode == STREAM_WRITE)
  ------------------
  |  |   42|  32.9k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (775:9): [True: 0, False: 32.9k]
  ------------------
  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|  32.9k|    if (pos >= s->pos &&
  ------------------
  |  Branch (779:9): [True: 32.5k, False: 422]
  ------------------
  780|  32.5k|        ((!s->seekable && s->fast_skip) ||
  ------------------
  |  Branch (780:11): [True: 0, False: 32.5k]
  |  Branch (780:27): [True: 0, False: 0]
  ------------------
  781|  32.5k|         pos - s->pos <= s->requested_buffer_size))
  ------------------
  |  Branch (781:10): [True: 30.4k, False: 2.08k]
  ------------------
  782|  30.4k|    {
  783|  30.4k|        return stream_skip_read(s, pos - stream_tell(s));
  784|  30.4k|    }
  785|       |
  786|  2.51k|    return stream_seek_unbuffered(s, pos);
  787|  32.9k|}
stream_seek_skip:
  792|  1.09M|{
  793|  1.09M|    uint64_t cur_pos = stream_tell(s);
  794|       |
  795|  1.09M|    if (cur_pos == pos)
  ------------------
  |  Branch (795:9): [True: 628k, False: 463k]
  ------------------
  796|   628k|        return true;
  797|       |
  798|   463k|    return !s->seekable && pos > cur_pos
  ------------------
  |  Branch (798:12): [True: 0, False: 463k]
  |  Branch (798:28): [True: 0, False: 0]
  ------------------
  799|   463k|        ? stream_skip_read(s, pos - cur_pos)
  800|   463k|        : stream_seek(s, pos);
  801|  1.09M|}
stream_control:
  804|   805k|{
  805|   805k|    return s->control ? s->control(s, cmd, arg) : STREAM_UNSUPPORTED;
  ------------------
  |  |   66|   805k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (805:12): [True: 0, False: 805k]
  ------------------
  806|   805k|}
stream_get_size:
  810|  48.5k|{
  811|  48.5k|    return s->get_size ? s->get_size(s) : -1;
  ------------------
  |  Branch (811:12): [True: 48.5k, False: 0]
  ------------------
  812|  48.5k|}
free_stream:
  815|  25.5k|{
  816|  25.5k|    if (!s)
  ------------------
  |  Branch (816:9): [True: 782, False: 24.7k]
  ------------------
  817|    782|        return;
  818|       |
  819|  24.7k|    if (s->close)
  ------------------
  |  Branch (819:9): [True: 24.7k, False: 0]
  ------------------
  820|  24.7k|        s->close(s);
  821|  24.7k|    talloc_free(s);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  822|  24.7k|}
stream.c:stream_create_instance:
  337|   272k|{
  338|   272k|    const char *url = args->url;
  339|   272k|    int flags = args->flags;
  340|       |
  341|   272k|    *ret = NULL;
  342|       |
  343|   272k|    const char *path = url;
  344|       |
  345|   272k|    if (flags & STREAM_LOCAL_FS_ONLY) {
  ------------------
  |  |   54|   272k|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  ------------------
  |  Branch (345:9): [True: 0, False: 272k]
  ------------------
  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|   272k|    } else {
  349|   272k|        char **get_protocols = sinfo->get_protocols ? sinfo->get_protocols() : NULL;
  ------------------
  |  Branch (349:32): [True: 0, False: 272k]
  ------------------
  350|   272k|        char **protocols = get_protocols ? get_protocols : (char **)sinfo->protocols;
  ------------------
  |  Branch (350:28): [True: 0, False: 272k]
  ------------------
  351|       |
  352|   618k|        for (int n = 0; protocols && protocols[n]; n++) {
  ------------------
  |  Branch (352:25): [True: 618k, False: 0]
  |  Branch (352:38): [True: 371k, False: 247k]
  ------------------
  353|   371k|            path = match_proto(url, protocols[n]);
  354|   371k|            if (path)
  ------------------
  |  Branch (354:17): [True: 24.7k, False: 346k]
  ------------------
  355|  24.7k|                break;
  356|   371k|        }
  357|       |
  358|   272k|        talloc_free(get_protocols);
  ------------------
  |  |   47|   272k|#define talloc_free                     ta_free
  ------------------
  359|       |
  360|   272k|        if (!path)
  ------------------
  |  Branch (360:13): [True: 247k, False: 24.7k]
  ------------------
  361|   247k|            return STREAM_NO_MATCH;
  ------------------
  |  |   65|   247k|#define STREAM_NO_MATCH -2
  ------------------
  362|   272k|    }
  363|       |
  364|  24.7k|    stream_t *s = talloc_zero(NULL, stream_t);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|  24.7k|    s->global = args->global;
  366|  24.7k|    struct stream_opts *opts = mp_get_config_group(s, s->global, &stream_conf);
  367|  24.7k|    if (flags & STREAM_SILENT) {
  ------------------
  |  |   44|  24.7k|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (367:9): [True: 0, False: 24.7k]
  ------------------
  368|      0|        s->log = mp_null_log;
  369|  24.7k|    } else {
  370|  24.7k|        s->log = mp_log_new(s, s->global->log, sinfo->name);
  371|  24.7k|    }
  372|  24.7k|    s->info = sinfo;
  373|  24.7k|    s->autoprobed = !args->sinfo;
  374|  24.7k|    s->cancel = args->cancel;
  375|  24.7k|    s->url = talloc_strdup(s, url);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
  376|  24.7k|    s->path = talloc_strdup(s, path);
  ------------------
  |  |   50|  24.7k|#define talloc_strdup                   ta_xstrdup
  ------------------
  377|  24.7k|    s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   41|  24.7k|#define STREAM_READ               0
  ------------------
                  s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   42|  24.7k|#define STREAM_WRITE              (1 << 0)
  ------------------
  378|  24.7k|    s->requested_buffer_size = opts->buffer_size;
  379|  24.7k|    s->allow_partial_read = flags & STREAM_ALLOW_PARTIAL_READ;
  ------------------
  |  |   56|  24.7k|#define STREAM_ALLOW_PARTIAL_READ (1 << 7) // allows partial read with stream_read_file()
  ------------------
  380|       |
  381|  24.7k|    if (flags & STREAM_LESS_NOISE)
  ------------------
  |  |   55|  24.7k|#define STREAM_LESS_NOISE         (1 << 6) // try to log errors only
  ------------------
  |  Branch (381:9): [True: 0, False: 24.7k]
  ------------------
  382|      0|        mp_msg_set_max_level(s->log, MSGL_WARN);
  383|       |
  384|  24.7k|    struct demux_opts *demux_opts = mp_get_config_group(s, s->global, &demux_conf);
  385|  24.7k|    s->access_references = demux_opts->access_references;
  386|  24.7k|    talloc_free(demux_opts);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  387|       |
  388|  24.7k|    MP_VERBOSE(s, "Opening %s\n", url);
  ------------------
  |  |   92|  24.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  389|       |
  390|  24.7k|    if (strlen(url) > INT_MAX / 8) {
  ------------------
  |  Branch (390:9): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    if ((s->mode & STREAM_WRITE) && !sinfo->can_write) {
  ------------------
  |  |   42|  24.7k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (396:9): [True: 0, False: 24.7k]
  |  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|  24.7k|    s->stream_origin = flags & STREAM_ORIGIN_MASK; // pass through by default
  ------------------
  |  |   52|  24.7k|#define STREAM_ORIGIN_MASK        (7 << 2) // for extracting origin value from flags
  ------------------
  403|  24.7k|    if (opts->load_unsafe_playlists) {
  ------------------
  |  Branch (403:9): [True: 0, False: 24.7k]
  ------------------
  404|      0|        s->stream_origin = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|      0|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  405|  24.7k|    } else if (sinfo->stream_origin) {
  ------------------
  |  Branch (405:16): [True: 24.7k, False: 0]
  ------------------
  406|  24.7k|        s->stream_origin = check_origin(s->stream_origin, sinfo->stream_origin);
  407|  24.7k|    }
  408|       |
  409|  24.7k|    if (!s->stream_origin) {
  ------------------
  |  Branch (409:9): [True: 0, False: 24.7k]
  ------------------
  410|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  411|      0|        return STREAM_UNSAFE;
  ------------------
  |  |   64|      0|#define STREAM_UNSAFE -3
  ------------------
  412|      0|    }
  413|       |
  414|  24.7k|    int r = STREAM_UNSUPPORTED;
  ------------------
  |  |   66|  24.7k|#define STREAM_UNSUPPORTED -1
  ------------------
  415|  24.7k|    if (sinfo->open2) {
  ------------------
  |  Branch (415:9): [True: 24.7k, False: 0]
  ------------------
  416|  24.7k|        r = sinfo->open2(s, args);
  417|  24.7k|    } else if (!args->special_arg) {
  ------------------
  |  Branch (417:16): [True: 0, False: 0]
  ------------------
  418|      0|        r = (sinfo->open)(s);
  419|      0|    }
  420|  24.7k|    if (r != STREAM_OK) {
  ------------------
  |  |   68|  24.7k|#define STREAM_OK    1
  ------------------
  |  Branch (420:9): [True: 0, False: 24.7k]
  ------------------
  421|      0|        talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  422|      0|        return r;
  423|      0|    }
  424|       |
  425|  24.7k|    if (!stream_resize_buffer(s, 0, 0)) {
  ------------------
  |  Branch (425:9): [True: 0, False: 24.7k]
  ------------------
  426|      0|        free_stream(s);
  427|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  428|      0|    }
  429|       |
  430|  24.7k|    mp_assert(s->seekable == !!s->seek);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 24.7k, False: 0]
  ------------------
  431|       |
  432|  24.7k|    if (s->mime_type)
  ------------------
  |  Branch (432:9): [True: 0, False: 24.7k]
  ------------------
  433|  24.7k|        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|  24.7k|    if (s->server_filename)
  ------------------
  |  Branch (434:9): [True: 0, False: 24.7k]
  ------------------
  435|  24.7k|        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|  24.7k|    MP_DBG(s, "Stream opened successfully.\n");
  ------------------
  |  |   93|  24.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|  24.7k|    *ret = s;
  440|  24.7k|    return STREAM_OK;
  ------------------
  |  |   68|  24.7k|#define STREAM_OK    1
  ------------------
  441|  24.7k|}
stream.c:match_proto:
  219|   371k|{
  220|   371k|    int l = strlen(proto);
  221|   371k|    if (l > 0) {
  ------------------
  |  Branch (221:9): [True: 346k, False: 24.7k]
  ------------------
  222|   346k|        if (strncasecmp(url, proto, l) == 0 && strncmp("://", url + l, 3) == 0)
  ------------------
  |  Branch (222:13): [True: 24.7k, False: 321k]
  |  Branch (222:48): [True: 24.7k, False: 0]
  ------------------
  223|  24.7k|            return url + l + 3;
  224|   346k|    } else if (!mp_is_url(bstr0(url))) {
  ------------------
  |  Branch (224:16): [True: 0, False: 24.7k]
  ------------------
  225|      0|        return url; // pure filenames
  226|      0|    }
  227|   346k|    return NULL;
  228|   371k|}
stream.c:check_origin:
  234|  24.7k|{
  235|  24.7k|    switch (src) {
  ------------------
  |  Branch (235:13): [True: 24.7k, False: 0]
  ------------------
  236|  24.7k|    case STREAM_ORIGIN_DIRECT:
  ------------------
  |  |   47|  24.7k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  |  Branch (236:5): [True: 24.7k, False: 0]
  ------------------
  237|  24.7k|    case STREAM_ORIGIN_UNSAFE:
  ------------------
  |  |   50|  24.7k|#define STREAM_ORIGIN_UNSAFE      (4 << 2) // from a grotesque source
  ------------------
  |  Branch (237:5): [True: 0, False: 24.7k]
  ------------------
  238|       |        // Allow anything, but constrain it to the new origin.
  239|  24.7k|        return new;
  240|      0|    case STREAM_ORIGIN_FS:
  ------------------
  |  |   48|      0|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
  |  Branch (240:5): [True: 0, False: 24.7k]
  ------------------
  241|       |        // From unix FS, allow all but unsafe.
  242|      0|        if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   48|      0|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
                      if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|      0|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (242:13): [True: 0, False: 0]
  |  Branch (242:40): [True: 0, False: 0]
  ------------------
  243|      0|            return new;
  244|      0|        break;
  245|      0|    case STREAM_ORIGIN_NET:
  ------------------
  |  |   49|      0|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (245:5): [True: 0, False: 24.7k]
  ------------------
  246|       |        // Allow only other network links.
  247|      0|        if (new == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|      0|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (247:13): [True: 0, False: 0]
  ------------------
  248|      0|            return new;
  249|      0|        break;
  250|  24.7k|    }
  251|      0|    return 0;
  252|  24.7k|}
stream.c:stream_read_unbuffered:
  517|   124k|{
  518|   124k|    mp_assert(len >= 0);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (518:5): [True: 124k, False: 0]
  ------------------
  519|   124k|    if (len <= 0)
  ------------------
  |  Branch (519:9): [True: 0, False: 124k]
  ------------------
  520|      0|        return 0;
  521|       |
  522|   124k|    int res = 0;
  523|       |    // we will retry even if we already reached EOF previously.
  524|   124k|    if (s->fill_buffer && !mp_cancel_test(s->cancel))
  ------------------
  |  Branch (524:9): [True: 124k, False: 0]
  |  Branch (524:27): [True: 124k, False: 0]
  ------------------
  525|   124k|        res = s->fill_buffer(s, buf, len);
  526|   124k|    if (res <= 0) {
  ------------------
  |  Branch (526:9): [True: 99.2k, False: 25.1k]
  ------------------
  527|  99.2k|        s->eof = 1;
  528|  99.2k|        return 0;
  529|  99.2k|    }
  530|  25.1k|    mp_assert(res <= len);
  ------------------
  |  |   41|  25.1k|#define mp_assert assert
  ------------------
  |  Branch (530:5): [True: 25.1k, False: 0]
  ------------------
  531|       |    // When reading succeeded we are obviously not at eof.
  532|  25.1k|    s->eof = 0;
  533|  25.1k|    s->pos += res;
  534|  25.1k|    s->total_unbuffered_read_bytes += res;
  535|  25.1k|    return res;
  536|  25.1k|}
stream.c:stream_read_more:
  543|   343k|{
  544|   343k|    mp_assert(forward >= 0);
  ------------------
  |  |   41|   343k|#define mp_assert assert
  ------------------
  |  Branch (544:5): [True: 343k, False: 0]
  ------------------
  545|       |
  546|   343k|    int forward_avail = s->buf_end - s->buf_cur;
  547|   343k|    if (forward_avail >= forward)
  ------------------
  |  Branch (547:9): [True: 219k, False: 124k]
  ------------------
  548|   219k|        return false;
  549|       |
  550|       |    // Avoid that many small reads will lead to many low-level read calls.
  551|   124k|    forward = MPMAX(forward, s->requested_buffer_size / 2);
  ------------------
  |  |   44|   124k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 124k]
  |  |  ------------------
  ------------------
  552|   124k|    mp_assert(forward_avail < forward);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (552:5): [True: 124k, False: 0]
  ------------------
  553|       |
  554|       |    // Keep guaranteed seek-back.
  555|   124k|    int buf_old = MPMIN(s->buf_cur - s->buf_start, s->requested_buffer_size / 2);
  ------------------
  |  |   45|   124k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 7.36k, False: 116k]
  |  |  ------------------
  ------------------
  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|   124k|    int new_size = MPMAX(buf_old + forward, s->buffer_mask + 1);
  ------------------
  |  |   44|   124k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 124k]
  |  |  ------------------
  ------------------
  561|       |
  562|   124k|    if (!stream_resize_buffer(s, buf_old + forward_avail, new_size))
  ------------------
  |  Branch (562:9): [True: 0, False: 124k]
  ------------------
  563|      0|        return false;
  564|       |
  565|   124k|    int buf_alloc = s->buffer_mask + 1;
  566|       |
  567|   124k|    mp_assert(s->buf_start <= s->buf_cur);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (567:5): [True: 124k, False: 0]
  ------------------
  568|   124k|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (568:5): [True: 124k, False: 0]
  ------------------
  569|   124k|    mp_assert(s->buf_cur < buf_alloc * 2);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (569:5): [True: 124k, False: 0]
  ------------------
  570|   124k|    mp_assert(s->buf_end < buf_alloc * 2);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (570:5): [True: 124k, False: 0]
  ------------------
  571|   124k|    mp_assert(s->buf_start < buf_alloc);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (571:5): [True: 124k, 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|   124k|    int read = buf_alloc - (buf_old + forward_avail); // free buffer past end
  577|       |
  578|   124k|    int pos = s->buf_end & s->buffer_mask;
  579|   124k|    read = MPMIN(read, buf_alloc - pos);
  ------------------
  |  |   45|   124k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 7.36k, False: 116k]
  |  |  ------------------
  ------------------
  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|   124k|    read = stream_read_unbuffered(s, &s->buffer[pos], read);
  585|       |
  586|   124k|    s->buf_end += read;
  587|       |
  588|       |    // May have overwritten old data.
  589|   124k|    if (s->buf_end - s->buf_start >= buf_alloc) {
  ------------------
  |  Branch (589:9): [True: 0, False: 124k]
  ------------------
  590|      0|        mp_assert(s->buf_end >= buf_alloc);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (590:9): [True: 0, False: 0]
  ------------------
  591|       |
  592|      0|        s->buf_start = s->buf_end - buf_alloc;
  593|       |
  594|      0|        mp_assert(s->buf_start <= s->buf_cur);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (594:9): [True: 0, False: 0]
  ------------------
  595|      0|        mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (595:9): [True: 0, False: 0]
  ------------------
  596|       |
  597|      0|        if (s->buf_start >= buf_alloc) {
  ------------------
  |  Branch (597:13): [True: 0, False: 0]
  ------------------
  598|      0|            s->buf_start -= buf_alloc;
  599|      0|            s->buf_cur -= buf_alloc;
  600|      0|            s->buf_end -= buf_alloc;
  601|      0|        }
  602|      0|    }
  603|       |
  604|       |    // Must not have overwritten guaranteed old data.
  605|   124k|    mp_assert(s->buf_cur - s->buf_start >= buf_old);
  ------------------
  |  |   41|   124k|#define mp_assert assert
  ------------------
  |  Branch (605:5): [True: 124k, False: 0]
  ------------------
  606|       |
  607|   124k|    if (s->buf_cur < s->buf_end)
  ------------------
  |  Branch (607:9): [True: 25.1k, False: 98.9k]
  ------------------
  608|  25.1k|        s->eof = 0;
  609|       |
  610|   124k|    return !!read;
  611|   124k|}
stream.c:ring_copy:
  260|  1.38M|{
  261|  1.38M|    mp_assert(len >= 0);
  ------------------
  |  |   41|  1.38M|#define mp_assert assert
  ------------------
  |  Branch (261:5): [True: 1.38M, False: 0]
  ------------------
  262|       |
  263|  1.38M|    if (pos < s->buf_start || pos > s->buf_end)
  ------------------
  |  Branch (263:9): [True: 0, False: 1.38M]
  |  Branch (263:31): [True: 0, False: 1.38M]
  ------------------
  264|      0|        return 0;
  265|       |
  266|  1.38M|    int copied = 0;
  267|  1.38M|    len = MPMIN(len, s->buf_end - pos);
  ------------------
  |  |   45|  1.38M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 75.2k, False: 1.30M]
  |  |  ------------------
  ------------------
  268|       |
  269|  1.38M|    if (len && pos <= s->buffer_mask) {
  ------------------
  |  Branch (269:9): [True: 1.31M, False: 68.5k]
  |  Branch (269:16): [True: 1.31M, False: 0]
  ------------------
  270|  1.31M|        int copy = MPMIN(len, s->buffer_mask + 1 - pos);
  ------------------
  |  |   45|  1.31M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 1.31M]
  |  |  ------------------
  ------------------
  271|  1.31M|        memcpy(dst, &s->buffer[pos], copy);
  272|  1.31M|        copied += copy;
  273|  1.31M|        len -= copy;
  274|  1.31M|        pos += copy;
  275|  1.31M|    }
  276|       |
  277|  1.38M|    if (len) {
  ------------------
  |  Branch (277:9): [True: 0, False: 1.38M]
  ------------------
  278|      0|        memcpy((char *)dst + copied, &s->buffer[pos & s->buffer_mask], len);
  279|      0|        copied += len;
  280|      0|    }
  281|       |
  282|  1.38M|    return copied;
  283|  1.38M|}
stream.c:stream_resize_buffer:
  293|   151k|{
  294|   151k|    mp_assert(keep >= s->buf_end - s->buf_cur);
  ------------------
  |  |   41|   151k|#define mp_assert assert
  ------------------
  |  Branch (294:5): [True: 151k, False: 0]
  ------------------
  295|   151k|    mp_assert(keep <= new);
  ------------------
  |  |   41|   151k|#define mp_assert assert
  ------------------
  |  Branch (295:5): [True: 151k, False: 0]
  ------------------
  296|       |
  297|   151k|    new = MPMAX(new, s->requested_buffer_size);
  ------------------
  |  |   44|   151k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 151k]
  |  |  ------------------
  ------------------
  298|   151k|    new = MPMIN(new, STREAM_MAX_BUFFER_SIZE);
  ------------------
  |  |   45|   151k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 151k]
  |  |  ------------------
  ------------------
  299|   151k|    new = mp_round_next_power_of_2(new);
  300|       |
  301|   151k|    mp_assert(keep <= new); // can't fail (if old buffer size was valid)
  ------------------
  |  |   41|   151k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 151k, False: 0]
  ------------------
  302|       |
  303|   151k|    if (new == s->buffer_mask + 1)
  ------------------
  |  Branch (303:9): [True: 126k, False: 24.7k]
  ------------------
  304|   126k|        return true;
  305|       |
  306|  24.7k|    int old_pos = s->buf_cur - s->buf_start;
  307|  24.7k|    int old_used_len = s->buf_end - s->buf_start;
  308|  24.7k|    int skip = old_used_len > new ? old_used_len - new : 0;
  ------------------
  |  Branch (308:16): [True: 0, False: 24.7k]
  ------------------
  309|       |
  310|  24.7k|    MP_DBG(s, "resize stream to %d bytes, drop %d bytes\n", new, skip);
  ------------------
  |  |   93|  24.7k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  311|       |
  312|  24.7k|    void *nbuf = ta_alloc_size(s, new);
  ------------------
  |  |  153|  24.7k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  ------------------
  |  |  |  |   43|  24.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  24.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   37|  24.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|  24.7k|    if (!nbuf)
  ------------------
  |  Branch (313:9): [True: 0, False: 24.7k]
  ------------------
  314|      0|        return false; // oom; tolerate it, caller needs to check if required
  315|       |
  316|  24.7k|    int new_len = 0;
  317|  24.7k|    if (s->buffer)
  ------------------
  |  Branch (317:9): [True: 0, False: 24.7k]
  ------------------
  318|      0|        new_len = ring_copy(s, nbuf, new, s->buf_start + skip);
  319|  24.7k|    mp_assert(new_len == old_used_len - skip);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (319:5): [True: 24.7k, False: 0]
  ------------------
  320|  24.7k|    mp_assert(old_pos >= skip); // "keep" too low
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (320:5): [True: 24.7k, False: 0]
  ------------------
  321|  24.7k|    mp_assert(old_pos - skip <= new_len);
  ------------------
  |  |   41|  24.7k|#define mp_assert assert
  ------------------
  |  Branch (321:5): [True: 24.7k, False: 0]
  ------------------
  322|  24.7k|    s->buf_start = 0;
  323|  24.7k|    s->buf_cur = old_pos - skip;
  324|  24.7k|    s->buf_end = new_len;
  325|       |
  326|  24.7k|    ta_free(s->buffer);
  327|       |
  328|  24.7k|    s->buffer = nbuf;
  329|  24.7k|    s->buffer_mask = new - 1;
  330|       |
  331|       |    return true;
  332|  24.7k|}
stream.c:stream_skip_read:
  689|  30.4k|{
  690|  55.8k|    while (len > 0) {
  ------------------
  |  Branch (690:12): [True: 55.8k, False: 0]
  ------------------
  691|  55.8k|        unsigned int left = s->buf_end - s->buf_cur;
  692|  55.8k|        if (!left) {
  ------------------
  |  Branch (692:13): [True: 30.4k, False: 25.3k]
  ------------------
  693|  30.4k|            if (!stream_read_more(s, 1))
  ------------------
  |  Branch (693:17): [True: 30.4k, False: 0]
  ------------------
  694|  30.4k|                return false;
  695|      0|            continue;
  696|  30.4k|        }
  697|  25.3k|        unsigned skip = MPMIN(len, left);
  ------------------
  |  |   45|  25.3k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 25.3k, False: 0]
  |  |  ------------------
  ------------------
  698|  25.3k|        s->buf_cur += skip;
  699|  25.3k|        len -= skip;
  700|  25.3k|    }
  701|      0|    return true;
  702|  30.4k|}
stream.c:stream_seek_unbuffered:
  726|  2.51k|{
  727|  2.51k|    if (newpos != s->pos) {
  ------------------
  |  Branch (727:9): [True: 2.51k, False: 0]
  ------------------
  728|  2.51k|        MP_VERBOSE(s, "stream level seek from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   92|  2.51k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.51k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  729|  2.51k|                   s->pos, newpos);
  730|       |
  731|  2.51k|        s->total_stream_seeks++;
  732|       |
  733|  2.51k|        if (newpos > s->pos && !s->seekable) {
  ------------------
  |  Branch (733:13): [True: 2.08k, False: 422]
  |  Branch (733:32): [True: 0, False: 2.08k]
  ------------------
  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|  2.51k|        if (newpos < s->pos && !s->seekable) {
  ------------------
  |  Branch (737:13): [True: 422, False: 2.08k]
  |  Branch (737:32): [True: 0, False: 422]
  ------------------
  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|  2.51k|        if (s->seek(s, newpos) <= 0) {
  ------------------
  |  Branch (741:13): [True: 0, False: 2.51k]
  ------------------
  742|      0|            int level = mp_cancel_test(s->cancel) ? MSGL_V : MSGL_ERR;
  ------------------
  |  Branch (742:25): [True: 0, False: 0]
  ------------------
  743|      0|            MP_MSG(s, level, "Seek failed (to %lld, size %lld)\n",
  ------------------
  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  744|      0|                   (long long)newpos, (long long)stream_get_size(s));
  745|      0|            return false;
  746|      0|        }
  747|  2.51k|        stream_drop_buffers(s);
  748|  2.51k|        s->pos = newpos;
  749|  2.51k|    }
  750|  2.51k|    return true;
  751|  2.51k|}

stream.c:stream_tell:
  389|  1.97M|{
  390|  1.97M|    return s->pos + s->buf_cur - s->buf_end;
  391|  1.97M|}
demux_mkv.c:stream_tell:
  389|  16.9M|{
  390|  16.9M|    return s->pos + s->buf_cur - s->buf_end;
  391|  16.9M|}
demux_mkv.c:stream_read_char:
  380|  2.04M|{
  381|  2.04M|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 2.04M, False: 366]
  ------------------
  382|  2.04M|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  2.04M|        : stream_read_char_fallback(s);
  384|  2.04M|}
ebml.c:stream_read_char:
  380|   160M|{
  381|   160M|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 160M, False: 61.6k]
  ------------------
  382|   160M|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|   160M|        : stream_read_char_fallback(s);
  384|   160M|}
ebml.c:stream_tell:
  389|  1.32M|{
  390|  1.32M|    return s->pos + s->buf_cur - s->buf_end;
  391|  1.32M|}

mp_file_url_to_filename:
  176|  49.5k|{
  177|  49.5k|    bstr proto = mp_split_proto(url, &url);
  178|  49.5k|    if (bstrcasecmp0(proto, "file") != 0)
  ------------------
  |  Branch (178:9): [True: 49.5k, False: 0]
  ------------------
  179|  49.5k|        return NULL;
  180|      0|    char *filename = bstrto0(talloc_ctx, url);
  181|      0|    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|      0|    return filename;
  188|  49.5k|}
stream_file.c:open_f:
  277|  24.7k|{
  278|  24.7k|    struct priv *p = talloc_ptrtype(stream, p);
  ------------------
  |  |   34|  24.7k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.7k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|  24.7k|    *p = (struct priv) {
  280|  24.7k|        .fd = -1,
  281|  24.7k|    };
  282|  24.7k|    stream->priv = p;
  283|  24.7k|    stream->is_local_fs = true;
  284|       |
  285|  24.7k|    bool strict_fs = args->flags & STREAM_LOCAL_FS_ONLY;
  ------------------
  |  |   54|  24.7k|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  ------------------
  286|  24.7k|    bool write = stream->mode == STREAM_WRITE;
  ------------------
  |  |   42|  24.7k|#define STREAM_WRITE              (1 << 0)
  ------------------
  287|  24.7k|    int m = O_CLOEXEC | (write ? O_RDWR | O_CREAT | O_TRUNC : O_RDONLY);
  ------------------
  |  Branch (287:26): [True: 0, False: 24.7k]
  ------------------
  288|       |
  289|  24.7k|    char *filename = stream->path;
  290|  24.7k|    char *url = "";
  291|  24.7k|    if (!strict_fs) {
  ------------------
  |  Branch (291:9): [True: 24.7k, False: 0]
  ------------------
  292|  24.7k|        char *fn = mp_file_url_to_filename(stream, bstr0(stream->url));
  293|  24.7k|        if (fn)
  ------------------
  |  Branch (293:13): [True: 0, False: 24.7k]
  ------------------
  294|      0|            filename = stream->path = fn;
  295|  24.7k|        url = stream->url;
  296|  24.7k|    }
  297|       |
  298|  24.7k|    bool is_fdclose = strncmp(url, "fdclose://", 10) == 0;
  299|  24.7k|    if (strncmp(url, "fd://", 5) == 0 || is_fdclose) {
  ------------------
  |  Branch (299:9): [True: 24.7k, False: 0]
  |  Branch (299:42): [True: 0, False: 0]
  ------------------
  300|  24.7k|        stream->is_local_fs = false;
  301|  24.7k|        char *begin = strstr(stream->url, "://") + 3, *end = NULL;
  302|  24.7k|        p->fd = strtol(begin, &end, 0);
  303|  24.7k|        if (end == begin || end[0] || p->fd < 0) {
  ------------------
  |  Branch (303:13): [True: 0, False: 24.7k]
  |  Branch (303:29): [True: 0, False: 24.7k]
  |  Branch (303:39): [True: 0, False: 24.7k]
  ------------------
  304|      0|            MP_ERR(stream, "Invalid FD number: %s\n", stream->url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  305|      0|            return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  306|      0|        }
  307|  24.7k|#ifdef F_SETFD
  308|  24.7k|        if (fcntl(p->fd, F_GETFD) == -1) {
  ------------------
  |  Branch (308:13): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|#endif
  313|  24.7k|        if (is_fdclose)
  ------------------
  |  Branch (313:13): [True: 0, False: 24.7k]
  ------------------
  314|      0|            p->close = true;
  315|  24.7k|    } else if (!strict_fs && !strcmp(filename, "-")) {
  ------------------
  |  Branch (315:16): [True: 0, False: 0]
  |  Branch (315:30): [True: 0, False: 0]
  ------------------
  316|      0|        stream->is_local_fs = false;
  317|      0|        if (!write) {
  ------------------
  |  Branch (317:13): [True: 0, False: 0]
  ------------------
  318|      0|            MP_INFO(stream, "Reading from stdin...\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__)
  |  |  ------------------
  ------------------
  319|      0|            p->fd = 0;
  320|      0|        } 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|      0|    } else {
  325|      0|        if (bstr_startswith0(bstr0(stream->url), "appending://"))
  ------------------
  |  Branch (325:13): [True: 0, False: 0]
  ------------------
  326|      0|            p->appending = true;
  327|       |
  328|      0|        mode_t openmode = S_IRUSR | S_IWUSR;
  329|      0|#ifndef __MINGW32__
  330|      0|        openmode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
  331|      0|        if (!write)
  ------------------
  |  Branch (331:13): [True: 0, False: 0]
  ------------------
  332|      0|            m |= O_NONBLOCK;
  333|      0|#endif
  334|      0|        p->fd = open(filename, m | O_BINARY, openmode);
  ------------------
  |  |  269|      0|#define open(...) mp_open(__VA_ARGS__)
  ------------------
  335|      0|        if (p->fd < 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 0]
  ------------------
  336|      0|            MP_ERR(stream, "Cannot open file '%s': %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__)
  |  |  ------------------
  ------------------
  337|      0|                   filename, mp_strerror(errno));
  338|      0|            return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  339|      0|        }
  340|      0|        p->close = true;
  341|      0|    }
  342|       |
  343|  24.7k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  344|  24.7k|    if (is_fdclose)
  ------------------
  |  Branch (344:9): [True: 0, False: 24.7k]
  ------------------
  345|      0|        p->close = false;
  346|  24.7k|    if (p->fd != 42) {
  ------------------
  |  Branch (346:9): [True: 0, False: 24.7k]
  ------------------
  347|      0|        s_close(stream);
  348|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  349|      0|    }
  350|  24.7k|#endif
  351|       |
  352|  24.7k|    struct stat st;
  353|  24.7k|    bool is_sock_or_fifo = false;
  354|  24.7k|    if (fstat(p->fd, &st) == 0) {
  ------------------
  |  Branch (354:9): [True: 24.7k, False: 0]
  ------------------
  355|  24.7k|        if (S_ISDIR(st.st_mode)) {
  ------------------
  |  Branch (355:13): [True: 0, False: 24.7k]
  ------------------
  356|      0|            stream->is_directory = true;
  357|  24.7k|        } else if (S_ISREG(st.st_mode)) {
  ------------------
  |  Branch (357:20): [True: 24.7k, False: 0]
  ------------------
  358|  24.7k|            p->regular_file = true;
  359|  24.7k|            stream->is_regular = true;
  360|  24.7k|#ifndef _WIN32
  361|       |            // O_NONBLOCK has weird semantics on file locks; remove it.
  362|  24.7k|            int val = fcntl(p->fd, F_GETFL) & ~(unsigned)O_NONBLOCK;
  363|  24.7k|            fcntl(p->fd, F_SETFL, val);
  364|  24.7k|#endif
  365|  24.7k|        } 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|  24.7k|    }
  372|       |
  373|       |#ifdef _WIN32
  374|       |    setmode(p->fd, O_BINARY);
  375|       |#endif
  376|       |
  377|  24.7k|    off_t len = lseek(p->fd, 0, SEEK_END);
  378|  24.7k|    lseek(p->fd, 0, SEEK_SET);
  379|  24.7k|    if (len != (off_t)-1) {
  ------------------
  |  Branch (379:9): [True: 24.7k, False: 0]
  ------------------
  380|  24.7k|        stream->seek = seek;
  381|  24.7k|        stream->seekable = true;
  382|  24.7k|    }
  383|       |
  384|  24.7k|    stream->fast_skip = true;
  385|  24.7k|    stream->fill_buffer = fill_buffer;
  386|  24.7k|    stream->write_buffer = write_buffer;
  387|  24.7k|    stream->get_size = get_size;
  388|  24.7k|    stream->close = s_close;
  389|       |
  390|  24.7k|    if (is_sock_or_fifo || check_stream_network(p->fd)) {
  ------------------
  |  Branch (390:9): [True: 0, False: 24.7k]
  |  Branch (390:28): [True: 0, False: 24.7k]
  ------------------
  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|  24.7k|    p->orig_size = get_size(stream);
  401|       |
  402|  24.7k|    p->cancel = mp_cancel_new(p);
  403|  24.7k|    if (stream->cancel)
  ------------------
  |  Branch (403:9): [True: 24.7k, False: 0]
  ------------------
  404|  24.7k|        mp_cancel_set_parent(p->cancel, stream->cancel);
  405|       |
  406|  24.7k|    return STREAM_OK;
  ------------------
  |  |   68|  24.7k|#define STREAM_OK    1
  ------------------
  407|  24.7k|}
stream_file.c:s_close:
  168|  24.7k|{
  169|  24.7k|    struct priv *p = s->priv;
  170|  24.7k|    if (p->close)
  ------------------
  |  Branch (170:9): [True: 0, False: 24.7k]
  ------------------
  171|      0|        close(p->fd);
  172|  24.7k|}
stream_file.c:seek:
  162|  2.51k|{
  163|  2.51k|    struct priv *p = s->priv;
  164|       |    return lseek(p->fd, newpos, SEEK_SET) != (off_t)-1;
  165|  2.51k|}
stream_file.c:fill_buffer:
  116|   124k|{
  117|   124k|    struct priv *p = s->priv;
  118|       |
  119|   124k|#ifndef _WIN32
  120|   124k|    if (p->use_poll) {
  ------------------
  |  Branch (120:9): [True: 0, False: 124k]
  ------------------
  121|      0|        int c = mp_cancel_get_fd(p->cancel);
  122|      0|        struct pollfd fds[2] = {
  123|      0|            {.fd = p->fd, .events = POLLIN},
  124|      0|            {.fd = c, .events = POLLIN},
  125|      0|        };
  126|      0|        poll(fds, c >= 0 ? 2 : 1, -1);
  ------------------
  |  Branch (126:19): [True: 0, False: 0]
  ------------------
  127|      0|        if (fds[1].revents & POLLIN)
  ------------------
  |  Branch (127:13): [True: 0, False: 0]
  ------------------
  128|      0|            return -1;
  129|      0|    }
  130|   124k|#endif
  131|       |
  132|   124k|    for (int retries = 0; retries < MAX_RETRIES; retries++) {
  ------------------
  |  |  100|   124k|#define MAX_RETRIES 10
  ------------------
  |  Branch (132:27): [True: 124k, False: 0]
  ------------------
  133|   124k|        int r = read(p->fd, buffer, max_len);
  134|   124k|        if (r > 0)
  ------------------
  |  Branch (134:13): [True: 25.1k, False: 99.2k]
  ------------------
  135|  25.1k|            return r;
  136|       |
  137|       |        // Try to detect and handle files being appended during playback.
  138|  99.2k|        int64_t size = get_size(s);
  139|  99.2k|        if (p->regular_file && size > p->orig_size && !p->appending) {
  ------------------
  |  Branch (139:13): [True: 99.2k, False: 0]
  |  Branch (139:32): [True: 0, False: 99.2k]
  |  Branch (139:55): [True: 0, False: 0]
  ------------------
  140|      0|            MP_WARN(s, "File is apparently being appended to, will keep "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  141|      0|                    "retrying with timeouts.\n");
  142|      0|            p->appending = true;
  143|      0|        }
  144|       |
  145|  99.2k|        if (!p->appending || p->use_poll)
  ------------------
  |  Branch (145:13): [True: 99.2k, False: 0]
  |  Branch (145:30): [True: 0, False: 0]
  ------------------
  146|  99.2k|            break;
  147|       |
  148|      0|        if (mp_cancel_wait(p->cancel, RETRY_TIMEOUT))
  ------------------
  |  |   99|      0|#define RETRY_TIMEOUT 0.2
  ------------------
  |  Branch (148:13): [True: 0, False: 0]
  ------------------
  149|      0|            break;
  150|      0|    }
  151|       |
  152|  99.2k|    return 0;
  153|   124k|}
stream_file.c:get_size:
  103|   172k|{
  104|   172k|    struct priv *p = s->priv;
  105|   172k|    struct stat st;
  106|   172k|    if (fstat(p->fd, &st) == 0) {
  ------------------
  |  Branch (106:9): [True: 172k, False: 0]
  ------------------
  107|   172k|        if (!S_ISREG(st.st_mode) && !s->seekable)
  ------------------
  |  Branch (107:13): [True: 0, False: 172k]
  |  Branch (107:37): [True: 0, False: 0]
  ------------------
  108|      0|            return -1;
  109|   172k|        if (st.st_size >= 0)
  ------------------
  |  Branch (109:13): [True: 172k, False: 0]
  ------------------
  110|   172k|            return st.st_size;
  111|   172k|    }
  112|      0|    return -1;
  113|   172k|}
stream_file.c:check_stream_network:
  216|  24.7k|{
  217|  24.7k|    struct statfs fs;
  218|  24.7k|    const uint32_t stypes[] = {
  219|  24.7k|        0x5346414F  /*AFS*/,    0x61756673  /*AUFS*/,   0x00C36400  /*CEPH*/,
  220|  24.7k|        0xFF534D42  /*CIFS*/,   0x73757245  /*CODA*/,   0x19830326  /*FHGFS*/,
  221|  24.7k|        0x65735546  /*FUSEBLK*/,0x65735543  /*FUSECTL*/,0x1161970   /*GFS*/,
  222|  24.7k|        0x47504653  /*GPFS*/,   0x6B414653  /*KAFS*/,   0x0BD00BD0  /*LUSTRE*/,
  223|  24.7k|        0x564C      /*NCP*/,    0x6969      /*NFS*/,    0x6E667364  /*NFSD*/,
  224|  24.7k|        0xAAD7AAEA  /*PANFS*/,  0x50495045  /*PIPEFS*/, 0x517B      /*SMB*/,
  225|  24.7k|        0xBEEFDEAD  /*SNFS*/,   0xBACBACBC  /*VMHGFS*/, 0x7461636f  /*OCFS2*/,
  226|  24.7k|        0xFE534D42  /*SMB2*/,   0x61636673  /*ACFS*/,   0x013111A8  /*IBRIX*/,
  227|  24.7k|        0
  228|  24.7k|    };
  229|  24.7k|    if (fstatfs(fd, &fs) == 0) {
  ------------------
  |  Branch (229:9): [True: 24.7k, False: 0]
  ------------------
  230|   618k|        for (int i=0; stypes[i]; i++) {
  ------------------
  |  Branch (230:23): [True: 594k, False: 24.7k]
  ------------------
  231|   594k|            if (stypes[i] == fs.f_type)
  ------------------
  |  Branch (231:17): [True: 0, False: 594k]
  ------------------
  232|      0|                return true;
  233|   594k|        }
  234|  24.7k|    }
  235|  24.7k|    return false;
  236|       |
  237|  24.7k|}

mp_ass_configure_fonts:
   81|  2.29k|{
   82|  2.29k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  2.29k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  2.29k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   83|  2.29k|    char *default_font = mp_find_config_file(tmp, global, "subfont.ttf");
   84|  2.29k|    char *config       = mp_find_config_file(tmp, global, "fonts.conf");
   85|       |
   86|  2.29k|    if (default_font && !mp_path_exists(default_font))
  ------------------
  |  Branch (86:9): [True: 0, False: 2.29k]
  |  Branch (86:25): [True: 0, False: 0]
  ------------------
   87|      0|        default_font = NULL;
   88|       |
   89|  2.29k|    int font_provider = ASS_FONTPROVIDER_AUTODETECT;
   90|  2.29k|    if (opts->font_provider == 1)
  ------------------
  |  Branch (90:9): [True: 0, False: 2.29k]
  ------------------
   91|      0|        font_provider = ASS_FONTPROVIDER_NONE;
   92|  2.29k|    if (opts->font_provider == 2)
  ------------------
  |  Branch (92:9): [True: 0, False: 2.29k]
  ------------------
   93|      0|        font_provider = ASS_FONTPROVIDER_FONTCONFIG;
   94|       |
   95|  2.29k|    mp_verbose(log, "Setting up fonts...\n");
  ------------------
  |  |   79|  2.29k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   96|  2.29k|    ass_set_fonts(priv, default_font, opts->font, font_provider, config, 1);
   97|  2.29k|    mp_verbose(log, "Done.\n");
  ------------------
  |  |   79|  2.29k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   98|       |
   99|  2.29k|    talloc_free(tmp);
  ------------------
  |  |   47|  2.29k|#define talloc_free                     ta_free
  ------------------
  100|  2.29k|}
mp_ass_init:
  127|  2.29k|{
  128|  2.29k|    char *path = opts->fonts_dir && opts->fonts_dir[0] ?
  ------------------
  |  Branch (128:18): [True: 0, False: 2.29k]
  |  Branch (128:37): [True: 0, False: 0]
  ------------------
  129|      0|                 mp_get_user_path(NULL, global, opts->fonts_dir) :
  130|  2.29k|                 mp_find_config_file(NULL, global, "fonts");
  131|  2.29k|    mp_dbg(log, "ASS library version: 0x%x (runtime 0x%x)\n",
  ------------------
  |  |   80|  2.29k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
  132|  2.29k|           (unsigned)LIBASS_VERSION, ass_library_version());
  133|  2.29k|    ASS_Library *priv = ass_library_init();
  134|  2.29k|    if (!priv)
  ------------------
  |  Branch (134:9): [True: 0, False: 2.29k]
  ------------------
  135|      0|        abort();
  136|  2.29k|    ass_set_message_cb(priv, message_callback, log);
  137|  2.29k|    if (path)
  ------------------
  |  Branch (137:9): [True: 0, False: 2.29k]
  ------------------
  138|      0|        ass_set_fonts_dir(priv, path);
  139|  2.29k|    talloc_free(path);
  ------------------
  |  |   47|  2.29k|#define talloc_free                     ta_free
  ------------------
  140|  2.29k|    return priv;
  141|  2.29k|}
ass_mp.c:message_callback:
  115|  39.5k|{
  116|  39.5k|    struct mp_log *log = ctx;
  117|  39.5k|    if (!log)
  ------------------
  |  Branch (117:9): [True: 0, False: 39.5k]
  ------------------
  118|      0|        return;
  119|  39.5k|    level = map_ass_level[level];
  120|  39.5k|    mp_msg_va(log, level, format, va);
  121|       |    // libass messages lack trailing \n
  122|  39.5k|    mp_msg(log, level, "\n");
  123|  39.5k|}

sub_destroy:
  148|  2.70k|{
  149|  2.70k|    if (!sub)
  ------------------
  |  Branch (149:9): [True: 0, False: 2.70k]
  ------------------
  150|      0|        return;
  151|  2.70k|    demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
  152|  2.70k|    if (sub->sd) {
  ------------------
  |  Branch (152:9): [True: 2.60k, False: 100]
  ------------------
  153|  2.60k|        sub_reset(sub);
  154|  2.60k|        sub->sd->driver->uninit(sub->sd);
  155|  2.60k|    }
  156|  2.70k|    talloc_free(sub->sd);
  ------------------
  |  |   47|  2.70k|#define talloc_free                     ta_free
  ------------------
  157|  2.70k|    mp_mutex_destroy(&sub->lock);
  ------------------
  |  |  133|  2.70k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  158|  2.70k|    talloc_free(sub);
  ------------------
  |  |   47|  2.70k|#define talloc_free                     ta_free
  ------------------
  159|  2.70k|}
sub_create:
  197|  2.70k|{
  198|  2.70k|    mp_assert(track->stream && track->stream->type == STREAM_SUB);
  ------------------
  |  |   41|  2.70k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 2.70k, False: 0]
  |  Branch (198:5): [True: 2.70k, False: 0]
  ------------------
  199|       |
  200|  2.70k|    struct dec_sub *sub = talloc(NULL, struct dec_sub);
  ------------------
  |  |   26|  2.70k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  2.70k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.70k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|  2.70k|    *sub = (struct dec_sub){
  202|  2.70k|        .log = mp_log_new(sub, global->log, "sub"),
  203|  2.70k|        .global = global,
  204|  2.70k|        .packet_pool = demux_packet_pool_get(global),
  205|  2.70k|        .opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_sub_opts),
  206|  2.70k|        .shared_opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_shared_sub_opts),
  207|  2.70k|        .sh = track->stream,
  208|  2.70k|        .codec = track->stream->codec,
  209|  2.70k|        .lang = track->lang,
  210|  2.70k|        .attachments = talloc_steal(sub, attachments),
  ------------------
  |  |   38|  2.70k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.70k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  211|  2.70k|        .play_dir = 1,
  212|  2.70k|        .order = order,
  213|  2.70k|        .last_pkt_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.70k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  214|  2.70k|        .last_vo_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.70k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  215|  2.70k|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.70k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  216|  2.70k|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.70k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  217|  2.70k|    };
  218|  2.70k|    sub->opts = sub->opts_cache->opts;
  219|  2.70k|    sub->shared_opts = sub->shared_opts_cache->opts;
  220|  2.70k|    mp_mutex_init(&sub->lock);
  221|       |
  222|  2.70k|    sub->sd = init_decoder(sub);
  223|  2.70k|    if (sub->sd) {
  ------------------
  |  Branch (223:9): [True: 2.60k, False: 100]
  ------------------
  224|  2.60k|        update_subtitle_speed(sub);
  225|  2.60k|        return sub;
  226|  2.60k|    }
  227|       |
  228|    100|    sub_destroy(sub);
  229|       |    return NULL;
  230|  2.70k|}
sub_read_packets:
  347|  30.2k|{
  348|  30.2k|    *packets_read = true;
  349|  30.2k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  30.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  350|  30.2k|    video_pts = pts_to_subtitle(sub, video_pts);
  351|  36.2k|    while (1) {
  ------------------
  |  Branch (351:12): [True: 36.2k, Folded]
  ------------------
  352|  36.2k|        bool read_more = true;
  353|  36.2k|        if (sub->sd->driver->accepts_packet)
  ------------------
  |  Branch (353:13): [True: 5.31k, False: 30.9k]
  ------------------
  354|  5.31k|            read_more = sub->sd->driver->accepts_packet(sub->sd, video_pts);
  355|       |
  356|  36.2k|        if (!read_more)
  ------------------
  |  Branch (356:13): [True: 0, False: 36.2k]
  ------------------
  357|      0|            break;
  358|       |
  359|  36.2k|        if (sub->new_segment && sub->new_segment->start < video_pts) {
  ------------------
  |  Branch (359:13): [True: 159, False: 36.1k]
  |  Branch (359:33): [True: 10, False: 149]
  ------------------
  360|     10|            sub->last_vo_pts = video_pts;
  361|     10|            update_segment(sub);
  362|     10|        }
  363|       |
  364|  36.2k|        if (sub->new_segment)
  ------------------
  |  Branch (364:13): [True: 149, False: 36.1k]
  ------------------
  365|    149|            break;
  366|       |
  367|       |        // (Use this mechanism only if sub_delay matters to avoid corner cases.)
  368|  36.1k|        double delay = sub->order < 0 ? 0.0 : sub->shared_opts->sub_delay[sub->order];
  ------------------
  |  Branch (368:24): [True: 0, False: 36.1k]
  ------------------
  369|  36.1k|        double min_pts = delay < 0 || force ? video_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  36.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (369:26): [True: 0, False: 36.1k]
  |  Branch (369:39): [True: 89, False: 36.0k]
  ------------------
  370|       |
  371|  36.1k|        struct demux_packet *pkt;
  372|  36.1k|        int st = demux_read_packet_async_until(sub->sh, min_pts, &pkt);
  373|       |        // Note: "wait" (st==0) happens with non-interleaved streams only, and
  374|       |        // then we should stop the playloop until a new enough packet has been
  375|       |        // seen (or the subtitle decoder's queue is full). This usually does not
  376|       |        // happen for interleaved subtitle streams, which never return "wait"
  377|       |        // when reading, unless min_pts is set.
  378|  36.1k|        if (st <= 0) {
  ------------------
  |  Branch (378:13): [True: 30.0k, False: 6.04k]
  ------------------
  379|  30.0k|            *packets_read = st < 0 || (sub->last_pkt_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      2|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (379:29): [True: 30.0k, False: 1]
  |  Branch (379:40): [True: 1, False: 0]
  ------------------
  380|      1|                                       sub->last_pkt_pts > video_pts);
  ------------------
  |  Branch (380:40): [True: 0, False: 1]
  ------------------
  381|  30.0k|            break;
  382|  30.0k|        }
  383|       |
  384|  6.04k|        if (sub->recorder_sink)
  ------------------
  |  Branch (384:13): [True: 0, False: 6.04k]
  ------------------
  385|      0|            mp_recorder_feed_packet(sub->recorder_sink, pkt);
  386|       |
  387|  6.04k|        sub->last_pkt_pts = pkt->pts;
  388|  6.04k|        MP_TARRAY_APPEND(sub, sub->cached_pkts, sub->num_cached_pkts, pkt);
  ------------------
  |  |  105|  6.04k|    do {                                            \
  |  |  106|  6.04k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  6.04k|    do {                                            \
  |  |  |  |   97|  6.04k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  6.04k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  6.04k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  6.04k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.02k, False: 5.02k]
  |  |  |  |  ------------------
  |  |  |  |   99|  6.04k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.02k|    do {                                                        \
  |  |  |  |  |  |   89|  1.02k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.02k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.02k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.02k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.02k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.02k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  6.04k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 6.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  6.04k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  6.04k|        (idxvar)++;                                 \
  |  |  109|  6.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 6.04k]
  |  |  ------------------
  ------------------
  389|       |
  390|  6.04k|        if (is_new_segment(sub, pkt)) {
  ------------------
  |  Branch (390:13): [True: 22, False: 6.02k]
  ------------------
  391|     22|            sub->new_segment = demux_copy_packet(sub->packet_pool, pkt);
  392|       |            // Note that this can be delayed to a much later point in time.
  393|     22|            update_segment(sub);
  394|     22|            break;
  395|     22|        }
  396|       |
  397|  6.02k|        if (!(sub->preload_attempted && sub->sd->preload_ok))
  ------------------
  |  Branch (397:15): [True: 0, False: 6.02k]
  |  Branch (397:41): [True: 0, False: 0]
  ------------------
  398|  6.02k|            sub->sd->driver->decode(sub->sd, pkt);
  399|  6.02k|    }
  400|  30.2k|    if (sub->cached_pkts && sub->num_cached_pkts) {
  ------------------
  |  Branch (400:9): [True: 13.8k, False: 16.4k]
  |  Branch (400:29): [True: 13.8k, False: 4]
  ------------------
  401|  13.8k|        bool visible = is_packet_visible(sub->cached_pkts[sub->cached_pkt_pos], video_pts);
  402|  13.8k|        *sub_updated = update_pkt_cache(sub, video_pts) || sub->sub_visible != visible;
  ------------------
  |  Branch (402:24): [True: 688, False: 13.1k]
  |  Branch (402:60): [True: 1.17k, False: 11.9k]
  ------------------
  403|  13.8k|        sub->sub_visible = visible;
  404|  13.8k|    }
  405|  30.2k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  30.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  406|  30.2k|}
sub_redecode_cached_packets:
  411|    724|{
  412|    724|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|    724|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  413|    724|    int index = sub->cached_pkt_pos;
  414|    726|    while (index < sub->num_cached_pkts) {
  ------------------
  |  Branch (414:12): [True: 2, False: 724]
  ------------------
  415|      2|        sub->sd->driver->decode(sub->sd, sub->cached_pkts[index]);
  416|      2|        ++index;
  417|      2|    }
  418|    724|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|    724|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  419|    724|}
sub_get_text:
  444|  1.10k|{
  445|  1.10k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  1.10k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  446|  1.10k|    char *text = NULL;
  447|       |
  448|  1.10k|    pts = pts_to_subtitle(sub, pts);
  449|       |
  450|  1.10k|    sub->last_vo_pts = pts;
  451|  1.10k|    update_segment(sub);
  452|       |
  453|  1.10k|    if (sub->sd->driver->get_text)
  ------------------
  |  Branch (453:9): [True: 611, False: 491]
  ------------------
  454|    611|        text = sub->sd->driver->get_text(sub->sd, pts, type);
  455|  1.10k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  1.10k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  456|  1.10k|    return text;
  457|  1.10k|}
sub_reset:
  491|  5.23k|{
  492|  5.23k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  5.23k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  493|  5.23k|    if (sub->sd->driver->reset)
  ------------------
  |  Branch (493:9): [True: 5.23k, False: 0]
  ------------------
  494|  5.23k|        sub->sd->driver->reset(sub->sd);
  495|  5.23k|    sub->last_pkt_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.23k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  496|  5.23k|    sub->last_vo_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.23k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  497|  5.23k|    destroy_cached_pkts(sub);
  498|  5.23k|    demux_packet_pool_push(sub->packet_pool, sub->new_segment);
  499|  5.23k|    sub->new_segment = NULL;
  500|  5.23k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  5.23k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  501|  5.23k|}
sub_select:
  504|  5.21k|{
  505|  5.21k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  5.21k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  506|  5.21k|    if (sub->sd->driver->select)
  ------------------
  |  Branch (506:9): [True: 4.56k, False: 652]
  ------------------
  507|  4.56k|        sub->sd->driver->select(sub->sd, selected);
  508|  5.21k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  5.21k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  509|  5.21k|}
sub_control:
  512|  57.0k|{
  513|  57.0k|    int r = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  57.0k|#define CONTROL_UNKNOWN -1
  ------------------
  514|  57.0k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  57.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  515|  57.0k|    bool propagate = false;
  516|  57.0k|    switch (cmd) {
  517|  2.60k|    case SD_CTRL_SET_VIDEO_DEF_FPS:
  ------------------
  |  Branch (517:5): [True: 2.60k, False: 54.4k]
  ------------------
  518|  2.60k|        sub->video_fps = *(double *)arg;
  519|  2.60k|        update_subtitle_speed(sub);
  520|  2.60k|        break;
  521|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (521:5): [True: 0, False: 57.0k]
  ------------------
  522|      0|        double *a = arg;
  523|      0|        double arg2[2] = {a[0], a[1]};
  524|      0|        arg2[0] = pts_to_subtitle(sub, arg2[0]);
  525|      0|        if (sub->sd->driver->control)
  ------------------
  |  Branch (525:13): [True: 0, False: 0]
  ------------------
  526|      0|            r = sub->sd->driver->control(sub->sd, cmd, arg2);
  527|      0|        if (r == CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            a[0] = pts_from_subtitle(sub, arg2[0]);
  529|      0|        break;
  530|      0|    }
  531|      0|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (531:5): [True: 0, False: 57.0k]
  ------------------
  532|      0|        uint64_t flags = *(uint64_t *)arg;
  533|      0|        if (m_config_cache_update(sub->opts_cache))
  ------------------
  |  Branch (533:13): [True: 0, False: 0]
  ------------------
  534|      0|            update_subtitle_speed(sub);
  535|      0|        m_config_cache_update(sub->shared_opts_cache);
  536|      0|        propagate = true;
  537|      0|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|      0|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (537:13): [True: 0, False: 0]
  ------------------
  538|       |            // forget about the previous preload because
  539|       |            // UPDATE_SUB_HARD will cause a sub reinit
  540|       |            // that clears all preloaded sub packets
  541|      0|            sub->preload_attempted = false;
  542|      0|        }
  543|      0|        break;
  544|      0|    }
  545|  54.4k|    default:
  ------------------
  |  Branch (545:5): [True: 54.4k, False: 2.60k]
  ------------------
  546|  54.4k|        propagate = true;
  547|  57.0k|    }
  548|  57.0k|    if (propagate && sub->sd->driver->control)
  ------------------
  |  Branch (548:9): [True: 54.4k, False: 2.60k]
  |  Branch (548:22): [True: 54.4k, False: 0]
  ------------------
  549|  54.4k|        r = sub->sd->driver->control(sub->sd, cmd, arg);
  550|  57.0k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  57.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  551|  57.0k|    return r;
  552|  57.0k|}
sub_set_play_dir:
  562|  2.64k|{
  563|  2.64k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  2.64k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  564|  2.64k|    sub->play_dir = dir;
  565|  2.64k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  2.64k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  566|  2.64k|}
dec_sub.c:init_decoder:
  162|  2.71k|{
  163|  5.20k|    for (int n = 0; sd_list[n]; n++) {
  ------------------
  |  Branch (163:21): [True: 5.10k, False: 100]
  ------------------
  164|  5.10k|        const struct sd_functions *driver = sd_list[n];
  165|  5.10k|        struct sd *sd = talloc(NULL, struct sd);
  ------------------
  |  |   26|  5.10k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  5.10k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  5.10k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|  5.10k|        *sd = (struct sd){
  167|  5.10k|            .global = sub->global,
  168|  5.10k|            .log = mp_log_new(sd, sub->log, driver->name),
  169|  5.10k|            .opts = sub->opts,
  170|  5.10k|            .shared_opts = sub->shared_opts,
  171|  5.10k|            .driver = driver,
  172|  5.10k|            .order = sub->order,
  173|  5.10k|            .attachments = sub->attachments,
  174|  5.10k|            .codec = sub->codec,
  175|  5.10k|            .lang = sub->lang,
  176|  5.10k|            .preload_ok = true,
  177|  5.10k|        };
  178|       |
  179|  5.10k|        if (sd->driver->init(sd) >= 0)
  ------------------
  |  Branch (179:13): [True: 2.61k, False: 2.49k]
  ------------------
  180|  2.61k|            return sd;
  181|       |
  182|  2.49k|        talloc_free(sd);
  ------------------
  |  |   47|  2.49k|#define talloc_free                     ta_free
  ------------------
  183|  2.49k|    }
  184|       |
  185|    100|    MP_ERR(sub, "Could not find subtitle decoder for format '%s'.\n",
  ------------------
  |  |   89|    100|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    100|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  186|    100|           sub->codec->codec);
  187|       |    return NULL;
  188|  2.71k|}
dec_sub.c:update_subtitle_speed:
   90|  5.22k|{
   91|  5.22k|    struct mp_subtitle_opts *opts = sub->opts;
   92|  5.22k|    sub->sub_speed = 1.0;
   93|       |
   94|  5.22k|    if (sub->video_fps > 0 && sub->codec->frame_based > 0) {
  ------------------
  |  Branch (94:9): [True: 2.33k, False: 2.89k]
  |  Branch (94:31): [True: 0, False: 2.33k]
  ------------------
   95|      0|        MP_VERBOSE(sub, "Frame based format, dummy FPS: %f, video FPS: %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__)
  |  |  ------------------
  ------------------
   96|      0|                   sub->codec->frame_based, sub->video_fps);
   97|      0|        sub->sub_speed *= sub->codec->frame_based / sub->video_fps;
   98|      0|    }
   99|       |
  100|  5.22k|    if (opts->sub_fps && sub->video_fps)
  ------------------
  |  Branch (100:9): [True: 0, False: 5.22k]
  |  Branch (100:26): [True: 0, False: 0]
  ------------------
  101|      0|        sub->sub_speed *= opts->sub_fps / sub->video_fps;
  102|       |
  103|  5.22k|    sub->sub_speed *= opts->sub_speed;
  104|  5.22k|}
dec_sub.c:pts_to_subtitle:
  108|  31.3k|{
  109|  31.3k|    struct mp_subtitle_shared_opts *opts = sub->shared_opts;
  110|  31.3k|    double delay = sub->order < 0 ? 0.0 : opts->sub_delay[sub->order];
  ------------------
  |  Branch (110:20): [True: 0, False: 31.3k]
  ------------------
  111|       |
  112|  31.3k|    if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  31.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (112:9): [True: 23.7k, False: 7.62k]
  ------------------
  113|  23.7k|        pts = (pts * sub->play_dir - delay) / sub->sub_speed;
  114|       |
  115|  31.3k|    return pts;
  116|  31.3k|}
dec_sub.c:update_segment:
  234|  1.13k|{
  235|  1.13k|    if (sub->new_segment && sub->last_vo_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  1.19k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (235:9): [True: 58, False: 1.07k]
  |  Branch (235:29): [True: 23, False: 35]
  ------------------
  236|     23|        sub->last_vo_pts >= sub->new_segment->start)
  ------------------
  |  Branch (236:9): [True: 10, False: 13]
  ------------------
  237|     10|    {
  238|     10|        MP_VERBOSE(sub, "Switch segment: %f at %f\n", sub->new_segment->start,
  ------------------
  |  |   92|     10|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     10|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  239|     10|                   sub->last_vo_pts);
  240|       |
  241|     10|        sub->codec = sub->new_segment->codec;
  242|     10|        sub->start = sub->new_segment->start;
  243|     10|        sub->end = sub->new_segment->end;
  244|     10|        struct sd *new = init_decoder(sub);
  245|     10|        if (new) {
  ------------------
  |  Branch (245:13): [True: 10, False: 0]
  ------------------
  246|     10|            sub->sd->driver->uninit(sub->sd);
  247|     10|            talloc_free(sub->sd);
  ------------------
  |  |   47|     10|#define talloc_free                     ta_free
  ------------------
  248|     10|            sub->sd = new;
  249|     10|            update_subtitle_speed(sub);
  250|     10|        } else {
  251|       |            // We'll just keep the current decoder, and feed it possibly
  252|       |            // invalid data (not our fault if it crashes or something).
  253|      0|            MP_ERR(sub, "Can't change to new 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__)
  |  |  ------------------
  ------------------
  254|      0|        }
  255|     10|        sub->sd->driver->decode(sub->sd, sub->new_segment);
  256|     10|        talloc_free(sub->new_segment);
  ------------------
  |  |   47|     10|#define talloc_free                     ta_free
  ------------------
  257|       |        sub->new_segment = NULL;
  258|     10|    }
  259|  1.13k|}
dec_sub.c:is_new_segment:
  299|  6.04k|{
  300|  6.04k|    return p->segmented &&
  ------------------
  |  Branch (300:12): [True: 38, False: 6.00k]
  ------------------
  301|     38|        (p->start != sub->start || p->end != sub->end || p->codec != sub->codec);
  ------------------
  |  Branch (301:10): [True: 22, False: 16]
  |  Branch (301:36): [True: 0, False: 16]
  |  Branch (301:58): [True: 0, False: 16]
  ------------------
  302|  6.04k|}
dec_sub.c:is_packet_visible:
  305|  13.8k|{
  306|  13.8k|    return p && p->pts <= video_pts && (video_pts <= p->pts + p->sub_duration ||
  ------------------
  |  Branch (306:12): [True: 13.8k, False: 0]
  |  Branch (306:17): [True: 8.96k, False: 4.84k]
  |  Branch (306:41): [True: 7.48k, False: 1.48k]
  ------------------
  307|  1.48k|           p->sub_duration < 0);
  ------------------
  |  Branch (307:12): [True: 1.17k, False: 305]
  ------------------
  308|  13.8k|}
dec_sub.c:update_pkt_cache:
  311|  13.8k|{
  312|  13.8k|    if (!sub->cached_pkts[sub->cached_pkt_pos])
  ------------------
  |  Branch (312:9): [True: 0, False: 13.8k]
  ------------------
  313|      0|        return false;
  314|       |
  315|  13.8k|    struct demux_packet *pkt = sub->cached_pkts[sub->cached_pkt_pos];
  316|  13.8k|    struct demux_packet *next_pkt = sub->cached_pkt_pos + 1 < sub->num_cached_pkts ?
  ------------------
  |  Branch (316:37): [True: 2.97k, False: 10.8k]
  ------------------
  317|  13.8k|                                    sub->cached_pkts[sub->cached_pkt_pos + 1] : NULL;
  318|  13.8k|    if (!pkt)
  ------------------
  |  Branch (318:9): [True: 0, False: 13.8k]
  ------------------
  319|      0|        return false;
  320|       |
  321|  13.8k|    double pts = video_pts + sub->shared_opts->sub_delay[sub->order];
  322|  13.8k|    double next_pts = next_pkt ? next_pkt->pts : INT_MAX;
  ------------------
  |  Branch (322:23): [True: 2.97k, False: 10.8k]
  ------------------
  323|  13.8k|    double end_pts = pkt->sub_duration >= 0 ? pkt->pts + pkt->sub_duration : INT_MAX;
  ------------------
  |  Branch (323:22): [True: 12.1k, False: 1.64k]
  ------------------
  324|       |
  325|  13.8k|    if (next_pts < pts || end_pts < pts) {
  ------------------
  |  Branch (325:9): [True: 604, False: 13.2k]
  |  Branch (325:27): [True: 284, False: 12.9k]
  ------------------
  326|    888|        if (sub->cached_pkt_pos + 1 < sub->num_cached_pkts) {
  ------------------
  |  Branch (326:13): [True: 623, False: 265]
  ------------------
  327|    623|            TA_FREEP(&sub->cached_pkts[sub->cached_pkt_pos]);
  ------------------
  |  |   81|    623|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    623|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 623]
  |  |  ------------------
  ------------------
  328|    623|            pkt = NULL;
  329|    623|            sub->cached_pkt_pos++;
  330|    623|        }
  331|    888|        if (next_pts < pts)
  ------------------
  |  Branch (331:13): [True: 604, False: 284]
  ------------------
  332|    604|            return true;
  333|    888|    }
  334|       |
  335|  13.2k|    if (pkt && pkt->animated == 1)
  ------------------
  |  Branch (335:9): [True: 13.1k, False: 19]
  |  Branch (335:16): [True: 84, False: 13.1k]
  ------------------
  336|     84|        return true;
  337|       |
  338|  13.1k|    return false;
  339|  13.2k|}
dec_sub.c:destroy_cached_pkts:
  136|  5.23k|{
  137|  5.23k|    int index = 0;
  138|  11.2k|    while (index < sub->num_cached_pkts) {
  ------------------
  |  Branch (138:12): [True: 6.04k, False: 5.23k]
  ------------------
  139|  6.04k|        demux_packet_pool_push(sub->packet_pool, sub->cached_pkts[index]);
  140|       |        sub->cached_pkts[index] = NULL;
  141|  6.04k|        ++index;
  142|  6.04k|    }
  143|  5.23k|    sub->cached_pkt_pos = 0;
  144|  5.23k|    sub->num_cached_pkts = 0;
  145|  5.23k|}

filter_regex.c:rf_init:
   17|  2.29k|{
   18|  2.29k|    if (strcmp(ft->codec, "ass") != 0)
  ------------------
  |  Branch (18:9): [True: 0, False: 2.29k]
  ------------------
   19|      0|        return false;
   20|       |
   21|  2.29k|    if (!ft->opts->rf_enable)
  ------------------
  |  Branch (21:9): [True: 0, False: 2.29k]
  ------------------
   22|      0|        return false;
   23|       |
   24|  2.29k|    struct priv *p = talloc_zero(ft, struct priv);
  ------------------
  |  |   27|  2.29k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.29k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.29k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   25|  2.29k|    ft->priv = p;
   26|       |
   27|  2.29k|    for (int n = 0; ft->opts->rf_items && ft->opts->rf_items[n]; n++) {
  ------------------
  |  Branch (27:21): [True: 0, False: 2.29k]
  |  Branch (27:43): [True: 0, False: 0]
  ------------------
   28|      0|        char *item = ft->opts->rf_items[n];
   29|       |
   30|      0|        MP_TARRAY_GROW(p, p->regexes, p->num_regexes);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
   31|      0|        regex_t *preg = &p->regexes[p->num_regexes];
   32|       |
   33|      0|        int err = regcomp(preg, item, REG_ICASE | REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
   34|      0|        if (err) {
  ------------------
  |  Branch (34:13): [True: 0, False: 0]
  ------------------
   35|      0|            char errbuf[512];
   36|      0|            regerror(err, preg, errbuf, sizeof(errbuf));
   37|      0|            MP_ERR(ft, "Regular expression error: '%s'\n", errbuf);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
   38|      0|            continue;
   39|      0|        }
   40|       |
   41|      0|        p->num_regexes += 1;
   42|      0|    }
   43|       |
   44|  2.29k|    if (!p->num_regexes)
  ------------------
  |  Branch (44:9): [True: 2.29k, False: 0]
  ------------------
   45|  2.29k|        return false;
   46|       |
   47|      0|    p->offset = sd_ass_fmt_offset(ft->event_format);
   48|       |    return true;
   49|  2.29k|}

filter_sdh.c:sdh_init:
  438|  2.29k|{
  439|  2.29k|    if (strcmp(ft->codec, "ass") != 0)
  ------------------
  |  Branch (439:9): [True: 0, False: 2.29k]
  ------------------
  440|      0|        return false;
  441|       |
  442|  2.29k|    if (!ft->opts->sub_filter_SDH)
  ------------------
  |  Branch (442:9): [True: 2.29k, False: 0]
  ------------------
  443|  2.29k|        return false;
  444|       |
  445|      0|    if (!ft->event_format) {
  ------------------
  |  Branch (445:9): [True: 0, False: 0]
  ------------------
  446|      0|        MP_VERBOSE(ft, "SDH filtering not possible - format missing\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__)
  |  |  ------------------
  ------------------
  447|      0|        return false;
  448|      0|    }
  449|       |
  450|      0|    struct priv *p = talloc_zero(ft, struct priv);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|      0|    ft->priv = p;
  452|      0|    p->offset = sd_ass_fmt_offset(ft->event_format);
  453|       |    return true;
  454|      0|}

lavc_conv_create:
   58|  1.44k|{
   59|  1.44k|    struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv);
  ------------------
  |  |   27|  1.44k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.44k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.44k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   60|  1.44k|    priv->log = sd->log;
   61|  1.44k|    priv->opts = sd->opts;
   62|  1.44k|    priv->cur_list = talloc_array(priv, char*, 0);
  ------------------
  |  |   29|  1.44k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  1.44k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.44k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|  1.44k|    priv->codec = sd->codec->codec;
   64|  1.44k|    AVCodecContext *avctx = NULL;
   65|  1.44k|    AVDictionary *opts = NULL;
   66|  1.44k|    const char *fmt = get_lavc_format(priv->codec);
   67|  1.44k|    const AVCodec *codec = avcodec_find_decoder(mp_codec_to_av_codec_id(fmt));
   68|  1.44k|    if (!codec)
  ------------------
  |  Branch (68:9): [True: 97, False: 1.35k]
  ------------------
   69|     97|        goto error;
   70|  1.35k|    avctx = avcodec_alloc_context3(codec);
   71|  1.35k|    if (!avctx)
  ------------------
  |  Branch (71:9): [True: 0, False: 1.35k]
  ------------------
   72|      0|        goto error;
   73|  1.35k|    if (mp_set_avctx_codec_headers(avctx, sd->codec) < 0)
  ------------------
  |  Branch (73:9): [True: 0, False: 1.35k]
  ------------------
   74|      0|        goto error;
   75|       |
   76|  1.35k|    MP_VERBOSE(sd, "Using subtitle decoder %s\n", codec->name);
  ------------------
  |  |   92|  1.35k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.35k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   77|       |
   78|  1.35k|    priv->avpkt = av_packet_alloc();
   79|  1.35k|    priv->avpkt_vtt = av_packet_alloc();
   80|  1.35k|    if (!priv->avpkt || !priv->avpkt_vtt)
  ------------------
  |  Branch (80:9): [True: 0, False: 1.35k]
  |  Branch (80:25): [True: 0, False: 1.35k]
  ------------------
   81|      0|        goto error;
   82|       |
   83|  1.35k|    switch (codec->id) {
  ------------------
  |  Branch (83:13): [True: 0, False: 1.35k]
  ------------------
   84|      0|    case AV_CODEC_ID_DVB_TELETEXT:
  ------------------
  |  Branch (84:5): [True: 0, False: 1.35k]
  ------------------
   85|      0|        av_dict_set_int(&opts, "txt_format", 2, 0);
   86|      0|        break;
   87|      0|    case AV_CODEC_ID_ARIB_CAPTION:
  ------------------
  |  Branch (87:5): [True: 0, False: 1.35k]
  ------------------
   88|      0|        av_dict_set_int(&opts, "sub_type", SUBTITLE_ASS, 0);
   89|      0|        break;
   90|  1.35k|    }
   91|       |
   92|  1.35k|    av_dict_set(&opts, "sub_text_format", "ass", 0);
   93|  1.35k|    av_dict_set(&opts, "flags2", "+ass_ro_flush_noop", 0);
   94|  1.35k|    if (strcmp(priv->codec, "eia_608") == 0)
  ------------------
  |  Branch (94:9): [True: 273, False: 1.07k]
  ------------------
   95|    273|        av_dict_set(&opts, "real_time", "1", 0);
   96|  1.35k|    if (avcodec_open2(avctx, codec, &opts) < 0)
  ------------------
  |  Branch (96:9): [True: 3, False: 1.34k]
  ------------------
   97|      3|        goto error;
   98|  1.34k|    av_dict_free(&opts);
   99|       |    // Documented as "set by libavcodec", but there is no other way
  100|  1.34k|    avctx->time_base = (AVRational) {1, 1000};
  101|  1.34k|    avctx->pkt_timebase = avctx->time_base;
  102|  1.34k|    avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_IGNORE;
  103|  1.34k|    priv->avctx = avctx;
  104|  1.34k|    priv->extradata = talloc_strndup(priv, avctx->subtitle_header,
  ------------------
  |  |   51|  1.34k|#define talloc_strndup                  ta_xstrndup
  ------------------
  105|  1.34k|                                     avctx->subtitle_header_size);
  106|  1.34k|    mp_codec_info_from_av(avctx, sd->codec);
  107|       |    // Keep original codec name, which get_lavc_format() may have transformed
  108|  1.34k|    sd->codec->codec = priv->codec;
  109|  1.34k|    return priv;
  110|       |
  111|    100| error:
  112|    100|    MP_FATAL(priv, "Could not open libavcodec subtitle converter\n");
  ------------------
  |  |   88|    100|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    100|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  113|    100|    av_dict_free(&opts);
  114|    100|    avcodec_free_context(&avctx);
  115|    100|    mp_free_av_packet(&priv->avpkt);
  116|    100|    mp_free_av_packet(&priv->avpkt_vtt);
  117|    100|    talloc_free(priv);
  ------------------
  |  |   47|    100|#define talloc_free                     ta_free
  ------------------
  118|       |    return NULL;
  119|  1.35k|}
lavc_conv_get_extradata:
  122|  1.34k|{
  123|  1.34k|    return priv->extradata;
  124|  1.34k|}
lavc_conv_decode:
  232|  5.64k|{
  233|  5.64k|    AVCodecContext *avctx = priv->avctx;
  234|  5.64k|    AVPacket *curr_pkt = priv->avpkt;
  235|  5.64k|    int ret, got_sub;
  236|  5.64k|    int num_cur = 0;
  237|       |
  238|  5.64k|    avsubtitle_free(&priv->cur);
  239|       |
  240|  5.64k|    mp_set_av_packet(priv->avpkt, packet, &avctx->time_base);
  241|  5.64k|    if (priv->avpkt->pts < 0)
  ------------------
  |  Branch (241:9): [True: 145, False: 5.50k]
  ------------------
  242|    145|        priv->avpkt->pts = 0;
  243|       |
  244|  5.64k|    if (strcmp(priv->codec, "webvtt-webm") == 0) {
  ------------------
  |  Branch (244:9): [True: 0, False: 5.64k]
  ------------------
  245|      0|        if (parse_webvtt(priv->avpkt, priv->avpkt_vtt) < 0) {
  ------------------
  |  Branch (245:13): [True: 0, False: 0]
  ------------------
  246|      0|            MP_ERR(priv, "Error parsing subtitle\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__)
  |  |  ------------------
  ------------------
  247|      0|            goto done;
  248|      0|        }
  249|      0|        curr_pkt = priv->avpkt_vtt;
  250|      0|    }
  251|       |
  252|  5.64k|    priv->styled = avctx->codec_id == AV_CODEC_ID_DVB_TELETEXT;
  253|       |
  254|  5.64k|    if (avctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
  ------------------
  |  Branch (254:9): [True: 0, False: 5.64k]
  ------------------
  255|      0|        if (!priv->opts->teletext_page) {
  ------------------
  |  Branch (255:13): [True: 0, False: 0]
  ------------------
  256|      0|            av_opt_set(avctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN);
  257|      0|            priv->styled = false;
  258|      0|        } else if (priv->opts->teletext_page == -1) {
  ------------------
  |  Branch (258:20): [True: 0, False: 0]
  ------------------
  259|      0|            av_opt_set(avctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN);
  260|      0|        } else {
  261|      0|            char page[4];
  262|      0|            snprintf(page, sizeof(page), "%d", priv->opts->teletext_page);
  263|      0|            av_opt_set(avctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN);
  264|      0|        }
  265|      0|    }
  266|       |
  267|  5.64k|    ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt);
  268|  5.64k|    if (ret < 0) {
  ------------------
  |  Branch (268:9): [True: 0, False: 5.64k]
  ------------------
  269|      0|        MP_ERR(priv, "Error decoding subtitle\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__)
  |  |  ------------------
  ------------------
  270|  5.64k|    } else if (got_sub) {
  ------------------
  |  Branch (270:16): [True: 5.44k, False: 205]
  ------------------
  271|  5.44k|        *sub_pts = packet->pts + mp_pts_from_av(priv->cur.start_display_time,
  272|  5.44k|                                               &avctx->time_base);
  273|  5.44k|        *sub_duration = priv->cur.end_display_time == UINT32_MAX ?
  ------------------
  |  Branch (273:25): [True: 0, False: 5.44k]
  ------------------
  274|  5.44k|                        UINT32_MAX :
  275|  5.44k|                        mp_pts_from_av(priv->cur.end_display_time -
  276|  5.44k|                                       priv->cur.start_display_time,
  277|  5.44k|                                       &avctx->time_base);
  278|       |
  279|  10.8k|        for (int i = 0; i < priv->cur.num_rects; i++) {
  ------------------
  |  Branch (279:25): [True: 5.44k, False: 5.44k]
  ------------------
  280|  5.44k|            if (priv->cur.rects[i]->w > 0 && priv->cur.rects[i]->h > 0)
  ------------------
  |  Branch (280:17): [True: 0, False: 5.44k]
  |  Branch (280:46): [True: 0, False: 0]
  ------------------
  281|  5.44k|                MP_WARN(priv, "Ignoring bitmap subtitle.\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__)
  |  |  ------------------
  ------------------
  282|  5.44k|            char *ass_line = priv->cur.rects[i]->ass;
  283|  5.44k|            if (!ass_line)
  ------------------
  |  Branch (283:17): [True: 0, False: 5.44k]
  ------------------
  284|      0|                continue;
  285|  5.44k|            MP_TARRAY_APPEND(priv, priv->cur_list, num_cur, ass_line);
  ------------------
  |  |  105|  5.44k|    do {                                            \
  |  |  106|  5.44k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  5.44k|    do {                                            \
  |  |  |  |   97|  5.44k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  5.44k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  5.44k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  5.44k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 358, False: 5.08k]
  |  |  |  |  ------------------
  |  |  |  |   99|  5.44k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    358|    do {                                                        \
  |  |  |  |  |  |   89|    358|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    358|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    358|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    358|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    358|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    358|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    358|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 358]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  5.44k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 5.44k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  5.44k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  5.44k|        (idxvar)++;                                 \
  |  |  109|  5.44k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.44k]
  |  |  ------------------
  ------------------
  286|  5.44k|        }
  287|  5.44k|    }
  288|       |
  289|  5.64k|done:
  290|  5.64k|    av_packet_unref(priv->avpkt_vtt);
  291|  5.64k|    MP_TARRAY_APPEND(priv, priv->cur_list, num_cur, NULL);
  ------------------
  |  |  105|  5.64k|    do {                                            \
  |  |  106|  5.64k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  5.64k|    do {                                            \
  |  |  |  |   97|  5.64k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  5.64k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  5.64k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  5.64k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 160, False: 5.48k]
  |  |  |  |  ------------------
  |  |  |  |   99|  5.64k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    160|    do {                                                        \
  |  |  |  |  |  |   89|    160|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    160|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    160|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    160|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    160|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    160|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    160|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 160]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  5.64k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 5.64k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  5.64k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  5.64k|        (idxvar)++;                                 \
  |  |  109|  5.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.64k]
  |  |  ------------------
  ------------------
  292|  5.64k|    return priv->cur_list;
  293|  5.64k|}
lavc_conv_reset:
  301|  2.68k|{
  302|  2.68k|    avcodec_flush_buffers(priv->avctx);
  303|  2.68k|}
lavc_conv_uninit:
  306|  1.34k|{
  307|  1.34k|    avsubtitle_free(&priv->cur);
  308|  1.34k|    avcodec_free_context(&priv->avctx);
  309|  1.34k|    mp_free_av_packet(&priv->avpkt);
  310|  1.34k|    mp_free_av_packet(&priv->avpkt_vtt);
  311|  1.34k|    talloc_free(priv);
  ------------------
  |  |   47|  1.34k|#define talloc_free                     ta_free
  ------------------
  312|  1.34k|}
lavc_conv.c:get_lavc_format:
   47|  1.44k|{
   48|       |    // For the hack involving parse_webvtt().
   49|  1.44k|    if (format && strcmp(format, "webvtt-webm") == 0)
  ------------------
  |  Branch (49:9): [True: 1.44k, False: 0]
  |  Branch (49:19): [True: 0, False: 1.44k]
  ------------------
   50|      0|        format = "webvtt";
   51|       |    // Most text subtitles are srt/html style anyway.
   52|  1.44k|    if (format && strcmp(format, "text") == 0)
  ------------------
  |  Branch (52:9): [True: 1.44k, False: 0]
  |  Branch (52:19): [True: 0, False: 1.44k]
  ------------------
   53|      0|        format = "subrip";
   54|  1.44k|    return format;
   55|  1.44k|}

osd_create:
  159|  24.7k|{
  160|  24.7k|    static_assert(MAX_OSD_PARTS >= OSDTYPE_COUNT, "");
  161|       |
  162|  24.7k|    struct osd_state *osd = talloc_zero(NULL, struct osd_state);
  ------------------
  |  |   27|  24.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  24.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|  24.7k|    *osd = (struct osd_state) {
  164|  24.7k|        .opts_cache = m_config_cache_alloc(osd, global, &mp_osd_render_sub_opts),
  165|  24.7k|        .global = global,
  166|  24.7k|        .log = mp_log_new(osd, global->log, "osd"),
  167|  24.7k|        .force_video_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  24.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  24.7k|        .stats = stats_ctx_create(osd, global, "osd"),
  169|  24.7k|    };
  170|  24.7k|    mp_mutex_init(&osd->lock);
  171|  24.7k|    osd->opts = osd->opts_cache->opts;
  172|       |
  173|   173k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   173k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (173:21): [True: 148k, False: 24.7k]
  ------------------
  174|   148k|        struct osd_object *obj = talloc(osd, struct osd_object);
  ------------------
  |  |   26|   148k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   148k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   148k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|   148k|        *obj = (struct osd_object) {
  176|   148k|            .type = n,
  177|   148k|            .text = talloc_strdup(obj, ""),
  ------------------
  |  |   50|   148k|#define talloc_strdup                   ta_xstrdup
  ------------------
  178|   148k|            .progbar_state = {.type = -1},
  179|   148k|            .vo_change_id = 1,
  180|   148k|        };
  181|   148k|        osd->objs[n] = obj;
  182|   148k|    }
  183|       |
  184|  24.7k|    osd->objs[OSDTYPE_SUB]->is_sub = true;
  185|  24.7k|    osd->objs[OSDTYPE_SUB2]->is_sub = true;
  186|       |
  187|  24.7k|    return osd;
  188|  24.7k|}
osd_free:
  191|  24.7k|{
  192|  24.7k|    if (!osd)
  ------------------
  |  Branch (192:9): [True: 0, False: 24.7k]
  ------------------
  193|      0|        return;
  194|  24.7k|    osd_destroy_backend(osd);
  195|  24.7k|    talloc_free(osd->objs[OSDTYPE_EXTERNAL2]->image_overlay);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  196|  24.7k|    talloc_free(osd->objs[OSDTYPE_DISC_MENU]->image_overlay);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  197|  24.7k|    mp_mutex_destroy(&osd->lock);
  ------------------
  |  |  133|  24.7k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  198|  24.7k|    talloc_free(osd);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  199|  24.7k|}
osd_set_text:
  202|  1.77k|{
  203|  1.77k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  1.77k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  204|  1.77k|    struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
  205|  1.77k|    if (!text)
  ------------------
  |  Branch (205:9): [True: 1.77k, False: 0]
  ------------------
  206|  1.77k|        text = "";
  207|  1.77k|    if (strcmp(osd_obj->text, text) != 0) {
  ------------------
  |  Branch (207:9): [True: 0, False: 1.77k]
  ------------------
  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|  1.77k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  1.77k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  214|  1.77k|}
osd_set_sub:
  217|  5.21k|{
  218|  5.21k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  5.21k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  219|  5.21k|    if (index >= 0 && index < 2) {
  ------------------
  |  Branch (219:9): [True: 5.21k, False: 0]
  |  Branch (219:23): [True: 5.21k, False: 0]
  ------------------
  220|  5.21k|        struct osd_object *obj = osd->objs[OSDTYPE_SUB + index];
  221|  5.21k|        obj->sub = dec_sub;
  222|  5.21k|        obj->vo_change_id += 1;
  223|  5.21k|    }
  224|  5.21k|    osd->want_redraw_notification = true;
  225|  5.21k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  5.21k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  226|  5.21k|}
osd_get_render_subs_in_filter:
  229|   120k|{
  230|   120k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   120k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|   120k|    bool r = osd->render_subs_in_filter;
  232|   120k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   120k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|   120k|    return r;
  234|   120k|}
osd_set_force_video_pts:
  252|   123k|{
  253|       |    atomic_store(&osd->force_video_pts, video_pts);
  254|   123k|}
osd_get_force_video_pts:
  257|  30.2k|{
  258|       |    return atomic_load(&osd->force_video_pts);
  259|  30.2k|}
osd_set_bitmaps:
  279|  24.7k|{
  280|  24.7k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  281|  24.7k|    struct osd_object *obj = osd->objs[type];
  282|  24.7k|    talloc_free(obj->image_overlay);
  ------------------
  |  |   47|  24.7k|#define talloc_free                     ta_free
  ------------------
  283|  24.7k|    obj->image_overlay = sub_bitmaps_copy(NULL, imgs);
  284|  24.7k|    obj->vo_change_id += 1;
  285|  24.7k|    osd->want_redraw_notification = true;
  286|  24.7k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  287|  24.7k|}
osd_changed:
  508|  24.7k|{
  509|  24.7k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  24.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  510|  24.7k|    osd->objs[OSDTYPE_OSD]->osd_changed = true;
  511|  24.7k|    osd->want_redraw_notification = true;
  512|       |    // Done here for a lack of a better place.
  513|  24.7k|    m_config_cache_update(osd->opts_cache);
  514|  24.7k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  24.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  515|  24.7k|}
osd_query_and_reset_want_redraw:
  518|  17.7k|{
  519|  17.7k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  17.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  520|  17.7k|    bool r = osd->want_redraw_notification;
  521|  17.7k|    osd->want_redraw_notification = false;
  522|  17.7k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  17.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  523|  17.7k|    return r;
  524|  17.7k|}
sub_bitmaps_copy:
  585|  24.7k|{
  586|  24.7k|    if (!in || !in->num_parts)
  ------------------
  |  Branch (586:9): [True: 24.7k, False: 0]
  |  Branch (586:16): [True: 0, False: 0]
  ------------------
  587|  24.7k|        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|  24.7k|{
   87|   173k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   173k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (87:21): [True: 148k, False: 24.7k]
  ------------------
   88|   148k|        struct osd_object *obj = osd->objs[n];
   89|   148k|        destroy_ass_renderer(&obj->ass);
   90|   148k|        for (int i = 0; i < obj->num_externals; i++)
  ------------------
  |  Branch (90:25): [True: 0, False: 148k]
  ------------------
   91|      0|            destroy_external(obj->externals[i]);
   92|   148k|        obj->num_externals = 0;
   93|   148k|    }
   94|  24.7k|}
osd_set_external_remove_owner:
  648|  49.5k|{
  649|  49.5k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  49.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  650|  49.5k|    struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
  651|  49.5k|    for (int n = obj->num_externals - 1; n >= 0; n--) {
  ------------------
  |  Branch (651:42): [True: 0, False: 49.5k]
  ------------------
  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|  49.5k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  49.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  661|  49.5k|}
osd_libass.c:destroy_ass_renderer:
   65|   148k|{
   66|   148k|    if (ass->track)
  ------------------
  |  Branch (66:9): [True: 0, False: 148k]
  ------------------
   67|      0|        ass_free_track(ass->track);
   68|   148k|    ass->track = NULL;
   69|   148k|    if (ass->render)
  ------------------
  |  Branch (69:9): [True: 0, False: 148k]
  ------------------
   70|      0|        ass_renderer_done(ass->render);
   71|   148k|    ass->render = NULL;
   72|   148k|    if (ass->library)
  ------------------
  |  Branch (72:9): [True: 0, False: 148k]
  ------------------
   73|      0|        ass_library_done(ass->library);
   74|   148k|    ass->library = NULL;
   75|   148k|    talloc_free(ass->log);
  ------------------
  |  |   47|   148k|#define talloc_free                     ta_free
  ------------------
   76|       |    ass->log = NULL;
   77|   148k|}

mp_sub_packer_alloc:
   52|  2.29k|{
   53|  2.29k|    struct mp_sub_packer *p = talloc_zero(ta_parent, struct mp_sub_packer);
  ------------------
  |  |   27|  2.29k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.29k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.29k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|  2.29k|    p->packer = talloc_zero(p, struct bitmap_packer);
  ------------------
  |  |   27|  2.29k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.29k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.29k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  2.29k|    p->packer->padding = 1; // assume bilinear sampling
   56|  2.29k|    return p;
   57|  2.29k|}

sd_ass.c:init:
  304|  2.39k|{
  305|  2.39k|    struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
  ------------------
  |  |   27|  2.39k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.39k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.39k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  2.39k|    sd->priv = ctx;
  307|       |
  308|       |    // Note: accept "null" as alias for "ass", so EDL delay_open subtitle
  309|       |    //       streams work.
  310|  2.39k|    if (strcmp(sd->codec->codec, "ass") != 0 &&
  ------------------
  |  Branch (310:9): [True: 1.44k, False: 942]
  ------------------
  311|  1.44k|        strcmp(sd->codec->codec, "null") != 0)
  ------------------
  |  Branch (311:9): [True: 1.44k, False: 0]
  ------------------
  312|  1.44k|    {
  313|  1.44k|        ctx->is_converted = true;
  314|  1.44k|        ctx->converter = lavc_conv_create(sd);
  315|  1.44k|        if (!ctx->converter)
  ------------------
  |  Branch (315:13): [True: 100, False: 1.34k]
  ------------------
  316|    100|            return -1;
  317|  1.44k|    }
  318|       |
  319|  2.29k|    assobjects_init(sd);
  320|  2.29k|    filters_init(sd);
  321|       |
  322|  2.29k|    ctx->packer = mp_sub_packer_alloc(ctx);
  323|       |
  324|       |    // Subtitles does not have any profile value, so put the converted type as a profile.
  325|  2.29k|    const char *_Atomic *desc = ctx->converter ? &sd->codec->codec_profile : &sd->codec->codec_desc;
  ------------------
  |  Branch (325:33): [True: 1.34k, False: 942]
  ------------------
  326|  2.29k|    switch (ctx->ass_track->track_type) {
  ------------------
  |  Branch (326:13): [True: 2.29k, False: 0]
  ------------------
  327|  1.87k|    case TRACK_TYPE_ASS:
  ------------------
  |  Branch (327:5): [True: 1.87k, False: 417]
  ------------------
  328|  1.87k|        *desc = "Advanced Sub Station Alpha";
  329|  1.87k|        break;
  330|    417|    case TRACK_TYPE_SSA:
  ------------------
  |  Branch (330:5): [True: 417, False: 1.87k]
  ------------------
  331|    417|        *desc = "Sub Station Alpha";
  332|    417|        break;
  333|  2.29k|    }
  334|       |
  335|  2.29k|    return 0;
  336|  2.29k|}
sd_ass.c:assobjects_init:
  249|  2.29k|{
  250|  2.29k|    struct sd_ass_priv *ctx = sd->priv;
  251|  2.29k|    struct mp_subtitle_opts *opts = sd->opts;
  252|  2.29k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  253|       |
  254|  2.29k|    ctx->ass_library = mp_ass_init(sd->global, sd->opts->sub_style, sd->log);
  255|  2.29k|    ass_set_extract_fonts(ctx->ass_library, opts->use_embedded_fonts);
  256|       |
  257|  2.29k|    add_subtitle_fonts(sd);
  258|       |
  259|  2.29k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (259:9): [True: 2.29k, False: 0]
  ------------------
  260|  2.29k|        ass_set_style_overrides(ctx->ass_library, opts->ass_style_override_list);
  261|       |
  262|  2.29k|    ctx->ass_track = ass_new_track(ctx->ass_library);
  263|  2.29k|    ctx->ass_track->track_type = TRACK_TYPE_ASS;
  264|       |
  265|  2.29k|    ctx->shadow_track = ass_new_track(ctx->ass_library);
  266|  2.29k|    ctx->shadow_track->PlayResX = MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|  2.29k|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  267|  2.29k|    ctx->shadow_track->PlayResY = MP_ASS_FONT_PLAYRESY;
  ------------------
  |  |   32|  2.29k|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  268|  2.29k|    mp_ass_add_default_styles(sd, ctx->shadow_track, opts, shared_opts);
  269|       |
  270|  2.29k|    char *extradata = sd->codec->extradata;
  271|  2.29k|    int extradata_size = sd->codec->extradata_size;
  272|  2.29k|    if (ctx->converter) {
  ------------------
  |  Branch (272:9): [True: 1.34k, False: 942]
  ------------------
  273|  1.34k|        extradata = lavc_conv_get_extradata(ctx->converter);
  274|  1.34k|        extradata_size = extradata ? strlen(extradata) : 0;
  ------------------
  |  Branch (274:26): [True: 1.34k, False: 0]
  ------------------
  275|  1.34k|    }
  276|  2.29k|    if (extradata)
  ------------------
  |  Branch (276:9): [True: 2.24k, False: 42]
  ------------------
  277|  2.24k|        ass_process_codec_private(ctx->ass_track, extradata, extradata_size);
  278|       |
  279|  2.29k|    mp_ass_add_default_styles(sd, ctx->ass_track, opts, shared_opts);
  280|       |
  281|  2.29k|#if LIBASS_VERSION >= 0x01302000
  282|  2.29k|    ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
  ------------------
  |  Branch (282:45): [True: 0, False: 2.29k]
  ------------------
  283|  2.29k|#endif
  284|       |
  285|  2.29k|#if LIBASS_VERSION >= 0x01703010
  286|  2.29k|    ass_configure_prune(ctx->ass_track, sd->opts->ass_prune_delay * 1000.0);
  287|  2.29k|#endif
  288|       |
  289|       |    enable_output(sd, true);
  290|  2.29k|    ass_set_cache_limits(ctx->ass_renderer, sd->opts->sub_glyph_limit, sd->opts->sub_bitmap_max_size);
  291|  2.29k|}
sd_ass.c:add_subtitle_fonts:
  182|  2.29k|{
  183|  2.29k|    struct sd_ass_priv *ctx = sd->priv;
  184|  2.29k|    struct mp_subtitle_opts *opts = sd->opts;
  185|  2.29k|    if (!opts->ass_enabled || !opts->use_embedded_fonts || !sd->attachments)
  ------------------
  |  Branch (185:9): [True: 0, False: 2.29k]
  |  Branch (185:31): [True: 0, False: 2.29k]
  |  Branch (185:60): [True: 0, False: 2.29k]
  ------------------
  186|      0|        return;
  187|  2.59k|    for (int i = 0; i < sd->attachments->num_entries; i++) {
  ------------------
  |  Branch (187:21): [True: 300, False: 2.29k]
  ------------------
  188|    300|        struct demux_attachment *f = &sd->attachments->entries[i];
  189|    300|        if (attachment_is_font(sd->log, f))
  ------------------
  |  Branch (189:13): [True: 282, False: 18]
  ------------------
  190|    282|            ass_add_font(ctx->ass_library, f->name, f->data, f->data_size);
  191|    300|    }
  192|  2.29k|}
sd_ass.c:attachment_is_font:
  160|    300|{
  161|    300|    if (!f->name || !f->type || !f->data || !f->data_size)
  ------------------
  |  Branch (161:9): [True: 0, False: 300]
  |  Branch (161:21): [True: 0, False: 300]
  |  Branch (161:33): [True: 0, False: 300]
  |  Branch (161:45): [True: 0, False: 300]
  ------------------
  162|      0|        return false;
  163|    510|    for (int n = 0; font_mimetypes[n]; n++) {
  ------------------
  |  Branch (163:21): [True: 489, False: 21]
  ------------------
  164|    489|        if (strcmp(font_mimetypes[n], f->type) == 0)
  ------------------
  |  Branch (164:13): [True: 279, False: 210]
  ------------------
  165|    279|            return true;
  166|    489|    }
  167|       |    // fallback: match against file extension
  168|     21|    char *ext = strlen(f->name) > 4 ? f->name + strlen(f->name) - 4 : "";
  ------------------
  |  Branch (168:17): [True: 21, False: 0]
  ------------------
  169|     93|    for (int n = 0; font_exts[n]; n++) {
  ------------------
  |  Branch (169:21): [True: 75, False: 18]
  ------------------
  170|     75|        if (strcasecmp(ext, font_exts[n]) == 0) {
  ------------------
  |  Branch (170:13): [True: 3, False: 72]
  ------------------
  171|      3|            mp_warn(log, "Loading font attachment '%s' with MIME type %s. "
  ------------------
  |  |   77|      3|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  172|      3|                    "Assuming this is a broken Matroska file, which was "
  173|      3|                    "muxed without setting a correct font MIME type.\n",
  174|      3|                    f->name, f->type);
  175|      3|            return true;
  176|      3|        }
  177|     75|    }
  178|     18|    return false;
  179|     21|}
sd_ass.c:mp_ass_add_default_styles:
  119|  4.58k|{
  120|  4.58k|    if (opts->ass_styles_file && shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (120:9): [True: 0, False: 4.58k]
  |  Branch (120:34): [True: 0, False: 0]
  ------------------
  121|      0|        char *file = mp_get_user_path(NULL, sd->global, opts->ass_styles_file);
  122|      0|        ass_read_styles(track, file, NULL);
  123|      0|        talloc_free(file);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  124|      0|    }
  125|       |
  126|  4.58k|    if (track->n_styles == 0) {
  ------------------
  |  Branch (126:9): [True: 0, False: 4.58k]
  ------------------
  127|      0|        if (!track->PlayResY) {
  ------------------
  |  Branch (127:13): [True: 0, False: 0]
  ------------------
  128|      0|            track->PlayResX = MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|      0|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  129|      0|            track->PlayResY = MP_ASS_FONT_PLAYRESY;
  ------------------
  |  |   32|      0|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  130|      0|        }
  131|      0|        track->Kerning = true;
  132|      0|        int sid = ass_alloc_style(track);
  133|      0|        track->default_style = sid;
  134|      0|        ASS_Style *style = track->styles + sid;
  135|      0|        style->Name = strdup("Default");
  136|      0|        mp_ass_set_style(style, track->PlayResY, opts->sub_style);
  137|      0|    }
  138|       |
  139|  4.58k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (139:9): [True: 4.58k, False: 0]
  ------------------
  140|  4.58k|        ass_process_force_style(track);
  141|  4.58k|}
sd_ass.c:filters_init:
  208|  2.29k|{
  209|  2.29k|    struct sd_ass_priv *ctx = sd->priv;
  210|       |
  211|  2.29k|    filters_destroy(sd);
  212|       |
  213|  6.87k|    for (int n = 0; filters[n]; n++) {
  ------------------
  |  Branch (213:21): [True: 4.58k, False: 2.29k]
  ------------------
  214|  4.58k|        struct sd_filter *ft = talloc_ptrtype(ctx, ft);
  ------------------
  |  |   34|  4.58k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  4.58k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.58k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|  4.58k|        *ft = (struct sd_filter){
  216|  4.58k|            .global = sd->global,
  217|  4.58k|            .log = sd->log,
  218|  4.58k|            .packet_pool = demux_packet_pool_get(sd->global),
  219|  4.58k|            .opts = mp_get_config_group(ft, sd->global, &mp_sub_filter_opts),
  220|  4.58k|            .driver = filters[n],
  221|  4.58k|            .codec = "ass",
  222|  4.58k|            .event_format = talloc_strdup(ft, ctx->ass_track->event_format),
  ------------------
  |  |   50|  4.58k|#define talloc_strdup                   ta_xstrdup
  ------------------
  223|  4.58k|        };
  224|  4.58k|        if (ft->driver->init(ft)) {
  ------------------
  |  Branch (224:13): [True: 0, False: 4.58k]
  ------------------
  225|      0|            MP_TARRAY_APPEND(ctx, ctx->filters, ctx->num_filters, ft);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  226|  4.58k|        } else {
  227|  4.58k|            talloc_free(ft);
  ------------------
  |  |   47|  4.58k|#define talloc_free                     ta_free
  ------------------
  228|  4.58k|        }
  229|  4.58k|    }
  230|  2.29k|}
sd_ass.c:filters_destroy:
  195|  4.58k|{
  196|  4.58k|    struct sd_ass_priv *ctx = sd->priv;
  197|       |
  198|  4.58k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (198:21): [True: 0, False: 4.58k]
  ------------------
  199|      0|        struct sd_filter *ft = ctx->filters[n];
  200|      0|        if (ft->driver->uninit)
  ------------------
  |  Branch (200:13): [True: 0, False: 0]
  ------------------
  201|      0|            ft->driver->uninit(ft);
  202|      0|        talloc_free(ft);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  203|      0|    }
  204|  4.58k|    ctx->num_filters = 0;
  205|  4.58k|}
sd_ass.c:decode:
  468|  5.96k|{
  469|  5.96k|    struct sd_ass_priv *ctx = sd->priv;
  470|  5.96k|    ASS_Track *track = ctx->ass_track;
  471|       |
  472|  5.96k|    packet->sub_duration = packet->duration;
  473|       |
  474|  5.96k|    if (ctx->converter) {
  ------------------
  |  Branch (474:9): [True: 5.70k, False: 262]
  ------------------
  475|  5.70k|        if (!sd->opts->sub_clear_on_seek && check_packet_seen(sd, packet))
  ------------------
  |  Branch (475:13): [True: 5.70k, False: 0]
  |  Branch (475:45): [True: 58, False: 5.64k]
  ------------------
  476|     58|            return;
  477|       |
  478|  5.64k|        double sub_pts = 0;
  479|  5.64k|        double sub_duration = 0;
  480|  5.64k|        char **r = lavc_conv_decode(ctx->converter, packet, &sub_pts,
  481|  5.64k|                                    &sub_duration);
  482|  5.64k|        if (sd->opts->sub_stretch_durations ||
  ------------------
  |  Branch (482:13): [True: 0, False: 5.64k]
  ------------------
  483|  5.64k|            packet->duration < 0 || sub_duration == UINT32_MAX) {
  ------------------
  |  Branch (483:13): [True: 5.10k, False: 539]
  |  Branch (483:37): [True: 0, False: 539]
  ------------------
  484|  5.10k|            MP_VERBOSE(sd, "Subtitle with unknown duration.\n");
  ------------------
  |  |   92|  5.10k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.10k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  485|  5.10k|            sub_duration = UNKNOWN_DURATION;
  ------------------
  |  |  465|  5.10k|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  486|  5.10k|        }
  487|       |
  488|  11.0k|        for (int n = 0; r && r[n]; n++) {
  ------------------
  |  Branch (488:25): [True: 11.0k, False: 0]
  |  Branch (488:30): [True: 5.44k, False: 5.64k]
  ------------------
  489|  5.44k|            struct demux_packet pkt2 = {
  490|  5.44k|                .pts = sub_pts,
  491|  5.44k|                .duration = sub_duration,
  492|  5.44k|                .buffer = r[n],
  493|  5.44k|                .len = strlen(r[n]),
  494|  5.44k|            };
  495|  5.44k|            filter_and_add(sd, &pkt2);
  496|  5.44k|        }
  497|  12.0k|        for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (497:43): [True: 11.0k, False: 914]
  ------------------
  498|  11.0k|            if (track->events[track->n_events - 1].Start == track->events[n].Start)
  ------------------
  |  Branch (498:17): [True: 6.10k, False: 4.99k]
  ------------------
  499|  6.10k|                continue;
  500|  4.99k|            if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
  ------------------
  |  |  465|  4.99k|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  |  Branch (500:17): [True: 4.95k, False: 40]
  ------------------
  501|  4.95k|                if (track->events[n].Start < track->events[n + 1].Start) {
  ------------------
  |  Branch (501:21): [True: 3.87k, False: 1.07k]
  ------------------
  502|  3.87k|                    track->events[n].Duration = track->events[n + 1].Start -
  503|  3.87k|                                                track->events[n].Start;
  504|  3.87k|                } else if (track->events[n].Start == track->events[n + 1].Start) {
  ------------------
  |  Branch (504:28): [True: 151, False: 924]
  ------------------
  505|    151|                    track->events[n].Duration = track->events[n + 1].Duration;
  506|    151|                }
  507|  4.95k|            }
  508|  4.99k|            if (n > 0 && track->events[n].Start != track->events[n - 1].Start)
  ------------------
  |  Branch (508:17): [True: 4.89k, False: 91]
  |  Branch (508:26): [True: 4.73k, False: 166]
  ------------------
  509|  4.73k|                break;
  510|  4.99k|        }
  511|  5.64k|    } else {
  512|       |        // Note that for this packet format, libass has an internal mechanism
  513|       |        // for discarding duplicate (already seen) packets but we check this
  514|       |        // anyways for our purposes for ASS subtitles.
  515|    262|        packet->seen = check_packet_seen(sd, packet);
  516|    262|        filter_and_add(sd, packet);
  517|    262|    }
  518|  5.96k|}
sd_ass.c:check_packet_seen:
  439|  5.96k|{
  440|  5.96k|    struct sd_ass_priv *priv = sd->priv;
  441|  5.96k|    int64_t sig = packet->pos >= 0 ? packet->pos
  ------------------
  |  Branch (441:19): [True: 5.70k, False: 263]
  ------------------
  442|  5.96k|                                   : hash_data(packet->buffer, packet->len);
  443|  5.96k|    int a = 0;
  444|  5.96k|    int b = priv->num_seen_packets;
  445|  31.9k|    while (a < b) {
  ------------------
  |  Branch (445:12): [True: 26.0k, False: 5.90k]
  ------------------
  446|  26.0k|        int mid = a + (b - a) / 2;
  447|  26.0k|        struct seen_packet *seen_packet = &priv->seen_packets[mid];
  448|  26.0k|        if (sig == seen_packet->sig && packet->pts == seen_packet->pts) {
  ------------------
  |  Branch (448:13): [True: 93, False: 25.9k]
  |  Branch (448:40): [True: 60, False: 33]
  ------------------
  449|     60|            packet->seen_pos = mid;
  450|     60|            return true;
  451|     60|        }
  452|  25.9k|        if (sig > seen_packet->sig ||
  ------------------
  |  Branch (452:13): [True: 25.9k, False: 44]
  ------------------
  453|  25.9k|            (sig == seen_packet->sig && packet->pts > seen_packet->pts)) {
  ------------------
  |  Branch (453:14): [True: 33, False: 11]
  |  Branch (453:41): [True: 26, False: 7]
  ------------------
  454|  25.9k|            a = mid + 1;
  455|  25.9k|        } else {
  456|     18|            b = mid;
  457|     18|        }
  458|  25.9k|    }
  459|  5.90k|    packet->seen_pos = a;
  460|  5.90k|    MP_TARRAY_INSERT_AT(priv, priv->seen_packets, priv->num_seen_packets, a,
  ------------------
  |  |  115|  5.90k|    do {                                            \
  |  |  116|  5.90k|        size_t at_ = (at);                          \
  |  |  117|  5.90k|        assert(at_ <= (idxvar));                    \
  |  |  118|  5.90k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  5.90k|    do {                                            \
  |  |  |  |   97|  5.90k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  5.90k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  5.90k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  5.90k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 964, False: 4.94k]
  |  |  |  |  ------------------
  |  |  |  |   99|  5.90k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    964|    do {                                                        \
  |  |  |  |  |  |   89|    964|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    964|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    964|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    964|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    964|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    964|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    964|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 964]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  5.90k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 5.90k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  5.90k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  5.90k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  5.90k|        (idxvar)++;                                 \
  |  |  122|  5.90k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  5.90k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 5.90k]
  |  |  ------------------
  ------------------
  |  Branch (460:5): [True: 5.90k, False: 0]
  ------------------
  461|  5.90k|                        (struct seen_packet){sig, packet->pts, -1});
  462|  5.90k|    return false;
  463|  5.90k|}
sd_ass.c:hash_data:
  427|    263|{
  428|    263|    uint64_t hash = 0xcbf29ce484222325; // offset basis
  429|  1.17k|    for (size_t n = 0; n < len; n++)
  ------------------
  |  Branch (429:24): [True: 912, False: 263]
  ------------------
  430|    912|        hash = (hash ^ data[n]) * 0x100000001b3; // FNV prime
  431|    263|    return hash;
  432|    263|}
sd_ass.c:filter_and_add:
  371|  5.70k|{
  372|  5.70k|    struct sd_ass_priv *ctx = sd->priv;
  373|  5.70k|    struct demux_packet *orig_pkt = pkt;
  374|  5.70k|    ASS_Track *track = ctx->ass_track;
  375|  5.70k|    int old_n_events = track->n_events;
  376|       |
  377|  5.70k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (377:21): [True: 0, False: 5.70k]
  ------------------
  378|      0|        struct sd_filter *ft = ctx->filters[n];
  379|      0|        struct demux_packet *npkt = ft->driver->filter(ft, pkt);
  380|      0|        if (pkt != npkt && pkt != orig_pkt)
  ------------------
  |  Branch (380:13): [True: 0, False: 0]
  |  Branch (380:28): [True: 0, False: 0]
  ------------------
  381|      0|            talloc_free(pkt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  382|      0|        pkt = npkt;
  383|      0|        if (!pkt)
  ------------------
  |  Branch (383:13): [True: 0, False: 0]
  ------------------
  384|      0|            return;
  385|      0|    }
  386|       |
  387|  5.70k|    ass_process_chunk(ctx->ass_track, pkt->buffer, pkt->len,
  388|  5.70k|                      floor(pkt->pts * 1000 + 1e-6),
  389|  5.70k|                      floor(pkt->duration * 1000 + 1e-6));
  390|  5.70k|    if (pkt != orig_pkt)
  ------------------
  |  Branch (390:9): [True: 0, False: 5.70k]
  ------------------
  391|      0|        talloc_free(pkt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  392|       |    // the seen and animated state is kept on the original packet
  393|  5.70k|    pkt = orig_pkt;
  394|       |
  395|       |    // This bookkeeping only has any practical use for ASS subs
  396|       |    // over a VO with no video.
  397|  5.70k|    if (!ctx->is_converted) {
  ------------------
  |  Branch (397:9): [True: 262, False: 5.44k]
  ------------------
  398|    262|        if (!pkt->seen) {
  ------------------
  |  Branch (398:13): [True: 260, False: 2]
  ------------------
  399|    337|            for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (399:47): [True: 193, False: 144]
  ------------------
  400|    193|                if (n + 1 == old_n_events || pkt->animated == 1)
  ------------------
  |  Branch (400:21): [True: 116, False: 77]
  |  Branch (400:46): [True: 0, False: 77]
  ------------------
  401|    116|                    break;
  402|     77|                ASS_Event *event = &track->events[n];
  403|       |                // Might as well mark pkt->animated here with effects if we can.
  404|     77|                pkt->animated = (event->Effect && event->Effect[0]) ? 1 : -1;
  ------------------
  |  Branch (404:34): [True: 68, False: 9]
  |  Branch (404:51): [True: 4, False: 64]
  ------------------
  405|     77|                if (ctx->check_animated && pkt->animated != 1)
  ------------------
  |  Branch (405:21): [True: 37, False: 40]
  |  Branch (405:44): [True: 35, False: 2]
  ------------------
  406|     35|                    pkt->animated = is_animated(event->Text);
  407|     77|            }
  408|    260|            ctx->seen_packets[pkt->seen_pos].animated = pkt->animated;
  409|    260|        } else {
  410|      2|            if (ctx->check_animated && ctx->seen_packets[pkt->seen_pos].animated == -1) {
  ------------------
  |  Branch (410:17): [True: 2, False: 0]
  |  Branch (410:40): [True: 0, False: 2]
  ------------------
  411|      0|                for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (411:51): [True: 0, False: 0]
  ------------------
  412|      0|                    if (n + 1 == old_n_events || pkt->animated == 1)
  ------------------
  |  Branch (412:25): [True: 0, False: 0]
  |  Branch (412:50): [True: 0, False: 0]
  ------------------
  413|      0|                        break;
  414|      0|                    ASS_Event *event = &track->events[n];
  415|      0|                    ctx->seen_packets[pkt->seen_pos].animated = is_animated(event->Text);
  416|      0|                    pkt->animated = ctx->seen_packets[pkt->seen_pos].animated;
  417|      0|                }
  418|      2|            } else {
  419|      2|                pkt->animated = ctx->seen_packets[pkt->seen_pos].animated;
  420|      2|            }
  421|      2|        }
  422|    262|    }
  423|  5.70k|}
sd_ass.c:is_animated:
  340|     35|{
  341|     35|    const char *begin = str;
  342|     38|    while ((str = strchr(str, '{'))) {
  ------------------
  |  Branch (342:12): [True: 30, False: 8]
  ------------------
  343|     30|        if (str++ > begin && str[-2] == '\\')
  ------------------
  |  Branch (343:13): [True: 4, False: 26]
  |  Branch (343:30): [True: 0, False: 4]
  ------------------
  344|      0|            continue;
  345|       |
  346|     30|        const char *end = strchr(str, '}');
  347|     30|        if (!end)
  ------------------
  |  Branch (347:13): [True: 2, False: 28]
  ------------------
  348|      2|            return false;
  349|       |
  350|    109|        while ((str = memchr(str, '\\', end - str))) {
  ------------------
  |  Branch (350:16): [True: 106, False: 3]
  ------------------
  351|    212|            while (str[0] == '\\')
  ------------------
  |  Branch (351:20): [True: 106, False: 106]
  ------------------
  352|    106|                ++str;
  353|    106|            while (str[0] == ' ' || str[0] == '\t')
  ------------------
  |  Branch (353:20): [True: 0, False: 106]
  |  Branch (353:37): [True: 0, False: 106]
  ------------------
  354|      0|                ++str;
  355|    106|            if (str[0] == 'k' || str[0] == 'K' || str[0] == 't' ||
  ------------------
  |  Branch (355:17): [True: 0, False: 106]
  |  Branch (355:34): [True: 0, False: 106]
  |  Branch (355:51): [True: 11, False: 95]
  ------------------
  356|     95|                (str[0] == 'f' && str[1] == 'a' && str[2] == 'd') ||
  ------------------
  |  Branch (356:18): [True: 32, False: 63]
  |  Branch (356:35): [True: 15, False: 17]
  |  Branch (356:52): [True: 14, False: 1]
  ------------------
  357|     81|                (str[0] == 'm' && str[1] == 'o' && str[2] == 'v' && str[3] == 'e'))
  ------------------
  |  Branch (357:18): [True: 0, False: 81]
  |  Branch (357:35): [True: 0, False: 0]
  |  Branch (357:52): [True: 0, False: 0]
  |  Branch (357:69): [True: 0, False: 0]
  ------------------
  358|     25|            {
  359|     25|                return true;
  360|     25|            }
  361|    106|        }
  362|       |
  363|      3|        str = end + 1;
  364|      3|    }
  365|       |
  366|      8|    return false;
  367|     35|}
sd_ass.c:reset:
 1008|  4.57k|{
 1009|  4.57k|    struct sd_ass_priv *ctx = sd->priv;
 1010|  4.57k|    if (sd->opts->sub_clear_on_seek || ctx->clear_once) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 4.57k]
  |  Branch (1010:40): [True: 0, False: 4.57k]
  ------------------
 1011|      0|        ass_flush_events(ctx->ass_track);
 1012|      0|        ctx->num_seen_packets = 0;
 1013|      0|        sd->preload_ok = false;
 1014|      0|        ctx->clear_once = false;
 1015|      0|    }
 1016|  4.57k|    if (ctx->converter)
  ------------------
  |  Branch (1016:9): [True: 2.68k, False: 1.89k]
  ------------------
 1017|  2.68k|        lavc_conv_reset(ctx->converter);
 1018|  4.57k|}
sd_ass.c:enable_output:
  233|  9.14k|{
  234|  9.14k|    struct sd_ass_priv *ctx = sd->priv;
  235|  9.14k|    if (enable == !!ctx->ass_renderer)
  ------------------
  |  Branch (235:9): [True: 4.56k, False: 4.58k]
  ------------------
  236|  4.56k|        return;
  237|  4.58k|    if (ctx->ass_renderer) {
  ------------------
  |  Branch (237:9): [True: 2.29k, False: 2.29k]
  ------------------
  238|  2.29k|        ass_renderer_done(ctx->ass_renderer);
  239|  2.29k|        ctx->ass_renderer = NULL;
  240|  2.29k|    } else {
  241|  2.29k|        ctx->ass_renderer = ass_renderer_init(ctx->ass_library);
  242|       |
  243|  2.29k|        mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_style,
  244|  2.29k|                               sd->global, sd->log);
  245|  2.29k|    }
  246|  4.58k|}
sd_ass.c:uninit:
 1021|  2.29k|{
 1022|  2.29k|    struct sd_ass_priv *ctx = sd->priv;
 1023|       |
 1024|  2.29k|    filters_destroy(sd);
 1025|  2.29k|    if (ctx->converter)
  ------------------
  |  Branch (1025:9): [True: 1.34k, False: 942]
  ------------------
 1026|  1.34k|        lavc_conv_uninit(ctx->converter);
 1027|  2.29k|    assobjects_destroy(sd);
 1028|  2.29k|    talloc_free(ctx->copy_cache);
  ------------------
  |  |   47|  2.29k|#define talloc_free                     ta_free
  ------------------
 1029|  2.29k|}
sd_ass.c:assobjects_destroy:
  294|  2.29k|{
  295|  2.29k|    struct sd_ass_priv *ctx = sd->priv;
  296|       |
  297|  2.29k|    ass_free_track(ctx->ass_track);
  298|  2.29k|    ass_free_track(ctx->shadow_track);
  299|       |    enable_output(sd, false);
  300|  2.29k|    ass_library_done(ctx->ass_library);
  301|  2.29k|}
sd_ass.c:control:
 1070|  45.0k|{
 1071|  45.0k|    struct sd_ass_priv *ctx = sd->priv;
 1072|  45.0k|    switch (cmd) {
 1073|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (1073:5): [True: 0, False: 45.0k]
  ------------------
 1074|      0|        double *a = arg;
 1075|      0|        long long ts = floor(a[0] * 1000.0 + 1e-6);
 1076|      0|        long long res = ass_step_sub(ctx->ass_track, ts, a[1]);
 1077|      0|        if (!res)
  ------------------
  |  Branch (1077:13): [True: 0, False: 0]
  ------------------
 1078|      0|            return false;
 1079|       |        // Try to account for overlapping durations
 1080|      0|        a[0] += res / 1000.0 + SUB_SEEK_OFFSET;
  ------------------
  |  |    9|      0|#define SUB_SEEK_OFFSET 0.01
  ------------------
 1081|      0|        return true;
 1082|      0|    }
 1083|  25.0k|    case SD_CTRL_SET_ANIMATED_CHECK:
  ------------------
  |  Branch (1083:5): [True: 25.0k, False: 19.9k]
  ------------------
 1084|  25.0k|        ctx->check_animated = *(bool *)arg;
 1085|  25.0k|        return CONTROL_OK;
  ------------------
  |  |   95|  25.0k|#define CONTROL_OK 1
  ------------------
 1086|      0|    case SD_CTRL_RESET_SOFT:
  ------------------
  |  Branch (1086:5): [True: 0, False: 45.0k]
  ------------------
 1087|      0|        ctx->clear_once = true;
 1088|      0|        reset(sd);
 1089|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
 1090|  19.9k|    case SD_CTRL_SET_VIDEO_PARAMS:
  ------------------
  |  Branch (1090:5): [True: 19.9k, False: 25.0k]
  ------------------
 1091|  19.9k|        ctx->video_params = *(struct mp_image_params *)arg;
 1092|  19.9k|        return CONTROL_OK;
  ------------------
  |  |   95|  19.9k|#define CONTROL_OK 1
  ------------------
 1093|      0|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (1093:5): [True: 0, False: 45.0k]
  ------------------
 1094|      0|        uint64_t flags = *(uint64_t *)arg;
 1095|      0|        if (flags & UPDATE_SUB_FILT) {
  ------------------
  |  |  443|      0|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
  |  Branch (1095:13): [True: 0, False: 0]
  ------------------
 1096|      0|            filters_destroy(sd);
 1097|      0|            filters_init(sd);
 1098|      0|            ctx->clear_once = true; // allow reloading on seeks
 1099|      0|            reset(sd);
 1100|      0|        }
 1101|      0|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|      0|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (1101:13): [True: 0, False: 0]
  ------------------
 1102|       |            // ass_track will be recreated, so clear duplicate cache
 1103|      0|            ctx->clear_once = true;
 1104|      0|            reset(sd);
 1105|      0|            assobjects_destroy(sd);
 1106|      0|            assobjects_init(sd);
 1107|      0|        }
 1108|      0|        ctx->ass_configured = false; // ass always needs to be reconfigured
 1109|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
 1110|      0|    }
 1111|      0|    default:
  ------------------
  |  Branch (1111:5): [True: 0, False: 45.0k]
  ------------------
 1112|      0|        return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1113|  45.0k|    }
 1114|  45.0k|}
sd_ass.c:find_timestamp:
  673|    124|{
  674|    124|    struct sd_ass_priv *priv = sd->priv;
  675|    124|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    124|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (675:9): [True: 0, False: 124]
  ------------------
  676|      0|        return 0;
  677|       |
  678|    124|    long long ts = floor(pts * 1000 + 1e-6);
  679|       |
  680|    124|    if (!sd->opts->sub_fix_timing ||
  ------------------
  |  Branch (680:9): [True: 124, False: 0]
  ------------------
  681|      0|        sd->shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_NONE)
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  ------------------
  682|    124|        return ts;
  683|       |
  684|       |    // Try to fix small gaps and overlaps.
  685|      0|    ASS_Track *track = priv->ass_track;
  686|      0|    int threshold = sd->opts->sub_fix_timing_threshold;
  687|      0|    int keep = sd->opts->sub_fix_timing_keep;
  688|       |
  689|       |    // Find the "current" event.
  690|      0|    ASS_Event *ev[2] = {0};
  691|      0|    int n_ev = 0;
  692|      0|    for (int n = 0; n < track->n_events; n++) {
  ------------------
  |  Branch (692:21): [True: 0, False: 0]
  ------------------
  693|      0|        ASS_Event *event = &track->events[n];
  694|      0|        if (ts >= event->Start - threshold && ts <= END(event) + threshold) {
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (694:13): [True: 0, False: 0]
  |  Branch (694:47): [True: 0, False: 0]
  ------------------
  695|      0|            if (n_ev >= MP_ARRAY_SIZE(ev))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (695:17): [True: 0, False: 0]
  ------------------
  696|      0|                return ts; // multiple overlaps - give up (probably complex subs)
  697|      0|            ev[n_ev++] = event;
  698|      0|        }
  699|      0|    }
  700|       |
  701|      0|    if (n_ev != 2)
  ------------------
  |  Branch (701:9): [True: 0, False: 0]
  ------------------
  702|      0|        return ts;
  703|       |
  704|       |    // Simple/minor heuristic against destroying typesetting.
  705|      0|    if (ev[0]->Style != ev[1]->Style || has_overrides(ev[0]->Text) ||
  ------------------
  |  Branch (705:9): [True: 0, False: 0]
  |  Branch (705:41): [True: 0, False: 0]
  ------------------
  706|      0|        has_overrides(ev[1]->Text))
  ------------------
  |  Branch (706:9): [True: 0, False: 0]
  ------------------
  707|      0|        return ts;
  708|       |
  709|       |    // Sort by start timestamps.
  710|      0|    if (ev[0]->Start > ev[1]->Start)
  ------------------
  |  Branch (710:9): [True: 0, False: 0]
  ------------------
  711|      0|        MPSWAP(ASS_Event*, ev[0], ev[1]);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
  712|       |
  713|       |    // We want to fix partial overlaps only.
  714|      0|    if (END(ev[0]) >= END(ev[1]))
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
                  if (END(ev[0]) >= END(ev[1]))
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (714:9): [True: 0, False: 0]
  ------------------
  715|      0|        return ts;
  716|       |
  717|      0|    if (ev[0]->Duration < keep || ev[1]->Duration < keep)
  ------------------
  |  Branch (717:9): [True: 0, False: 0]
  |  Branch (717:35): [True: 0, False: 0]
  ------------------
  718|      0|        return ts;
  719|       |
  720|       |    // Gap between the events -> move ts to show the end of the first event.
  721|      0|    if (ts >= END(ev[0]) && ts < ev[1]->Start && END(ev[0]) < ev[1]->Start &&
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
                  if (ts >= END(ev[0]) && ts < ev[1]->Start && END(ev[0]) < ev[1]->Start &&
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (721:9): [True: 0, False: 0]
  |  Branch (721:29): [True: 0, False: 0]
  |  Branch (721:50): [True: 0, False: 0]
  ------------------
  722|      0|        END(ev[0]) + threshold >= ev[1]->Start)
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (722:9): [True: 0, False: 0]
  ------------------
  723|      0|        return END(ev[0]) - 1;
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  724|       |
  725|       |    // Overlap -> move ts to the (exclusive) end of the first event.
  726|       |    // Relies on the fact that the ASS_Renderer has no overlap registered, even
  727|       |    // if there is one. This happens to work because we never render the
  728|       |    // overlapped state, and libass never resolves a collision.
  729|      0|    if (ts >= ev[1]->Start && ts <= END(ev[0]) && END(ev[0]) > ev[1]->Start &&
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
                  if (ts >= ev[1]->Start && ts <= END(ev[0]) && END(ev[0]) > ev[1]->Start &&
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (729:9): [True: 0, False: 0]
  |  Branch (729:31): [True: 0, False: 0]
  |  Branch (729:51): [True: 0, False: 0]
  ------------------
  730|      0|        END(ev[0]) <= ev[1]->Start + threshold)
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  |  Branch (730:9): [True: 0, False: 0]
  ------------------
  731|      0|        return END(ev[0]);
  ------------------
  |  |  670|      0|#define END(ev) ((ev)->Start + (ev)->Duration)
  ------------------
  732|       |
  733|      0|    return ts;
  734|      0|}
sd_ass.c:get_text_buf:
  870|    611|{
  871|    611|    struct sd_ass_priv *ctx = sd->priv;
  872|    611|    ASS_Track *track = ctx->ass_track;
  873|       |
  874|    611|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    611|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (874:9): [True: 487, False: 124]
  ------------------
  875|    487|        return (bstr){0};
  876|    124|    long long ipts = find_timestamp(sd, pts);
  877|       |
  878|    124|    bstr *b = &ctx->last_text;
  879|       |
  880|    124|    if (!b->start)
  ------------------
  |  Branch (880:9): [True: 52, False: 72]
  ------------------
  881|     52|        b->start = talloc_size(ctx, 4096);
  ------------------
  |  |   43|     52|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|     52|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|     52|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     52|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     52|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     52|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  882|       |
  883|    124|    b->len = 0;
  884|       |
  885|  10.8k|    for (int i = 0; i < track->n_events; ++i) {
  ------------------
  |  Branch (885:21): [True: 10.7k, False: 124]
  ------------------
  886|  10.7k|        ASS_Event *event = track->events + i;
  887|  10.7k|        if (ipts >= event->Start && ipts < event->Start + event->Duration) {
  ------------------
  |  Branch (887:13): [True: 1.25k, False: 9.45k]
  |  Branch (887:37): [True: 745, False: 510]
  ------------------
  888|    745|            if (event->Text) {
  ------------------
  |  Branch (888:17): [True: 745, False: 0]
  ------------------
  889|    745|                int start = b->len;
  890|    745|                if (type == SD_TEXT_TYPE_PLAIN) {
  ------------------
  |  Branch (890:21): [True: 745, False: 0]
  ------------------
  891|    745|                    ass_to_plaintext(b, event->Text);
  892|    745|                } else if (type == SD_TEXT_TYPE_ASS_FULL) {
  ------------------
  |  Branch (892:28): [True: 0, False: 0]
  ------------------
  893|      0|                    long long s = event->Start;
  894|      0|                    long long e = s + event->Duration;
  895|       |
  896|      0|                    ASS_Style *style = (event->Style < 0 || event->Style >= track->n_styles) ? NULL : &track->styles[event->Style];
  ------------------
  |  Branch (896:41): [True: 0, False: 0]
  |  Branch (896:61): [True: 0, False: 0]
  ------------------
  897|       |
  898|      0|                    int sh = (s / 60 / 60 / 1000);
  899|      0|                    int sm = (s / 60 / 1000) % 60;
  900|      0|                    int ss = (s / 1000) % 60;
  901|      0|                    int sc = (s / 10) % 100;
  902|      0|                    int eh = (e / 60 / 60 / 1000);
  903|      0|                    int em = (e / 60 / 1000) % 60;
  904|      0|                    int es = (e / 1000) % 60;
  905|      0|                    int ec = (e / 10) % 100;
  906|       |
  907|      0|                    bstr_xappend_asprintf(NULL, b, "Dialogue: %d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%04d,%04d,%04d,%s,%s",
  908|      0|                        event->Layer,
  909|      0|                        sh, sm, ss, sc,
  910|      0|                        eh, em, es, ec,
  911|      0|                        (style && style->Name) ? style->Name : "", event->Name,
  ------------------
  |  Branch (911:26): [True: 0, False: 0]
  |  Branch (911:35): [True: 0, False: 0]
  ------------------
  912|      0|                        event->MarginL, event->MarginR, event->MarginV,
  913|      0|                        event->Effect, event->Text);
  914|      0|                } else {
  915|      0|                    bstr_xappend(NULL, b, bstr0(event->Text));
  916|      0|                }
  917|    745|                if (is_whitespace_only(bstr_cut(*b, start))) {
  ------------------
  |  Branch (917:21): [True: 4, False: 741]
  ------------------
  918|      4|                    b->len = start;
  919|    741|                } else {
  920|    741|                    append(b, '\n');
  921|    741|                }
  922|    745|            }
  923|    745|        }
  924|  10.7k|    }
  925|       |
  926|    124|    bstr_eatend(b, (bstr)bstr0_lit("\n"));
  ------------------
  |  |   59|    124|#define bstr0_lit(s) {(unsigned char *)(s), sizeof("" s) - 1}
  ------------------
  927|       |
  928|    124|    return *b;
  929|    611|}
sd_ass.c:is_whitespace_only:
  861|    745|{
  862|    745|    for (int n = 0; n < b.len; n++) {
  ------------------
  |  Branch (862:21): [True: 741, False: 4]
  ------------------
  863|    741|        if (b.start[n] != ' ' && b.start[n] != '\t')
  ------------------
  |  Branch (863:13): [True: 741, False: 0]
  |  Branch (863:34): [True: 741, False: 0]
  ------------------
  864|    741|            return false;
  865|    741|    }
  866|      4|    return true;
  867|    745|}
sd_ass.c:append:
  810|  20.7k|{
  811|       |    bstr_xappend(NULL, b, (bstr){&c, 1});
  812|  20.7k|}
sd_ass.c:get_text:
  932|    611|{
  933|       |    return bstrto0(NULL, get_text_buf(sd, pts, type));
  934|    611|}
sd_ass.c:ass_to_plaintext:
  815|    745|{
  816|    745|    const char *open_tag_pos = NULL;
  817|    745|    bool in_drawing = false;
  818|  53.6k|    while (*in) {
  ------------------
  |  Branch (818:12): [True: 52.9k, False: 745]
  ------------------
  819|  52.9k|        if (open_tag_pos) {
  ------------------
  |  Branch (819:13): [True: 32.0k, False: 20.8k]
  ------------------
  820|  32.0k|            if (in[0] == '}') {
  ------------------
  |  Branch (820:17): [True: 842, False: 31.2k]
  ------------------
  821|    842|                in += 1;
  822|    842|                open_tag_pos = NULL;
  823|  31.2k|            } else if (in[0] == '\\' && in[1] == 'p' && in[2] != 'o') {
  ------------------
  |  Branch (823:24): [True: 3.35k, False: 27.8k]
  |  Branch (823:41): [True: 510, False: 2.84k]
  |  Branch (823:57): [True: 0, False: 510]
  ------------------
  824|      0|                in += 2;
  825|       |                // Skip text between \pN and \p0 tags. A \p without a number
  826|       |                // is the same as \p0, and leading 0s are also allowed.
  827|      0|                in_drawing = false;
  828|      0|                while (in[0] >= '0' && in[0] <= '9') {
  ------------------
  |  Branch (828:24): [True: 0, False: 0]
  |  Branch (828:40): [True: 0, False: 0]
  ------------------
  829|      0|                    if (in[0] != '0')
  ------------------
  |  Branch (829:25): [True: 0, False: 0]
  ------------------
  830|      0|                        in_drawing = true;
  831|      0|                    in += 1;
  832|      0|                }
  833|  31.2k|            } else {
  834|  31.2k|                in += 1;
  835|  31.2k|            }
  836|  32.0k|        } else {
  837|  20.8k|            if (in[0] == '\\' && (in[1] == 'N' || in[1] == 'n')) {
  ------------------
  |  Branch (837:17): [True: 136, False: 20.6k]
  |  Branch (837:35): [True: 136, False: 0]
  |  Branch (837:51): [True: 0, False: 0]
  ------------------
  838|    136|                in += 2;
  839|    136|                append(b, '\n');
  840|  20.6k|            } else if (in[0] == '\\' && in[1] == 'h') {
  ------------------
  |  Branch (840:24): [True: 0, False: 20.6k]
  |  Branch (840:41): [True: 0, False: 0]
  ------------------
  841|      0|                in += 2;
  842|      0|                append(b, ' ');
  843|  20.6k|            } else if (in[0] == '{') {
  ------------------
  |  Branch (843:24): [True: 844, False: 19.8k]
  ------------------
  844|    844|                open_tag_pos = in;
  845|    844|                in += 1;
  846|  19.8k|            } else {
  847|  19.8k|                if (!in_drawing)
  ------------------
  |  Branch (847:21): [True: 19.8k, False: 0]
  ------------------
  848|  19.8k|                    append(b, in[0]);
  849|  19.8k|                in += 1;
  850|  19.8k|            }
  851|  20.8k|        }
  852|  52.9k|    }
  853|       |    // A '{' without a closing '}' is always visible.
  854|    745|    if (open_tag_pos) {
  ------------------
  |  Branch (854:9): [True: 2, False: 743]
  ------------------
  855|       |        bstr_xappend(NULL, b, bstr0(open_tag_pos));
  856|      2|    }
  857|    745|}

sd_lavc.c:init:
   82|  2.71k|{
   83|  2.71k|    enum AVCodecID cid = mp_codec_to_av_codec_id(sd->codec->codec);
   84|       |
   85|       |    // Supported codecs must be known to decode to paletted bitmaps
   86|  2.71k|    switch (cid) {
   87|      0|    case AV_CODEC_ID_DVB_SUBTITLE:
  ------------------
  |  Branch (87:5): [True: 0, False: 2.71k]
  ------------------
   88|      0|    case AV_CODEC_ID_DVB_TELETEXT:
  ------------------
  |  Branch (88:5): [True: 0, False: 2.71k]
  ------------------
   89|      0|    case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
  ------------------
  |  Branch (89:5): [True: 0, False: 2.71k]
  ------------------
   90|      0|    case AV_CODEC_ID_XSUB:
  ------------------
  |  Branch (90:5): [True: 0, False: 2.71k]
  ------------------
   91|    329|    case AV_CODEC_ID_DVD_SUBTITLE:
  ------------------
  |  Branch (91:5): [True: 329, False: 2.38k]
  ------------------
   92|    329|    case AV_CODEC_ID_ARIB_CAPTION:
  ------------------
  |  Branch (92:5): [True: 0, False: 2.71k]
  ------------------
   93|    329|        break;
   94|  2.38k|    default:
  ------------------
  |  Branch (94:5): [True: 2.38k, False: 329]
  ------------------
   95|  2.38k|        return -1;
   96|  2.71k|    }
   97|       |
   98|    329|    struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
  ------------------
  |  |   27|    329|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    329|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    329|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|    329|    AVCodecContext *ctx = NULL;
  100|    329|    const AVCodec *sub_codec = avcodec_find_decoder(cid);
  101|    329|    if (!sub_codec)
  ------------------
  |  Branch (101:9): [True: 0, False: 329]
  ------------------
  102|      0|        goto error_probe;
  103|    329|    ctx = avcodec_alloc_context3(sub_codec);
  104|    329|    if (!ctx)
  ------------------
  |  Branch (104:9): [True: 0, False: 329]
  ------------------
  105|      0|        goto error_probe;
  106|       |
  107|    329|    mp_set_avopts(sd->log, ctx, sd->opts->sub_avopts);
  108|       |
  109|    329|    switch (cid) {
  ------------------
  |  Branch (109:13): [True: 0, False: 329]
  ------------------
  110|      0|    case AV_CODEC_ID_DVB_TELETEXT: {
  ------------------
  |  Branch (110:5): [True: 0, False: 329]
  ------------------
  111|      0|        int64_t format = -1;
  112|      0|        int ret = av_opt_get_int(ctx, "txt_format", AV_OPT_SEARCH_CHILDREN, &format);
  113|       |        // libzvbi_teletextdec: format == 0 is bitmap
  114|      0|        if (ret || format)
  ------------------
  |  Branch (114:13): [True: 0, False: 0]
  |  Branch (114:20): [True: 0, False: 0]
  ------------------
  115|      0|            goto error_probe;
  116|      0|        break;
  117|      0|    }
  118|      0|    case AV_CODEC_ID_ARIB_CAPTION: {
  ------------------
  |  Branch (118:5): [True: 0, False: 329]
  ------------------
  119|      0|        int64_t format = -1;
  120|       |        // FFmpeg has both libaribb24 and libaribcaption as decoders. Only the latter
  121|       |        // can produce bitmaps, so abort if we don't find the option.
  122|      0|        int ret = av_opt_get_int(ctx, "sub_type", AV_OPT_SEARCH_CHILDREN, &format);
  123|      0|        if (ret || format != SUBTITLE_BITMAP)
  ------------------
  |  Branch (123:13): [True: 0, False: 0]
  |  Branch (123:20): [True: 0, False: 0]
  ------------------
  124|      0|            goto error_probe;
  125|      0|        break;
  126|      0|    }
  127|    329|    }
  128|       |
  129|    329|    MP_VERBOSE(sd, "Using subtitle decoder %s\n", sub_codec->name);
  ------------------
  |  |   92|    329|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    329|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  130|       |
  131|    329|    priv->avpkt = av_packet_alloc();
  132|    329|    priv->codec = sd->codec;
  133|    329|    if (!priv->avpkt)
  ------------------
  |  Branch (133:9): [True: 0, False: 329]
  ------------------
  134|      0|        goto error;
  135|    329|    if (mp_set_avctx_codec_headers(ctx, sd->codec) < 0)
  ------------------
  |  Branch (135:9): [True: 0, False: 329]
  ------------------
  136|      0|        goto error;
  137|    329|    priv->pkt_timebase = mp_get_codec_timebase(sd->codec);
  138|    329|    ctx->pkt_timebase = priv->pkt_timebase;
  139|    329|    if (avcodec_open2(ctx, sub_codec, NULL) < 0)
  ------------------
  |  Branch (139:9): [True: 3, False: 326]
  ------------------
  140|      3|        goto error;
  141|    326|    priv->avctx = ctx;
  142|    326|    sd->priv = priv;
  143|    326|    priv->displayed_id = -1;
  144|    326|    priv->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    326|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  145|    326|    priv->packer = talloc_zero(priv, struct bitmap_packer);
  ------------------
  |  |   27|    326|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    326|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    326|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|    326|    return 0;
  147|       |
  148|      3|error:
  149|      3|    MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n");
  ------------------
  |  |   88|      3|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      3|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  150|      3|error_probe:
  151|      3|    avcodec_free_context(&ctx);
  152|      3|    mp_free_av_packet(&priv->avpkt);
  153|      3|    talloc_free(priv);
  ------------------
  |  |   47|      3|#define talloc_free                     ta_free
  ------------------
  154|      3|    return -1;
  155|      3|}
sd_lavc.c:decode:
  369|     69|{
  370|     69|    struct mp_subtitle_opts *opts = sd->opts;
  371|     69|    struct sd_lavc_priv *priv = sd->priv;
  372|     69|    AVCodecContext *ctx = priv->avctx;
  373|     69|    double pts = packet->pts;
  374|     69|    double endpts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|     69|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  375|     69|    AVSubtitle sub;
  376|       |
  377|     69|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|     69|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (377:9): [True: 0, False: 69]
  ------------------
  378|     69|        MP_WARN(sd, "Subtitle with unknown start time.\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__)
  |  |  ------------------
  ------------------
  379|       |
  380|     69|    mp_set_av_packet(priv->avpkt, packet, &priv->pkt_timebase);
  381|       |
  382|     69|    if (ctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
  ------------------
  |  Branch (382:9): [True: 0, False: 69]
  ------------------
  383|      0|        if (!opts->teletext_page) {
  ------------------
  |  Branch (383:13): [True: 0, False: 0]
  ------------------
  384|      0|            av_opt_set(ctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN);
  385|      0|        } else if (opts->teletext_page == -1) {
  ------------------
  |  Branch (385:20): [True: 0, False: 0]
  ------------------
  386|      0|            av_opt_set(ctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN);
  387|      0|        } else {
  388|      0|            char page[4];
  389|      0|            snprintf(page, sizeof(page), "%d", opts->teletext_page);
  390|      0|            av_opt_set(ctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN);
  391|      0|        }
  392|      0|    }
  393|       |
  394|     69|    int got_sub;
  395|     69|    int res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, priv->avpkt);
  396|     69|    if (res < 0 || !got_sub)
  ------------------
  |  Branch (396:9): [True: 0, False: 69]
  |  Branch (396:20): [True: 69, False: 0]
  ------------------
  397|     69|        return;
  398|       |
  399|      0|    mp_codec_info_from_av(ctx, priv->codec);
  400|       |
  401|      0|    packet->sub_duration = sub.end_display_time;
  402|       |
  403|      0|    if (sub.pts != AV_NOPTS_VALUE)
  ------------------
  |  Branch (403:9): [True: 0, False: 0]
  ------------------
  404|      0|        pts = sub.pts / (double)AV_TIME_BASE;
  405|       |
  406|      0|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (406:9): [True: 0, False: 0]
  ------------------
  407|      0|        if (sub.end_display_time > sub.start_display_time &&
  ------------------
  |  Branch (407:13): [True: 0, False: 0]
  ------------------
  408|      0|            sub.end_display_time != UINT32_MAX)
  ------------------
  |  Branch (408:13): [True: 0, False: 0]
  ------------------
  409|      0|        {
  410|      0|            endpts = pts + sub.end_display_time / 1000.0;
  411|      0|        }
  412|      0|        pts += sub.start_display_time / 1000.0;
  413|       |
  414|       |        // set end time of previous sub
  415|      0|        struct sub *prev = &priv->subs[0];
  416|      0|        if (prev->valid) {
  ------------------
  |  Branch (416:13): [True: 0, False: 0]
  ------------------
  417|      0|            if (prev->endpts == MP_NOPTS_VALUE || prev->endpts > pts)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (417:17): [True: 0, False: 0]
  |  Branch (417:51): [True: 0, False: 0]
  ------------------
  418|      0|                prev->endpts = pts;
  419|       |
  420|      0|            if (opts->sub_fix_timing && pts - prev->endpts <= opts->sub_fix_timing_threshold / 1000.0)
  ------------------
  |  Branch (420:17): [True: 0, False: 0]
  |  Branch (420:41): [True: 0, False: 0]
  ------------------
  421|      0|                prev->endpts = pts;
  422|       |
  423|      0|            for (int n = 0; n < priv->num_seekpoints; n++) {
  ------------------
  |  Branch (423:29): [True: 0, False: 0]
  ------------------
  424|      0|                if (priv->seekpoints[n].pts == prev->pts) {
  ------------------
  |  Branch (424:21): [True: 0, False: 0]
  ------------------
  425|      0|                    priv->seekpoints[n].endpts = prev->endpts;
  426|      0|                    break;
  427|      0|                }
  428|      0|            }
  429|      0|        }
  430|       |
  431|       |        // This subtitle packet only signals the end of subtitle display.
  432|      0|        if (!sub.num_rects) {
  ------------------
  |  Branch (432:13): [True: 0, False: 0]
  ------------------
  433|      0|            avsubtitle_free(&sub);
  434|      0|            return;
  435|      0|        }
  436|      0|    }
  437|       |
  438|      0|    alloc_sub(priv);
  439|      0|    struct sub *current = &priv->subs[0];
  440|       |
  441|      0|    current->valid = true;
  442|      0|    current->pts = pts;
  443|      0|    current->endpts = endpts;
  444|      0|    current->avsub = sub;
  445|       |
  446|      0|    read_sub_bitmaps(sd, current);
  447|       |
  448|      0|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (448:9): [True: 0, False: 0]
  ------------------
  449|      0|        for (int n = 0; n < priv->num_seekpoints; n++) {
  ------------------
  |  Branch (449:25): [True: 0, False: 0]
  ------------------
  450|      0|            if (priv->seekpoints[n].pts == pts)
  ------------------
  |  Branch (450:17): [True: 0, False: 0]
  ------------------
  451|      0|                goto skip;
  452|      0|        }
  453|       |        // Set arbitrary limit as safe-guard against insane files.
  454|      0|        if (priv->num_seekpoints >= 10000)
  ------------------
  |  Branch (454:13): [True: 0, False: 0]
  ------------------
  455|      0|            MP_TARRAY_REMOVE_AT(priv->seekpoints, priv->num_seekpoints, 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 (455:13): [True: 0, False: 0]
  ------------------
  456|      0|        MP_TARRAY_APPEND(priv, priv->seekpoints, priv->num_seekpoints,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  457|      0|                         (struct seekpoint){.pts = pts, .endpts = endpts});
  458|      0|        skip: ;
  459|      0|    }
  460|      0|}
sd_lavc.c:clear_sub:
  158|  3.93k|{
  159|  3.93k|    sub->count = 0;
  160|  3.93k|    sub->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  3.93k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  161|  3.93k|    sub->endpts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  3.93k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  162|  3.93k|    if (sub->valid)
  ------------------
  |  Branch (162:9): [True: 0, False: 3.93k]
  ------------------
  163|      0|        avsubtitle_free(&sub->avsub);
  164|       |    sub->valid = false;
  165|  3.93k|}
sd_lavc.c:reset:
  665|    657|{
  666|    657|    struct sd_lavc_priv *priv = sd->priv;
  667|       |
  668|  3.28k|    for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|  3.28k|#define MAX_QUEUE 4
  ------------------
  |  Branch (668:21): [True: 2.62k, False: 657]
  ------------------
  669|  2.62k|        clear_sub(&priv->subs[n]);
  670|       |    // lavc might not do this right for all codecs; may need close+reopen
  671|    657|    avcodec_flush_buffers(priv->avctx);
  672|       |
  673|    657|    priv->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    657|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  674|    657|}
sd_lavc.c:uninit:
  677|    326|{
  678|    326|    struct sd_lavc_priv *priv = sd->priv;
  679|       |
  680|  1.63k|    for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|  1.63k|#define MAX_QUEUE 4
  ------------------
  |  Branch (680:21): [True: 1.30k, False: 326]
  ------------------
  681|  1.30k|        clear_sub(&priv->subs[n]);
  682|    326|    avcodec_free_context(&priv->avctx);
  683|    326|    mp_free_av_packet(&priv->avpkt);
  684|    326|    talloc_free(priv);
  ------------------
  |  |   47|    326|#define talloc_free                     ta_free
  ------------------
  685|    326|}
sd_lavc.c:accepts_packet:
  633|  5.31k|{
  634|  5.31k|    struct sd_lavc_priv *priv = sd->priv;
  635|       |
  636|  5.31k|    double pts = priv->current_pts;
  637|  5.31k|    if (min_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  5.31k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (637:9): [True: 4.13k, False: 1.18k]
  ------------------
  638|       |        // guard against bogus rendering PTS in the future.
  639|  4.13k|        if (pts == MP_NOPTS_VALUE || min_pts < pts)
  ------------------
  |  |   39|  8.26k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (639:13): [True: 4.13k, False: 0]
  |  Branch (639:38): [True: 0, False: 0]
  ------------------
  640|  4.13k|            pts = min_pts;
  641|       |        // Heuristic: we assume rendering cannot lag behind more than 1 second
  642|       |        // behind decoding.
  643|  4.13k|        if (pts + 1 < min_pts)
  ------------------
  |  Branch (643:13): [True: 0, False: 4.13k]
  ------------------
  644|      0|            pts = min_pts;
  645|  4.13k|    }
  646|       |
  647|  5.31k|    int last_needed = -1;
  648|  26.5k|    for (int n = 0; n < MAX_QUEUE; n++) {
  ------------------
  |  |   38|  26.5k|#define MAX_QUEUE 4
  ------------------
  |  Branch (648:21): [True: 21.2k, False: 5.31k]
  ------------------
  649|  21.2k|        struct sub *sub = &priv->subs[n];
  650|  21.2k|        if (!sub->valid)
  ------------------
  |  Branch (650:13): [True: 21.2k, False: 0]
  ------------------
  651|  21.2k|            continue;
  652|      0|        if (pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (652:13): [True: 0, False: 0]
  ------------------
  653|      0|            ((sub->pts == MP_NOPTS_VALUE || sub->pts >= pts) ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (653:15): [True: 0, False: 0]
  |  Branch (653:45): [True: 0, False: 0]
  ------------------
  654|      0|             (sub->endpts == MP_NOPTS_VALUE || pts < sub->endpts)))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:15): [True: 0, False: 0]
  |  Branch (654:48): [True: 0, False: 0]
  ------------------
  655|      0|        {
  656|      0|            last_needed = n;
  657|      0|        }
  658|      0|    }
  659|       |    // We can accept a packet if it wouldn't overflow the fixed subtitle queue.
  660|       |    // We assume that get_bitmaps() never decreases the PTS.
  661|  5.31k|    return last_needed + 1 < MAX_QUEUE;
  ------------------
  |  |   38|  5.31k|#define MAX_QUEUE 4
  ------------------
  662|  5.31k|}
sd_lavc.c:control:
  748|  9.48k|{
  749|  9.48k|    struct sd_lavc_priv *priv = sd->priv;
  750|  9.48k|    switch (cmd) {
  751|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (751:5): [True: 0, False: 9.48k]
  ------------------
  752|      0|        double *a = arg;
  753|      0|        double res = step_sub(sd, a[0], a[1]);
  754|      0|        if (res == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (754:13): [True: 0, False: 0]
  ------------------
  755|      0|            return false;
  756|      0|        a[0] = res;
  757|      0|        return true;
  758|      0|    }
  759|  4.23k|    case SD_CTRL_SET_VIDEO_PARAMS:
  ------------------
  |  Branch (759:5): [True: 4.23k, False: 5.24k]
  ------------------
  760|  4.23k|        priv->video_params = *(struct mp_image_params *)arg;
  761|  4.23k|        return CONTROL_OK;
  ------------------
  |  |   95|  4.23k|#define CONTROL_OK 1
  ------------------
  762|      0|    case SD_CTRL_APPLY_DVDNAV: {
  ------------------
  |  Branch (762:5): [True: 0, False: 9.48k]
  ------------------
  763|      0|        const struct stream_nav_state *nav = arg;
  764|      0|        bool menu_closed = priv->menu_active && !nav->menu_active;
  ------------------
  |  Branch (764:28): [True: 0, False: 0]
  |  Branch (764:49): [True: 0, False: 0]
  ------------------
  765|      0|        bool changed = priv->hli_change_id != nav->change_id;
  766|      0|        priv->menu_active = nav->menu_active;
  767|      0|        priv->hl = nav->hl;
  768|      0|        priv->hli_change_id = nav->change_id;
  769|       |        // Don't let menu subpictures leak into title playback.
  770|      0|        if (menu_closed) {
  ------------------
  |  Branch (770:13): [True: 0, False: 0]
  ------------------
  771|      0|            for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|      0|#define MAX_QUEUE 4
  ------------------
  |  Branch (771:29): [True: 0, False: 0]
  ------------------
  772|      0|                clear_sub(&priv->subs[n]);
  773|      0|        }
  774|       |        // Re-render any decoded subtitles, after style update.
  775|      0|        if (changed)
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            rerender_queued_subs(sd);
  777|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  778|      0|    }
  779|  5.24k|    default:
  ------------------
  |  Branch (779:5): [True: 5.24k, False: 4.23k]
  ------------------
  780|  5.24k|        return CONTROL_UNKNOWN;
  ------------------
  |  |   98|  5.24k|#define CONTROL_UNKNOWN -1
  ------------------
  781|  9.48k|    }
  782|  9.48k|}

ta_set_parent:
   88|   402M|{
   89|   402M|    struct ta_header *ch = get_header(ptr);
   90|   402M|    if (!ch)
  ------------------
  |  Branch (90:9): [True: 315k, False: 401M]
  ------------------
   91|   315k|        return;
   92|   401M|    struct ta_header *new_parent = get_header(ta_parent);
   93|       |    // Unlink from previous parent
   94|   401M|    if (ch->prev)
  ------------------
  |  Branch (94:9): [True: 243k, False: 401M]
  ------------------
   95|   243k|        ch->prev->next = ch->next;
   96|   401M|    if (ch->next)
  ------------------
  |  Branch (96:9): [True: 63.7M, False: 338M]
  ------------------
   97|  63.7M|        ch->next->prev = ch->prev;
   98|       |    // If ch was the first child, change child link of old parent
   99|   401M|    if (ch->parent) {
  ------------------
  |  Branch (99:9): [True: 90.0M, False: 311M]
  ------------------
  100|  90.0M|        assert(ch->parent->child == ch);
  ------------------
  |  Branch (100:9): [True: 90.0M, False: 18.4E]
  ------------------
  101|  90.0M|        ch->parent->child = ch->next;
  102|  90.0M|        if (ch->parent->child) {
  ------------------
  |  Branch (102:13): [True: 63.6M, False: 26.4M]
  ------------------
  103|  63.6M|            assert(!ch->parent->child->parent);
  ------------------
  |  Branch (103:13): [True: 63.6M, False: 18.4E]
  ------------------
  104|  63.6M|            ch->parent->child->parent = ch->parent;
  105|  63.6M|        }
  106|  90.0M|    }
  107|   401M|    ch->next = ch->prev = ch->parent = NULL;
  108|       |    // Link to new parent - insert at start of list (LIFO destructor order)
  109|   401M|    if (new_parent) {
  ------------------
  |  Branch (109:9): [True: 90.3M, False: 311M]
  ------------------
  110|  90.3M|        ch->next = new_parent->child;
  111|  90.3M|        if (ch->next) {
  ------------------
  |  Branch (111:13): [True: 63.8M, False: 26.4M]
  ------------------
  112|  63.8M|            ch->next->prev = ch;
  113|       |            ch->next->parent = NULL;
  114|  63.8M|        }
  115|  90.3M|        new_parent->child = ch;
  116|  90.3M|        ch->parent = new_parent;
  117|  90.3M|    }
  118|   401M|}
ta_alloc_size:
  136|   125M|{
  137|   125M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   125M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (137:9): [True: 0, False: 125M]
  ------------------
  138|      0|        return NULL;
  139|   125M|    struct ta_header *h = malloc(sizeof(union aligned_header) + size);
  140|   125M|    if (!h)
  ------------------
  |  Branch (140:9): [True: 0, False: 125M]
  ------------------
  141|      0|        return NULL;
  142|   125M|    *h = (struct ta_header) {.size = size};
  143|   125M|    ta_dbg_add(h);
  144|   125M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|   125M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  145|   125M|    ta_set_parent(ptr, ta_parent);
  146|   125M|    return ptr;
  147|   125M|}
ta_zalloc_size:
  153|  29.4M|{
  154|  29.4M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|  29.4M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (154:9): [True: 0, False: 29.4M]
  ------------------
  155|      0|        return NULL;
  156|  29.4M|    struct ta_header *h = calloc(1, sizeof(union aligned_header) + size);
  157|  29.4M|    if (!h)
  ------------------
  |  Branch (157:9): [True: 0, False: 29.4M]
  ------------------
  158|      0|        return NULL;
  159|  29.4M|    *h = (struct ta_header) {.size = size};
  160|  29.4M|    ta_dbg_add(h);
  161|  29.4M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  29.4M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  162|  29.4M|    ta_set_parent(ptr, ta_parent);
  163|  29.4M|    return ptr;
  164|  29.4M|}
ta_realloc_size:
  179|  99.5M|{
  180|  99.5M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|  99.5M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (180:9): [True: 0, False: 99.5M]
  ------------------
  181|      0|        return NULL;
  182|  99.5M|    if (!size) {
  ------------------
  |  Branch (182:9): [True: 36.3k, False: 99.5M]
  ------------------
  183|  36.3k|        ta_free(ptr);
  184|  36.3k|        return NULL;
  185|  36.3k|    }
  186|  99.5M|    if (!ptr)
  ------------------
  |  Branch (186:9): [True: 95.5M, False: 4.00M]
  ------------------
  187|  95.5M|        return ta_alloc_size(ta_parent, size);
  188|  4.00M|    struct ta_header *h = get_header(ptr);
  189|  4.00M|    struct ta_header *old_h = h;
  190|  4.00M|    if (h->size == size)
  ------------------
  |  Branch (190:9): [True: 0, False: 4.00M]
  ------------------
  191|      0|        return ptr;
  192|  4.00M|    ta_dbg_remove(h);
  193|  4.00M|    h = realloc(h, sizeof(union aligned_header) + size);
  194|  18.4E|    ta_dbg_add(h ? h : old_h);
  ------------------
  |  Branch (194:16): [True: 4.00M, False: 18.4E]
  ------------------
  195|  4.00M|    if (!h)
  ------------------
  |  Branch (195:9): [True: 0, False: 4.00M]
  ------------------
  196|      0|        return NULL;
  197|  4.00M|    h->size = size;
  198|  4.00M|    if (h != old_h) {
  ------------------
  |  Branch (198:9): [True: 3.21M, False: 785k]
  ------------------
  199|       |        // Relink parent
  200|  3.21M|        if (h->parent)
  ------------------
  |  Branch (200:13): [True: 541k, False: 2.67M]
  ------------------
  201|   541k|            h->parent->child = h;
  202|       |        // Relink siblings
  203|  3.21M|        if (h->next)
  ------------------
  |  Branch (203:13): [True: 1.73M, False: 1.47M]
  ------------------
  204|  1.73M|            h->next->prev = h;
  205|  3.21M|        if (h->prev)
  ------------------
  |  Branch (205:13): [True: 2.20M, False: 1.01M]
  ------------------
  206|  2.20M|            h->prev->next = h;
  207|       |        // Relink children
  208|  3.21M|        if (h->child)
  ------------------
  |  Branch (208:13): [True: 1.66k, False: 3.21M]
  ------------------
  209|  1.66k|            h->child->parent = h;
  210|  3.21M|    }
  211|  4.00M|    return PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  4.00M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  212|  4.00M|}
ta_get_size:
  219|   341M|{
  220|   341M|    struct ta_header *h = get_header(ptr);
  221|   341M|    return h ? h->size : 0;
  ------------------
  |  Branch (221:12): [True: 154M, False: 186M]
  ------------------
  222|   341M|}
ta_free_children:
  228|   160M|{
  229|   160M|    struct ta_header *h = get_header(ptr);
  230|   250M|    while (h && h->child)
  ------------------
  |  Branch (230:12): [True: 250M, False: 356]
  |  Branch (230:17): [True: 89.7M, False: 160M]
  ------------------
  231|  89.7M|        ta_free(PTR_FROM_HEADER(h->child));
  ------------------
  |  |   64|  89.7M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  232|   160M|}
ta_free:
  237|   175M|{
  238|   175M|    struct ta_header *h = get_header(ptr);
  239|   175M|    if (!h)
  ------------------
  |  Branch (239:9): [True: 20.3M, False: 154M]
  ------------------
  240|  20.3M|        return;
  241|   154M|    if (h->destructor)
  ------------------
  |  Branch (241:9): [True: 23.5M, False: 131M]
  ------------------
  242|  23.5M|        h->destructor(ptr);
  243|   154M|    ta_free_children(ptr);
  244|       |    ta_set_parent(ptr, NULL);
  245|   154M|    ta_dbg_remove(h);
  246|   154M|    free(h);
  247|   154M|}
ta_set_destructor:
  260|  23.5M|{
  261|  23.5M|    struct ta_header *h = get_header(ptr);
  262|  23.5M|    if (h)
  ------------------
  |  Branch (262:9): [True: 23.5M, False: 9]
  ------------------
  263|  23.5M|        h->destructor = destructor;
  264|  23.5M|}
ta_dbg_set_loc:
  379|   158M|{
  380|   158M|    struct ta_header *h = get_header(ptr);
  381|   158M|    if (h)
  ------------------
  |  Branch (381:9): [True: 158M, False: 686k]
  ------------------
  382|   158M|        h->name = loc;
  383|   158M|    return ptr;
  384|   158M|}
ta_dbg_mark_as_string:
  389|  91.4M|{
  390|       |    // Specially handled by leak report code.
  391|  91.4M|    return ta_dbg_set_loc(ptr, &allocation_is_string);
  392|  91.4M|}
ta.c:get_header:
   73|  1.66G|{
   74|  1.66G|    struct ta_header *h = ptr ? PTR_TO_HEADER(ptr) : NULL;
  ------------------
  |  |   63|  1.14G|#define PTR_TO_HEADER(ptr) (&((union aligned_header *)(ptr) - 1)->ta)
  ------------------
  |  Branch (74:27): [True: 1.14G, False: 519M]
  ------------------
   75|  1.66G|    ta_dbg_check_header(h);
   76|  1.66G|    return h;
   77|  1.66G|}
ta.c:ta_dbg_check_header:
  289|  1.82G|{
  290|  1.82G|    if (h) {
  ------------------
  |  Branch (290:9): [True: 1.30G, False: 519M]
  ------------------
  291|  1.30G|        assert(h->canary == CANARY);
  ------------------
  |  Branch (291:9): [True: 1.30G, False: 18.4E]
  ------------------
  292|  1.30G|        if (h->parent) {
  ------------------
  |  Branch (292:13): [True: 403M, False: 903M]
  ------------------
  293|   403M|            assert(!h->prev);
  ------------------
  |  Branch (293:13): [True: 403M, False: 18.4E]
  ------------------
  294|   403M|            assert(h->parent->child == h);
  ------------------
  |  Branch (294:13): [True: 403M, False: 18.4E]
  ------------------
  295|   403M|        }
  296|  1.30G|    }
  297|  1.82G|}
ta.c:ta_dbg_add:
  276|   158M|{
  277|   158M|    h->canary = CANARY;
  ------------------
  |  |   50|   158M|#define CANARY 0xD3ADB3EF
  ------------------
  278|   158M|    if (enable_leak_check) {
  ------------------
  |  Branch (278:9): [True: 0, False: 158M]
  ------------------
  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|   158M|}
ta.c:ta_dbg_remove:
  300|   158M|{
  301|   158M|    ta_dbg_check_header(h);
  302|   158M|    if (h->leak_next) { // assume checking for !=NULL invariant ok without lock
  ------------------
  |  Branch (302:9): [True: 0, False: 158M]
  ------------------
  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|   158M|    h->canary = 0;
  310|   158M|}

client.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|}
command.c:ta_oom_p:
  162|   148k|{
  163|   148k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 148k]
  ------------------
  164|      0|        abort();
  165|   148k|    return p;
  166|   148k|}
configfiles.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
loadfile.c:ta_oom_p:
  162|   206k|{
  163|   206k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 206k]
  ------------------
  164|      0|        abort();
  165|   206k|    return p;
  166|   206k|}
main.c:ta_oom_p:
  162|  74.2k|{
  163|  74.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 74.2k]
  ------------------
  164|      0|        abort();
  165|  74.2k|    return p;
  166|  74.2k|}
osd.c:ta_oom_b:
  169|   122k|{
  170|   122k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 122k]
  ------------------
  171|      0|        abort();
  172|   122k|}
osd.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|}
screenshot.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
scripting.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
sub.c:ta_oom_p:
  162|  2.70k|{
  163|  2.70k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.70k]
  ------------------
  164|      0|        abort();
  165|  2.70k|    return p;
  166|  2.70k|}
video.c:ta_oom_p:
  162|  19.6k|{
  163|  19.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.6k]
  ------------------
  164|      0|        abort();
  165|  19.6k|    return p;
  166|  19.6k|}
clipboard.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
clipboard-vo.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
stream.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
stream_file.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
dec_sub.c:ta_oom_p:
  162|  7.81k|{
  163|  7.81k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 7.81k]
  ------------------
  164|      0|        abort();
  165|  7.81k|    return p;
  166|  7.81k|}
packer.c:ta_oom_p:
  162|  4.58k|{
  163|  4.58k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.58k]
  ------------------
  164|      0|        abort();
  165|  4.58k|    return p;
  166|  4.58k|}
sd_ass.c:ta_oom_p:
  162|  7.02k|{
  163|  7.02k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 7.02k]
  ------------------
  164|      0|        abort();
  165|  7.02k|    return p;
  166|  7.02k|}
sd_lavc.c:ta_oom_p:
  162|    655|{
  163|    655|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 655]
  ------------------
  164|      0|        abort();
  165|    655|    return p;
  166|    655|}
mp_image.c:ta_oom_p:
  162|   365k|{
  163|   365k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 365k]
  ------------------
  164|      0|        abort();
  165|   365k|    return p;
  166|   365k|}
mp_image_pool.c:ta_oom_p:
  162|  38.0k|{
  163|  38.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 38.0k]
  ------------------
  164|      0|        abort();
  165|  38.0k|    return p;
  166|  38.0k|}
vo.c:ta_oom_p:
  162|   305k|{
  163|   305k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 305k]
  ------------------
  164|      0|        abort();
  165|   305k|    return p;
  166|   305k|}
ta_talloc.c:ta_oom_b:
  169|  40.9k|{
  170|  40.9k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 40.9k]
  ------------------
  171|      0|        abort();
  172|  40.9k|}
ta_utils.c:ta_oom_b:
  169|   112M|{
  170|   112M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 112M]
  ------------------
  171|      0|        abort();
  172|   112M|}
ipc-unix.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
filter_regex.c:ta_oom_p:
  162|  2.29k|{
  163|  2.29k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.29k]
  ------------------
  164|      0|        abort();
  165|  2.29k|    return p;
  166|  2.29k|}
aframe.c:ta_oom_p:
  162|   706k|{
  163|   706k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 706k]
  ------------------
  164|      0|        abort();
  165|   706k|    return p;
  166|   706k|}
ao.c:ta_oom_p:
  162|  16.1k|{
  163|  16.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.1k]
  ------------------
  164|      0|        abort();
  165|  16.1k|    return p;
  166|  16.1k|}
buffer.c:ta_oom_p:
  162|  8.07k|{
  163|  8.07k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 8.07k]
  ------------------
  164|      0|        abort();
  165|  8.07k|    return p;
  166|  8.07k|}
codecs.c:ta_oom_p:
  162|  36.2k|{
  163|  36.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 36.2k]
  ------------------
  164|      0|        abort();
  165|  36.2k|    return p;
  166|  36.2k|}
msg.c:ta_oom_p:
  162|  2.42M|{
  163|  2.42M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.42M]
  ------------------
  164|      0|        abort();
  165|  2.42M|    return p;
  166|  2.42M|}
msg.c:ta_oom_s:
  175|   263k|{
  176|   263k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 263k]
  ------------------
  177|      0|        abort();
  178|   263k|    return s;
  179|   263k|}
playlist.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
stats.c:ta_oom_p:
  162|   167k|{
  163|   167k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 167k]
  ------------------
  164|      0|        abort();
  165|   167k|    return p;
  166|   167k|}
stats.c:ta_oom_s:
  175|  49.0k|{
  176|  49.0k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 49.0k]
  ------------------
  177|      0|        abort();
  178|  49.0k|    return s;
  179|  49.0k|}
tags.c:ta_oom_p:
  162|  52.6k|{
  163|  52.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 52.6k]
  ------------------
  164|      0|        abort();
  165|  52.6k|    return p;
  166|  52.6k|}
demux.c:ta_oom_p:
  162|   368k|{
  163|   368k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 368k]
  ------------------
  164|      0|        abort();
  165|   368k|    return p;
  166|   368k|}
demux_mkv.c:ta_oom_p:
  162|   224k|{
  163|   224k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 224k]
  ------------------
  164|      0|        abort();
  165|   224k|    return p;
  166|   224k|}
demux_mkv.c:ta_oom_s:
  175|      6|{
  176|      6|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 6]
  ------------------
  177|      0|        abort();
  178|      6|    return s;
  179|      6|}
demux_mkv_timeline.c:ta_oom_p:
  162|  3.05k|{
  163|  3.05k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 3.05k]
  ------------------
  164|      0|        abort();
  165|  3.05k|    return p;
  166|  3.05k|}
demux_timeline.c:ta_oom_p:
  162|  1.68k|{
  163|  1.68k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.68k]
  ------------------
  164|      0|        abort();
  165|  1.68k|    return p;
  166|  1.68k|}
demux_timeline.c:ta_oom_s:
  175|    286|{
  176|    286|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 286]
  ------------------
  177|      0|        abort();
  178|    286|    return s;
  179|    286|}
ebml.c:ta_oom_p:
  162|   238k|{
  163|   238k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 238k]
  ------------------
  164|      0|        abort();
  165|   238k|    return p;
  166|   238k|}
packet.c:ta_oom_p:
  162|   682k|{
  163|   682k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 682k]
  ------------------
  164|      0|        abort();
  165|   682k|    return p;
  166|   682k|}
packet_pool.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
timeline.c:ta_oom_p:
  162|  24.2k|{
  163|  24.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.2k]
  ------------------
  164|      0|        abort();
  165|  24.2k|    return p;
  166|  24.2k|}
f_async_queue.c:ta_oom_p:
  162|  16.1k|{
  163|  16.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.1k]
  ------------------
  164|      0|        abort();
  165|  16.1k|    return p;
  166|  16.1k|}
f_decoder_wrapper.c:ta_oom_p:
  162|  36.2k|{
  163|  36.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 36.2k]
  ------------------
  164|      0|        abort();
  165|  36.2k|    return p;
  166|  36.2k|}
f_output_chain.c:ta_oom_p:
  162|  32.0k|{
  163|  32.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.0k]
  ------------------
  164|      0|        abort();
  165|  32.0k|    return p;
  166|  32.0k|}
filter.c:ta_oom_p:
  162|  3.75M|{
  163|  3.75M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 3.75M]
  ------------------
  164|      0|        abort();
  165|  3.75M|    return p;
  166|  3.75M|}
cmd.c:ta_oom_p:
  162|   148k|{
  163|   148k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 148k]
  ------------------
  164|      0|        abort();
  165|   148k|    return p;
  166|   148k|}
input.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|}
charset_conv.c:ta_oom_p:
  162|  8.78k|{
  163|  8.78k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 8.78k]
  ------------------
  164|      0|        abort();
  165|  8.78k|    return p;
  166|  8.78k|}
dispatch.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|}
language.c:ta_oom_p:
  162|  12.6k|{
  163|  12.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.6k]
  ------------------
  164|      0|        abort();
  165|  12.6k|    return p;
  166|  12.6k|}
node.c:ta_oom_p:
  162|  74.2k|{
  163|  74.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 74.2k]
  ------------------
  164|      0|        abort();
  165|  74.2k|    return p;
  166|  74.2k|}
thread_pool.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
thread_tools.c:ta_oom_p:
  162|  99.0k|{
  163|  99.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 99.0k]
  ------------------
  164|      0|        abort();
  165|  99.0k|    return p;
  166|  99.0k|}
m_config_core.c:ta_oom_p:
  162|  7.42M|{
  163|  7.42M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 7.42M]
  ------------------
  164|      0|        abort();
  165|  7.42M|    return p;
  166|  7.42M|}
m_config_frontend.c:ta_oom_p:
  162|  36.7M|{
  163|  36.7M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 36.7M]
  ------------------
  164|      0|        abort();
  165|  36.7M|    return p;
  166|  36.7M|}
m_option.c:ta_oom_s:
  175|  74.2k|{
  176|  74.2k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 74.2k]
  ------------------
  177|      0|        abort();
  178|  74.2k|    return s;
  179|  74.2k|}
m_option.c:ta_oom_p:
  162|  2.97M|{
  163|  2.97M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.97M]
  ------------------
  164|      0|        abort();
  165|  2.97M|    return p;
  166|  2.97M|}
parse_configfile.c:ta_oom_p:
  162|  24.7k|{
  163|  24.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 24.7k]
  ------------------
  164|      0|        abort();
  165|  24.7k|    return p;
  166|  24.7k|}
path.c:ta_oom_p:
  162|   229k|{
  163|   229k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 229k]
  ------------------
  164|      0|        abort();
  165|   229k|    return p;
  166|   229k|}
audio.c:ta_oom_p:
  162|  16.5k|{
  163|  16.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.5k]
  ------------------
  164|      0|        abort();
  165|  16.5k|    return p;
  166|  16.5k|}
external_files.c:ta_oom_p:
  162|  48.5k|{
  163|  48.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 48.5k]
  ------------------
  164|      0|        abort();
  165|  48.5k|    return p;
  166|  48.5k|}
ass_mp.c:ta_oom_p:
  162|  2.29k|{
  163|  2.29k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.29k]
  ------------------
  164|      0|        abort();
  165|  2.29k|    return p;
  166|  2.29k|}
lavc_conv.c:ta_oom_p:
  162|  2.89k|{
  163|  2.89k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.89k]
  ------------------
  164|      0|        abort();
  165|  2.89k|    return p;
  166|  2.89k|}
ad_dsd.c:ta_oom_p:
  162|  16.5k|{
  163|  16.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.5k]
  ------------------
  164|      0|        abort();
  165|  16.5k|    return p;
  166|  16.5k|}
ad_spdif.c:ta_oom_p:
  162|  16.5k|{
  163|  16.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.5k]
  ------------------
  164|      0|        abort();
  165|  16.5k|    return p;
  166|  16.5k|}

ta_talloc_vasprintf_append_buffer:
   54|  40.9k|{
   55|  40.9k|    ta_xvasprintf_append_buffer(&s, fmt, ap);
  ------------------
  |  |  132|  40.9k|#define ta_xvasprintf_append_buffer(...) ta_oom_b(ta_vasprintf_append_buffer(__VA_ARGS__))
  ------------------
   56|  40.9k|    return s;
   57|  40.9k|}
ta_talloc_asprintf_append_buffer:
   70|  40.9k|{
   71|  40.9k|    char *res;
   72|  40.9k|    va_list ap;
   73|  40.9k|    va_start(ap, fmt);
   74|  40.9k|    res = talloc_vasprintf_append_buffer(s, fmt, ap);
  ------------------
  |  |   62|  40.9k|#define talloc_vasprintf_append_buffer  ta_talloc_vasprintf_append_buffer
  ------------------
   75|       |    va_end(ap);
   76|  40.9k|    return res;
   77|  40.9k|}

ta_calc_array_size:
   30|  10.7M|{
   31|  10.7M|    if (count > (((size_t)-1) / element_size))
  ------------------
  |  Branch (31:9): [True: 0, False: 10.7M]
  ------------------
   32|      0|        return (size_t)-1;
   33|  10.7M|    return element_size * count;
   34|  10.7M|}
ta_calc_prealloc_elems:
   41|  5.58M|{
   42|  5.58M|    if (nextidx >= ((size_t)-1) / 2 - 1)
  ------------------
  |  Branch (42:9): [True: 0, False: 5.58M]
  ------------------
   43|      0|        return (size_t)-1;
   44|  5.58M|    return (nextidx + 1) * 2;
   45|  5.58M|}
ta_new_context:
   50|   552k|{
   51|   552k|    return ta_alloc_size(ta_parent, 0);
   52|   552k|}
ta_steal_:
   58|  1.06M|{
   59|  1.06M|    ta_set_parent(ptr, ta_parent);
   60|  1.06M|    return ptr;
   61|  1.06M|}
ta_memdup:
   66|  1.10M|{
   67|  1.10M|    if (!ptr) {
  ------------------
  |  Branch (67:9): [True: 650k, False: 459k]
  ------------------
   68|   650k|        assert(!size);
  ------------------
  |  Branch (68:9): [True: 650k, False: 0]
  ------------------
   69|   650k|        return NULL;
   70|   650k|    }
   71|   459k|    void *res = ta_alloc_size(ta_parent, size);
   72|   459k|    if (!res)
  ------------------
  |  Branch (72:9): [True: 0, False: 459k]
  ------------------
   73|      0|        return NULL;
   74|   459k|    memcpy(res, ptr, size);
   75|   459k|    return res;
   76|   459k|}
ta_strdup:
  113|  97.3M|{
  114|  97.3M|    return ta_strndup(ta_parent, str, str ? strlen(str) : 0);
  ------------------
  |  Branch (114:39): [True: 85.2M, False: 12.0M]
  ------------------
  115|  97.3M|}
ta_strndup:
  123|   103M|{
  124|   103M|    if (!str)
  ------------------
  |  Branch (124:9): [True: 12.1M, False: 90.8M]
  ------------------
  125|  12.1M|        return NULL;
  126|  90.8M|    char *new = NULL;
  127|  90.8M|    strndup_append_at(&new, 0, str, n);
  128|  90.8M|    ta_set_parent(new, ta_parent);
  129|  90.8M|    return new;
  130|   103M|}
ta_strdup_append:
  137|   122k|{
  138|   122k|    return strndup_append_at(str, *str ? strlen(*str) : 0, a, (size_t)-1);
  ------------------
  |  Branch (138:35): [True: 122k, False: 0]
  ------------------
  139|   122k|}
ta_asprintf:
  204|   387k|{
  205|   387k|    char *res;
  206|   387k|    va_list ap;
  207|   387k|    va_start(ap, fmt);
  208|   387k|    res = ta_vasprintf(ta_parent, fmt, ap);
  209|       |    va_end(ap);
  210|   387k|    return res;
  211|   387k|}
ta_vasprintf:
  214|   387k|{
  215|   387k|    char *res = NULL;
  216|   387k|    ta_vasprintf_append_at(&res, 0, fmt, ap);
  217|   387k|    ta_set_parent(res, ta_parent);
  218|   387k|    if (!res) {
  ------------------
  |  Branch (218:9): [True: 0, False: 387k]
  ------------------
  219|      0|        ta_free(res);
  220|      0|        return NULL;
  221|      0|    }
  222|   387k|    return res;
  223|   387k|}
ta_vasprintf_append_buffer:
  262|  40.9k|{
  263|  40.9k|    size_t size = ta_get_size(*str);
  264|  40.9k|    if (size > 0)
  ------------------
  |  Branch (264:9): [True: 40.9k, False: 0]
  ------------------
  265|  40.9k|        size -= 1;
  266|  40.9k|    return ta_vasprintf_append_at(str, size, fmt, ap);
  267|  40.9k|}
ta_xmemdup:
  270|  1.07M|{
  271|  1.07M|    void *new = ta_memdup(ta_parent, ptr, size);
  272|  1.07M|    ta_oom_b(new || !ptr);
  ------------------
  |  Branch (272:14): [True: 428k, False: 650k]
  |  Branch (272:21): [True: 650k, False: 0]
  ------------------
  273|  1.07M|    return new;
  274|  1.07M|}
ta_xrealloc_size:
  277|  8.28M|{
  278|  8.28M|    ptr = ta_realloc_size(ta_parent, ptr, size);
  279|  8.28M|    ta_oom_b(ptr || !size);
  ------------------
  |  Branch (279:14): [True: 8.24M, False: 36.3k]
  |  Branch (279:21): [True: 36.3k, False: 0]
  ------------------
  280|  8.28M|    return ptr;
  281|  8.28M|}
ta_xstrdup:
  284|  97.3M|{
  285|  97.3M|    char *res = ta_strdup(ta_parent, str);
  286|  97.3M|    ta_oom_b(res || !str);
  ------------------
  |  Branch (286:14): [True: 85.2M, False: 12.0M]
  |  Branch (286:21): [True: 12.0M, False: 0]
  ------------------
  287|  97.3M|    return res;
  288|  97.3M|}
ta_xstrndup:
  291|  5.69M|{
  292|  5.69M|    char *res = ta_strndup(ta_parent, str, n);
  293|  5.69M|    ta_oom_b(res || !str);
  ------------------
  |  Branch (293:14): [True: 5.59M, False: 99.0k]
  |  Branch (293:21): [True: 99.0k, False: 0]
  ------------------
  294|  5.69M|    return res;
  295|  5.69M|}
ta_utils.c:strndup_append_at:
   82|  90.9M|{
   83|  90.9M|    assert(ta_get_size(*str) >= at);
  ------------------
  |  Branch (83:5): [True: 90.9M, False: 0]
  ------------------
   84|       |
   85|  90.9M|    if (!*str && !append)
  ------------------
  |  Branch (85:9): [True: 90.8M, False: 122k]
  |  Branch (85:18): [True: 0, False: 90.8M]
  ------------------
   86|      0|        return true; // stays NULL, but not an OOM condition
   87|       |
   88|  90.9M|    size_t real_len = append ? strnlen(append, append_len) : 0;
  ------------------
  |  Branch (88:23): [True: 90.9M, False: 0]
  ------------------
   89|  90.9M|    if (append_len > real_len)
  ------------------
  |  Branch (89:9): [True: 124k, False: 90.8M]
  ------------------
   90|   124k|        append_len = real_len;
   91|       |
   92|  90.9M|    if (ta_get_size(*str) < at + append_len + 1) {
  ------------------
  |  Branch (92:9): [True: 90.8M, False: 122k]
  ------------------
   93|  90.8M|        char *t = ta_realloc_size(NULL, *str, at + append_len + 1);
   94|  90.8M|        if (!t)
  ------------------
  |  Branch (94:13): [True: 0, False: 90.8M]
  ------------------
   95|      0|            return false;
   96|  90.8M|        *str = t;
   97|  90.8M|    }
   98|       |
   99|  90.9M|    if (append_len)
  ------------------
  |  Branch (99:9): [True: 90.4M, False: 523k]
  ------------------
  100|  90.4M|        memcpy(*str + at, append, append_len);
  101|       |
  102|  90.9M|    (*str)[at + append_len] = '\0';
  103|       |
  104|  90.9M|    ta_dbg_mark_as_string(*str);
  105|       |
  106|       |    return true;
  107|  90.9M|}
ta_utils.c:ta_vasprintf_append_at:
  174|   428k|{
  175|   428k|    assert(ta_get_size(*str) >= at);
  ------------------
  |  Branch (175:5): [True: 428k, False: 0]
  ------------------
  176|       |
  177|   428k|    int size;
  178|   428k|    va_list copy;
  179|   428k|    va_copy(copy, ap);
  180|   428k|    char c;
  181|   428k|    size = vsnprintf(&c, 1, fmt, copy);
  182|   428k|    va_end(copy);
  183|       |
  184|   428k|    if (size < 0)
  ------------------
  |  Branch (184:9): [True: 0, False: 428k]
  ------------------
  185|      0|        return false;
  186|       |
  187|   428k|    if (ta_get_size(*str) < at + size + 1) {
  ------------------
  |  Branch (187:9): [True: 428k, False: 0]
  ------------------
  188|   428k|        char *t = ta_realloc_size(NULL, *str, at + size + 1);
  189|   428k|        if (!t)
  ------------------
  |  Branch (189:13): [True: 0, False: 428k]
  ------------------
  190|      0|            return false;
  191|   428k|        *str = t;
  192|   428k|    }
  193|   428k|    vsnprintf(*str + at, size + 1, fmt, ap);
  194|       |
  195|   428k|    ta_dbg_mark_as_string(*str);
  196|       |
  197|       |    return true;
  198|   428k|}

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

vd_lavc.c:add_all_hwdec_methods:
  346|  19.0k|{
  347|  19.0k|    const AVCodec *codec = NULL;
  348|  19.0k|    void *iter = NULL;
  349|  9.55M|    while (1) {
  ------------------
  |  Branch (349:12): [True: 9.55M, Folded]
  ------------------
  350|  9.55M|        codec = av_codec_iterate(&iter);
  351|  9.55M|        if (!codec)
  ------------------
  |  Branch (351:13): [True: 19.0k, False: 9.53M]
  ------------------
  352|  19.0k|            break;
  353|  9.53M|        if (codec->type != AVMEDIA_TYPE_VIDEO || !av_codec_is_decoder(codec))
  ------------------
  |  Branch (353:13): [True: 4.66M, False: 4.87M]
  |  Branch (353:50): [True: 0, False: 4.87M]
  ------------------
  354|  4.66M|            continue;
  355|       |
  356|  4.87M|        struct hwdec_info info_template = {
  357|  4.87M|            .pix_fmt = AV_PIX_FMT_NONE,
  358|  4.87M|            .codec = codec,
  359|  4.87M|        };
  360|       |
  361|  4.87M|        const char *wrapper = NULL;
  362|  4.87M|        if (codec->capabilities & (AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_HYBRID))
  ------------------
  |  Branch (362:13): [True: 171k, False: 4.69M]
  ------------------
  363|   171k|            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|  4.87M|        bool found_any = false;
  369|  4.87M|        for (int n = 0; ; n++) {
  370|  4.87M|            const AVCodecHWConfig *cfg = avcodec_get_hw_config(codec, n);
  371|  4.87M|            if (!cfg)
  ------------------
  |  Branch (371:17): [True: 4.87M, False: 0]
  ------------------
  372|  4.87M|                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|  4.87M|        if (!found_any && wrapper) {
  ------------------
  |  Branch (435:13): [True: 4.87M, False: 0]
  |  Branch (435:27): [True: 171k, False: 4.69M]
  ------------------
  436|       |            // We _know_ there's something supported here, usually outputting
  437|       |            // sw surfaces. E.g. mediacodec (before hw_device_ctx support).
  438|       |
  439|   171k|            struct hwdec_info info = info_template;
  440|   171k|            info.copying = true; // probably
  441|       |
  442|   171k|            snprintf(info.method_name, sizeof(info.method_name), "%s", wrapper);
  443|   171k|            add_hwdec_item(infos, num_infos, info);
  444|   171k|        }
  445|  4.87M|    }
  446|       |
  447|  19.0k|    qsort(*infos, *num_infos, sizeof(struct hwdec_info), hwdec_compare);
  448|  19.0k|}
vd_lavc.c:add_hwdec_item:
  321|   171k|{
  322|   171k|    if (info.copying)
  ------------------
  |  Branch (322:9): [True: 171k, False: 0]
  ------------------
  323|   171k|        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|   171k|    snprintf(info.name, sizeof(info.name), "%s-%s",
  328|   171k|             info.codec->name, info.method_name);
  329|       |
  330|   171k|    info.rank = *num_infos;
  331|   171k|    info.auto_pos = INT_MAX;
  332|       |
  333|  3.25M|    for (int x = 0; hwdec_autoprobe_info[x].method_name; x++) {
  ------------------
  |  Branch (333:21): [True: 3.08M, False: 171k]
  ------------------
  334|  3.08M|        const struct autoprobe_info *entry = &hwdec_autoprobe_info[x];
  335|  3.08M|        if (strcmp(entry->method_name, info.method_name) == 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 3.08M]
  ------------------
  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|  3.08M|    }
  341|       |
  342|   171k|    MP_TARRAY_APPEND(NULL, *infos, *num_infos, info);
  ------------------
  |  |  105|   171k|    do {                                            \
  |  |  106|   171k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   171k|    do {                                            \
  |  |  |  |   97|   171k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   171k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   171k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   171k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 57.0k, False: 114k]
  |  |  |  |  ------------------
  |  |  |  |   99|   171k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  57.0k|    do {                                                        \
  |  |  |  |  |  |   89|  57.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  57.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  57.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  57.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  57.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  57.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  57.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 57.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   171k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 171k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   171k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   171k|        (idxvar)++;                                 \
  |  |  109|   171k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 171k]
  |  |  ------------------
  ------------------
  343|   171k|}
vd_lavc.c:hwdec_compare:
  295|   247k|{
  296|   247k|    struct hwdec_info *h1 = (void *)p1;
  297|   247k|    struct hwdec_info *h2 = (void *)p2;
  298|       |
  299|   247k|    if (h1 == h2)
  ------------------
  |  Branch (299:9): [True: 0, False: 247k]
  ------------------
  300|      0|        return 0;
  301|       |
  302|       |    // Strictly put non-preferred hwdecs to the end of the list.
  303|   247k|    if ((h1->auto_pos == INT_MAX) != (h2->auto_pos == INT_MAX))
  ------------------
  |  Branch (303:9): [True: 0, False: 247k]
  ------------------
  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|   247k|    if (h1->copying != h2->copying)
  ------------------
  |  Branch (306:9): [True: 0, False: 247k]
  ------------------
  307|      0|        return h1->copying ? 1 : -1;
  ------------------
  |  Branch (307:16): [True: 0, False: 0]
  ------------------
  308|       |    // Order by autoprobe preference order.
  309|   247k|    if (h1->auto_pos != h2->auto_pos)
  ------------------
  |  Branch (309:9): [True: 0, False: 247k]
  ------------------
  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|   247k|    if ((!!h1->lavc_device) != (!!h2->lavc_device))
  ------------------
  |  Branch (312:9): [True: 0, False: 247k]
  ------------------
  313|      0|        return h1->lavc_device ? -1 : 1;
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|       |    // Fallback sort order to make sorting stable.
  315|   247k|    return h1->rank > h2->rank ? 1 :-1;
  ------------------
  |  Branch (315:12): [True: 0, False: 247k]
  ------------------
  316|   247k|}
vd_lavc.c:create:
 1503|  19.0k|{
 1504|  19.0k|    struct mp_filter *vd = mp_filter_create(parent, &vd_lavc_filter);
 1505|  19.0k|    if (!vd)
  ------------------
  |  Branch (1505:9): [True: 0, False: 19.0k]
  ------------------
 1506|      0|        return NULL;
 1507|       |
 1508|  19.0k|    mp_filter_add_pin(vd, MP_PIN_IN, "in");
 1509|  19.0k|    mp_filter_add_pin(vd, MP_PIN_OUT, "out");
 1510|       |
 1511|  19.0k|    vd->log = mp_log_new(vd, parent->log, NULL);
 1512|       |
 1513|  19.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1514|  19.0k|    ctx->log = vd->log;
 1515|  19.0k|    ctx->opts_cache = m_config_cache_alloc(ctx, vd->global, &vd_lavc_conf);
 1516|  19.0k|    ctx->opts = ctx->opts_cache->opts;
 1517|  19.0k|    ctx->hwdec_opts_cache = m_config_cache_alloc(ctx, vd->global, &hwdec_conf);
 1518|  19.0k|    ctx->hwdec_opts = ctx->hwdec_opts_cache->opts;
 1519|  19.0k|    ctx->codec = codec;
 1520|  19.0k|    ctx->decoder = talloc_strdup(ctx, decoder);
  ------------------
  |  |   50|  19.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1521|  19.0k|    ctx->hwdec_swpool = mp_image_pool_new(ctx);
 1522|  19.0k|    ctx->dr_pool = mp_image_pool_new(ctx);
 1523|       |
 1524|  19.0k|    ctx->public.f = vd;
 1525|  19.0k|    ctx->public.control = control;
 1526|       |
 1527|  19.0k|    mp_mutex_init(&ctx->dr_lock);
 1528|       |
 1529|       |    // hwdec/DR
 1530|  19.0k|    struct mp_stream_info *info = mp_filter_find_stream_info(vd);
 1531|  19.0k|    if (info) {
  ------------------
  |  Branch (1531:9): [True: 19.0k, False: 0]
  ------------------
 1532|  19.0k|        ctx->hwdec_devs = info->hwdec_devs;
 1533|  19.0k|        ctx->vo = info->dr_vo;
 1534|  19.0k|        ctx->force_swdec = info->force_swdec;
 1535|  19.0k|    }
 1536|       |
 1537|  19.0k|    reinit(vd);
 1538|       |
 1539|  19.0k|    if (!ctx->avctx) {
  ------------------
  |  Branch (1539:9): [True: 723, False: 18.3k]
  ------------------
 1540|    723|        talloc_free(vd);
  ------------------
  |  |   47|    723|#define talloc_free                     ta_free
  ------------------
 1541|    723|        return NULL;
 1542|    723|    }
 1543|       |
 1544|  18.3k|    codec->codec_desc = ctx->avctx->codec_descriptor->long_name;
 1545|       |
 1546|  18.3k|    return &ctx->public;
 1547|  19.0k|}
vd_lavc.c:vd_lavc_destroy:
 1484|  19.0k|{
 1485|  19.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1486|       |
 1487|  19.0k|    uninit_avctx(vd);
 1488|       |
 1489|  19.0k|    mp_mutex_destroy(&ctx->dr_lock);
  ------------------
  |  |  133|  19.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1490|  19.0k|}
vd_lavc.c:uninit_avctx:
  937|  38.7k|{
  938|  38.7k|    vd_ffmpeg_ctx *ctx = vd->priv;
  939|       |
  940|  38.7k|    flush_all(vd);
  941|  38.7k|    av_frame_free(&ctx->pic);
  942|  38.7k|    mp_free_av_packet(&ctx->avpkt);
  943|  38.7k|    av_buffer_unref(&ctx->cached_hw_frames_ctx);
  944|       |
  945|  38.7k|    avcodec_free_context(&ctx->avctx);
  946|       |
  947|  38.7k|    av_buffer_unref(&ctx->hwdec_dev);
  948|       |
  949|  38.7k|    ctx->hwdec_failed = false;
  950|  38.7k|    ctx->hwdec_fail_count = 0;
  951|  38.7k|    ctx->max_delay_queue = 0;
  952|  38.7k|    ctx->hw_probing = false;
  953|  38.7k|    ctx->hwdec = (struct hwdec_info){0};
  954|       |    ctx->use_hwdec = false;
  955|  38.7k|}
vd_lavc.c:flush_all:
  918|  39.7k|{
  919|  39.7k|    vd_ffmpeg_ctx *ctx = vd->priv;
  920|       |
  921|  39.7k|    for (int n = 0; n < ctx->num_delay_queue; n++)
  ------------------
  |  Branch (921:21): [True: 0, False: 39.7k]
  ------------------
  922|      0|        talloc_free(ctx->delay_queue[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  923|  39.7k|    ctx->num_delay_queue = 0;
  924|       |
  925|  39.7k|    for (int n = 0; n < ctx->num_sent_packets; n++)
  ------------------
  |  Branch (925:21): [True: 0, False: 39.7k]
  ------------------
  926|      0|        talloc_free(ctx->sent_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  927|  39.7k|    ctx->num_sent_packets = 0;
  928|       |
  929|  39.7k|    for (int n = 0; n < ctx->num_requeue_packets; n++)
  ------------------
  |  Branch (929:21): [True: 0, False: 39.7k]
  ------------------
  930|      0|        talloc_free(ctx->requeue_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  931|  39.7k|    ctx->num_requeue_packets = 0;
  932|       |
  933|  39.7k|    reset_avctx(vd);
  934|  39.7k|}
vd_lavc.c:reset_avctx:
  905|  55.5k|{
  906|  55.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
  907|       |
  908|  55.5k|    if (ctx->avctx && avcodec_is_open(ctx->avctx))
  ------------------
  |  Branch (908:9): [True: 35.7k, False: 19.7k]
  |  Branch (908:23): [True: 35.0k, False: 723]
  ------------------
  909|  35.0k|        avcodec_flush_buffers(ctx->avctx);
  910|  55.5k|    ctx->flushing = false;
  911|  55.5k|    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|  55.5k|    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: 55.5k]
  ------------------
  915|  55.5k|}
vd_lavc.c:vd_lavc_process:
 1467|   966k|{
 1468|   966k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1469|       |
 1470|   966k|    lavc_process(vd, &ctx->state, send_packet, receive_frame);
 1471|   966k|}
vd_lavc.c:send_packet:
 1224|   389k|{
 1225|   389k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1226|   389k|    AVCodecContext *avctx = ctx->avctx;
 1227|       |
 1228|   389k|    if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt)
  ------------------
  |  Branch (1228:9): [True: 0, False: 389k]
  |  Branch (1228:37): [True: 0, False: 0]
  ------------------
 1229|      0|        return AVERROR(EAGAIN); // cannot consume the packet
 1230|       |
 1231|   389k|    if (ctx->hwdec_failed)
  ------------------
  |  Branch (1231:9): [True: 0, False: 389k]
  ------------------
 1232|      0|        return AVERROR(EAGAIN);
 1233|       |
 1234|   389k|    if (!ctx->avctx)
  ------------------
  |  Branch (1234:9): [True: 0, False: 389k]
  ------------------
 1235|      0|        return AVERROR_EOF;
 1236|       |
 1237|   389k|    prepare_decoding(vd);
 1238|       |
 1239|   389k|    if (ctx->wait_for_keyframe > 0 && pkt) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 389k]
  |  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|   389k|    if (avctx->skip_frame == AVDISCARD_ALL)
  ------------------
  |  Branch (1248:9): [True: 0, False: 389k]
  ------------------
 1249|      0|        return 0;
 1250|       |
 1251|   389k|    mp_set_av_packet(ctx->avpkt, pkt, &ctx->codec_timebase);
 1252|       |
 1253|   389k|    int ret = avcodec_send_packet(avctx, pkt ? ctx->avpkt : NULL);
  ------------------
  |  Branch (1253:42): [True: 373k, False: 15.8k]
  ------------------
 1254|   389k|    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
  ------------------
  |  Branch (1254:9): [True: 0, False: 389k]
  |  Branch (1254:35): [True: 0, False: 389k]
  ------------------
 1255|      0|        return ret;
 1256|       |
 1257|   389k|    if (ctx->hw_probing && ctx->num_sent_packets < 32 &&
  ------------------
  |  Branch (1257:9): [True: 0, False: 389k]
  |  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|   389k|    if (ret < 0)
  ------------------
  |  Branch (1264:9): [True: 166k, False: 222k]
  ------------------
 1265|   166k|        handle_err(vd);
 1266|   389k|    return ret;
 1267|   389k|}
vd_lavc.c:prepare_decoding:
 1184|  1.33M|{
 1185|  1.33M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1186|  1.33M|    AVCodecContext *avctx = ctx->avctx;
 1187|  1.33M|    struct vd_lavc_params *opts = ctx->opts;
 1188|       |
 1189|  1.33M|    if (!avctx)
  ------------------
  |  Branch (1189:9): [True: 0, False: 1.33M]
  ------------------
 1190|      0|        return;
 1191|       |
 1192|  1.33M|    int drop = ctx->framedrop_flags;
 1193|  1.33M|    if (drop == 1) {
  ------------------
  |  Branch (1193:9): [True: 0, False: 1.33M]
  ------------------
 1194|      0|        avctx->skip_frame = opts->framedrop;    // normal framedrop
 1195|  1.33M|    } else if (drop == 2) {
  ------------------
  |  Branch (1195:16): [True: 0, False: 1.33M]
  ------------------
 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|  1.33M|    } else {
 1201|  1.33M|        avctx->skip_frame = ctx->skip_frame;    // normal playback
 1202|  1.33M|    }
 1203|       |
 1204|  1.33M|    if (ctx->hwdec_request_reinit)
  ------------------
  |  Branch (1204:9): [True: 0, False: 1.33M]
  ------------------
 1205|      0|        reset_avctx(vd);
 1206|  1.33M|}
vd_lavc.c:handle_err:
 1209|   194k|{
 1210|   194k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1211|   194k|    struct hwdec_opts *hwdec_opts = ctx->hwdec_opts;
 1212|       |
 1213|   194k|    MP_WARN(vd, "Error while decoding frame%s!\n",
  ------------------
  |  |   90|   194k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   388k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 194k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1214|   194k|            ctx->use_hwdec ? " (hardware decoding)" : "");
 1215|       |
 1216|   194k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (1216:9): [True: 0, False: 194k]
  ------------------
 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|   194k|}
vd_lavc.c:receive_frame:
 1345|   948k|{
 1346|   948k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1347|       |
 1348|   948k|    int ret = decode_frame(vd);
 1349|       |
 1350|   948k|    if (ctx->hwdec_failed) {
  ------------------
  |  Branch (1350:9): [True: 0, False: 948k]
  ------------------
 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|   948k|    if (ret == AVERROR(EAGAIN) && ctx->num_requeue_packets)
  ------------------
  |  Branch (1377:9): [True: 784k, False: 164k]
  |  Branch (1377:35): [True: 0, False: 784k]
  ------------------
 1378|      0|        return 0; // force retry, so send_queued_packet() gets called
 1379|       |
 1380|   948k|    if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF)
  ------------------
  |  Branch (1380:9): [True: 827k, False: 120k]
  |  Branch (1380:57): [True: 811k, False: 15.7k]
  ------------------
 1381|   811k|        return ret;
 1382|       |
 1383|   136k|    if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1383:9): [True: 15.7k, False: 120k]
  ------------------
 1384|  15.7k|        return ret;
 1385|       |
 1386|   120k|    struct mp_image *res = ctx->delay_queue[0];
 1387|   120k|    MP_TARRAY_REMOVE_AT(ctx->delay_queue, ctx->num_delay_queue, 0);
  ------------------
  |  |  143|   120k|    do {                                            \
  |  |  144|   120k|        size_t at_ = (at);                          \
  |  |  145|   120k|        assert(at_ < (idxvar));                     \
  |  |  146|   120k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   120k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   120k|        (idxvar)--;                                 \
  |  |  149|   120k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 120k]
  |  |  ------------------
  ------------------
  |  Branch (1387:5): [True: 120k, False: 0]
  ------------------
 1388|       |
 1389|   120k|    res = res ? mp_img_swap_to_native(res) : NULL;
  ------------------
  |  Branch (1389:11): [True: 120k, False: 0]
  ------------------
 1390|   120k|    if (!res)
  ------------------
  |  Branch (1390:9): [True: 0, False: 120k]
  ------------------
 1391|      0|        return AVERROR_UNKNOWN;
 1392|       |
 1393|   120k|    if (ctx->use_hwdec && ctx->hwdec.copying && res->hwctx) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 120k]
  |  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|   120k|    if (!ctx->hwdec_notified) {
  ------------------
  |  Branch (1405:9): [True: 10.6k, False: 110k]
  ------------------
 1406|  10.6k|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1406:13): [True: 0, False: 10.6k]
  ------------------
 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|  10.6k|        } else {
 1410|  10.6k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  10.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1411|  10.6k|        }
 1412|  10.6k|        ctx->hwdec_notified = true;
 1413|  10.6k|    }
 1414|       |
 1415|   120k|    if (ctx->hw_probing) {
  ------------------
  |  Branch (1415:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    *out_frame = MAKE_FRAME(MP_FRAME_VIDEO, res);
  ------------------
  |  |   57|   120k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1423|   120k|    return 0;
 1424|   120k|}
vd_lavc.c:decode_frame:
 1283|   948k|{
 1284|   948k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1285|   948k|    AVCodecContext *avctx = ctx->avctx;
 1286|       |
 1287|   948k|    if (!avctx || ctx->force_eof)
  ------------------
  |  Branch (1287:9): [True: 0, False: 948k]
  |  Branch (1287:19): [True: 0, False: 948k]
  ------------------
 1288|      0|        return AVERROR_EOF;
 1289|       |
 1290|   948k|    prepare_decoding(vd);
 1291|       |
 1292|       |    // Re-send old packets (typically after a hwdec fallback during init).
 1293|   948k|    if (ctx->num_requeue_packets)
  ------------------
  |  Branch (1293:9): [True: 0, False: 948k]
  ------------------
 1294|      0|        send_queued_packet(vd);
 1295|       |
 1296|   948k|    int ret = avcodec_receive_frame(avctx, ctx->pic);
 1297|   948k|    if (ret < 0) {
  ------------------
  |  Branch (1297:9): [True: 827k, False: 120k]
  ------------------
 1298|   827k|        if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (1298:13): [True: 15.7k, False: 811k]
  ------------------
 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|  15.7k|            if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1303:17): [True: 15.7k, False: 0]
  ------------------
 1304|  15.7k|                reset_avctx(vd);
 1305|   811k|        } else if (ret == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1305:20): [True: 784k, False: 27.3k]
  ------------------
 1306|       |            // just retry after caller writes a packet
 1307|   784k|        } else {
 1308|  27.3k|            handle_err(vd);
 1309|  27.3k|        }
 1310|   827k|        return ret;
 1311|   827k|    }
 1312|       |
 1313|   120k|    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|   120k|    mp_assert(ctx->pic->buf[0]);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 120k, False: 0]
  ------------------
 1318|       |
 1319|   120k|    struct mp_image *mpi = mp_image_from_av_frame(ctx->pic);
 1320|   120k|    if (!mpi) {
  ------------------
  |  Branch (1320:9): [True: 0, False: 120k]
  ------------------
 1321|      0|        av_frame_unref(ctx->pic);
 1322|      0|        return ret;
 1323|      0|    }
 1324|       |
 1325|   120k|    if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 120k]
  |  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|   120k|    ctx->hwdec_fail_count = 0;
 1333|       |
 1334|   120k|    mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
 1335|   120k|    mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
 1336|   120k|    mpi->pkt_duration = mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
 1337|       |
 1338|   120k|    av_frame_unref(ctx->pic);
 1339|       |
 1340|   120k|    MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi);
  ------------------
  |  |  105|   120k|    do {                                            \
  |  |  106|   120k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   120k|    do {                                            \
  |  |  |  |   97|   120k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   120k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   120k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   120k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 10.6k, False: 110k]
  |  |  |  |  ------------------
  |  |  |  |   99|   120k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  10.6k|    do {                                                        \
  |  |  |  |  |  |   89|  10.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  10.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  10.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  10.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  10.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  10.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  10.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 10.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   120k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 120k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   120k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   120k|        (idxvar)++;                                 \
  |  |  109|   120k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 120k]
  |  |  ------------------
  ------------------
 1341|   120k|    return ret;
 1342|   120k|}
vd_lavc.c:select_and_set_hwdec:
  504|  19.0k|{
  505|  19.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
  506|  19.0k|    const char *codec = ctx->codec->codec;
  507|       |
  508|  19.0k|    m_config_cache_update(ctx->hwdec_opts_cache);
  509|       |
  510|  19.0k|    struct hwdec_info *hwdecs = NULL;
  511|  19.0k|    int num_hwdecs = 0;
  512|  19.0k|    add_all_hwdec_methods(&hwdecs, &num_hwdecs);
  513|       |
  514|  19.0k|    char **hwdec_api = ctx->hwdec_opts->hwdec_api;
  515|  19.0k|    for (int i = 0; hwdec_api && hwdec_api[i]; i++) {
  ------------------
  |  Branch (515:21): [True: 19.0k, False: 0]
  |  Branch (515:34): [True: 19.0k, False: 0]
  ------------------
  516|  19.0k|        bstr opt = bstr0(hwdec_api[i]);
  517|       |
  518|  19.0k|        bool hwdec_requested = !bstr_equals0(opt, "no");
  519|  19.0k|        bool hwdec_auto_safe = bstr_equals0(opt, "auto") ||
  ------------------
  |  Branch (519:32): [True: 0, False: 19.0k]
  ------------------
  520|  19.0k|                            bstr_equals0(opt, "auto-safe") ||
  ------------------
  |  Branch (520:29): [True: 0, False: 19.0k]
  ------------------
  521|  19.0k|                            bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (521:29): [True: 0, False: 19.0k]
  ------------------
  522|  19.0k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (522:29): [True: 0, False: 19.0k]
  ------------------
  523|  19.0k|                            bstr_equals0(opt, "yes") ||
  ------------------
  |  Branch (523:29): [True: 0, False: 19.0k]
  ------------------
  524|  19.0k|                            bstr_equals0(opt, "");
  ------------------
  |  Branch (524:29): [True: 0, False: 19.0k]
  ------------------
  525|  19.0k|        bool hwdec_auto_unsafe = bstr_equals0(opt, "auto-unsafe");
  526|  19.0k|        bool hwdec_auto_copy = bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (526:32): [True: 0, False: 19.0k]
  ------------------
  527|  19.0k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (527:29): [True: 0, False: 19.0k]
  ------------------
  528|  19.0k|                            bstr_equals0(opt, "auto-copy-unsafe");
  ------------------
  |  Branch (528:29): [True: 0, False: 19.0k]
  ------------------
  529|  19.0k|        bool hwdec_auto = hwdec_auto_unsafe || hwdec_auto_copy || hwdec_auto_safe;
  ------------------
  |  Branch (529:27): [True: 0, False: 19.0k]
  |  Branch (529:48): [True: 0, False: 19.0k]
  |  Branch (529:67): [True: 0, False: 19.0k]
  ------------------
  530|       |
  531|  19.0k|        if (!hwdec_requested) {
  ------------------
  |  Branch (531:13): [True: 19.0k, False: 0]
  ------------------
  532|  19.0k|            MP_VERBOSE(vd, "No hardware decoding requested.\n");
  ------------------
  |  |   92|  19.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  533|  19.0k|            break;
  534|  19.0k|        } 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|  19.0k|    }
  635|  19.0k|    talloc_free(hwdecs);
  ------------------
  |  |   47|  19.0k|#define talloc_free                     ta_free
  ------------------
  636|       |
  637|       |
  638|  19.0k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (638:9): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|    } 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|  19.0k|        if (ctx->hwdec_opts->software_fallback == INT_MAX) {
  ------------------
  |  Branch (646:13): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|        } else {
  650|  19.0k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  19.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  19.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  651|  19.0k|        }
  652|  19.0k|    }
  653|  19.0k|}
vd_lavc.c:init_avctx:
  728|  19.0k|{
  729|  19.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
  730|  19.0k|    struct vd_lavc_params *lavc_param = ctx->opts;
  731|  19.0k|    struct mp_codec_params *c = ctx->codec;
  732|       |
  733|  19.0k|    m_config_cache_update(ctx->opts_cache);
  734|       |
  735|  19.0k|    mp_assert(!ctx->avctx);
  ------------------
  |  |   41|  19.0k|#define mp_assert assert
  ------------------
  |  Branch (735:5): [True: 19.0k, False: 0]
  ------------------
  736|       |
  737|  19.0k|    const AVCodec *lavc_codec = NULL;
  738|       |
  739|  19.0k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (739:9): [True: 0, False: 19.0k]
  ------------------
  740|      0|        lavc_codec = ctx->hwdec.codec;
  741|  19.0k|    } else {
  742|  19.0k|        lavc_codec = avcodec_find_decoder_by_name(ctx->decoder);
  743|  19.0k|    }
  744|  19.0k|    if (!lavc_codec)
  ------------------
  |  Branch (744:9): [True: 0, False: 19.0k]
  ------------------
  745|      0|        return;
  746|       |
  747|  19.0k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id);
  748|  19.0k|    ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY);
  ------------------
  |  Branch (748:23): [True: 19.0k, False: 0]
  |  Branch (748:31): [True: 471, False: 18.5k]
  ------------------
  749|       |
  750|  19.0k|    ctx->codec_timebase = mp_get_codec_timebase(ctx->codec);
  751|       |
  752|  19.0k|    ctx->hwdec_failed = false;
  753|  19.0k|    ctx->hwdec_request_reinit = false;
  754|  19.0k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  755|  19.0k|    AVCodecContext *avctx = ctx->avctx;
  756|  19.0k|    if (!ctx->avctx)
  ------------------
  |  Branch (756:9): [True: 0, False: 19.0k]
  ------------------
  757|      0|        goto error;
  758|  19.0k|    avctx->codec_type = AVMEDIA_TYPE_VIDEO;
  759|  19.0k|    avctx->codec_id = lavc_codec->id;
  760|  19.0k|    avctx->pkt_timebase = ctx->codec_timebase;
  761|       |
  762|  19.0k|    ctx->pic = av_frame_alloc();
  763|  19.0k|    if (!ctx->pic)
  ------------------
  |  Branch (763:9): [True: 0, False: 19.0k]
  ------------------
  764|      0|        goto error;
  765|       |
  766|  19.0k|    ctx->avpkt = av_packet_alloc();
  767|  19.0k|    if (!ctx->avpkt)
  ------------------
  |  Branch (767:9): [True: 0, False: 19.0k]
  ------------------
  768|      0|        goto error;
  769|       |
  770|  19.0k|    int threads = lavc_param->threads;
  771|  19.0k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (771:9): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|    mp_set_avcodec_threads(vd->log, avctx, threads);
  820|       |
  821|  19.0k|    if (!ctx->use_hwdec && ctx->vo && lavc_param->dr) {
  ------------------
  |  Branch (821:9): [True: 19.0k, False: 0]
  |  Branch (821:28): [True: 19.0k, False: 0]
  |  Branch (821:39): [True: 19.0k, False: 0]
  ------------------
  822|  19.0k|        avctx->opaque = vd;
  823|  19.0k|        avctx->get_buffer2 = get_buffer2_direct;
  824|  19.0k|    }
  825|       |
  826|  19.0k|    avctx->flags |= lavc_param->bitexact ? AV_CODEC_FLAG_BITEXACT : 0;
  ------------------
  |  Branch (826:21): [True: 0, False: 19.0k]
  ------------------
  827|  19.0k|    avctx->flags2 |= lavc_param->fast ? AV_CODEC_FLAG2_FAST : 0;
  ------------------
  |  Branch (827:22): [True: 0, False: 19.0k]
  ------------------
  828|       |
  829|  19.0k|    if (lavc_param->show_all)
  ------------------
  |  Branch (829:9): [True: 0, False: 19.0k]
  ------------------
  830|      0|        avctx->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT;
  831|       |
  832|  19.0k|    avctx->skip_loop_filter = lavc_param->skip_loop_filter;
  833|  19.0k|    avctx->skip_idct = lavc_param->skip_idct;
  834|  19.0k|    avctx->skip_frame = lavc_param->skip_frame;
  835|  19.0k|    avctx->apply_cropping = lavc_param->apply_cropping;
  836|       |
  837|  19.0k|    if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
  ------------------
  |  Branch (837:9): [True: 7.17k, False: 11.8k]
  |  Branch (837:47): [True: 0, False: 7.17k]
  ------------------
  838|      0|        av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
  839|       |
  840|  19.0k|    switch(ctx->opts->film_grain) {
  841|      0|    case 0: /*CPU*/
  ------------------
  |  Branch (841:5): [True: 0, False: 19.0k]
  ------------------
  842|       |        // default lavc flags handle film grain within the decoder.
  843|      0|        break;
  844|      0|    case 1: /*GPU*/
  ------------------
  |  Branch (844:5): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|    default:
  ------------------
  |  Branch (856:5): [True: 19.0k, False: 0]
  ------------------
  857|  19.0k|        if (ctx->vo && (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))
  ------------------
  |  Branch (857:13): [True: 19.0k, False: 0]
  |  Branch (857:24): [True: 0, False: 19.0k]
  ------------------
  858|      0|            avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  859|       |
  860|  19.0k|        break;
  861|  19.0k|    }
  862|       |
  863|  19.0k|    mp_set_avopts(vd->log, avctx, lavc_param->avopts);
  864|       |
  865|       |    // Do this after the above avopt handling in case it changes values
  866|  19.0k|    ctx->skip_frame = avctx->skip_frame;
  867|       |
  868|  19.0k|    if (mp_set_avctx_codec_headers(avctx, c) < 0) {
  ------------------
  |  Branch (868:9): [True: 0, False: 19.0k]
  ------------------
  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|  19.0k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  874|  19.0k|    if (avctx->width > 8192 || avctx->height > 8192) {
  ------------------
  |  Branch (874:9): [True: 158, False: 18.8k]
  |  Branch (874:32): [True: 32, False: 18.8k]
  ------------------
  875|    190|        MP_ERR(vd, "Frame size too big %" PRIu32 "x%" PRIu32 ".\n", avctx->width, avctx->height);
  ------------------
  |  |   89|    190|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    190|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  876|    190|        goto error;
  877|    190|    }
  878|  18.8k|    avctx->max_pixels = 2048 * 2048;
  879|  18.8k|#endif
  880|       |
  881|       |    /* open it */
  882|  18.8k|    if (avcodec_open2(avctx, lavc_codec, NULL) < 0)
  ------------------
  |  Branch (882:9): [True: 533, False: 18.3k]
  ------------------
  883|    533|        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|  18.3k|    if (lavc_codec->id == AV_CODEC_ID_H264 && c->first_packet) {
  ------------------
  |  Branch (889:9): [True: 7.03k, False: 11.2k]
  |  Branch (889:47): [True: 6.12k, False: 903]
  ------------------
  890|  6.12k|        mp_set_av_packet(ctx->avpkt, c->first_packet, &ctx->codec_timebase);
  891|  6.12k|        avcodec_send_packet(avctx, ctx->avpkt);
  892|  6.12k|        avcodec_receive_frame(avctx, ctx->pic);
  893|  6.12k|        av_frame_unref(ctx->pic);
  894|  6.12k|        avcodec_flush_buffers(ctx->avctx);
  895|  6.12k|    }
  896|       |
  897|  18.3k|    return;
  898|       |
  899|    723|error:
  900|    723|    MP_ERR(vd, "Could not open codec.\n");
  ------------------
  |  |   89|    723|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    723|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  901|    723|    uninit_avctx(vd);
  902|    723|}
vd_lavc.c:get_buffer2_direct:
 1094|   330k|{
 1095|   330k|    struct mp_filter *vd = avctx->opaque;
 1096|   330k|    vd_ffmpeg_ctx *p = vd->priv;
 1097|       |
 1098|   330k|    mp_mutex_lock(&p->dr_lock);
  ------------------
  |  |  134|   330k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1099|       |
 1100|   330k|    int w = pic->width;
 1101|   330k|    int h = pic->height;
 1102|   330k|    int linesize_align[AV_NUM_DATA_POINTERS] = {0};
 1103|   330k|    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|   330k|    int stride_align = MP_IMAGE_BYTE_ALIGN;
  ------------------
  |  |   35|   330k|#define MP_IMAGE_BYTE_ALIGN 64
  ------------------
 1108|  2.97M|    for (int n = 0; n < AV_NUM_DATA_POINTERS; n++)
  ------------------
  |  Branch (1108:21): [True: 2.64M, False: 330k]
  ------------------
 1109|  2.64M|        stride_align = MPMAX(stride_align, linesize_align[n]);
  ------------------
  |  |   44|  2.64M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 2.64M, False: 0]
  |  |  ------------------
  ------------------
 1110|       |
 1111|       |    // Note: texel sizes may be NPOT, so use full lcm instead of max
 1112|   330k|    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
 1113|   330k|    if (!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)) {
  ------------------
  |  Branch (1113:9): [True: 330k, False: 0]
  ------------------
 1114|  1.32M|        for (int n = 0; n < desc->nb_components; n++)
  ------------------
  |  Branch (1114:25): [True: 991k, False: 330k]
  ------------------
 1115|   991k|            stride_align = mp_lcm(stride_align, desc->comp[n].step);
 1116|   330k|    }
 1117|       |
 1118|   330k|    int imgfmt = pixfmt2imgfmt(pic->format);
 1119|   330k|    if (!imgfmt)
  ------------------
  |  Branch (1119:9): [True: 0, False: 330k]
  ------------------
 1120|      0|        goto fallback;
 1121|       |
 1122|   330k|    if (p->dr_failed)
  ------------------
  |  Branch (1122:9): [True: 316k, False: 14.1k]
  ------------------
 1123|   316k|        goto fallback;
 1124|       |
 1125|       |    // (For simplicity, we realloc on any parameter change, instead of trying
 1126|       |    // to be clever.)
 1127|  14.1k|    if (stride_align != p->dr_stride_align || w != p->dr_w || h != p->dr_h ||
  ------------------
  |  Branch (1127:9): [True: 14.1k, 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|  14.1k|    {
 1130|  14.1k|        mp_image_pool_clear(p->dr_pool);
 1131|  14.1k|        p->dr_imgfmt = imgfmt;
 1132|  14.1k|        p->dr_w = w;
 1133|  14.1k|        p->dr_h = h;
 1134|  14.1k|        p->dr_stride_align = stride_align;
 1135|  14.1k|        MP_DBG(p, "DR parameter change to %dx%d %s align=%d\n", w, h,
  ------------------
  |  |   93|  14.1k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|  14.1k|               mp_imgfmt_to_name(imgfmt), stride_align);
 1137|  14.1k|    }
 1138|       |
 1139|  14.1k|    struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);
 1140|  14.1k|    if (!img) {
  ------------------
  |  Branch (1140:9): [True: 14.1k, False: 0]
  ------------------
 1141|  14.1k|        bool host_cached = p->opts->dr == -1; // auto
 1142|  14.1k|        int dr_flags = host_cached ? VO_DR_FLAG_HOST_CACHED : 0;
  ------------------
  |  Branch (1142:24): [True: 14.1k, False: 0]
  ------------------
 1143|  14.1k|        MP_DBG(p, "Allocating new%s DR image...\n", host_cached ? " (host-cached)" : "");
  ------------------
  |  |   93|  14.1k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 14.1k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|  14.1k|        img = vo_get_image(p->vo, imgfmt, w, h, stride_align, dr_flags);
 1145|  14.1k|        if (!img) {
  ------------------
  |  Branch (1145:13): [True: 14.1k, False: 0]
  ------------------
 1146|  14.1k|            MP_DBG(p, "...failed..\n");
  ------------------
  |  |   93|  14.1k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1147|  14.1k|            goto fallback;
 1148|  14.1k|        }
 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|   330k|fallback:
 1175|   330k|    if (!p->dr_failed)
  ------------------
  |  Branch (1175:9): [True: 14.1k, False: 316k]
  ------------------
 1176|   330k|        MP_VERBOSE(p, "DR failed - disabling.\n");
  ------------------
  |  |   92|  14.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1177|   330k|    p->dr_failed = true;
 1178|   330k|    mp_mutex_unlock(&p->dr_lock);
  ------------------
  |  |  136|   330k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1179|       |
 1180|   330k|    return avcodec_default_get_buffer2(avctx, pic, flags);
 1181|  14.1k|}
vd_lavc.c:vd_lavc_reset:
 1474|    963|{
 1475|    963|    vd_ffmpeg_ctx *ctx = vd->priv;
 1476|       |
 1477|    963|    flush_all(vd);
 1478|       |
 1479|    963|    ctx->state = (struct lavc_state){0};
 1480|    963|    ctx->framedrop_flags = 0;
 1481|    963|}
vd_lavc.c:control:
 1427|   476k|{
 1428|   476k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1429|   476k|    switch (cmd) {
  ------------------
  |  Branch (1429:13): [True: 476k, False: 0]
  ------------------
 1430|   392k|    case VDCTRL_SET_FRAMEDROP:
  ------------------
  |  Branch (1430:5): [True: 392k, False: 84.6k]
  ------------------
 1431|   392k|        ctx->framedrop_flags = *(int *)arg;
 1432|   392k|        return CONTROL_TRUE;
  ------------------
  |  |   96|   392k|#define CONTROL_TRUE 1
  ------------------
 1433|      0|    case VDCTRL_SET_EXTRA_HW_FRAMES:
  ------------------
  |  Branch (1433:5): [True: 0, False: 476k]
  ------------------
 1434|      0|        ctx->extra_hw_frames_hint = *(int *)arg;
 1435|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1436|  33.1k|    case VDCTRL_CHECK_FORCED_EOF: {
  ------------------
  |  Branch (1436:5): [True: 33.1k, False: 443k]
  ------------------
 1437|  33.1k|        *(bool *)arg = ctx->force_eof;
 1438|  33.1k|        return CONTROL_TRUE;
  ------------------
  |  |   96|  33.1k|#define CONTROL_TRUE 1
  ------------------
 1439|      0|    }
 1440|      0|    case VDCTRL_GET_BFRAMES: {
  ------------------
  |  Branch (1440:5): [True: 0, False: 476k]
  ------------------
 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|  51.4k|    case VDCTRL_GET_HWDEC: {
  ------------------
  |  Branch (1447:5): [True: 51.4k, False: 425k]
  ------------------
 1448|  51.4k|        if (!ctx->hwdec_notified)
  ------------------
  |  Branch (1448:13): [True: 37.0k, False: 14.4k]
  ------------------
 1449|  37.0k|            return CONTROL_FALSE;
  ------------------
  |  |   97|  37.0k|#define CONTROL_FALSE 0
  ------------------
 1450|  14.4k|        *(char **)arg = ctx->use_hwdec ? ctx->hwdec.method_name : NULL;
  ------------------
  |  Branch (1450:25): [True: 0, False: 14.4k]
  ------------------
 1451|  14.4k|        return CONTROL_TRUE;
  ------------------
  |  |   96|  14.4k|#define CONTROL_TRUE 1
  ------------------
 1452|  51.4k|    }
 1453|      0|    case VDCTRL_FORCE_HWDEC_FALLBACK:
  ------------------
  |  Branch (1453:5): [True: 0, False: 476k]
  ------------------
 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: 476k]
  ------------------
 1460|      0|        reinit(vd);
 1461|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1462|   476k|    }
 1463|      0|    return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1464|   476k|}
vd_lavc.c:reinit:
  696|  19.0k|{
  697|  19.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
  698|       |
  699|  19.0k|    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|  19.0k|    TA_FREEP(&ctx->attempted_hwdecs);
  ------------------
  |  |   81|  19.0k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  19.0k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 19.0k]
  |  |  ------------------
  ------------------
  708|  19.0k|    ctx->num_attempted_hwdecs = 0;
  709|  19.0k|    ctx->hwdec_notified = false;
  710|       |
  711|  19.0k|    select_and_set_hwdec(vd);
  712|       |
  713|  19.0k|    bool use_hwdec = ctx->use_hwdec;
  714|  19.0k|    init_avctx(vd);
  715|  19.0k|    if (!ctx->avctx && use_hwdec) {
  ------------------
  |  Branch (715:9): [True: 723, False: 18.3k]
  |  Branch (715:24): [True: 0, False: 723]
  ------------------
  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|  19.0k|    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: 19.0k]
  ------------------
  725|  19.0k|}
vd_lavc.c:add_decoders:
 1550|  19.6k|{
 1551|  19.6k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_VIDEO);
 1552|  19.6k|}

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

mp_imgfmt_to_name_buf:
  169|   111k|{
  170|   111k|    const struct mp_imgfmt_entry *p = get_mp_desc(fmt);
  171|   111k|    const char *name = p ? p->name : NULL;
  ------------------
  |  Branch (171:24): [True: 0, False: 111k]
  ------------------
  172|   111k|    if (!name) {
  ------------------
  |  Branch (172:9): [True: 111k, False: 0]
  ------------------
  173|   111k|        const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(imgfmt2pixfmt(fmt));
  174|   111k|        if (pixdesc)
  ------------------
  |  Branch (174:13): [True: 111k, False: 0]
  ------------------
  175|   111k|            name = pixdesc->name;
  176|   111k|    }
  177|   111k|    if (!name)
  ------------------
  |  Branch (177:9): [True: 0, False: 111k]
  ------------------
  178|      0|        name = "unknown";
  179|   111k|    snprintf(buf, buf_size, "%s", name);
  180|   111k|    int len = strlen(buf);
  181|   111k|    if (len > 2 && buf[len - 2] == MP_SELECT_LE_BE('l', 'b') && buf[len - 1] == 'e')
  ------------------
  |  |   38|   222k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  |  Branch (181:9): [True: 111k, False: 0]
  |  Branch (181:20): [True: 3.63k, False: 107k]
  |  Branch (181:65): [True: 3.51k, False: 117]
  ------------------
  182|  3.51k|        buf[len - 2] = '\0';
  183|   111k|    return buf;
  184|   111k|}
mp_imgfmt_desc_get_num_comps:
  557|   263k|{
  558|   263k|    int flags = desc->flags;
  559|   263k|    if (!(flags & MP_IMGFLAG_COLOR_MASK))
  ------------------
  |  |   55|   263k|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (559:9): [True: 0, False: 263k]
  ------------------
  560|      0|        return 0;
  561|   263k|    return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   75|   263k|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
                  return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   52|   263k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (561:17): [True: 0, False: 263k]
  ------------------
  562|   263k|}
mp_imgfmt_get_desc:
  565|   142k|{
  566|   142k|    struct mp_imgfmt_desc desc;
  567|       |
  568|   142k|    if (!get_native_desc(mpfmt, &desc) &&
  ------------------
  |  Branch (568:9): [True: 142k, False: 0]
  ------------------
  569|   142k|        !mp_imgfmt_get_desc_from_pixdesc(mpfmt, &desc))
  ------------------
  |  Branch (569:9): [True: 0, False: 142k]
  ------------------
  570|      0|        return (struct mp_imgfmt_desc){0};
  571|       |
  572|   562k|    for (int p = 0; p < desc.num_planes; p++) {
  ------------------
  |  Branch (572:21): [True: 420k, False: 142k]
  ------------------
  573|   420k|        desc.xs[p] = (p == 1 || p == 2) ? desc.chroma_xs : 0;
  ------------------
  |  Branch (573:23): [True: 138k, False: 281k]
  |  Branch (573:33): [True: 138k, False: 142k]
  ------------------
  574|   420k|        desc.ys[p] = (p == 1 || p == 2) ? desc.chroma_ys : 0;
  ------------------
  |  Branch (574:23): [True: 138k, False: 281k]
  |  Branch (574:33): [True: 138k, False: 142k]
  ------------------
  575|   420k|    }
  576|       |
  577|   142k|    bool is_ba = desc.num_planes > 0;
  578|   562k|    for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (578:21): [True: 420k, False: 142k]
  ------------------
  579|   420k|        is_ba = !(desc.bpp[p] % 8u);
  580|       |
  581|   142k|    if (is_ba)
  ------------------
  |  Branch (581:9): [True: 142k, False: 0]
  ------------------
  582|   142k|        desc.flags |= MP_IMGFLAG_BYTE_ALIGNED;
  ------------------
  |  |   40|   142k|#define MP_IMGFLAG_BYTE_ALIGNED (1 << 2)
  ------------------
  583|       |
  584|   142k|    if (desc.flags & MP_IMGFLAG_HAS_COMPS) {
  ------------------
  |  |   34|   142k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (584:9): [True: 142k, False: 145]
  ------------------
  585|   142k|        if (desc.comps[3].size)
  ------------------
  |  Branch (585:13): [True: 12, False: 142k]
  ------------------
  586|     12|            desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|     12|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  587|       |
  588|       |        // Assuming all colors are (CCC+[A]) or (C+[A]), the latter being gray.
  589|   142k|        if (!desc.comps[1].size)
  ------------------
  |  Branch (589:13): [True: 0, False: 142k]
  ------------------
  590|      0|            desc.flags |= MP_IMGFLAG_GRAY;
  ------------------
  |  |   75|      0|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
  591|       |
  592|   142k|        bool bb = true;
  593|   712k|        for (int n = 0; n < MP_NUM_COMPONENTS; n++) {
  ------------------
  |  |   29|   712k|#define MP_NUM_COMPONENTS 4
  ------------------
  |  Branch (593:25): [True: 570k, False: 142k]
  ------------------
  594|   570k|            if (desc.comps[n].offset % 8u || desc.comps[n].size % 8u)
  ------------------
  |  Branch (594:17): [True: 0, False: 570k]
  |  Branch (594:46): [True: 0, False: 570k]
  ------------------
  595|      0|                bb = false;
  596|   570k|        }
  597|   142k|        if (bb)
  ------------------
  |  Branch (597:13): [True: 142k, False: 0]
  ------------------
  598|   142k|            desc.flags |= MP_IMGFLAG_BYTES;
  ------------------
  |  |   37|   142k|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  599|   142k|    }
  600|       |
  601|   142k|    if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   67|   142k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|   142k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
                  if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   68|   142k|#define MP_IMGFLAG_RGB          MP_IMGFLAG_COLOR_RGB
  |  |  ------------------
  |  |  |  |   57|   142k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  |  |  ------------------
  ------------------
  |  Branch (601:9): [True: 142k, False: 0]
  ------------------
  602|   142k|        && (desc.flags & MP_IMGFLAG_HAS_COMPS)
  ------------------
  |  |   34|   142k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (602:12): [True: 142k, False: 145]
  ------------------
  603|   142k|        && (desc.flags & MP_IMGFLAG_BYTES)
  ------------------
  |  |   37|   142k|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  |  Branch (603:12): [True: 142k, False: 0]
  ------------------
  604|   142k|        && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   61|   142k|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
                      && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   62|   142k|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  |  Branch (604:12): [True: 142k, False: 0]
  ------------------
  605|   142k|    {
  606|   142k|        int cnt = mp_imgfmt_desc_get_num_comps(&desc);
  607|   142k|        bool same_depth = true;
  608|   562k|        for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (608:25): [True: 420k, False: 142k]
  ------------------
  609|   420k|            same_depth &= desc.bpp[p] == desc.bpp[0];
  610|   142k|        if (same_depth && cnt == desc.num_planes) {
  ------------------
  |  Branch (610:13): [True: 142k, False: 0]
  |  Branch (610:27): [True: 138k, False: 3.75k]
  ------------------
  611|   138k|            if (desc.flags & MP_IMGFLAG_YUV) {
  ------------------
  |  |   67|   138k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|   138k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
  |  Branch (611:17): [True: 138k, False: 0]
  ------------------
  612|   138k|                desc.flags |= MP_IMGFLAG_YUV_P;
  ------------------
  |  |   94|   138k|#define MP_IMGFLAG_YUV_P        (1 << 16)
  ------------------
  613|   138k|            } else {
  614|      0|                desc.flags |= MP_IMGFLAG_RGB_P;
  ------------------
  |  |   98|      0|#define MP_IMGFLAG_RGB_P        (1 << 17)
  ------------------
  615|      0|            }
  616|   138k|        }
  617|   142k|        if (cnt == 3 && desc.num_planes == 2 &&
  ------------------
  |  Branch (617:13): [True: 142k, False: 12]
  |  Branch (617:25): [True: 0, False: 142k]
  ------------------
  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|   142k|    }
  625|       |
  626|   142k|    return desc;
  627|   142k|}
mp_imgfmt_get_forced_csp:
  682|  10.8k|{
  683|  10.8k|    return get_forced_csp_from_flags(mp_imgfmt_get_desc(imgfmt).flags);
  684|  10.8k|}
mp_imgfmt_is_subsampled:
  830|  10.8k|{
  831|  10.8k|    struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
  832|  10.8k|    return desc.chroma_xs || desc.chroma_ys;
  ------------------
  |  Branch (832:12): [True: 10.6k, False: 210]
  |  Branch (832:30): [True: 3, False: 207]
  ------------------
  833|  10.8k|}
img_format.c:get_mp_desc:
  124|   253k|{
  125|   253k|    if (imgfmt < IMGFMT_CUST_BASE)
  ------------------
  |  Branch (125:9): [True: 244k, False: 9.49k]
  ------------------
  126|   244k|        return NULL;
  127|  9.49k|    int index = imgfmt - IMGFMT_CUST_BASE;
  128|  9.49k|    if (index >= MP_ARRAY_SIZE(mp_imgfmt_list))
  ------------------
  |  |   49|  9.49k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (128:9): [True: 9.49k, False: 0]
  ------------------
  129|  9.49k|        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|  9.49k|}
img_format.c:get_native_desc:
  523|   142k|{
  524|   142k|    const struct mp_imgfmt_entry *p = get_mp_desc(mpfmt);
  525|   142k|    if (!p || !p->desc.flags)
  ------------------
  |  Branch (525:9): [True: 142k, False: 0]
  |  Branch (525:15): [True: 0, False: 0]
  ------------------
  526|   142k|        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|   142k|}
img_format.c:mp_imgfmt_get_desc_from_pixdesc:
  413|   142k|{
  414|   142k|    enum AVPixelFormat fmt = imgfmt2pixfmt(mpfmt);
  415|   142k|    const AVPixFmtDescriptor *pd = av_pix_fmt_desc_get(fmt);
  416|   142k|    if (!pd || pd->nb_components > 4)
  ------------------
  |  Branch (416:9): [True: 0, False: 142k]
  |  Branch (416:16): [True: 0, False: 142k]
  ------------------
  417|      0|        return false;
  418|       |
  419|   142k|    struct mp_imgfmt_desc desc = {
  420|   142k|        .id = mpfmt,
  421|   142k|        .chroma_xs = pd->log2_chroma_w,
  422|   142k|        .chroma_ys = pd->log2_chroma_h,
  423|   142k|    };
  424|       |
  425|   142k|    if (pd->flags & AV_PIX_FMT_FLAG_ALPHA)
  ------------------
  |  Branch (425:9): [True: 157, False: 142k]
  ------------------
  426|    157|        desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|    157|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  427|       |
  428|   142k|    if (pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (428:9): [True: 0, False: 142k]
  ------------------
  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|   142k|    if (strncmp(pd->name, "xyz", 3) == 0) {
  ------------------
  |  Branch (432:9): [True: 0, False: 142k]
  ------------------
  433|      0|        desc.flags |= MP_IMGFLAG_COLOR_XYZ;
  ------------------
  |  |   58|      0|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  434|   142k|    } else if (pd->flags & AV_PIX_FMT_FLAG_RGB) {
  ------------------
  |  Branch (434:16): [True: 3.75k, False: 138k]
  ------------------
  435|  3.75k|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|  3.75k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  436|   138k|    } else if (fmt == AV_PIX_FMT_MONOBLACK || fmt == AV_PIX_FMT_MONOWHITE) {
  ------------------
  |  Branch (436:16): [True: 0, False: 138k]
  |  Branch (436:47): [True: 0, False: 138k]
  ------------------
  437|      0|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|      0|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  438|   138k|    } else if (fmt == AV_PIX_FMT_PAL8) {
  ------------------
  |  Branch (438:16): [True: 145, False: 138k]
  ------------------
  439|    145|        desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   57|    145|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
                      desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   64|    145|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  ------------------
  440|    145|    }
  441|       |
  442|   142k|    if (pd->flags & AV_PIX_FMT_FLAG_FLOAT)
  ------------------
  |  Branch (442:9): [True: 0, False: 142k]
  ------------------
  443|      0|        desc.flags |= MP_IMGFLAG_TYPE_FLOAT;
  ------------------
  |  |   63|      0|#define MP_IMGFLAG_TYPE_FLOAT   (2 << 10)
  ------------------
  444|       |
  445|       |    // Educated guess.
  446|   142k|    if (!(desc.flags & MP_IMGFLAG_COLOR_MASK) &&
  ------------------
  |  |   55|   142k|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (446:9): [True: 138k, False: 3.89k]
  ------------------
  447|   138k|        !(desc.flags & MP_IMGFLAG_TYPE_HW))
  ------------------
  |  |   65|   138k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  ------------------
  |  Branch (447:9): [True: 138k, False: 0]
  ------------------
  448|   138k|        desc.flags |= MP_IMGFLAG_COLOR_YUV;
  ------------------
  |  |   56|   138k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  ------------------
  449|       |
  450|   142k|    desc.align_x = 1 << desc.chroma_xs;
  451|   142k|    desc.align_y = 1 << desc.chroma_ys;
  452|       |
  453|   142k|    fill_pixdesc_layout(&desc, fmt, pd);
  454|       |
  455|   142k|    if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   34|   142k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
                  if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   86|   142k|#define MP_IMGFLAG_PACKED_SS_YUV (1 << 15)
  ------------------
  |  Branch (455:9): [True: 142k, False: 145]
  ------------------
  456|   142k|        if (!(desc.flags & MP_IMGFLAG_TYPE_MASK))
  ------------------
  |  |   61|   142k|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
  |  Branch (456:13): [True: 142k, False: 0]
  ------------------
  457|   142k|            desc.flags |= MP_IMGFLAG_TYPE_UINT;
  ------------------
  |  |   62|   142k|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  458|   142k|    }
  459|       |
  460|   142k|    if (desc.bpp[0] % 8u && (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM))
  ------------------
  |  Branch (460:9): [True: 0, False: 142k]
  |  Branch (460:29): [True: 0, False: 0]
  ------------------
  461|      0|        desc.align_x = 8 / desc.bpp[0]; // expect power of 2
  462|       |
  463|       |    // Very heuristical.
  464|   142k|    bool is_ne = !desc.endian_shift;
  465|   142k|    bool need_endian = (desc.comps[0].size % 8u && desc.bpp[0] > 8) ||
  ------------------
  |  Branch (465:25): [True: 0, False: 142k]
  |  Branch (465:52): [True: 0, False: 0]
  ------------------
  466|   142k|                       desc.comps[0].size > 8;
  ------------------
  |  Branch (466:24): [True: 2.56k, False: 140k]
  ------------------
  467|       |
  468|   142k|    if (need_endian) {
  ------------------
  |  Branch (468:9): [True: 2.56k, False: 140k]
  ------------------
  469|  2.56k|        bool is_le = MP_SELECT_LE_BE(is_ne, !is_ne);
  ------------------
  |  |   38|  2.56k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  470|  2.56k|        desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   43|  2.56k|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   46|  2.56k|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  |  Branch (470:23): [True: 2.56k, False: 0]
  ------------------
  471|   140k|    } else {
  472|   140k|        desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   43|   140k|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   46|   140k|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  473|   140k|    }
  474|       |
  475|   142k|    *out = desc;
  476|       |    return true;
  477|   142k|}
img_format.c:fill_pixdesc_layout:
  189|   142k|{
  190|   142k|    if (pd->flags & AV_PIX_FMT_FLAG_PAL ||
  ------------------
  |  Branch (190:9): [True: 145, False: 142k]
  ------------------
  191|   142k|        pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (191:9): [True: 0, False: 142k]
  ------------------
  192|    145|        goto fail;
  193|       |
  194|   142k|    bool has_alpha = pd->flags & AV_PIX_FMT_FLAG_ALPHA;
  195|   142k|    if (pd->nb_components != 1 + has_alpha &&
  ------------------
  |  Branch (195:9): [True: 142k, False: 0]
  ------------------
  196|   142k|        pd->nb_components != 3 + has_alpha)
  ------------------
  |  Branch (196:9): [True: 0, False: 142k]
  ------------------
  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|   142k|    bool is_be = pd->flags & AV_PIX_FMT_FLAG_BE;
  203|   142k|    bool is_ne = MP_SELECT_LE_BE(false, true) == is_be;
  ------------------
  |  |   38|   142k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  204|       |
  205|       |    // Packed sub-sampled YUV is very... special.
  206|   142k|    bool is_packed_ss_yuv = pd->log2_chroma_w && !pd->log2_chroma_h &&
  ------------------
  |  Branch (206:29): [True: 138k, False: 3.77k]
  |  Branch (206:50): [True: 1.43k, False: 137k]
  ------------------
  207|  1.43k|        pd->comp[1].plane == 0 && pd->comp[2].plane == 0 &&
  ------------------
  |  Branch (207:9): [True: 0, False: 1.43k]
  |  Branch (207:35): [True: 0, False: 0]
  ------------------
  208|      0|        pd->nb_components == 3;
  ------------------
  |  Branch (208:9): [True: 0, False: 0]
  ------------------
  209|       |
  210|   142k|    if (is_packed_ss_yuv)
  ------------------
  |  Branch (210:9): [True: 0, False: 142k]
  ------------------
  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|   142k|    bool any_shared_bytes = !!(pd->flags & AV_PIX_FMT_FLAG_BITSTREAM);
  217|   570k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (217:21): [True: 427k, False: 142k]
  ------------------
  218|   855k|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (218:25): [True: 427k, False: 427k]
  ------------------
  219|   427k|            const AVComponentDescriptor *d1 = &pd->comp[c];
  220|   427k|            const AVComponentDescriptor *d2 = &pd->comp[i];
  221|   427k|            if (d1->plane == d2->plane) {
  ------------------
  |  Branch (221:17): [True: 11.2k, False: 416k]
  ------------------
  222|  11.2k|                if (d1->offset + (d1->depth + 7) / 8u > d2->offset &&
  ------------------
  |  Branch (222:21): [True: 36, False: 11.2k]
  ------------------
  223|     36|                    d2->offset + (d2->depth + 7) / 8u > d1->offset)
  ------------------
  |  Branch (223:21): [True: 0, False: 36]
  ------------------
  224|      0|                    any_shared_bytes = true;
  225|  11.2k|            }
  226|   427k|        }
  227|   427k|    }
  228|       |
  229|   142k|    int el_bits = (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM) ? 1 : 8;
  ------------------
  |  Branch (229:19): [True: 0, False: 142k]
  ------------------
  230|   570k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (230:21): [True: 427k, False: 142k]
  ------------------
  231|   427k|        const AVComponentDescriptor *d = &pd->comp[c];
  232|   427k|        if (d->plane >= MP_MAX_PLANES)
  ------------------
  |  |   28|   427k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (232:13): [True: 0, False: 427k]
  ------------------
  233|      0|            goto fail;
  234|       |
  235|   427k|        desc->num_planes = MPMAX(desc->num_planes, d->plane + 1);
  ------------------
  |  |   44|   427k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 427k]
  |  |  ------------------
  ------------------
  236|       |
  237|   427k|        int plane_bits = desc->bpp[d->plane];
  238|   427k|        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|   427k|        if (plane_bits) {
  ------------------
  |  Branch (242:13): [True: 7.51k, False: 420k]
  ------------------
  243|  7.51k|            if (c_bits > plane_bits)
  ------------------
  |  Branch (243:17): [True: 0, False: 7.51k]
  ------------------
  244|      0|                goto fail; // inconsistent
  245|   420k|        } else {
  246|   420k|            desc->bpp[d->plane] = plane_bits = c_bits;
  247|   420k|        }
  248|       |
  249|   427k|        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|   427k|        if (fmt == AV_PIX_FMT_MONOBLACK)
  ------------------
  |  Branch (253:13): [True: 0, False: 427k]
  ------------------
  254|      0|            shift = 0;
  255|       |
  256|   427k|        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|   427k|        int word = mp_round_next_power_of_2(MPMAX(d->depth + shift, 8));
  ------------------
  |  |   44|   427k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 7.69k, False: 419k]
  |  |  ------------------
  ------------------
  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|   427k|        if (is_be && el_bits == 8 && word == 8)
  ------------------
  |  Branch (272:13): [True: 0, False: 427k]
  |  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|   427k|        int access_size = 8;
  288|   427k|        if (plane_bits > 8) {
  ------------------
  |  Branch (288:13): [True: 18.9k, False: 408k]
  ------------------
  289|  18.9k|            if (any_shared_bytes) {
  ------------------
  |  Branch (289:17): [True: 0, False: 18.9k]
  ------------------
  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|  18.9k|            } else {
  297|  18.9k|                access_size = word;
  298|  18.9k|            }
  299|  18.9k|        }
  300|   427k|        int endian_size = (access_size && !is_ne) ? access_size : 8;
  ------------------
  |  Branch (300:28): [True: 427k, False: 0]
  |  Branch (300:43): [True: 0, False: 427k]
  ------------------
  301|   427k|        int endian_shift = mp_log2(endian_size) - 3;
  302|   427k|        if (!MP_IS_POWER_OF_2(endian_size) || endian_shift < 0 || endian_shift > 3)
  ------------------
  |  |   56|   855k|#define MP_IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1)))
  |  |  ------------------
  |  |  |  Branch (56:30): [True: 427k, False: 0]
  |  |  |  Branch (56:41): [True: 427k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (302:47): [True: 0, False: 427k]
  |  Branch (302:67): [True: 0, False: 427k]
  ------------------
  303|      0|            goto fail;
  304|   427k|        if (desc->endian_shift && desc->endian_shift != endian_shift)
  ------------------
  |  Branch (304:13): [True: 0, False: 427k]
  |  Branch (304:35): [True: 0, False: 0]
  ------------------
  305|      0|            goto fail;
  306|   427k|        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|   427k|        offset += shift;
  311|   427k|        if (offset < 0 || offset >= (1 << 6))
  ------------------
  |  Branch (311:13): [True: 0, False: 427k]
  |  Branch (311:27): [True: 0, False: 427k]
  ------------------
  312|      0|            goto fail;
  313|   427k|        if (offset + d->depth > plane_bits)
  ------------------
  |  Branch (313:13): [True: 0, False: 427k]
  ------------------
  314|      0|            goto fail;
  315|   427k|        if (d->depth < 0 || d->depth >= (1 << 6))
  ------------------
  |  Branch (315:13): [True: 0, False: 427k]
  |  Branch (315:29): [True: 0, False: 427k]
  ------------------
  316|      0|            goto fail;
  317|   427k|        desc->comps[c] = (struct mp_imgfmt_comp_desc){
  318|   427k|            .plane = d->plane,
  319|   427k|            .offset = offset,
  320|   427k|            .size = d->depth,
  321|   427k|        };
  322|   427k|    }
  323|       |
  324|   562k|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (324:21): [True: 420k, False: 142k]
  ------------------
  325|   420k|        if (!desc->bpp[p])
  ------------------
  |  Branch (325:13): [True: 0, False: 420k]
  ------------------
  326|      0|            goto fail; // plane doesn't exist
  327|   420k|    }
  328|       |
  329|       |    // What the fuck: this is probably a pixdesc bug, so fix it.
  330|   142k|    if (fmt == AV_PIX_FMT_RGB8) {
  ------------------
  |  Branch (330:9): [True: 0, False: 142k]
  ------------------
  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|   142k|    bool any_shared_bits = false;
  340|   570k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (340:21): [True: 427k, False: 142k]
  ------------------
  341|   855k|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (341:25): [True: 427k, False: 427k]
  ------------------
  342|   427k|            struct mp_imgfmt_comp_desc *c1 = &desc->comps[c];
  343|   427k|            struct mp_imgfmt_comp_desc *c2 = &desc->comps[i];
  344|   427k|            if (c1->plane == c2->plane) {
  ------------------
  |  Branch (344:17): [True: 11.2k, False: 416k]
  ------------------
  345|  11.2k|                if (c1->offset + c1->size > c2->offset &&
  ------------------
  |  Branch (345:21): [True: 36, False: 11.2k]
  ------------------
  346|     36|                    c2->offset + c2->size > c1->offset)
  ------------------
  |  Branch (346:21): [True: 0, False: 36]
  ------------------
  347|      0|                    any_shared_bits = true;
  348|  11.2k|            }
  349|   427k|        }
  350|   427k|    }
  351|       |
  352|   142k|    if (any_shared_bits) {
  ------------------
  |  Branch (352:9): [True: 0, False: 142k]
  ------------------
  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|   570k|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (365:21): [True: 427k, False: 142k]
  ------------------
  366|   427k|        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|   427k|        int fsize = MP_ALIGN_UP(cd->size, 8);
  ------------------
  |  |   53|   427k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  370|   427k|        if (!any_shared_bytes && el_bits == 8 && fsize != cd->size &&
  ------------------
  |  Branch (370:13): [True: 427k, False: 0]
  |  Branch (370:34): [True: 427k, False: 0]
  |  Branch (370:50): [True: 7.69k, False: 419k]
  ------------------
  371|  7.69k|            fsize - cd->size <= (1 << 3))
  ------------------
  |  Branch (371:13): [True: 7.69k, False: 0]
  ------------------
  372|  7.69k|        {
  373|  7.69k|            if (!(cd->offset % 8u)) {
  ------------------
  |  Branch (373:17): [True: 7.69k, False: 0]
  ------------------
  374|  7.69k|                cd->pad = -(fsize - cd->size);
  375|  7.69k|                cd->size = fsize;
  376|  7.69k|            } 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|  7.69k|        }
  382|   427k|    }
  383|       |
  384|       |    // The alpha component always has ID 4 (index 3) in our representation, so
  385|       |    // move the alpha component to there.
  386|   142k|    if (has_alpha && pd->nb_components < 4) {
  ------------------
  |  Branch (386:9): [True: 12, False: 142k]
  |  Branch (386:22): [True: 0, False: 12]
  ------------------
  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|   142k|    if (is_packed_ss_yuv) {
  ------------------
  |  Branch (391:9): [True: 0, False: 142k]
  ------------------
  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|   142k|    } else if (!any_shared_bits) {
  ------------------
  |  Branch (394:16): [True: 142k, False: 0]
  ------------------
  395|   142k|        desc->flags |= MP_IMGFLAG_HAS_COMPS;
  ------------------
  |  |   34|   142k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  396|   142k|    }
  397|       |
  398|   142k|    return;
  399|       |
  400|    145|fail:
  401|    725|    for (int n = 0; n < 4; n++)
  ------------------
  |  Branch (401:21): [True: 580, False: 145]
  ------------------
  402|    580|        desc->comps[n] = (struct mp_imgfmt_comp_desc){0};
  403|       |    // Average bit size fallback.
  404|    145|    int num_planes = av_pix_fmt_count_planes(fmt);
  405|    145|    desc->num_planes = MPCLAMP(num_planes, 0, MP_MAX_PLANES);
  ------------------
  |  |   46|    145|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 145]
  |  |  |  Branch (46:56): [True: 0, False: 145]
  |  |  ------------------
  ------------------
  406|    290|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (406:21): [True: 145, False: 145]
  ------------------
  407|    145|        int ls = av_image_get_linesize(fmt, 256, p);
  408|    145|        desc->bpp[p] = ls > 0 ? ls * 8 / 256 : 0;
  ------------------
  |  Branch (408:24): [True: 145, False: 0]
  ------------------
  409|    145|    }
  410|    145|}
img_format.c:get_forced_csp_from_flags:
  671|  10.8k|{
  672|  10.8k|    if (flags & MP_IMGFLAG_COLOR_XYZ)
  ------------------
  |  |   58|  10.8k|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  |  Branch (672:9): [True: 0, False: 10.8k]
  ------------------
  673|      0|        return PL_COLOR_SYSTEM_XYZ;
  674|       |
  675|  10.8k|    if (flags & MP_IMGFLAG_COLOR_RGB)
  ------------------
  |  |   57|  10.8k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  |  Branch (675:9): [True: 201, False: 10.6k]
  ------------------
  676|    201|        return PL_COLOR_SYSTEM_RGB;
  677|       |
  678|  10.6k|    return PL_COLOR_SYSTEM_UNKNOWN;
  679|  10.8k|}

mp_image_sethwfmt:
  199|   120k|{
  200|   120k|    struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(sw_fmt ? sw_fmt : hw_fmt);
  ------------------
  |  Branch (200:52): [True: 0, False: 120k]
  ------------------
  201|   120k|    mpi->params.imgfmt = hw_fmt;
  202|   120k|    mpi->params.hw_subfmt = sw_fmt;
  203|   120k|    mpi->fmt = fmt;
  204|   120k|    mpi->imgfmt = hw_fmt;
  205|   120k|    mpi->num_planes = fmt.num_planes;
  206|   120k|    mpi->params.repr.alpha = (fmt.flags & MP_IMGFLAG_ALPHA) ? PL_ALPHA_INDEPENDENT
  ------------------
  |  |   52|   120k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (206:30): [True: 123, False: 120k]
  ------------------
  207|   120k|                                                            : PL_ALPHA_NONE;
  208|       |    // Calculate bit encoding from all components (excluding alpha)
  209|   120k|    struct pl_bit_encoding bits = {0};
  210|   120k|    const int num_comps = mp_imgfmt_desc_get_num_comps(&fmt);
  211|   483k|    for (int c = 0; c < MPMIN(num_comps, 3); c++) {
  ------------------
  |  |   45|   483k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 492, False: 483k]
  |  |  ------------------
  ------------------
  |  Branch (211:21): [True: 362k, False: 120k]
  ------------------
  212|   362k|        struct pl_bit_encoding cbits = {
  213|   362k|            .sample_depth = fmt.comps[c].size,
  214|   362k|            .color_depth  = fmt.comps[c].size - abs(fmt.comps[c].pad),
  215|   362k|            .bit_shift    = MPMAX(fmt.comps[c].pad, 0),
  ------------------
  |  |   44|   362k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 362k]
  |  |  ------------------
  ------------------
  216|   362k|        };
  217|       |
  218|   362k|        if (bits.sample_depth && !pl_bit_encoding_equal(&bits, &cbits)) {
  ------------------
  |  Branch (218:13): [True: 241k, False: 121k]
  |  Branch (218:34): [True: 0, False: 241k]
  ------------------
  219|       |            // Bit encoding differs between components, cannot handle this
  220|      0|            bits = (struct pl_bit_encoding) {0};
  221|      0|            break;
  222|      0|        }
  223|       |
  224|   362k|        bits = cbits;
  225|   362k|    }
  226|   120k|    mpi->params.repr.bits = bits;
  227|   120k|}
mp_image_set_size:
  269|   120k|{
  270|   120k|    mp_assert(w >= 0 && h >= 0);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (270:5): [True: 120k, False: 0]
  |  Branch (270:5): [True: 120k, False: 0]
  ------------------
  271|   120k|    mpi->w = mpi->params.w = w;
  272|   120k|    mpi->h = mpi->params.h = h;
  273|   120k|}
mp_image_new_ref:
  360|   365k|{
  361|   365k|    if (!img)
  ------------------
  |  Branch (361:9): [True: 0, False: 365k]
  ------------------
  362|      0|        return NULL;
  363|       |
  364|   365k|    if (!img->bufs[0])
  ------------------
  |  Branch (364:9): [True: 0, False: 365k]
  ------------------
  365|      0|        return mp_image_new_copy(img);
  366|       |
  367|   365k|    struct mp_image *new = talloc_ptrtype(NULL, new);
  ------------------
  |  |   34|   365k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   365k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   365k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|   365k|    talloc_set_destructor(new, mp_image_destructor);
  ------------------
  |  |   41|   365k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  369|   365k|    *new = *img;
  370|       |
  371|  1.82M|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|  1.82M|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (371:21): [True: 1.46M, False: 365k]
  ------------------
  372|  1.46M|        ref_buffer(&new->bufs[p]);
  373|       |
  374|   365k|    ref_buffer(&new->hwctx);
  375|   365k|    ref_buffer(&new->icc_profile);
  376|   365k|    ref_buffer(&new->a53_cc);
  377|   365k|    ref_buffer(&new->dovi);
  378|   365k|    ref_buffer(&new->film_grain);
  379|       |
  380|   365k|    new->ff_side_data = talloc_memdup(NULL, new->ff_side_data,
  ------------------
  |  |   49|   365k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   365k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   365k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   365k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   365k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|   365k|                        new->num_ff_side_data * sizeof(new->ff_side_data[0]));
  382|   386k|    for (int n = 0; n < new->num_ff_side_data; n++)
  ------------------
  |  Branch (382:21): [True: 21.4k, False: 365k]
  ------------------
  383|  21.4k|        ref_buffer(&new->ff_side_data[n].buf);
  384|       |
  385|   365k|    new->enhancement_layer = img->enhancement_layer
  ------------------
  |  Branch (385:30): [True: 0, False: 365k]
  ------------------
  386|   365k|        ? mp_image_new_ref(img->enhancement_layer) : NULL;
  387|       |
  388|   365k|    return new;
  389|   365k|}
mp_image_unrefp:
  488|   789k|{
  489|   789k|    talloc_free(*p_img);
  ------------------
  |  |   47|   789k|#define talloc_free                     ta_free
  ------------------
  490|       |    *p_img = NULL;
  491|   789k|}
mp_image_crop_valid:
  778|   222k|{
  779|   222k|    return p->crop.x1 > p->crop.x0 && p->crop.y1 > p->crop.y0 &&
  ------------------
  |  Branch (779:12): [True: 222k, False: 1]
  |  Branch (779:39): [True: 222k, False: 3]
  ------------------
  780|   222k|           p->crop.x0 >= 0 && p->crop.y0 >= 0 &&
  ------------------
  |  Branch (780:12): [True: 222k, False: 0]
  |  Branch (780:31): [True: 222k, False: 0]
  ------------------
  781|   222k|           p->crop.x1 <= p->w && p->crop.y1 <= p->h;
  ------------------
  |  Branch (781:12): [True: 222k, False: 2]
  |  Branch (781:34): [True: 222k, False: 0]
  ------------------
  782|   222k|}
mp_image_params_get_dsize:
  787|  14.6k|{
  788|  14.6k|    if (mp_image_crop_valid(p))
  ------------------
  |  Branch (788:9): [True: 14.6k, False: 0]
  ------------------
  789|  14.6k|    {
  790|  14.6k|        *d_w = mp_rect_w(p->crop);
  ------------------
  |  |  157|  14.6k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  791|  14.6k|        *d_h = mp_rect_h(p->crop);
  ------------------
  |  |  158|  14.6k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  792|  14.6k|    } else {
  793|      0|        *d_w = p->w;
  794|      0|        *d_h = p->h;
  795|      0|    }
  796|       |
  797|  14.6k|    if (p->p_w > p->p_h && p->p_h >= 1)
  ------------------
  |  Branch (797:9): [True: 6.41k, False: 8.27k]
  |  Branch (797:28): [True: 6.41k, False: 0]
  ------------------
  798|  6.41k|        *d_w = MPCLAMP(*d_w * (int64_t)p->p_w / p->p_h, 1, INT_MAX);
  ------------------
  |  |   46|  6.41k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 6.41k]
  |  |  |  Branch (46:56): [True: 0, False: 6.41k]
  |  |  ------------------
  ------------------
  799|  14.6k|    if (p->p_h > p->p_w && p->p_w >= 1)
  ------------------
  |  Branch (799:9): [True: 1.38k, False: 13.3k]
  |  Branch (799:28): [True: 1.38k, False: 0]
  ------------------
  800|  1.38k|        *d_h = MPCLAMP(*d_h * (int64_t)p->p_h / p->p_w, 1, INT_MAX);
  ------------------
  |  |   46|  1.38k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 1.38k]
  |  |  |  Branch (46:56): [True: 0, False: 1.38k]
  |  |  ------------------
  ------------------
  801|  14.6k|}
mp_image_params_set_dsize:
  804|  19.5k|{
  805|  19.5k|    AVRational ds = av_div_q((AVRational){d_w, d_h}, (AVRational){p->w, p->h});
  806|  19.5k|    p->p_w = ds.num;
  807|  19.5k|    p->p_h = ds.den;
  808|  19.5k|}
mp_image_params_to_str_buf:
  812|  86.4k|{
  813|  86.4k|    if (p && p->imgfmt) {
  ------------------
  |  Branch (813:9): [True: 86.4k, False: 0]
  |  Branch (813:14): [True: 86.4k, False: 0]
  ------------------
  814|  86.4k|        snprintf(b, bs, "%dx%d", p->w, p->h);
  815|  86.4k|        if (p->p_w != p->p_h || !p->p_w)
  ------------------
  |  Branch (815:13): [True: 36.9k, False: 49.4k]
  |  Branch (815:33): [True: 80, False: 49.3k]
  ------------------
  816|  37.0k|            mp_snprintf_cat(b, bs, " [%d:%d]", p->p_w, p->p_h);
  817|  86.4k|        mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
  ------------------
  |  |  333|  86.4k|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
  818|  86.4k|        if (p->hw_subfmt)
  ------------------
  |  Branch (818:13): [True: 0, False: 86.4k]
  ------------------
  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|  86.4k|        mp_snprintf_cat(b, bs, " %s/%s/%s/%s/%s",
  821|  86.4k|                        m_opt_choice_str(pl_csp_names, p->repr.sys),
  822|  86.4k|                        m_opt_choice_str(pl_csp_prim_names, p->color.primaries),
  823|  86.4k|                        m_opt_choice_str(pl_csp_trc_names, p->color.transfer),
  824|  86.4k|                        m_opt_choice_str(pl_csp_levels_names, p->repr.levels),
  825|  86.4k|                        m_opt_choice_str(mp_csp_light_names, p->light));
  826|  86.4k|        mp_snprintf_cat(b, bs, " CL=%s",
  827|  86.4k|                        m_opt_choice_str(pl_chroma_names, p->chroma_location));
  828|  86.4k|        if (mp_image_crop_valid(p)) {
  ------------------
  |  Branch (828:13): [True: 86.4k, False: 0]
  ------------------
  829|  86.4k|            mp_snprintf_cat(b, bs, " crop=%dx%d+%d+%d", mp_rect_w(p->crop),
  ------------------
  |  |  157|  86.4k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  830|  86.4k|                            mp_rect_h(p->crop), p->crop.x0, p->crop.y0);
  ------------------
  |  |  158|  86.4k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  831|  86.4k|        }
  832|  86.4k|        if (p->rotate)
  ------------------
  |  Branch (832:13): [True: 480, False: 85.9k]
  ------------------
  833|    480|            mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
  834|  86.4k|        if (p->stereo3d > 0) {
  ------------------
  |  Branch (834:13): [True: 0, False: 86.4k]
  ------------------
  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|  86.4k|        if (p->repr.alpha) {
  ------------------
  |  Branch (838:13): [True: 86.2k, False: 136]
  ------------------
  839|  86.2k|            mp_snprintf_cat(b, bs, " A=%s",
  840|  86.2k|                            m_opt_choice_str(pl_alpha_names, p->repr.alpha));
  841|  86.2k|        }
  842|  86.4k|    } else {
  843|      0|        snprintf(b, bs, "???");
  844|      0|    }
  845|  86.4k|    return b;
  846|  86.4k|}
mp_image_params_equal:
  883|  1.03M|{
  884|  1.03M|    return p1->imgfmt == p2->imgfmt &&
  ------------------
  |  Branch (884:12): [True: 882k, False: 148k]
  ------------------
  885|   882k|           p1->hw_subfmt == p2->hw_subfmt &&
  ------------------
  |  Branch (885:12): [True: 882k, False: 0]
  ------------------
  886|   882k|           p1->w == p2->w && p1->h == p2->h &&
  ------------------
  |  Branch (886:12): [True: 881k, False: 1.29k]
  |  Branch (886:30): [True: 880k, False: 390]
  ------------------
  887|   880k|           p1->p_w == p2->p_w && p1->p_h == p2->p_h &&
  ------------------
  |  Branch (887:12): [True: 880k, False: 24]
  |  Branch (887:34): [True: 880k, False: 0]
  ------------------
  888|   880k|           p1->force_window == p2->force_window &&
  ------------------
  |  Branch (888:12): [True: 880k, False: 0]
  ------------------
  889|   880k|           pl_color_space_equal(&p1->color, &p2->color) &&
  ------------------
  |  Branch (889:12): [True: 880k, False: 201]
  ------------------
  890|   880k|           pl_color_repr_equal(&p1->repr, &p2->repr) &&
  ------------------
  |  Branch (890:12): [True: 880k, False: 12]
  ------------------
  891|   880k|           p1->light == p2->light &&
  ------------------
  |  Branch (891:12): [True: 880k, False: 0]
  ------------------
  892|   880k|           p1->chroma_location == p2->chroma_location &&
  ------------------
  |  Branch (892:12): [True: 880k, False: 2]
  ------------------
  893|   880k|           p1->vflip == p2->vflip &&
  ------------------
  |  Branch (893:12): [True: 879k, False: 890]
  ------------------
  894|   879k|           p1->rotate == p2->rotate &&
  ------------------
  |  Branch (894:12): [True: 879k, False: 135]
  ------------------
  895|   879k|           p1->stereo3d == p2->stereo3d &&
  ------------------
  |  Branch (895:12): [True: 879k, False: 0]
  ------------------
  896|   879k|           mp_rect_equals(&p1->crop, &p2->crop);
  ------------------
  |  Branch (896:12): [True: 879k, False: 0]
  ------------------
  897|  1.03M|}
mp_image_params_static_equal:
  901|   186k|{
  902|       |    // Compare only static video parameters, excluding dynamic metadata.
  903|   186k|    struct mp_image_params a = *p1;
  904|   186k|    struct mp_image_params b = *p2;
  905|       |    a.repr.dovi = b.repr.dovi = NULL;
  906|   186k|    a.color.hdr = b.color.hdr = (struct pl_hdr_metadata){0};
  907|   186k|    return mp_image_params_equal(&a, &b);
  908|   186k|}
mp_image_params_update_dynamic:
  913|   110k|{
  914|   110k|    dst->repr.dovi = src->repr.dovi;
  915|       |    // Don't overwrite peak-detected HDR metadata if available.
  916|   110k|    struct pl_hdr_metadata *hdr = &dst->color.hdr;
  917|   110k|    const struct pl_hdr_metadata prev = *hdr;
  918|   110k|    *hdr = src->color.hdr;
  919|   110k|    if (has_peak_detect_values) {
  ------------------
  |  Branch (919:9): [True: 0, False: 110k]
  ------------------
  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|   110k|}
mp_image_params_guess_csp:
  990|  10.8k|{
  991|  10.8k|    enum pl_color_system forced_csp = mp_image_params_get_forced_csp(params);
  992|  10.8k|    if (forced_csp == PL_COLOR_SYSTEM_UNKNOWN) { // YUV/other
  ------------------
  |  Branch (992:9): [True: 10.6k, False: 201]
  ------------------
  993|  10.6k|        if (params->repr.sys != PL_COLOR_SYSTEM_BT_601 &&
  ------------------
  |  Branch (993:13): [True: 10.5k, False: 103]
  ------------------
  994|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_BT_709 &&
  ------------------
  |  Branch (994:13): [True: 10.5k, False: 1]
  ------------------
  995|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_NC &&
  ------------------
  |  Branch (995:13): [True: 10.5k, False: 0]
  ------------------
  996|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_C &&
  ------------------
  |  Branch (996:13): [True: 10.5k, False: 0]
  ------------------
  997|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_PQ &&
  ------------------
  |  Branch (997:13): [True: 10.5k, False: 1]
  ------------------
  998|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_HLG &&
  ------------------
  |  Branch (998:13): [True: 10.5k, False: 0]
  ------------------
  999|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_DOLBYVISION &&
  ------------------
  |  Branch (999:13): [True: 10.5k, False: 0]
  ------------------
 1000|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_SMPTE_240M &&
  ------------------
  |  Branch (1000:13): [True: 10.5k, False: 0]
  ------------------
 1001|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO &&
  ------------------
  |  Branch (1001:13): [True: 10.5k, False: 1]
  ------------------
 1002|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RE &&
  ------------------
  |  Branch (1002:13): [True: 10.5k, False: 1]
  ------------------
 1003|  10.5k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RO
  ------------------
  |  Branch (1003:13): [True: 10.5k, False: 0]
  ------------------
 1004|  10.6k|        ) {
 1005|       |            // Makes no sense, so guess instead
 1006|       |            // YCGCO should be separate, but libavcodec disagrees
 1007|  10.5k|            params->repr.sys = PL_COLOR_SYSTEM_UNKNOWN;
 1008|  10.5k|        }
 1009|  10.6k|        if (params->repr.sys == PL_COLOR_SYSTEM_UNKNOWN)
  ------------------
  |  Branch (1009:13): [True: 10.5k, False: 107]
  ------------------
 1010|  10.5k|            params->repr.sys = mp_csp_guess_colorspace(params->w, params->h);
 1011|  10.6k|        if (params->repr.levels == PL_COLOR_LEVELS_UNKNOWN) {
  ------------------
  |  Branch (1011:13): [True: 9.72k, False: 943]
  ------------------
 1012|  9.72k|            if (params->color.transfer == PL_COLOR_TRC_V_LOG) {
  ------------------
  |  Branch (1012:17): [True: 0, False: 9.72k]
  ------------------
 1013|      0|                params->repr.levels = PL_COLOR_LEVELS_FULL;
 1014|  9.72k|            } else {
 1015|  9.72k|                params->repr.levels = infer_levels(params->imgfmt);
 1016|  9.72k|            }
 1017|  9.72k|        }
 1018|  10.6k|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN) {
  ------------------
  |  Branch (1018:13): [True: 10.6k, False: 24]
  ------------------
 1019|       |            // Guess based on the colormatrix as a first priority
 1020|  10.6k|            if (params->repr.sys == PL_COLOR_SYSTEM_BT_2020_NC ||
  ------------------
  |  Branch (1020:17): [True: 0, False: 10.6k]
  ------------------
 1021|  10.6k|                params->repr.sys == PL_COLOR_SYSTEM_BT_2020_C) {
  ------------------
  |  Branch (1021:17): [True: 0, False: 10.6k]
  ------------------
 1022|      0|                params->color.primaries = PL_COLOR_PRIM_BT_2020;
 1023|  10.6k|            } else if (params->repr.sys == PL_COLOR_SYSTEM_BT_709) {
  ------------------
  |  Branch (1023:24): [True: 1.10k, False: 9.53k]
  ------------------
 1024|  1.10k|                params->color.primaries = PL_COLOR_PRIM_BT_709;
 1025|  9.53k|            } else {
 1026|       |                // Ambiguous colormatrix for BT.601, guess based on res
 1027|  9.53k|                params->color.primaries = mp_csp_guess_primaries(params->w, params->h);
 1028|  9.53k|            }
 1029|  10.6k|        }
 1030|  10.6k|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1030:13): [True: 10.6k, False: 33]
  ------------------
 1031|  10.6k|            params->color.transfer = params->repr.levels == PL_COLOR_LEVELS_LIMITED ?
  ------------------
  |  Branch (1031:38): [True: 10.0k, False: 552]
  ------------------
 1032|  10.0k|                                        PL_COLOR_TRC_BT_1886 : PL_COLOR_TRC_SRGB;
 1033|  10.6k|    } else if (forced_csp == PL_COLOR_SYSTEM_RGB) {
  ------------------
  |  Branch (1033:16): [True: 201, False: 0]
  ------------------
 1034|    201|        params->repr.sys = PL_COLOR_SYSTEM_RGB;
 1035|    201|        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|    201|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN)
  ------------------
  |  Branch (1042:13): [True: 201, False: 0]
  ------------------
 1043|    201|            params->color.primaries = PL_COLOR_PRIM_BT_709;
 1044|    201|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1044:13): [True: 201, False: 0]
  ------------------
 1045|    201|            params->color.transfer = PL_COLOR_TRC_SRGB;
 1046|    201|    } 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|  10.8k|    pl_color_space_infer(&params->color);
 1071|       |
 1072|  10.8k|    if (!pl_color_space_is_hdr(&params->color)) {
  ------------------
  |  Branch (1072:9): [True: 10.8k, False: 21]
  ------------------
 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|  10.8k|        params->color.hdr = pl_hdr_metadata_empty;
 1076|  10.8k|    }
 1077|       |
 1078|  10.8k|    if (mp_imgfmt_is_subsampled(params->hw_subfmt ? params->hw_subfmt : params->imgfmt)) {
  ------------------
  |  Branch (1078:9): [True: 10.6k, False: 207]
  |  Branch (1078:33): [True: 0, False: 10.8k]
  ------------------
 1079|  10.6k|        if (params->chroma_location == PL_CHROMA_UNKNOWN) {
  ------------------
  |  Branch (1079:13): [True: 3.46k, False: 7.19k]
  ------------------
 1080|  3.46k|            if (params->repr.levels == PL_COLOR_LEVELS_LIMITED)
  ------------------
  |  Branch (1080:17): [True: 3.25k, False: 214]
  ------------------
 1081|  3.25k|                params->chroma_location = PL_CHROMA_LEFT;
 1082|  3.46k|            if (params->repr.levels == PL_COLOR_LEVELS_FULL)
  ------------------
  |  Branch (1082:17): [True: 214, False: 3.25k]
  ------------------
 1083|    214|                params->chroma_location = PL_CHROMA_CENTER;
 1084|  3.46k|        }
 1085|  10.6k|    } else {
 1086|       |        // Set to center for non-subsampled formats.
 1087|    207|        params->chroma_location = PL_CHROMA_CENTER;
 1088|    207|    }
 1089|       |
 1090|  10.8k|    if (params->light == MP_CSP_LIGHT_AUTO) {
  ------------------
  |  Branch (1090:9): [True: 10.8k, False: 0]
  ------------------
 1091|       |        // HLG is always scene-referred (using its own OOTF), everything else
 1092|       |        // we assume is display-referred by default.
 1093|  10.8k|        if (params->color.transfer == PL_COLOR_TRC_HLG) {
  ------------------
  |  Branch (1093:13): [True: 1, False: 10.8k]
  ------------------
 1094|      1|            params->light = MP_CSP_LIGHT_SCENE_HLG;
 1095|  10.8k|        } else {
 1096|  10.8k|            params->light = MP_CSP_LIGHT_DISPLAY;
 1097|  10.8k|        }
 1098|  10.8k|    }
 1099|  10.8k|}
mp_image_from_av_frame:
 1103|   120k|{
 1104|   120k|    struct mp_image *dst = &(struct mp_image){0};
 1105|   120k|    AVFrameSideData *sd;
 1106|       |
 1107|   604k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   604k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (1107:21): [True: 483k, False: 120k]
  ------------------
 1108|   483k|        dst->bufs[p] = src->buf[p];
 1109|       |
 1110|   120k|    dst->hwctx = src->hw_frames_ctx;
 1111|       |
 1112|   120k|    if (dst->hwctx) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 120k]
  ------------------
 1113|      0|        AVHWFramesContext *fctx = (void *)dst->hwctx->data;
 1114|      0|        dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format);
 1115|      0|    }
 1116|       |
 1117|   120k|    mp_image_sethwfmt(dst, pixfmt2imgfmt(src->format), dst->params.hw_subfmt);
 1118|   120k|    mp_image_set_size(dst, src->width, src->height);
 1119|       |
 1120|   120k|    dst->params.p_w = src->sample_aspect_ratio.num;
 1121|   120k|    dst->params.p_h = src->sample_aspect_ratio.den;
 1122|       |
 1123|   604k|    for (int i = 0; i < 4; i++) {
  ------------------
  |  Branch (1123:21): [True: 483k, False: 120k]
  ------------------
 1124|   483k|        dst->planes[i] = src->data[i];
 1125|   483k|        dst->stride[i] = src->linesize[i];
 1126|   483k|    }
 1127|       |
 1128|   120k|    dst->pict_type = src->pict_type;
 1129|       |
 1130|   120k|    dst->params.crop.x0 = src->crop_left;
 1131|   120k|    dst->params.crop.y0 = src->crop_top;
 1132|   120k|    dst->params.crop.x1 = src->width - src->crop_right;
 1133|   120k|    dst->params.crop.y1 = src->height - src->crop_bottom;
 1134|       |
 1135|   120k|    dst->fields = 0;
 1136|   120k|    if (src->flags & AV_FRAME_FLAG_INTERLACED)
  ------------------
  |  Branch (1136:9): [True: 6.15k, False: 114k]
  ------------------
 1137|  6.15k|        dst->fields |= MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|  6.15k|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
 1138|   120k|    if (src->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
  ------------------
  |  Branch (1138:9): [True: 41.0k, False: 79.8k]
  ------------------
 1139|  41.0k|        dst->fields |= MP_IMGFIELD_TOP_FIRST;
  ------------------
  |  |   37|  41.0k|#define MP_IMGFIELD_TOP_FIRST 0x02
  ------------------
 1140|   120k|    if (src->repeat_pict == 1)
  ------------------
  |  Branch (1140:9): [True: 35, False: 120k]
  ------------------
 1141|     35|        dst->fields |= MP_IMGFIELD_REPEAT_FIRST;
  ------------------
  |  |   38|     35|#define MP_IMGFIELD_REPEAT_FIRST 0x04
  ------------------
 1142|       |
 1143|   120k|    dst->params.repr.sys = pl_system_from_av(src->colorspace);
 1144|   120k|    dst->params.repr.levels = pl_levels_from_av(src->color_range);
 1145|       |
 1146|   120k|    dst->params.color = (struct pl_color_space){
 1147|   120k|        .primaries = pl_primaries_from_av(src->color_primaries),
 1148|   120k|        .transfer = pl_transfer_from_av(src->color_trc),
 1149|   120k|    };
 1150|       |
 1151|   120k|    dst->params.chroma_location = pl_chroma_from_av(src->chroma_location);
 1152|       |
 1153|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_STEREO3D);
 1154|   120k|    if (sd)
  ------------------
  |  Branch (1154:9): [True: 0, False: 120k]
  ------------------
 1155|      0|        dst->params.stereo3d = mp_stereo3d_from_av((const AVStereo3D *)sd->data);
 1156|       |
 1157|   120k|    if (src->opaque_ref) {
  ------------------
  |  Branch (1157:9): [True: 0, False: 120k]
  ------------------
 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|   120k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(60, 11, 100)
 1170|       |    // mp_image_setfmt sets to PL_ALPHA_INDEPENDENT, if format has alpha.
 1171|   120k|    if (dst->params.repr.alpha == PL_ALPHA_INDEPENDENT)
  ------------------
  |  Branch (1171:9): [True: 123, False: 120k]
  ------------------
 1172|    123|        dst->params.repr.alpha = pl_alpha_from_av(src->alpha_mode);
 1173|   120k|#endif
 1174|       |
 1175|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DISPLAYMATRIX);
 1176|   120k|    if (sd) {
  ------------------
  |  Branch (1176:9): [True: 87, False: 120k]
  ------------------
 1177|     87|        int32_t *matrix = (int32_t *) sd->data;
 1178|       |        // determinant
 1179|     87|        int vflip = ((int64_t)matrix[0] * (int64_t)matrix[4]
 1180|     87|                    - (int64_t)matrix[1] * (int64_t)matrix[3]) < 0;
 1181|     87|        double r = av_display_rotation_get(matrix);
 1182|     87|        if (!isnan(r)) {
  ------------------
  |  Branch (1182:13): [True: 87, False: 0]
  ------------------
 1183|     87|            dst->params.rotate = (((int)(-r) % 360) + 360) % 360;
 1184|     87|            dst->params.vflip = vflip;
 1185|     87|        }
 1186|     87|    }
 1187|       |
 1188|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE);
 1189|   120k|    if (sd)
  ------------------
  |  Branch (1189:9): [True: 0, False: 120k]
  ------------------
 1190|      0|        dst->icc_profile = sd->buf;
 1191|       |
 1192|   120k|    AVFrameSideData *mdm = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
 1193|   120k|    AVFrameSideData *clm = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
 1194|   120k|    AVFrameSideData *dhp = av_frame_get_side_data(src, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
 1195|   120k|    pl_map_hdr_metadata(&dst->params.color.hdr, &(struct pl_av_hdr_metadata) {
 1196|   120k|        .mdm = (void *)(mdm ? mdm->data : NULL),
  ------------------
  |  Branch (1196:25): [True: 0, False: 120k]
  ------------------
 1197|   120k|        .clm = (void *)(clm ? clm->data : NULL),
  ------------------
  |  Branch (1197:25): [True: 26, False: 120k]
  ------------------
 1198|   120k|        .dhp = (void *)(dhp ? dhp->data : NULL),
  ------------------
  |  Branch (1198:25): [True: 0, False: 120k]
  ------------------
 1199|   120k|    });
 1200|       |
 1201|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_A53_CC);
 1202|   120k|    if (sd)
  ------------------
  |  Branch (1202:9): [True: 536, False: 120k]
  ------------------
 1203|    536|        dst->a53_cc = sd->buf;
 1204|       |
 1205|   120k|    dst->params.primaries_orig = dst->params.color.primaries;
 1206|   120k|    dst->params.transfer_orig = dst->params.color.transfer;
 1207|   120k|    dst->params.sys_orig = dst->params.repr.sys;
 1208|   120k|    AVBufferRef *dovi = NULL;
 1209|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_METADATA);
 1210|   120k|    if (sd) {
  ------------------
  |  Branch (1210:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_RPU_BUFFER);
 1221|   120k|    if (sd) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 120k]
  ------------------
 1222|      0|        pl_hdr_metadata_from_dovi_rpu(&dst->params.color.hdr, sd->buf->data,
 1223|      0|                                      sd->buf->size);
 1224|      0|    }
 1225|       |
 1226|   120k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
 1227|   120k|    if (sd)
  ------------------
  |  Branch (1227:9): [True: 0, False: 120k]
  ------------------
 1228|      0|        dst->film_grain = sd->buf;
 1229|       |
 1230|   127k|    for (int n = 0; n < src->nb_side_data; n++) {
  ------------------
  |  Branch (1230:21): [True: 6.46k, False: 120k]
  ------------------
 1231|  6.46k|        sd = src->side_data[n];
 1232|  6.46k|        struct mp_ff_side_data mpsd = {
 1233|  6.46k|            .type = sd->type,
 1234|  6.46k|            .buf = sd->buf,
 1235|  6.46k|        };
 1236|  6.46k|        MP_TARRAY_APPEND(NULL, dst->ff_side_data, dst->num_ff_side_data, mpsd);
  ------------------
  |  |  105|  6.46k|    do {                                            \
  |  |  106|  6.46k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  6.46k|    do {                                            \
  |  |  |  |   97|  6.46k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  6.46k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  6.46k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  6.46k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 5.74k, False: 715]
  |  |  |  |  ------------------
  |  |  |  |   99|  6.46k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  5.74k|    do {                                                        \
  |  |  |  |  |  |   89|  5.74k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  5.74k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  5.74k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  5.74k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.74k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  5.74k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  5.74k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 5.74k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  6.46k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 6.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  6.46k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  6.46k|        (idxvar)++;                                 \
  |  |  109|  6.46k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 6.46k]
  |  |  ------------------
  ------------------
 1237|  6.46k|    }
 1238|       |
 1239|   120k|    struct mp_image *res = mp_image_new_ref(dst);
 1240|       |
 1241|       |    // Allocated, but non-refcounted data.
 1242|   120k|    talloc_free(dst->ff_side_data);
  ------------------
  |  |   47|   120k|#define talloc_free                     ta_free
  ------------------
 1243|   120k|    av_buffer_unref(&dovi);
 1244|       |
 1245|   120k|    return res;
 1246|   120k|}
mp_image.c:mp_image_destructor:
  235|   365k|{
  236|   365k|    mp_image_t *mpi = ptr;
  237|  1.82M|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|  1.82M|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (237:21): [True: 1.46M, False: 365k]
  ------------------
  238|  1.46M|        av_buffer_unref(&mpi->bufs[p]);
  239|   365k|    av_buffer_unref(&mpi->hwctx);
  240|   365k|    av_buffer_unref(&mpi->icc_profile);
  241|   365k|    av_buffer_unref(&mpi->a53_cc);
  242|   365k|    av_buffer_unref(&mpi->dovi);
  243|   365k|    av_buffer_unref(&mpi->film_grain);
  244|   386k|    for (int n = 0; n < mpi->num_ff_side_data; n++)
  ------------------
  |  Branch (244:21): [True: 21.4k, False: 365k]
  ------------------
  245|  21.4k|        av_buffer_unref(&mpi->ff_side_data[n].buf);
  246|   365k|    talloc_free(mpi->ff_side_data);
  ------------------
  |  |   47|   365k|#define talloc_free                     ta_free
  ------------------
  247|   365k|    mp_image_unrefp(&mpi->enhancement_layer);
  248|   365k|}
mp_image.c:ref_buffer:
  350|  3.30M|{
  351|  3.30M|    if (*dst) {
  ------------------
  |  Branch (351:9): [True: 1.09M, False: 2.21M]
  ------------------
  352|  1.09M|        *dst = av_buffer_ref(*dst);
  353|  1.09M|        MP_HANDLE_OOM(*dst);
  ------------------
  |  |  206|  1.09M|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.09M|        void *oom_p_ = (x);     \
  |  |  208|  1.09M|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.09M]
  |  |  ------------------
  |  |  209|  1.09M|            abort();            \
  |  |  210|  1.09M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.09M]
  |  |  ------------------
  ------------------
  354|  1.09M|    }
  355|  3.30M|}
mp_image.c:mp_image_params_get_forced_csp:
  529|  10.8k|{
  530|  10.8k|    int imgfmt = params->hw_subfmt ? params->hw_subfmt : params->imgfmt;
  ------------------
  |  Branch (530:18): [True: 0, False: 10.8k]
  ------------------
  531|  10.8k|    enum pl_color_system csp = mp_imgfmt_get_forced_csp(imgfmt);
  532|       |
  533|  10.8k|    if (csp == PL_COLOR_SYSTEM_RGB && params->repr.sys == PL_COLOR_SYSTEM_XYZ)
  ------------------
  |  Branch (533:9): [True: 201, False: 10.6k]
  |  Branch (533:39): [True: 0, False: 201]
  ------------------
  534|      0|        csp = PL_COLOR_SYSTEM_XYZ;
  535|       |
  536|  10.8k|    return csp;
  537|  10.8k|}
mp_image.c:infer_levels:
  959|  9.72k|{
  960|  9.72k|    switch (imgfmt2pixfmt(imgfmt)) {
  961|      0|    case AV_PIX_FMT_YUVJ420P:
  ------------------
  |  Branch (961:5): [True: 0, False: 9.72k]
  ------------------
  962|      0|    case AV_PIX_FMT_YUVJ411P:
  ------------------
  |  Branch (962:5): [True: 0, False: 9.72k]
  ------------------
  963|      0|    case AV_PIX_FMT_YUVJ422P:
  ------------------
  |  Branch (963:5): [True: 0, False: 9.72k]
  ------------------
  964|      0|    case AV_PIX_FMT_YUVJ444P:
  ------------------
  |  Branch (964:5): [True: 0, False: 9.72k]
  ------------------
  965|      0|    case AV_PIX_FMT_YUVJ440P:
  ------------------
  |  Branch (965:5): [True: 0, False: 9.72k]
  ------------------
  966|      0|    case AV_PIX_FMT_GRAY8:
  ------------------
  |  Branch (966:5): [True: 0, False: 9.72k]
  ------------------
  967|      0|    case AV_PIX_FMT_YA8:
  ------------------
  |  Branch (967:5): [True: 0, False: 9.72k]
  ------------------
  968|      0|    case AV_PIX_FMT_GRAY9LE:
  ------------------
  |  Branch (968:5): [True: 0, False: 9.72k]
  ------------------
  969|      0|    case AV_PIX_FMT_GRAY9BE:
  ------------------
  |  Branch (969:5): [True: 0, False: 9.72k]
  ------------------
  970|      0|    case AV_PIX_FMT_GRAY10LE:
  ------------------
  |  Branch (970:5): [True: 0, False: 9.72k]
  ------------------
  971|      0|    case AV_PIX_FMT_GRAY10BE:
  ------------------
  |  Branch (971:5): [True: 0, False: 9.72k]
  ------------------
  972|      0|    case AV_PIX_FMT_GRAY12LE:
  ------------------
  |  Branch (972:5): [True: 0, False: 9.72k]
  ------------------
  973|      0|    case AV_PIX_FMT_GRAY12BE:
  ------------------
  |  Branch (973:5): [True: 0, False: 9.72k]
  ------------------
  974|      0|    case AV_PIX_FMT_GRAY14LE:
  ------------------
  |  Branch (974:5): [True: 0, False: 9.72k]
  ------------------
  975|      0|    case AV_PIX_FMT_GRAY14BE:
  ------------------
  |  Branch (975:5): [True: 0, False: 9.72k]
  ------------------
  976|      0|    case AV_PIX_FMT_GRAY16LE:
  ------------------
  |  Branch (976:5): [True: 0, False: 9.72k]
  ------------------
  977|      0|    case AV_PIX_FMT_GRAY16BE:
  ------------------
  |  Branch (977:5): [True: 0, False: 9.72k]
  ------------------
  978|      0|    case AV_PIX_FMT_YA16BE:
  ------------------
  |  Branch (978:5): [True: 0, False: 9.72k]
  ------------------
  979|      0|    case AV_PIX_FMT_YA16LE:
  ------------------
  |  Branch (979:5): [True: 0, False: 9.72k]
  ------------------
  980|      0|        return PL_COLOR_LEVELS_FULL;
  981|  9.72k|    default:
  ------------------
  |  Branch (981:5): [True: 9.72k, False: 0]
  ------------------
  982|  9.72k|        return PL_COLOR_LEVELS_LIMITED;
  983|  9.72k|    }
  984|  9.72k|}

mp_image_pool_new:
   82|  38.0k|{
   83|  38.0k|    struct mp_image_pool *pool = talloc_ptrtype(tparent, pool);
  ------------------
  |  |   34|  38.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  38.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  38.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  38.0k|    talloc_set_destructor(pool, image_pool_destructor);
  ------------------
  |  |   41|  38.0k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   85|  38.0k|    *pool = (struct mp_image_pool) {0};
   86|  38.0k|    return pool;
   87|  38.0k|}
mp_image_pool_clear:
   90|  52.1k|{
   91|  52.1k|    for (int n = 0; n < pool->num_images; n++) {
  ------------------
  |  Branch (91:21): [True: 0, False: 52.1k]
  ------------------
   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|  52.1k|    pool->num_images = 0;
  104|  52.1k|}
mp_image_pool_get_no_alloc:
  126|  14.1k|{
  127|  14.1k|    struct mp_image *new = NULL;
  128|  14.1k|    pool_lock();
  ------------------
  |  |   45|  14.1k|#define pool_lock() mp_mutex_lock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  134|  14.1k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  129|  14.1k|    for (int n = 0; n < pool->num_images; n++) {
  ------------------
  |  Branch (129:21): [True: 0, False: 14.1k]
  ------------------
  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|  14.1k|    pool_unlock();
  ------------------
  |  |   46|  14.1k|#define pool_unlock() mp_mutex_unlock(&pool_mutex)
  |  |  ------------------
  |  |  |  |  136|  14.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  147|  14.1k|    if (!new)
  ------------------
  |  Branch (147:9): [True: 14.1k, False: 0]
  ------------------
  148|  14.1k|        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|  38.0k|{
   76|  38.0k|    struct mp_image_pool *pool = ptr;
   77|  38.0k|    mp_image_pool_clear(pool);
   78|  38.0k|}

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

init_best_video_out:
  370|  19.6k|{
  371|  19.6k|    struct mp_vo_opts *opts = mp_get_config_group(NULL, global, &vo_sub_opts);
  372|  19.6k|    struct m_obj_settings *vo_list = opts->video_driver_list;
  373|  19.6k|    struct vo *vo = NULL;
  374|       |    // first try the preferred drivers, with their optional subdevice param:
  375|  19.6k|    if (vo_list && vo_list[0].name) {
  ------------------
  |  Branch (375:9): [True: 19.6k, False: 0]
  |  Branch (375:20): [True: 19.6k, False: 0]
  ------------------
  376|  19.6k|        for (int n = 0; vo_list[n].name; n++) {
  ------------------
  |  Branch (376:25): [True: 19.6k, False: 0]
  ------------------
  377|       |            // Something like "-vo name," allows fallback to autoprobing.
  378|  19.6k|            if (strlen(vo_list[n].name) == 0)
  ------------------
  |  Branch (378:17): [True: 0, False: 19.6k]
  ------------------
  379|      0|                goto autoprobe;
  380|  19.6k|            bool p = !!vo_list[n + 1].name;
  381|  19.6k|            vo = vo_create(p, global, ex, vo_list[n].name);
  382|  19.6k|            if (vo)
  ------------------
  |  Branch (382:17): [True: 19.6k, False: 0]
  ------------------
  383|  19.6k|                goto done;
  384|  19.6k|        }
  385|      0|        goto done;
  386|  19.6k|    }
  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|  19.6k|done:
  398|  19.6k|    talloc_free(opts);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  399|  19.6k|    return vo;
  400|      0|}
vo_destroy:
  410|  19.6k|{
  411|  19.6k|    struct vo_internal *in = vo->in;
  412|  19.6k|    mp_dispatch_run(in->dispatch, terminate_vo, vo);
  413|       |    mp_thread_join(vo->in->thread);
  ------------------
  |  |  215|  19.6k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  414|  19.6k|    dealloc_vo(vo);
  415|  19.6k|}
vo_reconfig2:
  724|  10.7k|{
  725|  10.7k|    int ret;
  726|  10.7k|    void *p[] = {vo, img, &ret};
  727|  10.7k|    mp_dispatch_run(vo->in->dispatch, run_reconfig, p);
  728|  10.7k|    return ret;
  729|  10.7k|}
vo_control:
  744|  61.2k|{
  745|  61.2k|    int ret;
  746|  61.2k|    void *p[] = {vo, (void *)(intptr_t)request, data, &ret};
  747|  61.2k|    mp_dispatch_run(vo->in->dispatch, run_control, p);
  748|  61.2k|    return ret;
  749|  61.2k|}
vo_control_async:
  754|  78.6k|{
  755|  78.6k|    void *p[4] = {vo, (void *)(intptr_t)request, NULL, NULL};
  756|  78.6k|    void **d = talloc_memdup(NULL, p, sizeof(p));
  ------------------
  |  |   49|  78.6k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  78.6k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  78.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  78.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  78.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|       |
  758|  78.6k|    switch (request) {
  759|  11.6k|    case VOCTRL_UPDATE_PLAYBACK_STATE:
  ------------------
  |  Branch (759:5): [True: 11.6k, False: 67.0k]
  ------------------
  760|  11.6k|        d[2] = talloc_dup(d, (struct voctrl_playback_state *)data);
  ------------------
  |  |   48|  11.6k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  11.6k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  761|  11.6k|        break;
  762|  15.2k|    case VOCTRL_KILL_SCREENSAVER:
  ------------------
  |  Branch (762:5): [True: 15.2k, False: 63.4k]
  ------------------
  763|  67.0k|    case VOCTRL_RESTORE_SCREENSAVER:
  ------------------
  |  Branch (763:5): [True: 51.8k, False: 26.8k]
  ------------------
  764|  67.0k|        break;
  765|      0|    default:
  ------------------
  |  Branch (765:5): [True: 0, False: 78.6k]
  ------------------
  766|      0|        abort(); // requires explicit support
  767|  78.6k|    }
  768|       |
  769|  78.6k|    mp_dispatch_enqueue_autofree(vo->in->dispatch, run_control, d);
  770|  78.6k|}
vo_wait_default:
  820|   349k|{
  821|   349k|    struct vo_internal *in = vo->in;
  822|       |
  823|   349k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   349k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  824|   349k|    if (!in->need_wakeup)
  ------------------
  |  Branch (824:9): [True: 328k, False: 21.2k]
  ------------------
  825|   328k|        mp_cond_timedwait_until(&in->wakeup, &in->lock, until_time);
  826|   349k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   349k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  827|   349k|}
vo_wakeup:
  857|   219k|{
  858|   219k|    struct vo_internal *in = vo->in;
  859|       |
  860|   219k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   219k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  861|   219k|    wakeup_locked(vo);
  862|   219k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   219k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  863|   219k|}
vo_still_displaying:
  912|  23.1k|{
  913|  23.1k|    mp_mutex_lock(&vo->in->lock);
  ------------------
  |  |  134|  23.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  914|  23.1k|    bool res = still_displaying(vo);
  915|  23.1k|    mp_mutex_unlock(&vo->in->lock);
  ------------------
  |  |  136|  23.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  916|  23.1k|    return res;
  917|  23.1k|}
vo_is_ready_for_frame:
  941|   141k|{
  942|   141k|    struct vo_internal *in = vo->in;
  943|   141k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   141k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  944|   141k|    bool r = vo->config_ok && !in->frame_queued &&
  ------------------
  |  Branch (944:14): [True: 133k, False: 7.93k]
  |  Branch (944:31): [True: 131k, False: 2.19k]
  ------------------
  945|   131k|             (!in->current_frame || in->current_frame->num_vsyncs < 1);
  ------------------
  |  Branch (945:15): [True: 10.7k, False: 120k]
  |  Branch (945:37): [True: 120k, False: 0]
  ------------------
  946|   141k|    if (r && next_pts >= 0) {
  ------------------
  |  Branch (946:9): [True: 131k, False: 10.1k]
  |  Branch (946:14): [True: 120k, False: 10.6k]
  ------------------
  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|   120k|        next_pts -= in->timing_offset;
  952|   120k|        next_pts -= in->flip_queue_offset;
  953|       |        // The lead presents the frame that much earlier, see check_timed_frame_late().
  954|   120k|        next_pts -= (int64_t)(in->vsync_interval * in->late.lead / 2);
  955|   120k|        int64_t now = mp_time_ns();
  956|   120k|        if (next_pts > now)
  ------------------
  |  Branch (956:13): [True: 0, False: 120k]
  ------------------
  957|      0|            r = false;
  958|   120k|        if (!in->wakeup_pts || next_pts < in->wakeup_pts) {
  ------------------
  |  Branch (958:13): [True: 120k, False: 164]
  |  Branch (958:32): [True: 164, False: 0]
  ------------------
  959|   120k|            in->wakeup_pts = next_pts;
  960|       |            // If we have to wait, update the vo thread's timer.
  961|   120k|            if (!r)
  ------------------
  |  Branch (961:17): [True: 0, False: 120k]
  ------------------
  962|      0|                wakeup_locked(vo);
  963|   120k|        }
  964|   120k|    }
  965|   141k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   141k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  966|   141k|    return r;
  967|   141k|}
vo_queue_frame:
  983|   120k|{
  984|   120k|    struct vo_internal *in = vo->in;
  985|   120k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   120k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  986|   120k|    mp_assert(vo->config_ok && !in->frame_queued &&
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (986:5): [True: 120k, False: 0]
  |  Branch (986:5): [True: 120k, False: 0]
  |  Branch (986:5): [True: 10.7k, False: 109k]
  |  Branch (986:5): [True: 109k, False: 0]
  ------------------
  987|   120k|           (!in->current_frame || in->current_frame->num_vsyncs < 1));
  988|   120k|    in->hasframe = true;
  989|   120k|    frame->frame_id = ++(in->current_frame_id);
  990|   120k|    in->frame_queued = frame;
  991|   120k|    in->wakeup_pts = frame->display_synced
  ------------------
  |  Branch (991:22): [True: 0, False: 120k]
  ------------------
  992|   120k|                   ? 0 : frame->pts + MPMAX(frame->duration, 0);
  ------------------
  |  |   44|   241k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 120k]
  |  |  ------------------
  ------------------
  993|   120k|    wakeup_locked(vo);
  994|   120k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   120k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  995|   120k|}
vo_wait_frame:
 1000|  10.6k|{
 1001|  10.6k|    struct vo_internal *in = vo->in;
 1002|  10.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  10.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1003|  21.2k|    while (in->frame_queued || in->rendering)
  ------------------
  |  Branch (1003:12): [True: 10.6k, False: 10.6k]
  |  Branch (1003:32): [True: 0, False: 10.6k]
  ------------------
 1004|  10.6k|        mp_cond_wait(&in->wakeup, &in->lock);
 1005|  10.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  10.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1006|  10.6k|}
vo_set_paused:
 1578|  19.4k|{
 1579|  19.4k|    struct vo_internal *in = vo->in;
 1580|  19.4k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1581|  19.4k|    if (in->paused != paused) {
  ------------------
  |  Branch (1581:9): [True: 1.15k, False: 18.3k]
  ------------------
 1582|  1.15k|        in->paused = paused;
 1583|  1.15k|        if (in->paused && in->dropped_frame) {
  ------------------
  |  Branch (1583:13): [True: 579, False: 579]
  |  Branch (1583:27): [True: 0, False: 579]
  ------------------
 1584|      0|            in->request_redraw = true;
 1585|      0|            wakeup_core(vo);
 1586|      0|        }
 1587|  1.15k|        reset_vsync_timings(vo);
 1588|  1.15k|        restart_lateness(in);
 1589|  1.15k|        in->late.drop = false;
 1590|  1.15k|        wakeup_locked(vo);
 1591|  1.15k|    }
 1592|  19.4k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1593|  19.4k|}
vo_redraw:
 1612|  4.94k|{
 1613|  4.94k|    struct vo_internal *in = vo->in;
 1614|  4.94k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  4.94k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1615|  4.94k|    if (!in->request_redraw) {
  ------------------
  |  Branch (1615:9): [True: 4.93k, False: 13]
  ------------------
 1616|  4.93k|        in->request_redraw = true;
 1617|  4.93k|        in->want_redraw = false;
 1618|  4.93k|        wakeup_locked(vo);
 1619|  4.93k|    }
 1620|  4.94k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  4.94k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1621|  4.94k|}
vo_want_redraw:
 1624|  12.8k|{
 1625|  12.8k|    struct vo_internal *in = vo->in;
 1626|  12.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  12.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1627|  12.8k|    bool r = in->want_redraw;
 1628|  12.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  12.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1629|  12.8k|    return r;
 1630|  12.8k|}
vo_seek_reset:
 1633|  38.3k|{
 1634|  38.3k|    struct vo_internal *in = vo->in;
 1635|  38.3k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  38.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1636|  38.3k|    forget_frames(vo);
 1637|  38.3k|    reset_vsync_timings(vo);
 1638|  38.3k|    in->send_reset = true;
 1639|  38.3k|    wakeup_locked(vo);
 1640|  38.3k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  38.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1641|  38.3k|}
vo_has_frame:
 1645|  34.3k|{
 1646|  34.3k|    return vo->in->hasframe;
 1647|  34.3k|}
vo_query_formats:
 1661|  48.7k|{
 1662|  48.7k|    void *p[] = {vo, list};
 1663|  48.7k|    mp_dispatch_run(vo->in->dispatch, run_query_format, p);
 1664|  48.7k|}
vo_get_num_req_frames:
 1704|   120k|{
 1705|   120k|    struct vo_internal *in = vo->in;
 1706|   120k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   120k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1707|   120k|    int res = in->req_frames;
 1708|   120k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   120k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1709|   120k|    return res;
 1710|   120k|}
vo_event:
 1798|  19.6k|{
 1799|  19.6k|    struct vo_internal *in = vo->in;
 1800|  19.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1801|  19.6k|    if ((in->queued_events & event & VO_EVENTS_USER) != (event & VO_EVENTS_USER))
  ------------------
  |  Branch (1801:9): [True: 19.6k, False: 0]
  ------------------
 1802|  19.6k|        wakeup_core(vo);
 1803|  19.6k|    if (event)
  ------------------
  |  Branch (1803:9): [True: 19.6k, False: 0]
  ------------------
 1804|  19.6k|        wakeup_locked(vo);
 1805|  19.6k|    in->queued_events |= event;
 1806|  19.6k|    in->internal_events |= event;
 1807|  19.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1808|  19.6k|}
vo_query_and_reset_events:
 1813|   248k|{
 1814|   248k|    struct vo_internal *in = vo->in;
 1815|   248k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   248k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1816|   248k|    int r = in->queued_events & events;
 1817|   248k|    in->queued_events &= ~(unsigned)r;
 1818|   248k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   248k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1819|   248k|    return r;
 1820|   248k|}
vo_get_image:
 1844|  14.1k|{
 1845|  14.1k|    struct mp_image *img = NULL;
 1846|  14.1k|    if (vo->driver->get_image_ts)
  ------------------
  |  Branch (1846:9): [True: 0, False: 14.1k]
  ------------------
 1847|      0|        img = vo->driver->get_image_ts(vo, imgfmt, w, h, stride_align, flags);
 1848|  14.1k|    if (!img && vo->in->dr_helper)
  ------------------
  |  Branch (1848:9): [True: 14.1k, False: 0]
  |  Branch (1848:17): [True: 0, False: 14.1k]
  ------------------
 1849|      0|        img = dr_helper_get_image(vo->in->dr_helper, imgfmt, w, h, stride_align, flags);
 1850|  14.1k|    return img;
 1851|  14.1k|}
vo_frame_ref:
 1864|   244k|{
 1865|   244k|    if (!frame)
  ------------------
  |  Branch (1865:9): [True: 546, False: 244k]
  ------------------
 1866|    546|        return NULL;
 1867|       |
 1868|   244k|    struct vo_frame *new = talloc_ptrtype(NULL, new);
  ------------------
  |  |   34|   244k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   244k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   244k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1869|   244k|    talloc_set_destructor(new, destroy_frame);
  ------------------
  |  |   41|   244k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1870|   244k|    *new = *frame;
 1871|   488k|    for (int n = 0; n < frame->num_frames; n++)
  ------------------
  |  Branch (1871:21): [True: 244k, False: 244k]
  ------------------
 1872|   244k|        new->frames[n] = mp_image_new_ref(frame->frames[n]);
 1873|   244k|    new->current = new->num_frames ? new->frames[0] : NULL;
  ------------------
  |  Branch (1873:20): [True: 244k, False: 0]
  ------------------
 1874|   244k|    return new;
 1875|   244k|}
vo.c:get_desc:
  224|   598k|{
  225|   598k|    if (index >= MP_ARRAY_SIZE(video_out_drivers))
  ------------------
  |  |   49|   598k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (225:9): [True: 24.7k, False: 573k]
  ------------------
  226|  24.7k|        return false;
  227|   573k|    const struct vo_driver *vo = video_out_drivers[index];
  228|   573k|    *dst = (struct m_obj_desc) {
  229|   573k|        .name = vo->name,
  230|   573k|        .description = vo->description,
  231|   573k|        .priv_size = vo->priv_size,
  232|   573k|        .priv_defaults = vo->priv_defaults,
  233|   573k|        .options = vo->options,
  234|   573k|        .options_prefix = vo->options_prefix,
  235|   573k|        .global_opts = vo->global_opts,
  236|   573k|        .hidden = vo->encode,
  237|   573k|        .p = vo,
  238|   573k|    };
  239|       |    return true;
  240|   598k|}
vo.c:vo_create:
  305|  19.6k|{
  306|  19.6k|    mp_assert(ex->wakeup_cb);
  ------------------
  |  |   41|  19.6k|#define mp_assert assert
  ------------------
  |  Branch (306:5): [True: 19.6k, False: 0]
  ------------------
  307|       |
  308|  19.6k|    struct mp_log *log = mp_log_new(NULL, global->log, "vo");
  309|  19.6k|    struct m_obj_desc desc;
  310|  19.6k|    if (!m_obj_list_find(&desc, &vo_obj_list, bstr0(name))) {
  ------------------
  |  Branch (310:9): [True: 0, False: 19.6k]
  ------------------
  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|  19.6k|    };
  315|  19.6k|    struct vo *vo = talloc_ptrtype(NULL, vo);
  ------------------
  |  |   34|  19.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  19.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|  19.6k|    *vo = (struct vo) {
  317|  19.6k|        .log = mp_log_new(vo, log, name),
  318|  19.6k|        .driver = desc.p,
  319|  19.6k|        .global = global,
  320|  19.6k|        .encode_lavc_ctx = ex->encode_lavc_ctx,
  321|  19.6k|        .input_ctx = ex->input_ctx,
  322|  19.6k|        .osd = ex->osd,
  323|  19.6k|        .monitor_par = 1,
  324|  19.6k|        .extra = *ex,
  325|  19.6k|        .probing = probing,
  326|  19.6k|        .in = talloc(vo, struct vo_internal),
  ------------------
  |  |   26|  19.6k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  19.6k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  19.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|  19.6k|    };
  328|  19.6k|    mp_mutex_init(&vo->params_mutex);
  329|  19.6k|    talloc_steal(vo, log);
  ------------------
  |  |   38|  19.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  19.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  330|  19.6k|    *vo->in = (struct vo_internal) {
  331|  19.6k|        .dispatch = mp_dispatch_create(vo),
  332|  19.6k|        .req_frames = 1,
  333|  19.6k|        .frame_refs = 2, // current_frame + frame_queued
  334|  19.6k|        .estimated_vsync_jitter = -1,
  335|  19.6k|        .presentation_delay = INT64_MIN,
  336|  19.6k|        .round_edge = 0.5,
  337|  19.6k|        .stats = stats_ctx_create(vo, global, "vo"),
  338|  19.6k|    };
  339|  19.6k|    mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo);
  340|  19.6k|    mp_mutex_init(&vo->in->lock);
  341|  19.6k|    mp_cond_init(&vo->in->wakeup);
  342|       |
  343|  19.6k|    vo->opts_cache = m_config_cache_alloc(NULL, global, &vo_sub_opts);
  344|  19.6k|    vo->opts = vo->opts_cache->opts;
  345|       |
  346|  19.6k|    m_config_cache_set_dispatch_change_cb(vo->opts_cache, vo->in->dispatch,
  347|  19.6k|                                          update_opts, vo);
  348|       |
  349|  19.6k|    mp_input_set_mouse_transform(vo->input_ctx, NULL, NULL);
  350|  19.6k|    if (vo->driver->encode != !!vo->encode_lavc_ctx)
  ------------------
  |  Branch (350:9): [True: 0, False: 19.6k]
  ------------------
  351|      0|        goto error;
  352|  19.6k|    vo->priv = m_config_group_from_desc(vo, vo->log, global, &desc, name);
  353|  19.6k|    if (!vo->priv)
  ------------------
  |  Branch (353:9): [True: 0, False: 19.6k]
  ------------------
  354|      0|        goto error;
  355|       |
  356|  19.6k|    if (mp_thread_create(&vo->in->thread, vo_thread, vo))
  ------------------
  |  |  214|  19.6k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 19.6k]
  |  |  ------------------
  ------------------
  357|      0|        goto error;
  358|  19.6k|    if (mp_rendezvous(vo, 0) < 0) { // init barrier
  ------------------
  |  Branch (358:9): [True: 0, False: 19.6k]
  ------------------
  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|  19.6k|    return vo;
  363|       |
  364|      0|error:
  365|      0|    dealloc_vo(vo);
  366|       |    return NULL;
  367|  19.6k|}
vo.c:dispatch_wakeup_cb:
  259|   219k|{
  260|   219k|    struct vo *vo = ptr;
  261|   219k|    vo_wakeup(vo);
  262|   219k|}
vo.c:update_opts:
  275|   150k|{
  276|   150k|    struct vo *vo = p;
  277|       |
  278|   150k|    if (m_config_cache_update(vo->opts_cache)) {
  ------------------
  |  Branch (278:9): [True: 0, False: 150k]
  ------------------
  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|   150k|}
vo.c:read_opts:
  266|  19.6k|{
  267|  19.6k|    struct vo_internal *in = vo->in;
  268|       |
  269|  19.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  270|  19.6k|    in->timing_offset = (uint64_t)(MP_TIME_S_TO_NS(vo->opts->timing_offset));
  ------------------
  |  |   71|  19.6k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  271|  19.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  272|  19.6k|}
vo.c:vo_thread:
 1469|  19.6k|{
 1470|  19.6k|    struct vo *vo = ptr;
 1471|  19.6k|    struct vo_internal *in = vo->in;
 1472|  19.6k|    bool vo_paused = false;
 1473|       |
 1474|  19.6k|    mp_thread_set_name("vo");
 1475|  19.6k|    mp_thread_set_min_timer_slack();
 1476|       |
 1477|  19.6k|    if (vo->driver->get_image) {
  ------------------
  |  Branch (1477:9): [True: 0, False: 19.6k]
  ------------------
 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|  19.6k|    int r = vo->driver->preinit(vo) ? -1 : 0;
  ------------------
  |  Branch (1482:13): [True: 0, False: 19.6k]
  ------------------
 1483|  19.6k|    mp_rendezvous(vo, r); // init barrier
 1484|  19.6k|    if (r < 0)
  ------------------
  |  Branch (1484:9): [True: 0, False: 19.6k]
  ------------------
 1485|      0|        goto done;
 1486|       |
 1487|  19.6k|    read_opts(vo);
 1488|  19.6k|    update_display_fps(vo);
 1489|  19.6k|    vo_event(vo, VO_EVENT_WIN_STATE);
 1490|       |
 1491|  1.40M|    while (1) {
  ------------------
  |  Branch (1491:12): [True: 1.40M, Folded]
  ------------------
 1492|  1.40M|        mp_dispatch_queue_process(vo->in->dispatch, 0);
 1493|  1.40M|        if (in->terminate)
  ------------------
  |  Branch (1493:13): [True: 19.6k, False: 1.38M]
  ------------------
 1494|  19.6k|            break;
 1495|  1.38M|        stats_event(in->stats, "iterations");
 1496|  1.38M|        vo->driver->control(vo, VOCTRL_CHECK_EVENTS, NULL);
 1497|  1.38M|        bool working = render_frame(vo);
 1498|  1.38M|        int64_t now = mp_time_ns();
 1499|  1.38M|        int64_t wait_until = now + MP_TIME_S_TO_NS(working ? 0 : 1000);
  ------------------
  |  |   71|  2.76M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 0, False: 1.38M]
  |  |  ------------------
  ------------------
 1500|  1.38M|        bool wakeup_on_done = false;
 1501|  1.38M|        int64_t wakeup_core_after = 0;
 1502|       |
 1503|  1.38M|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.38M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1504|  1.38M|        if (in->wakeup_pts) {
  ------------------
  |  Branch (1504:13): [True: 121k, False: 1.25M]
  ------------------
 1505|   121k|            if (in->wakeup_pts > now) {
  ------------------
  |  Branch (1505:17): [True: 1, False: 121k]
  ------------------
 1506|      1|                wait_until = MPMIN(wait_until, in->wakeup_pts);
  ------------------
  |  |   45|      1|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 1507|   121k|            } else {
 1508|   121k|                in->wakeup_pts = 0;
 1509|   121k|                wakeup_core(vo);
 1510|   121k|            }
 1511|   121k|        }
 1512|  1.38M|        if (vo->want_redraw) {
  ------------------
  |  Branch (1512:13): [True: 0, False: 1.38M]
  ------------------
 1513|      0|            in->want_redraw = true;
 1514|      0|            wakeup_core(vo);
 1515|      0|        }
 1516|  1.38M|        if ((!working && !in->rendering && !in->frame_queued) && in->wakeup_on_done) {
  ------------------
  |  Branch (1516:14): [True: 1.38M, False: 0]
  |  Branch (1516:26): [True: 1.38M, False: 0]
  |  Branch (1516:44): [True: 1.38M, False: 43]
  |  Branch (1516:66): [True: 0, False: 1.38M]
  ------------------
 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|  1.38M|        vo->want_redraw = false;
 1525|  1.38M|        bool redraw = in->request_redraw;
 1526|  1.38M|        bool send_reset = in->send_reset;
 1527|  1.38M|        in->send_reset = false;
 1528|  1.38M|        bool send_pause = in->paused != vo_paused;
 1529|  1.38M|        vo_paused = in->paused;
 1530|  1.38M|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.38M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1531|       |
 1532|  1.38M|        if (send_reset)
  ------------------
  |  Branch (1532:13): [True: 38.1k, False: 1.34M]
  ------------------
 1533|  38.1k|            vo->driver->control(vo, VOCTRL_RESET, NULL);
 1534|  1.38M|        if (send_pause)
  ------------------
  |  Branch (1534:13): [True: 1.11k, False: 1.38M]
  ------------------
 1535|  1.11k|            vo->driver->control(vo, vo_paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL);
  ------------------
  |  Branch (1535:37): [True: 559, False: 559]
  ------------------
 1536|  1.38M|        if (wait_until > now && redraw) {
  ------------------
  |  Branch (1536:13): [True: 1.38M, False: 0]
  |  Branch (1536:33): [True: 1.03M, False: 349k]
  ------------------
 1537|       |            // Allow manual redraws at most at display fps.
 1538|  1.03M|            int64_t max_interval = in->vsync_interval > 1 ? in->vsync_interval : 0;
  ------------------
  |  Branch (1538:36): [True: 0, False: 1.03M]
  ------------------
 1539|       |            // Some windowing platforms break if we submit frames too fast.
 1540|  1.03M|            if (vo->previous_redraw_time + max_interval <= now) {
  ------------------
  |  Branch (1540:17): [True: 1.03M, False: 0]
  ------------------
 1541|  1.03M|                vo->driver->control(vo, VOCTRL_REDRAW, NULL);
 1542|  1.03M|                do_redraw(vo); // now is a good time
 1543|  1.03M|                vo->previous_redraw_time = now;
 1544|  1.03M|            } else {
 1545|      0|                wait_vo(vo, now + max_interval);
 1546|      0|            }
 1547|  1.03M|            continue;
 1548|  1.03M|        }
 1549|   349k|        if (vo->want_redraw) // might have been set by VOCTRLs
  ------------------
  |  Branch (1549:13): [True: 0, False: 349k]
  ------------------
 1550|      0|            wait_until = 0;
 1551|       |
 1552|   349k|        if (wait_until <= now)
  ------------------
  |  Branch (1552:13): [True: 0, False: 349k]
  ------------------
 1553|      0|            continue;
 1554|       |
 1555|   349k|        if (wakeup_on_done) {
  ------------------
  |  Branch (1555:13): [True: 0, False: 349k]
  ------------------
 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|   349k|        wait_vo(vo, wait_until);
 1567|   349k|    }
 1568|  19.6k|    forget_frames(vo); // implicitly synchronized
 1569|  19.6k|    talloc_free(in->current_frame);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
 1570|  19.6k|    in->current_frame = NULL;
 1571|  19.6k|    vo->driver->uninit(vo);
 1572|  19.6k|done:
 1573|  19.6k|    TA_FREEP(&in->dr_helper);
  ------------------
  |  |   81|  19.6k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  19.6k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 19.6k]
  |  |  ------------------
  ------------------
 1574|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  19.6k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1575|  19.6k|}
vo.c:update_display_fps:
  609|  1.41M|{
  610|  1.41M|    struct vo_internal *in = vo->in;
  611|  1.41M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.41M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  612|  1.41M|    if (in->internal_events & VO_EVENT_WIN_STATE) {
  ------------------
  |  Branch (612:9): [True: 19.6k, False: 1.39M]
  ------------------
  613|  19.6k|        in->internal_events &= ~(unsigned)VO_EVENT_WIN_STATE;
  614|       |
  615|  19.6k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  19.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  616|       |
  617|  19.6k|        double fps = 0;
  618|  19.6k|        vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &fps);
  619|       |
  620|  19.6k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  19.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  621|       |
  622|  19.6k|        in->reported_display_fps = fps;
  623|  19.6k|    }
  624|       |
  625|  1.41M|    double display_fps = vo->opts->display_fps_override;
  626|  1.41M|    if (display_fps <= 0)
  ------------------
  |  Branch (626:9): [True: 1.41M, False: 0]
  ------------------
  627|  1.41M|        display_fps = in->reported_display_fps;
  628|       |    // Tiny rates overflow the int64_t vsync math.
  629|  1.41M|    if (!(display_fps >= 1e-6))
  ------------------
  |  Branch (629:9): [True: 1.41M, False: 0]
  ------------------
  630|  1.41M|        display_fps = 0;
  631|       |
  632|  1.41M|    if (in->display_fps != display_fps) {
  ------------------
  |  Branch (632:9): [True: 0, False: 1.41M]
  ------------------
  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|  1.41M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.41M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  647|  1.41M|}
vo.c:render_frame:
 1156|  1.38M|{
 1157|  1.38M|    struct vo_internal *in = vo->in;
 1158|  1.38M|    struct vo_frame *frame = NULL;
 1159|  1.38M|    bool more_frames = false;
 1160|       |
 1161|  1.38M|    update_display_fps(vo);
 1162|       |
 1163|  1.38M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.38M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1164|       |
 1165|  1.38M|    int64_t sync_target = 0;
 1166|  1.38M|    if (in->frame_queued) {
  ------------------
  |  Branch (1166:9): [True: 120k, False: 1.26M]
  ------------------
 1167|   120k|        if (in->frame_queued->display_synced &&
  ------------------
  |  Branch (1167:13): [True: 0, False: 120k]
  ------------------
 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|   120k|        talloc_free(in->current_frame);
  ------------------
  |  |   47|   120k|#define talloc_free                     ta_free
  ------------------
 1171|   120k|        in->current_frame = in->frame_queued;
 1172|   120k|        in->frame_queued = NULL;
 1173|  1.26M|    } else if (in->paused || !in->current_frame || !in->hasframe ||
  ------------------
  |  Branch (1173:16): [True: 1.13k, False: 1.25M]
  |  Branch (1173:30): [True: 1.22M, False: 35.2k]
  |  Branch (1173:52): [True: 10.9k, False: 24.3k]
  ------------------
 1174|  24.3k|               (in->current_frame->display_synced && in->current_frame->num_vsyncs < 1) ||
  ------------------
  |  Branch (1174:17): [True: 0, False: 24.3k]
  |  Branch (1174:54): [True: 0, False: 0]
  ------------------
 1175|  24.3k|               !in->current_frame->display_synced)
  ------------------
  |  Branch (1175:16): [True: 24.3k, False: 0]
  ------------------
 1176|  1.26M|    {
 1177|  1.26M|        goto done;
 1178|  1.26M|    }
 1179|       |
 1180|   120k|    frame = vo_frame_ref(in->current_frame);
 1181|   120k|    mp_assert(frame);
  ------------------
  |  |   41|   120k|#define mp_assert assert
  ------------------
  |  Branch (1181:5): [True: 120k, False: 0]
  ------------------
 1182|       |
 1183|   120k|    if (frame->display_synced) {
  ------------------
  |  Branch (1183:9): [True: 0, False: 120k]
  ------------------
 1184|      0|        frame->pts = 0;
 1185|      0|        frame->duration = -1;
 1186|      0|    }
 1187|       |
 1188|   120k|    int64_t now = mp_time_ns();
 1189|   120k|    int64_t pts = frame->pts;
 1190|   120k|    int64_t duration = frame->duration;
 1191|   120k|    int64_t end_time = pts + duration;
 1192|       |
 1193|       |    // Time at which we should flip_page on the VO.
 1194|   120k|    int64_t target = frame->display_synced ? sync_target : pts - in->flip_queue_offset;
  ------------------
  |  Branch (1194:22): [True: 0, False: 120k]
  ------------------
 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|   120k|    bool follows = in->refresh_kind == VO_REFRESH_VARIABLE ||
  ------------------
  |  Branch (1206:20): [True: 0, False: 120k]
  ------------------
 1207|   120k|                   (in->refresh_kind != VO_REFRESH_FIXED && in->shown_at_once > 0.5);
  ------------------
  |  Branch (1207:21): [True: 120k, False: 0]
  |  Branch (1207:61): [True: 0, False: 120k]
  ------------------
 1208|   120k|    if (follows != in->follows) {
  ------------------
  |  Branch (1208:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    int64_t due = 0;
 1233|   120k|    if (!frame->display_synced && !follows && duration >= 0 && in->vsync_grid &&
  ------------------
  |  Branch (1233:9): [True: 120k, False: 0]
  |  Branch (1233:35): [True: 120k, False: 0]
  |  Branch (1233:47): [True: 0, False: 120k]
  |  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|   120k|    bool rate_matched = due && !late_frame_catches_up(in, duration);
  ------------------
  |  Branch (1252:25): [True: 0, False: 120k]
  |  Branch (1252:32): [True: 0, False: 0]
  ------------------
 1253|   120k|    bool due_taken = due && due < in->last_due + in->vsync_interval / 2;
  ------------------
  |  Branch (1253:22): [True: 0, False: 120k]
  |  Branch (1253:29): [True: 0, False: 0]
  ------------------
 1254|   120k|    if (due_taken && !rate_matched) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 120k]
  |  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|   120k|    bool lost = end_time < now || due_taken;
  ------------------
  |  Branch (1262:17): [True: 120k, 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|   120k|    bool drain = in->late.drop && rate_matched && !lost;
  ------------------
  |  Branch (1266:18): [True: 0, False: 120k]
  |  Branch (1266:35): [True: 0, False: 0]
  |  Branch (1266:51): [True: 0, False: 0]
  ------------------
 1267|   120k|    in->dropped_frame = duration >= 0 && (lost || drain);
  ------------------
  |  Branch (1267:25): [True: 0, False: 120k]
  |  Branch (1267:43): [True: 0, False: 0]
  |  Branch (1267:51): [True: 0, False: 0]
  ------------------
 1268|       |
 1269|   120k|    in->dropped_frame &= !frame->display_synced;
 1270|   120k|    in->dropped_frame &= !(vo->driver->caps & VO_CAP_FRAMEDROP);
 1271|   120k|    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|   120k|    in->dropped_frame &= now - in->prev_vsync < MP_TIME_MS_TO_NS(100);
  ------------------
  |  |   72|   120k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
 1275|   120k|    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|   120k|    in->current_frame->repeat = true;
 1280|   120k|    if (frame->display_synced) {
  ------------------
  |  Branch (1280:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    if (in->current_frame->num_vsyncs > 0)
  ------------------
  |  Branch (1290:9): [True: 120k, False: 0]
  ------------------
 1291|   120k|        in->current_frame->num_vsyncs -= 1;
 1292|       |
 1293|       |    // Always render when paused (it's typically the last frame for a while).
 1294|   120k|    in->dropped_frame &= !in->paused;
 1295|       |
 1296|       |    // The frames flipped from here on tell what the drop did.
 1297|   120k|    bool drained = in->dropped_frame && drain;
  ------------------
  |  Branch (1297:20): [True: 0, False: 120k]
  |  Branch (1297:41): [True: 0, False: 0]
  ------------------
 1298|   120k|    if (drained) {
  ------------------
  |  Branch (1298:9): [True: 0, False: 120k]
  ------------------
 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|   120k|    if (drained || !rate_matched)
  ------------------
  |  Branch (1304:9): [True: 0, False: 120k]
  |  Branch (1304:20): [True: 120k, False: 0]
  ------------------
 1305|   120k|        in->late.drop = false;
 1306|       |    // No other frame takes the vsync a frame gave up for the queue.
 1307|   120k|    if (due && (!in->dropped_frame || drained))
  ------------------
  |  Branch (1307:9): [True: 0, False: 120k]
  |  Branch (1307:17): [True: 0, False: 0]
  |  Branch (1307:39): [True: 0, False: 0]
  ------------------
 1308|      0|        in->last_due = due;
 1309|       |
 1310|   120k|    bool use_vsync = in->current_frame->display_synced && !in->paused;
  ------------------
  |  Branch (1310:22): [True: 0, False: 120k]
  |  Branch (1310:59): [True: 0, False: 0]
  ------------------
 1311|   120k|    if (use_vsync && !in->expecting_vsync) // first DS frame in a row
  ------------------
  |  Branch (1311:9): [True: 0, False: 120k]
  |  Branch (1311:22): [True: 0, False: 0]
  ------------------
 1312|      0|        in->prev_vsync = now;
 1313|   120k|    in->expecting_vsync = use_vsync;
 1314|       |
 1315|   120k|    if (in->dropped_frame) {
  ------------------
  |  Branch (1315:9): [True: 0, False: 120k]
  ------------------
 1316|      0|        in->drop_count += 1;
 1317|      0|        wakeup_core(vo);
 1318|   120k|    } else {
 1319|   120k|        in->rendering = true;
 1320|   120k|        in->hasframe_rendered = true;
 1321|   120k|        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|   120k|        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|   120k|        bool can_queue = !in->frame_queued &&
  ------------------
  |  Branch (1326:26): [True: 120k, False: 0]
  ------------------
 1327|   120k|            (in->current_frame->num_vsyncs < 1 || !use_vsync);
  ------------------
  |  Branch (1327:14): [True: 120k, False: 0]
  |  Branch (1327:51): [True: 0, False: 0]
  ------------------
 1328|       |        // This draw covers every redraw request made so far.
 1329|   120k|        in->request_redraw = false;
 1330|   120k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   120k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1331|       |
 1332|   120k|        if (can_queue)
  ------------------
  |  Branch (1332:13): [True: 120k, False: 0]
  ------------------
 1333|   120k|            wakeup_core(vo);
 1334|       |
 1335|   120k|        stats_time_start(in->stats, "video-draw");
 1336|       |
 1337|   120k|        in->visible = vo->driver->draw_frame(vo, frame);
 1338|       |
 1339|   120k|        stats_time_end(in->stats, "video-draw");
 1340|       |
 1341|   120k|        wait_until(target, follows);
 1342|       |
 1343|   120k|        stats_time_start(in->stats, "video-flip");
 1344|       |
 1345|   120k|        int64_t present_time = mp_time_ns();
 1346|   120k|        vo->driver->flip_page(vo);
 1347|       |
 1348|   120k|        struct vo_vsync_info vsync = {
 1349|   120k|            .skipped_vsyncs = -1,
 1350|   120k|        };
 1351|   120k|        if (vo->driver->get_vsync)
  ------------------
  |  Branch (1351:13): [True: 0, False: 120k]
  ------------------
 1352|      0|            vo->driver->get_vsync(vo, &vsync);
 1353|   120k|        int64_t display_time = predict_display_time(&vsync, present_time);
 1354|   120k|        bool have_feedback = display_time > 0;
 1355|       |
 1356|       |        // Make up some crap if presentation feedback is missing.
 1357|   120k|        if (!have_feedback)
  ------------------
  |  Branch (1357:13): [True: 120k, False: 0]
  ------------------
 1358|   120k|            display_time = mp_time_ns();
 1359|       |
 1360|   120k|        stats_time_end(in->stats, "video-flip");
 1361|       |
 1362|   120k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   120k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1363|   120k|        in->dropped_frame = prev_drop_count < vo->in->drop_count;
 1364|   120k|        in->rendering = false;
 1365|       |
 1366|   120k|        in->refresh_kind = have_feedback ? vsync.refresh_kind : VO_REFRESH_UNKNOWN;
  ------------------
  |  Branch (1366:28): [True: 0, False: 120k]
  ------------------
 1367|   120k|        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|   120k|        int64_t shown_flip = in->flips - 1 - vsync.displayed_age;
 1371|   120k|        struct present_record *shown = NULL;
 1372|   120k|        if (vsync.displayed_time > 0 && !vsync.displayed_estimated && shown_flip >= 0 &&
  ------------------
  |  Branch (1372:13): [True: 0, False: 120k]
  |  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|   120k|        if (shown && shown->pts) {
  ------------------
  |  Branch (1375:13): [True: 0, False: 120k]
  |  Branch (1375:22): [True: 0, False: 0]
  ------------------
 1376|      0|            set_presentation_delay(vo, vsync.displayed_time - shown->pts);
 1377|   120k|        } else if (due && have_feedback) {
  ------------------
  |  Branch (1377:20): [True: 0, False: 120k]
  |  Branch (1377:27): [True: 0, False: 0]
  ------------------
 1378|      0|            set_presentation_delay(vo, display_time - pts);
 1379|   120k|        } else if (display_synced || !have_feedback) {
  ------------------
  |  Branch (1379:20): [True: 0, False: 120k]
  |  Branch (1379:38): [True: 120k, False: 0]
  ------------------
 1380|   120k|            set_presentation_delay(vo, INT64_MIN);
 1381|   120k|        }
 1382|   120k|        if (shown && shown->due)
  ------------------
  |  Branch (1382:13): [True: 0, False: 120k]
  |  Branch (1382:22): [True: 0, False: 0]
  ------------------
 1383|      0|            check_timed_frame_late(vo, shown_flip, shown->due, vsync.displayed_time, duration);
 1384|   120k|        if (shown && (shown->due || in->follows)) {
  ------------------
  |  Branch (1384:13): [True: 0, False: 120k]
  |  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|   120k|        bool grid = have_feedback && in->vsync_interval > 1 && !in->follows;
  ------------------
  |  Branch (1388:21): [True: 0, False: 120k]
  |  Branch (1388:38): [True: 0, False: 0]
  |  Branch (1388:64): [True: 0, False: 0]
  ------------------
 1389|   120k|        bool on_grid = grid && update_vsync_grid(in, display_time);
  ------------------
  |  Branch (1389:24): [True: 0, False: 120k]
  |  Branch (1389:32): [True: 0, False: 0]
  ------------------
 1390|   120k|        update_vsync_timing_after_swap(vo, display_time, grid, on_grid);
 1391|   120k|    }
 1392|       |
 1393|   120k|    if (vo->driver->caps & VO_CAP_NORETAIN) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 120k]
  ------------------
 1394|      0|        talloc_free(in->current_frame);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1395|      0|        in->current_frame = NULL;
 1396|      0|    }
 1397|       |
 1398|   120k|    if (in->dropped_frame)
  ------------------
  |  Branch (1398:9): [True: 0, False: 120k]
  ------------------
 1399|   120k|        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|   120k|    if (in->frame_queued)
  ------------------
  |  Branch (1404:9): [True: 19, False: 120k]
  ------------------
 1405|     19|        in->request_redraw = false;
 1406|       |
 1407|   120k|    if (in->current_frame && in->current_frame->num_vsyncs &&
  ------------------
  |  Branch (1407:9): [True: 120k, False: 0]
  |  Branch (1407:30): [True: 0, False: 120k]
  ------------------
 1408|      0|        in->current_frame->display_synced)
  ------------------
  |  Branch (1408:9): [True: 0, False: 0]
  ------------------
 1409|      0|        more_frames = true;
 1410|       |
 1411|   120k|    if (in->frame_queued && in->frame_queued->display_synced)
  ------------------
  |  Branch (1411:9): [True: 19, False: 120k]
  |  Branch (1411:29): [True: 0, False: 19]
  ------------------
 1412|      0|        more_frames = true;
 1413|       |
 1414|   120k|    mp_cond_broadcast(&in->wakeup); // for vo_wait_frame()
 1415|       |
 1416|  1.38M|done:
 1417|  1.38M|    if (!(vo->driver->caps & VO_CAP_FRAMEOWNER) || in->dropped_frame)
  ------------------
  |  Branch (1417:9): [True: 1.38M, False: 0]
  |  Branch (1417:52): [True: 0, False: 0]
  ------------------
 1418|  1.38M|        talloc_free(frame);
  ------------------
  |  |   47|  1.38M|#define talloc_free                     ta_free
  ------------------
 1419|  1.38M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.38M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1420|       |
 1421|  1.38M|    return more_frames;
 1422|   120k|}
vo.c:wait_until:
 1149|   120k|{
 1150|   120k|    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: 120k]
  ------------------
 1151|       |    // A sleep can end before its time.
 1152|   120k|    while (mp_time_ns() < target) {}
  ------------------
  |  Branch (1152:12): [True: 0, False: 120k]
  ------------------
 1153|   120k|}
vo.c:predict_display_time:
 1011|   120k|{
 1012|   120k|    int64_t known = vsync->displayed_time;
 1013|   120k|    int age = vsync->displayed_age;
 1014|   120k|    int64_t vd = vsync->vsync_duration;
 1015|   120k|    if (known <= 0 || (age && vd <= 0))
  ------------------
  |  Branch (1015:9): [True: 120k, False: 0]
  |  Branch (1015:24): [True: 0, False: 0]
  |  Branch (1015:31): [True: 0, False: 0]
  ------------------
 1016|   120k|        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|   123k|{
 1138|   123k|    in->presents[in->flips++ % MP_ARRAY_SIZE(in->presents)] = present;
  ------------------
  |  |   49|   123k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 1139|   123k|}
vo.c:set_presentation_delay:
  783|   209k|{
  784|   209k|    struct vo_internal *in = vo->in;
  785|   209k|    if (in->presentation_delay == delay)
  ------------------
  |  Branch (785:9): [True: 209k, False: 0]
  ------------------
  786|   209k|        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|   120k|{
  542|   120k|    struct vo_internal *in = vo->in;
  543|       |
  544|   120k|    int64_t prev_vsync = in->prev_vsync;
  545|   120k|    in->prev_vsync = vsync_time;
  546|       |
  547|   120k|    if (!in->expecting_vsync) {
  ------------------
  |  Branch (547:9): [True: 120k, False: 0]
  ------------------
  548|   120k|        reset_vsync_timings(vo);
  549|   120k|        return;
  550|   120k|    }
  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|  23.0k|{
  867|  23.0k|    struct vo_internal *in = vo->in;
  868|  23.0k|    if (!in->current_frame)
  ------------------
  |  Branch (868:9): [True: 10.5k, False: 12.4k]
  ------------------
  869|  10.5k|        return -1;
  870|  12.4k|    return in->current_frame->pts + MPMAX(in->current_frame->duration, 0);
  ------------------
  |  |   44|  12.4k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 12.4k]
  |  |  ------------------
  ------------------
  871|  23.0k|}
vo.c:do_redraw:
 1425|  1.03M|{
 1426|  1.03M|    struct vo_internal *in = vo->in;
 1427|       |
 1428|  1.03M|    if (!vo->config_ok)
  ------------------
  |  Branch (1428:9): [True: 1.02M, False: 3.33k]
  ------------------
 1429|  1.02M|        return;
 1430|       |
 1431|  3.33k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  3.33k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1432|  3.33k|    in->request_redraw = false;
 1433|       |
 1434|  3.33k|    if (vo->driver->caps & (VO_CAP_NORETAIN | VO_CAP_UNTIMED)) {
  ------------------
  |  Branch (1434:9): [True: 0, False: 3.33k]
  ------------------
 1435|      0|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1436|      0|        return;
 1437|      0|    }
 1438|       |
 1439|  3.33k|    bool full_redraw = in->dropped_frame;
 1440|  3.33k|    struct vo_frame *frame = vo_frame_ref(in->current_frame);
 1441|  3.33k|    if (frame)
  ------------------
  |  Branch (1441:9): [True: 2.78k, False: 546]
  ------------------
 1442|  2.78k|        in->dropped_frame = false;
 1443|  3.33k|    struct vo_frame dummy = {0};
 1444|  3.33k|    if (!frame)
  ------------------
  |  Branch (1444:9): [True: 546, False: 2.78k]
  ------------------
 1445|    546|        frame = &dummy;
 1446|  3.33k|    frame->redraw = !full_redraw; // unconditionally redraw if it was dropped
 1447|  3.33k|    frame->repeat = false;
 1448|  3.33k|    frame->still = true;
 1449|  3.33k|    frame->pts = 0;
 1450|  3.33k|    frame->duration = -1;
 1451|  3.33k|    record_present(in, (struct present_record){0});
 1452|  3.33k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  3.33k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1453|       |
 1454|  3.33k|    vo->driver->draw_frame(vo, frame);
 1455|  3.33k|    vo->driver->flip_page(vo);
 1456|       |
 1457|  3.33k|    if (frame != &dummy && !(vo->driver->caps & VO_CAP_FRAMEOWNER))
  ------------------
  |  Branch (1457:9): [True: 2.78k, False: 546]
  |  Branch (1457:28): [True: 2.78k, False: 0]
  ------------------
 1458|  2.78k|        talloc_free(frame);
  ------------------
  |  |   47|  2.78k|#define talloc_free                     ta_free
  ------------------
 1459|  3.33k|}
vo.c:wait_vo:
  831|   349k|{
  832|   349k|    struct vo_internal *in = vo->in;
  833|       |
  834|   349k|    if (vo->driver->wait_events) {
  ------------------
  |  Branch (834:9): [True: 0, False: 349k]
  ------------------
  835|      0|        vo->driver->wait_events(vo, until_time);
  836|   349k|    } else {
  837|   349k|        vo_wait_default(vo, until_time);
  838|   349k|    }
  839|   349k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   349k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  840|   349k|    in->need_wakeup = false;
  841|   349k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   349k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|   349k|}
vo.c:terminate_vo:
  403|  19.6k|{
  404|  19.6k|    struct vo *vo = p;
  405|  19.6k|    struct vo_internal *in = vo->in;
  406|       |    in->terminate = true;
  407|  19.6k|}
vo.c:dealloc_vo:
  291|  19.6k|{
  292|  19.6k|    forget_frames(vo); // implicitly synchronized
  293|       |
  294|       |    // These must be free'd before vo->in->dispatch.
  295|  19.6k|    talloc_free(vo->opts_cache);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  296|  19.6k|    mp_mutex_destroy(&vo->params_mutex);
  ------------------
  |  |  133|  19.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  297|       |
  298|  19.6k|    mp_mutex_destroy(&vo->in->lock);
  ------------------
  |  |  133|  19.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  299|  19.6k|    mp_cond_destroy(&vo->in->wakeup);
  300|  19.6k|    talloc_free(vo);
  ------------------
  |  |   47|  19.6k|#define talloc_free                     ta_free
  ------------------
  301|  19.6k|}
vo.c:run_reconfig:
  665|  10.7k|{
  666|  10.7k|    void **pp = p;
  667|  10.7k|    struct vo *vo = pp[0];
  668|  10.7k|    struct mp_image *img = pp[1];
  669|  10.7k|    int *ret = pp[2];
  670|       |
  671|  10.7k|    struct mp_image_params *params = &img->params;
  672|       |
  673|  10.7k|    struct vo_internal *in = vo->in;
  674|       |
  675|  10.7k|    MP_VERBOSE(vo, "reconfig to %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  10.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  676|       |
  677|  10.7k|    update_opts(vo);
  678|       |
  679|  10.7k|    mp_image_params_get_dsize(params, &vo->dwidth, &vo->dheight);
  680|       |
  681|  10.7k|    mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|  10.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  682|  10.7k|    talloc_free(vo->params);
  ------------------
  |  |   47|  10.7k|#define talloc_free                     ta_free
  ------------------
  683|  10.7k|    vo->params = talloc_dup(vo, params);
  ------------------
  |  |   48|  10.7k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  10.7k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  10.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|  10.7k|    vo->has_peak_detect_values = false;
  685|  10.7k|    mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|  10.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  686|       |
  687|  10.7k|    if (vo->driver->reconfig2) {
  ------------------
  |  Branch (687:9): [True: 0, False: 10.7k]
  ------------------
  688|      0|        *ret = vo->driver->reconfig2(vo, img);
  689|  10.7k|    } else {
  690|  10.7k|        *ret = vo->driver->reconfig(vo, vo->params);
  691|  10.7k|    }
  692|  10.7k|    vo->config_ok = *ret >= 0;
  693|  10.7k|    if (vo->config_ok) {
  ------------------
  |  Branch (693:9): [True: 10.7k, False: 0]
  ------------------
  694|  10.7k|        check_vo_caps(vo);
  695|  10.7k|    } 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|  10.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  10.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  704|  10.7k|    talloc_free(in->current_frame);
  ------------------
  |  |   47|  10.7k|#define talloc_free                     ta_free
  ------------------
  705|  10.7k|    in->current_frame = NULL;
  706|  10.7k|    forget_frames(vo);
  707|  10.7k|    reset_vsync_timings(vo);
  708|  10.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  10.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  709|       |
  710|  10.7k|    update_display_fps(vo);
  711|  10.7k|}
vo.c:check_vo_caps:
  650|  10.7k|{
  651|  10.7k|    int rot = vo->params->rotate;
  652|  10.7k|    if (rot) {
  ------------------
  |  Branch (652:9): [True: 60, False: 10.7k]
  ------------------
  653|     60|        bool ok = rot % 90 ? false : (vo->driver->caps & VO_CAP_ROTATE90);
  ------------------
  |  Branch (653:19): [True: 60, False: 0]
  ------------------
  654|     60|        if (!ok) {
  ------------------
  |  Branch (654:13): [True: 60, False: 0]
  ------------------
  655|     60|           MP_WARN(vo, "Video is flagged as rotated by %d degrees, but the "
  ------------------
  |  |   90|     60|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     60|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  656|     60|                   "video output does not support this.\n", rot);
  657|     60|        }
  658|     60|    }
  659|  10.7k|    if (vo->params->vflip && !(vo->driver->caps & VO_CAP_VFLIP))
  ------------------
  |  Branch (659:9): [True: 53, False: 10.7k]
  |  Branch (659:30): [True: 53, False: 0]
  ------------------
  660|  10.7k|        MP_WARN(vo, "Video is flagged as vertically flipped, but the "
  ------------------
  |  |   90|     53|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     53|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  661|  10.7k|                    "video output does not support this.\n");
  662|  10.7k|}
vo.c:run_control:
  732|   139k|{
  733|   139k|    void **pp = p;
  734|   139k|    struct vo *vo = pp[0];
  735|   139k|    int request = (intptr_t)pp[1];
  736|   139k|    void *data = pp[2];
  737|   139k|    update_opts(vo);
  738|   139k|    int ret = vo->driver->control(vo, request, data);
  739|   139k|    if (pp[3])
  ------------------
  |  Branch (739:9): [True: 61.2k, False: 78.6k]
  ------------------
  740|  61.2k|        *(int *)pp[3] = ret;
  741|   139k|}
vo.c:wakeup_locked:
  845|   403k|{
  846|   403k|    struct vo_internal *in = vo->in;
  847|       |
  848|   403k|    mp_cond_broadcast(&in->wakeup);
  849|   403k|    if (vo->driver->wakeup)
  ------------------
  |  Branch (849:9): [True: 0, False: 403k]
  ------------------
  850|      0|        vo->driver->wakeup(vo);
  851|       |    in->need_wakeup = true;
  852|   403k|}
vo.c:still_displaying:
  889|  23.1k|{
  890|  23.1k|    struct vo_internal *in = vo->in;
  891|  23.1k|    bool working = in->rendering || in->frame_queued;
  ------------------
  |  Branch (891:20): [True: 8, False: 23.1k]
  |  Branch (891:37): [True: 122, False: 23.0k]
  ------------------
  892|  23.1k|    if (working)
  ------------------
  |  Branch (892:9): [True: 130, False: 23.0k]
  ------------------
  893|    130|        goto done;
  894|       |
  895|  23.0k|    int64_t frame_end = get_display_synced_frame_end(vo);
  896|  23.0k|    if (frame_end > 0) {
  ------------------
  |  Branch (896:9): [True: 0, False: 23.0k]
  ------------------
  897|      0|        working = frame_end > in->base_vsync + in->vsync_interval;
  898|      0|        goto done;
  899|      0|    }
  900|       |
  901|  23.0k|    frame_end = get_current_frame_end(vo);
  902|  23.0k|    if (frame_end < 0)
  ------------------
  |  Branch (902:9): [True: 10.5k, False: 12.4k]
  ------------------
  903|  10.5k|        goto done;
  904|  12.4k|    working = mp_time_ns() < frame_end;
  905|       |
  906|  23.1k|done:
  907|  23.1k|    return working && in->hasframe;
  ------------------
  |  Branch (907:12): [True: 130, False: 23.0k]
  |  Branch (907:23): [True: 130, False: 0]
  ------------------
  908|  12.4k|}
vo.c:wakeup_core:
  419|   261k|{
  420|   261k|    vo->extra.wakeup_cb(vo->extra.wakeup_ctx);
  421|   261k|}
vo.c:reset_vsync_timings:
  426|   170k|{
  427|   170k|    struct vo_internal *in = vo->in;
  428|   170k|    in->drop_point = 0;
  429|   170k|    in->base_vsync = 0;
  430|       |    in->expecting_vsync = false;
  431|   170k|    in->num_successive_vsyncs = 0;
  432|   170k|}
vo.c:restart_lateness:
  776|  89.5k|{
  777|       |    in->late.prev[0] = in->late.prev[1] = INT_MIN;
  778|  89.5k|    in->late.judged = in->flips - 1;
  779|  89.5k|}
vo.c:forget_frames:
  794|  88.4k|{
  795|  88.4k|    struct vo_internal *in = vo->in;
  796|  88.4k|    in->hasframe = false;
  797|  88.4k|    in->hasframe_rendered = false;
  798|  88.4k|    in->drop_count = 0;
  799|  88.4k|    in->delayed_count = 0;
  800|  88.4k|    set_presentation_delay(vo, INT64_MIN);
  801|  88.4k|    in->last_due = 0;
  802|  88.4k|    restart_lateness(in);
  803|  88.4k|    in->late.drop = false;
  804|  88.4k|    in->late.drop_flip = 0;
  805|  88.4k|    in->late.held = 0;
  806|  88.4k|    talloc_free(in->frame_queued);
  ------------------
  |  |   47|  88.4k|#define talloc_free                     ta_free
  ------------------
  807|  88.4k|    in->frame_queued = NULL;
  808|  88.4k|    in->current_frame_id += VO_MAX_REQ_FRAMES + 1;
  ------------------
  |  |  216|  88.4k|#define VO_MAX_REQ_FRAMES 10
  ------------------
  809|       |    // don't unref current_frame; we always want to be able to redraw it
  810|  88.4k|    if (in->current_frame) {
  ------------------
  |  Branch (810:9): [True: 21.3k, False: 67.0k]
  ------------------
  811|  21.3k|        in->current_frame->num_vsyncs = 0; // but reset future repeats
  812|       |        in->current_frame->display_synced = false; // mark discontinuity
  813|  21.3k|    }
  814|  88.4k|}
vo.c:run_query_format:
 1650|  48.7k|{
 1651|  48.7k|    void **pp = p;
 1652|  48.7k|    struct vo *vo = pp[0];
 1653|  48.7k|    uint8_t *list = pp[1];
 1654|  27.3M|    for (int format = IMGFMT_START; format < IMGFMT_END; format++)
  ------------------
  |  Branch (1654:37): [True: 27.2M, False: 48.7k]
  ------------------
 1655|  27.2M|        list[format - IMGFMT_START] = vo->driver->query_format(vo, format);
 1656|  48.7k|}
vo.c:get_display_synced_frame_end:
  874|  23.0k|{
  875|  23.0k|    struct vo_internal *in = vo->in;
  876|  23.0k|    mp_assert(!in->frame_queued);
  ------------------
  |  |   41|  23.0k|#define mp_assert assert
  ------------------
  |  Branch (876:5): [True: 23.0k, False: 0]
  ------------------
  877|  23.0k|    int64_t res = 0;
  878|  23.0k|    if (in->base_vsync && in->vsync_interval > 1 && in->current_frame) {
  ------------------
  |  Branch (878:9): [True: 0, False: 23.0k]
  |  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|  23.0k|    return res;
  886|  23.0k|}
vo.c:destroy_frame:
 1854|   244k|{
 1855|   244k|    struct vo_frame *frame = p;
 1856|   488k|    for (int n = 0; n < frame->num_frames; n++)
  ------------------
  |  Branch (1856:21): [True: 244k, False: 244k]
  ------------------
 1857|   244k|        talloc_free(frame->frames[n]);
  ------------------
  |  |   47|   244k|#define talloc_free                     ta_free
  ------------------
 1858|   244k|}

vo_null.c:preinit:
   71|  19.6k|{
   72|  19.6k|    return 0;
   73|  19.6k|}
vo_null.c:query_format:
   57|  27.2M|{
   58|  27.2M|    return 1;
   59|  27.2M|}
vo_null.c:reconfig:
   62|  10.7k|{
   63|  10.7k|    return 0;
   64|  10.7k|}
vo_null.c:control:
   76|  2.61M|{
   77|  2.61M|    struct priv *p = vo->priv;
   78|  2.61M|    switch (request) {
  ------------------
  |  Branch (78:13): [True: 19.6k, False: 2.59M]
  ------------------
   79|  19.6k|    case VOCTRL_GET_DISPLAY_FPS:
  ------------------
  |  Branch (79:5): [True: 19.6k, False: 2.59M]
  ------------------
   80|  19.6k|        if (!p->cfg_fps)
  ------------------
  |  Branch (80:13): [True: 19.6k, False: 0]
  ------------------
   81|  19.6k|            break;
   82|      0|        *(double *)data = p->cfg_fps;
   83|      0|        return VO_TRUE;
  ------------------
  |  |  146|      0|#define VO_TRUE         true
  ------------------
   84|  2.61M|    }
   85|  2.61M|    return VO_NOTIMPL;
  ------------------
  |  |  150|  2.61M|#define VO_NOTIMPL      -3
  ------------------
   86|  2.61M|}
vo_null.c:draw_frame:
   36|   123k|{
   37|       |    return VO_TRUE;
  ------------------
  |  |  146|   123k|#define VO_TRUE         true
  ------------------
   38|   123k|}
vo_null.c:flip_page:
   41|   123k|{
   42|   123k|    struct priv *p = vo->priv;
   43|   123k|    if (p->cfg_fps >= 1e-6) {
  ------------------
  |  Branch (43:9): [True: 0, False: 123k]
  ------------------
   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|   123k|}
vo_null.c:uninit:
   67|  19.6k|{
   68|  19.6k|}

mp_img_swap_to_native:
  455|   120k|{
  456|   120k|    int avfmt = imgfmt2pixfmt(img->imgfmt);
  457|   120k|    int to = AV_PIX_FMT_NONE;
  458|   604k|    for (int n = 0; endian_swaps[n][0] != AV_PIX_FMT_NONE; n++) {
  ------------------
  |  Branch (458:21): [True: 483k, False: 120k]
  ------------------
  459|   483k|        if (endian_swaps[n][0] == avfmt)
  ------------------
  |  Branch (459:13): [True: 0, False: 483k]
  ------------------
  460|      0|            to = endian_swaps[n][1];
  461|   483k|    }
  462|   120k|    if (to == AV_PIX_FMT_NONE || !mp_image_make_writeable(img))
  ------------------
  |  Branch (462:9): [True: 120k, False: 0]
  |  Branch (462:34): [True: 0, False: 0]
  ------------------
  463|   120k|        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|   120k|}

