mp_aframe_create:
   53|  2.40M|{
   54|  2.40M|    struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe);
  ------------------
  |  |   27|  2.40M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.40M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.40M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  2.40M|    frame->av_frame = av_frame_alloc();
   56|  2.40M|    MP_HANDLE_OOM(frame->av_frame);
  ------------------
  |  |  206|  2.40M|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  2.40M|        void *oom_p_ = (x);     \
  |  |  208|  2.40M|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 2.40M]
  |  |  ------------------
  |  |  209|  2.40M|            abort();            \
  |  |  210|  2.40M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 2.40M]
  |  |  ------------------
  ------------------
   57|  2.40M|    talloc_set_destructor(frame, free_frame);
  ------------------
  |  |   41|  2.40M|#define talloc_set_destructor           ta_set_destructor
  ------------------
   58|  2.40M|    mp_aframe_reset(frame);
   59|  2.40M|    return frame;
   60|  2.40M|}
mp_aframe_new_ref:
   63|   217k|{
   64|   217k|    if (!frame)
  ------------------
  |  Branch (64:9): [True: 0, False: 217k]
  ------------------
   65|      0|        return NULL;
   66|       |
   67|   217k|    struct mp_aframe *dst = mp_aframe_create();
   68|       |
   69|   217k|    dst->chmap = frame->chmap;
   70|   217k|    dst->format = frame->format;
   71|   217k|    dst->pts = frame->pts;
   72|   217k|    dst->speed = frame->speed;
   73|       |
   74|   217k|    if (mp_aframe_is_allocated(frame)) {
  ------------------
  |  Branch (74:9): [True: 560, False: 216k]
  ------------------
   75|    560|        if (av_frame_ref(dst->av_frame, frame->av_frame) < 0)
  ------------------
  |  Branch (75:13): [True: 0, False: 560]
  ------------------
   76|      0|            abort();
   77|   216k|    } else {
   78|       |        // av_frame_ref() would fail.
   79|   216k|        mp_aframe_config_copy(dst, frame);
   80|   216k|    }
   81|       |
   82|   217k|    return dst;
   83|   217k|}
mp_aframe_reset:
   87|  4.38M|{
   88|  4.38M|    av_frame_unref(frame->av_frame);
   89|  4.38M|    frame->chmap.num = 0;
   90|  4.38M|    frame->format = 0;
   91|  4.38M|    frame->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.38M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   92|  4.38M|    frame->speed = 1.0;
   93|  4.38M|}
mp_aframe_alloc_data:
  110|  2.83k|{
  111|  2.83k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (111:9): [True: 0, False: 2.83k]
  ------------------
  112|      0|        return false;
  113|  2.83k|    struct mp_aframe_pool *p = mp_aframe_pool_create(NULL);
  114|  2.83k|    int r = mp_aframe_pool_allocate(p, frame, samples);
  115|  2.83k|    talloc_free(p);
  ------------------
  |  |   47|  2.83k|#define talloc_free                     ta_free
  ------------------
  116|  2.83k|    return r >= 0;
  117|  2.83k|}
mp_aframe_from_avframe:
  123|   223k|{
  124|   223k|    if (!av_frame || av_frame->width > 0 || av_frame->height > 0)
  ------------------
  |  Branch (124:9): [True: 0, False: 223k]
  |  Branch (124:22): [True: 0, False: 223k]
  |  Branch (124:45): [True: 0, False: 223k]
  ------------------
  125|      0|        return NULL;
  126|       |
  127|   223k|    if (!av_channel_layout_check(&av_frame->ch_layout))
  ------------------
  |  Branch (127:9): [True: 0, False: 223k]
  ------------------
  128|      0|        return NULL;
  129|       |
  130|   223k|    struct mp_chmap converted_map = { 0 };
  131|   223k|    if (!mp_chmap_from_av_layout(&converted_map, &av_frame->ch_layout)) {
  ------------------
  |  Branch (131:9): [True: 0, False: 223k]
  ------------------
  132|      0|        return NULL;
  133|      0|    }
  134|       |
  135|   223k|    int format = af_from_avformat(av_frame->format);
  136|   223k|    if (!format && av_frame->format != AV_SAMPLE_FMT_NONE)
  ------------------
  |  Branch (136:9): [True: 0, False: 223k]
  |  Branch (136:20): [True: 0, False: 0]
  ------------------
  137|      0|        return NULL;
  138|       |
  139|   223k|    struct mp_aframe *frame = mp_aframe_create();
  140|       |
  141|       |    // This also takes care of forcing refcounting.
  142|   223k|    if (av_frame_ref(frame->av_frame, av_frame) < 0)
  ------------------
  |  Branch (142:9): [True: 0, False: 223k]
  ------------------
  143|      0|        abort();
  144|       |
  145|   223k|    frame->format = format;
  146|   223k|    frame->chmap = converted_map;
  147|       |
  148|   223k|    if (av_frame->opaque_ref) {
  ------------------
  |  Branch (148:9): [True: 0, False: 223k]
  ------------------
  149|      0|        struct avframe_opaque *op = (void *)av_frame->opaque_ref->data;
  150|      0|        frame->speed = op->speed;
  151|      0|    }
  152|       |
  153|   223k|    return frame;
  154|   223k|}
mp_aframe_get_raw_avframe:
  192|   575k|{
  193|   575k|    return frame->av_frame;
  194|   575k|}
mp_aframe_is_allocated:
  198|  3.31M|{
  199|  3.31M|    return frame->av_frame->buf[0] || frame->av_frame->extended_data[0];
  ------------------
  |  Branch (199:12): [True: 1.26M, False: 2.05M]
  |  Branch (199:39): [True: 0, False: 2.05M]
  ------------------
  200|  3.31M|}
mp_aframe_config_copy:
  204|  1.94M|{
  205|  1.94M|    mp_aframe_reset(dst);
  206|       |
  207|  1.94M|    dst->chmap = src->chmap;
  208|  1.94M|    dst->format = src->format;
  209|       |
  210|  1.94M|    mp_aframe_copy_attributes(dst, src);
  211|       |
  212|  1.94M|    dst->av_frame->sample_rate = src->av_frame->sample_rate;
  213|  1.94M|    dst->av_frame->format = src->av_frame->format;
  214|       |
  215|  1.94M|    if (av_channel_layout_copy(&dst->av_frame->ch_layout, &src->av_frame->ch_layout) < 0)
  ------------------
  |  Branch (215:9): [True: 0, False: 1.94M]
  ------------------
  216|      0|        abort();
  217|  1.94M|}
mp_aframe_copy_attributes:
  222|  2.40M|{
  223|  2.40M|    dst->pts = src->pts;
  224|  2.40M|    dst->speed = src->speed;
  225|       |
  226|  2.40M|    int rate = dst->av_frame->sample_rate;
  227|       |
  228|  2.40M|    if (av_frame_copy_props(dst->av_frame, src->av_frame) < 0)
  ------------------
  |  Branch (228:9): [True: 0, False: 2.40M]
  ------------------
  229|      0|        abort();
  230|       |
  231|  2.40M|    dst->av_frame->sample_rate = rate;
  232|  2.40M|}
mp_aframe_config_equals:
  237|  1.43M|{
  238|  1.43M|    struct mp_chmap ca = {0}, cb = {0};
  239|  1.43M|    mp_aframe_get_chmap(a, &ca);
  240|  1.43M|    mp_aframe_get_chmap(b, &cb);
  241|  1.43M|    return mp_chmap_equals(&ca, &cb) &&
  ------------------
  |  Branch (241:12): [True: 1.37M, False: 62.9k]
  ------------------
  242|  1.37M|           mp_aframe_get_rate(a) == mp_aframe_get_rate(b) &&
  ------------------
  |  Branch (242:12): [True: 1.37M, False: 144]
  ------------------
  243|  1.37M|           mp_aframe_get_format(a) == mp_aframe_get_format(b);
  ------------------
  |  Branch (243:12): [True: 1.36M, False: 214]
  ------------------
  244|  1.43M|}
mp_aframe_config_is_valid:
  248|  15.4k|{
  249|  15.4k|    return frame->format && frame->chmap.num && frame->av_frame->sample_rate;
  ------------------
  |  Branch (249:12): [True: 15.4k, False: 0]
  |  Branch (249:29): [True: 15.4k, False: 0]
  |  Branch (249:49): [True: 15.4k, False: 0]
  ------------------
  250|  15.4k|}
mp_aframe_get_data_ro:
  256|   410k|{
  257|   410k|    return mp_aframe_is_allocated(frame) ? frame->av_frame->extended_data : NULL;
  ------------------
  |  Branch (257:12): [True: 410k, False: 18.4E]
  ------------------
  258|   410k|}
mp_aframe_get_data_rw:
  263|   334k|{
  264|   334k|    if (!mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (264:9): [True: 0, False: 334k]
  ------------------
  265|      0|        return NULL;
  266|   334k|    if (av_frame_make_writable(frame->av_frame) < 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 334k]
  ------------------
  267|      0|        return NULL;
  268|   334k|    return frame->av_frame->extended_data;
  269|   334k|}
mp_aframe_get_format:
  272|  9.92M|{
  273|  9.92M|    return frame->format;
  274|  9.92M|}
mp_aframe_get_chmap:
  277|  3.62M|{
  278|  3.62M|    if (!mp_chmap_is_valid(&frame->chmap))
  ------------------
  |  Branch (278:9): [True: 62.3k, False: 3.55M]
  ------------------
  279|  62.3k|        return false;
  280|  3.55M|    *out = frame->chmap;
  281|       |    return true;
  282|  3.62M|}
mp_aframe_get_channels:
  285|  3.15M|{
  286|  3.15M|    return frame->chmap.num;
  287|  3.15M|}
mp_aframe_get_rate:
  290|  7.38M|{
  291|  7.38M|    return frame->av_frame->sample_rate;
  292|  7.38M|}
mp_aframe_get_size:
  295|  4.42M|{
  296|  4.42M|    return frame->av_frame->nb_samples;
  297|  4.42M|}
mp_aframe_get_pts:
  300|  3.06M|{
  301|  3.06M|    return frame->pts;
  302|  3.06M|}
mp_aframe_set_format:
  305|  7.09k|{
  306|  7.09k|    if (mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (306:9): [True: 0, False: 7.09k]
  ------------------
  307|      0|        return false;
  308|  7.09k|    enum AVSampleFormat av_format = af_to_avformat(format);
  309|  7.09k|    if (av_format == AV_SAMPLE_FMT_NONE && format) {
  ------------------
  |  Branch (309:9): [True: 0, False: 7.09k]
  |  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|  7.09k|    frame->format = format;
  316|  7.09k|    frame->av_frame->format = av_format;
  317|       |    return true;
  318|  7.09k|}
mp_aframe_set_chmap:
  321|  6.87k|{
  322|  6.87k|    if (!mp_chmap_is_valid(in) && !mp_chmap_is_empty(in))
  ------------------
  |  Branch (322:9): [True: 0, False: 6.87k]
  |  Branch (322:35): [True: 0, False: 0]
  ------------------
  323|      0|        return false;
  324|  6.87k|    if (mp_aframe_is_allocated(frame) && in->num != frame->chmap.num)
  ------------------
  |  Branch (324:9): [True: 312, False: 6.55k]
  |  Branch (324:42): [True: 303, False: 9]
  ------------------
  325|    303|        return false;
  326|       |
  327|  6.56k|    frame->chmap = *in;
  328|  6.56k|    mp_chmap_to_av_layout(&frame->av_frame->ch_layout, in);
  329|       |
  330|       |    return true;
  331|  6.87k|}
mp_aframe_set_rate:
  334|  6.56k|{
  335|  6.56k|    if (rate < 1 || rate > 10000000)
  ------------------
  |  Branch (335:9): [True: 0, False: 6.56k]
  |  Branch (335:21): [True: 0, False: 6.56k]
  ------------------
  336|      0|        return false;
  337|  6.56k|    frame->av_frame->sample_rate = rate;
  338|       |    return true;
  339|  6.56k|}
mp_aframe_set_size:
  342|   516k|{
  343|   516k|    if (!mp_aframe_is_allocated(frame) || mp_aframe_get_size(frame) < samples)
  ------------------
  |  Branch (343:9): [True: 0, False: 516k]
  |  Branch (343:43): [True: 0, False: 516k]
  ------------------
  344|      0|        return false;
  345|   516k|    frame->av_frame->nb_samples = MPMAX(samples, 0);
  ------------------
  |  |   44|   516k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 461k, False: 54.6k]
  |  |  ------------------
  ------------------
  346|       |    return true;
  347|   516k|}
mp_aframe_set_pts:
  350|   908k|{
  351|   908k|    frame->pts = pts;
  352|   908k|}
mp_aframe_mul_speed:
  366|   462k|{
  367|   462k|    frame->speed *= factor;
  368|   462k|}
mp_aframe_get_speed:
  371|   260k|{
  372|   260k|    return frame->speed;
  373|   260k|}
mp_aframe_get_effective_rate:
  381|  3.55M|{
  382|  3.55M|    return mp_aframe_get_rate(frame) / frame->speed;
  383|  3.55M|}
mp_aframe_get_planes:
  387|  3.15M|{
  388|  3.15M|    return af_fmt_is_planar(mp_aframe_get_format(frame))
  ------------------
  |  Branch (388:12): [True: 2.41M, False: 739k]
  ------------------
  389|  3.15M|           ? mp_aframe_get_channels(frame) : 1;
  390|  3.15M|}
mp_aframe_get_sstride:
  394|  2.95M|{
  395|  2.95M|    int format = mp_aframe_get_format(frame);
  396|  2.95M|    return af_fmt_to_bytes(format) *
  397|  2.95M|           (af_fmt_is_planar(format) ? 1 : mp_aframe_get_channels(frame));
  ------------------
  |  Branch (397:13): [True: 2.21M, False: 738k]
  ------------------
  398|  2.95M|}
mp_aframe_format_str_buf:
  409|  62.9k|{
  410|  62.9k|    char ch[128];
  411|  62.9k|    mp_chmap_to_str_buf(ch, sizeof(ch), &fmt->chmap);
  412|  62.9k|    char *hr_ch = mp_chmap_to_str_hr(&fmt->chmap);
  ------------------
  |  |  153|  62.9k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  62.9k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  413|  62.9k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (413:9): [True: 522, False: 62.4k]
  ------------------
  414|    522|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  415|  62.9k|    snprintf(buf, buf_size, "%dHz %s %dch %s", fmt->av_frame->sample_rate,
  416|  62.9k|             ch, fmt->chmap.num, af_fmt_to_str(fmt->format));
  417|  62.9k|    return buf;
  418|  62.9k|}
mp_aframe_skip_samples:
  422|   671k|{
  423|   671k|    mp_assert(samples >= 0 && samples <= mp_aframe_get_size(f));
  ------------------
  |  |   41|   671k|#define mp_assert assert
  ------------------
  |  Branch (423:5): [True: 671k, False: 2]
  |  Branch (423:5): [True: 671k, False: 18.4E]
  ------------------
  424|       |
  425|   671k|    if (av_frame_make_writable(f->av_frame) < 0)
  ------------------
  |  Branch (425:9): [True: 0, False: 671k]
  ------------------
  426|      0|        return; // go complain to ffmpeg
  427|       |
  428|   671k|    int num_planes = mp_aframe_get_planes(f);
  429|   671k|    size_t sstride = mp_aframe_get_sstride(f);
  430|  1.83M|    for (int n = 0; n < num_planes; n++) {
  ------------------
  |  Branch (430:21): [True: 1.16M, False: 671k]
  ------------------
  431|  1.16M|        memmove(f->av_frame->extended_data[n],
  432|  1.16M|                f->av_frame->extended_data[n] + samples * sstride,
  433|  1.16M|                (f->av_frame->nb_samples - samples) * sstride);
  434|  1.16M|    }
  435|       |
  436|   671k|    f->av_frame->nb_samples -= samples;
  437|       |
  438|   671k|    if (f->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   671k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (438:9): [True: 670k, False: 496]
  ------------------
  439|   670k|        f->pts += samples / mp_aframe_get_effective_rate(f);
  440|   671k|}
mp_aframe_sanitize_float:
  449|   223k|{
  450|   223k|    int format = af_fmt_from_planar(mp_aframe_get_format(mpa));
  451|   223k|    if (format != AF_FORMAT_FLOAT && format != AF_FORMAT_DOUBLE)
  ------------------
  |  Branch (451:9): [True: 223k, False: 0]
  |  Branch (451:38): [True: 223k, False: 0]
  ------------------
  452|   223k|        return;
  453|      0|    int num_planes = mp_aframe_get_planes(mpa);
  454|      0|    uint8_t **planes = mp_aframe_get_data_rw(mpa);
  455|      0|    if (!planes)
  ------------------
  |  Branch (455:9): [True: 0, False: 0]
  ------------------
  456|      0|        return;
  457|      0|    for (int p = 0; p < num_planes; p++) {
  ------------------
  |  Branch (457:21): [True: 0, False: 0]
  ------------------
  458|      0|        void *ptr = planes[p];
  459|      0|        int total = mp_aframe_get_total_plane_samples(mpa);
  460|      0|        switch (format) {
  ------------------
  |  Branch (460:17): [True: 0, False: 0]
  ------------------
  461|      0|        case AF_FORMAT_FLOAT:
  ------------------
  |  Branch (461:9): [True: 0, False: 0]
  ------------------
  462|      0|            for (int s = 0; s < total; s++)
  ------------------
  |  Branch (462:29): [True: 0, False: 0]
  ------------------
  463|      0|                sanitizef(((float *)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]
  |  |  ------------------
  ------------------
  464|      0|            break;
  465|      0|        case AF_FORMAT_DOUBLE:
  ------------------
  |  Branch (465:9): [True: 0, False: 0]
  ------------------
  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|      0|        }
  470|      0|    }
  471|      0|}
mp_aframe_end_pts:
  475|  1.37M|{
  476|  1.37M|    double rate = mp_aframe_get_effective_rate(f);
  477|  1.37M|    if (f->pts == MP_NOPTS_VALUE || rate <= 0)
  ------------------
  |  |   39|  2.74M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (477:9): [True: 0, False: 1.37M]
  |  Branch (477:37): [True: 0, False: 1.37M]
  ------------------
  478|      0|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  479|  1.37M|    return f->pts + f->av_frame->nb_samples / rate;
  480|  1.37M|}
mp_aframe_duration:
  484|   746k|{
  485|   746k|    double rate = mp_aframe_get_effective_rate(f);
  486|   746k|    if (rate <= 0)
  ------------------
  |  Branch (486:9): [True: 0, False: 746k]
  ------------------
  487|      0|        return 0;
  488|   746k|    return f->av_frame->nb_samples / rate;
  489|   746k|}
mp_aframe_clip_timestamps:
  495|   557k|{
  496|   557k|    double f_end = mp_aframe_end_pts(f);
  497|   557k|    double rate = mp_aframe_get_effective_rate(f);
  498|   557k|    if (f_end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   557k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (498:9): [True: 0, False: 557k]
  ------------------
  499|      0|        return;
  500|   557k|    if (end != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   557k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (500:9): [True: 1.37k, False: 555k]
  ------------------
  501|  1.37k|        if (f_end >= end) {
  ------------------
  |  Branch (501:13): [True: 70, False: 1.30k]
  ------------------
  502|     70|            if (f->pts >= end) {
  ------------------
  |  Branch (502:17): [True: 0, False: 70]
  ------------------
  503|      0|                f->av_frame->nb_samples = 0;
  504|     70|            } else {
  505|     70|                if (!af_fmt_is_pcm(mp_aframe_get_format(f)))
  ------------------
  |  Branch (505:21): [True: 0, False: 70]
  ------------------
  506|      0|                    return;
  507|     70|                int new = (end - f->pts) * rate;
  508|     70|                f->av_frame->nb_samples = MPCLAMP(new, 0, f->av_frame->nb_samples);
  ------------------
  |  |   46|     70|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 70]
  |  |  |  Branch (46:56): [True: 0, False: 70]
  |  |  ------------------
  ------------------
  509|     70|            }
  510|     70|        }
  511|  1.37k|    }
  512|   557k|    if (start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   557k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (512:9): [True: 240k, False: 316k]
  ------------------
  513|   240k|        if (f->pts < start) {
  ------------------
  |  Branch (513:13): [True: 2.36k, False: 238k]
  ------------------
  514|  2.36k|            if (f_end <= start) {
  ------------------
  |  Branch (514:17): [True: 1.59k, False: 772]
  ------------------
  515|  1.59k|                f->av_frame->nb_samples = 0;
  516|  1.59k|                f->pts = f_end;
  517|  1.59k|            } else {
  518|    772|                if (!af_fmt_is_pcm(mp_aframe_get_format(f)))
  ------------------
  |  Branch (518:21): [True: 0, False: 772]
  ------------------
  519|      0|                    return;
  520|    772|                int skip = (start - f->pts) * rate;
  521|    772|                skip = MPCLAMP(skip, 0, f->av_frame->nb_samples);
  ------------------
  |  |   46|    772|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 772]
  |  |  |  Branch (46:56): [True: 0, False: 772]
  |  |  ------------------
  ------------------
  522|    772|                mp_aframe_skip_samples(f, skip);
  523|    772|            }
  524|  2.36k|        }
  525|   240k|    }
  526|   557k|}
mp_aframe_reverse:
  575|    765|{
  576|    765|    int format = mp_aframe_get_format(f);
  577|    765|    int bps = af_fmt_to_bytes(format);
  578|    765|    if (!af_fmt_is_pcm(format) || bps > 16)
  ------------------
  |  Branch (578:9): [True: 0, False: 765]
  |  Branch (578:35): [True: 0, False: 765]
  ------------------
  579|      0|        return false;
  580|       |
  581|    765|    uint8_t **d = mp_aframe_get_data_rw(f);
  582|    765|    if (!d)
  ------------------
  |  Branch (582:9): [True: 0, False: 765]
  ------------------
  583|      0|        return false;
  584|       |
  585|    765|    int planes = mp_aframe_get_planes(f);
  586|    765|    int samples = mp_aframe_get_size(f);
  587|    765|    int channels = mp_aframe_get_channels(f);
  588|    765|    size_t sstride = mp_aframe_get_sstride(f);
  589|       |
  590|    765|    int plane_samples = channels;
  591|    765|    if (af_fmt_is_planar(format))
  ------------------
  |  Branch (591:9): [True: 0, False: 765]
  ------------------
  592|      0|        plane_samples = 1;
  593|       |
  594|  1.53k|    for (int p = 0; p < planes; p++) {
  ------------------
  |  Branch (594:21): [True: 765, False: 765]
  ------------------
  595|   376k|        for (int n = 0; n < samples / 2; n++) {
  ------------------
  |  Branch (595:25): [True: 375k, False: 765]
  ------------------
  596|   375k|            int s1_offset = n * sstride;
  597|   375k|            int s2_offset = (samples - 1 - n) * sstride;
  598|   751k|            for (int c = 0; c < plane_samples; c++) {
  ------------------
  |  Branch (598:29): [True: 375k, False: 375k]
  ------------------
  599|       |                // Nobody said it'd be fast.
  600|   375k|                char tmp[16];
  601|   375k|                uint8_t *s1 = d[p] + s1_offset + c * bps;
  602|   375k|                uint8_t *s2 = d[p] + s2_offset + c * bps;
  603|   375k|                memcpy(tmp, s2, bps);
  604|   375k|                memcpy(s2, s1, bps);
  605|   375k|                memcpy(s1, tmp, bps);
  606|   375k|            }
  607|   375k|        }
  608|    765|    }
  609|       |
  610|       |    return true;
  611|    765|}
mp_aframe_approx_byte_size:
  614|   461k|{
  615|       |    // God damn, AVFrame is too fucking annoying. Just go with the size that
  616|       |    // allocating a new frame would use.
  617|   461k|    int planes = mp_aframe_get_planes(frame);
  618|   461k|    size_t sstride = mp_aframe_get_sstride(frame);
  619|   461k|    int samples = frame->av_frame->nb_samples;
  620|   461k|    int plane_size = MP_ALIGN_UP(sstride * MPMAX(samples, 1), 32);
  ------------------
  |  |   53|   922k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 461k, False: 40]
  |  |  ------------------
  ------------------
  621|   461k|    return plane_size * planes + sizeof(*frame);
  622|   461k|}
mp_aframe_pool_create:
  630|  8.58k|{
  631|  8.58k|    return talloc_zero(ta_parent, struct mp_aframe_pool);
  ------------------
  |  |   27|  8.58k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  8.58k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.58k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|  8.58k|}
mp_aframe_pool_allocate:
  643|  1.81M|{
  644|  1.81M|    int planes = mp_aframe_get_planes(frame);
  645|  1.81M|    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|  1.81M|    int align_samples = MP_ALIGN_UP(MPMAX(samples, 1), 32);
  ------------------
  |  |   53|  3.63M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (53:34): [True: 519k, False: 1.29M]
  |  |  ------------------
  ------------------
  650|  1.81M|    int plane_size = MP_ALIGN_UP(sstride * align_samples, 64);
  ------------------
  |  |   53|  1.81M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  651|  1.81M|    int size = plane_size * planes;
  652|       |
  653|  1.81M|    if (size <= 0 || mp_aframe_is_allocated(frame))
  ------------------
  |  Branch (653:9): [True: 0, False: 1.81M]
  |  Branch (653:22): [True: 0, False: 1.81M]
  ------------------
  654|      0|        return -1;
  655|       |
  656|  1.81M|    if (!pool->avpool || size > pool->element_size) {
  ------------------
  |  Branch (656:9): [True: 8.30k, False: 1.80M]
  |  Branch (656:26): [True: 51, False: 1.80M]
  ------------------
  657|  8.35k|        size_t alloc = ta_calc_prealloc_elems(size);
  658|  8.35k|        if (alloc >= INT_MAX)
  ------------------
  |  Branch (658:13): [True: 0, False: 8.35k]
  ------------------
  659|      0|            return -1;
  660|  8.35k|        av_buffer_pool_uninit(&pool->avpool);
  661|  8.35k|        pool->element_size = alloc;
  662|  8.35k|        pool->avpool = av_buffer_pool_init(pool->element_size, NULL);
  663|  8.35k|        if (!pool->avpool)
  ------------------
  |  Branch (663:13): [True: 0, False: 8.35k]
  ------------------
  664|      0|            return -1;
  665|  8.35k|        talloc_set_destructor(pool, mp_aframe_pool_destructor);
  ------------------
  |  |   41|  8.35k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  666|  8.35k|    }
  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|  1.81M|    AVFrame *av_frame = frame->av_frame;
  672|  1.81M|    if (av_frame->extended_data != av_frame->data)
  ------------------
  |  Branch (672:9): [True: 0, False: 1.81M]
  ------------------
  673|      0|        av_freep(&av_frame->extended_data); // sigh
  674|  1.81M|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (674:9): [True: 33.1k, False: 1.78M]
  ------------------
  675|  33.1k|        av_frame->extended_data =
  676|  33.1k|            av_calloc(planes, sizeof(av_frame->extended_data[0]));
  677|  33.1k|        MP_HANDLE_OOM(av_frame->extended_data);
  ------------------
  |  |  206|  33.1k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  33.1k|        void *oom_p_ = (x);     \
  |  |  208|  33.1k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 33.1k]
  |  |  ------------------
  |  |  209|  33.1k|            abort();            \
  |  |  210|  33.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 33.1k]
  |  |  ------------------
  ------------------
  678|  1.78M|    } else {
  679|  1.78M|        av_frame->extended_data = av_frame->data;
  680|  1.78M|    }
  681|  1.81M|    av_frame->buf[0] = av_buffer_pool_get(pool->avpool);
  682|  1.81M|    if (!av_frame->buf[0])
  ------------------
  |  Branch (682:9): [True: 0, False: 1.81M]
  ------------------
  683|      0|        return -1;
  684|  1.81M|    av_frame->linesize[0] = samples * sstride;
  685|  4.08M|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (685:21): [True: 2.26M, False: 1.81M]
  ------------------
  686|  2.26M|        av_frame->extended_data[n] = av_frame->buf[0]->data + n * plane_size;
  687|  1.81M|    if (planes > AV_NUM_DATA_POINTERS) {
  ------------------
  |  Branch (687:9): [True: 33.1k, False: 1.78M]
  ------------------
  688|   298k|        for (int n = 0; n < AV_NUM_DATA_POINTERS; n++)
  ------------------
  |  Branch (688:25): [True: 265k, False: 33.1k]
  ------------------
  689|   265k|            av_frame->data[n] = av_frame->extended_data[n];
  690|  33.1k|    }
  691|  1.81M|    av_frame->nb_samples = samples;
  692|       |
  693|  1.81M|    return 0;
  694|  1.81M|}
aframe.c:free_frame:
   47|  2.40M|{
   48|  2.40M|    struct mp_aframe *frame = ptr;
   49|  2.40M|    av_frame_free(&frame->av_frame);
   50|  2.40M|}
aframe.c:mp_aframe_pool_destructor:
  635|  8.30k|{
  636|  8.30k|    struct mp_aframe_pool *pool = p;
  637|  8.30k|    av_buffer_pool_uninit(&pool->avpool);
  638|  8.30k|}

mp_chmap_is_valid:
  126|  3.69M|{
  127|  3.69M|    bool mapped[MP_SPEAKER_ID_COUNT] = {0};
  128|  9.75M|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (128:21): [True: 6.06M, False: 3.69M]
  ------------------
  129|  6.06M|        int sp = src->speaker[n];
  130|  6.06M|        if (sp >= MP_SPEAKER_ID_COUNT || mapped[sp])
  ------------------
  |  Branch (130:13): [True: 0, False: 6.06M]
  |  Branch (130:42): [True: 0, False: 6.06M]
  ------------------
  131|      0|            return false;
  132|  6.06M|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (132:13): [True: 3.60M, False: 2.45M]
  ------------------
  133|  3.60M|            mapped[sp] = true;
  134|  6.06M|    }
  135|  3.69M|    return src->num > 0;
  136|  3.69M|}
mp_chmap_is_unknown:
  146|   228k|{
  147|   309k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (147:21): [True: 303k, False: 5.60k]
  ------------------
  148|   303k|        if (src->speaker[n] != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (148:13): [True: 223k, False: 80.5k]
  ------------------
  149|   223k|            return false;
  150|   303k|    }
  151|  5.60k|    return mp_chmap_is_valid(src);
  152|   228k|}
mp_chmap_equals:
  156|  2.58M|{
  157|  2.58M|    if (a->num != b->num)
  ------------------
  |  Branch (157:9): [True: 145k, False: 2.44M]
  ------------------
  158|   145k|        return false;
  159|  6.65M|    for (int n = 0; n < a->num; n++) {
  ------------------
  |  Branch (159:21): [True: 4.21M, False: 2.44M]
  ------------------
  160|  4.21M|        if (a->speaker[n] != b->speaker[n])
  ------------------
  |  Branch (160:13): [True: 91, False: 4.21M]
  ------------------
  161|     91|            return false;
  162|  4.21M|    }
  163|  2.44M|    return true;
  164|  2.44M|}
mp_chmap_equals_reordered:
  168|   175k|{
  169|   175k|    struct mp_chmap t1 = *a, t2 = *b;
  170|   175k|    mp_chmap_reorder_norm(&t1);
  171|   175k|    mp_chmap_reorder_norm(&t2);
  172|   175k|    return mp_chmap_equals(&t1, &t2);
  173|   175k|}
mp_chmap_reorder_norm:
  189|   350k|{
  190|   350k|    uint8_t *arr = &map->speaker[0];
  191|   350k|    qsort(arr, map->num, 1, comp_uint8);
  192|   350k|}
mp_chmap_remove_na:
  196|  77.9k|{
  197|  77.9k|    struct mp_chmap new = {0};
  198|   171k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (198:21): [True: 93.9k, False: 77.9k]
  ------------------
  199|  93.9k|        int sp = map->speaker[n];
  200|  93.9k|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (200:13): [True: 78.1k, False: 15.7k]
  ------------------
  201|  78.1k|            new.speaker[new.num++] = map->speaker[n];
  202|  93.9k|    }
  203|  77.9k|    *map = new;
  204|  77.9k|}
mp_chmap_from_channels:
  218|  3.95k|{
  219|  3.95k|    *dst = (struct mp_chmap) {0};
  220|  3.95k|    if (num_channels >= 0 && num_channels < MP_ARRAY_SIZE(default_layouts))
  ------------------
  |  |   49|  3.83k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (220:9): [True: 3.83k, False: 116]
  |  Branch (220:30): [True: 1.72k, False: 2.10k]
  ------------------
  221|  1.72k|        *dst = default_layouts[num_channels];
  222|  3.95k|    if (!dst->num)
  ------------------
  |  Branch (222:9): [True: 2.26k, False: 1.68k]
  ------------------
  223|  2.26k|        mp_chmap_set_unknown(dst, num_channels);
  224|  3.95k|}
mp_chmap_set_unknown:
  232|  2.26k|{
  233|  2.26k|    if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  2.14k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (233:9): [True: 116, False: 2.14k]
  |  Branch (233:29): [True: 25, False: 2.12k]
  ------------------
  234|    141|        *dst = (struct mp_chmap) {0};
  235|  2.12k|    } else {
  236|  2.12k|        dst->num = num_channels;
  237|  25.0k|        for (int n = 0; n < dst->num; n++)
  ------------------
  |  Branch (237:25): [True: 22.9k, False: 2.12k]
  ------------------
  238|  22.9k|            dst->speaker[n] = MP_SPEAKER_ID_NA;
  239|  2.12k|    }
  240|  2.26k|}
mp_chmap_to_lavc_unchecked:
  249|  13.3k|{
  250|  13.3k|    struct mp_chmap t = *src;
  251|  13.3k|    if (t.num > 64)
  ------------------
  |  Branch (251:9): [True: 0, False: 13.3k]
  ------------------
  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|  13.3k|    if (mp_chmap_is_unknown(&t))
  ------------------
  |  Branch (256:9): [True: 812, False: 12.5k]
  ------------------
  257|    812|        return t.num == 64 ? (uint64_t)-1 : (1ULL << t.num) - 1;
  ------------------
  |  Branch (257:16): [True: 0, False: 812]
  ------------------
  258|  12.5k|    uint64_t mask = 0;
  259|  26.4k|    for (int n = 0; n < t.num; n++) {
  ------------------
  |  Branch (259:21): [True: 13.8k, False: 12.5k]
  ------------------
  260|  13.8k|        if (t.speaker[n] < 64) // ignore MP_SPEAKER_ID_NA etc.
  ------------------
  |  Branch (260:13): [True: 13.8k, False: 0]
  ------------------
  261|  13.8k|            mask |= 1ULL << t.speaker[n];
  262|  13.8k|    }
  263|  12.5k|    return mask;
  264|  13.3k|}
mp_chmap_to_lavc:
  269|  5.89k|{
  270|  5.89k|    if (!mp_chmap_is_lavc(src))
  ------------------
  |  Branch (270:9): [True: 0, False: 5.89k]
  ------------------
  271|      0|        return 0;
  272|  5.89k|    return mp_chmap_to_lavc_unchecked(src);
  273|  5.89k|}
mp_chmap_from_lavc:
  279|   477k|{
  280|   477k|    dst->num = 0;
  281|  31.0M|    for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (281:21): [True: 30.5M, False: 477k]
  ------------------
  282|  30.5M|        if (src & (1ULL << n)) {
  ------------------
  |  Branch (282:13): [True: 477k, False: 30.1M]
  ------------------
  283|   477k|            if (dst->num >= MP_NUM_CHANNELS) {
  ------------------
  |  |   25|   477k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (283:17): [True: 0, False: 477k]
  ------------------
  284|      0|                dst->num = 0;
  285|      0|                return;
  286|      0|            }
  287|   477k|            dst->speaker[dst->num] = n;
  288|   477k|            dst->num++;
  289|   477k|        }
  290|  30.5M|    }
  291|   477k|}
mp_chmap_is_lavc:
  294|  5.89k|{
  295|  5.89k|    if (!mp_chmap_is_valid(src))
  ------------------
  |  Branch (295:9): [True: 0, False: 5.89k]
  ------------------
  296|      0|        return false;
  297|  5.89k|    if (mp_chmap_is_unknown(src))
  ------------------
  |  Branch (297:9): [True: 0, False: 5.89k]
  ------------------
  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|  5.89k|    mp_assert(src->num > 0);
  ------------------
  |  |   41|  5.89k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 5.89k, False: 0]
  ------------------
  302|  6.48k|    for (int n = 1; n < src->num; n++) {
  ------------------
  |  Branch (302:21): [True: 582, False: 5.89k]
  ------------------
  303|    582|        if (src->speaker[n - 1] >= src->speaker[n])
  ------------------
  |  Branch (303:13): [True: 0, False: 582]
  ------------------
  304|      0|            return false;
  305|    582|    }
  306|  12.3k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (306:21): [True: 6.48k, False: 5.89k]
  ------------------
  307|  6.48k|        if (src->speaker[n] >= 64)
  ------------------
  |  Branch (307:13): [True: 0, False: 6.48k]
  ------------------
  308|      0|            return false;
  309|  6.48k|    }
  310|  5.89k|    return true;
  311|  5.89k|}
mp_chmap_to_str_buf:
  368|   194k|{
  369|   194k|    buf[0] = '\0';
  370|       |
  371|   194k|    if (mp_chmap_is_unknown(src)) {
  ------------------
  |  Branch (371:9): [True: 2.23k, False: 192k]
  ------------------
  372|  2.23k|        snprintf(buf, buf_size, "unknown%d", src->num);
  373|  2.23k|        return buf;
  374|  2.23k|    }
  375|       |
  376|   387k|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (376:21): [True: 194k, False: 192k]
  ------------------
  377|   194k|        int sp = src->speaker[n];
  378|   194k|        const char *s = sp < MP_SPEAKER_ID_COUNT ? speaker_names[sp][0] : NULL;
  ------------------
  |  Branch (378:25): [True: 194k, False: 0]
  ------------------
  379|   194k|        char sp_buf[10];
  380|   194k|        if (!s) {
  ------------------
  |  Branch (380:13): [True: 0, False: 194k]
  ------------------
  381|      0|            snprintf(sp_buf, sizeof(sp_buf), "sp%d", sp);
  382|      0|            s = sp_buf;
  383|      0|        }
  384|   194k|        mp_snprintf_cat(buf, buf_size, "%s%s", n > 0 ? "-" : "", s);
  ------------------
  |  Branch (384:48): [True: 3.01k, False: 191k]
  ------------------
  385|   194k|    }
  386|       |
  387|       |    // To standard layout name
  388|   394k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (388:21): [True: 394k, False: 85]
  ------------------
  389|   394k|        if (strcmp(buf, std_layout_names[n][1]) == 0) {
  ------------------
  |  Branch (389:13): [True: 192k, False: 202k]
  ------------------
  390|   192k|            snprintf(buf, buf_size, "%s", std_layout_names[n][0]);
  391|   192k|            break;
  392|   192k|        }
  393|   394k|    }
  394|       |
  395|   192k|    return buf;
  396|   194k|}
mp_chmap_from_str:
  403|   163k|{
  404|       |    // Single number corresponds to mp_chmap_from_channels()
  405|   163k|    if (src.len > 0) {
  ------------------
  |  Branch (405:9): [True: 163k, False: 0]
  ------------------
  406|   163k|        bstr t = src;
  407|   163k|        bool unknown = bstr_eatstart0(&t, "unknown");
  408|   163k|        bstr rest;
  409|   163k|        long long count = bstrtoll(t, &rest, 10);
  410|   163k|        if (rest.len == 0) {
  ------------------
  |  Branch (410:13): [True: 3.95k, False: 159k]
  ------------------
  411|  3.95k|            struct mp_chmap res;
  412|  3.95k|            if (unknown) {
  ------------------
  |  Branch (412:17): [True: 0, False: 3.95k]
  ------------------
  413|      0|                mp_chmap_set_unknown(&res, count);
  414|  3.95k|            } else {
  415|  3.95k|                mp_chmap_from_channels(&res, count);
  416|  3.95k|            }
  417|  3.95k|            if (mp_chmap_is_valid(&res)) {
  ------------------
  |  Branch (417:17): [True: 3.77k, False: 180]
  ------------------
  418|  3.77k|                *dst = res;
  419|  3.77k|                return true;
  420|  3.77k|            }
  421|  3.95k|        }
  422|   163k|    }
  423|       |
  424|       |    // From standard layout name
  425|   312k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (425:21): [True: 312k, False: 850]
  ------------------
  426|   312k|        if (bstr_equals0(src, std_layout_names[n][0])) {
  ------------------
  |  Branch (426:13): [True: 158k, False: 153k]
  ------------------
  427|   158k|            src = bstr0(std_layout_names[n][1]);
  428|   158k|            break;
  429|   158k|        }
  430|   312k|    }
  431|       |
  432|       |    // Explicit speaker list (separated by "-")
  433|   159k|    struct mp_chmap res = {0};
  434|   249k|    while (src.len) {
  ------------------
  |  Branch (434:12): [True: 90.8k, False: 158k]
  ------------------
  435|  90.8k|        bstr s;
  436|  90.8k|        bstr_split_tok(src, "-", &s, &src);
  437|  90.8k|        int speaker = -1;
  438|   358k|        for (int n = 0; n < MP_SPEAKER_ID_COUNT; n++) {
  ------------------
  |  Branch (438:25): [True: 357k, False: 850]
  ------------------
  439|   357k|            const char *name = speaker_names[n][0];
  440|   357k|            if (name && bstr_equals0(s, name)) {
  ------------------
  |  Branch (440:17): [True: 324k, False: 33.3k]
  |  Branch (440:25): [True: 89.9k, False: 234k]
  ------------------
  441|  89.9k|                speaker = n;
  442|  89.9k|                break;
  443|  89.9k|            }
  444|   357k|        }
  445|  90.8k|        if (speaker < 0) {
  ------------------
  |  Branch (445:13): [True: 850, False: 89.9k]
  ------------------
  446|    850|            if (bstr_eatstart0(&s, "sp")) {
  ------------------
  |  Branch (446:17): [True: 28, False: 822]
  ------------------
  447|     28|                long long sp = bstrtoll(s, &s, 0);
  448|     28|                if (s.len == 0 && sp >= 0 && sp < MP_SPEAKER_ID_COUNT)
  ------------------
  |  Branch (448:21): [True: 18, False: 10]
  |  Branch (448:35): [True: 18, False: 0]
  |  Branch (448:46): [True: 18, False: 0]
  ------------------
  449|     18|                    speaker = sp;
  450|     28|            }
  451|    850|            if (speaker < 0)
  ------------------
  |  Branch (451:17): [True: 832, False: 18]
  ------------------
  452|    832|                return false;
  453|    850|        }
  454|  89.9k|        if (res.num >= MP_NUM_CHANNELS)
  ------------------
  |  |   25|  89.9k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (454:13): [True: 0, False: 89.9k]
  ------------------
  455|      0|            return false;
  456|  89.9k|        res.speaker[res.num] = speaker;
  457|  89.9k|        res.num++;
  458|  89.9k|    }
  459|       |
  460|   158k|    *dst = res;
  461|       |    return true;
  462|   159k|}
mp_chmap_to_str_hr_buf:
  468|  77.9k|{
  469|  77.9k|    struct mp_chmap map = *src;
  470|  77.9k|    mp_chmap_remove_na(&map);
  471|   158k|    for (int n = 0; std_layout_names[n][0]; n++) {
  ------------------
  |  Branch (471:21): [True: 158k, False: 32]
  ------------------
  472|   158k|        struct mp_chmap s;
  473|   158k|        if (mp_chmap_from_str(&s, bstr0(std_layout_names[n][0])) &&
  ------------------
  |  Branch (473:13): [True: 158k, False: 0]
  ------------------
  474|   158k|            mp_chmap_equals_reordered(&s, &map))
  ------------------
  |  Branch (474:13): [True: 77.9k, False: 80.5k]
  ------------------
  475|  77.9k|        {
  476|  77.9k|            map = s;
  477|  77.9k|            break;
  478|  77.9k|        }
  479|   158k|    }
  480|  77.9k|    return mp_chmap_to_str_buf(buf, buf_size, &map);
  481|  77.9k|}
chmap.c:comp_uint8:
  182|  75.4k|{
  183|  75.4k|    return *(const uint8_t *)a - *(const uint8_t *)b;
  184|  75.4k|}

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

mp_chmap_sel_add_any:
   88|  15.0k|{
   89|       |    s->allow_any = true;
   90|  15.0k|}
mp_chmap_sel_add_map:
  100|  16.4k|{
  101|  16.4k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (101:9): [True: 0, False: 16.4k]
  ------------------
  102|      0|        return;
  103|  16.4k|    if (!s->chmaps)
  ------------------
  |  Branch (103:9): [True: 16.4k, False: 0]
  ------------------
  104|  16.4k|        s->chmaps = s->chmaps_storage;
  105|  16.4k|    if (s->num_chmaps == MP_ARRAY_SIZE(s->chmaps_storage)) {
  ------------------
  |  |   49|  16.4k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (105:9): [True: 0, False: 16.4k]
  ------------------
  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|  16.4k|    if (s->chmaps != s->chmaps_storage)
  ------------------
  |  Branch (110:9): [True: 0, False: 16.4k]
  ------------------
  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|  16.4k|    s->chmaps[s->num_chmaps++] = *map;
  113|  16.4k|}
mp_chmap_sel_adjust:
  182|  30.8k|{
  183|  30.8k|    if (test_layout(s, map))
  ------------------
  |  Branch (183:9): [True: 30.2k, False: 550]
  ------------------
  184|  30.2k|        return true;
  185|    550|    if (mp_chmap_is_unknown(map)) {
  ------------------
  |  Branch (185:9): [True: 0, False: 550]
  ------------------
  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|    550|    if (mp_chmap_sel_fallback(s, map))
  ------------------
  |  Branch (193:9): [True: 136, False: 414]
  ------------------
  194|    136|        return true;
  195|       |
  196|  1.24k|    for (int i = 0; i < MP_ARRAY_SIZE(speaker_replacements); i++) {
  ------------------
  |  |   49|  1.24k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (196:21): [True: 828, False: 414]
  ------------------
  197|    828|        struct mp_chmap  t = *map;
  198|    828|        struct mp_chmap *r = (struct mp_chmap *)speaker_replacements[i];
  199|    828|        if (replace_speakers(&t, r) && test_layout(s, &t)) {
  ------------------
  |  Branch (199:13): [True: 0, False: 828]
  |  Branch (199:40): [True: 0, False: 0]
  ------------------
  200|      0|            *map = t;
  201|      0|            return true;
  202|      0|        }
  203|    828|    }
  204|       |
  205|       |    // Fallback to mono/stereo as last resort
  206|    414|    *map = (struct mp_chmap) MP_CHMAP_INIT_STEREO;
  ------------------
  |  |  119|    414|#define MP_CHMAP_INIT_STEREO MP_CHMAP2(FL, FR)
  |  |  ------------------
  |  |  |  |   88|    414|    {2, {MP_SP(a), MP_SP(b)}}
  |  |  |  |  ------------------
  |  |  |  |  |  |   85|    414|#define MP_SP(speaker) MP_SPEAKER_ID_ ## speaker
  |  |  |  |  ------------------
  |  |  |  |                   {2, {MP_SP(a), MP_SP(b)}}
  |  |  |  |  ------------------
  |  |  |  |  |  |   85|    414|#define MP_SP(speaker) MP_SPEAKER_ID_ ## speaker
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|    414|    if (test_layout(s, map))
  ------------------
  |  Branch (207:9): [True: 0, False: 414]
  ------------------
  208|      0|        return true;
  209|    414|    *map = (struct mp_chmap) MP_CHMAP_INIT_MONO;
  ------------------
  |  |  118|    414|#define MP_CHMAP_INIT_MONO {1, {MP_SPEAKER_ID_FC}}
  ------------------
  210|    414|    if (test_layout(s, map))
  ------------------
  |  Branch (210:9): [True: 0, False: 414]
  ------------------
  211|      0|        return true;
  212|    414|    *map = (struct mp_chmap) {0};
  213|       |    return false;
  214|    414|}
mp_chmap_sel_fallback:
  309|  15.5k|{
  310|  15.5k|    struct mp_chmap best = {0};
  311|       |
  312|  16.1k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (312:21): [True: 550, False: 15.5k]
  ------------------
  313|    550|        struct mp_chmap e = s->chmaps[n];
  314|       |
  315|    550|        if (mp_chmap_is_unknown(&e))
  ------------------
  |  Branch (315:13): [True: 414, False: 136]
  ------------------
  316|    414|            continue;
  317|       |
  318|    136|        if (mp_chmap_is_better(map, &best, &e))
  ------------------
  |  Branch (318:13): [True: 136, False: 0]
  ------------------
  319|    136|            best = e;
  320|    136|    }
  321|       |
  322|  15.5k|    if (best.num) {
  ------------------
  |  Branch (322:9): [True: 136, False: 15.4k]
  ------------------
  323|    136|        *map = best;
  324|    136|        return true;
  325|    136|    }
  326|       |
  327|  15.4k|    return false;
  328|  15.5k|}
mp_chmal_sel_log:
  359|  15.0k|{
  360|  15.0k|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (360:9): [True: 0, False: 15.0k]
  ------------------
  361|      0|        return;
  362|       |
  363|  15.0k|    for (int i = 0; i < s->num_chmaps; i++)
  ------------------
  |  Branch (363:21): [True: 0, False: 15.0k]
  ------------------
  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|   991k|    for (int i = 0; i < MP_SPEAKER_ID_COUNT; i++) {
  ------------------
  |  Branch (365:21): [True: 976k, False: 15.0k]
  ------------------
  366|   976k|        if (!s->speakers[i])
  ------------------
  |  Branch (366:13): [True: 976k, False: 0]
  ------------------
  367|   976k|            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|  15.0k|    if (s->allow_waveext)
  ------------------
  |  Branch (372:9): [True: 0, False: 15.0k]
  ------------------
  373|      0|        mp_msg(log, lev, " - waveext\n");
  374|  15.0k|    if (s->allow_any)
  ------------------
  |  Branch (374:9): [True: 15.0k, False: 0]
  ------------------
  375|  15.0k|        mp_msg(log, lev, " - anything\n");
  376|  15.0k|}
mp_chmap_sel_list:
  381|  15.0k|{
  382|       |    // This is a separate function to keep messing with mp_chmap_sel internals
  383|       |    // within this source file.
  384|  15.0k|    struct mp_chmap_sel sel = {
  385|  15.0k|        .chmaps = maps,
  386|  15.0k|        .num_chmaps = num_maps,
  387|  15.0k|    };
  388|  15.0k|    mp_chmap_sel_fallback(&sel, c);
  389|  15.0k|}
chmap_sel.c:test_layout:
  167|  31.6k|{
  168|  31.6k|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (168:9): [True: 0, False: 31.6k]
  ------------------
  169|      0|        return false;
  170|       |
  171|  31.6k|    return s->allow_any || test_waveext(s, map) || test_speakers(s, map) ||
  ------------------
  |  Branch (171:12): [True: 15.0k, False: 16.6k]
  |  Branch (171:28): [True: 0, False: 16.6k]
  |  Branch (171:52): [True: 0, False: 16.6k]
  ------------------
  172|  16.6k|           test_maps(s, map);
  ------------------
  |  Branch (172:12): [True: 15.2k, False: 1.37k]
  ------------------
  173|  31.6k|}
chmap_sel.c:test_waveext:
  154|  16.6k|{
  155|  16.6k|    if (s->allow_waveext) {
  ------------------
  |  Branch (155:9): [True: 0, False: 16.6k]
  ------------------
  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|  16.6k|    return false;
  164|  16.6k|}
chmap_sel.c:test_speakers:
  134|  16.6k|{
  135|  16.6k|    for (int n = 0; n < map->num; n++) {
  ------------------
  |  Branch (135:21): [True: 16.6k, False: 0]
  ------------------
  136|  16.6k|        if (!s->speakers[map->speaker[n]])
  ------------------
  |  Branch (136:13): [True: 16.6k, False: 0]
  ------------------
  137|  16.6k|            return false;
  138|  16.6k|    }
  139|      0|    return true;
  140|  16.6k|}
chmap_sel.c:test_maps:
  143|  16.6k|{
  144|  18.0k|    for (int n = 0; n < s->num_chmaps; n++) {
  ------------------
  |  Branch (144:21): [True: 16.6k, False: 1.37k]
  ------------------
  145|  16.6k|        if (mp_chmap_equals_reordered(&s->chmaps[n], map)) {
  ------------------
  |  Branch (145:13): [True: 15.2k, False: 1.37k]
  ------------------
  146|  15.2k|            *map = s->chmaps[n];
  147|  15.2k|            return true;
  148|  15.2k|        }
  149|  16.6k|    }
  150|  1.37k|    return false;
  151|  16.6k|}
chmap_sel.c:replace_speakers:
   36|    828|{
   37|    828|    mp_assert(list[0].num == list[1].num);
  ------------------
  |  |   41|    828|#define mp_assert assert
  ------------------
  |  Branch (37:5): [True: 828, False: 0]
  ------------------
   38|    828|    if (!mp_chmap_is_valid(map))
  ------------------
  |  Branch (38:9): [True: 0, False: 828]
  ------------------
   39|      0|        return false;
   40|  2.48k|    for (int dir = 0; dir < 2; dir++) {
  ------------------
  |  Branch (40:23): [True: 1.65k, False: 828]
  ------------------
   41|  1.65k|        int from = dir ? 0 : 1;
  ------------------
  |  Branch (41:20): [True: 828, False: 828]
  ------------------
   42|  1.65k|        int to   = dir ? 1 : 0;
  ------------------
  |  Branch (42:20): [True: 828, False: 828]
  ------------------
   43|  1.65k|        bool replaced = false;
   44|  1.65k|        struct mp_chmap t = *map;
   45|  3.31k|        for (int n = 0; n < t.num; n++) {
  ------------------
  |  Branch (45:25): [True: 1.65k, False: 1.65k]
  ------------------
   46|  4.96k|            for (int i = 0; i < list[0].num; i++) {
  ------------------
  |  Branch (46:29): [True: 3.31k, False: 1.65k]
  ------------------
   47|  3.31k|                if (t.speaker[n] == list[from].speaker[i]) {
  ------------------
  |  Branch (47:21): [True: 0, False: 3.31k]
  ------------------
   48|      0|                    t.speaker[n] = list[to].speaker[i];
   49|      0|                    replaced = true;
   50|      0|                    break;
   51|      0|                }
   52|  3.31k|            }
   53|  1.65k|        }
   54|  1.65k|        if (replaced && mp_chmap_is_valid(&t)) {
  ------------------
  |  Branch (54:13): [True: 0, False: 1.65k]
  |  Branch (54:25): [True: 0, False: 0]
  ------------------
   55|      0|            *map = t;
   56|      0|            return true;
   57|      0|        }
   58|  1.65k|    }
   59|    828|    return false;
   60|    828|}
chmap_sel.c:mp_chmap_is_better:
  250|    136|{
  251|       |    // Initial case
  252|    136|    if (!old->num)
  ------------------
  |  Branch (252:9): [True: 136, False: 0]
  ------------------
  253|    136|        return true;
  254|       |
  255|       |    // Exact pick - this also ensures that the best layout is chosen if the
  256|       |    // layouts are the same, but with different order of channels.
  257|      0|    if (mp_chmap_equals(req, old))
  ------------------
  |  Branch (257:9): [True: 0, False: 0]
  ------------------
  258|      0|        return false;
  259|      0|    if (mp_chmap_equals(req, new))
  ------------------
  |  Branch (259:9): [True: 0, False: 0]
  ------------------
  260|      0|        return true;
  261|       |
  262|       |    // If there's no exact match, strictly do a preferred conversion.
  263|      0|    bool old_pref = test_preferred_remix(req, old);
  264|      0|    bool new_pref = test_preferred_remix(req, new);
  265|      0|    if (old_pref && !new_pref)
  ------------------
  |  Branch (265:9): [True: 0, False: 0]
  |  Branch (265:21): [True: 0, False: 0]
  ------------------
  266|      0|        return false;
  267|      0|    if (!old_pref && new_pref)
  ------------------
  |  Branch (267:9): [True: 0, False: 0]
  |  Branch (267:22): [True: 0, False: 0]
  ------------------
  268|      0|        return true;
  269|       |
  270|      0|    int old_lost_r = mp_chmap_diffn_r(req, old); // num. channels only in req
  271|      0|    int new_lost_r = mp_chmap_diffn_r(req, new);
  272|       |
  273|       |    // Imperfect upmix (no real superset) - minimize lost channels
  274|      0|    if (new_lost_r != old_lost_r)
  ------------------
  |  Branch (274:9): [True: 0, False: 0]
  ------------------
  275|      0|        return new_lost_r < old_lost_r;
  276|       |
  277|      0|    struct mp_chmap old_p = *old, new_p = *new;
  278|      0|    mp_chmap_remove_na(&old_p);
  279|      0|    mp_chmap_remove_na(&new_p);
  280|       |
  281|       |    // If the situation is equal with replaced speakers, but the replacement is
  282|       |    // perfect for only one of them, let the better one win. This prefers
  283|       |    // inexact equivalents over exact supersets.
  284|      0|    bool perfect_r_new = !new_lost_r && new_p.num <= old_p.num;
  ------------------
  |  Branch (284:26): [True: 0, False: 0]
  |  Branch (284:41): [True: 0, False: 0]
  ------------------
  285|      0|    bool perfect_r_old = !old_lost_r && old_p.num <= new_p.num;
  ------------------
  |  Branch (285:26): [True: 0, False: 0]
  |  Branch (285:41): [True: 0, False: 0]
  ------------------
  286|      0|    if (perfect_r_new != perfect_r_old)
  ------------------
  |  Branch (286:9): [True: 0, False: 0]
  ------------------
  287|      0|        return perfect_r_new;
  288|       |
  289|      0|    int old_lost = mp_chmap_diffn(req, old);
  290|      0|    int new_lost = mp_chmap_diffn(req, new);
  291|       |    // If the situation is equal with replaced speakers, pick the better one,
  292|       |    // even if it means an upmix.
  293|      0|    if (new_lost != old_lost)
  ------------------
  |  Branch (293:9): [True: 0, False: 0]
  ------------------
  294|      0|        return new_lost < old_lost;
  295|       |
  296|       |    // Some kind of upmix. If it's perfect, prefer the smaller one. Even if not,
  297|       |    // both have equal loss, so also prefer the smaller one.
  298|       |    // Drop padding channels (NA) for the sake of this check, as the number of
  299|       |    // padding channels isn't really meaningful.
  300|      0|    if (new_p.num != old_p.num)
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|        return new_p.num < old_p.num;
  302|       |
  303|       |    // Again, with physical channels (minimizes number of NA channels).
  304|      0|    return new->num < old->num;
  305|      0|}

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

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

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

af_drop.c:af_drop_create:
   91|     39|{
   92|     39|    struct mp_filter *f = mp_filter_create(parent, &af_drop_filter);
   93|     39|    if (!f) {
  ------------------
  |  Branch (93:9): [True: 0, False: 39]
  ------------------
   94|      0|        talloc_free(options);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   95|      0|        return NULL;
   96|      0|    }
   97|       |
   98|     39|    mp_filter_add_pin(f, MP_PIN_IN, "in");
   99|     39|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  100|       |
  101|     39|    struct priv *p = f->priv;
  102|     39|    p->speed = 1.0;
  103|       |
  104|     39|    return f;
  105|     39|}
af_drop.c:af_drop_destroy:
   77|     39|{
   78|     39|    af_drop_reset(f);
   79|     39|}
af_drop.c:af_drop_process:
   15|  1.34k|{
   16|  1.34k|    struct priv *p = f->priv;
   17|       |
   18|  1.34k|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (18:9): [True: 39, False: 1.30k]
  ------------------
   19|     39|        return;
   20|       |
   21|  1.30k|    struct mp_frame frame = {0};
   22|       |
   23|  1.30k|    double last_dur = p->last ? mp_aframe_duration(p->last) : 0;
  ------------------
  |  Branch (23:23): [True: 1.16k, False: 137]
  ------------------
   24|  1.30k|    if (p->last && p->diff < 0 && -p->diff > last_dur / 2) {
  ------------------
  |  Branch (24:9): [True: 1.16k, False: 137]
  |  Branch (24:20): [True: 0, False: 1.16k]
  |  Branch (24:35): [True: 0, False: 0]
  ------------------
   25|      0|        MP_VERBOSE(f, "repeat\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__)
  |  |  ------------------
  ------------------
   26|      0|        frame = MAKE_FRAME(MP_FRAME_AUDIO, p->last);
  ------------------
  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
   27|      0|        p->last = NULL;
   28|  1.30k|    } else {
   29|  1.30k|        frame = mp_pin_out_read(f->ppins[0]);
   30|       |
   31|  1.30k|        if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (31:13): [True: 611, False: 692]
  ------------------
   32|    611|            last_dur = mp_aframe_duration(frame.data);
   33|    611|            p->diff -= last_dur;
   34|    611|            if (p->diff > last_dur / 2) {
  ------------------
  |  Branch (34:17): [True: 51, False: 560]
  ------------------
   35|     51|                MP_VERBOSE(f, "drop\n");
  ------------------
  |  |   92|     51|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     51|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   36|     51|                mp_frame_unref(&frame);
   37|     51|                mp_filter_internal_mark_progress(f);
   38|     51|            }
   39|    611|        }
   40|  1.30k|    }
   41|       |
   42|  1.30k|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (42:9): [True: 560, False: 743]
  ------------------
   43|    560|        struct mp_aframe *fr = frame.data;
   44|    560|        talloc_free(p->last);
  ------------------
  |  |   47|    560|#define talloc_free                     ta_free
  ------------------
   45|    560|        p->last = mp_aframe_new_ref(fr);
   46|    560|        mp_aframe_mul_speed(fr, p->speed);
   47|    560|        p->diff += mp_aframe_duration(fr);
   48|    560|        mp_aframe_set_pts(p->last, mp_aframe_end_pts(fr));
   49|    743|    } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (49:16): [True: 36, False: 707]
  ------------------
   50|       |        TA_FREEP(&p->last);
  ------------------
  |  |   81|     36|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     36|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 36]
  |  |  ------------------
  ------------------
   51|     36|    }
   52|  1.30k|    mp_pin_in_write(f->ppins[1], frame);
   53|  1.30k|}
af_drop.c:af_drop_reset:
   69|     93|{
   70|     93|    struct priv *p = f->priv;
   71|       |
   72|       |    TA_FREEP(&p->last);
  ------------------
  |  |   81|     93|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     93|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 93]
  |  |  ------------------
  ------------------
   73|     93|    p->diff = 0;
   74|     93|}
af_drop.c:af_drop_command:
   56|    714|{
   57|    714|    struct priv *p = f->priv;
   58|       |
   59|    714|    switch (cmd->type) {
  ------------------
  |  Branch (59:13): [True: 59, False: 655]
  ------------------
   60|     59|    case MP_FILTER_COMMAND_SET_SPEED:
  ------------------
  |  Branch (60:5): [True: 59, False: 655]
  ------------------
   61|     59|        p->speed = cmd->speed;
   62|     59|        return true;
   63|    714|    }
   64|       |
   65|    655|    return false;
   66|    714|}

af_format.c:af_format_create:
   93|  4.81k|{
   94|  4.81k|    struct mp_filter *f = mp_filter_create(parent, &af_format_filter);
   95|  4.81k|    if (!f) {
  ------------------
  |  Branch (95:9): [True: 0, False: 4.81k]
  ------------------
   96|      0|        talloc_free(options);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   97|      0|        return NULL;
   98|      0|    }
   99|       |
  100|  4.81k|    struct priv *p = f->priv;
  101|  4.81k|    p->opts = talloc_steal(p, options);
  ------------------
  |  |   38|  4.81k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  4.81k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  102|       |
  103|  4.81k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  104|  4.81k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  105|       |
  106|  4.81k|    struct mp_autoconvert *conv = mp_autoconvert_create(f);
  107|  4.81k|    if (!conv)
  ------------------
  |  Branch (107:9): [True: 0, False: 4.81k]
  ------------------
  108|      0|        abort();
  109|       |
  110|  4.81k|    if (p->opts->in_format)
  ------------------
  |  Branch (110:9): [True: 0, False: 4.81k]
  ------------------
  111|      0|        mp_autoconvert_add_afmt(conv, p->opts->in_format);
  112|  4.81k|    if (p->opts->in_srate)
  ------------------
  |  Branch (112:9): [True: 217, False: 4.60k]
  ------------------
  113|    217|        mp_autoconvert_add_srate(conv, p->opts->in_srate);
  114|  4.81k|    if (p->opts->in_channels.num_chmaps > 0)
  ------------------
  |  Branch (114:9): [True: 1.10k, False: 3.71k]
  ------------------
  115|  1.10k|        mp_autoconvert_add_chmap(conv, &p->opts->in_channels.chmaps[0]);
  116|       |
  117|  4.81k|    mp_pin_connect(conv->f->pins[0], f->ppins[0]);
  118|  4.81k|    p->in_pin = conv->f->pins[1];
  119|       |
  120|  4.81k|    return f;
  121|  4.81k|}
af_format.c:af_format_process:
   42|  1.07M|{
   43|  1.07M|    struct priv *p = f->priv;
   44|       |
   45|  1.07M|    if (!mp_pin_can_transfer_data(f->ppins[1], p->in_pin))
  ------------------
  |  Branch (45:9): [True: 540k, False: 534k]
  ------------------
   46|   540k|        return;
   47|       |
   48|   534k|    struct mp_frame frame = mp_pin_out_read(p->in_pin);
   49|       |
   50|   534k|    if (p->opts->fail) {
  ------------------
  |  Branch (50:9): [True: 0, False: 534k]
  ------------------
   51|      0|        MP_ERR(f, "Failing on purpose.\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__)
  |  |  ------------------
  ------------------
   52|      0|        goto error;
   53|      0|    }
   54|       |
   55|   534k|    if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (55:9): [True: 498k, False: 36.4k]
  ------------------
   56|   498k|        mp_pin_in_write(f->ppins[1], frame);
   57|   498k|        return;
   58|   498k|    }
   59|       |
   60|  36.4k|    if (frame.type != MP_FRAME_AUDIO) {
  ------------------
  |  Branch (60:9): [True: 0, False: 36.4k]
  ------------------
   61|      0|        MP_ERR(f, "audio frame expected\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__)
  |  |  ------------------
  ------------------
   62|      0|        goto error;
   63|      0|    }
   64|       |
   65|  36.4k|    struct mp_aframe *in = frame.data;
   66|       |
   67|  36.4k|    if (p->opts->out_channels.num_chmaps > 0) {
  ------------------
  |  Branch (67:9): [True: 312, False: 36.0k]
  ------------------
   68|    312|        if (!mp_aframe_set_chmap(in, &p->opts->out_channels.chmaps[0])) {
  ------------------
  |  Branch (68:13): [True: 303, False: 9]
  ------------------
   69|    303|            MP_ERR(f, "could not force output channels\n");
  ------------------
  |  |   89|    303|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    303|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   70|    303|            goto error;
   71|    303|        }
   72|    312|    }
   73|       |
   74|  36.0k|    if (p->opts->out_srate)
  ------------------
  |  Branch (74:9): [True: 5, False: 36.0k]
  ------------------
   75|      5|        mp_aframe_set_rate(in, p->opts->out_srate);
   76|       |
   77|  36.0k|    mp_pin_in_write(f->ppins[1], frame);
   78|  36.0k|    return;
   79|       |
   80|    303|error:
   81|    303|    mp_frame_unref(&frame);
   82|    303|    mp_filter_internal_mark_failed(f);
   83|    303|}

af_scaletempo2.c:af_scaletempo2_create:
  198|  2.19k|{
  199|  2.19k|    struct mp_filter *f = mp_filter_create(parent, &af_scaletempo2_filter);
  200|  2.19k|    if (!f) {
  ------------------
  |  Branch (200:9): [True: 0, False: 2.19k]
  ------------------
  201|      0|        talloc_free(options);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  202|      0|        return NULL;
  203|      0|    }
  204|       |
  205|  2.19k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  206|  2.19k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  207|       |
  208|  2.19k|    struct priv *p = f->priv;
  209|  2.19k|    p->data = talloc_zero(p, struct mp_scaletempo2);
  ------------------
  |  |   27|  2.19k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  2.19k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.19k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|  2.19k|    p->data->opts = talloc_steal(p, options);
  ------------------
  |  |   38|  2.19k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.19k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  211|  2.19k|    p->speed = 1.0;
  212|  2.19k|    p->cur_format = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  2.19k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.19k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  213|  2.19k|    p->out_pool = mp_aframe_pool_create(p);
  214|  2.19k|    p->pending = NULL;
  215|  2.19k|    p->initialized = false;
  216|       |
  217|  2.19k|    struct mp_autoconvert *conv = mp_autoconvert_create(f);
  218|  2.19k|    if (!conv)
  ------------------
  |  Branch (218:9): [True: 0, False: 2.19k]
  ------------------
  219|      0|        abort();
  220|       |
  221|  2.19k|    mp_autoconvert_add_afmt(conv, AF_FORMAT_FLOATP);
  222|       |
  223|  2.19k|    mp_pin_connect(conv->f->pins[0], f->ppins[0]);
  224|  2.19k|    p->in_pin = conv->f->pins[1];
  225|       |
  226|  2.19k|    return f;
  227|  2.19k|}
af_scaletempo2.c:af_scaletempo2_destroy:
  181|  2.19k|{
  182|  2.19k|    struct priv *p = f->priv;
  183|  2.19k|    TA_FREEP(&p->data);
  ------------------
  |  |   81|  2.19k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  2.19k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 2.19k]
  |  |  ------------------
  ------------------
  184|       |    TA_FREEP(&p->pending);
  ------------------
  |  |   81|  2.19k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  2.19k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 2.19k]
  |  |  ------------------
  ------------------
  185|  2.19k|}
af_scaletempo2.c:af_scaletempo2_process:
   25|  3.00M|{
   26|  3.00M|    struct priv *p = f->priv;
   27|       |
   28|  3.00M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (28:9): [True: 2.19k, False: 3.00M]
  ------------------
   29|  2.19k|        return;
   30|       |
   31|  3.28M|    while (!p->initialized || !p->pending ||
  ------------------
  |  Branch (31:12): [True: 2.71M, False: 566k]
  |  Branch (31:31): [True: 0, False: 566k]
  ------------------
   32|   566k|           !mp_scaletempo2_frames_available(p->data, p->speed))
  ------------------
  |  Branch (32:12): [True: 365k, False: 200k]
  ------------------
   33|  3.08M|    {
   34|  3.08M|        bool eof = false;
   35|  3.08M|        if (!p->pending || !mp_aframe_get_size(p->pending)) {
  ------------------
  |  Branch (35:13): [True: 2.71M, False: 365k]
  |  Branch (35:28): [True: 175k, False: 189k]
  ------------------
   36|  2.89M|            struct mp_frame frame = mp_pin_out_read(p->in_pin);
   37|  2.89M|            if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (37:17): [True: 88.7k, False: 2.80M]
  ------------------
   38|  88.7k|                TA_FREEP(&p->pending);
  ------------------
  |  |   81|  88.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  88.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 88.7k]
  |  |  ------------------
  ------------------
   39|  88.7k|                p->pending = frame.data;
   40|  2.80M|            } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (40:24): [True: 1.35M, False: 1.44M]
  ------------------
   41|  1.35M|                eof = true;
   42|  1.44M|            } else if (frame.type) {
  ------------------
  |  Branch (42:24): [True: 0, False: 1.44M]
  ------------------
   43|      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__)
  |  |  ------------------
  ------------------
   44|      0|                goto error;
   45|  1.44M|            } else {
   46|  1.44M|                return; // no new data yet
   47|  1.44M|            }
   48|  2.89M|        }
   49|  1.63M|        mp_assert(p->pending || eof);
  ------------------
  |  |   41|  1.63M|#define mp_assert assert
  ------------------
  |  Branch (49:9): [True: 281k, False: 1.35M]
  |  Branch (49:9): [True: 1.35M, False: 0]
  ------------------
   50|       |
   51|  1.63M|        if (!p->initialized) {
  ------------------
  |  Branch (51:13): [True: 1.35M, False: 278k]
  ------------------
   52|  1.35M|            if (!p->pending) {
  ------------------
  |  Branch (52:17): [True: 1.35M, False: 3.67k]
  ------------------
   53|  1.35M|                mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  1.35M|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  1.35M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
   54|  1.35M|                return;
   55|  1.35M|            }
   56|  3.67k|            if (!init_scaletempo2(f))
  ------------------
  |  Branch (56:17): [True: 0, False: 3.67k]
  ------------------
   57|      0|                goto error;
   58|  3.67k|        }
   59|       |
   60|  1.63M|        bool format_change =
   61|   281k|            p->pending && !mp_aframe_config_equals(p->pending, p->cur_format);
  ------------------
  |  Branch (61:13): [True: 281k, False: 0]
  |  Branch (61:27): [True: 106, False: 281k]
  ------------------
   62|       |
   63|   281k|        bool final = format_change || eof;
  ------------------
  |  Branch (63:22): [True: 106, False: 281k]
  |  Branch (63:39): [True: 3.56k, False: 278k]
  ------------------
   64|   281k|        if (p->pending && !format_change && !p->sent_final) {
  ------------------
  |  Branch (64:13): [True: 281k, False: 0]
  |  Branch (64:27): [True: 281k, False: 106]
  |  Branch (64:45): [True: 280k, False: 1.77k]
  ------------------
   65|   280k|            int frame_size = mp_aframe_get_size(p->pending);
   66|   280k|            uint8_t **planes = mp_aframe_get_data_ro(p->pending);
   67|   280k|            int read = mp_scaletempo2_fill_input_buffer(p->data,
   68|   280k|                planes, frame_size, p->speed);
   69|   280k|            mp_aframe_skip_samples(p->pending, read);
   70|   280k|        }
   71|   281k|        if (final && p->pending && !p->sent_final) {
  ------------------
  |  Branch (71:13): [True: 3.67k, False: 278k]
  |  Branch (71:22): [True: 3.67k, False: 0]
  |  Branch (71:36): [True: 1.84k, False: 1.83k]
  ------------------
   72|  1.84k|            mp_scaletempo2_set_final(p->data);
   73|  1.84k|            p->sent_final = true;
   74|  1.84k|        }
   75|       |
   76|   281k|        if (mp_scaletempo2_frames_available(p->data, p->speed)) {
  ------------------
  |  Branch (76:13): [True: 193k, False: 88.6k]
  ------------------
   77|   193k|            if (eof) {
  ------------------
  |  Branch (77:17): [True: 1.78k, False: 191k]
  ------------------
   78|  1.78k|                mp_pin_out_repeat_eof(p->in_pin); // drain more next time
   79|  1.78k|            }
   80|   193k|        } else if (final) {
  ------------------
  |  Branch (80:20): [True: 1.83k, False: 86.8k]
  ------------------
   81|  1.83k|            p->initialized = false;
   82|  1.83k|            p->sent_final = false;
   83|  1.83k|            if (eof) {
  ------------------
  |  Branch (83:17): [True: 1.77k, False: 53]
  ------------------
   84|  1.77k|                mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  1.77k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  1.77k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
   85|  1.77k|                return;
   86|  1.77k|            }
   87|       |            // for format change go on with proper reinit on the next iteration
   88|  1.83k|        }
   89|   281k|    }
   90|       |
   91|   200k|    mp_assert(p->pending);
  ------------------
  |  |   41|   200k|#define mp_assert assert
  ------------------
  |  Branch (91:5): [True: 200k, False: 0]
  ------------------
   92|   200k|    if (mp_scaletempo2_frames_available(p->data, p->speed)) {
  ------------------
  |  Branch (92:9): [True: 200k, False: 0]
  ------------------
   93|   200k|        struct mp_aframe *out = mp_aframe_new_ref(p->cur_format);
   94|   200k|        int out_samples = p->data->ola_hop_size;
   95|   200k|        if (mp_aframe_pool_allocate(p->out_pool, out, out_samples) < 0) {
  ------------------
  |  Branch (95:13): [True: 0, False: 200k]
  ------------------
   96|      0|            talloc_free(out);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   97|      0|            goto error;
   98|      0|        }
   99|       |
  100|   200k|        mp_aframe_copy_attributes(out, p->pending);
  101|       |
  102|   200k|        uint8_t **planes = mp_aframe_get_data_rw(out);
  103|   200k|        mp_assert(planes);
  ------------------
  |  |   41|   200k|#define mp_assert assert
  ------------------
  |  Branch (103:9): [True: 200k, False: 0]
  ------------------
  104|   200k|        mp_assert(mp_aframe_get_planes(out) == p->data->channels);
  ------------------
  |  |   41|   200k|#define mp_assert assert
  ------------------
  |  Branch (104:9): [True: 200k, False: 0]
  ------------------
  105|       |
  106|   200k|        out_samples = mp_scaletempo2_fill_buffer(p->data,
  107|   200k|            (float**)planes, out_samples, p->speed);
  108|       |
  109|   200k|        double pts = mp_aframe_get_pts(p->pending);
  110|   200k|        if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   200k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (110:13): [True: 200k, False: 0]
  ------------------
  111|   200k|            double frame_delay = mp_scaletempo2_get_latency(p->data, p->speed)
  112|   200k|                + out_samples * p->speed;
  113|   200k|            mp_aframe_set_pts(out, pts - frame_delay / mp_aframe_get_effective_rate(out));
  114|       |
  115|   200k|            if (p->sent_final) {
  ------------------
  |  Branch (115:17): [True: 5.05k, False: 195k]
  ------------------
  116|  5.05k|                double remain_pts = pts - mp_aframe_get_pts(out);
  117|  5.05k|                double rate = mp_aframe_get_effective_rate(out) / p->speed;
  118|  5.05k|                int max_samples = MPMAX(0, (int) (remain_pts * rate));
  ------------------
  |  |   44|  5.05k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 5.05k]
  |  |  ------------------
  ------------------
  119|       |                // truncate final packet to expected length
  120|  5.05k|                if (out_samples >= max_samples) {
  ------------------
  |  Branch (120:21): [True: 1.65k, False: 3.40k]
  ------------------
  121|  1.65k|                    out_samples = max_samples;
  122|       |
  123|       |                    // reset the filter to ensure it stops generating audio
  124|       |                    // and mp_scaletempo2_frames_available returns false
  125|  1.65k|                    mp_scaletempo2_reset(p->data);
  126|  1.65k|                }
  127|  5.05k|            }
  128|   200k|        }
  129|       |
  130|   200k|        mp_aframe_set_size(out, out_samples);
  131|   200k|        mp_aframe_mul_speed(out, p->speed);
  132|   200k|        mp_pin_in_write(f->ppins[1], MAKE_FRAME(MP_FRAME_AUDIO, out));
  ------------------
  |  |   57|   200k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
  133|   200k|    }
  134|       |
  135|   200k|    return;
  136|   200k|error:
  137|      0|    mp_filter_internal_mark_failed(f);
  138|      0|}
af_scaletempo2.c:init_scaletempo2:
  141|  3.67k|{
  142|  3.67k|    struct priv *p = f->priv;
  143|  3.67k|    mp_assert(p->pending);
  ------------------
  |  |   41|  3.67k|#define mp_assert assert
  ------------------
  |  Branch (143:5): [True: 3.67k, False: 0]
  ------------------
  144|       |
  145|  3.67k|    if (mp_aframe_get_format(p->pending) != AF_FORMAT_FLOATP)
  ------------------
  |  Branch (145:9): [True: 0, False: 3.67k]
  ------------------
  146|      0|        return false;
  147|       |
  148|  3.67k|    mp_aframe_reset(p->cur_format);
  149|  3.67k|    p->initialized = true;
  150|  3.67k|    p->sent_final = false;
  151|  3.67k|    mp_aframe_config_copy(p->cur_format, p->pending);
  152|       |
  153|  3.67k|    mp_scaletempo2_init(p->data, mp_aframe_get_channels(p->pending),
  154|  3.67k|        mp_aframe_get_rate(p->pending));
  155|       |
  156|       |    return true;
  157|  3.67k|}
af_scaletempo2.c:af_scaletempo2_reset:
  173|  1.35M|{
  174|  1.35M|    struct priv *p = f->priv;
  175|  1.35M|    mp_scaletempo2_reset(p->data);
  176|  1.35M|    p->initialized = false;
  177|       |    TA_FREEP(&p->pending);
  ------------------
  |  |   81|  1.35M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  1.35M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 1.35M]
  |  |  ------------------
  ------------------
  178|  1.35M|}
af_scaletempo2.c:af_scaletempo2_command:
  160|  1.44M|{
  161|  1.44M|    struct priv *p = f->priv;
  162|       |
  163|  1.44M|    switch (cmd->type) {
  ------------------
  |  Branch (163:13): [True: 1.44M, False: 0]
  ------------------
  164|  1.44M|    case MP_FILTER_COMMAND_SET_SPEED:
  ------------------
  |  Branch (164:5): [True: 1.44M, False: 0]
  ------------------
  165|  1.44M|        p->speed = cmd->speed;
  166|  1.44M|        return true;
  167|  1.44M|    }
  168|       |
  169|      0|    return false;
  170|  1.44M|}

mp_scaletempo2_set_final:
  500|  1.84k|{
  501|  1.84k|    if (p->input_buffer_final_frames <= 0) {
  ------------------
  |  Branch (501:9): [True: 1.84k, False: 0]
  ------------------
  502|  1.84k|        p->input_buffer_final_frames = p->input_buffer_frames;
  503|  1.84k|    }
  504|  1.84k|}
mp_scaletempo2_fill_input_buffer:
  508|   280k|{
  509|   280k|    int needed = frames_needed(p, playback_rate);
  510|   280k|    int read = MPMIN(needed, frame_size);
  ------------------
  |  |   45|   280k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 88.5k, False: 191k]
  |  |  ------------------
  ------------------
  511|   280k|    if (read == 0)
  ------------------
  |  Branch (511:9): [True: 1.78k, False: 278k]
  ------------------
  512|  1.78k|        return 0;
  513|       |
  514|   278k|    int last_index = read + p->input_buffer_frames - 1;
  515|   847k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (515:21): [True: 569k, False: 278k]
  ------------------
  516|   569k|        MP_TARRAY_GROW(p, p->input_buffer[i], last_index);
  ------------------
  |  |   96|   569k|    do {                                            \
  |  |   97|   569k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   569k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   569k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   569k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 181, False: 569k]
  |  |  ------------------
  |  |   99|   569k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|    181|    do {                                                        \
  |  |  |  |   89|    181|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|    181|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    181|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    181|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    181|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|    181|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|    181|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 181]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   569k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 569k]
  |  |  ------------------
  ------------------
  517|   569k|        memcpy(p->input_buffer[i] + p->input_buffer_frames,
  518|   569k|            planes[i], read * sizeof(float));
  519|   569k|    }
  520|       |
  521|   278k|    p->input_buffer_frames += read;
  522|   278k|    return read;
  523|   280k|}
mp_scaletempo2_fill_buffer:
  684|   200k|{
  685|   200k|    if (playback_rate == 0) return 0;
  ------------------
  |  Branch (685:9): [True: 0, False: 200k]
  ------------------
  686|       |
  687|   200k|    if (p->input_buffer_final_frames > 0) {
  ------------------
  |  Branch (687:9): [True: 5.05k, False: 195k]
  ------------------
  688|  5.05k|        add_input_buffer_final_silence(p, playback_rate);
  689|  5.05k|    }
  690|       |
  691|       |    // Optimize the muted case to issue a single clear instead of performing
  692|       |    // the full crossfade and clearing each crossfaded frame.
  693|   200k|    if (playback_rate < p->opts->min_playback_rate
  ------------------
  |  Branch (693:9): [True: 45.3k, False: 155k]
  ------------------
  694|   155k|        || (playback_rate > p->opts->max_playback_rate
  ------------------
  |  Branch (694:13): [True: 8.91k, False: 146k]
  ------------------
  695|  8.91k|            && p->opts->max_playback_rate > 0))
  ------------------
  |  Branch (695:16): [True: 8.91k, False: 0]
  ------------------
  696|  54.2k|    {
  697|  54.2k|        int frames_to_render = MPMIN(dest_size,
  ------------------
  |  |   45|  54.2k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 54.2k]
  |  |  ------------------
  ------------------
  698|  54.2k|            (int) (p->input_buffer_frames / playback_rate));
  699|       |
  700|       |        // Compute accurate number of frames to actually skip in the source data.
  701|       |        // Includes the leftover partial frame from last request. However, we can
  702|       |        // only skip over complete frames, so a partial frame may remain for next
  703|       |        // time.
  704|  54.2k|        p->muted_partial_frame += frames_to_render * playback_rate;
  705|  54.2k|        int seek_frames = (int) (p->muted_partial_frame);
  706|  54.2k|        zero_2d_partial(dest, p->channels, frames_to_render);
  707|  54.2k|        seek_buffer(p, seek_frames);
  708|       |
  709|       |        // Determine the partial frame that remains to be skipped for next call. If
  710|       |        // the user switches back to playing, it may be off time by this partial
  711|       |        // frame, which would be undetectable. If they subsequently switch to
  712|       |        // another playback rate that mutes, the code will attempt to line up the
  713|       |        // frames again.
  714|  54.2k|        p->muted_partial_frame -= seek_frames;
  715|  54.2k|        return frames_to_render;
  716|  54.2k|    }
  717|       |
  718|   146k|    int slower_step = (int) ceilf(p->ola_window_size * playback_rate);
  719|   146k|    int faster_step = (int) ceilf(p->ola_window_size / playback_rate);
  720|       |
  721|       |    // Optimize the most common |playback_rate| ~= 1 case to use a single copy
  722|       |    // instead of copying frame by frame.
  723|   146k|    if (p->ola_window_size <= faster_step && slower_step >= p->ola_window_size) {
  ------------------
  |  Branch (723:9): [True: 96.2k, False: 50.4k]
  |  Branch (723:46): [True: 0, False: 96.2k]
  ------------------
  724|       |
  725|      0|        if (p->wsola_output_started) {
  ------------------
  |  Branch (725:13): [True: 0, False: 0]
  ------------------
  726|      0|            p->wsola_output_started = false;
  727|       |
  728|       |            // sync audio precisely again
  729|      0|            set_output_time(p, p->target_block_index);
  730|      0|            remove_old_input_frames(p);
  731|      0|        }
  732|       |
  733|      0|        return read_input_buffer(p, dest_size, dest);
  734|      0|    }
  735|       |
  736|   146k|    int rendered_frames = 0;
  737|   293k|    do {
  738|   293k|        rendered_frames += write_completed_frames_to(p,
  739|   293k|            dest_size - rendered_frames, rendered_frames, dest);
  740|   293k|    } while (rendered_frames < dest_size
  ------------------
  |  Branch (740:14): [True: 146k, False: 146k]
  ------------------
  741|   146k|             && run_one_wsola_iteration(p, playback_rate));
  ------------------
  |  Branch (741:17): [True: 146k, False: 0]
  ------------------
  742|   146k|    return rendered_frames;
  743|   146k|}
mp_scaletempo2_get_latency:
  746|   200k|{
  747|   200k|    return p->input_buffer_frames - p->output_time
  748|   200k|        - p->input_buffer_added_silence
  749|   200k|        + p->num_complete_frames * playback_rate;
  750|   200k|}
mp_scaletempo2_frames_available:
  753|  1.04M|{
  754|  1.04M|    return (p->input_buffer_final_frames > p->target_block_index &&
  ------------------
  |  Branch (754:13): [True: 11.9k, False: 1.03M]
  ------------------
  755|  11.9k|            p->input_buffer_final_frames > 0)
  ------------------
  |  Branch (755:13): [True: 11.9k, False: 0]
  ------------------
  756|  1.03M|        || can_perform_wsola(p, playback_rate)
  ------------------
  |  Branch (756:12): [True: 583k, False: 453k]
  ------------------
  757|   453k|        || p->num_complete_frames > 0;
  ------------------
  |  Branch (757:12): [True: 0, False: 453k]
  ------------------
  758|  1.04M|}
mp_scaletempo2_reset:
  761|  1.35M|{
  762|  1.35M|    p->input_buffer_frames = 0;
  763|  1.35M|    p->input_buffer_final_frames = 0;
  764|  1.35M|    p->input_buffer_added_silence = 0;
  765|  1.35M|    p->output_time = 0.0;
  766|  1.35M|    p->search_block_index = 0;
  767|  1.35M|    p->target_block_index = 0;
  768|  1.35M|    p->num_complete_frames = 0;
  769|       |    p->wsola_output_started = false;
  770|  1.35M|}
mp_scaletempo2_init:
  783|  3.67k|{
  784|  3.67k|    p->muted_partial_frame = 0;
  785|  3.67k|    p->output_time = 0;
  786|  3.67k|    p->search_block_index = 0;
  787|  3.67k|    p->target_block_index = 0;
  788|  3.67k|    p->num_complete_frames = 0;
  789|  3.67k|    p->wsola_output_started = false;
  790|  3.67k|    p->channels = channels;
  791|       |
  792|  3.67k|    p->samples_per_second = rate;
  793|  3.67k|    p->num_candidate_blocks = (int)(p->opts->wsola_search_interval_ms
  794|  3.67k|        * p->samples_per_second / 1000);
  795|  3.67k|    p->ola_window_size = (int)(p->opts->ola_window_size_ms
  796|  3.67k|        * p->samples_per_second / 1000);
  797|       |    // Make sure window size in an even number.
  798|  3.67k|    p->ola_window_size += p->ola_window_size & 1;
  799|  3.67k|    p->ola_hop_size = p->ola_window_size / 2;
  800|       |    // |num_candidate_blocks| / 2 is the offset of the center of the search
  801|       |    // block to the center of the first (left most) candidate block. The offset
  802|       |    // of the center of a candidate block to its left most point is
  803|       |    // |ola_window_size| / 2 - 1. Note that |ola_window_size| is even and in
  804|       |    // our convention the center belongs to the left half, so we need to subtract
  805|       |    // one frame to get the correct offset.
  806|       |    //
  807|       |    //                             Search Block
  808|       |    //              <------------------------------------------->
  809|       |    //
  810|       |    //   |ola_window_size| / 2 - 1
  811|       |    //              <----
  812|       |    //
  813|       |    //             |num_candidate_blocks| / 2
  814|       |    //                   <----------------
  815|       |    //                                 center
  816|       |    //              X----X----------------X---------------X-----X
  817|       |    //              <---------->                     <---------->
  818|       |    //                Candidate      ...               Candidate
  819|       |    //                   1,          ...         |num_candidate_blocks|
  820|  3.67k|    p->search_block_center_offset = p->num_candidate_blocks / 2
  821|  3.67k|        + (p->ola_window_size / 2 - 1);
  822|  3.67k|    MP_RESIZE_ARRAY(p, p->ola_window, p->ola_window_size);
  ------------------
  |  |   88|  3.67k|    do {                                                        \
  |  |   89|  3.67k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  3.67k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.67k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  3.67k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  3.67k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  3.67k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  3.67k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 3.67k]
  |  |  ------------------
  ------------------
  823|  3.67k|    get_symmetric_hanning_window(p->ola_window_size, p->ola_window);
  824|  3.67k|    MP_RESIZE_ARRAY(p, p->transition_window, p->ola_window_size * 2);
  ------------------
  |  |   88|  3.67k|    do {                                                        \
  |  |   89|  3.67k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  3.67k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.67k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  3.67k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  3.67k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  3.67k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  3.67k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 3.67k]
  |  |  ------------------
  ------------------
  825|  3.67k|    get_symmetric_hanning_window(2 * p->ola_window_size, p->transition_window);
  826|       |
  827|  3.67k|    p->wsola_output_size = p->ola_window_size + p->ola_hop_size;
  828|  3.67k|    alloc_sample_buffer(p, &p->wsola_output, p->wsola_output_size);
  829|       |
  830|       |    // Auxiliary containers.
  831|  3.67k|    alloc_sample_buffer(p, &p->optimal_block, p->ola_window_size);
  832|  3.67k|    p->search_block_size = p->num_candidate_blocks + (p->ola_window_size - 1);
  833|  3.67k|    alloc_sample_buffer(p, &p->search_block, p->search_block_size);
  834|  3.67k|    alloc_sample_buffer(p, &p->target_block, p->ola_window_size);
  835|       |
  836|  3.67k|    p->input_buffer_frames = 0;
  837|  3.67k|    p->input_buffer_final_frames = 0;
  838|  3.67k|    p->input_buffer_added_silence = 0;
  839|  3.67k|    size_t initial_size = 4 * MPMAX(p->ola_window_size, p->search_block_size);
  ------------------
  |  |   44|  3.67k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 3.67k]
  |  |  ------------------
  ------------------
  840|  3.67k|    alloc_sample_buffer(p, &p->input_buffer, initial_size);
  841|       |
  842|  3.67k|    MP_RESIZE_ARRAY(p, p->energy_candidate_blocks,
  ------------------
  |  |   88|  3.67k|    do {                                                        \
  |  |   89|  3.67k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  3.67k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.67k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  3.67k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  3.67k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  3.67k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  3.67k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 3.67k]
  |  |  ------------------
  ------------------
  843|  3.67k|        p->channels * p->num_candidate_blocks);
  844|  3.67k|}
af_scaletempo2_internals.c:frames_needed:
  466|  1.46M|{
  467|  1.46M|    int search_block_index =
  468|  1.46M|        get_search_block_index(p, get_updated_time(p, playback_rate));
  469|  1.46M|    return MPMAX(0, MPMAX(
  ------------------
  |  |   44|  2.93M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 12.4k, False: 1.45M]
  |  |  |  Branch (44:29): [True: 114k, False: 1.35M]
  |  |  |  Branch (44:41): [True: 114k, False: 1.34M]
  |  |  ------------------
  ------------------
  470|  1.46M|        p->target_block_index + p->ola_window_size - p->input_buffer_frames,
  471|  1.46M|        search_block_index + p->search_block_size - p->input_buffer_frames));
  472|  1.46M|}
af_scaletempo2_internals.c:get_search_block_index:
  460|  1.61M|{
  461|  1.61M|    return (int)(output_time - p->search_block_center_offset + 0.5);
  462|  1.61M|}
af_scaletempo2_internals.c:get_updated_time:
  454|  1.61M|{
  455|  1.61M|    return p->output_time + p->ola_hop_size * playback_rate;
  456|  1.61M|}
af_scaletempo2_internals.c:add_input_buffer_final_silence:
  481|  5.05k|{
  482|  5.05k|    int needed = frames_needed(p, playback_rate);
  483|  5.05k|    if (needed <= 0)
  ------------------
  |  Branch (483:9): [True: 51, False: 5.00k]
  ------------------
  484|     51|        return; // no silence needed for iteration
  485|       |
  486|  5.00k|    int last_index = needed + p->input_buffer_frames - 1;
  487|  16.3k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (487:21): [True: 11.3k, False: 5.00k]
  ------------------
  488|  11.3k|        MP_TARRAY_GROW(p, p->input_buffer[i], last_index);
  ------------------
  |  |   96|  11.3k|    do {                                            \
  |  |   97|  11.3k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  11.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  11.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  11.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 59, False: 11.3k]
  |  |  ------------------
  |  |   99|  11.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|     59|    do {                                                        \
  |  |  |  |   89|     59|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|     59|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     59|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     59|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     59|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|     59|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|     59|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  11.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 11.3k]
  |  |  ------------------
  ------------------
  489|  11.3k|        float *ch_input = p->input_buffer[i];
  490|  10.0M|        for (int j = 0; j < needed; ++j) {
  ------------------
  |  Branch (490:25): [True: 10.0M, False: 11.3k]
  ------------------
  491|  10.0M|            ch_input[p->input_buffer_frames + j] = 0.0f;
  492|  10.0M|        }
  493|  11.3k|    }
  494|       |
  495|  5.00k|    p->input_buffer_added_silence += needed;
  496|  5.00k|    p->input_buffer_frames += needed;
  497|  5.00k|}
af_scaletempo2_internals.c:zero_2d_partial:
   56|  55.0k|{
   57|   157k|    for (int i = 0; i < x; ++i) {
  ------------------
  |  Branch (57:21): [True: 101k, False: 55.0k]
  ------------------
   58|   101k|        memset(a[i], 0, sizeof(float) * y);
   59|   101k|    }
   60|  55.0k|}
af_scaletempo2_internals.c:seek_buffer:
  417|   192k|{
  418|   192k|    mp_assert(p->input_buffer_frames >= frames);
  ------------------
  |  |   41|   192k|#define mp_assert assert
  ------------------
  |  Branch (418:5): [True: 192k, False: 0]
  ------------------
  419|   192k|    p->input_buffer_frames -= frames;
  420|   192k|    if (p->input_buffer_final_frames > 0) {
  ------------------
  |  Branch (420:9): [True: 4.95k, False: 187k]
  ------------------
  421|  4.95k|        p->input_buffer_final_frames = MPMAX(0, p->input_buffer_final_frames - frames);
  ------------------
  |  |   44|  4.95k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.07k, False: 3.87k]
  |  |  ------------------
  ------------------
  422|  4.95k|    }
  423|   565k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (423:21): [True: 372k, False: 192k]
  ------------------
  424|   372k|        memmove(p->input_buffer[i], p->input_buffer[i] + frames,
  425|   372k|            p->input_buffer_frames * sizeof(float));
  426|   372k|    }
  427|   192k|}
af_scaletempo2_internals.c:set_output_time:
  613|   146k|{
  614|   146k|    p->output_time = output_time;
  615|   146k|    p->search_block_index = get_search_block_index(p, output_time);
  616|   146k|}
af_scaletempo2_internals.c:remove_old_input_frames:
  619|   146k|{
  620|   146k|    const int earliest_used_index = MPMIN(
  ------------------
  |  |   45|   146k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 129k, False: 17.1k]
  |  |  ------------------
  ------------------
  621|   146k|        p->target_block_index, p->search_block_index);
  622|   146k|    if (earliest_used_index <= 0)
  ------------------
  |  Branch (622:9): [True: 8.30k, False: 138k]
  ------------------
  623|  8.30k|        return;  // Nothing to remove.
  624|       |
  625|       |    // Remove frames from input and adjust indices accordingly.
  626|   138k|    seek_buffer(p, earliest_used_index);
  627|   138k|    p->target_block_index -= earliest_used_index;
  628|   138k|    p->output_time -= earliest_used_index;
  629|   138k|    p->search_block_index -= earliest_used_index;
  630|   138k|}
af_scaletempo2_internals.c:peek_buffer:
  407|   205k|{
  408|   205k|    mp_assert(p->input_buffer_frames >= frames);
  ------------------
  |  |   41|   205k|#define mp_assert assert
  ------------------
  |  Branch (408:5): [True: 205k, False: 0]
  ------------------
  409|   679k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (409:21): [True: 473k, False: 205k]
  ------------------
  410|   473k|        memcpy(dest[i] + write_offset,
  411|   473k|            p->input_buffer[i] + read_offset,
  412|   473k|            frames * sizeof(float));
  413|   473k|    }
  414|   205k|}
af_scaletempo2_internals.c:write_completed_frames_to:
  431|   293k|{
  432|   293k|    int rendered_frames = MPMIN(p->num_complete_frames, requested_frames);
  ------------------
  |  |   45|   293k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 293k]
  |  |  ------------------
  ------------------
  433|       |
  434|   293k|    if (rendered_frames == 0)
  ------------------
  |  Branch (434:9): [True: 146k, False: 146k]
  ------------------
  435|   146k|        return 0;  // There is nothing to read from |wsola_output|, return.
  436|       |
  437|   436k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (437:21): [True: 290k, False: 146k]
  ------------------
  438|   290k|        memcpy(dest[i] + dest_offset, p->wsola_output[i],
  439|   290k|            rendered_frames * sizeof(float));
  440|   290k|    }
  441|       |
  442|       |    // Remove the frames which are read.
  443|   146k|    int frames_to_move = p->wsola_output_size - rendered_frames;
  444|   436k|    for (int k = 0; k < p->channels; ++k) {
  ------------------
  |  Branch (444:21): [True: 290k, False: 146k]
  ------------------
  445|   290k|        float *ch = p->wsola_output[k];
  446|   290k|        memmove(ch, &ch[rendered_frames], sizeof(*ch) * frames_to_move);
  447|   290k|    }
  448|   146k|    p->num_complete_frames -= rendered_frames;
  449|   146k|    return rendered_frames;
  450|   293k|}
af_scaletempo2_internals.c:run_one_wsola_iteration:
  633|   146k|{
  634|   146k|    if (!can_perform_wsola(p, playback_rate)) {
  ------------------
  |  Branch (634:9): [True: 0, False: 146k]
  ------------------
  635|      0|        return false;
  636|      0|    }
  637|       |
  638|   146k|    set_output_time(p, get_updated_time(p, playback_rate));
  639|   146k|    remove_old_input_frames(p);
  640|       |
  641|   146k|    mp_assert(p->search_block_index + p->search_block_size <= p->input_buffer_frames);
  ------------------
  |  |   41|   146k|#define mp_assert assert
  ------------------
  |  Branch (641:5): [True: 146k, False: 0]
  ------------------
  642|       |
  643|   146k|    get_optimal_block(p);
  644|       |
  645|       |    // Overlap-and-add.
  646|   436k|    for (int k = 0; k < p->channels; ++k) {
  ------------------
  |  Branch (646:21): [True: 290k, False: 146k]
  ------------------
  647|   290k|        float* ch_opt_frame = p->optimal_block[k];
  648|   290k|        float* ch_output = p->wsola_output[k] + p->num_complete_frames;
  649|   290k|        if (p->wsola_output_started) {
  ------------------
  |  Branch (649:13): [True: 284k, False: 5.65k]
  ------------------
  650|  75.6M|            for (int n = 0; n < p->ola_hop_size; ++n) {
  ------------------
  |  Branch (650:29): [True: 75.4M, False: 284k]
  ------------------
  651|  75.4M|                ch_output[n] = ch_output[n] * p->ola_window[p->ola_hop_size + n] +
  652|  75.4M|                    ch_opt_frame[n] * p->ola_window[n];
  653|  75.4M|            }
  654|       |
  655|       |            // Copy the second half to the output.
  656|   284k|            memcpy(&ch_output[p->ola_hop_size], &ch_opt_frame[p->ola_hop_size],
  657|   284k|                   sizeof(*ch_opt_frame) * p->ola_hop_size);
  658|   284k|        } else {
  659|       |            // No overlap for the first iteration.
  660|  5.65k|            memcpy(ch_output, ch_opt_frame,
  661|  5.65k|                   sizeof(*ch_opt_frame) * p->ola_window_size);
  662|  5.65k|        }
  663|   290k|    }
  664|       |
  665|   146k|    p->num_complete_frames += p->ola_hop_size;
  666|   146k|    p->wsola_output_started = true;
  667|       |    return true;
  668|   146k|}
af_scaletempo2_internals.c:get_optimal_block:
  552|   146k|{
  553|   146k|    int optimal_index = 0;
  554|       |
  555|       |    // An interval around last optimal block which is excluded from the search.
  556|       |    // This is to reduce the buzzy sound. The number 160 is rather arbitrary and
  557|       |    // derived heuristically.
  558|   146k|    const int exclude_interval_length_frames = 160;
  559|   146k|    if (target_is_within_search_region(p)) {
  ------------------
  |  Branch (559:9): [True: 117k, False: 29.3k]
  ------------------
  560|   117k|        optimal_index = p->target_block_index;
  561|   117k|        peek_audio_with_zero_prepend(p,
  562|   117k|            optimal_index, p->optimal_block, p->ola_window_size);
  563|   117k|    } else {
  564|  29.3k|        peek_audio_with_zero_prepend(p,
  565|  29.3k|            p->target_block_index, p->target_block, p->ola_window_size);
  566|  29.3k|        peek_audio_with_zero_prepend(p,
  567|  29.3k|            p->search_block_index, p->search_block, p->search_block_size);
  568|  29.3k|        int last_optimal = p->target_block_index
  569|  29.3k|            - p->ola_hop_size - p->search_block_index;
  570|  29.3k|        struct interval exclude_iterval = {
  571|  29.3k|            .lo = last_optimal - exclude_interval_length_frames / 2,
  572|  29.3k|            .hi = last_optimal + exclude_interval_length_frames / 2
  573|  29.3k|        };
  574|       |
  575|       |        // |optimal_index| is in frames and it is relative to the beginning of the
  576|       |        // |search_block|.
  577|  29.3k|        optimal_index = compute_optimal_index(
  578|  29.3k|            p->search_block, p->search_block_size,
  579|  29.3k|            p->target_block, p->ola_window_size,
  580|  29.3k|            p->energy_candidate_blocks,
  581|  29.3k|            p->channels,
  582|  29.3k|            exclude_iterval);
  583|       |
  584|       |        // Translate |index| w.r.t. the beginning of |audio_buffer| and extract the
  585|       |        // optimal block.
  586|  29.3k|        optimal_index += p->search_block_index;
  587|  29.3k|        peek_audio_with_zero_prepend(p,
  588|  29.3k|            optimal_index, p->optimal_block, p->ola_window_size);
  589|       |
  590|       |        // Make a transition from target block to the optimal block if different.
  591|       |        // Target block has the best continuation to the current output.
  592|       |        // Optimal block is the most similar block to the target, however, it might
  593|       |        // introduce some discontinuity when over-lap-added. Therefore, we combine
  594|       |        // them for a smoother transition. The length of transition window is twice
  595|       |        // as that of the optimal-block which makes it like a weighting function
  596|       |        // where target-block has higher weight close to zero (weight of 1 at index
  597|       |        // 0) and lower weight close the end.
  598|   121k|        for (int k = 0; k < p->channels; ++k) {
  ------------------
  |  Branch (598:25): [True: 91.8k, False: 29.3k]
  ------------------
  599|  91.8k|            float* ch_opt = p->optimal_block[k];
  600|  91.8k|            float* ch_target = p->target_block[k];
  601|  48.6M|            for (int n = 0; n < p->ola_window_size; ++n) {
  ------------------
  |  Branch (601:29): [True: 48.5M, False: 91.8k]
  ------------------
  602|  48.5M|                ch_opt[n] = ch_opt[n] * p->transition_window[n]
  603|  48.5M|                    + ch_target[n] * p->transition_window[p->ola_window_size + n];
  604|  48.5M|            }
  605|  91.8k|        }
  606|  29.3k|    }
  607|       |
  608|       |    // Next target is one hop ahead of the current optimal.
  609|   146k|    p->target_block_index = optimal_index + p->ola_hop_size;
  610|   146k|}
af_scaletempo2_internals.c:target_is_within_search_region:
  526|   146k|{
  527|   146k|    return p->target_block_index >= p->search_block_index
  ------------------
  |  Branch (527:12): [True: 129k, False: 17.1k]
  ------------------
  528|   129k|        && p->target_block_index + p->ola_window_size
  ------------------
  |  Branch (528:12): [True: 117k, False: 12.2k]
  ------------------
  529|   129k|            <= p->search_block_index + p->search_block_size;
  530|   146k|}
af_scaletempo2_internals.c:peek_audio_with_zero_prepend:
  535|   205k|{
  536|   205k|    mp_assert(read_offset_frames + dest_frames <= p->input_buffer_frames);
  ------------------
  |  |   41|   205k|#define mp_assert assert
  ------------------
  |  Branch (536:5): [True: 205k, False: 0]
  ------------------
  537|       |
  538|   205k|    int write_offset = 0;
  539|   205k|    int num_frames_to_read = dest_frames;
  540|   205k|    if (read_offset_frames < 0) {
  ------------------
  |  Branch (540:9): [True: 807, False: 204k]
  ------------------
  541|    807|        int num_zero_frames_appended = MPMIN(
  ------------------
  |  |   45|    807|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 807]
  |  |  ------------------
  ------------------
  542|    807|            -read_offset_frames, num_frames_to_read);
  543|    807|        read_offset_frames = 0;
  544|    807|        num_frames_to_read -= num_zero_frames_appended;
  545|    807|        write_offset = num_zero_frames_appended;
  546|    807|        zero_2d_partial(dest, p->channels, num_zero_frames_appended);
  547|    807|    }
  548|   205k|    peek_buffer(p, num_frames_to_read, read_offset_frames, write_offset, dest);
  549|   205k|}
af_scaletempo2_internals.c:compute_optimal_index:
  356|  29.3k|{
  357|  29.3k|    int num_candidate_blocks = search_block_frames - (target_block_frames - 1);
  358|       |
  359|       |    // This is a compromise between complexity reduction and search accuracy. I
  360|       |    // don't have a proof that down sample of order 5 is optimal.
  361|       |    // One can compute a decimation factor that minimizes complexity given
  362|       |    // the size of |search_block| and |target_block|. However, my experiments
  363|       |    // show the rate of missing the optimal index is significant.
  364|       |    // This value is chosen heuristically based on experiments.
  365|  29.3k|    const int search_decimation = 5;
  366|       |
  367|  29.3k|    float energy_target_block [MP_NUM_CHANNELS];
  368|       |    // energy_candidate_blocks must have at least size
  369|       |    // sizeof(float) * channels * num_candidate_blocks
  370|       |
  371|       |    // Energy of all candid frames.
  372|  29.3k|    multi_channel_moving_block_energies(
  373|  29.3k|        search_block,
  374|  29.3k|        search_block_frames,
  375|  29.3k|        channels,
  376|  29.3k|        target_block_frames,
  377|  29.3k|        energy_candidate_blocks);
  378|       |
  379|       |    // Energy of target frame.
  380|  29.3k|    multi_channel_dot_product(
  381|  29.3k|        target_block, 0,
  382|  29.3k|        target_block, 0,
  383|  29.3k|        channels,
  384|  29.3k|        target_block_frames, energy_target_block);
  385|       |
  386|  29.3k|    int optimal_index = decimated_search(
  387|  29.3k|        search_decimation, exclude_interval,
  388|  29.3k|        target_block, target_block_frames,
  389|  29.3k|        search_block, search_block_frames,
  390|  29.3k|        channels,
  391|  29.3k|        energy_target_block,
  392|  29.3k|        energy_candidate_blocks);
  393|       |
  394|  29.3k|    int lim_low = MPMAX(0, optimal_index - search_decimation);
  ------------------
  |  |   44|  29.3k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 286, False: 29.0k]
  |  |  ------------------
  ------------------
  395|  29.3k|    int lim_high = MPMIN(num_candidate_blocks - 1,
  ------------------
  |  |   45|  29.3k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 29.3k, False: 21]
  |  |  ------------------
  ------------------
  396|  29.3k|                            optimal_index + search_decimation);
  397|  29.3k|    return full_search(
  398|  29.3k|        lim_low, lim_high, exclude_interval,
  399|  29.3k|        target_block, target_block_frames,
  400|  29.3k|        search_block, search_block_frames,
  401|  29.3k|        channels,
  402|  29.3k|        energy_target_block, energy_candidate_blocks);
  403|  29.3k|}
af_scaletempo2_internals.c:multi_channel_moving_block_energies:
   69|  29.3k|{
   70|  29.3k|    int num_blocks = input_frames - (frames_per_block - 1);
   71|       |
   72|   121k|    for (int k = 0; k < channels; ++k) {
  ------------------
  |  Branch (72:21): [True: 91.8k, False: 29.3k]
  ------------------
   73|  91.8k|        const float* input_channel = input[k];
   74|       |
   75|  91.8k|        energy[k] = 0;
   76|       |
   77|       |        // First block of channel |k|.
   78|  48.6M|        for (int m = 0; m < frames_per_block; ++m) {
  ------------------
  |  Branch (78:25): [True: 48.5M, False: 91.8k]
  ------------------
   79|  48.5M|            energy[k] += input_channel[m] * input_channel[m];
   80|  48.5M|        }
   81|       |
   82|  91.8k|        const float* slide_out = input_channel;
   83|  91.8k|        const float* slide_in = input_channel + frames_per_block;
   84|   161M|        for (int n = 1; n < num_blocks; ++n, ++slide_in, ++slide_out) {
  ------------------
  |  Branch (84:25): [True: 161M, False: 91.8k]
  ------------------
   85|   161M|            energy[k + n * channels] = energy[k + (n - 1) * channels]
   86|   161M|                - *slide_out * *slide_out + *slide_in * *slide_in;
   87|   161M|        }
   88|  91.8k|    }
   89|  29.3k|}
af_scaletempo2_internals.c:multi_channel_dot_product:
  117|  10.6M|{
  118|  10.6M|    mp_assert(frame_offset_a >= 0);
  ------------------
  |  |   41|  10.6M|#define mp_assert assert
  ------------------
  |  Branch (118:5): [True: 10.6M, False: 0]
  ------------------
  119|  10.6M|    mp_assert(frame_offset_b >= 0);
  ------------------
  |  |   41|  10.6M|#define mp_assert assert
  ------------------
  |  Branch (119:5): [True: 10.6M, False: 0]
  ------------------
  120|       |
  121|  44.1M|    for (int k = 0; k < channels; ++k) {
  ------------------
  |  Branch (121:21): [True: 33.4M, False: 10.6M]
  ------------------
  122|  33.4M|        const float* ch_a = a[k] + frame_offset_a;
  123|  33.4M|        const float* ch_b = b[k] + frame_offset_b;
  124|  33.4M|        float sum = 0.0;
  125|  33.4M|        if (num_frames < 32)
  ------------------
  |  Branch (125:13): [True: 3.38k, False: 33.4M]
  ------------------
  126|  3.38k|            goto rest;
  127|       |
  128|  33.4M|        const v8sf *va = (const v8sf *) ch_a;
  129|  33.4M|        const v8sf *vb = (const v8sf *) ch_b;
  130|  33.4M|        v8sf vsum[4] = {
  131|       |            // Initialize to product of first 32 floats
  132|  33.4M|            va[0] * vb[0],
  133|  33.4M|            va[1] * vb[1],
  134|  33.4M|            va[2] * vb[2],
  135|  33.4M|            va[3] * vb[3],
  136|  33.4M|        };
  137|  33.4M|        va += 4;
  138|  33.4M|        vb += 4;
  139|       |
  140|       |        // Process `va` and `vb` across four vertical stripes
  141|   536M|        for (int n = 1; n < num_frames / 32; n++) {
  ------------------
  |  Branch (141:25): [True: 502M, False: 33.4M]
  ------------------
  142|   502M|            vsum[0] += va[0] * vb[0];
  143|   502M|            vsum[1] += va[1] * vb[1];
  144|   502M|            vsum[2] += va[2] * vb[2];
  145|   502M|            vsum[3] += va[3] * vb[3];
  146|   502M|            va += 4;
  147|   502M|            vb += 4;
  148|   502M|        }
  149|       |
  150|       |        // Vertical sum across `vsum` entries
  151|  33.4M|        vsum[0] += vsum[1];
  152|  33.4M|        vsum[2] += vsum[3];
  153|  33.4M|        vsum[0] += vsum[2];
  154|       |
  155|       |        // Horizontal sum across `vsum[0]`, could probably be done better but
  156|       |        // this section is not super performance critical
  157|  33.4M|        float *vf = (float *) &vsum[0];
  158|  33.4M|        sum = vf[0] + vf[1] + vf[2] + vf[3] + vf[4] + vf[5] + vf[6] + vf[7];
  159|  33.4M|        ch_a = (const float *) va;
  160|  33.4M|        ch_b = (const float *) vb;
  161|       |
  162|  33.4M|rest:
  163|       |        // Process the remainder
  164|   635M|        for (int n = 0; n < num_frames % 32; n++)
  ------------------
  |  Branch (164:25): [True: 602M, False: 33.4M]
  ------------------
  165|   602M|            sum += *ch_a++ * *ch_b++;
  166|       |
  167|  33.4M|        dot_product[k] = sum;
  168|  33.4M|    }
  169|  10.6M|}
af_scaletempo2_internals.c:decimated_search:
  226|  29.3k|{
  227|  29.3k|    int num_candidate_blocks = search_segment_frames - (target_block_frames - 1);
  228|  29.3k|    float dot_prod [MP_NUM_CHANNELS];
  229|  29.3k|    float similarity[3];  // Three elements for cubic interpolation.
  230|       |
  231|  29.3k|    int n = 0;
  232|  29.3k|    multi_channel_dot_product(
  233|  29.3k|        target_block, 0,
  234|  29.3k|        search_segment, n,
  235|  29.3k|        channels,
  236|  29.3k|        target_block_frames, dot_prod);
  237|  29.3k|    similarity[0] = multi_channel_similarity_measure(
  238|  29.3k|        dot_prod, energy_target_block,
  239|  29.3k|        &energy_candidate_blocks[n * channels], channels);
  240|       |
  241|       |    // Set the starting point as optimal point.
  242|  29.3k|    float best_similarity = similarity[0];
  243|  29.3k|    int optimal_index = 0;
  244|       |
  245|  29.3k|    n += decimation;
  246|  29.3k|    if (n >= num_candidate_blocks) {
  ------------------
  |  Branch (246:9): [True: 0, False: 29.3k]
  ------------------
  247|      0|        return 0;
  248|      0|    }
  249|       |
  250|  29.3k|    multi_channel_dot_product(
  251|  29.3k|        target_block, 0,
  252|  29.3k|        search_segment, n,
  253|  29.3k|        channels,
  254|  29.3k|        target_block_frames, dot_prod);
  255|  29.3k|    similarity[1] = multi_channel_similarity_measure(
  256|  29.3k|        dot_prod, energy_target_block,
  257|  29.3k|        &energy_candidate_blocks[n * channels], channels);
  258|       |
  259|  29.3k|    n += decimation;
  260|  29.3k|    if (n >= num_candidate_blocks) {
  ------------------
  |  Branch (260:9): [True: 0, False: 29.3k]
  ------------------
  261|       |        // We cannot do any more sampling. Compare these two values and return the
  262|       |        // optimal index.
  263|      0|        return similarity[1] > similarity[0] ? decimation : 0;
  ------------------
  |  Branch (263:16): [True: 0, False: 0]
  ------------------
  264|      0|    }
  265|       |
  266|  10.2M|    for (; n < num_candidate_blocks; n += decimation) {
  ------------------
  |  Branch (266:12): [True: 10.2M, False: 29.3k]
  ------------------
  267|  10.2M|        multi_channel_dot_product(
  268|  10.2M|            target_block, 0,
  269|  10.2M|            search_segment, n,
  270|  10.2M|            channels,
  271|  10.2M|            target_block_frames, dot_prod);
  272|       |
  273|  10.2M|        similarity[2] = multi_channel_similarity_measure(
  274|  10.2M|            dot_prod, energy_target_block,
  275|  10.2M|            &energy_candidate_blocks[n * channels], channels);
  276|       |
  277|  10.2M|        if ((similarity[1] > similarity[0] && similarity[1] >= similarity[2]) ||
  ------------------
  |  Branch (277:14): [True: 5.09M, False: 5.15M]
  |  Branch (277:47): [True: 507k, False: 4.59M]
  ------------------
  278|  9.75M|            (similarity[1] >= similarity[0] && similarity[1] > similarity[2]))
  ------------------
  |  Branch (278:14): [True: 4.64M, False: 5.10M]
  |  Branch (278:48): [True: 159, False: 4.64M]
  ------------------
  279|   507k|        {
  280|       |            // A local maximum is found. Do a cubic interpolation for a better
  281|       |            // estimate of candidate maximum.
  282|   507k|            float normalized_candidate_index;
  283|   507k|            float candidate_similarity;
  284|   507k|            quadratic_interpolation(similarity, &normalized_candidate_index,
  285|   507k|                                    &candidate_similarity);
  286|       |
  287|   507k|            int candidate_index = n - decimation
  288|   507k|                 + (int)(normalized_candidate_index * decimation +  0.5f);
  289|   507k|            if (candidate_similarity > best_similarity
  ------------------
  |  Branch (289:17): [True: 177k, False: 330k]
  ------------------
  290|   177k|                && !in_interval(candidate_index, exclude_interval)) {
  ------------------
  |  Branch (290:20): [True: 171k, False: 5.79k]
  ------------------
  291|   171k|                optimal_index = candidate_index;
  292|   171k|                best_similarity = candidate_similarity;
  293|   171k|            }
  294|  9.75M|        } else if (n + decimation >= num_candidate_blocks &&
  ------------------
  |  Branch (294:20): [True: 28.1k, False: 9.72M]
  ------------------
  295|  28.1k|                   similarity[2] > best_similarity &&
  ------------------
  |  Branch (295:20): [True: 34, False: 28.0k]
  ------------------
  296|     34|                   !in_interval(n, exclude_interval))
  ------------------
  |  Branch (296:20): [True: 21, False: 13]
  ------------------
  297|     21|        {
  298|       |            // If this is the end-point and has a better similarity-measure than
  299|       |            // optimal, then we accept it as optimal point.
  300|     21|            optimal_index = n;
  301|     21|            best_similarity = similarity[2];
  302|     21|        }
  303|  10.2M|        memmove(similarity, &similarity[1], 2 * sizeof(*similarity));
  304|  10.2M|    }
  305|  29.3k|    return optimal_index;
  306|  29.3k|}
af_scaletempo2_internals.c:multi_channel_similarity_measure:
   95|  10.6M|{
   96|  10.6M|    const float epsilon = 1e-12f;
   97|  10.6M|    float similarity_measure = 0.0f;
   98|  44.0M|    for (int n = 0; n < channels; ++n) {
  ------------------
  |  Branch (98:21): [True: 33.3M, False: 10.6M]
  ------------------
   99|  33.3M|        similarity_measure += dot_prod[n] * energy_target[n]
  100|  33.3M|            / sqrtf(energy_target[n] * energy_candidate[n] + epsilon);
  101|  33.3M|    }
  102|  10.6M|    return similarity_measure;
  103|  10.6M|}
af_scaletempo2_internals.c:quadratic_interpolation:
  201|   507k|{
  202|   507k|    float a = 0.5f * (y_values[2] + y_values[0]) - y_values[1];
  203|   507k|    float b = 0.5f * (y_values[2] - y_values[0]);
  204|   507k|    float c = y_values[1];
  205|       |
  206|   507k|    if (a == 0.f) {
  ------------------
  |  Branch (206:9): [True: 0, False: 507k]
  ------------------
  207|       |        // The coordinates are colinear (within floating-point error).
  208|      0|        *extremum = 0;
  209|      0|        *extremum_value = y_values[1];
  210|   507k|    } else {
  211|   507k|        *extremum = -b / (2.f * a);
  212|   507k|        *extremum_value = a * (*extremum) * (*extremum) + b * (*extremum) + c;
  213|   507k|    }
  214|   507k|}
af_scaletempo2_internals.c:in_interval:
   40|   498k|{
   41|   498k|    return n >= q.lo && n <= q.hi;
  ------------------
  |  Branch (41:12): [True: 311k, False: 187k]
  |  Branch (41:25): [True: 7.37k, False: 303k]
  ------------------
   42|   498k|}
af_scaletempo2_internals.c:full_search:
  320|  29.3k|{
  321|       |    // int block_size = target_block->frames;
  322|  29.3k|    float dot_prod [sizeof(float) * MP_NUM_CHANNELS];
  323|       |
  324|  29.3k|    float best_similarity = -FLT_MAX;//FLT_MIN;
  325|  29.3k|    int optimal_index = 0;
  326|       |
  327|   351k|    for (int n = low_limit; n <= high_limit; ++n) {
  ------------------
  |  Branch (327:29): [True: 321k, False: 29.3k]
  ------------------
  328|   321k|        if (in_interval(n, exclude_interval)) {
  ------------------
  |  Branch (328:13): [True: 1.56k, False: 320k]
  ------------------
  329|  1.56k|            continue;
  330|  1.56k|        }
  331|   320k|        multi_channel_dot_product(target_block, 0, search_block, n, channels,
  332|   320k|            target_block_frames, dot_prod);
  333|       |
  334|   320k|        float similarity = multi_channel_similarity_measure(
  335|   320k|            dot_prod, energy_target_block,
  336|   320k|            &energy_candidate_blocks[n * channels], channels);
  337|       |
  338|   320k|        if (similarity > best_similarity) {
  ------------------
  |  Branch (338:13): [True: 163k, False: 156k]
  ------------------
  339|   163k|            best_similarity = similarity;
  340|   163k|            optimal_index = n;
  341|   163k|        }
  342|   320k|    }
  343|       |
  344|  29.3k|    return optimal_index;
  345|  29.3k|}
af_scaletempo2_internals.c:can_perform_wsola:
  475|  1.18M|{
  476|  1.18M|    return frames_needed(p, playback_rate) <= 0;
  477|  1.18M|}
af_scaletempo2_internals.c:get_symmetric_hanning_window:
  775|  7.34k|{
  776|  7.34k|    const float scale = 2.0f * M_PI / window_length;
  777|  5.85M|    for (int n = 0; n < window_length; ++n)
  ------------------
  |  Branch (777:21): [True: 5.85M, False: 7.34k]
  ------------------
  778|  5.85M|        window[n] = 0.5f * (1.0f - cosf(n * scale));
  779|  7.34k|}
af_scaletempo2_internals.c:alloc_sample_buffer:
   45|  18.3k|{
   46|  18.3k|    talloc_free(*ptr);
  ------------------
  |  |   47|  18.3k|#define talloc_free                     ta_free
  ------------------
   47|       |
   48|  18.3k|    float **buff = talloc_array(p, float*, p->channels);
  ------------------
  |  |   29|  18.3k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  18.3k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  18.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   49|  55.1k|    for (int i = 0; i < p->channels; ++i) {
  ------------------
  |  Branch (49:21): [True: 36.8k, False: 18.3k]
  ------------------
   50|  36.8k|        buff[i] = talloc_array(buff, float, size);
  ------------------
  |  |   29|  36.8k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  36.8k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  36.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   51|  36.8k|    }
   52|  18.3k|    *ptr = buff;
   53|  18.3k|}

af_to_avformat:
   49|  14.5k|{
   50|  92.6k|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (50:21): [True: 92.6k, False: 0]
  ------------------
   51|  92.6k|        if (audio_conversion_map[i].fmt == fmt)
  ------------------
  |  Branch (51:13): [True: 14.5k, False: 78.1k]
  ------------------
   52|  14.5k|            return audio_conversion_map[i].sample_fmt;
   53|  92.6k|    }
   54|      0|    return AV_SAMPLE_FMT_NONE;
   55|  14.5k|}
af_from_avformat:
   58|   223k|{
   59|   446k|    for (int i = 0; audio_conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (59:21): [True: 446k, False: 0]
  ------------------
   60|   446k|        if (audio_conversion_map[i].sample_fmt == sample_fmt)
  ------------------
  |  Branch (60:13): [True: 223k, False: 223k]
  ------------------
   61|   223k|            return audio_conversion_map[i].fmt;
   62|   446k|    }
   63|      0|    return 0;
   64|   223k|}

af_fmt_to_bytes:
   27|  2.97M|{
   28|  2.97M|    switch (af_fmt_from_planar(format)) {
  ------------------
  |  Branch (28:13): [True: 2.97M, False: 18.4E]
  ------------------
   29|      0|    case AF_FORMAT_U8:      return 1;
  ------------------
  |  Branch (29:5): [True: 0, False: 2.97M]
  ------------------
   30|   755k|    case AF_FORMAT_S16:     return 2;
  ------------------
  |  Branch (30:5): [True: 755k, False: 2.21M]
  ------------------
   31|      0|    case AF_FORMAT_S32:     return 4;
  ------------------
  |  Branch (31:5): [True: 0, False: 2.97M]
  ------------------
   32|      0|    case AF_FORMAT_S64:     return 8;
  ------------------
  |  Branch (32:5): [True: 0, False: 2.97M]
  ------------------
   33|  2.21M|    case AF_FORMAT_FLOAT:   return 4;
  ------------------
  |  Branch (33:5): [True: 2.21M, False: 754k]
  ------------------
   34|      0|    case AF_FORMAT_DOUBLE:  return 8;
  ------------------
  |  Branch (34:5): [True: 0, False: 2.97M]
  ------------------
   35|  2.97M|    }
   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|   284k|{
   48|   284k|    return format == AF_FORMAT_U8 || format == AF_FORMAT_U8P;
  ------------------
  |  Branch (48:12): [True: 0, False: 284k]
  |  Branch (48:38): [True: 0, False: 284k]
  ------------------
   49|   284k|}
af_fmt_is_float:
   52|  7.48k|{
   53|  7.48k|    format = af_fmt_from_planar(format);
   54|  7.48k|    return format == AF_FORMAT_FLOAT || format == AF_FORMAT_DOUBLE;
  ------------------
  |  Branch (54:12): [True: 4.49k, False: 2.99k]
  |  Branch (54:41): [True: 0, False: 2.99k]
  ------------------
   55|  7.48k|}
af_fmt_is_spdif:
   66|   319k|{
   67|   319k|    return af_format_sample_alignment(format) > 1;
   68|   319k|}
af_fmt_is_pcm:
   71|   319k|{
   72|   319k|    return af_fmt_is_valid(format) && !af_fmt_is_spdif(format) &&
  ------------------
  |  Branch (72:12): [True: 319k, False: 0]
  |  Branch (72:39): [True: 319k, False: 0]
  ------------------
   73|   319k|           format != AF_FORMAT_S_DOP;
  ------------------
  |  Branch (73:12): [True: 319k, False: 0]
  ------------------
   74|   319k|}
af_fmt_is_planar:
   86|  6.25M|{
   87|  34.4M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  34.4M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (87:21): [True: 32.8M, False: 1.58M]
  ------------------
   88|  32.8M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (88:13): [True: 4.67M, False: 28.1M]
  ------------------
   89|  4.67M|            return true;
   90|  32.8M|    }
   91|  1.58M|    return false;
   92|  6.25M|}
af_fmt_from_planar:
  110|  3.21M|{
  111|  18.0M|    for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
  ------------------
  |  |   49|  18.0M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (111:21): [True: 17.0M, False: 981k]
  ------------------
  112|  17.0M|        if (planar_formats[n][0] == format)
  ------------------
  |  Branch (112:13): [True: 2.22M, False: 14.8M]
  ------------------
  113|  2.22M|            return planar_formats[n][1];
  114|  17.0M|    }
  115|   981k|    return format;
  116|  3.21M|}
af_fmt_is_valid:
  119|   319k|{
  120|   319k|    return format > 0 && format < AF_FORMAT_COUNT;
  ------------------
  |  Branch (120:12): [True: 319k, False: 0]
  |  Branch (120:26): [True: 319k, False: 0]
  ------------------
  121|   319k|}
af_fmt_to_str:
  124|   118k|{
  125|   118k|    switch (format) {
  ------------------
  |  Branch (125:13): [True: 118k, False: 0]
  ------------------
  126|    844|    case AF_FORMAT_U8:          return "u8";
  ------------------
  |  Branch (126:5): [True: 844, False: 117k]
  ------------------
  127|  89.8k|    case AF_FORMAT_S16:         return "s16";
  ------------------
  |  Branch (127:5): [True: 89.8k, False: 28.3k]
  ------------------
  128|    844|    case AF_FORMAT_S32:         return "s32";
  ------------------
  |  Branch (128:5): [True: 844, False: 117k]
  ------------------
  129|    844|    case AF_FORMAT_S64:         return "s64";
  ------------------
  |  Branch (129:5): [True: 844, False: 117k]
  ------------------
  130|    844|    case AF_FORMAT_FLOAT:       return "float";
  ------------------
  |  Branch (130:5): [True: 844, False: 117k]
  ------------------
  131|    844|    case AF_FORMAT_DOUBLE:      return "double";
  ------------------
  |  Branch (131:5): [True: 844, False: 117k]
  ------------------
  132|    844|    case AF_FORMAT_U8P:         return "u8p";
  ------------------
  |  Branch (132:5): [True: 844, False: 117k]
  ------------------
  133|    844|    case AF_FORMAT_S16P:        return "s16p";
  ------------------
  |  Branch (133:5): [True: 844, False: 117k]
  ------------------
  134|    844|    case AF_FORMAT_S32P:        return "s32p";
  ------------------
  |  Branch (134:5): [True: 844, False: 117k]
  ------------------
  135|    844|    case AF_FORMAT_S64P:        return "s64p";
  ------------------
  |  Branch (135:5): [True: 844, False: 117k]
  ------------------
  136|  12.3k|    case AF_FORMAT_FLOATP:      return "floatp";
  ------------------
  |  Branch (136:5): [True: 12.3k, False: 105k]
  ------------------
  137|    844|    case AF_FORMAT_DOUBLEP:     return "doublep";
  ------------------
  |  Branch (137:5): [True: 844, False: 117k]
  ------------------
  138|    844|    case AF_FORMAT_S_AAC:       return "spdif-aac";
  ------------------
  |  Branch (138:5): [True: 844, False: 117k]
  ------------------
  139|    844|    case AF_FORMAT_S_AC3:       return "spdif-ac3";
  ------------------
  |  Branch (139:5): [True: 844, False: 117k]
  ------------------
  140|    844|    case AF_FORMAT_S_DTS:       return "spdif-dts";
  ------------------
  |  Branch (140:5): [True: 844, False: 117k]
  ------------------
  141|    844|    case AF_FORMAT_S_DTSHD:     return "spdif-dtshd";
  ------------------
  |  Branch (141:5): [True: 844, False: 117k]
  ------------------
  142|    844|    case AF_FORMAT_S_EAC3:      return "spdif-eac3";
  ------------------
  |  Branch (142:5): [True: 844, False: 117k]
  ------------------
  143|    844|    case AF_FORMAT_S_MP3:       return "spdif-mp3";
  ------------------
  |  Branch (143:5): [True: 844, False: 117k]
  ------------------
  144|    844|    case AF_FORMAT_S_TRUEHD:    return "spdif-truehd";
  ------------------
  |  Branch (144:5): [True: 844, False: 117k]
  ------------------
  145|    844|    case AF_FORMAT_S_DOP:       return "dop";
  ------------------
  |  Branch (145:5): [True: 844, False: 117k]
  ------------------
  146|    844|    case AF_FORMAT_DSD:         return "dsd";
  ------------------
  |  Branch (146:5): [True: 844, False: 117k]
  ------------------
  147|   118k|    }
  148|      0|    return "??";
  149|   118k|}
af_fill_silence:
  152|   284k|{
  153|   284k|    int fill = 0;
  154|   284k|    if (af_fmt_is_unsigned(format))
  ------------------
  |  Branch (154:9): [True: 0, False: 284k]
  ------------------
  155|      0|        fill = 0x80;
  156|   284k|    if (format == AF_FORMAT_DSD)
  ------------------
  |  Branch (156:9): [True: 0, False: 284k]
  ------------------
  157|      0|        fill = 0x69; // only ultrasonic tones, filtered out on playback
  158|   284k|    memset(dst, fill, bytes);
  159|   284k|}
af_format_conversion_score:
  166|  17.7k|{
  167|  17.7k|    if (dst_format == AF_FORMAT_UNKNOWN || src_format == AF_FORMAT_UNKNOWN)
  ------------------
  |  Branch (167:9): [True: 0, False: 17.7k]
  |  Branch (167:44): [True: 0, False: 17.7k]
  ------------------
  168|      0|        return INT_MIN;
  169|  17.7k|    if (dst_format == src_format)
  ------------------
  |  Branch (169:9): [True: 15.2k, False: 2.49k]
  ------------------
  170|  15.2k|        return 1024;
  171|  2.49k|    if (src_format == AF_FORMAT_DSD) {
  ------------------
  |  Branch (171:9): [True: 0, False: 2.49k]
  ------------------
  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|  2.49k|    if (dst_format == AF_FORMAT_DSD)
  ------------------
  |  Branch (176:9): [True: 0, False: 2.49k]
  ------------------
  177|      0|        return INT_MIN;
  178|       |    // Can't be normally converted
  179|  2.49k|    if (!af_fmt_is_pcm(dst_format) || !af_fmt_is_pcm(src_format))
  ------------------
  |  Branch (179:9): [True: 0, False: 2.49k]
  |  Branch (179:39): [True: 0, False: 2.49k]
  ------------------
  180|      0|        return INT_MIN;
  181|  2.49k|    int score = 1024;
  182|  2.49k|    if (af_fmt_is_planar(dst_format) != af_fmt_is_planar(src_format))
  ------------------
  |  Branch (182:9): [True: 2.49k, False: 0]
  ------------------
  183|  2.49k|        score -= 1;     // has to (de-)planarize
  184|  2.49k|    if (af_fmt_is_float(dst_format) != af_fmt_is_float(src_format)) {
  ------------------
  |  Branch (184:9): [True: 2.49k, False: 0]
  ------------------
  185|  2.49k|        int dst_bytes = af_fmt_to_bytes(dst_format);
  186|  2.49k|        if (af_fmt_is_float(dst_format)) {
  ------------------
  |  Branch (186:13): [True: 1.99k, False: 500]
  ------------------
  187|       |            // For int->float, consider a lower bound on the precision difference.
  188|  1.99k|            int bytes = (dst_bytes == 4 ? 3 : 6) - af_fmt_to_bytes(src_format);
  ------------------
  |  Branch (188:26): [True: 1.99k, False: 0]
  ------------------
  189|  1.99k|            if (bytes >= 0) {
  ------------------
  |  Branch (189:17): [True: 1.99k, False: 0]
  ------------------
  190|  1.99k|                score -= 8 * bytes;          // excess precision
  191|  1.99k|            } else {
  192|      0|                score += 1024 * (bytes - 1); // precision is lost (i.e. s32 -> float)
  193|      0|            }
  194|  1.99k|        } else {
  195|       |            // float->int is the worst case. Penalize heavily and
  196|       |            // prefer highest bit depth int.
  197|    500|            score -= 1048576 * (8 - dst_bytes);
  198|    500|        }
  199|  2.49k|        score -= 512; // penalty for any float <-> int conversion
  200|  2.49k|    } 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|  2.49k|    return score;
  209|  2.49k|}
af_select_best_samplerate:
  249|  18.7k|{
  250|  18.7k|    if (!available)
  ------------------
  |  Branch (250:9): [True: 3.40k, False: 15.3k]
  ------------------
  251|  3.40k|        return -1;
  252|       |
  253|  15.3k|    int min_mult_rate = INT_MAX;
  254|  15.3k|    int max_rate      = INT_MIN;
  255|  15.4k|    for (int i = 0; available[i]; i++) {
  ------------------
  |  Branch (255:21): [True: 15.3k, False: 93]
  ------------------
  256|  15.3k|        if (available[i] == src_samplerate)
  ------------------
  |  Branch (256:13): [True: 15.2k, False: 93]
  ------------------
  257|  15.2k|            return available[i];
  258|       |
  259|     93|        if (!(available[i] % src_samplerate))
  ------------------
  |  Branch (259:13): [True: 0, False: 93]
  ------------------
  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|     93|        max_rate = MPMAX(max_rate, available[i]);
  ------------------
  |  |   44|     93|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 93]
  |  |  ------------------
  ------------------
  263|     93|    }
  264|       |
  265|     93|    if (min_mult_rate < INT_MAX)
  ------------------
  |  Branch (265:9): [True: 0, False: 93]
  ------------------
  266|      0|        return min_mult_rate;
  267|       |
  268|     93|    if (max_rate > INT_MIN)
  ------------------
  |  Branch (268:9): [True: 93, False: 0]
  ------------------
  269|     93|        return max_rate;
  270|       |
  271|      0|    return -1;
  272|     93|}
af_format_sample_alignment:
  277|   334k|{
  278|   334k|    switch (format) {
  279|      0|    case AF_FORMAT_S_AAC:       return 16384 / 4;
  ------------------
  |  Branch (279:5): [True: 0, False: 334k]
  ------------------
  280|      0|    case AF_FORMAT_S_AC3:       return 6144 / 4;
  ------------------
  |  Branch (280:5): [True: 0, False: 334k]
  ------------------
  281|      0|    case AF_FORMAT_S_DTSHD:     return 32768 / 16;
  ------------------
  |  Branch (281:5): [True: 0, False: 334k]
  ------------------
  282|      0|    case AF_FORMAT_S_DTS:       return 2048 / 4;
  ------------------
  |  Branch (282:5): [True: 0, False: 334k]
  ------------------
  283|      0|    case AF_FORMAT_S_EAC3:      return 24576 / 4;
  ------------------
  |  Branch (283:5): [True: 0, False: 334k]
  ------------------
  284|      0|    case AF_FORMAT_S_MP3:       return 4608 / 4;
  ------------------
  |  Branch (284:5): [True: 0, False: 334k]
  ------------------
  285|      0|    case AF_FORMAT_S_TRUEHD:    return 61440 / 16;
  ------------------
  |  Branch (285:5): [True: 0, False: 334k]
  ------------------
  286|   334k|    default:                    return 1;
  ------------------
  |  Branch (286:5): [True: 334k, False: 0]
  ------------------
  287|   334k|    }
  288|   334k|}

ao_init_best:
  296|  15.0k|{
  297|  15.0k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  15.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  15.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  298|  15.0k|    struct ao_opts *opts = mp_get_config_group(tmp, global, &ao_conf);
  299|  15.0k|    struct mp_log *log = mp_log_new(tmp, global->log, "ao");
  300|  15.0k|    struct ao *ao = NULL;
  301|  15.0k|    struct m_obj_settings *ao_list = NULL;
  302|  15.0k|    int ao_num = 0;
  303|       |
  304|  30.0k|    for (int n = 0; opts->audio_driver_list && opts->audio_driver_list[n].name; n++)
  ------------------
  |  Branch (304:21): [True: 30.0k, False: 0]
  |  Branch (304:48): [True: 15.0k, False: 15.0k]
  ------------------
  305|  15.0k|        MP_TARRAY_APPEND(tmp, ao_list, ao_num, opts->audio_driver_list[n]);
  ------------------
  |  |  105|  15.0k|    do {                                            \
  |  |  106|  15.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  15.0k|    do {                                            \
  |  |  |  |   97|  15.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  15.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  15.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  15.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 15.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  15.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  15.0k|    do {                                                        \
  |  |  |  |  |  |   89|  15.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  15.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  15.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  15.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  15.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  15.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  15.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 15.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  15.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 15.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  15.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  15.0k|        (idxvar)++;                                 \
  |  |  109|  15.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15.0k]
  |  |  ------------------
  ------------------
  306|       |
  307|  15.0k|    bool forced_dev = false;
  308|  15.0k|    char *pref_ao, *pref_dev;
  309|  15.0k|    split_ao_device(tmp, opts->audio_device, &pref_ao, &pref_dev);
  310|  15.0k|    if (!ao_num && pref_ao) {
  ------------------
  |  Branch (310:9): [True: 0, False: 15.0k]
  |  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|  15.0k|    bool autoprobe = ao_num == 0;
  318|       |
  319|       |    // Something like "--ao=a,b," means do autoprobing after a and b fail.
  320|  15.0k|    if (ao_num && strlen(ao_list[ao_num - 1].name) == 0) {
  ------------------
  |  Branch (320:9): [True: 15.0k, False: 0]
  |  Branch (320:19): [True: 0, False: 15.0k]
  ------------------
  321|      0|        ao_num -= 1;
  322|      0|        autoprobe = true;
  323|      0|    }
  324|       |
  325|  15.0k|    if (autoprobe) {
  ------------------
  |  Branch (325:9): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|    if (init_flags & AO_INIT_NULL_FALLBACK) {
  ------------------
  |  Branch (335:9): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|    for (int n = 0; n < ao_num; n++) {
  ------------------
  |  Branch (340:21): [True: 15.0k, False: 8]
  ------------------
  341|  15.0k|        struct m_obj_settings *entry = &ao_list[n];
  342|  15.0k|        bool probing = n + 1 != ao_num;
  343|  15.0k|        mp_verbose(log, "Trying audio driver '%s'\n", entry->name);
  ------------------
  |  |   79|  15.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  344|  15.0k|        char *dev = NULL;
  345|  15.0k|        if (pref_ao && pref_dev && strcmp(entry->name, pref_ao) == 0) {
  ------------------
  |  Branch (345:13): [True: 8, False: 15.0k]
  |  Branch (345:24): [True: 0, False: 8]
  |  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|  15.0k|        ao = ao_init(probing, global, wakeup_cb, wakeup_ctx, encode_lavc_ctx,
  350|  15.0k|                     init_flags, samplerate, format, channels, dev, entry->name);
  351|  15.0k|        if (ao)
  ------------------
  |  Branch (351:13): [True: 15.0k, False: 8]
  ------------------
  352|  15.0k|            break;
  353|      8|        if (!probing)
  ------------------
  |  Branch (353:13): [True: 8, False: 0]
  ------------------
  354|      8|            mp_err(log, "Failed to initialize audio driver '%s'\n", entry->name);
  ------------------
  |  |   76|      8|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  355|      8|        if (dev && forced_dev) {
  ------------------
  |  Branch (355:13): [True: 0, False: 8]
  |  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|      8|    }
  360|       |
  361|  15.0k|    talloc_free(tmp);
  ------------------
  |  |   47|  15.0k|#define talloc_free                     ta_free
  ------------------
  362|  15.0k|    return ao;
  363|  15.0k|}
ao_query_and_reset_events:
  367|  4.95M|{
  368|       |    return atomic_fetch_and(&ao->events_, ~(unsigned)events) & events;
  369|  4.95M|}
ao_chmap_sel_adjust:
  395|  15.0k|{
  396|  15.0k|    MP_VERBOSE(ao, "Channel layouts:\n");
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  397|  15.0k|    mp_chmal_sel_log(s, ao->log, MSGL_V);
  398|  15.0k|    bool r = mp_chmap_sel_adjust(s, map);
  399|  15.0k|    if (r)
  ------------------
  |  Branch (399:9): [True: 15.0k, False: 0]
  ------------------
  400|  15.0k|        MP_VERBOSE(ao, "result: %s\n", mp_chmap_to_str(map));
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  401|  15.0k|    return r;
  402|  15.0k|}
ao_get_format:
  437|  30.3k|{
  438|  30.3k|    *samplerate = ao->samplerate;
  439|  30.3k|    *format = ao->format;
  440|  30.3k|    *channels = ao->channels;
  441|  30.3k|}
ao_get_name:
  444|  15.0k|{
  445|  15.0k|    return ao->driver->name;
  446|  15.0k|}
ao_get_description:
  449|  15.0k|{
  450|  15.0k|    return ao->driver->description;
  451|  15.0k|}
ao_untimed:
  454|   144k|{
  455|   144k|    return ao->untimed;
  456|   144k|}
ao_hotplug_create:
  478|     12|{
  479|     12|    struct ao_hotplug *hp = talloc_ptrtype(NULL, hp);
  ------------------
  |  |   34|     12|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|     12|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     12|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|     12|    *hp = (struct ao_hotplug){
  481|     12|        .global = global,
  482|     12|        .wakeup_cb = wakeup_cb,
  483|     12|        .wakeup_ctx = wakeup_ctx,
  484|       |        .needs_update = true,
  485|     12|    };
  486|     12|    return hp;
  487|     12|}
ao_hotplug_check_update:
  499|    427|{
  500|    427|    if (hp->ao && ao_query_and_reset_events(hp->ao, AO_EVENT_HOTPLUG)) {
  ------------------
  |  Branch (500:9): [True: 0, False: 427]
  |  Branch (500:19): [True: 0, False: 0]
  ------------------
  501|      0|        hp->needs_update = true;
  502|      0|        return true;
  503|      0|    }
  504|    427|    return false;
  505|    427|}
ao_hotplug_get_device_list:
  510|     13|{
  511|     13|    if (hp->list && !hp->needs_update)
  ------------------
  |  Branch (511:9): [True: 7, False: 6]
  |  Branch (511:21): [True: 7, False: 0]
  ------------------
  512|      7|        return hp->list;
  513|       |
  514|      6|    talloc_free(hp->list);
  ------------------
  |  |   47|      6|#define talloc_free                     ta_free
  ------------------
  515|      6|    struct ao_device_list *list = talloc_zero(hp, struct ao_device_list);
  ------------------
  |  |   27|      6|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      6|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      6|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|      6|    hp->list = list;
  517|       |
  518|      6|    MP_TARRAY_APPEND(list, list->devices, list->num_devices,
  ------------------
  |  |  105|      6|    do {                                            \
  |  |  106|      6|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      6|    do {                                            \
  |  |  |  |   97|      6|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      6|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      6|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      6|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      6|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      6|    do {                                                        \
  |  |  |  |  |  |   89|      6|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      6|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      6|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      6|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      6|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      6|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      6|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      6|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      6|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      6|        (idxvar)++;                                 \
  |  |  109|      6|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 6]
  |  |  ------------------
  ------------------
  519|      6|        (struct ao_device_desc){"auto", "Autoselect device"});
  520|       |
  521|       |    // Try to use the same AO for hotplug handling as for playback.
  522|       |    // Different AOs may not agree and the playback one is the only one the
  523|       |    // user knows about and may even have configured explicitly.
  524|      6|    if (!hp->ao && playback_ao && playback_ao->driver->hotplug_init) {
  ------------------
  |  Branch (524:9): [True: 6, False: 0]
  |  Branch (524:20): [True: 1, False: 5]
  |  Branch (524:35): [True: 0, False: 1]
  ------------------
  525|      0|        struct ao *ao = ao_alloc(true, hp->global, hp->wakeup_cb, hp->wakeup_ctx,
  526|      0|                                 (char *)playback_ao->driver->name);
  527|      0|        if (playback_ao->driver->hotplug_init(ao) >= 0) {
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            hp->ao = ao;
  529|      0|        } else {
  530|      0|            talloc_free(ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  531|      0|        }
  532|      0|    }
  533|       |
  534|      6|    for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
  ------------------
  |  |   49|      6|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (534:21): [True: 6, False: 0]
  ------------------
  535|      6|        const struct ao_driver *d = audio_out_drivers[n];
  536|      6|        if (d == &audio_out_null)
  ------------------
  |  Branch (536:13): [True: 6, False: 0]
  ------------------
  537|      6|            break; // don't add unsafe/special entries
  538|       |
  539|      0|        struct ao *ao = ao_alloc(true, hp->global, hp->wakeup_cb, hp->wakeup_ctx,
  540|      0|                                 (char *)d->name);
  541|      0|        if (!ao)
  ------------------
  |  Branch (541:13): [True: 0, False: 0]
  ------------------
  542|      0|            continue;
  543|       |
  544|      0|        if (ao->driver->hotplug_init) {
  ------------------
  |  Branch (544:13): [True: 0, False: 0]
  ------------------
  545|      0|            if (ao->driver->hotplug_init(ao) >= 0) {
  ------------------
  |  Branch (545:17): [True: 0, False: 0]
  ------------------
  546|      0|                get_devices(ao, list);
  547|      0|                if (hp->ao)
  ------------------
  |  Branch (547:21): [True: 0, False: 0]
  ------------------
  548|      0|                    ao->driver->hotplug_uninit(ao);
  549|      0|                else
  550|      0|                    hp->ao = ao; // keep this one
  551|      0|            }
  552|      0|        } else {
  553|      0|            get_devices(ao, list);
  554|      0|        }
  555|      0|        if (ao != hp->ao)
  ------------------
  |  Branch (555:13): [True: 0, False: 0]
  ------------------
  556|      0|            talloc_free(ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  557|      0|    }
  558|       |    hp->needs_update = false;
  559|      6|    return list;
  560|     13|}
ao_hotplug_destroy:
  587|  11.6k|{
  588|  11.6k|    if (!hp)
  ------------------
  |  Branch (588:9): [True: 11.6k, False: 12]
  ------------------
  589|  11.6k|        return;
  590|     12|    if (hp->ao && hp->ao->driver->hotplug_uninit)
  ------------------
  |  Branch (590:9): [True: 0, False: 12]
  |  Branch (590:19): [True: 0, False: 0]
  ------------------
  591|      0|        hp->ao->driver->hotplug_uninit(hp->ao);
  592|     12|    talloc_free(hp->ao);
  ------------------
  |  |   47|     12|#define talloc_free                     ta_free
  ------------------
  593|     12|    talloc_free(hp);
  ------------------
  |  |   47|     12|#define talloc_free                     ta_free
  ------------------
  594|     12|}
ao_set_gain:
  614|  50.6k|{
  615|       |    atomic_store(&ao->gain, gain);
  616|  50.6k|}
ao_post_process_data:
  656|   132k|{
  657|   132k|    bool planar = af_fmt_is_planar(ao->format);
  658|   132k|    int planes = planar ? ao->channels.num : 1;
  ------------------
  |  Branch (658:18): [True: 42.0k, False: 90.9k]
  ------------------
  659|   132k|    int plane_samples = num_samples * (planar ? 1: ao->channels.num);
  ------------------
  |  Branch (659:40): [True: 42.0k, False: 90.9k]
  ------------------
  660|   417k|    for (int n = 0; n < planes; n++)
  ------------------
  |  Branch (660:21): [True: 284k, False: 132k]
  ------------------
  661|   284k|        process_plane(ao, data[n], plane_samples);
  662|   132k|}
ao.c:get_desc:
  116|   108k|{
  117|   108k|    if (index >= MP_ARRAY_SIZE(audio_out_drivers))
  ------------------
  |  |   49|   108k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (117:9): [True: 11.6k, False: 96.7k]
  ------------------
  118|  11.6k|        return false;
  119|  96.7k|    const struct ao_driver *ao = audio_out_drivers[index];
  120|  96.7k|    *dst = (struct m_obj_desc) {
  121|  96.7k|        .name = ao->name,
  122|  96.7k|        .description = ao->description,
  123|  96.7k|        .priv_size = ao->priv_size,
  124|  96.7k|        .priv_defaults = ao->priv_defaults,
  125|  96.7k|        .options = ao->options,
  126|  96.7k|        .options_prefix = ao->options_prefix,
  127|  96.7k|        .global_opts = ao->global_opts,
  128|  96.7k|        .hidden = ao->encode,
  129|  96.7k|        .p = ao,
  130|  96.7k|    };
  131|       |    return true;
  132|   108k|}
ao.c:split_ao_device:
  276|  15.0k|{
  277|  15.0k|    *out_ao = NULL;
  278|  15.0k|    *out_dev = NULL;
  279|  15.0k|    if (!opt)
  ------------------
  |  Branch (279:9): [True: 0, False: 15.0k]
  ------------------
  280|      0|        return;
  281|  15.0k|    if (!opt[0] || strcmp(opt, "auto") == 0)
  ------------------
  |  Branch (281:9): [True: 0, False: 15.0k]
  |  Branch (281:20): [True: 15.0k, False: 8]
  ------------------
  282|  15.0k|        return;
  283|       |    // Split on "/". If "/" is the final character, or absent, out_dev is NULL.
  284|      8|    bstr b_dev, b_ao;
  285|      8|    bstr_split_tok(bstr0(opt), "/", &b_ao, &b_dev);
  286|      8|    if (b_dev.len > 0)
  ------------------
  |  Branch (286:9): [True: 0, False: 8]
  ------------------
  287|      0|        *out_dev = bstrto0(tmp, b_dev);
  288|      8|    *out_ao = bstrto0(tmp, b_ao);
  289|      8|}
ao.c:ao_init:
  207|  15.0k|{
  208|  15.0k|    struct ao *ao = ao_alloc(probing, global, wakeup_cb, wakeup_ctx, name);
  209|  15.0k|    if (!ao)
  ------------------
  |  Branch (209:9): [True: 3, False: 15.0k]
  ------------------
  210|      3|        return NULL;
  211|  15.0k|    ao->samplerate = samplerate;
  212|  15.0k|    ao->channels = channels;
  213|  15.0k|    ao->format = format;
  214|  15.0k|    ao->encode_lavc_ctx = encode_lavc_ctx;
  215|  15.0k|    ao->init_flags = flags;
  216|  15.0k|    if (ao->driver->encode != !!ao->encode_lavc_ctx)
  ------------------
  |  Branch (216:9): [True: 0, False: 15.0k]
  ------------------
  217|      0|        goto fail;
  218|       |
  219|  15.0k|    MP_VERBOSE(ao, "requested format: %d Hz, %s channels, %s\n",
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  220|  15.0k|               ao->samplerate, mp_chmap_to_str(&ao->channels),
  221|  15.0k|               af_fmt_to_str(ao->format));
  222|       |
  223|  15.0k|    ao->device = talloc_strdup(ao, dev);
  ------------------
  |  |   50|  15.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  224|  15.0k|    ao->stream_silence = flags & AO_INIT_STREAM_SILENCE;
  225|       |
  226|  15.0k|    init_buffer_pre(ao);
  227|       |
  228|  15.0k|    int r = ao->driver->init(ao);
  229|  15.0k|    if (r < 0) {
  ------------------
  |  Branch (229:9): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|    ao->driver_initialized = true;
  243|       |
  244|  15.0k|    ao->sstride = af_fmt_to_bytes(ao->format);
  245|  15.0k|    ao->num_planes = 1;
  246|  15.0k|    if (af_fmt_is_planar(ao->format)) {
  ------------------
  |  Branch (246:9): [True: 1.85k, False: 13.1k]
  ------------------
  247|  1.85k|        ao->num_planes = ao->channels.num;
  248|  13.1k|    } else {
  249|  13.1k|        ao->sstride *= ao->channels.num;
  250|  13.1k|    }
  251|  15.0k|    ao->bps = (int64_t)ao->samplerate * ao->sstride;
  252|       |
  253|  15.0k|    if (ao->device_buffer <= 0 && ao->driver->write) {
  ------------------
  |  Branch (253:9): [True: 5, False: 15.0k]
  |  Branch (253:35): [True: 5, False: 0]
  ------------------
  254|      5|        MP_ERR(ao, "Device buffer size not set.\n");
  ------------------
  |  |   89|      5|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  255|      5|        goto fail;
  256|      5|    }
  257|  15.0k|    if (ao->device_buffer)
  ------------------
  |  Branch (257:9): [True: 15.0k, False: 0]
  ------------------
  258|  15.0k|        MP_VERBOSE(ao, "device buffer: %d samples.\n", ao->device_buffer);
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  259|  15.0k|    ao->buffer = MPMAX(ao->device_buffer, ao->def_buffer * ao->samplerate);
  ------------------
  |  |   44|  15.0k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 15.0k]
  |  |  ------------------
  ------------------
  260|  15.0k|    ao->buffer = MPMAX(ao->buffer, 1);
  ------------------
  |  |   44|  15.0k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 15.0k, False: 0]
  |  |  ------------------
  ------------------
  261|       |
  262|  15.0k|    int align = af_format_sample_alignment(ao->format);
  263|  15.0k|    ao->buffer = (ao->buffer + align - 1) / align * align;
  264|  15.0k|    MP_VERBOSE(ao, "using soft-buffer of %d samples.\n", ao->buffer);
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  265|       |
  266|  15.0k|    if (!init_buffer_post(ao))
  ------------------
  |  Branch (266:9): [True: 0, False: 15.0k]
  ------------------
  267|      0|        goto fail;
  268|  15.0k|    return ao;
  269|       |
  270|      5|fail:
  271|      5|    ao_uninit(ao);
  272|       |    return NULL;
  273|  15.0k|}
ao.c:ao_alloc:
  167|  15.0k|{
  168|  15.0k|    mp_assert(wakeup_cb);
  ------------------
  |  |   41|  15.0k|#define mp_assert assert
  ------------------
  |  Branch (168:5): [True: 15.0k, False: 0]
  ------------------
  169|       |
  170|  15.0k|    struct mp_log *log = mp_log_new(NULL, global->log, "ao");
  171|  15.0k|    struct m_obj_desc desc;
  172|  15.0k|    if (!m_obj_list_find(&desc, &ao_obj_list, bstr0(name))) {
  ------------------
  |  Branch (172:9): [True: 3, False: 15.0k]
  ------------------
  173|      3|        mp_msg(log, MSGL_ERR, "Audio output %s not found!\n", name);
  174|      3|        talloc_free(log);
  ------------------
  |  |   47|      3|#define talloc_free                     ta_free
  ------------------
  175|      3|        return NULL;
  176|  15.0k|    };
  177|  15.0k|    struct ao_opts *opts = mp_get_config_group(NULL, global, &ao_conf);
  178|  15.0k|    struct ao *ao = talloc_ptrtype(NULL, ao);
  ------------------
  |  |   34|  15.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  15.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  15.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|  15.0k|    talloc_steal(ao, log);
  ------------------
  |  |   38|  15.0k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  15.0k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  180|  15.0k|    *ao = (struct ao) {
  181|  15.0k|        .driver = desc.p,
  182|  15.0k|        .probing = probing,
  183|  15.0k|        .global = global,
  184|  15.0k|        .wakeup_cb = wakeup_cb,
  185|  15.0k|        .wakeup_ctx = wakeup_ctx,
  186|  15.0k|        .log = mp_log_new(ao, log, name),
  187|  15.0k|        .def_buffer = opts->audio_buffer,
  188|  15.0k|        .client_name = talloc_strdup(ao, opts->audio_client_name),
  ------------------
  |  |   50|  15.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  189|  15.0k|        .set_media_role = opts->audio_set_media_role
  190|  15.0k|    };
  191|  15.0k|    talloc_free(opts);
  ------------------
  |  |   47|  15.0k|#define talloc_free                     ta_free
  ------------------
  192|  15.0k|    ao->priv = m_config_group_from_desc(ao, ao->log, global, &desc, name);
  193|  15.0k|    if (!ao->priv)
  ------------------
  |  Branch (193:9): [True: 0, False: 15.0k]
  ------------------
  194|      0|        goto error;
  195|  15.0k|    ao_set_gain(ao, 1.0f);
  196|  15.0k|    return ao;
  197|      0|error:
  198|      0|    talloc_free(ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  199|       |    return NULL;
  200|  15.0k|}
ao.c:process_plane:
  629|   284k|{
  630|   284k|    float gain = atomic_load_explicit(&ao->gain, memory_order_relaxed);
  631|   284k|    int gi = lrint(256.0 * gain);
  632|   284k|    if (gi == 256)
  ------------------
  |  Branch (632:9): [True: 275k, False: 9.37k]
  ------------------
  633|   275k|        return;
  634|  9.37k|    switch (af_fmt_from_planar(ao->format)) {
  635|      0|    case AF_FORMAT_U8:
  ------------------
  |  Branch (635:5): [True: 0, False: 9.37k]
  ------------------
  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|    455|    case AF_FORMAT_S16:
  ------------------
  |  Branch (638:5): [True: 455, False: 8.92k]
  ------------------
  639|    455|        MUL_GAIN_i((int16_t *)data, num_samples, gi, INT16_MIN, 0, INT16_MAX);
  ------------------
  |  |  619|   253k|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (619:21): [True: 252k, False: 455]
  |  |  ------------------
  |  |  620|   252k|        (d)[n] = MPCLAMP(                                                       \
  |  |  ------------------
  |  |  |  |   46|   253k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:31): [True: 0, False: 252k]
  |  |  |  |  |  Branch (46:56): [True: 0, False: 252k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  621|    455|            ((((int64_t)((d)[n]) - (center)) * (gain) + 128) >> 8) + (center),  \
  |  |  622|    455|            (low), (high))
  ------------------
  640|    455|        break;
  641|      0|    case AF_FORMAT_S32:
  ------------------
  |  Branch (641:5): [True: 0, False: 9.37k]
  ------------------
  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|  8.92k|    case AF_FORMAT_FLOAT:
  ------------------
  |  Branch (644:5): [True: 8.92k, False: 455]
  ------------------
  645|  8.92k|        MUL_GAIN_f((float *)data, num_samples, gain);
  ------------------
  |  |  625|  1.01M|    for (int n = 0; n < (num_samples); n++)                                     \
  |  |  ------------------
  |  |  |  Branch (625:21): [True: 1.00M, False: 8.92k]
  |  |  ------------------
  |  |  626|  1.00M|        (d)[n] = (d)[n] * (gain)
  ------------------
  646|  8.92k|        break;
  647|      0|    case AF_FORMAT_DOUBLE:
  ------------------
  |  Branch (647:5): [True: 0, False: 9.37k]
  ------------------
  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: 9.37k]
  ------------------
  651|       |        // all other sample formats are simply not supported
  652|  9.37k|    }
  653|  9.37k|}

ao_null.c:init:
   85|  15.0k|{
   86|  15.0k|    struct priv *priv = ao->priv;
   87|       |
   88|  15.0k|    if (priv->format)
  ------------------
  |  Branch (88:9): [True: 0, False: 15.0k]
  ------------------
   89|      0|        ao->format = priv->format;
   90|       |
   91|  15.0k|    ao->untimed = priv->untimed;
   92|       |
   93|  15.0k|    struct mp_chmap_sel sel = {.tmp = ao};
   94|  15.0k|    if (priv->channel_layouts.num_chmaps) {
  ------------------
  |  Branch (94:9): [True: 0, False: 15.0k]
  ------------------
   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|  15.0k|    } else {
   98|  15.0k|        mp_chmap_sel_add_any(&sel);
   99|  15.0k|    }
  100|  15.0k|    if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
  ------------------
  |  Branch (100:9): [True: 0, False: 15.0k]
  ------------------
  101|      0|        mp_chmap_from_channels(&ao->channels, 2);
  102|       |
  103|  15.0k|    priv->latency = priv->latency_sec * ao->samplerate;
  104|       |
  105|       |    // A "buffer" for this many seconds of audio
  106|  15.0k|    int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
  107|  15.0k|    ao->device_buffer = priv->outburst * bursts + priv->latency;
  108|       |
  109|  15.0k|    priv->last_time = mp_time_sec();
  110|       |
  111|  15.0k|    return 0;
  112|  15.0k|}
ao_null.c:uninit:
  116|  15.0k|{
  117|  15.0k|}
ao_null.c:reset:
  121|  32.3k|{
  122|  32.3k|    struct priv *priv = ao->priv;
  123|  32.3k|    priv->paused = false;
  124|  32.3k|    priv->buffered = 0;
  125|       |    priv->playing = false;
  126|  32.3k|}
ao_null.c:set_pause:
  142|  7.44k|{
  143|  7.44k|    struct priv *priv = ao->priv;
  144|       |
  145|  7.44k|    if (!priv->playing)
  ------------------
  |  Branch (145:9): [True: 0, False: 7.44k]
  ------------------
  146|  7.44k|        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|  7.44k|    if (priv->paused != paused) {
  ------------------
  |  Branch (148:9): [True: 7.44k, False: 0]
  ------------------
  149|       |
  150|  7.44k|        drain(ao);
  151|  7.44k|        priv->paused = paused;
  152|  7.44k|        if (!priv->paused)
  ------------------
  |  Branch (152:13): [True: 2.97k, False: 4.47k]
  ------------------
  153|  2.97k|            priv->last_time = mp_time_sec();
  154|  7.44k|    }
  155|       |
  156|       |    return true;
  157|  7.44k|}
ao_null.c:drain:
   64|   193k|{
   65|   193k|    struct priv *priv = ao->priv;
   66|       |
   67|   193k|    if (ao->untimed) {
  ------------------
  |  Branch (67:9): [True: 193k, False: 0]
  ------------------
   68|   193k|        priv->buffered = 0;
   69|   193k|        return;
   70|   193k|    }
   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|  2.61k|{
  130|  2.61k|    struct priv *priv = ao->priv;
  131|       |
  132|  2.61k|    if (priv->paused)
  ------------------
  |  Branch (132:9): [True: 0, False: 2.61k]
  ------------------
  133|  2.61k|        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|  2.61k|    drain(ao);
  136|  2.61k|    priv->paused = false;
  137|  2.61k|    priv->last_time = mp_time_sec();
  138|       |    priv->playing = true;
  139|  2.61k|}
ao_null.c:audio_write:
  160|  62.0k|{
  161|  62.0k|    struct priv *priv = ao->priv;
  162|       |
  163|  62.0k|    if (priv->buffered <= 0)
  ------------------
  |  Branch (163:9): [True: 62.0k, False: 0]
  ------------------
  164|  62.0k|        priv->buffered = priv->latency; // emulate fixed latency
  165|       |
  166|  62.0k|    priv->buffered += samples;
  167|       |    return true;
  168|  62.0k|}
ao_null.c:get_state:
  171|   183k|{
  172|   183k|    struct priv *priv = ao->priv;
  173|       |
  174|   183k|    drain(ao);
  175|       |
  176|   183k|    state->free_samples = ao->device_buffer - priv->latency - priv->buffered;
  177|   183k|    state->free_samples = state->free_samples / priv->outburst * priv->outburst;
  178|   183k|    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|   183k|    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|   183k|    if (priv->broken_eof && priv->buffered < priv->latency)
  ------------------
  |  Branch (186:9): [True: 0, False: 183k]
  |  Branch (186:29): [True: 0, False: 0]
  ------------------
  187|      0|        state->delay = priv->latency;
  188|       |
  189|   183k|    state->delay /= ao->samplerate;
  190|       |
  191|   183k|    if (priv->broken_delay) { // Report only multiples of outburst
  ------------------
  |  Branch (191:9): [True: 0, False: 183k]
  ------------------
  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|   183k|    state->playing = priv->playing && priv->buffered > 0;
  ------------------
  |  Branch (197:22): [True: 134k, False: 48.9k]
  |  Branch (197:39): [True: 0, False: 134k]
  ------------------
  198|   183k|}

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

mp_codec_params_to_av:
   54|  51.3k|{
   55|  51.3k|    AVCodecParameters *avp = avcodec_parameters_alloc();
   56|  51.3k|    if (!avp)
  ------------------
  |  Branch (56:9): [True: 0, False: 51.3k]
  ------------------
   57|      0|        return NULL;
   58|       |
   59|       |    // If we have lavf demuxer params, they overwrite by definition any others.
   60|  51.3k|    if (c->lav_codecpar) {
  ------------------
  |  Branch (60:9): [True: 51.3k, False: 0]
  ------------------
   61|  51.3k|        if (avcodec_parameters_copy(avp, c->lav_codecpar) < 0)
  ------------------
  |  Branch (61:13): [True: 0, False: 51.3k]
  ------------------
   62|      0|            goto error;
   63|  51.3k|        return avp;
   64|  51.3k|    }
   65|       |
   66|      0|    avp->codec_type = mp_to_av_stream_type(c->type);
   67|      0|    avp->codec_id = mp_codec_to_av_codec_id(c->codec);
   68|      0|    avp->codec_tag = c->codec_tag;
   69|      0|    if (c->extradata_size) {
  ------------------
  |  Branch (69:9): [True: 0, False: 0]
  ------------------
   70|      0|        uint8_t *extradata = c->extradata;
   71|      0|        int size = c->extradata_size;
   72|       |
   73|      0|        if (avp->codec_id == AV_CODEC_ID_FLAC) {
  ------------------
  |  Branch (73:13): [True: 0, False: 0]
  ------------------
   74|       |            // ffmpeg expects FLAC extradata to be just the STREAMINFO,
   75|       |            // so grab only that (and assume it'll be the first block)
   76|      0|            if (size >= 8 && !memcmp(c->extradata, "fLaC", 4)) {
  ------------------
  |  Branch (76:17): [True: 0, False: 0]
  |  Branch (76:30): [True: 0, False: 0]
  ------------------
   77|      0|                extradata += 8;
   78|      0|                size = MPMIN(34, size - 8); // FLAC_STREAMINFO_SIZE
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   79|      0|            }
   80|      0|        }
   81|       |
   82|      0|        avp->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
   83|      0|        if (!avp->extradata)
  ------------------
  |  Branch (83:13): [True: 0, False: 0]
  ------------------
   84|      0|            goto error;
   85|      0|        avp->extradata_size = size;
   86|      0|        memcpy(avp->extradata, extradata, size);
   87|      0|    }
   88|      0|    avp->bits_per_coded_sample = c->bits_per_coded_sample;
   89|       |
   90|       |    // Video only
   91|      0|    avp->width = c->disp_w;
   92|      0|    avp->height = c->disp_h;
   93|       |
   94|       |    // Audio only
   95|      0|    avp->sample_rate = c->samplerate;
   96|      0|    avp->bit_rate = c->bitrate;
   97|      0|    avp->block_align = c->block_align;
   98|       |
   99|      0|    mp_chmap_to_av_layout(&avp->ch_layout, &c->channels);
  100|       |
  101|      0|    return avp;
  102|      0|error:
  103|      0|    avcodec_parameters_free(&avp);
  104|       |    return NULL;
  105|      0|}
mp_set_avctx_codec_headers:
  109|  51.3k|{
  110|  51.3k|    enum AVMediaType codec_type = avctx->codec_type;
  111|  51.3k|    enum AVCodecID codec_id = avctx->codec_id;
  112|  51.3k|    AVCodecParameters *avp = mp_codec_params_to_av(c);
  113|  51.3k|    if (!avp)
  ------------------
  |  Branch (113:9): [True: 0, False: 51.3k]
  ------------------
  114|      0|        return -1;
  115|       |
  116|  51.3k|    int r = avcodec_parameters_to_context(avctx, avp) < 0 ? -1 : 0;
  ------------------
  |  Branch (116:13): [True: 0, False: 51.3k]
  ------------------
  117|  51.3k|    avcodec_parameters_free(&avp);
  118|       |
  119|  51.3k|    if (avctx->codec_type != AVMEDIA_TYPE_UNKNOWN)
  ------------------
  |  Branch (119:9): [True: 51.3k, False: 0]
  ------------------
  120|  51.3k|        avctx->codec_type = codec_type;
  121|  51.3k|    if (avctx->codec_id != AV_CODEC_ID_NONE)
  ------------------
  |  Branch (121:9): [True: 51.3k, False: 0]
  ------------------
  122|  51.3k|        avctx->codec_id = codec_id;
  123|  51.3k|    return r;
  124|  51.3k|}
mp_get_codec_timebase:
  129|  46.5k|{
  130|  46.5k|    AVRational tb = {c->native_tb_num, c->native_tb_den};
  131|  46.5k|    if (tb.num < 1 || tb.den < 1) {
  ------------------
  |  Branch (131:9): [True: 0, False: 46.5k]
  |  Branch (131:23): [True: 0, False: 46.5k]
  ------------------
  132|      0|        if (c->reliable_fps)
  ------------------
  |  Branch (132:13): [True: 0, False: 0]
  ------------------
  133|      0|            tb = av_inv_q(av_d2q(c->fps, 1000000));
  134|      0|        if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:27): [True: 0, False: 0]
  ------------------
  135|      0|            tb = AV_TIME_BASE_Q;
  136|      0|    }
  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|  46.5k|    int64_t den = tb.den;
  141|  46.5k|    if (av_q2d(tb) > 0.001) {
  ------------------
  |  Branch (141:9): [True: 29.8k, False: 16.7k]
  ------------------
  142|  29.8k|        int64_t scaling_num = tb.num * INT64_C(1000);
  143|  29.8k|        int64_t scaling_den = tb.den;
  144|  29.8k|        den *= (scaling_num + scaling_den - 1) / scaling_den;
  145|  29.8k|    }
  146|       |
  147|  46.5k|    av_reduce(&tb.num, &tb.den, tb.num, den, INT_MAX);
  148|       |
  149|  46.5k|    if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (149:9): [True: 0, False: 46.5k]
  |  Branch (149:23): [True: 0, False: 46.5k]
  ------------------
  150|      0|        tb = AV_TIME_BASE_Q;
  151|       |
  152|  46.5k|    return tb;
  153|  46.5k|}
mp_pts_to_av:
  163|   537k|{
  164|   537k|    AVRational b = get_def_tb(tb);
  165|   537k|    return mp_pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : llrint(mp_pts / av_q2d(b));
  ------------------
  |  |   39|   537k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (165:12): [True: 5.95k, False: 531k]
  ------------------
  166|   537k|}
mp_pts_from_av:
  170|  2.73M|{
  171|  2.73M|    AVRational b = get_def_tb(tb);
  172|  2.73M|    return av_pts == AV_NOPTS_VALUE ? MP_NOPTS_VALUE : av_pts * av_q2d(b);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (172:12): [True: 0, False: 2.73M]
  ------------------
  173|  2.73M|}
mp_set_av_packet:
  180|   268k|{
  181|   268k|    dst->side_data = NULL;
  182|   268k|    dst->side_data_elems = 0;
  183|   268k|    dst->buf = NULL;
  184|   268k|    av_packet_unref(dst);
  185|       |
  186|   268k|    dst->data = mpkt ? mpkt->buffer : NULL;
  ------------------
  |  Branch (186:17): [True: 265k, False: 2.97k]
  ------------------
  187|   268k|    dst->size = mpkt ? mpkt->len : 0;
  ------------------
  |  Branch (187:17): [True: 265k, False: 2.97k]
  ------------------
  188|       |    /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
  189|       |     * from demuxer. */
  190|   268k|    if (mpkt && mpkt->keyframe)
  ------------------
  |  Branch (190:9): [True: 265k, False: 2.97k]
  |  Branch (190:17): [True: 265k, False: 0]
  ------------------
  191|   265k|        dst->flags |= AV_PKT_FLAG_KEY;
  192|   268k|    if (mpkt && mpkt->avpacket) {
  ------------------
  |  Branch (192:9): [True: 265k, False: 2.97k]
  |  Branch (192:17): [True: 265k, False: 0]
  ------------------
  193|   265k|        dst->side_data = mpkt->avpacket->side_data;
  194|   265k|        dst->side_data_elems = mpkt->avpacket->side_data_elems;
  195|   265k|        if (dst->data == mpkt->avpacket->data)
  ------------------
  |  Branch (195:13): [True: 265k, False: 0]
  ------------------
  196|   265k|            dst->buf = mpkt->avpacket->buf;
  197|   265k|        dst->flags |= mpkt->avpacket->flags;
  198|   265k|    }
  199|   268k|    if (mpkt && tb && tb->num > 0 && tb->den > 0)
  ------------------
  |  Branch (199:9): [True: 265k, False: 2.97k]
  |  Branch (199:17): [True: 265k, False: 0]
  |  Branch (199:23): [True: 265k, False: 0]
  |  Branch (199:38): [True: 265k, False: 0]
  ------------------
  200|   265k|        dst->duration = mpkt->duration / av_q2d(*tb);
  201|   268k|    dst->pts = mp_pts_to_av(mpkt ? mpkt->pts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  2.97k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (201:29): [True: 265k, False: 2.97k]
  ------------------
  202|   268k|    dst->dts = mp_pts_to_av(mpkt ? mpkt->dts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  2.97k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (202:29): [True: 265k, False: 2.97k]
  ------------------
  203|   268k|}
mp_set_avcodec_threads:
  206|  46.5k|{
  207|  46.5k|    if (threads == 0) {
  ------------------
  |  Branch (207:9): [True: 29.8k, False: 16.7k]
  ------------------
  208|  29.8k|        threads = av_cpu_count();
  209|  29.8k|        if (threads < 1) {
  ------------------
  |  Branch (209:13): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|        } else {
  213|  29.8k|            mp_verbose(l, "Detected %d logical cores.\n", threads);
  ------------------
  |  |   79|  29.8k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  214|  29.8k|            if (threads > 1)
  ------------------
  |  Branch (214:17): [True: 29.8k, False: 0]
  ------------------
  215|  29.8k|                threads += 1; // extra thread for better load balancing
  216|  29.8k|        }
  217|       |        // Apparently some libavcodec versions have or had trouble with more
  218|       |        // than 16 threads, and/or print a warning when using > 16.
  219|  29.8k|        threads = MPMIN(threads, 16);
  ------------------
  |  |   45|  29.8k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 29.8k, False: 0]
  |  |  ------------------
  ------------------
  220|  29.8k|    }
  221|  46.5k|    mp_verbose(l, "Requesting %d threads for decoding.\n", threads);
  ------------------
  |  |   79|  46.5k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  222|  46.5k|    avctx->thread_count = threads;
  223|  46.5k|}
mp_add_lavc_decoders:
  243|  46.5k|{
  244|       |    add_codecs(list, type, true);
  245|  46.5k|}
mp_get_lavf_demuxers:
  254|  60.3k|{
  255|  60.3k|    char **list = NULL;
  256|  60.3k|    void *iter = NULL;
  257|  60.3k|    int num = 0;
  258|  22.0M|    for (;;) {
  259|  22.0M|        const AVInputFormat *cur = av_demuxer_iterate(&iter);
  260|  22.0M|        if (!cur)
  ------------------
  |  Branch (260:13): [True: 60.3k, False: 22.0M]
  ------------------
  261|  60.3k|            break;
  262|  22.0M|        MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(list, cur->name));
  ------------------
  |  |  105|  22.0M|    do {                                            \
  |  |  106|  22.0M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  22.0M|    do {                                            \
  |  |  |  |   97|  22.0M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  22.0M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  22.0M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  22.0M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 482k, False: 21.5M]
  |  |  |  |  ------------------
  |  |  |  |   99|  22.0M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   482k|    do {                                                        \
  |  |  |  |  |  |   89|   482k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   482k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   482k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   482k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   482k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   482k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   482k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 482k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  22.0M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 22.0M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  22.0M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  22.0M|        (idxvar)++;                                 \
  |  |  109|  22.0M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 22.0M]
  |  |  ------------------
  ------------------
  263|  22.0M|    }
  264|  60.3k|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|  60.3k|    do {                                            \
  |  |  106|  60.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.3k|    do {                                            \
  |  |  |  |   97|  60.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 60.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.3k|        (idxvar)++;                                 \
  |  |  109|  60.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.3k]
  |  |  ------------------
  ------------------
  265|  60.3k|    return list;
  266|  60.3k|}
mp_get_lavf_protocols:
  269|  90.4k|{
  270|  90.4k|    char **list = NULL;
  271|  90.4k|    int num = 0;
  272|  90.4k|    void *opaque = NULL;
  273|  90.4k|    const char *name;
  274|  1.08M|    while ((name = avio_enum_protocols(&opaque, 0)))
  ------------------
  |  Branch (274:12): [True: 994k, False: 90.4k]
  ------------------
  275|   994k|        MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(list, name));
  ------------------
  |  |  105|   994k|    do {                                            \
  |  |  106|   994k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   994k|    do {                                            \
  |  |  |  |   97|   994k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   994k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   994k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   994k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 271k, False: 723k]
  |  |  |  |  ------------------
  |  |  |  |   99|   994k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   271k|    do {                                                        \
  |  |  |  |  |  |   89|   271k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   271k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   271k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   271k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   271k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   271k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   271k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 271k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   994k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 994k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   994k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   994k|        (idxvar)++;                                 \
  |  |  109|   994k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 994k]
  |  |  ------------------
  ------------------
  276|  90.4k|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|  90.4k|    do {                                            \
  |  |  106|  90.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  90.4k|    do {                                            \
  |  |  |  |   97|  90.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  90.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  90.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  90.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 90.4k]
  |  |  |  |  ------------------
  |  |  |  |   99|  90.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  90.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 90.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  90.4k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  90.4k|        (idxvar)++;                                 \
  |  |  109|  90.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 90.4k]
  |  |  ------------------
  ------------------
  277|  90.4k|    return list;
  278|  90.4k|}
mp_codec_to_av_codec_id:
  281|  24.1k|{
  282|  24.1k|    int id = AV_CODEC_ID_NONE;
  283|  24.1k|    if (codec) {
  ------------------
  |  Branch (283:9): [True: 24.1k, False: 0]
  ------------------
  284|  24.1k|        const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
  285|  24.1k|        if (desc)
  ------------------
  |  Branch (285:13): [True: 24.1k, False: 0]
  ------------------
  286|  24.1k|            id = desc->id;
  287|  24.1k|        if (id == AV_CODEC_ID_NONE) {
  ------------------
  |  Branch (287:13): [True: 0, False: 24.1k]
  ------------------
  288|      0|            const AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
  289|      0|            if (avcodec)
  ------------------
  |  Branch (289:17): [True: 0, False: 0]
  ------------------
  290|      0|                id = avcodec->id;
  291|      0|        }
  292|  24.1k|    }
  293|  24.1k|    return id;
  294|  24.1k|}
mp_codec_from_av_codec_id:
  297|  11.4M|{
  298|  11.4M|    const char *name = NULL;
  299|  11.4M|    const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
  300|  11.4M|    if (desc)
  ------------------
  |  Branch (300:9): [True: 11.4M, False: 0]
  ------------------
  301|  11.4M|        name = desc->name;
  302|  11.4M|    if (!name) {
  ------------------
  |  Branch (302:9): [True: 0, False: 11.4M]
  ------------------
  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|  11.4M|    return name;
  308|  11.4M|}
mp_codec_is_lossless:
  311|  14.6k|{
  312|  14.6k|    const AVCodecDescriptor *desc =
  313|  14.6k|        avcodec_descriptor_get(mp_codec_to_av_codec_id(codec));
  314|  14.6k|    return desc && (desc->props & AV_CODEC_PROP_LOSSLESS);
  ------------------
  |  Branch (314:12): [True: 14.6k, False: 0]
  |  Branch (314:20): [True: 14.6k, False: 0]
  ------------------
  315|  14.6k|}
mp_set_avdict:
  320|  63.6k|{
  321|  63.6k|    for (int n = 0; kv && kv[n * 2]; n++)
  ------------------
  |  Branch (321:21): [True: 0, False: 63.6k]
  |  Branch (321:27): [True: 0, False: 0]
  ------------------
  322|      0|        av_dict_set(dict, kv[n * 2 + 0], kv[n * 2 + 1], 0);
  323|  63.6k|}
mp_avdict_print_unset:
  328|  24.1k|{
  329|  24.1k|    AVDictionaryEntry *t = NULL;
  330|   109k|    while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX)))
  ------------------
  |  Branch (330:12): [True: 85.0k, False: 24.1k]
  ------------------
  331|  85.0k|        mp_msg(log, msgl, "Could not set AVOption %s='%s'\n", t->key, t->value);
  332|  24.1k|}
mp_set_avopts:
  369|  51.6k|{
  370|  51.6k|    return mp_set_avopts_pos(log, avobj, avobj, kv);
  371|  51.6k|}
mp_set_avopts_pos:
  376|  51.6k|{
  377|  51.6k|    int success = 0;
  378|  51.6k|    for (int n = 0; kv && kv[n * 2]; n++) {
  ------------------
  |  Branch (378:21): [True: 0, False: 51.6k]
  |  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|  51.6k|    return success;
  394|  51.6k|}
mp_free_av_packet:
  405|  85.9k|{
  406|  85.9k|    if (*pkt) {
  ------------------
  |  Branch (406:9): [True: 56.0k, False: 29.8k]
  ------------------
  407|  56.0k|        (*pkt)->side_data = NULL;
  408|  56.0k|        (*pkt)->side_data_elems = 0;
  409|       |        (*pkt)->buf = NULL;
  410|  56.0k|    }
  411|  85.9k|    av_packet_free(pkt);
  412|  85.9k|}
mp_codec_info_from_av:
  415|   266k|{
  416|   266k|    c->codec_profile = av_get_profile_name(avctx->codec, avctx->profile);
  417|   266k|    if (!c->codec_profile)
  ------------------
  |  Branch (417:9): [True: 266k, False: 0]
  ------------------
  418|   266k|        c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile);
  419|   266k|    c->codec = avctx->codec_descriptor->name;
  420|   266k|    c->codec_desc = avctx->codec_descriptor->long_name;
  421|   266k|    c->decoder = avctx->codec->name;
  422|   266k|    c->decoder_desc = avctx->codec->long_name;
  423|   266k|}
mp_codec_info_from_avcodecpar:
  426|  34.2k|{
  427|  34.2k|    const AVCodec *codec = avcodec_find_decoder(avcodecpar->codec_id);
  428|  34.2k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(avcodecpar->codec_id);
  429|  34.2k|    c->codec = mp_codec_from_av_codec_id(avcodecpar->codec_id);
  430|  34.2k|    if (desc)
  ------------------
  |  Branch (430:9): [True: 34.2k, False: 0]
  ------------------
  431|  34.2k|        c->codec_desc = desc->long_name;
  432|  34.2k|    if (codec) {
  ------------------
  |  Branch (432:9): [True: 34.2k, False: 0]
  ------------------
  433|  34.2k|        c->decoder = codec->name;
  434|  34.2k|        c->decoder_desc = codec->long_name;
  435|  34.2k|        c->codec_profile = av_get_profile_name(codec, avcodecpar->profile);
  436|  34.2k|    }
  437|  34.2k|    if (!c->codec_profile)
  ------------------
  |  Branch (437:9): [True: 34.2k, False: 0]
  ------------------
  438|  34.2k|        c->codec_profile = avcodec_profile_name(avcodecpar->codec_id, avcodecpar->profile);
  439|  34.2k|}
av_common.c:get_def_tb:
  156|  3.27M|{
  157|  3.27M|    return tb && tb->num > 0 && tb->den > 0 ? *tb : AV_TIME_BASE_Q;
  ------------------
  |  Branch (157:12): [True: 3.27M, False: 18.4E]
  |  Branch (157:18): [True: 3.27M, False: 6]
  |  Branch (157:33): [True: 3.27M, False: 3]
  ------------------
  158|  3.27M|}
av_common.c:add_codecs:
  227|  46.5k|{
  228|  46.5k|    void *iter = NULL;
  229|  23.3M|    for (;;) {
  230|  23.3M|        const AVCodec *cur = av_codec_iterate(&iter);
  231|  23.3M|        if (!cur)
  ------------------
  |  Branch (231:13): [True: 46.5k, False: 23.3M]
  ------------------
  232|  46.5k|            break;
  233|  23.3M|        if (av_codec_is_decoder(cur) == decoders &&
  ------------------
  |  Branch (233:13): [True: 23.3M, False: 0]
  ------------------
  234|  23.3M|            (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type))
  ------------------
  |  Branch (234:14): [True: 0, False: 23.3M]
  |  Branch (234:46): [True: 11.3M, False: 11.9M]
  ------------------
  235|  11.3M|        {
  236|  11.3M|            mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id),
  237|  11.3M|                           cur->name, cur->long_name);
  238|  11.3M|        }
  239|  23.3M|    }
  240|  46.5k|}

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

mp_add_decoder:
   26|  11.4M|{
   27|  11.4M|    struct mp_decoder_entry entry = {
   28|  11.4M|        .codec = talloc_strdup(list, codec),
  ------------------
  |  |   50|  11.4M|#define talloc_strdup                   ta_xstrdup
  ------------------
   29|  11.4M|        .decoder = talloc_strdup(list, decoder),
  ------------------
  |  |   50|  11.4M|#define talloc_strdup                   ta_xstrdup
  ------------------
   30|  11.4M|        .desc = talloc_strdup(list, desc),
  ------------------
  |  |   50|  11.4M|#define talloc_strdup                   ta_xstrdup
  ------------------
   31|  11.4M|    };
   32|  11.4M|    MP_TARRAY_APPEND(list, list->entries, list->num_entries, entry);
  ------------------
  |  |  105|  11.4M|    do {                                            \
  |  |  106|  11.4M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  11.4M|    do {                                            \
  |  |  |  |   97|  11.4M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  11.4M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  11.4M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  11.4M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 402k, False: 11.0M]
  |  |  |  |  ------------------
  |  |  |  |   99|  11.4M|            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|  11.4M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  11.4M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  11.4M|        (idxvar)++;                                 \
  |  |  109|  11.4M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11.4M]
  |  |  ------------------
  ------------------
   33|  11.4M|}
mp_select_decoders:
   60|  46.5k|{
   61|  46.5k|    struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  46.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  46.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  46.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  46.5k|    if (!codec)
  ------------------
  |  Branch (62:9): [True: 0, False: 46.5k]
  ------------------
   63|      0|        codec = "unknown";
   64|  46.5k|    bool stop = false;
   65|  46.5k|    bstr sel = bstr0(selection);
   66|  46.5k|    while (sel.len) {
  ------------------
  |  Branch (66:12): [True: 32, False: 46.5k]
  ------------------
   67|     32|        bstr entry;
   68|     32|        bstr_split_tok(sel, ",", &entry, &sel);
   69|     32|        if (bstr_equals0(entry, "-")) {
  ------------------
  |  Branch (69:13): [True: 0, False: 32]
  ------------------
   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|  7.16k|        for (int n = 0; n < all->num_entries; n++) {
  ------------------
  |  Branch (74:25): [True: 7.13k, False: 32]
  ------------------
   75|  7.13k|            struct mp_decoder_entry *cur = &all->entries[n];
   76|  7.13k|            if (bstr_equals0(entry, cur->decoder))
  ------------------
  |  Branch (76:17): [True: 0, False: 7.13k]
  ------------------
   77|      0|                add_new(list, cur, codec);
   78|  7.13k|        }
   79|     32|    }
   80|  46.5k|    if (!stop) {
  ------------------
  |  Branch (80:9): [True: 46.5k, False: 0]
  ------------------
   81|       |        // Add the remaining codecs which haven't been added yet
   82|  11.4M|        for (int n = 0; n < all->num_entries; n++)
  ------------------
  |  Branch (82:25): [True: 11.3M, False: 46.5k]
  ------------------
   83|  11.3M|            add_new(list, &all->entries[n], codec);
   84|  46.5k|    }
   85|  46.5k|    return list;
   86|  46.5k|}
mp_print_decoders:
   96|  46.5k|{
   97|  46.5k|    mp_msg(log, msgl, "%s\n", header);
   98|  93.0k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (98:21): [True: 46.5k, False: 46.5k]
  ------------------
   99|  46.5k|        struct mp_decoder_entry *entry = &list->entries[n];
  100|  46.5k|        mp_msg(log, msgl, "    %s", entry->decoder);
  101|  46.5k|        if (strcmp(entry->decoder, entry->codec) != 0)
  ------------------
  |  Branch (101:13): [True: 0, False: 46.5k]
  ------------------
  102|      0|            mp_msg(log, msgl, " (%s)", entry->codec);
  103|  46.5k|        mp_msg(log, msgl, " - %s\n", entry->desc);
  104|  46.5k|    }
  105|  46.5k|    if (list->num_entries == 0)
  ------------------
  |  Branch (105:9): [True: 0, False: 46.5k]
  ------------------
  106|      0|        mp_msg(log, msgl, "    (no decoders)\n");
  107|  46.5k|}
codecs.c:add_new:
   39|  11.3M|{
   40|  11.3M|    if (!entry || (codec && strcmp(entry->codec, codec) != 0))
  ------------------
  |  Branch (40:9): [True: 0, False: 11.3M]
  |  Branch (40:20): [True: 11.3M, False: 0]
  |  Branch (40:29): [True: 11.3M, False: 46.5k]
  ------------------
   41|  11.3M|        return;
   42|  46.5k|    mp_add_decoder(to, entry->codec, entry->decoder, entry->desc);
   43|  46.5k|}

mp_format_time_fmt:
   46|   122k|{
   47|   122k|    if (time == MP_NOPTS_VALUE || !(fabs(time) < 0x1p63))
  ------------------
  |  |   39|   244k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (47:9): [True: 2.85k, False: 119k]
  |  Branch (47:35): [True: 0, False: 119k]
  ------------------
   48|  2.85k|        return talloc_strdup(NULL, "unknown");
  ------------------
  |  |   50|  2.85k|#define talloc_strdup                   ta_xstrdup
  ------------------
   49|   119k|    char *sign = time < 0 ? "-" : "";
  ------------------
  |  Branch (49:18): [True: 117, False: 119k]
  ------------------
   50|   119k|    time = time < 0 ? -time : time;
  ------------------
  |  Branch (50:12): [True: 117, False: 119k]
  ------------------
   51|   119k|    long long int itime = time;
   52|   119k|    long long int h, m, tm, s;
   53|   119k|    int ms = lrint((time - itime) * 1000);
   54|   119k|    if (ms >= 1000) {
  ------------------
  |  Branch (54:9): [True: 20, False: 119k]
  ------------------
   55|     20|        ms -= 1000;
   56|     20|        itime += 1;
   57|     20|    }
   58|   119k|    s = itime;
   59|   119k|    tm = s / 60;
   60|   119k|    h = s / 3600;
   61|   119k|    s -= h * 3600;
   62|   119k|    m = s / 60;
   63|   119k|    s -= m * 60;
   64|   119k|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|   119k|#define talloc_strdup                   ta_xstrdup
  ------------------
   65|   715k|    while (*fmt) {
  ------------------
  |  Branch (65:12): [True: 596k, False: 119k]
  ------------------
   66|   596k|        if (fmt[0] == '%') {
  ------------------
  |  Branch (66:13): [True: 357k, False: 238k]
  ------------------
   67|   357k|            fmt++;
   68|   357k|            switch (fmt[0]) {
   69|      0|            case 'h': appendf(&res, "%s%lld", sign, h); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (69:13): [True: 0, False: 357k]
  ------------------
   70|   119k|            case 'H': appendf(&res, "%s%02lld", sign, h); break;
  ------------------
  |  |   33|   119k|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|   119k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 119k]
  |  |  ------------------
  ------------------
  |  Branch (70:13): [True: 119k, False: 238k]
  ------------------
   71|      0|            case 'm': appendf(&res, "%s%lld", sign, tm); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (71:13): [True: 0, False: 357k]
  ------------------
   72|   119k|            case 'M': appendf(&res, "%02lld", m); break;
  ------------------
  |  |   33|   119k|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|   119k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 119k]
  |  |  ------------------
  ------------------
  |  Branch (72:13): [True: 119k, False: 238k]
  ------------------
   73|      0|            case 's': appendf(&res, "%s%lld", sign, itime); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (73:13): [True: 0, False: 357k]
  ------------------
   74|   119k|            case 'S': appendf(&res, "%02lld", s); break;
  ------------------
  |  |   33|   119k|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|   119k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 119k]
  |  |  ------------------
  ------------------
  |  Branch (74:13): [True: 119k, False: 238k]
  ------------------
   75|      0|            case 'T': appendf(&res, "%03d", ms); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (75:13): [True: 0, False: 357k]
  ------------------
   76|      0|            case 'f': appendf(&res, "%f", time); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (76:13): [True: 0, False: 357k]
  ------------------
   77|      0|            case '%': appendf(&res, "%s", "%"); break;
  ------------------
  |  |   33|      0|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (77:13): [True: 0, False: 357k]
  ------------------
   78|      0|            default: goto error;
  ------------------
  |  Branch (78:13): [True: 0, False: 357k]
  ------------------
   79|   357k|            }
   80|   357k|            fmt++;
   81|   357k|        } else {
   82|   238k|            appendf(&res, "%c", *fmt);
  ------------------
  |  |   33|   238k|    do {(*(ptr)) = talloc_asprintf_append_buffer(*(ptr), __VA_ARGS__);} while(0)
  |  |  ------------------
  |  |  |  |   64|   238k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  |  |  ------------------
  |  |  |  Branch (33:79): [Folded, False: 238k]
  |  |  ------------------
  ------------------
   83|   238k|            fmt++;
   84|   238k|        }
   85|   596k|    }
   86|   119k|    return res;
   87|      0|error:
   88|      0|    talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   89|       |    return NULL;
   90|   119k|}
mp_format_time:
   93|   122k|{
   94|   122k|    return mp_format_time_fmt(fractions ? "%H:%M:%S.%T" : "%H:%M:%S", time);
  ------------------
  |  Branch (94:31): [True: 0, False: 122k]
  ------------------
   95|   122k|}
mp_format_double:
   99|  78.0k|{
  100|  78.0k|    bstr str = {0};
  101|  78.0k|    const char *fmt = plus_sign ? "%+.*f" : "%.*f";
  ------------------
  |  Branch (101:23): [True: 0, False: 78.0k]
  ------------------
  102|  78.0k|    bstr_xappend_asprintf(talloc_ctx, &str, fmt, precision, val);
  103|  78.0k|    size_t pos = str.len;
  104|  78.0k|    if (trim) {
  ------------------
  |  Branch (104:9): [True: 77.7k, False: 319]
  ------------------
  105|   377k|        while (--pos && str.start[pos] == '0')
  ------------------
  |  Branch (105:16): [True: 377k, False: 0]
  |  Branch (105:25): [True: 299k, False: 77.7k]
  ------------------
  106|   299k|            str.len--;
  107|  77.7k|        if (str.start[pos] == '.')
  ------------------
  |  Branch (107:13): [True: 77.6k, False: 88]
  ------------------
  108|  77.6k|            str.len--;
  109|  77.7k|    }
  110|  78.0k|    if (percent_sign)
  ------------------
  |  Branch (110:9): [True: 3, False: 78.0k]
  ------------------
  111|      3|        bstr_xappend(talloc_ctx, &str, bstr0("%"));
  112|  78.0k|    str.start[str.len] = '\0';
  113|  78.0k|    return str.start;
  114|  78.0k|}
mp_rect_equals:
  144|   193k|{
  145|   193k|    return rc1->x0 == rc2->x0 && rc1->y0 == rc2->y0 &&
  ------------------
  |  Branch (145:12): [True: 193k, False: 0]
  |  Branch (145:34): [True: 193k, False: 0]
  ------------------
  146|   193k|           rc1->x1 == rc2->x1 && rc1->y1 == rc2->y1;
  ------------------
  |  Branch (146:12): [True: 193k, False: 0]
  |  Branch (146:34): [True: 193k, False: 0]
  ------------------
  147|   193k|}
mp_snprintf_cat:
  214|  1.93M|{
  215|  1.93M|    size_t len = strnlen(str, size);
  216|  1.93M|    mp_assert(!size || len < size); // str with no 0-termination is not allowed
  ------------------
  |  |   41|  1.93M|#define mp_assert assert
  ------------------
  |  Branch (216:5): [True: 0, False: 1.93M]
  |  Branch (216:5): [True: 1.93M, False: 0]
  ------------------
  217|  1.93M|    int r;
  218|  1.93M|    va_list ap;
  219|  1.93M|    va_start(ap, format);
  220|  1.93M|    r = vsnprintf(str + len, size - len, format, ap);
  221|       |    va_end(ap);
  222|  1.93M|    return r;
  223|  1.93M|}
mp_append_utf8_bstr:
  229|  3.12M|{
  230|  3.12M|    char data[8];
  231|  3.12M|    uint8_t tmp;
  232|  3.12M|    char *output = data;
  233|       |    PUT_UTF8(codepoint, tmp, *output++ = tmp;);
  ------------------
  |  Branch (233:5): [True: 3.12M, False: 3.12M]
  |  Branch (233:5): [True: 6.49k, False: 3.12M]
  ------------------
  234|  3.12M|    bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
  235|  3.12M|}
mp_append_escaped_string_noalloc:
  300|   117k|{
  301|   117k|    bstr t = *src;
  302|   117k|    int cur = 0;
  303|   336k|    while (1) {
  ------------------
  |  Branch (303:12): [True: 336k, Folded]
  ------------------
  304|   336k|        if (cur >= t.len || t.start[cur] == '"') {
  ------------------
  |  Branch (304:13): [True: 52.8k, False: 284k]
  |  Branch (304:29): [True: 20.3k, False: 263k]
  ------------------
  305|  73.2k|            *src = bstr_cut(t, cur);
  306|  73.2k|            t = bstr_splice(t, 0, cur);
  307|  73.2k|            if (dst->start == NULL) {
  ------------------
  |  Branch (307:17): [True: 67.3k, False: 5.88k]
  ------------------
  308|  67.3k|                *dst = t;
  309|  67.3k|            } else {
  310|  5.88k|                bstr_xappend(talloc_ctx, dst, t);
  311|  5.88k|            }
  312|  73.2k|            return true;
  313|   263k|        } else if (t.start[cur] == '\\') {
  ------------------
  |  Branch (313:20): [True: 68.8k, False: 194k]
  ------------------
  314|  68.8k|            bstr_xappend(talloc_ctx, dst, bstr_splice(t, 0, cur));
  315|  68.8k|            t = bstr_cut(t, cur + 1);
  316|  68.8k|            cur = 0;
  317|  68.8k|            if (!mp_parse_escape(talloc_ctx, dst, &t))
  ------------------
  |  Branch (317:17): [True: 43.9k, False: 24.9k]
  ------------------
  318|  43.9k|                goto error;
  319|   194k|        } else {
  320|   194k|            cur++;
  321|   194k|        }
  322|   336k|    }
  323|  43.9k|error:
  324|       |    return false;
  325|   117k|}
mp_append_escaped_string:
  338|  2.38k|{
  339|  2.38k|    if (mp_append_escaped_string_noalloc(talloc_ctx, dst, src)) {
  ------------------
  |  Branch (339:9): [True: 1.01k, False: 1.36k]
  ------------------
  340|       |        // Guarantee copy (or allocation).
  341|  1.01k|        if (!dst->start || dst->start == src->start) {
  ------------------
  |  Branch (341:13): [True: 0, False: 1.01k]
  |  Branch (341:28): [True: 0, False: 1.01k]
  ------------------
  342|      0|            bstr res = *dst;
  343|      0|            *dst = (bstr){0};
  344|      0|            bstr_xappend(talloc_ctx, dst, res);
  345|      0|        }
  346|  1.01k|        return true;
  347|  1.01k|    }
  348|  1.36k|    return false;
  349|  2.38k|}
mp_strerror_buf:
  353|  25.9k|{
  354|       |    // This handles the nasty details of calling the right function for us.
  355|       |    av_strerror(AVERROR(errnum), buf, buf_size);
  356|  25.9k|    return buf;
  357|  25.9k|}
mp_tprintf_buf:
  376|   202k|{
  377|   202k|    va_list ap;
  378|   202k|    va_start(ap, format);
  379|   202k|    vsnprintf(buf, buf_size, format, ap);
  380|       |    va_end(ap);
  381|   202k|    return buf;
  382|   202k|}
mp_dup_str_array:
  385|  59.6k|{
  386|  59.6k|    char **r = NULL;
  387|  59.6k|    int num_r = 0;
  388|  67.3k|    for (int n = 0; s && s[n]; n++)
  ------------------
  |  Branch (388:21): [True: 9.02k, False: 58.3k]
  |  Branch (388:26): [True: 7.73k, False: 1.29k]
  ------------------
  389|  7.73k|        MP_TARRAY_APPEND(tctx, r, num_r, talloc_strdup(tctx, s[n]));
  ------------------
  |  |  105|  7.73k|    do {                                            \
  |  |  106|  7.73k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  7.73k|    do {                                            \
  |  |  |  |   97|  7.73k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  7.73k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  7.73k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  7.73k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 2.57k, False: 5.15k]
  |  |  |  |  ------------------
  |  |  |  |   99|  7.73k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  2.57k|    do {                                                        \
  |  |  |  |  |  |   89|  2.57k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  2.57k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  2.57k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  2.57k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.57k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  2.57k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  2.57k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 2.57k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  7.73k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 7.73k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  7.73k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  7.73k|        (idxvar)++;                                 \
  |  |  109|  7.73k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.73k]
  |  |  ------------------
  ------------------
  390|  59.6k|    if (r)
  ------------------
  |  Branch (390:9): [True: 1.29k, False: 58.3k]
  ------------------
  391|  1.29k|        MP_TARRAY_APPEND(tctx, r, num_r, NULL);
  ------------------
  |  |  105|  1.29k|    do {                                            \
  |  |  106|  1.29k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  1.29k|    do {                                            \
  |  |  |  |   97|  1.29k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  1.29k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.29k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  1.29k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.28k, False: 2]
  |  |  |  |  ------------------
  |  |  |  |   99|  1.29k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.28k|    do {                                                        \
  |  |  |  |  |  |   89|  1.28k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.28k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.28k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.28k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.28k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.28k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.28k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.28k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  1.29k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  1.29k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  1.29k|        (idxvar)++;                                 \
  |  |  109|  1.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
  392|  59.6k|    return r;
  393|  59.6k|}
mp_log2:
  401|  17.8M|{
  402|  17.8M|#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
  403|  17.8M|    return v ? 31 - __builtin_clz(v) : 0;
  ------------------
  |  Branch (403:12): [True: 16.6M, False: 1.17M]
  ------------------
  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|  17.8M|}
mp_round_next_power_of_2:
  419|  4.65M|{
  420|  4.65M|    if (!v)
  ------------------
  |  Branch (420:9): [True: 0, False: 4.65M]
  ------------------
  421|      0|        return 1;
  422|  4.65M|    if (!(v & (v - 1)))
  ------------------
  |  Branch (422:9): [True: 4.34M, False: 310k]
  ------------------
  423|  4.34M|        return v;
  424|   310k|    int l = mp_log2(v) + 1;
  425|   310k|    return l == 32 ? 0 : (uint32_t)1 << l;
  ------------------
  |  Branch (425:12): [True: 0, False: 310k]
  ------------------
  426|  4.65M|}
mp_lcm:
  429|   561k|{
  430|   561k|    mp_assert(x && y);
  ------------------
  |  |   41|   561k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 561k, False: 0]
  |  Branch (430:5): [True: 561k, False: 0]
  ------------------
  431|   561k|    return x * (y / av_gcd(x, y));
  432|   561k|}
common.c:mp_parse_escape:
  243|  68.8k|{
  244|  68.8k|    if (code->len < 1)
  ------------------
  |  Branch (244:9): [True: 258, False: 68.6k]
  ------------------
  245|    258|        return false;
  246|  68.6k|    char replace = 0;
  247|  68.6k|    switch (code->start[0]) {
  ------------------
  |  Branch (247:13): [True: 22.7k, False: 45.8k]
  ------------------
  248|  1.28k|    case '"':  replace = '"';  break;
  ------------------
  |  Branch (248:5): [True: 1.28k, False: 67.3k]
  ------------------
  249|  18.0k|    case '\\': replace = '\\'; break;
  ------------------
  |  Branch (249:5): [True: 18.0k, False: 50.5k]
  ------------------
  250|    120|    case '/':  replace = '/'; break;
  ------------------
  |  Branch (250:5): [True: 120, False: 68.5k]
  ------------------
  251|  1.06k|    case 'b':  replace = '\b'; break;
  ------------------
  |  Branch (251:5): [True: 1.06k, False: 67.5k]
  ------------------
  252|    153|    case 'f':  replace = '\f'; break;
  ------------------
  |  Branch (252:5): [True: 153, False: 68.4k]
  ------------------
  253|    171|    case 'n':  replace = '\n'; break;
  ------------------
  |  Branch (253:5): [True: 171, False: 68.4k]
  ------------------
  254|    706|    case 'r':  replace = '\r'; break;
  ------------------
  |  Branch (254:5): [True: 706, False: 67.9k]
  ------------------
  255|    799|    case 't':  replace = '\t'; break;
  ------------------
  |  Branch (255:5): [True: 799, False: 67.8k]
  ------------------
  256|    117|    case 'e':  replace = '\x1b'; break;
  ------------------
  |  Branch (256:5): [True: 117, False: 68.5k]
  ------------------
  257|    285|    case '\'': replace = '\''; break;
  ------------------
  |  Branch (257:5): [True: 285, False: 68.3k]
  ------------------
  258|  68.6k|    }
  259|  68.6k|    if (replace) {
  ------------------
  |  Branch (259:9): [True: 22.7k, False: 45.8k]
  ------------------
  260|  22.7k|        bstr_xappend(talloc_ctx, dst, (bstr){&replace, 1});
  261|  22.7k|        *code = bstr_cut(*code, 1);
  262|  22.7k|        return true;
  263|  22.7k|    }
  264|  45.8k|    if (code->start[0] == 'x' && code->len >= 3) {
  ------------------
  |  Branch (264:9): [True: 5.62k, False: 40.2k]
  |  Branch (264:34): [True: 5.49k, False: 131]
  ------------------
  265|  5.49k|        bstr num = bstr_splice(*code, 1, 3);
  266|  5.49k|        char c = bstrtoll(num, &num, 16);
  267|  5.49k|        if (num.len)
  ------------------
  |  Branch (267:13): [True: 4.94k, False: 551]
  ------------------
  268|  4.94k|            return false;
  269|    551|        bstr_xappend(talloc_ctx, dst, (bstr){&c, 1});
  270|    551|        *code = bstr_cut(*code, 3);
  271|    551|        return true;
  272|  5.49k|    }
  273|  40.3k|    if (code->start[0] == 'u' && code->len >= 5) {
  ------------------
  |  Branch (273:9): [True: 28.3k, False: 12.0k]
  |  Branch (273:34): [True: 5.12k, False: 23.2k]
  ------------------
  274|  5.12k|        bstr num = bstr_splice(*code, 1, 5);
  275|  5.12k|        uint32_t c = bstrtoll(num, &num, 16);
  276|  5.12k|        if (num.len || c > 0x10FFFF)
  ------------------
  |  Branch (276:13): [True: 3.35k, False: 1.76k]
  |  Branch (276:24): [True: 74, False: 1.69k]
  ------------------
  277|  3.43k|            return false;
  278|  1.69k|        if (c >= 0xd800 && c <= 0xdbff) {
  ------------------
  |  Branch (278:13): [True: 91, False: 1.59k]
  |  Branch (278:28): [True: 80, False: 11]
  ------------------
  279|     80|            if (code->len < 5 + 6 // udddd + \udddd
  ------------------
  |  Branch (279:17): [True: 10, False: 70]
  ------------------
  280|     70|                || code->start[5] != '\\' || code->start[6] != 'u')
  ------------------
  |  Branch (280:20): [True: 33, False: 37]
  |  Branch (280:46): [True: 15, False: 22]
  ------------------
  281|     58|                return false;
  282|     22|            *code = bstr_cut(*code, 5 + 1);
  283|     22|            bstr num2 = bstr_splice(*code, 1, 5);
  284|     22|            uint32_t c2 = bstrtoll(num2, &num2, 16);
  285|     22|            if (num2.len || c2 < 0xdc00 || c2 > 0xdfff)
  ------------------
  |  Branch (285:17): [True: 1, False: 21]
  |  Branch (285:29): [True: 15, False: 6]
  |  Branch (285:44): [True: 0, False: 6]
  ------------------
  286|     16|                return false;
  287|      6|            c = ((c - 0xd800) << 10) + 0x10000 + (c2 - 0xdc00);
  288|      6|        }
  289|  1.61k|        mp_append_utf8_bstr(talloc_ctx, dst, c);
  290|  1.61k|        *code = bstr_cut(*code, 5);
  291|  1.61k|        return true;
  292|  1.69k|    }
  293|  35.2k|    return false;
  294|  40.3k|}

encode_lavc_free:
  189|  11.6k|{
  190|  11.6k|    bool res = true;
  191|  11.6k|    if (!ctx)
  ------------------
  |  Branch (191:9): [True: 11.6k, False: 0]
  ------------------
  192|  11.6k|        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|  11.6k|}
encode_lavc_discontinuity:
  436|  2.72M|{
  437|  2.72M|    if (!ctx)
  ------------------
  |  Branch (437:9): [True: 2.72M, False: 0]
  ------------------
  438|  2.72M|        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|  11.6k|{
  521|  11.6k|    bool help_output = false;
  522|  11.6k|#define CHECKS(str) ((str) && \
  523|  11.6k|                     strcmp((str), "help") == 0 ? (help_output |= 1) : 0)
  524|  11.6k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  525|  11.6k|                      strcmp((strv)[0], "help") == 0 ? (help_output |= 1) : 0)
  526|  11.6k|    if (CHECKS(opts->format)) {
  ------------------
  |  |  522|  11.6k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 11.6k]
  |  |  |  Branch (522:22): [True: 0, False: 11.6k]
  |  |  ------------------
  |  |  523|  11.6k|                     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|  11.6k|    if (CHECKV(opts->fopts)) {
  ------------------
  |  |  524|  11.6k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 11.6k]
  |  |  |  Branch (524:23): [True: 0, False: 11.6k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  11.6k|                      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|  11.6k|    if (CHECKV(opts->vopts)) {
  ------------------
  |  |  524|  11.6k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 11.6k]
  |  |  |  Branch (524:23): [True: 0, False: 11.6k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  11.6k|                      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|  11.6k|    if (CHECKV(opts->aopts)) {
  ------------------
  |  |  524|  11.6k|#define CHECKV(strv) ((strv) && (strv)[0] && \
  |  |  ------------------
  |  |  |  Branch (524:22): [True: 0, False: 11.6k]
  |  |  |  Branch (524:23): [True: 0, False: 11.6k]
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|  11.6k|                      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|  11.6k|    if (CHECKS(opts->vcodec)) {
  ------------------
  |  |  522|  11.6k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 11.6k]
  |  |  |  Branch (522:22): [True: 0, False: 11.6k]
  |  |  ------------------
  |  |  523|  11.6k|                     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|  11.6k|    if (CHECKS(opts->acodec)) {
  ------------------
  |  |  522|  11.6k|#define CHECKS(str) ((str) && \
  |  |  ------------------
  |  |  |  Branch (522:21): [True: 0, False: 11.6k]
  |  |  |  Branch (522:22): [True: 0, False: 11.6k]
  |  |  ------------------
  |  |  523|  11.6k|                     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|  11.6k|    return help_output;
  648|  11.6k|}
encode_lavc_getstatus:
  653|  10.9k|{
  654|  10.9k|    if (!ctx)
  ------------------
  |  Branch (654:9): [True: 10.9k, False: 0]
  ------------------
  655|  10.9k|        return -1;
  656|       |
  657|      0|    struct encode_priv *p = ctx->priv;
  658|       |
  659|      0|    double now = mp_time_sec();
  660|      0|    float minutes, megabytes, fps, x;
  661|      0|    float f = MPMAX(0.0001, relative_position);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  662|       |
  663|      0|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  664|       |
  665|      0|    if (p->failed) {
  ------------------
  |  Branch (665:9): [True: 0, False: 0]
  ------------------
  666|      0|        snprintf(buf, bufsize, "(failed)\n");
  667|      0|        goto done;
  668|      0|    }
  669|       |
  670|      0|    minutes = (now - p->t0) / 60.0 * (1 - f) / f;
  671|      0|    megabytes = p->muxer->pb ? (avio_size(p->muxer->pb) / 1048576.0 / f) : 0;
  ------------------
  |  Branch (671:17): [True: 0, False: 0]
  ------------------
  672|      0|    fps = p->frames / (now - p->t0);
  673|      0|    x = p->audioseconds / (now - p->t0);
  674|      0|    if (p->frames) {
  ------------------
  |  Branch (674:9): [True: 0, False: 0]
  ------------------
  675|      0|        snprintf(buf, bufsize, "{%.1fmin %.1ffps %.1fMB}",
  676|      0|                 minutes, fps, megabytes);
  677|      0|    } else if (p->audioseconds) {
  ------------------
  |  Branch (677:16): [True: 0, False: 0]
  ------------------
  678|      0|        snprintf(buf, bufsize, "{%.1fmin %.2fx %.1fMB}",
  679|      0|                 minutes, x, megabytes);
  680|      0|    } else {
  681|      0|        snprintf(buf, bufsize, "{%.1fmin %.1fMB}",
  682|      0|                 minutes, megabytes);
  683|      0|    }
  684|      0|    buf[bufsize - 1] = 0;
  685|       |
  686|      0|done:
  687|      0|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  688|      0|    return 0;
  689|      0|}
encode_lavc_didfail:
  692|  11.4M|{
  693|  11.4M|    if (!ctx)
  ------------------
  |  Branch (693:9): [True: 11.4M, False: 0]
  ------------------
  694|  11.4M|        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|  11.4M|}
mp_encoder_update_log:
  936|    476|{
  937|    476|    struct encode_opts *options = mp_get_config_group(NULL, global, &encode_config);
  938|    476|    if (options->file && (!strcmp(options->file, "-") ||
  ------------------
  |  Branch (938:9): [True: 0, False: 476]
  |  Branch (938:27): [True: 0, False: 0]
  ------------------
  939|      0|                          !strcmp(options->file, "/dev/stdout") ||
  ------------------
  |  Branch (939:27): [True: 0, False: 0]
  ------------------
  940|      0|                          !strcmp(options->file, "pipe:") ||
  ------------------
  |  Branch (940:27): [True: 0, False: 0]
  ------------------
  941|      0|                          !strcmp(options->file, "pipe:1")))
  ------------------
  |  Branch (941:27): [True: 0, False: 0]
  ------------------
  942|      0|    {
  943|      0|        mp_msg_force_stderr(global, true);
  944|      0|    }
  945|    476|    talloc_free(options);
  ------------------
  |  |   47|    476|#define talloc_free                     ta_free
  ------------------
  946|    476|}

mp_msg_level:
  184|   108M|{
  185|   108M|    struct mp_log_root *root = log->root;
  186|   108M|    if (!root)
  ------------------
  |  Branch (186:9): [True: 715k, False: 108M]
  ------------------
  187|   715k|        return -1;
  188|   108M|    if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) !=
  ------------------
  |  Branch (188:9): [True: 753k, False: 107M]
  ------------------
  189|   108M|        atomic_load_explicit(&root->reload_counter, memory_order_relaxed))
  190|   753k|    {
  191|   753k|        update_loglevel(log);
  192|   753k|    }
  193|       |    return atomic_load_explicit(&log->level, memory_order_relaxed);
  194|   108M|}
mp_msg_flush_status_line:
  295|  35.9k|{
  296|  35.9k|    if (!log->root)
  ------------------
  |  Branch (296:9): [True: 0, False: 35.9k]
  ------------------
  297|      0|        return;
  298|       |
  299|  35.9k|    mp_mutex_lock(&log->root->lock);
  ------------------
  |  |  134|  35.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|  35.9k|    msg_flush_status_line(log->root, clear);
  301|  35.9k|    mp_mutex_unlock(&log->root->lock);
  ------------------
  |  |  136|  35.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  302|  35.9k|}
mp_msg_has_status_line:
  317|  11.3k|{
  318|  11.3k|    struct mp_log_root *root = global->log->root;
  319|  11.3k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  11.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  320|  11.3k|    bool r = root->status_lines > 0;
  321|  11.3k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  11.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  322|  11.3k|    return r;
  323|  11.3k|}
mp_msg_sanitize:
  576|  83.1M|{
  577|  2.68G|    for (size_t i = 0; i < text->len; i++) {
  ------------------
  |  Branch (577:24): [True: 2.60G, False: 83.1M]
  ------------------
  578|  2.60G|        unsigned char ch = text->start[i];
  579|       |
  580|       |        // Allow SGR escape sequences only, filter anything else.
  581|  2.60G|        if (allow_sgr && ch == 0x1B && i + 2 < text->len && text->start[i + 1] == '[') {
  ------------------
  |  Branch (581:13): [True: 2.60G, False: 0]
  |  Branch (581:26): [True: 57.9k, False: 2.60G]
  |  Branch (581:40): [True: 57.8k, False: 141]
  |  Branch (581:61): [True: 4.84k, False: 52.9k]
  ------------------
  582|  4.84k|            size_t j = i + 2;
  583|  4.84k|            bool sgr = false;
  584|       |
  585|  6.51k|            while (j < text->len) {
  ------------------
  |  Branch (585:20): [True: 6.49k, False: 26]
  ------------------
  586|  6.49k|                unsigned char c = text->start[j];
  587|  6.49k|                if (c == 'm') {
  ------------------
  |  Branch (587:21): [True: 171, False: 6.32k]
  ------------------
  588|    171|                    sgr = true;
  589|    171|                    i = j;
  590|    171|                    break;
  591|  6.32k|                } else if ((c >= '0' && c <= '9') || c == ';' || c == ':') {
  ------------------
  |  Branch (591:29): [True: 3.18k, False: 3.13k]
  |  Branch (591:41): [True: 874, False: 2.31k]
  |  Branch (591:54): [True: 105, False: 5.34k]
  |  Branch (591:66): [True: 698, False: 4.64k]
  ------------------
  592|  1.67k|                    j++;
  593|  4.64k|                } else {
  594|  4.64k|                    break;
  595|  4.64k|                }
  596|  6.49k|            }
  597|       |
  598|       |            // Nuke everything that is not an SGR sequence
  599|  4.84k|            if (!sgr)
  ------------------
  |  Branch (599:17): [True: 4.67k, False: 171]
  ------------------
  600|  4.67k|                text->start[i] = '?';
  601|  4.84k|            continue;
  602|  4.84k|        }
  603|       |
  604|  2.60G|        int len = bstr_parse_utf8_code_length(ch);
  605|       |
  606|       |        // ASCII: allow only printable plus HT, LF, CR.
  607|  2.60G|        if (len == 1) {
  ------------------
  |  Branch (607:13): [True: 2.59G, False: 9.67M]
  ------------------
  608|  2.59G|            if (ch == 0x7F || (ch < 0x20 && ch != '\t' && ch != '\n' && ch != '\r'))
  ------------------
  |  Branch (608:17): [True: 216k, False: 2.59G]
  |  Branch (608:32): [True: 80.7M, False: 2.51G]
  |  Branch (608:45): [True: 80.7M, False: 29.4k]
  |  Branch (608:59): [True: 910k, False: 79.8M]
  |  Branch (608:73): [True: 871k, False: 38.9k]
  ------------------
  609|  1.08M|                text->start[i] = '?';
  610|  2.59G|            continue;
  611|  2.59G|        }
  612|       |
  613|       |        // Block UTF-8 C1 controls (C2 80..C2 9F), except PU1/PU2 used internally.
  614|  9.67M|        if (ch == 0xC2 && i + 1 < text->len && (text->start[i + 1] & 0xC0) == 0x80) {
  ------------------
  |  Branch (614:13): [True: 184k, False: 9.49M]
  |  Branch (614:27): [True: 184k, False: 231]
  |  Branch (614:48): [True: 171k, False: 12.5k]
  ------------------
  615|   171k|            unsigned char c1 = text->start[i + 1];
  616|   171k|            if (c1 >= 0x80 && c1 <= 0x9F && c1 != 0x91 && c1 != 0x92) {
  ------------------
  |  Branch (616:17): [True: 171k, False: 0]
  |  Branch (616:31): [True: 10.3k, False: 161k]
  |  Branch (616:45): [True: 9.87k, False: 513]
  |  Branch (616:59): [True: 9.04k, False: 833]
  ------------------
  617|  9.04k|                text->start[i] = '?';
  618|  9.04k|                text->start[i + 1] = '?';
  619|  9.04k|            }
  620|   171k|            i++;
  621|   171k|            continue;
  622|   171k|        }
  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|  9.50M|        if (len >= 2 && ch >= 0xC2 && i + len <= text->len) {
  ------------------
  |  Branch (626:13): [True: 5.35M, False: 4.14M]
  |  Branch (626:25): [True: 4.66M, False: 688k]
  |  Branch (626:39): [True: 4.63M, False: 33.1k]
  ------------------
  627|  4.63M|            bool valid = true;
  628|  11.2M|            for (int n = 1; n < len; n++)
  ------------------
  |  Branch (628:29): [True: 6.58M, False: 4.63M]
  ------------------
  629|  6.58M|                valid &= (text->start[i + n] & 0xC0) == 0x80;
  630|  4.63M|            if (valid) {
  ------------------
  |  Branch (630:17): [True: 332k, False: 4.30M]
  ------------------
  631|   332k|                i += len - 1;
  632|   332k|                continue;
  633|   332k|            }
  634|  4.63M|        }
  635|       |
  636|       |        // Block raw 8-bit C1 (0x80-0x9F); leave other invalid bytes alone.
  637|  9.17M|        if (ch <= 0x9F)
  ------------------
  |  Branch (637:13): [True: 1.36M, False: 7.80M]
  ------------------
  638|  1.36M|            text->start[i] = '?';
  639|  9.17M|    }
  640|  83.1M|}
mp_msg_va:
  654|   104M|{
  655|   104M|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (655:9): [True: 21.8M, False: 83.0M]
  ------------------
  656|  21.8M|        return; // do not display
  657|       |
  658|  83.0M|    struct mp_log_root *root = log->root;
  659|       |
  660|  83.0M|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  83.0M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  661|       |
  662|  83.0M|    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|  83.0M|    size_t sanitized = utf8_tail_start(log->partial[lev]);
  667|  83.0M|    if (log->partial[lev].len)
  ------------------
  |  Branch (667:9): [True: 3.55M, False: 79.5M]
  ------------------
  668|  3.55M|        bstr_xappend(root, &root->buffer, log->partial[lev]);
  669|  83.0M|    log->partial[lev].len = 0;
  670|       |
  671|  83.0M|    if (bstr_xappend_vasprintf(root, &root->buffer, format, va) < 0) {
  ------------------
  |  Branch (671:9): [True: 0, False: 83.0M]
  ------------------
  672|      0|        bstr_xappend(root, &root->buffer, bstr0("format error: "));
  673|      0|        bstr_xappend(root, &root->buffer, bstr0(format));
  674|      0|    }
  675|       |
  676|  83.0M|    bstr text = {root->buffer.start + sanitized, root->buffer.len - sanitized};
  677|  83.0M|    mp_msg_sanitize(&text, true);
  678|       |
  679|       |    // Remember last status message and restore it to ensure that it is
  680|       |    // always displayed
  681|  83.0M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (681:9): [True: 10.6k, False: 83.0M]
  ------------------
  682|  10.6k|        root->status_log = log;
  683|  10.6k|        root->status_line.len = 0;
  684|       |        // Use bstr_xappend instead bstrdup to reuse allocated memory
  685|  10.6k|        if (root->buffer.len)
  ------------------
  |  Branch (685:13): [True: 9.78k, False: 901]
  ------------------
  686|  9.78k|            bstr_xappend(root, &root->status_line, root->buffer);
  687|  10.6k|    }
  688|       |
  689|  83.0M|    if (lev == MSGL_STATS) {
  ------------------
  |  Branch (689:9): [True: 78.8k, False: 82.9M]
  ------------------
  690|  78.8k|        dump_stats(log, lev, root->buffer);
  691|  82.9M|    } else if (lev == MSGL_STATUS && !test_terminal_level(log, lev)) {
  ------------------
  |  Branch (691:16): [True: 10.6k, False: 82.9M]
  |  Branch (691:38): [True: 0, False: 10.6k]
  ------------------
  692|       |        /* discard */
  693|  82.9M|    } else {
  694|  82.9M|        write_term_msg(log, lev, root->buffer, &root->term_msg);
  695|       |
  696|  82.9M|        FILE *stream = term_msg_fp(root, lev);
  697|  82.9M|        if (root->term_msg.len) {
  ------------------
  |  Branch (697:13): [True: 1.21M, False: 81.7M]
  ------------------
  698|  1.21M|            root->term_status_msg.len = 0;
  699|  1.21M|            if (lev != MSGL_STATUS && root->status_line.len && root->status_log &&
  ------------------
  |  Branch (699:17): [True: 1.20M, False: 10.1k]
  |  Branch (699:39): [True: 1.06M, False: 136k]
  |  Branch (699:64): [True: 1.06M, False: 0]
  ------------------
  700|  1.06M|                is_status_output(root, lev) && test_terminal_level(root->status_log, MSGL_STATUS))
  ------------------
  |  Branch (700:17): [True: 1.06M, False: 0]
  |  Branch (700:48): [True: 1.06M, False: 0]
  ------------------
  701|  1.06M|            {
  702|  1.06M|                write_term_msg(root->status_log, MSGL_STATUS, root->status_line,
  703|  1.06M|                               &root->term_status_msg);
  704|  1.06M|            }
  705|  1.21M|            terminal_lock_output();
  706|  1.21M|            fwrite(root->term_msg.start, root->term_msg.len, 1, stream);
  707|  1.21M|            if (root->term_status_msg.len)
  ------------------
  |  Branch (707:17): [True: 1.06M, False: 146k]
  ------------------
  708|  1.06M|                fwrite(root->term_status_msg.start, root->term_status_msg.len, 1, stream);
  709|  1.21M|            fflush(stream);
  710|  1.21M|            terminal_unlock_output();
  711|  1.21M|        }
  712|  82.9M|    }
  713|       |
  714|  83.0M|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  83.0M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  715|  83.0M|}
mp_log_new:
  737|  1.90M|{
  738|  1.90M|    mp_assert(parent);
  ------------------
  |  |   41|  1.90M|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 1.90M, False: 0]
  ------------------
  739|  1.90M|    struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
  ------------------
  |  |   27|  1.90M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.90M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.90M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  1.90M|    if (!parent->root)
  ------------------
  |  Branch (740:9): [True: 0, False: 1.90M]
  ------------------
  741|      0|        return log; // same as null_log
  742|  1.90M|    talloc_set_destructor(log, destroy_log);
  ------------------
  |  |   41|  1.90M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  743|  1.90M|    log->root = parent->root;
  744|  1.90M|    log->max_level = MSGL_MAX;
  745|  1.90M|    if (name) {
  ------------------
  |  Branch (745:9): [True: 1.86M, False: 46.5k]
  ------------------
  746|  1.86M|        if (name[0] == '!') {
  ------------------
  |  Branch (746:13): [True: 277k, False: 1.58M]
  ------------------
  747|   277k|            name = &name[1];
  748|  1.58M|        } else if (name[0] == '/') {
  ------------------
  |  Branch (748:20): [True: 0, False: 1.58M]
  ------------------
  749|      0|            name = &name[1];
  750|      0|            log->prefix = talloc_strdup(log, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  751|  1.58M|        } else {
  752|  1.58M|            log->prefix = parent->prefix
  ------------------
  |  Branch (752:27): [True: 103k, False: 1.48M]
  ------------------
  753|  1.58M|                    ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   103k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   103k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  754|  1.58M|                    : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.48M|#define talloc_strdup                   ta_xstrdup
  ------------------
  755|  1.58M|        }
  756|  1.86M|        log->verbose_prefix = parent->prefix
  ------------------
  |  Branch (756:31): [True: 103k, False: 1.75M]
  ------------------
  757|  1.86M|                ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   103k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   103k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  758|  1.86M|                : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.75M|#define talloc_strdup                   ta_xstrdup
  ------------------
  759|  1.86M|        if (log->prefix && !log->prefix[0])
  ------------------
  |  Branch (759:13): [True: 1.58M, False: 277k]
  |  Branch (759:28): [True: 11.6k, False: 1.57M]
  ------------------
  760|  11.6k|            log->prefix = NULL;
  761|  1.86M|        if (!log->verbose_prefix[0])
  ------------------
  |  Branch (761:13): [True: 11.6k, False: 1.84M]
  ------------------
  762|  11.6k|            log->verbose_prefix = "global";
  763|  1.86M|    } else {
  764|  46.5k|        log->prefix = talloc_strdup(log, parent->prefix);
  ------------------
  |  |   50|  46.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|  46.5k|        log->verbose_prefix = talloc_strdup(log, parent->verbose_prefix);
  ------------------
  |  |   50|  46.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  766|  46.5k|    }
  767|  1.90M|    return log;
  768|  1.90M|}
mp_msg_init:
  771|  11.6k|{
  772|  11.6k|    mp_assert(!global->log);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (772:5): [True: 11.6k, False: 0]
  ------------------
  773|       |
  774|  11.6k|    struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
  ------------------
  |  |   27|  11.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  775|  11.6k|    *root = (struct mp_log_root){
  776|  11.6k|        .global = global,
  777|  11.6k|        .reload_counter = 1,
  778|  11.6k|    };
  779|       |
  780|  11.6k|    mp_mutex_init(&root->lock);
  781|  11.6k|    mp_mutex_init(&root->log_file_lock);
  782|  11.6k|    mp_cond_init(&root->log_file_wakeup);
  783|       |
  784|  11.6k|    struct mp_log dummy = { .root = root };
  785|  11.6k|    struct mp_log *log = mp_log_new(root, &dummy, "");
  786|       |
  787|  11.6k|    global->log = log;
  788|  11.6k|}
mp_msg_update_msglevels:
  881|  24.0k|{
  882|  24.0k|    struct mp_log_root *root = global->log->root;
  883|       |
  884|  24.0k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  24.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  885|       |
  886|  24.0k|    root->verbose = opts->verbose;
  887|  24.0k|    root->really_quiet = opts->msg_really_quiet;
  888|  24.0k|    root->module = opts->msg_module;
  889|  24.0k|    root->use_terminal = opts->use_terminal;
  890|  24.0k|    root->show_time = opts->msg_time;
  891|       |
  892|  24.0k|    if (root->really_quiet)
  ------------------
  |  Branch (892:9): [True: 11, False: 24.0k]
  ------------------
  893|     11|        root->status_lines = 0;
  894|       |
  895|  25.0k|    for (int i = STDOUT_FILENO; i <= STDERR_FILENO && root->use_terminal; ++i) {
  ------------------
  |  Branch (895:33): [True: 24.5k, False: 476]
  |  Branch (895:55): [True: 952, False: 23.6k]
  ------------------
  896|    952|        root->isatty[i] = isatty(i);
  897|    952|        root->color[i] = opts->msg_color && root->isatty[i];
  ------------------
  |  Branch (897:26): [True: 952, False: 0]
  |  Branch (897:45): [True: 0, False: 952]
  ------------------
  898|    952|    }
  899|       |
  900|  24.0k|    m_option_type_msglevels.free(&root->msg_levels);
  901|  24.0k|    m_option_type_msglevels.copy(NULL, &root->msg_levels, &opts->msg_levels);
  902|       |
  903|  24.0k|    atomic_fetch_add(&root->reload_counter, 1);
  904|  24.0k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  24.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  905|       |
  906|  24.0k|    if (check_new_path(global, opts->log_file, &root->log_path)) {
  ------------------
  |  Branch (906:9): [True: 0, False: 24.0k]
  ------------------
  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|  24.0k|    if (check_new_path(global, opts->dump_stats, &root->stats_path)) {
  ------------------
  |  Branch (953:9): [True: 218, False: 23.8k]
  ------------------
  954|    218|        bool open_error = false;
  955|       |
  956|    218|        mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|    218|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  957|    218|        if (root->stats_file)
  ------------------
  |  Branch (957:13): [True: 113, False: 105]
  ------------------
  958|    113|            fclose(root->stats_file);
  959|    218|        root->stats_file = NULL;
  960|    218|        if (root->stats_path) {
  ------------------
  |  Branch (960:13): [True: 218, False: 0]
  ------------------
  961|    218|            root->stats_file = fopen(root->stats_path, "wb");
  ------------------
  |  |   84|    218|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
  962|    218|            open_error = !root->stats_file;
  963|    218|        }
  964|    218|        mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|    218|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  965|       |
  966|    218|        if (open_error) {
  ------------------
  |  Branch (966:13): [True: 0, False: 218]
  ------------------
  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|    218|    }
  971|  24.0k|}
mp_msg_has_log_file:
  984|  48.1k|{
  985|  48.1k|    struct mp_log_root *root = global->log->root;
  986|       |
  987|  48.1k|    return !!root->log_file;
  988|  48.1k|}
mp_msg_uninit:
  991|  11.6k|{
  992|  11.6k|    struct mp_log_root *root = global->log->root;
  993|  11.6k|    mp_msg_flush_status_line(global->log, true);
  994|  11.6k|    if (root->really_quiet && root->isatty[term_msg_fileno(root, MSGL_STATUS)]) {
  ------------------
  |  Branch (994:9): [True: 6, False: 11.6k]
  |  Branch (994:31): [True: 0, False: 6]
  ------------------
  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|  11.6k|    terminate_log_file_thread(root);
 1000|  11.6k|    mp_msg_log_buffer_destroy(root->early_buffer);
 1001|  11.6k|    mp_msg_log_buffer_destroy(root->early_filebuffer);
 1002|  11.6k|    mp_assert(root->num_buffers == 0);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (1002:5): [True: 11.6k, False: 0]
  ------------------
 1003|  11.6k|    if (root->stats_file)
  ------------------
  |  Branch (1003:9): [True: 105, False: 11.5k]
  ------------------
 1004|    105|        fclose(root->stats_file);
 1005|  11.6k|    talloc_free(root->stats_path);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1006|  11.6k|    talloc_free(root->log_path);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1007|  11.6k|    m_option_type_msglevels.free(&root->msg_levels);
 1008|  11.6k|    mp_mutex_destroy(&root->lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1009|  11.6k|    mp_mutex_destroy(&root->log_file_lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1010|  11.6k|    mp_cond_destroy(&root->log_file_wakeup);
 1011|  11.6k|    talloc_free(root);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1012|       |    global->log = NULL;
 1013|  11.6k|}
mp_msg_set_early_logging:
 1061|  23.3k|{
 1062|  23.3k|    struct mp_log_root *root = global->log->root;
 1063|       |
 1064|  23.3k|    mp_msg_set_early_logging_raw(global, enable, &root->early_buffer,
 1065|  23.3k|                                 EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   48|  23.3k|#define EARLY_TERM_BUF 100
  ------------------
                                               EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   27|  23.3k|#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|  23.3k|    mp_msg_set_early_logging_raw(global, enable, &root->early_filebuffer,
 1069|  23.3k|                                 EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   54|  23.3k|#define EARLY_FILE_BUF 5000
  ------------------
                                               EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   29|  23.3k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
 1070|  23.3k|}
mp_msg_log_buffer_new:
 1076|  23.3k|{
 1077|  23.3k|    struct mp_log_root *root = global->log->root;
 1078|       |
 1079|  23.3k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1080|       |
 1081|  23.3k|    if (level == MP_LOG_BUFFER_MSGL_TERM) {
  ------------------
  |  |   27|  23.3k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (1081:9): [True: 11.6k, False: 11.6k]
  ------------------
 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|  11.6k|        if (root->early_buffer) {
  ------------------
  |  Branch (1086:13): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|    }
 1096|       |
 1097|  23.3k|    mp_assert(size > 0);
  ------------------
  |  |   41|  23.3k|#define mp_assert assert
  ------------------
  |  Branch (1097:5): [True: 23.3k, False: 0]
  ------------------
 1098|       |
 1099|  23.3k|    struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer);
  ------------------
  |  |   34|  23.3k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  23.3k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  23.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|  23.3k|    *buffer = (struct mp_log_buffer) {
 1101|  23.3k|        .root = root,
 1102|  23.3k|        .level = level,
 1103|  23.3k|        .entries = talloc_array(buffer, struct mp_log_buffer_entry *, size),
  ------------------
  |  |   29|  23.3k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  23.3k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  23.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|  23.3k|        .capacity = size,
 1105|  23.3k|        .wakeup_cb = wakeup_cb,
 1106|  23.3k|        .wakeup_cb_ctx = wakeup_cb_ctx,
 1107|  23.3k|    };
 1108|       |
 1109|  23.3k|    mp_mutex_init(&buffer->lock);
 1110|       |
 1111|  23.3k|    MP_TARRAY_APPEND(root, root->buffers, root->num_buffers, buffer);
  ------------------
  |  |  105|  23.3k|    do {                                            \
  |  |  106|  23.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  23.3k|    do {                                            \
  |  |  |  |   97|  23.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  23.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  23.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  23.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 11.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  23.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  23.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 23.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  23.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  23.3k|        (idxvar)++;                                 \
  |  |  109|  23.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 23.3k]
  |  |  ------------------
  ------------------
 1112|       |
 1113|  23.3k|    atomic_fetch_add(&root->reload_counter, 1);
 1114|  23.3k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|       |
 1116|  23.3k|    return buffer;
 1117|  23.3k|}
mp_msg_log_buffer_destroy:
 1161|  93.3k|{
 1162|  93.3k|    if (!buffer)
  ------------------
  |  Branch (1162:9): [True: 70.0k, False: 23.3k]
  ------------------
 1163|  70.0k|        return;
 1164|       |
 1165|  23.3k|    struct mp_log_root *root = buffer->root;
 1166|       |
 1167|  23.3k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1168|       |
 1169|  23.3k|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (1169:21): [True: 23.3k, False: 0]
  ------------------
 1170|  23.3k|        if (root->buffers[n] == buffer) {
  ------------------
  |  Branch (1170:13): [True: 23.3k, False: 0]
  ------------------
 1171|  23.3k|            MP_TARRAY_REMOVE_AT(root->buffers, root->num_buffers, n);
  ------------------
  |  |  143|  23.3k|    do {                                            \
  |  |  144|  23.3k|        size_t at_ = (at);                          \
  |  |  145|  23.3k|        assert(at_ < (idxvar));                     \
  |  |  146|  23.3k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  23.3k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  23.3k|        (idxvar)--;                                 \
  |  |  149|  23.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 23.3k]
  |  |  ------------------
  ------------------
  |  Branch (1171:13): [True: 23.3k, False: 0]
  ------------------
 1172|  23.3k|            goto found;
 1173|  23.3k|        }
 1174|  23.3k|    }
 1175|       |
 1176|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (1176:5): [Folded, False: 0]
  ------------------
 1177|       |
 1178|  23.3k|found:
 1179|       |
 1180|   466k|    while (buffer->num_entries)
  ------------------
  |  Branch (1180:12): [True: 443k, False: 23.3k]
  ------------------
 1181|   443k|        talloc_free(log_buffer_read(buffer));
  ------------------
  |  |   47|   443k|#define talloc_free                     ta_free
  ------------------
 1182|       |
 1183|  23.3k|    mp_mutex_destroy(&buffer->lock);
  ------------------
  |  |  133|  23.3k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1184|  23.3k|    talloc_free(buffer);
  ------------------
  |  |   47|  23.3k|#define talloc_free                     ta_free
  ------------------
 1185|       |
 1186|  23.3k|    atomic_fetch_add(&root->reload_counter, 1);
 1187|  23.3k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1188|  23.3k|}
mp_msg:
 1223|   104M|{
 1224|   104M|    va_list va;
 1225|   104M|    va_start(va, format);
 1226|   104M|    mp_msg_va(log, lev, format, va);
 1227|       |    va_end(va);
 1228|   104M|}
mp_msg_find_level:
 1255|   741k|{
 1256|  5.93M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) {
  ------------------
  |  |   49|  5.93M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (1256:21): [True: 5.93M, False: 0]
  ------------------
 1257|  5.93M|        if (mp_log_levels[n] && !strcasecmp(s, mp_log_levels[n]))
  ------------------
  |  Branch (1257:13): [True: 5.93M, False: 0]
  |  Branch (1257:33): [True: 741k, False: 5.19M]
  ------------------
 1258|   741k|            return n;
 1259|  5.93M|    }
 1260|      0|    return -1;
 1261|   741k|}
msg.c:update_loglevel:
  141|   753k|{
  142|   753k|    struct mp_log_root *root = log->root;
  143|   753k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   753k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  144|   753k|    int level = MSGL_STATUS + root->verbose; // default log level
  145|   753k|    if (root->really_quiet)
  ------------------
  |  Branch (145:9): [True: 1.35k, False: 752k]
  ------------------
  146|  1.35k|        level = -1;
  147|  1.48M|    for (int n = 0; root->msg_levels && root->msg_levels[n * 2 + 0]; n++) {
  ------------------
  |  Branch (147:21): [True: 1.46M, False: 23.3k]
  |  Branch (147:41): [True: 730k, False: 730k]
  ------------------
  148|   730k|        if (match_mod(log->verbose_prefix, root->msg_levels[n * 2 + 0]))
  ------------------
  |  Branch (148:13): [True: 730k, False: 0]
  ------------------
  149|   730k|            level = mp_msg_find_level(root->msg_levels[n * 2 + 1]);
  150|   730k|    }
  151|   753k|    log->terminal_level = level;
  152|   870k|    for (int n = 0; n < log->root->num_buffers; n++) {
  ------------------
  |  Branch (152:21): [True: 116k, False: 753k]
  ------------------
  153|   116k|        int buffer_level = log->root->buffers[n]->level;
  154|   116k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   116k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (154:13): [True: 58.3k, False: 58.3k]
  ------------------
  155|  58.3k|            buffer_level = MSGL_DEBUG;
  156|   116k|        if (buffer_level != MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   116k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (156:13): [True: 58.3k, False: 58.3k]
  ------------------
  157|  58.3k|            level = MPMAX(level, buffer_level);
  ------------------
  |  |   44|  58.3k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 58.3k, False: 0]
  |  |  ------------------
  ------------------
  158|   116k|    }
  159|   753k|    if (log->root->log_file)
  ------------------
  |  Branch (159:9): [True: 0, False: 753k]
  ------------------
  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|   753k|    if (log->root->stats_file)
  ------------------
  |  Branch (161:9): [True: 4.45k, False: 749k]
  ------------------
  162|  4.45k|        level = MPMAX(level, MSGL_STATS);
  ------------------
  |  |   44|  4.45k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 4.45k]
  |  |  ------------------
  ------------------
  163|   753k|    level = MPMIN(level, log->max_level);
  ------------------
  |  |   45|   753k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 753k]
  |  |  ------------------
  ------------------
  164|   753k|    atomic_store_explicit(&log->level, level, memory_order_relaxed);
  165|   753k|    atomic_store(&log->reload_counter, atomic_load(&log->root->reload_counter));
  166|   753k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|   753k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  167|   753k|}
msg.c:match_mod:
  132|   730k|{
  133|   730k|    if (!strcmp(mod, "all"))
  ------------------
  |  Branch (133:9): [True: 730k, False: 0]
  ------------------
  134|   730k|        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|   730k|}
msg.c:msg_flush_status_line:
  265|  35.9k|{
  266|  35.9k|    if (!root->status_lines)
  ------------------
  |  Branch (266:9): [True: 34.7k, False: 1.24k]
  ------------------
  267|  34.7k|        goto done;
  268|       |
  269|  1.24k|    FILE *fp = term_msg_fp(root, MSGL_STATUS);
  270|  1.24k|    if (!clear) {
  ------------------
  |  Branch (270:9): [True: 866, False: 374]
  ------------------
  271|    866|        terminal_lock_output();
  272|    866|        if (root->isatty[term_msg_fileno(root, MSGL_STATUS)])
  ------------------
  |  Branch (272:13): [True: 0, False: 866]
  ------------------
  273|      0|            fprintf(fp, TERM_ESC_RESTORE_CURSOR);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  274|    866|        fprintf(fp, "\n");
  275|    866|        terminal_unlock_output();
  276|    866|        root->blank_lines = 0;
  277|    866|        root->status_lines = 0;
  278|    866|        goto done;
  279|    866|    }
  280|       |
  281|    374|    bstr term_msg = {0};
  282|    374|    prepare_prefix(root, &term_msg, MSGL_STATUS, 0);
  283|    374|    if (term_msg.len) {
  ------------------
  |  Branch (283:9): [True: 374, False: 0]
  ------------------
  284|    374|        terminal_lock_output();
  285|    374|        fprintf(fp, "%.*s", BSTR_P(term_msg));
  ------------------
  |  |  307|    374|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 374, False: 0]
  |  |  ------------------
  ------------------
  286|    374|        terminal_unlock_output();
  287|    374|        talloc_free(term_msg.start);
  ------------------
  |  |   47|    374|#define talloc_free                     ta_free
  ------------------
  288|    374|    }
  289|       |
  290|  35.9k|done:
  291|  35.9k|    root->status_line.len = 0;
  292|  35.9k|}
msg.c:prepare_prefix:
  221|  2.27M|{
  222|  2.27M|    int new_lines = lev == MSGL_STATUS ? term_lines : 0;
  ------------------
  |  Branch (222:21): [True: 1.07M, False: 1.20M]
  ------------------
  223|  2.27M|    out->len = 0;
  224|       |
  225|  2.27M|    if (!is_status_output(root, lev))
  ------------------
  |  Branch (225:9): [True: 0, False: 2.27M]
  ------------------
  226|      0|        return;
  227|       |
  228|  2.27M|    if (!root->isatty[term_msg_fileno(root, lev)]) {
  ------------------
  |  Branch (228:9): [True: 2.27M, False: 0]
  ------------------
  229|  2.27M|        if (root->status_lines)
  ------------------
  |  Branch (229:13): [True: 1.07M, False: 1.20M]
  ------------------
  230|  1.07M|            bstr_xappend(root, out, bstr0("\n"));
  231|  2.27M|        root->status_lines = new_lines;
  232|  2.27M|        return;
  233|  2.27M|    }
  234|       |
  235|       |    // Set cursor state
  236|      0|    if (new_lines && !root->status_lines) {
  ------------------
  |  Branch (236:9): [True: 0, False: 0]
  |  Branch (236:22): [True: 0, False: 0]
  ------------------
  237|      0|        bstr_xappend(root, out, bstr0(TERM_ESC_HIDE_CURSOR));
  ------------------
  |  |   29|      0|#define TERM_ESC_HIDE_CURSOR        "\033[?25l"
  ------------------
  238|      0|    } else if (!new_lines && root->status_lines) {
  ------------------
  |  Branch (238:16): [True: 0, False: 0]
  |  Branch (238:30): [True: 0, False: 0]
  ------------------
  239|      0|        bstr_xappend(root, out, bstr0(TERM_ESC_RESTORE_CURSOR));
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  240|      0|    }
  241|       |
  242|      0|    int line_skip = 0;
  243|      0|    if (root->status_lines) {
  ------------------
  |  Branch (243:9): [True: 0, False: 0]
  ------------------
  244|       |        // Clear previous status line
  245|      0|        bstr_xappend(root, out, bstr0("\033[1K\r"));
  246|      0|        bstr up_clear = bstr0("\033[A\033[K");
  247|      0|        for (int i = 1; i < root->status_lines; ++i)
  ------------------
  |  Branch (247:25): [True: 0, False: 0]
  ------------------
  248|      0|            bstr_xappend(root, out, up_clear);
  249|      0|        mp_assert(root->status_lines > 0 && root->blank_lines >= root->status_lines);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (249:9): [True: 0, False: 0]
  |  Branch (249:9): [True: 0, False: 0]
  ------------------
  250|      0|        line_skip = root->blank_lines - root->status_lines;
  251|      0|    }
  252|       |
  253|      0|    if (new_lines)
  ------------------
  |  Branch (253:9): [True: 0, False: 0]
  ------------------
  254|      0|        line_skip -= MPMAX(0, root->blank_lines - new_lines);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  255|       |
  256|      0|    if (line_skip)
  ------------------
  |  Branch (256:9): [True: 0, False: 0]
  ------------------
  257|      0|        bstr_xappend_asprintf(root, out, line_skip > 0 ? "\033[%dA" : "\033[%dB", abs(line_skip));
  ------------------
  |  Branch (257:42): [True: 0, False: 0]
  ------------------
  258|       |
  259|      0|    root->blank_lines = MPMAX(0, root->blank_lines - term_lines);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  260|      0|    root->status_lines = new_lines;
  261|      0|    root->blank_lines += root->status_lines;
  262|      0|}
msg.c:term_msg_fp:
  202|  83.0M|{
  203|  83.0M|    return term_msg_fileno(root, lev) == STDERR_FILENO ? stderr : stdout;
  ------------------
  |  Branch (203:12): [True: 0, False: 83.0M]
  ------------------
  204|  83.0M|}
msg.c:utf8_tail_start:
  644|  83.0M|{
  645|  83.0M|    for (size_t n = 1; n <= 4 && n <= str.len; n++) {
  ------------------
  |  Branch (645:24): [True: 83.0M, False: 23]
  |  Branch (645:34): [True: 3.55M, False: 79.5M]
  ------------------
  646|  3.55M|        unsigned char ch = str.start[str.len - n];
  647|  3.55M|        if ((ch & 0xC0) != 0x80)
  ------------------
  |  Branch (647:13): [True: 3.55M, False: 1.34k]
  ------------------
  648|  3.55M|            return ch >= 0xC0 ? str.len - n : str.len;
  ------------------
  |  Branch (648:20): [True: 2.56k, False: 3.55M]
  ------------------
  649|  3.55M|    }
  650|  79.5M|    return str.len;
  651|  83.0M|}
msg.c:dump_stats:
  511|  78.8k|{
  512|  78.8k|    struct mp_log_root *root = log->root;
  513|  78.8k|    if (lev == MSGL_STATS && root->stats_file)
  ------------------
  |  Branch (513:9): [True: 78.8k, False: 0]
  |  Branch (513:30): [True: 78.8k, False: 0]
  ------------------
  514|  78.8k|        fprintf(root->stats_file, "%"PRId64" %.*s\n", mp_time_ns(), BSTR_P(text));
  ------------------
  |  |  307|  78.8k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 78.8k, False: 0]
  |  |  ------------------
  ------------------
  515|  78.8k|}
msg.c:test_terminal_level:
  379|  85.1M|{
  380|  85.1M|    return lev <= log->terminal_level && log->root->use_terminal &&
  ------------------
  |  Branch (380:12): [True: 85.1M, False: 0]
  |  Branch (380:42): [True: 3.54M, False: 81.6M]
  ------------------
  381|  3.54M|           !(lev == MSGL_STATUS && terminal_in_background());
  ------------------
  |  Branch (381:14): [True: 2.15M, False: 1.39M]
  |  Branch (381:36): [True: 0, False: 2.15M]
  ------------------
  382|  85.1M|}
msg.c:write_term_msg:
  518|  84.0M|{
  519|  84.0M|    struct mp_log_root *root = log->root;
  520|  84.0M|    bool print_term = test_terminal_level(log, lev);
  521|  84.0M|    int fileno = term_msg_fileno(root, lev);
  522|  84.0M|    int term_w = 0, term_h = 0;
  523|  84.0M|    if (print_term && root->isatty[fileno])
  ------------------
  |  Branch (523:9): [True: 2.46M, False: 81.6M]
  |  Branch (523:23): [True: 0, False: 2.46M]
  ------------------
  524|      0|        terminal_get_size(&term_w, &term_h);
  525|       |
  526|  84.0M|    out->len = 0;
  527|       |
  528|       |    // Split away each line. Normally we require full lines; buffer partial
  529|       |    // lines if they happen.
  530|  84.0M|    root->term_msg_tmp.len = 0;
  531|  84.0M|    int term_msg_lines = 0;
  532|       |
  533|  84.0M|    bstr str = text;
  534|   164M|    while (str.len) {
  ------------------
  |  Branch (534:12): [True: 84.5M, False: 79.4M]
  ------------------
  535|  84.5M|        bstr line = bstr_getline(str, &str);
  536|  84.5M|        if (line.start[line.len - 1] != '\n') {
  ------------------
  |  Branch (536:13): [True: 4.60M, False: 79.9M]
  ------------------
  537|  4.60M|            mp_assert(str.len == 0);
  ------------------
  |  |   41|  4.60M|#define mp_assert assert
  ------------------
  |  Branch (537:13): [True: 4.60M, False: 0]
  ------------------
  538|  4.60M|            str = line;
  539|  4.60M|            break;
  540|  4.60M|        }
  541|       |
  542|  84.5M|        bool clip = bstr_eatstart0(&line, TERM_MSG_0);
  ------------------
  |  |   30|  79.9M|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  79.9M|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  543|  79.9M|        if (print_term) {
  ------------------
  |  Branch (543:13): [True: 1.33M, False: 78.6M]
  ------------------
  544|  1.33M|            int line_w;
  545|  1.33M|            append_terminal_line(log, lev, line, &root->term_msg_tmp, &line_w,
  546|  1.33M|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (546:34): [True: 0, False: 1.33M]
  |  Branch (546:42): [True: 0, False: 0]
  ------------------
  547|  1.33M|            term_msg_lines += (!line_w || !term_w)
  ------------------
  |  Branch (547:32): [True: 1.33M, False: 0]
  |  Branch (547:43): [True: 0, False: 0]
  ------------------
  548|  1.33M|                                ? 1 : (line_w + term_w - 1) / term_w;
  549|  1.33M|        }
  550|  79.9M|        write_msg_to_buffers(log, lev, line);
  551|  79.9M|    }
  552|       |
  553|  84.0M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (553:9): [True: 1.07M, False: 82.9M]
  ------------------
  554|  1.07M|        int line_w = 0;
  555|  1.07M|        bool clip = bstr_eatstart0(&str, TERM_MSG_0);
  ------------------
  |  |   30|  1.07M|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  1.07M|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  556|  1.07M|        if (str.len && print_term)
  ------------------
  |  Branch (556:13): [True: 1.05M, False: 23.0k]
  |  Branch (556:24): [True: 1.05M, False: 0]
  ------------------
  557|  1.05M|            append_terminal_line(log, lev, str, &root->term_msg_tmp, &line_w,
  558|  1.05M|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (558:34): [True: 0, False: 1.05M]
  |  Branch (558:42): [True: 0, False: 0]
  ------------------
  559|  1.07M|        term_msg_lines += !term_w ? (str.len ? 1 : 0)
  ------------------
  |  Branch (559:27): [True: 1.07M, False: 0]
  |  Branch (559:38): [True: 1.05M, False: 23.0k]
  ------------------
  560|  1.07M|                                  : (line_w + term_w - 1) / term_w;
  561|  82.9M|    } else if (str.len) {
  ------------------
  |  Branch (561:16): [True: 3.55M, False: 79.4M]
  ------------------
  562|  3.55M|        bstr_xappend(NULL, &log->partial[lev], str);
  563|  3.55M|    }
  564|       |
  565|  84.0M|    if (print_term && (root->term_msg_tmp.len || lev == MSGL_STATUS)) {
  ------------------
  |  Branch (565:9): [True: 2.46M, False: 81.6M]
  |  Branch (565:24): [True: 2.27M, False: 189k]
  |  Branch (565:50): [True: 901, False: 188k]
  ------------------
  566|  2.27M|        prepare_prefix(root, out, lev, term_msg_lines);
  567|  2.27M|        if (root->color[fileno] && root->term_msg_tmp.len) {
  ------------------
  |  Branch (567:13): [True: 0, False: 2.27M]
  |  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|  2.27M|        bstr_xappend(root, out, root->term_msg_tmp);
  572|  2.27M|    }
  573|  84.0M|}
msg.c:append_terminal_line:
  386|  2.39M|{
  387|  2.39M|    struct mp_log_root *root = log->root;
  388|       |
  389|  2.39M|    size_t start = term_msg->len;
  390|       |
  391|  2.39M|    if (root->show_time)
  ------------------
  |  Branch (391:9): [True: 4.55k, False: 2.38M]
  ------------------
  392|  4.55k|        bstr_xappend_asprintf(root, term_msg, "[%10.6f] ", mp_time_sec());
  393|       |
  394|  2.39M|    const char *log_prefix = (lev >= MSGL_V) || root->verbose || root->module
  ------------------
  |  Branch (394:30): [True: 485k, False: 1.90M]
  |  Branch (394:49): [True: 0, False: 1.90M]
  |  Branch (394:66): [True: 10.8k, False: 1.89M]
  ------------------
  395|  2.39M|                                ? log->verbose_prefix : log->prefix;
  396|  2.39M|    if (log_prefix) {
  ------------------
  |  Branch (396:9): [True: 1.21M, False: 1.17M]
  ------------------
  397|  1.21M|        if (root->module) {
  ------------------
  |  Branch (397:13): [True: 12.2k, False: 1.20M]
  ------------------
  398|  12.2k|            pretty_print_module(root, term_msg, log_prefix, lev);
  399|  1.20M|        } else {
  400|  1.20M|            bstr_xappend_asprintf(root, term_msg, "[%s] ", log_prefix);
  401|  1.20M|        }
  402|  1.21M|    }
  403|       |
  404|  2.39M|    bstr_xappend(root, term_msg, text);
  405|       |
  406|  2.39M|    const unsigned char *cut_pos = NULL;
  407|  2.39M|    int ellipsis_width = 2;
  408|  2.39M|    int width = term_disp_width(bstr_splice(*term_msg, start, term_msg->len),
  409|  2.39M|                                term_w - ellipsis_width, &cut_pos);
  410|  2.39M|    if (cut_pos) {
  ------------------
  |  Branch (410:9): [True: 0, False: 2.39M]
  ------------------
  411|      0|        int new_len = cut_pos - term_msg->start;
  412|      0|        bstr rem = bstrdup(NULL, (bstr){(unsigned char *)cut_pos, term_msg->len - new_len});
  413|      0|        void *ptr = rem.start;
  414|      0|        term_msg->len = new_len;
  415|       |
  416|      0|        bstr_xappend(root, term_msg, bstr0(".."));
  417|       |
  418|      0|        while (rem.len) {
  ------------------
  |  Branch (418:16): [True: 0, False: 0]
  ------------------
  419|      0|            if (bstr_eatstart0(&rem, "\n")) {
  ------------------
  |  Branch (419:17): [True: 0, False: 0]
  ------------------
  420|      0|                bstr_xappend(root, term_msg, bstr0("\n"));
  421|      0|                continue;
  422|      0|            }
  423|      0|            if (bstr_eatstart0(&rem, "\033[")) {
  ------------------
  |  Branch (423:17): [True: 0, False: 0]
  ------------------
  424|      0|                bstr_xappend(root, term_msg, bstr0("\033["));
  425|       |
  426|      0|                while (rem.len && !((*rem.start >= '@' && *rem.start <= '~') || *rem.start == 'm')) {
  ------------------
  |  Branch (426:24): [True: 0, False: 0]
  |  Branch (426:38): [True: 0, False: 0]
  |  Branch (426:59): [True: 0, False: 0]
  |  Branch (426:81): [True: 0, False: 0]
  ------------------
  427|      0|                    bstr_xappend(root, term_msg, bstr_splice(rem, 0, 1));
  428|      0|                    rem = bstr_cut(rem, 1);
  429|      0|                }
  430|      0|                bstr_xappend(root, term_msg, bstr_splice(rem, 0, 1));
  431|      0|            }
  432|      0|            rem = bstr_cut(rem, 1);
  433|      0|        }
  434|      0|        talloc_free(ptr);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  435|       |
  436|      0|        width += ellipsis_width;
  437|      0|    }
  438|  2.39M|    *line_w = root->isatty[term_msg_fileno(root, lev)] ? width : 0;
  ------------------
  |  Branch (438:15): [True: 0, False: 2.39M]
  ------------------
  439|  2.39M|}
msg.c:pretty_print_module:
  357|  12.2k|{
  358|  12.2k|    size_t prefix_len = strlen(prefix);
  359|  12.2k|    root->module_indent = MPMAX(10, MPMAX(root->module_indent, prefix_len));
  ------------------
  |  |   44|  24.5k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 9, False: 12.2k]
  |  |  |  Branch (44:29): [True: 5.81k, False: 6.45k]
  |  |  |  Branch (44:41): [True: 5.81k, False: 6.44k]
  |  |  ------------------
  ------------------
  360|  12.2k|    bool color = root->color[term_msg_fileno(root, lev)];
  361|       |
  362|       |    // Use random color based on the name of the module
  363|  12.2k|    if (color) {
  ------------------
  |  Branch (363:9): [True: 0, False: 12.2k]
  ------------------
  364|      0|        unsigned int mod = 0;
  365|      0|        for (int i = 0; i < prefix_len; ++i)
  ------------------
  |  Branch (365:25): [True: 0, False: 0]
  ------------------
  366|      0|            mod = mod * 33 + prefix[i];
  367|      0|        set_term_color(root, text, (mod + 1) % 15 + 1);
  368|      0|    }
  369|       |
  370|  12.2k|    bstr_xappend_asprintf(root, text, "%*s", root->module_indent, prefix);
  371|  12.2k|    if (color)
  ------------------
  |  Branch (371:9): [True: 0, False: 12.2k]
  ------------------
  372|      0|        set_term_color(root, text, -1);
  373|  12.2k|    bstr_xappend(root, text, bstr0(": "));
  374|  12.2k|    if (color)
  ------------------
  |  Branch (374:9): [True: 0, False: 12.2k]
  ------------------
  375|      0|        set_msg_color(root, text, lev);
  376|  12.2k|}
msg.c:write_msg_to_buffers:
  459|  79.9M|{
  460|  79.9M|    struct mp_log_root *root = log->root;
  461|  80.4M|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (461:21): [True: 443k, False: 79.9M]
  ------------------
  462|   443k|        struct mp_log_buffer *buffer = root->buffers[n];
  463|   443k|        bool wakeup = false;
  464|   443k|        mp_mutex_lock(&buffer->lock);
  ------------------
  |  |  134|   443k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  465|   443k|        int buffer_level = buffer->level;
  466|   443k|        if (buffer_level == MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   443k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (466:13): [True: 221k, False: 221k]
  ------------------
  467|   221k|            buffer_level = log->terminal_level;
  468|   443k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   443k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (468:13): [True: 221k, False: 221k]
  ------------------
  469|   221k|            buffer_level = MPMAX(log->terminal_level, MSGL_DEBUG);
  ------------------
  |  |   44|   221k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 221k, False: 0]
  |  |  ------------------
  ------------------
  470|   443k|        if (lev <= buffer_level && lev != MSGL_STATUS) {
  ------------------
  |  Branch (470:13): [True: 443k, False: 0]
  |  Branch (470:36): [True: 443k, False: 0]
  ------------------
  471|   443k|            if (buffer->level == MP_LOG_BUFFER_MSGL_LOGFILE) {
  ------------------
  |  |   29|   443k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (471:17): [True: 221k, False: 221k]
  ------------------
  472|       |                // If the buffer is full, block until we can write again,
  473|       |                // unless there's no write thread (died, or early filebuffer)
  474|   221k|                if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (474:21): [True: 0, False: 221k]
  ------------------
  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|   221k|            }
  487|   443k|            if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (487:17): [True: 0, False: 443k]
  ------------------
  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|   443k|            struct mp_log_buffer_entry *entry = talloc_ptrtype(NULL, entry);
  ------------------
  |  |   34|   443k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   443k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   443k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|   443k|            *entry = (struct mp_log_buffer_entry) {
  494|   443k|                .prefix = talloc_strdup(entry, log->verbose_prefix),
  ------------------
  |  |   50|   443k|#define talloc_strdup                   ta_xstrdup
  ------------------
  495|   443k|                .level = lev,
  496|   443k|                .text = bstrdup0(entry, text),
  497|   443k|            };
  498|   443k|            int pos = (buffer->entry0 + buffer->num_entries) % buffer->capacity;
  499|   443k|            buffer->entries[pos] = entry;
  500|   443k|            buffer->num_entries += 1;
  501|   443k|            if (buffer->wakeup_cb && !buffer->silent)
  ------------------
  |  Branch (501:17): [True: 0, False: 443k]
  |  Branch (501:38): [True: 0, False: 0]
  ------------------
  502|      0|                wakeup = true;
  503|   443k|        }
  504|   443k|        mp_mutex_unlock(&buffer->lock);
  ------------------
  |  |  136|   443k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|   443k|        if (wakeup)
  ------------------
  |  Branch (505:13): [True: 0, False: 443k]
  ------------------
  506|      0|            buffer->wakeup_cb(buffer->wakeup_cb_ctx);
  507|   443k|    }
  508|  79.9M|}
msg.c:is_status_output:
  207|  3.34M|{
  208|  3.34M|    if (lev == MSGL_STATUS)
  ------------------
  |  Branch (208:9): [True: 1.07M, False: 2.26M]
  ------------------
  209|  1.07M|        return true;
  210|  2.26M|    int msg_out = term_msg_fileno(root, lev);
  211|  2.26M|    int status_out = term_msg_fileno(root, MSGL_STATUS);
  212|  2.26M|    if (msg_out != status_out && root->isatty[msg_out] != root->isatty[status_out])
  ------------------
  |  Branch (212:9): [True: 0, False: 2.26M]
  |  Branch (212:34): [True: 0, False: 0]
  ------------------
  213|      0|        return false;
  214|  2.26M|    return true;
  215|  2.26M|}
msg.c:destroy_log:
  718|  1.90M|{
  719|  1.90M|    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|  19.0M|    for (int lvl = 0; lvl <= MSGL_MAX; ++lvl)
  ------------------
  |  Branch (722:23): [True: 17.1M, False: 1.90M]
  ------------------
  723|  17.1M|        talloc_free(log->partial[lvl].start);
  ------------------
  |  |   47|  17.1M|#define talloc_free                     ta_free
  ------------------
  724|  1.90M|}
msg.c:check_new_path:
  858|  48.1k|{
  859|  48.1k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  48.1k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  48.1k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  860|  48.1k|    bool res = false;
  861|       |
  862|  48.1k|    char *new_path = mp_get_user_path(tmp, global, opt);
  863|  48.1k|    if (!new_path)
  ------------------
  |  Branch (863:9): [True: 47.9k, False: 219]
  ------------------
  864|  47.9k|        new_path = "";
  865|       |
  866|  48.1k|    char *old_path = *current_path ? *current_path : "";
  ------------------
  |  Branch (866:22): [True: 114, False: 48.0k]
  ------------------
  867|  48.1k|    if (strcmp(old_path, new_path) != 0) {
  ------------------
  |  Branch (867:9): [True: 218, False: 47.9k]
  ------------------
  868|    218|        talloc_free(*current_path);
  ------------------
  |  |   47|    218|#define talloc_free                     ta_free
  ------------------
  869|    218|        *current_path = NULL;
  870|    218|        if (new_path[0])
  ------------------
  |  Branch (870:13): [True: 218, False: 0]
  ------------------
  871|    218|            *current_path = talloc_strdup(NULL, new_path);
  ------------------
  |  |   50|    218|#define talloc_strdup                   ta_xstrdup
  ------------------
  872|    218|        res = true;
  873|    218|    }
  874|       |
  875|  48.1k|    talloc_free(tmp);
  ------------------
  |  |   47|  48.1k|#define talloc_free                     ta_free
  ------------------
  876|       |
  877|  48.1k|    return res;
  878|  48.1k|}
msg.c:terminate_log_file_thread:
  832|  11.6k|{
  833|  11.6k|    bool wait_terminate = false;
  834|       |
  835|  11.6k|    mp_mutex_lock(&root->log_file_lock);
  ------------------
  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  836|  11.6k|    if (root->log_file_thread_active) {
  ------------------
  |  Branch (836:9): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    mp_mutex_unlock(&root->log_file_lock);
  ------------------
  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|       |
  843|  11.6k|    if (wait_terminate)
  ------------------
  |  Branch (843:9): [True: 0, False: 11.6k]
  ------------------
  844|      0|        mp_thread_join(root->log_file_thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  845|       |
  846|  11.6k|    mp_msg_log_buffer_destroy(root->log_file_buffer);
  847|  11.6k|    root->log_file_buffer = NULL;
  848|       |
  849|  11.6k|    if (root->log_file)
  ------------------
  |  Branch (849:9): [True: 0, False: 11.6k]
  ------------------
  850|      0|        fclose(root->log_file);
  851|       |    root->log_file = NULL;
  852|  11.6k|}
msg.c:term_msg_fileno:
  197|   176M|{
  198|   176M|    return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
  ------------------
  |  Branch (198:12): [True: 0, False: 176M]
  ------------------
  199|   176M|}
msg.c:mp_msg_set_early_logging_raw:
 1036|  46.6k|{
 1037|  46.6k|    struct mp_log_root *root = global->log->root;
 1038|  46.6k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  46.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1039|       |
 1040|  46.6k|    if (enable != !!*root_logbuf) {
  ------------------
  |  Branch (1040:9): [True: 46.6k, False: 0]
  ------------------
 1041|  46.6k|        if (enable) {
  ------------------
  |  Branch (1041:13): [True: 23.3k, False: 23.3k]
  ------------------
 1042|  23.3k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1043|  23.3k|            struct mp_log_buffer *buf =
 1044|  23.3k|                mp_msg_log_buffer_new(global, size, level, NULL, NULL);
 1045|  23.3k|            mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1046|  23.3k|            mp_assert(!*root_logbuf); // no concurrent calls to this function
  ------------------
  |  |   41|  23.3k|#define mp_assert assert
  ------------------
  |  Branch (1046:13): [True: 23.3k, False: 0]
  ------------------
 1047|  23.3k|            *root_logbuf = buf;
 1048|  23.3k|        } else {
 1049|  23.3k|            struct mp_log_buffer *buf = *root_logbuf;
 1050|  23.3k|            *root_logbuf = NULL;
 1051|  23.3k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1052|  23.3k|            mp_msg_log_buffer_destroy(buf);
 1053|  23.3k|            return;
 1054|  23.3k|        }
 1055|  46.6k|    }
 1056|       |
 1057|  23.3k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1058|  23.3k|}
msg.c:log_buffer_read:
  442|   443k|{
  443|   443k|    mp_assert(buffer->num_entries);
  ------------------
  |  |   41|   443k|#define mp_assert assert
  ------------------
  |  Branch (443:5): [True: 443k, False: 0]
  ------------------
  444|   443k|    struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0];
  445|   443k|    buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity;
  446|   443k|    buffer->num_entries -= 1;
  447|   443k|    return res;
  448|   443k|}

chmap_sel.c:mp_msg_test:
   64|  15.0k|{
   65|  15.0k|    return lev <= mp_msg_level(log);
   66|  15.0k|}
av_log.c:mp_msg_test:
   64|  2.51M|{
   65|  2.51M|    return lev <= mp_msg_level(log);
   66|  2.51M|}
msg.c:mp_msg_test:
   64|   104M|{
   65|   104M|    return lev <= mp_msg_level(log);
   66|   104M|}
cmd.c:mp_msg_test:
   64|   603k|{
   65|   603k|    return lev <= mp_msg_level(log);
   66|   603k|}
input.c:mp_msg_test:
   64|  20.8k|{
   65|  20.8k|    return lev <= mp_msg_level(log);
   66|  20.8k|}
m_config_frontend.c:mp_msg_test:
   64|  93.3k|{
   65|  93.3k|    return lev <= mp_msg_level(log);
   66|  93.3k|}
command.c:mp_msg_test:
   64|   548k|{
   65|   548k|    return lev <= mp_msg_level(log);
   66|   548k|}

playlist_entry_new:
   31|  13.5k|{
   32|  13.5k|    struct playlist_entry *e = talloc_zero(NULL, struct playlist_entry);
  ------------------
  |  |   27|  13.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  13.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  13.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   33|  13.5k|    char *local_filename = mp_file_url_to_filename(e, bstr0(filename));
   34|  13.5k|    e->filename = mp_normalize_path(e, local_filename ? local_filename : filename);
  ------------------
  |  Branch (34:40): [True: 0, False: 13.5k]
  ------------------
   35|  13.5k|    talloc_free(local_filename);
  ------------------
  |  |   47|  13.5k|#define talloc_free                     ta_free
  ------------------
   36|  13.5k|    e->stream_flags = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|  13.5k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
   37|  13.5k|    e->original_index = -1;
   38|  13.5k|    return e;
   39|  13.5k|}
playlist_insert_at:
   77|  13.5k|{
   78|  13.5k|    mp_assert(add->filename);
  ------------------
  |  |   41|  13.5k|#define mp_assert assert
  ------------------
  |  Branch (78:5): [True: 13.5k, False: 0]
  ------------------
   79|  13.5k|    mp_assert(!at || at->pl == pl);
  ------------------
  |  |   41|  13.5k|#define mp_assert assert
  ------------------
  |  Branch (79:5): [True: 13.5k, False: 0]
  |  Branch (79:5): [True: 0, False: 0]
  ------------------
   80|       |
   81|  13.5k|    int index = at ? at->pl_index : pl->num_entries;
  ------------------
  |  Branch (81:17): [True: 0, False: 13.5k]
  ------------------
   82|  13.5k|    MP_TARRAY_INSERT_AT(pl, pl->entries, pl->num_entries, index, add);
  ------------------
  |  |  115|  13.5k|    do {                                            \
  |  |  116|  13.5k|        size_t at_ = (at);                          \
  |  |  117|  13.5k|        assert(at_ <= (idxvar));                    \
  |  |  118|  13.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  13.5k|    do {                                            \
  |  |  |  |   97|  13.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  13.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  13.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  13.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.7k, False: 1.79k]
  |  |  |  |  ------------------
  |  |  |  |   99|  13.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.7k|    do {                                                        \
  |  |  |  |  |  |   89|  11.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  13.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 13.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  13.5k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  13.5k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  13.5k|        (idxvar)++;                                 \
  |  |  122|  13.5k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  13.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 13.5k]
  |  |  ------------------
  ------------------
  |  Branch (82:5): [True: 13.5k, False: 0]
  ------------------
   83|       |
   84|  13.5k|    add->pl = pl;
   85|  13.5k|    add->pl_index = index;
   86|  13.5k|    add->id = ++pl->id_alloc;
   87|       |
   88|  13.5k|    playlist_update_indexes(pl, index, pl->num_entries);
   89|       |
   90|  13.5k|    talloc_steal(pl, add);
  ------------------
  |  |   38|  13.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  13.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
   91|  13.5k|}
playlist_entry_unref:
   94|  18.2k|{
   95|  18.2k|    e->reserved--;
   96|  18.2k|    if (e->reserved < 0) {
  ------------------
  |  Branch (96:9): [True: 2.11k, False: 16.1k]
  ------------------
   97|  2.11k|        mp_assert(!e->pl);
  ------------------
  |  |   41|  2.11k|#define mp_assert assert
  ------------------
  |  Branch (97:9): [True: 2.11k, False: 0]
  ------------------
   98|  2.11k|        talloc_free(e);
  ------------------
  |  |   47|  2.11k|#define talloc_free                     ta_free
  ------------------
   99|  2.11k|    }
  100|  18.2k|}
playlist_remove:
  103|  2.11k|{
  104|  2.11k|    mp_assert(pl && entry->pl == pl);
  ------------------
  |  |   41|  2.11k|#define mp_assert assert
  ------------------
  |  Branch (104:5): [True: 2.11k, False: 0]
  |  Branch (104:5): [True: 2.11k, False: 0]
  ------------------
  105|       |
  106|  2.11k|    if (pl->current == entry) {
  ------------------
  |  Branch (106:9): [True: 1.69k, False: 423]
  ------------------
  107|  1.69k|        pl->current = playlist_entry_get_rel(entry, 1);
  108|  1.69k|        pl->current_was_replaced = true;
  109|  1.69k|    }
  110|       |
  111|  2.11k|    MP_TARRAY_REMOVE_AT(pl->entries, pl->num_entries, entry->pl_index);
  ------------------
  |  |  143|  2.11k|    do {                                            \
  |  |  144|  2.11k|        size_t at_ = (at);                          \
  |  |  145|  2.11k|        assert(at_ < (idxvar));                     \
  |  |  146|  2.11k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  2.11k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  2.11k|        (idxvar)--;                                 \
  |  |  149|  2.11k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 2.11k]
  |  |  ------------------
  ------------------
  |  Branch (111:5): [True: 2.11k, False: 0]
  ------------------
  112|  2.11k|    playlist_update_indexes(pl, entry->pl_index, -1);
  113|       |
  114|  2.11k|    entry->pl = NULL;
  115|  2.11k|    entry->pl_index = -1;
  116|  2.11k|    ta_set_parent(entry, NULL);
  117|       |
  118|       |    entry->removed = true;
  119|  2.11k|    playlist_entry_unref(entry);
  120|  2.11k|}
playlist_clear:
  123|  78.2k|{
  124|  80.3k|    for (int n = pl->num_entries - 1; n >= 0; n--)
  ------------------
  |  Branch (124:39): [True: 2.10k, False: 78.2k]
  ------------------
  125|  2.10k|        playlist_remove(pl, pl->entries[n]);
  126|  78.2k|    mp_assert(!pl->current);
  ------------------
  |  |   41|  78.2k|#define mp_assert assert
  ------------------
  |  Branch (126:5): [True: 78.2k, False: 0]
  ------------------
  127|  78.2k|    pl->current_was_replaced = false;
  128|  78.2k|    pl->playlist_completed = false;
  129|  78.2k|    pl->playlist_started = false;
  130|       |    TA_FREEP(&pl->playlist_dir);
  ------------------
  |  |   81|  78.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  78.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 78.2k]
  |  |  ------------------
  ------------------
  131|  78.2k|}
playlist_clear_except_current:
  134|    332|{
  135|    440|    for (int n = pl->num_entries - 1; n >= 0; n--) {
  ------------------
  |  Branch (135:39): [True: 108, False: 332]
  ------------------
  136|    108|        if (pl->entries[n] != pl->current)
  ------------------
  |  Branch (136:13): [True: 19, False: 89]
  ------------------
  137|     19|            playlist_remove(pl, pl->entries[n]);
  138|    108|    }
  139|    332|    pl->playlist_completed = false;
  140|       |    pl->playlist_started = false;
  141|    332|}
playlist_append_file:
  166|    121|{
  167|       |    playlist_insert_at(pl, playlist_entry_new(filename), NULL);
  168|    121|}
playlist_populate_playlist_path:
  171|  4.41k|{
  172|  4.41k|    char *playlist_path = talloc_strdup(pl, path);
  ------------------
  |  |   50|  4.41k|#define talloc_strdup                   ta_xstrdup
  ------------------
  173|  4.51k|    for (int n = 0; n < pl->num_entries; n++) {
  ------------------
  |  Branch (173:21): [True: 98, False: 4.41k]
  ------------------
  174|     98|        struct playlist_entry *e = pl->entries[n];
  175|     98|        e->playlist_path = playlist_path;
  176|     98|    }
  177|  4.41k|}
playlist_shuffle:
  180|    151|{
  181|    232|    for (int n = 0; n < pl->num_entries; n++)
  ------------------
  |  Branch (181:21): [True: 81, False: 151]
  ------------------
  182|     81|        pl->entries[n]->original_index = n;
  183|    151|    mp_rand_state s = mp_rand_seed(0);
  184|    151|    for (int n = 0; n < pl->num_entries - 1; n++) {
  ------------------
  |  Branch (184:21): [True: 0, False: 151]
  ------------------
  185|      0|        size_t j = mp_rand_in_range32(&s, n, pl->num_entries);
  186|      0|        MPSWAP(struct playlist_entry *, pl->entries[n], pl->entries[j]);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
  187|      0|    }
  188|    151|    playlist_update_indexes(pl, 0, -1);
  189|    151|}
playlist_unshuffle:
  204|    109|{
  205|    109|    if (pl->num_entries)
  ------------------
  |  Branch (205:9): [True: 83, False: 26]
  ------------------
  206|     83|        qsort(pl->entries, pl->num_entries, sizeof(pl->entries[0]), cmp_unshuffle);
  207|    109|    playlist_update_indexes(pl, 0, -1);
  208|    109|}
playlist_get_first:
  212|  29.2k|{
  213|  29.2k|    return pl->num_entries ? pl->entries[0] : NULL;
  ------------------
  |  Branch (213:12): [True: 294, False: 28.9k]
  ------------------
  214|  29.2k|}
playlist_get_next:
  223|  9.94k|{
  224|  9.94k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|  9.94k|#define mp_assert assert
  ------------------
  |  Branch (224:5): [True: 4.98k, False: 4.96k]
  |  Branch (224:5): [True: 4.96k, False: 0]
  ------------------
  225|  9.94k|    if (!pl->current && pl->playlist_completed && direction < 0) {
  ------------------
  |  Branch (225:9): [True: 3.02k, False: 6.92k]
  |  Branch (225:25): [True: 2.71k, False: 308]
  |  Branch (225:51): [True: 2.67k, False: 42]
  ------------------
  226|  2.67k|        return playlist_entry_from_index(pl, pl->num_entries - 1);
  227|  7.27k|    } else if (!pl->current && !pl->playlist_started && direction > 0) {
  ------------------
  |  Branch (227:16): [True: 350, False: 6.92k]
  |  Branch (227:32): [True: 330, False: 20]
  |  Branch (227:57): [True: 208, False: 122]
  ------------------
  228|    208|        return playlist_entry_from_index(pl, 0);
  229|  7.06k|    } else if (!pl->current) {
  ------------------
  |  Branch (229:16): [True: 142, False: 6.92k]
  ------------------
  230|    142|        return NULL;
  231|    142|    }
  232|  6.92k|    mp_assert(pl->current->pl == pl);
  ------------------
  |  |   41|  6.92k|#define mp_assert assert
  ------------------
  |  Branch (232:5): [True: 6.92k, False: 0]
  ------------------
  233|  6.92k|    if (direction < 0)
  ------------------
  |  Branch (233:9): [True: 2.19k, False: 4.73k]
  ------------------
  234|  2.19k|        return playlist_entry_get_rel(pl->current, -1);
  235|  4.73k|    return pl->current_was_replaced ? pl->current :
  ------------------
  |  Branch (235:12): [True: 0, False: 4.73k]
  ------------------
  236|  4.73k|           playlist_entry_get_rel(pl->current, 1);
  237|  6.92k|}
playlist_entry_get_rel:
  242|  8.62k|{
  243|  8.62k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|  8.62k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 2.19k, False: 6.43k]
  |  Branch (243:5): [True: 6.43k, False: 0]
  ------------------
  244|  8.62k|    if (!e->pl)
  ------------------
  |  Branch (244:9): [True: 0, False: 8.62k]
  ------------------
  245|      0|        return NULL;
  246|  8.62k|    return playlist_entry_from_index(e->pl, e->pl_index + direction);
  247|  8.62k|}
playlist_get_first_in_next_playlist:
  251|     27|{
  252|     27|    struct playlist_entry *entry = playlist_get_next(pl, direction);
  253|     27|    if (!entry)
  ------------------
  |  Branch (253:9): [True: 27, False: 0]
  ------------------
  254|     27|        return NULL;
  255|       |
  256|      0|    while (entry && entry->playlist_path && pl->current->playlist_path &&
  ------------------
  |  Branch (256:12): [True: 0, False: 0]
  |  Branch (256:21): [True: 0, False: 0]
  |  Branch (256:45): [True: 0, False: 0]
  ------------------
  257|      0|           strcmp(entry->playlist_path, pl->current->playlist_path) == 0)
  ------------------
  |  Branch (257:12): [True: 0, False: 0]
  ------------------
  258|      0|        entry = playlist_entry_get_rel(entry, direction);
  259|       |
  260|      0|    if (direction < 0)
  ------------------
  |  Branch (260:9): [True: 0, False: 0]
  ------------------
  261|      0|        entry = playlist_get_first_in_same_playlist(entry,
  262|      0|                                                    pl->current->playlist_path);
  263|       |
  264|      0|    return entry;
  265|     27|}
playlist_set_stream_flags:
  318|  4.44k|{
  319|  4.56k|    for (int n = 0; n < pl->num_entries; n++)
  ------------------
  |  Branch (319:21): [True: 121, False: 4.44k]
  ------------------
  320|    121|        pl->entries[n]->stream_flags = flags;
  321|  4.44k|}
playlist_transfer_entries_to:
  325|  8.83k|{
  326|  8.83k|    mp_assert(pl != source_pl);
  ------------------
  |  |   41|  8.83k|#define mp_assert assert
  ------------------
  |  Branch (326:5): [True: 8.83k, False: 0]
  ------------------
  327|  8.83k|    struct playlist_entry *first = playlist_get_first(source_pl);
  328|       |
  329|  8.83k|    int count = source_pl->num_entries;
  330|  8.83k|    MP_TARRAY_INSERT_N_AT(pl, pl->entries, pl->num_entries, dst_index, count);
  ------------------
  |  |  130|  8.83k|    do {                                            \
  |  |  131|  8.83k|        size_t at_ = (at);                          \
  |  |  132|  8.83k|        assert(at_ <= (idxvar));                    \
  |  |  133|  8.83k|        size_t c_ = (c);                            \
  |  |  134|  8.83k|        MP_TARRAY_GROW(ctx, p, (idxvar) + c_);      \
  |  |  ------------------
  |  |  |  |   96|  8.83k|    do {                                            \
  |  |  |  |   97|  8.83k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  8.83k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  8.83k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  8.83k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 4.41k, False: 4.41k]
  |  |  |  |  ------------------
  |  |  |  |   99|  8.83k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  4.41k|    do {                                                        \
  |  |  |  |  |  |   89|  4.41k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  4.41k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  4.41k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.41k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.41k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  4.41k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  4.41k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 4.41k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  8.83k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 8.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|  8.83k|        memmove((p) + at_ + c_, (p) + at_,          \
  |  |  136|  8.83k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  137|  8.83k|        (idxvar) += c_;                             \
  |  |  138|  8.83k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (138:14): [Folded, False: 8.83k]
  |  |  ------------------
  ------------------
  |  Branch (330:5): [True: 8.83k, False: 0]
  ------------------
  331|       |
  332|  9.02k|    for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (332:21): [True: 196, False: 8.83k]
  ------------------
  333|    196|        struct playlist_entry *e = source_pl->entries[n];
  334|    196|        e->pl = pl;
  335|    196|        e->pl_index = dst_index + n;
  336|    196|        e->id = ++pl->id_alloc;
  337|    196|        pl->entries[e->pl_index] = e;
  338|    196|        talloc_steal(pl, e);
  ------------------
  |  |   38|    196|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    196|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  339|    196|        talloc_steal(pl, e->playlist_path);
  ------------------
  |  |   38|    196|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    196|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  340|    196|    }
  341|       |
  342|  8.83k|    playlist_update_indexes(pl, dst_index + count, -1);
  343|  8.83k|    source_pl->num_entries = 0;
  344|       |
  345|  8.83k|    pl->playlist_completed = source_pl->playlist_completed;
  346|  8.83k|    pl->playlist_started = source_pl->playlist_started;
  347|       |
  348|  8.83k|    return first ? first->id : 0;
  ------------------
  |  Branch (348:12): [True: 196, False: 8.63k]
  ------------------
  349|  8.83k|}
playlist_transfer_entries:
  357|  4.41k|{
  358|       |
  359|  4.41k|    int add_at = pl->num_entries;
  360|  4.41k|    if (pl->current) {
  ------------------
  |  Branch (360:9): [True: 0, False: 4.41k]
  ------------------
  361|      0|        add_at = pl->current->pl_index + 1;
  362|      0|        if (pl->current_was_replaced)
  ------------------
  |  Branch (362:13): [True: 0, False: 0]
  ------------------
  363|      0|            add_at += 1;
  364|      0|    }
  365|  4.41k|    mp_assert(add_at >= 0);
  ------------------
  |  |   41|  4.41k|#define mp_assert assert
  ------------------
  |  Branch (365:5): [True: 4.41k, False: 0]
  ------------------
  366|  4.41k|    mp_assert(add_at <= pl->num_entries);
  ------------------
  |  |   41|  4.41k|#define mp_assert assert
  ------------------
  |  Branch (366:5): [True: 4.41k, False: 0]
  ------------------
  367|       |
  368|  4.41k|    return playlist_transfer_entries_to(pl, add_at, source_pl);
  369|  4.41k|}
playlist_append_entries:
  372|  4.41k|{
  373|  4.41k|    return playlist_transfer_entries_to(pl, pl->num_entries, source_pl);
  374|  4.41k|}
playlist_entry_to_index:
  379|  17.0k|{
  380|  17.0k|    if (!e || e->pl != pl)
  ------------------
  |  Branch (380:9): [True: 436, False: 16.6k]
  |  Branch (380:15): [True: 0, False: 16.6k]
  ------------------
  381|    436|        return -1;
  382|  16.6k|    return e->pl_index;
  383|  17.0k|}
playlist_entry_count:
  386|  1.27k|{
  387|  1.27k|    return pl->num_entries;
  388|  1.27k|}
playlist_entry_from_index:
  393|  16.2k|{
  394|  16.2k|    return index >= 0 && index < pl->num_entries ? pl->entries[index] : NULL;
  ------------------
  |  Branch (394:12): [True: 13.9k, False: 2.30k]
  |  Branch (394:26): [True: 2.89k, False: 11.0k]
  ------------------
  395|  16.2k|}
playlist_parse_file:
  399|  39.5k|{
  400|  39.5k|    struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser");
  401|  39.5k|    mp_verbose(log, "Parsing playlist file %s...\n", file);
  ------------------
  |  |   79|  39.5k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  402|       |
  403|  39.5k|    char *path = mp_get_user_path(NULL, global, file);
  404|  39.5k|    struct demuxer_params p = {
  405|  39.5k|        .force_format = "playlist",
  406|  39.5k|        .stream_flags = STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   47|  39.5k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  407|  39.5k|    };
  408|  39.5k|    struct demuxer *d = demux_open_url(path, &p, cancel, global);
  409|  39.5k|    struct playlist *ret = NULL;
  410|  39.5k|    if (!d)
  ------------------
  |  Branch (410:9): [True: 35.1k, False: 4.41k]
  ------------------
  411|  35.1k|        goto done;
  412|       |
  413|  4.41k|    if (d && d->playlist) {
  ------------------
  |  Branch (413:9): [True: 4.41k, False: 0]
  |  Branch (413:14): [True: 4.41k, False: 0]
  ------------------
  414|  4.41k|        ret = talloc_zero(NULL, struct playlist);
  ------------------
  |  |   27|  4.41k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.41k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.41k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|  4.41k|        playlist_populate_playlist_path(d->playlist, file);
  416|  4.41k|        playlist_transfer_entries(ret, d->playlist);
  417|  4.41k|        if (d->filetype && strcmp(d->filetype, "hls") == 0) {
  ------------------
  |  Branch (417:13): [True: 4.41k, False: 0]
  |  Branch (417:28): [True: 0, False: 4.41k]
  ------------------
  418|      0|            mp_warn(log, "This might be a HLS stream. For correct operation, "
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  419|      0|                         "pass it to the player\ndirectly. Don't use --playlist.\n");
  420|      0|        }
  421|  4.41k|    }
  422|  4.41k|    demux_free(d);
  423|       |
  424|  4.41k|    if (ret) {
  ------------------
  |  Branch (424:9): [True: 4.41k, False: 0]
  ------------------
  425|  4.41k|        mp_verbose(log, "Playlist successfully parsed\n");
  ------------------
  |  |   79|  4.41k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  426|  4.41k|    } else {
  427|      0|        mp_err(log, "Error while parsing playlist\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  428|      0|    }
  429|       |
  430|  4.41k|    if (ret && !ret->num_entries)
  ------------------
  |  Branch (430:9): [True: 4.41k, False: 0]
  |  Branch (430:16): [True: 4.31k, False: 98]
  ------------------
  431|  4.31k|        mp_warn(log, "Warning: empty playlist\n");
  ------------------
  |  |   77|  4.31k|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  432|       |
  433|  39.5k|done:
  434|  39.5k|    talloc_free(log);
  ------------------
  |  |   47|  39.5k|#define talloc_free                     ta_free
  ------------------
  435|  39.5k|    talloc_free(path);
  ------------------
  |  |   47|  39.5k|#define talloc_free                     ta_free
  ------------------
  436|  39.5k|    return ret;
  437|  4.41k|}
playlist.c:playlist_update_indexes:
   65|  24.8k|{
   66|  24.8k|    start = MPMAX(start, 0);
  ------------------
  |  |   44|  24.8k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 196, False: 24.6k]
  |  |  ------------------
  ------------------
   67|  24.8k|    end = end < 0 ? pl->num_entries : MPMIN(end, pl->num_entries);
  ------------------
  |  |   45|  38.3k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 13.5k]
  |  |  ------------------
  ------------------
  |  Branch (67:11): [True: 11.2k, False: 13.5k]
  ------------------
   68|       |
   69|  38.5k|    for (int n = start; n < end; n++)
  ------------------
  |  Branch (69:25): [True: 13.7k, False: 24.8k]
  ------------------
   70|  13.7k|        pl->entries[n]->pl_index = n;
   71|  24.8k|}

mp_recorder_create:
  137|     44|{
  138|     44|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  139|     44|    return NULL;
  140|      0|#endif
  141|      0|    struct mp_recorder *priv = talloc_zero(NULL, struct mp_recorder);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|       |
  143|      0|    priv->global = global;
  144|      0|    priv->log = mp_log_new(priv, global->log, "recorder");
  145|      0|    priv->packet_pool = demux_packet_pool_get(global);
  146|       |
  147|      0|    if (!num_streams) {
  ------------------
  |  Branch (147:9): [True: 0, False: 0]
  ------------------
  148|      0|        MP_ERR(priv, "No 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__)
  |  |  ------------------
  ------------------
  149|      0|        goto error;
  150|      0|    }
  151|       |
  152|      0|    priv->mux = avformat_alloc_context();
  153|      0|    if (!priv->mux)
  ------------------
  |  Branch (153:9): [True: 0, False: 0]
  ------------------
  154|      0|        goto error;
  155|       |
  156|      0|    priv->mux->oformat = av_guess_format(NULL, target_file, NULL);
  157|      0|    if (!priv->mux->oformat) {
  ------------------
  |  Branch (157:9): [True: 0, False: 0]
  ------------------
  158|      0|        MP_ERR(priv, "Output format not found.\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__)
  |  |  ------------------
  ------------------
  159|      0|        goto error;
  160|      0|    }
  161|       |
  162|      0|    if (avio_open2(&priv->mux->pb, target_file, AVIO_FLAG_WRITE, NULL, NULL) < 0) {
  ------------------
  |  Branch (162:9): [True: 0, False: 0]
  ------------------
  163|      0|        MP_ERR(priv, "Failed opening output 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__)
  |  |  ------------------
  ------------------
  164|      0|        goto error;
  165|      0|    }
  166|       |
  167|      0|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (167:21): [True: 0, False: 0]
  ------------------
  168|      0|        if (add_stream(priv, streams[n]) < 0) {
  ------------------
  |  Branch (168:13): [True: 0, False: 0]
  ------------------
  169|      0|            MP_ERR(priv, "Can't mux one of the input 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__)
  |  |  ------------------
  ------------------
  170|      0|            goto error;
  171|      0|        }
  172|      0|    }
  173|       |
  174|      0|    if (!strcmp(priv->mux->oformat->name, "matroska")) {
  ------------------
  |  Branch (174:9): [True: 0, False: 0]
  ------------------
  175|       |        // Only attach attachments (fonts) to matroska - mp4, nut, mpegts don't
  176|       |        // like them, and we find that out too late in the muxing process.
  177|      0|        AVStream *a_stream = NULL;
  178|      0|        for (int i = 0; i < num_attachments; ++i) {
  ------------------
  |  Branch (178:25): [True: 0, False: 0]
  ------------------
  179|      0|            a_stream = avformat_new_stream(priv->mux, NULL);
  180|      0|            if (!a_stream) {
  ------------------
  |  Branch (180:17): [True: 0, False: 0]
  ------------------
  181|      0|                MP_ERR(priv, "Can't mux one of the attachments.\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__)
  |  |  ------------------
  ------------------
  182|      0|                goto error;
  183|      0|            }
  184|      0|            struct demux_attachment *attachment = attachments[i];
  185|       |
  186|      0|            a_stream->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
  187|       |
  188|      0|            a_stream->codecpar->extradata  = av_mallocz(
  189|      0|                attachment->data_size + AV_INPUT_BUFFER_PADDING_SIZE
  190|      0|            );
  191|      0|            if (!a_stream->codecpar->extradata) {
  ------------------
  |  Branch (191:17): [True: 0, False: 0]
  ------------------
  192|      0|                goto error;
  193|      0|            }
  194|      0|            memcpy(a_stream->codecpar->extradata,
  195|      0|                attachment->data, attachment->data_size);
  196|      0|            a_stream->codecpar->extradata_size = attachment->data_size;
  197|       |
  198|      0|            av_dict_set(&a_stream->metadata, "filename", attachment->name, 0);
  199|      0|            av_dict_set(&a_stream->metadata, "mimetype", attachment->type, 0);
  200|      0|        }
  201|      0|    }
  202|       |
  203|       |    // Not sure how to write this in a "standard" way. It appears only mkv
  204|       |    // and mp4 support this directly.
  205|      0|    char version[200];
  206|      0|    snprintf(version, sizeof(version), "%s experimental stream recording "
  207|      0|             "feature (can generate broken files - please report bugs)",
  208|      0|             mpv_version);
  209|      0|    av_dict_set(&priv->mux->metadata, "encoding_tool", version, 0);
  210|       |
  211|      0|    if (avformat_write_header(priv->mux, NULL) < 0) {
  ------------------
  |  Branch (211:9): [True: 0, False: 0]
  ------------------
  212|      0|        MP_ERR(priv, "Writing header 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__)
  |  |  ------------------
  ------------------
  213|      0|        goto error;
  214|      0|    }
  215|       |
  216|      0|    priv->opened = true;
  217|      0|    priv->muxing_from_start = true;
  218|       |
  219|      0|    priv->base_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  220|      0|    priv->rebase_ts = 0;
  221|       |
  222|      0|    MP_WARN(priv, "This is an experimental feature. Output files might be "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  223|      0|                  "broken or not play correctly with various players "
  224|      0|                  "(including mpv itself).\n");
  225|       |
  226|      0|    return priv;
  227|       |
  228|      0|error:
  229|      0|    mp_recorder_destroy(priv);
  230|       |    return NULL;
  231|      0|}

stats_global_init:
   81|  11.6k|{
   82|  11.6k|    mp_assert(!global->stats);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (82:5): [True: 11.6k, False: 0]
  ------------------
   83|  11.6k|    struct stats_base *stats = talloc_zero(global, struct stats_base);
  ------------------
  |  |   27|  11.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  11.6k|    ta_set_destructor(stats, stats_destroy);
   85|  11.6k|    mp_mutex_init(&stats->lock);
   86|       |
   87|  11.6k|    global->stats = stats;
   88|  11.6k|    stats->global = global;
   89|  11.6k|}
stats_global_query:
  111|      8|{
  112|      8|    struct stats_base *stats = global->stats;
  113|      8|    mp_assert(stats);
  ------------------
  |  |   41|      8|#define mp_assert assert
  ------------------
  |  Branch (113:5): [True: 8, False: 0]
  ------------------
  114|       |
  115|      8|    mp_mutex_lock(&stats->lock);
  ------------------
  |  |  134|      8|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  116|       |
  117|      8|    atomic_store(&stats->active, true);
  118|       |
  119|      8|    if (!stats->num_entries) {
  ------------------
  |  Branch (119:9): [True: 6, False: 2]
  ------------------
  120|     30|        for (struct stats_ctx *ctx = stats->list.head; ctx; ctx = ctx->list.next)
  ------------------
  |  Branch (120:56): [True: 24, False: 6]
  ------------------
  121|     24|        {
  122|     36|            for (int n = 0; n < ctx->num_entries; n++) {
  ------------------
  |  Branch (122:29): [True: 12, False: 24]
  ------------------
  123|     12|                MP_TARRAY_APPEND(stats, stats->entries, stats->num_entries,
  ------------------
  |  |  105|     12|    do {                                            \
  |  |  106|     12|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     12|    do {                                            \
  |  |  |  |   97|     12|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     12|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     12|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     12|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6, False: 6]
  |  |  |  |  ------------------
  |  |  |  |   99|     12|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      6|    do {                                                        \
  |  |  |  |  |  |   89|      6|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      6|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      6|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      6|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      6|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      6|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      6|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     12|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     12|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     12|        (idxvar)++;                                 \
  |  |  109|     12|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 12]
  |  |  ------------------
  ------------------
  124|     12|                                 ctx->entries[n]);
  125|     12|            }
  126|     24|        }
  127|      6|        if (stats->num_entries) {
  ------------------
  |  Branch (127:13): [True: 6, False: 0]
  ------------------
  128|      6|            qsort(stats->entries, stats->num_entries, sizeof(stats->entries[0]),
  129|      6|                  cmp_entry);
  130|      6|        }
  131|      6|    }
  132|       |
  133|      8|    node_init(out, MPV_FORMAT_NODE_ARRAY, NULL);
  134|       |
  135|      8|#define FMT_T(e, t) ((t) > 0 ? mp_tprintf(80, "%.3f ms (%.2f%%)", (e), ((e) / (t)) * 100) \
  136|      8|                             : mp_tprintf(80, "%.3f ms", (e)))
  137|       |
  138|      8|    int64_t now = mp_time_ns();
  139|      8|    double t_ms = 0;
  140|      8|    if (stats->last_time) {
  ------------------
  |  Branch (140:9): [True: 2, False: 6]
  ------------------
  141|      2|        t_ms = MP_TIME_NS_TO_MS(now - stats->last_time);
  ------------------
  |  |   77|      2|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  142|      2|        struct mpv_node *ne = node_array_add(out, MPV_FORMAT_NODE_MAP);
  143|      2|        node_map_add_string(ne, "name", "poll-time");
  144|      2|        node_map_add_double(ne, "value", t_ms);
  145|      2|        node_map_add_string(ne, "text", FMT_T(t_ms, 0));
  ------------------
  |  |  135|      2|#define FMT_T(e, t) ((t) > 0 ? mp_tprintf(80, "%.3f ms (%.2f%%)", (e), ((e) / (t)) * 100) \
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (135:22): [Folded, False: 2]
  |  |  ------------------
  |  |  136|      2|                             : mp_tprintf(80, "%.3f ms", (e)))
  |  |  ------------------
  |  |  |  |  195|      2|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  146|       |
  147|       |        // Very dirty way to reset everything if the stats.lua page was probably
  148|       |        // closed. Not enough energy left for clean solution. Fuck it.
  149|      2|        if (t_ms > 2000) {
  ------------------
  |  Branch (149:13): [True: 0, False: 2]
  ------------------
  150|      0|            for (int n = 0; n < stats->num_entries; n++) {
  ------------------
  |  Branch (150:29): [True: 0, False: 0]
  ------------------
  151|      0|                struct stat_entry *e = stats->entries[n];
  152|       |
  153|      0|                e->cpu_start_ns = e->time_start_ns = 0;
  154|      0|                e->val_rt = e->val_th = 0;
  155|      0|                if (e->type != VAL_THREAD_CPU_TIME)
  ------------------
  |  Branch (155:21): [True: 0, False: 0]
  ------------------
  156|      0|                    e->type = 0;
  157|      0|            }
  158|      0|        }
  159|      2|    }
  160|      8|    stats->last_time = now;
  161|       |
  162|     24|    for (int n = 0; n < stats->num_entries; n++) {
  ------------------
  |  Branch (162:21): [True: 16, False: 8]
  ------------------
  163|     16|        struct stat_entry *e = stats->entries[n];
  164|       |
  165|     16|        switch (e->type) {
  166|      0|        case VAL_STATIC:
  ------------------
  |  Branch (166:9): [True: 0, False: 16]
  ------------------
  167|      0|            add_stat(out, e, NULL, e->val_d, NULL);
  168|      0|            break;
  169|      0|        case VAL_STATIC_SIZE: {
  ------------------
  |  Branch (169:9): [True: 0, False: 16]
  ------------------
  170|      0|            char *s = format_file_size(e->val_d);
  171|      0|            add_stat(out, e, NULL, e->val_d, s);
  172|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  173|      0|            break;
  174|      0|        }
  175|      0|        case VAL_INC:
  ------------------
  |  Branch (175:9): [True: 0, False: 16]
  ------------------
  176|      0|            add_stat(out, e, NULL, e->val_d, NULL);
  177|      0|            e->val_d = 0;
  178|      0|            break;
  179|      0|        case VAL_TIME: {
  ------------------
  |  Branch (179:9): [True: 0, False: 16]
  ------------------
  180|      0|            if (e->time_start_ns) {  // ongoing. effectively do end+start
  ------------------
  |  Branch (180:17): [True: 0, False: 0]
  ------------------
  181|      0|                e->val_rt += now - e->time_start_ns;
  182|      0|                e->time_start_ns = now;
  183|      0|                int64_t t = mp_thread_cpu_time_ns(e->thread_id);
  184|      0|                e->val_th += t - e->cpu_start_ns;
  185|      0|                e->cpu_start_ns = t;
  186|      0|            }
  187|      0|            double t_cpu = MP_TIME_NS_TO_MS(e->val_th);
  ------------------
  |  |   77|      0|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  188|      0|            if (e->cpu_start_ns >= 0)
  ------------------
  |  Branch (188:17): [True: 0, False: 0]
  ------------------
  189|      0|                add_stat(out, e, "cpu", t_cpu, FMT_T(t_cpu, t_ms));
  ------------------
  |  |  135|      0|#define FMT_T(e, t) ((t) > 0 ? mp_tprintf(80, "%.3f ms (%.2f%%)", (e), ((e) / (t)) * 100) \
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (135:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  136|      0|                             : mp_tprintf(80, "%.3f ms", (e)))
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  190|      0|            double t_rt = MP_TIME_NS_TO_MS(e->val_rt);
  ------------------
  |  |   77|      0|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  191|      0|            add_stat(out, e, "time", t_rt, FMT_T(t_rt, t_ms));
  ------------------
  |  |  135|      0|#define FMT_T(e, t) ((t) > 0 ? mp_tprintf(80, "%.3f ms (%.2f%%)", (e), ((e) / (t)) * 100) \
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (135:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  136|      0|                             : mp_tprintf(80, "%.3f ms", (e)))
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  192|      0|            e->val_rt = e->val_th = 0;
  193|      0|            break;
  194|      0|        }
  195|     16|        case VAL_THREAD_CPU_TIME: {
  ------------------
  |  Branch (195:9): [True: 16, False: 0]
  ------------------
  196|     16|            int64_t t = mp_thread_cpu_time_ns(e->thread_id);
  197|     16|            if (!e->cpu_start_ns)
  ------------------
  |  Branch (197:17): [True: 12, False: 4]
  ------------------
  198|     12|                e->cpu_start_ns = t;
  199|     16|            double t_msec = MP_TIME_NS_TO_MS(t - e->cpu_start_ns);
  ------------------
  |  |   77|     16|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  200|     16|            if (e->cpu_start_ns >= 0)
  ------------------
  |  Branch (200:17): [True: 16, False: 0]
  ------------------
  201|     16|                add_stat(out, e, NULL, t_msec, FMT_T(t_msec, t_ms));
  ------------------
  |  |  135|     16|#define FMT_T(e, t) ((t) > 0 ? mp_tprintf(80, "%.3f ms (%.2f%%)", (e), ((e) / (t)) * 100) \
  |  |  ------------------
  |  |  |  |  195|      4|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (135:22): [True: 4, False: 12]
  |  |  ------------------
  |  |  136|     16|                             : mp_tprintf(80, "%.3f ms", (e)))
  |  |  ------------------
  |  |  |  |  195|     12|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  202|     16|            e->cpu_start_ns = t;
  203|     16|            break;
  204|      0|        }
  205|      0|        default: ;
  ------------------
  |  Branch (205:9): [True: 0, False: 16]
  ------------------
  206|     16|        }
  207|     16|    }
  208|       |
  209|      8|    mp_mutex_unlock(&stats->lock);
  ------------------
  |  |  136|      8|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  210|      8|}
stats_ctx_create:
  224|   415k|{
  225|   415k|    struct stats_base *base = global->stats;
  226|   415k|    mp_assert(base);
  ------------------
  |  |   41|   415k|#define mp_assert assert
  ------------------
  |  Branch (226:5): [True: 415k, False: 0]
  ------------------
  227|       |
  228|   415k|    struct stats_ctx *ctx = talloc_zero(ta_parent, struct stats_ctx);
  ------------------
  |  |   27|   415k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   415k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   415k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|   415k|    ctx->base = base;
  230|   415k|    ctx->prefix = talloc_strdup(ctx, prefix);
  ------------------
  |  |   50|   415k|#define talloc_strdup                   ta_xstrdup
  ------------------
  231|   415k|    ta_set_destructor(ctx, stats_ctx_destroy);
  232|       |
  233|   415k|    mp_mutex_lock(&base->lock);
  ------------------
  |  |  134|   415k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  234|   415k|    LL_APPEND(list, &base->list, ctx);
  ------------------
  |  |   44|   415k|#define LL_APPEND(field, list, item)  do {                              \
  |  |   45|   415k|    (item)->field.prev = (list)->tail;                                  \
  |  |   46|   415k|    (item)->field.next = NULL;                                          \
  |  |   47|   415k|    LL_RELINK_(field, list, item)                                       \
  |  |  ------------------
  |  |  |  |   98|   415k|    if ((item)->field.prev) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:9): [True: 404k, False: 11.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|   404k|        (item)->field.prev->field.next = (item);                        \
  |  |  |  |  100|   404k|    } else {                                                            \
  |  |  |  |  101|  11.6k|        (list)->head = (item);                                          \
  |  |  |  |  102|  11.6k|    }                                                                   \
  |  |  |  |  103|   415k|    if ((item)->field.next) {                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:9): [True: 0, False: 415k]
  |  |  |  |  ------------------
  |  |  |  |  104|      0|        (item)->field.next->field.prev = (item);                        \
  |  |  |  |  105|   415k|    } else {                                                            \
  |  |  |  |  106|   415k|        (list)->tail = (item);                                          \
  |  |  |  |  107|   415k|    }
  |  |  ------------------
  |  |   48|   415k|} while (0)
  |  |  ------------------
  |  |  |  Branch (48:10): [Folded, False: 415k]
  |  |  ------------------
  ------------------
  235|   415k|    base->num_entries = 0; // invalidate
  236|   415k|    mp_mutex_unlock(&base->lock);
  ------------------
  |  |  136|   415k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  237|       |
  238|   415k|    return ctx;
  239|   415k|}
stats_time_start:
  283|   144k|{
  284|   144k|    MP_STATS(ctx->base->global, "start %s", name);
  ------------------
  |  |   99|   144k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   144k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  285|   144k|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|   144k|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (285:9): [True: 144k, False: 10]
  ------------------
  286|   144k|        return;
  287|     10|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|     10|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  288|     10|    struct stat_entry *e = find_entry(ctx, name);
  289|     10|    e->type = VAL_TIME;
  290|     10|    e->thread_id = mp_thread_current_id();
  ------------------
  |  |  217|     10|#define mp_thread_current_id      pthread_self
  ------------------
  291|     10|    e->cpu_start_ns = mp_thread_cpu_time_ns(e->thread_id);
  292|     10|    e->time_start_ns = mp_time_ns();
  293|     10|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|     10|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  294|     10|}
stats_time_end:
  297|   144k|{
  298|   144k|    MP_STATS(ctx->base->global, "end %s", name);
  ------------------
  |  |   99|   144k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   144k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  299|   144k|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|   144k|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (299:9): [True: 144k, False: 10]
  ------------------
  300|   144k|        return;
  301|     10|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|     10|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  302|     10|    struct stat_entry *e = find_entry(ctx, name);
  303|     10|    if (e->type == VAL_TIME && e->time_start_ns) {
  ------------------
  |  Branch (303:9): [True: 10, False: 0]
  |  Branch (303:32): [True: 10, False: 0]
  ------------------
  304|     10|        e->val_th += mp_thread_cpu_time_ns(e->thread_id) - e->cpu_start_ns;
  305|     10|        e->val_rt += mp_time_ns() - e->time_start_ns;
  306|     10|        e->time_start_ns = 0;
  307|     10|    }
  308|     10|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|     10|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  309|     10|}
stats_event:
  312|  14.7M|{
  313|  14.7M|    if (!IS_ACTIVE(ctx))
  ------------------
  |  |   68|  14.7M|    (atomic_load_explicit(&(ctx)->base->active, memory_order_relaxed))
  ------------------
  |  Branch (313:9): [True: 14.7M, False: 523]
  ------------------
  314|  14.7M|        return;
  315|    523|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|    523|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  316|    523|    struct stat_entry *e = find_entry(ctx, name);
  317|    523|    e->val_d += 1;
  318|    523|    e->type = VAL_INC;
  319|    523|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|    523|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  320|    523|}
stats_register_thread_cputime:
  333|  26.4k|{
  334|  26.4k|    register_thread(ctx, name, VAL_THREAD_CPU_TIME);
  335|  26.4k|}
stats_unregister_thread:
  338|  14.7k|{
  339|  14.7k|    register_thread(ctx, name, 0);
  340|  14.7k|}
stats.c:stats_destroy:
   71|  11.6k|{
   72|  11.6k|    struct stats_base *stats = p;
   73|       |
   74|       |    // All entries must have been destroyed before this.
   75|  11.6k|    mp_assert(!stats->list.head);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (75:5): [True: 11.6k, False: 0]
  ------------------
   76|       |
   77|  11.6k|    mp_mutex_destroy(&stats->lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   78|  11.6k|}
stats.c:cmp_entry:
  104|      6|{
  105|      6|    struct stat_entry **e1 = (void *)p1;
  106|      6|    struct stat_entry **e2 = (void *)p2;
  107|      6|    return strcmp((*e1)->full_name, (*e2)->full_name);
  108|      6|}
stats.c:add_stat:
   93|     16|{
   94|     16|    struct mpv_node *ne = node_array_add(list, MPV_FORMAT_NODE_MAP);
   95|       |
   96|     16|    node_map_add_string(ne, "name", suffix ?
  ------------------
  |  Branch (96:37): [True: 0, False: 16]
  ------------------
   97|     16|        mp_tprintf(80, "%s/%s", e->full_name, suffix) : e->full_name);
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
   98|     16|    node_map_add_double(ne, "value", num_val);
   99|     16|    if (text)
  ------------------
  |  Branch (99:9): [True: 16, False: 0]
  ------------------
  100|     16|        node_map_add_string(ne, "text", text);
  101|     16|}
stats.c:stats_ctx_destroy:
  213|   415k|{
  214|   415k|    struct stats_ctx *ctx = p;
  215|       |
  216|   415k|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|   415k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  217|   415k|    LL_REMOVE(list, &ctx->base->list, ctx);
  ------------------
  |  |   78|   415k|#define LL_REMOVE(field, list, item) do {                               \
  |  |   79|   415k|    if ((item)->field.prev) {                                           \
  |  |  ------------------
  |  |  |  Branch (79:9): [True: 404k, False: 11.6k]
  |  |  ------------------
  |  |   80|   404k|        (item)->field.prev->field.next = (item)->field.next;            \
  |  |   81|   404k|    } else {                                                            \
  |  |   82|  11.6k|        (list)->head = (item)->field.next;                              \
  |  |   83|  11.6k|    }                                                                   \
  |  |   84|   415k|    if ((item)->field.next) {                                           \
  |  |  ------------------
  |  |  |  Branch (84:9): [True: 16.4k, False: 399k]
  |  |  ------------------
  |  |   85|  16.4k|        (item)->field.next->field.prev = (item)->field.prev;            \
  |  |   86|   399k|    } else {                                                            \
  |  |   87|   399k|        (list)->tail = (item)->field.prev;                              \
  |  |   88|   399k|    }                                                                   \
  |  |   89|   415k|} while (0)
  |  |  ------------------
  |  |  |  Branch (89:10): [Folded, False: 415k]
  |  |  ------------------
  ------------------
  218|   415k|    ctx->base->num_entries = 0; // invalidate
  219|   415k|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|   415k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  220|   415k|}
stats.c:find_entry:
  242|  41.3k|{
  243|  41.3k|    for (int n = 0; n < ctx->num_entries; n++) {
  ------------------
  |  Branch (243:21): [True: 14.9k, False: 26.4k]
  ------------------
  244|  14.9k|        if (strcmp(ctx->entries[n]->name, name) == 0)
  ------------------
  |  Branch (244:13): [True: 14.8k, False: 59]
  ------------------
  245|  14.8k|            return ctx->entries[n];
  246|  14.9k|    }
  247|       |
  248|  26.4k|    struct stat_entry *e = talloc_zero(ctx, struct stat_entry);
  ------------------
  |  |   27|  26.4k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  26.4k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  26.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|  26.4k|    snprintf(e->name, sizeof(e->name), "%s", name);
  250|  26.4k|    mp_assert(strcmp(e->name, name) == 0); // make e->name larger and don't complain
  ------------------
  |  |   41|  26.4k|#define mp_assert assert
  ------------------
  |  Branch (250:5): [True: 26.4k, False: 0]
  ------------------
  251|       |
  252|  26.4k|    e->full_name = talloc_asprintf(e, "%s/%s", ctx->prefix, e->name);
  ------------------
  |  |   52|  26.4k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  26.4k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  253|       |
  254|  26.4k|    MP_TARRAY_APPEND(ctx, ctx->entries, ctx->num_entries, e);
  ------------------
  |  |  105|  26.4k|    do {                                            \
  |  |  106|  26.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  26.4k|    do {                                            \
  |  |  |  |   97|  26.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  26.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  26.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  26.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 26.4k, False: 7]
  |  |  |  |  ------------------
  |  |  |  |   99|  26.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  26.4k|    do {                                                        \
  |  |  |  |  |  |   89|  26.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  26.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  26.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  26.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  26.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  26.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  26.4k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 26.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  26.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 26.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  26.4k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  26.4k|        (idxvar)++;                                 \
  |  |  109|  26.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 26.4k]
  |  |  ------------------
  ------------------
  255|  26.4k|    ctx->base->num_entries = 0; // invalidate
  256|       |
  257|  26.4k|    return e;
  258|  26.4k|}
stats.c:register_thread:
  324|  41.1k|{
  325|  41.1k|    mp_mutex_lock(&ctx->base->lock);
  ------------------
  |  |  134|  41.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  326|  41.1k|    struct stat_entry *e = find_entry(ctx, name);
  327|  41.1k|    e->type = type;
  328|  41.1k|    e->thread_id = mp_thread_current_id();
  ------------------
  |  |  217|  41.1k|#define mp_thread_current_id      pthread_self
  ------------------
  329|  41.1k|    mp_mutex_unlock(&ctx->base->lock);
  ------------------
  |  |  136|  41.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  330|  41.1k|}

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

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

mp_probe_cue:
  181|  26.9k|{
  182|  26.9k|    bool valid = false;
  183|  26.9k|    data = skip_utf8_bom(data);
  184|  26.9k|    for (;;) {
  185|  26.9k|        enum cue_command cmd = read_cmd(&data, NULL);
  186|       |        // End reached. Since the line was most likely cut off, don't use the
  187|       |        // result of the last parsing call.
  188|  26.9k|        if (data.len == 0)
  ------------------
  |  Branch (188:13): [True: 26.9k, False: 49]
  ------------------
  189|  26.9k|            break;
  190|     49|        if (cmd == CUE_ERROR)
  ------------------
  |  Branch (190:13): [True: 29, False: 20]
  ------------------
  191|     29|            return false;
  192|     20|        if (cmd != CUE_EMPTY)
  ------------------
  |  Branch (192:13): [True: 0, False: 20]
  ------------------
  193|      0|            valid = true;
  194|     20|    }
  195|  26.9k|    return valid;
  196|  26.9k|}
cue.c:skip_utf8_bom:
  173|  26.9k|{
  174|  26.9k|    return bstr_startswith0(data, "\xEF\xBB\xBF") ? bstr_cut(data, 3) : data;
  ------------------
  |  Branch (174:12): [True: 30, False: 26.9k]
  ------------------
  175|  26.9k|}
cue.c:read_cmd:
   92|  26.9k|{
   93|  26.9k|    struct bstr line = bstr_strip_linebreaks(bstr_getline(*data, data));
   94|  26.9k|    line = lstrip_whitespace(line);
   95|  26.9k|    if (line.len == 0)
  ------------------
  |  Branch (95:9): [True: 59, False: 26.9k]
  ------------------
   96|     59|        return CUE_EMPTY;
   97|   430k|    for (int n = 0; cue_command_strings[n].command != -1; n++) {
  ------------------
  |  Branch (97:21): [True: 403k, False: 26.9k]
  ------------------
   98|   403k|        struct bstr name = bstr0(cue_command_strings[n].text);
   99|   403k|        if (bstr_case_startswith(line, name)) {
  ------------------
  |  Branch (99:13): [True: 28, False: 403k]
  ------------------
  100|     28|            struct bstr rest = bstr_cut(line, name.len);
  101|     28|            struct bstr par = lstrip_whitespace(rest);
  102|     28|            if (rest.len && par.len == rest.len)
  ------------------
  |  Branch (102:17): [True: 21, False: 7]
  |  Branch (102:29): [True: 21, False: 0]
  ------------------
  103|     21|                continue;
  104|      7|            if (out_params)
  ------------------
  |  Branch (104:17): [True: 0, False: 7]
  ------------------
  105|      0|                *out_params = par;
  106|      7|            return cue_command_strings[n].command;
  107|     28|        }
  108|   403k|    }
  109|  26.9k|    return CUE_ERROR;
  110|  26.9k|}
cue.c:lstrip_whitespace:
   69|  27.0k|{
   70|  27.1k|    while (data.len) {
  ------------------
  |  Branch (70:12): [True: 27.0k, False: 66]
  ------------------
   71|  27.0k|        bstr rest = data;
   72|  27.0k|        int code = bstr_decode_utf8(data, &rest);
   73|  27.0k|        if (code < 0) {
  ------------------
  |  Branch (73:13): [True: 3.32k, False: 23.7k]
  ------------------
   74|       |            // Tolerate Latin1 => probing works (which doesn't convert charsets).
   75|  3.32k|            code = data.start[0];
   76|  3.32k|            rest.start += 1;
   77|  3.32k|            rest.len -= 1;
   78|  3.32k|        }
   79|   216k|        for (size_t n = 0; n < MP_ARRAY_SIZE(spaces); n++) {
  ------------------
  |  |   49|   216k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (79:28): [True: 189k, False: 26.9k]
  ------------------
   80|   189k|            if (spaces[n] == code) {
  ------------------
  |  Branch (80:17): [True: 107, False: 188k]
  ------------------
   81|    107|                data = rest;
   82|    107|                goto next;
   83|    107|            }
   84|   189k|        }
   85|  26.9k|        break;
   86|  26.9k|    next: ;
   87|    107|    }
   88|  27.0k|    return data;
   89|  27.0k|}

demux_set_ts_offset:
  975|  14.5k|{
  976|  14.5k|    struct demux_internal *in = demuxer->in;
  977|  14.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  14.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  978|  14.5k|    in->ts_offset = offset;
  979|  14.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  14.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  980|  14.5k|}
demux_alloc_sh_stream:
 1004|  34.4k|{
 1005|  34.4k|    struct sh_stream *sh = talloc_ptrtype(NULL, sh);
  ------------------
  |  |   34|  34.4k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  34.4k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  34.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1006|  34.4k|    *sh = (struct sh_stream) {
 1007|  34.4k|        .type = type,
 1008|  34.4k|        .index = -1,
 1009|  34.4k|        .ff_index = -1,     // may be overwritten by demuxer
 1010|  34.4k|        .demuxer_id = -1,   // ... same
 1011|  34.4k|        .codec = talloc_zero(sh, struct mp_codec_params),
  ------------------
  |  |   27|  34.4k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  34.4k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  34.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|  34.4k|        .tags = talloc_zero(sh, struct mp_tags),
  ------------------
  |  |   27|  34.4k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  34.4k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  34.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  34.4k|    };
 1014|  34.4k|    sh->codec->type = type;
 1015|  34.4k|    return sh;
 1016|  34.4k|}
demux_add_sh_stream:
 1086|  34.4k|{
 1087|  34.4k|    struct demux_internal *in = demuxer->in;
 1088|  34.4k|    mp_assert(demuxer == in->d_thread);
  ------------------
  |  |   41|  34.4k|#define mp_assert assert
  ------------------
  |  Branch (1088:5): [True: 34.4k, False: 0]
  ------------------
 1089|  34.4k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  34.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1090|  34.4k|    demux_add_sh_stream_locked(in, sh);
 1091|  34.4k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  34.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1092|  34.4k|}
demux_get_stream:
 1099|  66.8k|{
 1100|  66.8k|    struct demux_internal *in = demuxer->in;
 1101|  66.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  66.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1102|  66.8k|    mp_assert(index >= 0 && index < in->num_streams);
  ------------------
  |  |   41|  66.8k|#define mp_assert assert
  ------------------
  |  Branch (1102:5): [True: 66.8k, False: 0]
  |  Branch (1102:5): [True: 66.8k, False: 0]
  ------------------
 1103|  66.8k|    struct sh_stream *r = in->streams[index];
 1104|  66.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  66.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1105|  66.8k|    return r;
 1106|  66.8k|}
demux_get_num_stream:
 1110|   101k|{
 1111|   101k|    struct demux_internal *in = demuxer->in;
 1112|   101k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   101k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1113|   101k|    int r = in->num_streams;
 1114|   101k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   101k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|   101k|    return r;
 1116|   101k|}
demux_free:
 1159|   376k|{
 1160|   376k|    if (!demuxer)
  ------------------
  |  Branch (1160:9): [True: 30.0k, False: 346k]
  ------------------
 1161|  30.0k|        return;
 1162|   346k|    struct demux_internal *in = demuxer->in;
 1163|   346k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   346k|#define mp_assert assert
  ------------------
  |  Branch (1163:5): [True: 346k, False: 0]
  ------------------
 1164|       |
 1165|   346k|    demux_stop_thread(demuxer);
 1166|   346k|    demux_shutdown(in);
 1167|   346k|    demux_dealloc(in);
 1168|   346k|}
demux_free_async:
 1178|  18.1k|{
 1179|  18.1k|    struct demux_internal *in = demuxer->in;
 1180|  18.1k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  18.1k|#define mp_assert assert
  ------------------
  |  Branch (1180:5): [True: 18.1k, False: 0]
  ------------------
 1181|       |
 1182|  18.1k|    if (!in->threading)
  ------------------
  |  Branch (1182:9): [True: 3.91k, False: 14.2k]
  ------------------
 1183|  3.91k|        return NULL;
 1184|       |
 1185|  14.2k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  14.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1186|  14.2k|    in->thread_terminate = true;
 1187|  14.2k|    in->shutdown_async = true;
 1188|  14.2k|    mp_cond_signal(&in->wakeup);
 1189|  14.2k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  14.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1190|       |
 1191|  14.2k|    return (struct demux_free_async_state *)demuxer->in; // lies
 1192|  18.1k|}
demux_free_async_finish:
 1210|  58.7k|{
 1211|  58.7k|    struct demux_internal *in = (struct demux_internal *)state; // reverse lies
 1212|       |
 1213|  58.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  58.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1214|  58.7k|    bool busy = in->shutdown_async;
 1215|  58.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  58.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1216|       |
 1217|  58.7k|    if (busy)
  ------------------
  |  Branch (1217:9): [True: 44.5k, False: 14.2k]
  ------------------
 1218|  44.5k|        return false;
 1219|       |
 1220|  14.2k|    demux_stop_thread(in->d_user);
 1221|  14.2k|    demux_dealloc(in);
 1222|       |    return true;
 1223|  58.7k|}
demux_cancel_and_free:
 1229|  41.9k|{
 1230|  41.9k|    if (!demuxer)
  ------------------
  |  Branch (1230:9): [True: 35.2k, False: 6.73k]
  ------------------
 1231|  35.2k|        return;
 1232|  6.73k|    mp_cancel_trigger(demuxer->cancel);
 1233|  6.73k|    demux_free(demuxer);
 1234|  6.73k|}
demux_start_thread:
 1238|  14.7k|{
 1239|  14.7k|    struct demux_internal *in = demuxer->in;
 1240|  14.7k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  14.7k|#define mp_assert assert
  ------------------
  |  Branch (1240:5): [True: 14.7k, False: 0]
  ------------------
 1241|       |
 1242|  14.7k|    if (!in->threading) {
  ------------------
  |  Branch (1242:9): [True: 14.7k, False: 0]
  ------------------
 1243|  14.7k|        in->threading = true;
 1244|  14.7k|        if (mp_thread_create(&in->thread, demux_thread, in))
  ------------------
  |  |  214|  14.7k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 14.7k]
  |  |  ------------------
  ------------------
 1245|      0|            in->threading = false;
 1246|  14.7k|    }
 1247|  14.7k|}
demux_stop_thread:
 1250|   360k|{
 1251|   360k|    struct demux_internal *in = demuxer->in;
 1252|   360k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   360k|#define mp_assert assert
  ------------------
  |  Branch (1252:5): [True: 360k, False: 0]
  ------------------
 1253|       |
 1254|   360k|    if (in->threading) {
  ------------------
  |  Branch (1254:9): [True: 14.7k, False: 345k]
  ------------------
 1255|  14.7k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  14.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1256|  14.7k|        in->thread_terminate = true;
 1257|  14.7k|        mp_cond_signal(&in->wakeup);
 1258|  14.7k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  14.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1259|  14.7k|        mp_thread_join(in->thread);
  ------------------
  |  |  215|  14.7k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1260|  14.7k|        in->threading = false;
 1261|       |        in->thread_terminate = false;
 1262|  14.7k|    }
 1263|   360k|}
demux_set_wakeup_cb:
 1267|  32.8k|{
 1268|  32.8k|    struct demux_internal *in = demuxer->in;
 1269|  32.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  32.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1270|  32.8k|    in->wakeup_cb = cb;
 1271|  32.8k|    in->wakeup_cb_ctx = ctx;
 1272|  32.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  32.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1273|  32.8k|}
demux_nav_refresh:
 1300|  2.69M|{
 1301|  2.69M|    struct demux_internal *in = demuxer->in;
 1302|  2.69M|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  2.69M|#define mp_assert assert
  ------------------
  |  Branch (1302:5): [True: 2.69M, False: 0]
  ------------------
 1303|       |
 1304|  2.69M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  2.69M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1305|  2.69M|    if (in->d_thread->desc->nav_refresh) {
  ------------------
  |  Branch (1305:9): [True: 0, False: 2.69M]
  ------------------
 1306|      0|        in->nav_refresh = true;
 1307|      0|        in->reading = true;
 1308|      0|        mp_cond_signal(&in->wakeup);
 1309|      0|    }
 1310|  2.69M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  2.69M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1311|  2.69M|}
stream_type_name:
 1314|  1.16M|{
 1315|  1.16M|    switch (type) {
 1316|   357k|    case STREAM_VIDEO:  return "video";
  ------------------
  |  Branch (1316:5): [True: 357k, False: 812k]
  ------------------
 1317|   622k|    case STREAM_AUDIO:  return "audio";
  ------------------
  |  Branch (1317:5): [True: 622k, False: 546k]
  ------------------
 1318|   189k|    case STREAM_SUB:    return "sub";
  ------------------
  |  Branch (1318:5): [True: 189k, False: 980k]
  ------------------
 1319|      0|    default:            return "unknown";
  ------------------
  |  Branch (1319:5): [True: 0, False: 1.16M]
  ------------------
 1320|  1.16M|    }
 1321|  1.16M|}
demux_append_codec_desc:
 1333|   179k|{
 1334|   179k|    struct mp_codec_params *c = sh->codec;
 1335|       |
 1336|   179k|    bstr_xappend0(ta_ctx, dst, c->codec ? c->codec : "<unknown>");
  ------------------
  |  Branch (1336:32): [True: 179k, False: 0]
  ------------------
 1337|       |
 1338|   179k|    if (c->codec_profile)
  ------------------
  |  Branch (1338:9): [True: 66.3k, False: 112k]
  ------------------
 1339|  66.3k|        bstr_xappend_asprintf(ta_ctx, dst, " [%s]", c->codec_profile);
 1340|   179k|    if (c->disp_w)
  ------------------
  |  Branch (1340:9): [True: 60.9k, False: 118k]
  ------------------
 1341|  60.9k|        append_field(ta_ctx, dst, skip_dup,
 1342|  60.9k|                     mp_tprintf(32, "%dx%d", c->disp_w, c->disp_h));
  ------------------
  |  |  195|  60.9k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1343|   179k|    if (c->fps && !sh->image) {
  ------------------
  |  Branch (1343:9): [True: 60.9k, False: 118k]
  |  Branch (1343:19): [True: 60.9k, False: 0]
  ------------------
 1344|  60.9k|        char *fps = mp_format_double(ta_ctx, c->fps, 4, false, false, true);
 1345|  60.9k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%s fps", fps));
  ------------------
  |  |  195|  60.9k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1346|  60.9k|    }
 1347|   179k|    if (c->channels.num)
  ------------------
  |  Branch (1347:9): [True: 51.7k, False: 127k]
  ------------------
 1348|  51.7k|        bstr_xappend_asprintf(ta_ctx, dst, " %dch", c->channels.num);
 1349|   179k|    if (c->samplerate)
  ------------------
  |  Branch (1349:9): [True: 51.7k, False: 127k]
  ------------------
 1350|  51.7k|        bstr_xappend_asprintf(ta_ctx, dst, " %d Hz", c->samplerate);
 1351|   179k|    int bitrate = 0;
 1352|   179k|    if (c->bitrate > 0 && c->bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1352:9): [True: 51.7k, False: 127k]
  |  Branch (1352:27): [True: 51.7k, False: 0]
  ------------------
 1353|  51.7k|        bitrate = (c->bitrate + 500) / 1000;
 1354|   127k|    } else if (sh->hls_bitrate > 0 && sh->hls_bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1354:16): [True: 0, False: 127k]
  |  Branch (1354:39): [True: 0, False: 0]
  ------------------
 1355|      0|        bitrate = (sh->hls_bitrate + 500) / 1000;
 1356|      0|    }
 1357|   179k|    if (bitrate)
  ------------------
  |  Branch (1357:9): [True: 51.7k, False: 127k]
  ------------------
 1358|  51.7k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%d kbps", bitrate));
  ------------------
  |  |  195|  51.7k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1359|   179k|}
demux_read_packet_async:
 2974|  8.18M|{
 2975|  8.18M|    return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt);
  ------------------
  |  |   39|  8.18M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2976|  8.18M|}
demux_read_packet_async_until:
 2984|  8.96M|{
 2985|  8.96M|    struct demux_stream *ds = sh ? sh->ds : NULL;
  ------------------
  |  Branch (2985:31): [True: 8.96M, False: 0]
  ------------------
 2986|  8.96M|    *out_pkt = NULL;
 2987|  8.96M|    if (!ds)
  ------------------
  |  Branch (2987:9): [True: 0, False: 8.96M]
  ------------------
 2988|      0|        return -1;
 2989|  8.96M|    struct demux_internal *in = ds->in;
 2990|       |
 2991|  8.96M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  8.96M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2992|  8.96M|    int r = -1;
 2993|  9.43M|    while (1) {
  ------------------
  |  Branch (2993:12): [True: 9.43M, Folded]
  ------------------
 2994|  9.43M|        r = dequeue_packet(ds, min_pts, out_pkt);
 2995|  9.43M|        if (in->threading || in->blocked || r != 0)
  ------------------
  |  Branch (2995:13): [True: 8.17M, False: 1.25M]
  |  Branch (2995:30): [True: 0, False: 1.25M]
  |  Branch (2995:45): [True: 789k, False: 467k]
  ------------------
 2996|  8.96M|            break;
 2997|       |        // Needs to actually read packets until we got a packet or EOF.
 2998|   467k|        thread_work(in);
 2999|   467k|    }
 3000|  8.96M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  8.96M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3001|  8.96M|    return r;
 3002|  8.96M|}
demux_update:
 3400|  11.4M|{
 3401|  11.4M|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|  11.4M|#define mp_assert assert
  ------------------
  |  Branch (3401:5): [True: 11.4M, False: 0]
  ------------------
 3402|  11.4M|    struct demux_internal *in = demuxer->in;
 3403|       |
 3404|  11.4M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  11.4M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3405|       |
 3406|  11.4M|    if (!in->threading)
  ------------------
  |  Branch (3406:9): [True: 25.3k, False: 11.4M]
  ------------------
 3407|  25.3k|        update_cache(in);
 3408|       |
 3409|       |    // This implies this function is actually called from "the" user thread.
 3410|  11.4M|    in->d_user->filesize = in->stream_size;
 3411|       |
 3412|  11.4M|    pts = MP_ADD_PTS(pts, -in->ts_offset);
  ------------------
  |  |   67|  11.4M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  11.4M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 25.3k, False: 11.4M]
  |  |  ------------------
  ------------------
 3413|       |
 3414|  11.4M|    struct timed_metadata *prev = lookup_timed_metadata(in, in->last_playback_pts);
 3415|  11.4M|    struct timed_metadata *cur = lookup_timed_metadata(in, pts);
 3416|  11.4M|    if (prev != cur || in->force_metadata_update) {
  ------------------
  |  Branch (3416:9): [True: 0, False: 11.4M]
  |  Branch (3416:24): [True: 384k, False: 11.0M]
  ------------------
 3417|   384k|        in->force_metadata_update = false;
 3418|   384k|        update_final_metadata(demuxer, cur);
 3419|   384k|        demuxer->events |= DEMUX_EVENT_METADATA;
 3420|   384k|    }
 3421|       |
 3422|  11.4M|    in->last_playback_pts = pts;
 3423|       |
 3424|  11.4M|    demuxer->events |= in->events;
 3425|  11.4M|    in->events = 0;
 3426|  11.4M|    if (in->lists_changed) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 11.4M]
  ------------------
 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|  34.3M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3434:21): [True: 22.8M, False: 11.4M]
  ------------------
 3435|  22.8M|        struct demux_stream *ds = in->streams[n]->ds;
 3436|  22.8M|        if (ds->staged_codec) {
  ------------------
  |  Branch (3436:13): [True: 0, False: 22.8M]
  ------------------
 3437|      0|            in->streams[n]->codec = ds->staged_codec;
 3438|      0|            ds->staged_codec = NULL;
 3439|      0|        }
 3440|  22.8M|    }
 3441|  11.4M|    if (demuxer->events & (DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS | DEMUX_EVENT_CODEC))
  ------------------
  |  Branch (3441:9): [True: 398k, False: 11.0M]
  ------------------
 3442|   398k|        demux_update_replaygain(demuxer);
 3443|  11.4M|    if (demuxer->events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (3443:9): [True: 87.5k, False: 11.3M]
  ------------------
 3444|  87.5k|        demuxer->duration = in->duration;
 3445|       |
 3446|  11.4M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  11.4M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3447|  11.4M|}
demux_close_stream:
 3484|  9.18k|{
 3485|  9.18k|    struct demux_internal *in = demuxer->in;
 3486|  9.18k|    mp_assert(!in->threading && demuxer == in->d_thread);
  ------------------
  |  |   41|  9.18k|#define mp_assert assert
  ------------------
  |  Branch (3486:5): [True: 9.18k, False: 0]
  |  Branch (3486:5): [True: 9.18k, False: 0]
  ------------------
 3487|       |
 3488|  9.18k|    if (!demuxer->stream || !in->owns_stream)
  ------------------
  |  Branch (3488:9): [True: 0, False: 9.18k]
  |  Branch (3488:29): [True: 0, False: 9.18k]
  ------------------
 3489|      0|        return;
 3490|       |
 3491|  9.18k|    MP_VERBOSE(demuxer, "demuxer read all data; closing stream\n");
  ------------------
  |  |   92|  9.18k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.18k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3492|  9.18k|    free_stream(demuxer->stream);
 3493|  9.18k|    demuxer->stream = NULL;
 3494|       |    in->d_user->stream = NULL;
 3495|  9.18k|}
demux_is_network_cached:
 3516|  10.9k|{
 3517|  10.9k|    struct demux_internal *in = demuxer->in;
 3518|  10.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  10.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3519|  10.9k|    bool r = in->using_network_cache_opts;
 3520|  10.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  10.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3521|  10.9k|    return r;
 3522|  10.9k|}
demux_open_url:
 3766|  83.3k|{
 3767|  83.3k|    if (!params)
  ------------------
  |  Branch (3767:9): [True: 0, False: 83.3k]
  ------------------
 3768|      0|        return NULL;
 3769|  83.3k|    struct mp_cancel *priv_cancel = mp_cancel_new(NULL);
 3770|  83.3k|    if (cancel)
  ------------------
  |  Branch (3770:9): [True: 83.3k, False: 0]
  ------------------
 3771|  83.3k|        mp_cancel_set_parent(priv_cancel, cancel);
 3772|  83.3k|    struct stream *s = params->external_stream;
 3773|  83.3k|    if (!s) {
  ------------------
  |  Branch (3773:9): [True: 83.3k, False: 0]
  ------------------
 3774|  83.3k|        s = stream_create(url, STREAM_READ | params->stream_flags,
  ------------------
  |  |   41|  83.3k|#define STREAM_READ               0
  ------------------
 3775|  83.3k|                          priv_cancel, global);
 3776|  83.3k|        if (s && params->init_fragment.len) {
  ------------------
  |  Branch (3776:13): [True: 38.0k, False: 45.2k]
  |  Branch (3776:18): [True: 0, False: 38.0k]
  ------------------
 3777|      0|            s = create_webshit_concat_stream(global, priv_cancel,
 3778|      0|                                             params->init_fragment, s);
 3779|      0|        }
 3780|  83.3k|    }
 3781|  83.3k|    if (!s) {
  ------------------
  |  Branch (3781:9): [True: 45.2k, False: 38.0k]
  ------------------
 3782|  45.2k|        talloc_free(priv_cancel);
  ------------------
  |  |   47|  45.2k|#define talloc_free                     ta_free
  ------------------
 3783|  45.2k|        return NULL;
 3784|  45.2k|    }
 3785|  38.0k|    struct demuxer *d = demux_open(s, priv_cancel, params, global);
 3786|  38.0k|    if (d) {
  ------------------
  |  Branch (3786:9): [True: 25.3k, False: 12.7k]
  ------------------
 3787|  25.3k|        talloc_steal(d->in, priv_cancel);
  ------------------
  |  |   38|  25.3k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  25.3k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3788|  25.3k|        mp_assert(d->cancel);
  ------------------
  |  |   41|  25.3k|#define mp_assert assert
  ------------------
  |  Branch (3788:9): [True: 25.3k, False: 0]
  ------------------
 3789|  25.3k|    } else {
 3790|  12.7k|        params->demuxer_failed = true;
 3791|  12.7k|        if (!params->external_stream)
  ------------------
  |  Branch (3791:13): [True: 12.7k, False: 0]
  ------------------
 3792|  12.7k|            free_stream(s);
 3793|  12.7k|        talloc_free(priv_cancel);
  ------------------
  |  |   47|  12.7k|#define talloc_free                     ta_free
  ------------------
 3794|  12.7k|    }
 3795|  38.0k|    return d;
 3796|  38.0k|}
demux_flush:
 3800|   367k|{
 3801|   367k|    struct demux_internal *in = demuxer->in;
 3802|   367k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   367k|#define mp_assert assert
  ------------------
  |  Branch (3802:5): [True: 367k, False: 0]
  ------------------
 3803|       |
 3804|   367k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   367k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3805|   367k|    clear_reader_state(in, true);
 3806|   399k|    for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (3806:21): [True: 31.9k, False: 367k]
  ------------------
 3807|  31.9k|        clear_cached_range(in, in->ranges[n]);
 3808|   367k|    free_empty_cached_ranges(in);
 3809|   414k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3809:21): [True: 47.6k, False: 367k]
  ------------------
 3810|  47.6k|        struct demux_stream *ds = in->streams[n]->ds;
 3811|  47.6k|        ds->refreshing = false;
 3812|  47.6k|        ds->eof = false;
 3813|  47.6k|    }
 3814|   367k|    in->eof = false;
 3815|   367k|    in->seeking = false;
 3816|   367k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   367k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3817|   367k|}
demux_seek:
 4076|  2.85M|{
 4077|  2.85M|    struct demux_internal *in = demuxer->in;
 4078|  2.85M|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  2.85M|#define mp_assert assert
  ------------------
  |  Branch (4078:5): [True: 2.85M, False: 0]
  ------------------
 4079|       |
 4080|  2.85M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  2.85M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4081|       |
 4082|  2.85M|    if (!(flags & SEEK_FACTOR))
  ------------------
  |  |   94|  2.85M|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (4082:9): [True: 2.85M, False: 0]
  ------------------
 4083|  2.85M|        seek_pts = MP_ADD_PTS(seek_pts, -in->ts_offset);
  ------------------
  |  |   67|  2.85M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  2.85M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 2.85M]
  |  |  ------------------
  ------------------
 4084|       |
 4085|  2.85M|    int res = queue_seek(in, seek_pts, flags, true);
 4086|       |
 4087|  2.85M|    mp_cond_signal(&in->wakeup);
 4088|  2.85M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  2.85M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4089|       |
 4090|  2.85M|    return res;
 4091|  2.85M|}
demuxer_select_track:
 4325|  66.9k|{
 4326|  66.9k|    struct demux_internal *in = demuxer->in;
 4327|  66.9k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  66.9k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4328|  66.9k|    bool changed = select_track(in, stream, ref_pts, selected);
 4329|  66.9k|    changed |= select_dependent_tracks(in, stream, ref_pts, selected);
 4330|  66.9k|    if (changed) {
  ------------------
  |  Branch (4330:9): [True: 66.3k, False: 575]
  ------------------
 4331|  66.3k|        if (in->threading) {
  ------------------
  |  Branch (4331:13): [True: 57.8k, False: 8.52k]
  ------------------
 4332|  57.8k|            mp_cond_signal(&in->wakeup);
 4333|  57.8k|        } else {
 4334|  8.52k|            execute_trackswitch(in);
 4335|  8.52k|        }
 4336|  66.3k|    }
 4337|  66.9k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  66.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4338|  66.9k|}
demux_stream_is_selected:
 4390|  1.33M|{
 4391|  1.33M|    if (!stream)
  ------------------
  |  Branch (4391:9): [True: 0, False: 1.33M]
  ------------------
 4392|      0|        return false;
 4393|  1.33M|    bool r = false;
 4394|  1.33M|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|  1.33M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4395|  1.33M|    r = stream->ds->selected;
 4396|  1.33M|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|  1.33M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4397|  1.33M|    return r;
 4398|  1.33M|}
demux_stream_eof_is_lazy:
 4405|  21.1M|{
 4406|  21.1M|    if (!stream)
  ------------------
  |  Branch (4406:9): [True: 0, False: 21.1M]
  ------------------
 4407|      0|        return false;
 4408|  21.1M|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|  21.1M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4409|  21.1M|    bool r = stream->ds->lazy_eof;
 4410|  21.1M|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|  21.1M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4411|  21.1M|    return r;
 4412|  21.1M|}
demux_set_stream_wakeup_cb:
 4427|   107k|{
 4428|   107k|    mp_mutex_lock(&sh->ds->in->lock);
  ------------------
  |  |  134|   107k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4429|   107k|    sh->ds->wakeup_cb = cb;
 4430|   107k|    sh->ds->wakeup_cb_ctx = ctx;
 4431|   107k|    sh->ds->need_wakeup = true;
 4432|   107k|    mp_mutex_unlock(&sh->ds->in->lock);
  ------------------
  |  |  136|   107k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4433|   107k|}
demux_block_reading:
 4490|  7.64M|{
 4491|  7.64M|    struct demux_internal *in = demuxer->in;
 4492|  7.64M|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  7.64M|#define mp_assert assert
  ------------------
  |  Branch (4492:5): [True: 7.64M, False: 0]
  ------------------
 4493|       |
 4494|  7.64M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  7.64M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4495|  7.64M|    in->blocked = block;
 4496|  22.7M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4496:21): [True: 15.1M, False: 7.64M]
  ------------------
 4497|  15.1M|        in->streams[n]->ds->need_wakeup = true;
 4498|  15.1M|        wakeup_ds(in->streams[n]->ds);
 4499|  15.1M|    }
 4500|  7.64M|    mp_cond_signal(&in->wakeup);
 4501|  7.64M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  7.64M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4502|  7.64M|}
demux_cache_dump_set:
 4708|    118|{
 4709|    118|    struct demux_internal *in = demuxer->in;
 4710|    118|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|    118|#define mp_assert assert
  ------------------
  |  Branch (4710:5): [True: 118, False: 0]
  ------------------
 4711|       |
 4712|    118|    bool res = false;
 4713|       |
 4714|    118|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|    118|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4715|       |
 4716|    118|    start = MP_ADD_PTS(start, -in->ts_offset);
  ------------------
  |  |   67|    118|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    118|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 74, False: 44]
  |  |  ------------------
  ------------------
 4717|    118|    end = MP_ADD_PTS(end, -in->ts_offset);
  ------------------
  |  |   67|    118|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    118|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 88, False: 30]
  |  |  ------------------
  ------------------
 4718|       |
 4719|    118|    dumper_close(in);
 4720|       |
 4721|    118|    if (file && file[0] && start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|    118|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4721:9): [True: 118, False: 0]
  |  Branch (4721:17): [True: 118, False: 0]
  |  Branch (4721:28): [True: 44, False: 74]
  ------------------
 4722|     44|        res = true;
 4723|       |
 4724|     44|        in->dumper = recorder_create(in, file);
 4725|       |
 4726|       |        // This is not asynchronous and will freeze the shit for a while if the
 4727|       |        // user is unlucky. It could be moved to a thread with some effort.
 4728|       |        // General idea: iterate over all cache ranges, dump what intersects.
 4729|       |        // After that, and if the user requested it, make it dump all newly
 4730|       |        // received packets, even if it's awkward (consider the case if the
 4731|       |        // current range is not the last range).
 4732|     44|        dump_cache(in, start, end);
 4733|     44|    }
 4734|       |
 4735|    118|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|    118|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4736|       |
 4737|    118|    return res;
 4738|    118|}
demux_cache_dump_get_status:
 4742|     44|{
 4743|     44|    struct demux_internal *in = demuxer->in;
 4744|     44|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|     44|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4745|     44|    int status = in->dumper_status;
 4746|     44|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|     44|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4747|     44|    return status;
 4748|     44|}
demux_probe_cache_dump_target:
 4757|    922|{
 4758|    922|    struct demux_internal *in = demuxer->in;
 4759|    922|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|    922|#define mp_assert assert
  ------------------
  |  Branch (4759:5): [True: 922, False: 0]
  ------------------
 4760|       |
 4761|    922|    double res = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    922|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4762|    922|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    922|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4762:9): [True: 611, False: 311]
  ------------------
 4763|    611|        return pts;
 4764|       |
 4765|    311|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|    311|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4766|       |
 4767|    311|    pts = MP_ADD_PTS(pts, -in->ts_offset);
  ------------------
  |  |   67|    311|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    311|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 311]
  |  |  ------------------
  ------------------
 4768|       |
 4769|       |    // (When determining the end, look before the keyframe at pts, so subtract
 4770|       |    // an arbitrary amount to round down.)
 4771|    311|    double seek_pts = for_end ? pts - 0.001 : pts;
  ------------------
  |  Branch (4771:23): [True: 61, False: 250]
  ------------------
 4772|    311|    int flags = 0;
 4773|    311|    struct demux_cached_range *r = find_cache_seek_range(in, seek_pts, flags);
 4774|    311|    if (r) {
  ------------------
  |  Branch (4774:9): [True: 133, False: 178]
  ------------------
 4775|    133|        if (!for_end)
  ------------------
  |  Branch (4775:13): [True: 110, False: 23]
  ------------------
 4776|    110|            adjust_cache_seek_target(in, r, &pts, &flags);
 4777|       |
 4778|    133|        double t[STREAM_TYPE_COUNT];
 4779|    532|        for (int n = 0; n < STREAM_TYPE_COUNT; n++)
  ------------------
  |  Branch (4779:25): [True: 399, False: 133]
  ------------------
 4780|    399|            t[n] = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    399|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4781|       |
 4782|    399|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4782:25): [True: 266, False: 133]
  ------------------
 4783|    266|            struct demux_stream *ds = in->streams[n]->ds;
 4784|    266|            struct demux_queue *q = r->streams[n];
 4785|       |
 4786|    266|            struct demux_packet *dp = find_seek_target(q, pts, flags);
 4787|    266|            if (dp) {
  ------------------
  |  Branch (4787:17): [True: 238, False: 28]
  ------------------
 4788|    238|                if (for_end) {
  ------------------
  |  Branch (4788:21): [True: 41, False: 197]
  ------------------
 4789|     45|                    while (dp) {
  ------------------
  |  Branch (4789:28): [True: 45, False: 0]
  ------------------
 4790|     45|                        double pdts = MP_PTS_OR_DEF(dp->dts, dp->pts);
  ------------------
  |  |   62|     45|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|     45|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 45]
  |  |  ------------------
  ------------------
 4791|       |
 4792|     45|                        if (pdts != MP_NOPTS_VALUE && pdts >= pts && dp->keyframe)
  ------------------
  |  |   39|     90|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4792:29): [True: 45, False: 0]
  |  Branch (4792:55): [True: 41, False: 4]
  |  Branch (4792:70): [True: 41, False: 0]
  ------------------
 4793|     41|                            break;
 4794|       |
 4795|      4|                        t[ds->type] = MP_PTS_MAX(t[ds->type], pdts);
  ------------------
  |  |   65|      4|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|      8|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 4]
  |  |  |  |  |  Branch (44:23): [True: 4, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 4]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4796|       |
 4797|      4|                        dp = dp->next;
 4798|      4|                    }
 4799|    197|                } else {
 4800|    197|                    double start;
 4801|    197|                    compute_keyframe_times(dp, &start, NULL);
 4802|    197|                    start = MP_PTS_MAX(start, r->seek_start);
  ------------------
  |  |   65|    197|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|    394|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 55, False: 142]
  |  |  |  |  |  Branch (44:23): [True: 0, False: 197]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 197]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 55]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4803|    197|                    t[ds->type] = MP_PTS_MAX(t[ds->type], start);
  ------------------
  |  |   65|    197|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|    394|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 197]
  |  |  |  |  |  Branch (44:23): [True: 197, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 197]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 197]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4804|    197|                }
 4805|    238|            }
 4806|    266|        }
 4807|       |
 4808|    133|        res = t[STREAM_VIDEO];
 4809|    133|        if (res == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    133|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4809:13): [True: 46, False: 87]
  ------------------
 4810|     46|            res = t[STREAM_AUDIO];
 4811|    133|        if (res == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|    133|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4811:13): [True: 19, False: 114]
  ------------------
 4812|     76|            for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4812:29): [True: 57, False: 19]
  ------------------
 4813|     57|                res = t[n];
 4814|     57|                if (res != MP_NOPTS_VALUE)
  ------------------
  |  |   39|     57|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4814:21): [True: 0, False: 57]
  ------------------
 4815|      0|                    break;
 4816|     57|            }
 4817|     19|        }
 4818|    133|    }
 4819|       |
 4820|    311|    res = MP_ADD_PTS(res, in->ts_offset);
  ------------------
  |  |   67|    311|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|    311|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 197, False: 114]
  |  |  ------------------
  ------------------
 4821|       |
 4822|    311|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|    311|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4823|       |
 4824|    311|    return res;
 4825|    922|}
demux_get_bitrate_stats:
 4856|     35|{
 4857|     35|    struct demux_internal *in = demuxer->in;
 4858|     35|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|     35|#define mp_assert assert
  ------------------
  |  Branch (4858:5): [True: 35, False: 0]
  ------------------
 4859|       |
 4860|     35|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|     35|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4861|       |
 4862|    140|    for (int n = 0; n < STREAM_TYPE_COUNT; n++)
  ------------------
  |  Branch (4862:21): [True: 105, False: 35]
  ------------------
 4863|    105|        rates[n] = -1;
 4864|    105|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4864:21): [True: 70, False: 35]
  ------------------
 4865|     70|        struct demux_stream *ds = in->streams[n]->ds;
 4866|     70|        if (ds->selected && ds->bitrate >= 0)
  ------------------
  |  Branch (4866:13): [True: 46, False: 24]
  |  Branch (4866:29): [True: 4, False: 42]
  ------------------
 4867|      4|            rates[ds->type] = MPMAX(0, rates[ds->type]) + ds->bitrate;
  ------------------
  |  |   44|      4|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 4, False: 0]
  |  |  ------------------
  ------------------
 4868|     70|    }
 4869|       |
 4870|     35|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|     35|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4871|     35|}
demux_get_reader_state:
 4874|  15.1M|{
 4875|  15.1M|    struct demux_internal *in = demuxer->in;
 4876|  15.1M|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  15.1M|#define mp_assert assert
  ------------------
  |  Branch (4876:5): [True: 15.1M, False: 0]
  ------------------
 4877|       |
 4878|  15.1M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  15.1M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4879|       |
 4880|  15.1M|    *r = (struct demux_reader_state){
 4881|  15.1M|        .eof = in->eof,
 4882|  15.1M|        .ts_info = {
 4883|  15.1M|            .reader = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  15.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4884|  15.1M|            .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  15.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4885|  15.1M|            .duration = -1,
 4886|  15.1M|        },
 4887|  15.1M|        .total_bytes = in->total_bytes,
 4888|  15.1M|        .seeking = in->seeking_in_progress,
 4889|  15.1M|        .low_level_seeks = in->low_level_seeks,
 4890|  15.1M|        .ts_last = in->demux_ts,
 4891|  15.1M|        .bytes_per_second = in->bytes_per_second,
 4892|  15.1M|        .byte_level_seeks = in->byte_level_seeks,
 4893|  15.1M|        .file_cache_bytes = in->cache ? demux_cache_get_size(in->cache) : -1,
  ------------------
  |  Branch (4893:29): [True: 0, False: 15.1M]
  ------------------
 4894|  15.1M|    };
 4895|  15.1M|    bool any_packets = false;
 4896|  60.7M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4896:21): [True: 45.5M, False: 15.1M]
  ------------------
 4897|  45.5M|        r->ts_per_stream[n] = r->ts_info;
 4898|  45.5M|    }
 4899|  45.5M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4899:21): [True: 30.3M, False: 15.1M]
  ------------------
 4900|  30.3M|        struct demux_stream *ds = in->streams[n]->ds;
 4901|  30.3M|        if (ds->eager && !(!ds->queue->head && ds->eof) && !ds->ignore_eof) {
  ------------------
  |  Branch (4901:13): [True: 27.9M, False: 2.38M]
  |  Branch (4901:28): [True: 27.3M, False: 661k]
  |  Branch (4901:48): [True: 21.8M, False: 5.50M]
  |  Branch (4901:60): [True: 6.16M, False: 0]
  ------------------
 4902|  6.16M|            r->underrun |= !ds->reader_head && !ds->eof && !ds->still_image;
  ------------------
  |  Branch (4902:28): [True: 5.52M, False: 643k]
  |  Branch (4902:48): [True: 5.50M, False: 16.3k]
  |  Branch (4902:60): [True: 5.50M, False: 0]
  ------------------
 4903|  6.16M|            any_packets |= !!ds->reader_head;
 4904|       |
 4905|  6.16M|            double ts_reader = ds->base_ts;
 4906|  6.16M|            double ts_end = ds->queue->last_ts;
 4907|  6.16M|            double ts_duration = -1;
 4908|  6.16M|            if (ts_reader != MP_NOPTS_VALUE && ts_reader <= ts_end)
  ------------------
  |  |   39|  12.3M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4908:17): [True: 679k, False: 5.48M]
  |  Branch (4908:48): [True: 656k, False: 22.9k]
  ------------------
 4909|   656k|                ts_duration = ts_end - ts_reader;
 4910|       |
 4911|  6.16M|            struct demux_ctrl_ts_info *i = &r->ts_per_stream[ds->type];
 4912|  6.16M|            i->reader = MP_PTS_MIN(i->reader, ts_reader);
  ------------------
  |  |   64|  6.16M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  12.3M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 6.16M]
  |  |  |  |  |  Branch (45:23): [True: 6.16M, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 5.48M, False: 679k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 6.16M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4913|  6.16M|            i->end = MP_PTS_MIN(i->end, ts_end);
  ------------------
  |  |   64|  6.16M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  12.3M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 6.16M]
  |  |  |  |  |  Branch (45:23): [True: 6.16M, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 5.50M, False: 661k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 6.16M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4914|  6.16M|            i->duration = ts_duration;
 4915|  6.16M|        }
 4916|  30.3M|        r->fw_bytes += get_forward_buffered_bytes(ds);
 4917|  30.3M|    }
 4918|  15.1M|    struct demux_ctrl_ts_info *ots = &r->ts_info;
 4919|       |    // find stream type with lowest duration and use its state
 4920|  60.7M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4920:21): [True: 45.5M, False: 15.1M]
  ------------------
 4921|  45.5M|        struct demux_ctrl_ts_info *ts = &r->ts_per_stream[n];
 4922|  45.5M|        if (r->ts_info.duration != -1) {
  ------------------
  |  Branch (4922:13): [True: 667k, False: 44.8M]
  ------------------
 4923|       |            // skip if timestamps unknown
 4924|   667k|            if (ts->duration == -1)
  ------------------
  |  Branch (4924:17): [True: 349k, False: 317k]
  ------------------
 4925|   349k|                continue;
 4926|       |            // skip if we already know of a smaller cached stream
 4927|   317k|            if (ts->duration > ots->duration)
  ------------------
  |  Branch (4927:17): [True: 66.7k, False: 250k]
  ------------------
 4928|  66.7k|                continue;
 4929|       |            // skip empty subtitle streams when other streams exist
 4930|   250k|            if (n == STREAM_SUB && ts->duration == 0.0)
  ------------------
  |  Branch (4930:17): [True: 0, False: 250k]
  |  Branch (4930:36): [True: 0, False: 0]
  ------------------
 4931|      0|                continue;
 4932|   250k|        }
 4933|  45.1M|        ots->duration = ts->duration;
 4934|  45.1M|        ots->reader = ts->reader;
 4935|  45.1M|        ots->end = ts->end;
 4936|  45.1M|    }
 4937|  15.1M|    r->idle = (!in->reading && !r->underrun) || r->eof;
  ------------------
  |  Branch (4937:16): [True: 14.6M, False: 528k]
  |  Branch (4937:32): [True: 11.9M, False: 2.71M]
  |  Branch (4937:49): [True: 0, False: 3.23M]
  ------------------
 4938|  15.1M|    r->underrun &= !r->idle && in->threading;
  ------------------
  |  Branch (4938:20): [True: 3.23M, False: 11.9M]
  |  Branch (4938:32): [True: 3.23M, False: 0]
  ------------------
 4939|  15.1M|    ots->reader = MP_ADD_PTS(ots->reader, in->ts_offset);
  ------------------
  |  |   67|  15.1M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  15.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 14.8M, False: 338k]
  |  |  ------------------
  ------------------
 4940|  15.1M|    ots->end = MP_ADD_PTS(ots->end, in->ts_offset);
  ------------------
  |  |   67|  15.1M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  15.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 14.8M, False: 338k]
  |  |  ------------------
  ------------------
 4941|  15.1M|    if (ots->reader != MP_NOPTS_VALUE && ots->reader <= ots->end)
  ------------------
  |  |   39|  30.3M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4941:9): [True: 338k, False: 14.8M]
  |  Branch (4941:42): [True: 338k, False: 0]
  ------------------
 4942|   338k|        ots->duration = ots->end - ots->reader;
 4943|  15.1M|    if (in->seeking || !any_packets)
  ------------------
  |  Branch (4943:9): [True: 188k, False: 14.9M]
  |  Branch (4943:24): [True: 14.6M, False: 336k]
  ------------------
 4944|  14.8M|        ots->duration = 0;
 4945|  30.3M|    for (int n = 0; n < MPMIN(in->num_ranges, MAX_SEEK_RANGES); n++) {
  ------------------
  |  |   45|  30.3M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 30.3M]
  |  |  ------------------
  ------------------
  |  Branch (4945:21): [True: 15.1M, False: 15.1M]
  ------------------
 4946|  15.1M|        struct demux_cached_range *range = in->ranges[n];
 4947|  15.1M|        if (range->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  15.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4947:13): [True: 33.3k, False: 15.1M]
  ------------------
 4948|  33.3k|            r->seek_ranges[r->num_seek_ranges++] =
 4949|  33.3k|                (struct demux_seek_range){
 4950|  33.3k|                    .start = MP_ADD_PTS(range->seek_start, in->ts_offset),
  ------------------
  |  |   67|  33.3k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  33.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 33.3k]
  |  |  ------------------
  ------------------
 4951|  33.3k|                    .end = MP_ADD_PTS(range->seek_end, in->ts_offset),
  ------------------
  |  |   67|  33.3k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  33.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 33.3k]
  |  |  ------------------
  ------------------
 4952|  33.3k|                };
 4953|  33.3k|            r->bof_cached |= range->is_bof;
 4954|  33.3k|            r->eof_cached |= range->is_eof;
 4955|  33.3k|        }
 4956|  15.1M|    }
 4957|       |
 4958|  15.1M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  15.1M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4959|  15.1M|}
demux_cancel_test:
 4962|  12.9M|{
 4963|  12.9M|    return mp_cancel_test(demuxer->cancel);
 4964|  12.9M|}
demux_read_interrupted:
 4969|  5.94M|{
 4970|  5.94M|    struct demux_internal *in = demuxer->in;
 4971|  5.94M|    return atomic_load_explicit(&in->seeking, memory_order_relaxed) ||
  ------------------
  |  Branch (4971:12): [True: 0, False: 5.94M]
  ------------------
 4972|  5.94M|           atomic_load_explicit(&in->thread_terminate, memory_order_relaxed) ||
  ------------------
  |  Branch (4972:12): [True: 1, False: 5.94M]
  ------------------
 4973|  5.94M|           demux_cancel_test(demuxer);
  ------------------
  |  Branch (4973:12): [True: 310, False: 5.94M]
  ------------------
 4974|  5.94M|}
demux_copy_chapter_data:
 4977|  14.2k|{
 4978|  14.2k|    struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num);
  ------------------
  |  |   29|  14.2k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  14.2k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  14.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4979|  14.2k|    for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (4979:21): [True: 0, False: 14.2k]
  ------------------
 4980|      0|        new[n] = c[n];
 4981|      0|        new[n].metadata = mp_tags_dup(new, new[n].metadata);
 4982|      0|    }
 4983|  14.2k|    return new;
 4984|  14.2k|}
demux.c:update_stream_eager_state:
  900|   100k|{
  901|   100k|    bool any_av_streams = false;
  902|   100k|    bool any_streams = false;
  903|       |
  904|   273k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (904:21): [True: 173k, False: 100k]
  ------------------
  905|   173k|        struct demux_stream *s = in->streams[n]->ds;
  906|       |
  907|   173k|        s->still_image = s->sh->still_image;
  908|   173k|        s->eager = s->selected && !s->sh->absent && !s->sh->attached_picture;
  ------------------
  |  Branch (908:20): [True: 90.2k, False: 82.9k]
  |  Branch (908:35): [True: 90.2k, False: 0]
  |  Branch (908:53): [True: 90.2k, False: 0]
  ------------------
  909|   173k|        if (s->eager && !s->still_image)
  ------------------
  |  Branch (909:13): [True: 90.2k, False: 82.9k]
  |  Branch (909:25): [True: 90.2k, False: 0]
  ------------------
  910|  90.2k|            any_av_streams |= s->type != STREAM_SUB;
  911|   173k|        any_streams |= s->selected;
  912|   173k|    }
  913|       |
  914|       |    // Subtitles and sparse still-image video are only eagerly read if there are
  915|       |    // no other eagerly read streams.
  916|   100k|    if (any_av_streams) {
  ------------------
  |  Branch (916:9): [True: 57.4k, False: 43.2k]
  ------------------
  917|   172k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (917:25): [True: 114k, False: 57.4k]
  ------------------
  918|   114k|            struct demux_stream *s = in->streams[n]->ds;
  919|       |
  920|   114k|            if (s->type == STREAM_SUB || s->still_image)
  ------------------
  |  Branch (920:17): [True: 0, False: 114k]
  |  Branch (920:42): [True: 0, False: 114k]
  ------------------
  921|      0|                s->eager = false;
  922|   114k|        }
  923|  57.4k|    }
  924|       |
  925|   100k|    if (!any_streams)
  ------------------
  |  Branch (925:9): [True: 38.5k, False: 62.2k]
  ------------------
  926|  38.5k|        in->blocked = false;
  927|   100k|}
demux.c:demux_add_sh_stream_locked:
 1023|  34.4k|{
 1024|  34.4k|    mp_assert(!sh->ds); // must not be added yet
  ------------------
  |  |   41|  34.4k|#define mp_assert assert
  ------------------
  |  Branch (1024:5): [True: 34.4k, False: 0]
  ------------------
 1025|       |
 1026|  34.4k|    sh->index = in->num_streams;
 1027|       |
 1028|  34.4k|    sh->ds = talloc(sh, struct demux_stream);
  ------------------
  |  |   26|  34.4k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  34.4k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  34.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1029|  34.4k|    *sh->ds = (struct demux_stream) {
 1030|  34.4k|        .in = in,
 1031|  34.4k|        .sh = sh,
 1032|  34.4k|        .type = sh->type,
 1033|  34.4k|        .index = sh->index,
 1034|  34.4k|        .global_correct_dts = true,
 1035|  34.4k|        .global_correct_pos = true,
 1036|  34.4k|    };
 1037|       |
 1038|  34.4k|    struct demux_stream *ds = sh->ds;
 1039|       |
 1040|  34.4k|    if (!sh->codec->codec)
  ------------------
  |  Branch (1040:9): [True: 0, False: 34.4k]
  ------------------
 1041|      0|        sh->codec->codec = "";
 1042|       |
 1043|  34.4k|    MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
  ------------------
  |  |  105|  34.4k|    do {                                            \
  |  |  106|  34.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  34.4k|    do {                                            \
  |  |  |  |   97|  34.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  34.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  34.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  34.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 19.8k, False: 14.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  34.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  19.8k|    do {                                                        \
  |  |  |  |  |  |   89|  19.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  19.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  19.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  19.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  19.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  19.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  19.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 19.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  34.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 34.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  34.4k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  34.4k|        (idxvar)++;                                 \
  |  |  109|  34.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 34.4k]
  |  |  ------------------
  ------------------
 1044|  34.4k|    mp_assert(in->streams[sh->index] == sh);
  ------------------
  |  |   41|  34.4k|#define mp_assert assert
  ------------------
  |  Branch (1044:5): [True: 34.4k, False: 0]
  ------------------
 1045|       |
 1046|  34.4k|    if (in->current_range) {
  ------------------
  |  Branch (1046:9): [True: 0, False: 34.4k]
  ------------------
 1047|      0|        for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (1047:25): [True: 0, False: 0]
  ------------------
 1048|      0|            add_missing_streams(in, in->ranges[n]);
 1049|       |
 1050|      0|        sh->ds->queue = in->current_range->streams[sh->ds->index];
 1051|      0|    }
 1052|       |
 1053|  34.4k|    update_stream_selection_state(in, sh->ds);
 1054|       |
 1055|  34.4k|    switch (ds->type) {
  ------------------
  |  Branch (1055:13): [True: 29.7k, False: 4.74k]
  ------------------
 1056|  14.6k|    case STREAM_AUDIO:
  ------------------
  |  Branch (1056:5): [True: 14.6k, False: 19.8k]
  ------------------
 1057|  14.6k|        ds->back_preroll = in->d_user->opts->audio_back_preroll;
 1058|  14.6k|        if (ds->back_preroll < 0) { // auto
  ------------------
  |  Branch (1058:13): [True: 14.6k, False: 0]
  ------------------
 1059|  14.6k|            ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1;
  ------------------
  |  Branch (1059:32): [True: 14.6k, False: 0]
  ------------------
 1060|  14.6k|            if (sh->codec->codec && (strcmp(sh->codec->codec, "opus") == 0 ||
  ------------------
  |  Branch (1060:17): [True: 14.6k, False: 0]
  |  Branch (1060:38): [True: 0, False: 14.6k]
  ------------------
 1061|  14.6k|                                     strcmp(sh->codec->codec, "vorbis") == 0 ||
  ------------------
  |  Branch (1061:38): [True: 0, False: 14.6k]
  ------------------
 1062|  14.6k|                                     strcmp(sh->codec->codec, "mp3") == 0))
  ------------------
  |  Branch (1062:38): [True: 0, False: 14.6k]
  ------------------
 1063|      0|                ds->back_preroll = 2;
 1064|  14.6k|        }
 1065|  14.6k|        break;
 1066|  15.0k|    case STREAM_VIDEO:
  ------------------
  |  Branch (1066:5): [True: 15.0k, False: 19.3k]
  ------------------
 1067|  15.0k|        ds->back_preroll = in->d_user->opts->video_back_preroll;
 1068|  15.0k|        if (ds->back_preroll < 0)
  ------------------
  |  Branch (1068:13): [True: 15.0k, False: 0]
  ------------------
 1069|  15.0k|            ds->back_preroll = 0; // auto
 1070|  15.0k|        break;
 1071|  34.4k|    }
 1072|       |
 1073|  34.4k|    if (!ds->sh->attached_picture) {
  ------------------
  |  Branch (1073:9): [True: 34.4k, False: 0]
  ------------------
 1074|       |        // Typically this is used for webradio, so any stream will do.
 1075|  34.4k|        if (!in->metadata_stream)
  ------------------
  |  Branch (1075:13): [True: 19.8k, False: 14.6k]
  ------------------
 1076|  19.8k|            in->metadata_stream = sh;
 1077|  34.4k|    }
 1078|       |
 1079|  34.4k|    in->events |= DEMUX_EVENT_STREAMS;
 1080|  34.4k|    if (in->wakeup_cb)
  ------------------
  |  Branch (1080:9): [True: 0, False: 34.4k]
  ------------------
 1081|      0|        in->wakeup_cb(in->wakeup_cb_ctx);
 1082|  34.4k|}
demux.c:add_missing_streams:
  984|   405k|{
  985|  1.18M|    for (int n = range->num_streams; n < in->num_streams; n++) {
  ------------------
  |  Branch (985:38): [True: 775k, False: 405k]
  ------------------
  986|   775k|        struct demux_stream *ds = in->streams[n]->ds;
  987|       |
  988|   775k|        struct demux_queue *queue = talloc_ptrtype(NULL, queue);
  ------------------
  |  |   34|   775k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   775k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   775k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|   775k|        *queue = (struct demux_queue){
  990|   775k|            .ds = ds,
  991|   775k|            .range = range,
  992|   775k|        };
  993|   775k|        clear_queue(queue);
  994|   775k|        MP_TARRAY_APPEND(range, range->streams, range->num_streams, queue);
  ------------------
  |  |  105|   775k|    do {                                            \
  |  |  106|   775k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   775k|    do {                                            \
  |  |  |  |   97|   775k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   775k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   775k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   775k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 399k, False: 376k]
  |  |  |  |  ------------------
  |  |  |  |   99|   775k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   399k|    do {                                                        \
  |  |  |  |  |  |   89|   399k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   399k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   399k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   399k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   399k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   399k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   399k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 399k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   775k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 775k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   775k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   775k|        (idxvar)++;                                 \
  |  |  109|   775k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 775k]
  |  |  ------------------
  ------------------
  995|       |        mp_assert(range->streams[ds->index] == queue);
  ------------------
  |  |   41|   775k|#define mp_assert assert
  ------------------
  |  Branch (995:9): [True: 775k, False: 0]
  ------------------
  996|   775k|    }
  997|   405k|}
demux.c:clear_queue:
  758|  10.0M|{
  759|  10.0M|    struct demux_stream *ds = queue->ds;
  760|  10.0M|    struct demux_internal *in = ds->in;
  761|       |
  762|  10.0M|    if (queue->head)
  ------------------
  |  Branch (762:9): [True: 102k, False: 9.99M]
  ------------------
  763|   102k|        in->total_bytes -= queue->tail_cum_pos - queue->head->cum_pos;
  764|       |
  765|  10.0M|    free_index(queue);
  766|       |
  767|  10.0M|    demux_packet_pool_prepend(in->packet_pool, queue->head, queue->tail);
  768|  10.0M|    queue->head = queue->tail = NULL;
  769|  10.0M|    queue->keyframe_first = NULL;
  770|  10.0M|    queue->keyframe_latest = NULL;
  771|  10.0M|    queue->seek_start = queue->seek_end = queue->last_pruned = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  10.0M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  772|       |
  773|  10.0M|    queue->correct_dts = queue->correct_pos = true;
  774|  10.0M|    queue->last_pos = -1;
  775|  10.0M|    queue->last_ts = queue->last_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  10.0M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  776|  10.0M|    queue->last_pos_fixup = -1;
  777|       |
  778|  10.0M|    queue->is_eof = false;
  779|       |    queue->is_bof = false;
  780|  10.0M|}
demux.c:free_index:
  746|  10.0M|{
  747|  10.0M|    struct demux_stream *ds = queue->ds;
  748|  10.0M|    struct demux_internal *in = ds->in;
  749|       |
  750|  10.0M|    in->total_bytes -= queue->index_size * sizeof(queue->index[0]);
  751|  10.0M|    queue->index_size = 0;
  752|  10.0M|    queue->index0 = 0;
  753|  10.0M|    queue->num_index = 0;
  754|       |    TA_FREEP(&queue->index);
  ------------------
  |  |   81|  10.0M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  10.0M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 10.0M]
  |  |  ------------------
  ------------------
  755|  10.0M|}
demux.c:demux_shutdown:
 1120|   360k|{
 1121|   360k|    struct demuxer *demuxer = in->d_user;
 1122|       |
 1123|   360k|    if (in->recorder) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 360k]
  ------------------
 1124|      0|        mp_recorder_destroy(in->recorder);
 1125|      0|        in->recorder = NULL;
 1126|      0|    }
 1127|       |
 1128|   360k|    dumper_close(in);
 1129|       |
 1130|   360k|    if (demuxer->desc->close)
  ------------------
  |  Branch (1130:9): [True: 130k, False: 230k]
  ------------------
 1131|   130k|        demuxer->desc->close(in->d_thread);
 1132|   360k|    demuxer->priv = NULL;
 1133|   360k|    in->d_thread->priv = NULL;
 1134|       |
 1135|   360k|    demux_flush(demuxer);
 1136|   360k|    mp_assert(in->total_bytes == 0);
  ------------------
  |  |   41|   360k|#define mp_assert assert
  ------------------
  |  Branch (1136:5): [True: 360k, False: 0]
  ------------------
 1137|       |
 1138|   360k|    in->current_range = NULL;
 1139|   360k|    free_empty_cached_ranges(in);
 1140|       |
 1141|   360k|    talloc_free(in->cache);
  ------------------
  |  |   47|   360k|#define talloc_free                     ta_free
  ------------------
 1142|   360k|    in->cache = NULL;
 1143|       |
 1144|   360k|    if (in->owns_stream)
  ------------------
  |  Branch (1144:9): [True: 360k, False: 0]
  ------------------
 1145|   360k|        free_stream(demuxer->stream);
 1146|       |    demuxer->stream = NULL;
 1147|   360k|}
demux.c:demux_dealloc:
 1150|   360k|{
 1151|   394k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1151:21): [True: 34.4k, False: 360k]
  ------------------
 1152|  34.4k|        talloc_free(in->streams[n]);
  ------------------
  |  |   47|  34.4k|#define talloc_free                     ta_free
  ------------------
 1153|   360k|    mp_mutex_destroy(&in->lock);
  ------------------
  |  |  133|   360k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1154|   360k|    mp_cond_destroy(&in->wakeup);
 1155|   360k|    talloc_free(in->d_user);
  ------------------
  |  |   47|   360k|#define talloc_free                     ta_free
  ------------------
 1156|   360k|}
demux.c:append_field:
 1325|   173k|{
 1326|   173k|    if (skip_dup && skip_dup[0] && strstr(skip_dup, value))
  ------------------
  |  Branch (1326:9): [True: 0, False: 173k]
  |  Branch (1326:21): [True: 0, False: 0]
  |  Branch (1326:36): [True: 0, False: 0]
  ------------------
 1327|      0|        return;
 1328|   173k|    bstr_xappend_asprintf(ta_ctx, dst, " %s", value);
 1329|   173k|}
demux.c:add_packet_locked:
 2153|  1.19M|{
 2154|  1.19M|    struct demux_stream *ds = stream ? stream->ds : NULL;
  ------------------
  |  Branch (2154:31): [True: 1.19M, False: 0]
  ------------------
 2155|  1.19M|    mp_assert(ds && ds->in);
  ------------------
  |  |   41|  1.19M|#define mp_assert assert
  ------------------
  |  Branch (2155:5): [True: 1.19M, False: 0]
  |  Branch (2155:5): [True: 1.19M, False: 0]
  ------------------
 2156|  1.19M|    if (!dp->len || demux_cancel_test(ds->in->d_thread)) {
  ------------------
  |  Branch (2156:9): [True: 50.5k, False: 1.14M]
  |  Branch (2156:21): [True: 0, False: 1.14M]
  ------------------
 2157|  50.5k|        talloc_free(dp);
  ------------------
  |  |   47|  50.5k|#define talloc_free                     ta_free
  ------------------
 2158|  50.5k|        return;
 2159|  50.5k|    }
 2160|       |
 2161|  1.14M|    mp_assert(dp->stream == stream->index);
  ------------------
  |  |   41|  1.14M|#define mp_assert assert
  ------------------
  |  Branch (2161:5): [True: 1.14M, False: 0]
  ------------------
 2162|  1.14M|    mp_assert(!dp->next);
  ------------------
  |  |   41|  1.14M|#define mp_assert assert
  ------------------
  |  Branch (2162:5): [True: 1.14M, False: 0]
  ------------------
 2163|       |
 2164|  1.14M|    struct demux_internal *in = ds->in;
 2165|       |
 2166|  1.14M|    in->after_seek = false;
 2167|  1.14M|    in->after_seek_to_start = false;
 2168|       |
 2169|  1.14M|    double ts = dp->dts == MP_NOPTS_VALUE ? dp->pts : dp->dts;
  ------------------
  |  |   39|  1.14M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2169:17): [True: 0, False: 1.14M]
  ------------------
 2170|  1.14M|    if (dp->segmented)
  ------------------
  |  Branch (2170:9): [True: 0, False: 1.14M]
  ------------------
 2171|      0|        ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|      0|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2172|       |
 2173|  1.14M|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.14M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2173:9): [True: 1.14M, False: 0]
  ------------------
 2174|  1.14M|        in->demux_ts = ts;
 2175|       |
 2176|  1.14M|    struct demux_queue *queue = ds->queue;
 2177|       |
 2178|  1.14M|    bool drop = !ds->selected || in->seeking || ds->sh->attached_picture;
  ------------------
  |  Branch (2178:17): [True: 0, False: 1.14M]
  |  Branch (2178:34): [True: 105, False: 1.14M]
  |  Branch (2178:49): [True: 0, False: 1.14M]
  ------------------
 2179|       |
 2180|  1.14M|    if (!drop) {
  ------------------
  |  Branch (2180:9): [True: 1.14M, False: 105]
  ------------------
 2181|       |        // If libavformat splits packets, some packets will have pos unset, so
 2182|       |        // make up one based on the first packet => makes refresh seeks work.
 2183|  1.14M|        if ((dp->pos < 0 || dp->pos == queue->last_pos_fixup) &&
  ------------------
  |  Branch (2183:14): [True: 960k, False: 183k]
  |  Branch (2183:29): [True: 0, False: 183k]
  ------------------
 2184|   960k|            !dp->keyframe && queue->last_pos_fixup >= 0)
  ------------------
  |  Branch (2184:13): [True: 0, False: 960k]
  |  Branch (2184:30): [True: 0, False: 0]
  ------------------
 2185|      0|            dp->pos = queue->last_pos_fixup + 1;
 2186|  1.14M|        queue->last_pos_fixup = dp->pos;
 2187|  1.14M|    }
 2188|       |
 2189|  1.14M|    if (!drop && ds->refreshing) {
  ------------------
  |  Branch (2189:9): [True: 1.14M, False: 105]
  |  Branch (2189:18): [True: 4, False: 1.14M]
  ------------------
 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|      4|        if (queue->correct_dts) {
  ------------------
  |  Branch (2193:13): [True: 4, False: 0]
  ------------------
 2194|      4|            ds->refreshing = dp->dts < queue->last_dts;
 2195|      4|        } else if (queue->correct_pos) {
  ------------------
  |  Branch (2195:20): [True: 0, False: 0]
  ------------------
 2196|      0|            ds->refreshing = dp->pos < queue->last_pos;
 2197|      0|        } else {
 2198|      0|            ds->refreshing = false; // should not happen
 2199|      0|            MP_WARN(in, "stream %d: demux refreshing failed\n", ds->index);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2200|      0|        }
 2201|      4|        drop = true;
 2202|      4|    }
 2203|       |
 2204|  1.14M|    if (drop) {
  ------------------
  |  Branch (2204:9): [True: 109, False: 1.14M]
  ------------------
 2205|    109|        demux_packet_pool_push(in->packet_pool, dp);
 2206|    109|        return;
 2207|    109|    }
 2208|       |
 2209|  1.14M|    record_packet(in, dp);
 2210|       |
 2211|  1.14M|    if (in->cache && in->d_user->opts->disk_cache && !dp->is_wrapped_avframe) {
  ------------------
  |  Branch (2211:9): [True: 0, False: 1.14M]
  |  Branch (2211:22): [True: 0, False: 0]
  |  Branch (2211:54): [True: 0, False: 0]
  ------------------
 2212|      0|        int64_t pos = demux_cache_write(in->cache, dp);
 2213|      0|        if (pos >= 0) {
  ------------------
  |  Branch (2213:13): [True: 0, False: 0]
  ------------------
 2214|      0|            demux_packet_unref_contents(dp);
 2215|      0|            dp->is_cached = true;
 2216|      0|            dp->cached_data.pos = pos;
 2217|      0|        }
 2218|      0|    }
 2219|       |
 2220|  1.14M|    queue->correct_pos &= dp->pos >= 0 && dp->pos > queue->last_pos;
  ------------------
  |  Branch (2220:27): [True: 183k, False: 960k]
  |  Branch (2220:43): [True: 183k, False: 0]
  ------------------
 2221|  1.14M|    queue->correct_dts &= dp->dts != MP_NOPTS_VALUE && dp->dts > queue->last_dts;
  ------------------
  |  |   39|  2.28M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2221:27): [True: 1.14M, False: 0]
  |  Branch (2221:56): [True: 1.14M, False: 0]
  ------------------
 2222|  1.14M|    queue->last_pos = dp->pos;
 2223|  1.14M|    queue->last_dts = dp->dts;
 2224|  1.14M|    ds->global_correct_pos &= queue->correct_pos;
 2225|  1.14M|    ds->global_correct_dts &= queue->correct_dts;
 2226|       |
 2227|       |    // (keep in mind that even if the reader went out of data, the queue is not
 2228|       |    // necessarily empty due to the backbuffer)
 2229|  1.14M|    if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
  ------------------
  |  Branch (2229:9): [True: 244k, False: 899k]
  |  Branch (2229:30): [True: 244k, False: 0]
  |  Branch (2229:55): [True: 0, False: 0]
  ------------------
 2230|   244k|        ds->reader_head = dp;
 2231|   244k|        ds->skip_to_keyframe = false;
 2232|   244k|    }
 2233|       |
 2234|  1.14M|    size_t bytes = demux_packet_estimate_total_size(dp);
 2235|  1.14M|    in->total_bytes += bytes;
 2236|  1.14M|    dp->cum_pos = queue->tail_cum_pos;
 2237|  1.14M|    queue->tail_cum_pos += bytes;
 2238|       |
 2239|  1.14M|    if (queue->tail) {
  ------------------
  |  Branch (2239:9): [True: 900k, False: 243k]
  ------------------
 2240|       |        // next packet in stream
 2241|   900k|        queue->tail->next = dp;
 2242|   900k|        queue->tail = dp;
 2243|   900k|    } else {
 2244|       |        // first packet in stream
 2245|   243k|        queue->head = queue->tail = dp;
 2246|   243k|    }
 2247|       |
 2248|  1.14M|    if (!ds->ignore_eof) {
  ------------------
  |  Branch (2248:9): [True: 1.14M, False: 0]
  ------------------
 2249|       |        // obviously not true anymore
 2250|  1.14M|        ds->eof = false;
 2251|  1.14M|        in->eof = false;
 2252|  1.14M|    }
 2253|       |
 2254|       |    // For video, PTS determination is not trivial, but for other media types
 2255|       |    // distinguishing PTS and DTS is not useful.
 2256|  1.14M|    if (stream->type != STREAM_VIDEO && dp->pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   797k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2256:9): [True: 797k, False: 346k]
  |  Branch (2256:41): [True: 0, False: 797k]
  ------------------
 2257|      0|        dp->pts = dp->dts;
 2258|       |
 2259|  1.14M|    if (ts != MP_NOPTS_VALUE && (ts > queue->last_ts || ts + 10 < queue->last_ts))
  ------------------
  |  |   39|  2.28M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2259:9): [True: 1.14M, False: 0]
  |  Branch (2259:34): [True: 1.14M, False: 0]
  |  Branch (2259:57): [True: 0, False: 0]
  ------------------
 2260|  1.14M|        queue->last_ts = ts;
 2261|  1.14M|    if (ds->base_ts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.14M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2261:9): [True: 220k, False: 923k]
  ------------------
 2262|   220k|        ds->base_ts = queue->last_ts;
 2263|       |
 2264|  1.14M|    const char *num_pkts = queue->head == queue->tail ? "1" : ">1";
  ------------------
  |  Branch (2264:28): [True: 243k, False: 900k]
  ------------------
 2265|  1.14M|    uint64_t fw_bytes = get_forward_buffered_bytes(ds);
 2266|  1.14M|    MP_TRACE(in, "append packet to %s: size=%zu pts=%f dts=%f pos=%"PRIi64" "
  ------------------
  |  |   94|  1.14M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.14M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2267|  1.14M|             "[num=%s size=%zd]\n", stream_type_name(stream->type),
 2268|  1.14M|             dp->len, dp->pts, dp->dts, dp->pos, num_pkts, (size_t)fw_bytes);
 2269|       |
 2270|  1.14M|    adjust_seek_range_on_packet(ds, dp);
 2271|       |
 2272|       |    // May need to reduce backward cache.
 2273|  1.14M|    prune_old_packets(in);
 2274|       |
 2275|       |    // Possibly update duration based on highest TS demuxed (but ignore subs).
 2276|  1.14M|    if (stream->type != STREAM_SUB) {
  ------------------
  |  Branch (2276:9): [True: 960k, False: 183k]
  ------------------
 2277|   960k|        if (dp->segmented)
  ------------------
  |  Branch (2277:13): [True: 0, False: 960k]
  ------------------
 2278|      0|            ts = MP_PTS_MIN(ts, dp->end);
  ------------------
  |  |   64|      0|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2279|   960k|        if (ts > in->highest_av_pts) {
  ------------------
  |  Branch (2279:13): [True: 947k, False: 13.6k]
  ------------------
 2280|   947k|            in->highest_av_pts = ts;
 2281|   947k|            double duration = in->highest_av_pts - in->d_thread->start_time;
 2282|   947k|            if (duration > in->d_thread->duration) {
  ------------------
  |  Branch (2282:17): [True: 947k, False: 0]
  ------------------
 2283|   947k|                in->d_thread->duration = duration;
 2284|       |                // (Don't wakeup user thread, would be too noisy.)
 2285|   947k|                in->events |= DEMUX_EVENT_DURATION;
 2286|   947k|                in->duration = duration;
 2287|   947k|            }
 2288|   947k|        }
 2289|   960k|    }
 2290|       |
 2291|       |    // Don't process the packet further if it's skipped by the previous seek
 2292|       |    // (see reader_head check/assignment above).
 2293|  1.14M|    if (!ds->reader_head)
  ------------------
  |  Branch (2293:9): [True: 0, False: 1.14M]
  ------------------
 2294|      0|        return;
 2295|       |
 2296|  1.14M|    back_demux_see_packets(ds);
 2297|       |
 2298|  1.14M|    wakeup_ds(ds);
 2299|  1.14M|}
demux.c:record_packet:
 2122|  1.14M|{
 2123|       |    // (should preferably be outside of the lock)
 2124|  1.14M|    if (in->enable_recording && !in->recorder &&
  ------------------
  |  Branch (2124:9): [True: 0, False: 1.14M]
  |  Branch (2124:33): [True: 0, False: 0]
  ------------------
 2125|      0|        in->d_user->opts->record_file && in->d_user->opts->record_file[0])
  ------------------
  |  Branch (2125:9): [True: 0, False: 0]
  |  Branch (2125:42): [True: 0, False: 0]
  ------------------
 2126|      0|    {
 2127|       |        // Later failures shouldn't make it retry and overwrite the previously
 2128|       |        // recorded file.
 2129|      0|        in->enable_recording = false;
 2130|       |
 2131|      0|        in->recorder = recorder_create(in, in->d_user->opts->record_file);
 2132|      0|        if (!in->recorder)
  ------------------
  |  Branch (2132:13): [True: 0, False: 0]
  ------------------
 2133|      0|            MP_ERR(in, "Disabling recording.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2134|      0|    }
 2135|       |
 2136|  1.14M|    if (in->recorder) {
  ------------------
  |  Branch (2136:9): [True: 0, False: 1.14M]
  ------------------
 2137|      0|        struct mp_recorder_sink *sink =
 2138|      0|            mp_recorder_get_sink(in->recorder, in->streams[dp->stream]);
 2139|      0|        if (sink) {
  ------------------
  |  Branch (2139:13): [True: 0, False: 0]
  ------------------
 2140|      0|            mp_recorder_feed_packet(sink, dp);
 2141|      0|        } else {
 2142|      0|            MP_ERR(in, "New stream appeared; stopping recording.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2143|      0|            mp_recorder_destroy(in->recorder);
 2144|      0|            in->recorder = NULL;
 2145|      0|        }
 2146|      0|    }
 2147|       |
 2148|  1.14M|    if (in->dumper_status == CONTROL_OK)
  ------------------
  |  |   95|  1.14M|#define CONTROL_OK 1
  ------------------
  |  Branch (2148:9): [True: 0, False: 1.14M]
  ------------------
 2149|      0|        write_dump_packet(in, dp);
 2150|  1.14M|}
demux.c:adjust_seek_range_on_packet:
 2015|  10.3M|{
 2016|  10.3M|    struct demux_queue *queue = ds->queue;
 2017|       |
 2018|  10.3M|    if (!ds->in->seekable_cache)
  ------------------
  |  Branch (2018:9): [True: 9.52M, False: 803k]
  ------------------
 2019|  9.52M|        return;
 2020|       |
 2021|  10.3M|    bool new_eof = !dp;
 2022|   803k|    bool update_ranges = queue->is_eof != new_eof;
 2023|   803k|    queue->is_eof = new_eof;
 2024|       |
 2025|   803k|    if (!dp || dp->keyframe) {
  ------------------
  |  Branch (2025:9): [True: 730k, False: 72.9k]
  |  Branch (2025:16): [True: 72.9k, False: 0]
  ------------------
 2026|   803k|        if (queue->keyframe_latest) {
  ------------------
  |  Branch (2026:13): [True: 52.1k, False: 751k]
  ------------------
 2027|  52.1k|            double kf_min, kf_max;
 2028|  52.1k|            compute_keyframe_times(queue->keyframe_latest, &kf_min, &kf_max);
 2029|       |
 2030|  52.1k|            if (kf_min != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  52.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2030:17): [True: 52.1k, False: 0]
  ------------------
 2031|  52.1k|                add_index_entry(queue, queue->keyframe_latest, kf_min);
 2032|       |
 2033|       |                // Initialize the queue's start if it's unset.
 2034|  52.1k|                if (queue->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  52.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2034:21): [True: 1.78k, False: 50.3k]
  ------------------
 2035|  1.78k|                    update_ranges = true;
 2036|  1.78k|                    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|  1.78k|                    double start_time = ds->in->d_thread->start_time;
 2044|  1.78k|                    if (queue->is_bof && ds->in->d_thread->seekable &&
  ------------------
  |  Branch (2044:25): [True: 1.57k, False: 214]
  |  Branch (2044:42): [True: 1.57k, False: 0]
  ------------------
 2045|  1.57k|                        start_time != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  3.36k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2045:25): [True: 1.57k, False: 0]
  ------------------
 2046|  1.57k|                        queue->seek_start > start_time + BOF_START_TOLERANCE)
  ------------------
  |  |  348|  1.57k|#define BOF_START_TOLERANCE 1.0
  ------------------
  |  Branch (2046:25): [True: 62, False: 1.51k]
  ------------------
 2047|     62|                    {
 2048|     62|                        queue->is_bof = false;
 2049|     62|                    }
 2050|  1.78k|                }
 2051|  52.1k|            }
 2052|       |
 2053|  52.1k|            if (kf_max != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|   104k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2053:17): [True: 52.1k, False: 0]
  ------------------
 2054|  52.1k|                (queue->seek_end == MP_NOPTS_VALUE || kf_max > queue->seek_end))
  ------------------
  |  |   39|   104k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2054:18): [True: 1.78k, False: 50.3k]
  |  Branch (2054:55): [True: 50.3k, False: 0]
  ------------------
 2055|  52.1k|            {
 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|  52.1k|                if (queue->range->seek_end == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|   104k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2061:21): [True: 4.13k, False: 47.9k]
  ------------------
 2062|  47.9k|                    queue->seek_end <= queue->range->seek_end)
  ------------------
  |  Branch (2062:21): [True: 24.4k, False: 23.5k]
  ------------------
 2063|  28.5k|                {
 2064|  28.5k|                    update_ranges = true;
 2065|  28.5k|                }
 2066|       |
 2067|  52.1k|                queue->seek_end = kf_max;
 2068|  52.1k|            }
 2069|  52.1k|        }
 2070|       |
 2071|   803k|        queue->keyframe_latest = dp;
 2072|   803k|    }
 2073|       |
 2074|       |    // Adding a sparse packet never changes the seek range.
 2075|   803k|    if (update_ranges && ds->eager) {
  ------------------
  |  Branch (2075:9): [True: 749k, False: 53.4k]
  |  Branch (2075:26): [True: 533k, False: 216k]
  ------------------
 2076|   533k|        update_seek_ranges(queue->range);
 2077|   533k|        attempt_range_joining(ds->in);
 2078|   533k|    }
 2079|   803k|}
demux.c:add_index_entry:
 1747|  52.1k|{
 1748|  52.1k|    struct demux_internal *in = queue->ds->in;
 1749|       |
 1750|  52.1k|    mp_assert(dp->keyframe && pts != MP_NOPTS_VALUE);
  ------------------
  |  |   41|  52.1k|#define mp_assert assert
  ------------------
  |  Branch (1750:5): [True: 52.1k, False: 0]
  |  Branch (1750:5): [True: 52.1k, False: 0]
  ------------------
 1751|       |
 1752|  52.1k|    if (queue->num_index > 0) {
  ------------------
  |  Branch (1752:9): [True: 50.3k, False: 1.78k]
  ------------------
 1753|  50.3k|        struct index_entry *last = &QUEUE_INDEX_ENTRY(queue, queue->num_index - 1);
  ------------------
  |  |  340|  50.3k|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|  50.3k|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1754|  50.3k|        if (pts - last->pts < INDEX_STEP_SIZE)
  ------------------
  |  |  344|  50.3k|#define INDEX_STEP_SIZE 1.0
  ------------------
  |  Branch (1754:13): [True: 50.3k, False: 0]
  ------------------
 1755|  50.3k|            return;
 1756|  50.3k|    }
 1757|       |
 1758|  1.78k|    if (queue->num_index == queue->index_size) {
  ------------------
  |  Branch (1758:9): [True: 1.78k, False: 0]
  ------------------
 1759|       |        // Needs to honor power-of-2 requirement.
 1760|  1.78k|        size_t new_size = MPMAX(128, queue->index_size * 2);
  ------------------
  |  |   44|  1.78k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.78k, False: 0]
  |  |  ------------------
  ------------------
 1761|  1.78k|        mp_assert(!(new_size & (new_size - 1)));
  ------------------
  |  |   41|  1.78k|#define mp_assert assert
  ------------------
  |  Branch (1761:9): [True: 1.78k, False: 0]
  ------------------
 1762|  1.78k|        MP_DBG(in, "stream %d: resize index to %zu\n", queue->ds->index,
  ------------------
  |  |   93|  1.78k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.78k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1763|  1.78k|               new_size);
 1764|       |        // Note: we could tolerate allocation failure, and just discard the
 1765|       |        // entire index (and prevent the index from being recreated).
 1766|  1.78k|        MP_RESIZE_ARRAY(NULL, queue->index, new_size);
  ------------------
  |  |   88|  1.78k|    do {                                                        \
  |  |   89|  1.78k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  1.78k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.78k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  1.78k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  1.78k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  1.78k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  1.78k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 1.78k]
  |  |  ------------------
  ------------------
 1767|  1.78k|        size_t highest_index = queue->index0 + queue->num_index;
 1768|  1.78k|        for (size_t n = queue->index_size; n < highest_index; n++)
  ------------------
  |  Branch (1768:44): [True: 0, False: 1.78k]
  ------------------
 1769|      0|            queue->index[n] = queue->index[n - queue->index_size];
 1770|  1.78k|        in->total_bytes +=
 1771|  1.78k|            (new_size - queue->index_size) * sizeof(queue->index[0]);
 1772|  1.78k|        queue->index_size = new_size;
 1773|  1.78k|    }
 1774|       |
 1775|  1.78k|    mp_assert(queue->num_index < queue->index_size);
  ------------------
  |  |   41|  1.78k|#define mp_assert assert
  ------------------
  |  Branch (1775:5): [True: 1.78k, False: 0]
  ------------------
 1776|       |
 1777|  1.78k|    queue->num_index += 1;
 1778|       |
 1779|  1.78k|    QUEUE_INDEX_ENTRY(queue, queue->num_index - 1) = (struct index_entry){
  ------------------
  |  |  340|  1.78k|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|  1.78k|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1780|  1.78k|        .pts = pts,
 1781|  1.78k|        .pkt = dp,
 1782|  1.78k|    };
 1783|  1.78k|}
demux.c:update_seek_ranges:
  629|  5.53M|{
  630|  5.53M|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.53M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  631|  5.53M|    range->is_bof = true;
  632|  5.53M|    range->is_eof = true;
  633|       |
  634|  5.53M|    double min_start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.53M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  635|  5.53M|    double max_end_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.53M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  636|       |
  637|  7.38M|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (637:21): [True: 6.96M, False: 413k]
  ------------------
  638|  6.96M|        struct demux_queue *queue = range->streams[n];
  639|       |
  640|  6.96M|        if (queue->ds->selected && queue->ds->eager) {
  ------------------
  |  Branch (640:13): [True: 5.82M, False: 1.14M]
  |  Branch (640:36): [True: 5.82M, False: 0]
  ------------------
  641|  5.82M|            if (queue->is_bof) {
  ------------------
  |  Branch (641:17): [True: 521k, False: 5.30M]
  ------------------
  642|   521k|                min_start_pts = MP_PTS_MIN(min_start_pts, queue->seek_start);
  ------------------
  |  |   64|   521k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  1.04M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 190, False: 521k]
  |  |  |  |  |  Branch (45:23): [True: 498k, False: 23.1k]
  |  |  |  |  |  Branch (45:29): [True: 471k, False: 50.0k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 190]
  |  |  |  |  |  Branch (45:41): [True: 498k, False: 22.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|  5.30M|            } else {
  644|  5.30M|                range->seek_start =
  645|  5.30M|                    MP_PTS_MAX(range->seek_start, queue->seek_start);
  ------------------
  |  |   65|  5.30M|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  10.6M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 473, False: 5.30M]
  |  |  |  |  |  Branch (44:23): [True: 5.29M, False: 1.21k]
  |  |  |  |  |  Branch (44:29): [True: 5.29M, False: 4.09k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 473]
  |  |  |  |  |  Branch (44:41): [True: 5.29M, False: 3.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|  5.30M|            }
  647|       |
  648|  5.82M|            if (queue->is_eof) {
  ------------------
  |  Branch (648:17): [True: 653k, False: 5.16M]
  ------------------
  649|   653k|                max_end_pts = MP_PTS_MAX(max_end_pts, queue->seek_end);
  ------------------
  |  |   65|   653k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  1.30M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 653k]
  |  |  |  |  |  Branch (44:23): [True: 651k, False: 1.42k]
  |  |  |  |  |  Branch (44:29): [True: 649k, False: 3.80k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 649k, False: 3.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|  5.16M|            } else {
  651|  5.16M|                range->seek_end = MP_PTS_MIN(range->seek_end, queue->seek_end);
  ------------------
  |  |   64|  5.16M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  10.3M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 4.17k, False: 5.16M]
  |  |  |  |  |  Branch (45:23): [True: 5.14M, False: 22.3k]
  |  |  |  |  |  Branch (45:29): [True: 5.12M, False: 49.1k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 4.17k]
  |  |  |  |  |  Branch (45:41): [True: 5.14M, False: 18.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|  5.16M|            }
  653|       |
  654|  5.82M|            range->is_eof &= queue->is_eof;
  655|  5.82M|            range->is_bof &= queue->is_bof;
  656|       |
  657|  5.82M|            bool empty = queue->is_eof && !queue->head;
  ------------------
  |  Branch (657:26): [True: 653k, False: 5.16M]
  |  Branch (657:43): [True: 649k, False: 3.78k]
  ------------------
  658|  5.82M|            if (queue->seek_start >= queue->seek_end && !empty &&
  ------------------
  |  Branch (658:17): [True: 5.77M, False: 49.7k]
  |  Branch (658:57): [True: 5.12M, False: 649k]
  ------------------
  659|  5.12M|                !(queue->seek_start == queue->seek_end &&
  ------------------
  |  Branch (659:19): [True: 5.12M, False: 1.25k]
  ------------------
  660|  5.12M|                  queue->seek_start != MP_NOPTS_VALUE))
  ------------------
  |  |   39|  5.12M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (660:19): [True: 3.18k, False: 5.11M]
  ------------------
  661|  5.12M|                goto broken;
  662|  5.82M|        }
  663|  6.96M|    }
  664|       |
  665|   413k|    if (range->is_eof)
  ------------------
  |  Branch (665:9): [True: 386k, False: 26.8k]
  ------------------
  666|   386k|        range->seek_end = max_end_pts;
  667|   413k|    if (range->is_bof)
  ------------------
  |  Branch (667:9): [True: 243k, False: 170k]
  ------------------
  668|   243k|        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|  1.20M|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (694:21): [True: 793k, False: 413k]
  ------------------
  695|   793k|        struct demux_queue *queue = range->streams[n];
  696|   793k|        if (queue->ds->selected && !queue->ds->eager &&
  ------------------
  |  Branch (696:13): [True: 557k, False: 235k]
  |  Branch (696:36): [True: 0, False: 557k]
  ------------------
  697|      0|            queue->last_pruned != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|   793k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (697:13): [True: 0, False: 0]
  ------------------
  698|      0|            range->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (698:13): [True: 0, False: 0]
  ------------------
  699|      0|        {
  700|       |            // (last_pruned is _exclusive_ to the seekable range, so add a small
  701|       |            // value to exclude it from the valid range.)
  702|      0|            range->seek_start =
  703|      0|                MP_PTS_MAX(range->seek_start, queue->last_pruned + 0.1);
  ------------------
  |  |   65|      0|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  704|      0|        }
  705|   793k|    }
  706|       |
  707|   413k|    if (range->seek_start >= range->seek_end && !(range->is_bof && range->is_eof))
  ------------------
  |  Branch (707:9): [True: 387k, False: 26.0k]
  |  Branch (707:51): [True: 218k, False: 169k]
  |  Branch (707:68): [True: 216k, False: 2.17k]
  ------------------
  708|   171k|        goto broken;
  709|       |
  710|   242k|    prune_metadata(range);
  711|   242k|    return;
  712|       |
  713|  5.29M|broken:
  714|  5.29M|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.29M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  715|  5.29M|    prune_metadata(range);
  716|  5.29M|}
demux.c:prune_metadata:
  603|  5.53M|{
  604|  5.53M|    int first_needed = 0;
  605|       |
  606|  5.53M|    if (range->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  5.53M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (606:9): [True: 5.50M, False: 26.0k]
  ------------------
  607|  5.50M|        first_needed = range->num_metadata;
  608|  5.50M|    } else {
  609|  26.0k|        for (int n = 0; n < range->num_metadata ; n++) {
  ------------------
  |  Branch (609:25): [True: 0, False: 26.0k]
  ------------------
  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|  26.0k|    }
  615|       |
  616|       |    // Always preserve the last entry.
  617|  5.53M|    first_needed = MPMIN(first_needed, range->num_metadata - 1);
  ------------------
  |  |   45|  5.53M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 5.53M, 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|  5.53M|    for (int n = 0; n < first_needed; n++) {
  ------------------
  |  Branch (621:21): [True: 0, False: 5.53M]
  ------------------
  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|  5.53M|}
demux.c:attempt_range_joining:
 1788|   533k|{
 1789|   533k|    struct demux_cached_range *current = in->current_range;
 1790|   533k|    struct demux_cached_range *next = NULL;
 1791|   533k|    double next_dist = INFINITY;
 1792|       |
 1793|   533k|    mp_assert(current && in->num_ranges > 0);
  ------------------
  |  |   41|   533k|#define mp_assert assert
  ------------------
  |  Branch (1793:5): [True: 533k, False: 0]
  |  Branch (1793:5): [True: 533k, False: 0]
  ------------------
 1794|   533k|    mp_assert(current == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|   533k|#define mp_assert assert
  ------------------
  |  Branch (1794:5): [True: 533k, False: 0]
  ------------------
 1795|       |
 1796|   533k|    for (int n = 0; n < in->num_ranges - 1; n++) {
  ------------------
  |  Branch (1796:21): [True: 137, False: 533k]
  ------------------
 1797|    137|        struct demux_cached_range *range = in->ranges[n];
 1798|       |
 1799|    137|        if (current->seek_start <= range->seek_start) {
  ------------------
  |  Branch (1799:13): [True: 55, False: 82]
  ------------------
 1800|       |            // This uses ">" to get some non-0 overlap.
 1801|     55|            double dist = current->seek_end - range->seek_start;
 1802|     55|            if (dist > 0 && dist < next_dist) {
  ------------------
  |  Branch (1802:17): [True: 0, False: 55]
  |  Branch (1802:29): [True: 0, False: 0]
  ------------------
 1803|      0|                next = range;
 1804|      0|                next_dist = dist;
 1805|      0|            }
 1806|     55|        }
 1807|    137|    }
 1808|       |
 1809|   533k|    if (!next)
  ------------------
  |  Branch (1809:9): [True: 533k, False: 0]
  ------------------
 1810|   533k|        return;
 1811|       |
 1812|      0|    MP_VERBOSE(in, "going to join ranges %f-%f + %f-%f\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1813|      0|               current->seek_start, current->seek_end,
 1814|      0|               next->seek_start, next->seek_end);
 1815|       |
 1816|       |    // Try to find a join point, where packets obviously overlap. (It would be
 1817|       |    // better and faster to do this incrementally, but probably too complex.)
 1818|       |    // The current range can overlap arbitrarily with the next one, not only by
 1819|       |    // the seek overlap, but for arbitrary packet readahead as well.
 1820|       |    // We also drop the overlapping packets (if joining fails, we discard the
 1821|       |    // entire next range anyway, so this does no harm).
 1822|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1822:21): [True: 0, False: 0]
  ------------------
 1823|      0|        struct demux_stream *ds = in->streams[n]->ds;
 1824|       |
 1825|      0|        struct demux_queue *q1 = current->streams[n];
 1826|      0|        struct demux_queue *q2 = next->streams[n];
 1827|       |
 1828|      0|        if (!ds->global_correct_pos && !ds->global_correct_dts) {
  ------------------
  |  Branch (1828:13): [True: 0, False: 0]
  |  Branch (1828:40): [True: 0, False: 0]
  ------------------
 1829|      0|            MP_WARN(in, "stream %d: ranges unjoinable\n", n);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1830|      0|            goto failed;
 1831|      0|        }
 1832|       |
 1833|      0|        struct demux_packet *end = q1->tail;
 1834|      0|        bool join_point_found = !end; // no packets yet -> joining will work
 1835|      0|        if (end) {
  ------------------
  |  Branch (1835:13): [True: 0, False: 0]
  ------------------
 1836|      0|            while (q2->head) {
  ------------------
  |  Branch (1836:20): [True: 0, False: 0]
  ------------------
 1837|      0|                struct demux_packet *dp = q2->head;
 1838|       |
 1839|       |                // Some weird corner-case. We'd have to search the equivalent
 1840|       |                // packet in q1 to update it correctly. Better just give up.
 1841|      0|                if (dp == q2->keyframe_latest) {
  ------------------
  |  Branch (1841:21): [True: 0, False: 0]
  ------------------
 1842|      0|                    MP_VERBOSE(in, "stream %d: not enough keyframes for join\n", n);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1843|      0|                    goto failed;
 1844|      0|                }
 1845|       |
 1846|      0|                if ((ds->global_correct_dts && dp->dts == end->dts) ||
  ------------------
  |  Branch (1846:22): [True: 0, False: 0]
  |  Branch (1846:48): [True: 0, False: 0]
  ------------------
 1847|      0|                    (ds->global_correct_pos && dp->pos == end->pos))
  ------------------
  |  Branch (1847:22): [True: 0, False: 0]
  |  Branch (1847:48): [True: 0, False: 0]
  ------------------
 1848|      0|                {
 1849|       |                    // Do some additional checks as a (imperfect) sanity check
 1850|       |                    // in case pos/dts are not "correct" across the ranges (we
 1851|       |                    // never actually check that).
 1852|      0|                    if (dp->dts != end->dts || dp->pos != end->pos ||
  ------------------
  |  Branch (1852:25): [True: 0, False: 0]
  |  Branch (1852:48): [True: 0, False: 0]
  ------------------
 1853|      0|                        dp->pts != end->pts)
  ------------------
  |  Branch (1853:25): [True: 0, False: 0]
  ------------------
 1854|      0|                    {
 1855|      0|                        MP_WARN(in,
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1856|      0|                            "stream %d: non-repeatable demuxer behavior\n", n);
 1857|      0|                        goto failed;
 1858|      0|                    }
 1859|       |
 1860|      0|                    remove_head_packet(q2);
 1861|      0|                    join_point_found = true;
 1862|      0|                    break;
 1863|      0|                }
 1864|       |
 1865|       |                // This happens if the next range misses the end packet. For
 1866|       |                // normal streams (ds->eager==true), this is a failure to find
 1867|       |                // an overlap. For subtitles, this can mean the current_range
 1868|       |                // has a subtitle somewhere before the end of its range, and
 1869|       |                // next has another subtitle somewhere after the start of its
 1870|       |                // range.
 1871|      0|                if ((ds->global_correct_dts && dp->dts > end->dts) ||
  ------------------
  |  Branch (1871:22): [True: 0, False: 0]
  |  Branch (1871:48): [True: 0, False: 0]
  ------------------
 1872|      0|                    (ds->global_correct_pos && dp->pos > end->pos))
  ------------------
  |  Branch (1872:22): [True: 0, False: 0]
  |  Branch (1872:48): [True: 0, False: 0]
  ------------------
 1873|      0|                    break;
 1874|       |
 1875|      0|                remove_head_packet(q2);
 1876|      0|            }
 1877|      0|        }
 1878|       |
 1879|       |        // For enabled non-sparse streams, always require an overlap packet.
 1880|      0|        if (ds->eager && !join_point_found) {
  ------------------
  |  Branch (1880:13): [True: 0, False: 0]
  |  Branch (1880:26): [True: 0, False: 0]
  ------------------
 1881|      0|            MP_WARN(in, "stream %d: no join point found\n", n);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1882|      0|            goto failed;
 1883|      0|        }
 1884|      0|    }
 1885|       |
 1886|       |    // Actually join the ranges. Now that we think it will work, mutate the
 1887|       |    // data associated with the current range.
 1888|       |
 1889|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1889:21): [True: 0, False: 0]
  ------------------
 1890|      0|        struct demux_queue *q1 = current->streams[n];
 1891|      0|        struct demux_queue *q2 = next->streams[n];
 1892|       |
 1893|      0|        struct demux_stream *ds = in->streams[n]->ds;
 1894|      0|        mp_assert(ds->queue == q1);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1894:9): [True: 0, False: 0]
  ------------------
 1895|       |
 1896|       |        // First new packet that is appended to the current range.
 1897|      0|        struct demux_packet *join_point = q2->head;
 1898|       |
 1899|      0|        if (q2->head) {
  ------------------
  |  Branch (1899:13): [True: 0, False: 0]
  ------------------
 1900|      0|            if (q1->head) {
  ------------------
  |  Branch (1900:17): [True: 0, False: 0]
  ------------------
 1901|      0|                q1->tail->next = q2->head;
 1902|      0|            } else {
 1903|      0|                q1->head = q2->head;
 1904|      0|            }
 1905|      0|            q1->tail = q2->tail;
 1906|      0|        }
 1907|       |
 1908|      0|        q1->seek_end = q2->seek_end;
 1909|      0|        q1->correct_dts &= q2->correct_dts;
 1910|      0|        q1->correct_pos &= q2->correct_pos;
 1911|      0|        q1->last_pos = q2->last_pos;
 1912|      0|        q1->last_dts = q2->last_dts;
 1913|      0|        q1->last_ts = q2->last_ts;
 1914|      0|        q1->keyframe_latest = q2->keyframe_latest;
 1915|      0|        q1->is_eof = q2->is_eof;
 1916|       |
 1917|      0|        q1->last_pos_fixup = -1;
 1918|       |
 1919|      0|        q2->head = q2->tail = NULL;
 1920|      0|        q2->keyframe_first = NULL;
 1921|      0|        q2->keyframe_latest = NULL;
 1922|       |
 1923|      0|        if (ds->selected && !ds->reader_head)
  ------------------
  |  Branch (1923:13): [True: 0, False: 0]
  |  Branch (1923:29): [True: 0, False: 0]
  ------------------
 1924|      0|            ds->reader_head = join_point;
 1925|      0|        ds->skip_to_keyframe = false;
 1926|       |
 1927|       |        // Make the cum_pos values in all q2 packets continuous.
 1928|      0|        for (struct demux_packet *dp = join_point; dp; dp = dp->next) {
  ------------------
  |  Branch (1928:52): [True: 0, False: 0]
  ------------------
 1929|      0|            uint64_t next_pos = dp->next ? dp->next->cum_pos : q2->tail_cum_pos;
  ------------------
  |  Branch (1929:33): [True: 0, False: 0]
  ------------------
 1930|      0|            uint64_t size = next_pos - dp->cum_pos;
 1931|      0|            dp->cum_pos = q1->tail_cum_pos;
 1932|      0|            q1->tail_cum_pos += size;
 1933|      0|        }
 1934|       |
 1935|       |        // And update the index with packets from q2.
 1936|      0|        for (size_t i = 0; i < q2->num_index; i++) {
  ------------------
  |  Branch (1936:28): [True: 0, False: 0]
  ------------------
 1937|      0|            struct index_entry *e = &QUEUE_INDEX_ENTRY(q2, i);
  ------------------
  |  |  340|      0|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|      0|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 1938|      0|            add_index_entry(q1, e->pkt, e->pts);
 1939|      0|        }
 1940|      0|        free_index(q2);
 1941|       |
 1942|       |        // For moving demuxer position.
 1943|      0|        ds->refreshing = ds->selected;
 1944|      0|    }
 1945|       |
 1946|      0|    for (int n = 0; n < next->num_metadata; n++) {
  ------------------
  |  Branch (1946:21): [True: 0, False: 0]
  ------------------
 1947|      0|        MP_TARRAY_APPEND(current, current->metadata, current->num_metadata,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1948|      0|                         next->metadata[n]);
 1949|      0|    }
 1950|      0|    next->num_metadata = 0;
 1951|       |
 1952|      0|    update_seek_ranges(current);
 1953|       |
 1954|       |    // Move demuxing position to after the current range.
 1955|      0|    in->seeking = true;
 1956|      0|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|      0|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 1957|      0|    in->seek_pts = next->seek_end - 1.0;
 1958|       |
 1959|      0|    MP_VERBOSE(in, "ranges joined!\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1960|       |
 1961|      0|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1961:21): [True: 0, False: 0]
  ------------------
 1962|      0|        back_demux_see_packets(in->streams[n]->ds);
 1963|       |
 1964|      0|failed:
 1965|      0|    clear_cached_range(in, next);
 1966|      0|    free_empty_cached_ranges(in);
 1967|      0|}
demux.c:remove_head_packet:
  720|   307k|{
  721|   307k|    struct demux_packet *dp = queue->head;
  722|       |
  723|   307k|    mp_assert(queue->ds->reader_head != dp);
  ------------------
  |  |   41|   307k|#define mp_assert assert
  ------------------
  |  Branch (723:5): [True: 307k, False: 0]
  ------------------
  724|   307k|    if (queue->keyframe_first == dp)
  ------------------
  |  Branch (724:9): [True: 150k, False: 157k]
  ------------------
  725|   150k|        queue->keyframe_first = NULL;
  726|   307k|    if (queue->keyframe_latest == dp)
  ------------------
  |  Branch (726:9): [True: 0, False: 307k]
  ------------------
  727|      0|        queue->keyframe_latest = NULL;
  728|   307k|    queue->is_bof = false;
  729|       |
  730|   307k|    uint64_t end_pos = dp->next ? dp->next->cum_pos : queue->tail_cum_pos;
  ------------------
  |  Branch (730:24): [True: 166k, False: 140k]
  ------------------
  731|   307k|    queue->ds->in->total_bytes -= end_pos - dp->cum_pos;
  732|       |
  733|   307k|    if (queue->num_index && queue->index[queue->index0].pkt == dp) {
  ------------------
  |  Branch (733:9): [True: 77, False: 307k]
  |  Branch (733:29): [True: 73, False: 4]
  ------------------
  734|     73|        queue->index0 = (queue->index0 + 1) & QUEUE_INDEX_SIZE_MASK(queue);
  ------------------
  |  |  335|     73|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  ------------------
  735|     73|        queue->num_index -= 1;
  736|     73|    }
  737|       |
  738|   307k|    queue->head = dp->next;
  739|   307k|    if (!queue->head)
  ------------------
  |  Branch (739:9): [True: 140k, False: 166k]
  ------------------
  740|   140k|        queue->tail = NULL;
  741|       |
  742|   307k|    demux_packet_pool_push(queue->ds->in->packet_pool, dp);
  743|   307k|}
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: 0]
  ------------------
 2467|       |
 2468|       |    // It's not clear what the ideal way to prune old packets is. For now, we
 2469|       |    // prune the oldest packet runs, as long as the total cache amount is too
 2470|       |    // big.
 2471|  1.85M|    while (1) {
  ------------------
  |  Branch (2471:12): [True: 1.85M, Folded]
  ------------------
 2472|  1.85M|        uint64_t fw_bytes = 0;
 2473|  5.13M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2473:25): [True: 3.27M, False: 1.85M]
  ------------------
 2474|  3.27M|            struct demux_stream *ds = in->streams[n]->ds;
 2475|  3.27M|            fw_bytes += get_forward_buffered_bytes(ds);
 2476|  3.27M|        }
 2477|  1.85M|        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|  1.85M|        if (max_avail && in->max_bytes > (fw_bytes + 1) && in->d_user->opts->donate_fw)
  ------------------
  |  Branch (2480:13): [True: 145k, False: 1.70M]
  |  Branch (2480:26): [True: 145k, False: 0]
  |  Branch (2480:60): [True: 145k, False: 0]
  ------------------
 2481|   145k|            max_avail += in->max_bytes - (fw_bytes + 1);
 2482|  1.85M|        if (in->total_bytes - fw_bytes <= max_avail)
  ------------------
  |  Branch (2482:13): [True: 1.54M, False: 308k]
  ------------------
 2483|  1.54M|            break;
 2484|       |
 2485|       |        // (Start from least recently used range.)
 2486|   308k|        struct demux_cached_range *range = in->ranges[0];
 2487|   308k|        double earliest_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   308k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2488|   308k|        struct demux_stream *earliest_stream = NULL;
 2489|       |
 2490|   469k|        for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (2490:25): [True: 468k, False: 787]
  ------------------
 2491|   468k|            struct demux_queue *queue = range->streams[n];
 2492|   468k|            struct demux_stream *ds = queue->ds;
 2493|       |
 2494|   468k|            if (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2494:17): [True: 462k, False: 6.07k]
  |  Branch (2494:32): [True: 307k, False: 155k]
  ------------------
 2495|   307k|                struct demux_packet *dp = queue->head;
 2496|   307k|                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|   307k|                bool prune_always =
 2501|   307k|                    !in->seekable_cache || ts == MP_NOPTS_VALUE || !dp->keyframe;
  ------------------
  |  |   39|   307k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2501:21): [True: 307k, False: 0]
  |  Branch (2501:44): [True: 0, False: 0]
  |  Branch (2501:68): [True: 0, False: 0]
  ------------------
 2502|   307k|                if (prune_always || !earliest_stream || ts < earliest_ts) {
  ------------------
  |  Branch (2502:21): [True: 307k, False: 0]
  |  Branch (2502:37): [True: 0, False: 0]
  |  Branch (2502:57): [True: 0, False: 0]
  ------------------
 2503|   307k|                    earliest_ts = ts;
 2504|   307k|                    earliest_stream = ds;
 2505|   307k|                    if (prune_always)
  ------------------
  |  Branch (2505:25): [True: 307k, False: 0]
  ------------------
 2506|   307k|                        break;
 2507|   307k|                }
 2508|   307k|            }
 2509|   468k|        }
 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|   308k|        if (!earliest_stream)
  ------------------
  |  Branch (2513:13): [True: 787, False: 307k]
  ------------------
 2514|    787|            break;
 2515|       |
 2516|   307k|        struct demux_stream *ds = earliest_stream;
 2517|   307k|        struct demux_queue *queue = range->streams[ds->index];
 2518|       |
 2519|   307k|        bool non_kf_prune = queue->head && !queue->head->keyframe;
  ------------------
  |  Branch (2519:29): [True: 307k, False: 0]
  |  Branch (2519:44): [True: 0, False: 307k]
  ------------------
 2520|   307k|        bool kf_was_pruned = false;
 2521|       |
 2522|   614k|        while (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2522:16): [True: 473k, False: 140k]
  |  Branch (2522:31): [True: 307k, False: 166k]
  ------------------
 2523|   307k|            if (queue->head->keyframe) {
  ------------------
  |  Branch (2523:17): [True: 307k, False: 0]
  ------------------
 2524|       |                // If the cache is seekable, only delete until up the next
 2525|       |                // keyframe. This is not always efficient, but ensures we
 2526|       |                // prune all streams fairly.
 2527|       |                // Also, if the first packet was _not_ a keyframe, we want it
 2528|       |                // to remove all preceding non-keyframe packets first, before
 2529|       |                // re-evaluating what to prune next.
 2530|   307k|                if ((kf_was_pruned || non_kf_prune) && in->seekable_cache)
  ------------------
  |  Branch (2530:22): [True: 278, False: 307k]
  |  Branch (2530:39): [True: 0, False: 307k]
  |  Branch (2530:56): [True: 0, False: 278]
  ------------------
 2531|      0|                    break;
 2532|   307k|                kf_was_pruned = true;
 2533|   307k|            }
 2534|       |
 2535|   307k|            remove_head_packet(queue);
 2536|   307k|        }
 2537|       |
 2538|       |        // Need to update the seekable time range.
 2539|   307k|        if (kf_was_pruned) {
  ------------------
  |  Branch (2539:13): [True: 307k, False: 0]
  ------------------
 2540|   307k|            mp_assert(!queue->keyframe_first); // it was just deleted, supposedly
  ------------------
  |  |   41|   307k|#define mp_assert assert
  ------------------
  |  Branch (2540:13): [True: 307k, False: 0]
  ------------------
 2541|       |
 2542|   307k|            queue->keyframe_first = queue->head;
 2543|       |            // (May happen if reader_head stopped pruning the range, and there's
 2544|       |            // no next range.)
 2545|   307k|            while (queue->keyframe_first && !queue->keyframe_first->keyframe)
  ------------------
  |  Branch (2545:20): [True: 166k, False: 140k]
  |  Branch (2545:45): [True: 0, False: 166k]
  ------------------
 2546|      0|                queue->keyframe_first = queue->keyframe_first->next;
 2547|       |
 2548|   307k|            if (queue->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   307k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2548:17): [True: 150k, False: 157k]
  ------------------
 2549|   150k|                queue->last_pruned = queue->seek_start;
 2550|       |
 2551|   307k|            double kf_min;
 2552|   307k|            compute_keyframe_times(queue->keyframe_first, &kf_min, NULL);
 2553|       |
 2554|   307k|            bool update_range = true;
 2555|       |
 2556|   307k|            queue->seek_start = kf_min;
 2557|       |
 2558|   307k|            if (queue->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   307k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2558:17): [True: 166k, False: 140k]
  ------------------
 2559|   166k|                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|   166k|                if (range->seek_start == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|   332k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2563:21): [True: 165k, False: 771]
  ------------------
 2564|    771|                    queue->seek_start <= range->seek_start)
  ------------------
  |  Branch (2564:21): [True: 58, False: 713]
  ------------------
 2565|   165k|                {
 2566|   165k|                    update_range = false;
 2567|   165k|                }
 2568|   166k|            }
 2569|       |
 2570|   307k|            if (update_range)
  ------------------
  |  Branch (2570:17): [True: 141k, False: 165k]
  ------------------
 2571|   141k|                update_seek_ranges(range);
 2572|   307k|        }
 2573|       |
 2574|   307k|        if (range != in->current_range && range->seek_start == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2574:13): [True: 1, False: 307k]
  |  Branch (2574:43): [True: 1, False: 0]
  ------------------
 2575|      1|            free_empty_cached_ranges(in);
 2576|   307k|    }
 2577|  1.54M|}
demux.c:back_demux_see_packets:
 1713|  14.0M|{
 1714|  14.0M|    struct demux_internal *in = ds->in;
 1715|       |
 1716|  14.0M|    if (!ds->selected || !in->back_demuxing || !ds->eager)
  ------------------
  |  Branch (1716:9): [True: 1.96M, False: 12.0M]
  |  Branch (1716:26): [True: 6.05M, False: 6.01M]
  |  Branch (1716:48): [True: 0, False: 6.01M]
  ------------------
 1717|  8.01M|        return;
 1718|       |
 1719|  6.01M|    mp_assert(!(ds->back_resuming && ds->back_restarting));
  ------------------
  |  |   41|  6.01M|#define mp_assert assert
  ------------------
  |  Branch (1719:5): [True: 7.06k, False: 6.00M]
  |  Branch (1719:5): [True: 0, False: 7.06k]
  ------------------
 1720|       |
 1721|  6.01M|    if (!ds->global_correct_dts && !ds->global_correct_pos) {
  ------------------
  |  Branch (1721:9): [True: 0, False: 6.01M]
  |  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|  6.01M|    while (ds->back_resuming && ds->reader_head) {
  ------------------
  |  Branch (1727:12): [True: 9.07k, False: 6.00M]
  |  Branch (1727:33): [True: 3.38k, False: 5.69k]
  ------------------
 1728|  3.38k|        struct demux_packet *head = ds->reader_head;
 1729|  3.38k|        if ((ds->global_correct_dts && head->dts == ds->back_resume_dts) ||
  ------------------
  |  Branch (1729:14): [True: 3.38k, False: 0]
  |  Branch (1729:40): [True: 1.37k, False: 2.01k]
  ------------------
 1730|  2.01k|            (ds->global_correct_pos && head->pos == ds->back_resume_pos))
  ------------------
  |  Branch (1730:14): [True: 0, False: 2.01k]
  |  Branch (1730:40): [True: 0, False: 0]
  ------------------
 1731|  1.37k|        {
 1732|  1.37k|            ds->back_resuming = false;
 1733|  1.37k|            ds->need_wakeup = true;
 1734|  1.37k|            wakeup_ds(ds); // probably
 1735|  1.37k|            break;
 1736|  1.37k|        }
 1737|  2.01k|        advance_reader_head(ds);
 1738|  2.01k|    }
 1739|       |
 1740|  6.01M|    if (ds->back_restarting)
  ------------------
  |  Branch (1740:9): [True: 3.82M, False: 2.19M]
  ------------------
 1741|  3.82M|        find_backward_restart_pos(ds);
 1742|  6.01M|}
demux.c:advance_reader_head:
 2778|   379k|{
 2779|   379k|    struct demux_packet *pkt = ds->reader_head;
 2780|   379k|    if (!pkt)
  ------------------
  |  Branch (2780:9): [True: 0, False: 379k]
  ------------------
 2781|      0|        return NULL;
 2782|       |
 2783|   379k|    ds->reader_head = pkt->next;
 2784|       |
 2785|   379k|    ds->last_ret_pos = pkt->pos;
 2786|   379k|    ds->last_ret_dts = pkt->dts;
 2787|       |
 2788|   379k|    return pkt;
 2789|   379k|}
demux.c:find_backward_restart_pos:
 1491|  3.82M|{
 1492|  3.82M|    struct demux_internal *in = ds->in;
 1493|       |
 1494|  3.82M|    ds->back_need_recheck = false;
 1495|  3.82M|    if (!ds->back_restarting)
  ------------------
  |  Branch (1495:9): [True: 0, False: 3.82M]
  ------------------
 1496|      0|        return;
 1497|       |
 1498|  3.82M|    struct demux_packet *first = ds->reader_head;
 1499|  3.82M|    struct demux_packet *last = ds->queue->tail;
 1500|       |
 1501|  3.82M|    if (first && !first->keyframe)
  ------------------
  |  Branch (1501:9): [True: 89.9k, False: 3.73M]
  |  Branch (1501:18): [True: 0, False: 89.9k]
  ------------------
 1502|  3.82M|        MP_WARN(in, "Queue not starting on keyframe.\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__)
  |  |  ------------------
  ------------------
 1503|       |
 1504|       |    // Packet at back_restart_pos. (Note: we don't actually need it, only the
 1505|       |    // packet immediately before it. But same effort.)
 1506|       |    // If this is NULL, look for EOF (resume from very last keyframe).
 1507|  3.82M|    struct demux_packet *back_restart = NULL;
 1508|       |
 1509|  3.82M|    if (ds->back_restart_next) {
  ------------------
  |  Branch (1509:9): [True: 55.4k, False: 3.77M]
  ------------------
 1510|       |        // Initial state. Switch to one of the other modi.
 1511|       |
 1512|  68.6k|        for (struct demux_packet *cur = first; cur; cur = cur->next) {
  ------------------
  |  Branch (1512:48): [True: 13.5k, False: 55.1k]
  ------------------
 1513|       |            // Restart for next keyframe after reader_head.
 1514|  13.5k|            if (cur != first && cur->keyframe) {
  ------------------
  |  Branch (1514:17): [True: 348, False: 13.2k]
  |  Branch (1514:33): [True: 348, False: 0]
  ------------------
 1515|    348|                ds->back_restart_dts = cur->dts;
 1516|    348|                ds->back_restart_pos = cur->pos;
 1517|    348|                ds->back_restart_eof = false;
 1518|    348|                ds->back_restart_next = false;
 1519|    348|                break;
 1520|    348|            }
 1521|  13.5k|        }
 1522|       |
 1523|  55.4k|        if (ds->back_restart_next && ds->eof) {
  ------------------
  |  Branch (1523:13): [True: 55.1k, False: 348]
  |  Branch (1523:38): [True: 24.1k, False: 30.9k]
  ------------------
 1524|       |            // Restart from end if nothing was found.
 1525|  24.1k|            ds->back_restart_eof = true;
 1526|  24.1k|            ds->back_restart_next = false;
 1527|  24.1k|        }
 1528|       |
 1529|  55.4k|        if (ds->back_restart_next)
  ------------------
  |  Branch (1529:13): [True: 30.9k, False: 24.5k]
  ------------------
 1530|  30.9k|            return;
 1531|  55.4k|    }
 1532|       |
 1533|  3.79M|    if (ds->back_restart_eof) {
  ------------------
  |  Branch (1533:9): [True: 3.63M, False: 158k]
  ------------------
 1534|       |        // We're trying to find EOF (without discarding packets). Only continue
 1535|       |        // if we really reach EOF.
 1536|  3.63M|        if (!ds->eof)
  ------------------
  |  Branch (1536:13): [True: 1.80M, False: 1.83M]
  ------------------
 1537|  1.80M|            return;
 1538|  3.63M|    } else if (!first && ds->eof) {
  ------------------
  |  Branch (1538:16): [True: 81.6k, False: 77.0k]
  |  Branch (1538:26): [True: 6.45k, False: 75.2k]
  ------------------
 1539|       |        // Reached EOF during normal backward demuxing. We probably returned the
 1540|       |        // last keyframe range to user. Need to resume at an earlier position.
 1541|       |        // Fall through, hit the no-keyframe case (and possibly the BOF check
 1542|       |        // if there are no packets at all), and then resume_earlier.
 1543|   152k|    } else if (!first) {
  ------------------
  |  Branch (1543:16): [True: 75.2k, False: 77.0k]
  ------------------
 1544|  75.2k|        return; // no packets yet
 1545|  77.0k|    } else {
 1546|  77.0k|        mp_assert(last);
  ------------------
  |  |   41|  77.0k|#define mp_assert assert
  ------------------
  |  Branch (1546:9): [True: 77.0k, False: 0]
  ------------------
 1547|       |
 1548|  77.0k|        if ((ds->global_correct_dts && last->dts < ds->back_restart_dts) ||
  ------------------
  |  Branch (1548:14): [True: 77.0k, False: 0]
  |  Branch (1548:40): [True: 0, False: 77.0k]
  ------------------
 1549|  77.0k|            (ds->global_correct_pos && last->pos < ds->back_restart_pos))
  ------------------
  |  Branch (1549:14): [True: 67.7k, False: 9.36k]
  |  Branch (1549:40): [True: 0, False: 67.7k]
  ------------------
 1550|      0|            return; // restart pos not reached yet
 1551|       |
 1552|       |        // The target we're searching for is apparently before the start of the
 1553|       |        // queue.
 1554|  77.0k|        if ((ds->global_correct_dts && first->dts > ds->back_restart_dts) ||
  ------------------
  |  Branch (1554:14): [True: 77.0k, False: 0]
  |  Branch (1554:40): [True: 8.68k, False: 68.3k]
  ------------------
 1555|  68.3k|            (ds->global_correct_pos && first->pos > ds->back_restart_pos))
  ------------------
  |  Branch (1555:14): [True: 67.7k, False: 674]
  |  Branch (1555:40): [True: 0, False: 67.7k]
  ------------------
 1556|  8.68k|            goto resume_earlier; // current position is too late; seek back
 1557|       |
 1558|       |
 1559|  69.0k|        for (struct demux_packet *cur = first; cur; cur = cur->next) {
  ------------------
  |  Branch (1559:48): [True: 69.0k, False: 0]
  ------------------
 1560|  69.0k|            if ((ds->global_correct_dts && cur->dts == ds->back_restart_dts) ||
  ------------------
  |  Branch (1560:18): [True: 69.0k, False: 0]
  |  Branch (1560:44): [True: 68.3k, False: 643]
  ------------------
 1561|    643|                (ds->global_correct_pos && cur->pos == ds->back_restart_pos))
  ------------------
  |  Branch (1561:18): [True: 0, False: 643]
  |  Branch (1561:44): [True: 0, False: 0]
  ------------------
 1562|  68.3k|            {
 1563|  68.3k|                back_restart = cur;
 1564|  68.3k|                break;
 1565|  68.3k|            }
 1566|  69.0k|        }
 1567|       |
 1568|  68.3k|        if (!back_restart) {
  ------------------
  |  Branch (1568:13): [True: 0, False: 68.3k]
  ------------------
 1569|       |            // The packet should have been in the searched range; maybe dts/pos
 1570|       |            // determinism assumptions were broken.
 1571|      0|            MP_ERR(in, "Demuxer not cooperating.\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__)
  |  |  ------------------
  ------------------
 1572|      0|            error_on_backward_demuxing(in);
 1573|      0|            return;
 1574|      0|        }
 1575|  68.3k|    }
 1576|       |
 1577|       |    // Find where to restart demuxing. It's usually the last keyframe packet
 1578|       |    // before restart_pos, but might be up to back_preroll + batch keyframe
 1579|       |    // packets earlier.
 1580|       |
 1581|       |    // (Normally, we'd just iterate backwards, but no back links.)
 1582|  1.90M|    int num_kf = 0;
 1583|  1.90M|    struct demux_packet *pre_1 = NULL; // idiotic "optimization" for total=1
 1584|  1.91M|    for (struct demux_packet *dp = first; dp != back_restart; dp = dp->next) {
  ------------------
  |  Branch (1584:43): [True: 6.90k, False: 1.90M]
  ------------------
 1585|  6.90k|        if (dp->keyframe) {
  ------------------
  |  Branch (1585:13): [True: 6.90k, False: 0]
  ------------------
 1586|  6.90k|            num_kf++;
 1587|  6.90k|            pre_1 = dp;
 1588|  6.90k|        }
 1589|  6.90k|    }
 1590|       |
 1591|       |    // Number of renderable keyframes to return to user.
 1592|       |    // (Excludes preroll, which is decoded by user, but then discarded.)
 1593|  1.90M|    int batch = MPMAX(in->d_user->opts->back_batch[ds->type], 1);
  ------------------
  |  |   44|  1.90M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.80M, False: 100k]
  |  |  ------------------
  ------------------
 1594|       |    // Number of keyframes to return to the user in total.
 1595|  1.90M|    int total = batch + ds->back_preroll;
 1596|       |
 1597|  1.90M|    mp_assert(total >= 1);
  ------------------
  |  |   41|  1.90M|#define mp_assert assert
  ------------------
  |  Branch (1597:5): [True: 1.90M, False: 0]
  ------------------
 1598|       |
 1599|  1.90M|    bool is_bof = ds->queue->is_bof &&
  ------------------
  |  Branch (1599:19): [True: 24.0k, False: 1.88M]
  ------------------
 1600|  24.0k|        (first == ds->queue->head || ds->back_seek_pos < ds->queue->seek_start);
  ------------------
  |  Branch (1600:10): [True: 24.0k, False: 1]
  |  Branch (1600:38): [True: 0, False: 1]
  ------------------
 1601|       |
 1602|  1.90M|    struct demux_packet *target = NULL; // resume pos
 1603|       |    // nr. of keyframes, incl. target, excl. restart_pos
 1604|  1.90M|    int got_total = num_kf < total && is_bof ? num_kf : total;
  ------------------
  |  Branch (1604:21): [True: 1.89M, False: 6.42k]
  |  Branch (1604:39): [True: 24.0k, False: 1.87M]
  ------------------
 1605|  1.90M|    int got_preroll = MPMAX(got_total - batch, 0);
  ------------------
  |  |   44|  1.90M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 1.90M]
  |  |  ------------------
  ------------------
 1606|       |
 1607|  1.90M|    if (got_total == 1) {
  ------------------
  |  Branch (1607:9): [True: 84.9k, False: 1.82M]
  ------------------
 1608|  84.9k|        target = pre_1;
 1609|  1.82M|    } else if (got_total <= num_kf) {
  ------------------
  |  Branch (1609:16): [True: 24.0k, False: 1.79M]
  ------------------
 1610|  24.0k|        int cur_kf = 0;
 1611|  24.0k|        for (struct demux_packet *dp = first; dp != back_restart; dp = dp->next) {
  ------------------
  |  Branch (1611:47): [True: 0, False: 24.0k]
  ------------------
 1612|      0|            if (dp->keyframe) {
  ------------------
  |  Branch (1612:17): [True: 0, False: 0]
  ------------------
 1613|      0|                if (num_kf - cur_kf == got_total) {
  ------------------
  |  Branch (1613:21): [True: 0, False: 0]
  ------------------
 1614|      0|                    target = dp;
 1615|      0|                    break;
 1616|      0|                }
 1617|      0|                cur_kf++;
 1618|      0|            }
 1619|      0|        }
 1620|  24.0k|    }
 1621|       |
 1622|  1.90M|    if (!target) {
  ------------------
  |  Branch (1622:9): [True: 1.89M, False: 6.43k]
  ------------------
 1623|  1.89M|        if (is_bof) {
  ------------------
  |  Branch (1623:13): [True: 24.0k, False: 1.87M]
  ------------------
 1624|  24.0k|            MP_VERBOSE(in, "BOF for stream %d\n", ds->index);
  ------------------
  |  |   92|  24.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1625|  24.0k|            ds->back_restarting = false;
 1626|  24.0k|            ds->back_range_started = false;
 1627|  24.0k|            ds->back_range_count = -1;
 1628|  24.0k|            ds->back_range_preroll = 0;
 1629|  24.0k|            ds->need_wakeup = true;
 1630|  24.0k|            wakeup_ds(ds);
 1631|  24.0k|            return;
 1632|  24.0k|        }
 1633|  1.87M|        goto resume_earlier;
 1634|  1.89M|    }
 1635|       |
 1636|       |    // Skip reader_head from previous keyframe to current one.
 1637|       |    // Or if preroll is involved, the first preroll packet.
 1638|  6.43k|    while (ds->reader_head != target) {
  ------------------
  |  Branch (1638:12): [True: 0, False: 6.43k]
  ------------------
 1639|      0|        if (!advance_reader_head(ds))
  ------------------
  |  Branch (1639:13): [True: 0, False: 0]
  ------------------
 1640|      0|            MP_ASSERT_UNREACHABLE(); // target must be in list
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (1640:13): [Folded, False: 0]
  ------------------
 1641|      0|    }
 1642|       |
 1643|  6.43k|    double seek_pts;
 1644|  6.43k|    compute_keyframe_times(target, &seek_pts, NULL);
 1645|  6.43k|    if (seek_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  6.43k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1645:9): [True: 6.43k, False: 0]
  ------------------
 1646|  6.43k|        ds->back_seek_pos = seek_pts;
 1647|       |
 1648|       |    // For next backward adjust action.
 1649|  6.43k|    struct demux_packet *restart_pkt = NULL;
 1650|  6.43k|    int kf_pos = 0;
 1651|  6.43k|    for (struct demux_packet *dp = target; dp; dp = dp->next) {
  ------------------
  |  Branch (1651:44): [True: 6.43k, False: 0]
  ------------------
 1652|  6.43k|        if (dp->keyframe) {
  ------------------
  |  Branch (1652:13): [True: 6.43k, False: 0]
  ------------------
 1653|  6.43k|            if (kf_pos == got_preroll) {
  ------------------
  |  Branch (1653:17): [True: 6.43k, False: 0]
  ------------------
 1654|  6.43k|                restart_pkt = dp;
 1655|  6.43k|                break;
 1656|  6.43k|            }
 1657|      0|            kf_pos++;
 1658|      0|        }
 1659|  6.43k|    }
 1660|  6.43k|    mp_assert(restart_pkt);
  ------------------
  |  |   41|  6.43k|#define mp_assert assert
  ------------------
  |  Branch (1660:5): [True: 6.43k, False: 0]
  ------------------
 1661|  6.43k|    ds->back_restart_dts = restart_pkt->dts;
 1662|  6.43k|    ds->back_restart_pos = restart_pkt->pos;
 1663|       |
 1664|  6.43k|    ds->back_restarting = false;
 1665|  6.43k|    ds->back_range_started = false;
 1666|  6.43k|    ds->back_range_count = got_total;
 1667|  6.43k|    ds->back_range_preroll = got_preroll;
 1668|  6.43k|    ds->need_wakeup = true;
 1669|  6.43k|    wakeup_ds(ds);
 1670|  6.43k|    return;
 1671|       |
 1672|  1.88M|resume_earlier:
 1673|       |    // We want to seek back to get earlier packets. But before we do this, we
 1674|       |    // must be sure that other streams have initialized their state. The only
 1675|       |    // time when this state is not initialized is right after the seek that
 1676|       |    // started backward demuxing (not any subsequent backstep seek). If this
 1677|       |    // initialization is omitted, the stream would try to start demuxing from
 1678|       |    // the "current" position. If another stream backstepped before that, the
 1679|       |    // other stream will miss the original seek target, and start playback from
 1680|       |    // a position that is too early.
 1681|  5.57M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1681:21): [True: 3.70M, False: 1.87M]
  ------------------
 1682|  3.70M|        struct demux_stream *ds2 = in->streams[n]->ds;
 1683|  3.70M|        if (ds2 == ds || !ds2->eager)
  ------------------
  |  Branch (1683:13): [True: 1.88M, False: 1.81M]
  |  Branch (1683:26): [True: 696k, False: 1.12M]
  ------------------
 1684|  2.58M|            continue;
 1685|       |
 1686|  1.12M|        if (ds2->back_restarting && ds2->back_restart_next) {
  ------------------
  |  Branch (1686:13): [True: 21.6k, False: 1.09M]
  |  Branch (1686:37): [True: 8.82k, False: 12.8k]
  ------------------
 1687|  8.82k|            MP_VERBOSE(in, "delaying stream %d for %d\n", ds->index, ds2->index);
  ------------------
  |  |   92|  8.82k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.82k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1688|  8.82k|            return;
 1689|  8.82k|        }
 1690|  1.12M|    }
 1691|       |
 1692|  1.87M|    if (ds->back_seek_pos != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.87M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1692:9): [True: 1.87M, False: 266]
  ------------------
 1693|  1.87M|        struct demux_packet *t =
 1694|  1.87M|            find_seek_target(ds->queue, ds->back_seek_pos - 0.001, 0);
 1695|  1.87M|        if (t && t != ds->reader_head) {
  ------------------
  |  Branch (1695:13): [True: 70.3k, False: 1.80M]
  |  Branch (1695:18): [True: 61, False: 70.2k]
  ------------------
 1696|     61|            double pts;
 1697|     61|            compute_keyframe_times(t, &pts, NULL);
 1698|     61|            ds->back_seek_pos = MP_PTS_MIN(ds->back_seek_pos, pts);
  ------------------
  |  |   64|     61|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|    122|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 5, False: 56]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 61]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 61]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 5]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1699|     61|            ds_clear_reader_state(ds, false);
 1700|     61|            ds->reader_head = t;
 1701|     61|            ds->back_need_recheck = true;
 1702|     61|            in->back_any_need_recheck = true;
 1703|     61|            mp_cond_signal(&in->wakeup);
 1704|  1.87M|        } else {
 1705|  1.87M|            ds->back_seek_pos -= in->d_user->opts->back_seek_size;
 1706|       |            in->need_back_seek = true;
 1707|  1.87M|        }
 1708|  1.87M|    }
 1709|  1.87M|}
demux.c:ds_clear_reader_state:
  842|  9.36M|{
  843|  9.36M|    ds_clear_reader_queue_state(ds);
  844|       |
  845|  9.36M|    ds->base_ts = ds->last_br_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.36M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  846|  9.36M|    ds->last_br_bytes = 0;
  847|  9.36M|    ds->bitrate = -1;
  848|  9.36M|    ds->skip_to_keyframe = false;
  849|  9.36M|    ds->attached_picture_added = false;
  850|  9.36M|    ds->lazy_eof = false;
  851|  9.36M|    ds->last_ret_pos = -1;
  852|  9.36M|    ds->last_ret_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.36M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  853|  9.36M|    ds->force_read_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.36M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  854|       |
  855|  9.36M|    if (clear_back_state) {
  ------------------
  |  Branch (855:9): [True: 5.68M, False: 3.67M]
  ------------------
  856|  5.68M|        ds->back_restart_pos = -1;
  857|  5.68M|        ds->back_restart_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  858|  5.68M|        ds->back_restart_eof = false;
  859|  5.68M|        ds->back_restart_next = ds->in->back_demuxing;
  860|  5.68M|        ds->back_restarting = ds->in->back_demuxing && ds->eager;
  ------------------
  |  Branch (860:31): [True: 26.8k, False: 5.66M]
  |  Branch (860:56): [True: 25.6k, False: 1.19k]
  ------------------
  861|  5.68M|        ds->back_seek_pos = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  862|  5.68M|        ds->back_resume_pos = -1;
  863|  5.68M|        ds->back_resume_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  5.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  864|  5.68M|        ds->back_resuming = false;
  865|       |        ds->back_range_started = false;
  866|  5.68M|        ds->back_range_count = 0;
  867|  5.68M|        ds->back_range_preroll = 0;
  868|  5.68M|    }
  869|  9.36M|}
demux.c:ds_clear_reader_queue_state:
  834|  9.38M|{
  835|  9.38M|    ds->reader_head = NULL;
  836|  9.38M|    ds->eof = false;
  837|       |    ds->need_wakeup = true;
  838|  9.38M|}
demux.c:demux_thread:
 2747|  14.7k|{
 2748|  14.7k|    struct demux_internal *in = pctx;
 2749|  14.7k|    mp_thread_set_name("demux");
 2750|  14.7k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  14.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2751|       |
 2752|  14.7k|    stats_register_thread_cputime(in->stats, "thread");
 2753|       |
 2754|  18.3M|    while (!in->thread_terminate) {
  ------------------
  |  Branch (2754:12): [True: 18.3M, False: 14.7k]
  ------------------
 2755|  18.3M|        if (thread_work(in))
  ------------------
  |  Branch (2755:13): [True: 11.8M, False: 6.49M]
  ------------------
 2756|  11.8M|            continue;
 2757|  6.49M|        mp_cond_signal(&in->wakeup);
 2758|  6.49M|        mp_cond_timedwait_until(&in->wakeup, &in->lock, in->next_cache_update);
 2759|  6.49M|    }
 2760|       |
 2761|  14.7k|    if (in->shutdown_async) {
  ------------------
  |  Branch (2761:9): [True: 14.2k, False: 545]
  ------------------
 2762|  14.2k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  14.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2763|  14.2k|        demux_shutdown(in);
 2764|  14.2k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  14.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2765|  14.2k|        in->shutdown_async = false;
 2766|  14.2k|        if (in->wakeup_cb)
  ------------------
  |  Branch (2766:13): [True: 14.2k, False: 0]
  ------------------
 2767|  14.2k|            in->wakeup_cb(in->wakeup_cb_ctx);
 2768|  14.2k|    }
 2769|       |
 2770|  14.7k|    stats_unregister_thread(in->stats, "thread");
 2771|       |
 2772|  14.7k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  14.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2773|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  14.7k|#define MP_THREAD_RETURN() return NULL
  ------------------
 2774|  14.7k|}
demux.c:dequeue_packet:
 2823|  9.43M|{
 2824|  9.43M|    struct demux_internal *in = ds->in;
 2825|       |
 2826|  9.43M|    if (!ds->selected)
  ------------------
  |  Branch (2826:9): [True: 0, False: 9.43M]
  ------------------
 2827|      0|        return -1;
 2828|  9.43M|    if (in->blocked)
  ------------------
  |  Branch (2828:9): [True: 0, False: 9.43M]
  ------------------
 2829|      0|        return 0;
 2830|       |
 2831|  9.43M|    if (ds->sh->attached_picture) {
  ------------------
  |  Branch (2831:9): [True: 0, False: 9.43M]
  ------------------
 2832|      0|        ds->eof = true;
 2833|      0|        if (ds->attached_picture_added)
  ------------------
  |  Branch (2833:13): [True: 0, False: 0]
  ------------------
 2834|      0|            return -1;
 2835|      0|        ds->attached_picture_added = true;
 2836|      0|        struct demux_packet *pkt = demux_copy_packet(in->packet_pool,
 2837|      0|                                                     ds->sh->attached_picture);
 2838|      0|        MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2839|      0|        pkt->stream = ds->sh->index;
 2840|      0|        *res = pkt;
 2841|      0|        return 1;
 2842|      0|    }
 2843|       |
 2844|  9.43M|    if (!in->reading && !in->eof) {
  ------------------
  |  Branch (2844:9): [True: 8.52M, False: 907k]
  |  Branch (2844:25): [True: 2.87M, False: 5.65M]
  ------------------
 2845|  2.87M|        in->reading = true; // enable demuxer thread prefetching
 2846|  2.87M|        mp_cond_signal(&in->wakeup);
 2847|  2.87M|    }
 2848|       |
 2849|  9.43M|    ds->force_read_until = min_pts;
 2850|       |
 2851|  9.43M|    if (ds->back_resuming || ds->back_restarting) {
  ------------------
  |  Branch (2851:9): [True: 1.44k, False: 9.43M]
  |  Branch (2851:30): [True: 543k, False: 8.89M]
  ------------------
 2852|   544k|        mp_assert(in->back_demuxing);
  ------------------
  |  |   41|   544k|#define mp_assert assert
  ------------------
  |  Branch (2852:9): [True: 544k, False: 0]
  ------------------
 2853|   544k|        return 0;
 2854|   544k|    }
 2855|       |
 2856|  9.43M|    bool eof = !ds->reader_head && ds->eof;
  ------------------
  |  Branch (2856:16): [True: 8.48M, False: 402k]
  |  Branch (2856:36): [True: 5.45M, False: 3.03M]
  ------------------
 2857|       |
 2858|  8.89M|    if (in->back_demuxing) {
  ------------------
  |  Branch (2858:9): [True: 55.5k, False: 8.83M]
  ------------------
 2859|       |        // Subtitles not supported => EOF.
 2860|  55.5k|        if (!ds->eager)
  ------------------
  |  Branch (2860:13): [True: 0, False: 55.5k]
  ------------------
 2861|      0|            return -1;
 2862|       |
 2863|       |        // Next keyframe (or EOF) was reached => step back.
 2864|  55.5k|        if (ds->back_range_started && !ds->back_range_count &&
  ------------------
  |  Branch (2864:13): [True: 6.32k, False: 49.2k]
  |  Branch (2864:39): [True: 6.32k, False: 0]
  ------------------
 2865|  6.32k|            ((ds->reader_head && ds->reader_head->keyframe) || eof))
  ------------------
  |  Branch (2865:15): [True: 64, False: 6.26k]
  |  Branch (2865:34): [True: 64, False: 0]
  |  Branch (2865:64): [True: 6.26k, False: 0]
  ------------------
 2866|  6.32k|        {
 2867|  6.32k|            ds->back_restarting = true;
 2868|  6.32k|            ds->back_restart_eof = false;
 2869|  6.32k|            ds->back_restart_next = false;
 2870|       |
 2871|  6.32k|            find_backward_restart_pos(ds);
 2872|       |
 2873|  6.32k|            if (ds->back_restarting)
  ------------------
  |  Branch (2873:17): [True: 6.32k, False: 1]
  ------------------
 2874|  6.32k|                return 0;
 2875|  6.32k|        }
 2876|       |
 2877|  49.2k|        eof = ds->back_range_count < 0;
 2878|  49.2k|    }
 2879|       |
 2880|  8.88M|    ds->need_wakeup = !ds->reader_head;
 2881|  8.88M|    if (!ds->reader_head || eof) {
  ------------------
  |  Branch (2881:9): [True: 8.48M, False: 402k]
  |  Branch (2881:29): [True: 25.2k, False: 377k]
  ------------------
 2882|  8.50M|        if (!ds->eager) {
  ------------------
  |  Branch (2882:13): [True: 0, False: 8.50M]
  ------------------
 2883|       |            // Non-eager streams temporarily return EOF. If they returned 0,
 2884|       |            // the reader would have to wait for new packets, which does not
 2885|       |            // make sense due to the sparseness and passiveness of non-eager
 2886|       |            // streams.
 2887|       |            // Unless the min_pts feature is used: then EOF is only signaled
 2888|       |            // if read-ahead went above min_pts.
 2889|      0|            if (!lazy_stream_needs_wait(ds))
  ------------------
  |  Branch (2889:17): [True: 0, False: 0]
  ------------------
 2890|      0|                ds->eof = eof = true;
 2891|      0|        }
 2892|       |        // Non-eager streams and streams starved by a queue overflow get EOF
 2893|       |        // while the demuxer can still read. Backward demuxing signals BOF
 2894|       |        // this way, which is final.
 2895|  8.50M|        if (eof)
  ------------------
  |  Branch (2895:13): [True: 5.47M, False: 3.03M]
  ------------------
 2896|  5.47M|            ds->lazy_eof = !in->eof && !in->back_demuxing;
  ------------------
  |  Branch (2896:28): [True: 25.5k, False: 5.45M]
  |  Branch (2896:40): [True: 0, False: 25.5k]
  ------------------
 2897|  8.50M|        return eof ? -1 : 0;
  ------------------
  |  Branch (2897:16): [True: 5.47M, False: 3.03M]
  ------------------
 2898|  8.50M|    }
 2899|       |
 2900|   377k|    struct demux_packet *pkt = advance_reader_head(ds);
 2901|   377k|    mp_assert(pkt);
  ------------------
  |  |   41|   377k|#define mp_assert assert
  ------------------
  |  Branch (2901:5): [True: 377k, False: 0]
  ------------------
 2902|   377k|    pkt = read_packet_from_cache(in, pkt);
 2903|   377k|    if (!pkt)
  ------------------
  |  Branch (2903:9): [True: 0, False: 377k]
  ------------------
 2904|      0|        return 0;
 2905|   377k|    ds->lazy_eof = false;
 2906|       |
 2907|   377k|    if (in->back_demuxing) {
  ------------------
  |  Branch (2907:9): [True: 6.32k, False: 371k]
  ------------------
 2908|  6.32k|        if (pkt->keyframe) {
  ------------------
  |  Branch (2908:13): [True: 6.32k, False: 0]
  ------------------
 2909|  6.32k|            mp_assert(ds->back_range_count > 0);
  ------------------
  |  |   41|  6.32k|#define mp_assert assert
  ------------------
  |  Branch (2909:13): [True: 6.32k, False: 0]
  ------------------
 2910|  6.32k|            ds->back_range_count -= 1;
 2911|  6.32k|            if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2911:17): [True: 6.32k, False: 0]
  ------------------
 2912|  6.32k|                ds->back_range_preroll -= 1;
 2913|  6.32k|        }
 2914|       |
 2915|  6.32k|        if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2915:13): [True: 0, False: 6.32k]
  ------------------
 2916|      0|            pkt->back_preroll = true;
 2917|       |
 2918|  6.32k|        if (!ds->back_range_started) {
  ------------------
  |  Branch (2918:13): [True: 6.32k, False: 0]
  ------------------
 2919|  6.32k|            pkt->back_restart = true;
 2920|  6.32k|            ds->back_range_started = true;
 2921|  6.32k|        }
 2922|  6.32k|    }
 2923|       |
 2924|   377k|    double ts = MP_PTS_OR_DEF(pkt->dts, pkt->pts);
  ------------------
  |  |   62|   377k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   377k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 377k]
  |  |  ------------------
  ------------------
 2925|   377k|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   377k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2925:9): [True: 377k, False: 0]
  ------------------
 2926|   377k|        ds->base_ts = ts;
 2927|       |
 2928|   377k|    if (pkt->keyframe && ts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   377k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2928:9): [True: 377k, False: 0]
  |  Branch (2928:26): [True: 377k, False: 0]
  ------------------
 2929|       |        // Update bitrate - only at keyframe points, because we use the
 2930|       |        // (possibly) reordered packet timestamps instead of realtime.
 2931|   377k|        double d = ts - ds->last_br_ts;
 2932|   377k|        if (ds->last_br_ts == MP_NOPTS_VALUE || d < 0) {
  ------------------
  |  |   39|   754k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2932:13): [True: 148k, False: 228k]
  |  Branch (2932:49): [True: 0, False: 228k]
  ------------------
 2933|   148k|            ds->bitrate = -1;
 2934|   148k|            ds->last_br_ts = ts;
 2935|   148k|            ds->last_br_bytes = 0;
 2936|   228k|        } else if (d >= 0.5) { // a window of least 500ms for UI purposes
  ------------------
  |  Branch (2936:20): [True: 3.25k, False: 225k]
  ------------------
 2937|  3.25k|            ds->bitrate = ds->last_br_bytes / d;
 2938|  3.25k|            ds->last_br_ts = ts;
 2939|  3.25k|            ds->last_br_bytes = 0;
 2940|  3.25k|        }
 2941|   377k|    }
 2942|   377k|    ds->last_br_bytes += pkt->len;
 2943|       |
 2944|       |    // This implies this function is actually called from "the" user thread.
 2945|   377k|    if (pkt->pos >= in->d_user->filepos)
  ------------------
  |  Branch (2945:9): [True: 377k, False: 0]
  ------------------
 2946|   377k|        in->d_user->filepos = pkt->pos;
 2947|   377k|    in->d_user->filesize = in->stream_size;
 2948|       |
 2949|   377k|    pkt->pts = MP_ADD_PTS(pkt->pts, in->ts_offset);
  ------------------
  |  |   67|   377k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   377k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 377k]
  |  |  ------------------
  ------------------
 2950|   377k|    pkt->dts = MP_ADD_PTS(pkt->dts, in->ts_offset);
  ------------------
  |  |   67|   377k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   377k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 377k]
  |  |  ------------------
  ------------------
 2951|       |
 2952|   377k|    if (pkt->segmented) {
  ------------------
  |  Branch (2952:9): [True: 0, False: 377k]
  ------------------
 2953|      0|        pkt->start = MP_ADD_PTS(pkt->start, in->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2954|      0|        pkt->end = MP_ADD_PTS(pkt->end, in->ts_offset);
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2955|      0|    }
 2956|       |
 2957|   377k|    prune_old_packets(in);
 2958|   377k|    *res = pkt;
 2959|   377k|    return 1;
 2960|   377k|}
demux.c:lazy_stream_needs_wait:
 2312|  1.29M|{
 2313|  1.29M|    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|  1.29M|    return !ds->eager && !in->back_demuxing &&
  ------------------
  |  Branch (2316:12): [True: 1.29M, False: 0]
  |  Branch (2316:26): [True: 591k, False: 700k]
  ------------------
 2317|   591k|           !in->eof && ds->force_read_until != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  1.88M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2317:12): [True: 591k, False: 0]
  |  Branch (2317:24): [True: 0, False: 591k]
  ------------------
 2318|      0|           (in->demux_ts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2318:13): [True: 0, False: 0]
  ------------------
 2319|      0|            in->demux_ts <= ds->force_read_until);
  ------------------
  |  Branch (2319:13): [True: 0, False: 0]
  ------------------
 2320|  1.29M|}
demux.c:read_packet_from_cache:
 2796|   377k|{
 2797|   377k|    if (!pkt)
  ------------------
  |  Branch (2797:9): [True: 0, False: 377k]
  ------------------
 2798|      0|        return NULL;
 2799|       |
 2800|   377k|    if (pkt->is_cached) {
  ------------------
  |  Branch (2800:9): [True: 0, False: 377k]
  ------------------
 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|   377k|    } else {
 2810|       |        // The returned packet is mutated etc. and will be owned by the user.
 2811|   377k|        pkt = demux_copy_packet(in->packet_pool, pkt);
 2812|   377k|    }
 2813|       |
 2814|   377k|    return pkt;
 2815|   377k|}
demux.c:thread_work:
 2708|  18.7M|{
 2709|  18.7M|    struct demux_opts *opts = in->d_user->opts;
 2710|  18.7M|    size_t old_max_bytes = opts->max_bytes;
 2711|  18.7M|    size_t old_max_bytes_bw = opts->max_bytes_bw;
 2712|  18.7M|    if (m_config_cache_update(in->d_user->opts_cache)) {
  ------------------
  |  Branch (2712:9): [True: 824, False: 18.7M]
  ------------------
 2713|    824|        update_opts(in->d_user);
 2714|    824|        if (opts->max_bytes + opts->max_bytes_bw < old_max_bytes + old_max_bytes_bw)
  ------------------
  |  Branch (2714:13): [True: 0, False: 824]
  ------------------
 2715|      0|            demux_packet_pool_clear(in->packet_pool);
 2716|    824|    }
 2717|  18.7M|    if (in->tracks_switched) {
  ------------------
  |  Branch (2717:9): [True: 44.1k, False: 18.7M]
  ------------------
 2718|  44.1k|        execute_trackswitch(in);
 2719|  44.1k|        return true;
 2720|  44.1k|    }
 2721|  18.7M|    if (in->nav_refresh) {
  ------------------
  |  Branch (2721:9): [True: 0, False: 18.7M]
  ------------------
 2722|      0|        execute_nav_refresh(in);
 2723|      0|        return true;
 2724|      0|    }
 2725|  18.7M|    if (in->need_back_seek) {
  ------------------
  |  Branch (2725:9): [True: 1.87M, False: 16.8M]
  ------------------
 2726|  1.87M|        perform_backward_seek(in);
 2727|  1.87M|        return true;
 2728|  1.87M|    }
 2729|  16.8M|    if (in->back_any_need_recheck) {
  ------------------
  |  Branch (2729:9): [True: 61, False: 16.8M]
  ------------------
 2730|     61|        check_backward_seek(in);
 2731|     61|        return true;
 2732|     61|    }
 2733|  16.8M|    if (in->seeking) {
  ------------------
  |  Branch (2733:9): [True: 4.49M, False: 12.3M]
  ------------------
 2734|  4.49M|        execute_seek(in);
 2735|  4.49M|        return true;
 2736|  4.49M|    }
 2737|  12.3M|    if (read_packet(in))
  ------------------
  |  Branch (2737:9): [True: 5.88M, False: 6.49M]
  ------------------
 2738|  5.88M|        return true; // read_packet unlocked, so recheck conditions
 2739|  6.49M|    if (mp_time_ns() >= in->next_cache_update) {
  ------------------
  |  Branch (2739:9): [True: 0, False: 6.49M]
  ------------------
 2740|      0|        update_cache(in);
 2741|      0|        return true;
 2742|      0|    }
 2743|  6.49M|    return false;
 2744|  6.49M|}
demux.c:update_opts:
 2638|  26.2k|{
 2639|  26.2k|    struct demux_opts *opts = demuxer->opts;
 2640|  26.2k|    struct demux_internal *in = demuxer->in;
 2641|       |
 2642|  26.2k|    in->min_secs = opts->min_secs;
 2643|  26.2k|    in->hyst_secs = opts->hyst_secs;
 2644|  26.2k|    in->hyst_bytes = opts->hyst_bytes;
 2645|  26.2k|    in->max_bytes = opts->max_bytes;
 2646|  26.2k|    in->max_bytes_bw = opts->max_bytes_bw;
 2647|       |
 2648|  26.2k|    int seekable = opts->seekable_cache;
 2649|  26.2k|    bool is_streaming = in->d_thread->is_streaming;
 2650|  26.2k|    bool use_cache = is_streaming;
 2651|  26.2k|    if (opts->enable_cache >= 0)
  ------------------
  |  Branch (2651:9): [True: 1.96k, False: 24.2k]
  ------------------
 2652|  1.96k|        use_cache = opts->enable_cache == 1;
 2653|       |
 2654|  26.2k|    if (use_cache) {
  ------------------
  |  Branch (2654:9): [True: 5.41k, False: 20.8k]
  ------------------
 2655|  5.41k|        in->min_secs = MPMAX(in->min_secs, opts->min_secs_cache);
  ------------------
  |  |   44|  5.41k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 5.41k]
  |  |  ------------------
  ------------------
 2656|  5.41k|        if (seekable < 0)
  ------------------
  |  Branch (2656:13): [True: 5.41k, False: 0]
  ------------------
 2657|  5.41k|            seekable = 1;
 2658|  5.41k|    }
 2659|  26.2k|    in->seekable_cache = seekable == 1;
 2660|  26.2k|    if (in->d_thread->no_cache_seeking)
  ------------------
  |  Branch (2660:9): [True: 0, False: 26.2k]
  ------------------
 2661|      0|        in->seekable_cache = false;
 2662|  26.2k|    in->using_network_cache_opts = is_streaming && use_cache;
  ------------------
  |  Branch (2662:36): [True: 4.31k, False: 21.8k]
  |  Branch (2662:52): [True: 4.12k, False: 191]
  ------------------
 2663|       |
 2664|  26.2k|    if (!in->seekable_cache)
  ------------------
  |  Branch (2664:9): [True: 20.8k, False: 5.41k]
  ------------------
 2665|  20.8k|        in->max_bytes_bw = 0;
 2666|       |
 2667|  26.2k|    if (!in->can_cache) {
  ------------------
  |  Branch (2667:9): [True: 4.43k, False: 21.7k]
  ------------------
 2668|  4.43k|        in->seekable_cache = false;
 2669|  4.43k|        in->min_secs = 0;
 2670|  4.43k|        in->max_bytes = 1;
 2671|  4.43k|        in->max_bytes_bw = 0;
 2672|  4.43k|        in->using_network_cache_opts = false;
 2673|  4.43k|    }
 2674|       |
 2675|  26.2k|    if (in->seekable_cache && opts->disk_cache && !in->cache) {
  ------------------
  |  Branch (2675:9): [True: 1.28k, False: 24.9k]
  |  Branch (2675:31): [True: 0, False: 1.28k]
  |  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|  26.2k|    char *old = in->record_filename ? in->record_filename : "";
  ------------------
  |  Branch (2683:17): [True: 0, False: 26.2k]
  ------------------
 2684|  26.2k|    char *new = opts->record_file ? opts->record_file : "";
  ------------------
  |  Branch (2684:17): [True: 0, False: 26.2k]
  ------------------
 2685|  26.2k|    if (strcmp(old, new) != 0) {
  ------------------
  |  Branch (2685:9): [True: 0, False: 26.2k]
  ------------------
 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|  26.2k|    prune_old_packets(in);
 2701|       |
 2702|       |    // In case the seekable cache was disabled.
 2703|  26.2k|    free_empty_cached_ranges(in);
 2704|  26.2k|}
demux.c:perform_backward_seek:
 1444|  1.87M|{
 1445|  1.87M|    double target = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.87M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1446|       |
 1447|  5.55M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1447:21): [True: 3.67M, False: 1.87M]
  ------------------
 1448|  3.67M|        struct demux_stream *ds = in->streams[n]->ds;
 1449|       |
 1450|  3.67M|        if (ds->reader_head && !ds->back_restarting && !ds->back_resuming &&
  ------------------
  |  Branch (1450:13): [True: 71.7k, False: 3.60M]
  |  Branch (1450:32): [True: 1.47k, False: 70.2k]
  |  Branch (1450:56): [True: 1.47k, False: 0]
  ------------------
 1451|  1.47k|            ds->eager)
  ------------------
  |  Branch (1451:13): [True: 1.47k, False: 0]
  ------------------
 1452|  1.47k|        {
 1453|  1.47k|            ds->back_resuming = true;
 1454|  1.47k|            ds->back_resume_pos = ds->reader_head->pos;
 1455|  1.47k|            ds->back_resume_dts = ds->reader_head->dts;
 1456|  1.47k|        }
 1457|       |
 1458|  3.67M|        target = MP_PTS_MIN(target, ds->back_seek_pos);
  ------------------
  |  |   64|  3.67M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  7.35M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 1.80M, False: 1.87M]
  |  |  |  |  |  Branch (45:23): [True: 1.87M, False: 1.80M]
  |  |  |  |  |  Branch (45:29): [True: 215, False: 3.67M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 1.80M]
  |  |  |  |  |  Branch (45:41): [True: 1.87M, False: 4.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1459|  3.67M|    }
 1460|       |
 1461|  1.87M|    target = MP_PTS_OR_DEF(target, in->d_thread->start_time);
  ------------------
  |  |   62|  1.87M|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|  1.87M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 1.87M]
  |  |  ------------------
  ------------------
 1462|       |
 1463|  1.87M|    MP_VERBOSE(in, "triggering backward seek to get more packets\n");
  ------------------
  |  |   92|  1.87M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.87M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1464|  1.87M|    queue_seek(in, target, SEEK_SATAN | SEEK_HR, false);
  ------------------
  |  |   98|  1.87M|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
                  queue_seek(in, target, SEEK_SATAN | SEEK_HR, false);
  ------------------
  |  |   99|  1.87M|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 1465|  1.87M|    in->reading = true;
 1466|       |
 1467|       |    // Don't starve other threads.
 1468|  1.87M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.87M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1469|  1.87M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.87M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1470|  1.87M|}
demux.c:check_backward_seek:
 1474|     61|{
 1475|     61|    in->back_any_need_recheck = false;
 1476|       |
 1477|    155|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (1477:21): [True: 94, False: 61]
  ------------------
 1478|     94|        struct demux_stream *ds = in->streams[n]->ds;
 1479|       |
 1480|     94|        if (ds->back_need_recheck)
  ------------------
  |  Branch (1480:13): [True: 60, False: 34]
  ------------------
 1481|     60|            find_backward_restart_pos(ds);
 1482|     94|    }
 1483|     61|}
demux.c:execute_seek:
 2604|  4.72M|{
 2605|  4.72M|    int flags = in->seek_flags;
 2606|  4.72M|    double pts = in->seek_pts;
 2607|  4.72M|    in->eof = false;
 2608|  4.72M|    in->seeking = false;
 2609|  4.72M|    in->seeking_in_progress = pts;
 2610|  4.72M|    in->demux_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.72M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2611|  4.72M|    in->low_level_seeks += 1;
 2612|  4.72M|    in->after_seek = true;
 2613|  4.72M|    in->after_seek_to_start =
 2614|  4.72M|        !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   95|  4.72M|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
                      !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   94|  4.72M|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (2614:9): [True: 4.71M, False: 10.9k]
  ------------------
 2615|  4.71M|        pts <= in->d_thread->start_time;
  ------------------
  |  Branch (2615:9): [True: 3.94M, False: 772k]
  ------------------
 2616|       |
 2617|  13.9M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2617:21): [True: 9.22M, False: 4.72M]
  ------------------
 2618|  9.22M|        in->streams[n]->ds->queue->last_pos_fixup = -1;
 2619|       |
 2620|  4.72M|    if (in->recorder)
  ------------------
  |  Branch (2620:9): [True: 0, False: 4.72M]
  ------------------
 2621|      0|        mp_recorder_mark_discontinuity(in->recorder);
 2622|       |
 2623|  4.72M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  4.72M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2624|       |
 2625|  4.72M|    MP_VERBOSE(in, "execute seek (to %f flags %d)\n", pts, flags);
  ------------------
  |  |   92|  4.72M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.72M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2626|       |
 2627|  4.72M|    if (in->d_thread->desc->seek)
  ------------------
  |  Branch (2627:9): [True: 4.72M, False: 0]
  ------------------
 2628|  4.72M|        in->d_thread->desc->seek(in->d_thread, pts, flags);
 2629|       |
 2630|  4.72M|    MP_VERBOSE(in, "seek done\n");
  ------------------
  |  |   92|  4.72M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.72M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2631|       |
 2632|  4.72M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  4.72M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2633|       |
 2634|  4.72M|    in->seeking_in_progress = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.72M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2635|  4.72M|}
demux.c:read_packet:
 2324|  12.3M|{
 2325|  12.3M|    bool was_reading = in->reading;
 2326|  12.3M|    in->reading = false;
 2327|       |
 2328|  12.3M|    if (!was_reading || in->blocked || demux_cancel_test(in->d_thread))
  ------------------
  |  Branch (2328:9): [True: 6.49M, False: 5.88M]
  |  Branch (2328:25): [True: 5, False: 5.88M]
  |  Branch (2328:40): [True: 0, False: 5.88M]
  ------------------
 2329|  6.49M|        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|  12.3M|    bool read_more = false, prefetch_more = false, refresh_more = false;
 2335|  5.88M|    uint64_t total_fw_bytes = 0;
 2336|  17.2M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2336:21): [True: 11.3M, False: 5.88M]
  ------------------
 2337|  11.3M|        total_fw_bytes += get_forward_buffered_bytes(in->streams[n]->ds);
 2338|  5.88M|    if (in->hyst_bytes > 0 && total_fw_bytes <= in->hyst_bytes)
  ------------------
  |  Branch (2338:9): [True: 18, False: 5.88M]
  |  Branch (2338:31): [True: 18, False: 0]
  ------------------
 2339|     18|        in->hyst_active = false;
 2340|  17.2M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2340:21): [True: 11.3M, False: 5.88M]
  ------------------
 2341|  11.3M|        struct demux_stream *ds = in->streams[n]->ds;
 2342|  11.3M|        if (ds->eager) {
  ------------------
  |  Branch (2342:13): [True: 10.0M, False: 1.29M]
  ------------------
 2343|  10.0M|            read_more |= !ds->reader_head;
 2344|  10.0M|            if (in->back_demuxing)
  ------------------
  |  Branch (2344:17): [True: 3.01M, False: 7.05M]
  ------------------
 2345|  3.01M|                read_more |= ds->back_restarting || ds->back_resuming;
  ------------------
  |  Branch (2345:30): [True: 1.91M, False: 1.09M]
  |  Branch (2345:53): [True: 5.62k, False: 1.09M]
  ------------------
 2346|  10.0M|        } else {
 2347|  1.29M|            if (lazy_stream_needs_wait(ds)) {
  ------------------
  |  Branch (2347:17): [True: 0, False: 1.29M]
  ------------------
 2348|      0|                read_more = true;
 2349|  1.29M|            } else {
 2350|  1.29M|                mark_stream_eof(ds); // let playback continue
 2351|  1.29M|            }
 2352|  1.29M|        }
 2353|  11.3M|        refresh_more |= ds->refreshing;
 2354|  11.3M|        if (ds->eager && ds->queue->last_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  21.4M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2354:13): [True: 10.0M, False: 1.29M]
  |  Branch (2354:26): [True: 2.01M, False: 8.05M]
  ------------------
 2355|  2.01M|            in->min_secs > 0 && ds->base_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  13.3M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2355:13): [True: 2.01M, False: 0]
  |  Branch (2355:33): [True: 2.01M, False: 1.06k]
  ------------------
 2356|  2.01M|            ds->queue->last_ts >= ds->base_ts &&
  ------------------
  |  Branch (2356:13): [True: 2.01M, False: 0]
  ------------------
 2357|  2.01M|            !in->back_demuxing)
  ------------------
  |  Branch (2357:13): [True: 2.00M, False: 9.90k]
  ------------------
 2358|  2.00M|        {
 2359|  2.00M|            if (ds->queue->last_ts - ds->base_ts <= in->hyst_secs)
  ------------------
  |  Branch (2359:17): [True: 166k, False: 1.83M]
  ------------------
 2360|   166k|                in->hyst_active = false;
 2361|  2.00M|            if (!in->hyst_active)
  ------------------
  |  Branch (2361:17): [True: 2.00M, False: 0]
  ------------------
 2362|  2.00M|                prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
 2363|  2.00M|        }
 2364|  11.3M|    }
 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|  5.88M|    if (in->nav_active)
  ------------------
  |  Branch (2369:9): [True: 0, False: 5.88M]
  ------------------
 2370|      0|        prefetch_more = false;
 2371|  5.88M|    prefetch_more |= in->nav_pump;
 2372|       |
 2373|  5.88M|    MP_TRACE(in, "bytes=%zd, read_more=%d prefetch_more=%d, refresh_more=%d\n",
  ------------------
  |  |   94|  5.88M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.88M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2374|  5.88M|             (size_t)total_fw_bytes, read_more, prefetch_more, refresh_more);
 2375|  5.88M|    if (total_fw_bytes >= in->max_bytes) {
  ------------------
  |  Branch (2375:9): [True: 0, False: 5.88M]
  ------------------
 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|  5.88M|    if (!read_more && !prefetch_more && !refresh_more) {
  ------------------
  |  Branch (2410:9): [True: 938k, False: 4.94M]
  |  Branch (2410:23): [True: 118, False: 938k]
  |  Branch (2410:41): [True: 118, False: 0]
  ------------------
 2411|    118|        in->hyst_active = in->hyst_secs > 0 || in->hyst_bytes > 0;
  ------------------
  |  Branch (2411:27): [True: 0, False: 118]
  |  Branch (2411:48): [True: 0, False: 118]
  ------------------
 2412|    118|        return false;
 2413|    118|    }
 2414|       |
 2415|  5.88M|    if (in->after_seek_to_start) {
  ------------------
  |  Branch (2415:9): [True: 3.95M, False: 1.92M]
  ------------------
 2416|  11.7M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2416:25): [True: 7.76M, False: 3.95M]
  ------------------
 2417|  7.76M|            struct demux_stream *ds = in->streams[n]->ds;
 2418|  7.76M|            in->current_range->streams[n]->is_bof =
 2419|  7.76M|                ds->selected && !ds->refreshing;
  ------------------
  |  Branch (2419:17): [True: 6.86M, False: 908k]
  |  Branch (2419:33): [True: 5.06M, False: 1.79M]
  ------------------
 2420|  7.76M|        }
 2421|  3.95M|    }
 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|  5.88M|    in->reading = true;
 2426|  5.88M|    in->nav_pump = false;
 2427|  5.88M|    in->after_seek = false;
 2428|  5.88M|    in->after_seek_to_start = false;
 2429|  5.88M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  5.88M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2430|       |
 2431|  5.88M|    struct demuxer *demux = in->d_thread;
 2432|  5.88M|    struct demux_packet *pkt = NULL;
 2433|       |
 2434|  5.88M|    bool eof = true;
 2435|  5.88M|    if (demux->desc->read_packet && !demux_read_interrupted(demux))
  ------------------
  |  Branch (2435:9): [True: 5.88M, False: 0]
  |  Branch (2435:37): [True: 5.88M, False: 1]
  ------------------
 2436|  5.88M|        eof = !demux->desc->read_packet(demux, &pkt);
 2437|       |
 2438|  5.88M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  5.88M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2439|  5.88M|    update_cache(in);
 2440|       |
 2441|  5.88M|    if (pkt) {
  ------------------
  |  Branch (2441:9): [True: 1.19M, False: 4.68M]
  ------------------
 2442|  1.19M|        mp_assert(pkt->stream >= 0 && pkt->stream < in->num_streams);
  ------------------
  |  |   41|  1.19M|#define mp_assert assert
  ------------------
  |  Branch (2442:9): [True: 1.19M, False: 0]
  |  Branch (2442:9): [True: 1.19M, False: 0]
  ------------------
 2443|  1.19M|        add_packet_locked(in->streams[pkt->stream], pkt);
 2444|  1.19M|    }
 2445|       |
 2446|  5.88M|    if (!in->seeking) {
  ------------------
  |  Branch (2446:9): [True: 5.88M, False: 444]
  ------------------
 2447|  5.88M|        if (eof) {
  ------------------
  |  Branch (2447:13): [True: 4.67M, False: 1.20M]
  ------------------
 2448|  13.8M|            for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2448:29): [True: 9.17M, False: 4.67M]
  ------------------
 2449|  9.17M|                mark_stream_eof(in->streams[n]->ds);
 2450|       |            // If we had EOF previously, then don't wakeup (avoids wakeup loop)
 2451|  4.67M|            if (!in->eof) {
  ------------------
  |  Branch (2451:17): [True: 4.67M, False: 0]
  ------------------
 2452|  4.67M|                if (in->wakeup_cb)
  ------------------
  |  Branch (2452:21): [True: 4.50M, False: 166k]
  ------------------
 2453|  4.50M|                    in->wakeup_cb(in->wakeup_cb_ctx);
 2454|  4.67M|                mp_cond_signal(&in->wakeup);
 2455|  4.67M|                MP_VERBOSE(in, "EOF reached.\n");
  ------------------
  |  |   92|  4.67M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.67M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2456|  4.67M|            }
 2457|  4.67M|        }
 2458|  5.88M|        in->eof = eof;
 2459|  5.88M|        in->reading = !eof;
 2460|  5.88M|    }
 2461|       |    return true;
 2462|  5.88M|}
demux.c:mark_stream_eof:
 2302|  10.4M|{
 2303|  10.4M|    if (!ds->eof) {
  ------------------
  |  Branch (2303:9): [True: 9.18M, False: 1.28M]
  ------------------
 2304|  9.18M|        ds->eof = true;
 2305|       |        adjust_seek_range_on_packet(ds, NULL);
 2306|  9.18M|        back_demux_see_packets(ds);
 2307|  9.18M|        wakeup_ds(ds);
 2308|  9.18M|    }
 2309|  10.4M|}
demux.c:lookup_timed_metadata:
 3374|  22.9M|{
 3375|  22.9M|    struct demux_cached_range *r = in->current_range;
 3376|       |
 3377|  22.9M|    if (!r || !r->num_metadata || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3377:9): [True: 0, False: 22.9M]
  |  Branch (3377:15): [True: 22.9M, False: 0]
  |  Branch (3377:35): [True: 0, False: 0]
  ------------------
 3378|  22.9M|        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|  22.9M|}
demux.c:update_final_metadata:
 3331|   384k|{
 3332|   384k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|   384k|#define mp_assert assert
  ------------------
  |  Branch (3332:5): [True: 384k, False: 0]
  ------------------
 3333|   384k|    struct demux_internal *in = demuxer->in;
 3334|       |
 3335|   384k|    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|   384k|    int astreams = 0;
 3341|   384k|    int astream_id = -1;
 3342|   384k|    int vstreams = 0;
 3343|  1.13M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3343:21): [True: 752k, False: 384k]
  ------------------
 3344|   752k|        struct sh_stream *sh = in->streams[n];
 3345|   752k|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3345:13): [True: 374k, False: 378k]
  |  Branch (3345:41): [True: 374k, False: 0]
  ------------------
 3346|   374k|            vstreams += 1;
 3347|   752k|        if (sh->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3347:13): [True: 373k, False: 378k]
  ------------------
 3348|   373k|            astreams += 1;
 3349|   373k|            astream_id = n;
 3350|   373k|        }
 3351|   752k|    }
 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|   384k|    if (vstreams == 0 && astreams == 1 &&
  ------------------
  |  Branch (3356:9): [True: 10.2k, False: 374k]
  |  Branch (3356:26): [True: 0, False: 10.2k]
  ------------------
 3357|      0|        in->streams[astream_id] == in->metadata_stream)
  ------------------
  |  Branch (3357:9): [True: 0, False: 0]
  ------------------
 3358|      0|    {
 3359|      0|        dyn_tags = in->metadata_stream->tags;
 3360|      0|        if (tm && tm->from_stream)
  ------------------
  |  Branch (3360:13): [True: 0, False: 0]
  |  Branch (3360:19): [True: 0, False: 0]
  ------------------
 3361|      0|            dyn_tags = tm->tags;
 3362|      0|    }
 3363|       |
 3364|       |    // Global metadata updates.
 3365|   384k|    if (tm && !tm->from_stream)
  ------------------
  |  Branch (3365:9): [True: 0, False: 384k]
  |  Branch (3365:15): [True: 0, False: 0]
  ------------------
 3366|      0|        dyn_tags = tm->tags;
 3367|       |
 3368|   384k|    if (dyn_tags)
  ------------------
  |  Branch (3368:9): [True: 0, False: 384k]
  ------------------
 3369|      0|        mp_tags_merge(demuxer->metadata, dyn_tags);
 3370|   384k|}
demux.c:demux_update_replaygain:
 3167|   398k|{
 3168|   398k|    struct demux_internal *in = demuxer->in;
 3169|  1.17M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3169:21): [True: 781k, False: 398k]
  ------------------
 3170|   781k|        struct sh_stream *sh = in->streams[n];
 3171|   781k|        if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
  ------------------
  |  Branch (3171:13): [True: 387k, False: 393k]
  |  Branch (3171:41): [True: 387k, False: 0]
  ------------------
 3172|   387k|            struct replaygain_data *rg = decode_rgain(demuxer->log, sh->tags);
 3173|   387k|            if (!rg)
  ------------------
  |  Branch (3173:17): [True: 387k, False: 0]
  ------------------
 3174|   387k|                rg = decode_rgain(demuxer->log, demuxer->metadata);
 3175|   387k|            if (rg)
  ------------------
  |  Branch (3175:17): [True: 0, False: 387k]
  ------------------
 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|   387k|        }
 3178|   781k|    }
 3179|   398k|}
demux.c:decode_rgain:
 3117|   775k|{
 3118|   775k|    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|   775k|    if (decode_gain(log, tags, "REPLAYGAIN_TRACK_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3124:9): [True: 0, False: 775k]
  ------------------
 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|   775k|    if (decode_gain(log, tags, "REPLAYGAIN_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3137:9): [True: 0, False: 775k]
  ------------------
 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|   775k|    if (decode_gain(log, tags, "R128_TRACK_GAIN", &rg.track_gain) >= 0) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 775k]
  ------------------
 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|   775k|    return NULL;
 3164|   775k|}
demux.c:decode_gain:
 3079|  2.32M|{
 3080|  2.32M|    char *tag_val = NULL;
 3081|  2.32M|    float dec_val;
 3082|       |
 3083|  2.32M|    tag_val = mp_tags_get_str(tags, tag);
 3084|  2.32M|    if (!tag_val)
  ------------------
  |  Branch (3084:9): [True: 2.32M, False: 0]
  ------------------
 3085|  2.32M|        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|  38.0k|{
 3679|  38.0k|    const int *check_levels = d_normal;
 3680|  38.0k|    const struct demuxer_desc *check_desc = NULL;
 3681|  38.0k|    struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
 3682|  38.0k|    struct demuxer *demuxer = NULL;
 3683|  38.0k|    char *force_format = params->force_format;
 3684|       |
 3685|  38.0k|    struct parent_stream_info sinfo = {
 3686|  38.0k|        .seekable = stream->seekable,
 3687|  38.0k|        .is_network = stream->is_network,
 3688|  38.0k|        .is_streaming = stream->streaming,
 3689|  38.0k|        .stream_origin = stream->stream_origin,
 3690|  38.0k|        .cancel = cancel,
 3691|  38.0k|        .filename = talloc_strdup(NULL, stream->url),
  ------------------
  |  |   50|  38.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3692|  38.0k|        .server_filename = stream->server_filename,
 3693|  38.0k|    };
 3694|       |
 3695|  38.0k|    if (!force_format)
  ------------------
  |  Branch (3695:9): [True: 33.6k, False: 4.41k]
  ------------------
 3696|  33.6k|        force_format = stream->demuxer;
 3697|       |
 3698|  38.0k|    if (force_format && force_format[0] && !stream->is_directory) {
  ------------------
  |  Branch (3698:9): [True: 20.3k, False: 17.7k]
  |  Branch (3698:25): [True: 20.3k, False: 0]
  |  Branch (3698:44): [True: 20.3k, False: 0]
  ------------------
 3699|  20.3k|        check_levels = d_request;
 3700|  20.3k|        if (force_format[0] == '+') {
  ------------------
  |  Branch (3700:13): [True: 0, False: 20.3k]
  ------------------
 3701|      0|            force_format += 1;
 3702|      0|            check_levels = d_force;
 3703|      0|        }
 3704|   166k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3704:25): [True: 166k, False: 0]
  ------------------
 3705|   166k|            if (strcmp(demuxer_list[n]->name, force_format) == 0) {
  ------------------
  |  Branch (3705:17): [True: 20.3k, False: 146k]
  ------------------
 3706|  20.3k|                check_desc = demuxer_list[n];
 3707|  20.3k|                break;
 3708|  20.3k|            }
 3709|   166k|        }
 3710|  20.3k|        if (!check_desc) {
  ------------------
  |  Branch (3710:13): [True: 0, False: 20.3k]
  ------------------
 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|  20.3k|    }
 3715|       |
 3716|       |    // Test demuxers from first to last, one pass for each check_levels[] entry
 3717|  63.4k|    for (int pass = 0; check_levels[pass] != -1; pass++) {
  ------------------
  |  Branch (3717:24): [True: 50.7k, False: 12.7k]
  ------------------
 3718|  50.7k|        enum demux_check level = check_levels[pass];
 3719|  50.7k|        mp_verbose(log, "Trying demuxers for level=%s.\n", d_level(level));
  ------------------
  |  |   79|  50.7k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3720|   536k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3720:25): [True: 510k, False: 25.3k]
  ------------------
 3721|   510k|            const struct demuxer_desc *desc = demuxer_list[n];
 3722|   510k|            if (!check_desc || desc == check_desc) {
  ------------------
  |  Branch (3722:17): [True: 343k, False: 167k]
  |  Branch (3722:32): [True: 20.3k, False: 147k]
  ------------------
 3723|   363k|                demuxer = open_given_type(global, log, desc, stream, &sinfo,
 3724|   363k|                                          params, level);
 3725|   363k|                if (demuxer) {
  ------------------
  |  Branch (3725:21): [True: 25.3k, False: 338k]
  ------------------
 3726|  25.3k|                    talloc_steal(demuxer, log);
  ------------------
  |  |   38|  25.3k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  25.3k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3727|  25.3k|                    log = NULL;
 3728|  25.3k|                    goto done;
 3729|  25.3k|                }
 3730|   363k|            }
 3731|   510k|        }
 3732|  50.7k|    }
 3733|       |
 3734|  38.0k|done:
 3735|  38.0k|    talloc_free(sinfo.filename);
  ------------------
  |  |   47|  38.0k|#define talloc_free                     ta_free
  ------------------
 3736|  38.0k|    talloc_free(log);
  ------------------
  |  |   47|  38.0k|#define talloc_free                     ta_free
  ------------------
 3737|  38.0k|    return demuxer;
 3738|  38.0k|}
demux.c:d_level:
 3054|   411k|{
 3055|   411k|    switch (level) {
  ------------------
  |  Branch (3055:13): [True: 411k, False: 0]
  ------------------
 3056|     11|    case DEMUX_CHECK_FORCE:  return "force";
  ------------------
  |  Branch (3056:5): [True: 11, False: 411k]
  ------------------
 3057|   161k|    case DEMUX_CHECK_UNSAFE: return "unsafe";
  ------------------
  |  Branch (3057:5): [True: 161k, False: 250k]
  ------------------
 3058|  40.7k|    case DEMUX_CHECK_REQUEST:return "request";
  ------------------
  |  Branch (3058:5): [True: 40.7k, False: 370k]
  ------------------
 3059|   209k|    case DEMUX_CHECK_NORMAL: return "normal";
  ------------------
  |  Branch (3059:5): [True: 209k, False: 201k]
  ------------------
 3060|   411k|    }
 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|   363k|{
 3542|   363k|    if (mp_cancel_test(sinfo->cancel))
  ------------------
  |  Branch (3542:9): [True: 3.32k, False: 360k]
  ------------------
 3543|  3.32k|        return NULL;
 3544|       |
 3545|   360k|    if (params->depth > 10) {
  ------------------
  |  Branch (3545:9): [True: 0, False: 360k]
  ------------------
 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|   360k|    mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
  ------------------
  |  |   80|   360k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
 3551|   360k|           desc->name, d_level(check));
 3552|       |
 3553|   360k|    if (stream && !stream_seek(stream, 0)) {
  ------------------
  |  Branch (3553:9): [True: 360k, False: 11]
  |  Branch (3553:19): [True: 0, False: 360k]
  ------------------
 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|   360k|    struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
  ------------------
  |  |   34|   360k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   360k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   360k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3559|   360k|    struct m_config_cache *opts_cache =
 3560|   360k|        m_config_cache_alloc(demuxer, global, &demux_conf);
 3561|   360k|    struct demux_opts *opts = opts_cache->opts;
 3562|   360k|    *demuxer = (struct demuxer) {
 3563|   360k|        .desc = desc,
 3564|   360k|        .stream = stream,
 3565|   360k|        .cancel = sinfo->cancel,
 3566|   360k|        .seekable = sinfo->seekable,
 3567|   360k|        .filepos = -1,
 3568|   360k|        .global = global,
 3569|   360k|        .log = mp_log_new(demuxer, log, desc->name),
 3570|   360k|        .packet_pool = demux_packet_pool_get(global),
 3571|   360k|        .glog = log,
 3572|   360k|        .filename = talloc_strdup(demuxer, sinfo->filename),
  ------------------
  |  |   50|   360k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3573|   360k|        .server_filename = talloc_strdup(demuxer, sinfo->server_filename),
  ------------------
  |  |   50|   360k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3574|   360k|        .is_network = sinfo->is_network,
 3575|   360k|        .is_streaming = sinfo->is_streaming,
 3576|   360k|        .stream_origin = sinfo->stream_origin,
 3577|   360k|        .access_references = opts->access_references,
 3578|   360k|        .opts = opts,
 3579|   360k|        .opts_cache = opts_cache,
 3580|   360k|        .events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS,
 3581|   360k|        .duration = -1,
 3582|   360k|        .depth = params->depth,
 3583|   360k|    };
 3584|       |
 3585|   360k|    struct demux_internal *in = demuxer->in = talloc_ptrtype(demuxer, in);
  ------------------
  |  |   34|   360k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   360k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   360k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3586|   360k|    *in = (struct demux_internal){
 3587|   360k|        .global = global,
 3588|   360k|        .log = demuxer->log,
 3589|   360k|        .packet_pool = demux_packet_pool_get(global),
 3590|   360k|        .stats = stats_ctx_create(in, global, "demuxer"),
 3591|   360k|        .can_cache = params->is_top_level,
 3592|   360k|        .can_record = params->stream_record,
 3593|   360k|        .d_thread = talloc(demuxer, struct demuxer),
  ------------------
  |  |   26|   360k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   360k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   360k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3594|   360k|        .d_user = demuxer,
 3595|   360k|        .after_seek = true, // (assumed identical to initial demuxer state)
 3596|   360k|        .after_seek_to_start = true,
 3597|   360k|        .highest_av_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   360k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3598|   360k|        .seeking_in_progress = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   360k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3599|   360k|        .demux_ts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   360k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3600|   360k|        .owns_stream = !params->external_stream,
 3601|   360k|    };
 3602|   360k|    mp_mutex_init(&in->lock);
 3603|   360k|    mp_cond_init(&in->wakeup);
 3604|       |
 3605|   360k|    *in->d_thread = *demuxer;
 3606|       |
 3607|   360k|    in->d_thread->metadata = talloc_zero(in->d_thread, struct mp_tags);
  ------------------
  |  |   27|   360k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   360k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   360k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3608|       |
 3609|   360k|    in->d_thread->params = params; // temporary during open()
 3610|   360k|    int ret = demuxer->desc->open(in->d_thread, check);
 3611|   360k|    if (ret >= 0) {
  ------------------
  |  Branch (3611:9): [True: 25.3k, False: 335k]
  ------------------
 3612|  25.3k|        in->d_thread->params = NULL;
 3613|  25.3k|        if (in->d_thread->filetype)
  ------------------
  |  Branch (3613:13): [True: 24.1k, False: 1.28k]
  ------------------
 3614|  24.1k|            mp_verbose(log, "Detected file format: %s (%s)\n",
  ------------------
  |  |   79|  24.1k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3615|  25.3k|                       in->d_thread->filetype, desc->desc);
 3616|  1.28k|        else
 3617|  1.28k|            mp_verbose(log, "Detected file format: %s\n", desc->desc);
  ------------------
  |  |   79|  1.28k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3618|  25.3k|        if (!in->d_thread->seekable)
  ------------------
  |  Branch (3618:13): [True: 1.11k, False: 24.2k]
  ------------------
 3619|  1.11k|            mp_verbose(log, "Stream is not seekable.\n");
  ------------------
  |  |   79|  1.11k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3620|  25.3k|        if (!in->d_thread->seekable && opts->force_seekable) {
  ------------------
  |  Branch (3620:13): [True: 1.11k, False: 24.2k]
  |  Branch (3620:40): [True: 0, False: 1.11k]
  ------------------
 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|  25.3k|        demux_init_cuesheet(in->d_thread);
 3626|  25.3k|        demux_init_ccs(demuxer, opts);
 3627|  25.3k|        demux_convert_tags_charset(in->d_thread);
 3628|  25.3k|        demux_copy(in->d_user, in->d_thread);
 3629|  25.3k|        in->duration = in->d_thread->duration;
 3630|  25.3k|        demuxer_sort_chapters(demuxer);
 3631|  25.3k|        in->events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS;
 3632|       |
 3633|  25.3k|        struct demuxer *sub = NULL;
 3634|  25.3k|        if (!params->disable_timeline) {
  ------------------
  |  Branch (3634:13): [True: 25.3k, False: 0]
  ------------------
 3635|  25.3k|            struct timeline *tl = timeline_load(global, log, demuxer);
 3636|  25.3k|            if (tl) {
  ------------------
  |  Branch (3636:17): [True: 11, False: 25.3k]
  ------------------
 3637|     11|                struct demuxer_params params2 = {0};
 3638|     11|                params2.timeline = tl;
 3639|     11|                params2.is_top_level = params->is_top_level;
 3640|     11|                params2.stream_record = params->stream_record;
 3641|     11|                params2.depth = params->depth + 1;
 3642|     11|                sub =
 3643|     11|                    open_given_type(global, log, &demuxer_desc_timeline,
 3644|     11|                                    NULL, sinfo, &params2, DEMUX_CHECK_FORCE);
 3645|     11|                if (sub) {
  ------------------
  |  Branch (3645:21): [True: 11, False: 0]
  ------------------
 3646|     11|                    in->can_cache = false;
 3647|     11|                    in->can_record = false;
 3648|     11|                } else {
 3649|      0|                    timeline_destroy(tl);
 3650|      0|                }
 3651|     11|            }
 3652|  25.3k|        }
 3653|       |
 3654|  25.3k|        switch_to_fresh_cache_range(in);
 3655|       |
 3656|  25.3k|        update_opts(demuxer);
 3657|       |
 3658|  25.3k|        demux_update(demuxer, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  25.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3659|       |
 3660|  25.3k|        demuxer = sub ? sub : demuxer;
  ------------------
  |  Branch (3660:19): [True: 11, False: 25.3k]
  ------------------
 3661|  25.3k|        return demuxer;
 3662|  25.3k|    }
 3663|       |
 3664|   335k|    demuxer->stream = NULL;
 3665|   335k|    demux_free(demuxer);
 3666|       |    return NULL;
 3667|   360k|}
demux.c:demux_init_cuesheet:
 3450|  25.3k|{
 3451|  25.3k|    if (demuxer->num_chapters)
  ------------------
  |  Branch (3451:9): [True: 11, False: 25.3k]
  ------------------
 3452|     11|        return;
 3453|       |
 3454|  25.3k|    struct sh_stream *sh = demuxer->in->metadata_stream;
 3455|  25.3k|    char *cue = mp_tags_get_str(demuxer->metadata, "cuesheet");
 3456|  25.3k|    if (!cue && sh)
  ------------------
  |  Branch (3456:9): [True: 25.3k, False: 0]
  |  Branch (3456:17): [True: 19.8k, False: 5.54k]
  ------------------
 3457|  19.8k|        cue = mp_tags_get_str(sh->tags, "cuesheet");
 3458|  25.3k|    if (!cue)
  ------------------
  |  Branch (3458:9): [True: 25.3k, False: 0]
  ------------------
 3459|  25.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|  25.3k|{
 3499|  25.3k|    struct demux_internal *in = demuxer->in;
 3500|  25.3k|    if (!opts->create_ccs)
  ------------------
  |  Branch (3500:9): [True: 25.3k, False: 0]
  ------------------
 3501|  25.3k|        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|  25.3k|{
 5042|  25.3k|    struct demux_internal *in = demuxer->in;
 5043|       |
 5044|  25.3k|    char *cp = demuxer->opts->meta_cp;
 5045|  25.3k|    if (!cp || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (5045:9): [True: 0, False: 25.3k]
  |  Branch (5045:16): [True: 0, False: 25.3k]
  ------------------
 5046|      0|        return;
 5047|       |
 5048|  25.3k|    char *data = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  25.3k|#define talloc_strdup                   ta_xstrdup
  ------------------
 5049|  25.3k|    visit_meta(demuxer, &data, visit_detect);
 5050|       |
 5051|  25.3k|    in->meta_charset = (char *)mp_charset_guess(in, in->log, bstr0(data), cp, 0);
 5052|  25.3k|    if (in->meta_charset && !mp_charset_is_utf8(in->meta_charset)) {
  ------------------
  |  Branch (5052:9): [True: 25.3k, False: 0]
  |  Branch (5052:29): [True: 4, False: 25.3k]
  ------------------
 5053|      4|        MP_INFO(demuxer, "Using tag charset: %s\n", in->meta_charset);
  ------------------
  |  |   91|      4|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 5054|      4|        visit_meta(demuxer, demuxer, visit_convert);
 5055|      4|    }
 5056|       |
 5057|  25.3k|    talloc_free(data);
  ------------------
  |  |   47|  25.3k|#define talloc_free                     ta_free
  ------------------
 5058|  25.3k|}
demux.c:visit_meta:
 4995|  25.3k|{
 4996|  25.3k|    struct demux_internal *in = demuxer->in;
 4997|       |
 4998|  59.8k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4998:21): [True: 34.4k, False: 25.3k]
  ------------------
 4999|  34.4k|        struct sh_stream *sh = in->streams[n];
 5000|       |
 5001|  34.4k|        visit(ctx, sh, &sh->title);
 5002|  34.4k|        visit_tags(ctx, visit, sh->tags);
 5003|  34.4k|    }
 5004|       |
 5005|  25.4k|    for (int n = 0; n < demuxer->num_chapters; n++)
  ------------------
  |  Branch (5005:21): [True: 15, False: 25.3k]
  ------------------
 5006|     15|        visit_tags(ctx, visit, demuxer->chapters[n].metadata);
 5007|       |
 5008|  25.3k|    visit_tags(ctx, visit, demuxer->metadata);
 5009|  25.3k|}
demux.c:visit_tags:
 4988|  59.8k|{
 4989|  59.8k|    for (int n = 0; n < (tags ? tags->num_keys : 0); n++)
  ------------------
  |  Branch (4989:21): [True: 15, False: 59.8k]
  |  Branch (4989:26): [True: 59.8k, False: 0]
  ------------------
 4990|     15|        visit(ctx, tags, &tags->values[n]);
 4991|  59.8k|}
demux.c:visit_detect:
 5013|  34.4k|{
 5014|  34.4k|    char **all = ctx;
 5015|       |
 5016|  34.4k|    if (*s)
  ------------------
  |  Branch (5016:9): [True: 11, False: 34.4k]
  ------------------
 5017|     11|        *all = talloc_asprintf_append_buffer(*all, "%s\n", *s);
  ------------------
  |  |   64|     11|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
 5018|  34.4k|}
demux.c:visit_convert:
 5021|      4|{
 5022|      4|    struct demuxer *demuxer = ctx;
 5023|      4|    struct demux_internal *in = demuxer->in;
 5024|       |
 5025|      4|    if (!*s)
  ------------------
  |  Branch (5025:9): [True: 0, False: 4]
  ------------------
 5026|      0|        return;
 5027|       |
 5028|      4|    bstr data = bstr0(*s);
 5029|      4|    bstr conv = mp_iconv_to_utf8(in->log, data, in->meta_charset,
 5030|      4|                                 MP_ICONV_VERBOSE);
 5031|      4|    if (conv.start && conv.start != data.start) {
  ------------------
  |  Branch (5031:9): [True: 4, False: 0]
  |  Branch (5031:23): [True: 4, False: 0]
  ------------------
 5032|      4|        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|      4|        *s = ns;
 5036|      4|        talloc_steal(ta, *s);
  ------------------
  |  |   38|      4|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      4|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5037|      4|    }
 5038|      4|}
demux.c:demux_copy:
 3183|  25.3k|{
 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|  25.3k|    dst->chapters = src->chapters;
 3188|  25.3k|    dst->num_chapters = src->num_chapters;
 3189|  25.3k|    dst->editions = src->editions;
 3190|  25.3k|    dst->num_editions = src->num_editions;
 3191|  25.3k|    dst->edition = src->edition;
 3192|  25.3k|    dst->edition_is_track_mapping = src->edition_is_track_mapping;
 3193|  25.3k|    dst->attachments = src->attachments;
 3194|  25.3k|    dst->num_attachments = src->num_attachments;
 3195|  25.3k|    dst->matroska_data = src->matroska_data;
 3196|  25.3k|    dst->playlist = src->playlist;
 3197|  25.3k|    dst->seekable = src->seekable;
 3198|  25.3k|    dst->partially_seekable = src->partially_seekable;
 3199|  25.3k|    dst->filetype = src->filetype;
 3200|  25.3k|    dst->ts_resets_possible = src->ts_resets_possible;
 3201|  25.3k|    dst->fully_read = src->fully_read;
 3202|  25.3k|    dst->start_time = src->start_time;
 3203|  25.3k|    dst->duration = src->duration;
 3204|  25.3k|    dst->is_network = src->is_network;
 3205|  25.3k|    dst->is_streaming = src->is_streaming;
 3206|  25.3k|    dst->stream_origin = src->stream_origin;
 3207|  25.3k|    dst->priv = src->priv;
 3208|  25.3k|    dst->metadata = mp_tags_dup(dst, src->metadata);
 3209|  25.3k|}
demux.c:demuxer_sort_chapters:
 4465|  25.3k|{
 4466|  25.3k|    if (demuxer->num_chapters) {
  ------------------
  |  Branch (4466:9): [True: 11, False: 25.3k]
  ------------------
 4467|     11|        qsort(demuxer->chapters, demuxer->num_chapters,
 4468|     11|            sizeof(struct demux_chapter), chapter_compare);
 4469|     11|    }
 4470|  25.3k|}
demux.c:switch_to_fresh_cache_range:
 4058|  4.74M|{
 4059|  4.74M|    if (!in->seekable_cache && in->current_range) {
  ------------------
  |  Branch (4059:9): [True: 4.36M, False: 379k]
  |  Branch (4059:32): [True: 4.34M, False: 25.3k]
  ------------------
 4060|  4.34M|        clear_cached_range(in, in->current_range);
 4061|  4.34M|        return;
 4062|  4.34M|    }
 4063|       |
 4064|   405k|    struct demux_cached_range *range = talloc_ptrtype(NULL, range);
  ------------------
  |  |   34|   405k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   405k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   405k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4065|   405k|    *range = (struct demux_cached_range){
 4066|   405k|        .seek_start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   405k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4067|   405k|        .seek_end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   405k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4068|   405k|    };
 4069|   405k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|   405k|    do {                                            \
  |  |  106|   405k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   405k|    do {                                            \
  |  |  |  |   97|   405k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   405k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   405k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   405k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 25.3k, False: 379k]
  |  |  |  |  ------------------
  |  |  |  |   99|   405k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  25.3k|    do {                                                        \
  |  |  |  |  |  |   89|  25.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  25.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  25.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  25.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  25.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  25.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  25.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 25.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   405k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 405k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   405k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   405k|        (idxvar)++;                                 \
  |  |  109|   405k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 405k]
  |  |  ------------------
  ------------------
 4070|   405k|    add_missing_streams(in, range);
 4071|       |
 4072|   405k|    switch_current_range(in, range);
 4073|   405k|}
demux.c:switch_current_range:
 3822|   405k|{
 3823|   405k|    struct demux_cached_range *old = in->current_range;
 3824|   405k|    mp_assert(old != range);
  ------------------
  |  |   41|   405k|#define mp_assert assert
  ------------------
  |  Branch (3824:5): [True: 405k, False: 0]
  ------------------
 3825|       |
 3826|   405k|    set_current_range(in, range);
 3827|       |
 3828|   405k|    if (old) {
  ------------------
  |  Branch (3828:9): [True: 379k, False: 25.3k]
  ------------------
 3829|       |        // Remove packets which can't be used when seeking back to the range.
 3830|  1.12M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3830:25): [True: 741k, False: 379k]
  ------------------
 3831|   741k|            struct demux_queue *queue = old->streams[n];
 3832|       |
 3833|       |            // Remove all packets which cannot be involved in seeking.
 3834|   741k|            while (queue->head && !queue->head->keyframe)
  ------------------
  |  Branch (3834:20): [True: 20.8k, False: 720k]
  |  Branch (3834:35): [True: 0, False: 20.8k]
  ------------------
 3835|      0|                remove_head_packet(queue);
 3836|   741k|        }
 3837|       |
 3838|       |        // Exclude weird corner cases that break resuming.
 3839|  1.12M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3839:25): [True: 741k, False: 379k]
  ------------------
 3840|   741k|            struct demux_stream *ds = in->streams[n]->ds;
 3841|       |            // This is needed to resume or join the range at all.
 3842|   741k|            if (ds->selected && !(ds->global_correct_dts ||
  ------------------
  |  Branch (3842:17): [True: 524k, False: 216k]
  |  Branch (3842:35): [True: 524k, 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|   741k|        }
 3850|   379k|    }
 3851|       |
 3852|       |    // Set up reading from new range (as well as writing to it).
 3853|  1.18M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3853:21): [True: 776k, False: 405k]
  ------------------
 3854|   776k|        struct demux_stream *ds = in->streams[n]->ds;
 3855|       |
 3856|   776k|        ds->queue = range->streams[n];
 3857|   776k|        ds->refreshing = false;
 3858|   776k|        ds->eof = false;
 3859|   776k|    }
 3860|       |
 3861|       |    // No point in keeping any junk (especially if old current_range is empty).
 3862|   405k|    free_empty_cached_ranges(in);
 3863|       |
 3864|       |    // The change detection doesn't work across ranges.
 3865|       |    in->force_metadata_update = true;
 3866|   405k|}
demux.c:set_current_range:
  589|   405k|{
  590|   405k|    in->current_range = range;
  591|       |
  592|       |    // Move to in->ranges[in->num_ranges-1] (for LRU sorting/invariant)
  593|   785k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (593:21): [True: 785k, False: 0]
  ------------------
  594|   785k|        if (in->ranges[n] == range) {
  ------------------
  |  Branch (594:13): [True: 405k, False: 379k]
  ------------------
  595|   405k|            MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|   405k|    do {                                            \
  |  |  144|   405k|        size_t at_ = (at);                          \
  |  |  145|   405k|        assert(at_ < (idxvar));                     \
  |  |  146|   405k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   405k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   405k|        (idxvar)--;                                 \
  |  |  149|   405k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 405k]
  |  |  ------------------
  ------------------
  |  Branch (595:13): [True: 405k, False: 0]
  ------------------
  596|   405k|            break;
  597|   405k|        }
  598|   785k|    }
  599|   405k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|   405k|    do {                                            \
  |  |  106|   405k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   405k|    do {                                            \
  |  |  |  |   97|   405k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   405k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   405k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   405k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 405k]
  |  |  |  |  ------------------
  |  |  |  |   99|   405k|            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|   405k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 405k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   405k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   405k|        (idxvar)++;                                 \
  |  |  109|   405k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 405k]
  |  |  ------------------
  ------------------
  600|   405k|}
demux.c:clear_reader_state:
  874|  5.09M|{
  875|  14.3M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (875:21): [True: 9.26M, False: 5.09M]
  ------------------
  876|  9.26M|        ds_clear_reader_state(in->streams[n]->ds, clear_back_state);
  877|  5.09M|    in->warned_queue_overflow = false;
  878|  5.09M|    in->d_user->filepos = -1; // implicitly synchronized
  879|  5.09M|    in->blocked = false;
  880|       |    in->need_back_seek = false;
  881|  5.09M|}
demux.c:clear_cached_range:
  784|  4.77M|{
  785|  14.0M|    for (int n = 0; n < range->num_streams; n++)
  ------------------
  |  Branch (785:21): [True: 9.28M, False: 4.77M]
  ------------------
  786|  9.28M|        clear_queue(range->streams[n]);
  787|       |
  788|  4.77M|    for (int n = 0; n < range->num_metadata; n++)
  ------------------
  |  Branch (788:21): [True: 0, False: 4.77M]
  ------------------
  789|      0|        talloc_free(range->metadata[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  790|  4.77M|    range->num_metadata = 0;
  791|       |
  792|  4.77M|    update_seek_ranges(range);
  793|  4.77M|}
demux.c:free_empty_cached_ranges:
  798|  1.25M|{
  799|  1.25M|    while (1) {
  ------------------
  |  Branch (799:12): [True: 1.25M, Folded]
  ------------------
  800|  1.25M|        struct demux_cached_range *worst = NULL;
  801|       |
  802|  1.25M|        int end = in->num_ranges - 1;
  803|       |
  804|       |        // (Not set during early init or late destruction.)
  805|  1.25M|        if (in->current_range) {
  ------------------
  |  Branch (805:13): [True: 529k, False: 729k]
  ------------------
  806|   529k|            mp_assert(in->current_range && in->num_ranges > 0);
  ------------------
  |  |   41|   529k|#define mp_assert assert
  ------------------
  |  Branch (806:13): [True: 529k, False: 0]
  |  Branch (806:13): [True: 529k, False: 0]
  ------------------
  807|   529k|            mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|   529k|#define mp_assert assert
  ------------------
  |  Branch (807:13): [True: 529k, False: 0]
  ------------------
  808|   529k|            end -= 1;
  809|   529k|        }
  810|       |
  811|  1.66M|        for (int n = end; n >= 0; n--) {
  ------------------
  |  Branch (811:27): [True: 405k, False: 1.25M]
  ------------------
  812|   405k|            struct demux_cached_range *range = in->ranges[n];
  813|   405k|            if (range->seek_start == MP_NOPTS_VALUE || !in->seekable_cache) {
  ------------------
  |  |   39|   810k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (813:17): [True: 405k, False: 81]
  |  Branch (813:56): [True: 0, False: 81]
  ------------------
  814|   405k|                clear_cached_range(in, range);
  815|   405k|                MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|   405k|    do {                                            \
  |  |  144|   405k|        size_t at_ = (at);                          \
  |  |  145|   405k|        assert(at_ < (idxvar));                     \
  |  |  146|   405k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   405k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   405k|        (idxvar)--;                                 \
  |  |  149|   405k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 405k]
  |  |  ------------------
  ------------------
  |  Branch (815:17): [True: 405k, False: 0]
  ------------------
  816|  1.18M|                for (int i = 0; i < range->num_streams; i++)
  ------------------
  |  Branch (816:33): [True: 775k, False: 405k]
  ------------------
  817|   775k|                    talloc_free(range->streams[i]);
  ------------------
  |  |   47|   775k|#define talloc_free                     ta_free
  ------------------
  818|   405k|                talloc_free(range);
  ------------------
  |  |   47|   405k|#define talloc_free                     ta_free
  ------------------
  819|   405k|            } else {
  820|     81|                if (!worst || (range->seek_end - range->seek_start <
  ------------------
  |  Branch (820:21): [True: 68, False: 13]
  |  Branch (820:31): [True: 1, False: 12]
  ------------------
  821|     13|                               worst->seek_end - worst->seek_start))
  822|     69|                    worst = range;
  823|     81|            }
  824|   405k|        }
  825|       |
  826|  1.25M|        if (in->num_ranges <= MAX_SEEK_RANGES || !worst)
  ------------------
  |  |   33|  2.51M|#define MAX_SEEK_RANGES 10
  ------------------
  |  Branch (826:13): [True: 1.25M, False: 0]
  |  Branch (826:50): [True: 0, False: 0]
  ------------------
  827|  1.25M|            break;
  828|       |
  829|      0|        clear_cached_range(in, worst);
  830|      0|    }
  831|  1.25M|}
demux.c:queue_seek:
 4095|  4.72M|{
 4096|  4.72M|    if (seek_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  4.72M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4096:9): [True: 0, False: 4.72M]
  ------------------
 4097|      0|        return false;
 4098|       |
 4099|  4.72M|    MP_VERBOSE(in, "queuing seek to %f%s\n", seek_pts,
  ------------------
  |  |   92|  4.72M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.45M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 4.78k, False: 4.72M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4100|  4.72M|               in->seeking ? " (cascade)" : "");
 4101|       |
 4102|  4.72M|    bool require_cache = flags & SEEK_CACHED;
  ------------------
  |  |   97|  4.72M|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4103|  4.72M|    flags &= ~(unsigned)SEEK_CACHED;
  ------------------
  |  |   97|  4.72M|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4104|       |
 4105|  4.72M|    bool set_backwards = flags & SEEK_SATAN;
  ------------------
  |  |   98|  4.72M|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4106|  4.72M|    flags &= ~(unsigned)SEEK_SATAN;
  ------------------
  |  |   98|  4.72M|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4107|       |
 4108|  4.72M|    bool block = flags & SEEK_BLOCK;
  ------------------
  |  |  100|  4.72M|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4109|  4.72M|    flags &= ~(unsigned)SEEK_BLOCK;
  ------------------
  |  |  100|  4.72M|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4110|       |
 4111|  4.72M|    struct demux_cached_range *cache_target =
 4112|  4.72M|        find_cache_seek_range(in, seek_pts, flags);
 4113|       |
 4114|  4.72M|    if (!cache_target) {
  ------------------
  |  Branch (4114:9): [True: 4.72M, False: 5.38k]
  ------------------
 4115|  4.72M|        if (require_cache) {
  ------------------
  |  Branch (4115:13): [True: 0, False: 4.72M]
  ------------------
 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|  4.72M|        if (!in->d_thread->seekable) {
  ------------------
  |  Branch (4119:13): [True: 0, False: 4.72M]
  ------------------
 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|  4.72M|    }
 4124|       |
 4125|  4.72M|    in->eof = false;
 4126|  4.72M|    in->reading = false;
 4127|  4.72M|    in->back_demuxing = set_backwards;
 4128|       |
 4129|  4.72M|    clear_reader_state(in, clear_back_state);
 4130|       |
 4131|  4.72M|    in->blocked = block;
 4132|       |
 4133|  4.72M|    if (cache_target) {
  ------------------
  |  Branch (4133:9): [True: 5.38k, False: 4.72M]
  ------------------
 4134|  5.38k|        execute_cache_seek(in, cache_target, seek_pts, flags);
 4135|  4.72M|    } else {
 4136|  4.72M|        switch_to_fresh_cache_range(in);
 4137|       |
 4138|  4.72M|        in->seeking = true;
 4139|  4.72M|        in->seek_flags = flags;
 4140|  4.72M|        in->seek_pts = seek_pts;
 4141|  4.72M|    }
 4142|       |
 4143|  13.9M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4143:21): [True: 9.21M, False: 4.72M]
  ------------------
 4144|  9.21M|        struct demux_stream *ds = in->streams[n]->ds;
 4145|       |
 4146|  9.21M|        if (in->back_demuxing) {
  ------------------
  |  Branch (4146:13): [True: 3.70M, False: 5.51M]
  ------------------
 4147|  3.70M|            if (ds->back_seek_pos == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  3.70M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4147:17): [True: 25.0k, False: 3.67M]
  ------------------
 4148|  25.0k|                ds->back_seek_pos = seek_pts;
 4149|       |            // Process possibly cached packets.
 4150|  3.70M|            back_demux_see_packets(in->streams[n]->ds);
 4151|  3.70M|        }
 4152|       |
 4153|  9.21M|        wakeup_ds(ds);
 4154|  9.21M|    }
 4155|       |
 4156|  4.72M|    if (!in->threading && in->seeking)
  ------------------
  |  Branch (4156:9): [True: 233k, False: 4.49M]
  |  Branch (4156:27): [True: 233k, False: 80]
  ------------------
 4157|   233k|        execute_seek(in);
 4158|       |
 4159|       |    return true;
 4160|  4.72M|}
demux.c:execute_cache_seek:
 4009|  5.38k|{
 4010|  5.38k|    adjust_cache_seek_target(in, range, &pts, &flags);
 4011|       |
 4012|  16.0k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4012:21): [True: 10.6k, False: 5.38k]
  ------------------
 4013|  10.6k|        struct demux_stream *ds = in->streams[n]->ds;
 4014|  10.6k|        struct demux_queue *queue = range->streams[n];
 4015|       |
 4016|  10.6k|        struct demux_packet *target = find_seek_target(queue, pts, flags);
 4017|  10.6k|        ds->reader_head = target;
 4018|  10.6k|        ds->skip_to_keyframe = !target;
 4019|  10.6k|        if (ds->reader_head)
  ------------------
  |  Branch (4019:13): [True: 9.09k, False: 1.59k]
  ------------------
 4020|  9.09k|            ds->base_ts = MP_PTS_OR_DEF(ds->reader_head->pts, ds->reader_head->dts);
  ------------------
  |  |   62|  9.09k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|  9.09k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 9.09k]
  |  |  ------------------
  ------------------
 4021|       |
 4022|  10.6k|        MP_VERBOSE(in, "seeking stream %d (%s) to ",
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 4023|  10.6k|                   n, stream_type_name(ds->type));
 4024|       |
 4025|  10.6k|        if (target) {
  ------------------
  |  Branch (4025:13): [True: 9.09k, False: 1.59k]
  ------------------
 4026|  9.09k|            MP_VERBOSE(in, "packet %f/%f\n", target->pts, target->dts);
  ------------------
  |  |   92|  9.09k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.09k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4027|  9.09k|        } else {
 4028|  1.59k|            MP_VERBOSE(in, "nothing\n");
  ------------------
  |  |   92|  1.59k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.59k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4029|  1.59k|        }
 4030|  10.6k|    }
 4031|       |
 4032|       |    // If we seek to another range, we want to seek the low level demuxer to
 4033|       |    // there as well, because reader and demuxer queue must be the same.
 4034|  5.38k|    if (in->current_range != range) {
  ------------------
  |  Branch (4034:9): [True: 6, False: 5.37k]
  ------------------
 4035|      6|        switch_current_range(in, range);
 4036|       |
 4037|      6|        in->seeking = true;
 4038|      6|        in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|      6|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 4039|      6|        in->seek_pts = range->seek_end - 1.0;
 4040|       |
 4041|       |        // When new packets are being appended, they could overlap with the old
 4042|       |        // range due to demuxer seek imprecisions, or because the queue contains
 4043|       |        // packets past the seek target but before the next seek target. Don't
 4044|       |        // append them twice, instead skip them until new packets are found.
 4045|     18|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4045:25): [True: 12, False: 6]
  ------------------
 4046|     12|            struct demux_stream *ds = in->streams[n]->ds;
 4047|       |
 4048|     12|            ds->refreshing = ds->selected;
 4049|     12|        }
 4050|       |
 4051|      6|        MP_VERBOSE(in, "resuming demuxer to end of cached range\n");
  ------------------
  |  |   92|      6|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      6|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4052|      6|    }
 4053|  5.38k|}
demux.c:select_track:
 4290|  66.9k|{
 4291|  66.9k|    struct demux_stream *ds = stream->ds;
 4292|  66.9k|    if (ds->selected == selected)
  ------------------
  |  Branch (4292:9): [True: 575, False: 66.3k]
  ------------------
 4293|    575|        return false;
 4294|  66.3k|    MP_VERBOSE(in, "%sselect track %d\n", selected ? "" : "de", stream->index);
  ------------------
  |  |   92|  66.3k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   132k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 47.1k, False: 19.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4295|  66.3k|    ds->selected = selected;
 4296|  66.3k|    update_stream_selection_state(in, ds);
 4297|  66.3k|    in->tracks_switched = true;
 4298|  66.3k|    if (ds->selected)
  ------------------
  |  Branch (4298:9): [True: 47.1k, False: 19.1k]
  ------------------
 4299|  47.1k|        refresh_track(in, stream, ref_pts);
 4300|       |    return true;
 4301|  66.9k|}
demux.c:select_dependent_tracks:
 4307|  66.9k|{
 4308|  66.9k|    bool changed = false;
 4309|  66.9k|    if (stream->group && !stream->dependent_track) {
  ------------------
  |  Branch (4309:9): [True: 0, False: 66.9k]
  |  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|  66.9k|    return changed;
 4318|  66.9k|}
demux.c:execute_trackswitch:
 2580|  52.6k|{
 2581|  52.6k|    in->tracks_switched = false;
 2582|       |
 2583|  52.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  52.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2584|       |
 2585|  52.6k|    if (in->d_thread->desc->switched_tracks)
  ------------------
  |  Branch (2585:9): [True: 52.6k, False: 0]
  ------------------
 2586|  52.6k|        in->d_thread->desc->switched_tracks(in->d_thread);
 2587|       |
 2588|  52.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  52.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2589|  52.6k|}
demux.c:update_stream_selection_state:
  948|   100k|{
  949|   100k|    ds->eof = false;
  950|   100k|    ds->refreshing = false;
  951|       |
  952|   100k|    update_stream_eager_state(in);
  953|       |
  954|   100k|    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|   167k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (960:21): [True: 66.3k, False: 100k]
  ------------------
  961|  66.3k|        struct demux_cached_range *range = in->ranges[n];
  962|       |
  963|  66.3k|        if (!ds->selected)
  ------------------
  |  Branch (963:13): [True: 19.1k, False: 47.1k]
  ------------------
  964|  19.1k|            clear_queue(range->streams[ds->index]);
  965|       |
  966|  66.3k|        update_seek_ranges(range);
  967|  66.3k|    }
  968|       |
  969|   100k|    free_empty_cached_ranges(in);
  970|       |
  971|   100k|    wakeup_ds(ds);
  972|   100k|}
demux.c:refresh_track:
 4256|  47.1k|{
 4257|  47.1k|    struct demux_stream *ds = stream->ds;
 4258|  47.1k|    ref_pts = MP_ADD_PTS(ref_pts, -in->ts_offset);
  ------------------
  |  |   67|  47.1k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  47.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 47.1k]
  |  |  ------------------
  ------------------
 4259|       |
 4260|  47.1k|    if (in->back_demuxing)
  ------------------
  |  Branch (4260:9): [True: 299, False: 46.8k]
  ------------------
 4261|    299|        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|  47.1k|    bool avoid_refresh = false;
 4265|  52.6k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4265:21): [True: 47.5k, False: 5.13k]
  ------------------
 4266|  47.5k|        struct demux_stream *ds_n = in->streams[n]->ds;
 4267|  47.5k|        if (ds_n->type == STREAM_VIDEO && ds_n->selected) {
  ------------------
  |  Branch (4267:13): [True: 42.3k, False: 5.13k]
  |  Branch (4267:43): [True: 42.0k, False: 368]
  ------------------
 4268|  42.0k|            avoid_refresh = true;
 4269|  42.0k|            break;
 4270|  42.0k|        }
 4271|  47.5k|    }
 4272|  47.1k|    avoid_refresh = avoid_refresh && !(in->after_seek && !in->after_seek_to_start);
  ------------------
  |  Branch (4272:21): [True: 42.0k, False: 5.13k]
  |  Branch (4272:40): [True: 34.3k, False: 7.64k]
  |  Branch (4272:58): [True: 156, False: 34.2k]
  ------------------
 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|  47.1k|    if (!in->after_seek || (ds->type != STREAM_VIDEO && !avoid_refresh)) {
  ------------------
  |  Branch (4280:9): [True: 7.72k, False: 39.4k]
  |  Branch (4280:29): [True: 18.8k, False: 20.6k]
  |  Branch (4280:57): [True: 5.07k, False: 13.7k]
  ------------------
 4281|  12.7k|        MP_VERBOSE(in, "refresh track %d (%s)\n", stream->index,
  ------------------
  |  |   92|  12.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4282|  12.7k|                   stream_type_name(ds->type));
 4283|  12.7k|        initiate_refresh_seek(in, ds, ref_pts);
 4284|  12.7k|    }
 4285|  47.1k|}
demux.c:initiate_refresh_seek:
 4184|  12.7k|{
 4185|  12.7k|    struct demuxer *demux = in->d_thread;
 4186|  12.7k|    bool seekable = demux->desc->seek && demux->seekable &&
  ------------------
  |  Branch (4186:21): [True: 12.7k, False: 0]
  |  Branch (4186:42): [True: 12.7k, False: 0]
  ------------------
 4187|  12.7k|                    !demux->partially_seekable;
  ------------------
  |  Branch (4187:21): [True: 12.7k, False: 0]
  ------------------
 4188|       |
 4189|  12.7k|    bool normal_seek = true;
 4190|  12.7k|    bool refresh_possible = true;
 4191|  33.6k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4191:21): [True: 20.8k, False: 12.7k]
  ------------------
 4192|  20.8k|        struct demux_stream *ds = in->streams[n]->ds;
 4193|       |
 4194|  20.8k|        if (!ds->selected)
  ------------------
  |  Branch (4194:13): [True: 443, False: 20.3k]
  ------------------
 4195|    443|            continue;
 4196|       |
 4197|  20.3k|        if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
  ------------------
  |  Branch (4197:13): [True: 7.66k, False: 12.7k]
  |  Branch (4197:41): [True: 7.95k, False: 4.76k]
  ------------------
 4198|  15.6k|            start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
  ------------------
  |  |   64|  15.6k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  31.2k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 8, False: 15.6k]
  |  |  |  |  |  Branch (45:23): [True: 0, False: 15.6k]
  |  |  |  |  |  Branch (45:29): [True: 8.47k, False: 7.13k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 8]
  |  |  |  |  |  Branch (45:41): [True: 0, False: 15.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|       |
 4200|       |        // If there were no other streams selected, we can use a normal seek.
 4201|  20.3k|        normal_seek &= stream == ds;
 4202|       |
 4203|  20.3k|        refresh_possible &= ds->queue->correct_dts || ds->queue->correct_pos;
  ------------------
  |  Branch (4203:29): [True: 20.3k, False: 0]
  |  Branch (4203:55): [True: 0, False: 0]
  ------------------
 4204|  20.3k|    }
 4205|       |
 4206|  12.7k|    if (start_ts == MP_NOPTS_VALUE || !seekable)
  ------------------
  |  |   39|  25.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4206:9): [True: 0, False: 12.7k]
  |  Branch (4206:39): [True: 0, False: 12.7k]
  ------------------
 4207|      0|        return;
 4208|       |
 4209|  12.7k|    if (!normal_seek) {
  ------------------
  |  Branch (4209:9): [True: 7.58k, False: 5.20k]
  ------------------
 4210|  7.58k|        if (!refresh_possible) {
  ------------------
  |  Branch (4210:13): [True: 0, False: 7.58k]
  ------------------
 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|  22.7k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4215:25): [True: 15.1k, False: 7.58k]
  ------------------
 4216|  15.1k|            struct demux_stream *ds = in->streams[n]->ds;
 4217|       |
 4218|  15.1k|            bool correct_pos = ds->queue->correct_pos;
 4219|  15.1k|            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|  15.1k|            ds_clear_reader_queue_state(ds);
 4227|  15.1k|            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|  15.1k|            if (ds->selected && (ds->last_ret_pos != -1 ||
  ------------------
  |  Branch (4231:17): [True: 15.1k, False: 0]
  |  Branch (4231:34): [True: 0, False: 15.1k]
  ------------------
 4232|  15.1k|                                 ds->last_ret_dts != MP_NOPTS_VALUE))
  ------------------
  |  |   39|  15.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4232:34): [True: 7.12k, False: 8.05k]
  ------------------
 4233|  7.12k|            {
 4234|  7.12k|                ds->refreshing = true;
 4235|  7.12k|                ds->queue->correct_dts = correct_dts;
 4236|  7.12k|                ds->queue->correct_pos = correct_pos;
 4237|  7.12k|                ds->queue->last_pos = ds->last_ret_pos;
 4238|  7.12k|                ds->queue->last_dts = ds->last_ret_dts;
 4239|  7.12k|            }
 4240|       |
 4241|  15.1k|            update_seek_ranges(in->current_range);
 4242|  15.1k|        }
 4243|       |
 4244|  7.58k|        start_ts -= 1.0; // small offset to get correct overlap
 4245|  7.58k|    }
 4246|       |
 4247|  12.7k|    MP_VERBOSE(in, "refresh seek to %f\n", start_ts);
  ------------------
  |  |   92|  12.7k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  12.7k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4248|  12.7k|    in->seeking = true;
 4249|  12.7k|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|  12.7k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 4250|  12.7k|    in->seek_pts = start_ts;
 4251|  12.7k|}
demux.c:wakeup_ds:
  887|  34.8M|{
  888|  34.8M|    if (ds->need_wakeup) {
  ------------------
  |  Branch (888:9): [True: 27.4M, False: 7.33M]
  ------------------
  889|  27.4M|        if (ds->wakeup_cb) {
  ------------------
  |  Branch (889:13): [True: 24.2M, False: 3.20M]
  ------------------
  890|  24.2M|            ds->wakeup_cb(ds->wakeup_cb_ctx);
  891|  24.2M|        } else if (ds->in->wakeup_cb) {
  ------------------
  |  Branch (891:20): [True: 2.49M, False: 711k]
  ------------------
  892|  2.49M|            ds->in->wakeup_cb(ds->in->wakeup_cb_ctx);
  893|  2.49M|        }
  894|       |        ds->need_wakeup = false;
  895|  27.4M|        mp_cond_signal(&ds->in->wakeup);
  896|  27.4M|    }
  897|  34.8M|}
demux.c:update_cache:
 4528|  5.90M|{
 4529|  5.90M|    struct demuxer *demuxer = in->d_thread;
 4530|  5.90M|    struct stream *stream = demuxer->stream;
 4531|       |
 4532|  5.90M|    int64_t now = mp_time_ns();
 4533|  5.90M|    int64_t diff = now - in->last_speed_query;
 4534|  5.90M|    bool do_update = diff >= MP_TIME_S_TO_NS(1) || !in->last_speed_query;
  ------------------
  |  |   71|  11.8M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (4534:22): [True: 25.5k, False: 5.88M]
  |  Branch (4534:52): [True: 50, False: 5.88M]
  ------------------
 4535|       |
 4536|       |    // Don't lock while querying the stream.
 4537|  5.90M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  5.90M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4538|       |
 4539|  5.90M|    int64_t stream_size = -1;
 4540|  5.90M|    struct mp_tags *stream_metadata = NULL;
 4541|  5.90M|    if (stream) {
  ------------------
  |  Branch (4541:9): [True: 5.49M, False: 408k]
  ------------------
 4542|  5.49M|        if (do_update)
  ------------------
  |  Branch (4542:13): [True: 16.3k, False: 5.48M]
  ------------------
 4543|  16.3k|            stream_size = stream_get_size(stream);
 4544|  5.49M|        stream_control(stream, STREAM_CTRL_GET_METADATA, &stream_metadata);
 4545|  5.49M|    }
 4546|       |
 4547|  5.90M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  5.90M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4548|       |
 4549|  5.90M|    update_bytes_read(in);
 4550|       |
 4551|  5.90M|    if (do_update)
  ------------------
  |  Branch (4551:9): [True: 25.5k, False: 5.88M]
  ------------------
 4552|  25.5k|        in->stream_size = stream_size;
 4553|  5.90M|    if (stream_metadata) {
  ------------------
  |  Branch (4553:9): [True: 0, False: 5.90M]
  ------------------
 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|  5.90M|    in->next_cache_update = INT64_MAX;
 4559|       |
 4560|  5.90M|    if (do_update) {
  ------------------
  |  Branch (4560:9): [True: 25.5k, False: 5.88M]
  ------------------
 4561|  25.5k|        uint64_t bytes = in->cache_unbuffered_read_bytes;
 4562|  25.5k|        in->cache_unbuffered_read_bytes = 0;
 4563|  25.5k|        in->last_speed_query = now;
 4564|  25.5k|        double speed = bytes / (diff / (double)MP_TIME_S_TO_NS(1));
  ------------------
  |  |   71|  25.5k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
 4565|  25.5k|        in->bytes_per_second = 0.5 * in->speed_query_prev_sample +
 4566|  25.5k|                               0.5 * speed;
 4567|  25.5k|        in->speed_query_prev_sample = speed;
 4568|  25.5k|    }
 4569|       |    // The idea is to update as long as there is "activity".
 4570|  5.90M|    if (in->bytes_per_second)
  ------------------
  |  Branch (4570:9): [True: 100, False: 5.90M]
  ------------------
 4571|    100|        in->next_cache_update = now + MP_TIME_S_TO_NS(1) + MP_TIME_US_TO_NS(1);
  ------------------
  |  |   71|    100|#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|    100|#define MP_TIME_US_TO_NS(us) ((us) * INT64_C(1000))
  ------------------
 4572|  5.90M|}
demux.c:dumper_close:
 4575|   360k|{
 4576|   360k|    if (in->dumper)
  ------------------
  |  Branch (4576:9): [True: 0, False: 360k]
  ------------------
 4577|      0|        mp_recorder_destroy(in->dumper);
 4578|   360k|    in->dumper = NULL;
 4579|   360k|    if (in->dumper_status == CONTROL_TRUE)
  ------------------
  |  |   96|   360k|#define CONTROL_TRUE 1
  ------------------
  |  Branch (4579:9): [True: 0, False: 360k]
  ------------------
 4580|      0|        in->dumper_status = CONTROL_FALSE; // make abort equal to success
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 4581|   360k|}
demux.c:recorder_create:
 2083|     44|{
 2084|     44|    struct sh_stream **streams = NULL;
 2085|     44|    int num_streams = 0;
 2086|    132|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2086:21): [True: 88, False: 44]
  ------------------
 2087|     88|        struct sh_stream *stream = in->streams[n];
 2088|     88|        if (stream->ds->selected)
  ------------------
  |  Branch (2088:13): [True: 65, False: 23]
  ------------------
 2089|     65|            MP_TARRAY_APPEND(NULL, streams, num_streams, stream);
  ------------------
  |  |  105|     65|    do {                                            \
  |  |  106|     65|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     65|    do {                                            \
  |  |  |  |   97|     65|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     65|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     65|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     65|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 36, False: 29]
  |  |  |  |  ------------------
  |  |  |  |   99|     65|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     36|    do {                                                        \
  |  |  |  |  |  |   89|     36|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     36|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     36|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     36|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     36|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     36|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     36|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 36]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     65|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     65|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     65|        (idxvar)++;                                 \
  |  |  109|     65|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 65]
  |  |  ------------------
  ------------------
 2090|     88|    }
 2091|       |
 2092|     44|    struct demuxer *demuxer = in->d_thread;
 2093|     44|    struct demux_attachment **attachments = talloc_array(NULL, struct demux_attachment*, demuxer->num_attachments);
  ------------------
  |  |   29|     44|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|     44|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     44|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2094|     44|    for (int n = 0; n < demuxer->num_attachments; n++) {
  ------------------
  |  Branch (2094:21): [True: 0, False: 44]
  ------------------
 2095|      0|        attachments[n] = &demuxer->attachments[n];
 2096|      0|    }
 2097|       |
 2098|     44|    struct mp_recorder *res = mp_recorder_create(in->d_thread->global, dst,
 2099|     44|                                                 streams, num_streams,
 2100|     44|                                                 attachments, demuxer->num_attachments);
 2101|     44|    talloc_free(streams);
  ------------------
  |  |   47|     44|#define talloc_free                     ta_free
  ------------------
 2102|     44|    talloc_free(attachments);
  ------------------
  |  |   47|     44|#define talloc_free                     ta_free
  ------------------
 2103|     44|    return res;
 2104|     44|}
demux.c:dump_cache:
 4594|     44|{
 4595|     44|    in->dumper_status = in->dumper ? CONTROL_TRUE : CONTROL_ERROR;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
                  in->dumper_status = in->dumper ? CONTROL_TRUE : CONTROL_ERROR;
  ------------------
  |  |   99|     88|#define CONTROL_ERROR -2
  ------------------
  |  Branch (4595:25): [True: 0, False: 44]
  ------------------
 4596|     44|    if (!in->dumper)
  ------------------
  |  Branch (4596:9): [True: 44, False: 0]
  ------------------
 4597|     44|        return;
 4598|       |
 4599|       |    // (only in pathological cases there might be more ranges than allowed)
 4600|      0|    struct demux_cached_range *ranges[MAX_SEEK_RANGES];
 4601|      0|    int num_ranges = 0;
 4602|      0|    for (int n = 0; n < MPMIN(MP_ARRAY_SIZE(ranges), in->num_ranges); n++)
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (4602:21): [True: 0, False: 0]
  ------------------
 4603|      0|        ranges[num_ranges++] = in->ranges[n];
 4604|      0|    qsort(ranges, num_ranges, sizeof(ranges[0]), range_time_compare);
 4605|       |
 4606|      0|    for (int n = 0; n < num_ranges; n++) {
  ------------------
  |  Branch (4606:21): [True: 0, False: 0]
  ------------------
 4607|      0|        struct demux_cached_range *r = ranges[n];
 4608|      0|        if (r->seek_start == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4608:13): [True: 0, False: 0]
  ------------------
 4609|      0|            continue;
 4610|      0|        if (r->seek_end <= start)
  ------------------
  |  Branch (4610:13): [True: 0, False: 0]
  ------------------
 4611|      0|            continue;
 4612|      0|        if (end != MP_NOPTS_VALUE && r->seek_start >= end)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4612:13): [True: 0, False: 0]
  |  Branch (4612:38): [True: 0, False: 0]
  ------------------
 4613|      0|            continue;
 4614|       |
 4615|      0|        mp_recorder_mark_discontinuity(in->dumper);
 4616|       |
 4617|      0|        double pts = start;
 4618|      0|        int flags = 0;
 4619|      0|        adjust_cache_seek_target(in, r, &pts, &flags);
 4620|       |
 4621|      0|        for (int i = 0; i < r->num_streams; i++) {
  ------------------
  |  Branch (4621:25): [True: 0, False: 0]
  ------------------
 4622|      0|            struct demux_queue *q = r->streams[i];
 4623|      0|            struct demux_stream *ds = q->ds;
 4624|       |
 4625|      0|            ds->dump_pos = find_seek_target(q, pts, flags);
 4626|      0|        }
 4627|       |
 4628|       |        // We need to reinterleave the separate streams somehow, which makes
 4629|       |        // everything more complex.
 4630|      0|        while (1) {
  ------------------
  |  Branch (4630:16): [True: 0, Folded]
  ------------------
 4631|      0|            struct demux_packet *next = NULL;
 4632|      0|            double next_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4633|       |
 4634|      0|            for (int i = 0; i < r->num_streams; i++) {
  ------------------
  |  Branch (4634:29): [True: 0, False: 0]
  ------------------
 4635|      0|                struct demux_stream *ds = r->streams[i]->ds;
 4636|      0|                struct demux_packet *dp = ds->dump_pos;
 4637|       |
 4638|      0|                if (!dp)
  ------------------
  |  Branch (4638:21): [True: 0, False: 0]
  ------------------
 4639|      0|                    continue;
 4640|      0|                mp_assert(dp->stream == ds->index);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (4640:17): [True: 0, False: 0]
  ------------------
 4641|       |
 4642|      0|                double pdts = MP_PTS_OR_DEF(dp->dts, dp->pts);
  ------------------
  |  |   62|      0|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4643|       |
 4644|       |                // Check for stream EOF. Note that we don't try to EOF
 4645|       |                // streams at the same point (e.g. video can take longer
 4646|       |                // to finish than audio, so the output file will have no
 4647|       |                // audio for the last part of the video). Too much effort.
 4648|      0|                if (pdts != MP_NOPTS_VALUE && end != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                              if (pdts != MP_NOPTS_VALUE && end != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4648:21): [True: 0, False: 0]
  |  Branch (4648:47): [True: 0, False: 0]
  ------------------
 4649|      0|                    pdts >= end && dp->keyframe)
  ------------------
  |  Branch (4649:21): [True: 0, False: 0]
  |  Branch (4649:36): [True: 0, False: 0]
  ------------------
 4650|      0|                {
 4651|      0|                    ds->dump_pos = NULL;
 4652|      0|                    continue;
 4653|      0|                }
 4654|       |
 4655|      0|                if (pdts == MP_NOPTS_VALUE || next_dts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                              if (pdts == MP_NOPTS_VALUE || next_dts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4655:21): [True: 0, False: 0]
  |  Branch (4655:47): [True: 0, False: 0]
  ------------------
 4656|      0|                    pdts < next_dts)
  ------------------
  |  Branch (4656:21): [True: 0, False: 0]
  ------------------
 4657|      0|                {
 4658|      0|                    next_dts = pdts;
 4659|      0|                    next = dp;
 4660|      0|                }
 4661|      0|            }
 4662|       |
 4663|      0|            if (!next)
  ------------------
  |  Branch (4663:17): [True: 0, False: 0]
  ------------------
 4664|      0|                break;
 4665|       |
 4666|      0|            struct demux_stream *ds = in->streams[next->stream]->ds;
 4667|      0|            ds->dump_pos = next->next;
 4668|       |
 4669|      0|            struct demux_packet *dp = read_packet_from_cache(in, next);
 4670|      0|            if (!dp) {
  ------------------
  |  Branch (4670:17): [True: 0, False: 0]
  ------------------
 4671|      0|                in->dumper_status = CONTROL_ERROR;
  ------------------
  |  |   99|      0|#define CONTROL_ERROR -2
  ------------------
 4672|      0|                break;
 4673|      0|            }
 4674|       |
 4675|      0|            write_dump_packet(in, dp);
 4676|       |
 4677|      0|            talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4678|      0|        }
 4679|       |
 4680|      0|        if (in->dumper_status != CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (4680:13): [True: 0, False: 0]
  ------------------
 4681|      0|            break;
 4682|      0|    }
 4683|       |
 4684|       |    // (strictly speaking unnecessary; for clarity)
 4685|      0|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (4685:21): [True: 0, False: 0]
  ------------------
 4686|      0|        in->streams[n]->ds->dump_pos = NULL;
 4687|       |
 4688|       |    // If dumping (in end==NOPTS mode) doesn't continue at the range that
 4689|       |    // was written last, we have a discontinuity.
 4690|      0|    if (num_ranges && ranges[num_ranges - 1] != in->current_range)
  ------------------
  |  Branch (4690:9): [True: 0, False: 0]
  |  Branch (4690:23): [True: 0, False: 0]
  ------------------
 4691|      0|        mp_recorder_mark_discontinuity(in->dumper);
 4692|       |
 4693|       |    // end=NOPTS means the demuxer output continues to be written to the
 4694|       |    // dump file.
 4695|      0|    if (end != MP_NOPTS_VALUE || in->dumper_status != CONTROL_OK)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (end != MP_NOPTS_VALUE || in->dumper_status != CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (4695:9): [True: 0, False: 0]
  |  Branch (4695:34): [True: 0, False: 0]
  ------------------
 4696|      0|        dumper_close(in);
 4697|      0|}
demux.c:find_cache_seek_range:
 3938|  4.72M|{
 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|  4.72M|    if ((flags & SEEK_FACTOR) || !in->seekable_cache)
  ------------------
  |  |   94|  4.72M|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (3943:9): [True: 0, False: 4.72M]
  |  Branch (3943:34): [True: 4.34M, False: 385k]
  ------------------
 3944|  4.34M|        return NULL;
 3945|       |
 3946|   385k|    struct demux_cached_range *res = NULL;
 3947|       |
 3948|   765k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (3948:21): [True: 385k, False: 379k]
  ------------------
 3949|   385k|        struct demux_cached_range *r = in->ranges[n];
 3950|   385k|        if (r->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   385k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3950:13): [True: 5.60k, False: 379k]
  ------------------
 3951|  5.60k|            MP_VERBOSE(in, "cached range %d: %f <-> %f (bof=%d, eof=%d)\n",
  ------------------
  |  |   92|  5.60k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.60k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3952|  5.60k|                       n, r->seek_start, r->seek_end, r->is_bof, r->is_eof);
 3953|       |
 3954|  5.60k|            if ((pts >= r->seek_start || r->is_bof) &&
  ------------------
  |  Branch (3954:18): [True: 3.11k, False: 2.49k]
  |  Branch (3954:42): [True: 2.42k, False: 69]
  ------------------
 3955|  5.53k|                (pts <= r->seek_end || r->is_eof))
  ------------------
  |  Branch (3955:18): [True: 4.72k, False: 816]
  |  Branch (3955:40): [True: 796, False: 20]
  ------------------
 3956|  5.51k|            {
 3957|  5.51k|                MP_VERBOSE(in, "...using this range for in-cache seek.\n");
  ------------------
  |  |   92|  5.51k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.51k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3958|  5.51k|                res = r;
 3959|  5.51k|                break;
 3960|  5.51k|            }
 3961|  5.60k|        }
 3962|   385k|    }
 3963|       |
 3964|   385k|    return res;
 3965|  4.72M|}
demux.c:adjust_cache_seek_target:
 3977|  5.49k|{
 3978|  5.49k|    if (*flags & SEEK_HR)
  ------------------
  |  |   99|  5.49k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
  |  Branch (3978:9): [True: 4.00k, False: 1.49k]
  ------------------
 3979|  4.00k|        return;
 3980|       |
 3981|  1.61k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3981:21): [True: 1.51k, False: 103]
  ------------------
 3982|  1.51k|        struct demux_stream *ds = in->streams[n]->ds;
 3983|  1.51k|        struct demux_queue *queue = range->streams[n];
 3984|  1.51k|        if (ds->selected && ds->type == STREAM_VIDEO) {
  ------------------
  |  Branch (3984:13): [True: 1.49k, False: 23]
  |  Branch (3984:29): [True: 1.38k, False: 103]
  ------------------
 3985|  1.38k|            struct demux_packet *target = find_seek_target(queue, *pts, *flags);
 3986|  1.38k|            if (target) {
  ------------------
  |  Branch (3986:17): [True: 756, False: 633]
  ------------------
 3987|    756|                double target_pts;
 3988|    756|                compute_keyframe_times(target, &target_pts, NULL);
 3989|    756|                if (target_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|    756|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3989:21): [True: 756, False: 0]
  ------------------
 3990|    756|                    MP_VERBOSE(in, "adjust seek target %f -> %f\n",
  ------------------
  |  |   92|    756|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    756|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3991|    756|                               *pts, target_pts);
 3992|       |                    // (We assume the find_seek_target() call will return
 3993|       |                    // the same target for the video stream.)
 3994|    756|                    *pts = target_pts;
 3995|    756|                    *flags &= ~SEEK_FORWARD;
  ------------------
  |  |   95|    756|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
 3996|    756|                }
 3997|    756|            }
 3998|  1.38k|            break;
 3999|  1.38k|        }
 4000|  1.51k|    }
 4001|  1.49k|}
demux.c:find_seek_target:
 3895|  1.88M|{
 3896|  1.88M|    pts -= queue->ds->sh->seek_preroll;
 3897|       |
 3898|  1.88M|    struct demux_packet *start = search_index(queue, pts);
 3899|  1.88M|    if (!start)
  ------------------
  |  Branch (3899:9): [True: 1.87M, False: 7.81k]
  ------------------
 3900|  1.87M|        start = queue->head;
 3901|       |
 3902|  1.88M|    struct demux_packet *target = NULL;
 3903|  1.88M|    struct demux_packet *next = NULL;
 3904|  2.08M|    for (struct demux_packet *dp = start; dp; dp = next) {
  ------------------
  |  Branch (3904:43): [True: 208k, False: 1.87M]
  ------------------
 3905|   208k|        next = dp->next;
 3906|   208k|        if (!dp->keyframe)
  ------------------
  |  Branch (3906:13): [True: 0, False: 208k]
  ------------------
 3907|      0|            continue;
 3908|       |
 3909|   208k|        double range_pts;
 3910|   208k|        next = compute_keyframe_times(dp, &range_pts, NULL);
 3911|       |
 3912|   208k|        if (range_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   208k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3912:13): [True: 0, False: 208k]
  ------------------
 3913|      0|            continue;
 3914|       |
 3915|   208k|        if (flags & SEEK_FORWARD) {
  ------------------
  |  |   95|   208k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (3915:13): [True: 57.3k, False: 151k]
  ------------------
 3916|       |            // Stop on the first packet that is >= pts.
 3917|  57.3k|            if (target)
  ------------------
  |  Branch (3917:17): [True: 0, False: 57.3k]
  ------------------
 3918|      0|                break;
 3919|  57.3k|            if (range_pts < pts)
  ------------------
  |  Branch (3919:17): [True: 57.3k, False: 0]
  ------------------
 3920|  57.3k|                continue;
 3921|   151k|        } else {
 3922|       |            // Stop before the first packet that is > pts.
 3923|       |            // This still returns a packet with > pts if there's no better one.
 3924|   151k|            if (target && range_pts > pts)
  ------------------
  |  Branch (3924:17): [True: 71.2k, False: 80.4k]
  |  Branch (3924:27): [True: 8.67k, False: 62.5k]
  ------------------
 3925|  8.67k|                break;
 3926|   151k|        }
 3927|       |
 3928|   142k|        target = dp;
 3929|   142k|    }
 3930|       |
 3931|  1.88M|    return target;
 3932|  1.88M|}
demux.c:search_index:
 3870|  1.88M|{
 3871|  1.88M|    size_t a = 0;
 3872|  1.88M|    size_t b = queue->num_index;
 3873|       |
 3874|  1.88M|    while (a < b) {
  ------------------
  |  Branch (3874:12): [True: 13.4k, False: 1.87M]
  ------------------
 3875|  13.4k|        size_t m = a + (b - a) / 2;
 3876|  13.4k|        struct index_entry *e = &QUEUE_INDEX_ENTRY(queue, m);
  ------------------
  |  |  340|  13.4k|    ((queue)->index[((queue)->index0 + (idx)) & QUEUE_INDEX_SIZE_MASK(queue)])
  |  |  ------------------
  |  |  |  |  335|  13.4k|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  |  |  ------------------
  ------------------
 3877|       |
 3878|  13.4k|        bool m_ok = e->pts <= pts;
 3879|       |
 3880|  13.4k|        if (a + 1 == b)
  ------------------
  |  Branch (3880:13): [True: 13.4k, False: 0]
  ------------------
 3881|  13.4k|            return m_ok ? e->pkt : NULL;
  ------------------
  |  Branch (3881:20): [True: 7.81k, False: 5.67k]
  ------------------
 3882|       |
 3883|      0|        if (m_ok) {
  ------------------
  |  Branch (3883:13): [True: 0, False: 0]
  ------------------
 3884|      0|            a = m;
 3885|      0|        } else {
 3886|      0|            b = m;
 3887|      0|        }
 3888|      0|    }
 3889|       |
 3890|  1.87M|    return NULL;
 3891|  1.88M|}
demux.c:compute_keyframe_times:
 1981|   575k|{
 1982|   575k|    struct demux_packet *start = pkt;
 1983|   575k|    double min = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   575k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1984|   575k|    double max = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   575k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1985|       |
 1986|  1.01M|    while (pkt) {
  ------------------
  |  Branch (1986:12): [True: 785k, False: 225k]
  ------------------
 1987|   785k|        if (pkt->keyframe && pkt != start)
  ------------------
  |  Branch (1987:13): [True: 785k, False: 0]
  |  Branch (1987:30): [True: 350k, False: 434k]
  ------------------
 1988|   350k|            break;
 1989|       |
 1990|   434k|        double ts = MP_PTS_OR_DEF(pkt->pts, pkt->dts);
  ------------------
  |  |   62|   434k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   434k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 434k]
  |  |  ------------------
  ------------------
 1991|   434k|        if (pkt->segmented && ((pkt->start != MP_NOPTS_VALUE && ts < pkt->start) ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1991:13): [True: 0, False: 434k]
  |  Branch (1991:33): [True: 0, False: 0]
  |  Branch (1991:65): [True: 0, False: 0]
  ------------------
 1992|      0|                               (pkt->end != MP_NOPTS_VALUE && ts > pkt->end)))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1992:33): [True: 0, False: 0]
  |  Branch (1992:63): [True: 0, False: 0]
  ------------------
 1993|      0|            ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1994|       |
 1995|   434k|        min = MP_PTS_MIN(min, ts);
  ------------------
  |  |   64|   434k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   869k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 434k]
  |  |  |  |  |  Branch (45:23): [True: 434k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 434k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 434k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1996|   434k|        max = MP_PTS_MAX(max, ts);
  ------------------
  |  |   65|   434k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|   869k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 434k]
  |  |  |  |  |  Branch (44:23): [True: 434k, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 434k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 434k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|   434k|        pkt = pkt->next;
 1999|   434k|    }
 2000|       |
 2001|   575k|    if (out_kf_min)
  ------------------
  |  Branch (2001:9): [True: 575k, False: 0]
  ------------------
 2002|   575k|        *out_kf_min = min;
 2003|   575k|    if (out_kf_max)
  ------------------
  |  Branch (2003:9): [True: 52.1k, False: 523k]
  ------------------
 2004|  52.1k|        *out_kf_max = max;
 2005|   575k|    return pkt;
 2006|   575k|}
demux.c:update_bytes_read:
 4505|  5.90M|{
 4506|  5.90M|    struct demuxer *demuxer = in->d_thread;
 4507|       |
 4508|  5.90M|    int64_t new = in->slave_unbuffered_read_bytes;
 4509|  5.90M|    in->slave_unbuffered_read_bytes = 0;
 4510|       |
 4511|  5.90M|    int64_t new_seeks = 0;
 4512|       |
 4513|  5.90M|    struct stream *stream = demuxer->stream;
 4514|  5.90M|    if (stream) {
  ------------------
  |  Branch (4514:9): [True: 5.49M, False: 408k]
  ------------------
 4515|  5.49M|        new += stream->total_unbuffered_read_bytes;
 4516|  5.49M|        stream->total_unbuffered_read_bytes = 0;
 4517|  5.49M|        new_seeks += stream->total_stream_seeks;
 4518|  5.49M|        stream->total_stream_seeks = 0;
 4519|  5.49M|    }
 4520|       |
 4521|  5.90M|    in->cache_unbuffered_read_bytes += new;
 4522|  5.90M|    in->hack_unbuffered_read_bytes += new;
 4523|  5.90M|    in->byte_level_seeks += new_seeks;
 4524|  5.90M|}
demux.c:get_forward_buffered_bytes:
  491|  46.1M|{
  492|  46.1M|    if (!ds->reader_head)
  ------------------
  |  Branch (492:9): [True: 39.6M, False: 6.55M]
  ------------------
  493|  39.6M|        return 0;
  494|  6.55M|    return ds->queue->tail_cum_pos - ds->reader_head->cum_pos;
  495|  46.1M|}
demux.c:get_demux_sub_opts:
 5061|   151k|{
 5062|   151k|    if (!demuxer_list[index])
  ------------------
  |  Branch (5062:9): [True: 11.6k, False: 140k]
  ------------------
 5063|  11.6k|        return false;
 5064|   140k|    *sub = demuxer_list[index]->options;
 5065|       |    return true;
 5066|   151k|}

demux_cue.c:try_open_file:
  248|  30.0k|{
  249|  30.0k|    if (!demuxer->access_references)
  ------------------
  |  Branch (249:9): [True: 0, False: 30.0k]
  ------------------
  250|      0|        return -1;
  251|       |
  252|  30.0k|    struct stream *s = demuxer->stream;
  253|  30.0k|    if (check >= DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (253:9): [True: 30.0k, False: 0]
  ------------------
  254|  30.0k|        char probe[PROBE_SIZE];
  255|  30.0k|        int len = stream_read_peek(s, probe, sizeof(probe));
  256|  30.0k|        if (len < 1 || !mp_probe_cue((bstr){probe, len}))
  ------------------
  |  Branch (256:13): [True: 3.13k, False: 26.9k]
  |  Branch (256:24): [True: 26.9k, False: 0]
  ------------------
  257|  30.0k|            return -1;
  258|  30.0k|    }
  259|      0|    struct priv *p = talloc_zero(demuxer, 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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|      0|    demuxer->priv = p;
  261|      0|    demuxer->fully_read = true;
  262|      0|    bstr data = stream_read_complete(s, p, 1000000);
  263|      0|    if (data.start == NULL)
  ------------------
  |  Branch (263:9): [True: 0, False: 0]
  ------------------
  264|      0|        return -1;
  265|       |
  266|      0|    struct demux_opts *opts = mp_get_config_group(p, demuxer->global, &demux_conf);
  267|      0|    const char *charset = mp_charset_guess(p, demuxer->log, data, opts->meta_cp, 0);
  268|      0|    if (charset && !mp_charset_is_utf8(charset)) {
  ------------------
  |  Branch (268:9): [True: 0, False: 0]
  |  Branch (268:20): [True: 0, False: 0]
  ------------------
  269|      0|        MP_INFO(demuxer, "Using CUE charset: %s\n", charset);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  270|      0|        bstr utf8 = mp_iconv_to_utf8(demuxer->log, data, charset, MP_ICONV_VERBOSE);
  271|      0|        if (utf8.start && utf8.start != data.start) {
  ------------------
  |  Branch (271:13): [True: 0, False: 0]
  |  Branch (271:27): [True: 0, False: 0]
  ------------------
  272|      0|            ta_steal(data.start, utf8.start);
  ------------------
  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  ------------------
  273|      0|            data = utf8;
  274|      0|        }
  275|      0|    }
  276|      0|    talloc_free(opts);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  277|       |
  278|      0|    p->f = mp_parse_cue(data);
  279|      0|    talloc_steal(p, p->f);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  280|      0|    if (!p->f) {
  ------------------
  |  Branch (280:9): [True: 0, False: 0]
  ------------------
  281|      0|        MP_ERR(demuxer, "error parsing input 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__)
  |  |  ------------------
  ------------------
  282|      0|        return -1;
  283|      0|    }
  284|       |
  285|      0|    demux_close_stream(demuxer);
  286|       |
  287|      0|    mp_tags_merge(demuxer->metadata, p->f->tags);
  288|      0|    return 0;
  289|      0|}

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

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

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

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

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

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

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

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

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

demux_timeline.c:d_open:
  771|     11|{
  772|     11|    struct priv *p = demuxer->priv = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|     11|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     11|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     11|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|     11|    p->tl = demuxer->params ? demuxer->params->timeline : NULL;
  ------------------
  |  Branch (773:13): [True: 11, False: 0]
  ------------------
  774|     11|    if (!p->tl || p->tl->num_pars < 1)
  ------------------
  |  Branch (774:9): [True: 0, False: 11]
  |  Branch (774:19): [True: 0, False: 11]
  ------------------
  775|      0|        return -1;
  776|       |
  777|     11|    demuxer->chapters = p->tl->chapters;
  778|     11|    demuxer->num_chapters = p->tl->num_chapters;
  779|       |
  780|     11|    struct demuxer *meta = p->tl->meta;
  781|     11|    if (meta) {
  ------------------
  |  Branch (781:9): [True: 11, False: 0]
  ------------------
  782|     11|        demuxer->metadata = meta->metadata;
  783|     11|        demuxer->attachments = meta->attachments;
  784|     11|        demuxer->num_attachments = meta->num_attachments;
  785|     11|        demuxer->editions = meta->editions;
  786|     11|        demuxer->num_editions = meta->num_editions;
  787|     11|        demuxer->edition = meta->edition;
  788|     11|    }
  789|       |
  790|     22|    for (int n = 0; n < p->tl->num_pars; n++) {
  ------------------
  |  Branch (790:21): [True: 11, False: 11]
  ------------------
  791|     11|        if (!add_tl(demuxer, p->tl->pars[n]))
  ------------------
  |  Branch (791:13): [True: 0, False: 11]
  ------------------
  792|      0|            return -1;
  793|     11|    }
  794|       |
  795|     11|    if (!p->num_sources)
  ------------------
  |  Branch (795:9): [True: 0, False: 11]
  ------------------
  796|      0|        return -1;
  797|       |
  798|     11|    build_editions(demuxer);
  799|       |
  800|     11|    demuxer->is_network |= p->tl->is_network;
  801|     11|    demuxer->is_streaming |= p->tl->is_streaming;
  802|       |
  803|     11|    demuxer->duration = p->duration;
  804|       |
  805|     11|    print_timeline(demuxer);
  806|       |
  807|     11|    demuxer->seekable = true;
  808|     11|    demuxer->partially_seekable = false;
  809|       |
  810|     11|    const char *format_name = "unknown";
  811|     11|    if (meta)
  ------------------
  |  Branch (811:9): [True: 11, False: 0]
  ------------------
  812|     11|        format_name = meta->filetype ? meta->filetype : meta->desc->name;
  ------------------
  |  Branch (812:23): [True: 0, False: 11]
  ------------------
  813|     11|    demuxer->filetype = talloc_asprintf(p, "%s/%s", p->tl->format, format_name);
  ------------------
  |  |   52|     11|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     11|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  814|       |
  815|     11|    reselect_streams(demuxer);
  816|       |
  817|       |    p->owns_tl = true;
  818|     11|    return 0;
  819|     11|}
demux_timeline.c:add_tl:
  552|     11|{
  553|     11|    struct priv *p = demuxer->priv;
  554|       |
  555|     11|    struct MPOpts *mp_opts = mp_get_config_group(NULL, demuxer->global, &mp_opt_root);
  556|     11|    struct virtual_source *src = talloc_ptrtype(p, src);
  ------------------
  |  |   34|     11|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|     11|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     11|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|     11|    *src = (struct virtual_source){
  558|     11|        .tl = tl,
  559|     11|        .dash = tl->dash,
  560|     11|        .delay_open = tl->delay_open,
  561|     11|        .no_clip = tl->no_clip || tl->dash,
  ------------------
  |  Branch (561:20): [True: 0, False: 11]
  |  Branch (561:35): [True: 0, False: 11]
  ------------------
  562|     11|        .dts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|     11|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  563|     11|        .rebase = tl->delay_open && mp_opts->rebase_start_time,
  ------------------
  |  Branch (563:19): [True: 0, False: 11]
  |  Branch (563:37): [True: 0, False: 0]
  ------------------
  564|     11|    };
  565|     11|    TA_FREEP(&mp_opts);
  ------------------
  |  |   81|     11|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     11|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 11]
  |  |  ------------------
  ------------------
  566|       |
  567|     11|    if (!tl->num_parts)
  ------------------
  |  Branch (567:9): [True: 0, False: 11]
  ------------------
  568|      0|        return false;
  569|       |
  570|     11|    MP_TARRAY_APPEND(p, p->sources, p->num_sources, src);
  ------------------
  |  |  105|     11|    do {                                            \
  |  |  106|     11|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     11|    do {                                            \
  |  |  |  |   97|     11|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     11|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     11|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     11|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     11|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     11|    do {                                                        \
  |  |  |  |  |  |   89|     11|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     11|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     11|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     11|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     11|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     11|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     11|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     11|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     11|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     11|        (idxvar)++;                                 \
  |  |  109|     11|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11]
  |  |  ------------------
  ------------------
  571|       |
  572|     11|    p->duration = MPMAX(p->duration, tl->parts[tl->num_parts - 1].end);
  ------------------
  |  |   44|     11|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 11]
  |  |  ------------------
  ------------------
  573|       |
  574|     11|    struct demuxer *meta = tl->track_layout;
  575|       |
  576|       |    // delay_open streams normally have meta==NULL, and 1 virtual stream
  577|     11|    int num_streams = 0;
  578|     11|    if (tl->delay_open) {
  ------------------
  |  Branch (578:9): [True: 0, False: 11]
  ------------------
  579|      0|        num_streams = tl->num_sh_meta;
  580|     11|    } else if (meta) {
  ------------------
  |  Branch (580:16): [True: 11, False: 0]
  ------------------
  581|     11|        num_streams = demux_get_num_stream(meta);
  582|     11|    }
  583|     11|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (583:21): [True: 0, False: 11]
  ------------------
  584|      0|        struct sh_stream *new = NULL;
  585|       |
  586|      0|        if (tl->delay_open) {
  ------------------
  |  Branch (586:13): [True: 0, False: 0]
  ------------------
  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|      0|        } else {
  594|      0|            struct sh_stream *sh = demux_get_stream(meta, n);
  595|      0|            new = demux_alloc_sh_stream(sh->type);
  596|      0|            apply_meta(new, sh);
  597|      0|            new->codec = sh->codec;
  598|      0|            struct sh_stream *tsh = find_matching_meta(tl, n);
  599|      0|            if (tsh)
  ------------------
  |  Branch (599:17): [True: 0, False: 0]
  ------------------
  600|      0|                apply_meta(new, tsh);
  601|      0|        }
  602|       |
  603|      0|        demux_add_sh_stream(demuxer, new);
  604|      0|        struct virtual_stream *vs = talloc_ptrtype(p, vs);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  605|      0|        *vs = (struct virtual_stream){
  606|      0|            .src = src,
  607|      0|            .sh = new,
  608|      0|        };
  609|      0|        MP_TARRAY_APPEND(p, p->streams, p->num_streams, vs);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  610|      0|        mp_assert(demux_get_stream(demuxer, p->num_streams - 1) == new);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (610:9): [True: 0, False: 0]
  ------------------
  611|      0|        MP_TARRAY_APPEND(src, src->streams, src->num_streams, vs);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  612|      0|    }
  613|       |
  614|     22|    for (int n = 0; n < tl->num_parts; n++) {
  ------------------
  |  Branch (614:21): [True: 11, False: 11]
  ------------------
  615|     11|        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|     11|        if (part->source) {
  ------------------
  |  Branch (619:13): [True: 11, False: 0]
  ------------------
  620|     11|            demuxer->is_network |= part->source->is_network;
  621|     11|            demuxer->is_streaming |= part->source->is_streaming;
  622|     11|        }
  623|       |
  624|     11|        if (!part->source)
  ------------------
  |  Branch (624:13): [True: 0, False: 11]
  ------------------
  625|     11|            mp_assert(tl->dash || tl->delay_open);
  ------------------
  |  |   41|     11|#define mp_assert assert
  ------------------
  |  Branch (625:13): [True: 0, False: 0]
  |  Branch (625:13): [True: 0, False: 0]
  ------------------
  626|       |
  627|     11|        struct segment *seg = talloc_ptrtype(src, seg);
  ------------------
  |  |   34|     11|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|     11|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     11|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|     11|        *seg = (struct segment){
  629|     11|            .d = part->source,
  630|     11|            .url = part->source ? part->source->filename : part->url,
  ------------------
  |  Branch (630:20): [True: 11, False: 0]
  ------------------
  631|     11|            .lazy = !part->source,
  632|     11|            .d_start = part->source_start,
  633|     11|            .start = part->start,
  634|     11|            .end = part->end,
  635|     11|        };
  636|       |
  637|     11|        associate_streams(demuxer, src, seg);
  638|       |
  639|     11|        seg->index = n;
  640|     11|        MP_TARRAY_APPEND(src, src->segments, src->num_segments, seg);
  ------------------
  |  |  105|     11|    do {                                            \
  |  |  106|     11|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     11|    do {                                            \
  |  |  |  |   97|     11|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     11|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     11|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     11|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|     11|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     11|    do {                                                        \
  |  |  |  |  |  |   89|     11|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     11|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     11|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     11|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     11|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     11|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     11|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     11|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     11|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     11|        (idxvar)++;                                 \
  |  |  109|     11|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11]
  |  |  ------------------
  ------------------
  641|     11|    }
  642|       |
  643|     11|    if (tl->track_layout) {
  ------------------
  |  Branch (643:9): [True: 11, False: 0]
  ------------------
  644|     11|        demuxer->is_network |= tl->track_layout->is_network;
  645|     11|        demuxer->is_streaming |= tl->track_layout->is_streaming;
  646|     11|    }
  647|       |    return true;
  648|     11|}
demux_timeline.c:associate_streams:
  115|     11|{
  116|     11|    if (!seg->d || seg->stream_map)
  ------------------
  |  Branch (116:9): [True: 0, False: 11]
  |  Branch (116:20): [True: 0, False: 11]
  ------------------
  117|      0|        return;
  118|       |
  119|     11|    int num_streams = demux_get_num_stream(seg->d);
  120|     11|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (120:21): [True: 0, False: 11]
  ------------------
  121|      0|        struct sh_stream *sh = demux_get_stream(seg->d, n);
  122|      0|        struct virtual_stream *other = NULL;
  123|       |
  124|      0|        for (int i = 0; i < src->num_streams; i++) {
  ------------------
  |  Branch (124:25): [True: 0, False: 0]
  ------------------
  125|      0|            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|      0|            if (sh->type != vs->sh->type || target_stream_used(seg, vs))
  ------------------
  |  Branch (129:17): [True: 0, False: 0]
  |  Branch (129:45): [True: 0, False: 0]
  ------------------
  130|      0|                continue;
  131|       |
  132|       |            // By default pick the first matching stream.
  133|      0|            if (!other)
  ------------------
  |  Branch (133:17): [True: 0, False: 0]
  ------------------
  134|      0|                other = vs;
  135|       |
  136|       |            // Matching by demuxer ID is supposedly useful and preferable for
  137|       |            // ordered chapters.
  138|      0|            if (sh->demuxer_id >= 0 && sh->demuxer_id == vs->sh->demuxer_id)
  ------------------
  |  Branch (138:17): [True: 0, False: 0]
  |  Branch (138:40): [True: 0, False: 0]
  ------------------
  139|      0|                other = vs;
  140|      0|        }
  141|       |
  142|      0|        if (!other) {
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  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|      0|        MP_TARRAY_APPEND(seg, seg->stream_map, seg->num_stream_map, other);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  148|      0|    }
  149|     11|}
demux_timeline.c:build_editions:
  660|     11|{
  661|       |    // Don't override editions from the underlying demuxer.
  662|     11|    if (demuxer->num_editions > 0)
  ------------------
  |  Branch (662:9): [True: 0, False: 11]
  ------------------
  663|      0|        return;
  664|       |
  665|     11|    struct MPOpts *mp_opts = mp_get_config_group(NULL, demuxer->global, &mp_opt_root);
  666|     11|    int hls_bitrate = mp_opts->hls_bitrate;
  667|     11|    int edition_id = mp_opts->edition_id;
  668|     11|    bool flatten_editions = mp_opts->flatten_editions;
  669|     11|    TA_FREEP(&mp_opts);
  ------------------
  |  |   81|     11|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     11|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 11]
  |  |  ------------------
  ------------------
  670|     11|    if (flatten_editions) {
  ------------------
  |  Branch (670:9): [True: 0, False: 11]
  ------------------
  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|     11|    int num_streams = demux_get_num_stream(demuxer);
  676|     11|    for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (676:21): [True: 0, False: 11]
  ------------------
  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|     11|    if (demuxer->num_editions <= 1) {
  ------------------
  |  Branch (708:9): [True: 11, False: 0]
  ------------------
  709|     11|        demuxer->num_editions = 0;
  710|     11|        return;
  711|     11|    }
  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|     11|{
  482|     11|    struct priv *p = demuxer->priv;
  483|       |
  484|     11|    MP_VERBOSE(demuxer, "Timeline segments:\n");
  ------------------
  |  |   92|     11|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  485|     22|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (485:21): [True: 11, False: 11]
  ------------------
  486|     11|        struct virtual_source *src = p->sources[x];
  487|       |
  488|     11|        if (x >= 1)
  ------------------
  |  Branch (488:13): [True: 0, False: 11]
  ------------------
  489|     11|            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|     22|        for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (491:25): [True: 11, False: 11]
  ------------------
  492|     11|            struct segment *seg = src->segments[n];
  493|     11|            int src_num = n;
  494|     11|            for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (494:29): [True: 0, False: 11]
  ------------------
  495|      0|                if (seg->d && src->segments[i]->d == seg->d) {
  ------------------
  |  Branch (495:21): [True: 0, False: 0]
  |  Branch (495:31): [True: 0, False: 0]
  ------------------
  496|      0|                    src_num = i;
  497|      0|                    break;
  498|      0|                }
  499|      0|            }
  500|     11|            MP_VERBOSE(demuxer, " %2d: %12f - %12f [%12f] (",
  ------------------
  |  |   92|     11|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  501|     11|                       n, seg->start, seg->end, seg->d_start);
  502|     11|            for (int i = 0; i < seg->num_stream_map; i++) {
  ------------------
  |  Branch (502:29): [True: 0, False: 11]
  ------------------
  503|      0|                struct virtual_stream *vs = seg->stream_map[i];
  504|      0|                MP_VERBOSE(demuxer, "%s%d", 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__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|      0|                           vs ? vs->sh->index : -1);
  506|      0|            }
  507|     11|            MP_VERBOSE(demuxer, ")\n  source %d:'%s'\n", src_num, seg->url);
  ------------------
  |  |   92|     11|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  508|     11|        }
  509|       |
  510|     11|        if (src->dash)
  ------------------
  |  Branch (510:13): [True: 0, False: 11]
  ------------------
  511|     11|            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|     11|    }
  513|     11|    MP_VERBOSE(demuxer, "Total duration: %f\n", p->duration);
  ------------------
  |  |   92|     11|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  514|     11|}
demux_timeline.c:reselect_streams:
  152|     11|{
  153|     11|    struct priv *p = demuxer->priv;
  154|       |
  155|     11|    for (int n = 0; n < p->num_streams; n++) {
  ------------------
  |  Branch (155:21): [True: 0, False: 11]
  ------------------
  156|      0|        struct virtual_stream *vs = p->streams[n];
  157|      0|        vs->selected = demux_stream_is_selected(vs->sh);
  158|      0|    }
  159|       |
  160|     22|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (160:21): [True: 11, False: 11]
  ------------------
  161|     11|        struct virtual_source *src = p->sources[x];
  162|       |
  163|     22|        for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (163:25): [True: 11, False: 11]
  ------------------
  164|     11|            struct segment *seg = src->segments[n];
  165|       |
  166|     11|            if (!seg->d)
  ------------------
  |  Branch (166:17): [True: 0, False: 11]
  ------------------
  167|      0|                continue;
  168|       |
  169|     11|            for (int i = 0; i < seg->num_stream_map; i++) {
  ------------------
  |  Branch (169:29): [True: 0, False: 11]
  ------------------
  170|      0|                bool selected =
  171|      0|                    seg->stream_map[i] && seg->stream_map[i]->selected;
  ------------------
  |  Branch (171:21): [True: 0, False: 0]
  |  Branch (171:43): [True: 0, False: 0]
  ------------------
  172|       |
  173|       |                // This stops demuxer readahead for inactive segments.
  174|      0|                if (!src->current || seg->d != src->current->d)
  ------------------
  |  Branch (174:21): [True: 0, False: 0]
  |  Branch (174:38): [True: 0, False: 0]
  ------------------
  175|      0|                    selected = false;
  176|      0|                struct sh_stream *sh = demux_get_stream(seg->d, i);
  177|      0|                demuxer_select_track(seg->d, sh, MP_NOPTS_VALUE, selected);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  178|       |
  179|      0|                update_slave_stats(demuxer, seg->d);
  180|      0|            }
  181|     11|        }
  182|       |
  183|     11|        bool was_selected = src->any_selected;
  184|     11|        src->any_selected = false;
  185|       |
  186|     11|        for (int n = 0; n < src->num_streams; n++)
  ------------------
  |  Branch (186:25): [True: 0, False: 11]
  ------------------
  187|      0|            src->any_selected |= src->streams[n]->selected;
  188|       |
  189|     11|        if (!was_selected && src->any_selected) {
  ------------------
  |  Branch (189:13): [True: 11, False: 0]
  |  Branch (189:30): [True: 0, False: 11]
  ------------------
  190|      0|            src->eof_reached = false;
  191|      0|            src->dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  192|       |            TA_FREEP(&src->next);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  193|      0|        }
  194|     11|    }
  195|     11|}
demux_timeline.c:d_close:
  822|     11|{
  823|     11|    struct priv *p = demuxer->priv;
  824|       |
  825|     22|    for (int x = 0; x < p->num_sources; x++) {
  ------------------
  |  Branch (825:21): [True: 11, False: 11]
  ------------------
  826|     11|        struct virtual_source *src = p->sources[x];
  827|       |
  828|     11|        src->current = NULL;
  829|     11|        TA_FREEP(&src->next);
  ------------------
  |  |   81|     11|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|     11|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 11]
  |  |  ------------------
  ------------------
  830|     11|        close_lazy_segments(demuxer, src);
  831|     11|    }
  832|       |
  833|     11|    if (p->owns_tl) {
  ------------------
  |  Branch (833:9): [True: 11, False: 0]
  ------------------
  834|     11|        struct demuxer *master = p->tl->demuxer;
  835|     11|        timeline_destroy(p->tl);
  836|     11|        demux_free(master);
  837|     11|    }
  838|     11|}
demux_timeline.c:close_lazy_segments:
  199|     11|{
  200|       |    // unload previous segment
  201|     22|    for (int n = 0; n < src->num_segments; n++) {
  ------------------
  |  Branch (201:21): [True: 11, False: 11]
  ------------------
  202|     11|        struct segment *seg = src->segments[n];
  203|     11|        if (seg != src->current && seg->d && seg->lazy) {
  ------------------
  |  Branch (203:13): [True: 11, False: 0]
  |  Branch (203:36): [True: 11, False: 0]
  |  Branch (203:46): [True: 0, False: 11]
  ------------------
  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|     11|    }
  209|     11|}

ebml_read_id:
   62|  25.6k|{
   63|  25.6k|    int i, len_mask = 0x80;
   64|  25.6k|    uint32_t id;
   65|       |
   66|  59.7k|    for (i = 0, id = stream_read_char(s); i < 4 && !(id & len_mask); i++)
  ------------------
  |  Branch (66:43): [True: 58.2k, False: 1.51k]
  |  Branch (66:52): [True: 34.1k, False: 24.1k]
  ------------------
   67|  34.1k|        len_mask >>= 1;
   68|  25.6k|    if (i >= 4)
  ------------------
  |  Branch (68:9): [True: 1.51k, False: 24.1k]
  ------------------
   69|  1.51k|        return EBML_ID_INVALID;
  ------------------
  |  |   75|  1.51k|#define EBML_ID_INVALID 0xffffffff
  ------------------
   70|  52.1k|    while (i--)
  ------------------
  |  Branch (70:12): [True: 28.0k, False: 24.1k]
  ------------------
   71|  28.0k|        id = (id << 8) | stream_read_char(s);
   72|  24.1k|    return id;
   73|  25.6k|}

demux_packet_unref_contents:
   48|   944k|{
   49|   944k|    if (dp->avpacket) {
  ------------------
  |  Branch (49:9): [True: 944k, False: 0]
  ------------------
   50|   944k|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|   944k|#define mp_assert assert
  ------------------
  |  Branch (50:9): [True: 944k, False: 0]
  ------------------
   51|   944k|        av_packet_free(&dp->avpacket);
   52|   944k|        dp->buffer = NULL;
   53|   944k|        dp->len = 0;
   54|       |        dp->is_wrapped_avframe = false;
   55|   944k|    }
   56|   944k|}
demux_packet_unref:
   81|  2.25M|{
   82|  2.25M|    if (!dp)
  ------------------
  |  Branch (82:9): [True: 944k, False: 1.31M]
  ------------------
   83|   944k|        return;
   84|  1.31M|    struct AVPacket *avpkt = dp->avpacket;
   85|  1.31M|    if (avpkt)
  ------------------
  |  Branch (85:9): [True: 1.31M, False: 18.4E]
  ------------------
   86|  1.31M|        av_packet_unref(avpkt);
   87|  1.31M|    ta_free_children(dp);
   88|  1.31M|    set_packet_defaults(dp);
   89|  1.31M|    dp->avpacket = avpkt;
   90|  1.31M|}
new_demux_packet_from_avpacket:
  111|  1.57M|{
  112|  1.57M|    if (avpkt->size > 1000000000)
  ------------------
  |  Branch (112:9): [True: 0, False: 1.57M]
  ------------------
  113|      0|        return NULL;
  114|  1.57M|    struct demux_packet *dp = packet_create(pool);
  115|  1.57M|    int r = -1;
  116|  1.57M|    if (avpkt->data) {
  ------------------
  |  Branch (116:9): [True: 1.57M, 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|  1.57M|        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|  1.57M|    if (r < 0) {
  ------------------
  |  Branch (123:9): [True: 0, False: 1.57M]
  ------------------
  124|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  125|      0|        return NULL;
  126|      0|    }
  127|  1.57M|    dp->buffer = dp->avpacket->data;
  128|  1.57M|    dp->len = dp->avpacket->size;
  129|  1.57M|    return dp;
  130|  1.57M|}
new_demux_packet_from_buf:
  135|  38.5k|{
  136|  38.5k|    if (!buf)
  ------------------
  |  Branch (136:9): [True: 38.5k, False: 0]
  ------------------
  137|  38.5k|        return NULL;
  138|      0|    if (buf->size > 1000000000)
  ------------------
  |  Branch (138:9): [True: 0, False: 0]
  ------------------
  139|      0|        return NULL;
  140|       |
  141|      0|    struct demux_packet *dp = packet_create(pool);
  142|      0|    dp->avpacket->buf = av_buffer_ref(buf);
  143|      0|    if (!dp->avpacket->buf) {
  ------------------
  |  Branch (143:9): [True: 0, False: 0]
  ------------------
  144|      0|        talloc_free(dp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        return NULL;
  146|      0|    }
  147|      0|    dp->avpacket->data = dp->buffer = buf->data;
  148|      0|    dp->avpacket->size = dp->len = buf->size;
  149|      0|    return dp;
  150|      0|}
free_demux_packet:
  188|   894k|{
  189|   894k|    talloc_free(dp);
  ------------------
  |  |   47|   894k|#define talloc_free                     ta_free
  ------------------
  190|   894k|}
demux_packet_copy_attribs:
  193|   377k|{
  194|   377k|    dst->pts = src->pts;
  195|   377k|    dst->dts = src->dts;
  196|   377k|    dst->duration = src->duration;
  197|   377k|    dst->pos = src->pos;
  198|   377k|    dst->is_wrapped_avframe = src->is_wrapped_avframe;
  199|   377k|    dst->segmented = src->segmented;
  200|   377k|    dst->start = src->start;
  201|   377k|    dst->end = src->end;
  202|   377k|    dst->codec = src->codec;
  203|   377k|    dst->back_restart = src->back_restart;
  204|   377k|    dst->back_preroll = src->back_preroll;
  205|   377k|    dst->keyframe = src->keyframe;
  206|   377k|    dst->stream = src->stream;
  207|   377k|}
demux_copy_packet:
  210|   377k|{
  211|   377k|    struct demux_packet *new = NULL;
  212|   377k|    if (dp->avpacket) {
  ------------------
  |  Branch (212:9): [True: 377k, False: 0]
  ------------------
  213|   377k|        new = new_demux_packet_from_avpacket(pool, dp->avpacket);
  214|   377k|    } 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|   377k|    if (!new)
  ------------------
  |  Branch (218:9): [True: 0, False: 377k]
  ------------------
  219|      0|        return NULL;
  220|   377k|    demux_packet_copy_attribs(new, dp);
  221|   377k|    return new;
  222|   377k|}
demux_packet_estimate_total_size:
  235|  1.14M|{
  236|  1.14M|    size_t size = ROUND_ALLOC(sizeof(struct demux_packet));
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  237|  1.14M|    size += 8 * sizeof(void *); // ta  overhead
  238|  1.14M|    size += 10 * sizeof(void *); // additional estimate for ta_ext_header
  239|  1.14M|    if (dp->avpacket) {
  ------------------
  |  Branch (239:9): [True: 1.14M, False: 0]
  ------------------
  240|  1.14M|        mp_assert(!dp->is_cached);
  ------------------
  |  |   41|  1.14M|#define mp_assert assert
  ------------------
  |  Branch (240:9): [True: 1.14M, False: 0]
  ------------------
  241|  1.14M|        size += ROUND_ALLOC(dp->len);
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  242|  1.14M|        if (dp->is_wrapped_avframe) {
  ------------------
  |  Branch (242:13): [True: 346k, False: 797k]
  ------------------
  243|   346k|            mp_require(dp->buffer);
  ------------------
  |  |   42|   346k|#define mp_require assert
  ------------------
  |  Branch (243:13): [True: 346k, False: 0]
  ------------------
  244|       |
  245|   346k|            const AVFrame *frame = (AVFrame *)dp->buffer;
  246|   346k|            if (frame->hw_frames_ctx) {
  ------------------
  |  Branch (246:17): [True: 0, False: 346k]
  ------------------
  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|  1.38M|            for (int i = 0; i < MP_ARRAY_SIZE(frame->buf) && frame->buf[i]; ++i)
  ------------------
  |  |   49|  2.77M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (252:29): [True: 1.38M, False: 0]
  |  Branch (252:62): [True: 1.03M, False: 346k]
  ------------------
  253|  1.03M|                size += ROUND_ALLOC(frame->buf[i]->size);
  ------------------
  |  |  224|  1.03M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.38M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  254|       |
  255|   346k|            size += ROUND_ALLOC(frame->nb_extended_buf * sizeof(frame->extended_buf[0]));
  ------------------
  |  |  224|   346k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   346k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  256|   346k|            for (int i = 0; i < frame->nb_extended_buf; ++i) {
  ------------------
  |  Branch (256:29): [True: 0, False: 346k]
  ------------------
  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|   346k|            size += ROUND_ALLOC(frame->nb_side_data * sizeof(frame->side_data[0]));
  ------------------
  |  |  224|   346k|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|   346k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  262|   346k|            for (int i = 0; i < frame->nb_side_data; ++i) {
  ------------------
  |  Branch (262:29): [True: 0, False: 346k]
  ------------------
  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|   346k|        }
  267|  1.14M|        size += ROUND_ALLOC(sizeof(AVPacket));
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  268|  1.14M|        size += 8 * sizeof(void *); // ta  overhead
  269|  1.14M|        size += ROUND_ALLOC(sizeof(AVBufferRef));
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  270|  1.14M|        size += ROUND_ALLOC(64); // upper bound estimate on sizeof(AVBuffer)
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  271|  1.14M|        size += ROUND_ALLOC(dp->avpacket->side_data_elems *
  ------------------
  |  |  224|  1.14M|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  272|  1.14M|                            sizeof(dp->avpacket->side_data[0]));
  273|  1.14M|        for (int n = 0; n < dp->avpacket->side_data_elems; n++)
  ------------------
  |  Branch (273:25): [True: 0, False: 1.14M]
  ------------------
  274|  1.14M|            size += ROUND_ALLOC(dp->avpacket->side_data[n].size);
  ------------------
  |  |  224|      0|#define ROUND_ALLOC(s) MP_ALIGN_UP((s), 16)
  |  |  ------------------
  |  |  |  |   53|  1.14M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  |  |  ------------------
  ------------------
  275|  1.14M|    }
  276|  1.14M|    return size;
  277|  1.14M|}
packet.c:set_packet_defaults:
   65|  2.25M|{
   66|  2.25M|    *dp = (struct demux_packet) {
   67|  2.25M|        .pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   68|  2.25M|        .dts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   69|  2.25M|        .duration = -1,
   70|  2.25M|        .pos = -1,
   71|  2.25M|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   72|  2.25M|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  2.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   73|  2.25M|        .stream = -1,
   74|  2.25M|        .animated = -1,
   75|  2.25M|    };
   76|  2.25M|}
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: 0]
  ------------------
   95|  1.57M|    if (!dp) {
  ------------------
  |  Branch (95:9): [True: 944k, False: 627k]
  ------------------
   96|   944k|        dp = talloc(NULL, struct demux_packet);
  ------------------
  |  |   26|   944k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   944k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   944k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   97|   944k|        talloc_set_destructor(dp, packet_destroy);
  ------------------
  |  |   41|   944k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   98|   944k|        set_packet_defaults(dp);
   99|   944k|    }
  100|  1.57M|    if (!dp->avpacket)
  ------------------
  |  Branch (100:9): [True: 944k, False: 627k]
  ------------------
  101|   944k|        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|   944k|{
   60|   944k|    struct demux_packet *dp = ptr;
   61|   944k|    demux_packet_unref_contents(dp);
   62|   944k|}

demux_packet_pool_init:
   50|  11.6k|{
   51|  11.6k|    struct demux_packet_pool *pool = talloc(global, struct demux_packet_pool);
  ------------------
  |  |   26|  11.6k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  11.6k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   52|  11.6k|    talloc_set_destructor(pool, uninit);
  ------------------
  |  |   41|  11.6k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   53|  11.6k|    mp_mutex_init(&pool->lock);
   54|  11.6k|    pool->packets = NULL;
   55|       |
   56|  11.6k|    mp_assert(!global->packet_pool);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 11.6k, False: 0]
  ------------------
   57|  11.6k|    global->packet_pool = pool;
   58|  11.6k|}
demux_packet_pool_get:
   61|  1.58M|{
   62|       |    // Currently all clients use the same packet pool. There is no additional
   63|       |    // state for each client, may be extended in the future.
   64|  1.58M|    return global->packet_pool;
   65|  1.58M|}
demux_packet_pool_clear:
   68|  28.3k|{
   69|  28.3k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  28.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   70|  28.3k|    struct demux_packet *dp = pool->packets;
   71|  28.3k|    pool->packets = NULL;
   72|  28.3k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  28.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   73|  28.3k|    free_demux_packets(dp);
   74|  28.3k|}
demux_packet_pool_push:
   78|   859k|{
   79|   859k|    if (!dp)
  ------------------
  |  Branch (79:9): [True: 174k, False: 684k]
  ------------------
   80|   174k|        return;
   81|   684k|    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|   684k|    demux_packet_unref(dp);
   86|   684k|    demux_packet_pool_prepend(pool, dp, dp);
   87|   684k|}
demux_packet_pool_prepend:
   91|  10.7M|{
   92|  10.7M|    if (!head)
  ------------------
  |  Branch (92:9): [True: 9.99M, False: 787k]
  ------------------
   93|  9.99M|        return;
   94|   787k|    mp_assert(tail);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (94:5): [True: 787k, False: 0]
  ------------------
   95|   787k|    mp_assert(head != tail ? !!head->next : !head->next);
  ------------------
  |  |   41|   787k|#define mp_assert assert
  ------------------
  |  Branch (95:5): [True: 27.0k, False: 760k]
  |  Branch (95:5): [True: 787k, False: 0]
  ------------------
   96|       |
   97|   787k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|   787k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   98|   787k|    tail->next = pool->packets;
   99|   787k|    pool->packets = head;
  100|       |#if HAVE_DISABLE_PACKET_POOL
  101|       |    struct demux_packet *dp = pool->packets;
  102|       |    pool->packets = NULL;
  103|       |#endif
  104|   787k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|   787k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  105|       |
  106|       |#if HAVE_DISABLE_PACKET_POOL
  107|       |    free_demux_packets(dp);
  108|       |#endif
  109|   787k|}
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: 627k, False: 944k]
  ------------------
  149|   627k|        pool->packets = dp->next;
  150|   627k|        dp->next = NULL;
  151|   627k|    }
  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|  11.6k|{
   35|  11.6k|    struct demux_packet_pool *pool = p;
   36|  11.6k|    demux_packet_pool_clear(pool);
   37|  11.6k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   38|  11.6k|}
packet_pool.c:free_demux_packets:
   41|  1.60M|{
   42|  2.49M|    while (dp) {
  ------------------
  |  Branch (42:12): [True: 894k, False: 1.60M]
  ------------------
   43|   894k|        struct demux_packet *next = dp->next;
   44|   894k|        free_demux_packet(dp);
   45|   894k|        dp = next;
   46|   894k|    }
   47|  1.60M|}
packet_pool.c:pool_gc_detach:
  126|  1.57M|{
  127|  1.57M|    struct demux_packet *cat_reserve = pool->packets;
  128|  7.06M|    for (int i = 1; cat_reserve && i < POOL_HOT_RESERVE; i++)
  ------------------
  |  |  114|  5.63M|#define POOL_HOT_RESERVE 16
  ------------------
  |  Branch (128:21): [True: 5.63M, False: 1.42M]
  |  Branch (128:36): [True: 5.49M, False: 149k]
  ------------------
  129|  5.49M|        cat_reserve = cat_reserve->next;
  130|       |
  131|  1.57M|    if (!cat_reserve || !cat_reserve->next)
  ------------------
  |  Branch (131:9): [True: 1.42M, False: 149k]
  |  Branch (131:25): [True: 113k, False: 35.4k]
  ------------------
  132|  1.53M|        return NULL;
  133|       |
  134|  35.4k|    struct demux_packet *gc = cat_reserve->next;
  135|  35.4k|    struct demux_packet *cut_rest = gc;
  136|  53.3k|    for (int i = 1; cut_rest->next && i < POOL_GC_BATCH; i++)
  ------------------
  |  |  121|  17.9k|#define POOL_GC_BATCH 64
  ------------------
  |  Branch (136:21): [True: 17.9k, False: 35.4k]
  |  Branch (136:39): [True: 17.9k, False: 0]
  ------------------
  137|  17.9k|        cut_rest = cut_rest->next;
  138|       |
  139|  35.4k|    cat_reserve->next = cut_rest->next;
  140|       |    cut_rest->next = NULL;
  141|  35.4k|    return gc;
  142|  1.57M|}

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

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

mp_deint_active:
  204|     15|{
  205|     15|    struct deint_priv *p = f->priv;
  206|     15|    struct filter_opts *opts = p->opts->opts;
  207|     15|    return opts->deinterlace == 1 || (opts->deinterlace == -1 && p->interlaced_frame);
  ------------------
  |  Branch (207:12): [True: 0, False: 15]
  |  Branch (207:39): [True: 0, False: 15]
  |  Branch (207:66): [True: 0, False: 0]
  ------------------
  208|     15|}
mp_deint_create:
  211|  29.8k|{
  212|  29.8k|    struct mp_filter *f = mp_filter_create(parent, &deint_filter);
  213|  29.8k|    if (!f)
  ------------------
  |  Branch (213:9): [True: 0, False: 29.8k]
  ------------------
  214|      0|        return NULL;
  215|       |
  216|  29.8k|    struct deint_priv *p = f->priv;
  217|       |
  218|  29.8k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  219|  29.8k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  220|       |
  221|  29.8k|    p->opts = m_config_cache_alloc(f, f->global, &filter_conf);
  222|       |
  223|  29.8k|    return f;
  224|  29.8k|}
mp_autorotate_create:
  337|  29.8k|{
  338|  29.8k|    struct mp_filter *f = mp_filter_create(parent, &rotate_filter);
  339|  29.8k|    if (!f)
  ------------------
  |  Branch (339:9): [True: 0, False: 29.8k]
  ------------------
  340|      0|        return NULL;
  341|       |
  342|  29.8k|    struct rotate_priv *p = f->priv;
  343|  29.8k|    p->prev_rotate = -1;
  344|       |
  345|  29.8k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  346|  29.8k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  347|       |
  348|  29.8k|    return f;
  349|  29.8k|}
mp_autovflip_create:
  458|  29.8k|{
  459|  29.8k|    struct mp_filter *f = mp_filter_create(parent, &vflip_filter);
  460|  29.8k|    if (!f)
  ------------------
  |  Branch (460:9): [True: 0, False: 29.8k]
  ------------------
  461|      0|        return NULL;
  462|       |
  463|  29.8k|    struct vflip_priv *p = f->priv;
  464|  29.8k|    p->prev_vflip = -1;
  465|       |
  466|  29.8k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  467|  29.8k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  468|       |
  469|  29.8k|    return f;
  470|  29.8k|}
mp_autoaspeed_create:
  581|  16.7k|{
  582|  16.7k|    struct mp_filter *f = mp_filter_create(parent, &aspeed_filter);
  583|  16.7k|    if (!f)
  ------------------
  |  Branch (583:9): [True: 0, False: 16.7k]
  ------------------
  584|      0|        return NULL;
  585|       |
  586|  16.7k|    struct aspeed_priv *p = f->priv;
  587|  16.7k|    p->cur_speed = 1.0;
  588|  16.7k|    p->cur_speed_drop = 1.0;
  589|       |
  590|  16.7k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  591|  16.7k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  592|       |
  593|  16.7k|    return f;
  594|  16.7k|}
f_auto_filters.c:deint_destroy:
  176|  29.8k|{
  177|  29.8k|    struct deint_priv *p = f->priv;
  178|       |
  179|  29.8k|    mp_subfilter_reset(&p->sub);
  180|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  29.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  29.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  181|  29.8k|}
f_auto_filters.c:deint_process:
   30|  5.10M|{
   31|  5.10M|    struct deint_priv *p = f->priv;
   32|       |
   33|  5.10M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (33:9): [True: 2.57M, False: 2.52M]
  ------------------
   34|  2.57M|        return;
   35|       |
   36|  2.52M|    struct mp_frame frame = p->sub.frame;
   37|       |
   38|  2.52M|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (38:9): [True: 2.48M, False: 39.2k]
  ------------------
   39|  2.48M|        mp_subfilter_continue(&p->sub);
   40|  2.48M|        return;
   41|  2.48M|    }
   42|       |
   43|  39.2k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (43:9): [True: 0, False: 39.2k]
  ------------------
   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|  39.2k|    struct mp_image *img = frame.data;
   50|  39.2k|    p->interlaced_frame = img->fields & MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|  39.2k|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
   51|       |
   52|  39.2k|    m_config_cache_update(p->opts);
   53|  39.2k|    struct filter_opts *opts = p->opts->opts;
   54|       |
   55|       |    // Handle deinterlace=0 case by destroying any existing filter immediately.
   56|  39.2k|    if (!opts->deinterlace)
  ------------------
  |  Branch (56:9): [True: 31.9k, False: 7.22k]
  ------------------
   57|  31.9k|        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|  39.2k|    bool filter_needed = opts->deinterlace == 1 ||
  ------------------
  |  Branch (63:26): [True: 5.18k, False: 34.0k]
  ------------------
   64|  34.0k|                         (opts->deinterlace == -1 && (p->interlaced_frame || p->sub.filter));
  ------------------
  |  Branch (64:27): [True: 2.04k, False: 31.9k]
  |  Branch (64:55): [True: 0, False: 2.04k]
  |  Branch (64:78): [True: 41, False: 2.00k]
  ------------------
   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|  39.2k|    if (img->imgfmt != p->prev_imgfmt) {
  ------------------
  |  Branch (69:9): [True: 15.8k, False: 23.3k]
  ------------------
   70|  15.8k|        mp_subfilter_destroy(&p->sub);
   71|  15.8k|        p->prev_imgfmt = img->imgfmt;
   72|  23.3k|    } else if (p->sub.filter && !filter_needed) {
  ------------------
  |  Branch (72:16): [True: 3.93k, False: 19.4k]
  |  Branch (72:33): [True: 0, False: 3.93k]
  ------------------
   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|  39.2k|    if (!filter_needed || p->sub.filter) {
  ------------------
  |  Branch (79:9): [True: 33.9k, False: 5.22k]
  |  Branch (79:27): [True: 3.93k, False: 1.28k]
  ------------------
   80|  37.9k|        mp_subfilter_continue(&p->sub);
   81|  37.9k|        return;
   82|  37.9k|    }
   83|       |
   84|  1.28k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  1.28k|#define mp_assert assert
  ------------------
  |  Branch (84:5): [True: 1.28k, False: 0]
  ------------------
   85|       |
   86|  1.28k|    char *field_parity;
   87|  1.28k|    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: 1.28k]
  ------------------
   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: 1.28k]
  ------------------
   92|      0|        field_parity = "bff";
   93|      0|        break;
   94|  1.28k|    default:
  ------------------
  |  Branch (94:5): [True: 1.28k, False: 0]
  ------------------
   95|  1.28k|        field_parity = "auto";
   96|  1.28k|    }
   97|       |
   98|  1.28k|    bool has_filter = true;
   99|  1.28k|    if (img->imgfmt == IMGFMT_VDPAU) {
  ------------------
  |  Branch (99:9): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|    } else if (img->imgfmt == IMGFMT_D3D11) {
  ------------------
  |  Branch (105:16): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|    } else if (img->imgfmt == IMGFMT_CUDA) {
  ------------------
  |  Branch (111:16): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|    } else if (img->imgfmt == IMGFMT_VULKAN) {
  ------------------
  |  Branch (117:16): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|    } else if (img->imgfmt == IMGFMT_VAAPI) {
  ------------------
  |  Branch (123:16): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|    } else {
  130|  1.28k|        has_filter = false;
  131|  1.28k|    }
  132|       |
  133|  1.28k|    if (!p->sub.filter) {
  ------------------
  |  Branch (133:9): [True: 1.28k, False: 0]
  ------------------
  134|  1.28k|        if (has_filter)
  ------------------
  |  Branch (134:13): [True: 0, False: 1.28k]
  ------------------
  135|  1.28k|            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|  1.28k|        struct mp_filter *subf = mp_bidir_dummy_filter_create(f);
  138|  1.28k|        struct mp_filter *filters[2] = {0};
  139|       |
  140|  1.28k|        struct mp_autoconvert *ac = mp_autoconvert_create(subf);
  141|  1.28k|        if (ac) {
  ------------------
  |  Branch (141:13): [True: 1.28k, False: 0]
  ------------------
  142|  1.28k|            filters[0] = ac->f;
  143|       |            // We know vf_bwdif does not support hw inputs.
  144|  1.28k|            mp_autoconvert_add_all_sw_imgfmts(ac);
  145|       |
  146|  1.28k|            if (!mp_autoconvert_probe_input_video(ac, img)) {
  ------------------
  |  Branch (146:17): [True: 0, False: 1.28k]
  ------------------
  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|  1.28k|        }
  154|       |
  155|  1.28k|        char *args[] = {"mode", "send_field",
  156|  1.28k|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (156:34): [True: 1.28k, False: 0]
  ------------------
  157|  1.28k|                        "parity", field_parity, NULL};
  158|  1.28k|        filters[1] =
  159|  1.28k|            mp_create_user_filter(subf, MP_OUTPUT_CHAIN_VIDEO, "bwdif", args);
  160|       |
  161|  1.28k|        mp_chain_filters(subf->ppins[0], subf->ppins[1], filters, 2);
  162|  1.28k|        p->sub.filter = subf;
  163|  1.28k|    }
  164|       |
  165|  1.28k|    mp_subfilter_continue(&p->sub);
  166|  1.28k|}
f_auto_filters.c:deint_reset:
  169|  2.49M|{
  170|  2.49M|    struct deint_priv *p = f->priv;
  171|       |
  172|  2.49M|    mp_subfilter_reset(&p->sub);
  173|  2.49M|}
f_auto_filters.c:deint_command:
  184|  2.52M|{
  185|  2.52M|    struct deint_priv *p = f->priv;
  186|       |
  187|  2.52M|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (187:9): [True: 2.52M, False: 0]
  ------------------
  188|  2.52M|        cmd->is_active = !!p->sub.filter;
  189|  2.52M|        return true;
  190|  2.52M|    }
  191|      0|    return false;
  192|  2.52M|}
f_auto_filters.c:rotate_destroy:
  309|  29.8k|{
  310|  29.8k|    struct rotate_priv *p = f->priv;
  311|       |
  312|  29.8k|    mp_subfilter_reset(&p->sub);
  313|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  29.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  29.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  314|  29.8k|}
f_auto_filters.c:rotate_process:
  234|  5.08M|{
  235|  5.08M|    struct rotate_priv *p = f->priv;
  236|       |
  237|  5.08M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (237:9): [True: 2.55M, False: 2.52M]
  ------------------
  238|  2.55M|        return;
  239|       |
  240|  2.52M|    struct mp_frame frame = p->sub.frame;
  241|       |
  242|  2.52M|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (242:9): [True: 2.48M, False: 37.9k]
  ------------------
  243|  2.48M|        mp_subfilter_continue(&p->sub);
  244|  2.48M|        return;
  245|  2.48M|    }
  246|       |
  247|  37.9k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (247:9): [True: 0, False: 37.9k]
  ------------------
  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|  37.9k|    struct mp_image *img = frame.data;
  253|       |
  254|  37.9k|    if (img->params.rotate == p->prev_rotate &&
  ------------------
  |  Branch (254:9): [True: 22.0k, False: 15.8k]
  ------------------
  255|  22.0k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (255:9): [True: 22.0k, False: 0]
  ------------------
  256|  22.0k|    {
  257|  22.0k|        img->params.rotate = p->target_rotate;
  258|  22.0k|        mp_subfilter_continue(&p->sub);
  259|  22.0k|        return;
  260|  22.0k|    }
  261|       |
  262|  15.8k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (262:9): [True: 0, False: 15.8k]
  ------------------
  263|      0|        return;
  264|       |
  265|  15.8k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (265:5): [True: 15.8k, False: 0]
  ------------------
  266|       |
  267|  15.8k|    int rotate = p->prev_rotate = img->params.rotate;
  268|  15.8k|    p->target_rotate = rotate;
  269|  15.8k|    p->prev_imgfmt = img->imgfmt;
  270|       |
  271|  15.8k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  272|  15.8k|    if (rotate == 0 || (info && info->rotate90 && !(rotate % 90))) {
  ------------------
  |  Branch (272:9): [True: 15.8k, False: 0]
  |  Branch (272:25): [True: 0, False: 0]
  |  Branch (272:33): [True: 0, False: 0]
  |  Branch (272:51): [True: 0, False: 0]
  ------------------
  273|  15.8k|        mp_subfilter_continue(&p->sub);
  274|  15.8k|        return;
  275|  15.8k|    }
  276|       |
  277|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|        MP_ERR(f, "Video rotation with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  279|      0|        mp_subfilter_continue(&p->sub);
  280|      0|        return;
  281|      0|    }
  282|       |
  283|      0|    double angle = rotate / 360.0 * M_PI * 2;
  284|      0|    char *args[] = {"angle", mp_tprintf(30, "%f", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  285|      0|                    "ow", mp_tprintf(30, "rotw(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  286|      0|                    "oh", mp_tprintf(30, "roth(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  287|      0|                    NULL};
  288|      0|    p->sub.filter =
  289|      0|        mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "rotate", args);
  290|       |
  291|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|        MP_INFO(f, "Inserting rotation filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  293|      0|        p->target_rotate = 0;
  294|      0|    } else {
  295|      0|        MP_ERR(f, "could not create rotation filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  296|      0|    }
  297|       |
  298|      0|    mp_subfilter_continue(&p->sub);
  299|      0|}
f_auto_filters.c:rotate_reset:
  302|  2.49M|{
  303|  2.49M|    struct rotate_priv *p = f->priv;
  304|       |
  305|  2.49M|    mp_subfilter_reset(&p->sub);
  306|  2.49M|}
f_auto_filters.c:rotate_command:
  317|  2.52M|{
  318|  2.52M|    struct rotate_priv *p = f->priv;
  319|       |
  320|  2.52M|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (320:9): [True: 2.52M, False: 0]
  ------------------
  321|  2.52M|        cmd->is_active = !!p->sub.filter;
  322|  2.52M|        return true;
  323|  2.52M|    }
  324|      0|    return false;
  325|  2.52M|}
f_auto_filters.c:vflip_destroy:
  430|  29.8k|{
  431|  29.8k|    struct vflip_priv *p = f->priv;
  432|       |
  433|  29.8k|    mp_subfilter_reset(&p->sub);
  434|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  29.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  29.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  435|  29.8k|}
f_auto_filters.c:vflip_process:
  359|  5.08M|{
  360|  5.08M|    struct vflip_priv *p = f->priv;
  361|       |
  362|  5.08M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (362:9): [True: 2.55M, False: 2.52M]
  ------------------
  363|  2.55M|        return;
  364|       |
  365|  2.52M|    struct mp_frame frame = p->sub.frame;
  366|       |
  367|  2.52M|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (367:9): [True: 2.48M, False: 37.9k]
  ------------------
  368|  2.48M|        mp_subfilter_continue(&p->sub);
  369|  2.48M|        return;
  370|  2.48M|    }
  371|       |
  372|  37.9k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (372:9): [True: 0, False: 37.9k]
  ------------------
  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|  37.9k|    struct mp_image *img = frame.data;
  378|       |
  379|  37.9k|    if (img->params.vflip == p->prev_vflip &&
  ------------------
  |  Branch (379:9): [True: 22.0k, False: 15.8k]
  ------------------
  380|  22.0k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (380:9): [True: 22.0k, False: 0]
  ------------------
  381|  22.0k|    {
  382|  22.0k|        img->params.vflip = p->target_vflip;
  383|  22.0k|        mp_subfilter_continue(&p->sub);
  384|  22.0k|        return;
  385|  22.0k|    }
  386|       |
  387|  15.8k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (387:9): [True: 0, False: 15.8k]
  ------------------
  388|      0|        return;
  389|       |
  390|  15.8k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  15.8k|#define mp_assert assert
  ------------------
  |  Branch (390:5): [True: 15.8k, False: 0]
  ------------------
  391|       |
  392|  15.8k|    int vflip = p->prev_vflip = img->params.vflip;
  393|  15.8k|    p->target_vflip = vflip;
  394|  15.8k|    p->prev_imgfmt = img->imgfmt;
  395|       |
  396|  15.8k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  397|  15.8k|    if (!vflip || (info && info->vflip)) {
  ------------------
  |  Branch (397:9): [True: 15.8k, False: 0]
  |  Branch (397:20): [True: 0, False: 0]
  |  Branch (397:28): [True: 0, False: 0]
  ------------------
  398|  15.8k|        mp_subfilter_continue(&p->sub);
  399|  15.8k|        return;
  400|  15.8k|    }
  401|       |
  402|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (402:9): [True: 0, False: 0]
  ------------------
  403|      0|        MP_ERR(f, "Video vflip with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  404|      0|        mp_subfilter_continue(&p->sub);
  405|      0|        return;
  406|      0|    }
  407|       |
  408|      0|    char *args[] = {NULL};
  409|       |
  410|      0|    p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vflip", args);
  411|       |
  412|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (412:9): [True: 0, False: 0]
  ------------------
  413|      0|        MP_INFO(f, "Inserting vflip filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  414|      0|        p->target_vflip = 0;
  415|      0|    } else {
  416|      0|        MP_ERR(f, "could not create vflip filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  417|      0|    }
  418|       |
  419|      0|    mp_subfilter_continue(&p->sub);
  420|      0|}
f_auto_filters.c:vflip_reset:
  423|  2.49M|{
  424|  2.49M|    struct vflip_priv *p = f->priv;
  425|       |
  426|  2.49M|    mp_subfilter_reset(&p->sub);
  427|  2.49M|}
f_auto_filters.c:vflip_command:
  438|  2.52M|{
  439|  2.52M|    struct vflip_priv *p = f->priv;
  440|       |
  441|  2.52M|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (441:9): [True: 2.52M, False: 0]
  ------------------
  442|  2.52M|        cmd->is_active = !!p->sub.filter;
  443|  2.52M|        return true;
  444|  2.52M|    }
  445|      0|    return false;
  446|  2.52M|}
f_auto_filters.c:aspeed_destroy:
  564|  16.7k|{
  565|  16.7k|    struct aspeed_priv *p = f->priv;
  566|       |
  567|  16.7k|    mp_subfilter_reset(&p->sub);
  568|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  16.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  16.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 16.7k]
  |  |  ------------------
  ------------------
  569|  16.7k|}
f_auto_filters.c:aspeed_process:
  479|  8.20M|{
  480|  8.20M|    struct aspeed_priv *p = f->priv;
  481|       |
  482|  8.20M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (482:9): [True: 5.66M, False: 2.53M]
  ------------------
  483|  5.66M|        return;
  484|       |
  485|  2.53M|    if (!p->sub.filter)
  ------------------
  |  Branch (485:9): [True: 1.09M, False: 1.44M]
  ------------------
  486|  1.09M|        p->current_filter = 0;
  487|       |
  488|  2.53M|    double speed = p->cur_speed * p->cur_speed_drop;
  489|       |
  490|  2.53M|    int req_filter = 0;
  491|  2.53M|    if (fabs(speed - 1.0) >= 1e-8) {
  ------------------
  |  Branch (491:9): [True: 1.44M, False: 1.09M]
  ------------------
  492|  1.44M|        req_filter = p->cur_speed_drop == 1.0 ? 1 : 2;
  ------------------
  |  Branch (492:22): [True: 1.44M, False: 0]
  ------------------
  493|  1.44M|        if (p->sub.frame.type == MP_FRAME_AUDIO &&
  ------------------
  |  Branch (493:13): [True: 90.6k, False: 1.35M]
  ------------------
  494|  90.6k|            !af_fmt_is_pcm(mp_aframe_get_format(p->sub.frame.data)))
  ------------------
  |  Branch (494:13): [True: 0, False: 90.6k]
  ------------------
  495|      0|            req_filter = 2;
  496|  1.44M|    }
  497|       |
  498|  2.53M|    if (req_filter != p->current_filter) {
  ------------------
  |  Branch (498:9): [True: 2.20k, False: 2.53M]
  ------------------
  499|  2.20k|        if (p->sub.filter)
  ------------------
  |  Branch (499:13): [True: 11, False: 2.19k]
  ------------------
  500|  2.20k|            MP_VERBOSE(f, "removing audio speed filter\n");
  ------------------
  |  |   92|     11|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  501|  2.20k|        if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (501:13): [True: 11, False: 2.19k]
  ------------------
  502|     11|            return;
  503|       |
  504|  2.19k|        if (req_filter) {
  ------------------
  |  Branch (504:13): [True: 2.19k, False: 0]
  ------------------
  505|  2.19k|            if (req_filter == 1) {
  ------------------
  |  Branch (505:17): [True: 2.19k, False: 0]
  ------------------
  506|  2.19k|                MP_VERBOSE(f, "adding scaletempo2\n");
  ------------------
  |  |   92|  2.19k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.19k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  507|  2.19k|                p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_AUDIO,
  508|  2.19k|                                                      "scaletempo2", NULL);
  509|  2.19k|            } 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|  2.19k|            if (!p->sub.filter) {
  ------------------
  |  Branch (514:17): [True: 0, False: 2.19k]
  ------------------
  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|  2.19k|            p->current_filter = req_filter;
  520|  2.19k|        }
  521|  2.19k|    }
  522|       |
  523|  2.53M|    if (p->sub.filter) {
  ------------------
  |  Branch (523:9): [True: 1.44M, False: 1.09M]
  ------------------
  524|  1.44M|        struct mp_filter_command cmd = {
  525|  1.44M|            .type = MP_FILTER_COMMAND_SET_SPEED,
  526|  1.44M|            .speed = speed,
  527|  1.44M|        };
  528|  1.44M|        mp_filter_command(p->sub.filter, &cmd);
  529|  1.44M|    }
  530|       |
  531|  2.53M|    mp_subfilter_continue(&p->sub);
  532|  2.53M|}
f_auto_filters.c:aspeed_reset:
  557|  2.32M|{
  558|  2.32M|    struct aspeed_priv *p = f->priv;
  559|       |
  560|  2.32M|    mp_subfilter_reset(&p->sub);
  561|  2.32M|}
f_auto_filters.c:aspeed_command:
  535|  2.74M|{
  536|  2.74M|    struct aspeed_priv *p = f->priv;
  537|       |
  538|  2.74M|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED) {
  ------------------
  |  Branch (538:9): [True: 33.4k, False: 2.71M]
  ------------------
  539|  33.4k|        p->cur_speed = cmd->speed;
  540|  33.4k|        return true;
  541|  33.4k|    }
  542|       |
  543|  2.71M|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_DROP) {
  ------------------
  |  Branch (543:9): [True: 33.4k, False: 2.67M]
  ------------------
  544|  33.4k|        p->cur_speed_drop = cmd->speed;
  545|  33.4k|        return true;
  546|  33.4k|    }
  547|       |
  548|  2.67M|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (548:9): [True: 2.64M, False: 33.4k]
  ------------------
  549|  2.64M|        cmd->is_active = !!p->sub.filter;
  550|  2.64M|        return true;
  551|  2.64M|    }
  552|       |
  553|  33.4k|    return false;
  554|  2.67M|}

mp_autoconvert_clear:
   61|  93.3k|{
   62|  93.3k|    struct priv *p = c->f->priv;
   63|       |
   64|  93.3k|    p->num_imgfmts = 0;
   65|  93.3k|    p->imgparams_set = false;
   66|  93.3k|    p->num_afmts = 0;
   67|  93.3k|    p->num_srates = 0;
   68|  93.3k|    p->chmaps = (struct mp_chmap_sel){0};
   69|       |    p->force_update = true;
   70|  93.3k|}
mp_autoconvert_add_imgfmt:
   73|  43.0M|{
   74|  43.0M|    struct priv *p = c->f->priv;
   75|       |
   76|  43.0M|    MP_TARRAY_GROW(p, p->imgfmts, p->num_imgfmts);
  ------------------
  |  |   96|  43.0M|    do {                                            \
  |  |   97|  43.0M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  43.0M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  43.0M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  43.0M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 279k, False: 42.7M]
  |  |  ------------------
  |  |   99|  43.0M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   279k|    do {                                                        \
  |  |  |  |   89|   279k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   279k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   279k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   279k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   279k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   279k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   279k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 279k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  43.0M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 43.0M]
  |  |  ------------------
  ------------------
   77|  43.0M|    MP_TARRAY_GROW(p, p->subfmts, p->num_imgfmts);
  ------------------
  |  |   96|  43.0M|    do {                                            \
  |  |   97|  43.0M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  43.0M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  43.0M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  43.0M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 279k, False: 42.7M]
  |  |  ------------------
  |  |   99|  43.0M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   279k|    do {                                                        \
  |  |  |  |   89|   279k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   279k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   279k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   279k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   279k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   279k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   279k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 279k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  43.0M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 43.0M]
  |  |  ------------------
  ------------------
   78|       |
   79|  43.0M|    p->imgfmts[p->num_imgfmts] = imgfmt;
   80|  43.0M|    p->subfmts[p->num_imgfmts] = subfmt;
   81|       |
   82|  43.0M|    p->num_imgfmts += 1;
   83|       |    p->force_update = true;
   84|  43.0M|}
mp_autoconvert_add_all_sw_imgfmts:
  104|  1.28k|{
  105|   721k|    for (int n = IMGFMT_START; n < IMGFMT_END; n++) {
  ------------------
  |  Branch (105:32): [True: 719k, False: 1.28k]
  ------------------
  106|   719k|        if (!IMGFMT_IS_HWACCEL(n))
  ------------------
  |  |  329|   719k|#define IMGFMT_IS_HWACCEL(fmt) (!!(mp_imgfmt_get_desc(fmt).flags & MP_IMGFLAG_HWACCEL))
  |  |  ------------------
  |  |  |  |   70|   719k|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  |  |  ------------------
  |  |  |  |  |  |   65|   719k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (106:13): [True: 696k, False: 23.1k]
  ------------------
  107|   696k|            mp_autoconvert_add_imgfmt(c, n, 0);
  108|   719k|    }
  109|  1.28k|}
mp_autoconvert_add_afmt:
  112|  17.5k|{
  113|  17.5k|    struct priv *p = c->f->priv;
  114|       |
  115|  17.5k|    MP_TARRAY_APPEND(p, p->afmts, p->num_afmts, afmt);
  ------------------
  |  |  105|  17.5k|    do {                                            \
  |  |  106|  17.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  17.5k|    do {                                            \
  |  |  |  |   97|  17.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  17.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  17.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  17.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 15.8k, False: 1.67k]
  |  |  |  |  ------------------
  |  |  |  |   99|  17.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  15.8k|    do {                                                        \
  |  |  |  |  |  |   89|  15.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  15.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  15.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  15.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  15.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  15.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  15.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 15.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  17.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 17.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  17.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  17.5k|        (idxvar)++;                                 \
  |  |  109|  17.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 17.5k]
  |  |  ------------------
  ------------------
  116|       |    p->force_update = true;
  117|  17.5k|}
mp_autoconvert_add_chmap:
  120|  16.4k|{
  121|  16.4k|    struct priv *p = c->f->priv;
  122|       |
  123|  16.4k|    mp_chmap_sel_add_map(&p->chmaps, chmap);
  124|       |    p->force_update = true;
  125|  16.4k|}
mp_autoconvert_add_srate:
  128|  15.5k|{
  129|  15.5k|    struct priv *p = c->f->priv;
  130|       |
  131|  15.5k|    MP_TARRAY_APPEND(p, p->srates, p->num_srates, rate);
  ------------------
  |  |  105|  15.5k|    do {                                            \
  |  |  106|  15.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  15.5k|    do {                                            \
  |  |  |  |   97|  15.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  15.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  15.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  15.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 13.8k, False: 1.67k]
  |  |  |  |  ------------------
  |  |  |  |   99|  15.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  13.8k|    do {                                                        \
  |  |  |  |  |  |   89|  13.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  13.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  13.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  13.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  13.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  13.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  13.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 13.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  15.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 15.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  15.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  15.5k|        (idxvar)++;                                 \
  |  |  109|  15.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15.5k]
  |  |  ------------------
  ------------------
  132|       |    // Some other API we call expects a 0-terminated sample rates array.
  133|  15.5k|    MP_TARRAY_GROW(p, p->srates, p->num_srates);
  ------------------
  |  |   96|  15.5k|    do {                                            \
  |  |   97|  15.5k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  15.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  15.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  15.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 15.5k]
  |  |  ------------------
  |  |   99|  15.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|  15.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 15.5k]
  |  |  ------------------
  ------------------
  134|  15.5k|    p->srates[p->num_srates] = 0;
  135|       |    p->force_update = true;
  136|  15.5k|}
mp_autoconvert_probe_input_video:
  342|  1.28k|{
  343|  1.28k|    struct mp_filter *conv = NULL;
  344|  1.28k|    bool res = build_image_converter(c, mp_null_log, img, &conv);
  345|  1.28k|    talloc_free(conv);
  ------------------
  |  |   47|  1.28k|#define talloc_free                     ta_free
  ------------------
  346|  1.28k|    return res;
  347|  1.28k|}
mp_autoconvert_format_change_continue:
  507|  15.3k|{
  508|  15.3k|    struct priv *p = c->f->priv;
  509|       |
  510|  15.3k|    if (p->format_change_blocked) {
  ------------------
  |  Branch (510:9): [True: 15.3k, False: 0]
  ------------------
  511|  15.3k|        p->format_change_cont = true;
  512|       |        p->format_change_blocked = false;
  513|  15.3k|        mp_filter_wakeup(c->f);
  514|  15.3k|    }
  515|  15.3k|}
mp_autoconvert_create:
  566|  55.7k|{
  567|  55.7k|    struct mp_filter *f = mp_filter_create(parent, &autoconvert_filter);
  568|  55.7k|    if (!f)
  ------------------
  |  Branch (568:9): [True: 0, False: 55.7k]
  ------------------
  569|      0|        return NULL;
  570|       |
  571|  55.7k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  572|  55.7k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  573|       |
  574|  55.7k|    struct priv *p = f->priv;
  575|  55.7k|    p->public.f = f;
  576|  55.7k|    p->log = f->log;
  577|  55.7k|    p->audio_speed = 1.0;
  578|  55.7k|    p->sub.in = f->ppins[0];
  579|  55.7k|    p->sub.out = f->ppins[1];
  580|       |
  581|  55.7k|    return &p->public;
  582|  55.7k|}
f_autoconvert.c:build_image_converter:
  141|  18.6k|{
  142|  18.6k|    struct mp_filter *f = c->f;
  143|  18.6k|    struct priv *p = f->priv;
  144|       |
  145|  18.6k|    *f_out = NULL;
  146|       |
  147|  18.6k|    if (!p->num_imgfmts)
  ------------------
  |  Branch (147:9): [True: 131, False: 18.4k]
  ------------------
  148|    131|        return true;
  149|       |
  150|  36.9k|    for (int n = 0; n < p->num_imgfmts; n++) {
  ------------------
  |  Branch (150:21): [True: 36.9k, False: 0]
  ------------------
  151|  36.9k|        bool samefmt = img->params.imgfmt == p->imgfmts[n];
  152|  36.9k|        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|  36.9k|        if (samefmt && samesubffmt) {
  ------------------
  |  Branch (158:13): [True: 18.4k, False: 18.4k]
  |  Branch (158:24): [True: 18.4k, False: 0]
  ------------------
  159|  18.4k|            if (p->imgparams_set) {
  ------------------
  |  Branch (159:17): [True: 0, False: 18.4k]
  ------------------
  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|  18.4k|            return true;
  164|  18.4k|        }
  165|  36.9k|    }
  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|  55.7k|{
  550|  55.7k|    struct priv *p = f->priv;
  551|       |
  552|  55.7k|    mp_subfilter_reset(&p->sub);
  553|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  55.7k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  55.7k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 55.7k]
  |  |  ------------------
  ------------------
  554|  55.7k|}
f_autoconvert.c:autoconvert_process:
  487|  17.7M|{
  488|  17.7M|    struct priv *p = f->priv;
  489|       |
  490|  17.7M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (490:9): [True: 10.5M, False: 7.24M]
  ------------------
  491|  10.5M|        return;
  492|       |
  493|  7.24M|    if (p->sub.frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (493:9): [True: 42.5k, False: 7.20M]
  ------------------
  494|  42.5k|        handle_video_frame(f);
  495|  42.5k|        return;
  496|  42.5k|    }
  497|       |
  498|  7.20M|    if (p->sub.frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (498:9): [True: 478k, False: 6.72M]
  ------------------
  499|   478k|        handle_audio_frame(f);
  500|   478k|        return;
  501|   478k|    }
  502|       |
  503|  6.72M|    mp_subfilter_continue(&p->sub);
  504|  6.72M|}
f_autoconvert.c:handle_video_frame:
  350|  42.5k|{
  351|  42.5k|    struct priv *p = f->priv;
  352|       |
  353|  42.5k|    struct mp_image *img = p->sub.frame.data;
  354|       |
  355|  42.5k|    if (p->force_update)
  ------------------
  |  Branch (355:9): [True: 17.2k, False: 25.3k]
  ------------------
  356|  17.2k|        p->in_imgfmt = p->in_subfmt = 0;
  357|       |
  358|  42.5k|    if (img->imgfmt == p->in_imgfmt && img->params.hw_subfmt == p->in_subfmt) {
  ------------------
  |  Branch (358:9): [True: 25.2k, False: 17.3k]
  |  Branch (358:40): [True: 25.2k, False: 0]
  ------------------
  359|  25.2k|        mp_subfilter_continue(&p->sub);
  360|  25.2k|        return;
  361|  25.2k|    }
  362|       |
  363|  17.3k|    if (!mp_subfilter_drain_destroy(&p->sub)) {
  ------------------
  |  Branch (363:9): [True: 0, False: 17.3k]
  ------------------
  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|  17.3k|    p->in_imgfmt = img->params.imgfmt;
  369|  17.3k|    p->in_subfmt = img->params.hw_subfmt;
  370|  17.3k|    p->force_update = false;
  371|       |
  372|  17.3k|    struct mp_filter *conv = NULL;
  373|  17.3k|    if (build_image_converter(&p->public, p->log, img, &conv)) {
  ------------------
  |  Branch (373:9): [True: 17.3k, False: 0]
  ------------------
  374|  17.3k|        p->sub.filter = conv;
  375|  17.3k|        mp_subfilter_continue(&p->sub);
  376|  17.3k|    } else {
  377|      0|        mp_filter_internal_mark_failed(f);
  378|      0|    }
  379|  17.3k|}
f_autoconvert.c:handle_audio_frame:
  382|   478k|{
  383|   478k|    struct priv *p = f->priv;
  384|       |
  385|   478k|    struct mp_aframe *aframe = p->sub.frame.data;
  386|       |
  387|   478k|    int afmt = mp_aframe_get_format(aframe);
  388|   478k|    int srate = mp_aframe_get_rate(aframe);
  389|   478k|    struct mp_chmap chmap = {0};
  390|   478k|    mp_aframe_get_chmap(aframe, &chmap);
  391|       |
  392|   478k|    if (p->resampling_forced && !af_fmt_is_pcm(afmt)) {
  ------------------
  |  Branch (392:9): [True: 161k, False: 317k]
  |  Branch (392:33): [True: 0, False: 161k]
  ------------------
  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|   478k|    bool format_change = afmt != p->in_afmt ||
  ------------------
  |  Branch (397:26): [True: 31.8k, False: 446k]
  ------------------
  398|   446k|                         srate != p->in_srate ||
  ------------------
  |  Branch (398:26): [True: 195, False: 446k]
  ------------------
  399|   446k|                         !mp_chmap_equals(&chmap, &p->in_chmap) ||
  ------------------
  |  Branch (399:26): [True: 343, False: 446k]
  ------------------
  400|   446k|                         p->force_update;
  ------------------
  |  Branch (400:26): [True: 2.39k, False: 443k]
  ------------------
  401|       |
  402|   478k|    if (!format_change && (!p->resampling_forced || p->sub.filter))
  ------------------
  |  Branch (402:9): [True: 443k, False: 34.7k]
  |  Branch (402:28): [True: 284k, False: 159k]
  |  Branch (402:53): [True: 159k, False: 1]
  ------------------
  403|   443k|        goto cont;
  404|       |
  405|  34.7k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (405:9): [True: 277, False: 34.5k]
  ------------------
  406|    277|        return;
  407|       |
  408|  34.5k|    if (format_change && p->public.on_audio_format_change) {
  ------------------
  |  Branch (408:9): [True: 34.5k, False: 1]
  |  Branch (408:26): [True: 31.0k, False: 3.49k]
  ------------------
  409|  31.0k|        if (p->format_change_blocked)
  ------------------
  |  Branch (409:13): [True: 0, False: 31.0k]
  ------------------
  410|      0|            return;
  411|       |
  412|  31.0k|        if (!p->format_change_cont) {
  ------------------
  |  Branch (412:13): [True: 15.7k, False: 15.2k]
  ------------------
  413|  15.7k|            p->format_change_blocked = true;
  414|  15.7k|            p->public.
  415|  15.7k|                on_audio_format_change(p->public.on_audio_format_change_opaque);
  416|  15.7k|            return;
  417|  15.7k|        }
  418|  15.2k|        p->format_change_cont = false;
  419|  15.2k|    }
  420|       |
  421|  18.7k|    p->in_afmt = afmt;
  422|  18.7k|    p->in_srate = srate;
  423|  18.7k|    p->in_chmap = chmap;
  424|  18.7k|    p->force_update = false;
  425|       |
  426|  18.7k|    int out_afmt = 0;
  427|  18.7k|    int best_score = 0;
  428|  36.0k|    for (int n = 0; n < p->num_afmts; n++) {
  ------------------
  |  Branch (428:21): [True: 17.2k, False: 18.7k]
  ------------------
  429|  17.2k|        int score = af_format_conversion_score(p->afmts[n], afmt);
  430|  17.2k|        if (!out_afmt || score > best_score) {
  ------------------
  |  Branch (430:13): [True: 17.2k, False: 0]
  |  Branch (430:26): [True: 0, False: 0]
  ------------------
  431|  17.2k|            best_score = score;
  432|  17.2k|            out_afmt = p->afmts[n];
  433|  17.2k|        }
  434|  17.2k|    }
  435|  18.7k|    if (!out_afmt)
  ------------------
  |  Branch (435:9): [True: 1.50k, False: 17.2k]
  ------------------
  436|  1.50k|        out_afmt = afmt;
  437|       |
  438|       |    // Raw DSD can only be converted to PCM, not resampled.
  439|  18.7k|    if (p->resampling_forced && out_afmt == AF_FORMAT_DSD) {
  ------------------
  |  Branch (439:9): [True: 869, False: 17.8k]
  |  Branch (439:33): [True: 0, False: 869]
  ------------------
  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|  18.7k|    int out_srate = af_select_best_samplerate(srate, p->srates);
  446|  18.7k|    if (out_srate <= 0)
  ------------------
  |  Branch (446:9): [True: 3.40k, False: 15.3k]
  ------------------
  447|  3.40k|        out_srate = p->num_srates ? p->srates[0] : srate;
  ------------------
  |  Branch (447:21): [True: 0, False: 3.40k]
  ------------------
  448|       |
  449|  18.7k|    struct mp_chmap out_chmap = chmap;
  450|  18.7k|    if (p->chmaps.num_chmaps) {
  ------------------
  |  Branch (450:9): [True: 15.8k, False: 2.94k]
  ------------------
  451|  15.8k|        if (!mp_chmap_sel_adjust(&p->chmaps, &out_chmap))
  ------------------
  |  Branch (451:13): [True: 414, False: 15.4k]
  ------------------
  452|    414|            out_chmap = p->chmaps.chmaps[0]; // violently force fallback
  453|  15.8k|    }
  454|       |
  455|  18.7k|    if (out_afmt == p->in_afmt && out_srate == p->in_srate &&
  ------------------
  |  Branch (455:9): [True: 16.5k, False: 2.20k]
  |  Branch (455:35): [True: 16.4k, False: 93]
  ------------------
  456|  16.4k|        mp_chmap_equals(&out_chmap, &p->in_chmap) && !p->resampling_forced)
  ------------------
  |  Branch (456:9): [True: 15.9k, False: 550]
  |  Branch (456:54): [True: 15.2k, False: 707]
  ------------------
  457|  15.2k|    {
  458|  15.2k|        goto cont;
  459|  15.2k|    }
  460|       |
  461|  3.55k|    MP_VERBOSE(p, "inserting resampler\n");
  ------------------
  |  |   92|  3.55k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.55k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  462|       |
  463|  3.55k|    struct mp_swresample *s = mp_swresample_create(f, NULL);
  464|  3.55k|    if (!s)
  ------------------
  |  Branch (464:9): [True: 0, False: 3.55k]
  ------------------
  465|      0|        abort();
  466|       |
  467|  3.55k|    s->out_format = out_afmt;
  468|  3.55k|    s->out_rate = out_srate;
  469|  3.55k|    s->out_channels = out_chmap;
  470|       |
  471|  3.55k|    p->sub.filter = s->f;
  472|       |
  473|   462k|cont:
  474|       |
  475|   462k|    if (p->sub.filter) {
  ------------------
  |  Branch (475:9): [True: 263k, False: 198k]
  ------------------
  476|   263k|        struct mp_filter_command cmd = {
  477|   263k|            .type = MP_FILTER_COMMAND_SET_SPEED_RESAMPLE,
  478|   263k|            .speed = p->audio_speed,
  479|   263k|        };
  480|   263k|        mp_filter_command(p->sub.filter, &cmd);
  481|   263k|    }
  482|       |
  483|   462k|    mp_subfilter_continue(&p->sub);
  484|   462k|}
f_autoconvert.c:autoconvert_reset:
  539|  6.74M|{
  540|  6.74M|    struct priv *p = f->priv;
  541|       |
  542|  6.74M|    mp_subfilter_reset(&p->sub);
  543|       |
  544|  6.74M|    p->format_change_cont = false;
  545|       |    p->format_change_blocked = false;
  546|  6.74M|}
f_autoconvert.c:autoconvert_command:
  518|  5.27M|{
  519|  5.27M|    struct priv *p = f->priv;
  520|       |
  521|  5.27M|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_RESAMPLE) {
  ------------------
  |  Branch (521:9): [True: 33.4k, False: 5.24M]
  ------------------
  522|  33.4k|        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|  33.4k|        if (p->audio_speed != 1.0)
  ------------------
  |  Branch (525:13): [True: 2.88k, False: 30.5k]
  ------------------
  526|  2.88k|            p->resampling_forced = true;
  527|  33.4k|        return true;
  528|  33.4k|    }
  529|       |
  530|  5.24M|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (530:9): [True: 5.17M, False: 66.8k]
  ------------------
  531|  5.17M|        cmd->is_active = !!p->sub.filter;
  532|  5.17M|        return true;
  533|  5.17M|    }
  534|       |
  535|  66.8k|    return false;
  536|  5.24M|}

mp_decoder_wrapper_control:
  363|  2.82M|{
  364|  2.82M|    struct priv *p = d->f->priv;
  365|  2.82M|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  2.82M|#define CONTROL_UNKNOWN -1
  ------------------
  366|  2.82M|    if (p->is_group) {
  ------------------
  |  Branch (366:9): [True: 0, False: 2.82M]
  ------------------
  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|  2.82M|    thread_lock(p);
  379|  2.82M|    if (cmd == VDCTRL_GET_HWDEC) {
  ------------------
  |  Branch (379:9): [True: 117, False: 2.82M]
  ------------------
  380|    117|        res = update_cached_values(p);
  381|    117|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|    117|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  382|    117|        *(char **)arg = p->cur_hwdec;
  383|    117|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|    117|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  384|  2.82M|    } else {
  385|  2.82M|        if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (385:13): [True: 2.82M, False: 0]
  |  Branch (385:27): [True: 2.82M, False: 0]
  ------------------
  386|  2.82M|            res = p->decoder->control(p->decoder->f, cmd, arg);
  387|  2.82M|        update_cached_values(p);
  388|  2.82M|    }
  389|  2.82M|    thread_unlock(p);
  390|  2.82M|    return res;
  391|  2.82M|}
mp_decoder_wrapper_reinit:
  532|  46.5k|{
  533|  46.5k|    struct priv *p = d->f->priv;
  534|  46.5k|    if (p->is_group) {
  ------------------
  |  Branch (534:9): [True: 0, False: 46.5k]
  ------------------
  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|  46.5k|    thread_lock(p);
  542|       |    bool res = reinit_decoder(p);
  543|  46.5k|    thread_unlock(p);
  544|  46.5k|    return res;
  545|  46.5k|}
mp_decoder_wrapper_get_frames_dropped:
  569|  9.27k|{
  570|  9.27k|    struct priv *p = d->f->priv;
  571|  9.27k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  9.27k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  572|  9.27k|    int res = p->dropped_frames;
  573|  9.27k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  9.27k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  574|  9.27k|    return res;
  575|  9.27k|}
mp_decoder_wrapper_get_container_fps:
  578|  29.8k|{
  579|  29.8k|    struct priv *p = d->f->priv;
  580|  29.8k|    thread_lock(p);
  581|  29.8k|    double res = p->fps;
  582|  29.8k|    thread_unlock(p);
  583|  29.8k|    return res;
  584|  29.8k|}
mp_decoder_wrapper_set_spdif_flag:
  587|  16.7k|{
  588|  16.7k|    struct priv *p = d->f->priv;
  589|  16.7k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  16.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  590|  16.7k|    p->try_spdif = spdif;
  591|  16.7k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  16.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  592|  16.7k|}
mp_decoder_wrapper_get_pts_reset:
  603|  9.69M|{
  604|  9.69M|    struct priv *p = d->f->priv;
  605|  9.69M|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  9.69M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  606|  9.69M|    bool res = p->pts_reset;
  607|  9.69M|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  9.69M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  608|  9.69M|    return res;
  609|  9.69M|}
mp_decoder_wrapper_set_play_dir:
  612|  9.70M|{
  613|  9.70M|    struct priv *p = d->f->priv;
  614|  9.70M|    if (p->is_group) {
  ------------------
  |  Branch (614:9): [True: 0, False: 9.70M]
  ------------------
  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|  9.70M|    thread_lock(p);
  621|  9.70M|    p->play_dir = dir;
  622|  9.70M|    thread_unlock(p);
  623|  9.70M|}
mp_decoder_wrapper_reset_params:
  733|    380|{
  734|    380|    struct priv *p = d->f->priv;
  735|    380|    p->last_format = (struct mp_image_params){0};
  736|    380|}
mp_decoder_wrapper_get_video_dec_params:
  740|      1|{
  741|      1|    struct priv *p = d->f->priv;
  742|      1|    *m = p->dec_format;
  743|      1|}
mp_decoder_wrapper_set_start_pts:
  946|  4.79M|{
  947|  4.79M|    struct priv *p = d->f->priv;
  948|  4.79M|    if (p->is_group) {
  ------------------
  |  Branch (948:9): [True: 0, False: 4.79M]
  ------------------
  949|      0|        for (int i = 0; i < p->num_children; i++)
  ------------------
  |  Branch (949:25): [True: 0, False: 0]
  ------------------
  950|      0|            mp_decoder_wrapper_set_start_pts(p->children[i], pts);
  951|      0|        return;
  952|      0|    }
  953|  4.79M|    p->start_pts = pts;
  954|  4.79M|}
mp_decoder_wrapper_create:
 1378|  46.5k|{
 1379|  46.5k|    struct mp_filter *public_f = mp_filter_create(parent, &decode_wrapper_filter);
 1380|  46.5k|    if (!public_f)
  ------------------
  |  Branch (1380:9): [True: 0, False: 46.5k]
  ------------------
 1381|      0|        return NULL;
 1382|       |
 1383|  46.5k|    struct priv *p = public_f->priv;
 1384|  46.5k|    p->public.f = public_f;
 1385|       |
 1386|  46.5k|    mp_mutex_init(&p->cache_lock);
 1387|  46.5k|    p->opt_cache = m_config_cache_alloc(p, public_f->global, &dec_wrapper_conf);
 1388|  46.5k|    p->opts = p->opt_cache->opts;
 1389|  46.5k|    p->header = src;
 1390|  46.5k|    p->codec = p->header->codec;
 1391|  46.5k|    p->play_dir = 1;
 1392|  46.5k|    mp_filter_add_pin(public_f, MP_PIN_OUT, "out");
 1393|       |
 1394|  46.5k|    if (src->group && src->group->lavfi_graph) {
  ------------------
  |  Branch (1394:9): [True: 0, False: 46.5k]
  |  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|  46.5k|    if (p->header->type == STREAM_VIDEO) {
  ------------------
  |  Branch (1404:9): [True: 29.8k, False: 16.7k]
  ------------------
 1405|  29.8k|        p->log = mp_log_new(p, parent->global->log, "!vd");
 1406|       |
 1407|  29.8k|        p->fps = src->codec->fps;
 1408|       |
 1409|  29.8k|        MP_VERBOSE(p, "Container reported FPS: %f\n", p->fps);
  ------------------
  |  |   92|  29.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  29.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1410|       |
 1411|  29.8k|        if (p->opts->fps_override) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 29.8k]
  ------------------
 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|  29.8k|        p->queue_opts = p->opts->vdec_queue_opts;
 1418|  29.8k|    } else if (p->header->type == STREAM_AUDIO) {
  ------------------
  |  Branch (1418:16): [True: 16.7k, False: 0]
  ------------------
 1419|  16.7k|        p->log = mp_log_new(p, parent->global->log, "!ad");
 1420|  16.7k|        p->queue_opts = p->opts->adec_queue_opts;
 1421|  16.7k|    } else {
 1422|      0|        goto error;
 1423|      0|    }
 1424|       |
 1425|  46.5k|    if (p->queue_opts && p->queue_opts->use_queue) {
  ------------------
  |  Branch (1425:9): [True: 46.5k, False: 0]
  |  Branch (1425:26): [True: 0, False: 46.5k]
  ------------------
 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|  46.5k|    p->decf = mp_filter_create(p->dec_root_filter ? p->dec_root_filter : public_f,
  ------------------
  |  Branch (1444:32): [True: 0, False: 46.5k]
  ------------------
 1445|  46.5k|                               &decf_filter);
 1446|  46.5k|    if (!p->decf)
  ------------------
  |  Branch (1446:9): [True: 0, False: 46.5k]
  ------------------
 1447|      0|        goto error;
 1448|  46.5k|    p->decf->priv = p;
 1449|  46.5k|    p->decf->log = public_f->log = p->log;
 1450|  46.5k|    mp_filter_add_pin(p->decf, MP_PIN_OUT, "out");
 1451|       |
 1452|  46.5k|    struct mp_filter *demux = mp_demux_in_create(p->decf, p->header);
 1453|  46.5k|    if (!demux)
  ------------------
  |  Branch (1453:9): [True: 0, False: 46.5k]
  ------------------
 1454|      0|        goto error;
 1455|  46.5k|    p->demux = demux->pins[0];
 1456|       |
 1457|  46.5k|    decf_reset(p->decf);
 1458|       |
 1459|  46.5k|    struct mp_pin *out_pin;
 1460|  46.5k|    if (p->queue) {
  ------------------
  |  Branch (1460:9): [True: 0, False: 46.5k]
  ------------------
 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|  46.5k|    } else {
 1474|  46.5k|        out_pin = p->decf->pins[0];
 1475|  46.5k|    }
 1476|       |
 1477|  46.5k|    mp_pin_connect(public_f->ppins[0], out_pin);
 1478|       |
 1479|  46.5k|    public_f_reset(public_f);
 1480|       |
 1481|  46.5k|    return &p->public;
 1482|      0|error:
 1483|      0|    talloc_free(public_f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1484|       |    return NULL;
 1485|  46.5k|}
lavc_process:
 1490|  10.4M|{
 1491|  10.4M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (1491:9): [True: 39.7k, False: 10.3M]
  ------------------
 1492|  39.7k|        return;
 1493|       |
 1494|  10.3M|    struct mp_frame frame = {0};
 1495|  10.3M|    int ret_recv = receive(f, &frame);
 1496|  10.3M|    if (frame.type) {
  ------------------
  |  Branch (1496:9): [True: 261k, False: 10.1M]
  ------------------
 1497|   261k|        state->eof_returned = false;
 1498|   261k|        mp_pin_in_write(f->ppins[1], frame);
 1499|  10.1M|    } else if (ret_recv == AVERROR_EOF) {
  ------------------
  |  Branch (1499:16): [True: 2.97k, False: 10.1M]
  ------------------
 1500|  2.97k|        if (!state->eof_returned)
  ------------------
  |  Branch (1500:13): [True: 2.97k, False: 0]
  ------------------
 1501|  2.97k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  2.97k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  2.97k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1502|  2.97k|        state->eof_returned = true;
 1503|  2.97k|        state->packets_sent = false;
 1504|  10.1M|    } else if (ret_recv == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1504:16): [True: 10.1M, False: 0]
  ------------------
 1505|       |        // Need to feed a packet.
 1506|  10.1M|        frame = mp_pin_out_read(f->ppins[0]);
 1507|  10.1M|        struct demux_packet *pkt = NULL;
 1508|  10.1M|        if (frame.type == MP_FRAME_PACKET) {
  ------------------
  |  Branch (1508:13): [True: 261k, False: 9.87M]
  ------------------
 1509|   261k|            pkt = frame.data;
 1510|  9.87M|        } else if (frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1510:20): [True: 5.07M, False: 4.80M]
  ------------------
 1511|  5.07M|            if (frame.type) {
  ------------------
  |  Branch (1511:17): [True: 0, False: 5.07M]
  ------------------
 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|  5.07M|            return;
 1517|  5.07M|        } else if (!state->packets_sent) {
  ------------------
  |  Branch (1517:20): [True: 4.79M, False: 2.97k]
  ------------------
 1518|       |            // EOF only; just return it, without requiring send/receive to
 1519|       |            // pass it through properly.
 1520|  4.79M|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  4.79M|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  4.79M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1521|  4.79M|            return;
 1522|  4.79M|        }
 1523|   264k|        int ret_send = send(f, pkt);
 1524|   264k|        if (ret_send == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1524:13): [True: 0, False: 264k]
  ------------------
 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|   264k|        state->packets_sent = true;
 1532|   264k|        demux_packet_pool_push(f->packet_pool, pkt);
 1533|   264k|        mp_filter_internal_mark_progress(f);
 1534|   264k|    } else {
 1535|       |        // Decoding error, or hwdec fallback recovery. Just try again.
 1536|      0|        mp_filter_internal_mark_progress(f);
 1537|      0|    }
 1538|  10.3M|}
f_decoder_wrapper.c:thread_lock:
  292|  12.6M|{
  293|  12.6M|    if (p->dec_dispatch)
  ------------------
  |  Branch (293:9): [True: 0, False: 12.6M]
  ------------------
  294|      0|        mp_dispatch_lock(p->dec_dispatch);
  295|       |
  296|  12.6M|    mp_assert(!p->dec_thread_lock);
  ------------------
  |  |   41|  12.6M|#define mp_assert assert
  ------------------
  |  Branch (296:5): [True: 12.6M, False: 0]
  ------------------
  297|  12.6M|    p->dec_thread_lock = true;
  298|  12.6M|}
f_decoder_wrapper.c:update_cached_values:
  275|  2.87M|{
  276|  2.87M|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  2.87M|#define CONTROL_UNKNOWN -1
  ------------------
  277|  2.87M|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  2.87M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  278|       |
  279|  2.87M|    p->cur_hwdec = NULL;
  280|  2.87M|    if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (280:9): [True: 2.87M, False: 0]
  |  Branch (280:23): [True: 2.85M, False: 16.7k]
  ------------------
  281|  2.85M|        res = p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
  282|       |
  283|  2.87M|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  2.87M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  284|  2.87M|    return res;
  285|  2.87M|}
f_decoder_wrapper.c:thread_unlock:
  302|  12.6M|{
  303|  12.6M|    mp_assert(p->dec_thread_lock);
  ------------------
  |  |   41|  12.6M|#define mp_assert assert
  ------------------
  |  Branch (303:5): [True: 12.6M, False: 0]
  ------------------
  304|  12.6M|    p->dec_thread_lock = false;
  305|       |
  306|  12.6M|    if (p->dec_dispatch)
  ------------------
  |  Branch (306:9): [True: 0, False: 12.6M]
  ------------------
  307|      0|        mp_dispatch_unlock(p->dec_dispatch);
  308|  12.6M|}
f_decoder_wrapper.c:reinit_decoder:
  425|  46.5k|{
  426|  46.5k|    if (p->decoder)
  ------------------
  |  Branch (426:9): [True: 0, False: 46.5k]
  ------------------
  427|      0|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  428|  46.5k|    p->decoder = NULL;
  429|       |
  430|  46.5k|    reset_decoder(p);
  431|  46.5k|    p->has_broken_packet_pts = -10; // needs 10 packets to reach decision
  432|       |
  433|  46.5k|    const struct mp_decoder_fns *driver = NULL;
  434|  46.5k|    struct mp_decoder_list *list = NULL;
  435|  46.5k|    char *user_list = NULL;
  436|  46.5k|    char *fallback = NULL;
  437|       |
  438|  46.5k|    if (p->codec->type == STREAM_VIDEO) {
  ------------------
  |  Branch (438:9): [True: 29.8k, False: 16.7k]
  ------------------
  439|  29.8k|        driver = &vd_lavc;
  440|  29.8k|        user_list = p->opts->video_decoders;
  441|  29.8k|        fallback = "h264";
  442|  29.8k|    } else if (p->codec->type == STREAM_AUDIO) {
  ------------------
  |  Branch (442:16): [True: 16.7k, False: 0]
  ------------------
  443|  16.7k|        driver = &ad_lavc;
  444|  16.7k|        user_list = p->opts->audio_decoders;
  445|  16.7k|        fallback = "aac";
  446|       |
  447|  16.7k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  16.7k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  448|  16.7k|        bool try_spdif = p->try_spdif;
  449|  16.7k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  16.7k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  450|       |
  451|  16.7k|        if (try_spdif && p->codec->codec) {
  ------------------
  |  Branch (451:13): [True: 16.7k, False: 0]
  |  Branch (451:26): [True: 16.7k, False: 0]
  ------------------
  452|  16.7k|            struct mp_decoder_list *spdif =
  453|  16.7k|                select_spdif_codec(p->codec->codec, p->opts->audio_spdif);
  454|  16.7k|            if (spdif->num_entries) {
  ------------------
  |  Branch (454:17): [True: 0, False: 16.7k]
  ------------------
  455|      0|                driver = &ad_spdif;
  456|      0|                list = spdif;
  457|  16.7k|            } else {
  458|  16.7k|                talloc_free(spdif);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  459|  16.7k|                struct mp_decoder_list *dsd =
  460|  16.7k|                    select_dsd_codec(p->codec->codec, p->opts->audio_spdif);
  461|  16.7k|                if (dsd->num_entries) {
  ------------------
  |  Branch (461:21): [True: 0, False: 16.7k]
  ------------------
  462|      0|                    driver = &ad_dsd;
  463|      0|                    list = dsd;
  464|  16.7k|                } else {
  465|  16.7k|                    talloc_free(dsd);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  466|  16.7k|                }
  467|  16.7k|            }
  468|  16.7k|        }
  469|  16.7k|    }
  470|       |
  471|  46.5k|    if (!driver)
  ------------------
  |  Branch (471:9): [True: 0, False: 46.5k]
  ------------------
  472|      0|        return false;
  473|       |
  474|  46.5k|    if (!list) {
  ------------------
  |  Branch (474:9): [True: 46.5k, False: 0]
  ------------------
  475|  46.5k|        struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  46.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  46.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  46.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|  46.5k|        driver->add_decoders(full);
  477|  46.5k|        const char *codec = p->codec->codec;
  478|  46.5k|        if (codec && strcmp(codec, "null") == 0)
  ------------------
  |  Branch (478:13): [True: 46.5k, False: 0]
  |  Branch (478:22): [True: 0, False: 46.5k]
  ------------------
  479|      0|            codec = fallback;
  480|  46.5k|        list = mp_select_decoders(p->log, full, codec, user_list);
  481|  46.5k|        talloc_free(full);
  ------------------
  |  |   47|  46.5k|#define talloc_free                     ta_free
  ------------------
  482|  46.5k|    }
  483|       |
  484|  46.5k|    mp_print_decoders(p->log, MSGL_V, "Codec list:", list);
  485|       |
  486|  46.5k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (486:21): [True: 46.5k, False: 0]
  ------------------
  487|  46.5k|        struct mp_decoder_entry *sel = &list->entries[n];
  488|  46.5k|        MP_VERBOSE(p, "Opening decoder %s\n", sel->decoder);
  ------------------
  |  |   92|  46.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  46.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|       |
  490|  46.5k|        p->decoder = driver->create(p->decf, p->codec, sel->decoder);
  491|  46.5k|        if (p->decoder) {
  ------------------
  |  Branch (491:13): [True: 46.5k, False: 0]
  ------------------
  492|  46.5k|            p->codec->decoder = talloc_strdup(p->codec, sel->decoder);
  ------------------
  |  |   50|  46.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  493|  46.5k|            p->codec->decoder_desc = talloc_strdup(p->codec, sel->desc && sel->desc[0] ? sel->desc : NULL);
  ------------------
  |  |   50|  46.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (493:62): [True: 46.5k, False: 0]
  |  Branch (493:75): [True: 46.5k, False: 0]
  ------------------
  494|  46.5k|            MP_VERBOSE(p, "Selected decoder: %s", sel->decoder);
  ------------------
  |  |   92|  46.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  46.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  495|  46.5k|            if (p->codec->decoder_desc)
  ------------------
  |  Branch (495:17): [True: 46.5k, False: 0]
  ------------------
  496|  46.5k|                MP_VERBOSE(p, " - %s", p->codec->decoder_desc);
  ------------------
  |  |   92|  46.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  46.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|  46.5k|            MP_VERBOSE(p, "\n");
  ------------------
  |  |   92|  46.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  46.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  498|  46.5k|            break;
  499|  46.5k|        }
  500|       |
  501|      0|        MP_WARN(p, "Decoder init failed for %s\n", sel->decoder);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  502|      0|    }
  503|       |
  504|  46.5k|    if (!p->decoder) {
  ------------------
  |  Branch (504:9): [True: 0, False: 46.5k]
  ------------------
  505|      0|        MP_ERR(p, "Failed to initialize a decoder for codec '%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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|      0|               p->codec->codec ? p->codec->codec : "<?>");
  507|      0|    }
  508|       |
  509|  46.5k|    if (p->decoder && p->decoder->control) {
  ------------------
  |  Branch (509:9): [True: 46.5k, False: 0]
  |  Branch (509:23): [True: 29.8k, False: 16.7k]
  ------------------
  510|  29.8k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  29.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  511|  29.8k|        int extra_hw_frames = p->extra_hw_frames;
  512|  29.8k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  29.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  513|  29.8k|        if (extra_hw_frames > 0) {
  ------------------
  |  Branch (513:13): [True: 0, False: 29.8k]
  ------------------
  514|      0|            p->decoder->control(p->decoder->f, VDCTRL_SET_EXTRA_HW_FRAMES,
  515|      0|                                &extra_hw_frames);
  516|      0|        }
  517|  29.8k|    }
  518|       |
  519|  46.5k|    update_cached_values(p);
  520|       |
  521|  46.5k|    talloc_free(list);
  ------------------
  |  |   47|  46.5k|#define talloc_free                     ta_free
  ------------------
  522|  46.5k|    return !!p->decoder;
  523|  46.5k|}
f_decoder_wrapper.c:reset_decoder:
  315|  4.95M|{
  316|  4.95M|    p->first_packet_pdts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.95M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  317|  4.95M|    p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.95M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  318|  4.95M|    p->codec_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.95M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  319|  4.95M|    p->codec_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.95M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  320|  4.95M|    p->num_codec_pts_problems = 0;
  321|  4.95M|    p->num_codec_dts_problems = 0;
  322|  4.95M|    p->has_broken_decoded_pts = 0;
  323|  4.95M|    p->packets_without_output = 0;
  324|  4.95M|    mp_frame_unref(&p->packet);
  325|  4.95M|    p->packet_fed = false;
  326|  4.95M|    p->preroll_discard = false;
  327|  4.95M|    talloc_free(p->new_segment);
  ------------------
  |  |   47|  4.95M|#define talloc_free                     ta_free
  ------------------
  328|  4.95M|    p->new_segment = NULL;
  329|  4.95M|    p->start = p->end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.95M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  330|       |
  331|  4.95M|    if (p->decoder)
  ------------------
  |  Branch (331:9): [True: 4.81M, False: 139k]
  ------------------
  332|  4.81M|        mp_filter_reset(p->decoder->f);
  333|  4.95M|}
f_decoder_wrapper.c:public_f_destroy:
 1252|  46.5k|{
 1253|  46.5k|    struct priv *p = f->priv;
 1254|  46.5k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  46.5k|#define mp_assert assert
  ------------------
  |  Branch (1254:5): [True: 46.5k, False: 0]
  ------------------
 1255|       |
 1256|  46.5k|    if (p->dec_thread_valid) {
  ------------------
  |  Branch (1256:9): [True: 0, False: 46.5k]
  ------------------
 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|  46.5k|    mp_filter_free_children(f);
 1267|       |
 1268|  46.5k|    talloc_free(p->dec_root_filter);
  ------------------
  |  |   47|  46.5k|#define talloc_free                     ta_free
  ------------------
 1269|  46.5k|    talloc_free(p->queue);
  ------------------
  |  |   47|  46.5k|#define talloc_free                     ta_free
  ------------------
 1270|  46.5k|    mp_mutex_destroy(&p->cache_lock);
  ------------------
  |  |  133|  46.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1271|  46.5k|}
f_decoder_wrapper.c:public_f_reset:
 1237|  4.86M|{
 1238|  4.86M|    struct priv *p = f->priv;
 1239|  4.86M|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  4.86M|#define mp_assert assert
  ------------------
  |  Branch (1239:5): [True: 4.86M, False: 0]
  ------------------
 1240|       |
 1241|  4.86M|    if (p->queue) {
  ------------------
  |  Branch (1241:9): [True: 0, False: 4.86M]
  ------------------
 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|  4.86M|}
f_decoder_wrapper.c:update_queue_config:
 1191|    419|{
 1192|    419|    if (!p->queue)
  ------------------
  |  Branch (1192:9): [True: 419, False: 0]
  ------------------
 1193|    419|        return;
 1194|       |
 1195|      0|    struct mp_async_queue_config cfg = {
 1196|      0|        .max_bytes = p->queue_opts->max_bytes,
 1197|      0|        .sample_unit = AQUEUE_UNIT_SAMPLES,
 1198|      0|        .max_samples = p->queue_opts->max_samples,
 1199|      0|        .max_duration = p->queue_opts->max_duration,
 1200|      0|    };
 1201|      0|    mp_async_queue_set_config(p->queue, cfg);
 1202|      0|}
f_decoder_wrapper.c:decf_destroy:
  394|  46.5k|{
  395|  46.5k|    struct priv *p = f->priv;
  396|  46.5k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  46.5k|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 46.5k, False: 0]
  ------------------
  397|       |
  398|  46.5k|    if (p->decoder) {
  ------------------
  |  Branch (398:9): [True: 46.5k, False: 0]
  ------------------
  399|  46.5k|        MP_DBG(f, "Uninit decoder.\n");
  ------------------
  |  |   93|  46.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  46.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  400|  46.5k|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|  46.5k|#define talloc_free                     ta_free
  ------------------
  401|  46.5k|        p->decoder = NULL;
  402|  46.5k|        p->codec->decoder = NULL;
  403|  46.5k|        p->codec->decoder_desc = NULL;
  404|  46.5k|    }
  405|       |
  406|  46.5k|    decf_reset(f);
  407|  46.5k|    mp_frame_unref(&p->decoded_coverart);
  408|  46.5k|}
f_decoder_wrapper.c:decf_process:
 1205|  20.3M|{
 1206|  20.3M|    struct priv *p = f->priv;
 1207|  20.3M|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  20.3M|#define mp_assert assert
  ------------------
  |  Branch (1207:5): [True: 20.3M, False: 0]
  ------------------
 1208|       |
 1209|  20.3M|    if (m_config_cache_update(p->opt_cache))
  ------------------
  |  Branch (1209:9): [True: 419, False: 20.3M]
  ------------------
 1210|    419|        update_queue_config(p);
 1211|       |
 1212|  20.3M|    feed_packet(p);
 1213|  20.3M|    read_frame(p);
 1214|  20.3M|}
f_decoder_wrapper.c:feed_packet:
  967|  20.3M|{
  968|  20.3M|    if (!p->decoder || !mp_pin_in_needs_data(p->decoder->f->pins[0]))
  ------------------
  |  Branch (968:9): [True: 0, False: 20.3M]
  |  Branch (968:24): [True: 10.1M, False: 10.1M]
  ------------------
  969|  10.1M|        return;
  970|       |
  971|  10.1M|    if (p->decoded_coverart.type)
  ------------------
  |  Branch (971:9): [True: 0, False: 10.1M]
  ------------------
  972|      0|        return;
  973|       |
  974|       |    // Don't read after EOF was output. If the stream continues, the player
  975|       |    // creates a new decoder.
  976|  10.1M|    if (p->eof_output)
  ------------------
  |  Branch (976:9): [True: 258, False: 10.1M]
  ------------------
  977|    258|        return;
  978|       |
  979|  10.1M|    if (!p->packet.type && !p->new_segment) {
  ------------------
  |  Branch (979:9): [True: 10.1M, False: 0]
  |  Branch (979:28): [True: 10.1M, False: 0]
  ------------------
  980|  10.1M|        p->packet = mp_pin_out_read(p->demux);
  981|  10.1M|        if (!p->packet.type)
  ------------------
  |  Branch (981:13): [True: 5.07M, False: 5.06M]
  ------------------
  982|  5.07M|            return;
  983|  5.06M|        if (p->packet.type != MP_FRAME_EOF && p->packet.type != MP_FRAME_PACKET) {
  ------------------
  |  Branch (983:13): [True: 261k, False: 4.80M]
  |  Branch (983:47): [True: 0, False: 261k]
  ------------------
  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|  5.06M|    }
  990|       |
  991|  5.06M|    if (!p->packet.type)
  ------------------
  |  Branch (991:9): [True: 0, False: 5.06M]
  ------------------
  992|      0|        return;
  993|       |
  994|       |    // Flush current data if the packet is a new segment.
  995|  5.06M|    if (is_new_segment(p, p->packet)) {
  ------------------
  |  Branch (995:9): [True: 0, False: 5.06M]
  ------------------
  996|      0|        mp_assert(!p->new_segment);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (996:9): [True: 0, False: 0]
  ------------------
  997|      0|        p->new_segment = p->packet.data;
  998|      0|        p->packet = MP_EOF_FRAME;
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  999|      0|    }
 1000|       |
 1001|  5.06M|    mp_assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF);
  ------------------
  |  |   41|  5.06M|#define mp_assert assert
  ------------------
  |  Branch (1001:5): [True: 261k, False: 4.80M]
  |  Branch (1001:5): [True: 4.80M, False: 0]
  ------------------
 1002|  5.06M|    struct demux_packet *packet =
 1003|  5.06M|        p->packet.type == MP_FRAME_PACKET ? p->packet.data : NULL;
  ------------------
  |  Branch (1003:9): [True: 261k, False: 4.80M]
  ------------------
 1004|       |
 1005|       |    // For video framedropping, including parts of the hr-seek logic.
 1006|  5.06M|    if (p->decoder->control) {
  ------------------
  |  Branch (1006:9): [True: 2.52M, False: 2.53M]
  ------------------
 1007|  2.52M|        double start_pts = p->start_pts;
 1008|  2.52M|        if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  5.05M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1008:13): [True: 0, False: 2.52M]
  |  Branch (1008:44): [True: 0, False: 0]
  ------------------
 1009|      0|                                           p->start > start_pts))
  ------------------
  |  Branch (1009:44): [True: 0, False: 0]
  ------------------
 1010|      0|            start_pts = p->start;
 1011|       |
 1012|  2.52M|        int framedrop_type = 0;
 1013|       |
 1014|  2.52M|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  2.52M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1015|  2.52M|        if (p->attempt_framedrops)
  ------------------
  |  Branch (1015:13): [True: 0, False: 2.52M]
  ------------------
 1016|      0|            framedrop_type = 1;
 1017|  2.52M|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  2.52M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1018|       |
 1019|  2.52M|        if (start_pts != MP_NOPTS_VALUE && packet && p->play_dir > 0 &&
  ------------------
  |  |   39|  5.05M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1019:13): [True: 2.48M, False: 48.0k]
  |  Branch (1019:44): [True: 1.46k, False: 2.47M]
  |  Branch (1019:54): [True: 1.41k, False: 48]
  ------------------
 1020|  1.41k|            packet->pts < start_pts - .005 && !p->has_broken_packet_pts)
  ------------------
  |  Branch (1020:13): [True: 303, False: 1.11k]
  |  Branch (1020:47): [True: 0, False: 303]
  ------------------
 1021|      0|            framedrop_type = 2;
 1022|       |
 1023|  2.52M|        p->decoder->control(p->decoder->f, VDCTRL_SET_FRAMEDROP, &framedrop_type);
 1024|  2.52M|    }
 1025|       |
 1026|  5.06M|    if (!p->dec_dispatch && p->public.recorder_sink)
  ------------------
  |  Branch (1026:9): [True: 5.06M, False: 0]
  |  Branch (1026:29): [True: 0, False: 5.06M]
  ------------------
 1027|      0|        mp_recorder_feed_packet(p->public.recorder_sink, packet);
 1028|       |
 1029|  5.06M|    double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.80M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1029:22): [True: 261k, False: 4.80M]
  ------------------
 1030|  5.06M|    double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.80M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1030:22): [True: 261k, False: 4.80M]
  ------------------
 1031|       |
 1032|  5.06M|    if (pkt_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  5.06M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1032:9): [True: 4.80M, False: 261k]
  ------------------
 1033|  4.80M|        p->has_broken_packet_pts = 1;
 1034|       |
 1035|  5.06M|    if (packet && packet->dts == MP_NOPTS_VALUE && !p->codec->avi_dts)
  ------------------
  |  |   39|  5.32M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1035:9): [True: 261k, False: 4.80M]
  |  Branch (1035:19): [True: 0, False: 261k]
  |  Branch (1035:52): [True: 0, False: 0]
  ------------------
 1036|      0|        packet->dts = packet->pts;
 1037|       |
 1038|  5.06M|    double pkt_pdts = pkt_pts == MP_NOPTS_VALUE ? pkt_dts : pkt_pts;
  ------------------
  |  |   39|  5.06M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1038:23): [True: 4.80M, False: 261k]
  ------------------
 1039|  5.06M|    if (p->first_packet_pdts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  5.06M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1039:9): [True: 4.83M, False: 230k]
  ------------------
 1040|  4.83M|        p->first_packet_pdts = pkt_pdts;
 1041|       |
 1042|  5.06M|    if (packet && packet->back_preroll) {
  ------------------
  |  Branch (1042:9): [True: 261k, False: 4.80M]
  |  Branch (1042:19): [True: 0, False: 261k]
  ------------------
 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|  5.06M|    mp_pin_in_write(p->decoder->f->pins[0], p->packet);
 1048|  5.06M|    p->packet_fed = true;
 1049|  5.06M|    p->packet = MP_NO_FRAME;
  ------------------
  |  |   58|  5.06M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  5.06M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1050|       |
 1051|  5.06M|    p->packets_without_output += 1;
 1052|  5.06M|}
f_decoder_wrapper.c:is_new_segment:
  957|  5.06M|{
  958|  5.06M|    if (frame.type != MP_FRAME_PACKET)
  ------------------
  |  Branch (958:9): [True: 4.80M, False: 261k]
  ------------------
  959|  4.80M|        return false;
  960|   261k|    struct demux_packet *pkt = frame.data;
  961|   261k|    return (pkt->segmented && (pkt->start != p->start || pkt->end != p->end ||
  ------------------
  |  Branch (961:13): [True: 0, False: 261k]
  |  Branch (961:32): [True: 0, False: 0]
  |  Branch (961:58): [True: 0, False: 0]
  ------------------
  962|      0|                               pkt->codec != p->codec)) ||
  ------------------
  |  Branch (962:32): [True: 0, False: 0]
  ------------------
  963|   261k|           (p->play_dir < 0 && pkt->back_restart && p->packet_fed);
  ------------------
  |  Branch (963:13): [True: 2.38k, False: 259k]
  |  Branch (963:32): [True: 67, False: 2.31k]
  |  Branch (963:53): [True: 0, False: 67]
  ------------------
  964|  5.06M|}
f_decoder_wrapper.c:read_frame:
 1084|  20.3M|{
 1085|  20.3M|    struct mp_pin *pin = p->decf->ppins[0];
 1086|  20.3M|    struct mp_frame frame = {0};
 1087|       |
 1088|  20.3M|    if (!p->decoder) {
  ------------------
  |  Branch (1088:9): [True: 0, False: 20.3M]
  ------------------
 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|  20.3M|    if (!mp_pin_in_needs_data(pin))
  ------------------
  |  Branch (1093:9): [True: 39.7k, False: 20.2M]
  ------------------
 1094|  39.7k|        return;
 1095|       |
 1096|  20.2M|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1096:9): [True: 0, False: 20.2M]
  ------------------
 1097|      0|        if (p->coverart_returned == 0) {
  ------------------
  |  Branch (1097:13): [True: 0, False: 0]
  ------------------
 1098|      0|            frame = mp_frame_ref(p->decoded_coverart);
 1099|      0|            p->coverart_returned = 1;
 1100|      0|            goto output_frame;
 1101|      0|        } else if (p->coverart_returned == 1) {
  ------------------
  |  Branch (1101:20): [True: 0, False: 0]
  ------------------
 1102|      0|            frame = MP_EOF_FRAME;
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1103|      0|            p->coverart_returned = 2;
 1104|      0|            goto output_frame;
 1105|      0|        }
 1106|      0|        return;
 1107|      0|    }
 1108|       |
 1109|  20.2M|    if (p->reverse_queue_complete && p->num_reverse_queue) {
  ------------------
  |  Branch (1109:9): [True: 18.7k, False: 20.2M]
  |  Branch (1109:38): [True: 18.7k, False: 11]
  ------------------
 1110|  18.7k|        frame = p->reverse_queue[p->num_reverse_queue - 1];
 1111|  18.7k|        p->num_reverse_queue -= 1;
 1112|  18.7k|        goto output_frame;
 1113|  18.7k|    }
 1114|  20.2M|    p->reverse_queue_complete = false;
 1115|       |
 1116|  20.2M|    frame = mp_pin_out_read(p->decoder->f->pins[1]);
 1117|  20.2M|    if (!frame.type)
  ------------------
  |  Branch (1117:9): [True: 15.2M, False: 5.06M]
  ------------------
 1118|  15.2M|        return;
 1119|       |
 1120|  5.06M|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  5.06M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1121|  5.06M|    if (p->attached_picture && frame.type == MP_FRAME_VIDEO)
  ------------------
  |  Branch (1121:9): [True: 0, False: 5.06M]
  |  Branch (1121:32): [True: 0, False: 0]
  ------------------
 1122|      0|        p->decoded_coverart = frame;
 1123|  5.06M|    if (p->attempt_framedrops) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 5.06M]
  ------------------
 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|  5.06M|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  5.06M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1129|       |
 1130|  5.06M|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1130:9): [True: 0, False: 5.06M]
  ------------------
 1131|      0|        mp_filter_internal_mark_progress(p->decf);
 1132|      0|        return;
 1133|      0|    }
 1134|       |
 1135|  5.06M|    p->packets_without_output = 0;
 1136|       |
 1137|  5.06M|    if (p->preroll_discard && frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 5.06M]
  |  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|  5.06M|    bool segment_ended = process_decoded_frame(p, &frame);
 1148|       |
 1149|  5.06M|    if (p->play_dir < 0 && frame.type) {
  ------------------
  |  Branch (1149:9): [True: 20.1k, False: 5.04M]
  |  Branch (1149:28): [True: 20.1k, False: 0]
  ------------------
 1150|  20.1k|        enqueue_backward_frame(p, frame);
 1151|  20.1k|        frame = MP_NO_FRAME;
  ------------------
  |  |   58|  20.1k|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  20.1k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1152|  20.1k|    }
 1153|       |
 1154|       |    // If there's a new segment, start it as soon as we're drained/finished.
 1155|  5.06M|    if (segment_ended && p->new_segment) {
  ------------------
  |  Branch (1155:9): [True: 4.80M, False: 261k]
  |  Branch (1155:26): [True: 0, False: 4.80M]
  ------------------
 1156|      0|        struct demux_packet *new_segment = p->new_segment;
 1157|      0|        p->new_segment = NULL;
 1158|       |
 1159|      0|        reset_decoder(p);
 1160|       |
 1161|      0|        if (new_segment->segmented) {
  ------------------
  |  Branch (1161:13): [True: 0, False: 0]
  ------------------
 1162|      0|            if (p->codec != new_segment->codec) {
  ------------------
  |  Branch (1162:17): [True: 0, False: 0]
  ------------------
 1163|      0|                p->codec = new_segment->codec;
 1164|      0|                if (!decoder_wrapper_reinit(&p->public))
  ------------------
  |  Branch (1164:21): [True: 0, False: 0]
  ------------------
 1165|      0|                    mp_filter_internal_mark_failed(p->decf);
 1166|      0|            }
 1167|       |
 1168|      0|            p->start = new_segment->start;
 1169|      0|            p->end = new_segment->end;
 1170|      0|        }
 1171|       |
 1172|      0|        p->reverse_queue_byte_size = 0;
 1173|      0|        p->reverse_queue_complete = p->num_reverse_queue > 0;
 1174|       |
 1175|      0|        p->packet = MAKE_FRAME(MP_FRAME_PACKET, new_segment);
  ------------------
  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1176|      0|        mp_filter_internal_mark_progress(p->decf);
 1177|      0|    }
 1178|       |
 1179|  5.06M|    if (!frame.type) {
  ------------------
  |  Branch (1179:9): [True: 20.1k, False: 5.04M]
  ------------------
 1180|  20.1k|        mp_filter_internal_mark_progress(p->decf); // make it retry
 1181|  20.1k|        return;
 1182|  20.1k|    }
 1183|       |
 1184|  5.06M|output_frame:
 1185|  5.06M|    process_output_frame(p, frame);
 1186|  5.06M|    p->eof_output = frame.type == MP_FRAME_EOF;
 1187|  5.06M|    mp_pin_in_write(pin, frame);
 1188|  5.06M|}
f_decoder_wrapper.c:process_decoded_frame:
  786|  5.06M|{
  787|  5.06M|    if (frame->type == MP_FRAME_EOF) {
  ------------------
  |  Branch (787:9): [True: 4.80M, False: 261k]
  ------------------
  788|       |        // if we were just draining current segment, don't propagate EOF
  789|  4.80M|        if (p->new_segment)
  ------------------
  |  Branch (789:13): [True: 0, False: 4.80M]
  ------------------
  790|      0|            mp_frame_unref(frame);
  791|  4.80M|        return true;
  792|  4.80M|    }
  793|       |
  794|  5.06M|    bool segment_ended = false;
  795|       |
  796|   261k|    if (frame->type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (796:9): [True: 38.5k, False: 223k]
  ------------------
  797|  38.5k|        struct mp_image *mpi = frame->data;
  798|       |
  799|  38.5k|        crazy_video_pts_stuff(p, mpi);
  800|       |
  801|  38.5k|        struct demux_packet *ccpkt = new_demux_packet_from_buf(p->public.f->packet_pool,
  802|  38.5k|                                                               mpi->a53_cc);
  803|  38.5k|        if (ccpkt) {
  ------------------
  |  Branch (803:13): [True: 0, False: 38.5k]
  ------------------
  804|      0|            av_buffer_unref(&mpi->a53_cc);
  805|      0|            ccpkt->pts = mpi->pts;
  806|      0|            ccpkt->dts = mpi->dts;
  807|      0|            demuxer_feed_caption(p->header, ccpkt);
  808|      0|        }
  809|       |
  810|       |        // Stop hr-seek logic.
  811|  38.5k|        if (mpi->pts == MP_NOPTS_VALUE || mpi->pts >= p->start_pts)
  ------------------
  |  |   39|  77.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (811:13): [True: 0, False: 38.5k]
  |  Branch (811:43): [True: 38.2k, False: 303]
  ------------------
  812|  38.2k|            p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  38.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  813|       |
  814|  38.5k|        if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  38.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (814:13): [True: 38.5k, False: 0]
  ------------------
  815|  38.5k|            segment_ended = p->end != MP_NOPTS_VALUE && mpi->pts >= p->end;
  ------------------
  |  |   39|  77.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (815:29): [True: 0, False: 38.5k]
  |  Branch (815:57): [True: 0, False: 0]
  ------------------
  816|  38.5k|            if ((p->start != MP_NOPTS_VALUE && mpi->pts < p->start) ||
  ------------------
  |  |   39|  77.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (816:18): [True: 0, False: 38.5k]
  |  Branch (816:48): [True: 0, False: 0]
  ------------------
  817|  38.5k|                segment_ended)
  ------------------
  |  Branch (817:17): [True: 0, False: 38.5k]
  ------------------
  818|      0|            {
  819|      0|                mp_frame_unref(frame);
  820|      0|                goto done;
  821|      0|            }
  822|  38.5k|        }
  823|   223k|    } else if (frame->type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (823:16): [True: 223k, False: 0]
  ------------------
  824|   223k|        struct mp_aframe *aframe = frame->data;
  825|       |
  826|   223k|        mp_aframe_clip_timestamps(aframe, p->start, p->end);
  827|   223k|        double pts = mp_aframe_get_pts(aframe);
  828|   223k|        if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   446k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   223k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (828:13): [True: 223k, False: 0]
  |  Branch (828:38): [True: 0, False: 223k]
  ------------------
  829|      0|            segment_ended = pts >= p->end;
  830|       |
  831|   223k|        if (mp_aframe_get_size(aframe) == 0) {
  ------------------
  |  Branch (831:13): [True: 0, False: 223k]
  ------------------
  832|      0|            mp_frame_unref(frame);
  833|      0|            goto done;
  834|      0|        }
  835|   223k|    } 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|   261k|done:
  840|   261k|    return segment_ended;
  841|   261k|}
f_decoder_wrapper.c:crazy_video_pts_stuff:
  749|  38.5k|{
  750|       |    // Note: the PTS is reordered, but the DTS is not. Both must be monotonic.
  751|       |
  752|  38.5k|    if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  38.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (752:9): [True: 38.5k, False: 0]
  ------------------
  753|  38.5k|        if (mpi->pts < p->codec_pts)
  ------------------
  |  Branch (753:13): [True: 0, False: 38.5k]
  ------------------
  754|      0|            p->num_codec_pts_problems++;
  755|  38.5k|        p->codec_pts = mpi->pts;
  756|  38.5k|    }
  757|       |
  758|  38.5k|    if (mpi->dts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  38.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (758:9): [True: 38.5k, False: 0]
  ------------------
  759|  38.5k|        if (mpi->dts <= p->codec_dts)
  ------------------
  |  Branch (759:13): [True: 0, False: 38.5k]
  ------------------
  760|      0|            p->num_codec_dts_problems++;
  761|  38.5k|        p->codec_dts = mpi->dts;
  762|  38.5k|    }
  763|       |
  764|  38.5k|    if (p->has_broken_packet_pts < 0)
  ------------------
  |  Branch (764:9): [True: 29.1k, False: 9.39k]
  ------------------
  765|  29.1k|        p->has_broken_packet_pts++;
  766|  38.5k|    if (p->num_codec_pts_problems)
  ------------------
  |  Branch (766:9): [True: 0, False: 38.5k]
  ------------------
  767|      0|        p->has_broken_packet_pts = 1;
  768|       |
  769|       |    // If PTS is unset, or non-monotonic, fall back to DTS.
  770|  38.5k|    if ((p->num_codec_pts_problems > p->num_codec_dts_problems ||
  ------------------
  |  Branch (770:10): [True: 0, False: 38.5k]
  ------------------
  771|  38.5k|        mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  38.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (771:9): [True: 0, False: 38.5k]
  |  Branch (771:40): [True: 0, False: 0]
  ------------------
  772|      0|        mpi->pts = mpi->dts;
  773|       |
  774|       |    // Compensate for incorrectly using mpeg-style DTS for avi timestamps.
  775|  38.5k|    if (p->decoder && p->decoder->control && p->codec->avi_dts &&
  ------------------
  |  Branch (775:9): [True: 38.5k, False: 0]
  |  Branch (775:23): [True: 38.5k, False: 0]
  |  Branch (775:46): [True: 0, False: 38.5k]
  ------------------
  776|      0|        mpi->pts != MP_NOPTS_VALUE && p->fps > 0)
  ------------------
  |  |   39|  38.5k|#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|  38.5k|}
f_decoder_wrapper.c:enqueue_backward_frame:
 1055|  20.1k|{
 1056|  20.1k|    bool eof = frame.type == MP_FRAME_EOF;
 1057|       |
 1058|  20.1k|    if (!eof) {
  ------------------
  |  Branch (1058:9): [True: 2.38k, False: 17.7k]
  ------------------
 1059|  2.38k|        struct dec_wrapper_opts *opts = p->opts;
 1060|       |
 1061|  2.38k|        uint64_t queue_size = 0;
 1062|  2.38k|        switch (p->header->type) {
  ------------------
  |  Branch (1062:17): [True: 2.38k, False: 0]
  ------------------
 1063|    938|        case STREAM_VIDEO: queue_size = opts->video_reverse_size; break;
  ------------------
  |  Branch (1063:9): [True: 938, False: 1.44k]
  ------------------
 1064|  1.44k|        case STREAM_AUDIO: queue_size = opts->audio_reverse_size; break;
  ------------------
  |  Branch (1064:9): [True: 1.44k, False: 938]
  ------------------
 1065|  2.38k|        }
 1066|       |
 1067|  2.38k|        if (p->reverse_queue_byte_size >= queue_size) {
  ------------------
  |  Branch (1067:13): [True: 0, False: 2.38k]
  ------------------
 1068|      0|            MP_ERR(p, "Reversal queue overflow, discarding 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__)
  |  |  ------------------
  ------------------
 1069|      0|            mp_frame_unref(&frame);
 1070|      0|            return;
 1071|      0|        }
 1072|       |
 1073|  2.38k|        p->reverse_queue_byte_size += mp_frame_approx_size(frame);
 1074|  2.38k|    }
 1075|       |
 1076|       |    // Note: EOF (really BOF) is propagated, but not reversed.
 1077|  20.1k|    MP_TARRAY_INSERT_AT(p, p->reverse_queue, p->num_reverse_queue,
  ------------------
  |  |  115|  20.1k|    do {                                            \
  |  |  116|  40.3k|        size_t at_ = (at);                          \
  |  |  ------------------
  |  |  |  Branch (116:23): [True: 17.7k, False: 2.38k]
  |  |  ------------------
  |  |  117|  20.1k|        assert(at_ <= (idxvar));                    \
  |  |  118|  20.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  20.1k|    do {                                            \
  |  |  |  |   97|  20.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  20.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  20.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  20.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.10k, False: 19.0k]
  |  |  |  |  ------------------
  |  |  |  |   99|  20.1k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.10k|    do {                                                        \
  |  |  |  |  |  |   89|  1.10k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.10k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.10k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.10k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.10k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.10k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.10k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.10k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  20.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 20.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  20.1k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  20.1k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  20.1k|        (idxvar)++;                                 \
  |  |  122|  20.1k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  20.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 20.1k]
  |  |  ------------------
  ------------------
  |  Branch (1077:5): [True: 20.1k, False: 0]
  ------------------
 1078|  20.1k|                        eof ? 0 : p->num_reverse_queue, frame);
 1079|       |
 1080|  20.1k|    p->reverse_queue_complete = eof;
 1081|  20.1k|}
f_decoder_wrapper.c:process_output_frame:
  922|  5.06M|{
  923|  5.06M|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (923:9): [True: 37.9k, False: 5.02M]
  ------------------
  924|  37.9k|        struct mp_image *mpi = frame.data;
  925|       |
  926|  37.9k|        correct_video_pts(p, mpi);
  927|       |
  928|  37.9k|        if (!mp_image_params_equal(&p->last_format, &mpi->params)) {
  ------------------
  |  Branch (928:13): [True: 18.0k, False: 19.8k]
  ------------------
  929|  18.0k|            fix_image_params(p, &mpi->params,
  930|  18.0k|                mp_image_params_static_equal(&p->last_format, &mpi->params));
  931|  18.0k|        }
  932|       |
  933|  37.9k|        mpi->params = p->fixed_format;
  934|  37.9k|        mpi->nominal_fps = p->fps;
  935|  5.02M|    } else if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (935:16): [True: 222k, False: 4.80M]
  ------------------
  936|   222k|        struct mp_aframe *aframe = frame.data;
  937|       |
  938|   222k|        if (p->play_dir < 0 && !mp_aframe_reverse(aframe))
  ------------------
  |  Branch (938:13): [True: 765, False: 221k]
  |  Branch (938:32): [True: 0, False: 765]
  ------------------
  939|   222k|            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|   222k|        correct_audio_pts(p, aframe);
  942|   222k|    }
  943|  5.06M|}
f_decoder_wrapper.c:correct_video_pts:
  844|  37.9k|{
  845|  37.9k|    mpi->pts *= p->play_dir;
  846|       |
  847|  37.9k|    if (!p->opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  37.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (847:9): [True: 0, False: 37.9k]
  |  Branch (847:34): [True: 0, False: 37.9k]
  ------------------
  848|      0|        double fps = p->fps > 0 ? p->fps : 25;
  ------------------
  |  Branch (848:22): [True: 0, False: 0]
  ------------------
  849|       |
  850|      0|        if (p->opts->correct_pts) {
  ------------------
  |  Branch (850:13): [True: 0, False: 0]
  ------------------
  851|      0|            if (p->has_broken_decoded_pts <= 1) {
  ------------------
  |  Branch (851:17): [True: 0, False: 0]
  ------------------
  852|      0|                MP_WARN(p, "No video PTS! Making something up. Using "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  853|      0|                        "%f FPS.\n", fps);
  854|      0|                if (p->has_broken_decoded_pts == 1)
  ------------------
  |  Branch (854:21): [True: 0, False: 0]
  ------------------
  855|      0|                    MP_WARN(p, "Ignoring further missing PTS warnings.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  856|      0|                p->has_broken_decoded_pts++;
  857|      0|            }
  858|      0|        }
  859|       |
  860|      0|        double frame_time = 1.0f / fps;
  861|      0|        double base = p->first_packet_pdts;
  862|      0|        mpi->pts = p->pts;
  863|      0|        if (mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (863:13): [True: 0, False: 0]
  ------------------
  864|      0|            mpi->pts = base == MP_NOPTS_VALUE ? 0 : base;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:24): [True: 0, False: 0]
  ------------------
  865|      0|        } else {
  866|      0|            mpi->pts += frame_time;
  867|      0|        }
  868|      0|    }
  869|       |
  870|  37.9k|    p->pts = mpi->pts;
  871|  37.9k|}
f_decoder_wrapper.c:fix_image_params:
  628|  18.0k|{
  629|  18.0k|    struct mp_image_params m = *params;
  630|  18.0k|    struct mp_codec_params *c = p->codec;
  631|  18.0k|    struct dec_wrapper_opts *opts = p->opts;
  632|       |
  633|  18.0k|    if (!quiet)
  ------------------
  |  Branch (633:9): [True: 18.0k, False: 0]
  ------------------
  634|  18.0k|        MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  18.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  635|  18.0k|    p->dec_format = *params;
  636|       |
  637|  18.0k|    if (!quiet && opts->movie_aspect == 0)
  ------------------
  |  Branch (637:9): [True: 18.0k, False: 0]
  |  Branch (637:19): [True: 2, False: 18.0k]
  ------------------
  638|  18.0k|        MP_WARN(p, "Setting video-aspect-override to 0 is deprecated.\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__)
  |  |  ------------------
  ------------------
  639|  18.0k|                   "Use --video-aspect-override=no --video-aspect-mode=ignore instead.\n");
  640|  18.0k|    if (!quiet && opts->movie_aspect == -1)
  ------------------
  |  Branch (640:9): [True: 18.0k, False: 0]
  |  Branch (640:19): [True: 0, False: 18.0k]
  ------------------
  641|  18.0k|        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|  18.0k|                   "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|  18.0k|    bool use_container = true;
  647|  18.0k|    if (opts->aspect_method == 1 && m.p_w > 0 && m.p_h > 0 &&
  ------------------
  |  Branch (647:9): [True: 0, False: 18.0k]
  |  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|  18.0k|    if (opts->aspect_method == 3 && opts->movie_aspect != -1) {
  ------------------
  |  Branch (654:9): [True: 0, False: 18.0k]
  |  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|  18.0k|    if (use_container && c->dar_w > 0 && c->dar_h > 0) {
  ------------------
  |  Branch (661:9): [True: 18.0k, False: 0]
  |  Branch (661:26): [True: 0, False: 18.0k]
  |  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|  18.0k|    } else if (use_container && c->par_w > 0 && c->par_h) {
  ------------------
  |  Branch (665:16): [True: 18.0k, False: 0]
  |  Branch (665:33): [True: 18.0k, False: 0]
  |  Branch (665:49): [True: 18.0k, False: 0]
  ------------------
  666|  18.0k|        if (!quiet)
  ------------------
  |  Branch (666:13): [True: 18.0k, False: 0]
  ------------------
  667|  18.0k|            MP_VERBOSE(p, "Using container aspect ratio.\n");
  ------------------
  |  |   92|  18.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  668|  18.0k|        m.p_w = c->par_w;
  669|  18.0k|        m.p_h = c->par_h;
  670|  18.0k|    }
  671|       |
  672|  18.0k|    if (opts->movie_aspect >= 0) {
  ------------------
  |  Branch (672:9): [True: 13, False: 18.0k]
  ------------------
  673|     13|        if (!quiet)
  ------------------
  |  Branch (673:13): [True: 13, False: 0]
  ------------------
  674|     13|            MP_VERBOSE(p, "Forcing user-set aspect ratio.\n");
  ------------------
  |  |   92|     13|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     13|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  675|     13|        if (opts->movie_aspect == 0) {
  ------------------
  |  Branch (675:13): [True: 2, False: 11]
  ------------------
  676|      2|            m.p_w = m.p_h = 1;
  677|     11|        } else {
  678|     11|            AVRational a = av_d2q(opts->movie_aspect, INT_MAX);
  679|     11|            mp_image_params_set_dsize(&m, a.num, a.den);
  680|     11|        }
  681|     13|    }
  682|       |
  683|       |    // Assume square pixels if no aspect ratio is set at all.
  684|  18.0k|    if (m.p_w <= 0 || m.p_h <= 0)
  ------------------
  |  Branch (684:9): [True: 0, False: 18.0k]
  |  Branch (684:23): [True: 0, False: 18.0k]
  ------------------
  685|      0|        m.p_w = m.p_h = 1;
  686|       |
  687|  18.0k|    if (!m.stereo3d)
  ------------------
  |  Branch (687:9): [True: 18.0k, False: 0]
  ------------------
  688|  18.0k|        m.stereo3d = p->codec->stereo_mode;
  689|       |
  690|  18.0k|    if (!mp_rect_equals(&p->codec->crop, &(struct mp_rect){0})) {
  ------------------
  |  Branch (690:9): [True: 0, False: 18.0k]
  ------------------
  691|      0|        struct mp_rect crop = p->codec->crop;
  692|       |        // Offset to respect existing decoder crop.
  693|      0|        crop.x0 += m.crop.x0;
  694|      0|        crop.x1 += m.crop.x0;
  695|      0|        crop.y0 += m.crop.y0;
  696|      0|        crop.y1 += m.crop.y0;
  697|       |        // Crop has to be inside existing image bounds.
  698|      0|        if (mp_image_crop_valid(&(struct mp_image_params) {
  ------------------
  |  Branch (698:13): [True: 0, False: 0]
  ------------------
  699|      0|            .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  157|      0|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                          .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop }))
  ------------------
  |  |  158|      0|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  700|      0|        {
  701|      0|            m.crop = crop;
  702|      0|        } else {
  703|      0|            MP_WARN(p, "Invalid container crop %dx%d+%d+%d for %dx%d image\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  704|      0|            mp_rect_w(crop), mp_rect_h(crop), crop.x0, crop.y0,
  705|      0|            mp_rect_w(m.crop), mp_rect_h(m.crop));
  706|      0|        }
  707|      0|    }
  708|       |
  709|  18.0k|    if (opts->video_rotate < 0) {
  ------------------
  |  Branch (709:9): [True: 0, False: 18.0k]
  ------------------
  710|      0|        m.rotate = 0;
  711|  18.0k|    } else {
  712|       |        // ffmpeg commit 535a835e51 says that frame rotate takes priority
  713|  18.0k|        if (!m.rotate)
  ------------------
  |  Branch (713:13): [True: 18.0k, False: 0]
  ------------------
  714|  18.0k|            m.rotate = p->codec->rotate;
  715|  18.0k|        m.rotate = (m.rotate + opts->video_rotate) % 360;
  716|  18.0k|    }
  717|       |
  718|  18.0k|    pl_color_space_merge(&m.color, &c->color);
  719|  18.0k|    pl_color_repr_merge(&m.repr, &c->repr);
  720|       |
  721|  18.0k|    if (m.chroma_location == PL_CHROMA_UNKNOWN)
  ------------------
  |  Branch (721:9): [True: 18.0k, False: 0]
  ------------------
  722|  18.0k|        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|  18.0k|    mp_image_params_guess_csp(&m);
  727|       |
  728|  18.0k|    p->last_format = *params;
  729|  18.0k|    p->fixed_format = m;
  730|  18.0k|}
f_decoder_wrapper.c:correct_audio_pts:
  874|   222k|{
  875|   222k|    double dir = p->play_dir;
  876|       |
  877|   222k|    double frame_pts = mp_aframe_get_pts(aframe);
  878|   222k|    double frame_len = mp_aframe_duration(aframe);
  879|       |
  880|   222k|    if (frame_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   222k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (880:9): [True: 222k, False: 0]
  ------------------
  881|   222k|        if (dir < 0)
  ------------------
  |  Branch (881:13): [True: 765, False: 221k]
  ------------------
  882|    765|            frame_pts = -(frame_pts + frame_len);
  883|       |
  884|   222k|        if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   222k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (884:13): [True: 206k, False: 15.9k]
  ------------------
  885|   222k|            MP_STATS(p, "value %f audio-pts-err", p->pts - frame_pts);
  ------------------
  |  |   99|   206k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   206k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  886|       |
  887|   222k|        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|   222k|        if (p->pts != MP_NOPTS_VALUE && diff > 0.1) {
  ------------------
  |  |   39|   445k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (892:13): [True: 206k, False: 15.9k]
  |  Branch (892:41): [True: 3, False: 206k]
  ------------------
  893|      3|            MP_WARN(p, "Invalid audio PTS: %f -> %f\n", p->pts, frame_pts);
  ------------------
  |  |   90|      3|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      3|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  894|      3|            if (diff >= 5) {
  ------------------
  |  Branch (894:17): [True: 0, False: 3]
  ------------------
  895|      0|                mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  896|      0|                p->pts_reset = true;
  897|      0|                mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  898|      0|            }
  899|      3|        }
  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|   222k|        if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   39|   445k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (p->pts == MP_NOPTS_VALUE || diff >= MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|   206k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (906:13): [True: 15.9k, False: 206k]
  |  Branch (906:41): [True: 3, False: 206k]
  ------------------
  907|  15.9k|            p->pts = frame_pts;
  908|   206k|        else
  909|   206k|            p->pts += (frame_pts - p->pts) * frame_len;
  910|   222k|    }
  911|       |
  912|   222k|    if (p->pts == MP_NOPTS_VALUE && p->header->missing_timestamps)
  ------------------
  |  |   39|   445k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (912:9): [True: 0, False: 222k]
  |  Branch (912:37): [True: 0, False: 0]
  ------------------
  913|      0|        p->pts = 0;
  914|       |
  915|   222k|    mp_aframe_set_pts(aframe, p->pts);
  916|       |
  917|   222k|    if (p->pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   222k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (917:9): [True: 222k, False: 0]
  ------------------
  918|   222k|        p->pts += frame_len;
  919|   222k|}
f_decoder_wrapper.c:decf_reset:
  336|  4.90M|{
  337|  4.90M|    struct priv *p = f->priv;
  338|  4.90M|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  4.90M|#define mp_assert assert
  ------------------
  |  Branch (338:5): [True: 4.90M, False: 0]
  ------------------
  339|       |
  340|  4.90M|    p->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  4.90M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  341|  4.90M|    p->last_format = p->fixed_format = (struct mp_image_params){0};
  342|       |
  343|  4.90M|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  4.90M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  344|  4.90M|    p->pts_reset = false;
  345|  4.90M|    p->attempt_framedrops = 0;
  346|  4.90M|    p->dropped_frames = 0;
  347|  4.90M|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  4.90M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  348|       |
  349|  4.90M|    p->coverart_returned = 0;
  350|  4.90M|    p->eof_output = false;
  351|       |
  352|  4.90M|    for (int n = 0; n < p->num_reverse_queue; n++)
  ------------------
  |  Branch (352:21): [True: 1.39k, False: 4.90M]
  ------------------
  353|  1.39k|        mp_frame_unref(&p->reverse_queue[n]);
  354|  4.90M|    p->num_reverse_queue = 0;
  355|  4.90M|    p->reverse_queue_byte_size = 0;
  356|  4.90M|    p->reverse_queue_complete = false;
  357|       |
  358|  4.90M|    reset_decoder(p);
  359|  4.90M|}

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

mp_lavfi_create_graph:
  921|     92|{
  922|     92|    if (!graph)
  ------------------
  |  Branch (922:9): [True: 21, False: 71]
  ------------------
  923|     21|        return NULL;
  924|       |
  925|     71|    struct lavfi *c = lavfi_alloc(parent);
  926|     71|    if (!c)
  ------------------
  |  Branch (926:9): [True: 0, False: 71]
  ------------------
  927|      0|        return NULL;
  928|       |
  929|     71|    c->force_type = type;
  930|     71|    c->force_bidir = bidir;
  931|     71|    c->graph_opts = mp_dup_str_array(c, graph_opts);
  932|     71|    c->graph_string = talloc_strdup(c, graph);
  ------------------
  |  |   50|     71|#define talloc_strdup                   ta_xstrdup
  ------------------
  933|     71|    c->hwdec_interop = talloc_strdup(c, hwdec_interop);
  ------------------
  |  |   50|     71|#define talloc_strdup                   ta_xstrdup
  ------------------
  934|       |
  935|     71|    return do_init(c);
  936|     71|}
mp_lavfi_create_filter:
  943|  1.28k|{
  944|  1.28k|    struct lavfi *c = lavfi_alloc(parent);
  945|  1.28k|    if (!c)
  ------------------
  |  Branch (945:9): [True: 0, False: 1.28k]
  ------------------
  946|      0|        return NULL;
  947|       |
  948|  1.28k|    c->force_type = type;
  949|  1.28k|    c->force_bidir = bidir;
  950|  1.28k|    c->hwdec_interop = talloc_strdup(c, hwdec_interop);
  ------------------
  |  |   50|  1.28k|#define talloc_strdup                   ta_xstrdup
  ------------------
  951|  1.28k|    c->graph_opts = mp_dup_str_array(c, graph_opts);
  952|  1.28k|    c->graph_string = talloc_strdup(c, filter);
  ------------------
  |  |   50|  1.28k|#define talloc_strdup                   ta_xstrdup
  ------------------
  953|  1.28k|    c->direct_filter_opts = mp_dup_str_array(c, filter_opts);
  954|  1.28k|    c->direct_filter = true;
  955|       |
  956|  1.28k|    return do_init(c);
  957|  1.28k|}
mp_lavfi_is_usable:
 1011|  7.29k|{
 1012|  7.29k|    const AVFilter *f = avfilter_get_by_name(name);
 1013|  7.29k|    return f && is_usable(f, media_type);
  ------------------
  |  Branch (1013:12): [True: 20, False: 7.27k]
  |  Branch (1013:17): [True: 0, False: 20]
  ------------------
 1014|  7.29k|}
print_lavfi_help_list:
 1101|    230|{
 1102|    230|    dump_list(log, media_type);
 1103|    230|    mp_info(log, "\nIf libavfilter filters clash with builtin mpv filters,\n"
  ------------------
  |  |   78|    230|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 1104|    230|            "prefix them with lavfi- to select the libavfilter one.\n\n");
 1105|    230|}
f_lavfi.c:lavfi_alloc:
  860|  1.35k|{
  861|  1.35k|    struct mp_filter *f = mp_filter_create(parent, &lavfi_filter);
  862|  1.35k|    if (!f)
  ------------------
  |  Branch (862:9): [True: 0, False: 1.35k]
  ------------------
  863|      0|        return NULL;
  864|       |
  865|  1.35k|    struct lavfi *c = f->priv;
  866|       |
  867|  1.35k|    c->f = f;
  868|  1.35k|    c->log = f->log;
  869|  1.35k|    c->public.f = f;
  870|  1.35k|    c->tmp_frame = av_frame_alloc();
  871|  1.35k|    MP_HANDLE_OOM(c->tmp_frame);
  ------------------
  |  |  206|  1.35k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.35k|        void *oom_p_ = (x);     \
  |  |  208|  1.35k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.35k]
  |  |  ------------------
  |  |  209|  1.35k|            abort();            \
  |  |  210|  1.35k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.35k]
  |  |  ------------------
  ------------------
  872|       |
  873|  1.35k|    return c;
  874|  1.35k|}
f_lavfi.c:lavfi_destroy:
  817|  1.35k|{
  818|  1.35k|    struct lavfi *c = f->priv;
  819|       |
  820|  1.35k|    lavfi_reset(f);
  821|  1.35k|    av_frame_free(&c->tmp_frame);
  822|  1.35k|}
f_lavfi.c:precreate_graph:
  258|  1.35k|{
  259|  1.35k|    mp_assert(!c->graph);
  ------------------
  |  |   41|  1.35k|#define mp_assert assert
  ------------------
  |  Branch (259:5): [True: 1.35k, False: 0]
  ------------------
  260|       |
  261|  1.35k|    c->failed = false;
  262|       |
  263|  1.35k|    c->graph = avfilter_graph_alloc();
  264|  1.35k|    MP_HANDLE_OOM(c->graph);
  ------------------
  |  |  206|  1.35k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  1.35k|        void *oom_p_ = (x);     \
  |  |  208|  1.35k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 1.35k]
  |  |  ------------------
  |  |  209|  1.35k|            abort();            \
  |  |  210|  1.35k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 1.35k]
  |  |  ------------------
  ------------------
  265|       |
  266|  1.35k|    if (mp_set_avopts(c->log, c->graph, c->graph_opts) < 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 1.35k]
  ------------------
  267|      0|        goto error;
  268|       |
  269|  1.35k|    if (c->direct_filter) {
  ------------------
  |  Branch (269:9): [True: 1.28k, False: 71]
  ------------------
  270|  1.28k|        AVFilterContext *filter = avfilter_graph_alloc_filter(c->graph,
  271|  1.28k|                            avfilter_get_by_name(c->graph_string), "filter");
  272|  1.28k|        if (!filter) {
  ------------------
  |  Branch (272:13): [True: 1.28k, False: 0]
  ------------------
  273|  1.28k|            MP_FATAL(c, "filter '%s' not found or failed to allocate\n",
  ------------------
  |  |   88|  1.28k|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.28k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  274|  1.28k|                     c->graph_string);
  275|  1.28k|            goto error;
  276|  1.28k|        }
  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|     71|    } else {
  292|     71|        AVFilterInOut *in = NULL, *out = NULL;
  293|     71|        if (avfilter_graph_parse2(c->graph, c->graph_string, &in, &out) < 0) {
  ------------------
  |  Branch (293:13): [True: 71, False: 0]
  ------------------
  294|     71|            MP_FATAL(c, "parsing the filter graph failed\n");
  ------------------
  |  |   88|     71|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     71|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  295|     71|            goto error;
  296|     71|        }
  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|  1.35k|error:
  312|  1.35k|    free_graph(c);
  313|       |    c->failed = true;
  314|  1.35k|}
f_lavfi.c:free_graph:
  137|  2.71k|{
  138|  2.71k|    avfilter_graph_free(&c->graph);
  139|  2.71k|    for (int n = 0; n < c->num_all_pads; n++) {
  ------------------
  |  Branch (139:21): [True: 0, False: 2.71k]
  ------------------
  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|  2.71k|    c->initialized = false;
  150|  2.71k|    c->draining_recover = false;
  151|  2.71k|    c->in_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.71k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  152|  2.71k|    c->in_samples = 0;
  153|  2.71k|    c->delay = 0;
  154|  2.71k|}
f_lavfi.c:lavfi_reset:
  807|  1.35k|{
  808|  1.35k|    struct lavfi *c = f->priv;
  809|       |
  810|  1.35k|    free_graph(c);
  811|       |
  812|  1.35k|    for (int n = 0; n < c->num_in_pads; n++)
  ------------------
  |  Branch (812:21): [True: 0, False: 1.35k]
  ------------------
  813|      0|        mp_frame_unref(&c->in_pads[n]->pending);
  814|  1.35k|}
f_lavfi.c:do_init:
  877|  1.35k|{
  878|  1.35k|    precreate_graph(c, true);
  879|       |
  880|  1.35k|    if (c->failed)
  ------------------
  |  Branch (880:9): [True: 1.35k, False: 0]
  ------------------
  881|  1.35k|        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|  1.35k|error:
  913|  1.35k|    talloc_free(c->f);
  ------------------
  |  |   47|  1.35k|#define talloc_free                     ta_free
  ------------------
  914|       |    return NULL;
  915|      0|}
f_lavfi.c:is_usable:
  996|  1.40k|{
  997|  1.40k|    int nb_inputs  = avfilter_filter_pad_count(filter, 0),
  998|  1.40k|        nb_outputs = avfilter_filter_pad_count(filter, 1);
  999|  1.40k|    if (nb_inputs > 1 || nb_outputs > 1)
  ------------------
  |  Branch (999:9): [True: 0, False: 1.40k]
  |  Branch (999:26): [True: 0, False: 1.40k]
  ------------------
 1000|      0|        return false;
 1001|  1.40k|    bool input_ok = filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS;
 1002|  1.40k|    bool output_ok = filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS;
 1003|  1.40k|    if (nb_inputs == 1)
  ------------------
  |  Branch (1003:9): [True: 460, False: 940]
  ------------------
 1004|    460|        input_ok = avfilter_pad_get_type(filter->inputs, 0) == media_type;
 1005|  1.40k|    if (nb_outputs == 1)
  ------------------
  |  Branch (1005:9): [True: 940, False: 460]
  ------------------
 1006|    940|        output_ok = avfilter_pad_get_type(filter->outputs, 0) == media_type;
 1007|  1.40k|    return input_ok && output_ok;
  ------------------
  |  Branch (1007:12): [True: 230, False: 1.17k]
  |  Branch (1007:24): [True: 0, False: 230]
  ------------------
 1008|  1.40k|}
f_lavfi.c:dump_list:
 1017|    230|{
 1018|    230|    mp_info(log, "Available libavfilter filters:\n");
  ------------------
  |  |   78|    230|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 1019|    230|    void *iter = NULL;
 1020|  1.61k|    for (;;) {
 1021|  1.61k|        const AVFilter *filter = av_filter_iterate(&iter);
 1022|  1.61k|        if (!filter)
  ------------------
  |  Branch (1022:13): [True: 230, False: 1.38k]
  ------------------
 1023|    230|            break;
 1024|  1.38k|        if (is_usable(filter, media_type))
  ------------------
  |  Branch (1024:13): [True: 0, False: 1.38k]
  ------------------
 1025|      0|            mp_info(log, "  %-16s %s\n", filter->name, filter->description);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 1026|  1.38k|    }
 1027|    230|}
f_lavfi.c:lavfi_create:
  975|     92|{
  976|     92|    struct lavfi_user_opts *opts = options;
  977|     92|    struct mp_lavfi *l;
  978|     92|    if (opts->is_bridge) {
  ------------------
  |  Branch (978:9): [True: 0, False: 92]
  ------------------
  979|      0|        l = mp_lavfi_create_filter(parent, opts->type, true,
  980|      0|                                   opts->hwdec_interop, opts->avopts,
  981|      0|                                   opts->filter_name, opts->filter_opts);
  982|     92|    } else {
  983|     92|        l = mp_lavfi_create_graph(parent, opts->type, true, opts->hwdec_interop,
  984|     92|                                  opts->avopts, opts->graph);
  985|     92|    }
  986|     92|    if (l) {
  ------------------
  |  Branch (986:9): [True: 0, False: 92]
  ------------------
  987|      0|        struct lavfi *c = l->f->priv;
  988|      0|        c->emulate_audio_pts = opts->fix_pts;
  989|      0|    }
  990|     92|    talloc_free(opts);
  ------------------
  |  |   47|     92|#define talloc_free                     ta_free
  ------------------
  991|     92|    return l ? l->f : NULL;
  ------------------
  |  Branch (991:12): [True: 0, False: 92]
  ------------------
  992|     92|}

mp_output_chain_reset_harder:
  343|  2.26k|{
  344|  2.26k|    struct chain *p = c->f->priv;
  345|       |
  346|  2.26k|    mp_filter_reset(p->f);
  347|       |
  348|  2.26k|    p->public.failed_output_conversion = false;
  349|  12.1k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (349:21): [True: 9.88k, False: 2.26k]
  ------------------
  350|  9.88k|        struct mp_user_filter *u = p->all_filters[n];
  351|       |
  352|  9.88k|        u->failed = false;
  353|  9.88k|        u->last_in_vformat = (struct mp_image_params){0};
  354|  9.88k|        mp_aframe_reset(u->last_in_aformat);
  355|  9.88k|    }
  356|       |
  357|  2.26k|    if (p->type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (357:9): [True: 2.26k, False: 0]
  ------------------
  358|       |        p->ao = NULL;
  359|  2.26k|        mp_autoconvert_clear(p->convert);
  360|  2.26k|    }
  361|  2.26k|}
mp_output_chain_set_vo:
  393|  29.8k|{
  394|  29.8k|    struct chain *p = c->f->priv;
  395|       |
  396|  29.8k|    p->stream_info.hwdec_devs = vo ? vo->hwdec_devs : NULL;
  ------------------
  |  Branch (396:33): [True: 29.8k, False: 0]
  ------------------
  397|  29.8k|    p->stream_info.osd = vo ? vo->osd : NULL;
  ------------------
  |  Branch (397:26): [True: 29.8k, False: 0]
  ------------------
  398|  29.8k|    p->stream_info.vflip = vo ? vo->driver->caps & VO_CAP_VFLIP : false;
  ------------------
  |  Branch (398:28): [True: 29.8k, False: 0]
  ------------------
  399|  29.8k|    p->stream_info.rotate90 = vo ? vo->driver->caps & VO_CAP_ROTATE90 : false;
  ------------------
  |  Branch (399:31): [True: 29.8k, False: 0]
  ------------------
  400|  29.8k|    p->stream_info.dr_vo = vo;
  401|  29.8k|    p->vo = vo;
  402|  29.8k|    update_output_caps(p);
  403|  29.8k|}
mp_output_chain_set_el_stream:
  407|  10.4M|{
  408|  10.4M|    struct chain *p = c->f->priv;
  409|       |
  410|  10.4M|    mp_assert(p->type == MP_OUTPUT_CHAIN_VIDEO);
  ------------------
  |  |   41|  10.4M|#define mp_assert assert
  ------------------
  |  Branch (410:5): [True: 10.4M, False: 0]
  ------------------
  411|       |
  412|  10.4M|    if (p->el_sh == el_sh && (!el_sh || p->el_pair))
  ------------------
  |  Branch (412:9): [True: 10.4M, False: 0]
  |  Branch (412:31): [True: 10.4M, False: 0]
  |  Branch (412:41): [True: 0, False: 0]
  ------------------
  413|  10.4M|        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|  15.3k|{
  446|  15.3k|    struct chain *p = c->f->priv;
  447|       |
  448|  15.3k|    mp_assert(p->public.ao_needs_update); // can't just call it any time
  ------------------
  |  |   41|  15.3k|#define mp_assert assert
  ------------------
  |  Branch (448:5): [True: 15.3k, False: 0]
  ------------------
  449|  15.3k|    mp_assert(!p->ao);
  ------------------
  |  |   41|  15.3k|#define mp_assert assert
  ------------------
  |  Branch (449:5): [True: 15.3k, False: 0]
  ------------------
  450|       |
  451|  15.3k|    p->public.ao_needs_update = false;
  452|       |
  453|  15.3k|    p->ao = ao;
  454|       |
  455|  15.3k|    int out_format = 0;
  456|  15.3k|    int out_rate = 0;
  457|  15.3k|    struct mp_chmap out_channels = {0};
  458|  15.3k|    ao_get_format(p->ao, &out_rate, &out_format, &out_channels);
  459|       |
  460|  15.3k|    mp_autoconvert_clear(p->convert);
  461|  15.3k|    mp_autoconvert_add_afmt(p->convert, out_format);
  462|  15.3k|    mp_autoconvert_add_srate(p->convert, out_rate);
  463|  15.3k|    mp_autoconvert_add_chmap(p->convert, &out_channels);
  464|       |
  465|  15.3k|    mp_autoconvert_format_change_continue(p->convert);
  466|       |
  467|       |    // Just to get the format change logged again.
  468|  15.3k|    mp_aframe_reset(p->public.output_aformat);
  469|  15.3k|}
mp_output_chain_command:
  505|      7|{
  506|      7|    struct chain *p = c->f->priv;
  507|       |
  508|      7|    if (!target || !target[0])
  ------------------
  |  Branch (508:9): [True: 0, False: 7]
  |  Branch (508:20): [True: 0, False: 7]
  ------------------
  509|      0|        return false;
  510|       |
  511|      7|    if (strcmp(target, "all") == 0 && cmd->type == MP_FILTER_COMMAND_TEXT) {
  ------------------
  |  Branch (511:9): [True: 0, False: 7]
  |  Branch (511:39): [True: 0, False: 0]
  ------------------
  512|       |        // (Following old semantics.)
  513|      0|        for (int n = 0; n < p->num_user_filters; n++)
  ------------------
  |  Branch (513:25): [True: 0, False: 0]
  ------------------
  514|      0|            mp_filter_command(p->user_filters[n]->f, cmd);
  515|      0|        return true;
  516|      0|    }
  517|       |
  518|      7|    struct mp_user_filter *f = find_by_label(p, target);
  519|      7|    if (!f)
  ------------------
  |  Branch (519:9): [True: 7, False: 0]
  ------------------
  520|      7|        return false;
  521|       |
  522|      0|    return mp_filter_command(f->f, cmd);
  523|      7|}
mp_output_chain_set_audio_speed:
  544|  33.4k|{
  545|  33.4k|    struct chain *p = c->f->priv;
  546|       |
  547|       |    // We always resample with the final libavresample instance.
  548|  33.4k|    set_speed_any(p->post_filters, p->num_post_filters,
  549|  33.4k|                  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|  33.4k|    set_speed_any(p->user_filters, p->num_user_filters,
  554|  33.4k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  555|  33.4k|    set_speed_any(p->post_filters, p->num_post_filters,
  556|  33.4k|                  MP_FILTER_COMMAND_SET_SPEED, &speed);
  557|  33.4k|    set_speed_any(p->user_filters, p->num_user_filters,
  558|  33.4k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  559|  33.4k|    set_speed_any(p->post_filters, p->num_post_filters,
  560|  33.4k|                  MP_FILTER_COMMAND_SET_SPEED_DROP, &drop);
  561|  33.4k|}
mp_output_get_measured_total_delay:
  564|  28.6k|{
  565|  28.6k|    struct chain *p = c->f->priv;
  566|       |
  567|  28.6k|    double delay = 0;
  568|       |
  569|   166k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (569:21): [True: 138k, False: 28.6k]
  ------------------
  570|   138k|        struct mp_user_filter *u = p->all_filters[n];
  571|       |
  572|   138k|        if (u->last_in_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|   276k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (572:13): [True: 106k, False: 31.5k]
  ------------------
  573|   106k|            u->last_out_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   106k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (573:13): [True: 106k, False: 141]
  ------------------
  574|   106k|        {
  575|   106k|            delay += u->last_in_pts - u->last_out_pts;
  576|   106k|        }
  577|   138k|    }
  578|       |
  579|  28.6k|    return delay;
  580|  28.6k|}
mp_output_chain_deinterlace_active:
  583|     15|{
  584|     15|    struct chain *p = c->f->priv;
  585|     30|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (585:21): [True: 30, False: 0]
  ------------------
  586|     30|        struct mp_user_filter *u = p->all_filters[n];
  587|     30|        if (strcmp(u->name, "userdeint") == 0)
  ------------------
  |  Branch (587:13): [True: 15, False: 15]
  ------------------
  588|     15|            return mp_deint_active(u->f);
  589|     30|    }
  590|      0|    return false;
  591|     15|}
mp_output_chain_update_filters:
  595|  61.2k|{
  596|  61.2k|    struct chain *p = c->f->priv;
  597|       |
  598|  61.2k|    struct mp_user_filter **add = NULL;      // new filters
  599|  61.2k|    int num_add = 0;
  600|  61.2k|    struct mp_user_filter **res = NULL;      // new final list
  601|  61.2k|    int num_res = 0;
  602|  61.2k|    bool *used = talloc_zero_array(NULL, bool, p->num_user_filters);
  ------------------
  |  |   30|  61.2k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  61.2k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  61.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|       |
  604|  76.6k|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (604:21): [True: 30.7k, False: 45.9k]
  |  Branch (604:29): [True: 15.5k, False: 15.1k]
  ------------------
  605|  15.5k|        struct m_obj_settings *entry = &list[n];
  606|       |
  607|  15.5k|        if (!entry->enabled)
  ------------------
  |  Branch (607:13): [True: 0, False: 15.5k]
  ------------------
  608|      0|            continue;
  609|       |
  610|  15.5k|        struct mp_user_filter *u = NULL;
  611|       |
  612|  23.3k|        for (int i = 0; i < p->num_user_filters; i++) {
  ------------------
  |  Branch (612:25): [True: 17.4k, False: 5.85k]
  ------------------
  613|  17.4k|            if (!used[i] && m_obj_settings_equal(entry, p->user_filters[i]->args))
  ------------------
  |  Branch (613:17): [True: 10.7k, False: 6.78k]
  |  Branch (613:29): [True: 9.65k, False: 1.05k]
  ------------------
  614|  9.65k|            {
  615|  9.65k|                u = p->user_filters[i];
  616|  9.65k|                used[i] = true;
  617|  9.65k|                break;
  618|  9.65k|            }
  619|  17.4k|        }
  620|       |
  621|  15.5k|        if (!u) {
  ------------------
  |  Branch (621:13): [True: 5.85k, False: 9.65k]
  ------------------
  622|  5.85k|            u = create_wrapper_filter(p);
  623|  5.85k|            u->name = talloc_strdup(u, entry->name);
  ------------------
  |  |   50|  5.85k|#define talloc_strdup                   ta_xstrdup
  ------------------
  624|  5.85k|            u->label = talloc_strdup(u, entry->label);
  ------------------
  |  |   50|  5.85k|#define talloc_strdup                   ta_xstrdup
  ------------------
  625|  5.85k|            u->f = mp_create_user_filter(u->wrapper, p->type, entry->name,
  626|  5.85k|                                         entry->attribs);
  627|  5.85k|            if (!u->f) {
  ------------------
  |  Branch (627:17): [True: 92, False: 5.76k]
  ------------------
  628|     92|                talloc_free(u->wrapper);
  ------------------
  |  |   47|     92|#define talloc_free                     ta_free
  ------------------
  629|     92|                goto error;
  630|     92|            }
  631|       |
  632|  5.76k|            struct m_obj_settings *args = (struct m_obj_settings[2]){*entry, {0}};
  633|       |
  634|  5.76k|            struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  635|  5.76k|            m_option_copy(&dummy, &u->args, &args);
  636|       |
  637|  5.76k|            MP_TARRAY_APPEND(NULL, add, num_add, u);
  ------------------
  |  |  105|  5.76k|    do {                                            \
  |  |  106|  5.76k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  5.76k|    do {                                            \
  |  |  |  |   97|  5.76k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  5.76k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  5.76k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  5.76k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 5.54k, False: 224]
  |  |  |  |  ------------------
  |  |  |  |   99|  5.76k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  5.54k|    do {                                                        \
  |  |  |  |  |  |   89|  5.54k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  5.54k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  5.54k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  5.54k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.54k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  5.54k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  5.54k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 5.54k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  5.76k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 5.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  5.76k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  5.76k|        (idxvar)++;                                 \
  |  |  109|  5.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.76k]
  |  |  ------------------
  ------------------
  638|  5.76k|        }
  639|       |
  640|  15.4k|        MP_TARRAY_APPEND(p, res, num_res, u);
  ------------------
  |  |  105|  15.4k|    do {                                            \
  |  |  106|  15.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  15.4k|    do {                                            \
  |  |  |  |   97|  15.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  15.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  15.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  15.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 13.8k, False: 1.59k]
  |  |  |  |  ------------------
  |  |  |  |   99|  15.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  13.8k|    do {                                                        \
  |  |  |  |  |  |   89|  13.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  13.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  13.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  13.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  13.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  13.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  13.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 13.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  15.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 15.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  15.4k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  15.4k|        (idxvar)++;                                 \
  |  |  109|  15.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15.4k]
  |  |  ------------------
  ------------------
  641|  15.4k|    }
  642|       |
  643|       |    // At this point we definitely know we'll use the new list, so clean up.
  644|       |
  645|  72.7k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (645:21): [True: 11.5k, False: 61.1k]
  ------------------
  646|  11.5k|        if (!used[n])
  ------------------
  |  Branch (646:13): [True: 1.89k, False: 9.65k]
  ------------------
  647|  1.89k|            talloc_free(p->user_filters[n]->wrapper);
  ------------------
  |  |   47|  1.89k|#define talloc_free                     ta_free
  ------------------
  648|  11.5k|    }
  649|       |
  650|  61.1k|    talloc_free(p->user_filters);
  ------------------
  |  |   47|  61.1k|#define talloc_free                     ta_free
  ------------------
  651|  61.1k|    p->user_filters = res;
  652|  61.1k|    p->num_user_filters = num_res;
  653|       |
  654|  61.1k|    relink_filter_list(p);
  655|       |
  656|  76.5k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (656:21): [True: 15.4k, False: 61.1k]
  ------------------
  657|  15.4k|        struct mp_user_filter *u = p->user_filters[n];
  658|  15.4k|        if (u->generated_label)
  ------------------
  |  Branch (658:13): [True: 9.65k, False: 5.76k]
  ------------------
  659|  9.65k|            TA_FREEP(&u->label);
  ------------------
  |  |   81|  9.65k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  9.65k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 9.65k]
  |  |  ------------------
  ------------------
  660|  15.4k|        if (!u->label) {
  ------------------
  |  Branch (660:13): [True: 15.4k, False: 0]
  ------------------
  661|  23.4k|            for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (661:29): [True: 23.4k, False: 0]
  ------------------
  662|  23.4k|                char *label = mp_tprintf(80, "%s.%02d", u->name, i);
  ------------------
  |  |  195|  23.4k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  663|  23.4k|                if (!find_by_label(p, label)) {
  ------------------
  |  Branch (663:21): [True: 15.4k, False: 8.02k]
  ------------------
  664|  15.4k|                    u->label = talloc_strdup(u, label);
  ------------------
  |  |   50|  15.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  665|  15.4k|                    u->generated_label = true;
  666|  15.4k|                    break;
  667|  15.4k|                }
  668|  23.4k|            }
  669|  15.4k|        }
  670|  15.4k|    }
  671|       |
  672|  61.1k|    MP_VERBOSE(p, "User filter list:\n");
  ------------------
  |  |   92|  61.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  61.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  673|  76.5k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (673:21): [True: 15.4k, False: 61.1k]
  ------------------
  674|  15.4k|        struct mp_user_filter *u = p->user_filters[n];
  675|  15.4k|        MP_VERBOSE(p, "  %s (%s)\n", u->name, u->label ? u->label : "-");
  ------------------
  |  |   92|  15.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  30.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 15.4k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|  15.4k|    }
  677|  61.1k|    if (!p->num_user_filters)
  ------------------
  |  Branch (677:9): [True: 47.9k, False: 13.1k]
  ------------------
  678|  61.1k|        MP_VERBOSE(p, "  (empty)\n");
  ------------------
  |  |   92|  47.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  47.9k|#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|  61.1k|    update_output_caps(p);
  682|       |
  683|  61.1k|    mp_filter_wakeup(p->f);
  684|       |
  685|  61.1k|    talloc_free(add);
  ------------------
  |  |   47|  61.1k|#define talloc_free                     ta_free
  ------------------
  686|  61.1k|    talloc_free(used);
  ------------------
  |  |   47|  61.1k|#define talloc_free                     ta_free
  ------------------
  687|  61.1k|    return true;
  688|       |
  689|     92|error:
  690|     92|    for (int n = 0; n < num_add; n++)
  ------------------
  |  Branch (690:21): [True: 0, False: 92]
  ------------------
  691|      0|        talloc_free(add[n]->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  692|     92|    talloc_free(add);
  ------------------
  |  |   47|     92|#define talloc_free                     ta_free
  ------------------
  693|     92|    talloc_free(used);
  ------------------
  |  |   47|     92|#define talloc_free                     ta_free
  ------------------
  694|       |    return false;
  695|  61.2k|}
mp_output_chain_create:
  743|  46.5k|{
  744|  46.5k|    struct mp_filter *f = mp_filter_create(parent, &output_chain_filter);
  745|  46.5k|    if (!f)
  ------------------
  |  Branch (745:9): [True: 0, False: 46.5k]
  ------------------
  746|      0|        return NULL;
  747|       |
  748|  46.5k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  749|  46.5k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  750|       |
  751|  46.5k|    const char *log_name = NULL;
  752|  46.5k|    switch (type) {
  ------------------
  |  Branch (752:13): [True: 46.5k, False: 0]
  ------------------
  753|  29.8k|    case MP_OUTPUT_CHAIN_VIDEO: log_name = "!vf"; break;
  ------------------
  |  Branch (753:5): [True: 29.8k, False: 16.7k]
  ------------------
  754|  16.7k|    case MP_OUTPUT_CHAIN_AUDIO: log_name = "!af"; break;
  ------------------
  |  Branch (754:5): [True: 16.7k, False: 29.8k]
  ------------------
  755|  46.5k|    }
  756|  46.5k|    if (log_name)
  ------------------
  |  Branch (756:9): [True: 46.5k, False: 0]
  ------------------
  757|  46.5k|        f->log = mp_log_new(f, parent->global->log, log_name);
  758|       |
  759|  46.5k|    struct chain *p = f->priv;
  760|  46.5k|    p->f = f;
  761|  46.5k|    p->log = f->log;
  762|  46.5k|    p->type = type;
  763|       |
  764|  46.5k|    struct mp_output_chain *c = &p->public;
  765|  46.5k|    c->f = f;
  766|  46.5k|    c->input_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  46.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  46.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  767|  46.5k|    c->output_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  46.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  46.5k|#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|  46.5k|    p->input = create_wrapper_filter(p);
  771|  46.5k|    p->input->f = mp_bidir_nop_filter_create(p->input->wrapper);
  772|  46.5k|    if (!p->input->f)
  ------------------
  |  Branch (772:9): [True: 0, False: 46.5k]
  ------------------
  773|      0|        abort();
  774|  46.5k|    p->input->name = "in";
  775|  46.5k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, p->input);
  ------------------
  |  |  105|  46.5k|    do {                                            \
  |  |  106|  46.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  46.5k|    do {                                            \
  |  |  |  |   97|  46.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  46.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  46.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  46.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 46.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  46.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  46.5k|    do {                                                        \
  |  |  |  |  |  |   89|  46.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  46.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  46.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  46.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  46.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  46.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  46.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 46.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  46.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 46.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  46.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  46.5k|        (idxvar)++;                                 \
  |  |  109|  46.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 46.5k]
  |  |  ------------------
  ------------------
  776|       |
  777|  46.5k|    switch (type) {
  ------------------
  |  Branch (777:13): [True: 46.5k, False: 0]
  ------------------
  778|  29.8k|    case MP_OUTPUT_CHAIN_VIDEO: create_video_things(p); break;
  ------------------
  |  Branch (778:5): [True: 29.8k, False: 16.7k]
  ------------------
  779|  16.7k|    case MP_OUTPUT_CHAIN_AUDIO: create_audio_things(p); break;
  ------------------
  |  Branch (779:5): [True: 16.7k, False: 29.8k]
  ------------------
  780|  46.5k|    }
  781|       |
  782|  46.5k|    p->convert_wrapper = create_wrapper_filter(p);
  783|  46.5k|    p->convert = mp_autoconvert_create(p->convert_wrapper->wrapper);
  784|  46.5k|    if (!p->convert)
  ------------------
  |  Branch (784:9): [True: 0, False: 46.5k]
  ------------------
  785|      0|        abort();
  786|  46.5k|    p->convert_wrapper->name = "convert";
  787|  46.5k|    p->convert_wrapper->f = p->convert->f;
  788|  46.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->convert_wrapper);
  ------------------
  |  |  105|  46.5k|    do {                                            \
  |  |  106|  46.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  46.5k|    do {                                            \
  |  |  |  |   97|  46.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  46.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  46.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  46.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 29.8k, False: 16.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  46.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  29.8k|    do {                                                        \
  |  |  |  |  |  |   89|  29.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  29.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  29.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  29.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  29.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  29.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  29.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 29.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  46.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 46.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  46.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  46.5k|        (idxvar)++;                                 \
  |  |  109|  46.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 46.5k]
  |  |  ------------------
  ------------------
  789|       |
  790|  46.5k|    if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (790:9): [True: 16.7k, False: 29.8k]
  ------------------
  791|  16.7k|        p->convert->on_audio_format_change = on_audio_format_change;
  792|  16.7k|        p->convert->on_audio_format_change_opaque = p;
  793|  16.7k|    }
  794|       |
  795|       |    // Dummy filter for reporting and logging the output format.
  796|  46.5k|    p->output = create_wrapper_filter(p);
  797|  46.5k|    p->output->f = mp_bidir_nop_filter_create(p->output->wrapper);
  798|  46.5k|    if (!p->output->f)
  ------------------
  |  Branch (798:9): [True: 0, False: 46.5k]
  ------------------
  799|      0|        abort();
  800|  46.5k|    p->output->name = "out";
  801|  46.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->output);
  ------------------
  |  |  105|  46.5k|    do {                                            \
  |  |  106|  46.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  46.5k|    do {                                            \
  |  |  |  |   97|  46.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  46.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  46.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  46.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 16.7k, False: 29.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  46.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  16.7k|    do {                                                        \
  |  |  |  |  |  |   89|  16.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  16.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  16.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  16.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  16.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  16.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  16.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 16.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  46.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 46.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  46.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  46.5k|        (idxvar)++;                                 \
  |  |  109|  46.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 46.5k]
  |  |  ------------------
  ------------------
  802|       |
  803|  46.5k|    relink_filter_list(p);
  804|       |
  805|  46.5k|    output_chain_reset(f);
  806|       |
  807|  46.5k|    return c;
  808|  46.5k|}
f_output_chain.c:update_output_caps:
   85|   106k|{
   86|   106k|    if (p->type != MP_OUTPUT_CHAIN_VIDEO)
  ------------------
  |  Branch (86:9): [True: 31.0k, False: 75.8k]
  ------------------
   87|  31.0k|        return;
   88|       |
   89|  75.8k|    mp_autoconvert_clear(p->convert);
   90|       |
   91|  75.8k|    if (p->vo) {
  ------------------
  |  Branch (91:9): [True: 75.8k, False: 0]
  ------------------
   92|  75.8k|        uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START] = {0};
   93|  75.8k|        vo_query_formats(p->vo, allowed_output_formats);
   94|       |
   95|  42.4M|        for (int n = 0; n < MP_ARRAY_SIZE(allowed_output_formats); n++) {
  ------------------
  |  |   49|  42.4M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (95:25): [True: 42.3M, False: 75.8k]
  ------------------
   96|  42.3M|            if (allowed_output_formats[n])
  ------------------
  |  Branch (96:17): [True: 42.3M, False: 0]
  ------------------
   97|  42.3M|                mp_autoconvert_add_imgfmt(p->convert, IMGFMT_START + n, 0);
   98|  42.3M|        }
   99|  75.8k|    }
  100|  75.8k|}
f_output_chain.c:create_wrapper_filter:
  258|   251k|{
  259|   251k|    struct mp_filter *f = mp_filter_create(p->f, &user_wrapper_filter);
  260|   251k|    if (!f)
  ------------------
  |  Branch (260:9): [True: 0, False: 251k]
  ------------------
  261|      0|        abort();
  262|   251k|    struct mp_user_filter *wrapper = f->priv;
  263|   251k|    wrapper->wrapper = f;
  264|   251k|    wrapper->p = p;
  265|   251k|    wrapper->last_in_aformat = talloc_steal(wrapper, mp_aframe_create());
  ------------------
  |  |   38|   251k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   251k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  266|       |    wrapper->last_is_active = true;
  267|   251k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  268|   251k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  269|   251k|    return wrapper;
  270|   251k|}
f_output_chain.c:user_wrapper_destroy:
  240|   251k|{
  241|   251k|    struct mp_user_filter *u = f->priv;
  242|       |
  243|   251k|    struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  244|   251k|    m_option_free(&dummy, &u->args);
  245|       |
  246|   251k|    mp_filter_free_children(f);
  247|   251k|}
f_output_chain.c:user_wrapper_process:
  157|   104M|{
  158|   104M|    struct mp_user_filter *u = f->priv;
  159|   104M|    struct chain *p = u->p;
  160|       |
  161|   104M|    mp_filter_set_error_handler(u->f, f);
  162|   104M|    const char *name = u->label ? u->label : u->name;
  ------------------
  |  Branch (162:24): [True: 2.41M, False: 102M]
  ------------------
  163|   104M|    mp_assert(u->name);
  ------------------
  |  |   41|   104M|#define mp_assert assert
  ------------------
  |  Branch (163:5): [True: 104M, False: 0]
  ------------------
  164|       |
  165|   104M|    if (!u->failed && mp_filter_has_failed(u->f)) {
  ------------------
  |  Branch (165:9): [True: 104M, False: 8.86k]
  |  Branch (165:23): [True: 303, False: 104M]
  ------------------
  166|    303|        if (u == p->convert_wrapper) {
  ------------------
  |  Branch (166:13): [True: 0, False: 303]
  ------------------
  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|    303|        } else {
  173|    303|            MP_ERR(p, "Disabling filter %s because it has failed.\n", name);
  ------------------
  |  |   89|    303|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    303|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  174|    303|            mp_filter_reset(u->f); // clear out staled buffered data
  175|    303|        }
  176|    303|        u->failed = true;
  177|    303|    }
  178|       |
  179|   104M|    if (u->failed) {
  ------------------
  |  Branch (179:9): [True: 9.17k, False: 104M]
  ------------------
  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|  9.17k|        if (u == p->convert_wrapper || u->in_eof) {
  ------------------
  |  Branch (184:13): [True: 0, False: 9.17k]
  |  Branch (184:40): [True: 0, False: 9.17k]
  ------------------
  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|  9.17k|        mp_pin_transfer_data(f->ppins[1], f->ppins[0]);
  194|  9.17k|        return;
  195|  9.17k|    }
  196|       |
  197|   104M|    if (mp_pin_can_transfer_data(u->f->pins[0], f->ppins[0])) {
  ------------------
  |  Branch (197:9): [True: 26.1M, False: 78.4M]
  ------------------
  198|  26.1M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  199|       |
  200|  26.1M|        check_in_format_change(u, frame);
  201|       |
  202|  26.1M|        double pts = mp_frame_get_pts(frame);
  203|  26.1M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  26.1M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (203:13): [True: 1.37M, False: 24.7M]
  ------------------
  204|  1.37M|            u->last_in_pts = pts;
  205|       |
  206|  26.1M|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (206:13): [True: 24.7M, False: 1.37M]
  ------------------
  207|  24.7M|            u->in_eof = true;
  208|       |
  209|  26.1M|        mp_pin_in_write(u->f->pins[0], frame);
  210|  26.1M|    }
  211|       |
  212|   104M|    if (mp_pin_can_transfer_data(f->ppins[1], u->f->pins[1])) {
  ------------------
  |  Branch (212:9): [True: 26.2M, False: 78.3M]
  ------------------
  213|  26.2M|        struct mp_frame frame = mp_pin_out_read(u->f->pins[1]);
  214|       |
  215|  26.2M|        double pts = mp_frame_get_pts(frame);
  216|  26.2M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  26.2M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (216:13): [True: 1.49M, False: 24.7M]
  ------------------
  217|  1.49M|            u->last_out_pts = pts;
  218|       |
  219|  26.2M|        mp_pin_in_write(f->ppins[1], frame);
  220|       |
  221|  26.2M|        struct mp_filter_command cmd = {.type = MP_FILTER_COMMAND_IS_ACTIVE};
  222|  26.2M|        if (mp_filter_command(u->f, &cmd) && u->last_is_active != cmd.is_active) {
  ------------------
  |  Branch (222:13): [True: 15.4M, False: 10.8M]
  |  Branch (222:46): [True: 107k, False: 15.2M]
  ------------------
  223|   107k|            u->last_is_active = cmd.is_active;
  224|   107k|            MP_VERBOSE(p, "[%s] (%sabled)\n", u->name,
  ------------------
  |  |   92|   107k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   215k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 868, False: 106k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|   107k|                       u->last_is_active ? "en" : "dis");
  226|   107k|        }
  227|  26.2M|    }
  228|   104M|}
f_output_chain.c:check_in_format_change:
  104|  26.1M|{
  105|  26.1M|    struct chain *p = u->p;
  106|       |
  107|  26.1M|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (107:9): [True: 228k, False: 25.8M]
  ------------------
  108|   228k|        struct mp_image *img = frame.data;
  109|       |
  110|   228k|        if (!mp_image_params_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (110:13): [True: 95.2k, False: 132k]
  ------------------
  111|  95.2k|            if (u == p->input) {
  ------------------
  |  Branch (111:17): [True: 15.8k, False: 79.4k]
  ------------------
  112|  15.8k|                p->public.input_params = img->params;
  113|  79.4k|            } else if (u == p->output) {
  ------------------
  |  Branch (113:24): [True: 15.8k, False: 63.5k]
  ------------------
  114|  15.8k|                p->public.output_params = img->params;
  115|  15.8k|            }
  116|       |
  117|  95.2k|            if (!mp_image_params_static_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (117:17): [True: 95.2k, False: 0]
  ------------------
  118|  95.2k|                MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  95.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  95.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  119|  95.2k|                           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|  95.2k|                if (strcmp(u->name, "convert") == 0)
  ------------------
  |  Branch (128:21): [True: 15.8k, False: 79.4k]
  ------------------
  129|  15.8k|                    update_output_caps(p);
  130|       |
  131|  95.2k|                p->public.reconfig_happened = true;
  132|  95.2k|            }
  133|  95.2k|            u->last_in_vformat = img->params;
  134|  95.2k|        }
  135|   228k|    }
  136|       |
  137|  26.1M|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (137:9): [True: 1.15M, False: 24.9M]
  ------------------
  138|  1.15M|        struct mp_aframe *aframe = frame.data;
  139|       |
  140|  1.15M|        if (!mp_aframe_config_equals(aframe, u->last_in_aformat)) {
  ------------------
  |  Branch (140:13): [True: 62.9k, False: 1.08M]
  ------------------
  141|  62.9k|            MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|  62.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  62.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  142|  62.9k|                       mp_aframe_format_str(aframe));
  143|  62.9k|            mp_aframe_config_copy(u->last_in_aformat, aframe);
  144|       |
  145|  62.9k|            if (u == p->input) {
  ------------------
  |  Branch (145:17): [True: 15.2k, False: 47.7k]
  ------------------
  146|  15.2k|                mp_aframe_config_copy(p->public.input_aformat, aframe);
  147|  47.7k|            } else if (u == p->output) {
  ------------------
  |  Branch (147:24): [True: 15.0k, False: 32.6k]
  ------------------
  148|  15.0k|                mp_aframe_config_copy(p->public.output_aformat, aframe);
  149|  15.0k|            }
  150|       |
  151|       |            p->public.reconfig_happened = true;
  152|  62.9k|        }
  153|  1.15M|    }
  154|  26.1M|}
f_output_chain.c:user_wrapper_reset:
  231|  24.8M|{
  232|  24.8M|    struct mp_user_filter *u = f->priv;
  233|       |
  234|  24.8M|    u->error_eof_sent = false;
  235|  24.8M|    u->in_eof = false;
  236|  24.8M|    u->last_in_pts = u->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  24.8M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  237|  24.8M|}
f_output_chain.c:relink_filter_list:
  274|   107k|{
  275|   107k|    struct mp_user_filter **all_filters[3] =
  276|   107k|        {p->pre_filters, p->user_filters, p->post_filters};
  277|   107k|    int all_filters_num[3] =
  278|   107k|        {p->num_pre_filters, p->num_user_filters, p->num_post_filters};
  279|   107k|    p->num_all_filters = 0;
  280|   430k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (280:21): [True: 323k, False: 107k]
  ------------------
  281|   323k|        struct mp_user_filter **filters = all_filters[n];
  282|   323k|        int filters_num = all_filters_num[n];
  283|   889k|        for (int i = 0; i < filters_num; i++)
  ------------------
  |  Branch (283:25): [True: 566k, False: 323k]
  ------------------
  284|   566k|            MP_TARRAY_APPEND(p, p->all_filters, p->num_all_filters, filters[i]);
  ------------------
  |  |  105|   566k|    do {                                            \
  |  |  106|   566k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   566k|    do {                                            \
  |  |  |  |   97|   566k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   566k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   566k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   566k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 94.0k, False: 472k]
  |  |  |  |  ------------------
  |  |  |  |   99|   566k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  94.0k|    do {                                                        \
  |  |  |  |  |  |   89|  94.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  94.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  94.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  94.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  94.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  94.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  94.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 94.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   566k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 566k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   566k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   566k|        (idxvar)++;                                 \
  |  |  109|   566k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 566k]
  |  |  ------------------
  ------------------
  285|   323k|    }
  286|       |
  287|   107k|    mp_assert(p->num_all_filters > 0);
  ------------------
  |  |   41|   107k|#define mp_assert assert
  ------------------
  |  Branch (287:5): [True: 107k, False: 0]
  ------------------
  288|       |
  289|   107k|    p->filters_in = NULL;
  290|   107k|    p->filters_out = NULL;
  291|   673k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (291:21): [True: 566k, False: 107k]
  ------------------
  292|   566k|        struct mp_filter *f = p->all_filters[n]->wrapper;
  293|   566k|        if (n == 0)
  ------------------
  |  Branch (293:13): [True: 107k, False: 458k]
  ------------------
  294|   107k|            p->filters_in = f->pins[0];
  295|   566k|        if (p->filters_out)
  ------------------
  |  Branch (295:13): [True: 458k, False: 107k]
  ------------------
  296|   458k|            mp_pin_connect(f->pins[0], p->filters_out);
  297|   566k|        p->filters_out = f->pins[1];
  298|   566k|    }
  299|       |
  300|   107k|    mp_pin_set_manual_connection_for(p->filters_in, p->f);
  301|   107k|    mp_pin_set_manual_connection_for(p->filters_out, p->f);
  302|   107k|}
f_output_chain.c:find_by_label:
  494|  23.4k|{
  495|  69.7k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (495:21): [True: 54.2k, False: 15.4k]
  ------------------
  496|  54.2k|        struct mp_user_filter *u = p->user_filters[n];
  497|  54.2k|        if (label && u->label && strcmp(label, u->label) == 0)
  ------------------
  |  Branch (497:13): [True: 54.2k, False: 0]
  |  Branch (497:22): [True: 36.9k, False: 17.3k]
  |  Branch (497:34): [True: 8.02k, False: 28.9k]
  ------------------
  498|  8.02k|            return u;
  499|  54.2k|    }
  500|  15.4k|    return NULL;
  501|  23.4k|}
f_output_chain.c:set_speed_any:
  530|   167k|{
  531|   497k|    for (int n = num_filters - 1; n >= 0; n--) {
  ------------------
  |  Branch (531:35): [True: 330k, False: 167k]
  ------------------
  532|   330k|        mp_assert(*speed);
  ------------------
  |  |   41|   330k|#define mp_assert assert
  ------------------
  |  Branch (532:9): [True: 330k, False: 0]
  ------------------
  533|   330k|        struct mp_filter_command cmd = {
  534|   330k|            .type = command,
  535|   330k|            .speed = *speed,
  536|   330k|        };
  537|   330k|        if (mp_filter_command(filters[n]->f, &cmd))
  ------------------
  |  Branch (537:13): [True: 100k, False: 230k]
  ------------------
  538|   100k|            *speed = 1.0;
  539|   330k|    }
  540|   167k|}
f_output_chain.c:output_chain_destroy:
  364|  46.5k|{
  365|  46.5k|    output_chain_reset(f);
  366|  46.5k|}
f_output_chain.c:output_chain_process:
  305|  20.5M|{
  306|  20.5M|    struct chain *p = f->priv;
  307|       |
  308|  20.5M|    if (mp_pin_can_transfer_data(p->filters_in, f->ppins[0])) {
  ------------------
  |  Branch (308:9): [True: 5.06M, False: 15.4M]
  ------------------
  309|  5.06M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  310|       |
  311|  5.06M|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (311:13): [True: 4.80M, False: 260k]
  ------------------
  312|  5.06M|            MP_VERBOSE(p, "filter input EOF\n");
  ------------------
  |  |   92|  4.80M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.80M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  313|       |
  314|  5.06M|        if (frame.type == MP_FRAME_VIDEO && p->public.update_subtitles) {
  ------------------
  |  Branch (314:13): [True: 37.9k, False: 5.02M]
  |  Branch (314:45): [True: 37.9k, False: 0]
  ------------------
  315|  37.9k|            p->public.update_subtitles(p->public.update_subtitles_ctx,
  316|  37.9k|                                       mp_frame_get_pts(frame));
  317|  37.9k|        }
  318|       |
  319|  5.06M|        mp_pin_in_write(p->filters_in, frame);
  320|  5.06M|    }
  321|       |
  322|  20.5M|    if (mp_pin_can_transfer_data(f->ppins[1], p->filters_out)) {
  ------------------
  |  Branch (322:9): [True: 5.17M, False: 15.3M]
  ------------------
  323|  5.17M|        struct mp_frame frame = mp_pin_out_read(p->filters_out);
  324|       |
  325|  5.17M|        p->public.got_output_eof = frame.type == MP_FRAME_EOF;
  326|  5.17M|        if (p->public.got_output_eof)
  ------------------
  |  Branch (326:13): [True: 4.80M, False: 372k]
  ------------------
  327|  5.17M|            MP_VERBOSE(p, "filter output EOF\n");
  ------------------
  |  |   92|  4.80M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.80M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  328|       |
  329|  5.17M|        mp_pin_in_write(f->ppins[1], frame);
  330|  5.17M|    }
  331|  20.5M|}
f_output_chain.c:create_video_things:
  698|  29.8k|{
  699|  29.8k|    p->frame_type = MP_FRAME_VIDEO;
  700|       |
  701|  29.8k|    p->stream_info.priv = p;
  702|  29.8k|    p->stream_info.get_display_fps = get_display_fps;
  703|  29.8k|    p->stream_info.get_display_res = get_display_res;
  704|       |
  705|  29.8k|    p->f->stream_info = &p->stream_info;
  706|       |
  707|  29.8k|    struct mp_user_filter *f = create_wrapper_filter(p);
  708|  29.8k|    f->name = "userdeint";
  709|  29.8k|    f->f = mp_deint_create(f->wrapper);
  710|  29.8k|    if (!f->f)
  ------------------
  |  Branch (710:9): [True: 0, False: 29.8k]
  ------------------
  711|      0|        abort();
  712|  29.8k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, f);
  ------------------
  |  |  105|  29.8k|    do {                                            \
  |  |  106|  29.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.8k|    do {                                            \
  |  |  |  |   97|  29.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 29.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.8k|        (idxvar)++;                                 \
  |  |  109|  29.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  713|       |
  714|  29.8k|    f = create_wrapper_filter(p);
  715|  29.8k|    f->name = "autovflip";
  716|  29.8k|    f->f = mp_autovflip_create(f->wrapper);
  717|  29.8k|    if (!f->f)
  ------------------
  |  Branch (717:9): [True: 0, False: 29.8k]
  ------------------
  718|      0|        abort();
  719|  29.8k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  29.8k|    do {                                            \
  |  |  106|  29.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.8k|    do {                                            \
  |  |  |  |   97|  29.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 29.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  29.8k|    do {                                                        \
  |  |  |  |  |  |   89|  29.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  29.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  29.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  29.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  29.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  29.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  29.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 29.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.8k|        (idxvar)++;                                 \
  |  |  109|  29.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  720|       |
  721|  29.8k|    f = create_wrapper_filter(p);
  722|  29.8k|    f->name = "autorotate";
  723|  29.8k|    f->f = mp_autorotate_create(f->wrapper);
  724|  29.8k|    if (!f->f)
  ------------------
  |  Branch (724:9): [True: 0, False: 29.8k]
  ------------------
  725|      0|        abort();
  726|  29.8k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  29.8k|    do {                                            \
  |  |  106|  29.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  29.8k|    do {                                            \
  |  |  |  |   97|  29.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  29.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  29.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  29.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 29.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  29.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  29.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 29.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  29.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  29.8k|        (idxvar)++;                                 \
  |  |  109|  29.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  727|  29.8k|}
f_output_chain.c:create_audio_things:
  730|  16.7k|{
  731|  16.7k|    p->frame_type = MP_FRAME_AUDIO;
  732|       |
  733|  16.7k|    struct mp_user_filter *f = create_wrapper_filter(p);
  734|  16.7k|    f->name = "userspeed";
  735|  16.7k|    f->f = mp_autoaspeed_create(f->wrapper);
  736|  16.7k|    if (!f->f)
  ------------------
  |  Branch (736:9): [True: 0, False: 16.7k]
  ------------------
  737|      0|        abort();
  738|  16.7k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  16.7k|    do {                                            \
  |  |  106|  16.7k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  16.7k|    do {                                            \
  |  |  |  |   97|  16.7k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  16.7k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  16.7k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  16.7k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 16.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  16.7k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  16.7k|    do {                                                        \
  |  |  |  |  |  |   89|  16.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  16.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  16.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  16.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  16.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  16.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  16.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 16.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  16.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 16.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  16.7k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  16.7k|        (idxvar)++;                                 \
  |  |  109|  16.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 16.7k]
  |  |  ------------------
  ------------------
  739|  16.7k|}
f_output_chain.c:on_audio_format_change:
  472|  15.7k|{
  473|  15.7k|    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|  15.7k|    mp_aframe_config_copy(p->public.output_aformat,
  481|  15.7k|                          p->convert_wrapper->last_in_aformat);
  482|       |
  483|       |    // Ask for calling mp_output_chain_set_ao().
  484|  15.7k|    p->public.ao_needs_update = true;
  485|  15.7k|    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|  15.7k|    mp_filter_wakeup(p->f);
  491|  15.7k|}
f_output_chain.c:output_chain_reset:
  334|  4.90M|{
  335|  4.90M|    struct chain *p = f->priv;
  336|       |
  337|  4.90M|    p->public.ao_needs_update = false;
  338|       |
  339|       |    p->public.got_output_eof = false;
  340|  4.90M|}

mp_swresample_create:
  613|  3.55k|{
  614|  3.55k|    struct mp_filter *f = mp_filter_create(parent, &swresample_filter);
  615|  3.55k|    if (!f)
  ------------------
  |  Branch (615:9): [True: 0, False: 3.55k]
  ------------------
  616|      0|        return NULL;
  617|       |
  618|  3.55k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  619|  3.55k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  620|       |
  621|  3.55k|    struct priv *p = f->priv;
  622|  3.55k|    p->public.f = f;
  623|  3.55k|    p->public.speed = 1.0;
  624|  3.55k|    p->cmd_speed = 1.0;
  625|  3.55k|    p->log = f->log;
  626|       |
  627|  3.55k|    if (opts) {
  ------------------
  |  Branch (627:9): [True: 0, False: 3.55k]
  ------------------
  628|      0|        p->opts = talloc_dup(p, opts);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|      0|        p->opts->avopts = mp_dup_str_array(p, p->opts->avopts);
  630|  3.55k|    } else {
  631|  3.55k|        p->opts = mp_get_config_group(p, f->global, &resample_conf);
  632|  3.55k|    }
  633|       |
  634|  3.55k|    p->out_pool = mp_aframe_pool_create(p);
  635|       |
  636|  3.55k|    return &p->public;
  637|  3.55k|}
f_swresample.c:get_delay:
   81|   260k|{
   82|   260k|    int64_t base = p->in_rate * (int64_t)p->out_rate;
   83|   260k|    return swr_get_delay(p->avrctx, base) / (double)base;
   84|   260k|}
f_swresample.c:swresample_destroy:
  595|  3.55k|{
  596|  3.55k|    struct priv *p = f->priv;
  597|       |
  598|  3.55k|    close_lavrr(p);
  599|       |    TA_FREEP(&p->input);
  ------------------
  |  |   81|  3.55k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  3.55k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 3.55k]
  |  |  ------------------
  ------------------
  600|  3.55k|}
f_swresample.c:close_lavrr:
   91|  7.28k|{
   92|  7.28k|    swr_free(&p->avrctx);
   93|       |
   94|       |    TA_FREEP(&p->out_fmt);
  ------------------
  |  |   81|  7.28k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  7.28k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 7.28k]
  |  |  ------------------
  ------------------
   95|  7.28k|}
f_swresample.c:swresample_process:
  422|  3.23M|{
  423|  3.23M|    struct priv *p = f->priv;
  424|       |
  425|  3.23M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (425:9): [True: 3.55k, False: 3.22M]
  ------------------
  426|  3.55k|        return;
  427|       |
  428|  3.22M|    p->speed = p->cmd_speed * p->public.speed;
  429|       |
  430|  3.22M|    struct mp_aframe *input = NULL;
  431|  3.22M|    if (!p->input) {
  ------------------
  |  Branch (431:9): [True: 3.22M, False: 151]
  ------------------
  432|  3.22M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  433|       |
  434|  3.22M|        if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (434:13): [True: 260k, False: 2.96M]
  ------------------
  435|   260k|            input = frame.data;
  436|  2.96M|        } else if (!frame.type) {
  ------------------
  |  Branch (436:20): [True: 1.61M, False: 1.35M]
  ------------------
  437|  1.61M|            return; // no new data
  438|  1.61M|        } else if (frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (438:20): [True: 0, False: 1.35M]
  ------------------
  439|      0|            MP_ERR(p, "Unsupported 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__)
  |  |  ------------------
  ------------------
  440|      0|            mp_frame_unref(&frame);
  441|      0|            mp_filter_internal_mark_failed(f);
  442|      0|            return;
  443|      0|        }
  444|       |
  445|  1.61M|        if (!input && !p->avrctx) {
  ------------------
  |  Branch (445:13): [True: 1.35M, False: 260k]
  |  Branch (445:23): [True: 0, False: 1.35M]
  ------------------
  446|       |            // Obviously no draining needed.
  447|      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)})
  |  |  ------------------
  ------------------
  448|      0|            return;
  449|      0|        }
  450|  1.61M|    }
  451|       |
  452|  1.61M|    if (input) {
  ------------------
  |  Branch (452:9): [True: 260k, False: 1.35M]
  ------------------
  453|   260k|        mp_assert(!p->input);
  ------------------
  |  |   41|   260k|#define mp_assert assert
  ------------------
  |  Branch (453:9): [True: 260k, False: 0]
  ------------------
  454|       |
  455|   260k|        struct mp_swresample *s = &p->public;
  456|       |
  457|   260k|        int in_rate = mp_aframe_get_rate(input);
  458|   260k|        int in_format = mp_aframe_get_format(input);
  459|   260k|        struct mp_chmap in_channels = {0};
  460|   260k|        mp_aframe_get_chmap(input, &in_channels);
  461|       |
  462|   260k|        if (!in_rate || !in_format || !in_channels.num) {
  ------------------
  |  Branch (462:13): [True: 0, False: 260k]
  |  Branch (462:25): [True: 0, False: 260k]
  |  Branch (462:39): [True: 0, False: 260k]
  ------------------
  463|      0|            MP_ERR(p, "Frame with invalid 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__)
  |  |  ------------------
  ------------------
  464|      0|            talloc_free(input);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  465|      0|            mp_filter_internal_mark_failed(f);
  466|      0|            return;
  467|      0|        }
  468|       |
  469|   260k|        int out_rate = s->out_rate ? s->out_rate : in_rate;
  ------------------
  |  Branch (469:24): [True: 260k, False: 0]
  ------------------
  470|   260k|        int out_format = s->out_format ? s->out_format : in_format;
  ------------------
  |  Branch (470:26): [True: 260k, False: 0]
  ------------------
  471|   260k|        struct mp_chmap out_channels =
  472|   260k|            s->out_channels.num ? s->out_channels : in_channels;
  ------------------
  |  Branch (472:13): [True: 260k, False: 0]
  ------------------
  473|       |
  474|   260k|        if (p->in_rate_user != in_rate ||
  ------------------
  |  Branch (474:13): [True: 3.55k, False: 256k]
  ------------------
  475|   256k|            p->in_format != in_format ||
  ------------------
  |  Branch (475:13): [True: 0, False: 256k]
  ------------------
  476|   256k|            !mp_chmap_equals(&p->in_channels, &in_channels) ||
  ------------------
  |  Branch (476:13): [True: 0, False: 256k]
  ------------------
  477|   256k|            p->out_rate != out_rate ||
  ------------------
  |  Branch (477:13): [True: 0, False: 256k]
  ------------------
  478|   256k|            p->out_format != out_format ||
  ------------------
  |  Branch (478:13): [True: 0, False: 256k]
  ------------------
  479|   256k|            !mp_chmap_equals(&p->out_channels, &out_channels) ||
  ------------------
  |  Branch (479:13): [True: 0, False: 256k]
  ------------------
  480|   256k|            !p->avrctx)
  ------------------
  |  Branch (480:13): [True: 0, False: 256k]
  ------------------
  481|  3.55k|        {
  482|  3.55k|            if (p->avrctx) {
  ------------------
  |  Branch (482:17): [True: 0, False: 3.55k]
  ------------------
  483|       |                // drain remaining audio
  484|      0|                struct mp_frame out = filter_resample_output(p, NULL);
  485|      0|                if (out.type) {
  ------------------
  |  Branch (485:21): [True: 0, False: 0]
  ------------------
  486|      0|                    mp_pin_in_write(f->ppins[1], out);
  487|       |                    // continue filtering next time.
  488|      0|                    mp_pin_out_unread(f->ppins[0],
  489|      0|                                      MAKE_FRAME(MP_FRAME_AUDIO, input));
  ------------------
  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
  490|      0|                    input = NULL;
  491|      0|                }
  492|      0|            }
  493|       |
  494|  3.55k|            MP_VERBOSE(p, "format change, reinitializing resampler\n");
  ------------------
  |  |   92|  3.55k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.55k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  495|       |
  496|  3.55k|            p->in_rate_user = in_rate;
  497|  3.55k|            p->in_format = in_format;
  498|  3.55k|            p->in_channels = in_channels;
  499|  3.55k|            p->out_rate = out_rate;
  500|  3.55k|            p->out_format = out_format;
  501|  3.55k|            p->out_channels = out_channels;
  502|       |
  503|  3.55k|            if (!configure_lavrr(p, true)) {
  ------------------
  |  Branch (503:17): [True: 0, False: 3.55k]
  ------------------
  504|      0|                talloc_free(input);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  505|      0|                return;
  506|      0|            }
  507|       |
  508|  3.55k|            if (!input) {
  ------------------
  |  Branch (508:17): [True: 0, False: 3.55k]
  ------------------
  509|       |                // continue filtering next time
  510|      0|                mp_filter_internal_mark_progress(f);
  511|      0|                return;
  512|      0|            }
  513|  3.55k|        }
  514|       |
  515|   260k|        p->input = input;
  516|   260k|    }
  517|       |
  518|  1.61M|    int new_rate = rate_from_speed(p->in_rate_user, p->speed);
  519|  1.61M|    bool exact_rate = new_rate == p->in_rate;
  520|  1.61M|    bool use_comp = fabs(new_rate / (double)p->in_rate - 1) <= 0.01;
  521|       |    // If we've never used compensation, avoid setting it - even if it's in
  522|       |    // theory a NOP, libswresample will enable resampling. _If_ we're
  523|       |    // resampling, we might have to disable previously enabled compensation.
  524|  1.61M|    if (exact_rate && !p->is_resampling)
  ------------------
  |  Branch (524:9): [True: 1.61M, False: 168]
  |  Branch (524:23): [True: 1.61M, False: 0]
  ------------------
  525|  1.61M|        use_comp = false;
  526|  1.61M|    if (p->avrctx && use_comp) {
  ------------------
  |  Branch (526:9): [True: 1.61M, False: 0]
  |  Branch (526:22): [True: 0, False: 1.61M]
  ------------------
  527|      0|        AVRational r =
  528|      0|            av_d2q(p->speed * p->in_rate_user / p->in_rate, INT_MAX / 2);
  529|       |        // Essentially, swr_set_compensation() does 2 things:
  530|       |        // - adjust output sample rate by sample_delta/compensation_distance
  531|       |        // - reset the adjustment after compensation_distance output samples
  532|       |        // Increase the compensation_distance to avoid undesired reset
  533|       |        // semantics - we want to keep the ratio for the whole frame we're
  534|       |        // feeding it, until the next filter() call.
  535|      0|        int mult = INT_MAX / 2 / MPMAX(MPMAX(abs(r.num), abs(r.den)), 1);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  536|      0|        r = (AVRational){ r.num * mult, r.den * mult };
  537|      0|        if (r.den == r.num)
  ------------------
  |  Branch (537:13): [True: 0, False: 0]
  ------------------
  538|      0|            r = (AVRational){0}; // fully disable
  539|      0|        if (swr_set_compensation(p->avrctx, r.den - r.num, r.den) >= 0) {
  ------------------
  |  Branch (539:13): [True: 0, False: 0]
  ------------------
  540|      0|            exact_rate = true;
  541|      0|            p->is_resampling = true; // libswresample can auto-enable it
  542|      0|        }
  543|      0|    }
  544|       |
  545|  1.61M|    if (!exact_rate) {
  ------------------
  |  Branch (545:9): [True: 168, False: 1.61M]
  ------------------
  546|       |        // Before reconfiguring, drain the audio that is still buffered
  547|       |        // in the resampler.
  548|    168|        struct mp_frame out = filter_resample_output(p, NULL);
  549|    168|        bool need_drain = !!out.type;
  550|    168|        if (need_drain)
  ------------------
  |  Branch (550:13): [True: 151, False: 17]
  ------------------
  551|    151|            mp_pin_in_write(f->ppins[1], out);
  552|       |        // Reinitialize resampler.
  553|    168|        configure_lavrr(p, false);
  554|       |        // If we've written output, we must continue filtering next time.
  555|    168|        if (need_drain)
  ------------------
  |  Branch (555:13): [True: 151, False: 17]
  ------------------
  556|    151|            return;
  557|    168|    }
  558|       |
  559|  1.61M|    struct mp_frame out = filter_resample_output(p, p->input);
  560|       |
  561|  1.61M|    if (out.type) {
  ------------------
  |  Branch (561:9): [True: 260k, False: 1.35M]
  ------------------
  562|   260k|        mp_pin_in_write(f->ppins[1], out);
  563|   260k|        if (!p->input)
  ------------------
  |  Branch (563:13): [True: 567, False: 260k]
  ------------------
  564|    567|            mp_pin_out_repeat_eof(f->ppins[0]);
  565|  1.35M|    } else if (p->input) {
  ------------------
  |  Branch (565:16): [True: 91, False: 1.35M]
  ------------------
  566|     91|        mp_filter_internal_mark_progress(f); // try to consume more input
  567|  1.35M|    } else {
  568|  1.35M|        mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  1.35M|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  1.35M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  569|  1.35M|    }
  570|       |
  571|  1.61M|    if (p->input && !mp_aframe_get_size(p->input))
  ------------------
  |  Branch (571:9): [True: 260k, False: 1.35M]
  |  Branch (571:21): [True: 260k, False: 0]
  ------------------
  572|       |        TA_FREEP(&p->input);
  ------------------
  |  |   81|   260k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   260k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 260k]
  |  |  ------------------
  ------------------
  573|  1.61M|}
f_swresample.c:filter_resample_output:
  367|  1.61M|{
  368|  1.61M|    struct mp_aframe *out = NULL;
  369|       |
  370|  1.61M|    if (!p->avrctx)
  ------------------
  |  Branch (370:9): [True: 0, False: 1.61M]
  ------------------
  371|      0|        goto error;
  372|       |
  373|       |    // Limit the filtered data size for better latency when changing speed.
  374|       |    // Avoid buffering data within the resampler => restrict input size.
  375|       |    // p->in_rate already includes the speed factor.
  376|  1.61M|    double s = p->opts->max_output_frame_size / 1000 * p->in_rate;
  377|  1.61M|    int max_in = lrint(MPCLAMP(s, 128, INT_MAX));
  ------------------
  |  |   46|  1.61M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 1.62k, False: 1.61M]
  |  |  |  Branch (46:56): [True: 0, False: 1.61M]
  |  |  ------------------
  ------------------
  378|  1.61M|    int consume_in = in ? mp_aframe_get_size(in) : 0;
  ------------------
  |  Branch (378:22): [True: 260k, False: 1.35M]
  ------------------
  379|  1.61M|    consume_in = MPMIN(consume_in, max_in);
  ------------------
  |  |   45|  1.61M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 1.61M]
  |  |  ------------------
  ------------------
  380|       |
  381|  1.61M|    int samples = get_out_samples(p, consume_in);
  382|  1.61M|    out = mp_aframe_create();
  383|  1.61M|    mp_aframe_config_copy(out, p->out_fmt);
  384|  1.61M|    if (mp_aframe_pool_allocate(p->out_pool, out, samples) < 0)
  ------------------
  |  Branch (384:9): [True: 0, False: 1.61M]
  ------------------
  385|      0|        goto error;
  386|       |
  387|  1.61M|    int out_samples = 0;
  388|  1.61M|    if (samples) {
  ------------------
  |  Branch (388:9): [True: 315k, False: 1.29M]
  ------------------
  389|   315k|        out_samples = resample_frame(p->avrctx, out, in, consume_in);
  390|   315k|        if (out_samples < 0 || out_samples > samples)
  ------------------
  |  Branch (390:13): [True: 0, False: 315k]
  |  Branch (390:32): [True: 0, False: 315k]
  ------------------
  391|      0|            goto error;
  392|   315k|        mp_aframe_set_size(out, out_samples);
  393|   315k|    }
  394|       |
  395|  1.61M|    if (in) {
  ------------------
  |  Branch (395:9): [True: 260k, False: 1.35M]
  ------------------
  396|   260k|        mp_aframe_copy_attributes(out, in);
  397|   260k|        p->current_pts = mp_aframe_end_pts(in);
  398|   260k|        mp_aframe_skip_samples(in, consume_in);
  399|   260k|    }
  400|       |
  401|  1.61M|    if (out_samples) {
  ------------------
  |  Branch (401:9): [True: 260k, False: 1.35M]
  ------------------
  402|   260k|        if (p->current_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   260k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (402:13): [True: 260k, False: 0]
  ------------------
  403|   260k|            double delay = get_delay(p) * mp_aframe_get_speed(out) +
  404|   260k|                           mp_aframe_duration(out) +
  405|   260k|                           (p->input ? mp_aframe_duration(p->input) : 0);
  ------------------
  |  Branch (405:29): [True: 260k, False: 567]
  ------------------
  406|   260k|            mp_aframe_set_pts(out, p->current_pts - delay);
  407|   260k|            mp_aframe_mul_speed(out, p->speed);
  408|   260k|        }
  409|  1.35M|    } else {
  410|  1.35M|        TA_FREEP(&out);
  ------------------
  |  |   81|  1.35M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  1.35M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 1.35M]
  |  |  ------------------
  ------------------
  411|  1.35M|    }
  412|       |
  413|  1.61M|    return out ? MAKE_FRAME(MP_FRAME_AUDIO, out) : MP_NO_FRAME;
  ------------------
  |  |   57|   260k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
                  return out ? MAKE_FRAME(MP_FRAME_AUDIO, out) : MP_NO_FRAME;
  ------------------
  |  |   58|  1.35M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  1.35M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  |  Branch (413:12): [True: 260k, False: 1.35M]
  ------------------
  414|      0|error:
  415|      0|    talloc_free(out);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  416|      0|    MP_ERR(p, "Error on resampling.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  417|      0|    mp_filter_internal_mark_failed(p->public.f);
  418|      0|    return 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)})
  |  |  ------------------
  ------------------
  419|  1.61M|}
f_swresample.c:get_out_samples:
   86|  1.61M|{
   87|  1.61M|    return swr_get_out_samples(p->avrctx, in_samples);
   88|  1.61M|}
f_swresample.c:resample_frame:
  105|   315k|{
  106|       |    // The channel layout and count can be different for in and out frames,
  107|       |    // libswresample remixes between them. The sample rates can differ too.
  108|   315k|    AVFrame *av_i = in ? mp_aframe_get_raw_avframe(in) : NULL;
  ------------------
  |  Branch (108:21): [True: 260k, False: 55.2k]
  ------------------
  109|   315k|    AVFrame *av_o = out ? mp_aframe_get_raw_avframe(out) : NULL;
  ------------------
  |  Branch (109:21): [True: 315k, False: 0]
  ------------------
  110|   315k|    return swr_convert(r,
  111|   315k|        av_o ? av_o->extended_data : NULL,
  ------------------
  |  Branch (111:9): [True: 315k, False: 0]
  ------------------
  112|   315k|        av_o ? av_o->nb_samples : 0,
  ------------------
  |  Branch (112:9): [True: 315k, False: 0]
  ------------------
  113|   315k|        (const uint8_t **)(av_i ? av_i->extended_data : NULL),
  ------------------
  |  Branch (113:28): [True: 260k, False: 55.2k]
  ------------------
  114|   315k|        av_i ? MPMIN(av_i->nb_samples, consume_in) : 0);
  ------------------
  |  |   45|   260k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 260k]
  |  |  ------------------
  ------------------
  |  Branch (114:9): [True: 260k, False: 55.2k]
  ------------------
  115|   315k|}
f_swresample.c:configure_lavrr:
  268|  3.72k|{
  269|  3.72k|    close_lavrr(p);
  270|       |
  271|  3.72k|    p->in_rate = rate_from_speed(p->in_rate_user, p->speed);
  272|       |
  273|  3.72k|    MP_VERBOSE(p, "%dHz %s %s -> %dHz %s %s\n",
  ------------------
  |  |   92|  3.72k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.72k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  274|  3.72k|               p->in_rate, mp_chmap_to_str(&p->in_channels),
  275|  3.72k|               af_fmt_to_str(p->in_format),
  276|  3.72k|               p->out_rate, mp_chmap_to_str(&p->out_channels),
  277|  3.72k|               af_fmt_to_str(p->out_format));
  278|       |
  279|  3.72k|    p->avrctx = swr_alloc();
  280|  3.72k|    if (!p->avrctx)
  ------------------
  |  Branch (280:9): [True: 0, False: 3.72k]
  ------------------
  281|      0|        goto error;
  282|       |
  283|  3.72k|    enum AVSampleFormat in_samplefmt = af_to_avformat(p->in_format);
  284|  3.72k|    enum AVSampleFormat out_samplefmt = af_to_avformat(p->out_format);
  285|       |
  286|  3.72k|    if (in_samplefmt == AV_SAMPLE_FMT_NONE ||
  ------------------
  |  Branch (286:9): [True: 0, False: 3.72k]
  ------------------
  287|  3.72k|        out_samplefmt == AV_SAMPLE_FMT_NONE)
  ------------------
  |  Branch (287:9): [True: 0, False: 3.72k]
  ------------------
  288|      0|    {
  289|      0|        MP_ERR(p, "unsupported conversion: %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__)
  |  |  ------------------
  ------------------
  290|      0|               af_fmt_to_str(p->in_format), af_fmt_to_str(p->out_format));
  291|      0|        goto error;
  292|      0|    }
  293|       |
  294|  3.72k|    av_opt_set_int(p->avrctx, "filter_size",        p->opts->filter_size, 0);
  295|  3.72k|    av_opt_set_int(p->avrctx, "phase_shift",        p->opts->phase_shift, 0);
  296|  3.72k|    av_opt_set_int(p->avrctx, "linear_interp",      p->opts->linear, 0);
  297|       |
  298|  3.72k|    double cutoff = p->opts->cutoff;
  299|  3.72k|    if (cutoff <= 0.0)
  ------------------
  |  Branch (299:9): [True: 3.72k, False: 0]
  ------------------
  300|  3.72k|        cutoff = MPMAX(1.0 - 6.5 / (p->opts->filter_size + 8), 0.80);
  ------------------
  |  |   44|  3.72k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 3.72k]
  |  |  ------------------
  ------------------
  301|  3.72k|    av_opt_set_double(p->avrctx, "cutoff",          cutoff, 0);
  302|       |
  303|  3.72k|    int normalize = p->opts->normalize;
  304|  3.72k|    av_opt_set_double(p->avrctx, "rematrix_maxval", normalize ? 1 : 1000, 0);
  ------------------
  |  Branch (304:53): [True: 0, False: 3.72k]
  ------------------
  305|       |
  306|  3.72k|    if (mp_set_avopts(p->log, p->avrctx, p->opts->avopts) < 0)
  ------------------
  |  Branch (306:9): [True: 0, False: 3.72k]
  ------------------
  307|      0|        goto error;
  308|       |
  309|  3.72k|    p->out_fmt = mp_aframe_create();
  310|  3.72k|    mp_aframe_set_rate(p->out_fmt, p->out_rate);
  311|  3.72k|    mp_aframe_set_chmap(p->out_fmt, &p->out_channels);
  312|  3.72k|    mp_aframe_set_format(p->out_fmt, p->out_format);
  313|       |
  314|       |    // libswresample is only told the number of channels on both sides. Two
  315|       |    // such layouts with the same number of channels compare equal, so it
  316|       |    // does nothing with the channels on its own.
  317|  3.72k|    AVChannelLayout in_layout = {
  318|  3.72k|        .order = AV_CHANNEL_ORDER_UNSPEC,
  319|  3.72k|        .nb_channels = p->in_channels.num,
  320|  3.72k|    };
  321|  3.72k|    AVChannelLayout out_layout = {
  322|  3.72k|        .order = AV_CHANNEL_ORDER_UNSPEC,
  323|  3.72k|        .nb_channels = p->out_channels.num,
  324|  3.72k|    };
  325|  3.72k|    av_opt_set_chlayout(p->avrctx, "in_chlayout",  &in_layout, 0);
  326|  3.72k|    av_opt_set_chlayout(p->avrctx, "out_chlayout", &out_layout, 0);
  327|  3.72k|    av_opt_set_int(p->avrctx, "in_sample_rate",     p->in_rate, 0);
  328|  3.72k|    av_opt_set_int(p->avrctx, "out_sample_rate",    p->out_rate, 0);
  329|  3.72k|    av_opt_set_int(p->avrctx, "in_sample_fmt",      in_samplefmt, 0);
  330|  3.72k|    av_opt_set_int(p->avrctx, "out_sample_fmt",     out_samplefmt, 0);
  331|       |
  332|       |    // What is set here survives swr_close(), see swresample_reset().
  333|  3.72k|    if (!set_channels(p, in_samplefmt, out_samplefmt, verbose))
  ------------------
  |  Branch (333:9): [True: 0, False: 3.72k]
  ------------------
  334|      0|        goto error;
  335|       |
  336|  3.72k|    p->is_resampling = false;
  337|       |
  338|  3.72k|    if (swr_init(p->avrctx) < 0) {
  ------------------
  |  Branch (338:9): [True: 0, False: 3.72k]
  ------------------
  339|      0|        MP_ERR(p, "Cannot open Libavresample context.\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__)
  |  |  ------------------
  ------------------
  340|      0|        goto error;
  341|      0|    }
  342|  3.72k|    return true;
  343|       |
  344|      0|error:
  345|      0|    close_lavrr(p);
  346|      0|    mp_filter_internal_mark_failed(p->public.f);
  347|      0|    MP_FATAL(p, "libswresample 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__)
  |  |  ------------------
  ------------------
  348|       |    return false;
  349|  3.72k|}
f_swresample.c:set_channels:
  215|  3.72k|{
  216|  3.72k|    const struct mp_chmap *map_in = &p->in_channels;
  217|  3.72k|    const struct mp_chmap *map_out = &p->out_channels;
  218|  3.72k|    double *matrix = talloc_zero_array(NULL, double,
  ------------------
  |  |   30|  3.72k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  3.72k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  3.72k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|  3.72k|                                       map_out->num * map_in->num);
  220|  3.72k|    bool ok = get_mix_matrix(p, matrix, map_in, map_out, out_samplefmt);
  221|       |
  222|       |    // The volume is in the matrix. libswresample would mix on its own to
  223|       |    // apply it, also if there is nothing to mix.
  224|  3.72k|    av_opt_set_double(p->avrctx, "rmvol", 1, 0);
  225|       |
  226|       |    // Without a mix, every output channel is one input channel, or silent.
  227|  3.72k|    bool mix = false;
  228|  3.72k|    bool in_place = map_in->num == map_out->num;
  229|  16.7k|    for (int o = 0; o < map_out->num; o++) {
  ------------------
  |  Branch (229:21): [True: 12.9k, False: 3.72k]
  ------------------
  230|  12.9k|        p->channel_map[o] = -1;
  231|   147k|        for (int i = 0; i < map_in->num; i++) {
  ------------------
  |  Branch (231:25): [True: 134k, False: 12.9k]
  ------------------
  232|   134k|            double gain = matrix[o * map_in->num + i];
  233|   134k|            if (gain) {
  ------------------
  |  Branch (233:17): [True: 7.62k, False: 127k]
  ------------------
  234|  7.62k|                mix |= gain != 1 || p->channel_map[o] >= 0;
  ------------------
  |  Branch (234:24): [True: 204, False: 7.42k]
  |  Branch (234:37): [True: 0, False: 7.42k]
  ------------------
  235|  7.62k|                p->channel_map[o] = i;
  236|  7.62k|            }
  237|   134k|        }
  238|  12.9k|        in_place &= p->channel_map[o] == o;
  239|  12.9k|    }
  240|       |
  241|  3.72k|    if (ok && verbose && (mix || !in_place)) {
  ------------------
  |  Branch (241:9): [True: 3.72k, False: 0]
  |  Branch (241:15): [True: 3.55k, False: 168]
  |  Branch (241:27): [True: 102, False: 3.45k]
  |  Branch (241:34): [True: 441, False: 3.01k]
  ------------------
  242|    543|        MP_VERBOSE(p, "%s: %s -> %s\n", mix ? "Remix" : "Remap",
  ------------------
  |  |   92|    543|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.08k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 102, False: 441]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|    543|                   mp_chmap_to_str(map_in), mp_chmap_to_str(map_out));
  244|    543|    }
  245|       |
  246|       |    // A channel map copies s32 as it is, a matrix takes it through floating
  247|       |    // point. Other formats come out the same, and faster without a map.
  248|  3.72k|    bool s32 = av_get_packed_sample_fmt(in_samplefmt) == AV_SAMPLE_FMT_S32 &&
  ------------------
  |  Branch (248:16): [True: 0, False: 3.72k]
  ------------------
  249|      0|               av_get_packed_sample_fmt(out_samplefmt) == AV_SAMPLE_FMT_S32;
  ------------------
  |  Branch (249:16): [True: 0, False: 0]
  ------------------
  250|       |
  251|  3.72k|    if (ok && (mix || (!in_place && !s32))) {
  ------------------
  |  Branch (251:9): [True: 3.72k, False: 0]
  |  Branch (251:16): [True: 102, False: 3.62k]
  |  Branch (251:24): [True: 441, False: 3.18k]
  |  Branch (251:37): [True: 441, False: 0]
  ------------------
  252|    543|        ok = swr_set_matrix(p->avrctx, matrix, map_in->num) >= 0;
  253|  3.18k|    } else if (ok && !in_place) {
  ------------------
  |  Branch (253:16): [True: 3.18k, False: 0]
  |  Branch (253:22): [True: 0, False: 3.18k]
  ------------------
  254|       |        // The map has an entry for every channel that is used after it.
  255|      0|        AVChannelLayout used = {
  256|      0|            .order = AV_CHANNEL_ORDER_UNSPEC,
  257|      0|            .nb_channels = map_out->num,
  258|      0|        };
  259|      0|        ok = av_opt_set_chlayout(p->avrctx, "used_chlayout", &used, 0) >= 0 &&
  ------------------
  |  Branch (259:14): [True: 0, False: 0]
  ------------------
  260|      0|             swr_set_channel_mapping(p->avrctx, p->channel_map) >= 0;
  ------------------
  |  Branch (260:14): [True: 0, False: 0]
  ------------------
  261|      0|    }
  262|       |
  263|  3.72k|    talloc_free(matrix);
  ------------------
  |  |   47|  3.72k|#define talloc_free                     ta_free
  ------------------
  264|  3.72k|    return ok;
  265|  3.72k|}
f_swresample.c:get_mix_matrix:
  124|  3.72k|{
  125|  3.72k|    double clev, slev, lfe_mix_level, maxval, volume;
  126|  3.72k|    int64_t matrix_encoding;
  127|  3.72k|    enum AVSampleFormat internal_samplefmt;
  128|  3.72k|    if (av_opt_get_double(p->avrctx, "clev", 0, &clev) < 0 ||
  ------------------
  |  Branch (128:9): [True: 0, False: 3.72k]
  ------------------
  129|  3.72k|        av_opt_get_double(p->avrctx, "slev", 0, &slev) < 0 ||
  ------------------
  |  Branch (129:9): [True: 0, False: 3.72k]
  ------------------
  130|  3.72k|        av_opt_get_double(p->avrctx, "lfe_mix_level", 0, &lfe_mix_level) < 0 ||
  ------------------
  |  Branch (130:9): [True: 0, False: 3.72k]
  ------------------
  131|  3.72k|        av_opt_get_double(p->avrctx, "rematrix_maxval", 0, &maxval) < 0 ||
  ------------------
  |  Branch (131:9): [True: 0, False: 3.72k]
  ------------------
  132|  3.72k|        av_opt_get_double(p->avrctx, "rmvol", 0, &volume) < 0 ||
  ------------------
  |  Branch (132:9): [True: 0, False: 3.72k]
  ------------------
  133|  3.72k|        av_opt_get_int(p->avrctx, "matrix_encoding", 0, &matrix_encoding) < 0 ||
  ------------------
  |  Branch (133:9): [True: 0, False: 3.72k]
  ------------------
  134|  3.72k|        av_opt_get_sample_fmt(p->avrctx, "internal_sample_fmt", 0,
  ------------------
  |  Branch (134:9): [True: 0, False: 3.72k]
  ------------------
  135|  3.72k|                              &internal_samplefmt) < 0)
  136|      0|        return false;
  137|       |    // Without a limit, libswresample picks one that suits the sample formats.
  138|       |    // The format it mixes in is an integer one only if the output is, or if
  139|       |    // it was set.
  140|  3.72k|    if (maxval <= 0) {
  ------------------
  |  Branch (140:9): [True: 0, False: 3.72k]
  ------------------
  141|      0|        bool integer =
  142|      0|            av_get_packed_sample_fmt(out_samplefmt) < AV_SAMPLE_FMT_FLT ||
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|            (internal_samplefmt != AV_SAMPLE_FMT_NONE &&
  ------------------
  |  Branch (143:14): [True: 0, False: 0]
  ------------------
  144|      0|             av_get_packed_sample_fmt(internal_samplefmt) < AV_SAMPLE_FMT_FLT);
  ------------------
  |  Branch (144:14): [True: 0, False: 0]
  ------------------
  145|      0|        maxval = integer ? 1 : INT_MAX;
  ------------------
  |  Branch (145:18): [True: 0, False: 0]
  ------------------
  146|      0|    }
  147|       |
  148|       |    // Channels keep their position if either side has no speaker information,
  149|       |    // or if both sides are the very same map, for example fl-fr-na -> fl-fr-na.
  150|       |    // If the number of channels differs, the first ones that fit are kept.
  151|  3.72k|    bool by_position = mp_chmap_is_unknown(map_in) ||
  ------------------
  |  Branch (151:24): [True: 199, False: 3.52k]
  ------------------
  152|  3.52k|                       mp_chmap_is_unknown(map_out) ||
  ------------------
  |  Branch (152:24): [True: 414, False: 3.11k]
  ------------------
  153|  3.11k|                       mp_chmap_equals(map_in, map_out);
  ------------------
  |  Branch (153:24): [True: 2.97k, False: 136]
  ------------------
  154|       |
  155|       |    // The same speakers on both sides only change their places. Nothing is
  156|       |    // mixed, so this works for all speakers, also for those that libswresample
  157|       |    // has no mix for.
  158|  3.72k|    uint64_t in_mask = mp_chmap_to_lavc_unchecked(map_in);
  159|  3.72k|    uint64_t out_mask = mp_chmap_to_lavc_unchecked(map_out);
  160|  3.72k|    bool copy = by_position || in_mask == out_mask;
  ------------------
  |  Branch (160:17): [True: 3.59k, False: 136]
  |  Branch (160:32): [True: 0, False: 136]
  ------------------
  161|       |
  162|       |    // Different speakers are mixed by libswresample. It builds the matrix
  163|       |    // between the speakers of both maps in their native order. A channel that
  164|       |    // is copied is one speaker on both sides.
  165|  3.72k|    AVChannelLayout in = AV_CHANNEL_LAYOUT_MONO;
  166|  3.72k|    AVChannelLayout out = AV_CHANNEL_LAYOUT_MONO;
  167|  3.72k|    if (!copy && (av_channel_layout_from_mask(&in, in_mask) < 0 ||
  ------------------
  |  Branch (167:9): [True: 136, False: 3.59k]
  |  Branch (167:19): [True: 0, False: 136]
  ------------------
  168|    136|                  av_channel_layout_from_mask(&out, out_mask) < 0))
  ------------------
  |  Branch (168:19): [True: 0, False: 136]
  ------------------
  169|      0|        return false;
  170|       |
  171|       |    // Channels that keep their position stay as they are, unless the volume
  172|       |    // is set. This is what libswresample does with equal layouts.
  173|  3.72k|    double *native = talloc_zero_array(NULL, double, SWR_MATRIX_CHANNELS *
  ------------------
  |  |   30|  3.72k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  3.72k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  3.72k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|  3.72k|                                                     SWR_MATRIX_CHANNELS);
  175|  3.72k|    native[0] = 1;
  176|  3.72k|    int r = 0;
  177|  3.72k|    if (!by_position || volume != 1) {
  ------------------
  |  Branch (177:9): [True: 136, False: 3.59k]
  |  Branch (177:25): [True: 0, False: 3.59k]
  ------------------
  178|    136|        r = swr_build_matrix2(&in, &out, clev, slev, lfe_mix_level, maxval,
  179|    136|                              volume, native, SWR_MATRIX_CHANNELS,
  ------------------
  |  |  117|    136|#define SWR_MATRIX_CHANNELS 64
  ------------------
  180|    136|                              matrix_encoding, p->avrctx);
  181|    136|    }
  182|       |
  183|       |    // Moved into the channel order of the maps, the matrix puts all channels
  184|       |    // in their place and leaves the NA channels silent. Copied channels all
  185|       |    // take the one coefficient that a single speaker has.
  186|  16.7k|    for (int o = 0; o < map_out->num; o++) {
  ------------------
  |  Branch (186:21): [True: 12.9k, False: 3.72k]
  ------------------
  187|   147k|        for (int i = 0; i < map_in->num; i++) {
  ------------------
  |  Branch (187:25): [True: 134k, False: 12.9k]
  ------------------
  188|   134k|            int no = 0, ni = 0;
  189|   134k|            if (by_position) {
  ------------------
  |  Branch (189:17): [True: 134k, False: 358]
  ------------------
  190|   134k|                ni = o == i ? 0 : -1;
  ------------------
  |  Branch (190:22): [True: 7.38k, False: 127k]
  ------------------
  191|   134k|            } else if (copy) {
  ------------------
  |  Branch (191:24): [True: 0, False: 358]
  ------------------
  192|      0|                ni = map_out->speaker[o] != MP_SPEAKER_ID_NA &&
  ------------------
  |  Branch (192:22): [True: 0, False: 0]
  ------------------
  193|      0|                     map_out->speaker[o] == map_in->speaker[i] ? 0 : -1;
  ------------------
  |  Branch (193:22): [True: 0, False: 0]
  ------------------
  194|    358|            } else {
  195|       |                // Negative for NA channels, which have no place in a native
  196|       |                // layout.
  197|    358|                no = av_channel_layout_index_from_channel(&out,
  198|    358|                                                          map_out->speaker[o]);
  199|    358|                ni = av_channel_layout_index_from_channel(&in,
  200|    358|                                                          map_in->speaker[i]);
  201|    358|            }
  202|   134k|            if (no >= 0 && ni >= 0) {
  ------------------
  |  Branch (202:17): [True: 134k, False: 0]
  |  Branch (202:28): [True: 7.74k, False: 127k]
  ------------------
  203|  7.74k|                matrix[o * map_in->num + i] =
  204|  7.74k|                    native[no * SWR_MATRIX_CHANNELS + ni];
  ------------------
  |  |  117|  7.74k|#define SWR_MATRIX_CHANNELS 64
  ------------------
  205|  7.74k|            }
  206|   134k|        }
  207|  12.9k|    }
  208|  3.72k|    talloc_free(native);
  ------------------
  |  |   47|  3.72k|#define talloc_free                     ta_free
  ------------------
  209|  3.72k|    return r >= 0;
  210|  3.72k|}
f_swresample.c:rate_from_speed:
   98|  1.61M|{
   99|  1.61M|    return lrint(rate * speed);
  100|  1.61M|}
f_swresample.c:swresample_reset:
  352|  1.35M|{
  353|  1.35M|    struct priv *p = f->priv;
  354|       |
  355|  1.35M|    p->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.35M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  356|  1.35M|    TA_FREEP(&p->input);
  ------------------
  |  |   81|  1.35M|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  1.35M|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 1.35M]
  |  |  ------------------
  ------------------
  357|       |
  358|  1.35M|    if (!p->avrctx)
  ------------------
  |  Branch (358:9): [True: 0, False: 1.35M]
  ------------------
  359|      0|        return;
  360|  1.35M|    swr_close(p->avrctx);
  361|  1.35M|    if (swr_init(p->avrctx) < 0)
  ------------------
  |  Branch (361:9): [True: 0, False: 1.35M]
  ------------------
  362|      0|        close_lavrr(p);
  363|  1.35M|}
f_swresample.c:swresample_command:
  583|   263k|{
  584|   263k|    struct priv *p = f->priv;
  585|       |
  586|   263k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_RESAMPLE) {
  ------------------
  |  Branch (586:9): [True: 263k, False: 0]
  ------------------
  587|   263k|        p->cmd_speed = cmd->speed;
  588|   263k|        return true;
  589|   263k|    }
  590|       |
  591|      0|    return false;
  592|   263k|}

mp_chain_filters:
   73|  1.28k|{
   74|  3.86k|    for (int n = 0; n < num_filters; n++) {
  ------------------
  |  Branch (74:21): [True: 2.57k, False: 1.28k]
  ------------------
   75|  2.57k|        if (!filters[n])
  ------------------
  |  Branch (75:13): [True: 1.28k, False: 1.28k]
  ------------------
   76|  1.28k|            continue;
   77|  1.28k|        mp_assert(filters[n]->num_pins == 2);
  ------------------
  |  |   41|  1.28k|#define mp_assert assert
  ------------------
  |  Branch (77:9): [True: 1.28k, False: 0]
  ------------------
   78|  1.28k|        mp_pin_connect(filters[n]->pins[0], in);
   79|  1.28k|        in = filters[n]->pins[1];
   80|  1.28k|    }
   81|  1.28k|    mp_pin_connect(out, in);
   82|  1.28k|}
mp_subfilter_read:
   94|  41.2M|{
   95|  41.2M|    if (sub->filter) {
  ------------------
  |  Branch (95:9): [True: 12.4M, False: 28.7M]
  ------------------
   96|  12.4M|        if (mp_pin_can_transfer_data(sub->out, sub->filter->pins[1])) {
  ------------------
  |  Branch (96:13): [True: 3.17M, False: 9.30M]
  ------------------
   97|  3.17M|            struct mp_frame frame = mp_pin_out_read(sub->filter->pins[1]);
   98|  3.17M|            if (sub->draining && frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (98:17): [True: 353, False: 3.17M]
  |  Branch (98:34): [True: 288, False: 65]
  ------------------
   99|    288|                sub->draining = false;
  100|    288|                TA_FREEP(&sub->filter);
  ------------------
  |  |   81|    288|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    288|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 288]
  |  |  ------------------
  ------------------
  101|    288|                mark_progress(sub);
  102|    288|                return false;
  103|    288|            }
  104|  3.17M|            mp_pin_in_write(sub->out, frame);
  105|  3.17M|            return false;
  106|  3.17M|        }
  107|  9.30M|        if (sub->draining)
  ------------------
  |  Branch (107:13): [True: 65, False: 9.30M]
  ------------------
  108|     65|            return false;
  109|  9.30M|    }
  110|       |
  111|  38.0M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (111:26): [True: 9.30M, False: 28.7M]
  ------------------
  112|       |
  113|  38.0M|    if (sub->frame.type)
  ------------------
  |  Branch (113:9): [True: 29.6k, False: 38.0M]
  ------------------
  114|  29.6k|        return mp_pin_in_needs_data(out);
  115|       |
  116|  38.0M|    if (!mp_pin_can_transfer_data(out, sub->in))
  ------------------
  |  Branch (116:9): [True: 20.6M, False: 17.3M]
  ------------------
  117|  20.6M|        return false;
  118|       |
  119|  17.3M|    sub->frame = mp_pin_out_read(sub->in);
  120|       |    return true;
  121|  38.0M|}
mp_subfilter_reset:
  124|  16.7M|{
  125|  16.7M|    if (sub->filter && sub->draining)
  ------------------
  |  Branch (125:9): [True: 2.72M, False: 13.9M]
  |  Branch (125:24): [True: 0, False: 2.72M]
  ------------------
  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|  16.7M|    mp_frame_unref(&sub->frame);
  129|  16.7M|}
mp_subfilter_continue:
  132|  17.3M|{
  133|  17.3M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (133:26): [True: 3.07M, False: 14.2M]
  ------------------
  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|  17.3M|    if (!mp_pin_in_needs_data(out)) {
  ------------------
  |  Branch (138:9): [True: 7.04k, False: 17.3M]
  ------------------
  139|  7.04k|        mark_progress(sub);
  140|  7.04k|        return;
  141|  7.04k|    }
  142|  17.3M|    mp_pin_in_write(out, sub->frame);
  143|  17.3M|    sub->frame = MP_NO_FRAME;
  ------------------
  |  |   58|  17.3M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  17.3M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  144|  17.3M|}
mp_subfilter_destroy:
  147|  47.8k|{
  148|  47.8k|    TA_FREEP(&sub->filter);
  ------------------
  |  |   81|  47.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  47.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 47.8k]
  |  |  ------------------
  ------------------
  149|       |    sub->draining = false;
  150|  47.8k|}
mp_subfilter_drain_destroy:
  153|  86.0k|{
  154|  86.0k|    if (!sub->draining && sub->filter) {
  ------------------
  |  Branch (154:9): [True: 86.0k, False: 0]
  |  Branch (154:27): [True: 288, False: 85.7k]
  ------------------
  155|       |        // We know the filter is writable (unless the user created a new filter
  156|       |        // and immediately called this function, which is invalid).
  157|    288|        mp_pin_in_write(sub->filter->pins[0], MP_EOF_FRAME);
  ------------------
  |  |   59|    288|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|    288|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  158|       |        sub->draining = true;
  159|    288|    }
  160|  86.0k|    return !sub->filter;
  161|  86.0k|}
mp_bidir_nop_filter_create:
  168|  93.0k|{
  169|  93.0k|    struct mp_filter *f = mp_filter_create(parent, &bidir_nop_filter);
  170|  93.0k|    if (!f)
  ------------------
  |  Branch (170:9): [True: 0, False: 93.0k]
  ------------------
  171|      0|        return NULL;
  172|       |
  173|  93.0k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  174|  93.0k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  175|       |
  176|  93.0k|    mp_pin_connect(f->ppins[1], f->ppins[0]);
  177|       |
  178|  93.0k|    return f;
  179|  93.0k|}
mp_bidir_dummy_filter_create:
  186|  1.28k|{
  187|  1.28k|    struct mp_filter *f = mp_filter_create(parent, &bidir_dummy_filter);
  188|  1.28k|    if (!f)
  ------------------
  |  Branch (188:9): [True: 0, False: 1.28k]
  ------------------
  189|      0|        return NULL;
  190|       |
  191|  1.28k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  192|  1.28k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  193|       |
  194|  1.28k|    return f;
  195|  1.28k|}
f_utils.c:mark_progress:
   86|  7.32k|{
   87|       |    // f == NULL is not really allowed, but at least don't crash.
   88|  7.32k|    struct mp_filter *f = mp_pin_get_manual_connection(sub->in);
   89|  7.32k|    if (f)
  ------------------
  |  Branch (89:9): [True: 7.32k, False: 0]
  ------------------
   90|  7.32k|        mp_filter_internal_mark_progress(f);
   91|  7.32k|}

mp_filter_internal_mark_progress:
  190|  1.19M|{
  191|  1.19M|    struct filter_runner *r = f->in->runner;
  192|  1.19M|    mp_assert(r->filtering); // only call from f's process()
  ------------------
  |  |   41|  1.19M|#define mp_assert assert
  ------------------
  |  Branch (192:5): [True: 1.19M, False: 0]
  ------------------
  193|  1.19M|    add_pending(f);
  194|  1.19M|}
mp_filter_graph_run:
  212|  14.8M|{
  213|  14.8M|    struct filter_runner *r = filter->in->runner;
  214|  14.8M|    mp_assert(filter == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  14.8M|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 14.8M, False: 18.4E]
  ------------------
  215|       |
  216|  14.8M|    int64_t end_time = 0;
  217|  14.8M|    if (isfinite(r->max_run_time))
  ------------------
  |  Branch (217:9): [True: 14.1M, False: 680k]
  ------------------
  218|  14.1M|        end_time = mp_time_ns_add(mp_time_ns(), MPMAX(r->max_run_time, 0));
  ------------------
  |  |   44|  14.1M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 14.1M, 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|  14.8M|    mp_assert(!r->filtering);
  ------------------
  |  |   41|  14.8M|#define mp_assert assert
  ------------------
  |  Branch (222:5): [True: 14.8M, False: 18.4E]
  ------------------
  223|       |
  224|  14.8M|    r->filtering = true;
  225|       |
  226|  14.8M|    flush_async_notifications(r);
  227|       |
  228|  14.8M|    bool exit_req = false;
  229|       |
  230|   245M|    while (1) {
  ------------------
  |  Branch (230:12): [True: 245M, Folded]
  ------------------
  231|   245M|        if (atomic_exchange_explicit(&r->interrupt_flag, false,
  ------------------
  |  Branch (231:13): [True: 0, False: 245M]
  ------------------
  232|   245M|                                     memory_order_acq_rel))
  233|      0|        {
  234|      0|            mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  235|      0|            if (!r->async_wakeup_sent && r->wakeup_cb)
  ------------------
  |  Branch (235:17): [True: 0, False: 0]
  |  Branch (235:42): [True: 0, False: 0]
  ------------------
  236|      0|                r->wakeup_cb(r->wakeup_ctx);
  237|      0|            r->async_wakeup_sent = true;
  238|      0|            mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  239|      0|            exit_req = true;
  240|      0|        }
  241|       |
  242|   245M|        if (!r->num_pending) {
  ------------------
  |  Branch (242:13): [True: 15.1M, False: 230M]
  ------------------
  243|  15.1M|            flush_async_notifications(r);
  244|  15.1M|            if (!r->num_pending)
  ------------------
  |  Branch (244:17): [True: 14.8M, False: 262k]
  ------------------
  245|  14.8M|                break;
  246|  15.1M|        }
  247|       |
  248|   231M|        struct mp_filter *next = NULL;
  249|       |
  250|   231M|        if (r->pending[0]->in->high_priority) {
  ------------------
  |  Branch (250:13): [True: 2.15M, False: 228M]
  ------------------
  251|  2.15M|            next = r->pending[0];
  252|  2.15M|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, 0);
  ------------------
  |  |  143|  2.15M|    do {                                            \
  |  |  144|  2.15M|        size_t at_ = (at);                          \
  |  |  145|  2.15M|        assert(at_ < (idxvar));                     \
  |  |  146|  2.15M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  2.15M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  2.15M|        (idxvar)--;                                 \
  |  |  149|  2.15M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 2.15M]
  |  |  ------------------
  ------------------
  |  Branch (252:13): [True: 2.15M, False: 0]
  ------------------
  253|   228M|        } else if (!exit_req) {
  ------------------
  |  Branch (253:20): [True: 228M, False: 18.4E]
  ------------------
  254|   228M|            next = r->pending[r->num_pending - 1];
  255|   228M|            r->num_pending -= 1;
  256|   228M|        }
  257|       |
  258|   231M|        if (!next)
  ------------------
  |  Branch (258:13): [True: 0, False: 231M]
  ------------------
  259|      0|            break;
  260|       |
  261|   231M|        next->in->pending = false;
  262|   231M|        if (next->in->info->process)
  ------------------
  |  Branch (262:13): [True: 227M, False: 3.22M]
  ------------------
  263|   227M|            next->in->info->process(next);
  264|       |
  265|   231M|        if (end_time && mp_time_ns() >= end_time)
  ------------------
  |  Branch (265:13): [True: 229M, False: 1.17M]
  |  Branch (265:25): [True: 0, False: 229M]
  ------------------
  266|      0|            mp_filter_graph_interrupt(r->root_filter);
  267|   231M|    }
  268|       |
  269|  14.8M|    r->filtering = false;
  270|       |
  271|  14.8M|    bool externals = r->external_pending;
  272|       |    r->external_pending = false;
  273|  14.8M|    return externals;
  274|  14.8M|}
mp_pin_can_transfer_data:
  277|   304M|{
  278|   304M|    return mp_pin_in_needs_data(dst) && mp_pin_out_request_data(src);
  ------------------
  |  Branch (278:12): [True: 228M, False: 76.0M]
  |  Branch (278:41): [True: 85.0M, False: 143M]
  ------------------
  279|   304M|}
mp_pin_transfer_data:
  282|  9.17k|{
  283|  9.17k|    if (!mp_pin_can_transfer_data(dst, src))
  ------------------
  |  Branch (283:9): [True: 4.58k, False: 4.58k]
  ------------------
  284|  4.58k|        return false;
  285|  4.58k|    mp_pin_in_write(dst, mp_pin_out_read(src));
  286|       |    return true;
  287|  9.17k|}
mp_pin_in_needs_data:
  290|   502M|{
  291|   502M|    mp_assert(p->dir == MP_PIN_IN);
  ------------------
  |  |   41|   502M|#define mp_assert assert
  ------------------
  |  Branch (291:5): [True: 502M, False: 18.4E]
  ------------------
  292|   502M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|   502M|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 502M, False: 18.4E]
  ------------------
  293|   502M|    return p->conn && p->conn->manual_connection && p->conn->data_requested;
  ------------------
  |  Branch (293:12): [True: 502M, False: 18.4E]
  |  Branch (293:23): [True: 502M, False: 18.4E]
  |  Branch (293:53): [True: 410M, False: 91.4M]
  ------------------
  294|   502M|}
mp_pin_in_write:
  297|   108M|{
  298|   108M|    if (!mp_pin_in_needs_data(p) || frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (298:9): [True: 18.4E, False: 108M]
  |  Branch (298:37): [True: 686, False: 108M]
  ------------------
  299|    707|        if (frame.type)
  ------------------
  |  Branch (299:13): [True: 0, False: 707]
  ------------------
  300|    707|            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|    707|        mp_frame_unref(&frame);
  302|    707|        return false;
  303|    707|    }
  304|   108M|    mp_assert(p->conn->data.type == MP_FRAME_NONE);
  ------------------
  |  |   41|   108M|#define mp_assert assert
  ------------------
  |  Branch (304:5): [True: 108M, False: 18.4E]
  ------------------
  305|   108M|    p->conn->data = frame;
  306|   108M|    p->conn->data_requested = false;
  307|   108M|    add_pending_pin(p->conn);
  308|   108M|    filter_recursive(p);
  309|       |    return true;
  310|   108M|}
mp_pin_out_has_data:
  313|   556M|{
  314|   556M|    mp_assert(p->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   556M|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 556M, False: 18.4E]
  ------------------
  315|   556M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|   556M|#define mp_assert assert
  ------------------
  |  Branch (315:5): [True: 556M, False: 18.4E]
  ------------------
  316|   556M|    return p->conn && p->conn->manual_connection && p->data.type != MP_FRAME_NONE;
  ------------------
  |  Branch (316:12): [True: 556M, False: 360]
  |  Branch (316:23): [True: 556M, False: 18.4E]
  |  Branch (316:53): [True: 196M, False: 360M]
  ------------------
  317|   556M|}
mp_pin_out_request_data:
  320|   376M|{
  321|   376M|    if (mp_pin_out_has_data(p))
  ------------------
  |  Branch (321:9): [True: 195M, False: 180M]
  ------------------
  322|   195M|        return true;
  323|   180M|    if (p->conn && p->conn->manual_connection) {
  ------------------
  |  Branch (323:9): [True: 180M, False: 18.4E]
  |  Branch (323:20): [True: 180M, False: 18.4E]
  ------------------
  324|   180M|        if (!p->data_requested) {
  ------------------
  |  Branch (324:13): [True: 110M, False: 70.4M]
  ------------------
  325|       |            p->data_requested = true;
  326|   110M|            add_pending_pin(p->conn);
  327|   110M|        }
  328|   180M|        filter_recursive(p);
  329|   180M|    }
  330|   180M|    return mp_pin_out_has_data(p);
  331|   376M|}
mp_pin_out_request_data_next:
  334|  1.21M|{
  335|  1.21M|    if (mp_pin_out_request_data(p))
  ------------------
  |  Branch (335:9): [True: 0, False: 1.21M]
  ------------------
  336|      0|        add_pending_pin(p->conn);
  337|  1.21M|}
mp_pin_out_read:
  340|   141M|{
  341|   141M|    if (!mp_pin_out_request_data(p))
  ------------------
  |  Branch (341:9): [True: 32.4M, False: 108M]
  ------------------
  342|  32.4M|        return MP_NO_FRAME;
  ------------------
  |  |   58|  32.4M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  32.4M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  343|   108M|    struct mp_frame res = p->data;
  344|   108M|    p->data = MP_NO_FRAME;
  ------------------
  |  |   58|   108M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|   108M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  345|   108M|    return res;
  346|   141M|}
mp_pin_out_unread:
  349|  3.44k|{
  350|  3.44k|    mp_assert(p->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  3.44k|#define mp_assert assert
  ------------------
  |  Branch (350:5): [True: 3.44k, False: 0]
  ------------------
  351|  3.44k|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  3.44k|#define mp_assert assert
  ------------------
  |  Branch (351:5): [True: 3.44k, False: 0]
  ------------------
  352|  3.44k|    mp_assert(p->conn && p->conn->manual_connection);
  ------------------
  |  |   41|  3.44k|#define mp_assert assert
  ------------------
  |  Branch (352:5): [True: 3.44k, False: 0]
  |  Branch (352:5): [True: 3.44k, False: 0]
  ------------------
  353|       |    // Unread is allowed strictly only if you didn't do anything else with
  354|       |    // the pin since the time you read it.
  355|  3.44k|    mp_assert(!mp_pin_out_has_data(p));
  ------------------
  |  |   41|  3.44k|#define mp_assert assert
  ------------------
  |  Branch (355:5): [True: 3.44k, False: 0]
  ------------------
  356|  3.44k|    mp_assert(!p->data_requested);
  ------------------
  |  |   41|  3.44k|#define mp_assert assert
  ------------------
  |  Branch (356:5): [True: 3.44k, False: 0]
  ------------------
  357|  3.44k|    p->data = frame;
  358|  3.44k|}
mp_pin_out_repeat_eof:
  361|  2.35k|{
  362|  2.35k|    mp_pin_out_unread(p, MP_EOF_FRAME);
  ------------------
  |  |   59|  2.35k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  2.35k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  363|  2.35k|}
mp_pin_connect:
  438|   670k|{
  439|   670k|    mp_assert(src->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   670k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 670k, False: 0]
  ------------------
  440|   670k|    mp_assert(dst->dir == MP_PIN_IN);
  ------------------
  |  |   41|   670k|#define mp_assert assert
  ------------------
  |  Branch (440:5): [True: 670k, False: 0]
  ------------------
  441|       |
  442|   670k|    if (dst->user_conn == src) {
  ------------------
  |  Branch (442:9): [True: 247k, False: 423k]
  ------------------
  443|   247k|        mp_assert(src->user_conn == dst);
  ------------------
  |  |   41|   247k|#define mp_assert assert
  ------------------
  |  Branch (443:9): [True: 247k, False: 0]
  ------------------
  444|   247k|        return;
  445|   247k|    }
  446|       |
  447|   423k|    mp_pin_disconnect(src);
  448|   423k|    mp_pin_disconnect(dst);
  449|       |
  450|   423k|    src->user_conn = dst;
  451|   423k|    dst->user_conn = src;
  452|       |
  453|   423k|    init_connection(src);
  454|   423k|}
mp_pin_set_manual_connection_for:
  462|   215k|{
  463|   215k|    if (p->manual_connection == f)
  ------------------
  |  Branch (463:9): [True: 215k, False: 0]
  ------------------
  464|   215k|        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_get_manual_connection:
  472|  7.32k|{
  473|  7.32k|    return p->manual_connection;
  474|  7.32k|}
mp_pin_disconnect:
  499|  3.67M|{
  500|  3.67M|    if (!mp_pin_is_connected(p))
  ------------------
  |  Branch (500:9): [True: 423k, False: 3.24M]
  ------------------
  501|   423k|        return;
  502|       |
  503|  3.24M|    p->manual_connection = NULL;
  504|       |
  505|  3.24M|    struct mp_pin *conn = p->user_conn;
  506|  3.24M|    if (conn) {
  ------------------
  |  Branch (506:9): [True: 423k, False: 2.82M]
  ------------------
  507|   423k|        p->user_conn = NULL;
  508|   423k|        conn->user_conn = NULL;
  509|   423k|        deinit_connection(conn);
  510|   423k|    }
  511|       |
  512|  3.24M|    deinit_connection(p);
  513|  3.24M|}
mp_pin_is_connected:
  516|  3.67M|{
  517|  3.67M|    return p->user_conn || p->manual_connection;
  ------------------
  |  Branch (517:12): [True: 423k, False: 3.24M]
  |  Branch (517:28): [True: 2.82M, False: 423k]
  ------------------
  518|  3.67M|}
mp_pin_get_dir:
  526|   905k|{
  527|   905k|    return p->dir;
  528|   905k|}
mp_filter_get_info:
  536|  15.0k|{
  537|  15.0k|    return f->in->info;
  538|  15.0k|}
mp_filter_set_high_priority:
  541|  15.0k|{
  542|  15.0k|    f->in->high_priority = pri;
  543|  15.0k|}
mp_filter_get_named_pin:
  552|  1.41M|{
  553|  2.02M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (553:21): [True: 612k, False: 1.41M]
  ------------------
  554|   612k|        if (name && strcmp(f->pins[n]->name, name) == 0)
  ------------------
  |  Branch (554:13): [True: 612k, False: 0]
  |  Branch (554:21): [True: 0, False: 612k]
  ------------------
  555|      0|            return f->pins[n];
  556|   612k|    }
  557|  1.41M|    return NULL;
  558|  1.41M|}
mp_filter_set_error_handler:
  561|   104M|{
  562|   104M|    f->in->error_handler = handler;
  563|   104M|}
mp_filter_internal_mark_failed:
  566|    303|{
  567|    303|    while (f) {
  ------------------
  |  Branch (567:12): [True: 303, False: 0]
  ------------------
  568|    303|        f->in->failed = true;
  569|    303|        if (f->in->error_handler) {
  ------------------
  |  Branch (569:13): [True: 303, False: 0]
  ------------------
  570|    303|            add_pending(f->in->error_handler);
  571|    303|            break;
  572|    303|        }
  573|      0|        f = f->in->parent;
  574|      0|    }
  575|    303|}
mp_filter_has_failed:
  578|   104M|{
  579|   104M|    bool failed = filter->in->failed;
  580|       |    filter->in->failed = false;
  581|   104M|    return failed;
  582|   104M|}
mp_filter_reset:
  595|  89.1M|{
  596|  89.1M|    if (!filter)
  ------------------
  |  Branch (596:9): [True: 7.04k, False: 89.1M]
  ------------------
  597|  7.04k|        return;
  598|       |
  599|   170M|    for (int n = 0; n < filter->in->num_children; n++)
  ------------------
  |  Branch (599:21): [True: 81.6M, False: 89.1M]
  ------------------
  600|  81.6M|        mp_filter_reset(filter->in->children[n]);
  601|       |
  602|   244M|    for (int n = 0; n < filter->num_pins; n++) {
  ------------------
  |  Branch (602:21): [True: 155M, False: 89.1M]
  ------------------
  603|   155M|        struct mp_pin *p = filter->ppins[n];
  604|   155M|        reset_pin(p);
  605|   155M|        reset_pin(p->other);
  606|   155M|    }
  607|       |
  608|  89.1M|    if (filter->in->info->reset)
  ------------------
  |  Branch (608:9): [True: 73.8M, False: 15.3M]
  ------------------
  609|  73.8M|        filter->in->info->reset(filter);
  610|  89.1M|}
mp_filter_add_pin:
  614|  1.41M|{
  615|  1.41M|    mp_assert(dir == MP_PIN_IN || dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (615:5): [True: 644k, False: 767k]
  |  Branch (615:5): [True: 767k, False: 0]
  ------------------
  616|  1.41M|    mp_assert(name && name[0]);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (616:5): [True: 1.41M, False: 0]
  |  Branch (616:5): [True: 1.41M, False: 0]
  ------------------
  617|  1.41M|    mp_assert(!mp_filter_get_named_pin(f, name));
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 1.41M, False: 0]
  ------------------
  618|       |
  619|       |    // "Public" pin
  620|  1.41M|    struct mp_pin *p = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.41M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.41M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.41M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|  1.41M|    *p = (struct mp_pin){
  622|  1.41M|        .name = talloc_strdup(p, name),
  ------------------
  |  |   50|  1.41M|#define talloc_strdup                   ta_xstrdup
  ------------------
  623|  1.41M|        .dir = dir,
  624|  1.41M|        .owner = f,
  625|  1.41M|        .manual_connection = f->in->parent,
  626|  1.41M|    };
  627|       |
  628|       |    // "Private" paired pin
  629|  1.41M|    p->other = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.41M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.41M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.41M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|  1.41M|    *p->other = (struct mp_pin){
  631|  1.41M|        .name = p->name,
  632|  1.41M|        .dir = p->dir == MP_PIN_IN ? MP_PIN_OUT : MP_PIN_IN,
  ------------------
  |  Branch (632:16): [True: 644k, False: 767k]
  ------------------
  633|  1.41M|        .owner = f,
  634|  1.41M|        .other = p,
  635|  1.41M|        .manual_connection = f,
  636|  1.41M|    };
  637|       |
  638|  1.41M|    MP_TARRAY_GROW(f, f->pins, f->num_pins);
  ------------------
  |  |   96|  1.41M|    do {                                            \
  |  |   97|  1.41M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.41M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.41M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.41M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 799k, False: 612k]
  |  |  ------------------
  |  |   99|  1.41M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   799k|    do {                                                        \
  |  |  |  |   89|   799k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   799k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   799k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   799k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   799k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   799k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   799k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 799k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.41M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.41M]
  |  |  ------------------
  ------------------
  639|  1.41M|    MP_TARRAY_GROW(f, f->ppins, f->num_pins);
  ------------------
  |  |   96|  1.41M|    do {                                            \
  |  |   97|  1.41M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.41M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.41M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.41M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 799k, False: 612k]
  |  |  ------------------
  |  |   99|  1.41M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   799k|    do {                                                        \
  |  |  |  |   89|   799k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   799k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   799k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   799k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   799k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   799k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   799k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 799k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.41M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.41M]
  |  |  ------------------
  ------------------
  640|  1.41M|    f->pins[f->num_pins] = p;
  641|  1.41M|    f->ppins[f->num_pins] = p->other;
  642|  1.41M|    f->num_pins += 1;
  643|       |
  644|  1.41M|    init_connection(p);
  645|       |
  646|  1.41M|    return p->other;
  647|  1.41M|}
mp_filter_remove_pin:
  650|  1.41M|{
  651|  1.41M|    if (!p)
  ------------------
  |  Branch (651:9): [True: 0, False: 1.41M]
  ------------------
  652|      0|        return;
  653|       |
  654|  1.41M|    mp_assert(p->owner == f);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (654:5): [True: 1.41M, False: 0]
  ------------------
  655|  1.41M|    mp_pin_disconnect(p);
  656|  1.41M|    mp_pin_disconnect(p->other);
  657|       |
  658|  1.41M|    int index = -1;
  659|  1.41M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (659:21): [True: 1.41M, False: 0]
  ------------------
  660|  1.41M|        if (f->ppins[n] == p) {
  ------------------
  |  Branch (660:13): [True: 1.41M, False: 0]
  ------------------
  661|  1.41M|            index = n;
  662|  1.41M|            break;
  663|  1.41M|        }
  664|  1.41M|    }
  665|  1.41M|    mp_assert(index >= 0);
  ------------------
  |  |   41|  1.41M|#define mp_assert assert
  ------------------
  |  Branch (665:5): [True: 1.41M, False: 0]
  ------------------
  666|       |
  667|  1.41M|    talloc_free(f->pins[index]);
  ------------------
  |  |   47|  1.41M|#define talloc_free                     ta_free
  ------------------
  668|  1.41M|    talloc_free(f->ppins[index]);
  ------------------
  |  |   47|  1.41M|#define talloc_free                     ta_free
  ------------------
  669|       |
  670|  1.41M|    int count = f->num_pins;
  671|  1.41M|    MP_TARRAY_REMOVE_AT(f->pins, count, index);
  ------------------
  |  |  143|  1.41M|    do {                                            \
  |  |  144|  1.41M|        size_t at_ = (at);                          \
  |  |  145|  1.41M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.41M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.41M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.41M|        (idxvar)--;                                 \
  |  |  149|  1.41M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.41M]
  |  |  ------------------
  ------------------
  |  Branch (671:5): [True: 1.41M, False: 0]
  ------------------
  672|  1.41M|    count = f->num_pins;
  673|  1.41M|    MP_TARRAY_REMOVE_AT(f->ppins, count, index);
  ------------------
  |  |  143|  1.41M|    do {                                            \
  |  |  144|  1.41M|        size_t at_ = (at);                          \
  |  |  145|  1.41M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.41M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.41M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.41M|        (idxvar)--;                                 \
  |  |  149|  1.41M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.41M]
  |  |  ------------------
  ------------------
  |  Branch (673:5): [True: 1.41M, False: 0]
  ------------------
  674|  1.41M|    f->num_pins -= 1;
  675|  1.41M|}
mp_filter_command:
  678|  28.2M|{
  679|  28.2M|    return f->in->info->command ? f->in->info->command(f, cmd) : false;
  ------------------
  |  Branch (679:12): [True: 17.3M, False: 10.9M]
  ------------------
  680|  28.2M|}
mp_filter_find_stream_info:
  683|  61.5k|{
  684|   214k|    while (f) {
  ------------------
  |  Branch (684:12): [True: 214k, False: 0]
  ------------------
  685|   214k|        if (f->stream_info)
  ------------------
  |  Branch (685:13): [True: 61.5k, False: 152k]
  ------------------
  686|  61.5k|            return f->stream_info;
  687|   152k|        f = f->in->parent;
  688|   152k|    }
  689|      0|    return NULL;
  690|  61.5k|}
mp_filter_wakeup:
  726|  29.6M|{
  727|       |    filter_wakeup(f, false);
  728|  29.6M|}
mp_filter_graph_set_max_run_time:
  736|  16.1k|{
  737|  16.1k|    struct filter_runner *r = f->in->runner;
  738|  16.1k|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 16.1k, False: 0]
  ------------------
  739|  16.1k|    r->max_run_time = seconds;
  740|  16.1k|}
mp_filter_free_children:
  750|  1.12M|{
  751|  1.76M|    while(f->in->num_children)
  ------------------
  |  Branch (751:11): [True: 631k, False: 1.12M]
  ------------------
  752|   631k|        talloc_free(f->in->children[0]);
  ------------------
  |  |   47|   631k|#define talloc_free                     ta_free
  ------------------
  753|  1.12M|}
mp_filter_create_with_params:
  800|   831k|{
  801|   831k|    struct mp_filter *f = talloc(NULL, struct mp_filter);
  ------------------
  |  |   26|   831k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   831k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   831k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|   831k|    talloc_set_destructor(f, filter_destructor);
  ------------------
  |  |   41|   831k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  803|   831k|    *f = (struct mp_filter){
  804|   831k|        .priv = params->info->priv_size ?
  ------------------
  |  Branch (804:17): [True: 642k, False: 188k]
  ------------------
  805|   831k|                    talloc_zero_size(f, params->info->priv_size) : NULL,
  ------------------
  |  |   44|   642k|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|   642k|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   642k|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   642k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   642k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   642k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|   831k|        .global = params->global,
  807|   831k|        .packet_pool = demux_packet_pool_get(params->parent ? params->parent->global : params->global),
  ------------------
  |  Branch (807:46): [True: 800k, False: 31.2k]
  ------------------
  808|   831k|        .in = talloc(f, struct mp_filter_internal),
  ------------------
  |  |   26|   831k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   831k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   831k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|   831k|    };
  810|   831k|    *f->in = (struct mp_filter_internal){
  811|   831k|        .info = params->info,
  812|   831k|        .parent = params->parent,
  813|   831k|        .runner = params->parent ? params->parent->in->runner : NULL,
  ------------------
  |  Branch (813:19): [True: 800k, False: 31.2k]
  ------------------
  814|   831k|    };
  815|       |
  816|   831k|    if (!f->in->runner) {
  ------------------
  |  Branch (816:9): [True: 31.2k, False: 800k]
  ------------------
  817|  31.2k|        mp_assert(params->global);
  ------------------
  |  |   41|  31.2k|#define mp_assert assert
  ------------------
  |  Branch (817:9): [True: 31.2k, False: 0]
  ------------------
  818|       |
  819|  31.2k|        f->in->runner = talloc(NULL, struct filter_runner);
  ------------------
  |  |   26|  31.2k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  31.2k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  31.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|  31.2k|        *f->in->runner = (struct filter_runner){
  821|  31.2k|            .global = params->global,
  822|  31.2k|            .root_filter = f,
  823|  31.2k|            .max_run_time = INFINITY,
  824|  31.2k|        };
  825|  31.2k|        mp_mutex_init(&f->in->runner->async_lock);
  826|  31.2k|    }
  827|       |
  828|   831k|    if (!f->global)
  ------------------
  |  Branch (828:9): [True: 800k, False: 31.2k]
  ------------------
  829|   800k|        f->global = f->in->runner->global;
  830|       |
  831|   831k|    if (f->in->parent) {
  ------------------
  |  Branch (831:9): [True: 800k, False: 31.2k]
  ------------------
  832|   800k|        struct mp_filter_internal *parent = f->in->parent->in;
  833|   800k|        MP_TARRAY_APPEND(parent, parent->children, parent->num_children, f);
  ------------------
  |  |  105|   800k|    do {                                            \
  |  |  106|   800k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   800k|    do {                                            \
  |  |  |  |   97|   800k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   800k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   800k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   800k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 540k, False: 259k]
  |  |  |  |  ------------------
  |  |  |  |   99|   800k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   540k|    do {                                                        \
  |  |  |  |  |  |   89|   540k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   540k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   540k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   540k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   540k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   540k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   540k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 540k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   800k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 800k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   800k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   800k|        (idxvar)++;                                 \
  |  |  109|   800k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 800k]
  |  |  ------------------
  ------------------
  834|   800k|        f->log = mp_log_new(f, f->global->log, params->info->name);
  835|   800k|    } else {
  836|  31.2k|        f->log = mp_log_new(f, f->global->log, "!root");
  837|  31.2k|    }
  838|       |
  839|   831k|    if (f->in->info->init) {
  ------------------
  |  Branch (839:9): [True: 0, False: 831k]
  ------------------
  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|   831k|    return f;
  847|   831k|}
mp_filter_create:
  851|   800k|{
  852|   800k|    mp_assert(parent);
  ------------------
  |  |   41|   800k|#define mp_assert assert
  ------------------
  |  Branch (852:5): [True: 800k, False: 0]
  ------------------
  853|   800k|    mp_assert(info);
  ------------------
  |  |   41|   800k|#define mp_assert assert
  ------------------
  |  Branch (853:5): [True: 800k, False: 0]
  ------------------
  854|   800k|    struct mp_filter_params params = {
  855|   800k|        .info = info,
  856|   800k|        .parent = parent,
  857|   800k|    };
  858|   800k|    return mp_filter_create_with_params(&params);
  859|   800k|}
mp_filter_create_root:
  868|  31.2k|{
  869|  31.2k|    struct mp_filter_params params = {
  870|  31.2k|        .info = &filter_root,
  871|  31.2k|        .global = global,
  872|  31.2k|    };
  873|  31.2k|    return mp_filter_create_with_params(&params);
  874|  31.2k|}
mp_filter_graph_set_wakeup_cb:
  878|  31.2k|{
  879|  31.2k|    struct filter_runner *r = root->in->runner;
  880|  31.2k|    mp_assert(root == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  31.2k|#define mp_assert assert
  ------------------
  |  Branch (880:5): [True: 31.2k, False: 0]
  ------------------
  881|  31.2k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  31.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  882|  31.2k|    r->wakeup_cb = wakeup_cb;
  883|  31.2k|    r->wakeup_ctx = ctx;
  884|  31.2k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  31.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  885|  31.2k|}
filter.c:add_pending:
  131|   234M|{
  132|   234M|    struct filter_runner *r = f->in->runner;
  133|       |
  134|   234M|    if (f->in->pending)
  ------------------
  |  Branch (134:9): [True: 2.89M, False: 231M]
  ------------------
  135|  2.89M|        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|   231M|    f->in->pending = true;
  140|   231M|    if (f->in->high_priority) {
  ------------------
  |  Branch (140:9): [True: 2.16M, False: 229M]
  ------------------
  141|  2.16M|        MP_TARRAY_INSERT_AT(r, r->pending, r->num_pending, 0, f);
  ------------------
  |  |  115|  2.16M|    do {                                            \
  |  |  116|  2.16M|        size_t at_ = (at);                          \
  |  |  117|  2.16M|        assert(at_ <= (idxvar));                    \
  |  |  118|  2.16M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.16M|    do {                                            \
  |  |  |  |   97|  2.16M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.16M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.16M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.16M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 2.16M]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.16M|            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|  2.16M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.16M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  2.16M|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  2.16M|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  2.16M|        (idxvar)++;                                 \
  |  |  122|  2.16M|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  2.16M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 2.16M]
  |  |  ------------------
  ------------------
  |  Branch (141:9): [True: 2.16M, False: 0]
  ------------------
  142|   229M|    } else {
  143|   229M|        MP_TARRAY_APPEND(r, r->pending, r->num_pending, f);
  ------------------
  |  |  105|   229M|    do {                                            \
  |  |  106|   229M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   229M|    do {                                            \
  |  |  |  |   97|   229M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   229M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   229M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   229M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 85.3k, False: 229M]
  |  |  |  |  ------------------
  |  |  |  |   99|   229M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  85.3k|    do {                                                        \
  |  |  |  |  |  |   89|  85.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  85.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  85.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  85.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  85.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  85.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  85.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 85.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   229M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 229M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   229M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   229M|        (idxvar)++;                                 \
  |  |  109|   229M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 229M]
  |  |  ------------------
  ------------------
  144|   229M|    }
  145|   231M|}
filter.c:flush_async_notifications:
  199|  30.8M|{
  200|  30.8M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  30.8M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  201|  42.5M|    for (int n = 0; n < r->num_async_pending; n++) {
  ------------------
  |  Branch (201:21): [True: 11.7M, False: 30.8M]
  ------------------
  202|  11.7M|        struct mp_filter *f = r->async_pending[n];
  203|  11.7M|        add_pending(f);
  204|  11.7M|        f->in->async_pending = false;
  205|  11.7M|    }
  206|  30.8M|    r->num_async_pending = 0;
  207|  30.8M|    r->async_wakeup_sent = false;
  208|  30.8M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  30.8M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  209|  30.8M|}
filter.c:add_pending_pin:
  148|   219M|{
  149|   219M|    struct mp_filter *f = p->manual_connection;
  150|   219M|    mp_assert(f);
  ------------------
  |  |   41|   219M|#define mp_assert assert
  ------------------
  |  Branch (150:5): [True: 219M, False: 18.4E]
  ------------------
  151|       |
  152|   219M|    if (f->in->pending)
  ------------------
  |  Branch (152:9): [True: 1.45M, False: 217M]
  ------------------
  153|  1.45M|        return;
  154|       |
  155|   217M|    add_pending(f);
  156|       |
  157|       |    // Need to tell user that something changed.
  158|   217M|    if (f == f->in->runner->root_filter && p != f->in->runner->recursive)
  ------------------
  |  Branch (158:9): [True: 3.07M, False: 214M]
  |  Branch (158:44): [True: 2.28M, False: 793k]
  ------------------
  159|  2.28M|        f->in->runner->external_pending = true;
  160|   217M|}
filter.c:filter_recursive:
  169|   289M|{
  170|   289M|    struct mp_filter *f = p->conn->manual_connection;
  171|   289M|    mp_assert(f);
  ------------------
  |  |   41|   289M|#define mp_assert assert
  ------------------
  |  Branch (171:5): [True: 289M, False: 18.4E]
  ------------------
  172|   289M|    struct filter_runner *r = f->in->runner;
  173|       |
  174|       |    // Never do internal filtering recursively.
  175|   289M|    if (r->filtering)
  ------------------
  |  Branch (175:9): [True: 286M, False: 3.44M]
  ------------------
  176|   286M|        return;
  177|       |
  178|  3.44M|    mp_assert(!r->recursive);
  ------------------
  |  |   41|  3.44M|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 3.44M, False: 18.4E]
  ------------------
  179|  3.44M|    r->recursive = p;
  180|       |
  181|       |    // Also don't lose the pending state, which the user may or may not
  182|       |    // care about.
  183|  3.44M|    r->external_pending |= mp_filter_graph_run(r->root_filter);
  184|       |
  185|  3.44M|    mp_assert(r->recursive == p);
  ------------------
  |  |   41|  3.44M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 3.44M, False: 18.4E]
  ------------------
  186|  3.44M|    r->recursive = NULL;
  187|  3.44M|}
filter.c:init_connection:
  385|  1.83M|{
  386|  1.83M|    struct filter_runner *runner = p->owner->in->runner;
  387|       |
  388|  1.83M|    if (p->dir == MP_PIN_IN)
  ------------------
  |  Branch (388:9): [True: 644k, False: 1.19M]
  ------------------
  389|   644k|        p = p->other;
  390|       |
  391|  1.83M|    struct mp_pin *in = find_connected_end(p);
  392|  1.83M|    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.83M|    mp_assert(!in->user_conn);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (395:5): [True: 1.83M, False: 0]
  ------------------
  396|  1.83M|    mp_assert(!out->user_conn);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 1.83M, False: 0]
  ------------------
  397|       |
  398|       |    // This and similar checks enforce the same root filter requirement.
  399|  1.83M|    if (in->manual_connection)
  ------------------
  |  Branch (399:9): [True: 1.83M, False: 0]
  ------------------
  400|  1.83M|        mp_assert(in->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (400:9): [True: 1.83M, False: 0]
  ------------------
  401|  1.83M|    if (out->manual_connection)
  ------------------
  |  Branch (401:9): [True: 1.83M, False: 0]
  ------------------
  402|  1.83M|        mp_assert(out->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (402:9): [True: 1.83M, 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.83M|    if (!in->manual_connection || !out->manual_connection)
  ------------------
  |  Branch (408:9): [True: 0, False: 1.83M]
  |  Branch (408:35): [True: 0, False: 1.83M]
  ------------------
  409|      0|        return;
  410|       |
  411|  1.83M|    mp_assert(in->dir == MP_PIN_IN);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (411:5): [True: 1.83M, False: 0]
  ------------------
  412|  1.83M|    mp_assert(out->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.83M|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 1.83M, False: 0]
  ------------------
  413|       |
  414|  1.83M|    struct mp_pin *cur = in;
  415|  4.14M|    while (cur) {
  ------------------
  |  Branch (415:12): [True: 2.30M, False: 1.83M]
  ------------------
  416|  2.30M|        mp_assert(!cur->within_conn && !cur->other->within_conn);
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (416:9): [True: 2.30M, False: 0]
  |  Branch (416:9): [True: 2.30M, False: 0]
  ------------------
  417|  2.30M|        mp_assert(!cur->conn && !cur->other->conn);
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (417:9): [True: 2.30M, False: 0]
  |  Branch (417:9): [True: 2.30M, False: 0]
  ------------------
  418|  2.30M|        mp_assert(!cur->data_requested); // unused for in pins
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (418:9): [True: 2.30M, False: 0]
  ------------------
  419|  2.30M|        mp_assert(!cur->data.type); // unused for in pins
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (419:9): [True: 2.30M, False: 0]
  ------------------
  420|  2.30M|        mp_assert(!cur->other->data_requested); // unset for unconnected out pins
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (420:9): [True: 2.30M, False: 0]
  ------------------
  421|  2.30M|        mp_assert(!cur->other->data.type); // unset for unconnected out pins
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (421:9): [True: 2.30M, False: 0]
  ------------------
  422|  2.30M|        mp_assert(cur->owner->in->runner == runner);
  ------------------
  |  |   41|  2.30M|#define mp_assert assert
  ------------------
  |  Branch (422:9): [True: 2.30M, False: 0]
  ------------------
  423|  2.30M|        cur->within_conn = cur->other->within_conn = true;
  424|  2.30M|        cur = cur->other->user_conn;
  425|  2.30M|    }
  426|       |
  427|  1.83M|    in->conn = out;
  428|  1.83M|    in->within_conn = false;
  429|  1.83M|    out->conn = in;
  430|  1.83M|    out->within_conn = false;
  431|       |
  432|       |    // Scheduling so far will be messed up.
  433|  1.83M|    add_pending(in->manual_connection);
  434|  1.83M|    add_pending(out->manual_connection);
  435|  1.83M|}
filter.c:find_connected_end:
  372|  7.34M|{
  373|  8.17M|    while (1) {
  ------------------
  |  Branch (373:12): [True: 8.17M, Folded]
  ------------------
  374|  8.17M|        struct mp_pin *other = p->other;
  375|  8.17M|        if (!other->user_conn)
  ------------------
  |  Branch (375:13): [True: 7.34M, False: 829k]
  ------------------
  376|  7.34M|            return other;
  377|   829k|        p = other->user_conn;
  378|   829k|    }
  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|  3.67M|{
  478|  3.67M|    if (p->dir == MP_PIN_OUT)
  ------------------
  |  Branch (478:9): [True: 1.83M, False: 1.83M]
  ------------------
  479|  1.83M|        p = p->other;
  480|       |
  481|  3.67M|    p = find_connected_end(p);
  482|       |
  483|  7.76M|    while (p) {
  ------------------
  |  Branch (483:12): [True: 4.09M, False: 3.67M]
  ------------------
  484|  4.09M|        p->conn = p->other->conn = NULL;
  485|  4.09M|        p->within_conn = p->other->within_conn = false;
  486|  4.09M|        mp_assert(!p->other->data_requested); // unused for in pins
  ------------------
  |  |   41|  4.09M|#define mp_assert assert
  ------------------
  |  Branch (486:9): [True: 4.09M, False: 0]
  ------------------
  487|  4.09M|        mp_assert(!p->other->data.type); // unused for in pins
  ------------------
  |  |   41|  4.09M|#define mp_assert assert
  ------------------
  |  Branch (487:9): [True: 4.09M, False: 0]
  ------------------
  488|  4.09M|        if (p->data.type)
  ------------------
  |  Branch (488:13): [True: 599, False: 4.09M]
  ------------------
  489|  4.09M|            MP_VERBOSE(p->owner, "dropping frame due to pin disconnect\n");
  ------------------
  |  |   92|    599|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    599|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  4.09M|        if (p->data_requested)
  ------------------
  |  Branch (490:13): [True: 97.4k, False: 3.99M]
  ------------------
  491|  4.09M|            MP_VERBOSE(p->owner, "dropping request due to pin disconnect\n");
  ------------------
  |  |   92|  97.4k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  97.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  492|       |        p->data_requested = false;
  493|  4.09M|        mp_frame_unref(&p->data);
  494|  4.09M|        p = p->other->user_conn;
  495|  4.09M|    }
  496|  3.67M|}
filter.c:reset_pin:
  585|   310M|{
  586|   310M|    if (!p->conn || p->dir != MP_PIN_OUT) {
  ------------------
  |  Branch (586:9): [True: 86.9M, False: 223M]
  |  Branch (586:21): [True: 111M, False: 111M]
  ------------------
  587|   198M|        mp_assert(!p->data.type);
  ------------------
  |  |   41|   198M|#define mp_assert assert
  ------------------
  |  Branch (587:9): [True: 198M, False: 0]
  ------------------
  588|   198M|        mp_assert(!p->data_requested);
  ------------------
  |  |   41|   198M|#define mp_assert assert
  ------------------
  |  Branch (588:9): [True: 198M, False: 0]
  ------------------
  589|   198M|    }
  590|   310M|    mp_frame_unref(&p->data);
  591|       |    p->data_requested = false;
  592|   310M|}
filter.c:filter_wakeup:
  709|  29.6M|{
  710|  29.6M|    struct filter_runner *r = f->in->runner;
  711|  29.6M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  29.6M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  712|  29.6M|    if (!f->in->async_pending) {
  ------------------
  |  Branch (712:9): [True: 11.7M, False: 17.9M]
  ------------------
  713|  11.7M|        f->in->async_pending = true;
  714|       |        // (not using a talloc parent for thread safety reasons)
  715|  11.7M|        MP_TARRAY_APPEND(NULL, r->async_pending, r->num_async_pending, f);
  ------------------
  |  |  105|  11.7M|    do {                                            \
  |  |  106|  11.7M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  11.7M|    do {                                            \
  |  |  |  |   97|  11.7M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  11.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  11.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  11.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 33.1k, False: 11.6M]
  |  |  |  |  ------------------
  |  |  |  |   99|  11.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  33.1k|    do {                                                        \
  |  |  |  |  |  |   89|  33.1k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  33.1k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  33.1k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  33.1k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  33.1k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  33.1k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  33.1k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 33.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  11.7M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11.7M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  11.7M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  11.7M|        (idxvar)++;                                 \
  |  |  109|  11.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11.7M]
  |  |  ------------------
  ------------------
  716|  11.7M|    }
  717|  29.6M|    if (!mark_only && !r->async_wakeup_sent) {
  ------------------
  |  Branch (717:9): [True: 29.6M, False: 18.4E]
  |  Branch (717:23): [True: 8.39M, False: 21.2M]
  ------------------
  718|  8.39M|        if (r->wakeup_cb)
  ------------------
  |  Branch (718:13): [True: 8.37M, False: 15.0k]
  ------------------
  719|  8.37M|            r->wakeup_cb(r->wakeup_ctx);
  720|  8.39M|        r->async_wakeup_sent = true;
  721|  8.39M|    }
  722|  29.6M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  29.6M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  723|  29.6M|}
filter.c:filter_destructor:
  756|   831k|{
  757|   831k|    struct mp_filter *f = p;
  758|   831k|    struct filter_runner *r = f->in->runner;
  759|       |
  760|   831k|    if (f->in->info->destroy)
  ------------------
  |  Branch (760:9): [True: 683k, False: 148k]
  ------------------
  761|   683k|        f->in->info->destroy(f);
  762|       |
  763|       |    // For convenience, free child filters.
  764|   831k|    mp_filter_free_children(f);
  765|       |
  766|  2.24M|    while (f->num_pins)
  ------------------
  |  Branch (766:12): [True: 1.41M, False: 831k]
  ------------------
  767|  1.41M|        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|   831k|    flush_async_notifications(r);
  772|       |
  773|  1.71M|    for (int n = 0; n < r->num_pending; n++) {
  ------------------
  |  Branch (773:21): [True: 1.04M, False: 670k]
  ------------------
  774|  1.04M|        if (r->pending[n] == f) {
  ------------------
  |  Branch (774:13): [True: 161k, False: 880k]
  ------------------
  775|   161k|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, n);
  ------------------
  |  |  143|   161k|    do {                                            \
  |  |  144|   161k|        size_t at_ = (at);                          \
  |  |  145|   161k|        assert(at_ < (idxvar));                     \
  |  |  146|   161k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   161k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   161k|        (idxvar)--;                                 \
  |  |  149|   161k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 161k]
  |  |  ------------------
  ------------------
  |  Branch (775:13): [True: 161k, False: 0]
  ------------------
  776|   161k|            break;
  777|   161k|        }
  778|  1.04M|    }
  779|       |
  780|   831k|    if (f->in->parent) {
  ------------------
  |  Branch (780:9): [True: 800k, False: 31.2k]
  ------------------
  781|   800k|        struct mp_filter_internal *p_in = f->in->parent->in;
  782|  1.15M|        for (int n = 0; n < p_in->num_children; n++) {
  ------------------
  |  Branch (782:25): [True: 1.15M, False: 0]
  ------------------
  783|  1.15M|            if (p_in->children[n] == f) {
  ------------------
  |  Branch (783:17): [True: 800k, False: 354k]
  ------------------
  784|   800k|                MP_TARRAY_REMOVE_AT(p_in->children, p_in->num_children, n);
  ------------------
  |  |  143|   800k|    do {                                            \
  |  |  144|   800k|        size_t at_ = (at);                          \
  |  |  145|   800k|        assert(at_ < (idxvar));                     \
  |  |  146|   800k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   800k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   800k|        (idxvar)--;                                 \
  |  |  149|   800k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 800k]
  |  |  ------------------
  ------------------
  |  Branch (784:17): [True: 800k, False: 0]
  ------------------
  785|   800k|                break;
  786|   800k|            }
  787|  1.15M|        }
  788|   800k|    }
  789|       |
  790|   831k|    if (r->root_filter == f) {
  ------------------
  |  Branch (790:9): [True: 31.2k, False: 800k]
  ------------------
  791|  31.2k|        mp_assert(!f->in->parent);
  ------------------
  |  |   41|  31.2k|#define mp_assert assert
  ------------------
  |  Branch (791:9): [True: 31.2k, False: 0]
  ------------------
  792|  31.2k|        mp_mutex_destroy(&r->async_lock);
  ------------------
  |  |  133|  31.2k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  793|  31.2k|        talloc_free(r->async_pending);
  ------------------
  |  |   47|  31.2k|#define talloc_free                     ta_free
  ------------------
  794|  31.2k|        talloc_free(r);
  ------------------
  |  |   47|  31.2k|#define talloc_free                     ta_free
  ------------------
  795|  31.2k|    }
  796|   831k|}

mp_frame_is_signaling:
  137|  9.36M|{
  138|  9.36M|    return frame_handlers[frame.type].is_signaling;
  139|  9.36M|}
mp_frame_unref:
  142|   337M|{
  143|   337M|    if (!frame)
  ------------------
  |  Branch (143:9): [True: 0, False: 337M]
  ------------------
  144|      0|        return;
  145|       |
  146|   337M|    if (frame_handlers[frame->type].free)
  ------------------
  |  Branch (146:9): [True: 209k, False: 337M]
  ------------------
  147|   209k|        frame_handlers[frame->type].free(frame->data);
  148|       |
  149|   337M|    *frame = (struct mp_frame){0};
  150|   337M|}
mp_frame_get_pts:
  164|  52.4M|{
  165|  52.4M|    if (frame_handlers[frame.type].get_pts)
  ------------------
  |  Branch (165:9): [True: 2.90M, False: 49.4M]
  ------------------
  166|  2.90M|        return frame_handlers[frame.type].get_pts(frame.data);
  167|  49.4M|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  49.4M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  52.4M|}
mp_frame_approx_size:
  177|  1.78M|{
  178|  1.78M|    if (frame_handlers[frame.type].approx_size)
  ------------------
  |  Branch (178:9): [True: 462k, False: 1.32M]
  ------------------
  179|   462k|        return frame_handlers[frame.type].approx_size(frame.data);
  180|  1.32M|    return 0;
  181|  1.78M|}
frame.c:video_get_pts:
   29|   494k|{
   30|   494k|    return ((struct mp_image *)data)->pts;
   31|   494k|}
frame.c:video_approx_size:
   39|    938|{
   40|    938|    return mp_image_approx_byte_size(data);
   41|    938|}
frame.c:audio_get_pts:
   59|  2.41M|{
   60|  2.41M|    return mp_aframe_get_pts(data);
   61|  2.41M|}
frame.c:audio_approx_size:
   69|   461k|{
   70|   461k|    return mp_aframe_approx_byte_size(data);
   71|   461k|}

mp_create_user_filter:
  151|  9.34k|{
  152|  9.34k|    const struct m_obj_list *obj_list = NULL;
  153|  9.34k|    enum mp_frame_type frame_type = 0;
  154|  9.34k|    if (type == MP_OUTPUT_CHAIN_VIDEO) {
  ------------------
  |  Branch (154:9): [True: 2.20k, False: 7.13k]
  ------------------
  155|  2.20k|        frame_type = MP_FRAME_VIDEO;
  156|  2.20k|        obj_list = &vf_obj_list;
  157|  7.13k|    } else if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (157:16): [True: 7.13k, False: 0]
  ------------------
  158|  7.13k|        frame_type = MP_FRAME_AUDIO;
  159|  7.13k|        obj_list = &af_obj_list;
  160|  7.13k|    }
  161|  9.34k|    mp_assert(frame_type && obj_list);
  ------------------
  |  |   41|  9.34k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 9.34k, False: 0]
  |  Branch (161:5): [True: 9.34k, False: 0]
  ------------------
  162|       |
  163|  9.34k|    struct mp_filter *f = NULL;
  164|       |
  165|  9.34k|    struct m_obj_desc desc;
  166|  9.34k|    if (!m_obj_list_find(&desc, obj_list, bstr0(name))) {
  ------------------
  |  Branch (166:9): [True: 1.28k, False: 8.05k]
  ------------------
  167|       |        // Generic lavfi bridge.
  168|  1.28k|        if (strncmp(name, "lavfi-", 6) == 0)
  ------------------
  |  Branch (168:13): [True: 0, False: 1.28k]
  ------------------
  169|      0|            name += 6;
  170|  1.28k|        struct mp_lavfi *l =
  171|  1.28k|            mp_lavfi_create_filter(parent, frame_type, true, NULL, NULL, name, args);
  172|  1.28k|        if (l)
  ------------------
  |  Branch (172:13): [True: 0, False: 1.28k]
  ------------------
  173|      0|            f = l->f;
  174|  1.28k|        goto done;
  175|  1.28k|    }
  176|       |
  177|  8.05k|    void *options = NULL;
  178|  8.05k|    if (desc.options) {
  ------------------
  |  Branch (178:9): [True: 8.01k, False: 39]
  ------------------
  179|  8.01k|        struct m_config *config =
  180|  8.01k|            m_config_from_obj_desc_and_args(NULL, parent->log, parent->global,
  181|  8.01k|                                            &desc, args);
  182|       |
  183|  8.01k|        if (!config)
  ------------------
  |  Branch (183:13): [True: 0, False: 8.01k]
  ------------------
  184|      0|            goto done;
  185|       |
  186|  8.01k|        options = config->optstruct;
  187|       |        // Free config when options is freed.
  188|  8.01k|        ta_set_parent(options, NULL);
  189|  8.01k|        ta_set_parent(config, options);
  190|  8.01k|    }
  191|       |
  192|  8.05k|    const struct mp_user_filter_entry *entry = desc.p;
  193|  8.05k|    f = entry->create(parent, options);
  194|       |
  195|  9.34k|done:
  196|  9.34k|    if (!f) {
  ------------------
  |  Branch (196:9): [True: 1.38k, False: 7.96k]
  ------------------
  197|  1.38k|        MP_ERR(parent, "Creating filter '%s' failed.\n", name);
  ------------------
  |  |   89|  1.38k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.38k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  198|  1.38k|        return NULL;
  199|  1.38k|    }
  200|  7.96k|    return f;
  201|  9.34k|}
user_filters.c:get_af_desc:
   48|   346k|{
   49|   346k|    return get_desc_from(af_list, MP_ARRAY_SIZE(af_list), dst, index);
  ------------------
  |  |   49|   346k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
   50|   346k|}
user_filters.c:get_desc_from:
   14|   423k|{
   15|   423k|    if (index >= num)
  ------------------
  |  Branch (15:9): [True: 32.1k, False: 391k]
  ------------------
   16|  32.1k|        return false;
   17|   391k|    const struct mp_user_filter_entry *entry = list[index];
   18|   391k|    *dst = entry->desc;
   19|   391k|    dst->p = entry;
   20|       |    return true;
   21|   423k|}
user_filters.c:check_af_lavfi:
   63|  6.41k|{
   64|  6.41k|    return check_unknown_entry(name, AVMEDIA_TYPE_AUDIO);
   65|  6.41k|}
user_filters.c:check_unknown_entry:
   24|  7.29k|{
   25|       |    // Generic lavfi bridge: skip the lavfi- prefix, if present.
   26|  7.29k|    if (strncmp(name, "lavfi-", 6) == 0)
  ------------------
  |  Branch (26:9): [True: 22, False: 7.27k]
  ------------------
   27|     22|        name += 6;
   28|  7.29k|    return mp_lavfi_is_usable(name, media_type);
   29|  7.29k|}
user_filters.c:print_af_help_list:
   53|    230|{
   54|    230|    print_lavfi_help_list(log, AVMEDIA_TYPE_AUDIO);
   55|    230|}
user_filters.c:get_vf_desc:
  113|  76.7k|{
  114|  76.7k|    return get_desc_from(vf_list, MP_ARRAY_SIZE(vf_list), dst, index);
  ------------------
  |  |   49|  76.7k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  115|  76.7k|}
user_filters.c:check_vf_lavfi:
  128|    883|{
  129|    883|    return check_unknown_entry(name, AVMEDIA_TYPE_VIDEO);
  130|    883|}

fuzzer_ipc.c:set_fontconfig_sysroot:
   54|  11.6k|{
   55|  11.6k|#ifdef MPV_FONTCONFIG_SYSROOT
   56|  11.6k|    const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT);
  ------------------
  |  |   35|  11.6k|#define MPV_STRINGIFY(X) MPV_STRINGIFY_(X)
  |  |  ------------------
  |  |  |  |   34|  11.6k|#define MPV_STRINGIFY_(X) #X
  |  |  ------------------
  ------------------
   57|  11.6k|    char path[PATH_MAX];
   58|  11.6k|    if (sysroot[0] != '/') {
  ------------------
  |  Branch (58:9): [True: 11.6k, False: 0]
  ------------------
   59|  11.6k|        ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);
   60|  11.6k|        if (len < 0)
  ------------------
  |  Branch (60:13): [True: 0, False: 11.6k]
  ------------------
   61|      0|            exit(1);
   62|  11.6k|        path[len] = '\0';
   63|  11.6k|        char *name = strrchr(path, '/') + 1;
   64|  11.6k|        snprintf(name, path + sizeof(path) - name, "%s", sysroot);
   65|  11.6k|        sysroot = path;
   66|  11.6k|    }
   67|  11.6k|    setenv("FONTCONFIG_SYSROOT", sysroot, 1);
   68|  11.6k|#endif
   69|  11.6k|}
fuzzer_ipc.c:check_error:
   38|   116k|{
   39|   116k|    if (status < 0) {
  ------------------
  |  Branch (39:9): [True: 0, False: 116k]
  ------------------
   40|       |        fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status));
   41|      0|        exit(1);
   42|      0|    }
   43|   116k|}
fuzzer_ipc.c:initialize:
  100|  11.6k|{
  101|  11.6k|    check_error(mpv_initialize(ctx));
  102|  11.6k|    if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx))
  ------------------
  |  Branch (102:9): [True: 0, False: 11.6k]
  |  Branch (102:45): [True: 0, False: 11.6k]
  ------------------
  103|      0|        exit(1);
  104|  11.6k|}
fuzzer_ipc.c:wait_event:
   72|  11.6k|{
   73|  11.6k|    while (1) {
  ------------------
  |  Branch (73:12): [True: 11.6k, Folded]
  ------------------
   74|  11.6k|        mpv_event *event = mpv_wait_event(ctx, -1);
   75|  11.6k|        if (event->event_id == id)
  ------------------
  |  Branch (75:13): [True: 11.6k, False: 0]
  ------------------
   76|  11.6k|            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|  11.6k|}
fuzzer_ipc.c:sync_core:
   84|  23.3k|{
   85|  23.3k|    uint64_t sync_id = 1;
   86|  23.3k|    mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE);
   87|  23.3k|    bool ok;
   88|  42.8k|    while (1) {
  ------------------
  |  Branch (88:12): [True: 42.8k, Folded]
  ------------------
   89|  42.8k|        mpv_event *event = mpv_wait_event(ctx, -1);
   90|  42.8k|        ok = event->event_id != MPV_EVENT_SHUTDOWN;
   91|  42.8k|        if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE &&
  ------------------
  |  Branch (91:13): [True: 1.78k, False: 41.0k]
  |  Branch (91:21): [True: 21.5k, False: 19.4k]
  ------------------
   92|  21.5k|                    event->reply_userdata == sync_id))
  ------------------
  |  Branch (92:21): [True: 21.5k, False: 0]
  ------------------
   93|  23.3k|            break;
   94|  42.8k|    }
   95|  23.3k|    mpv_unobserve_property(ctx, sync_id);
   96|  23.3k|    return ok;
   97|  23.3k|}
fuzzer_ipc.c:destroy:
  107|  11.6k|{
  108|  11.6k|    if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED)
  ------------------
  |  Branch (108:9): [True: 11.6k, False: 0]
  ------------------
  109|  11.6k|        sync_core(ctx);
  110|  11.6k|    mpv_terminate_destroy(ctx);
  111|  11.6k|}

LLVMFuzzerTestOneInput:
   54|  11.6k|{
   55|  11.6k|    if (size > MAX_FUZZ_SIZE)
  ------------------
  |  |   30|  11.6k|#define MAX_FUZZ_SIZE (100 << 10) // 100 KiB
  ------------------
  |  Branch (55:9): [True: 3, False: 11.6k]
  ------------------
   56|      3|        return 0;
   57|       |
   58|  11.6k|    set_fontconfig_sysroot();
   59|       |
   60|  11.6k|    mpv_handle *ctx = mpv_create();
   61|  11.6k|    if (!ctx)
  ------------------
  |  Branch (61:9): [True: 0, False: 11.6k]
  ------------------
   62|      0|        exit(1);
   63|       |
   64|  11.6k|    check_error(mpv_set_option_string(ctx, "vo", "null"));
   65|  11.6k|    check_error(mpv_set_option_string(ctx, "ao", "null"));
   66|  11.6k|    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
   67|  11.6k|    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
   68|  11.6k|    check_error(mpv_set_option_string(ctx, "pause", "yes"));
   69|  11.6k|    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
   70|  11.6k|    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
   71|  11.6k|    check_error(mpv_set_option_string(ctx, "input-builtin-bindings", "no"));
   72|       |
   73|  11.6k|    initialize(ctx);
   74|       |
   75|       |    // The IPC server reads events only when it gets woken up.
   76|  11.6k|    mpv_handle *client = mpv_create_client(ctx, "ipc");
   77|  11.6k|    if (!client)
  ------------------
  |  Branch (77:9): [True: 0, False: 11.6k]
  ------------------
   78|      0|        exit(1);
   79|  11.6k|    mpv_set_wakeup_callback(client, wakeup, NULL);
   80|  11.6k|    mpv_set_wakeup_callback(ctx, wakeup, NULL);
   81|       |
   82|  11.6k|    const char *cmd[] = {"loadfile", "av://lavfi:yuvtestsrc=d=1[out0];sine=d=1[out1]", NULL};
   83|  11.6k|    check_error(mpv_command(ctx, cmd));
   84|       |
   85|  93.3k|    while (1) {
  ------------------
  |  Branch (85:12): [True: 93.3k, Folded]
  ------------------
   86|  93.3k|        mpv_event *event = mpv_wait_event(ctx, -1);
   87|  93.3k|        if (event->event_id == MPV_EVENT_PLAYBACK_RESTART ||
  ------------------
  |  Branch (87:13): [True: 11.6k, False: 81.7k]
  ------------------
   88|  81.7k|            event->event_id == MPV_EVENT_END_FILE)
  ------------------
  |  Branch (88:13): [True: 0, False: 81.7k]
  ------------------
   89|  11.6k|            break;
   90|  93.3k|    }
   91|       |
   92|       |    // The IPC server only runs newline terminated commands.
   93|  11.6k|    bool active = true;
   94|  11.6k|    bstr input = {(unsigned char *)data, size};
   95|  6.04M|    while (active && bstrchr(input, '\n') >= 0) {
  ------------------
  |  Branch (95:12): [True: 6.04M, False: 17]
  |  Branch (95:22): [True: 6.03M, False: 11.6k]
  ------------------
   96|  6.03M|        bstr buf = bstrdup(NULL, bstr_getline(input, &input));
   97|  6.03M|        talloc_free(mp_ipc_consume_next_command(client, NULL, &buf));
  ------------------
  |  |   47|  6.03M|#define talloc_free                     ta_free
  ------------------
   98|  6.03M|        talloc_free(buf.start);
  ------------------
  |  |   47|  6.03M|#define talloc_free                     ta_free
  ------------------
   99|  6.03M|        if (atomic_exchange(&events_pending, false))
  ------------------
  |  Branch (99:13): [True: 172k, False: 5.86M]
  ------------------
  100|   172k|            active = drain_events(client, true) && drain_events(ctx, false);
  ------------------
  |  Branch (100:22): [True: 172k, False: 17]
  |  Branch (100:52): [True: 172k, False: 0]
  ------------------
  101|  6.03M|    }
  102|       |
  103|  12.8k|    for (int n = 0; active && n < EVENTS_LIMIT && playing(ctx); n++) {
  ------------------
  |  |  118|  25.3k|#define EVENTS_LIMIT 10
  ------------------
  |  Branch (103:21): [True: 12.5k, False: 321]
  |  Branch (103:31): [True: 12.4k, False: 50]
  |  Branch (103:51): [True: 1.18k, False: 11.3k]
  ------------------
  104|  1.18k|        mpv_event *event = mpv_wait_event(ctx, PLAYBACK_TIME_LIMIT);
  ------------------
  |  |  114|  1.18k|#define PLAYBACK_TIME_LIMIT 1
  ------------------
  105|  1.18k|        active = event->event_id != MPV_EVENT_NONE &&
  ------------------
  |  Branch (105:18): [True: 876, False: 304]
  ------------------
  106|    876|                 event->event_id != MPV_EVENT_SHUTDOWN;
  ------------------
  |  Branch (106:18): [True: 876, False: 0]
  ------------------
  107|  1.18k|    }
  108|       |
  109|  11.6k|    mpv_destroy(client);
  110|  11.6k|    destroy(ctx);
  111|       |
  112|  11.6k|    return 0;
  113|  11.6k|}
fuzzer_ipc.c:wakeup:
   28|  5.49M|{
   29|       |    atomic_store(&events_pending, true);
   30|  5.49M|}
fuzzer_ipc.c:drain_events:
   33|   344k|{
   34|  11.3M|    while (1) {
  ------------------
  |  Branch (34:12): [True: 11.3M, Folded]
  ------------------
   35|  11.3M|        mpv_event *event = mpv_wait_event(ctx, 0);
   36|  11.3M|        if (event->event_id == MPV_EVENT_NONE)
  ------------------
  |  Branch (36:13): [True: 344k, False: 11.0M]
  ------------------
   37|   344k|            return true;
   38|  11.0M|        if (event->event_id == MPV_EVENT_SHUTDOWN)
  ------------------
  |  Branch (38:13): [True: 17, False: 11.0M]
  ------------------
   39|     17|            return false;
   40|  11.0M|        if (encode)
  ------------------
  |  Branch (40:13): [True: 5.57M, False: 5.48M]
  ------------------
   41|  5.57M|            talloc_free(mp_json_encode_event(event));
  ------------------
  |  |   47|  5.57M|#define talloc_free                     ta_free
  ------------------
   42|  11.0M|    }
   43|   344k|}
fuzzer_ipc.c:playing:
   46|  12.4k|{
   47|  12.4k|    int idle = 1, pause = 1;
   48|  12.4k|    mpv_get_property(ctx, "idle-active", MPV_FORMAT_FLAG, &idle);
   49|  12.4k|    mpv_get_property(ctx, "pause", MPV_FORMAT_FLAG, &pause);
   50|  12.4k|    return !idle && !pause;
  ------------------
  |  Branch (50:12): [True: 10.8k, False: 1.62k]
  |  Branch (50:21): [True: 1.18k, False: 9.67k]
  ------------------
   51|  12.4k|}

mp_input_parse_cmd_node:
  293|  35.0k|{
  294|  35.0k|    struct mp_cmd *cmd = talloc_ptrtype(NULL, cmd);
  ------------------
  |  |   34|  35.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  35.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  35.0k|    talloc_set_destructor(cmd, destroy_cmd);
  ------------------
  |  |   41|  35.0k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  296|  35.0k|    *cmd = (struct mp_cmd) { .scale = 1, .scale_units = 1 };
  297|       |
  298|  35.0k|    bool res = false;
  299|  35.0k|    if (node->format == MPV_FORMAT_NODE_ARRAY) {
  ------------------
  |  Branch (299:9): [True: 35.0k, False: 0]
  ------------------
  300|  35.0k|        res = cmd_node_array(log, cmd, node);
  301|  35.0k|    } 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|  35.0k|    res = res && finish_cmd(log, cmd);
  ------------------
  |  Branch (305:11): [True: 35.0k, False: 0]
  |  Branch (305:18): [True: 35.0k, False: 0]
  ------------------
  306|       |
  307|  35.0k|    if (!res)
  ------------------
  |  Branch (307:9): [True: 0, False: 35.0k]
  ------------------
  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|  35.0k|    return cmd;
  311|  35.0k|}
mp_input_parse_cmd_str:
  455|  2.76M|{
  456|  2.76M|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  2.76M|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  2.76M|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  457|  2.76M|    bstr original = str;
  458|  2.76M|    struct mp_cmd *cmd = parse_cmd_str(log, tmp, &str, loc);
  459|  2.76M|    if (!cmd)
  ------------------
  |  Branch (459:9): [True: 2.19M, False: 569k]
  ------------------
  460|  2.19M|        goto done;
  461|       |
  462|       |    // Handle "multi" commands
  463|   569k|    struct mp_cmd **p_prev = NULL;
  464|   569k|    while (1) {
  ------------------
  |  Branch (464:12): [True: 569k, Folded]
  ------------------
  465|   569k|        str = bstr_lstrip(str);
  466|       |        // read_token just to check whether it's trailing whitespace only
  467|   569k|        bstr u1, u2;
  468|   569k|        if (!bstr_eatstart0(&str, ";") || !read_token(str, &u1, &u2))
  ------------------
  |  Branch (468:13): [True: 566k, False: 2.77k]
  |  Branch (468:43): [True: 1.64k, False: 1.13k]
  ------------------
  469|   568k|            break;
  470|       |        // Multi-command. Since other input.c code uses queue_next for its
  471|       |        // own purposes, a pseudo-command is used to wrap the command list.
  472|  1.13k|        if (!p_prev) {
  ------------------
  |  Branch (472:13): [True: 1.03k, False: 103]
  ------------------
  473|  1.03k|            struct mp_cmd *list = talloc_ptrtype(NULL, list);
  ------------------
  |  |   34|  1.03k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.03k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.03k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|  1.03k|            talloc_set_destructor(list, destroy_cmd);
  ------------------
  |  |   41|  1.03k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  475|  1.03k|            *list = (struct mp_cmd) {
  476|  1.03k|                .name = (char *)mp_cmd_list.name,
  477|  1.03k|                .def = &mp_cmd_list,
  478|  1.03k|            };
  479|  1.03k|            talloc_steal(list, cmd);
  ------------------
  |  |   38|  1.03k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  1.03k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  480|  1.03k|            struct mp_cmd_arg arg = {0};
  481|  1.03k|            arg.v.p = cmd;
  482|  1.03k|            list->args = talloc_dup(list, &arg);
  ------------------
  |  |   48|  1.03k|#define talloc_dup                      ta_xdup
  |  |  ------------------
  |  |  |  |  141|  1.03k|#define ta_xdup(...)                    ta_oom_g(ta_dup(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.03k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|  1.03k|            p_prev = &cmd->queue_next;
  484|  1.03k|            cmd = list;
  485|  1.03k|        }
  486|  1.13k|        struct mp_cmd *sub = parse_cmd_str(log, tmp, &str, loc);
  487|  1.13k|        if (!sub) {
  ------------------
  |  Branch (487:13): [True: 1.00k, False: 126]
  ------------------
  488|  1.00k|            talloc_free(cmd);
  ------------------
  |  |   47|  1.00k|#define talloc_free                     ta_free
  ------------------
  489|  1.00k|            cmd = NULL;
  490|  1.00k|            goto done;
  491|  1.00k|        }
  492|    126|        talloc_steal(cmd, sub);
  ------------------
  |  |   38|    126|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    126|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  493|    126|        *p_prev = sub;
  494|    126|        p_prev = &sub->queue_next;
  495|    126|    }
  496|       |
  497|   568k|    cmd->original = bstrto0(cmd, bstr_strip(
  498|   568k|                        bstr_splice(original, 0, str.start - original.start)));
  499|       |
  500|   568k|    str = bstr_strip(str);
  501|   568k|    if (bstr_eatstart0(&str, "#") && !bstr_startswith0(str, "#")) {
  ------------------
  |  Branch (501:9): [True: 17.7k, False: 550k]
  |  Branch (501:38): [True: 15.6k, False: 2.08k]
  ------------------
  502|  15.6k|        str = bstr_strip(str);
  503|  15.6k|        if (str.len)
  ------------------
  |  Branch (503:13): [True: 10.2k, False: 5.43k]
  ------------------
  504|  10.2k|            cmd->desc = bstrto0(cmd, str);
  505|  15.6k|    }
  506|       |
  507|  2.76M|done:
  508|  2.76M|    talloc_free(tmp);
  ------------------
  |  |   47|  2.76M|#define talloc_free                     ta_free
  ------------------
  509|  2.76M|    return cmd;
  510|   568k|}
mp_input_parse_cmd_strv:
  513|  35.0k|{
  514|  35.0k|    int count = 0;
  515|  81.7k|    while (argv[count])
  ------------------
  |  Branch (515:12): [True: 46.6k, False: 35.0k]
  ------------------
  516|  46.6k|        count++;
  517|  35.0k|    mpv_node *items = talloc_zero_array(NULL, mpv_node, count);
  ------------------
  |  |   30|  35.0k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  35.0k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|  35.0k|    mpv_node_list list = {.values = items, .num = count};
  519|  35.0k|    mpv_node node = {.format = MPV_FORMAT_NODE_ARRAY, .u = {.list = &list}};
  520|  81.7k|    for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (520:21): [True: 46.6k, False: 35.0k]
  ------------------
  521|  46.6k|        items[n] = (mpv_node){.format = MPV_FORMAT_STRING,
  522|  46.6k|                              .u = {.string = (char *)argv[n]}};
  523|  46.6k|    }
  524|  35.0k|    struct mp_cmd *res = mp_input_parse_cmd_node(log, &node);
  525|  35.0k|    talloc_free(items);
  ------------------
  |  |   47|  35.0k|#define talloc_free                     ta_free
  ------------------
  526|  35.0k|    return res;
  527|  35.0k|}
mp_cmd_dump:
  582|   603k|{
  583|   603k|    if (!mp_msg_test(log, msgl))
  ------------------
  |  Branch (583:9): [True: 0, False: 603k]
  ------------------
  584|      0|        return;
  585|   603k|    if (header)
  ------------------
  |  Branch (585:9): [True: 603k, False: 0]
  ------------------
  586|   603k|        mp_msg(log, msgl, "%s ", header);
  587|   603k|    if (!cmd) {
  ------------------
  |  Branch (587:9): [True: 0, False: 603k]
  ------------------
  588|      0|        mp_msg(log, msgl, "(NULL)\n");
  589|      0|        return;
  590|      0|    }
  591|   603k|    mp_msg(log, msgl, "%s, flags=%d, args=[", cmd->name, cmd->flags);
  592|   603k|    int argc = get_arg_count(cmd->def);
  593|  1.77M|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (593:21): [True: 1.16M, False: 603k]
  ------------------
  594|  1.16M|        const char *argname = cmd->def->args[MPMIN(n, argc - 1)].name;
  ------------------
  |  |   45|  1.16M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 10.3k, False: 1.15M]
  |  |  ------------------
  ------------------
  595|  1.16M|        char *s = m_option_print(cmd->args[n].type, &cmd->args[n].v);
  596|  1.16M|        if (n)
  ------------------
  |  Branch (596:13): [True: 631k, False: 537k]
  ------------------
  597|   631k|            mp_msg(log, msgl, ", ");
  598|  1.16M|        struct mpv_node node = {
  599|  1.16M|            .format = MPV_FORMAT_STRING,
  600|  1.16M|            .u.string = s ? s : "(NULL)",
  ------------------
  |  Branch (600:25): [True: 1.16M, False: 0]
  ------------------
  601|  1.16M|        };
  602|  1.16M|        char *esc = NULL;
  603|  1.16M|        json_write(&esc, &node);
  604|  1.16M|        mp_msg(log, msgl, "%s=%s", argname, esc ? esc : "<error>");
  ------------------
  |  Branch (604:45): [True: 1.16M, False: 0]
  ------------------
  605|  1.16M|        talloc_free(esc);
  ------------------
  |  |   47|  1.16M|#define talloc_free                     ta_free
  ------------------
  606|  1.16M|        talloc_free(s);
  ------------------
  |  |   47|  1.16M|#define talloc_free                     ta_free
  ------------------
  607|  1.16M|    }
  608|   603k|    mp_msg(log, msgl, "]\n");
  609|   603k|}
mp_input_is_scalable_cmd:
  621|    319|{
  622|    319|    return cmd->def->scalable && !(cmd->flags & MP_DISALLOW_SCALE);
  ------------------
  |  Branch (622:12): [True: 319, False: 0]
  |  Branch (622:34): [True: 319, False: 0]
  ------------------
  623|    319|}
cmd.c:destroy_cmd:
   33|  2.80M|{
   34|  2.80M|    struct mp_cmd *cmd = ptr;
   35|  4.01M|    for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (35:21): [True: 1.20M, False: 2.80M]
  ------------------
   36|  1.20M|        if (cmd->args[n].type)
  ------------------
  |  Branch (36:13): [True: 1.20M, False: 0]
  ------------------
   37|  1.20M|            m_option_free(cmd->args[n].type, &cmd->args[n].v);
   38|  1.20M|    }
   39|  2.80M|}
cmd.c:cmd_node_array:
  200|  35.0k|{
  201|  35.0k|    mp_assert(node->format == MPV_FORMAT_NODE_ARRAY);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (201:5): [True: 35.0k, False: 0]
  ------------------
  202|  35.0k|    mpv_node_list *args = node->u.list;
  203|  35.0k|    int cur = 0;
  204|       |
  205|  35.0k|    while (cur < args->num) {
  ------------------
  |  Branch (205:12): [True: 35.0k, False: 0]
  ------------------
  206|  35.0k|        if (args->values[cur].format != MPV_FORMAT_STRING)
  ------------------
  |  Branch (206:13): [True: 0, False: 35.0k]
  ------------------
  207|      0|            break;
  208|  35.0k|        if (!apply_flag(cmd, bstr0(args->values[cur].u.string)))
  ------------------
  |  Branch (208:13): [True: 35.0k, False: 0]
  ------------------
  209|  35.0k|            break;
  210|      0|        cur++;
  211|      0|    }
  212|       |
  213|  35.0k|    bstr cmd_name = {0};
  214|  35.0k|    if (cur < args->num && args->values[cur].format == MPV_FORMAT_STRING)
  ------------------
  |  Branch (214:9): [True: 35.0k, False: 0]
  |  Branch (214:28): [True: 35.0k, False: 0]
  ------------------
  215|  35.0k|        cmd_name = bstr0(args->values[cur++].u.string);
  216|  35.0k|    if (!find_cmd(log, cmd, cmd_name))
  ------------------
  |  Branch (216:9): [True: 0, False: 35.0k]
  ------------------
  217|      0|        return false;
  218|       |
  219|  35.0k|    int first = cur;
  220|  46.6k|    for (int i = 0; i < args->num - first; i++) {
  ------------------
  |  Branch (220:21): [True: 11.6k, False: 35.0k]
  ------------------
  221|  11.6k|        if (!set_node_arg(log, cmd, cmd->nargs, &args->values[cur++]))
  ------------------
  |  Branch (221:13): [True: 0, False: 11.6k]
  ------------------
  222|      0|            return false;
  223|  11.6k|    }
  224|       |
  225|  35.0k|    return true;
  226|  35.0k|}
cmd.c:apply_flag:
   63|  2.69M|{
   64|  35.0M|    for (int n = 0; cmd_flags[n].name; n++) {
  ------------------
  |  Branch (64:21): [True: 32.3M, False: 2.69M]
  ------------------
   65|  32.3M|        if (bstr_equals0(str, cmd_flags[n].name)) {
  ------------------
  |  Branch (65:13): [True: 1.10k, False: 32.3M]
  ------------------
   66|  1.10k|            cmd->flags = (cmd->flags & ~cmd_flags[n].remove) | cmd_flags[n].add;
   67|  1.10k|            return true;
   68|  1.10k|        }
   69|  32.3M|    }
   70|  2.69M|    return false;
   71|  2.69M|}
cmd.c:find_cmd:
   74|  2.69M|{
   75|  2.69M|    if (name.len == 0) {
  ------------------
  |  Branch (75:9): [True: 60.9k, False: 2.63M]
  ------------------
   76|  60.9k|        mp_err(log, "Command name missing.\n");
  ------------------
  |  |   76|  60.9k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
   77|  60.9k|        return false;
   78|  60.9k|    }
   79|       |
   80|  2.63M|    char nname[80];
   81|  2.63M|    snprintf(nname, sizeof(nname), "%.*s", BSTR_P(name));
  ------------------
  |  |  307|  2.63M|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 2.63M, False: 0]
  |  |  ------------------
  ------------------
   82|  19.0M|    for (int n = 0; nname[n]; n++) {
  ------------------
  |  Branch (82:21): [True: 16.4M, False: 2.63M]
  ------------------
   83|  16.4M|        if (nname[n] == '_')
  ------------------
  |  Branch (83:13): [True: 49.4k, False: 16.4M]
  ------------------
   84|  49.4k|            nname[n] = '-';
   85|  16.4M|    }
   86|       |
   87|   198M|    for (int n = 0; mp_cmds[n].name; n++) {
  ------------------
  |  Branch (87:21): [True: 196M, False: 1.94M]
  ------------------
   88|   196M|        if (strcmp(nname, mp_cmds[n].name) == 0) {
  ------------------
  |  Branch (88:13): [True: 692k, False: 195M]
  ------------------
   89|   692k|            cmd->def = &mp_cmds[n];
   90|   692k|            cmd->name = (char *)cmd->def->name;
   91|   692k|            return true;
   92|   692k|        }
   93|   196M|    }
   94|  1.94M|    mp_err(log, "Command '%.*s' not found.\n", BSTR_P(name));
  ------------------
  |  |   76|  3.89M|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 1.94M, False: 0]
  |  |  ------------------
  ------------------
   95|       |    return false;
   96|  2.63M|}
cmd.c:set_node_arg:
  161|  11.6k|{
  162|  11.6k|    const char *name = get_arg_name(cmd->def, i);
  ------------------
  |  |  123|  11.6k|    ((i) < MP_CMD_DEF_MAX_ARGS && (cmd)->args[(i)].name &&      \
  |  |  ------------------
  |  |  |  |   26|  23.3k|#define MP_CMD_DEF_MAX_ARGS 15
  |  |  ------------------
  |  |  |  Branch (123:6): [True: 11.6k, False: 0]
  |  |  |  Branch (123:35): [True: 11.6k, False: 0]
  |  |  ------------------
  |  |  124|  11.6k|     (cmd)->args[(i)].name[0]                                   \
  |  |  ------------------
  |  |  |  Branch (124:6): [True: 11.6k, False: 0]
  |  |  ------------------
  |  |  125|  11.6k|     ? (cmd)->args[(i)].name : mp_tprintf(10, "%d", (i) + 1))
  |  |  ------------------
  |  |  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  ------------------
  163|       |
  164|  11.6k|    const struct m_option *opt = get_arg_type(cmd->def, i);
  165|  11.6k|    if (!opt) {
  ------------------
  |  Branch (165:9): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    if (i < cmd->nargs && cmd->args[i].type) {
  ------------------
  |  Branch (170:9): [True: 0, False: 11.6k]
  |  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|  11.6k|    struct mp_cmd_arg arg = {.type = opt};
  176|  11.6k|    void *dst = &arg.v;
  177|  11.6k|    int r = m_option_set_node_or_string(log, opt, bstr0(cmd->name), dst, val);
  178|  11.6k|    if (r < 0) {
  ------------------
  |  Branch (178:9): [True: 0, False: 11.6k]
  ------------------
  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|  23.3k|    while (i >= cmd->nargs) {
  ------------------
  |  Branch (190:12): [True: 11.6k, False: 11.6k]
  ------------------
  191|  11.6k|        struct mp_cmd_arg t = {0};
  192|  11.6k|        MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, t);
  ------------------
  |  |  105|  11.6k|    do {                                            \
  |  |  106|  11.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  11.6k|    do {                                            \
  |  |  |  |   97|  11.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  11.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  11.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  11.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  11.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  11.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  11.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  11.6k|        (idxvar)++;                                 \
  |  |  109|  11.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
  193|  11.6k|    }
  194|       |
  195|  11.6k|    cmd->args[i] = arg;
  196|       |    return true;
  197|  11.6k|}
cmd.c:get_arg_type:
  104|  2.51M|{
  105|  2.51M|    const struct m_option *opt = NULL;
  106|  2.51M|    if (is_vararg(cmd, i)) {
  ------------------
  |  Branch (106:9): [True: 38.7k, False: 2.47M]
  ------------------
  107|       |        // The last arg in a vararg command sets all vararg types.
  108|   159k|        for (int n = MPMIN(i, MP_CMD_DEF_MAX_ARGS - 1); n >= 0; n--) {
  ------------------
  |  |   45|  38.7k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 4.35k, False: 34.4k]
  |  |  ------------------
  ------------------
  |  Branch (108:57): [True: 159k, False: 0]
  ------------------
  109|   159k|            if (cmd->args[n].type) {
  ------------------
  |  Branch (109:17): [True: 38.7k, False: 120k]
  ------------------
  110|  38.7k|                opt = &cmd->args[n];
  111|  38.7k|                break;
  112|  38.7k|            }
  113|   159k|        }
  114|  2.47M|    } else if (i < MP_CMD_DEF_MAX_ARGS) {
  ------------------
  |  |   26|  2.47M|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (114:16): [True: 2.47M, False: 0]
  ------------------
  115|  2.47M|        opt = &cmd->args[i];
  116|  2.47M|    }
  117|  2.51M|    return opt && opt->type ? opt : NULL;
  ------------------
  |  Branch (117:12): [True: 2.51M, False: 0]
  |  Branch (117:19): [True: 1.76M, False: 748k]
  ------------------
  118|  2.51M|}
cmd.c:is_vararg:
   99|  3.28M|{
  100|  3.28M|    return m->vararg && (i + 1 >= MP_CMD_DEF_MAX_ARGS || !m->args[i + 1].type);
  ------------------
  |  |   26|   121k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (100:12): [True: 60.8k, False: 3.21M]
  |  Branch (100:26): [True: 4.74k, False: 56.1k]
  |  Branch (100:58): [True: 44.1k, False: 11.9k]
  ------------------
  101|  3.28M|}
cmd.c:finish_cmd:
  129|   650k|{
  130|  1.82M|    for (int i = 0; i < MP_CMD_DEF_MAX_ARGS; i++) {
  ------------------
  |  |   26|  1.82M|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (130:21): [True: 1.82M, False: 285]
  ------------------
  131|       |        // (type==NULL is used for yet unset arguments)
  132|  1.82M|        if (i < cmd->nargs && cmd->args[i].type)
  ------------------
  |  Branch (132:13): [True: 464k, False: 1.36M]
  |  Branch (132:31): [True: 464k, False: 0]
  ------------------
  133|   464k|            continue;
  134|  1.36M|        const struct m_option *opt = get_arg_type(cmd->def, i);
  135|  1.36M|        if (i >= cmd->nargs && (!opt || is_vararg(cmd->def, i)))
  ------------------
  |  Branch (135:13): [True: 1.36M, False: 0]
  |  Branch (135:33): [True: 597k, False: 765k]
  |  Branch (135:41): [True: 10.1k, False: 755k]
  ------------------
  136|   607k|            break;
  137|   755k|        if (!opt->defval && !(opt->flags & MP_CMD_OPT_ARG)) {
  ------------------
  |  |   27|   382k|#define MP_CMD_OPT_ARG M_OPT_OPTIONAL_PARAM
  |  |  ------------------
  |  |  |  |  497|   382k|#define M_OPT_OPTIONAL_PARAM    (UINT64_C(1) << 54)
  |  |  ------------------
  ------------------
  |  Branch (137:13): [True: 382k, False: 373k]
  |  Branch (137:29): [True: 42.3k, False: 339k]
  ------------------
  138|  42.3k|            mp_err(log, "Command %s: required argument %s not set.\n",
  ------------------
  |  |   76|   254k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 42.3k, False: 0]
  |  |  |  Branch (76:55): [True: 42.3k, False: 0]
  |  |  |  Branch (76:55): [True: 42.3k, False: 0]
  |  |  ------------------
  ------------------
  139|  42.3k|                   cmd->name, get_arg_name(cmd->def, i));
  140|  42.3k|            return false;
  141|  42.3k|        }
  142|   712k|        struct mp_cmd_arg arg = {.type = opt};
  143|   712k|        if (opt->defval)
  ------------------
  |  Branch (143:13): [True: 373k, False: 339k]
  ------------------
  144|   373k|            m_option_copy(opt, &arg.v, opt->defval);
  145|   712k|        mp_assert(i <= cmd->nargs);
  ------------------
  |  |   41|   712k|#define mp_assert assert
  ------------------
  |  Branch (145:9): [True: 712k, False: 0]
  ------------------
  146|   712k|        if (i == cmd->nargs) {
  ------------------
  |  Branch (146:13): [True: 712k, False: 0]
  ------------------
  147|   712k|            MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, arg);
  ------------------
  |  |  105|   712k|    do {                                            \
  |  |  106|   712k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   712k|    do {                                            \
  |  |  |  |   97|   712k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   712k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   712k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   712k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 275k, False: 437k]
  |  |  |  |  ------------------
  |  |  |  |   99|   712k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   275k|    do {                                                        \
  |  |  |  |  |  |   89|   275k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   275k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   275k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   275k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   275k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   275k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   275k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 275k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   712k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 712k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   712k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   712k|        (idxvar)++;                                 \
  |  |  109|   712k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 712k]
  |  |  ------------------
  ------------------
  148|   712k|        } else {
  149|      0|            cmd->args[i] = arg;
  150|      0|        }
  151|   712k|    }
  152|       |
  153|   608k|    if (!(cmd->flags & (MP_ASYNC_CMD | MP_SYNC_CMD)))
  ------------------
  |  Branch (153:9): [True: 607k, False: 478]
  ------------------
  154|   607k|        cmd->flags |= cmd->def->default_async ? MP_ASYNC_CMD : MP_SYNC_CMD;
  ------------------
  |  Branch (154:23): [True: 0, False: 607k]
  ------------------
  155|       |
  156|       |    return true;
  157|   650k|}
cmd.c:parse_cmd_str:
  374|  2.76M|{
  375|  2.76M|    struct parse_ctx *ctx = &(struct parse_ctx){
  376|  2.76M|        .log = log,
  377|  2.76M|        .tmp = tmp,
  378|  2.76M|        .str = *str,
  379|  2.76M|        .start = *str,
  380|  2.76M|    };
  381|       |
  382|  2.76M|    struct mp_cmd *cmd = talloc_ptrtype(NULL, cmd);
  ------------------
  |  |   34|  2.76M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  2.76M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.76M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|  2.76M|    talloc_set_destructor(cmd, destroy_cmd);
  ------------------
  |  |   41|  2.76M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  384|  2.76M|    *cmd = (struct mp_cmd) {
  385|  2.76M|        .flags = MP_ON_OSD_AUTO | MP_EXPAND_PROPERTIES,
  386|  2.76M|        .scale = 1,
  387|  2.76M|        .scale_units = 1,
  388|  2.76M|    };
  389|       |
  390|  2.76M|    ctx->str = bstr_lstrip(ctx->str);
  391|       |
  392|  2.76M|    bstr cur_token;
  393|  2.76M|    if (pctx_read_token(ctx, &cur_token) < 0)
  ------------------
  |  Branch (393:9): [True: 105k, False: 2.66M]
  ------------------
  394|   105k|        goto error;
  395|       |
  396|  2.66M|    while (1) {
  ------------------
  |  Branch (396:12): [True: 2.66M, Folded]
  ------------------
  397|  2.66M|        if (!apply_flag(cmd, cur_token))
  ------------------
  |  Branch (397:13): [True: 2.66M, False: 1.10k]
  ------------------
  398|  2.66M|            break;
  399|  1.10k|        if (pctx_read_token(ctx, &cur_token) < 0)
  ------------------
  |  Branch (399:13): [True: 218, False: 891]
  ------------------
  400|    218|            goto error;
  401|  1.10k|    }
  402|       |
  403|  2.66M|    if (!find_cmd(ctx->log, cmd, cur_token))
  ------------------
  |  Branch (403:9): [True: 2.00M, False: 657k]
  ------------------
  404|  2.00M|        goto error;
  405|       |
  406|  1.13M|    for (int i = 0; i < MP_CMD_MAX_ARGS; i++) {
  ------------------
  |  |   86|  1.13M|#define MP_CMD_MAX_ARGS 100
  ------------------
  |  Branch (406:21): [True: 1.13M, False: 14]
  ------------------
  407|  1.13M|        const struct m_option *opt = get_arg_type(cmd->def, i);
  408|  1.13M|        if (!opt)
  ------------------
  |  Branch (408:13): [True: 150k, False: 989k]
  ------------------
  409|   150k|            break;
  410|       |
  411|   989k|        int r = pctx_read_token(ctx, &cur_token);
  412|   989k|        if (r < 0) {
  ------------------
  |  Branch (412:13): [True: 743, False: 988k]
  ------------------
  413|    743|            MP_ERR(ctx, "Command %s: error in argument %d.\n", cmd->name, i + 1);
  ------------------
  |  |   89|    743|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    743|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  414|    743|            goto error;
  415|    743|        }
  416|   988k|        if (r < 1)
  ------------------
  |  Branch (416:13): [True: 464k, False: 523k]
  ------------------
  417|   464k|            break;
  418|       |
  419|   523k|        struct mp_cmd_arg arg = {.type = opt};
  420|   523k|        r = m_option_parse(ctx->log, opt, bstr0(cmd->name), cur_token, &arg.v);
  421|   523k|        if (r < 0) {
  ------------------
  |  Branch (421:13): [True: 40.8k, False: 482k]
  ------------------
  422|  40.8k|            MP_ERR(ctx, "Command %s: argument %d can't be parsed: %s.\n",
  ------------------
  |  |   89|  40.8k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  40.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  423|  40.8k|                   cmd->name, i + 1, m_option_strerror(r));
  424|  40.8k|            goto error;
  425|  40.8k|        }
  426|       |
  427|   482k|        MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, arg);
  ------------------
  |  |  105|   482k|    do {                                            \
  |  |  106|   482k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   482k|    do {                                            \
  |  |  |  |   97|   482k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   482k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   482k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   482k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 414k, False: 68.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|   482k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   414k|    do {                                                        \
  |  |  |  |  |  |   89|   414k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   414k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   414k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   414k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   414k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   414k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   414k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 414k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   482k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 482k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   482k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   482k|        (idxvar)++;                                 \
  |  |  109|   482k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 482k]
  |  |  ------------------
  ------------------
  428|   482k|    }
  429|       |
  430|   615k|    if (!finish_cmd(ctx->log, cmd))
  ------------------
  |  Branch (430:9): [True: 42.3k, False: 573k]
  ------------------
  431|  42.3k|        goto error;
  432|       |
  433|   573k|    bstr dummy;
  434|   573k|    if (read_token(ctx->str, &dummy, &dummy) && ctx->str.len) {
  ------------------
  |  Branch (434:9): [True: 3.30k, False: 569k]
  |  Branch (434:49): [True: 3.30k, False: 0]
  ------------------
  435|  3.30k|        MP_ERR(ctx, "Command %s has trailing unused arguments: '%.*s'.\n",
  ------------------
  |  |   89|  3.30k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.61k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 3.30k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|  3.30k|               cmd->name, BSTR_P(ctx->str));
  437|       |        // Better make it fatal to make it clear something is wrong.
  438|  3.30k|        goto error;
  439|  3.30k|    }
  440|       |
  441|   569k|    bstr orig = {ctx->start.start, ctx->str.start - ctx->start.start};
  442|   569k|    cmd->original = bstrto0(cmd, bstr_strip(orig));
  443|       |
  444|   569k|    *str = ctx->str;
  445|   569k|    return cmd;
  446|       |
  447|  2.19M|error:
  448|  2.19M|    MP_ERR(ctx, "Command was defined at %s.\n", loc);
  ------------------
  |  |   89|  2.19M|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.19M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  449|  2.19M|    talloc_free(cmd);
  ------------------
  |  |   47|  2.19M|#define talloc_free                     ta_free
  ------------------
  450|  2.19M|    *str = ctx->str;
  451|       |    return NULL;
  452|   573k|}
cmd.c:pctx_read_token:
  331|  3.75M|{
  332|  3.75M|    *out = (bstr){0};
  333|  3.75M|    ctx->str = bstr_lstrip(ctx->str);
  334|  3.75M|    bstr start = ctx->str;
  335|  3.75M|    if (bstr_eatstart0(&ctx->str, "\"")) {
  ------------------
  |  Branch (335:9): [True: 114k, False: 3.64M]
  ------------------
  336|   114k|        if (!mp_append_escaped_string_noalloc(ctx->tmp, out, &ctx->str)) {
  ------------------
  |  Branch (336:13): [True: 42.6k, False: 72.2k]
  ------------------
  337|  42.6k|            MP_ERR(ctx, "Broken string escapes: ...>%.*s<.\n", BSTR_P(start));
  ------------------
  |  |   89|  42.6k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  85.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 42.6k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  338|  42.6k|            return -1;
  339|  42.6k|        }
  340|  72.2k|        if (!bstr_eatstart0(&ctx->str, "\"")) {
  ------------------
  |  Branch (340:13): [True: 51.8k, False: 20.3k]
  ------------------
  341|  51.8k|            MP_ERR(ctx, "Unterminated double quote: ...>%.*s<.\n", BSTR_P(start));
  ------------------
  |  |   89|  51.8k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   103k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 51.8k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  342|  51.8k|            return -1;
  343|  51.8k|        }
  344|  20.3k|        return 1;
  345|  72.2k|    }
  346|  3.64M|    if (bstr_eatstart0(&ctx->str, "'")) {
  ------------------
  |  Branch (346:9): [True: 12.7k, False: 3.63M]
  ------------------
  347|  12.7k|        int next = bstrchr(ctx->str, '\'');
  348|  12.7k|        if (next < 0) {
  ------------------
  |  Branch (348:13): [True: 10.5k, False: 2.24k]
  ------------------
  349|  10.5k|            MP_ERR(ctx, "Unterminated single quote: ...>%.*s<.\n", BSTR_P(start));
  ------------------
  |  |   89|  10.5k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  21.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 10.5k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|  10.5k|            return -1;
  351|  10.5k|        }
  352|  2.24k|        *out = bstr_splice(ctx->str, 0, next);
  353|  2.24k|        ctx->str = bstr_cut(ctx->str, next+1);
  354|  2.24k|        return 1;
  355|  12.7k|    }
  356|  3.63M|    if (ctx->start.len > 1 && bstr_eatstart0(&ctx->str, "`")) {
  ------------------
  |  Branch (356:9): [True: 3.56M, False: 71.5k]
  |  Branch (356:31): [True: 3.97k, False: 3.55M]
  ------------------
  357|  3.97k|        char endquote[2] = {ctx->str.start[0], '`'};
  358|  3.97k|        ctx->str = bstr_cut(ctx->str, 1);
  359|  3.97k|        int next = bstr_find(ctx->str, (bstr){endquote, 2});
  360|  3.97k|        if (next < 0) {
  ------------------
  |  Branch (360:13): [True: 1.54k, False: 2.43k]
  ------------------
  361|  1.54k|            MP_ERR(ctx, "Unterminated custom quote: ...>%.*s<.\n", BSTR_P(start));
  ------------------
  |  |   89|  1.54k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.08k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 1.54k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|  1.54k|            return -1;
  363|  1.54k|        }
  364|  2.43k|        *out = bstr_splice(ctx->str, 0, next);
  365|  2.43k|        ctx->str = bstr_cut(ctx->str, next+2);
  366|  2.43k|        return 1;
  367|  3.97k|    }
  368|       |
  369|  3.62M|    return read_token(ctx->str, &ctx->str, out) ? 1 : 0;
  ------------------
  |  Branch (369:12): [True: 3.10M, False: 522k]
  ------------------
  370|  3.63M|}
cmd.c:read_token:
  314|  4.20M|{
  315|  4.20M|    bstr t = bstr_lstrip(str);
  316|  4.20M|    int next = bstrcspn(t, WHITESPACE "#;");
  ------------------
  |  |  309|  4.20M|#define WHITESPACE " \f\n\r\t\v"
  ------------------
  317|  4.20M|    if (!next)
  ------------------
  |  Branch (317:9): [True: 1.09M, False: 3.11M]
  ------------------
  318|  1.09M|        return false;
  319|  3.11M|    *out_token = bstr_splice(t, 0, next);
  320|  3.11M|    *out_rest = bstr_cut(t, next);
  321|       |    return true;
  322|  4.20M|}
cmd.c:get_arg_count:
  573|   603k|{
  574|  8.49M|    for (int i = MP_CMD_DEF_MAX_ARGS - 1; i >= 0; i--) {
  ------------------
  |  |   26|   603k|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (574:43): [True: 8.42M, False: 66.3k]
  ------------------
  575|  8.42M|        if (cmd->args[i].type)
  ------------------
  |  Branch (575:13): [True: 537k, False: 7.89M]
  ------------------
  576|   537k|            return i + 1;
  577|  8.42M|    }
  578|  66.3k|    return 0;
  579|   603k|}

mp_dnd_init:
  148|  11.6k|{
  149|  11.6k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  150|       |    // Nothing drops files here, the thread only makes coverage timing dependent.
  151|  11.6k|    mpv_destroy(mpv);
  152|  11.6k|    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_put_key_artificial:
  853|  20.2k|{
  854|  20.2k|    if (value == 0.0)
  ------------------
  |  Branch (854:9): [True: 41, False: 20.1k]
  ------------------
  855|     41|        return;
  856|  20.2k|    input_lock(ictx);
  ------------------
  |  |   58|  20.1k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  20.1k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  857|  20.1k|    feed_key(ictx, code, value, true);
  858|  20.1k|    input_unlock(ictx);
  ------------------
  |  |   59|  20.1k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  20.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  859|  20.1k|}
mp_input_set_mouse_transform:
  886|  31.9k|{
  887|  31.9k|    input_lock(ictx);
  ------------------
  |  |   58|  31.9k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  31.9k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
  888|  31.9k|    ictx->mouse_mangle = dst || src;
  ------------------
  |  Branch (888:26): [True: 0, False: 31.9k]
  |  Branch (888:33): [True: 0, False: 31.9k]
  ------------------
  889|  31.9k|    if (ictx->mouse_mangle) {
  ------------------
  |  Branch (889:9): [True: 0, False: 31.9k]
  ------------------
  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|  31.9k|    input_unlock(ictx);
  ------------------
  |  |   59|  31.9k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  31.9k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
  896|  31.9k|}
mp_input_get_dropped_files:
 1307|      3|{
 1308|      3|    input_lock(ictx);
  ------------------
  |  |   58|      3|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|      3|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1309|      3|    *dnd_ts = ictx->dnd_ts;
 1310|      3|    *dnd_action = ictx->dnd_action;
 1311|      3|    *dropped_files = NULL;
 1312|      3|    int num = 0;
 1313|      3|    for (int i = 0; i < ictx->num_dropped_files; i++)
  ------------------
  |  Branch (1313:21): [True: 0, False: 3]
  ------------------
 1314|      0|        MP_TARRAY_APPEND(talloc_ctx, *dropped_files, 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]
  |  |  ------------------
  ------------------
 1315|      3|                         bstrto0(talloc_ctx, ictx->dropped_files[i]));
 1316|      3|    MP_TARRAY_APPEND(talloc_ctx, *dropped_files, num, NULL);
  ------------------
  |  |  105|      3|    do {                                            \
  |  |  106|      3|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      3|    do {                                            \
  |  |  |  |   97|      3|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      3|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      3|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      3|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      3|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      3|    do {                                                        \
  |  |  |  |  |  |   89|      3|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      3|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      3|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      3|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      3|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      3|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      3|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      3|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      3|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      3|        (idxvar)++;                                 \
  |  |  109|      3|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1317|      3|    input_unlock(ictx);
  ------------------
  |  |   59|      3|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|      3|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1318|      3|}
mp_input_get_mouse_event_counter:
 1321|  10.5M|{
 1322|       |    // Make the frontend always display the mouse cursor (as long as it's not
 1323|       |    // forced invisible) if mouse input is desired.
 1324|  10.5M|    input_lock(ictx);
  ------------------
  |  |   58|  10.5M|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  10.5M|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1325|  10.5M|    if (test_mouse_active(ictx, ictx->mouse_x, ictx->mouse_y))
  ------------------
  |  Branch (1325:9): [True: 2.80M, False: 7.69M]
  ------------------
 1326|  2.80M|        ictx->mouse_event_counter++;
 1327|  10.5M|    int ret = ictx->mouse_event_counter;
 1328|  10.5M|    input_unlock(ictx);
  ------------------
  |  |   59|  10.5M|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  10.5M|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1329|  10.5M|    return ret;
 1330|  10.5M|}
mp_input_get_delay:
 1387|  11.6M|{
 1388|  11.6M|    input_lock(ictx);
  ------------------
  |  |   58|  11.6M|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6M|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1389|  11.6M|    double seconds = INFINITY;
 1390|  11.6M|    adjust_max_wait_time(ictx, &seconds);
 1391|  11.6M|    input_unlock(ictx);
  ------------------
  |  |   59|  11.6M|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6M|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1392|  11.6M|    return seconds;
 1393|  11.6M|}
mp_input_wakeup:
 1396|    664|{
 1397|    664|    ictx->wakeup_cb(ictx->wakeup_ctx);
 1398|    664|}
mp_input_read_cmd:
 1401|  11.6M|{
 1402|  11.6M|    input_lock(ictx);
  ------------------
  |  |   58|  11.6M|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6M|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1403|  11.6M|    struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue);
 1404|  11.6M|    if (!ret)
  ------------------
  |  Branch (1404:9): [True: 11.6M, False: 3]
  ------------------
 1405|  11.6M|        ret = check_autorepeat(ictx);
 1406|  11.6M|    if (ret && ret->mouse_move) {
  ------------------
  |  Branch (1406:9): [True: 3, False: 11.6M]
  |  Branch (1406:16): [True: 0, False: 3]
  ------------------
 1407|      0|        ictx->mouse_x = ret->mouse_x;
 1408|      0|        ictx->mouse_y = ret->mouse_y;
 1409|      0|    }
 1410|  11.6M|    input_unlock(ictx);
  ------------------
  |  |   59|  11.6M|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6M|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1411|  11.6M|    return ret;
 1412|  11.6M|}
mp_input_disable_section:
 1446|     56|{
 1447|     56|    input_lock(ictx);
  ------------------
  |  |   58|     56|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|     56|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1448|     56|    disable_section(ictx, bstr0(name));
 1449|     56|    input_unlock(ictx);
  ------------------
  |  |   59|     56|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|     56|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1450|     56|}
mp_input_enable_section:
 1453|  14.4k|{
 1454|  14.4k|    bstr bname = bstr0(name);
 1455|  14.4k|    input_lock(ictx);
  ------------------
  |  |   58|  14.4k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  14.4k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1456|  14.4k|    bname = normalize_section(ictx, bname);
 1457|       |
 1458|  14.4k|    disable_section(ictx, bname);
 1459|       |
 1460|  14.4k|    MP_TRACE(ictx, "enable section '%.*s'\n", BSTR_P(bname));
  ------------------
  |  |   94|  14.4k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  28.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 14.4k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1461|       |
 1462|  14.4k|    int top = ictx->num_active_sections;
 1463|  14.4k|    if (!(flags & MP_INPUT_ON_TOP)) {
  ------------------
  |  Branch (1463:9): [True: 14.4k, False: 0]
  ------------------
 1464|       |        // insert before the first top entry
 1465|  20.9k|        for (top = 0; top < ictx->num_active_sections; top++) {
  ------------------
  |  Branch (1465:23): [True: 6.43k, False: 14.4k]
  ------------------
 1466|  6.43k|            if (ictx->active_sections[top].flags & MP_INPUT_ON_TOP)
  ------------------
  |  Branch (1466:17): [True: 0, False: 6.43k]
  ------------------
 1467|      0|                break;
 1468|  6.43k|        }
 1469|  14.4k|    }
 1470|  14.4k|    MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,
  ------------------
  |  |  115|  14.4k|    do {                                            \
  |  |  116|  14.4k|        size_t at_ = (at);                          \
  |  |  117|  14.4k|        assert(at_ <= (idxvar));                    \
  |  |  118|  14.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  14.4k|    do {                                            \
  |  |  |  |   97|  14.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  14.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  14.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  14.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.8k, False: 2.65k]
  |  |  |  |  ------------------
  |  |  |  |   99|  14.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.8k|    do {                                                        \
  |  |  |  |  |  |   89|  11.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  14.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 14.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  14.4k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  14.4k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  14.4k|        (idxvar)++;                                 \
  |  |  122|  14.4k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  14.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 14.4k]
  |  |  ------------------
  ------------------
  |  Branch (1470:5): [True: 14.4k, False: 0]
  ------------------
 1471|  14.4k|                        top, (struct active_section){bname, flags});
 1472|       |
 1473|  14.4k|    MP_TRACE(ictx, "active section stack:\n");
  ------------------
  |  |   94|  14.4k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1474|  35.3k|    for (int n = 0; n < ictx->num_active_sections; n++) {
  ------------------
  |  Branch (1474:21): [True: 20.9k, False: 14.4k]
  ------------------
 1475|  20.9k|        MP_TRACE(ictx, " %.*s %d\n", BSTR_P(ictx->active_sections[n].name),
  ------------------
  |  |   94|  20.9k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  41.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 20.9k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|  20.9k|                 ictx->active_sections[n].flags);
 1477|  20.9k|    }
 1478|       |
 1479|  14.4k|    input_unlock(ictx);
  ------------------
  |  |   59|  14.4k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  14.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1480|  14.4k|}
mp_input_define_section:
 1521|    107|{
 1522|    107|    bstr bname = bstr0(name);
 1523|    107|    if (!bname.len)
  ------------------
  |  Branch (1523:9): [True: 11, False: 96]
  ------------------
 1524|     11|        return; // parse_config() changes semantics with restrict_section==empty
 1525|    107|    input_lock(ictx);
  ------------------
  |  |   58|     96|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|     96|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1526|       |    // Delete:
 1527|     96|    struct cmd_bind_section *bs = get_bind_section(ictx, bname);
 1528|     96|    if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
  ------------------
  |  Branch (1528:10): [True: 20, False: 76]
  |  Branch (1528:25): [True: 76, False: 0]
  |  Branch (1528:34): [True: 0, False: 76]
  ------------------
 1529|     20|        !bstr_equals0(bs->section, "default"))
  ------------------
  |  Branch (1529:9): [True: 20, False: 0]
  ------------------
 1530|     20|    {
 1531|     20|        talloc_replace(bs, bs->owner, owner);
  ------------------
  |  |   54|     20|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|     20|    do {                                                \
  |  |  |  |  107|     20|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|     20|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|     20|        } 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|     20|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1532|     20|    }
 1533|     96|    remove_binds(bs, builtin);
 1534|     96|    if (contents && contents[0]) {
  ------------------
  |  Branch (1534:9): [True: 96, False: 0]
  |  Branch (1534:21): [True: 96, False: 0]
  ------------------
 1535|       |        // Redefine:
 1536|     96|        parse_config(ictx, builtin, bstr0(contents), location, bname);
 1537|     96|    } else {
 1538|       |        // Disable:
 1539|      0|        disable_section(ictx, bname);
 1540|      0|    }
 1541|     96|    input_unlock(ictx);
  ------------------
  |  |   59|     96|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|     96|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1542|     96|}
mp_input_remove_sections_by_owner:
 1545|  35.0k|{
 1546|  35.0k|    input_lock(ictx);
  ------------------
  |  |   58|  35.0k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1547|  71.1k|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (1547:21): [True: 36.1k, False: 35.0k]
  ------------------
 1548|  36.1k|        struct cmd_bind_section *bs = ictx->sections[n];
 1549|  36.1k|        if (bs->owner && owner && strcmp(bs->owner, owner) == 0) {
  ------------------
  |  Branch (1549:13): [True: 40, False: 36.0k]
  |  Branch (1549:26): [True: 40, False: 0]
  |  Branch (1549:35): [True: 20, False: 20]
  ------------------
 1550|     20|            disable_section(ictx, bs->section);
 1551|     20|            remove_binds(bs, false);
 1552|     20|            remove_binds(bs, true);
 1553|     20|        }
 1554|  36.1k|    }
 1555|  35.0k|    input_unlock(ictx);
  ------------------
  |  |   59|  35.0k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1556|  35.0k|}
mp_input_init:
 1717|  11.6k|{
 1718|       |
 1719|  11.6k|    struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
  ------------------
  |  |   34|  11.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  11.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1720|  11.6k|    *ictx = (struct input_ctx){
 1721|  11.6k|        .global = global,
 1722|  11.6k|        .ar_state = -1,
 1723|  11.6k|        .log = mp_log_new(ictx, global->log, "input"),
 1724|  11.6k|        .mouse_section = bstr0("default"),
 1725|  11.6k|        .opts_cache = m_config_cache_alloc(ictx, global, &input_config),
 1726|  11.6k|        .wakeup_cb = wakeup_cb,
 1727|  11.6k|        .wakeup_ctx = wakeup_ctx,
 1728|  11.6k|        .active_sections = talloc_array(ictx, struct active_section, 0),
  ------------------
  |  |   29|  11.6k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  11.6k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1729|  11.6k|        .touch_points = talloc_array(ictx, struct touch_point, 0),
  ------------------
  |  |   29|  11.6k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  11.6k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|  11.6k|        .dnd_action = DND_NONE,
 1731|  11.6k|    };
 1732|       |
 1733|  11.6k|    ictx->opts = ictx->opts_cache->opts;
 1734|       |
 1735|  11.6k|    mp_mutex_init(&ictx->mutex);
 1736|       |
 1737|       |    // Setup default section, so that it does nothing.
 1738|  11.6k|    mp_input_enable_section(ictx, NULL, MP_INPUT_ALLOW_VO_DRAGGING |
 1739|  11.6k|                                        MP_INPUT_ALLOW_HIDE_CURSOR);
 1740|       |
 1741|  11.6k|    return ictx;
 1742|  11.6k|}
mp_input_update_opts:
 1763|  11.6k|{
 1764|  11.6k|    input_lock(ictx);
  ------------------
  |  |   58|  11.6k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1765|  11.6k|    reload_opts(ictx, false);
 1766|  11.6k|    input_unlock(ictx);
  ------------------
  |  |   59|  11.6k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1767|  11.6k|}
mp_input_load_config:
 1770|  11.6k|{
 1771|  11.6k|    input_lock(ictx);
  ------------------
  |  |   58|  11.6k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1772|       |
 1773|  11.6k|    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|  11.6k|    bstr builtin = bstr0(builtin_input_conf);
 1778|  11.6k|    while (ictx->opts->builtin_bindings && builtin.len) {
  ------------------
  |  Branch (1778:12): [True: 0, False: 11.6k]
  |  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|  11.6k|    bool config_ok = false;
 1786|  11.6k|    if (ictx->opts->config_file && ictx->opts->config_file[0])
  ------------------
  |  Branch (1786:9): [True: 0, False: 11.6k]
  |  Branch (1786:36): [True: 0, False: 0]
  ------------------
 1787|      0|        config_ok = parse_config_file(ictx, ictx->opts->config_file);
 1788|  11.6k|    if (!config_ok) {
  ------------------
  |  Branch (1788:9): [True: 11.6k, False: 0]
  ------------------
 1789|       |        // Try global conf dir
 1790|  11.6k|        void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  11.6k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  11.6k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1791|  11.6k|        char **files = mp_find_all_config_files(tmp, ictx->global, "input.conf");
 1792|  11.6k|        for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1792:25): [True: 11.6k, False: 0]
  |  Branch (1792:34): [True: 0, False: 11.6k]
  ------------------
 1793|      0|            parse_config_file(ictx, files[n]);
 1794|  11.6k|        talloc_free(tmp);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1795|  11.6k|    }
 1796|       |
 1797|  11.6k|    bool use_gamepad = ictx->opts->use_gamepad;
 1798|  11.6k|    input_unlock(ictx);
  ------------------
  |  |   59|  11.6k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6k|#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|  11.6k|    (void)use_gamepad;
 1805|  11.6k|#endif
 1806|  11.6k|}
mp_input_load_config_file:
 1809|     23|{
 1810|     23|    input_lock(ictx);
  ------------------
  |  |   58|     23|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|     23|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1811|     23|    bool result = parse_config_file(ictx, file);
 1812|     23|    input_unlock(ictx);
  ------------------
  |  |   59|     23|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|     23|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1813|     23|    return result;
 1814|     23|}
mp_input_uninit:
 1826|  11.6k|{
 1827|  11.6k|    if (!ictx)
  ------------------
  |  Branch (1827:9): [True: 0, False: 11.6k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  11.6k|    input_lock(ictx);
  ------------------
  |  |   58|  11.6k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1831|  11.6k|    reload_opts(ictx, true);
 1832|  11.6k|    input_unlock(ictx);
  ------------------
  |  |   59|  11.6k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1833|       |
 1834|  11.6k|    close_input_sources(ictx);
 1835|  11.6k|    clear_queue(&ictx->cmd_queue);
 1836|  11.6k|    talloc_free(ictx->current_down_cmd);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1837|  11.6k|    mp_mutex_destroy(&ictx->mutex);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1838|  11.6k|    talloc_free(ictx);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 1839|  11.6k|}
mp_input_parse_cmd:
 1859|  2.76M|{
 1860|  2.76M|    return mp_input_parse_cmd_str(ictx->log, str, location);
 1861|  2.76M|}
mp_input_bind_key:
 1872|  1.59k|{
 1873|  1.59k|    char *name = talloc_strdup(NULL, key);
  ------------------
  |  |   50|  1.59k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1874|  1.59k|    int keys[MP_MAX_KEY_DOWN];
 1875|  1.59k|    int num_keys = 0;
 1876|  1.59k|    if (!mp_input_get_keys_from_string(name, MP_MAX_KEY_DOWN, &num_keys, keys)) {
  ------------------
  |  |   61|  1.59k|#define MP_MAX_KEY_DOWN 16
  ------------------
  |  Branch (1876:9): [True: 347, False: 1.25k]
  ------------------
 1877|    347|        talloc_free(name);
  ------------------
  |  |   47|    347|#define talloc_free                     ta_free
  ------------------
 1878|    347|        return false;
 1879|    347|    }
 1880|  1.25k|    talloc_free(name);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 1881|       |
 1882|  1.25k|    input_lock(ictx);
  ------------------
  |  |   58|  1.25k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  1.25k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1883|  1.25k|    bind_keys(ictx, false, (bstr){0}, keys, num_keys, command,
 1884|  1.25k|              "keybind-command", desc);
 1885|  1.25k|    input_unlock(ictx);
  ------------------
  |  |   59|  1.25k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  1.25k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1886|       |    return true;
 1887|  1.59k|}
mp_input_get_bindings:
 1890|      1|{
 1891|      1|    input_lock(ictx);
  ------------------
  |  |   58|      1|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|      1|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1892|      1|    struct mpv_node root;
 1893|      1|    node_init(&root, MPV_FORMAT_NODE_ARRAY, NULL);
 1894|       |
 1895|      2|    for (int x = 0; x < ictx->num_sections; x++) {
  ------------------
  |  Branch (1895:21): [True: 1, False: 1]
  ------------------
 1896|      1|        struct cmd_bind_section *s = ictx->sections[x];
 1897|      1|        int priority = -1;
 1898|       |
 1899|      1|        for (int i = 0; i < ictx->num_active_sections; i++) {
  ------------------
  |  Branch (1899:25): [True: 1, False: 0]
  ------------------
 1900|      1|            struct active_section *as = &ictx->active_sections[i];
 1901|      1|            if (bstr_equals(as->name, s->section)) {
  ------------------
  |  Branch (1901:17): [True: 1, False: 0]
  ------------------
 1902|      1|                priority = i;
 1903|      1|                break;
 1904|      1|            }
 1905|      1|        }
 1906|       |
 1907|      1|        for (int n = 0; n < s->num_binds; n++) {
  ------------------
  |  Branch (1907:25): [True: 0, False: 1]
  ------------------
 1908|      0|            struct cmd_bind *b = &s->binds[n];
 1909|      0|            struct mpv_node *entry = node_array_add(&root, MPV_FORMAT_NODE_MAP);
 1910|       |
 1911|      0|            int b_priority = priority;
 1912|      0|            if (b->is_builtin && !ictx->opts->default_bindings)
  ------------------
  |  Branch (1912:17): [True: 0, False: 0]
  |  Branch (1912:34): [True: 0, False: 0]
  ------------------
 1913|      0|                b_priority = -1;
 1914|       |
 1915|       |            // Try to fixup the weird logic so consumer of this bindings list
 1916|       |            // does not get too confused.
 1917|      0|            if (b_priority >= 0 && !b->is_builtin)
  ------------------
  |  Branch (1917:17): [True: 0, False: 0]
  |  Branch (1917:36): [True: 0, False: 0]
  ------------------
 1918|      0|                b_priority += ictx->num_active_sections;
 1919|       |
 1920|      0|            node_map_add_bstr(entry, "section", s->section);
 1921|      0|            if (s->owner)
  ------------------
  |  Branch (1921:17): [True: 0, False: 0]
  ------------------
 1922|      0|                node_map_add_string(entry, "owner", s->owner);
 1923|      0|            node_map_add_string(entry, "cmd", b->cmd);
 1924|      0|            node_map_add_flag(entry, "is_weak", b->is_builtin);
 1925|      0|            node_map_add_int64(entry, "priority", b_priority);
 1926|      0|            if (b->desc)
  ------------------
  |  Branch (1926:17): [True: 0, False: 0]
  ------------------
 1927|      0|                node_map_add_string(entry, "comment", b->desc);
 1928|       |
 1929|      0|            char *key = mp_input_get_key_combo_name(b->keys, b->num_keys);
 1930|      0|            node_map_add_string(entry, "key", key);
 1931|      0|            talloc_free(key);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1932|      0|        }
 1933|      1|    }
 1934|       |
 1935|      1|    input_unlock(ictx);
  ------------------
  |  |   59|      1|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|      1|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1936|      1|    return root;
 1937|      1|}
input.c:feed_key:
  775|  20.1k|{
  776|  20.1k|    struct input_opts *opts = ictx->opts;
  777|       |
  778|  20.1k|    code = mp_normalize_keycode(code);
  779|  20.1k|    int unmod = code & ~MP_KEY_MODIFIER_MASK;
  ------------------
  |  |  264|  20.1k|#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  245|  20.1k|#define MP_KEY_MODIFIER_SHIFT  (1u<<24)
  |  |  ------------------
  |  |               #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  246|  20.1k|#define MP_KEY_MODIFIER_CTRL   (1u<<25)
  |  |  ------------------
  |  |  265|  20.1k|                              MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  247|  20.1k|#define MP_KEY_MODIFIER_ALT    (1u<<26)
  |  |  ------------------
  |  |                                             MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  248|  20.1k|#define MP_KEY_MODIFIER_META   (1u<<27)
  |  |  ------------------
  |  |  266|  20.1k|                              MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  253|  20.1k|#define MP_KEY_STATE_DOWN      (1u<<28)
  |  |  ------------------
  |  |                                             MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  259|  20.1k|#define MP_KEY_STATE_UP        (1u<<29)
  |  |  ------------------
  ------------------
  780|  20.1k|    if (code == MP_INPUT_RELEASE_ALL) {
  ------------------
  |  |  230|  20.1k|#define MP_INPUT_RELEASE_ALL    (MP_KEY_INTERN+6)
  |  |  ------------------
  |  |  |  |  205|  20.1k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  20.1k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (780:9): [True: 580, False: 19.5k]
  ------------------
  781|    580|        MP_TRACE(ictx, "release all\n");
  ------------------
  |  |   94|    580|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    580|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  782|    580|        release_down_cmd(ictx, false);
  783|    580|        ictx->dragging_button_down = false;
  784|    580|        return;
  785|    580|    }
  786|  19.5k|    if (code == MP_TOUCH_RELEASE_ALL) {
  ------------------
  |  |  232|  19.5k|#define MP_TOUCH_RELEASE_ALL    (MP_KEY_INTERN+7)
  |  |  ------------------
  |  |  |  |  205|  19.5k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  19.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (786:9): [True: 0, False: 19.5k]
  ------------------
  787|      0|        MP_TRACE(ictx, "release all touch\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__)
  |  |  ------------------
  ------------------
  788|      0|        ictx->num_touch_points = 0;
  789|      0|        return;
  790|      0|    }
  791|  19.5k|    if (!opts->enable_mouse_movements && MP_KEY_IS_MOUSE(unmod) && !force_mouse)
  ------------------
  |  |  224|  19.5k|    (MP_KEY_IS_MOUSE_CLICK(code) || MP_KEY_IS_MOUSE_MOVE(code))
  |  |  ------------------
  |  |  |  |  213|      0|    (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|    ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  146|      0|#define MP_MBTN_END      (MP_MBTN_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (149:6): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (149:32): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  160|      0|    ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  157|      0|#define MP_MBTN_DBL_END    (MP_MBTN_DBL_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:6): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (160:36): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (MP_KEY_IS_MOUSE_CLICK(code) || MP_KEY_IS_MOUSE_MOVE(code))
  |  |  ------------------
  |  |  |  |  216|      0|    ((code) == MP_KEY_MOUSE_MOVE || (code) == MP_KEY_MOUSE_ENTER || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  208|      0|#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  205|      0|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   ((code) == MP_KEY_MOUSE_MOVE || (code) == MP_KEY_MOUSE_ENTER || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  205|      0|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 0]
  |  |  |  |  |  Branch (216:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  217|      0|     (code) == MP_KEY_MOUSE_LEAVE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  209|      0|#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  205|      0|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (217:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (791:9): [True: 0, False: 19.5k]
  |  Branch (791:68): [True: 0, False: 0]
  ------------------
  792|      0|        return;
  793|  19.5k|    if (unmod == MP_KEY_MOUSE_LEAVE || unmod == MP_KEY_MOUSE_ENTER) {
  ------------------
  |  |  209|  39.1k|#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  205|  19.5k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  19.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|  19.5k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
                  if (unmod == MP_KEY_MOUSE_LEAVE || unmod == MP_KEY_MOUSE_ENTER) {
  ------------------
  |  |  210|  19.5k|#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  205|  19.5k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  19.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|  19.5k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
  |  Branch (793:9): [True: 1, False: 19.5k]
  |  Branch (793:40): [True: 2, False: 19.5k]
  ------------------
  794|      3|        ictx->mouse_hover = unmod == MP_KEY_MOUSE_ENTER;
  ------------------
  |  |  210|      3|#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  205|      3|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      3|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|      3|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
  795|      3|        update_mouse_section(ictx);
  796|       |
  797|      3|        mp_cmd_t *cmd = get_cmd_from_keys(ictx, (bstr){0}, code);
  798|      3|        if (!cmd)  // queue dummy cmd so that mouse-pos can notify observers
  ------------------
  |  Branch (798:13): [True: 3, False: 0]
  ------------------
  799|      3|            cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>");
  800|      3|        if (cmd)
  ------------------
  |  Branch (800:13): [True: 3, False: 0]
  ------------------
  801|      3|            cmd->notify_event = true;
  802|      3|        queue_cmd(ictx, cmd);
  803|      3|        return;
  804|      3|    }
  805|  19.5k|    double now = mp_time_sec();
  806|       |    // ignore system double-click if we generate these events ourselves
  807|  19.5k|    if (!force_mouse && opts->doubleclick_time && MP_KEY_IS_MOUSE_BTN_DBL(unmod))
  ------------------
  |  |  160|      0|    ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  ------------------
  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  ------------------
  |  |  |  |  157|      0|#define MP_MBTN_DBL_END    (MP_MBTN_DBL_BASE+20)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (160:6): [True: 0, False: 0]
  |  |  |  Branch (160:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (807:9): [True: 0, False: 19.5k]
  |  Branch (807:25): [True: 0, False: 0]
  ------------------
  808|      0|        return;
  809|  19.5k|    int units = 1;
  810|  19.5k|    if (MP_KEY_IS_WHEEL(unmod) && opts->preprocess_wheel && !process_wheel(ictx, unmod, &scale, &units))
  ------------------
  |  |  151|  39.1k|    ((code) >= MP_WHEEL_UP && (code) <= MP_WHEEL_RIGHT)
  |  |  ------------------
  |  |  |  |  129|  39.1k|#define MP_WHEEL_UP      (MP_MBTN_BASE+3)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  19.5k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  19.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|  19.5k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  237|  19.5k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((code) >= MP_WHEEL_UP && (code) <= MP_WHEEL_RIGHT)
  |  |  ------------------
  |  |  |  |  132|    108|#define MP_WHEEL_RIGHT   (MP_MBTN_BASE+6)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|    108|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|    108|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|    108|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  237|    108|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (151:6): [True: 108, False: 19.4k]
  |  |  |  Branch (151:31): [True: 53, False: 55]
  |  |  ------------------
  ------------------
  |  Branch (810:35): [True: 53, False: 0]
  |  Branch (810:61): [True: 0, False: 53]
  ------------------
  811|      0|        return;
  812|  19.5k|    interpret_key(ictx, code, scale, units);
  813|  19.5k|    if (code & MP_KEY_STATE_DOWN) {
  ------------------
  |  |  253|  19.5k|#define MP_KEY_STATE_DOWN      (1u<<28)
  ------------------
  |  Branch (813:9): [True: 19.0k, False: 565]
  ------------------
  814|  19.0k|        code &= ~MP_KEY_STATE_DOWN;
  ------------------
  |  |  253|  19.0k|#define MP_KEY_STATE_DOWN      (1u<<28)
  ------------------
  815|  19.0k|        if (ictx->last_doubleclick_key_down == code &&
  ------------------
  |  Branch (815:13): [True: 18.5k, False: 506]
  ------------------
  816|  18.5k|            now - ictx->last_doubleclick_time < opts->doubleclick_time / 1000.0 &&
  ------------------
  |  Branch (816:13): [True: 18.5k, False: 2]
  ------------------
  817|  18.5k|            code >= MP_MBTN_LEFT && code <= MP_MBTN_RIGHT)
  ------------------
  |  |  126|  37.5k|#define MP_MBTN_LEFT     (MP_MBTN_BASE+0)
  |  |  ------------------
  |  |  |  |  125|  18.5k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  18.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|  18.5k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|  18.5k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                          code >= MP_MBTN_LEFT && code <= MP_MBTN_RIGHT)
  ------------------
  |  |  128|      0|#define MP_MBTN_RIGHT    (MP_MBTN_BASE+2)
  |  |  ------------------
  |  |  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (817:13): [True: 0, False: 18.5k]
  |  Branch (817:37): [True: 0, False: 0]
  ------------------
  818|      0|        {
  819|      0|            now = 0;
  820|      0|            interpret_key(ictx, code - MP_MBTN_BASE + MP_MBTN_DBL_BASE,
  ------------------
  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  ------------------
  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  ------------------
  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  ------------------
  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  ------------------
  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  ------------------
  ------------------
                          interpret_key(ictx, code - MP_MBTN_BASE + MP_MBTN_DBL_BASE,
  ------------------
  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  ------------------
  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
  821|      0|                          1, 1);
  822|  19.0k|        } else if (code == MP_MBTN_LEFT && ictx->opts->allow_win_drag &&
  ------------------
  |  |  126|  38.0k|#define MP_MBTN_LEFT     (MP_MBTN_BASE+0)
  |  |  ------------------
  |  |  |  |  125|  19.0k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  19.0k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|  19.0k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|  19.0k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (822:20): [True: 21, False: 18.9k]
  |  Branch (822:44): [True: 21, False: 0]
  ------------------
  823|     21|                   !test_mouse(ictx, ictx->mouse_vo_x, ictx->mouse_vo_y, MP_INPUT_ALLOW_VO_DRAGGING))
  ------------------
  |  Branch (823:20): [True: 20, False: 1]
  ------------------
  824|     20|        {
  825|       |            // This is a mouse left button down event which isn't part of a double-click,
  826|       |            // and the mouse is on an input section which allows VO dragging.
  827|       |            // Mark the dragging mouse button down in this case.
  828|     20|            ictx->dragging_button_down = true;
  829|       |            // Store the current mouse position for deadzone handling.
  830|     20|            ictx->mouse_drag_x = ictx->mouse_raw_x;
  831|     20|            ictx->mouse_drag_y = ictx->mouse_raw_y;
  832|     20|        }
  833|  19.0k|        ictx->last_doubleclick_key_down = code;
  834|  19.0k|        ictx->last_doubleclick_time = now;
  835|  19.0k|    }
  836|  19.5k|    if (code & MP_KEY_STATE_UP) {
  ------------------
  |  |  259|  19.5k|#define MP_KEY_STATE_UP        (1u<<29)
  ------------------
  |  Branch (836:9): [True: 130, False: 19.4k]
  ------------------
  837|    130|        code &= ~MP_KEY_STATE_UP;
  ------------------
  |  |  259|    130|#define MP_KEY_STATE_UP        (1u<<29)
  ------------------
  838|    130|        if (code == MP_MBTN_LEFT) {
  ------------------
  |  |  126|    130|#define MP_MBTN_LEFT     (MP_MBTN_BASE+0)
  |  |  ------------------
  |  |  |  |  125|    130|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    130|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|    130|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|    130|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (838:13): [True: 0, False: 130]
  ------------------
  839|       |            // This is a mouse left button up event. Mark the dragging mouse button up.
  840|       |            ictx->dragging_button_down = false;
  841|      0|        }
  842|    130|    }
  843|  19.5k|}
input.c:release_down_cmd:
  583|  1.22k|{
  584|  1.22k|    if (ictx->current_down_cmd && ictx->current_down_cmd->emit_on_up &&
  ------------------
  |  Branch (584:9): [True: 0, False: 1.22k]
  |  Branch (584:35): [True: 0, False: 0]
  ------------------
  585|      0|        (!drop_current || ictx->current_down_cmd->def->on_updown))
  ------------------
  |  Branch (585:10): [True: 0, False: 0]
  |  Branch (585:27): [True: 0, False: 0]
  ------------------
  586|      0|    {
  587|      0|        memset(ictx->key_history, 0, sizeof(ictx->key_history));
  588|      0|        ictx->current_down_cmd->is_up = true;
  589|      0|        if (drop_current)
  ------------------
  |  Branch (589:13): [True: 0, False: 0]
  ------------------
  590|      0|            ictx->current_down_cmd->canceled = true;
  591|      0|        queue_cmd(ictx, ictx->current_down_cmd);
  592|  1.22k|    } else {
  593|  1.22k|        talloc_free(ictx->current_down_cmd);
  ------------------
  |  |   47|  1.22k|#define talloc_free                     ta_free
  ------------------
  594|  1.22k|    }
  595|       |    ictx->current_down_cmd = NULL;
  596|  1.22k|    ictx->last_key_down = 0;
  597|  1.22k|    ictx->last_key_down_time = 0;
  598|  1.22k|    ictx->ar_state = -1;
  599|  1.22k|    update_mouse_section(ictx);
  600|  1.22k|}
input.c:update_mouse_section:
  558|  2.17k|{
  559|  2.17k|    struct cmd_bind *bind =
  560|  2.17k|        find_any_bind_for_key(ictx, (bstr){0}, MP_KEY_MOUSE_MOVE);
  ------------------
  |  |  208|  2.17k|#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  205|  2.17k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  2.17k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|  2.17k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
  561|       |
  562|  2.17k|    bstr new_section = bind ? bind->owner->section : bstr0("default");
  ------------------
  |  Branch (562:24): [True: 0, False: 2.17k]
  ------------------
  563|       |
  564|  2.17k|    bstr old = ictx->mouse_section;
  565|  2.17k|    ictx->mouse_section = new_section;
  566|       |
  567|  2.17k|    if (!bstr_equals(old, ictx->mouse_section)) {
  ------------------
  |  Branch (567:9): [True: 0, False: 2.17k]
  ------------------
  568|      0|        MP_TRACE(ictx, "input: switch section %.*s -> %.*s\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__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|      0|                 BSTR_P(old), BSTR_P(ictx->mouse_section));
  570|      0|        queue_cmd(ictx, get_cmd_from_keys(ictx, old, MP_KEY_MOUSE_LEAVE));
  ------------------
  |  |  209|      0|#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  205|      0|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  ------------------
  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  ------------------
  ------------------
  571|      0|    }
  572|  2.17k|}
input.c:find_any_bind_for_key:
  467|  4.32k|{
  468|  4.32k|    if (force_section.len)
  ------------------
  |  Branch (468:9): [True: 0, False: 4.32k]
  ------------------
  469|      0|        return find_bind_for_key_section(ictx, force_section, code);
  470|       |
  471|  4.32k|    bool use_mouse = MP_KEY_DEPENDS_ON_MOUSE_POS(code);
  ------------------
  |  |  221|  4.32k|    (MP_KEY_IS_MOUSE_CLICK(code) || (code) == MP_KEY_MOUSE_MOVE)
  |  |  ------------------
  |  |  |  |  213|  8.64k|    (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  8.64k|    ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  125|  8.64k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|  4.32k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|  4.32k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  237|  4.32k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  146|     96|#define MP_MBTN_END      (MP_MBTN_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  125|     96|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|     96|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|     96|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  237|     96|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (149:6): [True: 96, False: 4.22k]
  |  |  |  |  |  |  |  Branch (149:32): [True: 93, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  160|  4.23k|    ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  153|  8.46k|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|  4.23k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|  4.23k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  157|  2.19k|#define MP_MBTN_DBL_END    (MP_MBTN_DBL_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  153|  2.19k|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|  2.19k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|  2.19k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:6): [True: 2.19k, False: 2.03k]
  |  |  |  |  |  |  |  Branch (160:36): [True: 22, False: 2.17k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (MP_KEY_IS_MOUSE_CLICK(code) || (code) == MP_KEY_MOUSE_MOVE)
  |  |  ------------------
  |  |  |  |  208|  4.20k|#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  205|  4.20k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  4.20k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|  4.20k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (221:37): [True: 2.17k, False: 2.03k]
  |  |  ------------------
  ------------------
  472|       |
  473|       |    // First look whether a mouse section is capturing all mouse input
  474|       |    // exclusively (regardless of the active section stack order).
  475|  4.32k|    if (use_mouse && MP_KEY_IS_MOUSE_BTN_SINGLE(ictx->last_key_down) &&
  ------------------
  |  |  149|  6.61k|    ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  ------------------
  |  |  |  |  125|  4.57k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  2.28k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|  2.28k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|  2.28k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_MBTN_END      (MP_MBTN_BASE+20)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (149:6): [True: 0, False: 2.28k]
  |  |  |  Branch (149:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (475:9): [True: 2.28k, False: 2.03k]
  ------------------
  476|      0|        !MP_KEY_IS_MOUSE_BTN_DBL(code))
  ------------------
  |  |  160|      0|    ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  ------------------
  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  ------------------
  |  |  |  |  157|      0|#define MP_MBTN_DBL_END    (MP_MBTN_DBL_BASE+20)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      0|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (160:6): [True: 0, False: 0]
  |  |  |  Branch (160:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  477|      0|    {
  478|      0|        struct cmd_bind *bind =
  479|      0|            find_bind_for_key_section(ictx, ictx->mouse_section, code);
  480|      0|        if (bind)
  ------------------
  |  Branch (480:13): [True: 0, False: 0]
  ------------------
  481|      0|            return bind;
  482|      0|    }
  483|       |
  484|  4.32k|    struct cmd_bind *best_bind = NULL;
  485|  8.67k|    for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
  ------------------
  |  Branch (485:49): [True: 4.35k, False: 4.32k]
  ------------------
  486|  4.35k|        struct active_section *s = &ictx->active_sections[i];
  487|  4.35k|        struct cmd_bind *bind = find_bind_for_key_section(ictx, s->name, code);
  488|  4.35k|        if (bind) {
  ------------------
  |  Branch (488:13): [True: 0, False: 4.35k]
  ------------------
  489|      0|            struct cmd_bind_section *bs = bind->owner;
  490|      0|            if (!use_mouse || (bs->mouse_area_set && test_rect(&bs->mouse_area,
  ------------------
  |  Branch (490:17): [True: 0, False: 0]
  |  Branch (490:32): [True: 0, False: 0]
  |  Branch (490:54): [True: 0, False: 0]
  ------------------
  491|      0|                                                               ictx->mouse_vo_x,
  492|      0|                                                               ictx->mouse_vo_y)))
  493|      0|            {
  494|      0|                if (!best_bind || bind->num_keys > best_bind->num_keys ||
  ------------------
  |  Branch (494:21): [True: 0, False: 0]
  |  Branch (494:35): [True: 0, False: 0]
  ------------------
  495|      0|                    (best_bind->is_builtin && !bind->is_builtin &&
  ------------------
  |  Branch (495:22): [True: 0, False: 0]
  |  Branch (495:47): [True: 0, False: 0]
  ------------------
  496|      0|                     bind->num_keys == best_bind->num_keys))
  ------------------
  |  Branch (496:22): [True: 0, False: 0]
  ------------------
  497|      0|                {
  498|      0|                    best_bind = bind;
  499|      0|                }
  500|      0|            }
  501|      0|        }
  502|  4.35k|        if (s->flags & MP_INPUT_EXCLUSIVE)
  ------------------
  |  Branch (502:13): [True: 0, False: 4.35k]
  ------------------
  503|      0|            break;
  504|  4.35k|        if (best_bind && (s->flags & MP_INPUT_ON_TOP))
  ------------------
  |  Branch (504:13): [True: 0, False: 4.35k]
  |  Branch (504:26): [True: 0, False: 0]
  ------------------
  505|      0|            break;
  506|  4.35k|    }
  507|       |
  508|  4.32k|    return best_bind;
  509|  4.32k|}
input.c:find_bind_for_key_section:
  431|  4.35k|{
  432|  4.35k|    struct cmd_bind_section *bs = get_bind_section(ictx, section);
  433|       |
  434|  4.35k|    if (!bs->num_binds)
  ------------------
  |  Branch (434:9): [True: 3.93k, False: 422]
  ------------------
  435|  3.93k|        return NULL;
  436|       |
  437|    422|    int keys[MP_MAX_KEY_DOWN];
  438|    422|    memcpy(keys, ictx->key_history, sizeof(keys));
  439|    422|    key_buf_add(keys, code);
  440|       |
  441|    422|    struct cmd_bind *best = NULL;
  442|       |
  443|       |    // Prefer user-defined keys over builtin bindings
  444|    844|    for (int builtin = 0; builtin < 2; builtin++) {
  ------------------
  |  Branch (444:27): [True: 844, False: 0]
  ------------------
  445|    844|        if (builtin && !ictx->opts->default_bindings)
  ------------------
  |  Branch (445:13): [True: 422, False: 422]
  |  Branch (445:24): [True: 422, False: 0]
  ------------------
  446|    422|            break;
  447|  1.72k|        for (int n = 0; n < bs->num_binds; n++) {
  ------------------
  |  Branch (447:25): [True: 1.30k, False: 422]
  ------------------
  448|  1.30k|            if (bs->binds[n].is_builtin == (bool)builtin) {
  ------------------
  |  Branch (448:17): [True: 1.30k, False: 0]
  ------------------
  449|  1.30k|                struct cmd_bind *b = &bs->binds[n];
  450|       |                // we have: keys=[key2 key1 keyX ...]
  451|       |                // and: b->keys=[key1 key2] (and may be just a prefix)
  452|  1.30k|                for (int i = 0; i < b->num_keys; i++) {
  ------------------
  |  Branch (452:33): [True: 1.30k, False: 0]
  ------------------
  453|  1.30k|                    if (b->keys[i] != keys[b->num_keys - 1 - i])
  ------------------
  |  Branch (453:25): [True: 1.30k, False: 0]
  ------------------
  454|  1.30k|                        goto skip;
  455|  1.30k|                }
  456|      0|                if (!best || b->num_keys > best->num_keys)
  ------------------
  |  Branch (456:21): [True: 0, False: 0]
  |  Branch (456:30): [True: 0, False: 0]
  ------------------
  457|      0|                    best = b;
  458|  1.30k|            skip: ;
  459|  1.30k|            }
  460|  1.30k|        }
  461|    422|    }
  462|    422|    return best;
  463|    422|}
input.c:key_buf_add:
  423|  1.36k|{
  424|  21.8k|    for (int n = MP_MAX_KEY_DOWN - 1; n > 0; n--)
  ------------------
  |  |   61|  1.36k|#define MP_MAX_KEY_DOWN 16
  ------------------
  |  Branch (424:39): [True: 20.5k, False: 1.36k]
  ------------------
  425|  20.5k|        buf[n] = buf[n - 1];
  426|  1.36k|    buf[0] = code;
  427|  1.36k|}
input.c:test_rect:
  277|  2.80M|{
  278|  2.80M|    return x >= rc->x0 && y >= rc->y0 && x < rc->x1 && y < rc->y1;
  ------------------
  |  Branch (278:12): [True: 2.80M, False: 0]
  |  Branch (278:27): [True: 2.80M, False: 0]
  |  Branch (278:42): [True: 2.80M, False: 0]
  |  Branch (278:56): [True: 2.80M, False: 0]
  ------------------
  279|  2.80M|}
input.c:get_cmd_from_keys:
  513|    948|{
  514|    948|    if (ictx->opts->test)
  ------------------
  |  Branch (514:9): [True: 0, False: 948]
  ------------------
  515|      0|        return handle_test(ictx, code);
  516|       |
  517|    948|    struct cmd_bind *cmd = NULL;
  518|       |
  519|    948|    if (MP_KEY_IS_UNICODE(code))
  ------------------
  |  |   27|    948|#define MP_KEY_IS_UNICODE(key) ((key) >= 32 && (key) <= 0x10FFFF)
  |  |  ------------------
  |  |  |  Branch (27:33): [True: 379, False: 569]
  |  |  |  Branch (27:48): [True: 256, False: 123]
  |  |  ------------------
  ------------------
  520|    256|        cmd = find_any_bind_for_key(ictx, force_section, MP_KEY_ANY_UNICODE);
  ------------------
  |  |  228|    256|#define MP_KEY_ANY_UNICODE      (MP_KEY_INTERN+5)
  |  |  ------------------
  |  |  |  |  205|    256|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    256|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|    948|    if (!cmd)
  ------------------
  |  Branch (521:9): [True: 948, False: 0]
  ------------------
  522|    948|        cmd = find_any_bind_for_key(ictx, force_section, code);
  523|    948|    if (!cmd)
  ------------------
  |  Branch (523:9): [True: 948, False: 0]
  ------------------
  524|    948|        cmd = find_any_bind_for_key(ictx, force_section, MP_KEY_UNMAPPED);
  ------------------
  |  |  227|    948|#define MP_KEY_UNMAPPED         (MP_KEY_INTERN+4)
  |  |  ------------------
  |  |  |  |  205|    948|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    948|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  525|    948|    if (!cmd) {
  ------------------
  |  Branch (525:9): [True: 948, False: 0]
  ------------------
  526|    948|        if (code == MP_KEY_CLOSE_WIN)
  ------------------
  |  |  206|    948|#define MP_KEY_CLOSE_WIN (MP_KEY_INTERN+0)
  |  |  ------------------
  |  |  |  |  205|    948|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    948|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (526:13): [True: 0, False: 948]
  ------------------
  527|      0|            return mp_input_parse_cmd_strv(ictx->log, (const char*[]){"quit", 0});
  528|    948|        int msgl = MSGL_WARN;
  529|    948|        if (MP_KEY_IS_MOUSE_MOVE(code))
  ------------------
  |  |  216|    948|    ((code) == MP_KEY_MOUSE_MOVE || (code) == MP_KEY_MOUSE_ENTER || \
  |  |  ------------------
  |  |  |  |  208|  1.89k|#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  205|    948|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|    948|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|    948|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((code) == MP_KEY_MOUSE_MOVE || (code) == MP_KEY_MOUSE_ENTER || \
  |  |  ------------------
  |  |  |  |  210|  1.89k|#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  205|    948|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|    948|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|    948|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (216:6): [True: 0, False: 948]
  |  |  |  Branch (216:37): [True: 0, False: 948]
  |  |  ------------------
  |  |  217|    948|     (code) == MP_KEY_MOUSE_LEAVE)
  |  |  ------------------
  |  |  |  |  209|    948|#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  205|    948|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|    948|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|    948|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (217:6): [True: 0, False: 948]
  |  |  ------------------
  ------------------
  530|      0|            msgl = MSGL_TRACE;
  531|    948|        char *key_buf = mp_input_get_key_combo_name(&code, 1);
  532|    948|        MP_MSG(ictx, msgl, "No key binding found for key '%s'.\n", key_buf);
  ------------------
  |  |   86|    948|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  533|    948|        talloc_free(key_buf);
  ------------------
  |  |   47|    948|#define talloc_free                     ta_free
  ------------------
  534|    948|        return NULL;
  535|    948|    }
  536|      0|    mp_cmd_t *ret = mp_input_parse_cmd(ictx, bstr0(cmd->cmd), cmd->location);
  537|      0|    if (ret) {
  ------------------
  |  Branch (537:9): [True: 0, False: 0]
  ------------------
  538|      0|        ret->input_section = cmd->owner->section;
  539|      0|        ret->key_name = talloc_steal(ret, mp_input_get_key_combo_name(&code, 1));
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  540|      0|        MP_TRACE(ictx, "key '%s' -> '%s' in '%.*s'\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__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  541|      0|                 ret->key_name, cmd->cmd, BSTR_P(ret->input_section));
  542|      0|        if (MP_KEY_IS_UNICODE(code)) {
  ------------------
  |  |   27|      0|#define MP_KEY_IS_UNICODE(key) ((key) >= 32 && (key) <= 0x10FFFF)
  |  |  ------------------
  |  |  |  Branch (27:33): [True: 0, False: 0]
  |  |  |  Branch (27:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  543|      0|            bstr text = {0};
  544|      0|            mp_append_utf8_bstr(ret, &text, code);
  545|      0|            ret->key_text = text.start;
  546|      0|        }
  547|      0|        ret->is_mouse_button = code & MP_KEY_EMIT_ON_UP;
  ------------------
  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  ------------------
  548|      0|    } else {
  549|      0|        char *key_buf = mp_input_get_key_combo_name(&code, 1);
  550|      0|        MP_ERR(ictx, "Invalid command for key binding '%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__)
  |  |  ------------------
  ------------------
  551|      0|               key_buf, cmd->cmd);
  552|      0|        talloc_free(key_buf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  553|      0|    }
  554|      0|    return ret;
  555|    948|}
input.c:process_wheel:
  711|     53|{
  712|       |    // Size of the deadzone in scroll units. The user must scroll at least this
  713|       |    // much in any direction before their scroll is registered.
  714|     53|    static const double DEADZONE_DIST = 0.125;
  715|       |    // The deadzone accumulator is reset if no scrolls happened in this many
  716|       |    // seconds, e.g. the user is assumed to have finished scrolling.
  717|     53|    static const double DEADZONE_SCROLL_TIME = 0.2;
  718|       |    // The scale_units accumulator is reset if no scrolls happened in this many
  719|       |    // seconds. This value should be fairly large, so commands will still be
  720|       |    // sent when the user scrolls slowly.
  721|     53|    static const double UNIT_SCROLL_TIME = 0.5;
  722|       |
  723|       |    // Determine which direction is being scrolled
  724|     53|    double dir;
  725|     53|    struct wheel_state *state;
  726|     53|    switch (code) {
  727|      9|    case MP_WHEEL_UP:    dir = -1; state = &ictx->wheel_state_y; break;
  ------------------
  |  |  129|      9|#define MP_WHEEL_UP      (MP_MBTN_BASE+3)
  |  |  ------------------
  |  |  |  |  125|      9|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      9|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      9|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|      9|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (727:5): [True: 9, False: 44]
  ------------------
  728|      8|    case MP_WHEEL_DOWN:  dir = +1; state = &ictx->wheel_state_y; break;
  ------------------
  |  |  130|      8|#define MP_WHEEL_DOWN    (MP_MBTN_BASE+4)
  |  |  ------------------
  |  |  |  |  125|      8|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      8|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      8|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|      8|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (728:5): [True: 8, False: 45]
  ------------------
  729|      0|    case MP_WHEEL_LEFT:  dir = -1; state = &ictx->wheel_state_x; break;
  ------------------
  |  |  131|      0|#define MP_WHEEL_LEFT    (MP_MBTN_BASE+5)
  |  |  ------------------
  |  |  |  |  125|      0|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      0|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (729:5): [True: 0, False: 53]
  ------------------
  730|     36|    case MP_WHEEL_RIGHT: dir = +1; state = &ictx->wheel_state_x; break;
  ------------------
  |  |  132|     36|#define MP_WHEEL_RIGHT   (MP_MBTN_BASE+6)
  |  |  ------------------
  |  |  |  |  125|     36|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|     36|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|     36|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  237|     36|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (730:5): [True: 36, False: 17]
  ------------------
  731|      0|    default:
  ------------------
  |  Branch (731:5): [True: 0, False: 53]
  ------------------
  732|      0|        return true;
  733|     53|    }
  734|       |
  735|       |    // Reset accumulators if it's determined that the user finished scrolling
  736|     53|    double now = mp_time_sec();
  737|     53|    if (now > ictx->last_wheel_time + DEADZONE_SCROLL_TIME) {
  ------------------
  |  Branch (737:9): [True: 17, False: 36]
  ------------------
  738|     17|        ictx->wheel_current = NULL;
  739|     17|        ictx->wheel_state_y.dead_zone_accum = 0;
  740|     17|        ictx->wheel_state_x.dead_zone_accum = 0;
  741|     17|    }
  742|     53|    if (now > ictx->last_wheel_time + UNIT_SCROLL_TIME) {
  ------------------
  |  Branch (742:9): [True: 17, False: 36]
  ------------------
  743|     17|        ictx->wheel_state_y.unit_accum = 0;
  744|     17|        ictx->wheel_state_x.unit_accum = 0;
  745|     17|    }
  746|     53|    ictx->last_wheel_time = now;
  747|       |
  748|       |    // Process wheel deadzone. A lot of touchpad drivers don't filter scroll
  749|       |    // input, which makes it difficult for the user to send WHEEL_UP/DOWN
  750|       |    // without accidentally triggering WHEEL_LEFT/RIGHT. We try to fix this by
  751|       |    // implementing a deadzone. When the value of either direction breaks out
  752|       |    // of the deadzone, events from the other direction will be ignored until
  753|       |    // the user finishes scrolling.
  754|     53|    if (ictx->wheel_current == NULL) {
  ------------------
  |  Branch (754:9): [True: 17, False: 36]
  ------------------
  755|     17|        state->dead_zone_accum += *scale * dir;
  756|     17|        if (state->dead_zone_accum * dir > DEADZONE_DIST) {
  ------------------
  |  Branch (756:13): [True: 17, False: 0]
  ------------------
  757|     17|            ictx->wheel_current = state;
  758|     17|            *scale = state->dead_zone_accum * dir;
  759|     17|        }
  760|     17|    }
  761|     53|    if (ictx->wheel_current != state)
  ------------------
  |  Branch (761:9): [True: 0, False: 53]
  ------------------
  762|      0|        return false;
  763|       |
  764|       |    // Determine scale_units. This is incremented every time the accumulated
  765|       |    // scale value crosses 1.0. Non-scalable input commands will be ran that
  766|       |    // many times.
  767|     53|    state->unit_accum += *scale * dir;
  768|     53|    *scale_units = trunc(state->unit_accum * dir);
  769|     53|    state->unit_accum -= *scale_units * dir;
  770|       |    return true;
  771|     53|}
input.c:interpret_key:
  623|  19.5k|{
  624|  19.5k|    int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP);
  ------------------
  |  |  253|  19.5k|#define MP_KEY_STATE_DOWN      (1u<<28)
  ------------------
                  int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP);
  ------------------
  |  |  259|  19.5k|#define MP_KEY_STATE_UP        (1u<<29)
  ------------------
  625|  19.5k|    bool no_emit = code & MP_KEY_STATE_SET_ONLY;
  ------------------
  |  |  262|  19.5k|#define MP_KEY_STATE_SET_ONLY  (1u<<30)
  ------------------
  626|  19.5k|    code = code & ~(unsigned)(state | MP_KEY_STATE_SET_ONLY);
  ------------------
  |  |  262|  19.5k|#define MP_KEY_STATE_SET_ONLY  (1u<<30)
  ------------------
  627|       |
  628|  19.5k|    if (mp_msg_test(ictx->log, MSGL_TRACE)) {
  ------------------
  |  Branch (628:9): [True: 19.5k, False: 0]
  ------------------
  629|  19.5k|        char *key = mp_input_get_key_name(code);
  630|  19.5k|        MP_TRACE(ictx, "key code=%#x '%s'%s%s\n",
  ------------------
  |  |   94|  19.5k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  78.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 19.0k, False: 565]
  |  |  |  |  |  Branch (86:57): [True: 130, False: 19.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|  19.5k|                 code, key, (state & MP_KEY_STATE_DOWN) ? " down" : "",
  632|  19.5k|                 (state & MP_KEY_STATE_UP) ? " up" : "");
  633|  19.5k|        talloc_free(key);
  ------------------
  |  |   47|  19.5k|#define talloc_free                     ta_free
  ------------------
  634|  19.5k|    }
  635|       |
  636|  19.5k|    if (MP_KEY_DEPENDS_ON_MOUSE_POS(code & ~MP_KEY_MODIFIER_MASK)) {
  ------------------
  |  |  221|  19.5k|    (MP_KEY_IS_MOUSE_CLICK(code) || (code) == MP_KEY_MOUSE_MOVE)
  |  |  ------------------
  |  |  |  |  213|  39.1k|    (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  39.1k|    ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  125|  39.1k|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|  19.5k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|  19.5k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  237|  19.5k|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  146|    129|#define MP_MBTN_END      (MP_MBTN_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  125|    129|#define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|    129|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|    129|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_BASE     ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  237|    129|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (149:6): [True: 129, False: 19.4k]
  |  |  |  |  |  |  |  Branch (149:32): [True: 129, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
  |  |  |  |  ------------------
  |  |  |  |  |  |  160|  19.4k|    ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  153|  38.8k|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   23|  19.4k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|  19.4k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                   ((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  157|     22|#define MP_MBTN_DBL_END    (MP_MBTN_DBL_BASE+20)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  153|     22|#define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   23|     22|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define MP_MBTN_DBL_BASE   ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  242|     22|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:6): [True: 22, False: 19.4k]
  |  |  |  |  |  |  |  Branch (160:36): [True: 22, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (MP_KEY_IS_MOUSE_CLICK(code) || (code) == MP_KEY_MOUSE_MOVE)
  |  |  ------------------
  |  |  |  |  208|  19.4k|#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  205|  19.4k|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  19.4k|#define MP_KEY_BASE (1<<21)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
  |  |  |  |  ------------------
  |  |  |  |  |  |  242|  19.4k|#define MP_NO_REPEAT_KEY       (1u<<23)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (221:37): [True: 0, False: 19.4k]
  |  |  ------------------
  ------------------
  637|    151|        ictx->mouse_event_counter++;
  638|    151|        mp_input_wakeup(ictx);
  639|    151|    }
  640|       |
  641|  19.5k|    struct mp_cmd *cmd = NULL;
  642|       |
  643|  19.5k|    if (state == MP_KEY_STATE_DOWN) {
  ------------------
  |  |  253|  19.5k|#define MP_KEY_STATE_DOWN      (1u<<28)
  ------------------
  |  Branch (643:9): [True: 19.0k, False: 565]
  ------------------
  644|       |        // Protect against VOs which send STATE_DOWN with autorepeat
  645|  19.0k|        if (ictx->last_key_down == code)
  ------------------
  |  Branch (645:13): [True: 18.5k, False: 510]
  ------------------
  646|  18.5k|            return;
  647|       |        // Cancel current down-event (there can be only one)
  648|    510|        release_down_cmd(ictx, true);
  649|    510|        cmd = resolve_key(ictx, code);
  650|    510|        if (cmd) {
  ------------------
  |  Branch (650:13): [True: 0, False: 510]
  ------------------
  651|      0|            cmd->is_up_down = true;
  652|      0|            cmd->emit_on_up = (code & MP_KEY_EMIT_ON_UP) || cmd->def->on_updown;
  ------------------
  |  |  237|      0|#define MP_KEY_EMIT_ON_UP      (1u<<22)
  ------------------
  |  Branch (652:31): [True: 0, False: 0]
  |  Branch (652:61): [True: 0, False: 0]
  ------------------
  653|      0|            ictx->current_down_cmd = mp_cmd_clone(cmd);
  654|      0|        }
  655|    510|        ictx->last_key_down = code;
  656|    510|        ictx->last_key_down_time = mp_time_ns();
  657|    510|        ictx->ar_state = 0;
  658|    510|        mp_input_wakeup(ictx); // possibly start timer for autorepeat
  659|    565|    } else if (state == MP_KEY_STATE_UP) {
  ------------------
  |  |  259|    565|#define MP_KEY_STATE_UP        (1u<<29)
  ------------------
  |  Branch (659:16): [True: 130, False: 435]
  ------------------
  660|       |        // Most VOs send RELEASE_ALL anyway
  661|    130|        release_down_cmd(ictx, false);
  662|    435|    } else {
  663|       |        // Press of key with no separate down/up events
  664|       |        // Mixing press events and up/down with the same key is not supported,
  665|       |        // and input sources shouldn't do this, but can happen anyway if
  666|       |        // multiple input sources interfere with each other.
  667|    435|        if (ictx->last_key_down == code)
  ------------------
  |  Branch (667:13): [True: 4, False: 431]
  ------------------
  668|      4|            release_down_cmd(ictx, false);
  669|    435|        cmd = resolve_key(ictx, code);
  670|    435|    }
  671|       |
  672|  1.07k|    if (!cmd)
  ------------------
  |  Branch (672:9): [True: 1.07k, False: 0]
  ------------------
  673|  1.07k|        return;
  674|       |
  675|       |    // Don't emit a command on key-down if the key is designed to emit commands
  676|       |    // on key-up (like mouse buttons), or setting key state only without emitting commands.
  677|       |    // Also, if the command specifically should be sent both on key down and key up,
  678|       |    // still emit the command.
  679|      0|    if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) {
  ------------------
  |  Branch (679:10): [True: 0, False: 0]
  |  Branch (679:29): [True: 0, False: 0]
  |  Branch (679:54): [True: 0, False: 0]
  ------------------
  680|      0|        talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  681|      0|        return;
  682|      0|    }
  683|       |
  684|      0|    memset(ictx->key_history, 0, sizeof(ictx->key_history));
  685|       |
  686|      0|    if (mp_input_is_scalable_cmd(cmd)) {
  ------------------
  |  Branch (686:9): [True: 0, False: 0]
  ------------------
  687|      0|        cmd->scale = scale;
  688|      0|        cmd->scale_units = scale_units;
  689|      0|        queue_cmd(ictx, cmd);
  690|      0|    } else {
  691|       |        // Non-scalable commands won't understand cmd->scale, so synthesize
  692|       |        // multiple commands with cmd->scale = 1
  693|      0|        cmd->scale = 1;
  694|      0|        cmd->scale_units = 1;
  695|       |        // Avoid spamming the player with too many commands
  696|      0|        scale_units = MPMIN(scale_units, 20);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  697|      0|        for (int i = 0; i < scale_units - 1; i++)
  ------------------
  |  Branch (697:25): [True: 0, False: 0]
  ------------------
  698|      0|            queue_cmd(ictx, mp_cmd_clone(cmd));
  699|      0|        if (scale_units) {
  ------------------
  |  Branch (699:13): [True: 0, False: 0]
  ------------------
  700|      0|            queue_cmd(ictx, cmd);
  701|      0|        } else {
  702|      0|            talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  703|      0|        }
  704|      0|    }
  705|      0|}
input.c:resolve_key:
  611|    945|{
  612|    945|    update_mouse_section(ictx);
  613|    945|    struct mp_cmd *cmd = get_cmd_from_keys(ictx, (bstr){0}, code);
  614|    945|    key_buf_add(ictx->key_history, code);
  615|    945|    if (cmd && !cmd->def->is_ignore && !should_drop_cmd(ictx, cmd))
  ------------------
  |  Branch (615:9): [True: 0, False: 945]
  |  Branch (615:16): [True: 0, False: 0]
  |  Branch (615:40): [True: 0, False: 0]
  ------------------
  616|      0|        return cmd;
  617|    945|    talloc_free(cmd);
  ------------------
  |  |   47|    945|#define talloc_free                     ta_free
  ------------------
  618|       |    return NULL;
  619|    945|}
input.c:queue_remove:
  290|      3|{
  291|      3|    struct mp_cmd **p_prev = &queue->first;
  292|      3|    while (*p_prev != cmd) {
  ------------------
  |  Branch (292:12): [True: 0, False: 3]
  ------------------
  293|      0|        p_prev = &(*p_prev)->queue_next;
  294|      0|    }
  295|       |    // if this fails, cmd was not in the queue
  296|      3|    mp_assert(*p_prev == cmd);
  ------------------
  |  |   41|      3|#define mp_assert assert
  ------------------
  |  Branch (296:5): [True: 3, False: 0]
  ------------------
  297|      3|    *p_prev = cmd->queue_next;
  298|      3|}
input.c:test_mouse_active:
 1266|  10.5M|{
 1267|  10.5M|    return test_mouse(ictx, x, y, MP_INPUT_ALLOW_HIDE_CURSOR);
 1268|  10.5M|}
input.c:test_mouse:
 1250|  10.5M|{
 1251|  10.5M|    bool res = false;
 1252|  21.0M|    for (int i = 0; i < ictx->num_active_sections; i++) {
  ------------------
  |  Branch (1252:21): [True: 13.3M, False: 7.69M]
  ------------------
 1253|  13.3M|        struct active_section *as = &ictx->active_sections[i];
 1254|  13.3M|        if (as->flags & rej_flags)
  ------------------
  |  Branch (1254:13): [True: 10.5M, False: 2.80M]
  ------------------
 1255|  10.5M|            continue;
 1256|  2.80M|        struct cmd_bind_section *s = get_bind_section(ictx, as->name);
 1257|  2.80M|        if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {
  ------------------
  |  Branch (1257:13): [True: 2.80M, False: 0]
  |  Branch (1257:34): [True: 2.80M, False: 0]
  ------------------
 1258|       |            res = true;
 1259|  2.80M|            break;
 1260|  2.80M|        }
 1261|  2.80M|    }
 1262|  10.5M|    return res;
 1263|  10.5M|}
input.c:queue_cmd:
  326|      3|{
  327|      3|    if (!cmd)
  ------------------
  |  Branch (327:9): [True: 0, False: 3]
  ------------------
  328|      0|        return;
  329|      3|    queue_add_tail(&ictx->cmd_queue, cmd);
  330|      3|    mp_input_wakeup(ictx);
  331|      3|}
input.c:queue_add_tail:
  309|      3|{
  310|      3|    struct mp_cmd **p_prev = &queue->first;
  311|      3|    while (*p_prev)
  ------------------
  |  Branch (311:12): [True: 0, False: 3]
  ------------------
  312|      0|        p_prev = &(*p_prev)->queue_next;
  313|      3|    *p_prev = cmd;
  314|       |    cmd->queue_next = NULL;
  315|      3|}
input.c:adjust_max_wait_time:
 1334|  11.6M|{
 1335|  11.6M|    struct input_opts *opts = ictx->opts;
 1336|  11.6M|    if (ictx->last_key_down && opts->ar_rate > 0 && ictx->ar_state >= 0) {
  ------------------
  |  Branch (1336:9): [True: 1.43M, False: 10.2M]
  |  Branch (1336:32): [True: 1.43M, False: 0]
  |  Branch (1336:53): [True: 0, False: 1.43M]
  ------------------
 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|  11.6M|}
input.c:queue_remove_head:
  301|  11.6M|{
  302|  11.6M|    struct mp_cmd *ret = queue->first;
  303|  11.6M|    if (ret)
  ------------------
  |  Branch (303:9): [True: 3, False: 11.6M]
  ------------------
  304|      3|        queue_remove(queue, ret);
  305|  11.6M|    return ret;
  306|  11.6M|}
input.c:check_autorepeat:
 1353|  11.6M|{
 1354|  11.6M|    struct input_opts *opts = ictx->opts;
 1355|       |
 1356|       |    // No input : autorepeat ?
 1357|  11.6M|    if (opts->ar_rate <= 0 || !ictx->current_down_cmd || !ictx->last_key_down ||
  ------------------
  |  Branch (1357:9): [True: 0, False: 11.6M]
  |  Branch (1357:31): [True: 11.6M, 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|  11.6M|        ictx->ar_state = -1; // disable
 1361|       |
 1362|  11.6M|    if (ictx->ar_state >= 0) {
  ------------------
  |  Branch (1362:9): [True: 0, False: 11.6M]
  ------------------
 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|  11.6M|    return NULL;
 1384|  11.6M|}
input.c:disable_section:
 1432|  14.5k|{
 1433|  14.5k|    name = normalize_section(ictx, name);
 1434|       |
 1435|       |    // Remove old section, or make sure it's on top if re-enabled
 1436|  23.3k|    for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
  ------------------
  |  Branch (1436:49): [True: 8.80k, False: 14.5k]
  ------------------
 1437|  8.80k|        struct active_section *as = &ictx->active_sections[i];
 1438|  8.80k|        if (bstr_equals(as->name, name)) {
  ------------------
  |  Branch (1438:13): [True: 2.29k, False: 6.50k]
  ------------------
 1439|       |            MP_TARRAY_REMOVE_AT(ictx->active_sections,
  ------------------
  |  |  143|  2.29k|    do {                                            \
  |  |  144|  2.29k|        size_t at_ = (at);                          \
  |  |  145|  2.29k|        assert(at_ < (idxvar));                     \
  |  |  146|  2.29k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  2.29k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  2.29k|        (idxvar)--;                                 \
  |  |  149|  2.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 2.29k]
  |  |  ------------------
  ------------------
  |  Branch (1439:13): [True: 2.29k, False: 0]
  ------------------
 1440|  2.29k|                                ictx->num_active_sections, i);
 1441|  2.29k|        }
 1442|  8.80k|    }
 1443|  14.5k|}
input.c:normalize_section:
 1427|  29.0k|{
 1428|  29.0k|    return get_bind_section(ictx, name)->section;
 1429|  29.0k|}
input.c:get_bind_section:
  406|  2.84M|{
  407|  2.84M|    if (section.len == 0)
  ------------------
  |  Branch (407:9): [True: 12.9k, False: 2.82M]
  ------------------
  408|  12.9k|        section = bstr0("default");
  409|  2.84M|    struct cmd_bind_section *bind_section = find_section(ictx, section);
  410|  2.84M|    if (bind_section)
  ------------------
  |  Branch (410:9): [True: 2.82M, False: 12.2k]
  ------------------
  411|  2.82M|        return bind_section;
  412|  12.2k|    bind_section = talloc_ptrtype(ictx, bind_section);
  ------------------
  |  |   34|  12.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  12.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  12.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|  12.2k|    *bind_section = (struct cmd_bind_section) {
  414|  12.2k|        .section = bstrdup(bind_section, section),
  415|  12.2k|        .mouse_area = {INT_MIN, INT_MIN, INT_MAX, INT_MAX},
  416|  12.2k|        .mouse_area_set = true,
  417|  12.2k|    };
  418|  12.2k|    MP_TARRAY_APPEND(ictx, ictx->sections, ictx->num_sections, bind_section);
  ------------------
  |  |  105|  12.2k|    do {                                            \
  |  |  106|  12.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  12.2k|    do {                                            \
  |  |  |  |   97|  12.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  12.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  12.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  12.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.8k, False: 392]
  |  |  |  |  ------------------
  |  |  |  |   99|  12.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.8k|    do {                                                        \
  |  |  |  |  |  |   89|  11.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  12.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 12.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  12.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  12.2k|        (idxvar)++;                                 \
  |  |  109|  12.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 12.2k]
  |  |  ------------------
  ------------------
  419|  12.2k|    return bind_section;
  420|  2.84M|}
input.c:find_section:
  395|  2.84M|{
  396|  5.67M|    for (int n = 0; n < ictx->num_sections; n++) {
  ------------------
  |  Branch (396:21): [True: 5.66M, False: 12.2k]
  ------------------
  397|  5.66M|        struct cmd_bind_section *bs = ictx->sections[n];
  398|  5.66M|        if (bstr_equals(section, bs->section))
  ------------------
  |  Branch (398:13): [True: 2.82M, False: 2.83M]
  ------------------
  399|  2.82M|            return bs;
  400|  5.66M|    }
  401|  12.2k|    return NULL;
  402|  2.84M|}
input.c:remove_binds:
 1508|    136|{
 1509|    136|    for (int n = bs->num_binds - 1; n >= 0; n--) {
  ------------------
  |  Branch (1509:37): [True: 0, False: 136]
  ------------------
 1510|      0|        if (bs->binds[n].is_builtin == builtin) {
  ------------------
  |  Branch (1510:13): [True: 0, False: 0]
  ------------------
 1511|      0|            bind_dealloc(&bs->binds[n]);
 1512|      0|            mp_assert(bs->num_binds >= 1);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1512:13): [True: 0, False: 0]
  ------------------
 1513|      0|            bs->binds[n] = bs->binds[bs->num_binds - 1];
 1514|      0|            bs->num_binds--;
 1515|      0|        }
 1516|      0|    }
 1517|    136|}
input.c:bind_dealloc:
 1500|  1.25k|{
 1501|  1.25k|    talloc_free(bind->cmd);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 1502|  1.25k|    talloc_free(bind->location);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 1503|  1.25k|    talloc_free(bind->desc);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 1504|  1.25k|}
input.c:parse_config:
 1616|    110|{
 1617|    110|    int n_binds = 0;
 1618|    110|    int line_no = 0;
 1619|    110|    char *cur_loc = NULL;
 1620|       |
 1621|    209|    while (data.len) {
  ------------------
  |  Branch (1621:12): [True: 99, False: 110]
  ------------------
 1622|     99|        line_no++;
 1623|     99|        if (cur_loc)
  ------------------
  |  Branch (1623:13): [True: 0, False: 99]
  ------------------
 1624|      0|            talloc_free(cur_loc);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1625|     99|        cur_loc = talloc_asprintf(NULL, "%s:%d", location, line_no);
  ------------------
  |  |   52|     99|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     99|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1626|       |
 1627|     99|        bstr line = bstr_strip_linebreaks(bstr_getline(data, &data));
 1628|     99|        line = bstr_lstrip(line);
 1629|     99|        if (line.len == 0 || bstr_startswith0(line, "#"))
  ------------------
  |  Branch (1629:13): [True: 0, False: 99]
  |  Branch (1629:30): [True: 0, False: 99]
  ------------------
 1630|      0|            continue;
 1631|     99|        if (bstr_eatstart0(&line, "default-bindings ")) {
  ------------------
  |  Branch (1631:13): [True: 0, False: 99]
  ------------------
 1632|      0|            bstr orig = line;
 1633|      0|            bstr_split_tok(line, "#", &line, &(bstr){0});
 1634|      0|            line = bstr_strip(line);
 1635|      0|            if (bstr_equals0(line, "start")) {
  ------------------
  |  Branch (1635:17): [True: 0, False: 0]
  ------------------
 1636|      0|                builtin = true;
 1637|      0|            } else {
 1638|      0|                MP_ERR(ictx, "Broken line: %.*s at %s\n", BSTR_P(orig), cur_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__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1639|      0|            }
 1640|      0|            continue;
 1641|      0|        }
 1642|     99|        struct bstr command;
 1643|       |        // Find the key name starting a line
 1644|     99|        struct bstr keyname = bstr_split(line, WHITESPACE, &command);
  ------------------
  |  |  309|     99|#define WHITESPACE " \f\n\r\t\v"
  ------------------
 1645|     99|        command = bstr_strip(command);
 1646|     99|        if (command.len == 0) {
  ------------------
  |  Branch (1646:13): [True: 99, False: 0]
  ------------------
 1647|     99|            MP_ERR(ictx, "Unfinished key binding: %.*s at %s\n", BSTR_P(line),
  ------------------
  |  |   89|     99|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    198|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 99, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1648|     99|                   cur_loc);
 1649|     99|            continue;
 1650|     99|        }
 1651|      0|        char *name = bstrdup0(NULL, keyname);
 1652|      0|        int keys[MP_MAX_KEY_DOWN];
 1653|      0|        int num_keys = 0;
 1654|      0|        if (!mp_input_get_keys_from_string(name, MP_MAX_KEY_DOWN, &num_keys, keys)) {
  ------------------
  |  |   61|      0|#define MP_MAX_KEY_DOWN 16
  ------------------
  |  Branch (1654:13): [True: 0, False: 0]
  ------------------
 1655|      0|            talloc_free(name);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1656|      0|            MP_ERR(ictx, "Unknown key '%.*s' at %s\n", BSTR_P(keyname), cur_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__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1657|      0|            continue;
 1658|      0|        }
 1659|      0|        talloc_free(name);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1660|       |
 1661|      0|        bstr section = restrict_section;
 1662|      0|        if (!section.len) {
  ------------------
  |  Branch (1662:13): [True: 0, False: 0]
  ------------------
 1663|      0|            if (bstr_startswith0(command, "{")) {
  ------------------
  |  Branch (1663:17): [True: 0, False: 0]
  ------------------
 1664|      0|                int p = bstrchr(command, '}');
 1665|      0|                if (p != -1) {
  ------------------
  |  Branch (1665:21): [True: 0, False: 0]
  ------------------
 1666|      0|                    section = bstr_strip(bstr_splice(command, 1, p));
 1667|      0|                    command = bstr_lstrip(bstr_cut(command, p + 1));
 1668|      0|                }
 1669|      0|            }
 1670|      0|        }
 1671|       |
 1672|       |        // Print warnings if invalid commands are encountered.
 1673|      0|        struct mp_cmd *cmd = mp_input_parse_cmd(ictx, command, cur_loc);
 1674|      0|        const char *desc = NULL;
 1675|      0|        if (cmd) {
  ------------------
  |  Branch (1675:13): [True: 0, False: 0]
  ------------------
 1676|      0|            desc = cmd->desc;
 1677|      0|            command = bstr0(cmd->original);
 1678|      0|        }
 1679|       |
 1680|      0|        bind_keys(ictx, builtin, section, keys, num_keys, command, cur_loc, desc);
 1681|      0|        n_binds++;
 1682|       |
 1683|      0|        talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1684|      0|    }
 1685|       |
 1686|    110|    talloc_free(cur_loc);
  ------------------
  |  |   47|    110|#define talloc_free                     ta_free
  ------------------
 1687|       |
 1688|    110|    return n_binds;
 1689|    110|}
input.c:reload_opts:
 1745|  35.0k|{
 1746|  35.0k|    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|  35.0k|}
input.c:parse_config_file:
 1692|     23|{
 1693|     23|    bool r = false;
 1694|     23|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|     23|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|     23|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1695|       |
 1696|     23|    file = mp_get_user_path(tmp, ictx->global, file);
 1697|       |
 1698|     23|    bstr data = stream_read_file2(file, tmp, STREAM_ORIGIN_DIRECT | STREAM_READ,
  ------------------
  |  |   47|     23|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
                  bstr data = stream_read_file2(file, tmp, STREAM_ORIGIN_DIRECT | STREAM_READ,
  ------------------
  |  |   41|     23|#define STREAM_READ               0
  ------------------
 1699|     23|                                  ictx->global, 1000000);
 1700|     23|    if (data.start) {
  ------------------
  |  Branch (1700:9): [True: 14, False: 9]
  ------------------
 1701|     14|        MP_VERBOSE(ictx, "Parsing input config file %s\n", file);
  ------------------
  |  |   92|     14|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     14|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1702|     14|        bstr_eatstart0(&data, "\xEF\xBB\xBF"); // skip BOM
 1703|     14|        int num = parse_config(ictx, false, data, file, (bstr){0});
 1704|     14|        MP_VERBOSE(ictx, "Input config file %s parsed: %d binds\n", file, num);
  ------------------
  |  |   92|     14|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     14|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1705|     14|        r = true;
 1706|     14|    } else {
 1707|      9|        MP_ERR(ictx, "Error reading input config file %s\n", file);
  ------------------
  |  |   89|      9|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      9|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1708|      9|    }
 1709|       |
 1710|     23|    talloc_free(tmp);
  ------------------
  |  |   47|     23|#define talloc_free                     ta_free
  ------------------
 1711|     23|    return r;
 1712|     23|}
input.c:clear_queue:
 1817|  11.6k|{
 1818|  11.6k|    while (queue->first) {
  ------------------
  |  Branch (1818:12): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|}
input.c:bind_keys:
 1572|  1.25k|{
 1573|  1.25k|    struct cmd_bind_section *bs = get_bind_section(ictx, section);
 1574|  1.25k|    struct cmd_bind *bind = NULL;
 1575|       |
 1576|  1.25k|    mp_assert(num_keys <= MP_MAX_KEY_DOWN);
  ------------------
  |  |   41|  1.25k|#define mp_assert assert
  ------------------
  |  Branch (1576:5): [True: 1.25k, False: 0]
  ------------------
 1577|       |
 1578|  3.30k|    for (int n = 0; n < bs->num_binds; n++) {
  ------------------
  |  Branch (1578:21): [True: 3.06k, False: 245]
  ------------------
 1579|  3.06k|        struct cmd_bind *b = &bs->binds[n];
 1580|  3.06k|        if (bind_matches_key(b, num_keys, keys) && b->is_builtin == builtin) {
  ------------------
  |  Branch (1580:13): [True: 1.00k, False: 2.05k]
  |  Branch (1580:52): [True: 1.00k, False: 0]
  ------------------
 1581|  1.00k|            bind = b;
 1582|  1.00k|            break;
 1583|  1.00k|        }
 1584|  3.06k|    }
 1585|       |
 1586|  1.25k|    if (!bind) {
  ------------------
  |  Branch (1586:9): [True: 245, False: 1.00k]
  ------------------
 1587|    245|        struct cmd_bind empty = {{0}};
 1588|    245|        MP_TARRAY_APPEND(bs, bs->binds, bs->num_binds, empty);
  ------------------
  |  |  105|    245|    do {                                            \
  |  |  106|    245|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    245|    do {                                            \
  |  |  |  |   97|    245|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    245|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    245|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    245|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 150, False: 95]
  |  |  |  |  ------------------
  |  |  |  |   99|    245|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    150|    do {                                                        \
  |  |  |  |  |  |   89|    150|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    150|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    150|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    150|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    150|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    150|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    150|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 150]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    245|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 245]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    245|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    245|        (idxvar)++;                                 \
  |  |  109|    245|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 245]
  |  |  ------------------
  ------------------
 1589|    245|        bind = &bs->binds[bs->num_binds - 1];
 1590|    245|    }
 1591|       |
 1592|  1.25k|    bind_dealloc(bind);
 1593|       |
 1594|  1.25k|    *bind = (struct cmd_bind) {
 1595|  1.25k|        .cmd = bstrdup0(bs->binds, command),
 1596|  1.25k|        .location = talloc_strdup(bs->binds, loc),
  ------------------
  |  |   50|  1.25k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1597|  1.25k|        .desc = talloc_strdup(bs->binds, desc),
  ------------------
  |  |   50|  1.25k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1598|  1.25k|        .owner = bs,
 1599|  1.25k|        .is_builtin = builtin,
 1600|  1.25k|        .num_keys = num_keys,
 1601|  1.25k|    };
 1602|  1.25k|    memcpy(bind->keys, keys, num_keys * sizeof(bind->keys[0]));
 1603|  1.25k|    if (mp_msg_test(ictx->log, MSGL_DEBUG)) {
  ------------------
  |  Branch (1603:9): [True: 1.25k, False: 0]
  ------------------
 1604|  1.25k|        char *s = mp_input_get_key_combo_name(keys, num_keys);
 1605|  1.25k|        MP_TRACE(ictx, "add: section='%.*s' key='%s'%s cmd='%s' location='%s'\n",
  ------------------
  |  |   94|  1.25k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.00k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 1.25k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1606|  1.25k|                 BSTR_P(bind->owner->section), s, bind->is_builtin ? " builtin" : "",
 1607|  1.25k|                 bind->cmd, bind->location);
 1608|  1.25k|        talloc_free(s);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 1609|  1.25k|    }
 1610|  1.25k|}
input.c:bind_matches_key:
 1559|  3.06k|{
 1560|  3.06k|    if (bind->num_keys != num_keys)
  ------------------
  |  Branch (1560:9): [True: 1.59k, False: 1.47k]
  ------------------
 1561|  1.59k|        return false;
 1562|  5.06k|    for (int i = 0; i < num_keys; i++) {
  ------------------
  |  Branch (1562:21): [True: 4.06k, False: 1.00k]
  ------------------
 1563|  4.06k|        if (bind->keys[i] != keys[i])
  ------------------
  |  Branch (1563:13): [True: 464, False: 3.59k]
  ------------------
 1564|    464|            return false;
 1565|  4.06k|    }
 1566|  1.00k|    return true;
 1567|  1.47k|}
input.c:close_input_sources:
 1976|  11.6k|{
 1977|       |    // To avoid lock-order issues, we first remove each source from the context,
 1978|       |    // and then destroy it.
 1979|  11.6k|    while (1) {
  ------------------
  |  Branch (1979:12): [True: 11.6k, Folded]
  ------------------
 1980|  11.6k|        input_lock(ictx);
  ------------------
  |  |   58|  11.6k|#define input_lock(ictx)    mp_mutex_lock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  |  |  ------------------
  ------------------
 1981|  11.6k|        struct mp_input_src *src = ictx->num_sources ? ictx->sources[0] : NULL;
  ------------------
  |  Branch (1981:36): [True: 0, False: 11.6k]
  ------------------
 1982|  11.6k|        input_unlock(ictx);
  ------------------
  |  |   59|  11.6k|#define input_unlock(ictx)  mp_mutex_unlock(&ictx->mutex)
  |  |  ------------------
  |  |  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  |  |  ------------------
  ------------------
 1983|  11.6k|        if (!src)
  ------------------
  |  Branch (1983:13): [True: 11.6k, False: 0]
  ------------------
 1984|  11.6k|            break;
 1985|      0|        input_src_kill(src);
 1986|      0|    }
 1987|  11.6k|}

mp_init_ipc:
  408|  11.6k|{
  409|  11.6k|    struct MPOpts *opts = mp_get_config_group(NULL, global, &mp_opt_root);
  410|       |
  411|  11.6k|    struct mp_ipc_ctx *arg = talloc_ptrtype(NULL, arg);
  ------------------
  |  |   34|  11.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  11.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|  11.6k|    *arg = (struct mp_ipc_ctx){
  413|  11.6k|        .log        = mp_log_new(arg, global->log, "ipc"),
  414|  11.6k|        .client_api = client_api,
  415|  11.6k|        .path       = mp_get_user_path(arg, global, opts->ipc_path),
  416|  11.6k|        .death_pipe = {-1, -1},
  417|  11.6k|    };
  418|       |
  419|  11.6k|    if (opts->ipc_client && opts->ipc_client[0]) {
  ------------------
  |  Branch (419:9): [True: 0, False: 11.6k]
  |  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|  11.6k|    talloc_free(opts);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  436|       |
  437|  11.6k|    if (!arg->path || !arg->path[0])
  ------------------
  |  Branch (437:9): [True: 11.6k, False: 0]
  |  Branch (437:23): [True: 0, False: 0]
  ------------------
  438|  11.6k|        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|  11.6k|out:
  449|  11.6k|    if (arg->death_pipe[0] >= 0) {
  ------------------
  |  Branch (449:9): [True: 0, False: 11.6k]
  ------------------
  450|      0|        close(arg->death_pipe[0]);
  451|      0|        close(arg->death_pipe[1]);
  452|      0|    }
  453|  11.6k|    talloc_free(arg);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  454|       |    return NULL;
  455|      0|}
mp_uninit_ipc:
  458|  11.6k|{
  459|  11.6k|    if (!arg)
  ------------------
  |  Branch (459:9): [True: 11.6k, False: 0]
  ------------------
  460|  11.6k|        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|}

mp_json_encode_event:
   93|  5.57M|{
   94|  5.57M|    void *ta_parent = talloc_new(NULL);
  ------------------
  |  |   40|  5.57M|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  5.57M|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   95|       |
   96|  5.57M|    struct mpv_node event_node;
   97|  5.57M|    if (event->event_id == MPV_EVENT_COMMAND_REPLY) {
  ------------------
  |  Branch (97:9): [True: 0, False: 5.57M]
  ------------------
   98|      0|        event_node = (mpv_node){.format = MPV_FORMAT_NODE_MAP, .u.list = NULL};
   99|      0|        mpv_format_command_reply(ta_parent, event, &event_node);
  100|  5.57M|    } else {
  101|  5.57M|        mpv_event_to_node(&event_node, event);
  102|       |        // Abuse mpv_event_to_node() internals.
  103|  5.57M|        talloc_steal(ta_parent, node_get_alloc(&event_node));
  ------------------
  |  |   38|  5.57M|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  5.57M|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  104|  5.57M|    }
  105|       |
  106|  5.57M|    char *output = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  5.57M|#define talloc_strdup                   ta_xstrdup
  ------------------
  107|  5.57M|    json_write(&output, &event_node);
  108|  5.57M|    output = ta_talloc_strdup_append(output, "\n");
  109|       |
  110|  5.57M|    talloc_free(ta_parent);
  ------------------
  |  |   47|  5.57M|#define talloc_free                     ta_free
  ------------------
  111|       |
  112|  5.57M|    return output;
  113|  5.57M|}
mp_ipc_consume_next_command:
  393|  6.03M|{
  394|  6.03M|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  6.03M|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  6.03M|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  395|       |
  396|  6.03M|    bstr rest;
  397|  6.03M|    bstr line = bstr_getline(*buf, &rest);
  398|  6.03M|    char *line0 = bstrto0(tmp, line);
  399|  6.03M|    talloc_steal(tmp, buf->start);
  ------------------
  |  |   38|  6.03M|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  6.03M|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  400|  6.03M|    *buf = bstrdup(NULL, rest);
  401|       |
  402|  6.03M|    json_skip_whitespace(&line0);
  403|       |
  404|  6.03M|    char *reply_msg = NULL;
  405|  6.03M|    if (line0[0] == '\0' || line0[0] == '#') {
  ------------------
  |  Branch (405:9): [True: 2.76M, False: 3.27M]
  |  Branch (405:29): [True: 25.1k, False: 3.24M]
  ------------------
  406|       |        // skip
  407|  3.24M|    } else if (line0[0] == '{') {
  ------------------
  |  Branch (407:16): [True: 478k, False: 2.76M]
  ------------------
  408|   478k|        reply_msg = json_execute_command(client, tmp, line0);
  409|  2.76M|    } else {
  410|  2.76M|        reply_msg = text_execute_command(client, tmp, line0);
  411|  2.76M|    }
  412|       |
  413|  6.03M|    talloc_steal(ctx, reply_msg);
  ------------------
  |  |   38|  6.03M|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  6.03M|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  414|  6.03M|    talloc_free(tmp);
  ------------------
  |  |   47|  6.03M|#define talloc_free                     ta_free
  ------------------
  415|  6.03M|    return reply_msg;
  416|  6.03M|}
ipc.c:mpv_node_map_add_int64:
   66|   478k|{
   67|   478k|    mpv_node val_node = {.format = MPV_FORMAT_INT64, .u.int64 = val};
   68|   478k|    mpv_node_map_add(ta_parent, src, key, &val_node);
   69|   478k|}
ipc.c:mpv_node_map_add_string:
   72|   478k|{
   73|   478k|    mpv_node val_node = {.format = MPV_FORMAT_STRING, .u.string = (char*)val};
   74|   478k|    mpv_node_map_add(ta_parent, src, key, &val_node);
   75|   478k|}
ipc.c:mpv_node_map_add:
   41|   957k|{
   42|   957k|    if (src->format != MPV_FORMAT_NODE_MAP)
  ------------------
  |  Branch (42:9): [True: 0, False: 957k]
  ------------------
   43|      0|        return;
   44|       |
   45|   957k|    if (!src->u.list)
  ------------------
  |  Branch (45:9): [True: 478k, False: 478k]
  ------------------
   46|   478k|        src->u.list = talloc_zero(ta_parent, mpv_node_list);
  ------------------
  |  |   27|   478k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   478k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   478k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   47|       |
   48|   957k|    MP_TARRAY_GROW(src->u.list, src->u.list->keys, src->u.list->num);
  ------------------
  |  |   96|   957k|    do {                                            \
  |  |   97|   957k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   957k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   957k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   957k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 478k, False: 478k]
  |  |  ------------------
  |  |   99|   957k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   478k|    do {                                                        \
  |  |  |  |   89|   478k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   478k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   478k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   478k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   478k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   478k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   478k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 478k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   957k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 957k]
  |  |  ------------------
  ------------------
   49|   957k|    MP_TARRAY_GROW(src->u.list, src->u.list->values, src->u.list->num);
  ------------------
  |  |   96|   957k|    do {                                            \
  |  |   97|   957k|        size_t nextidx_ = (nextidx);                \
  |  |   98|   957k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|   957k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|   957k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 478k, False: 478k]
  |  |  ------------------
  |  |   99|   957k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   478k|    do {                                                        \
  |  |  |  |   89|   478k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   478k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   478k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   478k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   478k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   478k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   478k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 478k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|   957k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 957k]
  |  |  ------------------
  ------------------
   50|       |
   51|   957k|    src->u.list->keys[src->u.list->num] = talloc_strdup(ta_parent, key);
  ------------------
  |  |   50|   957k|#define talloc_strdup                   ta_xstrdup
  ------------------
   52|       |
   53|   957k|    static const struct m_option type = { .type = CONF_TYPE_NODE };
  ------------------
  |  |  253|   957k|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
   54|   957k|    m_option_get_node(&type, ta_parent, &src->u.list->values[src->u.list->num], val);
   55|       |
   56|   957k|    src->u.list->num++;
   57|   957k|}
ipc.c:json_execute_command:
  118|   478k|{
  119|   478k|    int rc;
  120|   478k|    const char *cmd = NULL;
  121|   478k|    struct mp_log *log = mp_client_get_log(client);
  122|       |
  123|   478k|    mpv_node msg_node;
  124|   478k|    mpv_node reply_node = {.format = MPV_FORMAT_NODE_MAP, .u.list = NULL};
  125|   478k|    mpv_node *reqid_node = NULL;
  126|   478k|    int64_t reqid = 0;
  127|   478k|    mpv_node *async_node = NULL;
  128|   478k|    bool async = false;
  129|   478k|    bool send_reply = true;
  130|       |
  131|   478k|    rc = json_parse(ta_parent, &msg_node, &src, MAX_JSON_DEPTH);
  ------------------
  |  |   21|   478k|#define MAX_JSON_DEPTH 50
  ------------------
  132|   478k|    if (rc < 0) {
  ------------------
  |  Branch (132:9): [True: 476k, False: 2.16k]
  ------------------
  133|   476k|        mp_err(log, "malformed JSON received: '%s'\n", src);
  ------------------
  |  |   76|   476k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  134|   476k|        rc = MPV_ERROR_INVALID_PARAMETER;
  135|   476k|        goto error;
  136|   476k|    }
  137|       |
  138|  2.16k|    if (msg_node.format != MPV_FORMAT_NODE_MAP) {
  ------------------
  |  Branch (138:9): [True: 0, False: 2.16k]
  ------------------
  139|      0|        rc = MPV_ERROR_INVALID_PARAMETER;
  140|      0|        goto error;
  141|      0|    }
  142|       |
  143|  2.16k|    async_node = node_map_get(&msg_node, "async");
  144|  2.16k|    if (async_node) {
  ------------------
  |  Branch (144:9): [True: 0, False: 2.16k]
  ------------------
  145|      0|        if (async_node->format != MPV_FORMAT_FLAG) {
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  147|      0|            goto error;
  148|      0|        }
  149|      0|        async = async_node->u.flag;
  150|      0|    }
  151|       |
  152|  2.16k|    reqid_node = node_map_get(&msg_node, "request_id");
  153|  2.16k|    if (reqid_node) {
  ------------------
  |  Branch (153:9): [True: 0, False: 2.16k]
  ------------------
  154|      0|        if (reqid_node->format == MPV_FORMAT_INT64) {
  ------------------
  |  Branch (154:13): [True: 0, False: 0]
  ------------------
  155|      0|            reqid = reqid_node->u.int64;
  156|      0|        } else if (async) {
  ------------------
  |  Branch (156:20): [True: 0, False: 0]
  ------------------
  157|      0|            mp_err(log, "'request_id' must be an integer for async commands.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  158|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  159|      0|            goto error;
  160|      0|        } else {
  161|      0|            mp_warn(log, "'request_id' must be an integer. Using other types is "
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
  162|      0|                    "deprecated and will trigger an error in the future!\n");
  163|      0|        }
  164|      0|    }
  165|       |
  166|  2.16k|    mpv_node *cmd_node = node_map_get(&msg_node, "command");
  167|  2.16k|    if (!cmd_node) {
  ------------------
  |  Branch (167:9): [True: 2.16k, False: 0]
  ------------------
  168|  2.16k|        rc = MPV_ERROR_INVALID_PARAMETER;
  169|  2.16k|        goto error;
  170|  2.16k|    }
  171|       |
  172|      0|    if (cmd_node->format == MPV_FORMAT_NODE_ARRAY) {
  ------------------
  |  Branch (172:9): [True: 0, False: 0]
  ------------------
  173|      0|        mpv_node *cmd_str_node = mpv_node_array_get(cmd_node, 0);
  174|      0|        if (!cmd_str_node || (cmd_str_node->format != MPV_FORMAT_STRING)) {
  ------------------
  |  Branch (174:13): [True: 0, False: 0]
  |  Branch (174:30): [True: 0, False: 0]
  ------------------
  175|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  176|      0|            goto error;
  177|      0|        }
  178|       |
  179|      0|        cmd = cmd_str_node->u.string;
  180|      0|    }
  181|       |
  182|      0|    if (cmd && !strcmp("client_name", cmd)) {
  ------------------
  |  Branch (182:9): [True: 0, False: 0]
  |  Branch (182:16): [True: 0, False: 0]
  ------------------
  183|      0|        const char *client_name = mpv_client_name(client);
  184|      0|        mpv_node_map_add_string(ta_parent, &reply_node, "data", client_name);
  185|      0|        rc = MPV_ERROR_SUCCESS;
  186|      0|    } else if (cmd && !strcmp("get_time_us", cmd)) {
  ------------------
  |  Branch (186:16): [True: 0, False: 0]
  |  Branch (186:23): [True: 0, False: 0]
  ------------------
  187|      0|        int64_t time_us = mpv_get_time_us(client);
  188|      0|        mpv_node_map_add_int64(ta_parent, &reply_node, "data", time_us);
  189|      0|        rc = MPV_ERROR_SUCCESS;
  190|      0|    } else if (cmd && !strcmp("get_version", cmd)) {
  ------------------
  |  Branch (190:16): [True: 0, False: 0]
  |  Branch (190:23): [True: 0, False: 0]
  ------------------
  191|      0|        int64_t ver = mpv_client_api_version();
  192|      0|        mpv_node_map_add_int64(ta_parent, &reply_node, "data", ver);
  193|      0|        rc = MPV_ERROR_SUCCESS;
  194|      0|    } else if (cmd && !strcmp("get_property", cmd)) {
  ------------------
  |  Branch (194:16): [True: 0, False: 0]
  |  Branch (194:23): [True: 0, False: 0]
  ------------------
  195|      0|        mpv_node result_node;
  196|       |
  197|      0|        if (cmd_node->u.list->num != 2) {
  ------------------
  |  Branch (197:13): [True: 0, False: 0]
  ------------------
  198|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  199|      0|            goto error;
  200|      0|        }
  201|       |
  202|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  ------------------
  203|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  204|      0|            goto error;
  205|      0|        }
  206|       |
  207|      0|        rc = mpv_get_property(client, cmd_node->u.list->values[1].u.string,
  208|      0|                              MPV_FORMAT_NODE, &result_node);
  209|      0|        if (rc >= 0) {
  ------------------
  |  Branch (209:13): [True: 0, False: 0]
  ------------------
  210|      0|            mpv_node_map_add(ta_parent, &reply_node, "data", &result_node);
  211|      0|            mpv_free_node_contents(&result_node);
  212|      0|        }
  213|      0|    } else if (cmd && !strcmp("get_property_string", cmd)) {
  ------------------
  |  Branch (213:16): [True: 0, False: 0]
  |  Branch (213:23): [True: 0, False: 0]
  ------------------
  214|      0|        if (cmd_node->u.list->num != 2) {
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  216|      0|            goto error;
  217|      0|        }
  218|       |
  219|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  221|      0|            goto error;
  222|      0|        }
  223|       |
  224|      0|        char *result = mpv_get_property_string(client,
  225|      0|                                        cmd_node->u.list->values[1].u.string);
  226|      0|        if (result) {
  ------------------
  |  Branch (226:13): [True: 0, False: 0]
  ------------------
  227|      0|            mpv_node_map_add_string(ta_parent, &reply_node, "data", result);
  228|      0|            mpv_free(result);
  229|      0|        } else {
  230|      0|            mpv_node_map_add_null(ta_parent, &reply_node, "data");
  231|      0|        }
  232|      0|    } else if (cmd && (!strcmp("set_property", cmd) ||
  ------------------
  |  Branch (232:16): [True: 0, False: 0]
  |  Branch (232:24): [True: 0, False: 0]
  ------------------
  233|      0|                       !strcmp("set_property_string", cmd)))
  ------------------
  |  Branch (233:24): [True: 0, False: 0]
  ------------------
  234|      0|    {
  235|      0|        if (cmd_node->u.list->num != 3) {
  ------------------
  |  Branch (235:13): [True: 0, False: 0]
  ------------------
  236|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  237|      0|            goto error;
  238|      0|        }
  239|       |
  240|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (240:13): [True: 0, False: 0]
  ------------------
  241|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  242|      0|            goto error;
  243|      0|        }
  244|       |
  245|      0|        rc = mpv_set_property(client, cmd_node->u.list->values[1].u.string,
  246|      0|                              MPV_FORMAT_NODE, &cmd_node->u.list->values[2]);
  247|      0|    } else if (cmd && !strcmp("observe_property", cmd)) {
  ------------------
  |  Branch (247:16): [True: 0, False: 0]
  |  Branch (247:23): [True: 0, False: 0]
  ------------------
  248|      0|        if (cmd_node->u.list->num != 3) {
  ------------------
  |  Branch (248:13): [True: 0, False: 0]
  ------------------
  249|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  250|      0|            goto error;
  251|      0|        }
  252|       |
  253|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_INT64) {
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  ------------------
  254|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  255|      0|            goto error;
  256|      0|        }
  257|       |
  258|      0|        if (cmd_node->u.list->values[2].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (258:13): [True: 0, False: 0]
  ------------------
  259|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  260|      0|            goto error;
  261|      0|        }
  262|       |
  263|      0|        rc = mpv_observe_property(client,
  264|      0|                                  cmd_node->u.list->values[1].u.int64,
  265|      0|                                  cmd_node->u.list->values[2].u.string,
  266|      0|                                  MPV_FORMAT_NODE);
  267|      0|    } else if (cmd && !strcmp("observe_property_string", cmd)) {
  ------------------
  |  Branch (267:16): [True: 0, False: 0]
  |  Branch (267:23): [True: 0, False: 0]
  ------------------
  268|      0|        if (cmd_node->u.list->num != 3) {
  ------------------
  |  Branch (268:13): [True: 0, False: 0]
  ------------------
  269|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  270|      0|            goto error;
  271|      0|        }
  272|       |
  273|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_INT64) {
  ------------------
  |  Branch (273:13): [True: 0, False: 0]
  ------------------
  274|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  275|      0|            goto error;
  276|      0|        }
  277|       |
  278|      0|        if (cmd_node->u.list->values[2].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (278:13): [True: 0, False: 0]
  ------------------
  279|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  280|      0|            goto error;
  281|      0|        }
  282|       |
  283|      0|        rc = mpv_observe_property(client,
  284|      0|                                  cmd_node->u.list->values[1].u.int64,
  285|      0|                                  cmd_node->u.list->values[2].u.string,
  286|      0|                                  MPV_FORMAT_STRING);
  287|      0|    } else if (cmd && !strcmp("unobserve_property", cmd)) {
  ------------------
  |  Branch (287:16): [True: 0, False: 0]
  |  Branch (287:23): [True: 0, False: 0]
  ------------------
  288|      0|        if (cmd_node->u.list->num != 2) {
  ------------------
  |  Branch (288:13): [True: 0, False: 0]
  ------------------
  289|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  290|      0|            goto error;
  291|      0|        }
  292|       |
  293|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_INT64) {
  ------------------
  |  Branch (293:13): [True: 0, False: 0]
  ------------------
  294|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  295|      0|            goto error;
  296|      0|        }
  297|       |
  298|      0|        rc = mpv_unobserve_property(client,
  299|      0|                                    cmd_node->u.list->values[1].u.int64);
  300|      0|    } else if (cmd && !strcmp("request_log_messages", cmd)) {
  ------------------
  |  Branch (300:16): [True: 0, False: 0]
  |  Branch (300:23): [True: 0, False: 0]
  ------------------
  301|      0|        if (cmd_node->u.list->num != 2) {
  ------------------
  |  Branch (301:13): [True: 0, False: 0]
  ------------------
  302|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  303|      0|            goto error;
  304|      0|        }
  305|       |
  306|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (306:13): [True: 0, False: 0]
  ------------------
  307|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  308|      0|            goto error;
  309|      0|        }
  310|       |
  311|      0|        rc = mpv_request_log_messages(client,
  312|      0|                                      cmd_node->u.list->values[1].u.string);
  313|      0|    } else if (cmd && (!strcmp("enable_event", cmd) ||
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  |  Branch (313:24): [True: 0, False: 0]
  ------------------
  314|      0|                       !strcmp("disable_event", cmd)))
  ------------------
  |  Branch (314:24): [True: 0, False: 0]
  ------------------
  315|      0|    {
  316|      0|        bool enable = !strcmp("enable_event", cmd);
  317|       |
  318|      0|        if (cmd_node->u.list->num != 2) {
  ------------------
  |  Branch (318:13): [True: 0, False: 0]
  ------------------
  319|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  320|      0|            goto error;
  321|      0|        }
  322|       |
  323|      0|        if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
  ------------------
  |  Branch (323:13): [True: 0, False: 0]
  ------------------
  324|      0|            rc = MPV_ERROR_INVALID_PARAMETER;
  325|      0|            goto error;
  326|      0|        }
  327|       |
  328|      0|        char *name = cmd_node->u.list->values[1].u.string;
  329|      0|        if (strcmp(name, "all") == 0) {
  ------------------
  |  Branch (329:13): [True: 0, False: 0]
  ------------------
  330|      0|            for (int n = 0; n < 64; n++)
  ------------------
  |  Branch (330:29): [True: 0, False: 0]
  ------------------
  331|      0|                mpv_request_event(client, n, enable);
  332|      0|            rc = MPV_ERROR_SUCCESS;
  333|      0|        } else {
  334|      0|            int event = -1;
  335|      0|            for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (335:29): [True: 0, False: 0]
  ------------------
  336|      0|                const char *evname = mpv_event_name(n);
  337|      0|                if (evname && strcmp(evname, name) == 0)
  ------------------
  |  Branch (337:21): [True: 0, False: 0]
  |  Branch (337:31): [True: 0, False: 0]
  ------------------
  338|      0|                    event = n;
  339|      0|            }
  340|      0|            if (event < 0) {
  ------------------
  |  Branch (340:17): [True: 0, False: 0]
  ------------------
  341|      0|                rc = MPV_ERROR_INVALID_PARAMETER;
  342|      0|                goto error;
  343|      0|            }
  344|      0|            rc = mpv_request_event(client, event, enable);
  345|      0|        }
  346|      0|    } else {
  347|      0|        mpv_node result_node = {0};
  348|       |
  349|      0|        if (async) {
  ------------------
  |  Branch (349:13): [True: 0, False: 0]
  ------------------
  350|      0|            rc = mpv_command_node_async(client, reqid, cmd_node);
  351|      0|            if (rc >= 0)
  ------------------
  |  Branch (351:17): [True: 0, False: 0]
  ------------------
  352|      0|                send_reply = false;
  353|      0|        } else {
  354|      0|            rc = mpv_command_node(client, cmd_node, &result_node);
  355|      0|            if (rc >= 0)
  ------------------
  |  Branch (355:17): [True: 0, False: 0]
  ------------------
  356|      0|                mpv_node_map_add(ta_parent, &reply_node, "data", &result_node);
  357|      0|        }
  358|       |
  359|      0|        mpv_free_node_contents(&result_node);
  360|      0|    }
  361|       |
  362|   478k|error:
  363|       |    /* If the request contains a "request_id", copy it back into the response.
  364|       |     * This makes it easier on the requester to match up the IPC results with
  365|       |     * the original requests.
  366|       |     */
  367|   478k|    if (reqid_node) {
  ------------------
  |  Branch (367:9): [True: 0, False: 478k]
  ------------------
  368|      0|        mpv_node_map_add(ta_parent, &reply_node, "request_id", reqid_node);
  369|   478k|    } else {
  370|   478k|        mpv_node_map_add_int64(ta_parent, &reply_node, "request_id", 0);
  371|   478k|    }
  372|       |
  373|   478k|    mpv_node_map_add_string(ta_parent, &reply_node, "error", mpv_error_string(rc));
  374|       |
  375|   478k|    char *output = talloc_strdup(ta_parent, "");
  ------------------
  |  |   50|   478k|#define talloc_strdup                   ta_xstrdup
  ------------------
  376|       |
  377|   478k|    if (send_reply) {
  ------------------
  |  Branch (377:9): [True: 478k, False: 0]
  ------------------
  378|   478k|        json_write(&output, &reply_node);
  379|   478k|        output = ta_talloc_strdup_append(output, "\n");
  380|   478k|    }
  381|       |
  382|   478k|    return output;
  383|      0|}
ipc.c:text_execute_command:
  386|  2.76M|{
  387|  2.76M|    mpv_command_string(client, src);
  388|       |
  389|       |    return NULL;
  390|  2.76M|}

mp_input_get_key_from_name:
  247|  25.7k|{
  248|  25.7k|    int modifiers = 0;
  249|  25.7k|    const char *p;
  250|  25.7k|    while ((p = strchr(name, '+'))) {
  ------------------
  |  Branch (250:12): [True: 210, False: 25.5k]
  ------------------
  251|  1.05k|        for (const struct key_name *m = modifier_names; m->name; m++)
  ------------------
  |  Branch (251:57): [True: 840, False: 210]
  ------------------
  252|    840|            if (!bstrcasecmp(bstr0(m->name),
  ------------------
  |  Branch (252:17): [True: 0, False: 840]
  ------------------
  253|    840|                             (struct bstr){(char *)name, p - name})) {
  254|      0|                modifiers |= m->key;
  255|      0|                goto found;
  256|      0|            }
  257|    210|        if (!strcmp(name, "+"))
  ------------------
  |  Branch (257:13): [True: 184, False: 26]
  ------------------
  258|    184|            return '+' + modifiers;
  259|     26|        return -1;
  260|      0|found:
  261|      0|        name = p + 1;
  262|      0|    }
  263|       |
  264|  25.5k|    struct bstr bname = bstr0(name);
  265|       |
  266|  25.5k|    struct bstr rest;
  267|  25.5k|    int code = bstr_decode_utf8(bname, &rest);
  268|  25.5k|    if (code >= 0 && rest.len == 0)
  ------------------
  |  Branch (268:9): [True: 24.9k, False: 644]
  |  Branch (268:22): [True: 23.9k, False: 955]
  ------------------
  269|  23.9k|        return mp_normalize_keycode(code + modifiers);
  270|       |
  271|  1.59k|    if (bstr_startswith0(bname, "0x")) {
  ------------------
  |  Branch (271:9): [True: 0, False: 1.59k]
  ------------------
  272|      0|        char *end;
  273|      0|        long long val = strtoll(name, &end, 16);
  274|      0|        if (name == end || val > INT_MAX || val < INT_MIN)
  ------------------
  |  Branch (274:13): [True: 0, False: 0]
  |  Branch (274:28): [True: 0, False: 0]
  |  Branch (274:45): [True: 0, False: 0]
  ------------------
  275|      0|            return -1;
  276|      0|        long long keycode = val + modifiers;
  277|      0|        if (keycode > INT_MAX || keycode < INT_MIN)
  ------------------
  |  Branch (277:13): [True: 0, False: 0]
  |  Branch (277:34): [True: 0, False: 0]
  ------------------
  278|      0|            return -1;
  279|      0|        return mp_normalize_keycode(keycode);
  280|      0|    }
  281|       |
  282|   288k|    for (int i = 0; key_names[i].name != NULL; i++) {
  ------------------
  |  Branch (282:21): [True: 287k, False: 1.40k]
  ------------------
  283|   287k|        if (strcasecmp(key_names[i].name, name) == 0)
  ------------------
  |  Branch (283:13): [True: 198, False: 286k]
  ------------------
  284|    198|            return mp_normalize_keycode(key_names[i].key + modifiers);
  285|   287k|    }
  286|       |
  287|  1.40k|    return -1;
  288|  1.59k|}
mp_input_get_key_name:
  315|  19.5k|{
  316|  19.5k|    bstr dst = {0};
  317|  19.5k|    mp_input_append_key_name(&dst, key);
  318|  19.5k|    return dst.start;
  319|  19.5k|}
mp_input_get_key_combo_name:
  322|  2.19k|{
  323|  2.19k|    bstr dst = {0};
  324|  5.42k|    while (max > 0) {
  ------------------
  |  Branch (324:12): [True: 5.42k, False: 0]
  ------------------
  325|  5.42k|        mp_input_append_key_name(&dst, *keys);
  326|  5.42k|        if (--max && *++keys)
  ------------------
  |  Branch (326:13): [True: 3.22k, False: 2.19k]
  |  Branch (326:22): [True: 3.22k, False: 0]
  ------------------
  327|  3.22k|            bstr_xappend(NULL, &dst, bstr0("-"));
  328|  2.19k|        else
  329|  2.19k|            break;
  330|  5.42k|    }
  331|  2.19k|    return dst.start;
  332|  2.19k|}
mp_input_get_keys_from_string:
  336|  1.59k|{
  337|  1.59k|    char *end, *ptr;
  338|  1.59k|    int n = 0;
  339|       |
  340|  1.59k|    ptr = name;
  341|  1.59k|    n = 0;
  342|  5.09k|    for (end = strchr(ptr, '-'); ; end = strchr(ptr, '-')) {
  343|  5.09k|        if (end && end[1] != '\0') {
  ------------------
  |  Branch (343:13): [True: 4.79k, False: 300]
  |  Branch (343:20): [True: 3.90k, False: 894]
  ------------------
  344|  3.90k|            if (*ptr == '-' && end[1] == '-')
  ------------------
  |  Branch (344:17): [True: 2.57k, False: 1.32k]
  |  Branch (344:32): [True: 2.43k, False: 141]
  ------------------
  345|  2.43k|                end = &end[1];
  346|  3.90k|            end[0] = '\0';
  347|  3.90k|        }
  348|  5.09k|        keys[n] = mp_input_get_key_from_name(ptr);
  349|  5.09k|        if (keys[n] < 0)
  ------------------
  |  Branch (349:13): [True: 347, False: 4.74k]
  ------------------
  350|    347|            return 0;
  351|  4.74k|        n++;
  352|  4.74k|        if (end && end[1] != '\0' && n < max_num_keys)
  ------------------
  |  Branch (352:13): [True: 4.52k, False: 225]
  |  Branch (352:20): [True: 3.51k, False: 1.00k]
  |  Branch (352:38): [True: 3.49k, False: 21]
  ------------------
  353|  3.49k|            ptr = &end[1];
  354|  1.25k|        else
  355|  1.25k|            break;
  356|  4.74k|    }
  357|  1.25k|    *out_num_keys = n;
  358|  1.25k|    return 1;
  359|  1.59k|}
mp_get_key_list:
  369|      2|{
  370|      2|    char **list = NULL;
  371|      2|    int num = 0;
  372|    378|    for (int i = 0; key_names[i].name != NULL; i++)
  ------------------
  |  Branch (372:21): [True: 376, False: 2]
  ------------------
  373|    376|        MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(NULL, key_names[i].name));
  ------------------
  |  |  105|    376|    do {                                            \
  |  |  106|    376|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    376|    do {                                            \
  |  |  |  |   97|    376|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    376|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    376|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    376|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14, False: 362]
  |  |  |  |  ------------------
  |  |  |  |   99|    376|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     14|    do {                                                        \
  |  |  |  |  |  |   89|     14|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     14|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     14|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     14|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     14|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     14|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     14|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    376|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 376]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    376|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    376|        (idxvar)++;                                 \
  |  |  109|    376|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 376]
  |  |  ------------------
  ------------------
  374|      2|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|      2|    do {                                            \
  |  |  106|      2|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      2|    do {                                            \
  |  |  |  |   97|      2|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      2|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      2|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      2|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |   99|      2|            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|      2|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      2|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      2|        (idxvar)++;                                 \
  |  |  109|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  375|      2|    return list;
  376|      2|}
mp_normalize_keycode:
  379|  44.3k|{
  380|  44.3k|    if (keycode <= 0)
  ------------------
  |  Branch (380:9): [True: 0, False: 44.3k]
  ------------------
  381|      0|        return keycode;
  382|  44.3k|    int code = keycode & ~MP_KEY_MODIFIER_MASK;
  ------------------
  |  |  264|  44.3k|#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  245|  44.3k|#define MP_KEY_MODIFIER_SHIFT  (1u<<24)
  |  |  ------------------
  |  |               #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  246|  44.3k|#define MP_KEY_MODIFIER_CTRL   (1u<<25)
  |  |  ------------------
  |  |  265|  44.3k|                              MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  247|  44.3k|#define MP_KEY_MODIFIER_ALT    (1u<<26)
  |  |  ------------------
  |  |                                             MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  248|  44.3k|#define MP_KEY_MODIFIER_META   (1u<<27)
  |  |  ------------------
  |  |  266|  44.3k|                              MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  253|  44.3k|#define MP_KEY_STATE_DOWN      (1u<<28)
  |  |  ------------------
  |  |                                             MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  259|  44.3k|#define MP_KEY_STATE_UP        (1u<<29)
  |  |  ------------------
  ------------------
  383|  44.3k|    int mod = keycode & MP_KEY_MODIFIER_MASK;
  ------------------
  |  |  264|  44.3k|#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  245|  44.3k|#define MP_KEY_MODIFIER_SHIFT  (1u<<24)
  |  |  ------------------
  |  |               #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
  |  |  ------------------
  |  |  |  |  246|  44.3k|#define MP_KEY_MODIFIER_CTRL   (1u<<25)
  |  |  ------------------
  |  |  265|  44.3k|                              MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  247|  44.3k|#define MP_KEY_MODIFIER_ALT    (1u<<26)
  |  |  ------------------
  |  |                                             MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
  |  |  ------------------
  |  |  |  |  248|  44.3k|#define MP_KEY_MODIFIER_META   (1u<<27)
  |  |  ------------------
  |  |  266|  44.3k|                              MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  253|  44.3k|#define MP_KEY_STATE_DOWN      (1u<<28)
  |  |  ------------------
  |  |                                             MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
  |  |  ------------------
  |  |  |  |  259|  44.3k|#define MP_KEY_STATE_UP        (1u<<29)
  |  |  ------------------
  ------------------
  384|       |    /* On normal keyboards shift changes the character code of non-special
  385|       |     * keys, so don't count the modifier separately for those. In other words
  386|       |     * we want to have "a" and "A" instead of "a" and "Shift+A"; but a separate
  387|       |     * shift modifier is still kept for special keys like arrow keys. */
  388|  44.3k|    if (code >= 32 && code < MP_KEY_BASE) {
  ------------------
  |  |   23|  6.44k|#define MP_KEY_BASE (1<<21)
  ------------------
  |  Branch (388:9): [True: 6.44k, False: 37.8k]
  |  Branch (388:23): [True: 5.51k, False: 931]
  ------------------
  389|       |        /* Still try to support ASCII case-modifications properly. For example,
  390|       |         * we want to change "Shift+a" to "A", not "a". Doing this for unicode
  391|       |         * in general would require huge lookup tables, or a libc with proper
  392|       |         * unicode support, so we don't do that. */
  393|  5.51k|        if (code >= 'a' && code <= 'z' && (mod & MP_KEY_MODIFIER_SHIFT))
  ------------------
  |  |  245|  1.44k|#define MP_KEY_MODIFIER_SHIFT  (1u<<24)
  ------------------
  |  Branch (393:13): [True: 1.78k, False: 3.72k]
  |  Branch (393:28): [True: 1.44k, False: 343]
  |  Branch (393:43): [True: 0, False: 1.44k]
  ------------------
  394|      0|            code &= 0x5F;
  395|  5.51k|        mod &= ~MP_KEY_MODIFIER_SHIFT;
  ------------------
  |  |  245|  5.51k|#define MP_KEY_MODIFIER_SHIFT  (1u<<24)
  ------------------
  396|  5.51k|    }
  397|  44.3k|    return code | mod;
  398|  44.3k|}
keycodes.c:mp_input_append_key_name:
  291|  25.0k|{
  292|   125k|    for (int i = 0; modifier_names[i].name; i++) {
  ------------------
  |  Branch (292:21): [True: 100k, False: 25.0k]
  ------------------
  293|   100k|        if (modifier_names[i].key & key) {
  ------------------
  |  Branch (293:13): [True: 0, False: 100k]
  ------------------
  294|      0|            bstr_xappend_asprintf(NULL, buf, "%s+", modifier_names[i].name);
  295|      0|            key -= modifier_names[i].key;
  296|      0|        }
  297|   100k|    }
  298|  4.69M|    for (int i = 0; key_names[i].name != NULL; i++) {
  ------------------
  |  Branch (298:21): [True: 4.66M, False: 24.6k]
  ------------------
  299|  4.66M|        if (key_names[i].key == key) {
  ------------------
  |  Branch (299:13): [True: 315, False: 4.66M]
  ------------------
  300|    315|            bstr_xappend_asprintf(NULL, buf, "%s", key_names[i].name);
  301|    315|            return;
  302|    315|        }
  303|  4.66M|    }
  304|       |
  305|  24.6k|    if (MP_KEY_IS_UNICODE(key)) {
  ------------------
  |  |   27|  24.6k|#define MP_KEY_IS_UNICODE(key) ((key) >= 32 && (key) <= 0x10FFFF)
  |  |  ------------------
  |  |  |  Branch (27:33): [True: 5.16k, False: 19.5k]
  |  |  |  Branch (27:48): [True: 5.15k, False: 3]
  |  |  ------------------
  ------------------
  306|  5.15k|        mp_append_utf8_bstr(NULL, buf, key);
  307|  5.15k|        return;
  308|  5.15k|    }
  309|       |
  310|       |    // Print the hex key code
  311|  19.5k|    bstr_xappend_asprintf(NULL, buf, "0x%x", key);
  312|  19.5k|}

bstrcmp:
   31|   105M|{
   32|   105M|    int ret = 0;
   33|   105M|    if (str1.len && str2.len)
  ------------------
  |  Branch (33:9): [True: 105M, False: 118k]
  |  Branch (33:21): [True: 105M, False: 11.6k]
  ------------------
   34|   105M|        ret = memcmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|   105M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 39.2M, False: 66.3M]
  |  |  ------------------
  ------------------
   35|       |
   36|   105M|    if (!ret) {
  ------------------
  |  Branch (36:9): [True: 14.5M, False: 91.2M]
  ------------------
   37|  14.5M|        if (str1.len == str2.len)
  ------------------
  |  Branch (37:13): [True: 12.0M, False: 2.45M]
  ------------------
   38|  12.0M|            return 0;
   39|  2.45M|        else if (str1.len > str2.len)
  ------------------
  |  Branch (39:18): [True: 90.0k, False: 2.36M]
  ------------------
   40|  90.0k|            return 1;
   41|  2.36M|        else
   42|  2.36M|            return -1;
   43|  14.5M|    }
   44|  91.2M|    return ret;
   45|   105M|}
bstrcasecmp:
   48|  1.10M|{
   49|  1.10M|    int ret = 0;
   50|  1.10M|    if (str1.len && str2.len)
  ------------------
  |  Branch (50:9): [True: 936k, False: 164k]
  |  Branch (50:21): [True: 935k, False: 776]
  ------------------
   51|   935k|        ret = strncasecmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|   935k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 256k, False: 679k]
  |  |  ------------------
  ------------------
   52|       |
   53|  1.10M|    if (!ret) {
  ------------------
  |  Branch (53:9): [True: 340k, False: 760k]
  ------------------
   54|   340k|        if (str1.len == str2.len)
  ------------------
  |  Branch (54:13): [True: 163k, False: 177k]
  ------------------
   55|   163k|            return 0;
   56|   177k|        else if (str1.len > str2.len)
  ------------------
  |  Branch (56:18): [True: 836, False: 176k]
  ------------------
   57|    836|            return 1;
   58|   176k|        else
   59|   176k|            return -1;
   60|   340k|    }
   61|   760k|    return ret;
   62|  1.10M|}
bstrchr:
   65|   104M|{
   66|   104M|    if (!str.len)
  ------------------
  |  Branch (66:9): [True: 10.4k, False: 104M]
  ------------------
   67|  10.4k|        return -1;
   68|   104M|    unsigned char *pos = memchr(str.start, c, str.len);
   69|   104M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (69:12): [True: 99.4M, False: 5.45M]
  ------------------
   70|   104M|}
bstrrchr:
   73|  31.1M|{
   74|  31.1M|    if (!str.len)
  ------------------
  |  Branch (74:9): [True: 58.0k, False: 31.0M]
  ------------------
   75|  58.0k|        return -1;
   76|  31.0M|#if HAVE_MEMRCHR
   77|  31.0M|    unsigned char *pos = memrchr(str.start, c, str.len);
   78|  31.0M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (78:12): [True: 30.5M, False: 554k]
  ------------------
   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|  31.1M|}
bstrcspn:
   88|  12.8M|{
   89|  12.8M|    int i;
   90|   144M|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (90:17): [True: 143M, False: 1.51M]
  ------------------
   91|   143M|        if (strchr(reject, str.start[i]))
  ------------------
  |  Branch (91:13): [True: 11.3M, False: 131M]
  ------------------
   92|  11.3M|            break;
   93|  12.8M|    return i;
   94|  12.8M|}
bstrspn:
   97|   198k|{
   98|   198k|    int i;
   99|   598k|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (99:17): [True: 529k, False: 69.0k]
  ------------------
  100|   529k|        if (!strchr(accept, str.start[i]))
  ------------------
  |  Branch (100:13): [True: 128k, False: 400k]
  ------------------
  101|   128k|            break;
  102|   198k|    return i;
  103|   198k|}
bstr_find:
  106|  33.7M|{
  107|   153M|    for (int i = 0; i < haystack.len; i++)
  ------------------
  |  Branch (107:21): [True: 148M, False: 5.77M]
  ------------------
  108|   148M|        if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle))
  ------------------
  |  Branch (108:13): [True: 27.9M, False: 120M]
  ------------------
  109|  27.9M|            return i;
  110|  5.77M|    return -1;
  111|  33.7M|}
bstr_lstrip:
  114|  17.8M|{
  115|  19.3M|    while (str.len && mp_isspace(*str.start)) {
  ------------------
  |  Branch (115:12): [True: 15.6M, False: 3.72M]
  |  Branch (115:23): [True: 1.49M, False: 14.1M]
  ------------------
  116|  1.49M|        str.start++;
  117|  1.49M|        str.len--;
  118|  1.49M|    }
  119|  17.8M|    return str;
  120|  17.8M|}
bstr_strip:
  123|  2.63M|{
  124|  2.63M|    str = bstr_lstrip(str);
  125|  4.05M|    while (str.len && mp_isspace(str.start[str.len - 1]))
  ------------------
  |  Branch (125:12): [True: 3.45M, False: 598k]
  |  Branch (125:23): [True: 1.42M, False: 2.03M]
  ------------------
  126|  1.42M|        str.len--;
  127|  2.63M|    return str;
  128|  2.63M|}
bstr_split:
  131|  44.9k|{
  132|  44.9k|    int start;
  133|  45.0k|    for (start = 0; start < str.len; start++)
  ------------------
  |  Branch (133:21): [True: 45.0k, False: 10]
  ------------------
  134|  45.0k|        if (!strchr(sep, str.start[start]))
  ------------------
  |  Branch (134:13): [True: 44.9k, False: 67]
  ------------------
  135|  44.9k|            break;
  136|  44.9k|    str = bstr_cut(str, start);
  137|  44.9k|    int end = bstrcspn(str, sep);
  138|  44.9k|    if (rest) {
  ------------------
  |  Branch (138:9): [True: 259, False: 44.7k]
  ------------------
  139|    259|        *rest = bstr_cut(str, end);
  140|    259|    }
  141|  44.9k|    return bstr_splice(str, 0, end);
  142|  44.9k|}
bstr_split_tok:
  148|  5.87M|{
  149|  5.87M|    bstr bsep = bstr0(tok);
  150|  5.87M|    int pos = bstr_find(str, bsep);
  151|  5.87M|    if (pos < 0)
  ------------------
  |  Branch (151:9): [True: 5.61M, False: 267k]
  ------------------
  152|  5.61M|        pos = str.len;
  153|  5.87M|    *out_left = bstr_splice(str, 0, pos);
  154|  5.87M|    *out_right = bstr_cut(str, pos + bsep.len);
  155|  5.87M|    return pos != str.len;
  156|  5.87M|}
bstr_splice:
  159|   295M|{
  160|   295M|    if (!str.len)
  ------------------
  |  Branch (160:9): [True: 8.89k, False: 295M]
  ------------------
  161|  8.89k|        return str;
  162|       |
  163|   295M|    if (start < 0)
  ------------------
  |  Branch (163:9): [True: 0, False: 295M]
  ------------------
  164|      0|        start += str.len;
  165|   295M|    if (end < 0)
  ------------------
  |  Branch (165:9): [True: 4, False: 295M]
  ------------------
  166|      4|        end += str.len;
  167|   295M|    end = MPMIN(end, str.len);
  ------------------
  |  |   45|   295M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 4.67M, False: 290M]
  |  |  ------------------
  ------------------
  168|   295M|    start = MPMAX(start, 0);
  ------------------
  |  |   44|   295M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 142M, False: 153M]
  |  |  ------------------
  ------------------
  169|   295M|    end = MPMAX(end, start);
  ------------------
  |  |   44|   295M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 295M, False: 329k]
  |  |  ------------------
  ------------------
  170|   295M|    str.start += start;
  171|   295M|    str.len = end - start;
  172|   295M|    return str;
  173|   295M|}
bstrtoll:
  176|   205k|{
  177|   205k|    str = bstr_lstrip(str);
  178|   205k|    char buf[51];
  179|   205k|    int len = MPMIN(str.len, 50);
  ------------------
  |  |   45|   205k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 765, False: 204k]
  |  |  ------------------
  ------------------
  180|   205k|    memcpy(buf, str.start, len);
  181|   205k|    buf[len] = 0;
  182|   205k|    char *endptr;
  183|   205k|    long long r = strtoll(buf, &endptr, base);
  184|   205k|    if (rest)
  ------------------
  |  Branch (184:9): [True: 205k, False: 0]
  ------------------
  185|   205k|        *rest = bstr_cut(str, endptr - buf);
  186|   205k|    return r;
  187|   205k|}
bstrtod:
  190|   132k|{
  191|   132k|    str = bstr_lstrip(str);
  192|   132k|    char buf[101];
  193|   132k|    int len = MPMIN(str.len, 100);
  ------------------
  |  |   45|   132k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 144, False: 132k]
  |  |  ------------------
  ------------------
  194|   132k|    memcpy(buf, str.start, len);
  195|   132k|    buf[len] = 0;
  196|   132k|    char *endptr;
  197|   132k|    double r = strtod(buf, &endptr);
  198|   132k|    if (rest)
  ------------------
  |  Branch (198:9): [True: 132k, False: 0]
  ------------------
  199|   132k|        *rest = bstr_cut(str, endptr - buf);
  200|   132k|    return r;
  201|   132k|}
bstr_splitchar:
  204|  97.8M|{
  205|  97.8M|    int pos = bstrchr(str, c);
  206|  97.8M|    if (pos < 0)
  ------------------
  |  Branch (206:9): [True: 4.63M, False: 93.2M]
  ------------------
  207|  4.63M|        pos = str.len;
  208|  97.8M|    if (rest)
  ------------------
  |  Branch (208:9): [True: 97.8M, False: 18.4E]
  ------------------
  209|  97.8M|        *rest = bstr_cut(str, pos + 1);
  210|  97.8M|    return bstr_splice(str, 0, pos + 1);
  211|  97.8M|}
bstr_strip_linebreaks:
  214|  1.20M|{
  215|  1.20M|    if (bstr_endswith0(str, "\r\n")) {
  ------------------
  |  Branch (215:9): [True: 16, False: 1.20M]
  ------------------
  216|     16|        str = bstr_splice(str, 0, str.len - 2);
  217|  1.20M|    } else if (bstr_endswith0(str, "\n")) {
  ------------------
  |  Branch (217:16): [True: 1.17M, False: 27.0k]
  ------------------
  218|  1.17M|        str = bstr_splice(str, 0, str.len - 1);
  219|  1.17M|    }
  220|  1.20M|    return str;
  221|  1.20M|}
bstr_eatstart:
  224|   378M|{
  225|   378M|    if (!bstr_startswith(*s, prefix))
  ------------------
  |  Branch (225:9): [True: 357M, False: 20.9M]
  ------------------
  226|   357M|        return false;
  227|  20.9M|    *s = bstr_cut(*s, prefix.len);
  228|       |    return true;
  229|   378M|}
bstr_eatend:
  232|  2.22k|{
  233|  2.22k|    if (!bstr_endswith(*s, prefix))
  ------------------
  |  Branch (233:9): [True: 1.34k, False: 880]
  ------------------
  234|  1.34k|        return false;
  235|    880|    s->len -= prefix.len;
  236|       |    return true;
  237|  2.22k|}
bstr_sscanf:
  246|   147k|{
  247|   147k|    char *ptr = bstrdup0(NULL, str);
  248|   147k|    va_list va;
  249|   147k|    va_start(va, format);
  250|   147k|    int ret = vsscanf(ptr, format, va);
  251|   147k|    va_end(va);
  252|   147k|    talloc_free(ptr);
  ------------------
  |  |   47|   147k|#define talloc_free                     ta_free
  ------------------
  253|   147k|    return ret;
  254|   147k|}
bstr_parse_utf8_code_length:
  257|  2.60G|{
  258|  2.60G|    if (b < 128)
  ------------------
  |  Branch (258:9): [True: 2.59G, False: 13.6M]
  ------------------
  259|  2.59G|        return 1;
  260|  13.6M|    int bytes = 7 - mp_log2(b ^ 255);
  261|  13.6M|    return (bytes >= 2 && bytes <= 4) ? bytes : -1;
  ------------------
  |  Branch (261:13): [True: 9.26M, False: 4.34M]
  |  Branch (261:27): [True: 7.74M, False: 1.52M]
  ------------------
  262|  2.60G|}
bstr_decode_partial_utf8:
  265|   100M|{
  266|   100M|    if (s->len == 0)
  ------------------
  |  Branch (266:9): [True: 151, False: 100M]
  ------------------
  267|    151|        return -1;
  268|   100M|    unsigned int codepoint = s->start[0];
  269|   100M|    s->start++; s->len--;
  270|   100M|    if (codepoint >= 128) {
  ------------------
  |  Branch (270:9): [True: 3.85M, False: 96.7M]
  ------------------
  271|  3.85M|        int bytes = bstr_parse_utf8_code_length(codepoint);
  272|  3.85M|        if (bytes < 1)
  ------------------
  |  Branch (272:13): [True: 1.67M, False: 2.18M]
  ------------------
  273|  1.67M|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|  1.67M|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  274|  2.18M|        codepoint &= 127 >> bytes;
  275|  2.28M|        for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (275:25): [True: 2.22M, False: 57.2k]
  ------------------
  276|  2.22M|            if (!s->len)
  ------------------
  |  Branch (276:17): [True: 6.32k, False: 2.22M]
  ------------------
  277|  6.32k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|  6.32k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  278|  2.22M|            int tmp = (unsigned char)s->start[0];
  279|  2.22M|            if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (279:17): [True: 2.11M, False: 104k]
  ------------------
  280|  2.11M|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|  2.11M|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  281|   104k|            codepoint = (codepoint << 6) | (tmp & ~0xC0);
  282|   104k|            s->start++; s->len--;
  283|   104k|        }
  284|  57.2k|        if (codepoint > 0x10FFFF || (codepoint >= 0xD800 && codepoint <= 0xDFFF))
  ------------------
  |  Branch (284:13): [True: 599, False: 56.6k]
  |  Branch (284:38): [True: 13.4k, False: 43.1k]
  |  Branch (284:61): [True: 4.46k, False: 8.96k]
  ------------------
  285|  5.05k|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|  5.05k|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  286|       |
  287|       |        // Overlong sequences - check taken from libavcodec.
  288|  52.1k|        unsigned int min = bytes == 2 ? 0x80 : 1 << (5 * bytes - 4);
  ------------------
  |  Branch (288:28): [True: 22.0k, False: 30.0k]
  ------------------
  289|  52.1k|        if (codepoint < min)
  ------------------
  |  Branch (289:13): [True: 406, False: 51.7k]
  ------------------
  290|    406|            return BSTR_DECODE_OVERLONG_ENCODING;
  ------------------
  |  |   93|    406|#define BSTR_DECODE_OVERLONG_ENCODING -3
  ------------------
  291|  52.1k|    }
  292|  96.8M|    return codepoint;
  293|   100M|}
bstr_decode_utf8:
  296|  6.41M|{
  297|  6.41M|    int res = bstr_decode_partial_utf8(&s);
  298|  6.41M|    if (res >= 0 && out_next)
  ------------------
  |  Branch (298:9): [True: 3.21M, False: 3.19M]
  |  Branch (298:21): [True: 3.21M, False: 0]
  ------------------
  299|  3.21M|        *out_next = s;
  300|  6.41M|    return res;
  301|  6.41M|}
bstr_validate_utf8:
  315|   173k|{
  316|  2.52M|    while (s.len) {
  ------------------
  |  Branch (316:12): [True: 2.42M, False: 100k]
  ------------------
  317|  2.42M|        if (bstr_decode_utf8(s, &s) < 0) {
  ------------------
  |  Branch (317:13): [True: 72.9k, False: 2.35M]
  ------------------
  318|       |            // Try to guess whether the sequence was just cut-off.
  319|  72.9k|            unsigned int codepoint = (unsigned char)s.start[0];
  320|  72.9k|            int bytes = bstr_parse_utf8_code_length(codepoint);
  321|  72.9k|            if (bytes > 1 && s.len < 6) {
  ------------------
  |  Branch (321:17): [True: 32.2k, False: 40.6k]
  |  Branch (321:30): [True: 8.39k, False: 23.8k]
  ------------------
  322|       |                // Manually check validity of left bytes
  323|  9.04k|                for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (323:33): [True: 8.85k, False: 196]
  ------------------
  324|  8.85k|                    if (n >= s.len) {
  ------------------
  |  Branch (324:25): [True: 5.31k, False: 3.53k]
  ------------------
  325|       |                        // Everything valid until now - just cut off.
  326|  5.31k|                        return -(bytes - s.len);
  327|  5.31k|                    }
  328|  3.53k|                    int tmp = (unsigned char)s.start[n];
  329|  3.53k|                    if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (329:25): [True: 2.87k, False: 655]
  ------------------
  330|  2.87k|                        break;
  331|  3.53k|                }
  332|  8.39k|            }
  333|  67.5k|            return -8;
  334|  72.9k|        }
  335|  2.42M|    }
  336|   100k|    return 0;
  337|   173k|}
bstr_sanitize_utf8_latin1:
  340|  7.29k|{
  341|  7.29k|    bstr new = {0};
  342|  7.29k|    bstr left = s;
  343|  7.29k|    unsigned char *first_ok = s.start;
  344|  3.91M|    while (left.len) {
  ------------------
  |  Branch (344:12): [True: 3.90M, False: 7.29k]
  ------------------
  345|  3.90M|        int r = bstr_decode_utf8(left, &left);
  346|  3.90M|        if (r < 0) {
  ------------------
  |  Branch (346:13): [True: 3.12M, False: 786k]
  ------------------
  347|  3.12M|            bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  348|  3.12M|            mp_append_utf8_bstr(talloc_ctx, &new, (unsigned char)left.start[0]);
  349|  3.12M|            left.start += 1;
  350|  3.12M|            left.len -= 1;
  351|  3.12M|            first_ok = left.start;
  352|  3.12M|        }
  353|  3.90M|    }
  354|  7.29k|    if (!new.start)
  ------------------
  |  Branch (354:9): [True: 0, False: 7.29k]
  ------------------
  355|      0|        return s;
  356|  7.29k|    if (first_ok != left.start)
  ------------------
  |  Branch (356:9): [True: 4.89k, False: 2.40k]
  ------------------
  357|  4.89k|        bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  358|  7.29k|    return new;
  359|  7.29k|}
bstr_xappend:
  375|  80.8M|{
  376|  80.8M|    if (!append.len)
  ------------------
  |  Branch (376:9): [True: 3.61M, False: 77.2M]
  ------------------
  377|  3.61M|        return;
  378|  77.2M|    resize_append(talloc_ctx, s, append.len + 1);
  379|  77.2M|    memmove(s->start + s->len, append.start, append.len);
  380|  77.2M|    s->len += append.len;
  381|  77.2M|    s->start[s->len] = '\0';
  382|  77.2M|}
bstr_xappend_asprintf:
  385|  2.75M|{
  386|  2.75M|    va_list ap;
  387|  2.75M|    va_start(ap, fmt);
  388|  2.75M|    int ret = bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap);
  389|       |    va_end(ap);
  390|  2.75M|    return ret;
  391|  2.75M|}
bstr_xappend_vasprintf:
  395|  88.3M|{
  396|  88.3M|    int size;
  397|  88.3M|    va_list copy;
  398|  88.3M|    va_copy(copy, ap);
  399|  88.3M|    size_t avail = talloc_get_size(s->start) - s->len;
  ------------------
  |  |   45|  88.3M|#define talloc_get_size                 ta_get_size
  ------------------
  400|  88.3M|    char *dest = s->start ? s->start + s->len : NULL;
  ------------------
  |  Branch (400:18): [True: 88.2M, False: 141k]
  ------------------
  401|  88.3M|    size = vsnprintf(dest, avail, fmt, copy);
  402|  88.3M|    va_end(copy);
  403|       |
  404|  88.3M|    if (size < 0)
  ------------------
  |  Branch (404:9): [True: 0, False: 88.3M]
  ------------------
  405|      0|        return size;
  406|       |
  407|  88.3M|    if (avail < 1 || size + 1 > avail) {
  ------------------
  |  Branch (407:9): [True: 140k, False: 88.2M]
  |  Branch (407:22): [True: 500k, False: 87.7M]
  ------------------
  408|   640k|        resize_append(talloc_ctx, s, size + 1);
  409|   640k|        vsnprintf(s->start + s->len, size + 1, fmt, ap);
  410|   640k|    }
  411|  88.3M|    s->len += size;
  412|  88.3M|    return size;
  413|  88.3M|}
bstr_case_startswith:
  416|   413k|{
  417|   413k|    struct bstr start = bstr_splice(s, 0, prefix.len);
  418|   413k|    return start.len == prefix.len && bstrcasecmp(start, prefix) == 0;
  ------------------
  |  Branch (418:12): [True: 379k, False: 34.0k]
  |  Branch (418:39): [True: 28, False: 378k]
  ------------------
  419|   413k|}
bstr_decode_hex:
  440|  1.59k|{
  441|  1.59k|    if (!out)
  ------------------
  |  Branch (441:9): [True: 0, False: 1.59k]
  ------------------
  442|      0|        return false;
  443|       |
  444|  1.59k|    char *arr = talloc_array(talloc_ctx, char, hex.len / 2);
  ------------------
  |  |   29|  1.59k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  1.59k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.59k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|  1.59k|    int len = 0;
  446|       |
  447|  27.0k|    while (hex.len >= 2) {
  ------------------
  |  Branch (447:12): [True: 26.0k, False: 1.01k]
  ------------------
  448|  26.0k|        int a = h_to_i(hex.start[0]);
  449|  26.0k|        int b = h_to_i(hex.start[1]);
  450|  26.0k|        hex = bstr_splice(hex, 2, hex.len);
  451|       |
  452|  26.0k|        if (a < 0 || b < 0) {
  ------------------
  |  Branch (452:13): [True: 224, False: 25.8k]
  |  Branch (452:22): [True: 354, False: 25.4k]
  ------------------
  453|    578|            talloc_free(arr);
  ------------------
  |  |   47|    578|#define talloc_free                     ta_free
  ------------------
  454|    578|            return false;
  455|    578|        }
  456|       |
  457|  25.4k|        arr[len++] = (a << 4) | b;
  458|  25.4k|    }
  459|       |
  460|  1.01k|    *out = (struct bstr){ .start = arr, .len = len };
  461|       |    return true;
  462|  1.59k|}
bstr_find_in_list0:
  465|   150k|{
  466|   452k|    for (int n = 0; list && list[n]; n++)
  ------------------
  |  Branch (466:21): [True: 452k, False: 0]
  |  Branch (466:29): [True: 452k, False: 0]
  ------------------
  467|   452k|        if (case_sensitive ? !bstrcmp0(str, list[n]) : !bstrcasecmp0(str, list[n]))
  ------------------
  |  Branch (467:13): [True: 0, False: 452k]
  |  Branch (467:13): [True: 150k, False: 301k]
  ------------------
  468|   150k|            return n;
  469|       |
  470|      0|    return -1;
  471|   150k|}
bstr_in_list0:
  474|   150k|{
  475|       |    return bstr_find_in_list0(str, list, false) != -1;
  476|   150k|}
bstr.c:resize_append:
  362|  77.9M|{
  363|  77.9M|    size_t size = talloc_get_size(s->start);
  ------------------
  |  |   45|  77.9M|#define talloc_get_size                 ta_get_size
  ------------------
  364|  77.9M|    mp_assert(s->len <= size);
  ------------------
  |  |   41|  77.9M|#define mp_assert assert
  ------------------
  |  Branch (364:5): [True: 77.9M, False: 34]
  ------------------
  365|  77.9M|    if (append_min > size - s->len) {
  ------------------
  |  Branch (365:9): [True: 25.1M, False: 52.7M]
  ------------------
  366|  25.1M|        if (append_min < size)
  ------------------
  |  Branch (366:13): [True: 9.84M, False: 15.3M]
  ------------------
  367|  9.84M|            append_min = size; // preallocate in power of 2s
  368|  25.1M|        if (size >= SIZE_MAX / 2 || append_min >= SIZE_MAX / 2)
  ------------------
  |  Branch (368:13): [True: 0, False: 25.1M]
  |  Branch (368:37): [True: 3, False: 25.1M]
  ------------------
  369|      0|            abort(); // oom
  370|  25.1M|        s->start = talloc_realloc_size(talloc_ctx, s->start, size + append_min);
  ------------------
  |  |   39|  25.1M|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  25.1M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  25.1M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  25.1M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  25.1M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|  25.1M|    }
  372|  77.9M|}
bstr.c:h_to_i:
  428|  52.0k|{
  429|  52.0k|    if (c >= '0' && c <= '9')
  ------------------
  |  Branch (429:9): [True: 52.0k, False: 69]
  |  Branch (429:21): [True: 32.1k, False: 19.8k]
  ------------------
  430|  32.1k|        return c - '0';
  431|  19.9k|    if (c >= 'a' && c <= 'f')
  ------------------
  |  Branch (431:9): [True: 11.2k, False: 8.66k]
  |  Branch (431:21): [True: 10.7k, False: 540]
  ------------------
  432|  10.7k|        return c - 'a' + 10;
  433|  9.20k|    if (c >= 'A' && c <= 'F')
  ------------------
  |  Branch (433:9): [True: 9.12k, False: 81]
  |  Branch (433:21): [True: 8.53k, False: 586]
  ------------------
  434|  8.53k|        return c - 'A' + 10;
  435|       |
  436|    667|    return -1; // invalid char
  437|  9.20k|}

chmap.c:bstr_eatstart0:
  291|   163k|{
  292|   163k|    return bstr_eatstart(s, bstr0(prefix));
  293|   163k|}
chmap.c:bstr_equals0:
  276|   636k|{
  277|   636k|    return bstr_equals(str1, bstr0(str2));
  278|   636k|}
chmap.c:bstr_equals:
  268|   636k|{
  269|   636k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 191k, False: 444k]
  ------------------
  270|   191k|        return false;
  271|       |
  272|   444k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 237k, False: 207k]
  |  Branch (272:40): [True: 10.6k, False: 196k]
  ------------------
  273|   636k|}
chmap.c:bstr0:
   62|  1.11M|{
   63|  1.11M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.11M, False: 0]
  ------------------
   64|  1.11M|}
ao.c:bstr0:
   62|  15.0k|{
   63|  15.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 15.0k, False: 0]
  ------------------
   64|  15.0k|}
ao.c:bstrto0:
   46|      8|{
   47|      8|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 8, False: 0]
  ------------------
   48|      8|}
ao.c:bstrdup0:
   40|      8|{
   41|      8|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|      8|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|      8|}
codecs.c:bstr0:
   62|  53.7k|{
   63|  53.7k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 7.19k, False: 46.5k]
  ------------------
   64|  53.7k|}
codecs.c:bstr_equals0:
  276|  7.16k|{
  277|  7.16k|    return bstr_equals(str1, bstr0(str2));
  278|  7.16k|}
codecs.c:bstr_equals:
  268|  7.16k|{
  269|  7.16k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 7.07k, False: 92]
  ------------------
  270|  7.07k|        return false;
  271|       |
  272|     92|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 92]
  |  Branch (272:40): [True: 0, False: 92]
  ------------------
  273|  7.16k|}
common.c:bstr0:
   62|      3|{
   63|      3|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 3, False: 0]
  ------------------
   64|      3|}
common.c:bstr_cut:
  227|   167k|{
  228|   167k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 167k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   167k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 167k]
  ------------------
  234|      0|        n = str.len;
  235|   167k|    return (struct bstr){str.start + n, str.len - n};
  236|   167k|}
msg.c:bstr_eatstart0:
  291|  81.0M|{
  292|  81.0M|    return bstr_eatstart(s, bstr0(prefix));
  293|  81.0M|}
msg.c:bstr0:
   62|  82.1M|{
   63|  82.1M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 82.1M, False: 0]
  ------------------
   64|  82.1M|}
msg.c:bstr_getline:
  156|  84.5M|{
  157|  84.5M|    return bstr_splitchar(str, rest, '\n');
  158|  84.5M|}
msg.c:bstrdup0:
   40|   443k|{
   41|   443k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   443k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   443k|}
playlist.c:bstr0:
   62|  13.5k|{
   63|  13.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 13.5k, False: 0]
  ------------------
   64|  13.5k|}
tags.c:bstr0:
   62|  85.6M|{
   63|  85.6M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 85.6M, False: 0]
  ------------------
   64|  85.6M|}
tags.c:bstrto0:
   46|     22|{
   47|     22|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 22, False: 0]
  ------------------
   48|     22|}
tags.c:bstrdup0:
   40|     22|{
   41|     22|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|     22|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|     22|}
cue.c:bstr_startswith0:
  246|  26.9k|{
  247|  26.9k|    return bstr_startswith(str, bstr0(prefix));
  248|  26.9k|}
cue.c:bstr_startswith:
  239|  26.9k|{
  240|  26.9k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 664, False: 26.2k]
  ------------------
  241|    664|        return false;
  242|  26.2k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  26.9k|}
cue.c:bstr_cut:
  227|     58|{
  228|     58|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 58]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|     58|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 58]
  ------------------
  234|      0|        n = str.len;
  235|     58|    return (struct bstr){str.start + n, str.len - n};
  236|     58|}
cue.c:bstr_getline:
  156|  26.9k|{
  157|  26.9k|    return bstr_splitchar(str, rest, '\n');
  158|  26.9k|}
cue.c:bstr0:
   62|   430k|{
   63|   430k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 430k, False: 0]
  ------------------
   64|   430k|}
demux.c:bstr_xappend0:
  180|   179k|{
  181|   179k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|   179k|}
demux.c:bstr0:
   62|   204k|{
   63|   204k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 204k, False: 0]
  ------------------
   64|   204k|}
demux_edl.c:bstr0:
   62|  26.4k|{
   63|  26.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 26.4k, False: 0]
  ------------------
   64|  26.4k|}
demux_edl.c:bstr_eatstart0:
  291|  12.6k|{
  292|  12.6k|    return bstr_eatstart(s, bstr0(prefix));
  293|  12.6k|}
demux_edl.c:bstr_cut:
  227|  4.33k|{
  228|  4.33k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 4.33k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  4.33k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 4.33k]
  ------------------
  234|      0|        n = str.len;
  235|  4.33k|    return (struct bstr){str.start + n, str.len - n};
  236|  4.33k|}
demux_edl.c:bstr_startswith0:
  246|     23|{
  247|     23|    return bstr_startswith(str, bstr0(prefix));
  248|     23|}
demux_edl.c:bstr_startswith:
  239|     23|{
  240|     23|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 3, False: 20]
  ------------------
  241|      3|        return false;
  242|     20|    return !memcmp(str.start, prefix.start, prefix.len);
  243|     23|}
demux_edl.c:bstr_equals:
  268|  9.03k|{
  269|  9.03k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 6.81k, False: 2.22k]
  ------------------
  270|  6.81k|        return false;
  271|       |
  272|  2.22k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 1.87k, False: 355]
  |  Branch (272:40): [True: 0, False: 355]
  ------------------
  273|  9.03k|}
demux_edl.c:bstr_equals0:
  276|  2.25k|{
  277|  2.25k|    return bstr_equals(str1, bstr0(str2));
  278|  2.25k|}
demux_edl.c:bstrdup0:
   40|  1.56k|{
   41|  1.56k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.56k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.56k|}
demux_edl.c:bstrcasecmp0:
  281|  1.12k|{
  282|  1.12k|    return bstrcasecmp(str1, bstr0(str2));
  283|  1.12k|}
demux_lavf.c:bstrcasecmp0:
  281|   124k|{
  282|   124k|    return bstrcasecmp(str1, bstr0(str2));
  283|   124k|}
demux_lavf.c:bstr0:
   62|   199k|{
   63|   199k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 199k, False: 0]
  ------------------
   64|   199k|}
demux_lavf.c:bstr_endswith0:
  258|  14.9k|{
  259|  14.9k|    return bstr_endswith(str, bstr0(suffix));
  260|  14.9k|}
demux_lavf.c:bstr_endswith:
  251|  14.9k|{
  252|  14.9k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 329, False: 14.6k]
  ------------------
  253|    329|        return false;
  254|  14.6k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  14.9k|}
demux_mf.c:bstr0:
   62|    170|{
   63|    170|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 170, False: 0]
  ------------------
   64|    170|}
demux_mf.c:bstrdup0:
   40|    251|{
   41|    251|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|    251|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|    251|}
demux_null.c:bstr_startswith0:
  246|  24.7k|{
  247|  24.7k|    return bstr_startswith(str, bstr0(prefix));
  248|  24.7k|}
demux_null.c:bstr_startswith:
  239|  24.7k|{
  240|  24.7k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 60, False: 24.6k]
  ------------------
  241|     60|        return false;
  242|  24.6k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  24.7k|}
demux_null.c:bstr0:
   62|  49.4k|{
   63|  49.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 49.4k, False: 0]
  ------------------
   64|  49.4k|}
demux_playlist.c:bstr_equals0:
  276|  87.7k|{
  277|  87.7k|    return bstr_equals(str1, bstr0(str2));
  278|  87.7k|}
demux_playlist.c:bstr_equals:
  268|  87.7k|{
  269|  87.7k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 86.3k, False: 1.42k]
  ------------------
  270|  86.3k|        return false;
  271|       |
  272|  1.42k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 1.42k]
  |  Branch (272:40): [True: 0, False: 1.42k]
  ------------------
  273|  87.7k|}
demux_playlist.c:bstr0:
   62|   467k|{
   63|   467k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 424k, False: 42.4k]
  ------------------
   64|   467k|}
demux_playlist.c:bstrto0:
   46|     98|{
   47|     98|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 98, False: 0]
  ------------------
   48|     98|}
demux_playlist.c:bstrdup0:
   40|     98|{
   41|     98|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|     98|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|     98|}
demux_playlist.c:bstrcasecmp0:
  281|  58.6k|{
  282|  58.6k|    return bstrcasecmp(str1, bstr0(str2));
  283|  58.6k|}
user_filters.c:bstr0:
   62|  9.34k|{
   63|  9.34k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 9.34k, False: 0]
  ------------------
   64|  9.34k|}
cmd.c:bstr_equals0:
  276|  32.3M|{
  277|  32.3M|    return bstr_equals(str1, bstr0(str2));
  278|  32.3M|}
cmd.c:bstr_equals:
  268|  32.3M|{
  269|  32.3M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 30.8M, False: 1.58M]
  ------------------
  270|  30.8M|        return false;
  271|       |
  272|  1.58M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 1.58M]
  |  Branch (272:40): [True: 1.10k, False: 1.58M]
  ------------------
  273|  32.3M|}
cmd.c:bstr0:
   62|  45.1M|{
   63|  45.1M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 45.1M, False: 0]
  ------------------
   64|  45.1M|}
cmd.c:bstr_cut:
  227|  3.11M|{
  228|  3.11M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 3.11M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  3.11M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 82, False: 3.11M]
  ------------------
  234|     82|        n = str.len;
  235|  3.11M|    return (struct bstr){str.start + n, str.len - n};
  236|  3.11M|}
cmd.c:bstr_eatstart0:
  291|  12.1M|{
  292|  12.1M|    return bstr_eatstart(s, bstr0(prefix));
  293|  12.1M|}
cmd.c:bstrto0:
   46|  1.14M|{
   47|  1.14M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 1.14M, False: 0]
  ------------------
   48|  1.14M|}
cmd.c:bstrdup0:
   40|  1.14M|{
   41|  1.14M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.14M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.14M|}
cmd.c:bstr_startswith0:
  246|  17.7k|{
  247|  17.7k|    return bstr_startswith(str, bstr0(prefix));
  248|  17.7k|}
cmd.c:bstr_startswith:
  239|  17.7k|{
  240|  17.7k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 5.43k, False: 12.3k]
  ------------------
  241|  5.43k|        return false;
  242|  12.3k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  17.7k|}
input.c:bstrdup:
   52|  12.2k|{
   53|  12.2k|    struct bstr r = { NULL, str.len };
   54|  12.2k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 12.2k, False: 0]
  ------------------
   55|  12.2k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  12.2k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  12.2k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  12.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  12.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  12.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  12.2k|    return r;
   57|  12.2k|}
input.c:bstr0:
   62|  53.4k|{
   63|  53.4k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 41.7k, False: 11.6k]
  ------------------
   64|  53.4k|}
input.c:bstrdup0:
   40|  1.25k|{
   41|  1.25k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.25k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.25k|}
input.c:bstr_equals0:
  276|     20|{
  277|     20|    return bstr_equals(str1, bstr0(str2));
  278|     20|}
input.c:bstr_getline:
  156|     99|{
  157|     99|    return bstr_splitchar(str, rest, '\n');
  158|     99|}
input.c:bstr_eatstart0:
  291|    113|{
  292|    113|    return bstr_eatstart(s, bstr0(prefix));
  293|    113|}
input.c:bstr_startswith0:
  246|     99|{
  247|     99|    return bstr_startswith(str, bstr0(prefix));
  248|     99|}
input.c:bstr_startswith:
  239|     99|{
  240|     99|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 0, False: 99]
  ------------------
  241|      0|        return false;
  242|     99|    return !memcmp(str.start, prefix.start, prefix.len);
  243|     99|}
input.c:bstr_equals:
  268|  5.67M|{
  269|  5.67M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 2.83M, False: 2.83M]
  ------------------
  270|  2.83M|        return false;
  271|       |
  272|  2.83M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 2.82M, False: 9.37k]
  |  Branch (272:40): [True: 3.65k, False: 5.72k]
  ------------------
  273|  5.67M|}
ipc.c:bstr_getline:
  156|  6.03M|{
  157|  6.03M|    return bstr_splitchar(str, rest, '\n');
  158|  6.03M|}
ipc.c:bstrto0:
   46|  6.03M|{
   47|  6.03M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 6.03M, False: 0]
  ------------------
   48|  6.03M|}
ipc.c:bstrdup0:
   40|  6.03M|{
   41|  6.03M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  6.03M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  6.03M|}
ipc.c:bstrdup:
   52|  6.03M|{
   53|  6.03M|    struct bstr r = { NULL, str.len };
   54|  6.03M|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 6.03M, False: 0]
  ------------------
   55|  6.03M|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  6.03M|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  6.03M|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  6.03M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  6.03M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  6.03M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  6.03M|    return r;
   57|  6.03M|}
keycodes.c:bstr0:
   62|  31.2k|{
   63|  31.2k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 31.2k, False: 0]
  ------------------
   64|  31.2k|}
keycodes.c:bstr_startswith0:
  246|  1.59k|{
  247|  1.59k|    return bstr_startswith(str, bstr0(prefix));
  248|  1.59k|}
keycodes.c:bstr_startswith:
  239|  1.59k|{
  240|  1.59k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 401, False: 1.19k]
  ------------------
  241|    401|        return false;
  242|  1.19k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  1.59k|}
bstr.c:bstr_startswith:
  239|   526M|{
  240|   526M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 21.3M, False: 504M]
  ------------------
  241|  21.3M|        return false;
  242|   504M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   526M|}
bstr.c:bstr_cut:
  227|   124M|{
  228|   124M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 124M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   124M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 10.2M, False: 114M]
  ------------------
  234|  10.2M|        n = str.len;
  235|   124M|    return (struct bstr){str.start + n, str.len - n};
  236|   124M|}
bstr.c:bstr0:
   62|  8.74M|{
   63|  8.74M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 8.74M, False: 0]
  ------------------
   64|  8.74M|}
bstr.c:bstr_endswith0:
  258|  2.41M|{
  259|  2.41M|    return bstr_endswith(str, bstr0(suffix));
  260|  2.41M|}
bstr.c:bstr_endswith:
  251|  2.41M|{
  252|  2.41M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 153k, False: 2.26M]
  ------------------
  253|   153k|        return false;
  254|  2.26M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  2.41M|}
bstr.c:bstrdup0:
   40|   147k|{
   41|   147k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   147k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   147k|}
bstr.c:bstrcasecmp0:
  281|   452k|{
  282|   452k|    return bstrcasecmp(str1, bstr0(str2));
  283|   452k|}
charset_conv.c:bstr0:
   62|   534k|{
   63|   534k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 534k, False: 0]
  ------------------
   64|   534k|}
charset_conv.c:bstr_startswith0:
  246|   519k|{
  247|   519k|    return bstr_startswith(str, bstr0(prefix));
  248|   519k|}
charset_conv.c:bstr_startswith:
  239|   519k|{
  240|   519k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 212k, False: 307k]
  ------------------
  241|   212k|        return false;
  242|   307k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   519k|}
codepoint_width.c:bstr_eatstart0:
  291|  94.2M|{
  292|  94.2M|    return bstr_eatstart(s, bstr0(prefix));
  293|  94.2M|}
codepoint_width.c:bstr0:
   62|  94.2M|{
   63|  94.2M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 94.2M, False: 0]
  ------------------
   64|  94.2M|}
codepoint_width.c:bstr_cut:
  227|  5.77k|{
  228|  5.77k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 5.77k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  5.77k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 5.77k]
  ------------------
  234|      0|        n = str.len;
  235|  5.77k|    return (struct bstr){str.start + n, str.len - n};
  236|  5.77k|}
json.c:bstr0:
   62|  67.7M|{
   63|  67.7M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 66.6M, False: 1.16M]
  ------------------
   64|  67.7M|}
language.c:bstr0:
   62|    553|{
   63|    553|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 553, False: 0]
  ------------------
   64|    553|}
language.c:bstrcasecmp0:
  281|    460|{
  282|    460|    return bstrcasecmp(str1, bstr0(str2));
  283|    460|}
node.c:bstr0:
   62|  5.63M|{
   63|  5.63M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 5.63M, False: 0]
  ------------------
   64|  5.63M|}
node.c:bstrdup0:
   40|  5.62M|{
   41|  5.62M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  5.62M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  5.62M|}
node.c:bstr_equals0:
  276|  2.60k|{
  277|  2.60k|    return bstr_equals(str1, bstr0(str2));
  278|  2.60k|}
node.c:bstr_equals:
  268|  2.60k|{
  269|  2.60k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 2.30k, False: 298]
  ------------------
  270|  2.30k|        return false;
  271|       |
  272|    298|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 298]
  |  Branch (272:40): [True: 0, False: 298]
  ------------------
  273|  2.60k|}
path_utils.c:bstr0:
   62|  55.3M|{
   63|  55.3M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 55.3M, False: 0]
  ------------------
   64|  55.3M|}
path_utils.c:bstrdup0:
   40|  23.3k|{
   41|  23.3k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  23.3k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  23.3k|}
path_utils.c:bstr_find0:
  286|  27.7M|{
  287|  27.7M|    return bstr_find(haystack, bstr0(needle));
  288|  27.7M|}
m_config_frontend.c:bstr0:
   62|  71.8M|{
   63|  71.8M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 71.8M, False: 0]
  ------------------
   64|  71.8M|}
m_config_frontend.c:bstrcmp0:
  263|  18.8M|{
  264|  18.8M|    return bstrcmp(str1, bstr0(str2));
  265|  18.8M|}
m_config_frontend.c:bstr_eatstart0:
  291|   160k|{
  292|   160k|    return bstr_eatstart(s, bstr0(prefix));
  293|   160k|}
m_config_frontend.c:bstr_startswith:
  239|  48.4M|{
  240|  48.4M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 33.8M, False: 14.6M]
  ------------------
  241|  33.8M|        return false;
  242|  14.6M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  48.4M|}
m_config_frontend.c:bstr_endswith:
  251|   163k|{
  252|   163k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 22, False: 163k]
  ------------------
  253|     22|        return false;
  254|   163k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|   163k|}
m_config_frontend.c:bstr_equals0:
  276|  3.78M|{
  277|  3.78M|    return bstr_equals(str1, bstr0(str2));
  278|  3.78M|}
m_config_frontend.c:bstr_equals:
  268|  3.78M|{
  269|  3.78M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 3.45M, False: 337k]
  ------------------
  270|  3.45M|        return false;
  271|       |
  272|   337k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 12.3k, False: 325k]
  |  Branch (272:40): [True: 24.6k, False: 300k]
  ------------------
  273|  3.78M|}
m_config_frontend.c:bstrto0:
   46|  1.37M|{
   47|  1.37M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 1.37M, False: 0]
  ------------------
   48|  1.37M|}
m_config_frontend.c:bstrdup0:
   40|  1.37M|{
   41|  1.37M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.37M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.37M|}
m_option.c:bstr_equals0:
  276|  2.83M|{
  277|  2.83M|    return bstr_equals(str1, bstr0(str2));
  278|  2.83M|}
m_option.c:bstr_equals:
  268|  5.09M|{
  269|  5.09M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 2.26M, False: 2.82M]
  ------------------
  270|  2.26M|        return false;
  271|       |
  272|  2.82M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 1.86M, False: 959k]
  |  Branch (272:40): [True: 854k, False: 104k]
  ------------------
  273|  5.09M|}
m_option.c:bstr0:
   62|  11.3M|{
   63|  11.3M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 7.74M, False: 3.59M]
  ------------------
   64|  11.3M|}
m_option.c:bstrcasecmp0:
  281|  38.6k|{
  282|  38.6k|    return bstrcasecmp(str1, bstr0(str2));
  283|  38.6k|}
m_option.c:bstrcmp0:
  263|   969k|{
  264|   969k|    return bstrcmp(str1, bstr0(str2));
  265|   969k|}
m_option.c:bstr_eatstart0:
  291|  1.36M|{
  292|  1.36M|    return bstr_eatstart(s, bstr0(prefix));
  293|  1.36M|}
m_option.c:bstrdup0:
   40|   852k|{
   41|   852k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   852k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   852k|}
m_option.c:bstr_endswith0:
  258|  1.39M|{
  259|  1.39M|    return bstr_endswith(str, bstr0(suffix));
  260|  1.39M|}
m_option.c:bstr_endswith:
  251|  1.39M|{
  252|  1.39M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 401k, False: 992k]
  ------------------
  253|   401k|        return false;
  254|   992k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  1.39M|}
m_option.c:bstr_cut:
  227|   443k|{
  228|   443k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 443k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   443k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 36.9k, False: 406k]
  ------------------
  234|  36.9k|        n = str.len;
  235|   443k|    return (struct bstr){str.start + n, str.len - n};
  236|   443k|}
m_option.c:bstrdup:
   52|  37.4k|{
   53|  37.4k|    struct bstr r = { NULL, str.len };
   54|  37.4k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 37.4k, False: 0]
  ------------------
   55|  37.4k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  37.4k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  37.4k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  37.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  37.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  37.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  37.4k|    return r;
   57|  37.4k|}
m_option.c:bstr_startswith0:
  246|  6.59k|{
  247|  6.59k|    return bstr_startswith(str, bstr0(prefix));
  248|  6.59k|}
m_option.c:bstr_startswith:
  239|  6.59k|{
  240|  6.59k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 2.27k, False: 4.31k]
  ------------------
  241|  2.27k|        return false;
  242|  4.31k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  6.59k|}
m_option.c:bstrto0:
   46|   263k|{
   47|   263k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 263k, False: 0]
  ------------------
   48|   263k|}
m_option.c:bstr_find0:
  286|   105k|{
  287|   105k|    return bstr_find(haystack, bstr0(needle));
  288|   105k|}
m_property.c:bstrcmp0:
  263|  82.8M|{
  264|  82.8M|    return bstrcmp(str1, bstr0(str2));
  265|  82.8M|}
m_property.c:bstr0:
   62|   338M|{
   63|   338M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 338M, False: 21.0k]
  ------------------
   64|   338M|}
m_property.c:bstr_eatstart0:
  291|   186M|{
  292|   186M|    return bstr_eatstart(s, bstr0(prefix));
  293|   186M|}
m_property.c:bstr_startswith0:
  246|  53.6M|{
  247|  53.6M|    return bstr_startswith(str, bstr0(prefix));
  248|  53.6M|}
m_property.c:bstr_startswith:
  239|  53.6M|{
  240|  53.6M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 3.14M, False: 50.5M]
  ------------------
  241|  3.14M|        return false;
  242|  50.5M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  53.6M|}
m_property.c:bstr_cut:
  227|  62.1M|{
  228|  62.1M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 62.1M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  62.1M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 62.1M]
  ------------------
  234|      0|        n = str.len;
  235|  62.1M|    return (struct bstr){str.start + n, str.len - n};
  236|  62.1M|}
m_property.c:bstrdup0:
   40|  8.42M|{
   41|  8.42M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  8.42M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  8.42M|}
m_property.c:bstr_equals0:
  276|  7.11k|{
  277|  7.11k|    return bstr_equals(str1, bstr0(str2));
  278|  7.11k|}
m_property.c:bstr_equals:
  268|  7.11k|{
  269|  7.11k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 6.91k, False: 195]
  ------------------
  270|  6.91k|        return false;
  271|       |
  272|    195|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 195]
  |  Branch (272:40): [True: 43, False: 152]
  ------------------
  273|  7.11k|}
parse_configfile.c:bstr_eatstart0:
  291|  3.14M|{
  292|  3.14M|    return bstr_eatstart(s, bstr0(prefix));
  293|  3.14M|}
parse_configfile.c:bstr0:
   62|  6.70M|{
   63|  6.70M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 6.70M, False: 0]
  ------------------
   64|  6.70M|}
parse_configfile.c:bstr_getline:
  156|  1.17M|{
  157|  1.17M|    return bstr_splitchar(str, rest, '\n');
  158|  1.17M|}
parse_configfile.c:bstr_startswith0:
  246|  3.56M|{
  247|  3.56M|    return bstr_startswith(str, bstr0(prefix));
  248|  3.56M|}
parse_configfile.c:bstr_startswith:
  239|  3.56M|{
  240|  3.56M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 1.03M, False: 2.52M]
  ------------------
  241|  1.03M|        return false;
  242|  2.52M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  3.56M|}
parse_configfile.c:bstrto0:
   46|   140k|{
   47|   140k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 140k, False: 0]
  ------------------
   48|   140k|}
parse_configfile.c:bstrdup0:
   40|   140k|{
   41|   140k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   140k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   140k|}
parse_configfile.c:bstr_cut:
  227|  9.30M|{
  228|  9.30M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 9.30M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  9.30M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 9.30M]
  ------------------
  234|      0|        n = str.len;
  235|  9.30M|    return (struct bstr){str.start + n, str.len - n};
  236|  9.30M|}
path.c:bstr0:
   62|   879k|{
   63|   879k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 856k, False: 23.3k]
  ------------------
   64|   879k|}
path.c:bstr_eatstart0:
  291|   227k|{
  292|   227k|    return bstr_eatstart(s, bstr0(prefix));
  293|   227k|}
path.c:bstr_equals0:
  276|  46.8k|{
  277|  46.8k|    return bstr_equals(str1, bstr0(str2));
  278|  46.8k|}
path.c:bstr_equals:
  268|  46.8k|{
  269|  46.8k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 46.7k, False: 42]
  ------------------
  270|  46.7k|        return false;
  271|       |
  272|     42|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 42]
  |  Branch (272:40): [True: 2, False: 40]
  ------------------
  273|  46.8k|}
client.c:bstr0:
   62|  2.86M|{
   63|  2.86M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 2.86M, False: 0]
  ------------------
   64|  2.86M|}
command.c:bstrdup0:
   40|  3.92k|{
   41|  3.92k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  3.92k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  3.92k|}
command.c:bstr_equals0:
  276|    395|{
  277|    395|    return bstr_equals(str1, bstr0(str2));
  278|    395|}
command.c:bstr_equals:
  268|    395|{
  269|    395|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 0, False: 395]
  ------------------
  270|      0|        return false;
  271|       |
  272|    395|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 395]
  |  Branch (272:40): [True: 346, False: 49]
  ------------------
  273|    395|}
command.c:bstr0:
   62|  28.5M|{
   63|  28.5M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 28.5M, False: 21.9k]
  ------------------
   64|  28.5M|}
configfiles.c:bstr0:
   62|  32.3k|{
   63|  32.3k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.3k, False: 0]
  ------------------
   64|  32.3k|}
external_files.c:bstr0:
   62|  28.8k|{
   63|  28.8k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 28.8k, False: 0]
  ------------------
   64|  28.8k|}
external_files.c:bstrdup:
   52|  14.4k|{
   53|  14.4k|    struct bstr r = { NULL, str.len };
   54|  14.4k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 14.4k, False: 0]
  ------------------
   55|  14.4k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  14.4k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  14.4k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  14.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  14.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  14.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  14.4k|    return r;
   57|  14.4k|}
external_files.c:bstrdup0:
   40|  14.4k|{
   41|  14.4k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  14.4k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  14.4k|}
loadfile.c:bstr0:
   62|  25.0k|{
   63|  25.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 25.0k, False: 0]
  ------------------
   64|  25.0k|}
loadfile.c:bstrdup0:
   40|      2|{
   41|      2|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|      2|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|      2|}
loadfile.c:bstrto0:
   46|      2|{
   47|      2|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 2, False: 0]
  ------------------
   48|      2|}
loadfile.c:bstr_xappend0:
  180|      2|{
  181|      2|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|      2|}
main.c:bstr0:
   62|  11.6k|{
   63|  11.6k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 11.6k, False: 0]
  ------------------
   64|  11.6k|}
misc.c:bstr0:
   62|   424k|{
   63|   424k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 424k, False: 0]
  ------------------
   64|   424k|}
misc.c:bstr_xappend0:
  180|   424k|{
  181|   424k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|   424k|}
misc.c:bstrto0:
   46|   179k|{
   47|   179k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 179k, False: 0]
  ------------------
   48|   179k|}
misc.c:bstrdup0:
   40|   179k|{
   41|   179k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   179k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   179k|}
osd.c:bstr0:
   62|  42.1k|{
   63|  42.1k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 21.0k, False: 21.0k]
  ------------------
   64|  42.1k|}
osd.c:bstr_equals:
  268|  21.0k|{
  269|  21.0k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 0, False: 21.0k]
  ------------------
  270|      0|        return false;
  271|       |
  272|  21.0k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 21.0k]
  |  Branch (272:40): [True: 21.0k, False: 0]
  ------------------
  273|  21.0k|}
screenshot.c:bstr0:
   62|     34|{
   63|     34|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 34, False: 0]
  ------------------
   64|     34|}
screenshot.c:bstrto0:
   46|  34.4k|{
   47|  34.4k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 34.4k, False: 0]
  ------------------
   48|  34.4k|}
screenshot.c:bstrdup0:
   40|  34.4k|{
   41|  34.4k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  34.4k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  34.4k|}
scripting.c:bstrcasecmp0:
  281|  3.31k|{
  282|  3.31k|    return bstrcasecmp(str1, bstr0(str2));
  283|  3.31k|}
scripting.c:bstr0:
   62|  16.0k|{
   63|  16.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 16.0k, False: 0]
  ------------------
   64|  16.0k|}
stream.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|}
stream.c:bstr_startswith0:
  246|   191k|{
  247|   191k|    return bstr_startswith(str, bstr0(prefix));
  248|   191k|}
stream.c:bstr_startswith:
  239|   191k|{
  240|   191k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 47.9k, False: 143k]
  ------------------
  241|  47.9k|        return false;
  242|   143k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   191k|}
stream_aes_ctr.c:bstr0:
   62|     16|{
   63|     16|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 16, False: 0]
  ------------------
   64|     16|}
stream_cb.c:bstr0:
   62|  30.1k|{
   63|  30.1k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 30.1k, False: 0]
  ------------------
   64|  30.1k|}
stream_cb.c:bstrto0:
   46|  30.1k|{
   47|  30.1k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 30.1k, False: 0]
  ------------------
   48|  30.1k|}
stream_cb.c:bstrdup0:
   40|  30.1k|{
   41|  30.1k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  30.1k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  30.1k|}
stream_file.c:bstrcasecmp0:
  281|  39.8k|{
  282|  39.8k|    return bstrcasecmp(str1, bstr0(str2));
  283|  39.8k|}
stream_file.c:bstr0:
   62|   118k|{
   63|   118k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 118k, False: 0]
  ------------------
   64|   118k|}
stream_file.c:bstrto0:
   46|     99|{
   47|     99|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 99, False: 0]
  ------------------
   48|     99|}
stream_file.c:bstrdup0:
   40|     99|{
   41|     99|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|     99|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|     99|}
stream_file.c:bstr_startswith0:
  246|  25.9k|{
  247|  25.9k|    return bstr_startswith(str, bstr0(prefix));
  248|  25.9k|}
stream_file.c:bstr_startswith:
  239|  25.9k|{
  240|  25.9k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 21.1k, False: 4.79k]
  ------------------
  241|  21.1k|        return false;
  242|  4.79k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  25.9k|}
stream_lavf.c:bstr0:
   62|   380k|{
   63|   380k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 380k, False: 0]
  ------------------
   64|   380k|}
stream_lavf.c:bstr_eatstart0:
  291|   175k|{
  292|   175k|    return bstr_eatstart(s, bstr0(prefix));
  293|   175k|}
stream_lavf.c:bstr_equals0:
  276|   146k|{
  277|   146k|    return bstr_equals(str1, bstr0(str2));
  278|   146k|}
stream_lavf.c:bstr_equals:
  268|   146k|{
  269|   146k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 146k, False: 318]
  ------------------
  270|   146k|        return false;
  271|       |
  272|    318|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 318]
  |  Branch (272:40): [True: 0, False: 318]
  ------------------
  273|   146k|}
stream_memory.c:bstr0:
   62|   245k|{
   63|   245k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 245k, False: 0]
  ------------------
   64|   245k|}
stream_memory.c:bstr_eatstart0:
  291|   163k|{
  292|   163k|    return bstr_eatstart(s, bstr0(prefix));
  293|   163k|}
stream_memory.c:bstrdup:
   52|  82.4k|{
   53|  82.4k|    struct bstr r = { NULL, str.len };
   54|  82.4k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 82.4k, False: 0]
  ------------------
   55|  82.4k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  82.4k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  82.4k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  82.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  82.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  82.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  82.4k|    return r;
   57|  82.4k|}
stream_slice.c:bstr0:
   62|    118|{
   63|    118|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 118, False: 0]
  ------------------
   64|    118|}
stream_slice.c:bstrto0:
   46|     60|{
   47|     60|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 60, False: 0]
  ------------------
   48|     60|}
stream_slice.c:bstrdup0:
   40|     60|{
   41|     60|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|     60|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|     60|}
stream_env.c:bstr0:
   62|     20|{
   63|     20|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 20, False: 0]
  ------------------
   64|     20|}
stream_env.c:bstr_eatstart0:
  291|     10|{
  292|     10|    return bstr_eatstart(s, bstr0(prefix));
  293|     10|}
stream_env.c:bstrdup0:
   40|     10|{
   41|     10|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|     10|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|     10|}
osd_libass.c:bstr0:
   62|     82|{
   63|     82|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 82, False: 0]
  ------------------
   64|     82|}
sd_ass.c:bstrto0:
   46|  25.4k|{
   47|  25.4k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|  23.2k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 2.22k, False: 23.2k]
  ------------------
   48|  25.4k|}
sd_ass.c:bstrdup0:
   40|  2.22k|{
   41|  2.22k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  2.22k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  2.22k|}
sd_ass.c:bstr_cut:
  227|    880|{
  228|    880|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 880]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|    880|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 880]
  ------------------
  234|      0|        n = str.len;
  235|    880|    return (struct bstr){str.start + n, str.len - n};
  236|    880|}
csputils.c:bstr0:
   62|     78|{
   63|     78|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 78, False: 0]
  ------------------
   64|     78|}
vd_lavc.c:bstr0:
   62|   358k|{
   63|   358k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 358k, False: 0]
  ------------------
   64|   358k|}
vd_lavc.c:bstr_equals0:
  276|   328k|{
  277|   328k|    return bstr_equals(str1, bstr0(str2));
  278|   328k|}
vd_lavc.c:bstr_equals:
  268|   328k|{
  269|   328k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 298k, False: 29.8k]
  ------------------
  270|   298k|        return false;
  271|       |
  272|  29.8k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 29.8k]
  |  Branch (272:40): [True: 29.8k, False: 70]
  ------------------
  273|   328k|}
hwdec.c:bstr0:
   62|     32|{
   63|     32|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32, False: 0]
  ------------------
   64|     32|}
hwdec.c:bstr_equals:
  268|     16|{
  269|     16|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 10, False: 6]
  ------------------
  270|     10|        return false;
  271|       |
  272|      6|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 6]
  |  Branch (272:40): [True: 0, False: 6]
  ------------------
  273|     16|}
hwdec.c:bstr_equals0:
  276|     16|{
  277|     16|    return bstr_equals(str1, bstr0(str2));
  278|     16|}
image_writer.c:bstrcmp0:
  263|    204|{
  264|    204|    return bstrcmp(str1, bstr0(str2));
  265|    204|}
image_writer.c:bstr0:
   62|    204|{
   63|    204|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 204, False: 0]
  ------------------
   64|    204|}
img_format.c:bstr_equals0:
  276|  85.1k|{
  277|  85.1k|    return bstr_equals(str1, bstr0(str2));
  278|  85.1k|}
img_format.c:bstr0:
   62|  85.1k|{
   63|  85.1k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 85.1k, False: 0]
  ------------------
   64|  85.1k|}
img_format.c:bstr_equals:
  268|  88.3k|{
  269|  88.3k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 77.9k, False: 10.4k]
  ------------------
  270|  77.9k|        return false;
  271|       |
  272|  10.4k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 10.4k]
  |  Branch (272:40): [True: 0, False: 10.4k]
  ------------------
  273|  88.3k|}
vo.c:bstr0:
   62|  31.9k|{
   63|  31.9k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 31.9k, False: 0]
  ------------------
   64|  31.9k|}
fuzzer_ipc.c:bstrdup:
   52|  6.03M|{
   53|  6.03M|    struct bstr r = { NULL, str.len };
   54|  6.03M|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 6.03M, False: 0]
  ------------------
   55|  6.03M|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  6.03M|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  6.03M|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  6.03M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  6.03M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  6.03M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  6.03M|    return r;
   57|  6.03M|}
fuzzer_ipc.c:bstr_getline:
  156|  6.03M|{
  157|  6.03M|    return bstr_splitchar(str, rest, '\n');
  158|  6.03M|}

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

term_disp_width:
  681|  2.39M|{
  682|  2.39M|    static const int ambiguous_width = 1;
  683|       |
  684|  2.39M|    int width = 0;
  685|       |
  686|  2.39M|    const unsigned char *prev_pos = str.start;
  687|  96.6M|    while (str.len) {
  ------------------
  |  Branch (687:12): [True: 94.2M, False: 2.39M]
  ------------------
  688|  94.2M|        int current_width = 0;
  689|       |
  690|  94.2M|        if (bstr_eatstart0(&str, "\033[")) {
  ------------------
  |  Branch (690:13): [True: 373, False: 94.2M]
  ------------------
  691|  5.77k|            while (str.len && !((*str.start >= '@' && *str.start <= '~') || *str.start == 'm'))
  ------------------
  |  Branch (691:20): [True: 5.77k, False: 0]
  |  Branch (691:34): [True: 373, False: 5.40k]
  |  Branch (691:55): [True: 373, False: 0]
  |  Branch (691:77): [True: 0, False: 5.40k]
  ------------------
  692|  5.40k|                str = bstr_cut(str, 1);
  693|    373|            str = bstr_cut(str, 1);
  694|    373|            goto next;
  695|    373|        }
  696|       |
  697|  94.2M|        prev_pos = str.start;
  698|  94.2M|        int cp = bstr_decode_partial_utf8(&str);
  699|       |
  700|       |        // Assume the terminal replaces maximal ill-formed subparts with
  701|       |        // a single U+FFFD replacement character as described in
  702|       |        // https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G66453
  703|  94.2M|        if (cp < 0) {
  ------------------
  |  Branch (703:13): [True: 604k, False: 93.6M]
  ------------------
  704|   604k|            struct bstr partial = {(unsigned char *)prev_pos, str.start - prev_pos};
  705|   604k|            if (cp == BSTR_DECODE_TRUNCATED_SEQUENCE &&
  ------------------
  |  |   92|  1.20M|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  |  Branch (705:17): [True: 377k, False: 227k]
  ------------------
  706|   377k|                is_valid_partial_sequence(partial))
  ------------------
  |  Branch (706:17): [True: 376k, False: 1.18k]
  ------------------
  707|   376k|            {
  708|       |                // This is a truncated but initially well-formed sequence,
  709|       |                // should be replaced with a single U+FFFD.
  710|   376k|                current_width = 1;
  711|   376k|            } else {
  712|       |                // Otherwise each byte should be replaced individually.
  713|   228k|                current_width = partial.len;
  714|   228k|            }
  715|   604k|            goto next;
  716|   604k|        }
  717|       |
  718|  93.6M|        if (cp == '\r') {
  ------------------
  |  Branch (718:13): [True: 5.24k, False: 93.6M]
  ------------------
  719|  5.24k|            width = 0;
  720|  5.24k|            goto next;
  721|  5.24k|        }
  722|       |
  723|  93.6M|        if (cp == '\t') {
  ------------------
  |  Branch (723:13): [True: 592, False: 93.6M]
  ------------------
  724|       |            // Assume tabstop width is 8
  725|    592|            current_width = 8 - width % 8;
  726|    592|            goto next;
  727|    592|        }
  728|       |
  729|  93.6M|        if (cp < 0x20)
  ------------------
  |  Branch (729:13): [True: 1.33M, False: 92.2M]
  ------------------
  730|  1.33M|            goto next;
  731|       |
  732|  92.2M|        if (cp <= 0x7E) {
  ------------------
  |  Branch (732:13): [True: 92.2M, False: 28.3k]
  ------------------
  733|  92.2M|            current_width = 1;
  734|  92.2M|            goto next;
  735|  92.2M|        }
  736|       |
  737|  28.3k|        int state = 0;
  738|       |
  739|  28.4k|        while (true) {
  ------------------
  |  Branch (739:16): [True: 28.4k, Folded]
  ------------------
  740|  28.4k|            int lead = ucdLookup(cp);
  741|  28.4k|            int w = ucdToCharacterWidth(lead);
  742|  28.4k|            if (w == 3)
  ------------------
  |  Branch (742:17): [True: 3.68k, False: 24.8k]
  ------------------
  743|  3.68k|                w = ambiguous_width;
  744|       |
  745|       |            // U+FE0F Variation Selector-16 is used to turn unqualified Emojis into qualified ones.
  746|       |            // By convention, this turns them from being ambiguous width (= narrow) into wide ones.
  747|       |            // We achieve this here by explicitly giving this codepoint a wide width.
  748|       |            // Later down below we'll clamp width back to <= 2.
  749|  28.4k|            if (cp == 0xFE0F)
  ------------------
  |  Branch (749:17): [True: 0, False: 28.4k]
  ------------------
  750|      0|                w = 2;
  751|       |
  752|  28.4k|            current_width += w;
  753|       |
  754|  28.4k|            if (!str.len)
  ------------------
  |  Branch (754:17): [True: 0, False: 28.4k]
  ------------------
  755|      0|                break;
  756|       |
  757|       |            // Fetch next codepoint in grapheme cluster
  758|  28.4k|            bstr cluster_end;
  759|  28.4k|            cp = bstr_decode_utf8(str, &cluster_end);
  760|       |            // Invalid sequences end the current grapheme.
  761|  28.4k|            if (cp < 0)
  ------------------
  |  Branch (761:17): [True: 1.41k, False: 27.0k]
  ------------------
  762|  1.41k|                break;
  763|  27.0k|            int trail = ucdLookup(cp);
  764|       |
  765|  27.0k|            state = ucdGraphemeJoins(state, lead, trail);
  766|  27.0k|            if (ucdGraphemeDone(state))
  ------------------
  |  Branch (766:17): [True: 26.9k, False: 127]
  ------------------
  767|  26.9k|                break;
  768|       |
  769|    127|            str = cluster_end;
  770|    127|        }
  771|       |
  772|  28.3k|        current_width = MPMIN(current_width, 2);
  ------------------
  |  |   45|  28.3k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 28.3k]
  |  |  ------------------
  ------------------
  773|  94.2M|next:
  774|  94.2M|        if (width + current_width > max_width) {
  ------------------
  |  Branch (774:13): [True: 0, False: 94.2M]
  ------------------
  775|      0|            mp_assert(prev_pos < str.start + str.len);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            *cut_pos = prev_pos;
  777|      0|            break;
  778|      0|        }
  779|  94.2M|        width += current_width;
  780|  94.2M|        if (width == max_width) {
  ------------------
  |  Branch (780:13): [True: 0, False: 94.2M]
  ------------------
  781|      0|            if (str.len)
  ------------------
  |  Branch (781:17): [True: 0, False: 0]
  ------------------
  782|      0|                *cut_pos = str.start;
  783|      0|            break;
  784|      0|        }
  785|  94.2M|    }
  786|       |
  787|  2.39M|    return width;
  788|  2.39M|}
codepoint_width.c:is_valid_partial_sequence:
  665|   377k|{
  666|   377k|    if (seq.len < 2)
  ------------------
  |  Branch (666:9): [True: 374k, False: 2.51k]
  ------------------
  667|   374k|        return true;
  668|       |
  669|  2.51k|    if (seq.start[0] == 0xE0)
  ------------------
  |  Branch (669:9): [True: 34, False: 2.47k]
  ------------------
  670|     34|        return seq.start[1] >= 0xA0;
  671|  2.47k|    else if (seq.start[0] == 0xED)
  ------------------
  |  Branch (671:14): [True: 1.15k, False: 1.32k]
  ------------------
  672|  1.15k|        return seq.start[1] <= 0x9F;
  673|  1.32k|    else if (seq.start[0] == 0xF0)
  ------------------
  |  Branch (673:14): [True: 396, False: 932]
  ------------------
  674|    396|        return seq.start[1] >= 0x90;
  675|    932|    else if (seq.start[0] == 0xF4)
  ------------------
  |  Branch (675:14): [True: 33, False: 899]
  ------------------
  676|     33|        return seq.start[1] <= 0x8F;
  677|    899|    return true;
  678|  2.51k|}
codepoint_width.c:ucdLookup:
  618|  55.5k|{
  619|  55.5k|    const uint16_t s0 = s_stage0[cp >> 11];
  620|  55.5k|    const uint16_t s1 = s_stage1[s0 + ((cp >> 6) & 31)];
  621|  55.5k|    const uint16_t s2 = s_stage2[s1 + ((cp >> 3) & 7)];
  622|  55.5k|    const uint8_t s3 = s_stage3[s2 + ((cp >> 0) & 7)];
  623|  55.5k|    return s3;
  624|  55.5k|}
codepoint_width.c:ucdToCharacterWidth:
  636|  28.4k|{
  637|  28.4k|    return val >> 6;
  638|  28.4k|}
codepoint_width.c:ucdGraphemeJoins:
  626|  27.0k|{
  627|  27.0k|    const int l = lead & 15;
  628|  27.0k|    const int t = trail & 15;
  629|  27.0k|    return (s_joinRules[state][l] >> (t * 2)) & 3;
  630|  27.0k|}
codepoint_width.c:ucdGraphemeDone:
  632|  27.0k|{
  633|  27.0k|    return state == 3;
  634|  27.0k|}

demux_mf.c:mp_isdigit:
   12|    126|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 103, False: 23]
  |  Branch (12:59): [True: 85, False: 18]
  ------------------
bstr.c:mp_isspace:
    8|  19.0M|static inline int mp_isspace(char c) { return c == ' ' || c == '\f' || c == '\n' ||
  ------------------
  |  Branch (8:47): [True: 733k, False: 18.3M]
  |  Branch (8:59): [True: 61.3k, False: 18.2M]
  |  Branch (8:72): [True: 1.33M, False: 16.9M]
  ------------------
    9|  16.9M|                                              c == '\r' || c == '\t' || c =='\v'; }
  ------------------
  |  Branch (9:47): [True: 365k, False: 16.5M]
  |  Branch (9:60): [True: 100k, False: 16.4M]
  |  Branch (9:73): [True: 328k, False: 16.1M]
  ------------------
json.c:mp_isalpha:
   13|   745k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 9.51k, False: 736k]
  |  Branch (13:64): [True: 247k, False: 488k]
  ------------------
json.c:mp_isupper:
   10|   745k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 330k, False: 415k]
  |  Branch (10:59): [True: 9.51k, False: 320k]
  ------------------
json.c:mp_islower:
   11|   736k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 312k, False: 423k]
  |  Branch (11:59): [True: 247k, False: 64.5k]
  ------------------
json.c:mp_isalnum:
   14|   262k|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 215k, False: 47.7k]
  |  Branch (14:64): [True: 617, False: 47.1k]
  ------------------
json.c:mp_isdigit:
   12|  47.7k|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 20.8k, False: 26.9k]
  |  Branch (12:59): [True: 617, False: 20.1k]
  ------------------
language.c:mp_isalpha:
   13|  8.51k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 1.11k, False: 7.39k]
  |  Branch (13:64): [True: 3.30k, False: 4.09k]
  ------------------
language.c:mp_isupper:
   10|  8.51k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 4.56k, False: 3.94k]
  |  Branch (10:59): [True: 1.11k, False: 3.44k]
  ------------------
language.c:mp_islower:
   11|  7.39k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 3.38k, False: 4.01k]
  |  Branch (11:59): [True: 3.30k, False: 80]
  ------------------
path_utils.c:mp_isalpha:
   13|  83.3M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 10.0k, False: 83.3M]
  |  Branch (13:64): [True: 83.3M, False: 18.2k]
  ------------------
path_utils.c:mp_isupper:
   10|  83.3M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 83.3M, False: 18.0k]
  |  Branch (10:59): [True: 10.0k, False: 83.3M]
  ------------------
path_utils.c:mp_islower:
   11|  83.3M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 83.3M, False: 18.0k]
  |  Branch (11:59): [True: 83.3M, False: 224]
  ------------------
path_utils.c:mp_isalnum:
   14|  55.7M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 55.7M, False: 9.77k]
  |  Branch (14:64): [True: 3.56k, False: 6.20k]
  ------------------
path_utils.c:mp_isdigit:
   12|  9.77k|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 3.88k, False: 5.89k]
  |  Branch (12:59): [True: 3.56k, False: 315]
  ------------------
parse_configfile.c:mp_isalnum:
   14|  10.0M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 8.49M, False: 1.55M]
  |  Branch (14:64): [True: 0, False: 1.55M]
  ------------------
parse_configfile.c:mp_isalpha:
   13|  10.0M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 10, False: 10.0M]
  |  Branch (13:64): [True: 8.49M, False: 1.55M]
  ------------------
parse_configfile.c:mp_isupper:
   10|  10.0M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 8.49M, False: 1.55M]
  |  Branch (10:59): [True: 10, False: 8.49M]
  ------------------
parse_configfile.c:mp_islower:
   11|  10.0M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 8.49M, False: 1.55M]
  |  Branch (11:59): [True: 8.49M, False: 0]
  ------------------
parse_configfile.c:mp_isdigit:
   12|  1.55M|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 747k, False: 805k]
  |  Branch (12:59): [True: 0, False: 747k]
  ------------------
client.c:mp_isalnum:
   14|   116k|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 116k, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
client.c:mp_isalpha:
   13|   116k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 116k]
  |  Branch (13:64): [True: 116k, False: 0]
  ------------------
client.c:mp_isupper:
   10|   116k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 116k, False: 0]
  |  Branch (10:59): [True: 0, False: 116k]
  ------------------
client.c:mp_islower:
   11|   116k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 116k, False: 0]
  |  Branch (11:59): [True: 116k, False: 0]
  ------------------

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

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

json_skip_whitespace:
   79|  6.03M|{
   80|  6.03M|    eat_ws(src);
   81|  6.03M|}
json_parse:
  190|   497k|{
  191|   497k|    max_depth -= 1;
  192|   497k|    if (max_depth < 0)
  ------------------
  |  Branch (192:9): [True: 6, False: 497k]
  ------------------
  193|      6|        return -1;
  194|       |
  195|   497k|    eat_ws(src);
  196|       |
  197|   497k|    char c = **src;
  198|   497k|    if (!c)
  ------------------
  |  Branch (198:9): [True: 609, False: 496k]
  ------------------
  199|    609|        return -1; // early EOF
  200|   496k|    if (c == 'n' && strncmp(*src, "null", 4) == 0) {
  ------------------
  |  Branch (200:9): [True: 745, False: 495k]
  |  Branch (200:21): [True: 299, False: 446]
  ------------------
  201|    299|        *src += 4;
  202|    299|        dst->format = MPV_FORMAT_NONE;
  203|    299|        return 0;
  204|   496k|    } else if (c == 't' && strncmp(*src, "true", 4) == 0) {
  ------------------
  |  Branch (204:16): [True: 184, False: 496k]
  |  Branch (204:28): [True: 10, False: 174]
  ------------------
  205|     10|        *src += 4;
  206|     10|        dst->format = MPV_FORMAT_FLAG;
  207|     10|        dst->u.flag = 1;
  208|     10|        return 0;
  209|   496k|    } else if (c == 'f' && strncmp(*src, "false", 5) == 0) {
  ------------------
  |  Branch (209:16): [True: 483, False: 495k]
  |  Branch (209:28): [True: 0, False: 483]
  ------------------
  210|      0|        *src += 5;
  211|      0|        dst->format = MPV_FORMAT_FLAG;
  212|      0|        dst->u.flag = 0;
  213|      0|        return 0;
  214|   496k|    } else if (c == '"') {
  ------------------
  |  Branch (214:16): [True: 3.24k, False: 493k]
  ------------------
  215|  3.24k|        return read_str(ta_parent, dst, src);
  216|   493k|    } else if (c == '[' || c == '{') {
  ------------------
  |  Branch (216:16): [True: 1.51k, False: 491k]
  |  Branch (216:28): [True: 481k, False: 9.64k]
  ------------------
  217|   483k|        return read_sub(ta_parent, dst, src, max_depth);
  218|   483k|    } else if (c == '-' || (c >= '0' && c <= '9')) {
  ------------------
  |  Branch (218:16): [True: 360, False: 9.28k]
  |  Branch (218:29): [True: 8.04k, False: 1.23k]
  |  Branch (218:41): [True: 5.85k, False: 2.19k]
  ------------------
  219|       |        // The number could be either a float or an int. JSON doesn't make a
  220|       |        // difference, but the client API does.
  221|  6.21k|        char *nsrci = *src, *nsrcf = *src;
  222|  6.21k|        errno = 0;
  223|  6.21k|        long long int numi = strtoll(*src, &nsrci, 0);
  224|  6.21k|        if (errno)
  ------------------
  |  Branch (224:13): [True: 294, False: 5.92k]
  ------------------
  225|    294|            nsrci = *src;
  226|  6.21k|        errno = 0;
  227|  6.21k|        double numf = strtod(*src, &nsrcf);
  228|  6.21k|        if (errno)
  ------------------
  |  Branch (228:13): [True: 23, False: 6.19k]
  ------------------
  229|     23|            nsrcf = *src;
  230|  6.21k|        if (nsrci >= nsrcf) {
  ------------------
  |  Branch (230:13): [True: 5.82k, False: 391]
  ------------------
  231|  5.82k|            *src = nsrci;
  232|  5.82k|            dst->format = MPV_FORMAT_INT64; // long long is usually 64 bits
  233|  5.82k|            dst->u.int64 = numi;
  234|  5.82k|            return 0;
  235|  5.82k|        }
  236|    391|        if (nsrcf > *src && isfinite(numf)) {
  ------------------
  |  Branch (236:13): [True: 391, False: 0]
  |  Branch (236:29): [True: 390, False: 1]
  ------------------
  237|    390|            *src = nsrcf;
  238|    390|            dst->format = MPV_FORMAT_DOUBLE;
  239|    390|            dst->u.double_ = numf;
  240|    390|            return 0;
  241|    390|        }
  242|      1|        return -1;
  243|    391|    }
  244|  3.43k|    return -1; // character doesn't start a valid token
  245|   496k|}
json_append:
  295|  13.7M|{
  296|  13.7M|    switch (src->format) {
  ------------------
  |  Branch (296:13): [True: 13.7M, False: 0]
  ------------------
  297|      0|    case MPV_FORMAT_NONE:
  ------------------
  |  Branch (297:5): [True: 0, False: 13.7M]
  ------------------
  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: 13.7M]
  ------------------
  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|   500k|    case MPV_FORMAT_INT64:
  ------------------
  |  Branch (303:5): [True: 500k, False: 13.2M]
  ------------------
  304|   500k|        bstr_xappend_asprintf(NULL, b, "%"PRId64, src->u.int64);
  305|   500k|        return 0;
  306|      0|    case MPV_FORMAT_DOUBLE: {
  ------------------
  |  Branch (306:5): [True: 0, False: 13.7M]
  ------------------
  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|  7.23M|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (311:5): [True: 7.23M, False: 6.55M]
  ------------------
  312|  7.23M|        if (indent == 0)
  ------------------
  |  Branch (312:13): [True: 0, False: 7.23M]
  ------------------
  313|      0|            APPEND(b, src->u.string);
  ------------------
  |  |  248|      0|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  314|  7.23M|        else
  315|  7.23M|            write_json_str(b, src->u.string);
  316|  7.23M|        return 0;
  317|    677|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (317:5): [True: 677, False: 13.7M]
  ------------------
  318|  6.05M|    case MPV_FORMAT_NODE_MAP: {
  ------------------
  |  Branch (318:5): [True: 6.05M, False: 7.73M]
  ------------------
  319|  6.05M|        struct mpv_node_list *list = src->u.list;
  320|  6.05M|        bool is_obj = src->format == MPV_FORMAT_NODE_MAP;
  321|  6.05M|        APPEND(b, is_obj ? "{" : "[");
  ------------------
  |  |  248|  12.1M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  |  |  ------------------
  |  |  |  Branch (248:52): [True: 6.05M, False: 677]
  |  |  ------------------
  ------------------
  322|  6.05M|        int next_indent = indent >= 0 ? indent + 1 : -1;
  ------------------
  |  Branch (322:27): [True: 0, False: 6.05M]
  ------------------
  323|  12.6M|        for (int n = 0; n < list->num; n++) {
  ------------------
  |  Branch (323:25): [True: 6.56M, False: 6.05M]
  ------------------
  324|  6.56M|            if (n)
  ------------------
  |  Branch (324:17): [True: 514k, False: 6.05M]
  ------------------
  325|   514k|                APPEND(b, ",");
  ------------------
  |  |  248|   514k|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  326|  6.56M|            add_indent(b, next_indent);
  327|  6.56M|            if (is_obj) {
  ------------------
  |  Branch (327:17): [True: 6.55M, False: 6.48k]
  ------------------
  328|  6.55M|                write_json_str(b, list->keys[n]);
  329|  6.55M|                APPEND(b, ":");
  ------------------
  |  |  248|  6.55M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  330|  6.55M|            }
  331|  6.56M|            json_append(b, &list->values[n], next_indent);
  332|  6.56M|        }
  333|  6.05M|        add_indent(b, indent);
  334|  6.05M|        APPEND(b, is_obj ? "}" : "]");
  ------------------
  |  |  248|  12.1M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  |  |  ------------------
  |  |  |  Branch (248:52): [True: 6.05M, False: 677]
  |  |  ------------------
  ------------------
  335|  6.05M|        return 0;
  336|    677|    }
  337|  13.7M|    }
  338|      0|    return -1; // unknown format
  339|  13.7M|}
json_write:
  355|  7.22M|{
  356|  7.22M|    return json_append_str(dst, src, -1);
  357|  7.22M|}
json.c:eat_ws:
   69|  7.58M|{
   70|  10.9M|    while (1) {
  ------------------
  |  Branch (70:12): [True: 10.9M, Folded]
  ------------------
   71|  10.9M|        char c = **src;
   72|  10.9M|        if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
  ------------------
  |  Branch (72:13): [True: 10.8M, False: 76.2k]
  |  Branch (72:25): [True: 10.7M, False: 103k]
  |  Branch (72:38): [True: 7.82M, False: 2.89M]
  |  Branch (72:51): [True: 7.58M, False: 245k]
  ------------------
   73|  7.58M|            return;
   74|  3.32M|        *src += 1;
   75|  3.32M|    }
   76|  7.58M|}
json.c:read_str:
  102|   441k|{
  103|   441k|    if (!eat_c(src, '"'))
  ------------------
  |  Branch (103:9): [True: 420k, False: 21.7k]
  ------------------
  104|   420k|        return -1; // not a string
  105|  21.7k|    char *str = *src;
  106|  21.7k|    char *cur = str;
  107|  21.7k|    bool has_escapes = false;
  108|   205k|    while (cur[0] && cur[0] != '"') {
  ------------------
  |  Branch (108:12): [True: 197k, False: 8.26k]
  |  Branch (108:22): [True: 184k, False: 13.4k]
  ------------------
  109|   184k|        if (cur[0] == '\\') {
  ------------------
  |  Branch (109:13): [True: 13.1k, False: 170k]
  ------------------
  110|  13.1k|            has_escapes = true;
  111|       |            // skip >\"< and >\\< (latter to handle >\\"< correctly)
  112|  13.1k|            if (cur[1] == '"' || cur[1] == '\\')
  ------------------
  |  Branch (112:17): [True: 266, False: 12.8k]
  |  Branch (112:34): [True: 2.17k, False: 10.6k]
  ------------------
  113|  2.44k|                cur++;
  114|  13.1k|        }
  115|   184k|        cur++;
  116|   184k|    }
  117|  21.7k|    if (cur[0] != '"')
  ------------------
  |  Branch (117:9): [True: 8.26k, False: 13.4k]
  ------------------
  118|  8.26k|        return -1; // invalid termination
  119|       |    // Mutate input string so we have a null-terminated string to the literal.
  120|       |    // This is a stupid micro-optimization, so we can avoid allocation.
  121|  13.4k|    cur[0] = '\0';
  122|  13.4k|    *src = cur + 1;
  123|  13.4k|    if (has_escapes) {
  ------------------
  |  Branch (123:9): [True: 2.38k, False: 11.0k]
  ------------------
  124|  2.38k|        bstr unescaped = {0};
  125|  2.38k|        bstr r = bstr0(str);
  126|  2.38k|        if (!mp_append_escaped_string(ta_parent, &unescaped, &r))
  ------------------
  |  Branch (126:13): [True: 1.36k, False: 1.01k]
  ------------------
  127|  1.36k|            return -1; // broken escapes
  128|  1.01k|        str = unescaped.start; // the function guarantees null-termination
  129|  1.01k|    }
  130|  12.0k|    dst->format = MPV_FORMAT_STRING;
  131|  12.0k|    dst->u.string = str;
  132|  12.0k|    return 0;
  133|  13.4k|}
json.c:eat_c:
   60|  2.49M|{
   61|  2.49M|    if (**s == c) {
  ------------------
  |  Branch (61:9): [True: 529k, False: 1.96M]
  ------------------
   62|   529k|        *s += 1;
   63|   529k|        return true;
   64|   529k|    }
   65|  1.96M|    return false;
   66|  2.49M|}
json.c:read_sub:
  137|   483k|{
  138|   483k|    bool is_arr = eat_c(src, '[');
  139|   483k|    bool is_obj = !is_arr && eat_c(src, '{');
  ------------------
  |  Branch (139:19): [True: 481k, False: 1.51k]
  |  Branch (139:30): [True: 481k, False: 0]
  ------------------
  140|   483k|    if (!is_arr && !is_obj)
  ------------------
  |  Branch (140:9): [True: 481k, False: 1.51k]
  |  Branch (140:20): [True: 0, False: 481k]
  ------------------
  141|      0|        return -1; // not an array or object
  142|   483k|    char term = is_obj ? '}' : ']';
  ------------------
  |  Branch (142:17): [True: 481k, False: 1.51k]
  ------------------
  143|   483k|    struct mpv_node_list *list = talloc_zero(ta_parent, struct mpv_node_list);
  ------------------
  |  |   27|   483k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   483k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   483k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|   492k|    while (1) {
  ------------------
  |  Branch (144:12): [True: 492k, Folded]
  ------------------
  145|   492k|        eat_ws(src);
  146|   492k|        if (eat_c(src, term))
  ------------------
  |  Branch (146:13): [True: 3.70k, False: 489k]
  ------------------
  147|  3.70k|            break;
  148|   489k|        if (list->num > 0 && !eat_c(src, ','))
  ------------------
  |  Branch (148:13): [True: 7.99k, False: 481k]
  |  Branch (148:30): [True: 1.96k, False: 6.03k]
  ------------------
  149|  1.96k|            return -1; // missing ','
  150|   487k|        eat_ws(src);
  151|       |        // non-standard extension: allow a trailing ","
  152|   487k|        if (eat_c(src, term))
  ------------------
  |  Branch (152:13): [True: 1, False: 487k]
  ------------------
  153|      1|            break;
  154|   487k|        if (is_obj) {
  ------------------
  |  Branch (154:13): [True: 482k, False: 4.28k]
  ------------------
  155|   482k|            struct mpv_node keynode;
  156|       |            // non-standard extension: allow unquoted strings as keys
  157|   482k|            if (read_id(list, &keynode, src) < 0 &&
  ------------------
  |  Branch (157:17): [True: 438k, False: 44.3k]
  ------------------
  158|   438k|                read_str(list, &keynode, src) < 0)
  ------------------
  |  Branch (158:17): [True: 427k, False: 10.6k]
  ------------------
  159|   427k|                return -1; // key is not a string
  160|  55.0k|            eat_ws(src);
  161|       |            // non-standard extension: allow "=" instead of ":"
  162|  55.0k|            if (!eat_c(src, ':') && !eat_c(src, '='))
  ------------------
  |  Branch (162:17): [True: 42.6k, False: 12.4k]
  |  Branch (162:37): [True: 40.6k, False: 1.90k]
  ------------------
  163|  40.6k|                return -1; // ':' missing
  164|  14.3k|            eat_ws(src);
  165|  14.3k|            MP_TARRAY_GROW(list, list->keys, list->num);
  ------------------
  |  |   96|  14.3k|    do {                                            \
  |  |   97|  14.3k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  14.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  14.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  14.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 11.8k, False: 2.48k]
  |  |  ------------------
  |  |   99|  14.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  11.8k|    do {                                                        \
  |  |  |  |   89|  11.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  11.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  11.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  11.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  11.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  11.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 11.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
  166|  14.3k|            list->keys[list->num] = keynode.u.string;
  167|  14.3k|        }
  168|  18.6k|        MP_TARRAY_GROW(list, list->values, list->num);
  ------------------
  |  |   96|  18.6k|    do {                                            \
  |  |   97|  18.6k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  18.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  18.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  18.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 13.8k, False: 4.78k]
  |  |  ------------------
  |  |   99|  18.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  13.8k|    do {                                                        \
  |  |  |  |   89|  13.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  13.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  13.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  13.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  13.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  13.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  13.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 13.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  18.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 18.6k]
  |  |  ------------------
  ------------------
  169|  18.6k|        if (json_parse(ta_parent, &list->values[list->num], src, max_depth) < 0)
  ------------------
  |  Branch (169:13): [True: 9.13k, False: 9.49k]
  ------------------
  170|  9.13k|            return -1;
  171|  9.49k|        list->num++;
  172|  9.49k|    }
  173|  3.70k|    dst->format = is_obj ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NODE_ARRAY;
  ------------------
  |  Branch (173:19): [True: 3.39k, False: 308]
  ------------------
  174|  3.70k|    dst->u.list = list;
  175|  3.70k|    return 0;
  176|   483k|}
json.c:read_id:
   84|   482k|{
   85|   482k|    char *start = *src;
   86|   482k|    if (!mp_isalpha(**src) && **src != '_')
  ------------------
  |  Branch (86:9): [True: 440k, False: 42.2k]
  |  Branch (86:31): [True: 438k, False: 2.14k]
  ------------------
   87|   438k|        return -1;
   88|   262k|    while (mp_isalnum(**src) || **src == '_')
  ------------------
  |  Branch (88:12): [True: 215k, False: 47.1k]
  |  Branch (88:33): [True: 2.73k, False: 44.3k]
  ------------------
   89|   218k|        *src += 1;
   90|  44.3k|    if (**src == ' ') {
  ------------------
  |  Branch (90:9): [True: 849, False: 43.5k]
  ------------------
   91|    849|        **src = '\0'; // we're allowed to mutate it => can avoid the strndup
   92|    849|        *src += 1;
   93|  43.5k|    } else {
   94|  43.5k|        start = talloc_strndup(ta_parent, start, *src - start);
  ------------------
  |  |   51|  43.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
   95|  43.5k|    }
   96|  44.3k|    dst->format = MPV_FORMAT_STRING;
   97|  44.3k|    dst->u.string = start;
   98|  44.3k|    return 0;
   99|   482k|}
json.c:write_json_str:
  259|  13.7M|{
  260|  13.7M|    mp_assert(str);
  ------------------
  |  |   41|  13.7M|#define mp_assert assert
  ------------------
  |  Branch (260:5): [True: 13.7M, False: 0]
  ------------------
  261|       |
  262|  13.7M|    APPEND(b, "\"");
  ------------------
  |  |  248|  13.7M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  263|  14.1M|    while (1) {
  ------------------
  |  Branch (263:12): [True: 14.1M, Folded]
  ------------------
  264|  14.1M|        unsigned char *cur = str;
  265|   126M|        while (cur[0] >= 32 && cur[0] != '"' && cur[0] != '\\')
  ------------------
  |  Branch (265:16): [True: 112M, False: 14.0M]
  |  Branch (265:32): [True: 112M, False: 40.1k]
  |  Branch (265:49): [True: 111M, False: 90.2k]
  ------------------
  266|   111M|            cur++;
  267|  14.1M|        if (!cur[0])
  ------------------
  |  Branch (267:13): [True: 13.7M, False: 347k]
  ------------------
  268|  13.7M|            break;
  269|   347k|        bstr_xappend(NULL, b, (bstr){str, cur - str});
  270|   347k|        if (cur[0] == '\"') {
  ------------------
  |  Branch (270:13): [True: 40.1k, False: 307k]
  ------------------
  271|  40.1k|            bstr_xappend(NULL, b, (bstr){"\\\"", 2});
  272|   307k|        } else if (cur[0] == '\\') {
  ------------------
  |  Branch (272:20): [True: 90.2k, False: 216k]
  ------------------
  273|  90.2k|            bstr_xappend(NULL, b, (bstr){"\\\\", 2});
  274|   216k|        } else if (cur[0] < sizeof(special_escape) && special_escape[cur[0]]) {
  ------------------
  |  Branch (274:20): [True: 161k, False: 55.0k]
  |  Branch (274:55): [True: 5.18k, False: 156k]
  ------------------
  275|  5.18k|            bstr_xappend_asprintf(NULL, b, "\\%c", special_escape[cur[0]]);
  276|   211k|        } else {
  277|   211k|            bstr_xappend_asprintf(NULL, b, "\\u%04x", (unsigned char)cur[0]);
  278|   211k|        }
  279|   347k|        str = cur + 1;
  280|   347k|    }
  281|  13.7M|    APPEND(b, str);
  ------------------
  |  |  248|  13.7M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  282|       |    APPEND(b, "\"");
  ------------------
  |  |  248|  13.7M|#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
  ------------------
  283|  13.7M|}
json.c:add_indent:
  286|  12.6M|{
  287|  12.6M|    if (indent < 0)
  ------------------
  |  Branch (287:9): [True: 12.6M, False: 0]
  ------------------
  288|  12.6M|        return;
  289|      0|    bstr_xappend(NULL, b, bstr0("\n"));
  290|      0|    for (int n = 0; n < indent; n++)
  ------------------
  |  Branch (290:21): [True: 0, False: 0]
  ------------------
  291|      0|        bstr_xappend(NULL, b, bstr0(" "));
  292|      0|}
json.c:json_append_str:
  342|  7.22M|{
  343|  7.22M|    bstr buffer = bstr0(*dst);
  344|  7.22M|    int r = json_append(&buffer, src, indent);
  345|  7.22M|    *dst = buffer.start;
  346|  7.22M|    return r;
  347|  7.22M|}

mp_match_lang:
  255|    604|{
  256|    604|    if (!lang)
  ------------------
  |  Branch (256:9): [True: 511, False: 93]
  ------------------
  257|    511|        return 0;
  258|       |
  259|     93|    void *ta_ctx = talloc_new(NULL);
  ------------------
  |  |   40|     93|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|     93|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  260|     93|    int lang_parts_n = 0;
  261|     93|    bstr *lang_parts = NULL;
  262|     93|    bstr rest = bstr0(lang);
  263|    253|    while (rest.len) {
  ------------------
  |  Branch (263:12): [True: 160, False: 93]
  ------------------
  264|    160|        bstr s = bstr_split(rest, "-", &rest);
  265|    160|        MP_TARRAY_APPEND(ta_ctx, lang_parts, lang_parts_n, s);
  ------------------
  |  |  105|    160|    do {                                            \
  |  |  106|    160|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    160|    do {                                            \
  |  |  |  |   97|    160|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    160|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    160|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    160|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 95, False: 65]
  |  |  |  |  ------------------
  |  |  |  |   99|    160|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     95|    do {                                                        \
  |  |  |  |  |  |   89|     95|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     95|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     95|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     95|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     95|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     95|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     95|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 95]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    160|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 160]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    160|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    160|        (idxvar)++;                                 \
  |  |  109|    160|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 160]
  |  |  ------------------
  ------------------
  266|    160|    }
  267|       |
  268|     93|    int best_score = 0;
  269|     93|    if (!lang_parts_n)
  ------------------
  |  Branch (269:9): [True: 0, False: 93]
  ------------------
  270|      0|        goto done;
  271|       |
  272|     93|    for (int idx = 0; langs && langs[idx]; idx++) {
  ------------------
  |  Branch (272:23): [True: 39, False: 54]
  |  Branch (272:32): [True: 0, False: 39]
  ------------------
  273|      0|        rest = bstr0(langs[idx]);
  274|      0|        int part = 0;
  275|      0|        int score = 0;
  276|      0|        while (rest.len) {
  ------------------
  |  Branch (276:16): [True: 0, False: 0]
  ------------------
  277|      0|            bstr s = bstr_split(rest, "-", &rest);
  278|      0|            if (!part) {
  ------------------
  |  Branch (278:17): [True: 0, False: 0]
  ------------------
  279|      0|                if (bstrcasecmp(canonicalize(lang_parts[0]), canonicalize(s)))
  ------------------
  |  Branch (279:21): [True: 0, False: 0]
  ------------------
  280|      0|                    break;
  281|      0|                score = INT_MAX - idx;
  282|      0|                part++;
  283|      0|                continue;
  284|      0|            }
  285|       |
  286|      0|            if (part >= lang_parts_n)
  ------------------
  |  Branch (286:17): [True: 0, False: 0]
  ------------------
  287|      0|                break;
  288|       |
  289|      0|            if (bstrcasecmp(lang_parts[part], s))
  ------------------
  |  Branch (289:17): [True: 0, False: 0]
  ------------------
  290|      0|                score -= 1000;
  291|       |
  292|      0|            part++;
  293|      0|        }
  294|      0|        score -= (lang_parts_n - part) * 1000;
  295|      0|        best_score = MPMAX(best_score, score);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  296|      0|    }
  297|       |
  298|     93|done:
  299|     93|    talloc_free(ta_ctx);
  ------------------
  |  |   47|     93|#define talloc_free                     ta_free
  ------------------
  300|     93|    return best_score;
  301|     93|}
mp_guess_lang_from_filename:
  304|  3.92k|{
  305|  3.92k|    name = bstr_strip(mp_strip_ext(name));
  306|       |
  307|  3.92k|    if (lang_start)
  ------------------
  |  Branch (307:9): [True: 0, False: 3.92k]
  ------------------
  308|      0|        *lang_start = -1;
  309|       |
  310|  3.92k|    if (flags)
  ------------------
  |  Branch (310:9): [True: 3.92k, False: 0]
  ------------------
  311|  3.92k|        *flags = 0;
  312|       |
  313|  3.92k|    if (name.len < 2)
  ------------------
  |  Branch (313:9): [True: 0, False: 3.92k]
  ------------------
  314|      0|        return (bstr){0};
  315|       |
  316|  3.92k|    int lang_length = 0;
  317|  3.92k|    int i = name.len - 1;
  318|  3.92k|    int suffixes_length = 0;
  319|       |
  320|  3.92k|    char delimiter = '.';
  321|  3.92k|    if (name.start[i] == ')') {
  ------------------
  |  Branch (321:9): [True: 18, False: 3.90k]
  ------------------
  322|     18|        delimiter = '(';
  323|     18|        i--;
  324|     18|    }
  325|  3.92k|    if (name.start[i] == ']') {
  ------------------
  |  Branch (325:9): [True: 5, False: 3.91k]
  ------------------
  326|      5|        delimiter = '[';
  327|      5|        i--;
  328|      5|    }
  329|       |
  330|  3.92k|    enum track_flags *f = flags ? flags : &(enum track_flags){0};
  ------------------
  |  Branch (330:27): [True: 3.92k, False: 0]
  ------------------
  331|       |
  332|  4.09k|    while (true) {
  ------------------
  |  Branch (332:12): [True: 4.09k, Folded]
  ------------------
  333|  8.51k|        while (i >= 0 && mp_isalpha(name.start[i])) {
  ------------------
  |  Branch (333:16): [True: 8.51k, False: 0]
  |  Branch (333:26): [True: 4.42k, False: 4.09k]
  ------------------
  334|  4.42k|            lang_length++;
  335|  4.42k|            i--;
  336|  4.42k|        }
  337|       |
  338|  4.09k|        if (i >= 0 && lang_length >= 2 && name.start[i] == delimiter) {
  ------------------
  |  Branch (338:13): [True: 4.09k, False: 0]
  |  Branch (338:23): [True: 615, False: 3.47k]
  |  Branch (338:43): [True: 92, False: 523]
  ------------------
  339|     92|            bool matched = false;
  340|     92|            static const char *const suffixes[] = { "sdh", "hi", "cc" };
  341|     92|            bstr tag = { name.start + i + 1, lang_length };
  342|    368|            for (int n = 0; n < MP_ARRAY_SIZE(suffixes); n++) {
  ------------------
  |  |   49|    368|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (342:29): [True: 276, False: 92]
  ------------------
  343|    276|                if (!bstrcasecmp0(tag, suffixes[n])) {
  ------------------
  |  Branch (343:21): [True: 0, False: 276]
  ------------------
  344|      0|                    *f |= TRACK_HEARING_IMPAIRED;
  345|      0|                    matched = true;
  346|      0|                    break;
  347|      0|                }
  348|    276|            }
  349|     92|            if (!bstrcasecmp0(tag, "forced")) {
  ------------------
  |  Branch (349:17): [True: 0, False: 92]
  ------------------
  350|      0|                *f |= TRACK_FORCED;
  351|      0|                matched = true;
  352|      0|            }
  353|     92|            if (!bstrcasecmp0(tag, "default")) {
  ------------------
  |  Branch (353:17): [True: 0, False: 92]
  ------------------
  354|      0|                *f |= TRACK_DEFAULT;
  355|      0|                matched = true;
  356|      0|            }
  357|     92|            if (matched) {
  ------------------
  |  Branch (357:17): [True: 0, False: 92]
  ------------------
  358|      0|                lang_length = 0;
  359|      0|                i -= (delimiter != '.') ? 2 : 1;
  ------------------
  |  Branch (359:22): [True: 0, False: 0]
  ------------------
  360|      0|                continue;
  361|      0|            }
  362|     92|        }
  363|       |
  364|       |        // According to
  365|       |        // https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags
  366|       |        // subtags after the first are composed of 1 to 8 letters.
  367|  4.09k|        if (lang_length < suffixes_length + 1 || lang_length > suffixes_length + 8)
  ------------------
  |  Branch (367:13): [True: 3.25k, False: 832]
  |  Branch (367:50): [True: 148, False: 684]
  ------------------
  368|  3.40k|            return (bstr){0};
  369|       |
  370|    684|        if (i >= 0 && name.start[i] == '-') {
  ------------------
  |  Branch (370:13): [True: 684, False: 0]
  |  Branch (370:23): [True: 169, False: 515]
  ------------------
  371|    169|            lang_length++;
  372|    169|            i--;
  373|    169|            suffixes_length = lang_length;
  374|    515|        } else {
  375|    515|            break;
  376|    515|        }
  377|    684|    }
  378|       |
  379|       |    // The primary subtag can have 2 or 3 letters.
  380|    515|    if (lang_length < suffixes_length + 2 || lang_length > suffixes_length + 3 ||
  ------------------
  |  Branch (380:9): [True: 218, False: 297]
  |  Branch (380:46): [True: 95, False: 202]
  ------------------
  381|    202|        i <= 0 || name.start[i] != delimiter)
  ------------------
  |  Branch (381:9): [True: 0, False: 202]
  |  Branch (381:19): [True: 110, False: 92]
  ------------------
  382|    423|        return (bstr){0};
  383|       |
  384|     92|    if (lang_start)
  ------------------
  |  Branch (384:9): [True: 0, False: 92]
  ------------------
  385|      0|        *lang_start = i;
  386|       |
  387|     92|    return (bstr){name.start + i + 1, lang_length};
  388|    515|}

node_init:
   13|  11.2M|{
   14|       |    // Other formats need to be initialized manually.
   15|  11.2M|    mp_assert(format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY ||
  ------------------
  |  |   41|  11.2M|#define mp_assert assert
  ------------------
  |  Branch (15:5): [True: 5.60M, False: 5.64M]
  |  Branch (15:5): [True: 12.4k, False: 5.62M]
  |  Branch (15:5): [True: 1.14k, False: 5.62M]
  |  Branch (15:5): [True: 38.9k, False: 5.58M]
  |  Branch (15:5): [True: 28, False: 5.58M]
  |  Branch (15:5): [True: 840, False: 5.58M]
  |  Branch (15:5): [True: 5.58M, False: 0]
  ------------------
   16|  11.2M|           format == MPV_FORMAT_FLAG || format == MPV_FORMAT_INT64 ||
   17|  11.2M|           format == MPV_FORMAT_DOUBLE || format == MPV_FORMAT_BYTE_ARRAY ||
   18|  11.2M|           format == MPV_FORMAT_NONE);
   19|       |
   20|  11.2M|    void *ta_parent = NULL;
   21|  11.2M|    if (parent) {
  ------------------
  |  Branch (21:9): [True: 5.63M, False: 5.61M]
  ------------------
   22|  5.63M|        mp_assert(parent->format == MPV_FORMAT_NODE_MAP ||
  ------------------
  |  |   41|  5.63M|#define mp_assert assert
  ------------------
  |  Branch (22:9): [True: 5.62M, False: 6.98k]
  |  Branch (22:9): [True: 6.98k, False: 0]
  ------------------
   23|  5.63M|               parent->format == MPV_FORMAT_NODE_ARRAY);
   24|  5.63M|        ta_parent = parent->u.list;
   25|  5.63M|    }
   26|       |
   27|  11.2M|    *dst = (struct mpv_node){ .format = format };
   28|  11.2M|    if (format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY)
  ------------------
  |  Branch (28:9): [True: 5.60M, False: 5.64M]
  |  Branch (28:42): [True: 12.4k, False: 5.62M]
  ------------------
   29|  5.61M|        dst->u.list = talloc_zero(ta_parent, struct mpv_node_list);
  ------------------
  |  |   27|  5.61M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  5.61M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  5.61M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   30|  11.2M|    if (format == MPV_FORMAT_BYTE_ARRAY)
  ------------------
  |  Branch (30:9): [True: 840, False: 11.2M]
  ------------------
   31|    840|        dst->u.ba = talloc_zero(ta_parent, struct mpv_byte_array);
  ------------------
  |  |   27|    840|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    840|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    840|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   32|  11.2M|}
node_array_add:
   37|  6.98k|{
   38|  6.98k|    struct mpv_node_list *list = dst->u.list;
   39|  6.98k|    mp_assert(dst->format == MPV_FORMAT_NODE_ARRAY && dst->u.list);
  ------------------
  |  |   41|  6.98k|#define mp_assert assert
  ------------------
  |  Branch (39:5): [True: 6.98k, False: 0]
  |  Branch (39:5): [True: 6.98k, False: 0]
  ------------------
   40|  6.98k|    MP_TARRAY_GROW(list, list->values, list->num);
  ------------------
  |  |   96|  6.98k|    do {                                            \
  |  |   97|  6.98k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  6.98k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  6.98k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  6.98k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 1.70k, False: 5.28k]
  |  |  ------------------
  |  |   99|  6.98k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  1.70k|    do {                                                        \
  |  |  |  |   89|  1.70k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  1.70k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.70k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.70k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.70k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  1.70k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  1.70k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 1.70k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  6.98k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 6.98k]
  |  |  ------------------
  ------------------
   41|  6.98k|    node_init(&list->values[list->num], format, dst);
   42|  6.98k|    return &list->values[list->num++];
   43|  6.98k|}
node_map_add:
   49|  5.62M|{
   50|  5.62M|    mp_assert(key);
  ------------------
  |  |   41|  5.62M|#define mp_assert assert
  ------------------
  |  Branch (50:5): [True: 5.62M, False: 0]
  ------------------
   51|  5.62M|    return node_map_badd(dst, bstr0(key), format);
   52|  5.62M|}
node_map_badd:
   55|  5.62M|{
   56|  5.62M|    mp_assert(key.start);
  ------------------
  |  |   41|  5.62M|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 5.62M, False: 0]
  ------------------
   57|       |
   58|  5.62M|    struct mpv_node_list *list = dst->u.list;
   59|  5.62M|    mp_assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list);
  ------------------
  |  |   41|  5.62M|#define mp_assert assert
  ------------------
  |  Branch (59:5): [True: 5.62M, False: 0]
  |  Branch (59:5): [True: 5.62M, False: 0]
  ------------------
   60|  5.62M|    MP_TARRAY_GROW(list, list->values, list->num);
  ------------------
  |  |   96|  5.62M|    do {                                            \
  |  |   97|  5.62M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  5.62M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  5.62M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  5.62M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 5.59M, False: 27.5k]
  |  |  ------------------
  |  |   99|  5.62M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  5.59M|    do {                                                        \
  |  |  |  |   89|  5.59M|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  5.59M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  5.59M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  5.59M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.59M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  5.59M|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  5.59M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 5.59M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  5.62M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 5.62M]
  |  |  ------------------
  ------------------
   61|  5.62M|    MP_TARRAY_GROW(list, list->keys, list->num);
  ------------------
  |  |   96|  5.62M|    do {                                            \
  |  |   97|  5.62M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  5.62M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  5.62M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  5.62M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 5.59M, False: 27.5k]
  |  |  ------------------
  |  |   99|  5.62M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  5.59M|    do {                                                        \
  |  |  |  |   89|  5.59M|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  5.59M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  5.59M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  5.59M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.59M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  5.59M|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  5.59M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 5.59M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  5.62M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 5.62M]
  |  |  ------------------
  ------------------
   62|  5.62M|    list->keys[list->num] = bstrdup0(list, key);
   63|  5.62M|    node_init(&list->values[list->num], format, dst);
   64|  5.62M|    return &list->values[list->num++];
   65|  5.62M|}
node_map_add_string:
   71|  5.58M|{
   72|  5.58M|    mp_assert(val);
  ------------------
  |  |   41|  5.58M|#define mp_assert assert
  ------------------
  |  Branch (72:5): [True: 5.58M, False: 0]
  ------------------
   73|       |
   74|  5.58M|    struct mpv_node *entry = node_map_add(dst, key, MPV_FORMAT_NONE);
   75|  5.58M|    entry->format = MPV_FORMAT_STRING;
   76|  5.58M|    entry->u.string = talloc_strdup(dst->u.list, val);
  ------------------
  |  |   50|  5.58M|#define talloc_strdup                   ta_xstrdup
  ------------------
   77|  5.58M|}
node_map_add_int64:
   89|  38.9k|{
   90|  38.9k|    node_map_add(dst, key, MPV_FORMAT_INT64)->u.int64 = v;
   91|  38.9k|}
node_map_add_double:
   94|     28|{
   95|     28|    node_map_add(dst, key, MPV_FORMAT_DOUBLE)->u.double_ = v;
   96|     28|}
node_map_add_flag:
   99|  1.14k|{
  100|  1.14k|    node_map_add(dst, key, MPV_FORMAT_FLAG)->u.flag = v;
  101|  1.14k|}
node_map_get:
  104|  6.49k|{
  105|  6.49k|    return node_map_bget(src, bstr0(key));
  106|  6.49k|}
node_map_bget:
  109|  6.49k|{
  110|  6.49k|    if (src->format != MPV_FORMAT_NODE_MAP)
  ------------------
  |  Branch (110:9): [True: 0, False: 6.49k]
  ------------------
  111|      0|        return NULL;
  112|       |
  113|  9.09k|    for (int i = 0; i < src->u.list->num; i++) {
  ------------------
  |  Branch (113:21): [True: 2.60k, False: 6.49k]
  ------------------
  114|  2.60k|        if (bstr_equals0(key, src->u.list->keys[i]))
  ------------------
  |  Branch (114:13): [True: 0, False: 2.60k]
  ------------------
  115|      0|            return &src->u.list->values[i];
  116|  2.60k|    }
  117|       |
  118|  6.49k|    return NULL;
  119|  6.49k|}

mp_basename_bstr:
   43|  27.6M|{
   44|  27.6M|    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|  27.6M|    separator_pos = bstrrchr(path, '/');
   57|  27.6M|    if (separator_pos < 0)
  ------------------
  |  Branch (57:9): [True: 70.4k, False: 27.6M]
  ------------------
   58|  70.4k|        return path;
   59|  27.6M|    return bstr_splice(path, separator_pos + 1, path.len);
   60|  27.6M|}
mp_basename:
   63|  27.5M|{
   64|  27.5M|    return mp_basename_bstr(bstr0(path)).start;
   65|  27.5M|}
mp_dirname:
   68|  48.8k|{
   69|  48.8k|    struct bstr ret = {
   70|  48.8k|        (uint8_t *)path, mp_basename(path) - path
   71|  48.8k|    };
   72|  48.8k|    if (ret.len == 0)
  ------------------
  |  Branch (72:9): [True: 34.4k, False: 14.4k]
  ------------------
   73|  34.4k|        return bstr0(".");
   74|  14.4k|    return ret;
   75|  48.8k|}
mp_strip_ext:
  114|  23.0k|{
  115|  23.0k|    bstr root = {0};
  116|  23.0k|    split_ext(path, &root);
  117|  23.0k|    return root.len ? root : path;
  ------------------
  |  Branch (117:12): [True: 2.34k, False: 20.7k]
  ------------------
  118|  23.0k|}
mp_get_ext:
  121|  86.5k|{
  122|       |    return split_ext(path, NULL);
  123|  86.5k|}
mp_path_is_absolute:
  126|  14.1k|{
  127|  14.1k|    if (path.len && strchr(mp_path_separators, path.start[0]))
  ------------------
  |  Branch (127:9): [True: 14.1k, False: 0]
  |  Branch (127:21): [True: 4.86k, False: 9.32k]
  ------------------
  128|  4.86k|        return true;
  129|       |
  130|       |#if HAVE_DOS_PATHS
  131|       |    // Note: "X:filename" is a path relative to the current working directory
  132|       |    //       of drive X, and thus is not an absolute path. It needs to be
  133|       |    //       followed by \ or /.
  134|       |    if (path.len >= 3 && path.start[1] == ':' &&
  135|       |        strchr(mp_path_separators, path.start[2]))
  136|       |        return true;
  137|       |#endif
  138|       |
  139|  9.32k|    return false;
  140|  14.1k|}
mp_path_join_bstr:
  143|  28.0k|{
  144|  28.0k|    if (p1.len == 0)
  ------------------
  |  Branch (144:9): [True: 23.3k, False: 4.67k]
  ------------------
  145|  23.3k|        return bstrdup0(talloc_ctx, p2);
  146|  4.67k|    if (p2.len == 0)
  ------------------
  |  Branch (146:9): [True: 1, False: 4.67k]
  ------------------
  147|      1|        return bstrdup0(talloc_ctx, p1);
  148|       |
  149|  4.67k|    if (mp_path_is_absolute(p2))
  ------------------
  |  Branch (149:9): [True: 1, False: 4.67k]
  ------------------
  150|      1|        return bstrdup0(talloc_ctx, p2);
  151|       |
  152|  4.67k|    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|  4.67k|    return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1),
  ------------------
  |  |   52|  4.67k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  28.0k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 4.67k, False: 0]
  |  |  |  |  |  Branch (127:62): [True: 6, False: 4.66k]
  |  |  |  |  |  Branch (127:62): [True: 4.67k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|  4.67k|                           have_separator ? "" : "/", BSTR_P(p2));
  161|  4.67k|}
mp_path_join:
  164|  4.67k|{
  165|  4.67k|    return mp_path_join_bstr(talloc_ctx, bstr0(p1), bstr0(p2));
  166|  4.67k|}
mp_getcwd:
  169|  4.65k|{
  170|  4.65k|#if !HAVE_DOS_PATHS
  171|  4.65k|    char *e_wd = getenv("PWD");
  172|  4.65k|    struct stat pwd_st, dot_st;
  173|  4.65k|    if (e_wd && mp_path_is_absolute(bstr0(e_wd)) &&
  ------------------
  |  Branch (173:9): [True: 4.65k, False: 0]
  |  Branch (173:17): [True: 4.65k, False: 0]
  ------------------
  174|  4.65k|        stat(e_wd, &pwd_st) == 0 && stat(".", &dot_st) == 0 &&
  ------------------
  |  Branch (174:9): [True: 4.65k, False: 0]
  |  Branch (174:37): [True: 4.65k, False: 0]
  ------------------
  175|  4.65k|        pwd_st.st_dev == dot_st.st_dev && pwd_st.st_ino == dot_st.st_ino)
  ------------------
  |  Branch (175:9): [True: 4.65k, False: 0]
  |  Branch (175:43): [True: 4.65k, False: 0]
  ------------------
  176|  4.65k|        return talloc_strdup(talloc_ctx, e_wd);
  ------------------
  |  |   50|  4.65k|#define talloc_strdup                   ta_xstrdup
  ------------------
  177|      0|#endif
  178|       |
  179|      0|    char *wd = talloc_array(talloc_ctx, char, 20);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|      0|    while (getcwd(wd, talloc_get_size(wd)) == NULL) {
  ------------------
  |  |   45|      0|#define talloc_get_size                 ta_get_size
  ------------------
  |  Branch (180:12): [True: 0, False: 0]
  ------------------
  181|      0|        if (errno != ERANGE) {
  ------------------
  |  Branch (181:13): [True: 0, False: 0]
  ------------------
  182|      0|            talloc_free(wd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  183|      0|            return NULL;
  184|      0|        }
  185|      0|        wd = talloc_realloc(talloc_ctx, wd, char, talloc_get_size(wd) * 2);
  ------------------
  |  |   33|      0|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|      0|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|      0|    }
  187|      0|    return wd;
  188|      0|}
mp_normalize_path:
  191|  21.4k|{
  192|  21.4k|    if (!path)
  ------------------
  |  Branch (192:9): [True: 0, False: 21.4k]
  ------------------
  193|      0|        return NULL;
  194|       |
  195|  21.4k|    if (!path[0] || mp_is_url(bstr0(path)) || !strcmp(path, "-"))
  ------------------
  |  Branch (195:9): [True: 18, False: 21.3k]
  |  Branch (195:21): [True: 16.5k, False: 4.87k]
  |  Branch (195:47): [True: 10, False: 4.86k]
  ------------------
  196|  16.5k|        return talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|  16.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  197|       |
  198|  4.86k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  4.86k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  4.86k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  199|  4.86k|    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|  4.86k|    if (!mp_path_is_absolute(bstr0(path))) {
  ------------------
  |  Branch (218:9): [True: 4.65k, False: 212]
  ------------------
  219|  4.65k|        char *cwd = mp_getcwd(tmp);
  220|  4.65k|        if (!cwd) {
  ------------------
  |  Branch (220:13): [True: 0, False: 4.65k]
  ------------------
  221|      0|            result = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  222|      0|            goto exit;
  223|      0|        }
  224|  4.65k|        path = mp_path_join(tmp, cwd, path);
  225|  4.65k|    }
  226|       |
  227|  4.86k|    result = talloc_strdup(tmp, "");
  ------------------
  |  |   50|  4.86k|#define talloc_strdup                   ta_xstrdup
  ------------------
  228|  4.86k|    const char *next;
  229|  4.86k|    const char *end = path + strlen(path);
  230|       |
  231|  29.5k|    for (const char *ptr = path; ptr < end; ptr = next + 1) {
  ------------------
  |  Branch (231:34): [True: 24.7k, False: 4.85k]
  ------------------
  232|  24.7k|        next = memchr(ptr, '/', end - ptr);
  233|  24.7k|        if (next == NULL)
  ------------------
  |  Branch (233:13): [True: 4.72k, False: 19.9k]
  ------------------
  234|  4.72k|            next = end;
  235|       |
  236|  24.7k|        switch (next - ptr) {
  ------------------
  |  Branch (236:17): [True: 6.11k, False: 18.5k]
  ------------------
  237|  5.44k|            case 0:
  ------------------
  |  Branch (237:13): [True: 5.44k, False: 19.2k]
  ------------------
  238|  5.44k|                continue;
  239|    461|            case 1:
  ------------------
  |  Branch (239:13): [True: 461, False: 24.2k]
  ------------------
  240|    461|                if (ptr[0] == '.')
  ------------------
  |  Branch (240:21): [True: 275, False: 186]
  ------------------
  241|    275|                    continue;
  242|    186|                break;
  243|    206|            case 2:
  ------------------
  |  Branch (243:13): [True: 206, False: 24.5k]
  ------------------
  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|    206|                if (ptr[0] == '.' && ptr[1] == '.') {
  ------------------
  |  Branch (252:21): [True: 44, False: 162]
  |  Branch (252:38): [True: 10, False: 34]
  ------------------
  253|     10|                    char *tmp_result = realpath(path, NULL);
  254|     10|                    result = talloc_strdup(talloc_ctx,
  ------------------
  |  |   50|     10|#define talloc_strdup                   ta_xstrdup
  ------------------
  255|     10|                                           tmp_result ? tmp_result : path);
  ------------------
  |  Branch (255:44): [True: 10, False: 0]
  ------------------
  256|     10|                    free(tmp_result);
  257|     10|                    goto exit;
  258|     10|                }
  259|  24.7k|        }
  260|       |
  261|  18.9k|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|  18.9k|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  262|  18.9k|        result = talloc_strndup_append_buffer(result, ptr, next - ptr);
  ------------------
  |  |   60|  18.9k|#define talloc_strndup_append_buffer    ta_talloc_strndup_append_buffer
  ------------------
  263|  18.9k|    }
  264|       |
  265|  4.85k|    if (!result[0])
  ------------------
  |  Branch (265:9): [True: 122, False: 4.73k]
  ------------------
  266|    122|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|    122|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  267|       |
  268|  4.85k|    result = talloc_steal(talloc_ctx, result);
  ------------------
  |  |   38|  4.85k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  4.85k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  269|  4.85k|#endif
  270|       |
  271|  4.86k|exit:
  272|  4.86k|    talloc_free(tmp);
  ------------------
  |  |   47|  4.86k|#define talloc_free                     ta_free
  ------------------
  273|  4.86k|    return result;
  274|  4.85k|}
mp_path_exists:
  277|  69.2k|{
  278|  69.2k|    struct stat st;
  279|  69.2k|    return path && stat(path, &st) == 0;
  ------------------
  |  Branch (279:12): [True: 69.2k, False: 0]
  |  Branch (279:20): [True: 34.5k, False: 34.7k]
  ------------------
  280|  69.2k|}
mp_is_url:
  290|  27.7M|{
  291|  27.7M|    int proto = bstr_find0(path, "://");
  292|  27.7M|    if (proto < 1)
  ------------------
  |  Branch (292:9): [True: 59.2k, False: 27.6M]
  ------------------
  293|  59.2k|        return false;
  294|       |    // Per RFC3986, the first character of the protocol must be alphabetic.
  295|       |    // The rest must be alphanumeric plus -, + and .
  296|  83.3M|    for (int i = 0; i < proto; i++) {
  ------------------
  |  Branch (296:21): [True: 55.7M, False: 27.6M]
  ------------------
  297|  55.7M|        unsigned char c = path.start[i];
  298|  55.7M|        if ((i == 0 && !mp_isalpha(c)) ||
  ------------------
  |  Branch (298:14): [True: 27.6M, False: 28.0M]
  |  Branch (298:24): [True: 8.47k, False: 27.6M]
  ------------------
  299|  55.7M|            (!mp_isalnum(c) && c != '.' && c != '-' && c != '+'))
  ------------------
  |  Branch (299:14): [True: 6.20k, False: 55.7M]
  |  Branch (299:32): [True: 4.92k, False: 1.28k]
  |  Branch (299:44): [True: 3.38k, False: 1.53k]
  |  Branch (299:56): [True: 1.80k, False: 1.57k]
  ------------------
  300|  10.2k|        {
  301|  10.2k|            return false;
  302|  10.2k|        }
  303|  55.7M|    }
  304|  27.6M|    return true;
  305|  27.6M|}
mp_split_proto:
  310|   115k|{
  311|   115k|    if (!mp_is_url(path))
  ------------------
  |  Branch (311:9): [True: 29.3k, False: 86.5k]
  ------------------
  312|  29.3k|        return (bstr){0};
  313|  86.5k|    bstr r;
  314|  86.5k|    bstr_split_tok(path, "://", &r, out_url ? out_url : &(bstr){0});
  ------------------
  |  Branch (314:37): [True: 12.0k, False: 74.4k]
  ------------------
  315|  86.5k|    return r;
  316|   115k|}
mp_mkdirp:
  319|  34.4k|{
  320|  34.4k|    if (mp_path_exists(dir))
  ------------------
  |  Branch (320:9): [True: 34.4k, False: 0]
  ------------------
  321|  34.4k|        return;
  322|       |
  323|      0|    char *path = talloc_strdup(NULL, dir);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  324|      0|    char *cdir = path + 1;
  325|       |
  326|      0|    while (cdir) {
  ------------------
  |  Branch (326:12): [True: 0, False: 0]
  ------------------
  327|      0|        cdir = strchr(cdir, '/');
  328|      0|        if (cdir)
  ------------------
  |  Branch (328:13): [True: 0, False: 0]
  ------------------
  329|      0|            *cdir = 0;
  330|       |
  331|      0|        mkdir(path, 0777);
  ------------------
  |  |  270|      0|#define mkdir(...) mp_mkdir(__VA_ARGS__)
  ------------------
  332|       |
  333|      0|        if (cdir)
  ------------------
  |  Branch (333:13): [True: 0, False: 0]
  ------------------
  334|      0|            *cdir++ = '/';
  335|      0|    }
  336|       |
  337|      0|    talloc_free(path);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  338|      0|}
path_utils.c:split_ext:
   97|   109k|{
   98|   109k|    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|   109k|    basename = bstr_splice(basename, bstrspn(basename, "."), basename.len);
  103|       |
  104|   109k|    int dot_pos = bstrrchr(basename, '.');
  105|   109k|    if (dot_pos < 0 || dot_pos == basename.len - 1)
  ------------------
  |  Branch (105:9): [True: 102k, False: 6.88k]
  |  Branch (105:24): [True: 97, False: 6.78k]
  ------------------
  106|   102k|        return (bstr){0};
  107|  6.78k|    bstr ext = bstr_splice(basename, dot_pos + 1, basename.len);
  108|  6.78k|    if (root)
  ------------------
  |  Branch (108:9): [True: 2.34k, False: 4.43k]
  ------------------
  109|  2.34k|        *root = (bstr){path.start, ext.start - 1 - path.start};
  110|  6.78k|    return ext;
  111|   109k|}

mp_rand_seed:
   45|    151|{
   46|    151|    mp_rand_state ret;
   47|       |
   48|    151|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
   49|    151|    seed = 42;
   50|    151|#endif
   51|       |
   52|    151|    if (seed == 0) {
  ------------------
  |  Branch (52:9): [True: 0, False: 151]
  ------------------
   53|      0|        if (av_random_bytes((void *)ret.v, sizeof(ret.v)) == 0) {
  ------------------
  |  Branch (53:13): [True: 0, False: 0]
  ------------------
   54|      0|            return ret;
   55|      0|        }
   56|      0|        seed = mp_raw_time_ns();
   57|      0|        seed ^= (uintptr_t)&mp_rand_seed; // ASLR, hopefully
   58|      0|        seed += (uintptr_t)&ret; // stack position
   59|      0|    }
   60|       |
   61|    151|    ret.v[0] = seed;
   62|    604|    for (int i = 1; i < 4; i++)
  ------------------
  |  Branch (62:21): [True: 453, False: 151]
  ------------------
   63|    453|        ret.v[i] = splitmix64(&seed);
   64|    151|    return ret;
   65|    151|}
random.c:splitmix64:
   37|    453|{
   38|    453|    uint64_t z = (*x += UINT64_C(0x9e3779b97f4a7c15));
   39|    453|    z = (z ^ (z >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
   40|       |    z = (z ^ (z >> 27)) * UINT64_C(0x94d049bb133111eb);
   41|    453|    return z ^ (z >> 31);
   42|    453|}

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

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

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

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

m_config_from_obj_desc_noalloc:
  146|  16.4k|{
  147|       |    return m_config_from_obj_desc(talloc_ctx, log, NULL, desc);
  148|  16.4k|}
m_config_from_obj_desc_and_args:
  167|  8.01k|{
  168|  8.01k|    struct m_config *config = m_config_from_obj_desc(ta_parent, log, global, desc);
  169|  8.01k|    if (m_config_set_obj_params(config, log, global, desc, args) < 0)
  ------------------
  |  Branch (169:9): [True: 0, False: 8.01k]
  ------------------
  170|      0|        goto error;
  171|       |
  172|  8.01k|    return config;
  173|      0|error:
  174|      0|    talloc_free(config);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  175|       |    return NULL;
  176|  8.01k|}
m_config_restore_backups:
  235|  52.3k|{
  236|  52.3k|    restore_backups(&config->backup_opts, config);
  237|  52.3k|}
m_config_backup_watch_later_opts:
  276|  11.6k|{
  277|       |    // Runs once on the empty list, which is looked up by name.
  278|  11.6k|    mp_assert(!config->watch_later_backup_opts);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (278:5): [True: 11.6k, False: 0]
  ------------------
  279|  9.16M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (279:21): [True: 9.15M, False: 11.6k]
  ------------------
  280|  9.15M|        if (config->opts[n].data)
  ------------------
  |  Branch (280:13): [True: 8.56M, False: 583k]
  ------------------
  281|  8.56M|            add_backup(&config->watch_later_backup_opts, 0, &config->opts[n]);
  282|  9.15M|    }
  283|  11.6k|}
m_config_get_co_raw:
  300|  2.10M|{
  301|  2.10M|    struct m_config_option **co =
  302|  2.10M|        bsearch(&name, config->sorted_opts, config->num_opts,
  303|  2.10M|                sizeof(config->sorted_opts[0]), search_opt_name);
  304|  2.10M|    return co ? *co : NULL;
  ------------------
  |  Branch (304:12): [True: 1.93M, False: 169k]
  ------------------
  305|  2.10M|}
m_config_get_co:
  359|  1.67M|{
  360|  1.67M|    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|  1.67M|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (363:9): [True: 1.58M, False: 90.6k]
  |  Branch (363:15): [True: 81.7k, False: 1.50M]
  ------------------
  364|  81.7k|        co = NULL;
  365|  1.67M|    return co;
  366|  1.67M|}
m_config_get_co_count:
  369|  11.6k|{
  370|  11.6k|    return config->num_opts;
  371|  11.6k|}
m_config_get_co_index:
  374|  9.15M|{
  375|  9.15M|    return &config->opts[index];
  376|  9.15M|}
m_config_get_positional_option:
  385|  8.09k|{
  386|  8.09k|    int pos = 0;
  387|  21.2k|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (387:21): [True: 21.2k, False: 58]
  ------------------
  388|  21.2k|        struct m_config_option *co = &config->opts[n];
  389|  21.2k|        if (!co->opt->deprecation_message) {
  ------------------
  |  Branch (389:13): [True: 21.0k, False: 180]
  ------------------
  390|  21.0k|            if (pos == p)
  ------------------
  |  Branch (390:17): [True: 8.03k, False: 13.0k]
  ------------------
  391|  8.03k|                return co->name;
  392|  13.0k|            pos++;
  393|  13.0k|        }
  394|  21.2k|    }
  395|     58|    return NULL;
  396|  8.09k|}
m_config_mark_co_flags:
  431|   279k|{
  432|   279k|    if (flags & M_SETOPT_FROM_CMDLINE)
  ------------------
  |  Branch (432:9): [True: 0, False: 279k]
  ------------------
  433|      0|        co->is_set_from_cmdline = true;
  434|       |
  435|   279k|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (435:9): [True: 105k, False: 174k]
  ------------------
  436|   105k|        co->is_set_from_config = true;
  437|   279k|}
m_config_set_update_dispatch_queue:
  530|  11.6k|{
  531|  11.6k|    m_config_cache_set_dispatch_change_cb(config->cache, dispatch,
  532|  11.6k|                                          async_change_cb, config);
  533|  11.6k|}
m_config_new:
  554|  36.1k|{
  555|  36.1k|    struct m_config *config = talloc(talloc_ctx, struct m_config);
  ------------------
  |  |   26|  36.1k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  36.1k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  36.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  36.1k|    talloc_set_destructor(config, config_destroy);
  ------------------
  |  |   41|  36.1k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  557|  36.1k|    *config = (struct m_config){.log = log,};
  558|       |
  559|  36.1k|    config->shadow = m_config_shadow_new(root);
  560|       |
  561|  36.1k|    if (root->size) {
  ------------------
  |  Branch (561:9): [True: 19.6k, False: 16.4k]
  ------------------
  562|  19.6k|        config->cache = m_config_cache_from_shadow(config, config->shadow, root);
  563|  19.6k|        config->optstruct = config->cache->opts;
  564|  19.6k|    }
  565|       |
  566|  36.1k|    int32_t optid = -1;
  567|  9.48M|    while (m_config_shadow_get_next_opt(config->shadow, &optid)) {
  ------------------
  |  Branch (567:12): [True: 9.44M, False: 36.1k]
  ------------------
  568|  9.44M|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  569|  9.44M|        const char *opt_name =
  570|  9.44M|            m_config_shadow_get_opt_name(config->shadow, optid, buf, sizeof(buf));
  571|       |
  572|  9.44M|        struct m_config_option co = {
  573|  9.44M|            .name = talloc_strdup(config, opt_name),
  ------------------
  |  |   50|  9.44M|#define talloc_strdup                   ta_xstrdup
  ------------------
  574|  9.44M|            .opt = m_config_shadow_get_opt(config->shadow, optid),
  575|  9.44M|            .opt_id = optid,
  576|  9.44M|        };
  577|       |
  578|  9.44M|        if (config->cache)
  ------------------
  |  Branch (578:13): [True: 9.21M, False: 234k]
  ------------------
  579|  9.21M|            co.data = m_config_cache_get_opt_data(config->cache, optid);
  580|       |
  581|  9.44M|        MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
  ------------------
  |  |  105|  9.44M|    do {                                            \
  |  |  106|  9.44M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  9.44M|    do {                                            \
  |  |  |  |   97|  9.44M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  9.44M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  9.44M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  9.44M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 168k, False: 9.28M]
  |  |  |  |  ------------------
  |  |  |  |   99|  9.44M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   168k|    do {                                                        \
  |  |  |  |  |  |   89|   168k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   168k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   168k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   168k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   168k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   168k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   168k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 168k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  9.44M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 9.44M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  9.44M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  9.44M|        (idxvar)++;                                 \
  |  |  109|  9.44M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.44M]
  |  |  ------------------
  ------------------
  582|  9.44M|    }
  583|       |
  584|  36.1k|    config->sorted_opts = talloc_array(config, struct m_config_option *, config->num_opts);
  ------------------
  |  |   29|  36.1k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  36.1k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  36.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|  9.48M|    for (int n = 0; n < config->num_opts; n++)
  ------------------
  |  Branch (585:21): [True: 9.44M, False: 36.1k]
  ------------------
  586|  9.44M|        config->sorted_opts[n] = &config->opts[n];
  587|  36.1k|    qsort(config->sorted_opts, config->num_opts, sizeof(config->sorted_opts[0]), compare_opt_name);
  588|       |
  589|  36.1k|    return config;
  590|  36.1k|}
m_config_notify_change_opt_ptr:
  623|  2.82M|{
  624|       |    notify_opt(config, ptr, true);
  625|  2.82M|}
m_config_set_option_raw:
  637|   971k|{
  638|   971k|    if (!co)
  ------------------
  |  Branch (638:9): [True: 0, False: 971k]
  ------------------
  639|      0|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  640|       |
  641|   971k|    int r = handle_set_opt_flags(config, co, flags);
  642|   971k|    if (r <= 1)
  ------------------
  |  Branch (642:9): [True: 691k, False: 279k]
  ------------------
  643|   691k|        return r;
  644|       |
  645|   279k|    r = m_config_handle_special_options(config, co, data, flags);
  646|   279k|    if (r != M_OPT_UNKNOWN)
  ------------------
  |  |  529|   279k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (646:9): [True: 0, False: 279k]
  ------------------
  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|   279k|    if (!co->data)
  ------------------
  |  Branch (651:9): [True: 0, False: 279k]
  ------------------
  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|   279k|    if (config->profile_backup_tmp)
  ------------------
  |  Branch (654:9): [True: 0, False: 279k]
  ------------------
  655|      0|        ensure_backup(config->profile_backup_tmp, config->profile_backup_flags, co);
  656|       |
  657|   279k|    m_config_mark_co_flags(co, flags);
  658|       |
  659|   279k|    m_option_copy(co->opt, co->data, data);
  660|   279k|    if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (660:9): [True: 268k, False: 11.3k]
  ------------------
  661|   268k|        force_self_notify_change_opt(config, co, false);
  662|       |
  663|   279k|    return 0;
  664|   279k|}
m_config_set_option_cli:
  739|   862k|{
  740|   862k|    int r;
  741|   862k|    mp_assert(config != NULL);
  ------------------
  |  |   41|   862k|#define mp_assert assert
  ------------------
  |  Branch (741:5): [True: 862k, False: 0]
  ------------------
  742|       |
  743|   862k|    bool negate;
  744|   862k|    struct m_config_option *co =
  745|   862k|        m_config_mogrify_cli_opt(config, &name, &negate, &(int){0});
  746|       |
  747|   862k|    if (!co) {
  ------------------
  |  Branch (747:9): [True: 58.3k, False: 803k]
  ------------------
  748|  58.3k|        r = M_OPT_UNKNOWN;
  ------------------
  |  |  529|  58.3k|#define M_OPT_UNKNOWN           -1
  ------------------
  749|  58.3k|        goto done;
  750|  58.3k|    }
  751|       |
  752|   803k|    if (negate) {
  ------------------
  |  Branch (752:9): [True: 0, False: 803k]
  ------------------
  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|   803k|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (761:9): [True: 793k, False: 10.1k]
  ------------------
  762|   793k|        co->coalesce = true;
  763|       |
  764|       |    // This is the only mandatory function
  765|   803k|    mp_assert(co->opt->type->parse);
  ------------------
  |  |   41|   803k|#define mp_assert assert
  ------------------
  |  Branch (765:5): [True: 803k, False: 0]
  ------------------
  766|       |
  767|   803k|    r = handle_set_opt_flags(config, co, flags);
  768|   803k|    if (r <= 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 803k]
  ------------------
  769|      0|        goto done;
  770|       |
  771|   803k|    if (r == 2) {
  ------------------
  |  Branch (771:9): [True: 107k, False: 696k]
  ------------------
  772|   107k|        MP_VERBOSE(config, "Setting option '%.*s' = '%.*s' (flags = %d)\n",
  ------------------
  |  |   92|   107k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   428k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 107k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 107k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|   107k|                   BSTR_P(name), BSTR_P(param), flags);
  774|   107k|    }
  775|       |
  776|   803k|    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|   803k|    if (co->data)
  ------------------
  |  Branch (780:9): [True: 760k, False: 43.0k]
  ------------------
  781|   760k|        m_option_copy(co->opt, &val, co->data);
  782|       |
  783|   803k|    r = m_option_parse(config->log, co->opt, name, param, &val);
  784|       |
  785|   803k|    if (r >= 0)
  ------------------
  |  Branch (785:9): [True: 798k, False: 5.70k]
  ------------------
  786|   798k|        r = m_config_set_option_raw(config, co, &val, flags);
  787|       |
  788|   803k|    m_option_free(co->opt, &val);
  789|       |
  790|   862k|done:
  791|   862k|    if (r < 0 && r != M_OPT_EXIT) {
  ------------------
  |  |  545|  64.0k|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (791:9): [True: 64.0k, False: 798k]
  |  Branch (791:18): [True: 64.0k, False: 0]
  ------------------
  792|  64.0k|        MP_ERR(config, "Error parsing option %.*s (%s)\n",
  ------------------
  |  |   89|  64.0k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   128k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 64.0k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|  64.0k|               BSTR_P(name), m_option_strerror(r));
  794|  64.0k|        r = M_OPT_INVALID;
  ------------------
  |  |  535|  64.0k|#define M_OPT_INVALID           -3
  ------------------
  795|  64.0k|    }
  796|   862k|    return r;
  797|   803k|}
m_config_set_option_node:
  801|  93.3k|{
  802|  93.3k|    int r;
  803|       |
  804|  93.3k|    struct m_config_option *co = m_config_get_co(config, name);
  805|  93.3k|    if (!co)
  ------------------
  |  Branch (805:9): [True: 0, False: 93.3k]
  ------------------
  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|  93.3k|    union m_option_value val = m_option_value_default;
  811|       |
  812|  93.3k|    r = m_option_set_node_or_string(mp_null_log, co->opt, name, &val, data);
  813|  93.3k|    if (r >= 0)
  ------------------
  |  Branch (813:9): [True: 93.3k, False: 0]
  ------------------
  814|  93.3k|        r = m_config_set_option_raw(config, co, &val, flags);
  815|       |
  816|  93.3k|    if (mp_msg_test(config->log, MSGL_V)) {
  ------------------
  |  Branch (816:9): [True: 0, False: 93.3k]
  ------------------
  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|  93.3k|    m_option_free(co->opt, &val);
  824|  93.3k|    return r;
  825|  93.3k|}
m_config_option_requires_param:
  828|  20.6k|{
  829|  20.6k|    bool negate;
  830|  20.6k|    int flags;
  831|  20.6k|    struct m_config_option *co =
  832|  20.6k|        m_config_mogrify_cli_opt(config, &name, &negate, &flags);
  833|       |
  834|  20.6k|    if (!co)
  ------------------
  |  Branch (834:9): [True: 20.5k, False: 97]
  ------------------
  835|  20.5k|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|  20.5k|#define M_OPT_UNKNOWN           -1
  ------------------
  836|       |
  837|     97|    if (negate || (flags & M_OPT_TYPE_OPTIONAL_PARAM))
  ------------------
  |  |  507|     97|#define M_OPT_TYPE_OPTIONAL_PARAM       (1 << 0)
  ------------------
  |  Branch (837:9): [True: 0, False: 97]
  |  Branch (837:19): [True: 0, False: 97]
  ------------------
  838|      0|        return 0;
  839|       |
  840|     97|    return m_option_required_params(co->opt);
  841|     97|}
m_config_list_options:
  924|      1|{
  925|      1|    char **list = talloc_new(ta_parent);
  ------------------
  |  |   40|      1|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      1|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  926|      1|    int count = 0;
  927|    785|    for (int i = 0; i < config->num_opts; i++) {
  ------------------
  |  Branch (927:21): [True: 784, False: 1]
  ------------------
  928|    784|        struct m_config_option *co = &config->opts[i];
  929|       |        // For use with CONF_TYPE_STRING_LIST, it's important not to set list
  930|       |        // as allocation parent.
  931|    784|        char *s = talloc_strdup(ta_parent, co->name);
  ------------------
  |  |   50|    784|#define talloc_strdup                   ta_xstrdup
  ------------------
  932|    784|        MP_TARRAY_APPEND(ta_parent, list, count, s);
  ------------------
  |  |  105|    784|    do {                                            \
  |  |  106|    784|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    784|    do {                                            \
  |  |  |  |   97|    784|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    784|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    784|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    784|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 9, False: 775]
  |  |  |  |  ------------------
  |  |  |  |   99|    784|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      9|    do {                                                        \
  |  |  |  |  |  |   89|      9|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      9|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      9|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      9|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      9|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      9|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      9|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 9]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    784|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 784]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    784|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    784|        (idxvar)++;                                 \
  |  |  109|    784|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 784]
  |  |  ------------------
  ------------------
  933|    784|    }
  934|      1|    MP_TARRAY_APPEND(ta_parent, list, count, NULL);
  ------------------
  |  |  105|      1|    do {                                            \
  |  |  106|      1|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      1|    do {                                            \
  |  |  |  |   97|      1|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      1|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      1|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      1|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |   99|      1|            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|      1|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      1|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      1|        (idxvar)++;                                 \
  |  |  109|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
  935|      1|    return list;
  936|      1|}
m_config_get_profile:
  939|   203k|{
  940|  1.71M|    for (struct m_profile *p = config->profiles; p; p = p->next) {
  ------------------
  |  Branch (940:50): [True: 1.54M, False: 166k]
  ------------------
  941|  1.54M|        if (bstr_equals0(name, p->name))
  ------------------
  |  Branch (941:13): [True: 36.9k, False: 1.50M]
  ------------------
  942|  36.9k|            return p;
  943|  1.54M|    }
  944|   166k|    return NULL;
  945|   203k|}
m_config_get_profile0:
  949|   203k|{
  950|   203k|    return m_config_get_profile(config, bstr0(name));
  951|   203k|}
m_config_add_profile:
  954|   164k|{
  955|   164k|    if (!name || !name[0])
  ------------------
  |  Branch (955:9): [True: 24.6k, False: 140k]
  |  Branch (955:18): [True: 0, False: 140k]
  ------------------
  956|  24.6k|        name = "default";
  957|   164k|    struct m_profile *p = m_config_get_profile0(config, name);
  958|   164k|    if (p)
  ------------------
  |  Branch (958:9): [True: 12.9k, False: 151k]
  ------------------
  959|  12.9k|        return p;
  960|   151k|    p = talloc_zero(config, struct m_profile);
  ------------------
  |  |   27|   151k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   151k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   151k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|   151k|    p->name = talloc_strdup(p, name);
  ------------------
  |  |   50|   151k|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|   151k|    p->next = config->profiles;
  963|   151k|    config->profiles = p;
  964|   151k|    return p;
  965|   164k|}
m_config_set_profile_option:
  969|   747k|{
  970|   747k|    if (bstr_equals0(name, "profile-desc")) {
  ------------------
  |  Branch (970:9): [True: 0, False: 747k]
  ------------------
  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|   747k|    if (bstr_equals0(name, "profile-cond")) {
  ------------------
  |  Branch (975:9): [True: 0, False: 747k]
  ------------------
  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|   747k|    if (bstr_equals0(name, profile_restore_mode_opt.name)) {
  ------------------
  |  Branch (982:9): [True: 0, False: 747k]
  ------------------
  983|      0|        return m_option_parse(config->log, &profile_restore_mode_opt, name, val,
  984|      0|                              &p->restore_mode);
  985|      0|    }
  986|       |
  987|   747k|    int i = m_config_set_option_cli(config, name, val,
  988|   747k|                                    M_SETOPT_CHECK_ONLY |
  989|   747k|                                    M_SETOPT_FROM_CONFIG_FILE);
  990|   747k|    if (i < 0)
  ------------------
  |  Branch (990:9): [True: 58.3k, False: 688k]
  ------------------
  991|  58.3k|        return i;
  992|   688k|    p->opts = talloc_realloc(p, p->opts, char *, 2 * (p->num_opts + 2));
  ------------------
  |  |   33|   688k|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|   688k|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   688k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   688k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   688k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   688k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|   688k|    p->opts[p->num_opts * 2] = bstrto0(p, name);
  994|   688k|    p->opts[p->num_opts * 2 + 1] = bstrto0(p, val);
  995|   688k|    p->num_opts++;
  996|       |    p->opts[p->num_opts * 2] = p->opts[p->num_opts * 2 + 1] = NULL;
  997|   688k|    return 1;
  998|   747k|}
m_config_set_profile:
 1021|  24.0k|{
 1022|  24.0k|    MP_VERBOSE(config, "Applying profile '%s'...\n", name);
  ------------------
  |  |   92|  24.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  24.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1023|  24.0k|    struct m_profile *p = find_check_profile(config, name);
 1024|  24.0k|    if (!p)
  ------------------
  |  Branch (1024:9): [True: 38, False: 23.9k]
  ------------------
 1025|     38|        return M_OPT_INVALID;
  ------------------
  |  |  535|     38|#define M_OPT_INVALID           -3
  ------------------
 1026|       |
 1027|  23.9k|    if (!config->profile_backup_tmp && p->restore_mode) {
  ------------------
  |  Branch (1027:9): [True: 23.9k, False: 0]
  |  Branch (1027:40): [True: 0, False: 23.9k]
  ------------------
 1028|      0|        config->profile_backup_tmp = &p->backups;
 1029|      0|        config->profile_backup_flags = p->restore_mode == 2 ? BACKUP_NVAL : 0;
  ------------------
  |  |  187|      0|#define BACKUP_NVAL 2
  ------------------
  |  Branch (1029:40): [True: 0, False: 0]
  ------------------
 1030|      0|    }
 1031|       |
 1032|  23.9k|    char *profile_name = talloc_strdup(NULL, name);
  ------------------
  |  |   50|  23.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1033|       |    // Note that we don't check if profile applied correctly, it doesn't matter.
 1034|  23.9k|    MP_TARRAY_APPEND(config, config->profile_stack, config->profile_stack_depth, profile_name);
  ------------------
  |  |  105|  23.9k|    do {                                            \
  |  |  106|  23.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  23.9k|    do {                                            \
  |  |  |  |   97|  23.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  23.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  23.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  23.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 12.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  23.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  23.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 23.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  23.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  23.9k|        (idxvar)++;                                 \
  |  |  109|  23.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 23.9k]
  |  |  ------------------
  ------------------
 1035|  23.9k|    talloc_steal(config->profile_stack, profile_name);
  ------------------
  |  |   38|  23.9k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  23.9k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1036|   129k|    for (int i = 0; i < p->num_opts; i++) {
  ------------------
  |  Branch (1036:21): [True: 105k, False: 23.9k]
  ------------------
 1037|   105k|        m_config_set_option_cli(config,
 1038|   105k|                                bstr0(p->opts[2 * i]),
 1039|   105k|                                bstr0(p->opts[2 * i + 1]),
 1040|   105k|                                flags | M_SETOPT_FROM_CONFIG_FILE);
 1041|   105k|    }
 1042|  23.9k|    if (MP_TARRAY_POP(config->profile_stack, config->profile_stack_depth, &profile_name))
  ------------------
  |  |  153|  23.9k|    ((idxvar) > 0                                   \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 23.9k, False: 0]
  |  |  |  Branch (153:6): [True: 23.9k, False: 0]
  |  |  ------------------
  |  |  154|  23.9k|        ? (*(out) = (p)[--(idxvar)], true)          \
  |  |  155|  23.9k|        : false                                     \
  |  |  156|  23.9k|    )
  ------------------
 1043|  23.9k|        talloc_free(profile_name);
  ------------------
  |  |   47|  23.9k|#define talloc_free                     ta_free
  ------------------
 1044|       |
 1045|  23.9k|    if (config->profile_backup_tmp == &p->backups) {
  ------------------
  |  Branch (1045:9): [True: 0, False: 23.9k]
  ------------------
 1046|      0|        config->profile_backup_tmp = NULL;
 1047|       |
 1048|      0|        for (struct m_opt_backup *bc = p->backups; bc; bc = bc->next) {
  ------------------
  |  Branch (1048:52): [True: 0, False: 0]
  ------------------
 1049|      0|            if (bc && bc->nval)
  ------------------
  |  Branch (1049:17): [True: 0, False: 0]
  |  Branch (1049:23): [True: 0, False: 0]
  ------------------
 1050|      0|                m_option_copy(bc->co->opt, bc->nval, bc->co->data);
 1051|      0|            talloc_steal(p, bc);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1052|      0|        }
 1053|      0|    }
 1054|       |
 1055|  23.9k|    return 0;
 1056|  24.0k|}
m_config_finish_default_profile:
 1074|  12.3k|{
 1075|       |    struct m_profile *p = m_config_add_profile(config, NULL);
 1076|  12.3k|    m_config_set_profile(config, p->name, flags & ~M_SETOPT_FROM_CONFIG_FILE);
 1077|  12.3k|    p->num_opts = 0;
 1078|  12.3k|}
m_config_get_profiles:
 1081|      1|{
 1082|      1|    struct mpv_node root;
 1083|      1|    node_init(&root, MPV_FORMAT_NODE_ARRAY, NULL);
 1084|       |
 1085|     14|    for (m_profile_t *profile = config->profiles; profile; profile = profile->next)
  ------------------
  |  Branch (1085:51): [True: 13, False: 1]
  ------------------
 1086|     13|    {
 1087|     13|        struct mpv_node *entry = node_array_add(&root, MPV_FORMAT_NODE_MAP);
 1088|       |
 1089|     13|        node_map_add_string(entry, "name", profile->name);
 1090|     13|        if (profile->desc)
  ------------------
  |  Branch (1090:13): [True: 0, False: 13]
  ------------------
 1091|      0|            node_map_add_string(entry, "profile-desc", profile->desc);
 1092|     13|        if (profile->cond)
  ------------------
  |  Branch (1092:13): [True: 0, False: 13]
  ------------------
 1093|      0|            node_map_add_string(entry, "profile-cond", profile->cond);
 1094|     13|        if (profile->restore_mode) {
  ------------------
  |  Branch (1094:13): [True: 0, False: 13]
  ------------------
 1095|      0|            char *s =
 1096|      0|                m_option_print(&profile_restore_mode_opt, &profile->restore_mode);
 1097|      0|            node_map_add_string(entry, profile_restore_mode_opt.name, s);
 1098|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1099|      0|        }
 1100|       |
 1101|     13|        struct mpv_node *opts =
 1102|     13|            node_map_add(entry, "options", MPV_FORMAT_NODE_ARRAY);
 1103|       |
 1104|     72|        for (int n = 0; n < profile->num_opts; n++) {
  ------------------
  |  Branch (1104:25): [True: 59, False: 13]
  ------------------
 1105|     59|            struct mpv_node *opt_entry = node_array_add(opts, MPV_FORMAT_NODE_MAP);
 1106|     59|            node_map_add_string(opt_entry, "key", profile->opts[n * 2 + 0]);
 1107|     59|            node_map_add_string(opt_entry, "value", profile->opts[n * 2 + 1]);
 1108|     59|        }
 1109|     13|    }
 1110|       |
 1111|      1|    return root;
 1112|      1|}
m_config_frontend.c:m_config_from_obj_desc:
  128|  24.4k|{
  129|  24.4k|    struct m_sub_options *root = talloc_ptrtype(NULL, root);
  ------------------
  |  |   34|  24.4k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  24.4k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  24.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|  24.4k|    *root = (struct m_sub_options){
  131|  24.4k|        .opts = desc->options,
  132|       |        // (global == NULL got repurposed to mean "no alloc")
  133|  24.4k|        .size = global ? desc->priv_size : 0,
  ------------------
  |  Branch (133:17): [True: 8.01k, False: 16.4k]
  ------------------
  134|  24.4k|        .defaults = desc->priv_defaults,
  135|  24.4k|    };
  136|       |
  137|  24.4k|    struct m_config *c = m_config_new(talloc_ctx, log, root);
  138|  24.4k|    talloc_steal(c, root);
  ------------------
  |  |   38|  24.4k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  24.4k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  139|  24.4k|    c->global = global;
  140|  24.4k|    return c;
  141|  24.4k|}
m_config_frontend.c:m_config_set_obj_params:
  153|  8.01k|{
  154|  10.1k|    for (int n = 0; args && args[n * 2 + 0]; n++) {
  ------------------
  |  Branch (154:21): [True: 3.53k, False: 6.58k]
  |  Branch (154:29): [True: 2.10k, False: 1.43k]
  ------------------
  155|  2.10k|        bstr opt = bstr0(args[n * 2 + 0]);
  156|  2.10k|        bstr val = bstr0(args[n * 2 + 1]);
  157|  2.10k|        if (m_config_set_option_cli(config, opt, val, 0) < 0)
  ------------------
  |  Branch (157:13): [True: 0, False: 2.10k]
  ------------------
  158|      0|            return -1;
  159|  2.10k|    }
  160|       |
  161|  8.01k|    return 0;
  162|  8.01k|}
m_config_frontend.c:restore_backups:
  220|  52.3k|{
  221|  52.3k|    while (*list) {
  ------------------
  |  Branch (221:12): [True: 0, False: 52.3k]
  ------------------
  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|  52.3k|}
m_config_frontend.c:add_backup:
  190|  8.56M|{
  191|  8.56M|    struct m_opt_backup *bc = talloc_ptrtype(NULL, bc);
  ------------------
  |  |   34|  8.56M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  8.56M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.56M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  8.56M|    talloc_set_destructor(bc, backup_dtor);
  ------------------
  |  |   41|  8.56M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  193|  8.56M|    *bc = (struct m_opt_backup) {
  194|  8.56M|        .co = co,
  195|  8.56M|        .backup = talloc_zero_size(bc, co->opt->type->size),
  ------------------
  |  |   44|  8.56M|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|  8.56M|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.56M|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  8.56M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  8.56M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  8.56M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  8.56M|        .nval = flags & BACKUP_NVAL
  ------------------
  |  |  187|  8.56M|#define BACKUP_NVAL 2
  ------------------
  |  Branch (196:17): [True: 0, False: 8.56M]
  ------------------
  197|  8.56M|            ? 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|  8.56M|        .flags = flags,
  199|  8.56M|    };
  200|  8.56M|    m_option_copy(co->opt, bc->backup, co->data);
  201|  8.56M|    bc->next = *list;
  202|  8.56M|    *list = bc;
  203|  8.56M|    if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|  8.56M|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (203:9): [True: 0, False: 8.56M]
  ------------------
  204|      0|        co->is_set_locally = true;
  205|  8.56M|}
m_config_frontend.c:backup_dtor:
  179|  8.56M|{
  180|  8.56M|    struct m_opt_backup *bc = p;
  181|  8.56M|    m_option_free(bc->co->opt, bc->backup);
  182|  8.56M|    if (bc->nval)
  ------------------
  |  Branch (182:9): [True: 0, False: 8.56M]
  ------------------
  183|      0|        m_option_free(bc->co->opt, bc->nval);
  184|  8.56M|}
m_config_frontend.c:search_opt_name:
  293|  18.8M|{
  294|  18.8M|    const struct m_config_option *co = *(const struct m_config_option **)pelem;
  295|  18.8M|    return bstrcmp0(*(const bstr *)pkey, co->name);
  296|  18.8M|}
m_config_frontend.c:m_config_get_co_any:
  310|  1.83M|{
  311|  1.83M|    struct m_config_option *co = m_config_get_co_raw(config, name);
  312|  1.83M|    if (!co)
  ------------------
  |  Branch (312:9): [True: 169k, False: 1.66M]
  ------------------
  313|   169k|        return NULL;
  314|       |
  315|  1.66M|    const char *prefix = config->is_toplevel ? "--" : "";
  ------------------
  |  Branch (315:26): [True: 1.65M, False: 10.3k]
  ------------------
  316|  1.66M|    if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (316:9): [True: 97, False: 1.66M]
  ------------------
  317|     97|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  318|     97|        const char *alias = m_config_shadow_get_alias_from_opt(config->shadow, co->opt_id,
  319|     97|                                                               buf, sizeof(buf));
  320|     97|        if (co->opt->deprecation_message && !co->warning_was_printed) {
  ------------------
  |  Branch (320:13): [True: 0, False: 97]
  |  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|     97|        return m_config_get_co_any(config, bstr0(alias));
  333|  1.66M|    } else if (co->opt->type == &m_option_type_removed) {
  ------------------
  |  Branch (333:16): [True: 2, False: 1.66M]
  ------------------
  334|      2|        if (!co->warning_was_printed) {
  ------------------
  |  Branch (334:13): [True: 1, False: 1]
  ------------------
  335|      1|            char *msg = co->opt->priv;
  336|      1|            if (msg) {
  ------------------
  |  Branch (336:17): [True: 1, False: 0]
  ------------------
  337|      1|                MP_FATAL(config, "Option %s%s was removed: %s\n",
  ------------------
  |  |   88|      1|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  338|      1|                         prefix, co->name, msg);
  339|      1|            } 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|      1|            co->warning_was_printed = true;
  344|      1|        }
  345|      2|        return NULL;
  346|  1.66M|    } else if (co->opt->deprecation_message) {
  ------------------
  |  Branch (346:16): [True: 0, False: 1.66M]
  ------------------
  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|  1.66M|    return co;
  355|  1.66M|}
m_config_frontend.c:async_change_cb:
  507|   113k|{
  508|   113k|    struct m_config *config = p;
  509|       |
  510|   113k|    void *ptr;
  511|   114k|    while (m_config_cache_get_next_changed(config->cache, &ptr)) {
  ------------------
  |  Branch (511:12): [True: 620, False: 113k]
  ------------------
  512|       |        // Regrettable linear search, might degenerate to quadratic.
  513|  96.9k|        for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (513:25): [True: 96.9k, False: 0]
  ------------------
  514|  96.9k|            struct m_config_option *co = &config->opts[n];
  515|  96.9k|            if (co->data == ptr) {
  ------------------
  |  Branch (515:17): [True: 620, False: 96.3k]
  ------------------
  516|    620|                if (config->option_change_callback) {
  ------------------
  |  Branch (516:21): [True: 620, False: 0]
  ------------------
  517|    620|                    config->option_change_callback(
  518|    620|                        config->option_change_callback_ctx, co,
  519|       |                        config->cache->change_flags, false);
  520|    620|                }
  521|    620|                break;
  522|    620|            }
  523|  96.9k|        }
  524|    620|        config->cache->change_flags = 0;
  525|    620|    }
  526|   113k|}
m_config_frontend.c:config_destroy:
  536|  36.1k|{
  537|  36.1k|    struct m_config *config = p;
  538|  36.1k|    config->option_change_callback = NULL;
  539|  36.1k|    m_config_restore_backups(config);
  540|       |
  541|  36.1k|    struct m_opt_backup **list = &config->watch_later_backup_opts;
  542|  8.60M|    while (*list) {
  ------------------
  |  Branch (542:12): [True: 8.56M, False: 36.1k]
  ------------------
  543|  8.56M|        struct m_opt_backup *bc = *list;
  544|  8.56M|        *list = bc->next;
  545|  8.56M|        talloc_free(bc);
  ------------------
  |  |   47|  8.56M|#define talloc_free                     ta_free
  ------------------
  546|  8.56M|    }
  547|       |
  548|  36.1k|    talloc_free(config->cache);
  ------------------
  |  |   47|  36.1k|#define talloc_free                     ta_free
  ------------------
  549|  36.1k|    talloc_free(config->shadow);
  ------------------
  |  |   47|  36.1k|#define talloc_free                     ta_free
  ------------------
  550|  36.1k|}
m_config_frontend.c:compare_opt_name:
  286|  72.8M|{
  287|  72.8M|    const struct m_config_option *a = *(const struct m_config_option **)pa;
  288|  72.8M|    const struct m_config_option *b = *(const struct m_config_option **)pb;
  289|  72.8M|    return strcmp(a->name, b->name);
  290|  72.8M|}
m_config_frontend.c:notify_opt:
  608|  2.82M|{
  609|   133M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (609:21): [True: 133M, False: 0]
  ------------------
  610|   133M|        struct m_config_option *co = &config->opts[n];
  611|   133M|        if (co->data == ptr) {
  ------------------
  |  Branch (611:13): [True: 2.82M, False: 131M]
  ------------------
  612|  2.82M|            if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (612:17): [True: 67.2k, False: 2.75M]
  ------------------
  613|  67.2k|                force_self_notify_change_opt(config, co, self_notification);
  614|  2.82M|            return;
  615|  2.82M|        }
  616|   133M|    }
  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|  1.77M|{
  402|  1.77M|    uint64_t optflags = co->opt->flags;
  403|  1.77M|    bool set = !(flags & M_SETOPT_CHECK_ONLY);
  404|       |
  405|  1.77M|    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: 1.77M]
  |  Branch (405:46): [True: 0, False: 0]
  ------------------
  406|      0|        return 0;
  407|       |
  408|  1.77M|    if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline)
  ------------------
  |  Branch (408:9): [True: 0, False: 1.77M]
  |  Branch (408:48): [True: 0, False: 0]
  ------------------
  409|      0|        set = false;
  410|       |
  411|  1.77M|    if ((flags & M_SETOPT_NO_OVERWRITE) &&
  ------------------
  |  Branch (411:9): [True: 0, False: 1.77M]
  ------------------
  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|  1.77M|    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: 1.77M]
  |  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|  1.77M|    if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
  ------------------
  |  |  468|  1.58M|#define M_OPT_NOCFG             (UINT64_C(1) << 63)
  ------------------
  |  Branch (419:9): [True: 1.58M, False: 187k]
  |  Branch (419:48): [True: 0, False: 1.58M]
  ------------------
  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|  1.77M|    if ((flags & M_SETOPT_BACKUP) && set)
  ------------------
  |  Branch (424:9): [True: 0, False: 1.77M]
  |  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|  1.77M|    return set ? 2 : 1;
  ------------------
  |  Branch (427:12): [True: 387k, False: 1.38M]
  ------------------
  428|  1.77M|}
m_config_frontend.c:m_config_handle_special_options:
  446|   279k|{
  447|   279k|    if (config->use_profiles && strcmp(co->name, "profile") == 0) {
  ------------------
  |  Branch (447:9): [True: 277k, False: 2.10k]
  |  Branch (447:33): [True: 0, False: 277k]
  ------------------
  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|   279k|    if (config->includefunc && strcmp(co->name, "include") == 0) {
  ------------------
  |  Branch (467:9): [True: 277k, False: 2.10k]
  |  Branch (467:32): [True: 0, False: 277k]
  ------------------
  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|   279k|    if (config->use_profiles && strcmp(co->name, "show-profile") == 0)
  ------------------
  |  Branch (483:9): [True: 277k, False: 2.10k]
  |  Branch (483:33): [True: 0, False: 277k]
  ------------------
  484|      0|        return show_profile(config, bstr0(*(char **)data), 0);
  485|       |
  486|   279k|    if (config->is_toplevel && (strcmp(co->name, "h") == 0 ||
  ------------------
  |  Branch (486:9): [True: 277k, False: 2.10k]
  |  Branch (486:33): [True: 0, False: 277k]
  ------------------
  487|   277k|                                strcmp(co->name, "help") == 0))
  ------------------
  |  Branch (487:33): [True: 0, False: 277k]
  ------------------
  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|   279k|    if (strcmp(co->name, "list-options") == 0) {
  ------------------
  |  Branch (496:9): [True: 0, False: 279k]
  ------------------
  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|   279k|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|   279k|#define M_OPT_UNKNOWN           -1
  ------------------
  502|   279k|}
m_config_frontend.c:force_self_notify_change_opt:
  597|   335k|{
  598|   335k|    int changed =
  599|   335k|        m_config_cache_get_option_change_mask(config->cache, co->opt_id);
  600|       |
  601|   335k|    if (config->option_change_callback) {
  ------------------
  |  Branch (601:9): [True: 135k, False: 200k]
  ------------------
  602|   135k|        config->option_change_callback(config->option_change_callback_ctx, co,
  603|   135k|                                       changed, self_notification);
  604|   135k|    }
  605|   335k|}
m_config_frontend.c:m_config_mogrify_cli_opt:
  673|   882k|{
  674|   882k|    *out_negate = false;
  675|   882k|    *out_add_flags = 0;
  676|       |
  677|   882k|    struct m_config_option *co = m_config_get_co(config, *name);
  678|   882k|    if (co)
  ------------------
  |  Branch (678:9): [True: 722k, False: 160k]
  ------------------
  679|   722k|        return co;
  680|       |
  681|       |    // Turn "--no-foo" into "foo" + set *out_negate.
  682|   160k|    bstr no_name = *name;
  683|   160k|    if (!co && bstr_eatstart0(&no_name, "no-")) {
  ------------------
  |  Branch (683:9): [True: 160k, False: 0]
  |  Branch (683:16): [True: 13, False: 160k]
  ------------------
  684|     13|        co = m_config_get_co(config, no_name);
  685|     13|        if (!co)
  ------------------
  |  Branch (685:13): [True: 13, False: 0]
  ------------------
  686|     13|            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|   160k|    co = m_config_get_co_any(config, *name);
  701|   160k|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (701:9): [True: 81.7k, False: 78.8k]
  |  Branch (701:15): [True: 81.7k, False: 0]
  ------------------
  702|  81.7k|        *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|  48.5M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (706:21): [True: 48.4M, False: 78.8k]
  ------------------
  707|  48.4M|        co = &config->opts[n];
  708|  48.4M|        struct bstr basename = bstr0(co->name);
  709|       |
  710|  48.4M|        if (!bstr_startswith(*name, basename))
  ------------------
  |  Branch (710:13): [True: 48.2M, False: 198k]
  ------------------
  711|  48.2M|            continue;
  712|       |
  713|       |        // Aliased option + a suffix action, e.g. --opengl-shaders-append
  714|   198k|        if (co->opt->type == &m_option_type_alias)
  ------------------
  |  Branch (714:13): [True: 0, False: 198k]
  ------------------
  715|      0|            co = m_config_get_co_any(config, basename);
  716|   198k|        if (!co)
  ------------------
  |  Branch (716:13): [True: 0, False: 198k]
  ------------------
  717|      0|            continue;
  718|       |
  719|   198k|        const struct m_option_type *type = co->opt->type;
  720|   280k|        for (int i = 0; type->actions && type->actions[i].name; i++) {
  ------------------
  |  Branch (720:25): [True: 163k, False: 116k]
  |  Branch (720:42): [True: 163k, False: 63]
  ------------------
  721|   163k|            const struct m_option_action *action = &type->actions[i];
  722|   163k|            bstr suffix = bstr0(action->name);
  723|       |
  724|   163k|            if (bstr_endswith(*name, suffix) &&
  ------------------
  |  Branch (724:17): [True: 81.7k, False: 82.0k]
  ------------------
  725|  81.7k|                (name->len == basename.len + 1 + suffix.len) &&
  ------------------
  |  Branch (725:17): [True: 81.7k, False: 19]
  ------------------
  726|  81.7k|                name->start[basename.len] == '-')
  ------------------
  |  Branch (726:17): [True: 81.7k, False: 0]
  ------------------
  727|  81.7k|            {
  728|  81.7k|                *out_add_flags = action->flags;
  729|  81.7k|                return co;
  730|  81.7k|            }
  731|   163k|        }
  732|   198k|    }
  733|       |
  734|  78.8k|    return NULL;
  735|   160k|}
m_config_frontend.c:find_check_profile:
 1001|  24.0k|{
 1002|  24.0k|    struct m_profile *p = m_config_get_profile0(config, name);
 1003|  24.0k|    if (!p) {
  ------------------
  |  Branch (1003:9): [True: 38, False: 23.9k]
  ------------------
 1004|     38|        MP_WARN(config, "Unknown profile '%s'.\n", name);
  ------------------
  |  |   90|     38|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     38|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1005|     38|        return NULL;
 1006|     38|    }
 1007|  23.9k|    for (size_t i = 0; i < config->profile_stack_depth; ++i) {
  ------------------
  |  Branch (1007:24): [True: 0, False: 23.9k]
  ------------------
 1008|      0|        if (strcmp(config->profile_stack[i], name))
  ------------------
  |  Branch (1008:13): [True: 0, False: 0]
  ------------------
 1009|      0|            continue;
 1010|      0|        MP_WARN(config, "Profile '%s' has already been applied.\n", name);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1011|      0|        return NULL;
 1012|      0|    }
 1013|  23.9k|    if (config->profile_stack_depth > MAX_PROFILE_DEPTH) {
  ------------------
  |  |   43|  23.9k|#define MAX_PROFILE_DEPTH 20
  ------------------
  |  Branch (1013:9): [True: 0, False: 23.9k]
  ------------------
 1014|      0|        MP_WARN(config, "Profile inclusion too deep.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1015|      0|        return NULL;
 1016|      0|    }
 1017|  23.9k|    return p;
 1018|  23.9k|}

m_option_parse:
   65|  1.48M|{
   66|  1.48M|    int r = M_OPT_INVALID;
  ------------------
  |  |  535|  1.48M|#define M_OPT_INVALID           -3
  ------------------
   67|  1.48M|    if (bstr_equals0(param, "help") && opt->help) {
  ------------------
  |  Branch (67:9): [True: 481, False: 1.48M]
  |  Branch (67:40): [True: 0, False: 481]
  ------------------
   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.48M|    r = opt->type->parse(log, opt, name, param, dst);
   74|  1.48M|    if (r < 0)
  ------------------
  |  Branch (74:9): [True: 69.7k, False: 1.41M]
  ------------------
   75|  69.7k|        return r;
   76|       |
   77|  1.41M|    if (opt->validate) {
  ------------------
  |  Branch (77:9): [True: 55, False: 1.41M]
  ------------------
   78|     55|        r = opt->validate(log, opt, name, dst);
   79|     55|        if (r < 0) {
  ------------------
  |  Branch (79:13): [True: 55, False: 0]
  ------------------
   80|     55|            if (opt->type->free)
  ------------------
  |  Branch (80:17): [True: 55, False: 0]
  ------------------
   81|     55|                opt->type->free(dst);
   82|     55|            return r;
   83|     55|        }
   84|     55|    }
   85|  1.41M|    return 1;
   86|  1.41M|}
m_option_strerror:
   89|   104k|{
   90|   104k|    switch (code) {
   91|  58.3k|    case M_OPT_UNKNOWN:
  ------------------
  |  |  529|  58.3k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (91:5): [True: 58.3k, False: 46.5k]
  ------------------
   92|  58.3k|        return "option not found";
   93|  1.09k|    case M_OPT_MISSING_PARAM:
  ------------------
  |  |  532|  1.09k|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (93:5): [True: 1.09k, False: 103k]
  ------------------
   94|  1.09k|        return "option requires parameter";
   95|  44.9k|    case M_OPT_INVALID:
  ------------------
  |  |  535|  44.9k|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (95:5): [True: 44.9k, False: 60.0k]
  ------------------
   96|  44.9k|        return "option parameter could not be parsed";
   97|    558|    case M_OPT_OUT_OF_RANGE:
  ------------------
  |  |  539|    558|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  |  Branch (97:5): [True: 558, False: 104k]
  ------------------
   98|    558|        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: 104k]
  ------------------
  100|      0|        return "option doesn't take a parameter";
  101|      0|    default:
  ------------------
  |  Branch (101:5): [True: 0, False: 104k]
  ------------------
  102|      0|        return "parser error";
  103|   104k|    }
  104|   104k|}
m_option_required_params:
  107|     97|{
  108|     97|    if (opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM)
  ------------------
  |  |  507|     97|#define M_OPT_TYPE_OPTIONAL_PARAM       (1 << 0)
  ------------------
  |  Branch (108:9): [True: 0, False: 97]
  ------------------
  109|      0|        return 0;
  110|     97|    if (opt->flags & M_OPT_OPTIONAL_PARAM)
  ------------------
  |  |  497|     97|#define M_OPT_OPTIONAL_PARAM    (UINT64_C(1) << 54)
  ------------------
  |  Branch (110:9): [True: 0, False: 97]
  ------------------
  111|      0|        return 0;
  112|     97|    if (opt->type == &m_option_type_choice) {
  ------------------
  |  Branch (112:9): [True: 8, False: 89]
  ------------------
  113|      8|        const struct m_opt_choice_alternatives *alt;
  114|    152|        for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (114:31): [True: 144, False: 8]
  ------------------
  115|    144|            if (strcmp(alt->name, "yes") == 0)
  ------------------
  |  Branch (115:17): [True: 0, False: 144]
  ------------------
  116|      0|                return 0;
  117|    144|        }
  118|      8|    }
  119|     97|    return 1;
  120|     97|}
m_option_set_node_or_string:
  124|   106k|{
  125|   106k|    if (src->format == MPV_FORMAT_STRING) {
  ------------------
  |  Branch (125:9): [True: 106k, False: 0]
  ------------------
  126|   106k|        return m_option_parse(log, opt, name, bstr0(src->u.string), dst);
  127|   106k|    } else {
  128|      0|        return m_option_set_node(opt, dst, src);
  129|      0|    }
  130|   106k|}
format_file_size:
  569|  1.25k|{
  570|  1.25k|    double s = size;
  571|  1.25k|    if (size < 1024)
  ------------------
  |  Branch (571:9): [True: 119, False: 1.13k]
  ------------------
  572|    119|        return talloc_asprintf(NULL, "%.0f B", s);
  ------------------
  |  |   52|    119|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|    119|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  573|       |
  574|  1.13k|    if (size < (1024 * 1024))
  ------------------
  |  Branch (574:9): [True: 12, False: 1.12k]
  ------------------
  575|     12|        return talloc_asprintf(NULL, "%.3f KiB", s / (1024.0));
  ------------------
  |  |   52|     12|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     12|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  576|       |
  577|  1.12k|    if (size < (1024 * 1024 * 1024))
  ------------------
  |  Branch (577:9): [True: 54, False: 1.06k]
  ------------------
  578|     54|        return talloc_asprintf(NULL, "%.3f MiB", s / (1024.0 * 1024.0));
  ------------------
  |  |   52|     54|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     54|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  579|       |
  580|  1.06k|    if (size < (1024LL * 1024LL * 1024LL * 1024LL))
  ------------------
  |  Branch (580:9): [True: 1.02k, False: 43]
  ------------------
  581|  1.02k|        return talloc_asprintf(NULL, "%.3f GiB", s / (1024.0 * 1024.0 * 1024.0));
  ------------------
  |  |   52|  1.02k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  1.02k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  582|       |
  583|     43|    return talloc_asprintf(NULL, "%.3f TiB", s / (1024.0 * 1024.0 * 1024.0 * 1024.0));
  ------------------
  |  |   52|     43|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     43|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  584|  1.06k|}
m_opt_choice_str:
  608|  1.51M|{
  609|  1.51M|    const char *val = m_opt_choice_str_def(choices, value, NULL);
  610|  1.51M|    if (val)
  ------------------
  |  Branch (610:9): [True: 1.51M, False: 0]
  ------------------
  611|  1.51M|        return val;
  612|      0|    return "<unknown>";
  613|  1.51M|}
m_opt_choice_str_def:
  617|  1.51M|{
  618|  4.44M|    for (const struct m_opt_choice_alternatives *c = choices; c->name; c++) {
  ------------------
  |  Branch (618:63): [True: 4.44M, False: 0]
  ------------------
  619|  4.44M|        if (c->value == value)
  ------------------
  |  Branch (619:13): [True: 1.51M, False: 2.92M]
  ------------------
  620|  1.51M|            return c->name;
  621|  4.44M|    }
  622|      0|    return def;
  623|  1.51M|}
m_obj_list_find:
 3045|   141k|{
 3046|   588k|    for (int i = 0; ; i++) {
 3047|   588k|        if (!l->get_desc(dst, i))
  ------------------
  |  Branch (3047:13): [True: 8.74k, False: 579k]
  ------------------
 3048|  8.74k|            break;
 3049|   579k|        if (bstr_equals0(name, dst->name))
  ------------------
  |  Branch (3049:13): [True: 132k, False: 446k]
  ------------------
 3050|   132k|            return true;
 3051|   579k|    }
 3052|  8.97k|    for (int i = 0; l->aliases[i][0]; i++) {
  ------------------
  |  Branch (3052:21): [True: 236, False: 8.74k]
  ------------------
 3053|    236|        const char *aname = l->aliases[i][0];
 3054|    236|        const char *alias = l->aliases[i][1];
 3055|    236|        if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias)))
  ------------------
  |  Branch (3055:13): [True: 0, False: 236]
  |  Branch (3055:42): [True: 0, False: 0]
  ------------------
 3056|      0|        {
 3057|      0|            dst->replaced_name = aname;
 3058|      0|            return true;
 3059|      0|        }
 3060|    236|    }
 3061|  8.74k|    return false;
 3062|  8.74k|}
m_obj_settings_equal:
 3891|  90.4k|{
 3892|  90.4k|    if (!str_equal(NULL, &a->name, &b->name))
  ------------------
  |  Branch (3892:9): [True: 79, False: 90.3k]
  ------------------
 3893|     79|        return false;
 3894|       |
 3895|  90.3k|    if (!str_equal(NULL, &a->label, &b->label))
  ------------------
  |  Branch (3895:9): [True: 0, False: 90.3k]
  ------------------
 3896|      0|        return false;
 3897|       |
 3898|  90.3k|    if (a->enabled != b->enabled)
  ------------------
  |  Branch (3898:9): [True: 0, False: 90.3k]
  ------------------
 3899|      0|        return false;
 3900|       |
 3901|  90.3k|    return str_list_equal(NULL, &a->attribs, &b->attribs);
 3902|  90.3k|}
node_get_alloc:
 4018|  6.48M|{
 4019|       |    // Assume it was allocated with copy_node(), which allocates all
 4020|       |    // sub-nodes with the parent node as talloc parent.
 4021|  6.48M|    switch (node->format) {
 4022|    957|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (4022:5): [True: 957, False: 6.48M]
  ------------------
 4023|    957|        return node->u.string;
 4024|     37|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (4024:5): [True: 37, False: 6.48M]
  ------------------
 4025|  5.59M|    case MPV_FORMAT_NODE_MAP:
  ------------------
  |  Branch (4025:5): [True: 5.59M, False: 890k]
  ------------------
 4026|  5.59M|        return node->u.list;
 4027|   889k|    default:
  ------------------
  |  Branch (4027:5): [True: 889k, False: 5.59M]
  ------------------
 4028|       |        return NULL;
 4029|  6.48M|    }
 4030|  6.48M|}
m_option.c:parse_bool:
  146|   340k|{
  147|   340k|    if (bstr_equals0(param, "yes") || !param.len) {
  ------------------
  |  Branch (147:9): [True: 70.0k, False: 270k]
  |  Branch (147:39): [True: 1.56k, False: 269k]
  ------------------
  148|  71.5k|        if (dst)
  ------------------
  |  Branch (148:13): [True: 71.5k, False: 0]
  ------------------
  149|  71.5k|            VAL(dst) = 1;
  ------------------
  |  |  142|  71.5k|#define VAL(x) (*(bool *)(x))
  ------------------
  150|  71.5k|        return 1;
  151|  71.5k|    }
  152|   269k|    if (bstr_equals0(param, "no")) {
  ------------------
  |  Branch (152:9): [True: 268k, False: 729]
  ------------------
  153|   268k|        if (dst)
  ------------------
  |  Branch (153:13): [True: 268k, False: 0]
  ------------------
  154|   268k|            VAL(dst) = 0;
  ------------------
  |  |  142|   268k|#define VAL(x) (*(bool *)(x))
  ------------------
  155|   268k|        return 1;
  156|   268k|    }
  157|   269k|    bool is_help = bstr_equals0(param, "help");
  158|    729|    if (is_help) {
  ------------------
  |  Branch (158:9): [True: 0, False: 729]
  ------------------
  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|    729|    } else {
  161|    729|        mp_fatal(log, "Invalid parameter for %.*s flag: %.*s\n",
  ------------------
  |  |   75|  2.91k|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 729, False: 0]
  |  |  |  Branch (75:57): [True: 729, False: 0]
  |  |  ------------------
  ------------------
  162|    729|                 BSTR_P(name), BSTR_P(param));
  163|    729|        mp_info(log, "Valid values are:\n");
  ------------------
  |  |   78|    729|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  164|    729|    }
  165|    729|    mp_info(log, "    yes\n");
  ------------------
  |  |   78|    729|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  166|    729|    mp_info(log, "    no\n");
  ------------------
  |  |   78|    729|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  167|    729|    mp_info(log, "    (passing nothing)\n");
  ------------------
  |  |   78|    729|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  168|    729|    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|    729|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (168:12): [True: 0, False: 729]
  ------------------
  169|   269k|}
m_option.c:print_bool:
  172|  9.06k|{
  173|  9.06k|    return talloc_strdup(NULL, VAL(val) ? "yes" : "no");
  ------------------
  |  |   50|  9.06k|#define talloc_strdup                   ta_xstrdup
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? "yes" : "no");
  ------------------
  |  |  142|  9.06k|#define VAL(x) (*(bool *)(x))
  |  |  ------------------
  |  |  |  Branch (142:16): [True: 2.65k, False: 6.41k]
  |  |  ------------------
  ------------------
  174|  9.06k|}
m_option.c:copy_opt:
  135|  8.78M|{
  136|  8.78M|    if (dst && src)
  ------------------
  |  Branch (136:9): [True: 8.78M, False: 0]
  |  Branch (136:16): [True: 8.78M, False: 0]
  ------------------
  137|  8.78M|        memcpy(dst, src, opt->type->size);
  138|  8.78M|}
m_option.c:add_bool:
  177|  2.32k|{
  178|  2.32k|    if (fabs(add) < 0.5)
  ------------------
  |  Branch (178:9): [True: 34, False: 2.29k]
  ------------------
  179|     34|        return;
  180|  2.32k|    bool state = !!VAL(val);
  ------------------
  |  |  142|  2.29k|#define VAL(x) (*(bool *)(x))
  ------------------
  181|  2.29k|    state = wrap ? !state : add > 0;
  ------------------
  |  Branch (181:13): [True: 1.27k, False: 1.02k]
  ------------------
  182|  2.29k|    VAL(val) = state ? 1 : 0;
  ------------------
  |  |  142|  2.29k|#define VAL(x) (*(bool *)(x))
  ------------------
  |  Branch (182:16): [True: 1.65k, False: 642]
  ------------------
  183|  2.29k|}
m_option.c:bool_get:
  195|  25.0k|{
  196|  25.0k|    dst->format = MPV_FORMAT_FLAG;
  197|  25.0k|    dst->u.flag = !!VAL(src);
  ------------------
  |  |  142|  25.0k|#define VAL(x) (*(bool *)(x))
  ------------------
  198|  25.0k|    return 1;
  199|  25.0k|}
m_option.c:bool_equal:
  202|  8.03M|{
  203|  8.03M|    return VAL(a) == VAL(b);
  ------------------
  |  |  142|  8.03M|#define VAL(x) (*(bool *)(x))
  ------------------
                  return VAL(a) == VAL(b);
  ------------------
  |  |  142|  8.03M|#define VAL(x) (*(bool *)(x))
  ------------------
  204|  8.03M|}
m_option.c:parse_int:
  352|  16.4k|{
  353|  16.4k|    long long tmp;
  354|  16.4k|    int r = parse_longlong(log, opt, INT_MIN, INT_MAX, name, param, &tmp);
  355|  16.4k|    if (r >= 0 && dst)
  ------------------
  |  Branch (355:9): [True: 15.0k, False: 1.35k]
  |  Branch (355:19): [True: 15.0k, False: 0]
  ------------------
  356|  15.0k|        *(int *)dst = tmp;
  357|  16.4k|    return r;
  358|  16.4k|}
m_option.c:parse_longlong:
  308|  16.7k|{
  309|  16.7k|    if (param.len == 0)
  ------------------
  |  Branch (309:9): [True: 130, False: 16.6k]
  ------------------
  310|    130|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|    130|#define M_OPT_MISSING_PARAM     -2
  ------------------
  311|       |
  312|  16.6k|    struct bstr rest;
  313|  16.6k|    long long tmp_int = bstrtoll(param, &rest, 10);
  314|  16.6k|    if (rest.len)
  ------------------
  |  Branch (314:9): [True: 1.16k, False: 15.4k]
  ------------------
  315|  1.16k|        tmp_int = bstrtoll(param, &rest, 0);
  316|  16.6k|    if (rest.len) {
  ------------------
  |  Branch (316:9): [True: 1.16k, False: 15.4k]
  ------------------
  317|  1.16k|        mp_err(log, "The %.*s option must be an integer: %.*s\n",
  ------------------
  |  |   76|  4.64k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 1.16k, False: 0]
  |  |  |  Branch (76:55): [True: 1.16k, False: 0]
  |  |  ------------------
  ------------------
  318|  1.16k|               BSTR_P(name), BSTR_P(param));
  319|  1.16k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  1.16k|#define M_OPT_INVALID           -3
  ------------------
  320|  1.16k|    }
  321|       |
  322|  15.4k|    long long min = OPT_INT_MIN(opt, long long, i_min);
  ------------------
  |  |   58|  15.4k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 12.2k, False: 3.19k]
  |  |  ------------------
  |  |   59|  15.4k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 12.2k]
  |  |  ------------------
  ------------------
  323|  15.4k|    if (tmp_int < min) {
  ------------------
  |  Branch (323:9): [True: 16, False: 15.4k]
  ------------------
  324|     16|        mp_err(log, "The %.*s option must be >= %lld: %.*s\n",
  ------------------
  |  |   76|     64|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 16, False: 0]
  |  |  |  Branch (76:55): [True: 16, False: 0]
  |  |  ------------------
  ------------------
  325|     16|               BSTR_P(name), min, BSTR_P(param));
  326|     16|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     16|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  327|     16|    }
  328|       |
  329|  15.4k|    long long max = OPT_INT_MAX(opt, long long, i_max);
  ------------------
  |  |   60|  15.4k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 12.2k, False: 3.19k]
  |  |  ------------------
  |  |   61|  15.4k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 11.7k, False: 570]
  |  |  ------------------
  ------------------
  330|  15.4k|    if (tmp_int > max) {
  ------------------
  |  Branch (330:9): [True: 318, False: 15.1k]
  ------------------
  331|    318|        mp_err(log, "The %.*s option must be <= %lld: %.*s\n",
  ------------------
  |  |   76|  1.27k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 318, False: 0]
  |  |  |  Branch (76:55): [True: 318, False: 0]
  |  |  ------------------
  ------------------
  332|    318|               BSTR_P(name), max, BSTR_P(param));
  333|    318|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|    318|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  334|    318|    }
  335|       |
  336|  15.1k|    if (dst)
  ------------------
  |  Branch (336:9): [True: 15.1k, False: 0]
  ------------------
  337|  15.1k|        *(long long *)dst = tmp_int;
  338|       |
  339|  15.1k|    return 1;
  340|  15.4k|}
m_option.c:print_int:
  371|   160k|{
  372|   160k|    if (opt->type->size == sizeof(int64_t))
  ------------------
  |  Branch (372:9): [True: 29.5k, False: 131k]
  ------------------
  373|  29.5k|        return talloc_asprintf(NULL, "%"PRId64, *(const int64_t *)val);
  ------------------
  |  |   52|  29.5k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  29.5k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  374|   131k|    return talloc_asprintf(NULL, "%d", *(const int *)val);
  ------------------
  |  |   52|   131k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   131k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  375|   160k|}
m_option.c:add_int:
  401|  3.28k|{
  402|  3.28k|    int64_t tmp = *(int *)val;
  403|  3.28k|    add_int64(opt, &tmp, add, wrap);
  404|  3.28k|    *(int *)val = tmp;
  405|  3.28k|}
m_option.c:int_get:
  461|     43|{
  462|     43|    dst->format = MPV_FORMAT_INT64;
  463|     43|    dst->u.int64 = *(int *)src;
  464|     43|    return 1;
  465|     43|}
m_option.c:int_equal:
  468|  3.83M|{
  469|  3.83M|    return *(int *)a == *(int *)b;
  470|  3.83M|}
m_option.c:parse_int64:
  362|     85|{
  363|     85|    long long tmp;
  364|     85|    int r = parse_longlong(log, opt, INT64_MIN, INT64_MAX, name, param, &tmp);
  365|     85|    if (r >= 0 && dst)
  ------------------
  |  Branch (365:9): [True: 27, False: 58]
  |  Branch (365:19): [True: 27, False: 0]
  ------------------
  366|     27|        *(int64_t *)dst = tmp;
  367|     85|    return r;
  368|     85|}
m_option.c:add_int64:
  378|  33.2k|{
  379|  33.2k|    int64_t v = *(int64_t *)val;
  380|       |
  381|  33.2k|    clamp_int64(opt, &v);
  382|       |
  383|  33.2k|    v = v + add;
  384|       |
  385|  33.2k|    bool is64 = opt->type->size == sizeof(int64_t);
  386|  33.2k|    int64_t nmin = is64 ? INT64_MIN : INT_MIN;
  ------------------
  |  Branch (386:20): [True: 29.9k, False: 3.28k]
  ------------------
  387|  33.2k|    int64_t nmax = is64 ? INT64_MAX : INT_MAX;
  ------------------
  |  Branch (387:20): [True: 29.9k, False: 3.28k]
  ------------------
  388|       |
  389|  33.2k|    int64_t min = OPT_INT_MIN(opt, int64_t, nmin);
  ------------------
  |  |   58|  33.2k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 1.37k, False: 31.8k]
  |  |  ------------------
  |  |   59|  33.2k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 1.37k]
  |  |  ------------------
  ------------------
  390|  33.2k|    int64_t max = OPT_INT_MAX(opt, int64_t, nmax);
  ------------------
  |  |   60|  33.2k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 1.37k, False: 31.8k]
  |  |  ------------------
  |  |   61|  33.2k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 56, False: 1.31k]
  |  |  ------------------
  ------------------
  391|       |
  392|  33.2k|    if (v < min)
  ------------------
  |  Branch (392:9): [True: 61, False: 33.2k]
  ------------------
  393|     61|        v = wrap ? max : min;
  ------------------
  |  Branch (393:13): [True: 1, False: 60]
  ------------------
  394|  33.2k|    if (v > max)
  ------------------
  |  Branch (394:9): [True: 10, False: 33.2k]
  ------------------
  395|     10|        v = wrap ? min : max;
  ------------------
  |  Branch (395:13): [True: 1, False: 9]
  ------------------
  396|       |
  397|  33.2k|    *(int64_t *)val = v;
  398|  33.2k|}
m_option.c:clamp_int64:
  343|  33.2k|{
  344|  33.2k|    long long tmp = *(int64_t *)val;
  345|  33.2k|    int r = clamp_longlong(opt, INT64_MIN, INT64_MAX, &tmp);
  346|  33.2k|    *(int64_t *)val = tmp;
  347|  33.2k|    return r;
  348|  33.2k|}
m_option.c:clamp_longlong:
  288|  33.2k|{
  289|  33.2k|    long long v = *(long long *)val;
  290|  33.2k|    int r = 0;
  291|  33.2k|    long long min = OPT_INT_MIN(opt, long long, i_min);
  ------------------
  |  |   58|  33.2k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 1.37k, False: 31.8k]
  |  |  ------------------
  |  |   59|  33.2k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 1.37k]
  |  |  ------------------
  ------------------
  292|  33.2k|    long long max = OPT_INT_MAX(opt, long long, i_max);
  ------------------
  |  |   60|  33.2k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 1.37k, False: 31.8k]
  |  |  ------------------
  |  |   61|  33.2k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 39, False: 1.33k]
  |  |  ------------------
  ------------------
  293|  33.2k|    if (v > max) {
  ------------------
  |  Branch (293:9): [True: 0, False: 33.2k]
  ------------------
  294|      0|        v = max;
  295|      0|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  296|      0|    }
  297|  33.2k|    if (v < min) {
  ------------------
  |  Branch (297:9): [True: 0, False: 33.2k]
  ------------------
  298|      0|        v = min;
  299|      0|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  300|      0|    }
  301|  33.2k|    *(long long *)val = v;
  302|  33.2k|    return r;
  303|  33.2k|}
m_option.c:int64_get:
  453|     25|{
  454|     25|    dst->format = MPV_FORMAT_INT64;
  455|     25|    dst->u.int64 = *(int64_t *)src;
  456|     25|    return 1;
  457|     25|}
m_option.c:int64_equal:
  473|  82.8k|{
  474|  82.8k|    return *(int64_t *)a == *(int64_t *)b;
  475|  82.8k|}
m_option.c:parse_byte_size:
  507|  12.6k|{
  508|  12.6k|    if (param.len == 0)
  ------------------
  |  Branch (508:9): [True: 427, False: 12.2k]
  ------------------
  509|    427|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|    427|#define M_OPT_MISSING_PARAM     -2
  ------------------
  510|       |
  511|  12.2k|    struct bstr r;
  512|  12.2k|    long long tmp_int = bstrtoll(param, &r, 0);
  513|  12.2k|    int64_t unit = 1;
  514|  12.2k|    if (r.len) {
  ------------------
  |  Branch (514:9): [True: 12.1k, False: 44]
  ------------------
  515|  12.1k|        if (bstrcasecmp0(r, "b") == 0) {
  ------------------
  |  Branch (515:13): [True: 13, False: 12.1k]
  ------------------
  516|     13|            unit = 1;
  517|  12.1k|        } else if (bstrcasecmp0(r, "kib") == 0 || bstrcasecmp0(r, "k") == 0) {
  ------------------
  |  Branch (517:20): [True: 0, False: 12.1k]
  |  Branch (517:51): [True: 11.6k, False: 488]
  ------------------
  518|  11.6k|            unit = 1024;
  519|  11.6k|        } else if (bstrcasecmp0(r, "mib") == 0 || bstrcasecmp0(r, "m") == 0) {
  ------------------
  |  Branch (519:20): [True: 0, False: 488]
  |  Branch (519:51): [True: 169, False: 319]
  ------------------
  520|    169|            unit = 1024 * 1024;
  521|    319|        } else if (bstrcasecmp0(r, "gib") == 0 || bstrcasecmp0(r, "g") == 0) {
  ------------------
  |  Branch (521:20): [True: 0, False: 319]
  |  Branch (521:51): [True: 94, False: 225]
  ------------------
  522|     94|            unit = 1024 * 1024 * 1024;
  523|    225|        } else if (bstrcasecmp0(r, "tib") == 0 || bstrcasecmp0(r, "t") == 0) {
  ------------------
  |  Branch (523:20): [True: 0, False: 225]
  |  Branch (523:51): [True: 56, False: 169]
  ------------------
  524|     56|            unit = 1024 * 1024 * 1024 * 1024LL;
  525|    169|        } else {
  526|    169|            mp_err(log, "The %.*s option must be an integer: %.*s\n",
  ------------------
  |  |   76|    676|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 169, False: 0]
  |  |  |  Branch (76:55): [True: 169, False: 0]
  |  |  ------------------
  ------------------
  527|    169|                   BSTR_P(name), BSTR_P(param));
  528|    169|            mp_err(log, "The following suffixes are also allowed: "
  ------------------
  |  |   76|    169|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  529|    169|                   "KiB, MiB, GiB, TiB, B, K, M, G, T.\n");
  530|    169|            return M_OPT_INVALID;
  ------------------
  |  |  535|    169|#define M_OPT_INVALID           -3
  ------------------
  531|    169|        }
  532|  12.1k|    }
  533|       |
  534|  12.0k|    if (tmp_int < 0) {
  ------------------
  |  Branch (534:9): [True: 18, False: 12.0k]
  ------------------
  535|     18|        mp_err(log, "The %.*s option does not support negative numbers: %.*s\n",
  ------------------
  |  |   76|     72|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 18, False: 0]
  |  |  |  Branch (76:55): [True: 18, False: 0]
  |  |  ------------------
  ------------------
  536|     18|               BSTR_P(name), BSTR_P(param));
  537|     18|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     18|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  538|     18|    }
  539|       |
  540|  12.0k|    if (INT64_MAX / unit < tmp_int) {
  ------------------
  |  Branch (540:9): [True: 1, False: 12.0k]
  ------------------
  541|      1|        mp_err(log, "The %.*s option overflows: %.*s\n",
  ------------------
  |  |   76|      4|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 1, False: 0]
  |  |  |  Branch (76:55): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  542|      1|               BSTR_P(name), BSTR_P(param));
  543|      1|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      1|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  544|      1|    }
  545|       |
  546|  12.0k|    tmp_int *= unit;
  547|       |
  548|  12.0k|    int64_t min = OPT_INT_MIN(opt, int64_t, INT64_MIN);
  ------------------
  |  |   58|  12.0k|#define OPT_INT_MIN(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (58:34): [True: 12.0k, False: 0]
  |  |  ------------------
  |  |   59|  12.0k|    ? ((opt)->min <= (double)(Tm) ? (Tm) : (T)((opt)->min)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (59:8): [True: 0, False: 12.0k]
  |  |  ------------------
  ------------------
  549|  12.0k|    if (tmp_int < min) {
  ------------------
  |  Branch (549:9): [True: 0, False: 12.0k]
  ------------------
  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|  12.0k|    int64_t max = OPT_INT_MAX(opt, int64_t, INT64_MAX);
  ------------------
  |  |   60|  12.0k|#define OPT_INT_MAX(opt, T, Tm) ((opt)->min < (opt)->max \
  |  |  ------------------
  |  |  |  Branch (60:34): [True: 12.0k, False: 0]
  |  |  ------------------
  |  |   61|  12.0k|    ? ((opt)->max >= (double)(Tm) ? (Tm) : (T)((opt)->max)) : (Tm))
  |  |  ------------------
  |  |  |  Branch (61:8): [True: 0, False: 12.0k]
  |  |  ------------------
  ------------------
  556|  12.0k|    if (tmp_int > max) {
  ------------------
  |  Branch (556:9): [True: 24, False: 12.0k]
  ------------------
  557|     24|        mp_err(log, "The %.*s option must be <= %"PRId64": %.*s\n",
  ------------------
  |  |   76|     96|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 24, False: 0]
  |  |  |  Branch (76:55): [True: 24, False: 0]
  |  |  ------------------
  ------------------
  558|     24|               BSTR_P(name), max, BSTR_P(param));
  559|     24|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     24|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  560|     24|    }
  561|       |
  562|  12.0k|    if (dst)
  ------------------
  |  Branch (562:9): [True: 12.0k, False: 0]
  ------------------
  563|  12.0k|        *(int64_t *)dst = tmp_int;
  564|       |
  565|  12.0k|    return 1;
  566|  12.0k|}
m_option.c:pretty_print_byte_size:
  587|  1.25k|{
  588|  1.25k|    return format_file_size(*(int64_t *)val);
  589|  1.25k|}
m_option.c:parse_choice:
  636|   227k|{
  637|   227k|    const struct m_opt_choice_alternatives *alt = opt->priv;
  638|   850k|    for ( ; alt->name; alt++) {
  ------------------
  |  Branch (638:13): [True: 845k, False: 5.31k]
  ------------------
  639|   845k|        if (!bstrcmp0(param, alt->name))
  ------------------
  |  Branch (639:13): [True: 221k, False: 623k]
  ------------------
  640|   221k|            break;
  641|   845k|    }
  642|   227k|    if (!alt->name && param.len == 0) {
  ------------------
  |  Branch (642:9): [True: 5.31k, False: 221k]
  |  Branch (642:23): [True: 422, False: 4.89k]
  ------------------
  643|       |        // allow flag-style options, e.g. "--mute" implies "--mute=yes"
  644|  1.70k|        for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (644:31): [True: 1.28k, False: 422]
  ------------------
  645|  1.28k|            if (!strcmp("yes", alt->name))
  ------------------
  |  Branch (645:17): [True: 0, False: 1.28k]
  ------------------
  646|      0|                break;
  647|  1.28k|        }
  648|    422|    }
  649|   227k|    if (!alt->name) {
  ------------------
  |  Branch (649:9): [True: 5.31k, False: 221k]
  ------------------
  650|  5.31k|        if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (650:13): [True: 0, False: 5.31k]
  ------------------
  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|  5.31k|        if (param.len == 0)
  ------------------
  |  Branch (655:13): [True: 422, False: 4.89k]
  ------------------
  656|    422|            return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|    422|#define M_OPT_MISSING_PARAM     -2
  ------------------
  657|  4.89k|        if (opt->min < opt->max) {
  ------------------
  |  Branch (657:13): [True: 250, False: 4.64k]
  ------------------
  658|    250|            long long val;
  659|    250|            if (parse_longlong(mp_null_log, opt, INT_MIN, INT_MAX, name, param,
  ------------------
  |  Branch (659:17): [True: 35, False: 215]
  ------------------
  660|    250|                               &val) == 1)
  661|     35|            {
  662|     35|                if (dst)
  ------------------
  |  Branch (662:21): [True: 35, False: 0]
  ------------------
  663|     35|                    *(int *)dst = val;
  664|     35|                return 1;
  665|     35|            }
  666|    250|        }
  667|  4.85k|        mp_fatal(log, "Invalid value for option %.*s: %.*s\n",
  ------------------
  |  |   75|  19.4k|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 4.85k, False: 0]
  |  |  |  Branch (75:57): [True: 4.85k, False: 0]
  |  |  ------------------
  ------------------
  668|  4.85k|                 BSTR_P(name), BSTR_P(param));
  669|  4.85k|        mp_info(log, "Valid values are:\n");
  ------------------
  |  |   78|  4.85k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  670|  4.85k|        print_choice_values(log, opt);
  671|  4.85k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  4.85k|#define M_OPT_INVALID           -3
  ------------------
  672|  4.89k|    }
  673|   221k|    if (dst)
  ------------------
  |  Branch (673:9): [True: 221k, False: 0]
  ------------------
  674|   221k|        *(int *)dst = alt->value;
  675|       |
  676|   221k|    return 1;
  677|   227k|}
m_option.c:print_choice_values:
  626|  4.85k|{
  627|  4.85k|    const struct m_opt_choice_alternatives *alt = opt->priv;
  628|  90.0k|    for ( ; alt->name; alt++)
  ------------------
  |  Branch (628:13): [True: 85.1k, False: 4.85k]
  ------------------
  629|  85.1k|        mp_info(log, "    %s\n", alt->name[0] ? alt->name : "(passing nothing)");
  ------------------
  |  |   78|   170k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (78:56): [True: 85.1k, False: 9]
  |  |  ------------------
  ------------------
  630|  4.85k|    if (opt->min < opt->max)
  ------------------
  |  Branch (630:9): [True: 215, False: 4.64k]
  ------------------
  631|    215|        mp_info(log, "    %g-%g (integer range)\n", opt->min, opt->max);
  ------------------
  |  |   78|    215|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  632|  4.85k|}
m_option.c:print_choice:
  814|   150k|{
  815|   150k|    int ival = 0;
  816|   150k|    const struct m_opt_choice_alternatives *alt = get_choice(opt, val, &ival);
  817|   150k|    return alt ? talloc_strdup(NULL, alt->name)
  ------------------
  |  |   50|   149k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (817:12): [True: 149k, False: 951]
  ------------------
  818|   150k|               : talloc_asprintf(NULL, "%d", ival);
  ------------------
  |  |   52|    951|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|    951|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  819|   150k|}
m_option.c:get_choice:
  764|   150k|{
  765|   150k|    int v = *(int *)val;
  766|   150k|    const struct m_opt_choice_alternatives *alt;
  767|   162k|    for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (767:27): [True: 161k, False: 951]
  ------------------
  768|   161k|        if (alt->value == v)
  ------------------
  |  Branch (768:13): [True: 149k, False: 12.0k]
  ------------------
  769|   149k|            return alt;
  770|   161k|    }
  771|    951|    if (opt->min < opt->max) {
  ------------------
  |  Branch (771:9): [True: 951, False: 0]
  ------------------
  772|    951|        if (v >= opt->min && v <= opt->max) {
  ------------------
  |  Branch (772:13): [True: 951, False: 0]
  |  Branch (772:30): [True: 951, False: 0]
  ------------------
  773|    951|            *out_val = v;
  774|    951|            return NULL;
  775|    951|        }
  776|    951|    }
  777|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (777:5): [Folded, False: 0]
  ------------------
  778|      0|}
m_option.c:add_choice:
  705|  6.66k|{
  706|  6.66k|    mp_assert(opt->type == &m_option_type_choice);
  ------------------
  |  |   41|  6.66k|#define mp_assert assert
  ------------------
  |  Branch (706:5): [True: 6.66k, False: 0]
  ------------------
  707|  6.66k|    int dir = add > 0 ? +1 : -1;
  ------------------
  |  Branch (707:15): [True: 6.49k, False: 161]
  ------------------
  708|  6.66k|    bool found = false;
  709|  6.66k|    int ival = *(int *)val;
  710|  6.66k|    int best = 0; // init. value unused
  711|       |
  712|  6.66k|    if (fabs(add) < 0.5)
  ------------------
  |  Branch (712:9): [True: 10, False: 6.65k]
  ------------------
  713|     10|        return;
  714|       |
  715|  6.65k|    if (opt->min < opt->max) {
  ------------------
  |  Branch (715:9): [True: 856, False: 5.79k]
  ------------------
  716|    856|        int newval = ival + add;
  717|    856|        if (ival >= opt->min && ival <= opt->max &&
  ------------------
  |  Branch (717:13): [True: 725, False: 131]
  |  Branch (717:33): [True: 725, False: 0]
  ------------------
  718|    725|            newval >= opt->min && newval <= opt->max)
  ------------------
  |  Branch (718:13): [True: 692, False: 33]
  |  Branch (718:35): [True: 681, False: 11]
  ------------------
  719|    681|        {
  720|    681|            found = true;
  721|    681|            best = newval;
  722|    681|        } else {
  723|    175|            check_choice(dir, ival, &found, &best, opt->min);
  724|    175|            check_choice(dir, ival, &found, &best, opt->max);
  725|    175|        }
  726|    856|    }
  727|       |
  728|  28.3k|    for (const struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++)
  ------------------
  |  Branch (728:67): [True: 21.6k, False: 6.65k]
  ------------------
  729|  21.6k|        check_choice(dir, ival, &found, &best, alt->value);
  730|       |
  731|  6.65k|    if (!found) {
  ------------------
  |  Branch (731:9): [True: 1.70k, False: 4.94k]
  ------------------
  732|  1.70k|        int min, max;
  733|  1.70k|        choice_get_min_max(opt, &min, &max);
  734|  1.70k|        best = (dir == -1) ^ wrap ? min : max;
  ------------------
  |  Branch (734:16): [True: 1.62k, False: 83]
  ------------------
  735|  1.70k|    }
  736|       |
  737|  6.65k|    *(int *)val = best;
  738|  6.65k|}
m_option.c:check_choice:
  695|  22.0k|{
  696|  22.0k|    if ((dir == -1 && (!(*found) || choice > (*best)) && choice < val) ||
  ------------------
  |  Branch (696:10): [True: 557, False: 21.4k]
  |  Branch (696:24): [True: 415, False: 142]
  |  Branch (696:37): [True: 46, False: 96]
  |  Branch (696:58): [True: 74, False: 387]
  ------------------
  697|  21.9k|        (dir == +1 && (!(*found) || choice < (*best)) && choice > val))
  ------------------
  |  Branch (697:10): [True: 21.4k, False: 483]
  |  Branch (697:24): [True: 13.7k, False: 7.69k]
  |  Branch (697:37): [True: 4.56k, False: 3.13k]
  |  Branch (697:58): [True: 4.24k, False: 14.0k]
  ------------------
  698|  4.31k|    {
  699|       |        *found = true;
  700|  4.31k|        *best = choice;
  701|  4.31k|    }
  702|  22.0k|}
m_option.c:choice_get_min_max:
  680|  1.70k|{
  681|  1.70k|    mp_assert(opt->type == &m_option_type_choice);
  ------------------
  |  |   41|  1.70k|#define mp_assert assert
  ------------------
  |  Branch (681:5): [True: 1.70k, False: 0]
  ------------------
  682|  1.70k|    *min = INT_MAX;
  683|  1.70k|    *max = INT_MIN;
  684|  7.19k|    for (const struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (684:67): [True: 5.48k, False: 1.70k]
  ------------------
  685|  5.48k|        *min = MPMIN(*min, alt->value);
  ------------------
  |  |   45|  5.48k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 3.36k, False: 2.11k]
  |  |  ------------------
  ------------------
  686|  5.48k|        *max = MPMAX(*max, alt->value);
  ------------------
  |  |   44|  5.48k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 2.01k, False: 3.46k]
  |  |  ------------------
  ------------------
  687|  5.48k|    }
  688|  1.70k|    if (opt->min < opt->max) {
  ------------------
  |  Branch (688:9): [True: 31, False: 1.67k]
  ------------------
  689|     31|        *min = MPMIN(*min, opt->min);
  ------------------
  |  |   45|     31|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  690|     31|        *max = MPMAX(*max, opt->max);
  ------------------
  |  |   44|     31|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  691|     31|    }
  692|  1.70k|}
m_option.c:parse_flags:
  868|  11.8k|{
  869|  11.8k|    int value = 0;
  870|  11.8k|    while (param.len) {
  ------------------
  |  Branch (870:12): [True: 11.3k, False: 505]
  ------------------
  871|  11.3k|        bstr flag;
  872|  11.3k|        bstr_split_tok(param, "+", &flag, &param);
  873|  11.3k|        int r = apply_flag(opt, &value, flag);
  874|  11.3k|        if (r == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|  11.3k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (874:13): [True: 11.3k, False: 35]
  ------------------
  875|  11.3k|            mp_fatal(log, "Invalid flag for option %.*s: %.*s\n",
  ------------------
  |  |   75|  45.2k|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 11.3k, False: 0]
  |  |  |  Branch (75:57): [True: 11.3k, False: 0]
  |  |  ------------------
  ------------------
  876|  11.3k|                     BSTR_P(name), BSTR_P(flag));
  877|  11.3k|            mp_info(log, "Valid flags are:\n");
  ------------------
  |  |   78|  11.3k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  878|  11.3k|            const struct m_opt_choice_alternatives *alt;
  879|  97.7k|            for (alt = opt->priv; alt->name; alt++)
  ------------------
  |  Branch (879:35): [True: 86.4k, False: 11.3k]
  ------------------
  880|  86.4k|                mp_info(log, "    %s\n", alt->name);
  ------------------
  |  |   78|  86.4k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  881|  11.3k|            mp_info(log, "Flags can usually be combined with '+'.\n");
  ------------------
  |  |   78|  11.3k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  882|  11.3k|            return M_OPT_INVALID;
  ------------------
  |  |  535|  11.3k|#define M_OPT_INVALID           -3
  ------------------
  883|  11.3k|        } else if (r < 0) {
  ------------------
  |  Branch (883:20): [True: 0, False: 35]
  ------------------
  884|      0|            mp_fatal(log, "Option %.*s: flag '%.*s' conflicts with a previous "
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  885|      0|                     "flag value.\n", BSTR_P(name), BSTR_P(flag));
  886|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  887|      0|        }
  888|  11.3k|    }
  889|    505|    if (dst)
  ------------------
  |  Branch (889:9): [True: 505, False: 0]
  ------------------
  890|    505|        *(int *)dst = value;
  891|    505|    return 1;
  892|  11.8k|}
m_option.c:apply_flag:
  835|  11.3k|{
  836|  11.3k|    const struct m_opt_choice_alternatives *alt;
  837|  97.7k|    for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (837:27): [True: 86.4k, False: 11.3k]
  ------------------
  838|  86.4k|        if (bstr_equals0(flag, alt->name)) {
  ------------------
  |  Branch (838:13): [True: 35, False: 86.4k]
  ------------------
  839|     35|            if (*val & alt->value)
  ------------------
  |  Branch (839:17): [True: 0, False: 35]
  ------------------
  840|      0|                return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  841|     35|            *val |= alt->value;
  842|     35|            return 0;
  843|     35|        }
  844|  86.4k|    }
  845|  11.3k|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|  11.3k|#define M_OPT_UNKNOWN           -1
  ------------------
  846|  11.3k|}
m_option.c:print_flags:
  933|   194k|{
  934|   194k|    int value = *(int *)val;
  935|   194k|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|   194k|#define talloc_strdup                   ta_xstrdup
  ------------------
  936|   294k|    while (1) {
  ------------------
  |  Branch (936:12): [True: 294k, Folded]
  ------------------
  937|   294k|        const char *flag = find_next_flag(opt, &value);
  938|   294k|        if (!flag)
  ------------------
  |  Branch (938:13): [True: 194k, False: 99.5k]
  ------------------
  939|   194k|            break;
  940|       |
  941|  99.5k|        res = talloc_asprintf_append_buffer(res, "%s%s", res[0] ? "+" : "", flag);
  ------------------
  |  |   64|  99.5k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  |  Branch (941:58): [True: 0, False: 99.5k]
  ------------------
  942|  99.5k|    }
  943|   194k|    return res;
  944|   194k|}
m_option.c:find_next_flag:
  849|   294k|{
  850|   294k|    const struct m_opt_choice_alternatives *best = NULL;
  851|   294k|    const struct m_opt_choice_alternatives *alt;
  852|  2.39M|    for (alt = opt->priv; alt->name; alt++) {
  ------------------
  |  Branch (852:27): [True: 2.09M, False: 294k]
  ------------------
  853|  2.09M|        if (alt->value && (alt->value & (*val)) == alt->value) {
  ------------------
  |  Branch (853:13): [True: 1.82M, False: 270k]
  |  Branch (853:27): [True: 139k, False: 1.68M]
  ------------------
  854|   139k|            if (!best || av_popcount64(alt->value) > av_popcount64(best->value))
  ------------------
  |  Branch (854:17): [True: 99.5k, False: 40.4k]
  |  Branch (854:26): [True: 0, False: 40.4k]
  ------------------
  855|  99.5k|                best = alt;
  856|   139k|        }
  857|  2.09M|    }
  858|   294k|    if (best) {
  ------------------
  |  Branch (858:9): [True: 99.5k, False: 194k]
  ------------------
  859|  99.5k|        *val = *val & ~(unsigned)best->value;
  860|  99.5k|        return best->name;
  861|  99.5k|    }
  862|   194k|    *val = 0; // if there are still flags left, there's not much we can do
  863|       |    return NULL;
  864|   294k|}
m_option.c:parse_double:
 1021|  37.8k|{
 1022|  37.8k|    double tmp;
 1023|  37.8k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_double);
 1024|  37.8k|    if (r == 1 && dst)
  ------------------
  |  Branch (1024:9): [True: 26.8k, False: 10.9k]
  |  Branch (1024:19): [True: 26.8k, False: 0]
  ------------------
 1025|  26.8k|        VAL(dst) = tmp;
  ------------------
  |  |  960|  26.8k|#define VAL(x) (*(double *)(x))
  ------------------
 1026|  37.8k|    return r;
 1027|  37.8k|}
m_option.c:parse_numeric:
  988|   131k|{
  989|   131k|    if (param.len == 0)
  ------------------
  |  Branch (989:9): [True: 39, False: 131k]
  ------------------
  990|     39|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|     39|#define M_OPT_MISSING_PARAM     -2
  ------------------
  991|       |
  992|   131k|    struct bstr rest;
  993|   131k|    *out = bstrtod(param, &rest);
  994|       |
  995|   131k|    if (bstr_eatstart0(&rest, ":") || bstr_eatstart0(&rest, "/"))
  ------------------
  |  Branch (995:9): [True: 38, False: 131k]
  |  Branch (995:39): [True: 172, False: 131k]
  ------------------
  996|    210|        *out /= bstrtod(rest, &rest);
  997|       |
  998|   131k|    if ((opt->flags & M_OPT_DEFAULT_NAN) && bstr_equals0(param, "default")) {
  ------------------
  |  |  483|   131k|#define M_OPT_DEFAULT_NAN       (UINT64_C(1) << 58)
  ------------------
  |  Branch (998:9): [True: 115, False: 131k]
  |  Branch (998:45): [True: 0, False: 115]
  ------------------
  999|      0|        *out = NAN;
 1000|      0|        return 1;
 1001|      0|    }
 1002|       |
 1003|   131k|    if (rest.len) {
  ------------------
  |  Branch (1003:9): [True: 11.0k, False: 120k]
  ------------------
 1004|  11.0k|        mp_err(log, "The %.*s option must be a floating point number or a "
  ------------------
  |  |   76|  44.3k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 11.0k, False: 0]
  |  |  |  Branch (76:55): [True: 11.0k, False: 0]
  |  |  ------------------
  ------------------
 1005|  11.0k|               "ratio (numerator[:/]denominator): %.*s\n",
 1006|  11.0k|               BSTR_P(name), BSTR_P(param));
 1007|  11.0k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  11.0k|#define M_OPT_INVALID           -3
  ------------------
 1008|  11.0k|    }
 1009|       |
 1010|   120k|    if (clamp(opt, out) < 0) {
  ------------------
  |  Branch (1010:9): [True: 229, False: 120k]
  ------------------
 1011|    229|        mp_err(log, "The %.*s option is out of range: %.*s\n",
  ------------------
  |  |   76|    916|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 229, False: 0]
  |  |  |  Branch (76:55): [True: 229, False: 0]
  |  |  ------------------
  ------------------
 1012|    229|               BSTR_P(name), BSTR_P(param));
 1013|    229|        return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|    229|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
 1014|    229|    }
 1015|       |
 1016|   120k|    return 1;
 1017|   120k|}
m_option.c:clamp_double:
  963|   133k|{
  964|   133k|    double v = *val;
  965|   133k|    int r = 0;
  966|   133k|    if (opt->min < opt->max) {
  ------------------
  |  Branch (966:9): [True: 82.4k, False: 51.2k]
  ------------------
  967|  82.4k|        if (v > opt->max) {
  ------------------
  |  Branch (967:13): [True: 18, False: 82.4k]
  ------------------
  968|     18|            v = opt->max;
  969|     18|            r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     18|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  970|     18|        }
  971|  82.4k|        if (v < opt->min) {
  ------------------
  |  Branch (971:13): [True: 19, False: 82.4k]
  ------------------
  972|     19|            v = opt->min;
  973|     19|            r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     19|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  974|     19|        }
  975|  82.4k|    }
  976|       |    // (setting max/min to INFINITY/-INFINITY is allowed)
  977|   133k|    if (!isfinite(v) && v != opt->max && v != opt->min) {
  ------------------
  |  Branch (977:9): [True: 193, False: 133k]
  |  Branch (977:25): [True: 193, False: 0]
  |  Branch (977:42): [True: 193, False: 0]
  ------------------
  978|    193|        v = opt->min;
  979|    193|        r = M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|    193|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  980|    193|    }
  981|   133k|    *val = v;
  982|   133k|    return r;
  983|   133k|}
m_option.c:print_double:
 1030|  31.0k|{
 1031|  31.0k|    double f = VAL(val);
  ------------------
  |  |  960|  31.0k|#define VAL(x) (*(double *)(x))
  ------------------
 1032|  31.0k|    if (isnan(f) && (opt->flags & M_OPT_DEFAULT_NAN))
  ------------------
  |  |  483|      0|#define M_OPT_DEFAULT_NAN       (UINT64_C(1) << 58)
  ------------------
  |  Branch (1032:9): [True: 0, False: 31.0k]
  |  Branch (1032:21): [True: 0, False: 0]
  ------------------
 1033|      0|        return talloc_strdup(NULL, "default");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1034|  31.0k|    return talloc_asprintf(NULL, "%f", f);
  ------------------
  |  |   52|  31.0k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  31.0k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1035|  31.0k|}
m_option.c:pretty_print_double:
 1038|  11.1k|{
 1039|  11.1k|    double f = VAL(val);
  ------------------
  |  |  960|  11.1k|#define VAL(x) (*(double *)(x))
  ------------------
 1040|  11.1k|    if (isnan(f))
  ------------------
  |  Branch (1040:9): [True: 0, False: 11.1k]
  ------------------
 1041|      0|        return print_double(opt, val);
 1042|  11.1k|    return mp_format_double(NULL, f, 4, false, false, !(opt->flags & M_OPT_FIXED_LEN_PRINT));
  ------------------
  |  |  494|  11.1k|#define M_OPT_FIXED_LEN_PRINT   (UINT64_C(1) << 55)
  ------------------
 1043|  11.1k|}
m_option.c:add_double:
 1046|  19.1k|{
 1047|  19.1k|    double v = VAL(val);
  ------------------
  |  |  960|  19.1k|#define VAL(x) (*(double *)(x))
  ------------------
 1048|       |
 1049|  19.1k|    v = v + add;
 1050|       |
 1051|  19.1k|    double min = opt->min < opt->max ? opt->min : -INFINITY;
  ------------------
  |  Branch (1051:18): [True: 18.1k, False: 1.01k]
  ------------------
 1052|  19.1k|    double max = opt->min < opt->max ? opt->max : +INFINITY;
  ------------------
  |  Branch (1052:18): [True: 18.1k, False: 1.01k]
  ------------------
 1053|       |
 1054|  19.1k|    if (v < min)
  ------------------
  |  Branch (1054:9): [True: 65, False: 19.0k]
  ------------------
 1055|     65|        v = wrap ? max : min;
  ------------------
  |  Branch (1055:13): [True: 1, False: 64]
  ------------------
 1056|  19.1k|    if (v > max)
  ------------------
  |  Branch (1056:9): [True: 399, False: 18.7k]
  ------------------
 1057|    399|        v = wrap ? min : max;
  ------------------
  |  Branch (1057:13): [True: 51, False: 348]
  ------------------
 1058|       |
 1059|  19.1k|    VAL(val) = v;
  ------------------
  |  |  960|  19.1k|#define VAL(x) (*(double *)(x))
  ------------------
 1060|  19.1k|}
m_option.c:double_get:
 1087|     13|{
 1088|     13|    double f = VAL(src);
  ------------------
  |  |  960|     13|#define VAL(x) (*(double *)(x))
  ------------------
 1089|     13|    if (isnan(f) && (opt->flags & M_OPT_DEFAULT_NAN)) {
  ------------------
  |  |  483|      0|#define M_OPT_DEFAULT_NAN       (UINT64_C(1) << 58)
  ------------------
  |  Branch (1089:9): [True: 0, False: 13]
  |  Branch (1089:21): [True: 0, False: 0]
  ------------------
 1090|      0|        dst->format = MPV_FORMAT_STRING;
 1091|      0|        dst->u.string = talloc_strdup(ta_parent, "default");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1092|     13|    } else {
 1093|     13|        dst->format = MPV_FORMAT_DOUBLE;
 1094|     13|        dst->u.double_ = f;
 1095|     13|    }
 1096|     13|    return 1;
 1097|     13|}
m_option.c:double_equal:
 1100|  2.43M|{
 1101|  2.43M|    double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  2.43M|#define VAL(x) (*(double *)(x))
  ------------------
                  double fa = VAL(a), fb = VAL(b);
  ------------------
  |  |  960|  2.43M|#define VAL(x) (*(double *)(x))
  ------------------
 1102|  2.43M|    if (isnan(fa) || isnan(fb))
  ------------------
  |  Branch (1102:9): [True: 871, False: 2.43M]
  |  Branch (1102:22): [True: 0, False: 2.43M]
  ------------------
 1103|    871|        return isnan(fa) == isnan(fb);
 1104|  2.43M|    return fa == fb;
 1105|  2.43M|}
m_option.c:parse_double_aspect:
 1125|     82|{
 1126|     82|    if (bstr_equals0(param, "no")) {
  ------------------
  |  Branch (1126:9): [True: 0, False: 82]
  ------------------
 1127|      0|        if (dst)
  ------------------
  |  Branch (1127:13): [True: 0, False: 0]
  ------------------
 1128|      0|            VAL(dst) = -2.0;
  ------------------
  |  |  960|      0|#define VAL(x) (*(double *)(x))
  ------------------
 1129|      0|        return 1;
 1130|      0|    }
 1131|     82|    return parse_double(log, opt, name, param, dst);
 1132|     82|}
m_option.c:parse_float:
 1172|  93.7k|{
 1173|  93.7k|    double tmp;
 1174|  93.7k|    int r = parse_numeric(log, opt, name, param, &tmp, clamp_float);
 1175|  93.7k|    if (r == 1 && dst)
  ------------------
  |  Branch (1175:9): [True: 93.3k, False: 386]
  |  Branch (1175:19): [True: 93.3k, False: 0]
  ------------------
 1176|  93.3k|        VAL(dst) = tmp;
  ------------------
  |  | 1150|  93.3k|#define VAL(x) (*(float *)(x))
  ------------------
 1177|  93.7k|    return r;
 1178|  93.7k|}
m_option.c:clamp_float:
 1153|   106k|{
 1154|   106k|    double v = *val;
 1155|   106k|    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|   106k|    if (isfinite(v) && v > FLT_MAX) {
  ------------------
  |  Branch (1158:9): [True: 106k, False: 0]
  |  Branch (1158:24): [True: 0, False: 106k]
  ------------------
 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|   106k|    if (isfinite(v) && v < -FLT_MAX) {
  ------------------
  |  Branch (1162:9): [True: 106k, False: 0]
  |  Branch (1162:24): [True: 0, False: 106k]
  ------------------
 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|   106k|    *val = v;
 1167|   106k|    return r;
 1168|   106k|}
m_option.c:print_float:
 1181|  2.56k|{
 1182|  2.56k|    double tmp = VAL(val);
  ------------------
  |  | 1150|  2.56k|#define VAL(x) (*(float *)(x))
  ------------------
 1183|  2.56k|    return print_double(opt, &tmp);
 1184|  2.56k|}
m_option.c:pretty_print_float:
 1187|  11.0k|{
 1188|  11.0k|    double tmp = VAL(val);
  ------------------
  |  | 1150|  11.0k|#define VAL(x) (*(float *)(x))
  ------------------
 1189|  11.0k|    return pretty_print_double(opt, &tmp);
 1190|  11.0k|}
m_option.c:add_float:
 1193|  13.2k|{
 1194|  13.2k|    double tmp = VAL(val);
  ------------------
  |  | 1150|  13.2k|#define VAL(x) (*(float *)(x))
  ------------------
 1195|  13.2k|    add_double(opt, &tmp, add, wrap);
 1196|  13.2k|    clamp_float(opt, &tmp);
 1197|  13.2k|    VAL(val) = tmp;
  ------------------
  |  | 1150|  13.2k|#define VAL(x) (*(float *)(x))
  ------------------
 1198|  13.2k|}
m_option.c:float_get:
 1221|      3|{
 1222|      3|    double tmp = VAL(src);
  ------------------
  |  | 1150|      3|#define VAL(x) (*(float *)(x))
  ------------------
 1223|      3|    return double_get(opt, ta_parent, dst, &tmp);
 1224|      3|}
m_option.c:float_equal:
 1227|  1.40M|{
 1228|  1.40M|    return double_equal(opt, &(double){VAL(a)}, &(double){VAL(b)});
  ------------------
  |  | 1150|  1.40M|#define VAL(x) (*(float *)(x))
  ------------------
                  return double_equal(opt, &(double){VAL(a)}, &(double){VAL(b)});
  ------------------
  |  | 1150|  1.40M|#define VAL(x) (*(float *)(x))
  ------------------
 1229|  1.40M|}
m_option.c:parse_str:
 1254|   455k|{
 1255|   455k|    if (dst) {
  ------------------
  |  Branch (1255:9): [True: 455k, False: 0]
  ------------------
 1256|   455k|        talloc_free(VAL(dst));
  ------------------
  |  |   47|   455k|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(dst));
  ------------------
  |  | 1250|   455k|#define VAL(x) (*(char **)(x))
  ------------------
 1257|   455k|        VAL(dst) = bstrdup0(NULL, param);
  ------------------
  |  | 1250|   455k|#define VAL(x) (*(char **)(x))
  ------------------
 1258|   455k|    }
 1259|       |
 1260|   455k|    return 0;
 1261|   455k|}
m_option.c:print_str:
 1264|  8.72M|{
 1265|  8.72M|    return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  |   50|  8.72M|#define talloc_strdup                   ta_xstrdup
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|  8.72M|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 8.66M, False: 65.4k]
  |  |  ------------------
  ------------------
                  return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
  ------------------
  |  | 1250|  8.66M|#define VAL(x) (*(char **)(x))
  ------------------
 1266|  8.72M|}
m_option.c:copy_str:
 1269|  12.4M|{
 1270|  12.4M|    if (dst && src)
  ------------------
  |  Branch (1270:9): [True: 12.4M, False: 0]
  |  Branch (1270:16): [True: 12.4M, False: 0]
  ------------------
 1271|  12.4M|        talloc_replace(NULL, VAL(dst), VAL(src));
  ------------------
  |  |   54|  12.4M|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  12.4M|    do {                                                \
  |  |  |  |  107|  12.4M|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 12.4M, False: 276]
  |  |  |  |  ------------------
  |  |  |  |  108|  12.4M|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  12.4M|        } else {                                        \
  |  |  |  |  110|    276|            *(str) = '\0';                              \
  |  |  |  |  111|    276|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|    276|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|    276|        }                                               \
  |  |  |  |  113|  12.4M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 12.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1272|  12.4M|}
m_option.c:free_str:
 1299|  21.2M|{
 1300|  21.2M|    if (src && VAL(src)) {
  ------------------
  |  | 1250|  21.2M|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 11.9M, False: 9.26M]
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 21.2M, False: 18.4E]
  ------------------
 1301|  11.9M|        talloc_free(VAL(src));
  ------------------
  |  |   47|  11.9M|#define talloc_free                     ta_free
  ------------------
                      talloc_free(VAL(src));
  ------------------
  |  | 1250|  11.9M|#define VAL(x) (*(char **)(x))
  ------------------
 1302|  11.9M|        VAL(src) = NULL;
  ------------------
  |  | 1250|  11.9M|#define VAL(x) (*(char **)(x))
  ------------------
 1303|  11.9M|    }
 1304|  21.2M|}
m_option.c:str_get:
 1287|     70|{
 1288|     70|    dst->format = MPV_FORMAT_STRING;
 1289|     70|    dst->u.string = talloc_strdup(ta_parent, VAL(src) ? VAL(src) : "");
  ------------------
  |  |   50|     70|#define talloc_strdup                   ta_xstrdup
  ------------------
                  dst->u.string = talloc_strdup(ta_parent, VAL(src) ? VAL(src) : "");
  ------------------
  |  | 1250|     70|#define VAL(x) (*(char **)(x))
  |  |  ------------------
  |  |  |  Branch (1250:16): [True: 70, False: 0]
  |  |  ------------------
  ------------------
                  dst->u.string = talloc_strdup(ta_parent, VAL(src) ? VAL(src) : "");
  ------------------
  |  | 1250|     70|#define VAL(x) (*(char **)(x))
  ------------------
 1290|     70|    return 1;
 1291|     70|}
m_option.c:str_equal:
 1294|  2.25M|{
 1295|  2.25M|    return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  2.25M|#define VAL(x) (*(char **)(x))
  ------------------
                  return bstr_equals(bstr0(VAL(a)), bstr0(VAL(b)));
  ------------------
  |  | 1250|  2.25M|#define VAL(x) (*(char **)(x))
  ------------------
 1296|  2.25M|}
m_option.c:parse_str_list:
 1622|  37.4k|{
 1623|  37.4k|    return parse_str_list_impl(log, opt, name, param, dst, OP_NONE);
  ------------------
  |  | 1323|  37.4k|#define OP_NONE 0
  ------------------
 1624|  37.4k|}
m_option.c:parse_str_list_impl:
 1467|  37.4k|{
 1468|  37.4k|    char **res;
 1469|  37.4k|    int op = default_op;
 1470|       |
 1471|  37.4k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1471:9): [True: 0, False: 37.4k]
  ------------------
 1472|      0|        op = OP_ADD;
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
 1473|  37.4k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1473:16): [True: 0, False: 37.4k]
  ------------------
 1474|      0|        op = OP_APPEND;
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
 1475|  37.4k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (1475:16): [True: 0, False: 37.4k]
  ------------------
 1476|      0|        op = OP_PRE;
  ------------------
  |  | 1325|      0|#define OP_PRE 2
  ------------------
 1477|  37.4k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1477:16): [True: 0, False: 37.4k]
  ------------------
 1478|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 1479|  37.4k|    } else if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1479:16): [True: 0, False: 37.4k]
  ------------------
 1480|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1481|  37.4k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (1481:16): [True: 0, False: 37.4k]
  ------------------
 1482|      0|        op = OP_NONE;
  ------------------
  |  | 1323|      0|#define OP_NONE 0
  ------------------
 1483|  37.4k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (1483:16): [True: 0, False: 37.4k]
  ------------------
 1484|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 1485|  37.4k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1485:16): [True: 0, False: 37.4k]
  ------------------
 1486|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1487|      0|    }
 1488|       |
 1489|  37.4k|    if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1328|  74.9k|#define OP_TOGGLE 5
  ------------------
                  if (op == OP_TOGGLE || op == OP_REMOVE) {
  ------------------
  |  | 1330|  37.4k|#define OP_REMOVE 7
  ------------------
  |  Branch (1489:9): [True: 0, False: 37.4k]
  |  Branch (1489:28): [True: 0, False: 37.4k]
  ------------------
 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|  37.4k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|  37.4k|#define OP_CLR 3
  ------------------
  |  Branch (1504:9): [True: 0, False: 37.4k]
  ------------------
 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|  37.4k|    if (param.len == 0 && op != OP_NONE)
  ------------------
  |  | 1323|    508|#define OP_NONE 0
  ------------------
  |  Branch (1511:9): [True: 508, False: 36.9k]
  |  Branch (1511:27): [True: 0, False: 508]
  ------------------
 1512|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 1513|       |
 1514|  37.4k|    if (!dst)
  ------------------
  |  Branch (1514:9): [True: 0, False: 37.4k]
  ------------------
 1515|      0|        return 1;
 1516|       |
 1517|  37.4k|    int n = 0;
 1518|  37.4k|    res = separate_input_param(opt, param, &n, op);
 1519|  37.4k|    if (!res)
  ------------------
  |  Branch (1519:9): [True: 0, False: 37.4k]
  ------------------
 1520|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1521|       |
 1522|  37.4k|    switch (op) {
  ------------------
  |  Branch (1522:13): [True: 0, False: 37.4k]
  ------------------
 1523|      0|    case OP_ADD:
  ------------------
  |  | 1324|      0|#define OP_ADD 1
  ------------------
  |  Branch (1523:5): [True: 0, False: 37.4k]
  ------------------
 1524|      0|    case OP_APPEND:
  ------------------
  |  | 1329|      0|#define OP_APPEND 6
  ------------------
  |  Branch (1524:5): [True: 0, False: 37.4k]
  ------------------
 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: 37.4k]
  ------------------
 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: 37.4k]
  ------------------
 1529|      0|        return str_list_remove(res, n, dst);
 1530|  37.4k|    }
 1531|       |
 1532|  37.4k|    if (VAL(dst))
  ------------------
  |  | 1321|  37.4k|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 0, False: 37.4k]
  |  |  ------------------
  ------------------
 1533|      0|        free_str_list(dst);
 1534|  37.4k|    VAL(dst) = res;
  ------------------
  |  | 1321|  37.4k|#define VAL(x) (*(char ***)(x))
  ------------------
 1535|       |
 1536|  37.4k|    if (!res[0])
  ------------------
  |  Branch (1536:9): [True: 0, False: 37.4k]
  ------------------
 1537|      0|        free_str_list(dst);
 1538|       |
 1539|  37.4k|    return 1;
 1540|  37.4k|}
m_option.c:separate_input_param:
 1405|  37.4k|{
 1406|  37.4k|    char separator = opt->priv ? *(char *)opt->priv : OPTION_LIST_SEPARATOR;
  ------------------
  |  |  644|  74.9k|#define OPTION_LIST_SEPARATOR ','
  ------------------
  |  Branch (1406:22): [True: 46, False: 37.4k]
  ------------------
 1407|  37.4k|    if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1329|  74.9k|#define OP_APPEND 6
  ------------------
                  if (op == OP_APPEND || op == OP_REMOVE)
  ------------------
  |  | 1330|  37.4k|#define OP_REMOVE 7
  ------------------
  |  Branch (1407:9): [True: 0, False: 37.4k]
  |  Branch (1407:28): [True: 0, False: 37.4k]
  ------------------
 1408|      0|        separator = 0; // specially handled
 1409|  37.4k|    struct bstr str = param;
 1410|  37.4k|    int n = *len;
 1411|   104k|    while (str.len) {
  ------------------
  |  Branch (1411:12): [True: 67.0k, False: 37.4k]
  ------------------
 1412|  67.0k|        get_nextsep(&str, separator, 0);
 1413|  67.0k|        str = bstr_cut(str, 1);
 1414|  67.0k|        n++;
 1415|  67.0k|    }
 1416|  37.4k|    if (n == 0 && op != OP_NONE)
  ------------------
  |  | 1323|    508|#define OP_NONE 0
  ------------------
  |  Branch (1416:9): [True: 508, False: 36.9k]
  |  Branch (1416:19): [True: 0, False: 508]
  ------------------
 1417|      0|        return NULL;
 1418|       |
 1419|  37.4k|    char **list = talloc_array(NULL, char *, n + 2);
  ------------------
  |  |   29|  37.4k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  37.4k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  37.4k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|  37.4k|    str = bstrdup(NULL, param);
 1421|  37.4k|    char *ptr = str.start;
 1422|  37.4k|    n = 0;
 1423|       |
 1424|  64.2k|    while (1) {
  ------------------
  |  Branch (1424:12): [True: 64.2k, Folded]
  ------------------
 1425|  64.2k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1426|  64.2k|        if (n >= 100)
  ------------------
  |  Branch (1426:13): [True: 166, False: 64.1k]
  ------------------
 1427|    166|            break;
 1428|  64.1k|#endif
 1429|  64.1k|        struct bstr el = get_nextsep(&str, separator, 1);
 1430|  64.1k|        list[n] = bstrdup0(NULL, el);
 1431|  64.1k|        n++;
 1432|  64.1k|        if (!str.len)
  ------------------
  |  Branch (1432:13): [True: 37.3k, False: 26.8k]
  ------------------
 1433|  37.3k|            break;
 1434|  26.8k|        str = bstr_cut(str, 1);
 1435|  26.8k|    }
 1436|  37.4k|    list[n] = NULL;
 1437|  37.4k|    *len = n;
 1438|  37.4k|    talloc_free(ptr);
  ------------------
  |  |   47|  37.4k|#define talloc_free                     ta_free
  ------------------
 1439|  37.4k|    return list;
 1440|  37.4k|}
m_option.c:get_nextsep:
 1382|   131k|{
 1383|   131k|    struct bstr str = *ptr;
 1384|   131k|    struct bstr orig = str;
 1385|   131k|    for (;;) {
 1386|   131k|        int idx = sep ? bstrchr(str, sep) : -1;
  ------------------
  |  Branch (1386:19): [True: 131k, False: 0]
  ------------------
 1387|   131k|        if (idx > 0 && str.start[idx - 1] == '\\') {
  ------------------
  |  Branch (1387:13): [True: 9.68k, False: 121k]
  |  Branch (1387:24): [True: 38, False: 9.65k]
  ------------------
 1388|     38|            if (modify) {
  ------------------
  |  Branch (1388:17): [True: 19, False: 19]
  ------------------
 1389|     19|                memmove(str.start + idx - 1, str.start + idx, str.len - idx);
 1390|     19|                str.len--;
 1391|     19|                str = bstr_cut(str, idx);
 1392|     19|            } else
 1393|     19|                str = bstr_cut(str, idx + 1);
 1394|   131k|        } else {
 1395|   131k|            str = bstr_cut(str, idx < 0 ? str.len : idx);
  ------------------
  |  Branch (1395:33): [True: 74.2k, False: 56.9k]
  ------------------
 1396|   131k|            break;
 1397|   131k|        }
 1398|   131k|    }
 1399|   131k|    *ptr = str;
 1400|   131k|    return bstr_splice(orig, 0, str.start - orig.start);
 1401|   131k|}
m_option.c:print_str_list:
 1569|  1.80k|{
 1570|  1.80k|    char **lst = NULL;
 1571|  1.80k|    char *ret = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  1.80k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1572|  1.80k|    const char sep = opt->priv ? *(char *)opt->priv : OPTION_LIST_SEPARATOR;
  ------------------
  |  |  644|  3.60k|#define OPTION_LIST_SEPARATOR ','
  ------------------
  |  Branch (1572:22): [True: 11, False: 1.79k]
  ------------------
 1573|       |
 1574|  1.80k|    if (!(src && VAL(src)))
  ------------------
  |  | 1321|  1.80k|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 947, False: 860]
  |  |  ------------------
  ------------------
  |  Branch (1574:11): [True: 1.80k, False: 0]
  ------------------
 1575|    860|        return ret;
 1576|    947|    lst = VAL(src);
  ------------------
  |  | 1321|    947|#define VAL(x) (*(char ***)(x))
  ------------------
 1577|       |
 1578|  28.4k|    for (int i = 0; lst[i]; i++) {
  ------------------
  |  Branch (1578:21): [True: 27.4k, False: 947]
  ------------------
 1579|  27.4k|        if (i > 0)
  ------------------
  |  Branch (1579:13): [True: 26.5k, False: 947]
  ------------------
 1580|  26.5k|            ret = talloc_strndup_append_buffer(ret, &sep, 1);
  ------------------
  |  |   60|  26.5k|#define talloc_strndup_append_buffer    ta_talloc_strndup_append_buffer
  ------------------
 1581|  27.4k|        ret = talloc_strdup_append_buffer(ret, lst[i]);
  ------------------
  |  |   58|  27.4k|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
 1582|  27.4k|    }
 1583|    947|    return ret;
 1584|  1.80k|}
m_option.c:copy_str_list:
 1543|  7.52M|{
 1544|  7.52M|    int n;
 1545|  7.52M|    char **d, **s;
 1546|       |
 1547|  7.52M|    if (!(dst && src))
  ------------------
  |  Branch (1547:11): [True: 7.52M, False: 0]
  |  Branch (1547:18): [True: 7.52M, False: 0]
  ------------------
 1548|      0|        return;
 1549|  7.52M|    s = VAL(src);
  ------------------
  |  | 1321|  7.52M|#define VAL(x) (*(char ***)(x))
  ------------------
 1550|       |
 1551|  7.52M|    if (VAL(dst))
  ------------------
  |  | 1321|  7.52M|#define VAL(x) (*(char ***)(x))
  |  |  ------------------
  |  |  |  Branch (1321:16): [True: 155, False: 7.52M]
  |  |  ------------------
  ------------------
 1552|    155|        free_str_list(dst);
 1553|       |
 1554|  7.52M|    if (!s) {
  ------------------
  |  Branch (1554:9): [True: 4.80M, False: 2.71M]
  ------------------
 1555|  4.80M|        VAL(dst) = NULL;
  ------------------
  |  | 1321|  4.80M|#define VAL(x) (*(char ***)(x))
  ------------------
 1556|  4.80M|        return;
 1557|  4.80M|    }
 1558|       |
 1559|  29.7M|    for (n = 0; s[n] != NULL; n++)
  ------------------
  |  Branch (1559:17): [True: 27.0M, False: 2.71M]
  ------------------
 1560|  27.0M|        /* NOTHING */;
 1561|  2.71M|    d = talloc_array(NULL, char *, n + 1);
  ------------------
  |  |   29|  2.71M|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  2.71M|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.71M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1562|  32.4M|    for (; n >= 0; n--)
  ------------------
  |  Branch (1562:12): [True: 29.7M, False: 2.71M]
  ------------------
 1563|  29.7M|        d[n] = talloc_strdup(NULL, s[n]);
  ------------------
  |  |   50|  29.7M|#define talloc_strdup                   ta_xstrdup
  ------------------
 1564|       |
 1565|  2.71M|    VAL(dst) = d;
  ------------------
  |  | 1321|  2.71M|#define VAL(x) (*(char ***)(x))
  ------------------
 1566|  2.71M|}
m_option.c:free_str_list:
 1333|  7.66M|{
 1334|  7.66M|    char **d;
 1335|  7.66M|    int i;
 1336|       |
 1337|  7.66M|    if (!dst || !VAL(dst))
  ------------------
  |  | 1321|  7.66M|#define VAL(x) (*(char ***)(x))
  ------------------
  |  Branch (1337:9): [True: 0, False: 7.66M]
  |  Branch (1337:17): [True: 4.81M, False: 2.85M]
  ------------------
 1338|  4.81M|        return;
 1339|  2.85M|    d = VAL(dst);
  ------------------
  |  | 1321|  2.85M|#define VAL(x) (*(char ***)(x))
  ------------------
 1340|       |
 1341|  30.1M|    for (i = 0; d[i] != NULL; i++)
  ------------------
  |  Branch (1341:17): [True: 27.2M, False: 2.85M]
  ------------------
 1342|  27.2M|        talloc_free(d[i]);
  ------------------
  |  |   47|  27.2M|#define talloc_free                     ta_free
  ------------------
 1343|  2.85M|    talloc_free(d);
  ------------------
  |  |   47|  2.85M|#define talloc_free                     ta_free
  ------------------
 1344|  2.85M|    VAL(dst) = NULL;
  ------------------
  |  | 1321|  2.85M|#define VAL(x) (*(char ***)(x))
  ------------------
 1345|  2.85M|}
m_option.c:str_list_equal:
 1627|  1.81M|{
 1628|  1.81M|    char **la = VAL(a);
  ------------------
  |  | 1321|  1.81M|#define VAL(x) (*(char ***)(x))
  ------------------
 1629|  1.81M|    char **lb = VAL(b);
  ------------------
  |  | 1321|  1.81M|#define VAL(x) (*(char ***)(x))
  ------------------
 1630|       |
 1631|  1.81M|    bool a_empty = !la || !la[0];
  ------------------
  |  Branch (1631:20): [True: 960k, False: 858k]
  |  Branch (1631:27): [True: 0, False: 858k]
  ------------------
 1632|  1.81M|    bool b_empty = !lb || !lb[0];
  ------------------
  |  Branch (1632:20): [True: 937k, False: 882k]
  |  Branch (1632:27): [True: 0, False: 882k]
  ------------------
 1633|  1.81M|    if (a_empty || b_empty)
  ------------------
  |  Branch (1633:9): [True: 960k, False: 858k]
  |  Branch (1633:20): [True: 1.01k, False: 857k]
  ------------------
 1634|   961k|        return a_empty == b_empty;
 1635|       |
 1636|  13.9M|    for (int n = 0; la[n] || lb[n]; n++) {
  ------------------
  |  Branch (1636:21): [True: 13.1M, False: 857k]
  |  Branch (1636:30): [True: 121, False: 857k]
  ------------------
 1637|  13.1M|        if (!la[n] || !lb[n])
  ------------------
  |  Branch (1637:13): [True: 121, False: 13.1M]
  |  Branch (1637:23): [True: 118, False: 13.1M]
  ------------------
 1638|    239|            return false;
 1639|  13.1M|        if (strcmp(la[n], lb[n]) != 0)
  ------------------
  |  Branch (1639:13): [True: 437, False: 13.1M]
  ------------------
 1640|    437|            return false;
 1641|  13.1M|    }
 1642|       |
 1643|   857k|    return true;
 1644|   857k|}
m_option.c:parse_keyvalue_list:
 1799|  94.4k|{
 1800|  94.4k|    char **lst = NULL;
 1801|  94.4k|    int num = 0;
 1802|  94.4k|    int r = 0;
 1803|  94.4k|    bool append = false;
 1804|  94.4k|    bool full_value = false;
 1805|       |
 1806|  94.4k|    if ((opt->flags & M_OPT_HAVE_HELP) && bstr_equals0(param, "help"))
  ------------------
  |  |  480|  94.4k|#define M_OPT_HAVE_HELP         (UINT64_C(1) << 59)
  ------------------
  |  Branch (1806:9): [True: 1.02k, False: 93.4k]
  |  Branch (1806:43): [True: 1, False: 1.02k]
  ------------------
 1807|      1|        param = bstr0("help=");
 1808|       |
 1809|  94.4k|    int op = 0;
 1810|  94.4k|    if (bstr_endswith0(name, "-del")) {
  ------------------
  |  Branch (1810:9): [True: 0, False: 94.4k]
  ------------------
 1811|      0|        op = OP_DEL;
  ------------------
  |  | 1327|      0|#define OP_DEL 4
  ------------------
 1812|  94.4k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (1812:16): [True: 0, False: 94.4k]
  ------------------
 1813|      0|        op = OP_REMOVE;
  ------------------
  |  | 1330|      0|#define OP_REMOVE 7
  ------------------
 1814|      0|    }
 1815|       |
 1816|  94.4k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (1816:9): [True: 0, False: 94.4k]
  ------------------
 1817|      0|        append = true;
 1818|  94.4k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (1818:16): [True: 81.7k, False: 12.7k]
  ------------------
 1819|  81.7k|        append = full_value = true;
 1820|  81.7k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (1820:16): [True: 0, False: 12.7k]
  ------------------
 1821|      0|        if (dst)
  ------------------
  |  Branch (1821:13): [True: 0, False: 0]
  ------------------
 1822|      0|            free_str_list(dst);
 1823|      0|        return 0;
 1824|  12.7k|    } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1327|  25.4k|#define OP_DEL 4
  ------------------
                  } else if (op == OP_DEL || op == OP_REMOVE) {
  ------------------
  |  | 1330|  12.7k|#define OP_REMOVE 7
  ------------------
  |  Branch (1824:16): [True: 0, False: 12.7k]
  |  Branch (1824:32): [True: 0, False: 12.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|  94.4k|    if (append && dst) {
  ------------------
  |  Branch (1842:9): [True: 81.7k, False: 12.7k]
  |  Branch (1842:19): [True: 81.7k, False: 0]
  ------------------
 1843|  81.7k|        lst = VAL(dst);
  ------------------
  |  | 1321|  81.7k|#define VAL(x) (*(char ***)(x))
  ------------------
 1844|  81.7k|        for (int n = 0; lst && lst[n]; n++)
  ------------------
  |  Branch (1844:25): [True: 0, False: 81.7k]
  |  Branch (1844:32): [True: 0, False: 0]
  ------------------
 1845|      0|            num++;
 1846|  81.7k|    }
 1847|       |
 1848|  95.6k|    while (param.len) {
  ------------------
  |  Branch (1848:12): [True: 95.6k, False: 37]
  ------------------
 1849|  95.6k|        bstr key, val;
 1850|  95.6k|        r = read_subparam(log, name, "=", &param, &key);
 1851|  95.6k|        if (r < 0)
  ------------------
  |  Branch (1851:13): [True: 12, False: 95.6k]
  ------------------
 1852|     12|            break;
 1853|  95.6k|        if (!bstr_eatstart0(&param, "=")) {
  ------------------
  |  Branch (1853:13): [True: 727, False: 94.9k]
  ------------------
 1854|    727|            mp_err(log, "Expected '=' and a value.\n");
  ------------------
  |  |   76|    727|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 1855|    727|            r = M_OPT_INVALID;
  ------------------
  |  |  535|    727|#define M_OPT_INVALID           -3
  ------------------
 1856|    727|            break;
 1857|    727|        }
 1858|  94.9k|        if (full_value) {
  ------------------
  |  Branch (1858:13): [True: 81.7k, False: 13.2k]
  ------------------
 1859|  81.7k|            val = param;
 1860|  81.7k|            param.len = 0;
 1861|  81.7k|        } else {
 1862|  13.2k|            r = read_subparam(log, name, ",", &param, &val);
 1863|  13.2k|            if (r < 0)
  ------------------
  |  Branch (1863:17): [True: 45, False: 13.1k]
  ------------------
 1864|     45|                break;
 1865|  13.2k|        }
 1866|  94.8k|        if (dst) {
  ------------------
  |  Branch (1866:13): [True: 94.8k, False: 0]
  ------------------
 1867|  94.8k|            int index = keyvalue_list_find_key(lst, key);
 1868|  94.8k|            if (index >= 0) {
  ------------------
  |  Branch (1868:17): [True: 128, False: 94.7k]
  ------------------
 1869|    128|                keyvalue_list_del_key(lst, index);
 1870|    128|                num -= 2;
 1871|    128|            }
 1872|  94.8k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, key));
  ------------------
  |  |  105|  94.8k|    do {                                            \
  |  |  106|  94.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  94.8k|    do {                                            \
  |  |  |  |   97|  94.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  94.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  94.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  94.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 93.7k, False: 1.11k]
  |  |  |  |  ------------------
  |  |  |  |   99|  94.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  93.7k|    do {                                                        \
  |  |  |  |  |  |   89|  93.7k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  93.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  93.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  93.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  93.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  93.7k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  93.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 93.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  94.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 94.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  94.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  94.8k|        (idxvar)++;                                 \
  |  |  109|  94.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 94.8k]
  |  |  ------------------
  ------------------
 1873|  94.8k|            MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, val));
  ------------------
  |  |  105|  94.8k|    do {                                            \
  |  |  106|  94.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  94.8k|    do {                                            \
  |  |  |  |   97|  94.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  94.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  94.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  94.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 94.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  94.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  94.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 94.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  94.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  94.8k|        (idxvar)++;                                 \
  |  |  109|  94.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 94.8k]
  |  |  ------------------
  ------------------
 1874|  94.8k|            MP_TARRAY_APPEND(NULL, lst, num, NULL);
  ------------------
  |  |  105|  94.8k|    do {                                            \
  |  |  106|  94.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  94.8k|    do {                                            \
  |  |  |  |   97|  94.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  94.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  94.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  94.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 94.0k, False: 877]
  |  |  |  |  ------------------
  |  |  |  |   99|  94.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  94.0k|    do {                                                        \
  |  |  |  |  |  |   89|  94.0k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  94.0k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  94.0k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  94.0k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  94.0k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  94.0k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  94.0k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 94.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  94.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 94.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  94.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  94.8k|        (idxvar)++;                                 \
  |  |  109|  94.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 94.8k]
  |  |  ------------------
  ------------------
 1875|  94.8k|            num -= 1;
 1876|  94.8k|        }
 1877|       |
 1878|  94.8k|        if (!bstr_eatstart0(&param, ",") && !bstr_eatstart0(&param, ":"))
  ------------------
  |  Branch (1878:13): [True: 93.6k, False: 1.26k]
  |  Branch (1878:45): [True: 93.6k, False: 0]
  ------------------
 1879|  93.6k|            break;
 1880|  94.8k|    }
 1881|       |
 1882|  94.4k|    if (param.len) {
  ------------------
  |  Branch (1882:9): [True: 64, False: 94.3k]
  ------------------
 1883|     64|        mp_err(log, "Unparsable garbage at end of option value: '%.*s'\n",
  ------------------
  |  |   76|    128|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 64, False: 0]
  |  |  ------------------
  ------------------
 1884|     64|               BSTR_P(param));
 1885|     64|        r = M_OPT_INVALID;
  ------------------
  |  |  535|     64|#define M_OPT_INVALID           -3
  ------------------
 1886|     64|    }
 1887|       |
 1888|  94.4k|    if (dst) {
  ------------------
  |  Branch (1888:9): [True: 94.4k, False: 0]
  ------------------
 1889|  94.4k|        if (!append)
  ------------------
  |  Branch (1889:13): [True: 12.7k, False: 81.7k]
  ------------------
 1890|  12.7k|            free_str_list(dst);
 1891|  94.4k|        VAL(dst) = lst;
  ------------------
  |  | 1321|  94.4k|#define VAL(x) (*(char ***)(x))
  ------------------
 1892|  94.4k|        if (r < 0)
  ------------------
  |  Branch (1892:13): [True: 791, False: 93.6k]
  ------------------
 1893|    791|            free_str_list(dst);
 1894|  94.4k|    } else {
 1895|      0|        free_str_list(&lst);
 1896|      0|    }
 1897|  94.4k|    return r;
 1898|  94.4k|}
m_option.c:keyvalue_list_find_key:
 1776|  94.8k|{
 1777|  99.0k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1777:21): [True: 5.30k, False: 93.7k]
  |  Branch (1777:28): [True: 4.31k, False: 990]
  |  Branch (1777:38): [True: 4.31k, False: 0]
  ------------------
 1778|  4.31k|        if (bstr_equals0(str, lst[n]))
  ------------------
  |  Branch (1778:13): [True: 128, False: 4.19k]
  ------------------
 1779|    128|            return n / 2;
 1780|  4.31k|    }
 1781|  94.7k|    return -1;
 1782|  94.8k|}
m_option.c:keyvalue_list_del_key:
 1785|    128|{
 1786|    128|    int count = 0;
 1787|    994|    for (int n = 0; lst && lst[n]; n++)
  ------------------
  |  Branch (1787:21): [True: 994, False: 0]
  |  Branch (1787:28): [True: 866, False: 128]
  ------------------
 1788|    866|        count++;
 1789|    128|    mp_assert(index * 2 + 1 < count);
  ------------------
  |  |   41|    128|#define mp_assert assert
  ------------------
  |  Branch (1789:5): [True: 128, False: 0]
  ------------------
 1790|    128|    count += 1; // terminating item
 1791|    128|    talloc_free(lst[index * 2 + 0]);
  ------------------
  |  |   47|    128|#define talloc_free                     ta_free
  ------------------
 1792|    128|    talloc_free(lst[index * 2 + 1]);
  ------------------
  |  |   47|    128|#define talloc_free                     ta_free
  ------------------
 1793|    128|    MP_TARRAY_REMOVE_AT(lst, count, index * 2 + 1);
  ------------------
  |  |  143|    128|    do {                                            \
  |  |  144|    128|        size_t at_ = (at);                          \
  |  |  145|    128|        assert(at_ < (idxvar));                     \
  |  |  146|    128|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|    128|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|    128|        (idxvar)--;                                 \
  |  |  149|    128|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 128]
  |  |  ------------------
  ------------------
  |  Branch (1793:5): [True: 128, False: 0]
  ------------------
 1794|    128|    MP_TARRAY_REMOVE_AT(lst, count, index * 2 + 0);
  ------------------
  |  |  143|    128|    do {                                            \
  |  |  144|    128|        size_t at_ = (at);                          \
  |  |  145|    128|        assert(at_ < (idxvar));                     \
  |  |  146|    128|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|    128|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|    128|        (idxvar)--;                                 \
  |  |  149|    128|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 128]
  |  |  ------------------
  ------------------
  |  Branch (1794:5): [True: 128, False: 0]
  ------------------
 1795|    128|}
m_option.c:read_subparam:
 2081|   131k|{
 2082|   131k|    bstr p = *str;
 2083|   131k|    bstr subparam = {0};
 2084|       |
 2085|   131k|    if (bstr_eatstart0(&p, "\"")) {
  ------------------
  |  Branch (2085:9): [True: 2.15k, False: 129k]
  ------------------
 2086|  2.15k|        int optlen = bstrcspn(p, "\"");
 2087|  2.15k|        subparam = bstr_splice(p, 0, optlen);
 2088|  2.15k|        p = bstr_cut(p, optlen);
 2089|  2.15k|        if (!bstr_startswith0(p, "\"")) {
  ------------------
  |  Branch (2089:13): [True: 2.11k, False: 38]
  ------------------
 2090|  2.11k|            mp_err(log, "Terminating '\"' missing for '%.*s'\n",
  ------------------
  |  |   76|  4.22k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 2.11k, False: 0]
  |  |  ------------------
  ------------------
 2091|  2.11k|                   BSTR_P(optname));
 2092|  2.11k|            return M_OPT_INVALID;
  ------------------
  |  |  535|  2.11k|#define M_OPT_INVALID           -3
  ------------------
 2093|  2.11k|        }
 2094|     38|        p = bstr_cut(p, 1);
 2095|   129k|    } else if (bstr_eatstart0(&p, "[")) {
  ------------------
  |  Branch (2095:16): [True: 179, False: 129k]
  ------------------
 2096|    179|        bstr s = p;
 2097|    179|        int balance = 1;
 2098|  1.98k|        while (p.len && balance > 0) {
  ------------------
  |  Branch (2098:16): [True: 1.82k, False: 164]
  |  Branch (2098:25): [True: 1.80k, False: 15]
  ------------------
 2099|  1.80k|            if (p.start[0] == '[') {
  ------------------
  |  Branch (2099:17): [True: 364, False: 1.44k]
  ------------------
 2100|    364|                balance++;
 2101|  1.44k|            } else if (p.start[0] == ']') {
  ------------------
  |  Branch (2101:24): [True: 78, False: 1.36k]
  ------------------
 2102|     78|                balance--;
 2103|     78|            }
 2104|  1.80k|            p = bstr_cut(p, 1);
 2105|  1.80k|        }
 2106|    179|        if (balance != 0) {
  ------------------
  |  Branch (2106:13): [True: 164, False: 15]
  ------------------
 2107|    164|            mp_err(log, "Terminating ']' missing for '%.*s'\n",
  ------------------
  |  |   76|    328|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 164, False: 0]
  |  |  ------------------
  ------------------
 2108|    164|                   BSTR_P(optname));
 2109|    164|            return M_OPT_INVALID;
  ------------------
  |  |  535|    164|#define M_OPT_INVALID           -3
  ------------------
 2110|    164|        }
 2111|     15|        subparam = bstr_splice(s, 0, s.len - p.len - 1);
 2112|   129k|    } else if (bstr_eatstart0(&p, "%")) {
  ------------------
  |  Branch (2112:16): [True: 109, False: 129k]
  ------------------
 2113|    109|        int optlen = bstrtoll(p, &p, 0);
 2114|    109|        if (!bstr_startswith0(p, "%") || (optlen > p.len - 1)) {
  ------------------
  |  Branch (2114:13): [True: 93, False: 16]
  |  Branch (2114:42): [True: 0, False: 16]
  ------------------
 2115|     93|            mp_err(log, "Invalid length %d for '%.*s'\n",
  ------------------
  |  |   76|    186|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 93, False: 0]
  |  |  ------------------
  ------------------
 2116|     93|                   optlen, BSTR_P(optname));
 2117|     93|            return M_OPT_INVALID;
  ------------------
  |  |  535|     93|#define M_OPT_INVALID           -3
  ------------------
 2118|     93|        }
 2119|     16|        subparam = bstr_splice(p, 1, optlen + 1);
 2120|     16|        p = bstr_cut(p, optlen + 1);
 2121|   129k|    } else {
 2122|       |        // Skip until the next character that could possibly be a meta
 2123|       |        // character in option parsing.
 2124|   129k|        int optlen = bstrcspn(p, termset);
 2125|   129k|        subparam = bstr_splice(p, 0, optlen);
 2126|   129k|        p = bstr_cut(p, optlen);
 2127|   129k|    }
 2128|       |
 2129|   129k|    *str = p;
 2130|   129k|    *out_subparam = subparam;
 2131|   129k|    return 0;
 2132|   131k|}
m_option.c:print_keyvalue_list:
 1901|  13.5k|{
 1902|  13.5k|    char **lst = VAL(src);
  ------------------
  |  | 1321|  13.5k|#define VAL(x) (*(char ***)(x))
  ------------------
 1903|  13.5k|    char *ret = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  13.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1904|  13.9k|    for (int n = 0; lst && lst[n] && lst[n + 1]; n += 2) {
  ------------------
  |  Branch (1904:21): [True: 507, False: 13.4k]
  |  Branch (1904:28): [True: 395, False: 112]
  |  Branch (1904:38): [True: 395, False: 0]
  ------------------
 1905|    395|        if (ret[0])
  ------------------
  |  Branch (1905:13): [True: 283, False: 112]
  ------------------
 1906|    283|            ret = talloc_strdup_append(ret, ",");
  ------------------
  |  |   57|    283|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 1907|    395|        ret = talloc_asprintf_append(ret, "%s=%s", lst[n], lst[n + 1]);
  ------------------
  |  |   63|    395|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 1908|    395|    }
 1909|  13.5k|    return ret;
 1910|  13.5k|}
m_option.c:parse_msglevels:
 1993|  11.6k|{
 1994|  11.6k|    if (bstr_equals0(param, "help")) {
  ------------------
  |  Branch (1994:9): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|    char **dst_copy = NULL;
 2006|  11.6k|    int r = m_option_type_keyvalue_list.parse(log, opt, name, param, &dst_copy);
 2007|  11.6k|    if (r >= 0)
  ------------------
  |  Branch (2007:9): [True: 11.6k, False: 0]
  ------------------
 2008|  11.6k|        r = check_msg_levels(log, dst_copy);
 2009|       |
 2010|  11.6k|    if (r >= 0)
  ------------------
  |  Branch (2010:9): [True: 11.6k, False: 0]
  ------------------
 2011|  11.6k|        m_option_type_keyvalue_list.copy(opt, dst, &dst_copy);
 2012|  11.6k|    m_option_type_keyvalue_list.free(&dst_copy);
 2013|  11.6k|    return r;
 2014|  11.6k|}
m_option.c:check_msg_levels:
 1980|  11.6k|{
 1981|  23.3k|    for (int n = 0; list && list[n * 2 + 0]; n++) {
  ------------------
  |  Branch (1981:21): [True: 23.3k, False: 0]
  |  Branch (1981:29): [True: 11.6k, False: 11.6k]
  ------------------
 1982|  11.6k|        char *level = list[n * 2 + 1];
 1983|  11.6k|        if (mp_msg_find_level(level) < 0 && strcmp(level, "no") != 0) {
  ------------------
  |  Branch (1983:13): [True: 0, False: 11.6k]
  |  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|  11.6k|    }
 1988|  11.6k|    return 1;
 1989|  11.6k|}
m_option.c:parse_color:
 2184|    177|{
 2185|    177|    if (param.len == 0)
  ------------------
  |  Branch (2185:9): [True: 0, False: 177]
  ------------------
 2186|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 2187|       |
 2188|    177|    bool is_help = bstr_equals0(param, "help");
 2189|    177|    if (is_help)
  ------------------
  |  Branch (2189:9): [True: 0, False: 177]
  ------------------
 2190|      0|        goto exit;
 2191|       |
 2192|    177|    bstr val = param;
 2193|    177|    struct m_color color = {0};
 2194|       |
 2195|    177|    if (bstr_eatstart0(&val, "#")) {
  ------------------
  |  Branch (2195:9): [True: 0, False: 177]
  ------------------
 2196|       |        // #[AA]RRGGBB
 2197|      0|        if (val.len != 6 && val.len != 8)
  ------------------
  |  Branch (2197:13): [True: 0, False: 0]
  |  Branch (2197:29): [True: 0, False: 0]
  ------------------
 2198|      0|            goto exit;
 2199|      0|        bool has_alpha = val.len == 8;
 2200|      0|        uint32_t c = bstrtoll(val, &val, 16);
 2201|      0|        if (val.len)
  ------------------
  |  Branch (2201:13): [True: 0, False: 0]
  ------------------
 2202|      0|            goto exit;
 2203|      0|        color = (struct m_color) {
 2204|      0|            (c >> 16) & 0xFF,
 2205|      0|            (c >> 8) & 0xFF,
 2206|      0|            c & 0xFF,
 2207|      0|            has_alpha ? (c >> 24) & 0xFF : 0xFF,
  ------------------
  |  Branch (2207:13): [True: 0, False: 0]
  ------------------
 2208|      0|        };
 2209|    177|    } else {
 2210|    177|        bstr comp_str[5];
 2211|    177|        int num = split_char(param, '/', 5, comp_str);
 2212|    177|        if (num < 1 || num > 4)
  ------------------
  |  Branch (2212:13): [True: 0, False: 177]
  |  Branch (2212:24): [True: 8, False: 169]
  ------------------
 2213|      8|            goto exit;
 2214|    169|        double comp[4] = {0, 0, 0, 1};
 2215|    183|        for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (2215:25): [True: 176, False: 7]
  ------------------
 2216|    176|            bstr rest;
 2217|    176|            double d = bstrtod(comp_str[n], &rest);
 2218|    176|            if (rest.len || !comp_str[n].len || d < 0 || d > 1 || !isfinite(d))
  ------------------
  |  Branch (2218:17): [True: 131, False: 45]
  |  Branch (2218:29): [True: 8, False: 37]
  |  Branch (2218:49): [True: 0, False: 37]
  |  Branch (2218:58): [True: 23, False: 14]
  |  Branch (2218:67): [True: 0, False: 14]
  ------------------
 2219|    162|                goto exit;
 2220|     14|            comp[n] = d;
 2221|     14|        }
 2222|      7|        if (num == 2)
  ------------------
  |  Branch (2222:13): [True: 0, False: 7]
  ------------------
 2223|      0|            comp[3] = comp[1];
 2224|      7|        if (num < 3)
  ------------------
  |  Branch (2224:13): [True: 7, False: 0]
  ------------------
 2225|      7|            comp[2] = comp[1] = comp[0];
 2226|      7|        color = (struct m_color) { comp[0] * 0xFF, comp[1] * 0xFF,
 2227|      7|                                   comp[2] * 0xFF, comp[3] * 0xFF };
 2228|      7|    }
 2229|       |
 2230|      7|    if (dst)
  ------------------
  |  Branch (2230:9): [True: 7, False: 0]
  ------------------
 2231|      7|        *((struct m_color *)dst) = color;
 2232|       |
 2233|      7|    return 1;
 2234|       |
 2235|    170|exit:
 2236|    170|    if (!is_help) {
  ------------------
  |  Branch (2236:9): [True: 170, False: 0]
  ------------------
 2237|    170|        mp_err(log, "Option %.*s: invalid color: '%.*s'\n",
  ------------------
  |  |   76|    680|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 170, False: 0]
  |  |  |  Branch (76:55): [True: 170, False: 0]
  |  |  ------------------
  ------------------
 2238|    170|               BSTR_P(name), BSTR_P(param));
 2239|    170|    }
 2240|    170|    mp_info(log, "Valid colors must be in the form #RRGGBB or #AARRGGBB (in hex)\n"
  ------------------
  |  |   78|    170|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2241|    170|            "or in the form 'r/g/b/a', where each component is a value in the\n"
 2242|    170|            "range 0.0-1.0. (Also allowed: 'gray', 'gray/a', 'r/g/b').\n");
 2243|    170|    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|    170|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (2243:12): [True: 0, False: 170]
  ------------------
 2244|    177|}
m_option.c:split_char:
 2164|    177|{
 2165|    177|    if (max < 1)
  ------------------
  |  Branch (2165:9): [True: 0, False: 177]
  ------------------
 2166|      0|        return 0;
 2167|       |
 2168|    177|    int count = 0;
 2169|    225|    while (1) {
  ------------------
  |  Branch (2169:12): [True: 225, Folded]
  ------------------
 2170|    225|        int next = bstrchr(str, split);
 2171|    225|        if (next >= 0 && max - count > 1) {
  ------------------
  |  Branch (2171:13): [True: 53, False: 172]
  |  Branch (2171:26): [True: 48, False: 5]
  ------------------
 2172|     48|            out_arr[count++] = bstr_splice(str, 0, next);
 2173|     48|            str = bstr_cut(str, next + 1);
 2174|    177|        } else {
 2175|    177|            out_arr[count++] = str;
 2176|    177|            break;
 2177|    177|        }
 2178|    225|    }
 2179|    177|    return count;
 2180|    177|}
m_option.c:color_equal:
 2253|  2.74k|{
 2254|  2.74k|    struct m_color *ca = a;
 2255|  2.74k|    struct m_color *cb = b;
 2256|  2.74k|    return ca->a == cb->a && ca->r == cb->r && ca->g == cb->g && ca->b == cb->b;
  ------------------
  |  Branch (2256:12): [True: 2.73k, False: 7]
  |  Branch (2256:30): [True: 2.73k, False: 0]
  |  Branch (2256:48): [True: 2.73k, False: 0]
  |  Branch (2256:66): [True: 2.73k, False: 0]
  ------------------
 2257|  2.74k|}
m_option.c:parse_geometry_str:
 2289|  1.27k|{
 2290|  1.27k|    *gm = (struct m_geometry) { .x = INT_MIN, .y = INT_MIN };
 2291|  1.27k|    if (s.len == 0)
  ------------------
  |  Branch (2291:9): [True: 40, False: 1.23k]
  ------------------
 2292|     40|        return true;
 2293|       |    // Approximate grammar:
 2294|       |    // [[W][xH]][{+-}X{+-}Y][/WS] | [X:Y]
 2295|       |    // (meaning: [optional] {one character of} one|alternative)
 2296|       |    // Every number can be followed by '%'
 2297|  1.23k|    int num;
 2298|  1.23k|    bool per;
 2299|       |
 2300|  1.23k|#define READ_NUM(F, F_PER) do {         \
 2301|  1.23k|    if (!eat_num_per(&s, &num, &per))   \
 2302|  1.23k|        goto error;                     \
 2303|  1.23k|    gm->F = num;                        \
 2304|  1.23k|    gm->F_PER = per;                    \
 2305|  1.23k|} while(0)
 2306|       |
 2307|  1.23k|#define READ_SIGN(F) do {               \
 2308|  1.23k|    if (bstr_eatstart0(&s, "+")) {      \
 2309|  1.23k|        gm->F = false;                  \
 2310|  1.23k|    } else if (bstr_eatstart0(&s, "-")) {\
 2311|  1.23k|        gm->F = true;                   \
 2312|  1.23k|    } else goto error;                  \
 2313|  1.23k|} while(0)
 2314|       |
 2315|  1.23k|    if (bstrchr(s, ':') < 0) {
  ------------------
  |  Branch (2315:9): [True: 965, False: 272]
  ------------------
 2316|    965|        gm->wh_valid = true;
 2317|    965|        if (!bstr_startswith0(s, "+") && !bstr_startswith0(s, "-") &&
  ------------------
  |  Branch (2317:13): [True: 948, False: 17]
  |  Branch (2317:42): [True: 897, False: 51]
  ------------------
 2318|    897|            !bstr_startswith0(s, "/"))
  ------------------
  |  Branch (2318:13): [True: 846, False: 51]
  ------------------
 2319|    846|        {
 2320|    846|            if (!bstr_startswith0(s, "x"))
  ------------------
  |  Branch (2320:17): [True: 808, False: 38]
  ------------------
 2321|    808|                READ_NUM(w, w_per);
  ------------------
  |  | 2300|    808|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|    808|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 529, False: 279]
  |  |  ------------------
  |  | 2302|    808|        goto error;                     \
  |  | 2303|    808|    gm->F = num;                        \
  |  | 2304|    279|    gm->F_PER = per;                    \
  |  | 2305|    279|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 279]
  |  |  ------------------
  ------------------
 2322|    317|            if (bstr_eatstart0(&s, "x"))
  ------------------
  |  Branch (2322:17): [True: 38, False: 279]
  ------------------
 2323|     38|                READ_NUM(h, h_per);
  ------------------
  |  | 2300|     38|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|     38|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 23, False: 15]
  |  |  ------------------
  |  | 2302|     38|        goto error;                     \
  |  | 2303|     38|    gm->F = num;                        \
  |  | 2304|     15|    gm->F_PER = per;                    \
  |  | 2305|     15|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 15]
  |  |  ------------------
  ------------------
 2324|    317|        }
 2325|    413|        if (s.len > 0 && !bstr_startswith0(s, "/")) {
  ------------------
  |  Branch (2325:13): [True: 335, False: 78]
  |  Branch (2325:26): [True: 271, False: 64]
  ------------------
 2326|    271|            gm->xy_valid = true;
 2327|    271|            READ_SIGN(x_sign);
  ------------------
  |  | 2307|    271|#define READ_SIGN(F) do {               \
  |  | 2308|    271|    if (bstr_eatstart0(&s, "+")) {      \
  |  |  ------------------
  |  |  |  Branch (2308:9): [True: 23, False: 248]
  |  |  ------------------
  |  | 2309|     23|        gm->F = false;                  \
  |  | 2310|    248|    } else if (bstr_eatstart0(&s, "-")) {\
  |  |  ------------------
  |  |  |  Branch (2310:16): [True: 158, False: 90]
  |  |  ------------------
  |  | 2311|    158|        gm->F = true;                   \
  |  | 2312|    158|    } else goto error;                  \
  |  | 2313|    271|} while(0)
  |  |  ------------------
  |  |  |  Branch (2313:9): [Folded, False: 181]
  |  |  ------------------
  ------------------
 2328|    181|            READ_NUM(x, x_per);
  ------------------
  |  | 2300|    181|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|    181|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 79, False: 102]
  |  |  ------------------
  |  | 2302|    181|        goto error;                     \
  |  | 2303|    181|    gm->F = num;                        \
  |  | 2304|    102|    gm->F_PER = per;                    \
  |  | 2305|    102|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 102]
  |  |  ------------------
  ------------------
 2329|    102|            READ_SIGN(y_sign);
  ------------------
  |  | 2307|    102|#define READ_SIGN(F) do {               \
  |  | 2308|    102|    if (bstr_eatstart0(&s, "+")) {      \
  |  |  ------------------
  |  |  |  Branch (2308:9): [True: 4, False: 98]
  |  |  ------------------
  |  | 2309|      4|        gm->F = false;                  \
  |  | 2310|     98|    } else if (bstr_eatstart0(&s, "-")) {\
  |  |  ------------------
  |  |  |  Branch (2310:16): [True: 19, False: 79]
  |  |  ------------------
  |  | 2311|     19|        gm->F = true;                   \
  |  | 2312|     79|    } else goto error;                  \
  |  | 2313|    102|} while(0)
  |  |  ------------------
  |  |  |  Branch (2313:9): [Folded, False: 23]
  |  |  ------------------
  ------------------
 2330|     23|            READ_NUM(y, y_per);
  ------------------
  |  | 2300|     23|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|     23|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 9, False: 14]
  |  |  ------------------
  |  | 2302|     23|        goto error;                     \
  |  | 2303|     23|    gm->F = num;                        \
  |  | 2304|     14|    gm->F_PER = per;                    \
  |  | 2305|     14|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 14]
  |  |  ------------------
  ------------------
 2331|     23|        }
 2332|    156|        if (bstr_eatstart0(&s, "/")) {
  ------------------
  |  Branch (2332:13): [True: 64, False: 92]
  ------------------
 2333|     64|            bstr rest;
 2334|     64|            long long v = bstrtoll(s, &rest, 10);
 2335|     64|            if (s.len == rest.len || v < 1 || v > INT_MAX)
  ------------------
  |  Branch (2335:17): [True: 42, False: 22]
  |  Branch (2335:38): [True: 0, False: 22]
  |  Branch (2335:47): [True: 8, False: 14]
  ------------------
 2336|     50|                goto error;
 2337|     14|            s = rest;
 2338|     14|            gm->ws = v;
 2339|     14|        }
 2340|    272|    } else {
 2341|    272|        gm->xy_valid = true;
 2342|    272|        READ_NUM(x, x_per);
  ------------------
  |  | 2300|    272|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|    272|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 78, False: 194]
  |  |  ------------------
  |  | 2302|    272|        goto error;                     \
  |  | 2303|    272|    gm->F = num;                        \
  |  | 2304|    194|    gm->F_PER = per;                    \
  |  | 2305|    194|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 194]
  |  |  ------------------
  ------------------
 2343|    194|        if (!bstr_eatstart0(&s, ":"))
  ------------------
  |  Branch (2343:13): [True: 74, False: 120]
  ------------------
 2344|     74|            goto error;
 2345|    120|        READ_NUM(y, y_per);
  ------------------
  |  | 2300|    120|#define READ_NUM(F, F_PER) do {         \
  |  | 2301|    120|    if (!eat_num_per(&s, &num, &per))   \
  |  |  ------------------
  |  |  |  Branch (2301:9): [True: 47, False: 73]
  |  |  ------------------
  |  | 2302|    120|        goto error;                     \
  |  | 2303|    120|    gm->F = num;                        \
  |  | 2304|     73|    gm->F_PER = per;                    \
  |  | 2305|     73|} while(0)
  |  |  ------------------
  |  |  |  Branch (2305:9): [Folded, False: 73]
  |  |  ------------------
  ------------------
 2346|    120|    }
 2347|       |
 2348|    179|    return s.len == 0;
 2349|       |
 2350|  1.05k|error:
 2351|       |    return false;
 2352|  1.23k|}
m_option.c:eat_num_per:
 2273|  1.44k|{
 2274|  1.44k|    bstr rest;
 2275|  1.44k|    long long v = bstrtoll(*s, &rest, 10);
 2276|  1.44k|    if (s->len == rest.len || v < INT_MIN || v > INT_MAX)
  ------------------
  |  Branch (2276:9): [True: 586, False: 856]
  |  Branch (2276:31): [True: 0, False: 856]
  |  Branch (2276:46): [True: 179, False: 677]
  ------------------
 2277|    765|        return false;
 2278|    677|    *out_num = v;
 2279|    677|    *out_per = false;
 2280|    677|    *s = rest;
 2281|    677|    if (bstr_eatstart0(&rest, "%") && v >= 0 && v <= 100) {
  ------------------
  |  Branch (2281:9): [True: 40, False: 637]
  |  Branch (2281:39): [True: 39, False: 1]
  |  Branch (2281:49): [True: 37, False: 2]
  ------------------
 2282|     37|        *out_per = true;
 2283|     37|        *s = rest;
 2284|     37|    }
 2285|       |    return true;
 2286|  1.44k|}
m_option.c:print_geometry:
 2361|     26|{
 2362|     26|    const struct m_geometry *gm = val;
 2363|     26|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|     26|#define talloc_strdup                   ta_xstrdup
  ------------------
 2364|     26|    if (gm->wh_valid || gm->xy_valid) {
  ------------------
  |  Branch (2364:9): [True: 25, False: 1]
  |  Branch (2364:25): [True: 0, False: 1]
  ------------------
 2365|     25|        if (gm->wh_valid) {
  ------------------
  |  Branch (2365:13): [True: 25, False: 0]
  ------------------
 2366|     25|            APPEND_PER(w, w_per);
  ------------------
  |  | 2358|     25|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|     25|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 25]
  |  |  ------------------
  ------------------
 2367|     25|            res = talloc_asprintf_append(res, "x");
  ------------------
  |  |   63|     25|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 2368|     25|            APPEND_PER(h, h_per);
  ------------------
  |  | 2358|     25|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|     25|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 25]
  |  |  ------------------
  ------------------
 2369|     25|            if (gm->xy_valid) {
  ------------------
  |  Branch (2369:17): [True: 0, False: 25]
  ------------------
 2370|      0|                res = talloc_asprintf_append(res, gm->x_sign ? "-" : "+");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (2370:51): [True: 0, False: 0]
  ------------------
 2371|      0|                APPEND_PER(x, x_per);
  ------------------
  |  | 2358|      0|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2372|      0|                res = talloc_asprintf_append(res, gm->y_sign ? "-" : "+");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (2372:51): [True: 0, False: 0]
  ------------------
 2373|      0|                APPEND_PER(y, y_per);
  ------------------
  |  | 2358|      0|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2374|      0|            }
 2375|     25|        } else {
 2376|      0|            APPEND_PER(x, x_per);
  ------------------
  |  | 2358|      0|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2377|      0|            res = talloc_asprintf_append(res, ":");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 2378|      0|            APPEND_PER(y, y_per);
  ------------------
  |  | 2358|      0|    res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  |  |  |  Branch (2358:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2379|      0|        }
 2380|     25|        if (gm->ws > 0)
  ------------------
  |  Branch (2380:13): [True: 1, False: 24]
  ------------------
 2381|      1|            res = talloc_asprintf_append(res, "/%d", gm->ws);
  ------------------
  |  |   63|      1|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 2382|     25|    }
 2383|     26|    return res;
 2384|     26|}
m_option.c:geometry_equal:
 2459|   175k|{
 2460|   175k|    struct m_geometry *ga = a;
 2461|   175k|    struct m_geometry *gb = b;
 2462|   175k|    return ga->x == gb->x && ga->y == gb->y && ga->w == gb->w && ga->h == gb->h &&
  ------------------
  |  Branch (2462:12): [True: 175k, False: 119]
  |  Branch (2462:30): [True: 175k, False: 0]
  |  Branch (2462:48): [True: 175k, False: 20]
  |  Branch (2462:66): [True: 175k, False: 0]
  ------------------
 2463|   175k|           ga->xy_valid == gb->xy_valid && ga->wh_valid == gb->wh_valid &&
  ------------------
  |  Branch (2463:12): [True: 175k, False: 0]
  |  Branch (2463:44): [True: 175k, False: 0]
  ------------------
 2464|   175k|           ga->w_per == gb->w_per && ga->h_per == gb->h_per &&
  ------------------
  |  Branch (2464:12): [True: 175k, False: 0]
  |  Branch (2464:38): [True: 175k, False: 0]
  ------------------
 2465|   175k|           ga->x_per == gb->x_per && ga->y_per == gb->y_per &&
  ------------------
  |  Branch (2465:12): [True: 175k, False: 0]
  |  Branch (2465:38): [True: 175k, False: 0]
  ------------------
 2466|   175k|           ga->x_sign == gb->x_sign && ga->y_sign == gb->y_sign &&
  ------------------
  |  Branch (2466:12): [True: 175k, False: 0]
  |  Branch (2466:40): [True: 175k, False: 0]
  ------------------
 2467|   175k|           ga->ws == gb->ws;
  ------------------
  |  Branch (2467:12): [True: 175k, False: 0]
  ------------------
 2468|   175k|}
m_option.c:parse_size_box:
 2481|  1.16k|{
 2482|  1.16k|    bool is_help = bstr_equals0(param, "help");
 2483|  1.16k|    if (is_help)
  ------------------
  |  Branch (2483:9): [True: 0, False: 1.16k]
  ------------------
 2484|      0|        goto exit;
 2485|       |
 2486|  1.16k|    struct m_geometry gm;
 2487|  1.16k|    if (!parse_geometry_str(&gm, param))
  ------------------
  |  Branch (2487:9): [True: 1.03k, False: 139]
  ------------------
 2488|  1.03k|        goto exit;
 2489|       |
 2490|    139|    if (gm.xy_valid)
  ------------------
  |  Branch (2490:9): [True: 41, False: 98]
  ------------------
 2491|     41|        goto exit;
 2492|       |
 2493|     98|    if (dst)
  ------------------
  |  Branch (2493:9): [True: 98, False: 0]
  ------------------
 2494|     98|        *((struct m_geometry *)dst) = gm;
 2495|       |
 2496|     98|    return 1;
 2497|       |
 2498|  1.07k|exit:
 2499|  1.07k|    if (!is_help) {
  ------------------
  |  Branch (2499:9): [True: 1.07k, False: 0]
  ------------------
 2500|  1.07k|        mp_err(log, "Option %.*s: invalid size: '%.*s'\n",
  ------------------
  |  |   76|  4.28k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 1.07k, False: 0]
  |  |  |  Branch (76:55): [True: 1.07k, False: 0]
  |  |  ------------------
  ------------------
 2501|  1.07k|               BSTR_P(name), BSTR_P(param));
 2502|  1.07k|    }
 2503|  1.07k|    mp_info(log, "Valid format: W[%%][xH[%%]] or empty string\n");
  ------------------
  |  |   78|  1.07k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2504|  1.07k|    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|  1.07k|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (2504:12): [True: 0, False: 1.07k]
  ------------------
 2505|    139|}
m_option.c:parse_rect:
 2536|    108|{
 2537|    108|    bool is_help = bstr_equals0(param, "help");
 2538|    108|    if (is_help)
  ------------------
  |  Branch (2538:9): [True: 0, False: 108]
  ------------------
 2539|      0|        goto exit;
 2540|       |
 2541|    108|    struct m_geometry gm;
 2542|    108|    if (!parse_geometry_str(&gm, param))
  ------------------
  |  Branch (2542:9): [True: 80, False: 28]
  ------------------
 2543|     80|        goto exit;
 2544|       |
 2545|    108|    bool invalid = gm.x_sign || gm.y_sign || gm.ws;
  ------------------
  |  Branch (2545:20): [True: 0, False: 28]
  |  Branch (2545:33): [True: 0, False: 28]
  |  Branch (2545:46): [True: 0, False: 28]
  ------------------
 2546|     28|    invalid |= gm.wh_valid && (gm.w < 0 || gm.h < 0);
  ------------------
  |  Branch (2546:16): [True: 28, False: 0]
  |  Branch (2546:32): [True: 0, False: 28]
  |  Branch (2546:44): [True: 0, False: 28]
  ------------------
 2547|     28|    invalid |= gm.wh_valid && !gm.xy_valid && gm.w <= 0 && gm.h <= 0;
  ------------------
  |  Branch (2547:16): [True: 28, False: 0]
  |  Branch (2547:31): [True: 28, False: 0]
  |  Branch (2547:47): [True: 11, False: 17]
  |  Branch (2547:60): [True: 11, False: 0]
  ------------------
 2548|       |
 2549|     28|    if (invalid)
  ------------------
  |  Branch (2549:9): [True: 11, False: 17]
  ------------------
 2550|     11|        goto exit;
 2551|       |
 2552|     17|    if (dst)
  ------------------
  |  Branch (2552:9): [True: 17, False: 0]
  ------------------
 2553|     17|        *((struct m_geometry *)dst) = gm;
 2554|       |
 2555|     17|    return 1;
 2556|       |
 2557|     91|exit:
 2558|     91|    if (!is_help) {
  ------------------
  |  Branch (2558:9): [True: 91, False: 0]
  ------------------
 2559|     91|        mp_err(log, "Option %.*s: invalid rect: '%.*s'\n",
  ------------------
  |  |   76|    364|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 91, False: 0]
  |  |  |  Branch (76:55): [True: 91, False: 0]
  |  |  ------------------
  ------------------
 2560|     91|               BSTR_P(name), BSTR_P(param));
 2561|     91|    }
 2562|     91|    mp_info(log, "Valid format: W[%%][xH[%%]][+x+y]\n");
  ------------------
  |  |   78|     91|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2563|     91|    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|     91|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (2563:12): [True: 0, False: 91]
  ------------------
 2564|     28|}
m_option.c:parse_imgfmt:
 2579|  3.27k|{
 2580|  3.27k|    if (param.len == 0)
  ------------------
  |  Branch (2580:9): [True: 0, False: 3.27k]
  ------------------
 2581|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
 2582|       |
 2583|  3.27k|    if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (2583:9): [True: 0, False: 3.27k]
  ------------------
 2584|      0|        mp_info(log, "Available formats:");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2585|      0|        char **list = mp_imgfmt_name_list();
 2586|      0|        for (int i = 0; list[i]; i++)
  ------------------
  |  Branch (2586:25): [True: 0, False: 0]
  ------------------
 2587|      0|            mp_info(log, " %s", list[i]);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2588|      0|        mp_info(log, " no");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2589|      0|        mp_info(log, "\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2590|      0|        talloc_free(list);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2591|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 2592|      0|    }
 2593|       |
 2594|  3.27k|    unsigned int fmt = mp_imgfmt_from_name(param);
 2595|  3.27k|    if (!fmt && !bstr_equals0(param, "no")) {
  ------------------
  |  Branch (2595:9): [True: 3.27k, False: 0]
  |  Branch (2595:17): [True: 3.25k, False: 23]
  ------------------
 2596|  3.25k|        mp_err(log, "Option %.*s: unknown format name: '%.*s'\n",
  ------------------
  |  |   76|  13.0k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 3.25k, False: 0]
  |  |  |  Branch (76:55): [True: 3.25k, False: 0]
  |  |  ------------------
  ------------------
 2597|  3.25k|               BSTR_P(name), BSTR_P(param));
 2598|  3.25k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  3.25k|#define M_OPT_INVALID           -3
  ------------------
 2599|  3.25k|    }
 2600|       |
 2601|     23|    if (dst)
  ------------------
  |  Branch (2601:9): [True: 23, False: 0]
  ------------------
 2602|     23|        *((int *)dst) = fmt;
 2603|       |
 2604|     23|    return 1;
 2605|  3.27k|}
m_option.c:parse_afmt:
 2668|    850|{
 2669|    850|    if (param.len == 0)
  ------------------
  |  Branch (2669:9): [True: 6, False: 844]
  ------------------
 2670|      6|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      6|#define M_OPT_MISSING_PARAM     -2
  ------------------
 2671|       |
 2672|    844|    if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (2672:9): [True: 0, False: 844]
  ------------------
 2673|      0|        mp_info(log, "Available formats:");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2674|      0|        for (int i = 1; i < AF_FORMAT_COUNT; i++)
  ------------------
  |  Branch (2674:25): [True: 0, False: 0]
  ------------------
 2675|      0|            mp_info(log, " %s", af_fmt_to_str(i));
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2676|      0|        mp_info(log, "\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2677|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 2678|      0|    }
 2679|       |
 2680|    844|    int fmt = 0;
 2681|  18.5k|    for (int i = 1; i < AF_FORMAT_COUNT; i++) {
  ------------------
  |  Branch (2681:21): [True: 17.7k, False: 844]
  ------------------
 2682|  17.7k|        if (bstr_equals0(param, af_fmt_to_str(i)))
  ------------------
  |  Branch (2682:13): [True: 0, False: 17.7k]
  ------------------
 2683|      0|            fmt = i;
 2684|  17.7k|    }
 2685|    844|    if (!fmt) {
  ------------------
  |  Branch (2685:9): [True: 844, False: 0]
  ------------------
 2686|    844|        mp_err(log, "Option %.*s: unknown format name: '%.*s'\n",
  ------------------
  |  |   76|  3.37k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 844, False: 0]
  |  |  |  Branch (76:55): [True: 844, False: 0]
  |  |  ------------------
  ------------------
 2687|    844|               BSTR_P(name), BSTR_P(param));
 2688|    844|        return M_OPT_INVALID;
  ------------------
  |  |  535|    844|#define M_OPT_INVALID           -3
  ------------------
 2689|    844|    }
 2690|       |
 2691|      0|    if (dst)
  ------------------
  |  Branch (2691:9): [True: 0, False: 0]
  ------------------
 2692|      0|        *((int *)dst) = fmt;
 2693|       |
 2694|      0|    return 1;
 2695|    844|}
m_option.c:parse_channels:
 2716|  4.62k|{
 2717|  4.62k|    bool limited = opt->flags & M_OPT_CHANNELS_LIMITED;
  ------------------
  |  |  491|  4.62k|#define M_OPT_CHANNELS_LIMITED  (UINT64_C(1) << 56)
  ------------------
 2718|       |
 2719|  4.62k|    struct m_channels res = {0};
 2720|       |
 2721|  4.62k|    if (bstr_equals0(param, "help")) {
  ------------------
  |  Branch (2721:9): [True: 0, False: 4.62k]
  ------------------
 2722|      0|        mp_chmap_print_help(log);
 2723|      0|        if (!limited) {
  ------------------
  |  Branch (2723:13): [True: 0, False: 0]
  ------------------
 2724|      0|            mp_info(log, "\nOther values:\n"
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 2725|      0|                         "    auto-safe\n");
 2726|      0|        }
 2727|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 2728|      0|    }
 2729|       |
 2730|  4.62k|    bool auto_safe = bstr_equals0(param, "auto-safe");
 2731|  4.62k|    if (bstr_equals0(param, "auto") || bstr_equals0(param, "empty") || auto_safe) {
  ------------------
  |  Branch (2731:9): [True: 0, False: 4.62k]
  |  Branch (2731:40): [True: 0, False: 4.62k]
  |  Branch (2731:72): [True: 0, False: 4.62k]
  ------------------
 2732|      0|        if (limited) {
  ------------------
  |  Branch (2732:13): [True: 0, False: 0]
  ------------------
 2733|      0|            mp_err(log, "Disallowed parameter.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 2734|      0|            return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 2735|      0|        }
 2736|      0|        param.len = 0;
 2737|      0|        res.set = true;
 2738|      0|        res.auto_safe = auto_safe;
 2739|      0|    }
 2740|       |
 2741|  8.40k|    while (param.len) {
  ------------------
  |  Branch (2741:12): [True: 4.62k, False: 3.78k]
  ------------------
 2742|  4.62k|        bstr item;
 2743|  4.62k|        if (limited) {
  ------------------
  |  Branch (2743:13): [True: 4.62k, False: 0]
  ------------------
 2744|  4.62k|            item = param;
 2745|  4.62k|            param.len = 0;
 2746|  4.62k|        } else {
 2747|      0|            bstr_split_tok(param, ",", &item, &param);
 2748|      0|        }
 2749|       |
 2750|  4.62k|        struct mp_chmap map = {0};
 2751|  4.62k|        if (!mp_chmap_from_str(&map, item) || !mp_chmap_is_valid(&map)) {
  ------------------
  |  Branch (2751:13): [True: 832, False: 3.78k]
  |  Branch (2751:47): [True: 0, False: 3.78k]
  ------------------
 2752|    832|            mp_err(log, "Invalid channel layout: %.*s\n", BSTR_P(item));
  ------------------
  |  |   76|  1.66k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 832, False: 0]
  |  |  ------------------
  ------------------
 2753|    832|            talloc_free(res.chmaps);
  ------------------
  |  |   47|    832|#define talloc_free                     ta_free
  ------------------
 2754|    832|            return M_OPT_INVALID;
  ------------------
  |  |  535|    832|#define M_OPT_INVALID           -3
  ------------------
 2755|    832|        }
 2756|       |
 2757|  3.78k|        MP_TARRAY_APPEND(NULL, res.chmaps, res.num_chmaps, map);
  ------------------
  |  |  105|  3.78k|    do {                                            \
  |  |  106|  3.78k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  3.78k|    do {                                            \
  |  |  |  |   97|  3.78k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  3.78k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.78k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  3.78k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3.78k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.78k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  3.78k|    do {                                                        \
  |  |  |  |  |  |   89|  3.78k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  3.78k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  3.78k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.78k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.78k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  3.78k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  3.78k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3.78k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  3.78k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  3.78k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  3.78k|        (idxvar)++;                                 \
  |  |  109|  3.78k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.78k]
  |  |  ------------------
  ------------------
 2758|  3.78k|        res.set = true;
 2759|  3.78k|    }
 2760|       |
 2761|  3.78k|    if (dst) {
  ------------------
  |  Branch (2761:9): [True: 3.78k, False: 0]
  ------------------
 2762|  3.78k|        opt->type->free(dst);
 2763|  3.78k|        *(struct m_channels *)dst = res;
 2764|  3.78k|    } else {
 2765|      0|        talloc_free(res.chmaps);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2766|      0|    }
 2767|       |
 2768|  3.78k|    return 1;
 2769|  4.62k|}
m_option.c:copy_channels:
 2801|   468k|{
 2802|   468k|    if (!(dst && src))
  ------------------
  |  Branch (2802:11): [True: 468k, False: 0]
  |  Branch (2802:18): [True: 468k, False: 0]
  ------------------
 2803|      0|        return;
 2804|       |
 2805|   468k|    struct m_channels *ch = dst;
 2806|   468k|    free_channels(dst);
 2807|   468k|    *ch = *(struct m_channels *)src;
 2808|   468k|    ch->chmaps =
 2809|   468k|        talloc_memdup(NULL, ch->chmaps, sizeof(ch->chmaps[0]) * ch->num_chmaps);
  ------------------
  |  |   49|   468k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   468k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   468k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   468k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   468k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2810|   468k|}
m_option.c:free_channels:
 2791|   939k|{
 2792|   939k|    if (!src)
  ------------------
  |  Branch (2792:9): [True: 0, False: 939k]
  ------------------
 2793|      0|        return;
 2794|       |
 2795|   939k|    struct m_channels *ch = src;
 2796|   939k|    talloc_free(ch->chmaps);
  ------------------
  |  |   47|   939k|#define talloc_free                     ta_free
  ------------------
 2797|   939k|    *ch = (struct m_channels){0};
 2798|   939k|}
m_option.c:channels_equal:
 2813|  83.9k|{
 2814|  83.9k|    struct m_channels *ca = a;
 2815|  83.9k|    struct m_channels *cb = b;
 2816|       |
 2817|  83.9k|    if (ca->set         != cb->set ||
  ------------------
  |  Branch (2817:9): [True: 1.77k, False: 82.1k]
  ------------------
 2818|  82.1k|        ca->auto_safe   != cb->auto_safe ||
  ------------------
  |  Branch (2818:9): [True: 0, False: 82.1k]
  ------------------
 2819|  82.1k|        ca->num_chmaps  != cb->num_chmaps)
  ------------------
  |  Branch (2819:9): [True: 0, False: 82.1k]
  ------------------
 2820|  1.77k|        return false;
 2821|       |
 2822|  82.1k|    for (int n = 0; n < ca->num_chmaps; n++) {
  ------------------
  |  Branch (2822:21): [True: 23, False: 82.1k]
  ------------------
 2823|     23|        if (!mp_chmap_equals(&ca->chmaps[n], &cb->chmaps[n]))
  ------------------
  |  Branch (2823:13): [True: 0, False: 23]
  ------------------
 2824|      0|            return false;
 2825|     23|    }
 2826|       |
 2827|  82.1k|    return true;
 2828|  82.1k|}
m_option.c:parse_time:
 2879|  52.7k|{
 2880|  52.7k|    if (param.len == 0)
  ------------------
  |  Branch (2880:9): [True: 73, False: 52.6k]
  ------------------
 2881|     73|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|     73|#define M_OPT_MISSING_PARAM     -2
  ------------------
 2882|       |
 2883|  52.6k|    double time = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  52.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2884|  52.6k|    if (HAS_NOPTS(opt) && bstr_equals0(param, "no")) {
  ------------------
  |  | 2875|   105k|#define HAS_NOPTS(opt) ((opt)->flags & M_OPT_ALLOW_NO)
  |  |  ------------------
  |  |  |  |  488|  52.6k|#define M_OPT_ALLOW_NO          (UINT64_C(1) << 57)
  |  |  ------------------
  |  |  |  Branch (2875:24): [True: 291, False: 52.3k]
  |  |  ------------------
  ------------------
  |  Branch (2884:27): [True: 0, False: 291]
  ------------------
 2885|       |        // nothing
 2886|  52.6k|    } else if (!parse_timestring(param, &time, 0)) {
  ------------------
  |  Branch (2886:16): [True: 11.7k, False: 40.9k]
  ------------------
 2887|  11.7k|        mp_err(log, "Option %.*s: invalid time: '%.*s'\n",
  ------------------
  |  |   76|  46.8k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 11.7k, False: 0]
  |  |  |  Branch (76:55): [True: 11.7k, False: 0]
  |  |  ------------------
  ------------------
 2888|  11.7k|               BSTR_P(name), BSTR_P(param));
 2889|  11.7k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  11.7k|#define M_OPT_INVALID           -3
  ------------------
 2890|  11.7k|    }
 2891|       |
 2892|  40.9k|    if (dst)
  ------------------
  |  Branch (2892:9): [True: 40.9k, False: 0]
  ------------------
 2893|  40.9k|        *(double *)dst = time;
 2894|  40.9k|    return 1;
 2895|  52.6k|}
m_option.c:parse_timestring:
 2841|  52.7k|{
 2842|  52.7k|    int len;
 2843|  52.7k|    unsigned h, m;
 2844|  52.7k|    double s;
 2845|  52.7k|    *time = 0; /* ensure initialization for error cases */
 2846|  52.7k|    bool neg = bstr_eatstart0(&str, "-");
 2847|  52.7k|    if (!neg)
  ------------------
  |  Branch (2847:9): [True: 31.4k, False: 21.3k]
  ------------------
 2848|  31.4k|        bstr_eatstart0(&str, "+");
 2849|  52.7k|    bool sci = bstr_find0(str, "e-") >= 0 || bstr_find0(str, "e+") >= 0;
  ------------------
  |  Branch (2849:16): [True: 307, False: 52.4k]
  |  Branch (2849:46): [True: 8, False: 52.4k]
  ------------------
 2850|       |    /* non-scientific notation timestamps shouldn't contain anymore +/- after this point */
 2851|  52.7k|    if (!sci && (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0))
  ------------------
  |  Branch (2851:9): [True: 52.4k, False: 315]
  |  Branch (2851:18): [True: 876, False: 51.5k]
  |  Branch (2851:44): [True: 2.43k, False: 49.1k]
  ------------------
 2852|  3.31k|        return 0;
 2853|  49.4k|    if (bstr_sscanf(str, "%u:%u:%lf%n", &h, &m, &s, &len) >= 3) {
  ------------------
  |  Branch (2853:9): [True: 326, False: 49.1k]
  ------------------
 2854|    326|        if (m >= 60 || s >= 60)
  ------------------
  |  Branch (2854:13): [True: 208, False: 118]
  |  Branch (2854:24): [True: 10, False: 108]
  ------------------
 2855|    218|            return 0; /* minutes or seconds are out of range */
 2856|    108|        *time = 3600.0 * h + 60 * m + s;
 2857|  49.1k|    } else if (bstr_sscanf(str, "%u:%lf%n", &m, &s, &len) >= 2) {
  ------------------
  |  Branch (2857:16): [True: 193, False: 48.9k]
  ------------------
 2858|    193|        if (s >= 60)
  ------------------
  |  Branch (2858:13): [True: 85, False: 108]
  ------------------
 2859|     85|            return 0; /* seconds are out of range */
 2860|    108|        *time = 60.0 * m + s;
 2861|  48.9k|    } else if (bstr_sscanf(str, "%lf%n", &s, &len) >= 1) {
  ------------------
  |  Branch (2861:16): [True: 42.8k, False: 6.08k]
  ------------------
 2862|  42.8k|        *time = s;
 2863|  42.8k|    } else {
 2864|  6.08k|        return 0;  /* unsupported time format */
 2865|  6.08k|    }
 2866|  43.0k|    if (len < str.len && str.start[len] != endchar)
  ------------------
  |  Branch (2866:9): [True: 2.08k, False: 40.9k]
  |  Branch (2866:26): [True: 2.08k, False: 0]
  ------------------
 2867|  2.08k|        return 0;  /* invalid extra characters at the end */
 2868|  40.9k|    if (!isfinite(*time))
  ------------------
  |  Branch (2868:9): [True: 20, False: 40.9k]
  ------------------
 2869|     20|        return 0;
 2870|  40.9k|    if (neg)
  ------------------
  |  Branch (2870:9): [True: 15.1k, False: 25.7k]
  ------------------
 2871|  15.1k|        *time = -*time;
 2872|  40.9k|    return len;
 2873|  40.9k|}
m_option.c:print_time:
 2898|  40.4k|{
 2899|  40.4k|    double pts = *(double *)val;
 2900|  40.4k|    if (pts == MP_NOPTS_VALUE && HAS_NOPTS(opt))
  ------------------
  |  |   39|  80.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (pts == MP_NOPTS_VALUE && HAS_NOPTS(opt))
  ------------------
  |  | 2875|    165|#define HAS_NOPTS(opt) ((opt)->flags & M_OPT_ALLOW_NO)
  |  |  ------------------
  |  |  |  |  488|    165|#define M_OPT_ALLOW_NO          (UINT64_C(1) << 57)
  |  |  ------------------
  |  |  |  Branch (2875:24): [True: 0, False: 165]
  |  |  ------------------
  ------------------
  |  Branch (2900:9): [True: 165, False: 40.2k]
  ------------------
 2901|      0|        return talloc_strdup(NULL, "no"); // symmetry with parsing
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2902|  40.4k|    return talloc_asprintf(NULL, "%f", pts);
  ------------------
  |  |   52|  40.4k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  40.4k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 2903|  40.4k|}
m_option.c:pretty_print_time:
 2906|  21.7k|{
 2907|  21.7k|    double pts = *(double *)val;
 2908|  21.7k|    if (pts == MP_NOPTS_VALUE && HAS_NOPTS(opt))
  ------------------
  |  |   39|  43.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (pts == MP_NOPTS_VALUE && HAS_NOPTS(opt))
  ------------------
  |  | 2875|  10.4k|#define HAS_NOPTS(opt) ((opt)->flags & M_OPT_ALLOW_NO)
  |  |  ------------------
  |  |  |  |  488|  10.4k|#define M_OPT_ALLOW_NO          (UINT64_C(1) << 57)
  |  |  ------------------
  |  |  |  Branch (2875:24): [True: 10.4k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2908:9): [True: 10.4k, False: 11.3k]
  ------------------
 2909|  10.4k|        return talloc_strdup(NULL, "no"); // symmetry with parsing
  ------------------
  |  |   50|  10.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
 2910|  11.3k|    return mp_format_time(pts, false);
 2911|  21.7k|}
m_option.c:parse_rel_time:
 2953|    108|{
 2954|    108|    struct m_rel_time t = {0};
 2955|       |
 2956|    108|    if (param.len == 0)
  ------------------
  |  Branch (2956:9): [True: 1, False: 107]
  ------------------
 2957|      1|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      1|#define M_OPT_MISSING_PARAM     -2
  ------------------
 2958|       |
 2959|    107|    if (bstr_equals0(param, "none")) {
  ------------------
  |  Branch (2959:9): [True: 0, False: 107]
  ------------------
 2960|      0|        t.type = REL_TIME_NONE;
 2961|      0|        goto out;
 2962|      0|    }
 2963|       |
 2964|       |    // Percent pos
 2965|    107|    if (bstr_endswith0(param, "%")) {
  ------------------
  |  Branch (2965:9): [True: 4, False: 103]
  ------------------
 2966|      4|        double percent = bstrtod(bstr_splice(param, 0, -1), &param);
 2967|      4|        if (param.len == 0 && percent >= 0 && percent <= 100) {
  ------------------
  |  Branch (2967:13): [True: 0, False: 4]
  |  Branch (2967:31): [True: 0, False: 0]
  |  Branch (2967:47): [True: 0, False: 0]
  ------------------
 2968|      0|            t.type = REL_TIME_PERCENT;
 2969|      0|            t.pos = percent;
 2970|      0|            goto out;
 2971|      0|        }
 2972|      4|    }
 2973|       |
 2974|       |    // Chapter pos
 2975|    107|    if (bstr_startswith0(param, "#")) {
  ------------------
  |  Branch (2975:9): [True: 0, False: 107]
  ------------------
 2976|      0|        int chapter = bstrtoll(bstr_cut(param, 1), &param, 10);
 2977|      0|        if (param.len == 0 && chapter >= 1) {
  ------------------
  |  Branch (2977:13): [True: 0, False: 0]
  |  Branch (2977:31): [True: 0, False: 0]
  ------------------
 2978|      0|            t.type = REL_TIME_CHAPTER;
 2979|      0|            t.pos = chapter - 1;
 2980|      0|            goto out;
 2981|      0|        }
 2982|      0|    }
 2983|       |
 2984|    107|    double time;
 2985|    107|    if (parse_timestring(param, &time, 0)) {
  ------------------
  |  Branch (2985:9): [True: 6, False: 101]
  ------------------
 2986|      6|        if (bstr_startswith0(param, "+") || bstr_startswith0(param, "-")) {
  ------------------
  |  Branch (2986:13): [True: 0, False: 6]
  |  Branch (2986:45): [True: 1, False: 5]
  ------------------
 2987|      1|            t.type = REL_TIME_RELATIVE;
 2988|      5|        } else {
 2989|      5|            t.type = REL_TIME_ABSOLUTE;
 2990|      5|        }
 2991|      6|        t.pos = time;
 2992|      6|        goto out;
 2993|      6|    }
 2994|       |
 2995|    101|    mp_err(log, "Option %.*s: invalid time or position: '%.*s'\n",
  ------------------
  |  |   76|    404|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 101, False: 0]
  |  |  |  Branch (76:55): [True: 101, False: 0]
  |  |  ------------------
  ------------------
 2996|    101|           BSTR_P(name), BSTR_P(param));
 2997|    101|    return M_OPT_INVALID;
  ------------------
  |  |  535|    101|#define M_OPT_INVALID           -3
  ------------------
 2998|       |
 2999|      6|out:
 3000|      6|    if (dst)
  ------------------
  |  Branch (3000:9): [True: 6, False: 0]
  ------------------
 3001|      6|        *(struct m_rel_time *)dst = t;
 3002|      6|    return 1;
 3003|    107|}
m_option.c:print_rel_time:
 3006|      2|{
 3007|      2|    const struct m_rel_time *t = val;
 3008|      2|    switch(t->type) {
  ------------------
  |  Branch (3008:12): [True: 2, False: 0]
  ------------------
 3009|      2|    case REL_TIME_ABSOLUTE:
  ------------------
  |  Branch (3009:5): [True: 2, False: 0]
  ------------------
 3010|      2|        return talloc_asprintf(NULL, "%g", t->pos);
  ------------------
  |  |   52|      2|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      2|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3011|      0|    case REL_TIME_RELATIVE:
  ------------------
  |  Branch (3011:5): [True: 0, False: 2]
  ------------------
 3012|      0|        return talloc_asprintf(NULL, "%+g", t->pos);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3013|      0|    case REL_TIME_CHAPTER:
  ------------------
  |  Branch (3013:5): [True: 0, False: 2]
  ------------------
 3014|      0|        return talloc_asprintf(NULL, "#%g", t->pos + 1);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3015|      0|    case REL_TIME_PERCENT:
  ------------------
  |  Branch (3015:5): [True: 0, False: 2]
  ------------------
 3016|      0|        return talloc_asprintf(NULL, "%g%%", t->pos);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3017|      2|    }
 3018|      0|    return talloc_strdup(NULL, "none");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3019|      2|}
m_option.c:rel_time_equal:
 3022|   230k|{
 3023|   230k|    struct m_rel_time *ta = a;
 3024|   230k|    struct m_rel_time *tb = b;
 3025|   230k|    return ta->type == tb->type && ta->pos == tb->pos;
  ------------------
  |  Branch (3025:12): [True: 230k, False: 6]
  |  Branch (3025:36): [True: 230k, False: 0]
  ------------------
 3026|   230k|}
m_option.c:parse_obj_settings_list:
 3510|  89.5k|{
 3511|  89.5k|    m_obj_settings_t *res = NULL;
 3512|  89.5k|    int op = OP_NONE;
  ------------------
  |  | 1323|  89.5k|#define OP_NONE 0
  ------------------
 3513|  89.5k|    bool *mark_del = NULL;
 3514|  89.5k|    int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0);
  ------------------
  |  | 3041|  89.5k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3514:49): [True: 89.5k, False: 0]
  ------------------
 3515|  89.5k|    const struct m_obj_list *ol = opt->priv;
 3516|  89.5k|    int ret = 1;
 3517|       |
 3518|  89.5k|    mp_assert(opt->priv);
  ------------------
  |  |   41|  89.5k|#define mp_assert assert
  ------------------
  |  Branch (3518:5): [True: 89.5k, False: 0]
  ------------------
 3519|       |
 3520|  89.5k|    if (bstr_endswith0(name, "-add")) {
  ------------------
  |  Branch (3520:9): [True: 647, False: 88.8k]
  ------------------
 3521|    647|        op = OP_ADD;
  ------------------
  |  | 1324|    647|#define OP_ADD 1
  ------------------
 3522|  88.8k|    } else if (bstr_endswith0(name, "-append")) {
  ------------------
  |  Branch (3522:16): [True: 16, False: 88.8k]
  ------------------
 3523|     16|        op = OP_APPEND;
  ------------------
  |  | 1329|     16|#define OP_APPEND 6
  ------------------
 3524|  88.8k|    } else if (bstr_endswith0(name, "-set")) {
  ------------------
  |  Branch (3524:16): [True: 68, False: 88.7k]
  ------------------
 3525|     68|        op = OP_NONE;
  ------------------
  |  | 1323|     68|#define OP_NONE 0
  ------------------
 3526|  88.7k|    } else if (bstr_endswith0(name, "-pre")) {
  ------------------
  |  Branch (3526:16): [True: 20, False: 88.7k]
  ------------------
 3527|     20|        op = OP_PRE;
  ------------------
  |  | 1325|     20|#define OP_PRE 2
  ------------------
 3528|  88.7k|    } else if (bstr_endswith0(name, "-remove")) {
  ------------------
  |  Branch (3528:16): [True: 2.50k, False: 86.2k]
  ------------------
 3529|  2.50k|        op = OP_REMOVE;
  ------------------
  |  | 1330|  2.50k|#define OP_REMOVE 7
  ------------------
 3530|  86.2k|    } else if (bstr_endswith0(name, "-clr")) {
  ------------------
  |  Branch (3530:16): [True: 0, False: 86.2k]
  ------------------
 3531|      0|        op = OP_CLR;
  ------------------
  |  | 1326|      0|#define OP_CLR 3
  ------------------
 3532|  86.2k|    } else if (bstr_endswith0(name, "-toggle")) {
  ------------------
  |  Branch (3532:16): [True: 0, False: 86.2k]
  ------------------
 3533|      0|        op = OP_TOGGLE;
  ------------------
  |  | 1328|      0|#define OP_TOGGLE 5
  ------------------
 3534|  86.2k|    } else if (bstr_endswith0(name, "-help")) {
  ------------------
  |  Branch (3534:16): [True: 1, False: 86.2k]
  ------------------
 3535|      1|        mp_err(log, "Option %s:\n"
  ------------------
  |  |   76|      1|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3536|      1|                "Supported operations are:\n"
 3537|      1|                "  %s-set\n"
 3538|      1|                " Overwrite the old list with the given list\n\n"
 3539|      1|                "  %s-append\n"
 3540|      1|                " Append the given item to the current list\n\n"
 3541|      1|                "  %s-add\n"
 3542|      1|                " Append the given list to the current list\n\n"
 3543|      1|                "  %s-pre\n"
 3544|      1|                " Prepend the given list to the current list\n\n"
 3545|      1|                "  %s-remove\n"
 3546|      1|                " Remove the given item from the current list\n\n"
 3547|      1|                "  %s-toggle\n"
 3548|      1|                " Add the item to the list, or remove it if it's already added.\n\n"
 3549|      1|                "  %s-clr\n"
 3550|      1|                " Clear the current list.\n\n",
 3551|      1|                opt->name, opt->name, opt->name, opt->name, opt->name,
 3552|      1|                opt->name, opt->name, opt->name);
 3553|       |
 3554|      1|        ret = M_OPT_EXIT;
  ------------------
  |  |  545|      1|#define M_OPT_EXIT              -6
  ------------------
 3555|      1|        goto done;
 3556|      1|    }
 3557|       |
 3558|  89.5k|    if (!bstrcmp0(param, "help")) {
  ------------------
  |  Branch (3558:9): [True: 230, False: 89.2k]
  ------------------
 3559|    230|        mp_info(log, "Available %s:\n", ol->description);
  ------------------
  |  |   78|    230|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3560|  2.07k|        for (int n = 0; ; n++) {
 3561|  2.07k|            struct m_obj_desc desc;
 3562|  2.07k|            if (!ol->get_desc(&desc, n))
  ------------------
  |  Branch (3562:17): [True: 230, False: 1.84k]
  ------------------
 3563|    230|                break;
 3564|  1.84k|            if (!desc.hidden) {
  ------------------
  |  Branch (3564:17): [True: 1.84k, False: 0]
  ------------------
 3565|  1.84k|                mp_info(log, "  %-16s %s\n",
  ------------------
  |  |   78|  1.84k|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3566|  1.84k|                       desc.name, desc.description);
 3567|  1.84k|            }
 3568|  1.84k|        }
 3569|    230|        mp_info(log, "\n");
  ------------------
  |  |   78|    230|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3570|    230|        if (ol->print_help_list)
  ------------------
  |  Branch (3570:13): [True: 230, False: 0]
  ------------------
 3571|    230|            ol->print_help_list(log);
 3572|    230|        if (!ol->use_global_options) {
  ------------------
  |  Branch (3572:13): [True: 230, False: 0]
  ------------------
 3573|    230|            mp_info(log, "Get help on individual entries via: --%s=entry=help\n",
  ------------------
  |  |   78|    230|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
 3574|    230|                    opt->name);
 3575|    230|        }
 3576|    230|        ret = M_OPT_EXIT;
  ------------------
  |  |  545|    230|#define M_OPT_EXIT              -6
  ------------------
 3577|    230|        goto done;
 3578|    230|    }
 3579|       |
 3580|  89.2k|    if (op == OP_CLR) {
  ------------------
  |  | 1326|  89.2k|#define OP_CLR 3
  ------------------
  |  Branch (3580:9): [True: 0, False: 89.2k]
  ------------------
 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|  89.2k|    } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|  89.2k|#define OP_REMOVE 7
  ------------------
  |  Branch (3591:16): [True: 2.50k, False: 86.7k]
  ------------------
 3592|  2.50k|        mark_del = talloc_zero_array(NULL, bool, num_items + 1);
  ------------------
  |  |   30|  2.50k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  2.50k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  2.50k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3593|  2.50k|    }
 3594|       |
 3595|  89.2k|    if (op != OP_NONE && param.len == 0) {
  ------------------
  |  | 1323|   178k|#define OP_NONE 0
  ------------------
  |  Branch (3595:9): [True: 3.18k, False: 86.1k]
  |  Branch (3595:26): [True: 10, False: 3.17k]
  ------------------
 3596|     10|        ret = M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|     10|#define M_OPT_MISSING_PARAM     -2
  ------------------
 3597|     10|        goto done;
 3598|     10|    }
 3599|       |
 3600|   158k|    while (param.len > 0) {
  ------------------
  |  Branch (3600:12): [True: 88.5k, False: 69.6k]
  ------------------
 3601|  88.5k|        int r = 0;
 3602|  88.5k|        if (op == OP_REMOVE)
  ------------------
  |  | 1330|  88.5k|#define OP_REMOVE 7
  ------------------
  |  Branch (3602:13): [True: 2.49k, False: 86.0k]
  ------------------
 3603|  2.49k|            r = parse_obj_settings_del(log, name, &param, dst, mark_del);
 3604|  88.5k|        if (r == 0) {
  ------------------
  |  Branch (3604:13): [True: 88.3k, False: 154]
  ------------------
 3605|  88.3k|            r = parse_obj_settings(log, name, op, &param, ol, dst ? &res : NULL);
  ------------------
  |  Branch (3605:63): [True: 88.3k, False: 0]
  ------------------
 3606|  88.3k|        }
 3607|  88.5k|        if (r < 0) {
  ------------------
  |  Branch (3607:13): [True: 19.0k, False: 69.5k]
  ------------------
 3608|  19.0k|            free_obj_settings_list(&res);
 3609|  19.0k|            ret = r;
 3610|  19.0k|            goto done;
 3611|  19.0k|        }
 3612|  69.5k|        if (param.len > 0) {
  ------------------
  |  Branch (3612:13): [True: 607, False: 68.9k]
  ------------------
 3613|    607|            const char sep[2] = {OPTION_LIST_SEPARATOR, 0};
  ------------------
  |  |  644|    607|#define OPTION_LIST_SEPARATOR ','
  ------------------
 3614|    607|            if (!bstr_eatstart0(&param, sep)) {
  ------------------
  |  Branch (3614:17): [True: 584, False: 23]
  ------------------
 3615|    584|                free_obj_settings_list(&res);
 3616|    584|                ret = M_OPT_INVALID;
  ------------------
  |  |  535|    584|#define M_OPT_INVALID           -3
  ------------------
 3617|    584|                goto done;
 3618|    584|            }
 3619|     23|            if (param.len == 0) {
  ------------------
  |  Branch (3619:17): [True: 13, False: 10]
  ------------------
 3620|     13|                if (!ol->allow_trailer) {
  ------------------
  |  Branch (3620:21): [True: 13, False: 0]
  ------------------
 3621|     13|                    free_obj_settings_list(&res);
 3622|     13|                    ret = M_OPT_INVALID;
  ------------------
  |  |  535|     13|#define M_OPT_INVALID           -3
  ------------------
 3623|     13|                    goto done;
 3624|     13|                }
 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|     23|        }
 3634|  69.5k|    }
 3635|       |
 3636|  69.6k|    if (op != OP_NONE && res && res[0].name && res[1].name) {
  ------------------
  |  | 1323|   139k|#define OP_NONE 0
  ------------------
  |  Branch (3636:9): [True: 2.97k, False: 66.6k]
  |  Branch (3636:26): [True: 2.82k, False: 151]
  |  Branch (3636:33): [True: 2.82k, False: 0]
  |  Branch (3636:48): [True: 0, False: 2.82k]
  ------------------
 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|  69.6k|    if (dst) {
  ------------------
  |  Branch (3646:9): [True: 69.6k, False: 0]
  ------------------
 3647|  69.6k|        m_obj_settings_t *list = VAL(dst);
  ------------------
  |  | 3041|  69.6k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3648|  69.6k|        if (op == OP_PRE) {
  ------------------
  |  | 1325|  69.6k|#define OP_PRE 2
  ------------------
  |  Branch (3648:13): [True: 7, False: 69.6k]
  ------------------
 3649|      7|            int prepend_counter = 0;
 3650|     14|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3650:29): [True: 14, False: 0]
  |  Branch (3650:36): [True: 7, False: 7]
  ------------------
 3651|      7|                int label = obj_settings_list_find_by_label0(list, res[n].label);
 3652|      7|                if (label < 0) {
  ------------------
  |  Branch (3652:21): [True: 7, False: 0]
  ------------------
 3653|      7|                    if (!obj_settings_list_insert_at(log, &list, prepend_counter, &res[n]))
  ------------------
  |  Branch (3653:25): [True: 0, False: 7]
  ------------------
 3654|      0|                        obj_setting_free(&res[n]);
 3655|      7|                    prepend_counter++;
 3656|      7|                } 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|      7|            }
 3663|      7|            talloc_free(res);
  ------------------
  |  |   47|      7|#define talloc_free                     ta_free
  ------------------
 3664|  69.6k|        } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1324|   139k|#define OP_ADD 1
  ------------------
                      } else if (op == OP_ADD || op == OP_APPEND) {
  ------------------
  |  | 1329|  69.0k|#define OP_APPEND 6
  ------------------
  |  Branch (3664:20): [True: 601, False: 69.0k]
  |  Branch (3664:36): [True: 15, False: 69.0k]
  ------------------
 3665|  1.23k|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3665:29): [True: 1.23k, False: 0]
  |  Branch (3665:36): [True: 616, False: 616]
  ------------------
 3666|    616|                int label = obj_settings_list_find_by_label0(list, res[n].label);
 3667|    616|                if (label < 0) {
  ------------------
  |  Branch (3667:21): [True: 616, False: 0]
  ------------------
 3668|    616|                    if (!obj_settings_list_insert_at(log, &list, -1, &res[n]))
  ------------------
  |  Branch (3668:25): [True: 243, False: 373]
  ------------------
 3669|    243|                        obj_setting_free(&res[n]);
 3670|    616|                } 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|    616|            }
 3677|    616|            talloc_free(res);
  ------------------
  |  |   47|    616|#define talloc_free                     ta_free
  ------------------
 3678|  69.0k|        } else if (op == OP_TOGGLE) {
  ------------------
  |  | 1328|  69.0k|#define OP_TOGGLE 5
  ------------------
  |  Branch (3678:20): [True: 0, False: 69.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|  69.0k|        } else if (op == OP_REMOVE) {
  ------------------
  |  | 1330|  69.0k|#define OP_REMOVE 7
  ------------------
  |  Branch (3703:20): [True: 2.35k, False: 66.6k]
  ------------------
 3704|  3.27k|            for (int n = num_items - 1; n >= 0; n--) {
  ------------------
  |  Branch (3704:41): [True: 923, False: 2.35k]
  ------------------
 3705|    923|                if (mark_del[n])
  ------------------
  |  Branch (3705:21): [True: 0, False: 923]
  ------------------
 3706|      0|                    obj_settings_list_del_at(&list, n);
 3707|    923|            }
 3708|  4.55k|            for (int n = 0; res && res[n].name; n++) {
  ------------------
  |  Branch (3708:29): [True: 4.40k, False: 151]
  |  Branch (3708:36): [True: 2.20k, False: 2.20k]
  ------------------
 3709|  2.20k|                int found = obj_settings_find_by_content(list, &res[n]);
 3710|  2.20k|                if (found >= 0)
  ------------------
  |  Branch (3710:21): [True: 698, False: 1.50k]
  ------------------
 3711|    698|                    obj_settings_list_del_at(&list, found);
 3712|  2.20k|            }
 3713|  2.35k|            free_obj_settings_list(&res);
 3714|  66.6k|        } else {
 3715|  66.6k|            mp_assert(op == OP_NONE);
  ------------------
  |  |   41|  66.6k|#define mp_assert assert
  ------------------
  |  Branch (3715:13): [True: 66.6k, False: 0]
  ------------------
 3716|  66.6k|            free_obj_settings_list(&list);
 3717|  66.6k|            list = res;
 3718|  66.6k|        }
 3719|  69.6k|        VAL(dst) = list;
  ------------------
  |  | 3041|  69.6k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3720|  69.6k|    }
 3721|       |
 3722|  89.5k|done:
 3723|  89.5k|    talloc_free(mark_del);
  ------------------
  |  |   47|  89.5k|#define talloc_free                     ta_free
  ------------------
 3724|  89.5k|    return ret;
 3725|  69.6k|}
m_option.c:obj_settings_list_num_items:
 3082|   160k|{
 3083|   160k|    int num = 0;
 3084|   191k|    while (obj_list && obj_list[num].name)
  ------------------
  |  Branch (3084:12): [True: 59.8k, False: 131k]
  |  Branch (3084:24): [True: 31.4k, False: 28.3k]
  ------------------
 3085|  31.4k|        num++;
 3086|   160k|    return num;
 3087|   160k|}
m_option.c:parse_obj_settings_del:
 3482|  2.49k|{
 3483|  2.49k|    bstr s = *param;
 3484|  2.49k|    if (bstr_eatstart0(&s, "@")) {
  ------------------
  |  Branch (3484:9): [True: 223, False: 2.27k]
  ------------------
 3485|       |        // '@name:' -> parse as normal filter entry
 3486|       |        // '@name,' or '@name<end>' -> parse here
 3487|    223|        int idx = bstrspn(s, NAMECH);
  ------------------
  |  | 3383|    223|#define NAMECH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  ------------------
 3488|    223|        bstr label = bstr_splice(s, 0, idx);
 3489|    223|        s = bstr_cut(s, idx);
 3490|    223|        if (bstr_startswith0(s, ":"))
  ------------------
  |  Branch (3490:13): [True: 69, False: 154]
  ------------------
 3491|     69|            return 0;
 3492|    154|        if (dst) {
  ------------------
  |  Branch (3492:13): [True: 154, False: 0]
  ------------------
 3493|    154|            int label_index = 0;
 3494|    154|            label_index = obj_settings_list_find_by_label(VAL(dst), label);
  ------------------
  |  | 3041|    154|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3495|    154|            if (label_index >= 0) {
  ------------------
  |  Branch (3495:17): [True: 0, False: 154]
  ------------------
 3496|      0|                mark_del[label_index] = true;
 3497|    154|            } else {
 3498|    154|                mp_warn(log, "Option %.*s: item label @%.*s not found.\n",
  ------------------
  |  |   77|    616|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 154, False: 0]
  |  |  |  Branch (77:56): [True: 154, False: 0]
  |  |  ------------------
  ------------------
 3499|    154|                        BSTR_P(opt_name), BSTR_P(label));
 3500|    154|            }
 3501|    154|        }
 3502|    154|        *param = s;
 3503|    154|        return 1;
 3504|    223|    }
 3505|  2.27k|    return 0;
 3506|  2.49k|}
m_option.c:obj_settings_list_find_by_label:
 3141|    777|{
 3142|  3.88k|    for (int n = 0; obj_list && obj_list[n].name; n++) {
  ------------------
  |  Branch (3142:21): [True: 3.79k, False: 95]
  |  Branch (3142:33): [True: 3.11k, False: 682]
  ------------------
 3143|  3.11k|        if (label.len && bstr_equals0(label, obj_list[n].label))
  ------------------
  |  Branch (3143:13): [True: 37, False: 3.07k]
  |  Branch (3143:26): [True: 0, False: 37]
  ------------------
 3144|      0|            return n;
 3145|  3.11k|    }
 3146|    777|    return -1;
 3147|    777|}
m_option.c:parse_obj_settings:
 3389|  88.3k|{
 3390|  88.3k|    int r;
 3391|  88.3k|    char **plist = NULL;
 3392|  88.3k|    struct m_obj_desc desc;
 3393|  88.3k|    bstr str = {0};
 3394|  88.3k|    bstr label = {0};
 3395|  88.3k|    bool nopos = list->disallow_positional_parameters;
 3396|  88.3k|    bool enabled = true;
 3397|       |
 3398|  88.3k|    if (bstr_eatstart0(pstr, "@")) {
  ------------------
  |  Branch (3398:9): [True: 185, False: 88.2k]
  ------------------
 3399|    185|        bstr rest;
 3400|    185|        if (!bstr_split_tok(*pstr, ":", &label, &rest)) {
  ------------------
  |  Branch (3400:13): [True: 70, False: 115]
  ------------------
 3401|       |            // "@labelname" is the special enable/disable toggle syntax
 3402|     70|            if (op == OP_TOGGLE) {
  ------------------
  |  | 1328|     70|#define OP_TOGGLE 5
  ------------------
  |  Branch (3402:17): [True: 0, False: 70]
  ------------------
 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|     70|            mp_err(log, "Option %.*s: ':' expected after label.\n", BSTR_P(opt));
  ------------------
  |  |   76|    140|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 70, False: 0]
  |  |  ------------------
  ------------------
 3411|     70|            return M_OPT_INVALID;
  ------------------
  |  |  535|     70|#define M_OPT_INVALID           -3
  ------------------
 3412|     70|        }
 3413|    115|        *pstr = rest;
 3414|    115|        if (label.len == 0) {
  ------------------
  |  Branch (3414:13): [True: 75, False: 40]
  ------------------
 3415|     75|            mp_err(log, "Option %.*s: label name expected.\n", BSTR_P(opt));
  ------------------
  |  |   76|    150|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 75, False: 0]
  |  |  ------------------
  ------------------
 3416|     75|            return M_OPT_INVALID;
  ------------------
  |  |  535|     75|#define M_OPT_INVALID           -3
  ------------------
 3417|     75|        }
 3418|    115|    }
 3419|       |
 3420|  88.2k|    if (list->allow_disable_entries && bstr_eatstart0(pstr, "!"))
  ------------------
  |  Branch (3420:9): [True: 41.3k, False: 46.8k]
  |  Branch (3420:40): [True: 18, False: 41.3k]
  ------------------
 3421|     18|        enabled = false;
 3422|       |
 3423|  88.2k|    bool has_param = false;
 3424|  88.2k|    int idx = bstrspn(*pstr, NAMECH);
  ------------------
  |  | 3383|  88.2k|#define NAMECH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  ------------------
 3425|  88.2k|    str = bstr_splice(*pstr, 0, idx);
 3426|  88.2k|    if (!str.len) {
  ------------------
  |  Branch (3426:9): [True: 3.41k, False: 84.8k]
  ------------------
 3427|  3.41k|        mp_err(log, "Option %.*s: item name expected.\n", BSTR_P(opt));
  ------------------
  |  |   76|  6.82k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 3.41k, False: 0]
  |  |  ------------------
  ------------------
 3428|  3.41k|        return M_OPT_INVALID;
  ------------------
  |  |  535|  3.41k|#define M_OPT_INVALID           -3
  ------------------
 3429|  3.41k|    }
 3430|  84.8k|    *pstr = bstr_cut(*pstr, idx);
 3431|       |    // video filters use "=", VOs use ":"
 3432|  84.8k|    if (bstr_eatstart0(pstr, "=") || bstr_eatstart0(pstr, ":"))
  ------------------
  |  Branch (3432:9): [True: 2.34k, False: 82.4k]
  |  Branch (3432:38): [True: 16.8k, False: 65.6k]
  ------------------
 3433|  19.2k|        has_param = true;
 3434|       |
 3435|  84.8k|    bool skip = false;
 3436|  84.8k|    if (m_obj_list_find(&desc, list, str)) {
  ------------------
  |  Branch (3436:9): [True: 77.3k, False: 7.44k]
  ------------------
 3437|  77.3k|        if (desc.replaced_name)
  ------------------
  |  Branch (3437:13): [True: 0, False: 77.3k]
  ------------------
 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|  77.3k|                   desc.replaced_name, desc.name);
 3440|  77.3k|    } else {
 3441|  7.44k|        char name[80];
 3442|  7.44k|        snprintf(name, sizeof(name), "%.*s", BSTR_P(str));
  ------------------
  |  |  307|  7.44k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 7.44k, False: 0]
  |  |  ------------------
  ------------------
 3443|  7.44k|        if (list->check_unknown_entry && !list->check_unknown_entry(name)) {
  ------------------
  |  Branch (3443:13): [True: 7.37k, False: 67]
  |  Branch (3443:42): [True: 7.37k, False: 0]
  ------------------
 3444|  7.37k|            mp_err(log, "Option %.*s: '%.*s' isn't supported.\n",
  ------------------
  |  |   76|  29.5k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 7.37k, False: 0]
  |  |  |  Branch (76:55): [True: 7.37k, False: 0]
  |  |  ------------------
  ------------------
 3445|  7.37k|                   BSTR_P(opt), BSTR_P(str));
 3446|  7.37k|            return M_OPT_INVALID;
  ------------------
  |  |  535|  7.37k|#define M_OPT_INVALID           -3
  ------------------
 3447|  7.37k|        }
 3448|     67|        desc = (struct m_obj_desc){0};
 3449|     67|        skip = true;
 3450|     67|    }
 3451|       |
 3452|  77.4k|    if (has_param) {
  ------------------
  |  Branch (3452:9): [True: 16.4k, False: 61.0k]
  ------------------
 3453|  16.4k|        struct m_config *config = NULL;
 3454|  16.4k|        if (!skip)
  ------------------
  |  Branch (3454:13): [True: 16.4k, False: 3]
  ------------------
 3455|  16.4k|            config = m_config_from_obj_desc_noalloc(NULL, log, &desc);
 3456|  16.4k|        r = m_obj_parse_sub_config(log, opt, str, pstr, config,
 3457|  16.4k|                                   M_SETOPT_CHECK_ONLY, nopos, &desc, list,
 3458|  16.4k|                                   _ret ? &plist : NULL);
  ------------------
  |  Branch (3458:36): [True: 16.4k, False: 0]
  ------------------
 3459|  16.4k|        talloc_free(config);
  ------------------
  |  |   47|  16.4k|#define talloc_free                     ta_free
  ------------------
 3460|  16.4k|        if (r < 0)
  ------------------
  |  Branch (3460:13): [True: 8.09k, False: 8.35k]
  ------------------
 3461|  8.09k|            return r;
 3462|  16.4k|    }
 3463|  69.3k|    if (!_ret)
  ------------------
  |  Branch (3463:9): [True: 0, False: 69.3k]
  ------------------
 3464|      0|        return 1;
 3465|       |
 3466|  69.3k|done: ;
 3467|  69.3k|    m_obj_settings_t item = {
 3468|  69.3k|        .name = bstrto0(NULL, str),
 3469|  69.3k|        .label = bstrdup0(NULL, label),
 3470|  69.3k|        .enabled = enabled,
 3471|  69.3k|        .attribs = plist,
 3472|  69.3k|    };
 3473|  69.3k|    if (!obj_settings_list_insert_at(log, _ret, -1, &item))
  ------------------
  |  Branch (3473:9): [True: 0, False: 69.3k]
  ------------------
 3474|      0|        obj_setting_free(&item);
 3475|  69.3k|    return 1;
 3476|  69.3k|}
m_option.c:m_obj_parse_sub_config:
 3306|  16.4k|{
 3307|  16.4k|    int nold = 0;
 3308|  16.4k|    char **args = NULL;
 3309|  16.4k|    int num_args = 0;
 3310|  16.4k|    int r = 1;
 3311|  16.4k|    char tmp[80];
 3312|       |
 3313|  16.4k|    if (ret) {
  ------------------
  |  Branch (3313:9): [True: 16.4k, False: 0]
  ------------------
 3314|  16.4k|        args = *ret;
 3315|  16.4k|        while (args && args[num_args])
  ------------------
  |  Branch (3315:16): [True: 0, False: 16.4k]
  |  Branch (3315:24): [True: 0, False: 0]
  ------------------
 3316|      0|            num_args++;
 3317|  16.4k|    }
 3318|       |
 3319|  30.3k|    while (pstr->len > 0) {
  ------------------
  |  Branch (3319:12): [True: 22.9k, False: 7.42k]
  ------------------
 3320|  22.9k|        bstr fname, fval;
 3321|  22.9k|        r = split_subconf(log, opt_name, pstr, &fname, &fval);
 3322|  22.9k|        if (r < 0)
  ------------------
  |  Branch (3322:13): [True: 2.31k, False: 20.6k]
  ------------------
 3323|  2.31k|            goto exit;
 3324|       |
 3325|  20.6k|        if (list->use_global_options) {
  ------------------
  |  Branch (3325:13): [True: 3, False: 20.6k]
  ------------------
 3326|      3|            mp_err(log, "Option %.*s: this option does not accept sub-options.\n",
  ------------------
  |  |   76|      6|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 3, False: 0]
  |  |  ------------------
  ------------------
 3327|      3|                   BSTR_P(opt_name));
 3328|      3|            mp_err(log, "Sub-options for --vo and --ao were removed from mpv in "
  ------------------
  |  |   76|      3|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3329|      3|                   "release 0.23.0.\nSee https://0x0.st/uM for details.\n");
 3330|      3|            r = M_OPT_INVALID;
  ------------------
  |  |  535|      3|#define M_OPT_INVALID           -3
  ------------------
 3331|      3|            goto exit;
 3332|      3|        }
 3333|       |
 3334|  20.6k|        if (bstr_equals0(fname, "help"))
  ------------------
  |  Branch (3334:13): [True: 0, False: 20.6k]
  ------------------
 3335|      0|            goto print_help;
 3336|  20.6k|        r = get_obj_param(log, opt_name, name, config, fname, fval, flags,
 3337|  20.6k|                          nopos, &nold, &fname, &fval, tmp, sizeof(tmp));
 3338|  20.6k|        if (r < 0)
  ------------------
  |  Branch (3338:13): [True: 5.77k, False: 14.8k]
  ------------------
 3339|  5.77k|            goto exit;
 3340|       |
 3341|  14.8k|        if (r > 0 && ret) {
  ------------------
  |  Branch (3341:13): [True: 2.33k, False: 12.5k]
  |  Branch (3341:22): [True: 2.33k, False: 0]
  ------------------
 3342|  2.33k|            MP_TARRAY_APPEND(NULL, args, num_args, bstrto0(NULL, fname));
  ------------------
  |  |  105|  2.33k|    do {                                            \
  |  |  106|  2.33k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.33k|    do {                                            \
  |  |  |  |   97|  2.33k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.33k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.33k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.33k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.75k, False: 584]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.33k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.75k|    do {                                                        \
  |  |  |  |  |  |   89|  1.75k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.75k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.75k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.75k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.75k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.75k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.75k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.75k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  2.33k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  2.33k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  2.33k|        (idxvar)++;                                 \
  |  |  109|  2.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.33k]
  |  |  ------------------
  ------------------
 3343|  2.33k|            MP_TARRAY_APPEND(NULL, args, num_args, bstrto0(NULL, fval));
  ------------------
  |  |  105|  2.33k|    do {                                            \
  |  |  106|  2.33k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.33k|    do {                                            \
  |  |  |  |   97|  2.33k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.33k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.33k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.33k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 2.33k]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.33k|            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|  2.33k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  2.33k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  2.33k|        (idxvar)++;                                 \
  |  |  109|  2.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.33k]
  |  |  ------------------
  ------------------
 3344|  2.33k|            MP_TARRAY_APPEND(NULL, args, num_args, NULL);
  ------------------
  |  |  105|  2.33k|    do {                                            \
  |  |  106|  2.33k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.33k|    do {                                            \
  |  |  |  |   97|  2.33k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.33k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.33k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.33k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.75k, False: 583]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.33k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.75k|    do {                                                        \
  |  |  |  |  |  |   89|  1.75k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.75k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.75k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.75k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.75k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.75k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.75k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.75k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  2.33k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  2.33k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  2.33k|        (idxvar)++;                                 \
  |  |  109|  2.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.33k]
  |  |  ------------------
  ------------------
 3345|  2.33k|            MP_TARRAY_APPEND(NULL, args, num_args, NULL);
  ------------------
  |  |  105|  2.33k|    do {                                            \
  |  |  106|  2.33k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  2.33k|    do {                                            \
  |  |  |  |   97|  2.33k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  2.33k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  2.33k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  2.33k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 2.33k]
  |  |  |  |  ------------------
  |  |  |  |   99|  2.33k|            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|  2.33k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  2.33k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  2.33k|        (idxvar)++;                                 \
  |  |  109|  2.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.33k]
  |  |  ------------------
  ------------------
 3346|  2.33k|            num_args -= 2;
 3347|  2.33k|        }
 3348|       |
 3349|  14.8k|        if (!bstr_eatstart0(pstr, ":"))
  ------------------
  |  Branch (3349:13): [True: 930, False: 13.9k]
  ------------------
 3350|    930|            break;
 3351|  14.8k|    }
 3352|       |
 3353|  8.35k|    if (ret) {
  ------------------
  |  Branch (3353:9): [True: 8.35k, False: 0]
  ------------------
 3354|  8.35k|        if (num_args > 0) {
  ------------------
  |  Branch (3354:13): [True: 1.37k, False: 6.97k]
  ------------------
 3355|  1.37k|            *ret = args;
 3356|  1.37k|            args = NULL;
 3357|  6.97k|        } else {
 3358|  6.97k|            *ret = NULL;
 3359|  6.97k|        }
 3360|  8.35k|    }
 3361|       |
 3362|  8.35k|    goto exit;
 3363|       |
 3364|      0|print_help: ;
 3365|      0|    if (config) {
  ------------------
  |  Branch (3365:9): [True: 0, False: 0]
  ------------------
 3366|      0|        if (desc->print_help)
  ------------------
  |  Branch (3366:13): [True: 0, False: 0]
  ------------------
 3367|      0|            desc->print_help(log);
 3368|      0|        m_config_print_option_list(config, "*");
 3369|      0|    } else if (list->print_unknown_entry_help) {
  ------------------
  |  Branch (3369:16): [True: 0, False: 0]
  ------------------
 3370|      0|        list->print_unknown_entry_help(log, mp_tprintf(80, "%.*s", BSTR_P(name)));
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (195:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3371|      0|    } else {
 3372|      0|        mp_warn(log, "Option %.*s: item '%.*s' isn't supported.\n",
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (77:56): [True: 0, False: 0]
  |  |  |  Branch (77:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3373|      0|               BSTR_P(opt_name), BSTR_P(name));
 3374|      0|    }
 3375|      0|    r = M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
 3376|       |
 3377|  16.4k|exit:
 3378|  16.4k|    free_str_list(&args);
 3379|  16.4k|    return r;
 3380|      0|}
m_option.c:split_subconf:
 2140|  22.9k|{
 2141|  22.9k|    bstr p = *str;
 2142|  22.9k|    bstr subparam = {0};
 2143|  22.9k|    bstr subopt;
 2144|  22.9k|    int r = read_subparam(log, optname, ":=,\\%\"'[]", &p, &subopt);
 2145|  22.9k|    if (r < 0)
  ------------------
  |  Branch (2145:9): [True: 2.30k, False: 20.6k]
  ------------------
 2146|  2.30k|        return r;
 2147|  20.6k|    if (bstr_eatstart0(&p, "=")) {
  ------------------
  |  Branch (2147:9): [True: 29, False: 20.6k]
  ------------------
 2148|     29|        r = read_subparam(log, subopt, ":=,\\%\"'[]", &p, &subparam);
 2149|     29|        if (r < 0)
  ------------------
  |  Branch (2149:13): [True: 8, False: 21]
  ------------------
 2150|      8|            return r;
 2151|     29|    }
 2152|  20.6k|    *str = p;
 2153|  20.6k|    *out_name = subopt;
 2154|  20.6k|    *out_val = subparam;
 2155|  20.6k|    return 0;
 2156|  20.6k|}
m_option.c:get_obj_param:
 3220|  20.6k|{
 3221|  20.6k|    int r;
 3222|       |
 3223|  20.6k|    if (!config) {
  ------------------
  |  Branch (3223:9): [True: 0, False: 20.6k]
  ------------------
 3224|       |        // Duplicates the logic below, but with unknown parameter types/names.
 3225|      0|        if (val.start || nopos) {
  ------------------
  |  Branch (3225:13): [True: 0, False: 0]
  |  Branch (3225:26): [True: 0, False: 0]
  ------------------
 3226|      0|            *out_name = name;
 3227|      0|            *out_val = val;
 3228|      0|        } else {
 3229|      0|            val = name;
 3230|       |            // positional fields
 3231|      0|            if (val.len == 0) { // Empty field, count it and go on
  ------------------
  |  Branch (3231:17): [True: 0, False: 0]
  ------------------
 3232|      0|                (*nold)++;
 3233|      0|                return 0;
 3234|      0|            }
 3235|       |            // Positional naming convention for/followed by mp_set_avopts().
 3236|      0|            snprintf(tmp, tmp_size, "@%d", *nold);
 3237|      0|            *out_name = bstr0(tmp);
 3238|      0|            *out_val = val;
 3239|      0|            (*nold)++;
 3240|      0|        }
 3241|      0|        return 1;
 3242|      0|    }
 3243|       |
 3244|       |    // val.start != NULL => of the form name=val (not positional)
 3245|       |    // If it's just "name", and the associated option exists and is a flag,
 3246|       |    // don't accept it as positional argument.
 3247|  20.6k|    if (val.start || m_config_option_requires_param(config, name) == 0 || nopos) {
  ------------------
  |  Branch (3247:9): [True: 21, False: 20.6k]
  |  Branch (3247:22): [True: 0, False: 20.6k]
  |  Branch (3247:75): [True: 0, False: 20.6k]
  ------------------
 3248|     21|        r = m_config_set_option_cli(config, name, val, flags);
 3249|     21|        if (r < 0) {
  ------------------
  |  Branch (3249:13): [True: 21, False: 0]
  ------------------
 3250|     21|            if (r == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|     21|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (3250:17): [True: 0, False: 21]
  ------------------
 3251|      0|                mp_err(log, "Option %.*s: %.*s doesn't have a %.*s parameter.\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]
  |  |  ------------------
  ------------------
 3252|      0|                       BSTR_P(opt_name), BSTR_P(obj_name), BSTR_P(name));
 3253|      0|                return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
 3254|      0|            }
 3255|     21|            if (r != M_OPT_EXIT)
  ------------------
  |  |  545|     21|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (3255:17): [True: 21, False: 0]
  ------------------
 3256|     21|                mp_err(log, "Option %.*s: "
  ------------------
  |  |   76|    168|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 21, False: 0]
  |  |  |  Branch (76:55): [True: 21, False: 0]
  |  |  |  Branch (76:55): [True: 21, False: 0]
  |  |  |  Branch (76:55): [True: 21, False: 0]
  |  |  ------------------
  ------------------
 3257|     21|                       "Error while parsing %.*s parameter %.*s (%.*s)\n",
 3258|     21|                       BSTR_P(opt_name), BSTR_P(obj_name), BSTR_P(name),
 3259|     21|                       BSTR_P(val));
 3260|     21|            return r;
 3261|     21|        }
 3262|      0|        *out_name = name;
 3263|      0|        *out_val = val;
 3264|      0|        return 1;
 3265|  20.6k|    } else {
 3266|  20.6k|        val = name;
 3267|       |        // positional fields
 3268|  20.6k|        if (val.len == 0) { // Empty field, count it and go on
  ------------------
  |  Branch (3268:13): [True: 12.5k, False: 8.09k]
  ------------------
 3269|  12.5k|            (*nold)++;
 3270|  12.5k|            return 0;
 3271|  12.5k|        }
 3272|  8.09k|        const char *opt = m_config_get_positional_option(config, *nold);
 3273|  8.09k|        if (!opt) {
  ------------------
  |  Branch (3273:13): [True: 58, False: 8.03k]
  ------------------
 3274|     58|            mp_err(log, "Option %.*s: %.*s has only %d "
  ------------------
  |  |   76|    232|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 58, False: 0]
  |  |  |  Branch (76:55): [True: 58, False: 0]
  |  |  ------------------
  ------------------
 3275|     58|                   "params, so you can't give more than %d unnamed params.\n",
 3276|     58|                   BSTR_P(opt_name), BSTR_P(obj_name), *nold, *nold);
 3277|     58|            return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|     58|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
 3278|     58|        }
 3279|  8.03k|        r = m_config_set_option_cli(config, bstr0(opt), val, flags);
 3280|  8.03k|        if (r < 0) {
  ------------------
  |  Branch (3280:13): [True: 5.69k, False: 2.33k]
  ------------------
 3281|  5.69k|            if (r != M_OPT_EXIT)
  ------------------
  |  |  545|  5.69k|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (3281:17): [True: 5.69k, False: 0]
  ------------------
 3282|  5.69k|                mp_err(log, "Option %.*s: "
  ------------------
  |  |   76|  34.1k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (76:55): [True: 5.69k, False: 0]
  |  |  |  Branch (76:55): [True: 5.69k, False: 0]
  |  |  |  Branch (76:55): [True: 5.69k, False: 0]
  |  |  ------------------
  ------------------
 3283|  5.69k|                       "Error while parsing %.*s parameter %s (%.*s)\n",
 3284|  5.69k|                       BSTR_P(opt_name), BSTR_P(obj_name), opt, BSTR_P(val));
 3285|  5.69k|            return r;
 3286|  5.69k|        }
 3287|  2.33k|        *out_name = bstr0(opt);
 3288|  2.33k|        *out_val = val;
 3289|  2.33k|        (*nold)++;
 3290|  2.33k|        return 1;
 3291|  8.03k|    }
 3292|  20.6k|}
m_option.c:obj_settings_list_insert_at:
 3117|  69.9k|{
 3118|  69.9k|    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|  69.9k|    if (num >= OBJ_SETTINGS_LIST_MAX) {
  ------------------
  |  | 3106|  69.9k|#define OBJ_SETTINGS_LIST_MAX 8
  ------------------
  |  Branch (3121:9): [True: 243, False: 69.7k]
  ------------------
 3122|    243|        mp_warn(log, "Object settings list capacity exceeded: "
  ------------------
  |  |   77|    243|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
 3123|    243|                     "a maximum of %d elements is allowed.\n",
 3124|    243|                OBJ_SETTINGS_LIST_MAX);
 3125|    243|        return false;
 3126|    243|    }
 3127|  69.7k|    if (idx < 0)
  ------------------
  |  Branch (3127:9): [True: 69.7k, False: 7]
  ------------------
 3128|  69.7k|        idx = num + idx + 1;
 3129|  69.7k|    mp_assert(idx >= 0 && idx <= num);
  ------------------
  |  |   41|  69.7k|#define mp_assert assert
  ------------------
  |  Branch (3129:5): [True: 69.7k, False: 0]
  |  Branch (3129:5): [True: 69.7k, False: 0]
  ------------------
 3130|  69.7k|    *p_obj_list = talloc_realloc(NULL, *p_obj_list, struct m_obj_settings,
  ------------------
  |  |   33|  69.7k|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  69.7k|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  69.7k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  69.7k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  69.7k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  69.7k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3131|  69.7k|                                 num + 2);
 3132|  69.7k|    memmove(*p_obj_list + idx + 1, *p_obj_list + idx,
 3133|  69.7k|            (num - idx) * sizeof(m_obj_settings_t));
 3134|  69.7k|    (*p_obj_list)[idx] = *item;
 3135|  69.7k|    (*p_obj_list)[num + 1] = (m_obj_settings_t){0};
 3136|       |    return true;
 3137|  69.7k|}
m_option.c:obj_setting_free:
 3065|  1.14M|{
 3066|  1.14M|    talloc_free(item->name);
  ------------------
  |  |   47|  1.14M|#define talloc_free                     ta_free
  ------------------
 3067|  1.14M|    talloc_free(item->label);
  ------------------
  |  |   47|  1.14M|#define talloc_free                     ta_free
  ------------------
 3068|  1.14M|    free_str_list(&(item->attribs));
 3069|  1.14M|}
m_option.c:obj_settings_list_find_by_label0:
 3151|    623|{
 3152|    623|    return obj_settings_list_find_by_label(obj_list, bstr0(label));
 3153|    623|}
m_option.c:obj_settings_find_by_content:
 3157|  2.20k|{
 3158|  2.28k|    for (int n = 0; obj_list && obj_list[n].name; n++) {
  ------------------
  |  Branch (3158:21): [True: 2.22k, False: 62]
  |  Branch (3158:33): [True: 779, False: 1.44k]
  ------------------
 3159|    779|        if (obj_setting_match(&obj_list[n], item))
  ------------------
  |  Branch (3159:13): [True: 698, False: 81]
  ------------------
 3160|    698|            return n;
 3161|    779|    }
 3162|  1.50k|    return -1;
 3163|  2.20k|}
m_option.c:obj_setting_match:
 3073|    779|{
 3074|    779|    bstr la = bstr0(a->label), lb = bstr0(b->label);
 3075|    779|    if (la.len || lb.len)
  ------------------
  |  Branch (3075:9): [True: 0, False: 779]
  |  Branch (3075:19): [True: 0, False: 779]
  ------------------
 3076|      0|        return bstr_equals(la, lb);
 3077|       |
 3078|    779|    return m_obj_settings_equal(a, b);
 3079|    779|}
m_option.c:obj_settings_list_del_at:
 3090|    698|{
 3091|    698|    m_obj_settings_t *obj_list = *p_obj_list;
 3092|    698|    int num = obj_settings_list_num_items(obj_list);
 3093|       |
 3094|    698|    mp_assert(idx >= 0 && idx < num);
  ------------------
  |  |   41|    698|#define mp_assert assert
  ------------------
  |  Branch (3094:5): [True: 698, False: 0]
  |  Branch (3094:5): [True: 698, False: 0]
  ------------------
 3095|       |
 3096|    698|    obj_setting_free(&obj_list[idx]);
 3097|       |
 3098|       |    // Note: the NULL-terminating element is moved down as part of this
 3099|    698|    memmove(&obj_list[idx], &obj_list[idx + 1],
 3100|    698|            sizeof(m_obj_settings_t) * (num - idx));
 3101|       |
 3102|    698|    *p_obj_list = talloc_realloc(NULL, obj_list, struct m_obj_settings, num);
  ------------------
  |  |   33|    698|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|    698|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|    698|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    698|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    698|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    698|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3103|    698|}
m_option.c:print_obj_settings_list:
 3738|     11|{
 3739|     11|    m_obj_settings_t *list = VAL(val);
  ------------------
  |  | 3041|     11|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3740|     11|    char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|     11|#define talloc_strdup                   ta_xstrdup
  ------------------
 3741|     22|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (3741:21): [True: 22, False: 0]
  |  Branch (3741:29): [True: 11, False: 11]
  ------------------
 3742|     11|        m_obj_settings_t *entry = &list[n];
 3743|     11|        if (n > 0)
  ------------------
  |  Branch (3743:13): [True: 0, False: 11]
  ------------------
 3744|      0|            res = talloc_strdup_append(res, ",");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3745|       |        // Assume labels and names don't need escaping
 3746|     11|        if (entry->label && entry->label[0])
  ------------------
  |  Branch (3746:13): [True: 0, False: 11]
  |  Branch (3746:29): [True: 0, False: 0]
  ------------------
 3747|      0|            res = talloc_asprintf_append(res, "@%s:", entry->label);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3748|     11|        if (!entry->enabled)
  ------------------
  |  Branch (3748:13): [True: 0, False: 11]
  ------------------
 3749|      0|            res = talloc_strdup_append(res, "!");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3750|     11|        res = talloc_strdup_append(res, entry->name);
  ------------------
  |  |   57|     11|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3751|     11|        if (entry->attribs && entry->attribs[0]) {
  ------------------
  |  Branch (3751:13): [True: 0, False: 11]
  |  Branch (3751:31): [True: 0, False: 0]
  ------------------
 3752|      0|            res = talloc_strdup_append(res, "=");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3753|      0|            for (int i = 0; entry->attribs[i * 2 + 0]; i++) {
  ------------------
  |  Branch (3753:29): [True: 0, False: 0]
  ------------------
 3754|      0|                if (i > 0)
  ------------------
  |  Branch (3754:21): [True: 0, False: 0]
  ------------------
 3755|      0|                    res = talloc_strdup_append(res, ":");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3756|      0|                append_param(&res, entry->attribs[i * 2 + 0]);
 3757|      0|                res = talloc_strdup_append(res, "=");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3758|      0|                append_param(&res, entry->attribs[i * 2 + 1]);
 3759|      0|            }
 3760|      0|        }
 3761|     11|    }
 3762|     11|    return res;
 3763|     11|}
m_option.c:copy_obj_settings_list:
 3182|  1.11M|{
 3183|  1.11M|    m_obj_settings_t *d, *s;
 3184|  1.11M|    int n;
 3185|       |
 3186|  1.11M|    if (!(dst && src))
  ------------------
  |  Branch (3186:11): [True: 1.11M, False: 0]
  |  Branch (3186:18): [True: 1.11M, False: 0]
  ------------------
 3187|      0|        return;
 3188|       |
 3189|  1.11M|    s = VAL(src);
  ------------------
  |  | 3041|  1.11M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3190|       |
 3191|  1.11M|    if (VAL(dst))
  ------------------
  |  | 3041|  1.11M|#define VAL(x) (*(m_obj_settings_t **)(x))
  |  |  ------------------
  |  |  |  Branch (3041:16): [True: 3.35k, False: 1.10M]
  |  |  ------------------
  ------------------
 3192|  3.35k|        free_obj_settings_list(dst);
 3193|  1.11M|    if (!s)
  ------------------
  |  Branch (3193:9): [True: 572k, False: 539k]
  ------------------
 3194|   572k|        return;
 3195|       |
 3196|  1.62M|    for (n = 0; s[n].name; n++)
  ------------------
  |  Branch (3196:17): [True: 1.08M, False: 539k]
  ------------------
 3197|  1.08M|        /* NOP */;
 3198|   539k|    d = talloc_array(NULL, struct m_obj_settings, n + 1);
  ------------------
  |  |   29|   539k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|   539k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   539k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3199|  1.62M|    for (n = 0; s[n].name; n++) {
  ------------------
  |  Branch (3199:17): [True: 1.08M, False: 539k]
  ------------------
 3200|  1.08M|        d[n].name = talloc_strdup(NULL, s[n].name);
  ------------------
  |  |   50|  1.08M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3201|  1.08M|        d[n].label = talloc_strdup(NULL, s[n].label);
  ------------------
  |  |   50|  1.08M|#define talloc_strdup                   ta_xstrdup
  ------------------
 3202|  1.08M|        d[n].enabled = s[n].enabled;
 3203|  1.08M|        d[n].attribs = NULL;
 3204|  1.08M|        copy_str_list(NULL, &(d[n].attribs), &(s[n].attribs));
 3205|  1.08M|    }
 3206|   539k|    d[n].name = NULL;
 3207|   539k|    d[n].label = NULL;
 3208|   539k|    d[n].attribs = NULL;
 3209|   539k|    VAL(dst) = d;
  ------------------
  |  | 3041|   539k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3210|   539k|}
m_option.c:free_obj_settings_list:
 3166|  1.42M|{
 3167|  1.42M|    int n;
 3168|  1.42M|    m_obj_settings_t *d;
 3169|       |
 3170|  1.42M|    if (!dst || !VAL(dst))
  ------------------
  |  | 3041|  1.42M|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
  |  Branch (3170:9): [True: 0, False: 1.42M]
  |  Branch (3170:17): [True: 813k, False: 608k]
  ------------------
 3171|   813k|        return;
 3172|       |
 3173|   608k|    d = VAL(dst);
  ------------------
  |  | 3041|   608k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3174|  1.75M|    for (n = 0; d[n].name; n++)
  ------------------
  |  Branch (3174:17): [True: 1.14M, False: 608k]
  ------------------
 3175|  1.14M|        obj_setting_free(&d[n]);
 3176|   608k|    talloc_free(d);
  ------------------
  |  |   47|   608k|#define talloc_free                     ta_free
  ------------------
 3177|   608k|    VAL(dst) = NULL;
  ------------------
  |  | 3041|   608k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3178|   608k|}
m_option.c:obj_settings_list_equal:
 3873|   240k|{
 3874|   240k|    struct m_obj_settings *a = VAL(pa);
  ------------------
  |  | 3041|   240k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3875|   240k|    struct m_obj_settings *b = VAL(pb);
  ------------------
  |  | 3041|   240k|#define VAL(x) (*(m_obj_settings_t **)(x))
  ------------------
 3876|       |
 3877|   240k|    if (a == b || !a || !b)
  ------------------
  |  Branch (3877:9): [True: 138k, False: 102k]
  |  Branch (3877:19): [True: 25.1k, False: 76.8k]
  |  Branch (3877:25): [True: 383, False: 76.5k]
  ------------------
 3878|   163k|        return a == b || (!a && !b[0].name) || (!b && !a[0].name);
  ------------------
  |  Branch (3878:16): [True: 138k, False: 25.5k]
  |  Branch (3878:27): [True: 25.1k, False: 383]
  |  Branch (3878:33): [True: 254, False: 24.8k]
  |  Branch (3878:49): [True: 383, False: 24.8k]
  |  Branch (3878:55): [True: 14, False: 369]
  ------------------
 3879|       |
 3880|   154k|    for (int n = 0; a[n].name || b[n].name; n++) {
  ------------------
  |  Branch (3880:21): [True: 79.6k, False: 74.4k]
  |  Branch (3880:34): [True: 948, False: 73.5k]
  ------------------
 3881|  80.6k|        if (!a[n].name || !b[n].name)
  ------------------
  |  Branch (3881:13): [True: 948, False: 79.6k]
  |  Branch (3881:27): [True: 721, False: 78.9k]
  ------------------
 3882|  1.66k|            return false;
 3883|  78.9k|        if (!m_obj_settings_equal(&a[n], &b[n]))
  ------------------
  |  Branch (3883:13): [True: 1.32k, False: 77.6k]
  ------------------
 3884|  1.32k|            return false;
 3885|  78.9k|    }
 3886|       |
 3887|  73.5k|    return true;
 3888|  76.5k|}
m_option.c:parse_node:
 3932|    228|{
 3933|       |    // Maybe use JSON?
 3934|    228|    mp_err(log, "option type doesn't accept strings");
  ------------------
  |  |   76|    228|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
 3935|    228|    return M_OPT_INVALID;
  ------------------
  |  |  535|    228|#define M_OPT_INVALID           -3
  ------------------
 3936|    228|}
m_option.c:print_node:
 3939|     50|{
 3940|     50|    char *t = talloc_strdup(NULL, "");
  ------------------
  |  |   50|     50|#define talloc_strdup                   ta_xstrdup
  ------------------
 3941|     50|    if (json_write(&t, &VAL(val)) < 0) {
  ------------------
  |  | 3928|     50|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
  |  Branch (3941:9): [True: 0, False: 50]
  ------------------
 3942|      0|        talloc_free(t);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3943|       |        t = NULL;
 3944|      0|    }
 3945|     50|    return t;
 3946|     50|}
m_option.c:copy_node:
 4006|      1|{
 4007|      1|    static_assert(sizeof(struct mpv_node) <= sizeof(union m_option_value), "");
 4008|       |
 4009|      1|    if (!(dst && src))
  ------------------
  |  Branch (4009:11): [True: 1, False: 0]
  |  Branch (4009:18): [True: 1, False: 0]
  ------------------
 4010|      0|        return;
 4011|       |
 4012|      1|    opt->type->free(dst);
 4013|      1|    VAL(dst) = VAL(src);
  ------------------
  |  | 3928|      1|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
                  VAL(dst) = VAL(src);
  ------------------
  |  | 3928|      1|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4014|      1|    dup_node(NULL, &VAL(dst));
  ------------------
  |  | 3928|      1|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4015|      1|}
m_option.c:dup_node:
 3959|   957k|{
 3960|   957k|    switch (node->format) {
 3961|   478k|    case MPV_FORMAT_STRING:
  ------------------
  |  Branch (3961:5): [True: 478k, False: 478k]
  ------------------
 3962|   478k|        node->u.string = talloc_strdup(ta_parent, node->u.string);
  ------------------
  |  |   50|   478k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3963|   478k|        break;
 3964|      0|    case MPV_FORMAT_NODE_ARRAY:
  ------------------
  |  Branch (3964:5): [True: 0, False: 957k]
  ------------------
 3965|      1|    case MPV_FORMAT_NODE_MAP: {
  ------------------
  |  Branch (3965:5): [True: 1, False: 957k]
  ------------------
 3966|      1|        struct mpv_node_list *oldlist = node->u.list;
 3967|      1|        struct mpv_node_list *new = talloc_zero(ta_parent, struct mpv_node_list);
  ------------------
  |  |   27|      1|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      1|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3968|      1|        node->u.list = new;
 3969|      1|        if (oldlist->num > 0) {
  ------------------
  |  Branch (3969:13): [True: 0, False: 1]
  ------------------
 3970|      0|            *new = *oldlist;
 3971|      0|            new->values = talloc_array(new, struct mpv_node, new->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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3972|      0|            for (int n = 0; n < new->num; n++) {
  ------------------
  |  Branch (3972:29): [True: 0, False: 0]
  ------------------
 3973|      0|                new->values[n] = oldlist->values[n];
 3974|      0|                dup_node(new, &new->values[n]);
 3975|      0|            }
 3976|      0|            if (node->format == MPV_FORMAT_NODE_MAP) {
  ------------------
  |  Branch (3976:17): [True: 0, False: 0]
  ------------------
 3977|      0|                new->keys = talloc_array(new, char*, new->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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3978|      0|                for (int n = 0; n < new->num; n++)
  ------------------
  |  Branch (3978:33): [True: 0, False: 0]
  ------------------
 3979|      0|                    new->keys[n] = talloc_strdup(new, oldlist->keys[n]);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3980|      0|            }
 3981|      0|        }
 3982|      1|        break;
 3983|      0|    }
 3984|      0|    case MPV_FORMAT_BYTE_ARRAY: {
  ------------------
  |  Branch (3984:5): [True: 0, False: 957k]
  ------------------
 3985|      0|        struct mpv_byte_array *old = node->u.ba;
 3986|      0|        struct mpv_byte_array *new = 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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3987|      0|        node->u.ba = new;
 3988|      0|        if (old->size > 0) {
  ------------------
  |  Branch (3988:13): [True: 0, False: 0]
  ------------------
 3989|      0|            *new = *old;
 3990|      0|            new->data = talloc_memdup(new, old->data, old->size);
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3991|      0|        }
 3992|      0|        break;
 3993|      0|    }
 3994|      0|    case MPV_FORMAT_NONE:
  ------------------
  |  Branch (3994:5): [True: 0, False: 957k]
  ------------------
 3995|      0|    case MPV_FORMAT_FLAG:
  ------------------
  |  Branch (3995:5): [True: 0, False: 957k]
  ------------------
 3996|   478k|    case MPV_FORMAT_INT64:
  ------------------
  |  Branch (3996:5): [True: 478k, False: 478k]
  ------------------
 3997|   478k|    case MPV_FORMAT_DOUBLE:
  ------------------
  |  Branch (3997:5): [True: 0, False: 957k]
  ------------------
 3998|   478k|        break;
 3999|      0|    default:
  ------------------
  |  Branch (3999:5): [True: 0, False: 957k]
  ------------------
 4000|       |        // unknown entry - mark as invalid
 4001|      0|        node->format = (mpv_format)-1;
 4002|   957k|    }
 4003|   957k|}
m_option.c:free_node:
 4033|   909k|{
 4034|   909k|    if (src) {
  ------------------
  |  Branch (4034:9): [True: 909k, False: 0]
  ------------------
 4035|   909k|        struct mpv_node *node = &VAL(src);
  ------------------
  |  | 3928|   909k|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4036|   909k|        talloc_free(node_get_alloc(node));
  ------------------
  |  |   47|   909k|#define talloc_free                     ta_free
  ------------------
 4037|   909k|        *node = (struct mpv_node){{0}};
 4038|   909k|    }
 4039|   909k|}
m_option.c:node_get:
 4050|   957k|{
 4051|   957k|    *dst = VAL(src);
  ------------------
  |  | 3928|   957k|#define VAL(x) (*(struct mpv_node *)(x))
  ------------------
 4052|   957k|    dup_node(ta_parent, dst);
 4053|   957k|    return 1;
 4054|   957k|}
m_option.c:parse_cycle_dir:
 4076|  12.6k|{
 4077|  12.6k|    double val;
 4078|  12.6k|    if (bstrcmp0(param, "up") == 0) {
  ------------------
  |  Branch (4078:9): [True: 19, False: 12.6k]
  ------------------
 4079|     19|        val = +1;
 4080|  12.6k|    } else if (bstrcmp0(param, "down") == 0) {
  ------------------
  |  Branch (4080:16): [True: 10, False: 12.6k]
  ------------------
 4081|     10|        val = -1;
 4082|  12.6k|    } else {
 4083|  12.6k|        return m_option_type_double.parse(log, opt, name, param, dst);
 4084|  12.6k|    }
 4085|     29|    *(double *)dst = val;
 4086|     29|    return 1;
 4087|  12.6k|}
m_option.c:print_cycle_dir:
 4090|   141k|{
 4091|   141k|    return talloc_asprintf(NULL, "%f", *(double *)val);
  ------------------
  |  |   52|   141k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   141k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 4092|   141k|}

f_lavfi.c:ra_hwdec_validate_drivers_only_opt_str:
  209|     16|                                            struct bstr name, void *value) { \
  210|     16|    return OPT_FUNC(func)(log, opt, name, value); \
  ------------------
  |  |  203|     16|#define OPT_FUNC(name) name
  ------------------
  211|     16|} \
f_output_chain.c:m_option_free:
  589|   251k|{
  590|   251k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 251k, False: 0]
  ------------------
  591|   251k|        opt->type->free(dst);
  592|   251k|}
f_output_chain.c:m_option_copy:
  582|  5.76k|{
  583|  5.76k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 5.76k, False: 0]
  ------------------
  584|  5.76k|        opt->type->copy(opt, dst, src);
  585|  5.76k|}
cmd.c:m_option_free:
  589|  1.20M|{
  590|  1.20M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 524k, False: 682k]
  ------------------
  591|   524k|        opt->type->free(dst);
  592|  1.20M|}
cmd.c:m_option_copy:
  582|   373k|{
  583|   373k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 373k, False: 0]
  ------------------
  584|   373k|        opt->type->copy(opt, dst, src);
  585|   373k|}
cmd.c:m_option_print:
  559|  1.16M|{
  560|  1.16M|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 1.16M, False: 0]
  ------------------
  561|  1.16M|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|  1.16M|}
ipc.c:m_option_get_node:
  610|   957k|{
  611|   957k|    if (opt->type->get)
  ------------------
  |  Branch (611:9): [True: 957k, False: 0]
  ------------------
  612|   957k|        return opt->type->get(opt, ta_parent, dst, src);
  613|      0|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  614|   957k|}
m_config_core.c:m_option_free:
  589|   108M|{
  590|   108M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 18.6M, False: 89.4M]
  ------------------
  591|  18.6M|        opt->type->free(dst);
  592|   108M|}
m_config_core.c:m_option_equal:
  617|  18.9M|{
  618|       |    // Handle trivial equivalence.
  619|       |    // If not implemented, assume this type has no actual values => always equal.
  620|  18.9M|    if (a == b || !opt->type->equal)
  ------------------
  |  Branch (620:9): [True: 0, False: 18.9M]
  |  Branch (620:19): [True: 0, False: 18.9M]
  ------------------
  621|      0|        return true;
  622|  18.9M|    return opt->type->equal(opt, a, b);
  623|  18.9M|}
m_config_core.c:m_option_copy:
  582|  19.0M|{
  583|  19.0M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 19.0M, False: 0]
  ------------------
  584|  19.0M|        opt->type->copy(opt, dst, src);
  585|  19.0M|}
m_config_frontend.c:m_option_copy:
  582|  9.60M|{
  583|  9.60M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 9.60M, False: 0]
  ------------------
  584|  9.60M|        opt->type->copy(opt, dst, src);
  585|  9.60M|}
m_config_frontend.c:m_option_free:
  589|  9.46M|{
  590|  9.46M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 1.72M, False: 7.74M]
  ------------------
  591|  1.72M|        opt->type->free(dst);
  592|  9.46M|}
m_property.c:m_option_pretty_print:
  569|  2.82M|{
  570|  2.82M|    m_option_t o = *opt;
  571|  2.82M|    if (fixed_len)
  ------------------
  |  Branch (571:9): [True: 0, False: 2.82M]
  ------------------
  572|      0|        o.flags |= M_OPT_FIXED_LEN_PRINT;
  ------------------
  |  |  494|      0|#define M_OPT_FIXED_LEN_PRINT   (UINT64_C(1) << 55)
  ------------------
  573|  2.82M|    if (opt->type->pretty_print)
  ------------------
  |  Branch (573:9): [True: 34.1k, False: 2.79M]
  ------------------
  574|  34.1k|        return opt->type->pretty_print(&o, val_ptr);
  575|  2.79M|    else
  576|  2.79M|        return m_option_print(&o, val_ptr);
  577|  2.82M|}
m_property.c:m_option_free:
  589|  8.42M|{
  590|  8.42M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 8.25M, False: 169k]
  ------------------
  591|  8.25M|        opt->type->free(dst);
  592|  8.42M|}
m_property.c:m_option_print:
  559|  8.30M|{
  560|  8.30M|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 8.30M, False: 0]
  ------------------
  561|  8.30M|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|  8.30M|}
m_property.c:m_option_get_node:
  610|  25.1k|{
  611|  25.1k|    if (opt->type->get)
  ------------------
  |  Branch (611:9): [True: 25.1k, False: 0]
  ------------------
  612|  25.1k|        return opt->type->get(opt, ta_parent, dst, src);
  613|      0|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  614|  25.1k|}
m_property.c:m_option_copy:
  582|  1.79k|{
  583|  1.79k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 1.79k, False: 0]
  ------------------
  584|  1.79k|        opt->type->copy(opt, dst, src);
  585|  1.79k|}
client.c:m_option_free:
  589|   909k|{
  590|   909k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 909k, False: 0]
  ------------------
  591|   909k|        opt->type->free(dst);
  592|   909k|}
command.c:m_option_print:
  559|  1.25k|{
  560|  1.25k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 1.25k, False: 0]
  ------------------
  561|  1.25k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|  1.25k|}
command.c:m_option_equal:
  617|  1.26k|{
  618|       |    // Handle trivial equivalence.
  619|       |    // If not implemented, assume this type has no actual values => always equal.
  620|  1.26k|    if (a == b || !opt->type->equal)
  ------------------
  |  Branch (620:9): [True: 0, False: 1.26k]
  |  Branch (620:19): [True: 0, False: 1.26k]
  ------------------
  621|      0|        return true;
  622|  1.26k|    return opt->type->equal(opt, a, b);
  623|  1.26k|}
command.c:m_option_copy:
  582|   221k|{
  583|   221k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 221k, False: 0]
  ------------------
  584|   221k|        opt->type->copy(opt, dst, src);
  585|   221k|}
command.c:m_option_free:
  589|  79.6k|{
  590|  79.6k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 79.1k, False: 551]
  ------------------
  591|  79.1k|        opt->type->free(dst);
  592|  79.6k|}
command.c:m_option_get_node:
  610|     31|{
  611|     31|    if (opt->type->get)
  ------------------
  |  Branch (611:9): [True: 30, False: 1]
  ------------------
  612|     30|        return opt->type->get(opt, ta_parent, dst, src);
  613|      1|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      1|#define M_OPT_UNKNOWN           -1
  ------------------
  614|     31|}
video.c:validate_target_gamut_str:
  209|     39|                                            struct bstr name, void *value) { \
  210|     39|    return OPT_FUNC(func)(log, opt, name, value); \
  ------------------
  |  |  203|     39|#define OPT_FUNC(name) name
  ------------------
  211|     39|} \

m_property_list_sort:
   45|  11.6k|{
   46|  11.6k|    qsort(list->props, list->num, sizeof(list->props[0]), compare_prop_name);
   47|  11.6k|}
m_property_list_find:
   64|   193k|{
   65|   193k|    return find_prop(list, bstr0(name));
   66|   193k|}
m_property_do:
  142|  8.97M|{
  143|  8.97M|    union m_option_value val = m_option_value_default;
  144|  8.97M|    int r;
  145|       |
  146|  8.97M|    const char *key;
  147|  8.97M|    struct m_property *prop = resolve_name(prop_list, name, &key);
  148|  8.97M|    if (!prop)
  ------------------
  |  Branch (148:9): [True: 127k, False: 8.84M]
  ------------------
  149|   127k|        return M_PROPERTY_UNKNOWN;
  150|       |
  151|  8.84M|    struct m_option opt = {0};
  152|  8.84M|    bool get_opt_required[M_PROPERTY_MAX_ACTION] = {
  153|  8.84M|        [M_PROPERTY_FIXED_LEN_PRINT] = true, [M_PROPERTY_PRINT] = true,
  154|  8.84M|        [M_PROPERTY_PRINT_UNCUT] = true, [M_PROPERTY_GET_STRING] = true,
  155|  8.84M|        [M_PROPERTY_MULTIPLY] = true, [M_PROPERTY_SWITCH] = true,
  156|  8.84M|        [M_PROPERTY_GET_NODE] = true, [M_PROPERTY_SET_NODE] = true,
  157|  8.84M|    };
  158|  8.84M|    if (get_opt_required[action]) {
  ------------------
  |  Branch (158:9): [True: 8.55M, False: 286k]
  ------------------
  159|  8.55M|        r = do_action(prop, key, M_PROPERTY_GET_TYPE, &opt, ctx);
  160|  8.55M|        if (r <= 0)
  ------------------
  |  Branch (160:13): [True: 19.1k, False: 8.53M]
  ------------------
  161|  19.1k|            return r;
  162|  8.53M|        mp_assert(opt.type);
  ------------------
  |  |   41|  8.53M|#define mp_assert assert
  ------------------
  |  Branch (162:9): [True: 8.53M, False: 0]
  ------------------
  163|       |        // Make sure dynamic range from properties with M_PROPERTY_GET_CONSTRICTED_TYPE is applied
  164|  8.53M|        struct m_option copt = {0};
  165|  8.53M|        r = do_action(prop, key, M_PROPERTY_GET_CONSTRICTED_TYPE, &copt, ctx);
  166|  8.53M|        if (r == M_PROPERTY_OK) {
  ------------------
  |  Branch (166:13): [True: 8.93k, False: 8.53M]
  ------------------
  167|  8.93k|            opt.min = copt.min;
  168|  8.93k|            opt.max = copt.max;
  169|  8.93k|        }
  170|  8.53M|    }
  171|       |
  172|  8.82M|    switch (action) {
  173|      0|    case M_PROPERTY_PRINT_UNCUT:
  ------------------
  |  Branch (173:5): [True: 0, False: 8.82M]
  ------------------
  174|      0|    case M_PROPERTY_FIXED_LEN_PRINT:
  ------------------
  |  Branch (174:5): [True: 0, False: 8.82M]
  ------------------
  175|  2.89M|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (175:5): [True: 2.89M, False: 5.92M]
  ------------------
  176|  2.89M|        if ((r = do_action(prop, key, action, arg, ctx)) >= 0)
  ------------------
  |  Branch (176:13): [True: 73.1k, False: 2.82M]
  ------------------
  177|  73.1k|            return r;
  178|  2.82M|        if (action == M_PROPERTY_PRINT_UNCUT &&
  ------------------
  |  Branch (178:13): [True: 0, False: 2.82M]
  ------------------
  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|  2.82M|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (182:13): [True: 69, False: 2.82M]
  ------------------
  183|     69|            return r;
  184|  2.82M|        char *str = m_option_pretty_print(&opt, &val, action == M_PROPERTY_FIXED_LEN_PRINT);
  185|  2.82M|        m_option_free(&opt, &val);
  186|  2.82M|        *(char **)arg = str;
  187|  2.82M|        return str != NULL;
  188|  2.82M|    }
  189|  5.50M|    case M_PROPERTY_GET_STRING: {
  ------------------
  |  Branch (189:5): [True: 5.50M, False: 3.31M]
  ------------------
  190|  5.50M|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (190:13): [True: 12, False: 5.50M]
  ------------------
  191|     12|            return r;
  192|  5.50M|        char *str = m_option_print(&opt, &val);
  193|  5.50M|        m_option_free(&opt, &val);
  194|  5.50M|        *(char **)arg = str;
  195|  5.50M|        return str != NULL;
  196|  5.50M|    }
  197|  1.13k|    case M_PROPERTY_SET_STRING: {
  ------------------
  |  Branch (197:5): [True: 1.13k, False: 8.82M]
  ------------------
  198|  1.13k|        struct mpv_node node = { .format = MPV_FORMAT_STRING, .u.string = arg };
  199|  1.13k|        return m_property_do(log, prop_list, name, M_PROPERTY_SET_NODE, &node, ctx);
  200|  5.50M|    }
  201|      0|    case M_PROPERTY_MULTIPLY: {
  ------------------
  |  Branch (201:5): [True: 0, False: 8.82M]
  ------------------
  202|      0|        return m_property_multiply(log, prop, key, *(double *)arg, ctx, &opt);
  203|  5.50M|    }
  204|   105k|    case M_PROPERTY_SWITCH: {
  ------------------
  |  Branch (204:5): [True: 105k, False: 8.72M]
  ------------------
  205|   105k|        return m_property_switch(log, prop, key, arg, ctx, &opt);
  206|  5.50M|    }
  207|   146k|    case M_PROPERTY_GET_CONSTRICTED_TYPE: {
  ------------------
  |  Branch (207:5): [True: 146k, False: 8.68M]
  ------------------
  208|   146k|        r = do_action(prop, key, action, arg, ctx);
  209|   146k|        if (r >= 0 || r == M_PROPERTY_UNAVAILABLE)
  ------------------
  |  Branch (209:13): [True: 2.68k, False: 143k]
  |  Branch (209:23): [True: 2.22k, False: 141k]
  ------------------
  210|  4.90k|            return r;
  211|   141k|        if ((r = do_action(prop, key, M_PROPERTY_GET_TYPE, arg, ctx)) >= 0)
  ------------------
  |  Branch (211:13): [True: 141k, False: 0]
  ------------------
  212|   141k|            return r;
  213|      0|        return M_PROPERTY_NOT_IMPLEMENTED;
  214|   141k|    }
  215|  21.7k|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (215:5): [True: 21.7k, False: 8.80M]
  ------------------
  216|  21.7k|        return do_action(prop, key, M_PROPERTY_SET, arg, ctx);
  217|   141k|    }
  218|  24.9k|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (218:5): [True: 24.9k, False: 8.80M]
  ------------------
  219|  24.9k|        if ((r = do_action(prop, key, M_PROPERTY_GET_NODE, arg, ctx)) !=
  ------------------
  |  Branch (219:13): [True: 0, False: 24.9k]
  ------------------
  220|  24.9k|            M_PROPERTY_NOT_IMPLEMENTED)
  221|      0|            return r;
  222|  24.9k|        if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (222:13): [True: 0, False: 24.9k]
  ------------------
  223|      0|            return r;
  224|  24.9k|        struct mpv_node *node = arg;
  225|  24.9k|        int err = m_option_get_node(&opt, NULL, node, &val);
  226|  24.9k|        if (err == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|  24.9k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (226:13): [True: 0, False: 24.9k]
  ------------------
  227|      0|            r = M_PROPERTY_NOT_IMPLEMENTED;
  228|  24.9k|        } else if (err < 0) {
  ------------------
  |  Branch (228:20): [True: 0, False: 24.9k]
  ------------------
  229|      0|            r = M_PROPERTY_INVALID_FORMAT;
  230|  24.9k|        } else {
  231|  24.9k|            r = M_PROPERTY_OK;
  232|  24.9k|        }
  233|  24.9k|        m_option_free(&opt, &val);
  234|  24.9k|        return r;
  235|  24.9k|    }
  236|  1.18k|    case M_PROPERTY_SET_NODE: {
  ------------------
  |  Branch (236:5): [True: 1.18k, False: 8.82M]
  ------------------
  237|  1.18k|        if (!log)
  ------------------
  |  Branch (237:13): [True: 0, False: 1.18k]
  ------------------
  238|      0|            return M_PROPERTY_ERROR;
  239|  1.18k|        if ((r = do_action(prop, key, M_PROPERTY_SET_NODE, arg, ctx)) !=
  ------------------
  |  Branch (239:13): [True: 46, False: 1.13k]
  ------------------
  240|  1.18k|            M_PROPERTY_NOT_IMPLEMENTED)
  241|     46|            return r;
  242|  1.13k|        int err = m_option_set_node_or_string(log, &opt, bstr0(name), &val, arg);
  243|  1.13k|        if (err == M_OPT_UNKNOWN) {
  ------------------
  |  |  529|  1.13k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (243:13): [True: 0, False: 1.13k]
  ------------------
  244|      0|            r = M_PROPERTY_NOT_IMPLEMENTED;
  245|  1.13k|        } else if (err < 0) {
  ------------------
  |  Branch (245:20): [True: 663, False: 472]
  ------------------
  246|    663|            r = M_PROPERTY_INVALID_FORMAT;
  247|    663|        } else {
  248|    472|            r = do_action(prop, key, M_PROPERTY_SET, &val, ctx);
  249|    472|        }
  250|  1.13k|        m_option_free(&opt, &val);
  251|  1.13k|        return r;
  252|  1.18k|    }
  253|   117k|    default:
  ------------------
  |  Branch (253:5): [True: 117k, False: 8.70M]
  ------------------
  254|   117k|        return do_action(prop, key, action, arg, ctx);
  255|  8.82M|    }
  256|  8.82M|}
m_property_split_path:
  259|    346|{
  260|    346|    const char *next = strchr(path, '/');
  261|    346|    if (next) {
  ------------------
  |  Branch (261:9): [True: 346, False: 0]
  ------------------
  262|    346|        *prefix = bstr_splice(bstr0(path), 0, next - path);
  263|    346|        *rem = next + 1;
  264|    346|        return true;
  265|    346|    } else {
  266|      0|        *prefix = bstr0(path);
  267|      0|        *rem = "";
  268|       |        return false;
  269|      0|    }
  270|    346|}
m_properties_expand_string:
  338|  3.34M|{
  339|  3.34M|    char *ret = NULL;
  340|  3.34M|    int ret_len = 0;
  341|  3.34M|    bool skip = false;
  342|  3.34M|    int level = 0, skip_level = 0;
  343|  3.34M|    bstr str = bstr0(str0);
  344|  3.34M|    int last_brace = bstrrchr(str, '}');
  345|  3.34M|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  346|  3.34M|    int n = 0;
  347|  3.34M|#endif
  348|       |
  349|  65.4M|    while (str.len) {
  ------------------
  |  Branch (349:12): [True: 62.1M, False: 3.33M]
  ------------------
  350|  62.1M|        if (level > 0 && bstr_eatstart0(&str, "}")) {
  ------------------
  |  Branch (350:13): [True: 30.5M, False: 31.5M]
  |  Branch (350:26): [True: 8.43M, False: 22.1M]
  ------------------
  351|  8.43M|            if (skip && level <= skip_level)
  ------------------
  |  Branch (351:17): [True: 5.67M, False: 2.76M]
  |  Branch (351:25): [True: 5.66M, False: 9.01k]
  ------------------
  352|  5.66M|                skip = false;
  353|  8.43M|            level--;
  354|  53.6M|        } else if (bstr_startswith0(str, "${") && str.start - (unsigned char *)str0 < last_brace) {
  ------------------
  |  Branch (354:20): [True: 8.43M, False: 45.2M]
  |  Branch (354:51): [True: 8.43M, False: 110]
  ------------------
  355|  8.43M|            str = bstr_cut(str, 2);
  356|  8.43M|            level++;
  357|       |
  358|       |            // Assume ":" and "}" can't be part of the property name
  359|       |            // => if ":" comes before "}", it must be for the fallback
  360|  8.43M|            int term_pos = bstrcspn(str, ":}");
  361|  8.43M|            bstr name = bstr_splice(str, 0, term_pos < 0 ? str.len : term_pos);
  ------------------
  |  Branch (361:45): [True: 0, False: 8.43M]
  ------------------
  362|  8.43M|            str = bstr_cut(str, term_pos);
  363|  8.43M|            bool have_fallback = bstr_eatstart0(&str, ":");
  364|       |
  365|  8.43M|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  366|  8.43M|            if (n++ > 10)
  ------------------
  |  Branch (366:17): [True: 0, False: 8.43M]
  ------------------
  367|      0|                break;
  368|  8.43M|#endif
  369|       |
  370|  8.43M|            if (!skip) {
  ------------------
  |  Branch (370:17): [True: 8.42M, False: 9.01k]
  ------------------
  371|  8.42M|                skip = expand_property(prop_list, &ret, &ret_len, name,
  372|  8.42M|                                       have_fallback, ctx, print_action);
  373|  8.42M|                if (skip)
  ------------------
  |  Branch (373:21): [True: 5.66M, False: 2.76M]
  ------------------
  374|  5.66M|                    skip_level = level;
  375|  8.42M|            }
  376|  45.2M|        } else if (level == 0 && bstr_eatstart0(&str, "$>")) {
  ------------------
  |  Branch (376:20): [True: 25.8M, False: 19.3M]
  |  Branch (376:34): [True: 6.75k, False: 25.8M]
  ------------------
  377|  6.75k|            append_str(&ret, &ret_len, str);
  378|  6.75k|            break;
  379|  45.2M|        } else {
  380|  45.2M|            char c;
  381|       |
  382|       |            // Other combinations, e.g. "$x", are added verbatim
  383|  45.2M|            if (bstr_eatstart0(&str, "$$")) {
  ------------------
  |  Branch (383:17): [True: 16.1k, False: 45.2M]
  ------------------
  384|  16.1k|                c = '$';
  385|  45.2M|            } else if (bstr_eatstart0(&str, "$}")) {
  ------------------
  |  Branch (385:24): [True: 22, False: 45.2M]
  ------------------
  386|     22|                c = '}';
  387|  45.2M|            } else {
  388|  45.2M|                c = str.start[0];
  389|  45.2M|                str = bstr_cut(str, 1);
  390|  45.2M|            }
  391|       |
  392|  45.2M|            if (!skip)
  ------------------
  |  Branch (392:17): [True: 25.9M, False: 19.3M]
  ------------------
  393|  25.9M|                MP_TARRAY_APPEND(NULL, ret, ret_len, c);
  ------------------
  |  |  105|  25.9M|    do {                                            \
  |  |  106|  25.9M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  25.9M|    do {                                            \
  |  |  |  |   97|  25.9M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  25.9M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  25.9M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  25.9M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.48M, False: 24.4M]
  |  |  |  |  ------------------
  |  |  |  |   99|  25.9M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.48M|    do {                                                        \
  |  |  |  |  |  |   89|  1.48M|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.48M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.48M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.48M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.48M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.48M|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.48M|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.48M]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  25.9M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 25.9M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  25.9M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  25.9M|        (idxvar)++;                                 \
  |  |  109|  25.9M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 25.9M]
  |  |  ------------------
  ------------------
  394|  45.2M|        }
  395|  62.1M|    }
  396|       |
  397|  3.34M|    MP_TARRAY_APPEND(NULL, ret, ret_len, '\0');
  ------------------
  |  |  105|  3.34M|    do {                                            \
  |  |  106|  3.34M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  3.34M|    do {                                            \
  |  |  |  |   97|  3.34M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  3.34M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.34M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  3.34M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 126k, False: 3.21M]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.34M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   126k|    do {                                                        \
  |  |  |  |  |  |   89|   126k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   126k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   126k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   126k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   126k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   126k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   126k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 126k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  3.34M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3.34M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  3.34M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  3.34M|        (idxvar)++;                                 \
  |  |  109|  3.34M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.34M]
  |  |  ------------------
  ------------------
  398|  3.34M|    return ret;
  399|  3.34M|}
m_property_bool_ro:
  411|  50.3k|{
  412|  50.3k|    switch (action) {
  ------------------
  |  Branch (412:13): [True: 25.1k, False: 25.1k]
  ------------------
  413|  12.5k|    case M_PROPERTY_GET:
  ------------------
  |  Branch (413:5): [True: 12.5k, False: 37.8k]
  ------------------
  414|  12.5k|        *(bool *)arg = !!var;
  415|  12.5k|        return M_PROPERTY_OK;
  416|  12.6k|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (416:5): [True: 12.6k, False: 37.7k]
  ------------------
  417|  12.6k|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_BOOL};
  ------------------
  |  |  238|  12.6k|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  ------------------
  418|  12.6k|        return M_PROPERTY_OK;
  419|  50.3k|    }
  420|  25.1k|    return M_PROPERTY_NOT_IMPLEMENTED;
  421|  50.3k|}
m_property_int_ro:
  424|    873|{
  425|    873|    switch (action) {
  ------------------
  |  Branch (425:13): [True: 435, False: 438]
  ------------------
  426|    145|    case M_PROPERTY_GET:
  ------------------
  |  Branch (426:5): [True: 145, False: 728]
  ------------------
  427|    145|        *(int *)arg = var;
  428|    145|        return M_PROPERTY_OK;
  429|    290|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (429:5): [True: 290, False: 583]
  ------------------
  430|    290|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT};
  ------------------
  |  |  240|    290|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
  431|    290|        return M_PROPERTY_OK;
  432|    873|    }
  433|    438|    return M_PROPERTY_NOT_IMPLEMENTED;
  434|    873|}
m_property_int64_ro:
  437|    180|{
  438|    180|    switch (action) {
  ------------------
  |  Branch (438:13): [True: 87, False: 93]
  ------------------
  439|     29|    case M_PROPERTY_GET:
  ------------------
  |  Branch (439:5): [True: 29, False: 151]
  ------------------
  440|     29|        *(int64_t *)arg = var;
  441|     29|        return M_PROPERTY_OK;
  442|     58|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (442:5): [True: 58, False: 122]
  ------------------
  443|     58|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT64};
  ------------------
  |  |  241|     58|#define CONF_TYPE_INT64         (&m_option_type_int64)
  ------------------
  444|     58|        return M_PROPERTY_OK;
  445|    180|    }
  446|     93|    return M_PROPERTY_NOT_IMPLEMENTED;
  447|    180|}
m_property_float_ro:
  450|  5.18k|{
  451|  5.18k|    switch (action) {
  ------------------
  |  Branch (451:13): [True: 2.59k, False: 2.59k]
  ------------------
  452|    864|    case M_PROPERTY_GET:
  ------------------
  |  Branch (452:5): [True: 864, False: 4.32k]
  ------------------
  453|    864|        *(float *)arg = var;
  454|    864|        return M_PROPERTY_OK;
  455|  1.72k|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (455:5): [True: 1.72k, False: 3.45k]
  ------------------
  456|  1.72k|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLOAT};
  ------------------
  |  |  242|  1.72k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  ------------------
  457|  1.72k|        return M_PROPERTY_OK;
  458|  5.18k|    }
  459|  2.59k|    return M_PROPERTY_NOT_IMPLEMENTED;
  460|  5.18k|}
m_property_double_ro:
  463|    114|{
  464|    114|    switch (action) {
  ------------------
  |  Branch (464:13): [True: 57, False: 57]
  ------------------
  465|     19|    case M_PROPERTY_GET:
  ------------------
  |  Branch (465:5): [True: 19, False: 95]
  ------------------
  466|     19|        *(double *)arg = var;
  467|     19|        return M_PROPERTY_OK;
  468|     38|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (468:5): [True: 38, False: 76]
  ------------------
  469|     38|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_DOUBLE};
  ------------------
  |  |  243|     38|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  ------------------
  470|     38|        return M_PROPERTY_OK;
  471|    114|    }
  472|     57|    return M_PROPERTY_NOT_IMPLEMENTED;
  473|    114|}
m_property_strdup_ro:
  476|  27.5M|{
  477|  27.5M|    if (!var)
  ------------------
  |  Branch (477:9): [True: 175, False: 27.5M]
  ------------------
  478|    175|        return M_PROPERTY_UNAVAILABLE;
  479|  27.5M|    switch (action) {
  ------------------
  |  Branch (479:13): [True: 16.5M, False: 11.0M]
  ------------------
  480|  8.25M|    case M_PROPERTY_GET:
  ------------------
  |  Branch (480:5): [True: 8.25M, False: 19.2M]
  ------------------
  481|  8.25M|        *(char **)arg = talloc_strdup(NULL, var);
  ------------------
  |  |   50|  8.25M|#define talloc_strdup                   ta_xstrdup
  ------------------
  482|  8.25M|        return M_PROPERTY_OK;
  483|  8.25M|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (483:5): [True: 8.25M, False: 19.2M]
  ------------------
  484|  8.25M|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|  8.25M|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  485|  8.25M|        return M_PROPERTY_OK;
  486|  27.5M|    }
  487|  11.0M|    return M_PROPERTY_NOT_IMPLEMENTED;
  488|  27.5M|}
m_property_read_sub_validate:
  492|  10.5k|{
  493|  10.5k|    m_property_unkey(&action, &arg);
  494|  10.5k|    switch (action) {
  495|    175|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (495:5): [True: 175, False: 10.3k]
  ------------------
  496|    175|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|    175|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
  497|    175|        return M_PROPERTY_OK;
  498|      9|    case M_PROPERTY_GET:
  ------------------
  |  Branch (498:5): [True: 9, False: 10.5k]
  ------------------
  499|     10|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (499:5): [True: 1, False: 10.5k]
  ------------------
  500|  10.1k|    case M_PROPERTY_KEY_ACTION:
  ------------------
  |  Branch (500:5): [True: 10.1k, False: 359]
  ------------------
  501|  10.1k|        return M_PROPERTY_VALID;
  502|    174|    default:
  ------------------
  |  Branch (502:5): [True: 174, False: 10.3k]
  ------------------
  503|    174|        return M_PROPERTY_NOT_IMPLEMENTED;
  504|  10.5k|    };
  505|      0|}
m_property_read_sub:
  512|  10.2k|{
  513|  10.2k|    m_property_unkey(&action, &arg);
  514|  10.2k|    switch (action) {
  ------------------
  |  Branch (514:13): [True: 10.2k, False: 20]
  ------------------
  515|     20|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (515:5): [True: 20, False: 10.2k]
  ------------------
  516|     20|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     20|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
  517|     20|        return M_PROPERTY_OK;
  518|     10|    case M_PROPERTY_GET:
  ------------------
  |  Branch (518:5): [True: 10, False: 10.2k]
  ------------------
  519|     35|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (519:5): [True: 25, False: 10.2k]
  ------------------
  520|     35|        struct mpv_node node;
  521|     35|        node.format = MPV_FORMAT_NODE_MAP;
  522|     35|        node.u.list = talloc_zero(NULL, mpv_node_list);
  ------------------
  |  |   27|     35|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     35|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     35|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|     35|        mpv_node_list *list = node.u.list;
  524|    299|        for (int n = 0; props && props[n].name; n++) {
  ------------------
  |  Branch (524:25): [True: 299, False: 0]
  |  Branch (524:34): [True: 264, False: 35]
  ------------------
  525|    264|            const struct m_sub_property *prop = &props[n];
  526|    264|            if (prop->unavailable)
  ------------------
  |  Branch (526:17): [True: 97, False: 167]
  ------------------
  527|     97|                continue;
  528|    167|            MP_TARRAY_GROW(list, list->values, list->num);
  ------------------
  |  |   96|    167|    do {                                            \
  |  |   97|    167|        size_t nextidx_ = (nextidx);                \
  |  |   98|    167|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|    167|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|    167|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 65, False: 102]
  |  |  ------------------
  |  |   99|    167|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|     65|    do {                                                        \
  |  |  |  |   89|     65|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|     65|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     65|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     65|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     65|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|     65|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|     65|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|    167|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 167]
  |  |  ------------------
  ------------------
  529|    167|            MP_TARRAY_GROW(list, list->keys, list->num);
  ------------------
  |  |   96|    167|    do {                                            \
  |  |   97|    167|        size_t nextidx_ = (nextidx);                \
  |  |   98|    167|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|    167|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|    167|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 65, False: 102]
  |  |  ------------------
  |  |   99|    167|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|     65|    do {                                                        \
  |  |  |  |   89|     65|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|     65|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|     65|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|     65|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|     65|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|     65|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|     65|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|    167|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 167]
  |  |  ------------------
  ------------------
  530|    167|            mpv_node *val = &list->values[list->num];
  531|    167|            if (m_option_get_node(&prop->type, list, val, (void*)&prop->value) < 0)
  ------------------
  |  Branch (531:17): [True: 0, False: 167]
  ------------------
  532|      0|            {
  533|      0|                char *s = m_option_print(&prop->type, &prop->value);
  534|      0|                val->format = MPV_FORMAT_STRING;
  535|      0|                val->u.string = talloc_steal(list, s);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  536|      0|            }
  537|    167|            list->keys[list->num] = (char *)prop->name;
  538|    167|            list->num++;
  539|    167|        }
  540|     35|        *(struct mpv_node *)arg = node;
  541|     35|        return M_PROPERTY_OK;
  542|     10|    }
  543|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (543:5): [True: 0, False: 10.2k]
  ------------------
  544|       |        // Output "something" - what it really should return is not yet decided.
  545|       |        // It should probably be something that is easy to consume by slave
  546|       |        // mode clients. (M_PROPERTY_PRINT on the other hand can return this
  547|       |        // as human readable version just fine).
  548|      0|        char *res = NULL;
  549|      0|        for (int n = 0; props && props[n].name; n++) {
  ------------------
  |  Branch (549:25): [True: 0, False: 0]
  |  Branch (549:34): [True: 0, False: 0]
  ------------------
  550|      0|            const struct m_sub_property *prop = &props[n];
  551|      0|            if (prop->unavailable)
  ------------------
  |  Branch (551:17): [True: 0, False: 0]
  ------------------
  552|      0|                continue;
  553|      0|            char *s = m_option_print(&prop->type, &prop->value);
  554|      0|            ta_xasprintf_append(&res, "%s=%s\n", prop->name, s);
  ------------------
  |  |  129|      0|#define ta_xasprintf_append(...)        ta_oom_b(ta_asprintf_append(__VA_ARGS__))
  ------------------
  555|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  556|      0|        }
  557|      0|        *(char **)arg = res;
  558|      0|        return M_PROPERTY_OK;
  559|     10|    }
  560|  10.1k|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (560:5): [True: 10.1k, False: 75]
  ------------------
  561|  10.1k|        struct m_property_action_arg *ka = arg;
  562|  10.1k|        const struct m_sub_property *prop = NULL;
  563|  65.6k|        for (int n = 0; props && props[n].name; n++) {
  ------------------
  |  Branch (563:25): [True: 65.6k, False: 0]
  |  Branch (563:34): [True: 65.6k, False: 49]
  ------------------
  564|  65.6k|            if (strcmp(props[n].name, ka->key) == 0) {
  ------------------
  |  Branch (564:17): [True: 10.1k, False: 55.4k]
  ------------------
  565|  10.1k|                prop = &props[n];
  566|  10.1k|                break;
  567|  10.1k|            }
  568|  65.6k|        }
  569|  10.1k|        if (!prop)
  ------------------
  |  Branch (569:13): [True: 49, False: 10.1k]
  ------------------
  570|     49|            return M_PROPERTY_UNKNOWN;
  571|  10.1k|        if (prop->unavailable)
  ------------------
  |  Branch (571:13): [True: 0, False: 10.1k]
  ------------------
  572|      0|            return M_PROPERTY_UNAVAILABLE;
  573|  10.1k|        switch (ka->action) {
  ------------------
  |  Branch (573:17): [True: 5.48k, False: 4.64k]
  ------------------
  574|  1.79k|        case M_PROPERTY_GET: {
  ------------------
  |  Branch (574:9): [True: 1.79k, False: 8.33k]
  ------------------
  575|  1.79k|            memset(ka->arg, 0, prop->type.type->size);
  576|  1.79k|            m_option_copy(&prop->type, ka->arg, &prop->value);
  577|  1.79k|            return M_PROPERTY_OK;
  578|      0|        }
  579|  3.69k|        case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (579:9): [True: 3.69k, False: 6.43k]
  ------------------
  580|  3.69k|            *(struct m_option *)ka->arg = prop->type;
  581|  3.69k|            return M_PROPERTY_OK;
  582|  10.1k|        }
  583|  10.1k|    }
  584|  10.2k|    }
  585|  4.66k|    return M_PROPERTY_NOT_IMPLEMENTED;
  586|  10.2k|}
m_property_read_list:
  599|    698|{
  600|    698|    m_property_unkey(&action, &arg);
  601|    698|    switch (action) {
  ------------------
  |  Branch (601:13): [True: 617, False: 81]
  ------------------
  602|     72|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (602:5): [True: 72, False: 626]
  ------------------
  603|     72|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     72|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
  604|     72|        return M_PROPERTY_OK;
  605|     26|    case M_PROPERTY_GET:
  ------------------
  |  Branch (605:5): [True: 26, False: 672]
  ------------------
  606|     26|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (606:5): [True: 0, False: 698]
  ------------------
  607|     26|        struct mpv_node node;
  608|     26|        node.format = MPV_FORMAT_NODE_ARRAY;
  609|     26|        node.u.list = talloc_zero(NULL, mpv_node_list);
  ------------------
  |  |   27|     26|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     26|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     26|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|     26|        node.u.list->num = count;
  611|     26|        node.u.list->values = talloc_array(node.u.list, mpv_node, count);
  ------------------
  |  |   29|     26|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|     26|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     26|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|     51|        for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (612:25): [True: 25, False: 26]
  ------------------
  613|     25|            struct mpv_node *sub = &node.u.list->values[n];
  614|     25|            sub->format = MPV_FORMAT_NONE;
  615|     25|            int r;
  616|     25|            r = get_item(n, M_PROPERTY_GET_NODE, sub, ctx);
  617|     25|            if (r >= 0) {
  ------------------
  |  Branch (617:17): [True: 25, False: 0]
  ------------------
  618|     25|                talloc_steal(node.u.list, node_get_alloc(sub));
  ------------------
  |  |   38|     25|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|     25|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  619|     25|            } else if (r == M_PROPERTY_NOT_IMPLEMENTED) {
  ------------------
  |  Branch (619:24): [True: 0, False: 0]
  ------------------
  620|      0|                struct m_option opt = {0};
  621|      0|                r = get_item(n, M_PROPERTY_GET_TYPE, &opt, ctx);
  622|      0|                if (r != M_PROPERTY_OK)
  ------------------
  |  Branch (622:21): [True: 0, False: 0]
  ------------------
  623|      0|                    goto err;
  624|      0|                union m_option_value val = m_option_value_default;
  625|      0|                r = get_item(n, M_PROPERTY_GET, &val, ctx);
  626|      0|                if (r != M_PROPERTY_OK)
  ------------------
  |  Branch (626:21): [True: 0, False: 0]
  ------------------
  627|      0|                    goto err;
  628|      0|                m_option_get_node(&opt, node.u.list, sub, &val);
  629|      0|                m_option_free(&opt, &val);
  630|      0|            err: ;
  631|      0|            }
  632|     25|        }
  633|     26|        *(struct mpv_node *)arg = node;
  634|     26|        return M_PROPERTY_OK;
  635|     26|    }
  636|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (636:5): [True: 0, False: 698]
  ------------------
  637|       |        // See m_property_read_sub() remarks.
  638|      0|        char *res = NULL;
  639|      0|        for (int n = 0; n < count; n++) {
  ------------------
  |  Branch (639:25): [True: 0, False: 0]
  ------------------
  640|      0|            char *s = NULL;
  641|      0|            int r = get_item(n, M_PROPERTY_PRINT, &s, ctx);
  642|      0|            if (r != M_PROPERTY_OK) {
  ------------------
  |  Branch (642:17): [True: 0, False: 0]
  ------------------
  643|      0|                talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  644|      0|                return r;
  645|      0|            }
  646|      0|            ta_xasprintf_append(&res, "%d: %s\n", n, s);
  ------------------
  |  |  129|      0|#define ta_xasprintf_append(...)        ta_oom_b(ta_asprintf_append(__VA_ARGS__))
  ------------------
  647|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  648|      0|        }
  649|      0|        *(char **)arg = res;
  650|      0|        return M_PROPERTY_OK;
  651|      0|    }
  652|    519|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (652:5): [True: 519, False: 179]
  ------------------
  653|    519|        struct m_property_action_arg *ka = arg;
  654|    519|        if (strcmp(ka->key, "count") == 0) {
  ------------------
  |  Branch (654:13): [True: 251, False: 268]
  ------------------
  655|    251|            switch (ka->action) {
  ------------------
  |  Branch (655:21): [True: 134, False: 117]
  ------------------
  656|     90|            case M_PROPERTY_GET_TYPE: {
  ------------------
  |  Branch (656:13): [True: 90, False: 161]
  ------------------
  657|     90|                struct m_option opt = {.type = CONF_TYPE_INT};
  ------------------
  |  |  240|     90|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
  658|     90|                *(struct m_option *)ka->arg = opt;
  659|     90|                return M_PROPERTY_OK;
  660|      0|            }
  661|     44|            case M_PROPERTY_GET:
  ------------------
  |  Branch (661:13): [True: 44, False: 207]
  ------------------
  662|     44|                *(int *)ka->arg = MPMAX(0, count);
  ------------------
  |  |   44|     44|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 44]
  |  |  ------------------
  ------------------
  663|     44|                return M_PROPERTY_OK;
  664|    251|            }
  665|    117|            return M_PROPERTY_NOT_IMPLEMENTED;
  666|    251|        }
  667|       |        // This is expected of the form "123" or "123/rest"
  668|    268|        char *end;
  669|    268|        long int item = strtol(ka->key, &end, 10);
  670|       |        // not a number, trailing characters, etc.
  671|    268|        if (end == ka->key || (end[0] == '/' && !end[1]))
  ------------------
  |  Branch (671:13): [True: 6, False: 262]
  |  Branch (671:32): [True: 212, False: 50]
  |  Branch (671:49): [True: 0, False: 212]
  ------------------
  672|      6|            return M_PROPERTY_UNKNOWN;
  673|    262|        if (item < 0 || item >= count)
  ------------------
  |  Branch (673:13): [True: 14, False: 248]
  |  Branch (673:25): [True: 6, False: 242]
  ------------------
  674|     20|            return M_PROPERTY_UNKNOWN;
  675|    242|        if (*end) {
  ------------------
  |  Branch (675:13): [True: 230, False: 12]
  ------------------
  676|       |            // Sub-path
  677|    230|            struct m_property_action_arg n_ka = *ka;
  678|    230|            n_ka.key = end + 1;
  679|    230|            return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx);
  680|    230|        } else {
  681|       |            // Direct query
  682|     12|            return get_item(item, ka->action, ka->arg, ctx);
  683|     12|        }
  684|    242|    }
  685|    698|    }
  686|     81|    return M_PROPERTY_NOT_IMPLEMENTED;
  687|    698|}
m_property.c:compare_prop_name:
   39|  88.7M|{
   40|  88.7M|    const struct m_property *a = pa, *b = pb;
   41|  88.7M|    return strcmp(a->name, b->name);
   42|  88.7M|}
m_property.c:find_prop:
   57|  9.16M|{
   58|  9.16M|    return bsearch(&name, list->props, list->num, sizeof(list->props[0]),
   59|  9.16M|                   search_prop_name);
   60|  9.16M|}
m_property.c:search_prop_name:
   50|  82.8M|{
   51|  82.8M|    const struct m_property *prop = pelem;
   52|  82.8M|    return bstrcmp0(*(const bstr *)pkey, prop->name);
   53|  82.8M|}
m_property.c:resolve_name:
   72|  8.97M|{
   73|  8.97M|    *key = NULL;
   74|  8.97M|    const char *sep = strchr(name, '/');
   75|  8.97M|    if (sep && sep[1]) {
  ------------------
  |  Branch (75:9): [True: 10.3k, False: 8.96M]
  |  Branch (75:16): [True: 9.79k, False: 595]
  ------------------
   76|  9.79k|        *key = sep + 1;
   77|  9.79k|        return find_prop(list, bstr_splice(bstr0(name), 0, sep - name));
   78|  9.79k|    }
   79|  8.96M|    return find_prop(list, bstr0(name));
   80|  8.97M|}
m_property.c:do_action:
   84|  29.0M|{
   85|  29.0M|    if (key) {
  ------------------
  |  Branch (85:9): [True: 14.5k, False: 29.0M]
  ------------------
   86|  14.5k|        struct m_property_action_arg ka = {
   87|  14.5k|            .key = key,
   88|  14.5k|            .action = action,
   89|  14.5k|            .arg = arg,
   90|  14.5k|        };
   91|  14.5k|        return prop->call(ctx, prop, M_PROPERTY_KEY_ACTION, &ka);
   92|  14.5k|    }
   93|  29.0M|    return prop->call(ctx, prop, action, arg);
   94|  29.0M|}
m_property.c:m_property_switch:
  119|   105k|{
  120|   105k|    union m_option_value val = m_option_value_default;
  121|   105k|    int r;
  122|       |
  123|   105k|    mp_require(log);
  ------------------
  |  |   42|   105k|#define mp_require assert
  ------------------
  |  Branch (123:5): [True: 105k, False: 0]
  ------------------
  124|   105k|    struct m_property_switch_arg *sarg = arg;
  125|   105k|    if ((r = do_action(prop, key, M_PROPERTY_SWITCH, arg, ctx)) !=
  ------------------
  |  Branch (125:9): [True: 43.2k, False: 62.3k]
  ------------------
  126|   105k|        M_PROPERTY_NOT_IMPLEMENTED)
  127|  43.2k|        return r;
  128|       |    // Fallback to m_option
  129|  62.3k|    if (!opt->type->add)
  ------------------
  |  Branch (129:9): [True: 848, False: 61.4k]
  ------------------
  130|    848|        return M_PROPERTY_NOT_IMPLEMENTED;
  131|  61.4k|    if ((r = do_action(prop, key, M_PROPERTY_GET, &val, ctx)) <= 0)
  ------------------
  |  Branch (131:9): [True: 64, False: 61.4k]
  ------------------
  132|     64|        return r;
  133|  61.4k|    opt->type->add(opt, &val, sarg->inc, sarg->wrap);
  134|  61.4k|    r = do_action(prop, key, M_PROPERTY_SET, &val, ctx);
  135|  61.4k|    m_option_free(opt, &val);
  136|  61.4k|    return r;
  137|  61.4k|}
m_property.c:expand_property:
  305|  8.42M|{
  306|  8.42M|    bool cond_yes = bstr_eatstart0(&prop, "?");
  307|  8.42M|    bool cond_no = !cond_yes && bstr_eatstart0(&prop, "!");
  ------------------
  |  Branch (307:20): [True: 5.65M, False: 2.76M]
  |  Branch (307:33): [True: 2.75M, False: 2.89M]
  ------------------
  308|  8.42M|    bool test = cond_yes || cond_no;
  ------------------
  |  Branch (308:17): [True: 2.76M, False: 5.65M]
  |  Branch (308:29): [True: 2.75M, False: 2.89M]
  ------------------
  309|  8.42M|    bool raw = bstr_eatstart0(&prop, "=");
  310|  8.42M|    bool fixed_len = !raw && bstr_eatstart0(&prop, ">");
  ------------------
  |  Branch (310:22): [True: 8.41M, False: 5.83k]
  |  Branch (310:30): [True: 1, False: 8.41M]
  ------------------
  311|  8.42M|    bstr comp_with = {0};
  312|  8.42M|    bool comp = test && bstr_split_tok(prop, "==", &prop, &comp_with);
  ------------------
  |  Branch (312:17): [True: 5.52M, False: 2.89M]
  |  Branch (312:25): [True: 7.11k, False: 5.51M]
  ------------------
  313|  8.42M|    if (test && !comp)
  ------------------
  |  Branch (313:9): [True: 5.52M, False: 2.89M]
  |  Branch (313:17): [True: 5.51M, False: 7.11k]
  ------------------
  314|  5.51M|        raw = true;
  315|  8.42M|    int method = raw ? M_PROPERTY_GET_STRING : print_action;
  ------------------
  |  Branch (315:18): [True: 5.52M, False: 2.89M]
  ------------------
  316|  8.42M|    method = fixed_len ? M_PROPERTY_FIXED_LEN_PRINT : method;
  ------------------
  |  Branch (316:14): [True: 1, False: 8.42M]
  ------------------
  317|       |
  318|  8.42M|    char *s = NULL;
  319|  8.42M|    int r = m_property_do_bstr(prop_list, prop, method, &s, ctx);
  320|  8.42M|    bool skip;
  321|  8.42M|    if (comp) {
  ------------------
  |  Branch (321:9): [True: 7.11k, False: 8.41M]
  ------------------
  322|  7.11k|        skip = ((s && bstr_equals0(comp_with, s)) != cond_yes);
  ------------------
  |  Branch (322:18): [True: 7.11k, False: 0]
  |  Branch (322:23): [True: 43, False: 7.06k]
  ------------------
  323|  8.41M|    } else if (test) {
  ------------------
  |  Branch (323:16): [True: 5.51M, False: 2.89M]
  ------------------
  324|  5.51M|        skip = (!!s != cond_yes);
  325|  5.51M|    } else {
  326|  2.89M|        skip = !!s;
  327|  2.89M|        char *append = s;
  328|  2.89M|        if (!s && !silent_error && !raw)
  ------------------
  |  Branch (328:13): [True: 1.81k, False: 2.89M]
  |  Branch (328:19): [True: 1.81k, False: 1]
  |  Branch (328:36): [True: 1.81k, False: 0]
  ------------------
  329|  1.81k|            append = (r == M_PROPERTY_UNAVAILABLE) ? "(unavailable)" : "(error)";
  ------------------
  |  Branch (329:22): [True: 1.81k, False: 2]
  ------------------
  330|  2.89M|        append_str(ret, ret_len, bstr0(append));
  331|  2.89M|    }
  332|  8.42M|    talloc_free(s);
  ------------------
  |  |   47|  8.42M|#define talloc_free                     ta_free
  ------------------
  333|  8.42M|    return skip;
  334|  8.42M|}
m_property.c:m_property_do_bstr:
  287|  8.42M|{
  288|  8.42M|    char *name0 = bstrdup0(NULL, name);
  289|  8.42M|    int ret = m_property_do(NULL, prop_list, name0, action, arg, ctx);
  290|  8.42M|    talloc_free(name0);
  ------------------
  |  |   47|  8.42M|#define talloc_free                     ta_free
  ------------------
  291|  8.42M|    return ret;
  292|  8.42M|}
m_property.c:append_str:
  295|  2.90M|{
  296|  2.90M|    MP_TARRAY_GROW(NULL, *s, *len + append.len);
  ------------------
  |  |   96|  2.90M|    do {                                            \
  |  |   97|  2.90M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  2.90M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  2.90M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  2.90M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 2.83M, False: 68.9k]
  |  |  ------------------
  |  |   99|  2.90M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  2.83M|    do {                                                        \
  |  |  |  |   89|  2.83M|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  2.83M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  2.83M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  2.83M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.83M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  2.83M|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  2.83M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 2.83M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  2.90M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 2.90M]
  |  |  ------------------
  ------------------
  297|  2.90M|    if (append.len)
  ------------------
  |  Branch (297:9): [True: 2.90M, False: 189]
  ------------------
  298|  2.90M|        memcpy(*s + *len, append.start, append.len);
  299|  2.90M|    *len = *len + append.len;
  300|  2.90M|}
m_property.c:m_property_unkey:
  275|  21.4k|{
  276|  21.4k|    if (*action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (276:9): [True: 20.8k, False: 601]
  ------------------
  277|  20.8k|        struct m_property_action_arg *ka = *arg;
  278|  20.8k|        if (!ka->key[0]) {
  ------------------
  |  Branch (278:13): [True: 12, False: 20.8k]
  ------------------
  279|     12|            *action = ka->action;
  280|     12|            *arg = ka->arg;
  281|     12|        }
  282|  20.8k|    }
  283|  21.4k|}

m_config_parse:
   45|  12.3k|{
   46|  12.3k|    m_profile_t *profile = m_config_add_profile(config, initial_section);
   47|  12.3k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  12.3k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  12.3k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   48|  12.3k|    int line_no = 0;
   49|  12.3k|    int errors = 0;
   50|       |
   51|  12.3k|    bstr_eatstart0(&data, "\xEF\xBB\xBF"); // skip BOM
   52|       |
   53|  1.19M|    while (data.len) {
  ------------------
  |  Branch (53:12): [True: 1.17M, False: 12.3k]
  ------------------
   54|  1.17M|        talloc_free_children(tmp);
  ------------------
  |  |   46|  1.17M|#define talloc_free_children            ta_free_children
  ------------------
   55|  1.17M|        bool ok = false;
   56|       |
   57|  1.17M|        line_no++;
   58|  1.17M|        char loc[512];
   59|  1.17M|        snprintf(loc, sizeof(loc), "%s:%d:", location, line_no);
   60|       |
   61|  1.17M|        bstr line = bstr_strip_linebreaks(bstr_getline(data, &data));
   62|  1.17M|        if (!skip_ws(&line))
  ------------------
  |  Branch (62:13): [True: 291k, False: 887k]
  ------------------
   63|   291k|            continue;
   64|       |
   65|       |        // Profile declaration
   66|   887k|        if (bstr_eatstart0(&line, "[")) {
  ------------------
  |  Branch (66:13): [True: 140k, False: 747k]
  ------------------
   67|   140k|            bstr profilename;
   68|   140k|            if (!bstr_split_tok(line, "]", &profilename, &line)) {
  ------------------
  |  Branch (68:17): [True: 0, False: 140k]
  ------------------
   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|   140k|            if (skip_ws(&line)) {
  ------------------
  |  Branch (72:17): [True: 0, False: 140k]
  ------------------
   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|   140k|            profile = m_config_add_profile(config, bstrto0(tmp, profilename));
   78|   140k|            continue;
   79|   140k|        }
   80|       |
   81|   747k|        bstr_eatstart0(&line, "--");
   82|       |
   83|   747k|        bstr option = line;
   84|  10.0M|        while (line.len && (mp_isalnum(line.start[0]) || line.start[0] == '_' ||
  ------------------
  |  Branch (84:16): [True: 10.0M, False: 0]
  |  Branch (84:29): [True: 8.49M, False: 1.55M]
  |  Branch (84:58): [True: 0, False: 1.55M]
  ------------------
   85|  1.55M|                            line.start[0] == '-'))
  ------------------
  |  Branch (85:29): [True: 805k, False: 747k]
  ------------------
   86|  9.30M|            line = bstr_cut(line, 1);
   87|   747k|        option.len = option.len - line.len;
   88|   747k|        skip_ws(&line);
   89|       |
   90|   747k|        bstr value = {0};
   91|   747k|        if (bstr_eatstart0(&line, "=")) {
  ------------------
  |  Branch (91:13): [True: 747k, False: 10]
  ------------------
   92|   747k|            skip_ws(&line);
   93|   747k|            if (line.len && (line.start[0] == '"' || line.start[0] == '\'')) {
  ------------------
  |  Branch (93:17): [True: 747k, False: 0]
  |  Branch (93:30): [True: 0, False: 747k]
  |  Branch (93:54): [True: 0, False: 747k]
  ------------------
   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|   747k|            } else if (bstr_eatstart0(&line, "%")) {
  ------------------
  |  Branch (101:24): [True: 0, False: 747k]
  ------------------
  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|   747k|            } else {
  117|       |                // No quoting; take everything until the comment or end of line
  118|   747k|                int end = bstrchr(line, '#');
  119|   747k|                value = bstr_strip(end < 0 ? line : bstr_splice(line, 0, end));
  ------------------
  |  Branch (119:36): [True: 630k, False: 116k]
  ------------------
  120|   747k|                line.len = 0;
  121|   747k|            }
  122|   747k|        }
  123|   747k|        if (skip_ws(&line)) {
  ------------------
  |  Branch (123:13): [True: 10, False: 747k]
  ------------------
  124|     10|            MP_ERR(config, "%s unparsable extra characters: '%.*s'\n",
  ------------------
  |  |   89|     10|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     20|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|     10|                   loc, BSTR_P(line));
  126|     10|            goto error;
  127|     10|        }
  128|       |
  129|   747k|        int res = m_config_set_profile_option(config, profile, option, value);
  130|   747k|        if (res < 0) {
  ------------------
  |  Branch (130:13): [True: 58.3k, False: 688k]
  ------------------
  131|  58.3k|            MP_ERR(config, "%s setting option %.*s='%.*s' failed.\n",
  ------------------
  |  |   89|  58.3k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   233k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 58.3k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 58.3k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|  58.3k|                   loc, BSTR_P(option), BSTR_P(value));
  133|  58.3k|            goto error;
  134|  58.3k|        }
  135|       |
  136|   688k|        ok = true;
  137|   747k|    error:
  138|   747k|        if (!ok)
  ------------------
  |  Branch (138:13): [True: 58.3k, False: 688k]
  ------------------
  139|  58.3k|            errors++;
  140|   747k|        if (errors > 16) {
  ------------------
  |  Branch (140:13): [True: 0, False: 747k]
  ------------------
  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|   747k|    }
  145|       |
  146|  12.3k|    if (config->recursion_depth == 0)
  ------------------
  |  Branch (146:9): [True: 12.3k, False: 0]
  ------------------
  147|  12.3k|        m_config_finish_default_profile(config, flags);
  148|       |
  149|  12.3k|    talloc_free(tmp);
  ------------------
  |  |   47|  12.3k|#define talloc_free                     ta_free
  ------------------
  150|  12.3k|    return 1;
  151|  12.3k|}
m_config_parse_config_file:
  161|  8.00k|{
  162|  8.00k|    flags = flags | M_SETOPT_FROM_CONFIG_FILE;
  163|       |
  164|  8.00k|    MP_VERBOSE(config, "Reading config file %s\n", conffile);
  ------------------
  |  |   92|  8.00k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  8.00k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  165|       |
  166|  8.00k|    int r = 0;
  167|       |
  168|  8.00k|    bstr data = stream_read_file2(conffile, NULL, STREAM_ORIGIN_DIRECT | STREAM_READ,
  ------------------
  |  |   47|  8.00k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
                  bstr data = stream_read_file2(conffile, NULL, STREAM_ORIGIN_DIRECT | STREAM_READ,
  ------------------
  |  |   41|  8.00k|#define STREAM_READ               0
  ------------------
  169|  8.00k|                                  global, 1000000000);
  170|  8.00k|    if (data.start)
  ------------------
  |  Branch (170:9): [True: 630, False: 7.37k]
  ------------------
  171|    630|        r = m_config_parse(config, conffile, data, initial_section, flags);
  172|       |
  173|  8.00k|    talloc_free(data.start);
  ------------------
  |  |   47|  8.00k|#define talloc_free                     ta_free
  ------------------
  174|  8.00k|    return r;
  175|  8.00k|}
parse_configfile.c:skip_ws:
   36|  3.56M|{
   37|  3.56M|    *s = bstr_lstrip(*s);
   38|  3.56M|    if (bstr_startswith0(*s, "#"))
  ------------------
  |  Branch (38:9): [True: 140k, False: 3.42M]
  ------------------
   39|   140k|        s->len = 0;
   40|  3.56M|    return s->len;
   41|  3.56M|}

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

mp_als_create:
   64|      8|{
   65|      8|    struct mp_als *state =
   66|      8|        talloc_zero(parent, struct mp_als);
  ------------------
  |  |   27|      8|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      8|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      8|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   67|       |
   68|      8|    state->log = mp_log_new(state, mpctx->global->log, "linux-als");
   69|       |
   70|      8|    talloc_set_destructor(state, mp_als_destroy);
  ------------------
  |  |   41|      8|#define talloc_set_destructor           ta_set_destructor
  ------------------
   71|       |
   72|      8|    return state;
   73|      8|}
mp_als_get_lux:
  179|     83|{
  180|     83|    if (state->found_no_devices)
  ------------------
  |  Branch (180:9): [True: 75, False: 8]
  ------------------
  181|     75|        return MP_ALS_STATUS_NODEVICE;
  182|       |
  183|      8|    if (!state->device_dir && acquire_sensor(state) < 0) {
  ------------------
  |  Branch (183:9): [True: 8, False: 0]
  |  Branch (183:31): [True: 8, False: 0]
  ------------------
  184|      8|        state->found_no_devices = true;
  185|      8|        return MP_ALS_STATUS_NODEVICE;
  186|      8|    }
  187|       |
  188|      0|    return read_als_assume_have_sensor(state, lux);
  189|      8|}
als-linux.c:mp_als_destroy:
   55|      8|{
   56|      8|    struct mp_als *state = p;
   57|       |
   58|      8|    if (state->device_dir) {
  ------------------
  |  Branch (58:9): [True: 0, False: 8]
  ------------------
   59|      0|        closedir(state->device_dir);
   60|      0|    }
   61|      8|}
als-linux.c:acquire_sensor:
   77|      8|{
   78|      8|    mp_assert(!state->device_dir);
  ------------------
  |  |   41|      8|#define mp_assert assert
  ------------------
  |  Branch (78:5): [True: 8, False: 0]
  ------------------
   79|      8|    DIR *devices_dir = opendir(SYSFS_BASEDIR);
  ------------------
  |  |   40|      8|#define SYSFS_BASEDIR "/sys/bus/iio/devices"
  ------------------
   80|      8|    if (!devices_dir) {
  ------------------
  |  Branch (80:9): [True: 8, False: 0]
  ------------------
   81|      8|        MP_WARN(state,
  ------------------
  |  |   90|      8|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      8|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   82|      8|                "No IIO device directory in sysfs: %s\n",
   83|      8|                mp_strerror(errno));
   84|      8|        return -1;
   85|      8|    }
   86|       |
   87|      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__))
  |  |  ------------------
  ------------------
   88|       |
   89|      0|    struct dirent *ent;
   90|      0|    while ((ent = readdir(devices_dir))) {
  ------------------
  |  Branch (90:12): [True: 0, False: 0]
  ------------------
   91|       |        // The directory also contains files named `trigger*` which we don't
   92|       |        // care about; only include ones for devices.
   93|      0|        if (!bstr_startswith0(bstr0(ent->d_name), "iio:device"))
  ------------------
  |  Branch (93:13): [True: 0, False: 0]
  ------------------
   94|      0|            continue;
   95|       |
   96|       |        // Check if in_illuminance_raw exists so we know we have an ambient
   97|       |        // light sensor.
   98|      0|        char *inp_raw_path = mp_path_join(tmp, ent->d_name, INP_RAW);
  ------------------
  |  |   41|      0|#define INP_RAW "in_illuminance_raw"
  ------------------
   99|       |
  100|      0|        if (faccessat(dirfd(devices_dir), inp_raw_path, R_OK, 0) != 0) {
  ------------------
  |  Branch (100:13): [True: 0, False: 0]
  ------------------
  101|       |            // Couldn't stat, continue
  102|      0|            continue;
  103|      0|        }
  104|       |
  105|       |        // We found an ALS
  106|       |
  107|      0|        char *dev_path = mp_path_join(tmp, SYSFS_BASEDIR, ent->d_name);
  ------------------
  |  |   40|      0|#define SYSFS_BASEDIR "/sys/bus/iio/devices"
  ------------------
  108|       |
  109|      0|        state->device_dir = opendir(dev_path);
  110|      0|        if (state->device_dir) {
  ------------------
  |  Branch (110:13): [True: 0, False: 0]
  ------------------
  111|      0|            MP_VERBOSE(state, "Chose ALS device %s\n", dev_path);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  112|      0|            break;
  113|      0|        }
  114|       |
  115|      0|        MP_WARN(state, "Failed to open ambient light sensor %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__)
  |  |  ------------------
  ------------------
  116|      0|                ent->d_name,
  117|      0|                mp_strerror(errno));
  118|      0|    }
  119|       |
  120|      0|    talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  121|      0|    closedir(devices_dir);
  122|       |
  123|      0|    return state->device_dir ? 0 : -1;
  ------------------
  |  Branch (123:12): [True: 0, False: 0]
  ------------------
  124|      8|}

mp_fopen:
   67|  34.4k|{
   68|  34.4k|    if (!mode[0]) {
  ------------------
  |  Branch (68:9): [True: 0, False: 34.4k]
  ------------------
   69|      0|        errno = EINVAL;
   70|      0|        return NULL;
   71|      0|    }
   72|       |
   73|  34.4k|    int rwmode;
   74|  34.4k|    int oflags = 0;
   75|  34.4k|    switch (mode[0]) {
   76|      0|    case 'r':
  ------------------
  |  Branch (76:5): [True: 0, False: 34.4k]
  ------------------
   77|      0|        rwmode = O_RDONLY;
   78|      0|        break;
   79|  34.4k|    case 'w':
  ------------------
  |  Branch (79:5): [True: 34.4k, False: 2]
  ------------------
   80|  34.4k|        rwmode = O_WRONLY;
   81|  34.4k|        oflags |= O_CREAT | O_TRUNC;
   82|  34.4k|        break;
   83|      2|    case 'a':
  ------------------
  |  Branch (83:5): [True: 2, False: 34.4k]
  ------------------
   84|      2|        rwmode = O_WRONLY;
   85|      2|        oflags |= O_CREAT | O_APPEND;
   86|      2|        break;
   87|      0|    default:
  ------------------
  |  Branch (87:5): [True: 0, False: 34.4k]
  ------------------
   88|      0|        errno = EINVAL;
   89|      0|        return NULL;
   90|  34.4k|    }
   91|       |
   92|       |    // Parse extra mode flags
   93|   103k|    for (const char *pos = mode + 1; *pos; pos++) {
  ------------------
  |  Branch (93:38): [True: 68.6k, False: 34.4k]
  ------------------
   94|  68.6k|        switch (*pos) {
   95|      0|        case '+': rwmode = O_RDWR;  break;
  ------------------
  |  Branch (95:9): [True: 0, False: 68.6k]
  ------------------
   96|  34.2k|        case 'x': oflags |= O_EXCL; break;
  ------------------
  |  Branch (96:9): [True: 34.2k, False: 34.4k]
  ------------------
   97|       |        // Ignore unknown flags (glibc does too)
   98|  34.4k|        default: break;
  ------------------
  |  Branch (98:9): [True: 34.4k, False: 34.2k]
  ------------------
   99|  68.6k|        }
  100|  68.6k|    }
  101|       |
  102|       |    // Open a CRT file descriptor
  103|  34.4k|    int fd = open(filename, rwmode | oflags | O_CLOEXEC, 0666);
  ------------------
  |  |  269|  34.4k|#define open(...) mp_open(__VA_ARGS__)
  ------------------
  104|  34.4k|    if (fd < 0)
  ------------------
  |  Branch (104:9): [True: 0, False: 34.4k]
  ------------------
  105|      0|        return NULL;
  106|       |
  107|       |    // Add 'b' to the mode so the CRT knows the file is opened in binary mode
  108|  34.4k|    char bmode[] = { mode[0], '\0', '\0', '\0' };
  109|  34.4k|    int idx = 1;
  110|  34.4k|    if (rwmode == O_RDWR)
  ------------------
  |  Branch (110:9): [True: 0, False: 34.4k]
  ------------------
  111|      0|        bmode[idx++] = '+';
  112|  34.4k|    bmode[idx++] = 'b';
  113|  34.4k|    FILE *fp = fdopen(fd, bmode);
  114|  34.4k|    if (!fp) {
  ------------------
  |  Branch (114:9): [True: 0, False: 34.4k]
  ------------------
  115|      0|        close(fd);
  116|      0|        return NULL;
  117|      0|    }
  118|       |
  119|  34.4k|    return fp;
  120|  34.4k|}
mp_make_cloexec_pipe:
  129|    428|{
  130|    428|#if HAVE_PIPE2
  131|    428|    if (pipe2(pipes, O_CLOEXEC) != 0) {
  ------------------
  |  Branch (131:9): [True: 0, False: 428]
  ------------------
  132|      0|        pipes[0] = pipes[1] = -1;
  133|      0|        return -1;
  134|      0|    }
  135|       |#else
  136|       |    if (pipe(pipes) != 0) {
  137|       |        pipes[0] = pipes[1] = -1;
  138|       |        return -1;
  139|       |    }
  140|       |
  141|       |    for (int i = 0; i < 2; i++)
  142|       |        mp_set_cloexec(pipes[i]);
  143|       |#endif
  144|    428|    return 0;
  145|    428|}
mp_make_wakeup_pipe:
  149|    428|{
  150|    428|    if (mp_make_cloexec_pipe(pipes) < 0)
  ------------------
  |  Branch (150:9): [True: 0, False: 428]
  ------------------
  151|      0|        return -1;
  152|       |
  153|  1.28k|    for (int i = 0; i < 2; i++) {
  ------------------
  |  Branch (153:21): [True: 856, False: 428]
  ------------------
  154|    856|        int val = fcntl(pipes[i], F_GETFL) | O_NONBLOCK;
  155|       |        fcntl(pipes[i], F_SETFL, val);
  156|    856|    }
  157|    428|    return 0;
  158|    428|}
mp_open:
  171|  61.3k|{
  172|  61.3k|    if (oflag & (O_WRONLY | O_RDWR | O_CREAT | O_TRUNC))
  ------------------
  |  Branch (172:9): [True: 34.8k, False: 26.4k]
  ------------------
  173|  34.8k|        return memfd_create("mpv", oflag & O_CLOEXEC ? MFD_CLOEXEC : 0);
  ------------------
  |  Branch (173:36): [True: 34.8k, False: 0]
  ------------------
  174|  26.4k|    return (open)(filename, oflag);
  175|  61.3k|}
mp_unlink:
  183|  34.2k|{
  184|  34.2k|    return 0;
  185|  34.2k|}

mp_get_user_langs:
   26|  14.3k|{
   27|  14.3k|    static const char *const list[] = {
   28|  14.3k|        "LC_ALL",
   29|  14.3k|        "LC_MESSAGES",
   30|  14.3k|        "LANG",
   31|  14.3k|        NULL
   32|  14.3k|    };
   33|       |
   34|  14.3k|    size_t nb = 0;
   35|  14.3k|    char **ret = NULL;
   36|  14.3k|    bool has_c = false;
   37|       |
   38|       |    // Prefer anything we get from LANGUAGE first
   39|  14.3k|    for (const char *langList = getenv("LANGUAGE"); langList && *langList;) {
  ------------------
  |  Branch (39:53): [True: 0, False: 14.3k]
  |  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|  57.5k|    for (int i = 0; list[i]; i++) {
  ------------------
  |  Branch (54:21): [True: 43.1k, False: 14.3k]
  ------------------
   55|  43.1k|        const char *envval = getenv(list[i]);
   56|  43.1k|        if (envval && *envval) {
  ------------------
  |  Branch (56:13): [True: 0, False: 43.1k]
  |  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|  43.1k|    }
   73|       |
   74|  14.3k|    if (has_c && !nb) {
  ------------------
  |  Branch (74:9): [True: 0, False: 14.3k]
  |  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|  14.3k|    MP_TARRAY_APPEND(NULL, ret, nb, NULL);
  ------------------
  |  |  105|  14.3k|    do {                                            \
  |  |  106|  14.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  14.3k|    do {                                            \
  |  |  |  |   97|  14.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  14.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  14.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  14.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  14.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  14.3k|    do {                                                        \
  |  |  |  |  |  |   89|  14.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  14.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  14.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  14.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  14.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  14.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  14.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  14.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 14.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  14.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  14.3k|        (idxvar)++;                                 \
  |  |  109|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
   81|       |
   82|  14.3k|    return ret;
   83|  14.3k|}

polldev:
   48|      1|{
   49|       |#ifdef __APPLE__
   50|       |    int maxfd = 0;
   51|       |    fd_set readfds, writefds;
   52|       |    FD_ZERO(&readfds);
   53|       |    FD_ZERO(&writefds);
   54|       |    for (size_t i = 0; i < nfds; ++i) {
   55|       |        struct pollfd *fd = &fds[i];
   56|       |        if (fd->fd > maxfd) {
   57|       |            maxfd = fd->fd;
   58|       |        }
   59|       |        if ((fd->events & POLLIN)) {
   60|       |            FD_SET(fd->fd, &readfds);
   61|       |        }
   62|       |        if ((fd->events & POLLOUT)) {
   63|       |            FD_SET(fd->fd, &writefds);
   64|       |        }
   65|       |    }
   66|       |    struct timeval _timeout = {
   67|       |        .tv_sec = timeout / 1000,
   68|       |        .tv_usec = (timeout % 1000) * 1000
   69|       |    };
   70|       |    int n = select(maxfd + 1, &readfds, &writefds, NULL,
   71|       |        timeout != -1 ? &_timeout : NULL);
   72|       |    if (n < 0) {
   73|       |        return n;
   74|       |    }
   75|       |    for (size_t i = 0; i < nfds; ++i) {
   76|       |        struct pollfd *fd = &fds[i];
   77|       |        fd->revents = 0;
   78|       |        if (FD_ISSET(fd->fd, &readfds)) {
   79|       |            fd->revents |= POLLIN;
   80|       |        }
   81|       |        if (FD_ISSET(fd->fd, &writefds)) {
   82|       |            fd->revents |= POLLOUT;
   83|       |        }
   84|       |    }
   85|       |    return n;
   86|       |#else
   87|      1|    return poll(fds, nfds, timeout);
   88|      1|#endif
   89|      1|}

mp_subprocess2:
    5|  9.02k|{
    6|  9.02k|    *res = (struct mp_subprocess_result){.error = MP_SUBPROCESS_EUNSUPPORTED};
  ------------------
  |  |   77|  9.02k|#define MP_SUBPROCESS_EUNSUPPORTED      -4  // API not supported
  ------------------
    7|  9.02k|}

mp_subprocess_err_str:
   25|  9.91k|{
   26|       |    // Note: these are visible to the public client API
   27|  9.91k|    switch (num) {
   28|      0|    case MP_SUBPROCESS_OK:              return "success";
  ------------------
  |  |   73|      0|#define MP_SUBPROCESS_OK                0   // no error
  ------------------
  |  Branch (28:5): [True: 0, False: 9.91k]
  ------------------
   29|      0|    case MP_SUBPROCESS_EKILLED_BY_US:   return "killed";
  ------------------
  |  |   75|      0|#define MP_SUBPROCESS_EKILLED_BY_US     -2  // mp_cancel was triggered
  ------------------
  |  Branch (29:5): [True: 0, False: 9.91k]
  ------------------
   30|      0|    case MP_SUBPROCESS_EINIT:           return "init";
  ------------------
  |  |   76|      0|#define MP_SUBPROCESS_EINIT             -3  // error during initialization
  ------------------
  |  Branch (30:5): [True: 0, False: 9.91k]
  ------------------
   31|  9.91k|    case MP_SUBPROCESS_EUNSUPPORTED:    return "unsupported";
  ------------------
  |  |   77|  9.91k|#define MP_SUBPROCESS_EUNSUPPORTED      -4  // API not supported
  ------------------
  |  Branch (31:5): [True: 9.91k, False: 0]
  ------------------
   32|      0|    case MP_SUBPROCESS_EGENERIC:        // fall through
  ------------------
  |  |   74|      0|#define MP_SUBPROCESS_EGENERIC          -1  // unknown error
  ------------------
  |  Branch (32:5): [True: 0, False: 9.91k]
  ------------------
   33|      0|    default:                            return "unknown";
  ------------------
  |  Branch (33:5): [True: 0, False: 9.91k]
  ------------------
   34|  9.91k|    }
   35|  9.91k|}
mp_subprocess:
   40|  9.02k|{
   41|  9.02k|    mp_verbose(log, "Starting subprocess: [%s", opts->args[0]);
  ------------------
  |  |   79|  9.02k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   42|  9.02k|    char **arg = &opts->args[1];
   43|  42.0k|    while (*arg)
  ------------------
  |  Branch (43:12): [True: 33.0k, False: 9.02k]
  ------------------
   44|  33.0k|        mp_verbose(log, ", %s", *arg++);
  ------------------
  |  |   79|  33.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   45|  9.02k|    mp_verbose(log, "]\n");
  ------------------
  |  |   79|  9.02k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   46|  9.02k|    mp_subprocess2(opts, res);
   47|  9.02k|    if (res->error < 0) {
  ------------------
  |  Branch (47:9): [True: 9.02k, False: 0]
  ------------------
   48|  9.02k|        int lev = res->error == MP_SUBPROCESS_EKILLED_BY_US ? MSGL_V : MSGL_ERR;
  ------------------
  |  |   75|  9.02k|#define MP_SUBPROCESS_EKILLED_BY_US     -2  // mp_cancel was triggered
  ------------------
  |  Branch (48:19): [True: 0, False: 9.02k]
  ------------------
   49|  9.02k|        mp_msg(log, lev, "Subprocess failed: %s\n", mp_subprocess_err_str(res->error));
   50|  9.02k|    }
   51|  9.02k|}

terminal_setup_getch:
  542|      1|{
  543|      1|    if (!getch2_enabled || input_ctx)
  ------------------
  |  Branch (543:9): [True: 0, False: 1]
  |  Branch (543:28): [True: 0, False: 1]
  ------------------
  544|      0|        return;
  545|       |
  546|      1|    if (mp_make_wakeup_pipe(death_pipe) < 0)
  ------------------
  |  Branch (546:9): [True: 0, False: 1]
  ------------------
  547|      0|        return;
  548|       |
  549|       |    // Disable reading from the terminal even if stdout is not a tty, to make
  550|       |    //   mpv ... | less
  551|       |    // do the right thing.
  552|      1|    read_terminal = isatty(tty_in) && isatty(STDOUT_FILENO);
  ------------------
  |  Branch (552:21): [True: 0, False: 1]
  |  Branch (552:39): [True: 0, False: 0]
  ------------------
  553|       |
  554|      1|    input_ctx = ictx;
  555|       |
  556|      1|    if (mp_thread_create(&input_thread, terminal_thread, NULL)) {
  ------------------
  |  |  214|      1|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  557|      0|        input_ctx = NULL;
  558|      0|        close_sig_pipes();
  559|      0|        close_tty();
  560|      0|        return;
  561|      0|    }
  562|       |
  563|      1|    setsigaction(SIGINT,  quit_request_sighandler, SA_RESETHAND, false, &old_sigint);
  564|      1|    setsigaction(SIGQUIT, quit_request_sighandler, 0, true, &old_sigquit);
  565|      1|    setsigaction(SIGTERM, quit_request_sighandler, 0, true, &old_sigterm);
  566|      1|}
terminal_uninit:
  577|    427|{
  578|    427|    if (!getch2_enabled)
  ------------------
  |  Branch (578:9): [True: 0, False: 427]
  ------------------
  579|      0|        return;
  580|       |
  581|       |    // restore signals
  582|    427|    restore_sigaction(SIGCONT, stop_cont_sighandler, &old_sigcont);
  583|    427|    restore_sigaction(SIGTSTP, stop_cont_sighandler, &old_sigtstp);
  584|    427|    restore_sigaction(SIGWINCH, winch_sighandler, &old_sigwinch);
  585|    427|    if (input_ctx) {
  ------------------
  |  Branch (585:9): [True: 1, False: 426]
  ------------------
  586|      1|        restore_sigaction(SIGINT, quit_request_sighandler, &old_sigint);
  587|      1|        restore_sigaction(SIGQUIT, quit_request_sighandler, &old_sigquit);
  588|      1|        restore_sigaction(SIGTERM, quit_request_sighandler, &old_sigterm);
  589|      1|    }
  590|    427|    restore_sigaction(SIGTTIN, SIG_IGN, &old_sigttin);
  591|    427|    restore_sigaction(SIGTTOU, SIG_IGN, &old_sigttou);
  592|       |
  593|    427|    if (input_ctx) {
  ------------------
  |  Branch (593:9): [True: 1, False: 426]
  ------------------
  594|      1|        (void)write(death_pipe[1], &(char){0}, 1);
  595|      1|        mp_thread_join(input_thread);
  ------------------
  |  |  215|      1|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  596|      1|    }
  597|       |
  598|    427|    close_sig_pipes();
  599|    427|    input_ctx = NULL;
  600|       |
  601|    427|    do_deactivate_getch2();
  602|    427|    close_tty();
  603|       |
  604|    427|    getch2_enabled = 0;
  605|       |    read_terminal = false;
  606|    427|}
terminal_in_background:
  609|  2.15M|{
  610|  2.15M|    return read_terminal && tcgetpgrp(STDERR_FILENO) != getpgrp();
  ------------------
  |  Branch (610:12): [True: 0, False: 2.15M]
  |  Branch (610:29): [True: 0, False: 0]
  ------------------
  611|  2.15M|}
terminal_get_size:
  614|     36|{
  615|     36|    struct winsize ws;
  616|     36|    if (ioctl(tty_in, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col)
  ------------------
  |  Branch (616:9): [True: 36, False: 0]
  |  Branch (616:47): [True: 0, False: 0]
  |  Branch (616:61): [True: 0, False: 0]
  ------------------
  617|     36|        return;
  618|       |
  619|      0|    *w = ws.ws_col;
  620|      0|    *h = ws.ws_row;
  621|      0|}
terminal_lock_output:
  645|  1.21M|{
  646|  1.21M|    mp_mutex_lock(&output_lock);
  ------------------
  |  |  134|  1.21M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  647|  1.21M|}
terminal_unlock_output:
  650|  1.21M|{
  651|  1.21M|    mp_mutex_unlock(&output_lock);
  ------------------
  |  |  136|  1.21M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  652|  1.21M|}
terminal_init:
  655|    427|{
  656|    427|    mp_assert(!getch2_enabled);
  ------------------
  |  |   41|    427|#define mp_assert assert
  ------------------
  |  Branch (656:5): [True: 427, False: 0]
  ------------------
  657|    427|    getch2_enabled = 1;
  658|       |
  659|    427|    if (mp_make_wakeup_pipe(stop_cont_pipe) < 0) {
  ------------------
  |  Branch (659:9): [True: 0, False: 427]
  ------------------
  660|      0|        getch2_enabled = 0;
  661|      0|        return;
  662|      0|    }
  663|       |
  664|    427|    tty_in = tty_out = open("/dev/tty", O_RDWR | O_CLOEXEC);
  ------------------
  |  |  269|    427|#define open(...) mp_open(__VA_ARGS__)
  ------------------
  665|    427|    if (tty_in < 0) {
  ------------------
  |  Branch (665:9): [True: 0, False: 427]
  ------------------
  666|      0|        tty_in = STDIN_FILENO;
  667|      0|        tty_out = STDOUT_FILENO;
  668|      0|    }
  669|       |
  670|    427|    tcgetattr(tty_in, &tio_orig);
  671|       |
  672|       |    // handlers to fix terminal settings
  673|    427|    setsigaction(SIGCONT, stop_cont_sighandler, 0, true, &old_sigcont);
  674|    427|    setsigaction(SIGTSTP, stop_cont_sighandler, 0, true, &old_sigtstp);
  675|    427|    setsigaction(SIGWINCH, winch_sighandler, 0, true, &old_sigwinch);
  676|    427|    setsigaction(SIGTTIN, SIG_IGN, 0, true, &old_sigttin);
  677|    427|    setsigaction(SIGTTOU, SIG_IGN, 0, true, &old_sigttou);
  678|       |
  679|    427|    getch2_poll();
  680|    427|}
terminal-unix.c:terminal_thread:
  472|      1|{
  473|      1|    mp_thread_set_name("terminal/input");
  474|      1|    bool stdin_ok = read_terminal; // if false, we still wait for SIGTERM
  475|      1|    while (1) {
  ------------------
  |  Branch (475:12): [True: 1, Folded]
  ------------------
  476|      1|        getch2_poll();
  477|      1|        struct pollfd fds[3] = {
  478|      1|            { .events = POLLIN, .fd = death_pipe[0] },
  479|      1|            { .events = POLLIN, .fd = stop_cont_pipe[0] },
  480|      1|            { .events = POLLIN, .fd = tty_in }
  481|      1|        };
  482|       |        /*
  483|       |         * if the process isn't in foreground process group, then on macos
  484|       |         * polldev() doesn't rest and gets into 100% cpu usage (see issue #11795)
  485|       |         * with read() returning EIO. but we shouldn't quit on EIO either since
  486|       |         * the process might be foregrounded later.
  487|       |         *
  488|       |         * so just avoid poll-ing tty_in when we know the process is not in the
  489|       |         * foreground. there's a small race window, but the timeout will take
  490|       |         * care of it so it's fine.
  491|       |         */
  492|      1|        bool is_fg = tcgetpgrp(tty_in) == getpgrp();
  493|      1|        int r = polldev(fds, stdin_ok && is_fg ? 3 : 2, buf.len ? ESC_TIMEOUT : INPUT_TIMEOUT);
  ------------------
  |  |   43|      0|#define ESC_TIMEOUT 100
  ------------------
                      int r = polldev(fds, stdin_ok && is_fg ? 3 : 2, buf.len ? ESC_TIMEOUT : INPUT_TIMEOUT);
  ------------------
  |  |   51|      1|#define INPUT_TIMEOUT 1000
  ------------------
  |  Branch (493:30): [True: 0, False: 1]
  |  Branch (493:42): [True: 0, False: 0]
  |  Branch (493:57): [True: 0, False: 1]
  ------------------
  494|      1|        if (fds[0].revents) {
  ------------------
  |  Branch (494:13): [True: 1, False: 0]
  ------------------
  495|      1|            do_deactivate_getch2();
  496|      1|            break;
  497|      1|        }
  498|      0|        if (fds[1].revents & POLLIN) {
  ------------------
  |  Branch (498:13): [True: 0, False: 0]
  ------------------
  499|      0|            int8_t c = -1;
  500|      0|            (void)read(stop_cont_pipe[0], &c, 1);
  501|      0|            if (c == PIPE_STOP) {
  ------------------
  |  Branch (501:17): [True: 0, False: 0]
  ------------------
  502|      0|                do_deactivate_getch2();
  503|      0|                if (isatty(STDERR_FILENO)) {
  ------------------
  |  Branch (503:21): [True: 0, False: 0]
  ------------------
  504|      0|                    (void)write(STDERR_FILENO, TERM_ESC_RESTORE_CURSOR,
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  505|      0|                                sizeof(TERM_ESC_RESTORE_CURSOR) - 1);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  506|      0|                }
  507|       |                // trying to reset SIGTSTP handler to default and raise it will
  508|       |                // result in a race and there's no other way to invoke the
  509|       |                // default handler. so just invoke SIGSTOP since it's
  510|       |                // effectively the same thing.
  511|      0|                raise(SIGSTOP);
  512|      0|            } else if (c == PIPE_CONT) {
  ------------------
  |  Branch (512:24): [True: 0, False: 0]
  ------------------
  513|      0|                getch2_poll();
  514|      0|            } else if (c == PIPE_WINCH) {
  ------------------
  |  Branch (514:24): [True: 0, False: 0]
  ------------------
  515|      0|                notify_resize();
  516|      0|            }
  517|      0|        }
  518|      0|        if (fds[2].revents) {
  ------------------
  |  Branch (518:13): [True: 0, False: 0]
  ------------------
  519|      0|            int retval = read(tty_in, &buf.b[buf.len], BUF_LEN - buf.len);
  ------------------
  |  |  188|      0|#define BUF_LEN 256
  ------------------
  520|      0|            if (!retval || (retval == -1 && errno != EINTR && errno != EAGAIN && errno != EIO))
  ------------------
  |  Branch (520:17): [True: 0, False: 0]
  |  Branch (520:29): [True: 0, False: 0]
  |  Branch (520:45): [True: 0, False: 0]
  |  Branch (520:63): [True: 0, False: 0]
  |  Branch (520:82): [True: 0, False: 0]
  ------------------
  521|      0|                break; // EOF/closed
  522|      0|            if (retval > 0) {
  ------------------
  |  Branch (522:17): [True: 0, False: 0]
  ------------------
  523|      0|                buf.len += retval;
  524|      0|                process_input(input_ctx, false);
  525|      0|            }
  526|      0|        }
  527|      0|        if (r == 0)
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            process_input(input_ctx, true);
  529|      0|    }
  530|      1|    char c;
  531|      1|    bool quit = read(death_pipe[0], &c, 1) == 1 && c == 1;
  ------------------
  |  Branch (531:17): [True: 1, False: 0]
  |  Branch (531:52): [True: 0, False: 1]
  ------------------
  532|       |    // Important if we received SIGTERM, rather than regular quit.
  533|      1|    if (quit) {
  ------------------
  |  Branch (533:9): [True: 0, False: 1]
  ------------------
  534|      0|        struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit 4"), "");
  535|      0|        if (cmd)
  ------------------
  |  Branch (535:13): [True: 0, False: 0]
  ------------------
  536|      0|            mp_input_queue_cmd(input_ctx, cmd);
  537|      0|    }
  538|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|      1|#define MP_THREAD_RETURN() return NULL
  ------------------
  539|      1|}
terminal-unix.c:close_sig_pipes:
  449|    427|{
  450|  1.28k|    for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (450:21): [True: 854, False: 427]
  ------------------
  451|    854|        safe_close(&death_pipe[n]);
  452|    854|        safe_close(&stop_cont_pipe[n]);
  453|    854|    }
  454|    427|}
terminal-unix.c:safe_close:
  442|  1.70k|{
  443|  1.70k|    if (*p >= 0)
  ------------------
  |  Branch (443:9): [True: 856, False: 852]
  ------------------
  444|    856|        close(*p);
  445|  1.70k|    *p = -1;
  446|  1.70k|}
terminal-unix.c:close_tty:
  457|    427|{
  458|    427|    if (tty_in >= 0 && tty_in != STDIN_FILENO)
  ------------------
  |  Branch (458:9): [True: 427, False: 0]
  |  Branch (458:24): [True: 427, False: 0]
  ------------------
  459|    427|        close(tty_in);
  460|       |
  461|    427|    tty_in = tty_out = -1;
  462|    427|}
terminal-unix.c:setsigaction:
  371|  2.13k|{
  372|  2.13k|    struct sigaction sa;
  373|  2.13k|    sa.sa_handler = handler;
  374|       |
  375|  2.13k|    if (do_mask)
  ------------------
  |  Branch (375:9): [True: 2.13k, False: 1]
  ------------------
  376|  2.13k|        sigfillset(&sa.sa_mask);
  377|      1|    else
  378|      1|        sigemptyset(&sa.sa_mask);
  379|       |
  380|       |    sa.sa_flags = flags | SA_RESTART;
  381|  2.13k|    return sigaction(signo, &sa, old);
  382|  2.13k|}
terminal-unix.c:restore_sigaction:
  570|  2.13k|{
  571|  2.13k|    struct sigaction cur;
  572|  2.13k|    if (!sigaction(signo, NULL, &cur) && cur.sa_handler == handler)
  ------------------
  |  Branch (572:9): [True: 2.13k, False: 0]
  |  Branch (572:42): [True: 2.13k, False: 0]
  ------------------
  573|  2.13k|        sigaction(signo, old, NULL);
  574|  2.13k|}
terminal-unix.c:do_deactivate_getch2:
  355|    856|{
  356|    856|    if (!getch2_active)
  ------------------
  |  Branch (356:9): [True: 856, False: 0]
  ------------------
  357|    856|        return;
  358|       |
  359|      0|    enable_kx(false);
  360|      0|    tcsetattr(tty_in, TCSANOW, &tio_orig);
  361|       |
  362|      0|    getch2_active = 0;
  363|      0|}
terminal-unix.c:getch2_poll:
  385|    428|{
  386|    428|    if (!getch2_enabled)
  ------------------
  |  Branch (386:9): [True: 0, False: 428]
  ------------------
  387|      0|        return;
  388|       |
  389|       |    // check if stdin is in the foreground process group
  390|    428|    int newstatus = (tcgetpgrp(tty_in) == getpgrp());
  391|       |
  392|       |    // and activate getch2 if it is, deactivate otherwise
  393|    428|    if (newstatus)
  ------------------
  |  Branch (393:9): [True: 0, False: 428]
  ------------------
  394|      0|        do_activate_getch2();
  395|    428|    else
  396|    428|        do_deactivate_getch2();
  397|    428|}

buffer.c:mp_cond_broadcast:
  166|  1.10M|{
  167|  1.10M|    mp_assert(cond);
  ------------------
  |  |   41|  1.10M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 1.10M, False: 1]
  ------------------
  168|  1.10M|    return pthread_cond_broadcast(&cond->cond);
  169|  1.10M|}
buffer.c:mp_cond_timedwait:
  184|  1.00M|{
  185|  1.00M|    mp_assert(cond);
  ------------------
  |  |   41|  1.00M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 1.00M, False: 0]
  ------------------
  186|       |
  187|  1.00M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  1.00M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 1.00M]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  1.00M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  1.00M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 951k, False: 49.8k]
  ------------------
  190|   951k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  49.8k|    struct timespec ts;
  193|  49.8k|    clock_gettime(cond->clk_id, &ts);
  194|  49.8k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  49.8k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  49.8k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  49.8k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  49.8k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  49.8k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 2.22k, False: 47.6k]
  ------------------
  197|  2.22k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  2.22k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  2.22k|        ts.tv_sec++;
  199|  2.22k|    }
  200|       |
  201|  49.8k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  1.00M|}
buffer.c:mp_cond_destroy:
  160|  30.0k|{
  161|  30.0k|    mp_assert(cond);
  ------------------
  |  |   41|  30.0k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 30.0k, False: 0]
  ------------------
  162|  30.0k|    return pthread_cond_destroy(&cond->cond);
  163|  30.0k|}
buffer.c:mp_mutex_init:
  113|  30.0k|{
  114|  30.0k|#ifndef NDEBUG
  115|  30.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  30.0k|    int ret = 0;
  121|  30.0k|    pthread_mutexattr_t attr;
  122|  30.0k|    ret = pthread_mutexattr_init(&attr);
  123|  30.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 30.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  30.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  30.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  30.0k|    pthread_mutexattr_destroy(&attr);
  129|  30.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  30.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 30.0k, False: 0]
  ------------------
  130|  30.0k|    return ret;
  131|  30.0k|}
buffer.c:mp_cond_init:
  139|  30.0k|{
  140|  30.0k|    mp_assert(cond);
  ------------------
  |  |   41|  30.0k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 30.0k, False: 0]
  ------------------
  141|       |
  142|  30.0k|    int ret = 0;
  143|  30.0k|    pthread_condattr_t attr;
  144|  30.0k|    ret = pthread_condattr_init(&attr);
  145|  30.0k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 30.0k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  30.0k|    cond->clk_id = CLOCK_REALTIME;
  149|  30.0k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  30.0k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 30.0k, False: 0]
  ------------------
  151|  30.0k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  30.0k|#endif
  153|       |
  154|  30.0k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  30.0k|    pthread_condattr_destroy(&attr);
  156|  30.0k|    return ret;
  157|  30.0k|}
buffer.c:mp_thread_set_name:
  222|  15.0k|{
  223|  15.0k|#if HAVE_GLIBC_THREAD_NAME
  224|  15.0k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|}
msg.c:mp_mutex_init:
  113|  46.6k|{
  114|  46.6k|#ifndef NDEBUG
  115|  46.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  46.6k|    int ret = 0;
  121|  46.6k|    pthread_mutexattr_t attr;
  122|  46.6k|    ret = pthread_mutexattr_init(&attr);
  123|  46.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 46.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  46.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  46.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  46.6k|    pthread_mutexattr_destroy(&attr);
  129|  46.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  46.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 46.6k, False: 0]
  ------------------
  130|  46.6k|    return ret;
  131|  46.6k|}
msg.c:mp_cond_init:
  139|  11.6k|{
  140|  11.6k|    mp_assert(cond);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 11.6k, False: 0]
  ------------------
  141|       |
  142|  11.6k|    int ret = 0;
  143|  11.6k|    pthread_condattr_t attr;
  144|  11.6k|    ret = pthread_condattr_init(&attr);
  145|  11.6k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 11.6k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  11.6k|    cond->clk_id = CLOCK_REALTIME;
  149|  11.6k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  11.6k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 11.6k, False: 0]
  ------------------
  151|  11.6k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  11.6k|#endif
  153|       |
  154|  11.6k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  11.6k|    pthread_condattr_destroy(&attr);
  156|  11.6k|    return ret;
  157|  11.6k|}
msg.c:mp_cond_destroy:
  160|  11.6k|{
  161|  11.6k|    mp_assert(cond);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 11.6k, False: 0]
  ------------------
  162|  11.6k|    return pthread_cond_destroy(&cond->cond);
  163|  11.6k|}
stats.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
stats.c:mp_thread_cpu_time_ns:
  244|     36|{
  245|     36|#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_THREAD_CPUTIME)
  246|     36|    clockid_t id;
  247|     36|    struct timespec ts;
  248|     36|    if (pthread_getcpuclockid(thread, &id) == 0 && clock_gettime(id, &ts) == 0)
  ------------------
  |  Branch (248:9): [True: 36, False: 0]
  |  Branch (248:52): [True: 36, False: 0]
  ------------------
  249|     36|        return MP_TIME_S_TO_NS(ts.tv_sec) + ts.tv_nsec;
  ------------------
  |  |   71|     36|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  250|      0|#endif
  251|      0|    return -1;
  252|     36|}
demux.c:mp_cond_destroy:
  160|   360k|{
  161|   360k|    mp_assert(cond);
  ------------------
  |  |   41|   360k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 360k, False: 0]
  ------------------
  162|   360k|    return pthread_cond_destroy(&cond->cond);
  163|   360k|}
demux.c:mp_cond_signal:
  172|  52.1M|{
  173|  52.1M|    mp_assert(cond);
  ------------------
  |  |   41|  52.1M|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 52.1M, False: 0]
  ------------------
  174|  52.1M|    return pthread_cond_signal(&cond->cond);
  175|  52.1M|}
demux.c:mp_thread_set_name:
  222|  14.7k|{
  223|  14.7k|#if HAVE_GLIBC_THREAD_NAME
  224|  14.7k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 14.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|  14.7k|}
demux.c:mp_cond_timedwait_until:
  205|  6.49M|{
  206|  6.49M|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  6.49M|}
demux.c:mp_cond_timedwait:
  184|  6.49M|{
  185|  6.49M|    mp_assert(cond);
  ------------------
  |  |   41|  6.49M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 6.49M, False: 0]
  ------------------
  186|       |
  187|  6.49M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  6.49M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 6.49M]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  6.49M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  6.49M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 6.49M, False: 0]
  ------------------
  190|  6.49M|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|      0|    struct timespec ts;
  193|      0|    clock_gettime(cond->clk_id, &ts);
  194|      0|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|      0|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|      0|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|      0|        ts.tv_sec++;
  199|      0|    }
  200|       |
  201|      0|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  6.49M|}
demux.c:mp_mutex_init:
  113|   360k|{
  114|   360k|#ifndef NDEBUG
  115|   360k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   360k|    int ret = 0;
  121|   360k|    pthread_mutexattr_t attr;
  122|   360k|    ret = pthread_mutexattr_init(&attr);
  123|   360k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 360k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   360k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   360k|    ret = pthread_mutex_init(mutex, &attr);
  128|   360k|    pthread_mutexattr_destroy(&attr);
  129|   360k|    mp_assert(!ret);
  ------------------
  |  |   41|   360k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 360k, False: 0]
  ------------------
  130|   360k|    return ret;
  131|   360k|}
demux.c:mp_cond_init:
  139|   360k|{
  140|   360k|    mp_assert(cond);
  ------------------
  |  |   41|   360k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 360k, False: 0]
  ------------------
  141|       |
  142|   360k|    int ret = 0;
  143|   360k|    pthread_condattr_t attr;
  144|   360k|    ret = pthread_condattr_init(&attr);
  145|   360k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 360k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|   360k|    cond->clk_id = CLOCK_REALTIME;
  149|   360k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|   360k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 360k, False: 0]
  ------------------
  151|   360k|        cond->clk_id = CLOCK_MONOTONIC;
  152|   360k|#endif
  153|       |
  154|   360k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|   360k|    pthread_condattr_destroy(&attr);
  156|   360k|    return ret;
  157|   360k|}
packet_pool.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
f_async_queue.c:mp_mutex_init:
  113|  15.0k|{
  114|  15.0k|#ifndef NDEBUG
  115|  15.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  15.0k|    int ret = 0;
  121|  15.0k|    pthread_mutexattr_t attr;
  122|  15.0k|    ret = pthread_mutexattr_init(&attr);
  123|  15.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 15.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  15.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  15.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  15.0k|    pthread_mutexattr_destroy(&attr);
  129|  15.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  15.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 15.0k, False: 0]
  ------------------
  130|  15.0k|    return ret;
  131|  15.0k|}
f_decoder_wrapper.c:mp_mutex_init:
  113|  46.5k|{
  114|  46.5k|#ifndef NDEBUG
  115|  46.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  46.5k|    int ret = 0;
  121|  46.5k|    pthread_mutexattr_t attr;
  122|  46.5k|    ret = pthread_mutexattr_init(&attr);
  123|  46.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 46.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  46.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  46.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  46.5k|    pthread_mutexattr_destroy(&attr);
  129|  46.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  46.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 46.5k, False: 0]
  ------------------
  130|  46.5k|    return ret;
  131|  46.5k|}
filter.c:mp_mutex_init:
  113|  31.2k|{
  114|  31.2k|#ifndef NDEBUG
  115|  31.2k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  31.2k|    int ret = 0;
  121|  31.2k|    pthread_mutexattr_t attr;
  122|  31.2k|    ret = pthread_mutexattr_init(&attr);
  123|  31.2k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 31.2k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  31.2k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  31.2k|    ret = pthread_mutex_init(mutex, &attr);
  128|  31.2k|    pthread_mutexattr_destroy(&attr);
  129|  31.2k|    mp_assert(!ret);
  ------------------
  |  |   41|  31.2k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 31.2k, False: 0]
  ------------------
  130|  31.2k|    return ret;
  131|  31.2k|}
input.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
dispatch.c:mp_cond_destroy:
  160|  48.3k|{
  161|  48.3k|    mp_assert(cond);
  ------------------
  |  |   41|  48.3k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 48.3k, False: 0]
  ------------------
  162|  48.3k|    return pthread_cond_destroy(&cond->cond);
  163|  48.3k|}
dispatch.c:mp_mutex_init:
  113|  48.3k|{
  114|  48.3k|#ifndef NDEBUG
  115|  48.3k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  48.3k|    int ret = 0;
  121|  48.3k|    pthread_mutexattr_t attr;
  122|  48.3k|    ret = pthread_mutexattr_init(&attr);
  123|  48.3k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 48.3k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  48.3k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  48.3k|    ret = pthread_mutex_init(mutex, &attr);
  128|  48.3k|    pthread_mutexattr_destroy(&attr);
  129|  48.3k|    mp_assert(!ret);
  ------------------
  |  |   41|  48.3k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 48.3k, False: 0]
  ------------------
  130|  48.3k|    return ret;
  131|  48.3k|}
dispatch.c:mp_cond_init:
  139|  48.3k|{
  140|  48.3k|    mp_assert(cond);
  ------------------
  |  |   41|  48.3k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 48.3k, False: 0]
  ------------------
  141|       |
  142|  48.3k|    int ret = 0;
  143|  48.3k|    pthread_condattr_t attr;
  144|  48.3k|    ret = pthread_condattr_init(&attr);
  145|  48.3k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 48.3k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  48.3k|    cond->clk_id = CLOCK_REALTIME;
  149|  48.3k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  48.3k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 48.3k, False: 0]
  ------------------
  151|  48.3k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  48.3k|#endif
  153|       |
  154|  48.3k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  48.3k|    pthread_condattr_destroy(&attr);
  156|  48.3k|    return ret;
  157|  48.3k|}
dispatch.c:mp_cond_wait:
  178|  1.22M|{
  179|  1.22M|    mp_assert(cond);
  ------------------
  |  |   41|  1.22M|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 1.22M, False: 0]
  ------------------
  180|  1.22M|    return pthread_cond_wait(&cond->cond, mutex);
  181|  1.22M|}
dispatch.c:mp_cond_broadcast:
  166|  37.8M|{
  167|  37.8M|    mp_assert(cond);
  ------------------
  |  |   41|  37.8M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 37.8M, False: 14]
  ------------------
  168|  37.8M|    return pthread_cond_broadcast(&cond->cond);
  169|  37.8M|}
dispatch.c:mp_cond_timedwait_until:
  205|   989k|{
  206|   989k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   989k|}
dispatch.c:mp_cond_timedwait:
  184|   989k|{
  185|   989k|    mp_assert(cond);
  ------------------
  |  |   41|   989k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 989k, False: 0]
  ------------------
  186|       |
  187|   989k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   989k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 49, False: 989k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   989k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   989k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 24.0k, False: 965k]
  ------------------
  190|  24.0k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|   965k|    struct timespec ts;
  193|   965k|    clock_gettime(cond->clk_id, &ts);
  194|   965k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   965k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|   965k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   965k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|   965k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|   965k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 221k, False: 744k]
  ------------------
  197|   221k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|   221k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|   221k|        ts.tv_sec++;
  199|   221k|    }
  200|       |
  201|   965k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   989k|}
rendezvous.c:mp_cond_broadcast:
  166|  31.9k|{
  167|  31.9k|    mp_assert(cond);
  ------------------
  |  |   41|  31.9k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 31.9k, False: 0]
  ------------------
  168|  31.9k|    return pthread_cond_broadcast(&cond->cond);
  169|  31.9k|}
rendezvous.c:mp_cond_wait:
  178|  31.9k|{
  179|  31.9k|    mp_assert(cond);
  ------------------
  |  |   41|  31.9k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 31.9k, False: 0]
  ------------------
  180|  31.9k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  31.9k|}
thread_pool.c:mp_cond_broadcast:
  166|  11.6k|{
  167|  11.6k|    mp_assert(cond);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 11.6k, False: 0]
  ------------------
  168|  11.6k|    return pthread_cond_broadcast(&cond->cond);
  169|  11.6k|}
thread_pool.c:mp_cond_destroy:
  160|  11.6k|{
  161|  11.6k|    mp_assert(cond);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 11.6k, False: 0]
  ------------------
  162|  11.6k|    return pthread_cond_destroy(&cond->cond);
  163|  11.6k|}
thread_pool.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
thread_pool.c:mp_cond_init:
  139|  11.6k|{
  140|  11.6k|    mp_assert(cond);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 11.6k, False: 0]
  ------------------
  141|       |
  142|  11.6k|    int ret = 0;
  143|  11.6k|    pthread_condattr_t attr;
  144|  11.6k|    ret = pthread_condattr_init(&attr);
  145|  11.6k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 11.6k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  11.6k|    cond->clk_id = CLOCK_REALTIME;
  149|  11.6k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  11.6k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 11.6k, False: 0]
  ------------------
  151|  11.6k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  11.6k|#endif
  153|       |
  154|  11.6k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  11.6k|    pthread_condattr_destroy(&attr);
  156|  11.6k|    return ret;
  157|  11.6k|}
thread_pool.c:mp_thread_set_name:
  222|  12.0k|{
  223|  12.0k|#if HAVE_GLIBC_THREAD_NAME
  224|  12.0k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 12.0k]
  ------------------
  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|  12.0k|}
thread_pool.c:mp_cond_timedwait_until:
  205|  25.0k|{
  206|  25.0k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  25.0k|}
thread_pool.c:mp_cond_timedwait:
  184|  25.0k|{
  185|  25.0k|    mp_assert(cond);
  ------------------
  |  |   41|  25.0k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 25.0k, False: 0]
  ------------------
  186|       |
  187|  25.0k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  25.0k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 25.0k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  25.0k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  25.0k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 0, False: 25.0k]
  ------------------
  190|      0|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  25.0k|    struct timespec ts;
  193|  25.0k|    clock_gettime(cond->clk_id, &ts);
  194|  25.0k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  25.0k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  25.0k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  25.0k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  25.0k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  25.0k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 25.0k, False: 0]
  ------------------
  197|  25.0k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  25.0k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  25.0k|        ts.tv_sec++;
  199|  25.0k|    }
  200|       |
  201|  25.0k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  25.0k|}
thread_pool.c:mp_cond_wait:
  178|   141k|{
  179|   141k|    mp_assert(cond);
  ------------------
  |  |   41|   141k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 141k, False: 0]
  ------------------
  180|   141k|    return pthread_cond_wait(&cond->cond, mutex);
  181|   141k|}
thread_pool.c:mp_cond_signal:
  172|   166k|{
  173|   166k|    mp_assert(cond);
  ------------------
  |  |   41|   166k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 166k, False: 0]
  ------------------
  174|   166k|    return pthread_cond_signal(&cond->cond);
  175|   166k|}
thread_tools.c:mp_cond_wait:
  178|   152k|{
  179|   152k|    mp_assert(cond);
  ------------------
  |  |   41|   152k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 152k, False: 0]
  ------------------
  180|   152k|    return pthread_cond_wait(&cond->cond, mutex);
  181|   152k|}
thread_tools.c:mp_cond_destroy:
  160|   821k|{
  161|   821k|    mp_assert(cond);
  ------------------
  |  |   41|   821k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 821k, False: 0]
  ------------------
  162|   821k|    return pthread_cond_destroy(&cond->cond);
  163|   821k|}
thread_tools.c:mp_cond_signal:
  172|   617k|{
  173|   617k|    mp_assert(cond);
  ------------------
  |  |   41|   617k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 617k, False: 0]
  ------------------
  174|   617k|    return pthread_cond_signal(&cond->cond);
  175|   617k|}
thread_tools.c:mp_mutex_init:
  113|   204k|{
  114|   204k|#ifndef NDEBUG
  115|   204k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   204k|    int ret = 0;
  121|   204k|    pthread_mutexattr_t attr;
  122|   204k|    ret = pthread_mutexattr_init(&attr);
  123|   204k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 204k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   204k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   204k|    ret = pthread_mutex_init(mutex, &attr);
  128|   204k|    pthread_mutexattr_destroy(&attr);
  129|   204k|    mp_assert(!ret);
  ------------------
  |  |   41|   204k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 204k, False: 0]
  ------------------
  130|   204k|    return ret;
  131|   204k|}
thread_tools.c:mp_cond_init:
  139|   204k|{
  140|   204k|    mp_assert(cond);
  ------------------
  |  |   41|   204k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 204k, False: 0]
  ------------------
  141|       |
  142|   204k|    int ret = 0;
  143|   204k|    pthread_condattr_t attr;
  144|   204k|    ret = pthread_condattr_init(&attr);
  145|   204k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 204k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|   204k|    cond->clk_id = CLOCK_REALTIME;
  149|   204k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|   204k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 204k, False: 0]
  ------------------
  151|   204k|        cond->clk_id = CLOCK_MONOTONIC;
  152|   204k|#endif
  153|       |
  154|   204k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|   204k|    pthread_condattr_destroy(&attr);
  156|   204k|    return ret;
  157|   204k|}
thread_tools.c:mp_cond_broadcast:
  166|  72.8k|{
  167|  72.8k|    mp_assert(cond);
  ------------------
  |  |   41|  72.8k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 72.8k, False: 0]
  ------------------
  168|  72.8k|    return pthread_cond_broadcast(&cond->cond);
  169|  72.8k|}
m_config_core.c:mp_mutex_init:
  113|  36.1k|{
  114|  36.1k|#ifndef NDEBUG
  115|  36.1k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  36.1k|    int ret = 0;
  121|  36.1k|    pthread_mutexattr_t attr;
  122|  36.1k|    ret = pthread_mutexattr_init(&attr);
  123|  36.1k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 36.1k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  36.1k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  36.1k|    ret = pthread_mutex_init(mutex, &attr);
  128|  36.1k|    pthread_mutexattr_destroy(&attr);
  129|  36.1k|    mp_assert(!ret);
  ------------------
  |  |   41|  36.1k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 36.1k, False: 0]
  ------------------
  130|  36.1k|    return ret;
  131|  36.1k|}
client.c:mp_mutex_init:
  113|  81.7k|{
  114|  81.7k|#ifndef NDEBUG
  115|  81.7k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  81.7k|    int ret = 0;
  121|  81.7k|    pthread_mutexattr_t attr;
  122|  81.7k|    ret = pthread_mutexattr_init(&attr);
  123|  81.7k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 81.7k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  81.7k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  81.7k|    ret = pthread_mutex_init(mutex, &attr);
  128|  81.7k|    pthread_mutexattr_destroy(&attr);
  129|  81.7k|    mp_assert(!ret);
  ------------------
  |  |   41|  81.7k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 81.7k, False: 0]
  ------------------
  130|  81.7k|    return ret;
  131|  81.7k|}
client.c:mp_cond_init:
  139|  35.0k|{
  140|  35.0k|    mp_assert(cond);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 35.0k, False: 0]
  ------------------
  141|       |
  142|  35.0k|    int ret = 0;
  143|  35.0k|    pthread_condattr_t attr;
  144|  35.0k|    ret = pthread_condattr_init(&attr);
  145|  35.0k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 35.0k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  35.0k|    cond->clk_id = CLOCK_REALTIME;
  149|  35.0k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  35.0k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 35.0k, False: 0]
  ------------------
  151|  35.0k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  35.0k|#endif
  153|       |
  154|  35.0k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  35.0k|    pthread_condattr_destroy(&attr);
  156|  35.0k|    return ret;
  157|  35.0k|}
client.c:mp_cond_timedwait_until:
  205|  5.46M|{
  206|  5.46M|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  5.46M|}
client.c:mp_cond_timedwait:
  184|  5.46M|{
  185|  5.46M|    mp_assert(cond);
  ------------------
  |  |   41|  5.46M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 5.46M, False: 0]
  ------------------
  186|       |
  187|  5.46M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  5.46M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 5.34M, False: 118k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  5.46M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  5.46M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 117k, False: 5.34M]
  ------------------
  190|   117k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  5.34M|    struct timespec ts;
  193|  5.34M|    clock_gettime(cond->clk_id, &ts);
  194|  5.34M|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  5.34M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  5.34M|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  5.34M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  5.34M|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  5.34M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 825, False: 5.34M]
  ------------------
  197|    825|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|    825|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|    825|        ts.tv_sec++;
  199|    825|    }
  200|       |
  201|  5.34M|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  5.46M|}
client.c:mp_cond_destroy:
  160|  35.0k|{
  161|  35.0k|    mp_assert(cond);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 35.0k, False: 0]
  ------------------
  162|  35.0k|    return pthread_cond_destroy(&cond->cond);
  163|  35.0k|}
client.c:mp_thread_set_name:
  222|  11.6k|{
  223|  11.6k|#if HAVE_GLIBC_THREAD_NAME
  224|  11.6k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 11.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|  11.6k|}
client.c:mp_cond_broadcast:
  166|  5.49M|{
  167|  5.49M|    mp_assert(cond);
  ------------------
  |  |   41|  5.49M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 5.49M, False: 0]
  ------------------
  168|  5.49M|    return pthread_cond_broadcast(&cond->cond);
  169|  5.49M|}
loadfile.c:mp_thread_set_name:
  222|  16.1k|{
  223|  16.1k|#if HAVE_GLIBC_THREAD_NAME
  224|  16.1k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 16.1k]
  ------------------
  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|  16.1k|}
main.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
osd.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
clipboard.c:mp_mutex_init:
  113|  11.6k|{
  114|  11.6k|#ifndef NDEBUG
  115|  11.6k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  11.6k|    int ret = 0;
  121|  11.6k|    pthread_mutexattr_t attr;
  122|  11.6k|    ret = pthread_mutexattr_init(&attr);
  123|  11.6k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 11.6k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  11.6k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  11.6k|    ret = pthread_mutex_init(mutex, &attr);
  128|  11.6k|    pthread_mutexattr_destroy(&attr);
  129|  11.6k|    mp_assert(!ret);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 11.6k, False: 0]
  ------------------
  130|  11.6k|    return ret;
  131|  11.6k|}
dec_sub.c:mp_mutex_init:
  113|  4.76k|{
  114|  4.76k|#ifndef NDEBUG
  115|  4.76k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  4.76k|    int ret = 0;
  121|  4.76k|    pthread_mutexattr_t attr;
  122|  4.76k|    ret = pthread_mutexattr_init(&attr);
  123|  4.76k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 4.76k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  4.76k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  4.76k|    ret = pthread_mutex_init(mutex, &attr);
  128|  4.76k|    pthread_mutexattr_destroy(&attr);
  129|  4.76k|    mp_assert(!ret);
  ------------------
  |  |   41|  4.76k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 4.76k, False: 0]
  ------------------
  130|  4.76k|    return ret;
  131|  4.76k|}
vd_lavc.c:mp_mutex_init:
  113|  29.8k|{
  114|  29.8k|#ifndef NDEBUG
  115|  29.8k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  29.8k|    int ret = 0;
  121|  29.8k|    pthread_mutexattr_t attr;
  122|  29.8k|    ret = pthread_mutexattr_init(&attr);
  123|  29.8k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 29.8k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  29.8k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  29.8k|    ret = pthread_mutex_init(mutex, &attr);
  128|  29.8k|    pthread_mutexattr_destroy(&attr);
  129|  29.8k|    mp_assert(!ret);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 29.8k, False: 0]
  ------------------
  130|  29.8k|    return ret;
  131|  29.8k|}
vo.c:mp_mutex_init:
  113|  63.8k|{
  114|  63.8k|#ifndef NDEBUG
  115|  63.8k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  63.8k|    int ret = 0;
  121|  63.8k|    pthread_mutexattr_t attr;
  122|  63.8k|    ret = pthread_mutexattr_init(&attr);
  123|  63.8k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 63.8k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  63.8k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  63.8k|    ret = pthread_mutex_init(mutex, &attr);
  128|  63.8k|    pthread_mutexattr_destroy(&attr);
  129|  63.8k|    mp_assert(!ret);
  ------------------
  |  |   41|  63.8k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 63.8k, False: 0]
  ------------------
  130|  63.8k|    return ret;
  131|  63.8k|}
vo.c:mp_cond_init:
  139|  31.9k|{
  140|  31.9k|    mp_assert(cond);
  ------------------
  |  |   41|  31.9k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 31.9k, False: 0]
  ------------------
  141|       |
  142|  31.9k|    int ret = 0;
  143|  31.9k|    pthread_condattr_t attr;
  144|  31.9k|    ret = pthread_condattr_init(&attr);
  145|  31.9k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 31.9k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  31.9k|    cond->clk_id = CLOCK_REALTIME;
  149|  31.9k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  31.9k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 31.9k, False: 0]
  ------------------
  151|  31.9k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  31.9k|#endif
  153|       |
  154|  31.9k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  31.9k|    pthread_condattr_destroy(&attr);
  156|  31.9k|    return ret;
  157|  31.9k|}
vo.c:mp_thread_set_name:
  222|  31.9k|{
  223|  31.9k|#if HAVE_GLIBC_THREAD_NAME
  224|  31.9k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 31.9k]
  ------------------
  225|      0|        char tname[16] = {0}; // glibc-checked kernel limit
  226|      0|        strncpy(tname, name, sizeof(tname) - 1);
  227|      0|        pthread_setname_np(pthread_self(), tname);
  228|      0|    }
  229|       |#elif HAVE_BSD_THREAD_NAME
  230|       |    pthread_set_name_np(pthread_self(), name);
  231|       |#elif HAVE_MAC_THREAD_NAME
  232|       |    pthread_setname_np(name);
  233|       |#endif
  234|  31.9k|}
vo.c:mp_thread_set_min_timer_slack:
  237|  31.9k|{
  238|  31.9k|#if HAVE_PR_SET_TIMERSLACK
  239|       |    prctl(PR_SET_TIMERSLACK, 1UL);
  240|  31.9k|#endif
  241|  31.9k|}
vo.c:mp_cond_broadcast:
  166|  3.13M|{
  167|  3.13M|    mp_assert(cond);
  ------------------
  |  |   41|  3.13M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 3.13M, False: 0]
  ------------------
  168|  3.13M|    return pthread_cond_broadcast(&cond->cond);
  169|  3.13M|}
vo.c:mp_cond_destroy:
  160|  31.9k|{
  161|  31.9k|    mp_assert(cond);
  ------------------
  |  |   41|  31.9k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 31.9k, False: 0]
  ------------------
  162|  31.9k|    return pthread_cond_destroy(&cond->cond);
  163|  31.9k|}
vo.c:mp_cond_timedwait_until:
  205|  2.92M|{
  206|  2.92M|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  2.92M|}
vo.c:mp_cond_timedwait:
  184|  2.92M|{
  185|  2.92M|    mp_assert(cond);
  ------------------
  |  |   41|  2.92M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 2.92M, False: 0]
  ------------------
  186|       |
  187|  2.92M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  2.92M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 2.92M]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  2.92M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  2.92M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 0, False: 2.92M]
  ------------------
  190|      0|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  2.92M|    struct timespec ts;
  193|  2.92M|    clock_gettime(cond->clk_id, &ts);
  194|  2.92M|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  2.92M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  2.92M|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  2.92M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  2.92M|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  2.92M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 2.92M, False: 286]
  ------------------
  197|  2.92M|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  2.92M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  2.92M|        ts.tv_sec++;
  199|  2.92M|    }
  200|       |
  201|  2.92M|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  2.92M|}
vo.c:mp_cond_wait:
  178|  17.4k|{
  179|  17.4k|    mp_assert(cond);
  ------------------
  |  |   41|  17.4k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 17.4k, False: 0]
  ------------------
  180|  17.4k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  17.4k|}
terminal-unix.c:mp_thread_set_name:
  222|      1|{
  223|      1|#if HAVE_GLIBC_THREAD_NAME
  224|      1|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 1]
  ------------------
  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|      1|}

mp_sleep_ns:
   31|  36.7k|{
   32|  36.7k|    if (ns < 0)
  ------------------
  |  Branch (32:9): [True: 36.6k, False: 174]
  ------------------
   33|  36.6k|        return;
   34|    174|    struct timespec ts;
   35|    174|    ts.tv_sec  = ns / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|    174|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   36|    174|    ts.tv_nsec = ns % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|    174|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   37|       |    nanosleep(&ts, NULL);
   38|    174|}
mp_set_idle_power_mode:
   41|  45.9k|{
   42|  45.9k|}
mp_raw_time_ns:
   45|   391M|{
   46|   391M|    struct timespec tp = {0};
   47|   391M|    clock_gettime(clk_id, &tp);
   48|       |    return MP_TIME_S_TO_NS(tp.tv_sec) + tp.tv_nsec;
  ------------------
  |  |   71|   391M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
   49|   391M|}
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|  11.6k|{
   40|  11.6k|    mp_exec_once(&timer_init_once, do_timer_init);
  ------------------
  |  |  209|  11.6k|#define mp_exec_once pthread_once
  ------------------
   41|  11.6k|}
mp_time_ns:
   44|   391M|{
   45|   391M|    return mp_time_ns_from_raw_time(mp_raw_time_ns());
   46|   391M|}
mp_time_ns_from_raw_time:
   49|   391M|{
   50|   391M|    return raw_time - raw_time_offset;
   51|   391M|}
mp_time_sec:
   54|  66.0M|{
   55|  66.0M|    return mp_time_ns() / 1e9;
   56|  66.0M|}
mp_time_ns_add:
   59|  58.4M|{
   60|  58.4M|    mp_assert(time_ns > 0); // mp_time_ns() returns strictly positive values
  ------------------
  |  |   41|  58.4M|#define mp_assert assert
  ------------------
  |  Branch (60:5): [True: 58.4M, False: 18.4E]
  ------------------
   61|  58.4M|    double t = MPCLAMP(timeout_sec * 1e9, -0x1p63, 0x1p63);
  ------------------
  |  |   46|  58.4M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 58.4M]
  |  |  |  Branch (46:56): [True: 185k, False: 58.2M]
  |  |  ------------------
  ------------------
   62|  58.4M|    int64_t ti = t == 0x1p63 ? INT64_MAX : (int64_t)t;
  ------------------
  |  Branch (62:18): [True: 185k, False: 58.2M]
  ------------------
   63|  58.4M|    if (ti > INT64_MAX - time_ns)
  ------------------
  |  Branch (63:9): [True: 185k, False: 58.2M]
  ------------------
   64|   185k|        return INT64_MAX;
   65|  58.2M|    if (ti <= -time_ns)
  ------------------
  |  Branch (65:9): [True: 0, False: 58.2M]
  ------------------
   66|      0|        return 1;
   67|  58.2M|    return time_ns + ti;
   68|  58.2M|}
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|}

reinit_audio_filters:
  108|  22.5k|{
  109|  22.5k|    struct ao_chain *ao_c = mpctx->ao_chain;
  110|  22.5k|    if (!ao_c)
  ------------------
  |  Branch (110:9): [True: 8.23k, False: 14.3k]
  ------------------
  111|  8.23k|        return 0;
  112|       |
  113|  14.3k|    double delay = mp_output_get_measured_total_delay(ao_c->filter);
  114|       |
  115|  14.3k|    if (recreate_audio_filters(mpctx) < 0)
  ------------------
  |  Branch (115:9): [True: 78, False: 14.2k]
  ------------------
  116|     78|        return -1;
  117|       |
  118|  14.2k|    double ndelay = mp_output_get_measured_total_delay(ao_c->filter);
  119|       |
  120|       |    // Only force refresh if the amount of dropped buffered data is going to
  121|       |    // cause "issues" for the A/V sync logic.
  122|  14.2k|    if (mpctx->audio_status == STATUS_PLAYING && delay - ndelay >= 0.2)
  ------------------
  |  Branch (122:9): [True: 10.7k, False: 3.57k]
  |  Branch (122:50): [True: 0, False: 10.7k]
  ------------------
  123|      0|        issue_refresh_seek(mpctx, MPSEEK_EXACT);
  124|  14.2k|    return 1;
  125|  14.3k|}
audio_get_gain:
  174|  35.5k|{
  175|  35.5k|    struct MPOpts *opts = mpctx->opts;
  176|  35.5k|    float gain = MPMAX(opts->softvol_volume / 100.0, 0);
  ------------------
  |  |   44|  35.5k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 35.5k, False: 4]
  |  |  ------------------
  ------------------
  177|  35.5k|    gain = pow(gain, 3);
  178|  35.5k|    gain *= compute_replaygain(mpctx);
  179|  35.5k|    gain *= db_gain(opts->softvol_gain);
  180|  35.5k|    if (opts->softvol_mute)
  ------------------
  |  Branch (180:9): [True: 73, False: 35.5k]
  ------------------
  181|     73|        gain = 0.0;
  182|  35.5k|    return gain;
  183|  35.5k|}
audio_update_volume:
  187|  43.2k|{
  188|  43.2k|    struct ao_chain *ao_c = mpctx->ao_chain;
  189|  43.2k|    if (!ao_c || !ao_c->ao)
  ------------------
  |  Branch (189:9): [True: 12.2k, False: 30.9k]
  |  Branch (189:18): [True: 227, False: 30.7k]
  ------------------
  190|  12.4k|        return;
  191|       |
  192|  30.7k|    float gain = audio_get_gain(mpctx);
  193|  30.7k|    ao_set_gain(ao_c->ao, gain);
  194|  30.7k|}
update_playback_speed:
  198|  19.8k|{
  199|  19.8k|    mpctx->audio_speed = mpctx->opts->playback_speed * mpctx->speed_factor_a;
  200|  19.8k|    mpctx->video_speed = mpctx->opts->playback_speed * mpctx->speed_factor_v;
  201|       |
  202|  19.8k|    update_speed_filters(mpctx);
  203|  19.8k|}
reset_audio_state:
  231|  2.74M|{
  232|  2.74M|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (232:9): [True: 2.33M, False: 402k]
  ------------------
  233|  2.33M|        ao_chain_reset_state(mpctx->ao_chain);
  234|  2.33M|        struct track *t = mpctx->ao_chain->track;
  235|  2.33M|        if (t && t->dec)
  ------------------
  |  Branch (235:13): [True: 2.33M, False: 0]
  |  Branch (235:18): [True: 2.33M, False: 0]
  ------------------
  236|  2.33M|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  237|  2.33M|    }
  238|  2.74M|    mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (238:27): [True: 2.33M, False: 402k]
  ------------------
  239|  2.74M|    mpctx->delay = 0;
  240|  2.74M|}
uninit_audio_out:
  243|  51.8k|{
  244|  51.8k|    struct ao_chain *ao_c = mpctx->ao_chain;
  245|  51.8k|    if (ao_c) {
  ------------------
  |  Branch (245:9): [True: 17.2k, False: 34.5k]
  ------------------
  246|  17.2k|        ao_c->ao_queue = NULL;
  247|  17.2k|        TA_FREEP(&ao_c->queue_filter);
  ------------------
  |  |   81|  17.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  17.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  248|  17.2k|        ao_c->ao = NULL;
  249|  17.2k|    }
  250|  51.8k|    if (mpctx->ao) {
  ------------------
  |  Branch (250:9): [True: 15.0k, False: 36.8k]
  ------------------
  251|       |        // Note: with gapless_audio, stop_play is not correctly set
  252|  15.0k|        if ((mpctx->opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) &&
  ------------------
  |  Branch (252:14): [True: 15.0k, False: 1]
  |  Branch (252:44): [True: 0, False: 1]
  ------------------
  253|  15.0k|            ao_is_playing(mpctx->ao) && !get_internal_paused(mpctx))
  ------------------
  |  Branch (253:13): [True: 2.28k, False: 12.7k]
  |  Branch (253:41): [True: 91, False: 2.19k]
  ------------------
  254|     91|        {
  255|     91|            MP_VERBOSE(mpctx, "draining left over audio\n");
  ------------------
  |  |   92|     91|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     91|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  256|     91|            ao_drain(mpctx->ao);
  257|     91|        }
  258|  15.0k|        ao_uninit(mpctx->ao);
  259|       |
  260|  15.0k|        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  261|  15.0k|    }
  262|  51.8k|    mpctx->ao = NULL;
  263|       |    TA_FREEP(&mpctx->ao_filter_fmt);
  ------------------
  |  |   81|  51.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  51.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  264|  51.8k|}
uninit_audio_chain:
  289|  21.7k|{
  290|  21.7k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (290:9): [True: 16.7k, False: 5.05k]
  ------------------
  291|  16.7k|        ao_chain_uninit(mpctx->ao_chain);
  292|  16.7k|        mpctx->ao_chain = NULL;
  293|       |
  294|  16.7k|        mpctx->audio_status = STATUS_EOF;
  295|       |
  296|       |        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  297|  16.7k|    }
  298|  21.7k|}
init_audio_decoder:
  522|  16.7k|{
  523|  16.7k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  16.7k|#define mp_assert assert
  ------------------
  |  Branch (523:5): [True: 16.7k, False: 0]
  ------------------
  524|  16.7k|    if (!track->stream)
  ------------------
  |  Branch (524:9): [True: 0, False: 16.7k]
  ------------------
  525|      0|        goto init_error;
  526|       |
  527|  16.7k|    track->dec = mp_decoder_wrapper_create(mpctx->filter_root, track->stream);
  528|  16.7k|    if (!track->dec)
  ------------------
  |  Branch (528:9): [True: 0, False: 16.7k]
  ------------------
  529|      0|        goto init_error;
  530|       |
  531|  16.7k|    if (track->ao_c)
  ------------------
  |  Branch (531:9): [True: 16.7k, False: 0]
  ------------------
  532|  16.7k|        mp_decoder_wrapper_set_spdif_flag(track->dec, true);
  533|       |
  534|  16.7k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (534:9): [True: 0, False: 16.7k]
  ------------------
  535|      0|        goto init_error;
  536|       |
  537|  16.7k|    return 1;
  538|       |
  539|      0|init_error:
  540|      0|    if (track->sink)
  ------------------
  |  Branch (540:9): [True: 0, False: 0]
  ------------------
  541|      0|        mp_pin_disconnect(track->sink);
  542|      0|    track->sink = NULL;
  543|       |    track->dec_failed = true;
  544|      0|    return 0;
  545|  16.7k|}
reinit_audio_chain:
  548|  19.8k|{
  549|  19.8k|    struct track *track = NULL;
  550|  19.8k|    track = mpctx->current_track[0][STREAM_AUDIO];
  551|  19.8k|    if (!track || !track->stream) {
  ------------------
  |  Branch (551:9): [True: 3.07k, False: 16.7k]
  |  Branch (551:19): [True: 0, False: 16.7k]
  ------------------
  552|  3.07k|        if (!mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (552:13): [True: 3.07k, False: 0]
  ------------------
  553|  3.07k|            uninit_audio_out(mpctx);
  554|  3.07k|        error_on_track(mpctx, track);
  555|  3.07k|        return;
  556|  3.07k|    }
  557|  16.7k|    reinit_audio_chain_src(mpctx, track);
  558|  16.7k|}
reinit_audio_chain_src:
  603|  16.7k|{
  604|  16.7k|    mp_assert(!mpctx->ao_chain);
  ------------------
  |  |   41|  16.7k|#define mp_assert assert
  ------------------
  |  Branch (604:5): [True: 16.7k, False: 0]
  ------------------
  605|       |
  606|  16.7k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  607|       |
  608|  16.7k|    struct ao_chain *ao_c = talloc_zero(NULL, struct ao_chain);
  ------------------
  |  |   27|  16.7k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  16.7k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  16.7k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|  16.7k|    mpctx->ao_chain = ao_c;
  610|  16.7k|    ao_c->mpctx = mpctx;
  611|  16.7k|    ao_c->log = mpctx->log;
  612|  16.7k|    ao_c->filter =
  613|  16.7k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_AUDIO);
  614|  16.7k|    ao_c->spdif_passthrough = true;
  615|  16.7k|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  16.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  616|  16.7k|    ao_c->delay = mpctx->opts->audio_delay;
  617|       |
  618|  16.7k|    ao_c->ao_filter = mp_filter_create(mpctx->filter_root, &ao_filter);
  619|  16.7k|    if (!ao_c->filter || !ao_c->ao_filter)
  ------------------
  |  Branch (619:9): [True: 0, False: 16.7k]
  |  Branch (619:26): [True: 0, False: 16.7k]
  ------------------
  620|      0|        goto init_error;
  621|  16.7k|    ao_c->ao_filter->priv = ao_c;
  622|       |
  623|  16.7k|    mp_filter_add_pin(ao_c->ao_filter, MP_PIN_IN, "in");
  624|  16.7k|    mp_pin_connect(ao_c->ao_filter->pins[0], ao_c->filter->f->pins[1]);
  625|       |
  626|  16.7k|    if (track) {
  ------------------
  |  Branch (626:9): [True: 16.7k, False: 0]
  ------------------
  627|  16.7k|        ao_c->track = track;
  628|  16.7k|        track->ao_c = ao_c;
  629|  16.7k|        if (!ao_chain_init_decoder(mpctx, ao_c))
  ------------------
  |  Branch (629:13): [True: 0, False: 16.7k]
  ------------------
  630|      0|            goto init_error;
  631|  16.7k|    }
  632|       |
  633|  16.7k|    reset_audio_state(mpctx);
  634|       |
  635|  16.7k|    if (recreate_audio_filters(mpctx) < 0)
  ------------------
  |  Branch (635:9): [True: 2, False: 16.7k]
  ------------------
  636|      2|        goto init_error;
  637|       |
  638|  16.7k|    if (mpctx->ao)
  ------------------
  |  Branch (638:9): [True: 99, False: 16.6k]
  ------------------
  639|     99|        audio_update_volume(mpctx);
  640|       |
  641|  16.7k|    mp_wakeup_core(mpctx);
  642|  16.7k|    return;
  643|       |
  644|      2|init_error:
  645|      2|    uninit_audio_chain(mpctx);
  646|      2|    uninit_audio_out(mpctx);
  647|      2|    error_on_track(mpctx, track);
  648|      2|}
written_audio_pts:
  653|  7.26M|{
  654|  7.26M|    return mpctx->ao_chain ? mpctx->ao_chain->last_out_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|   748k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:12): [True: 6.51M, False: 748k]
  ------------------
  655|  7.26M|}
playing_audio_pts:
  660|  7.24M|{
  661|  7.24M|    double pts = written_audio_pts(mpctx);
  662|  7.24M|    if (pts == MP_NOPTS_VALUE || !mpctx->ao)
  ------------------
  |  |   39|  14.4M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (662:9): [True: 7.16M, False: 78.2k]
  |  Branch (662:34): [True: 0, False: 78.2k]
  ------------------
  663|  7.16M|        return pts;
  664|  78.2k|    return pts - mpctx->audio_speed * ao_get_delay(mpctx->ao);
  665|  7.24M|}
reload_audio_output:
  787|  27.3k|{
  788|  27.3k|    if (!mpctx->ao)
  ------------------
  |  Branch (788:9): [True: 24.7k, False: 2.56k]
  ------------------
  789|  24.7k|        return;
  790|       |
  791|  2.56k|    ao_reset(mpctx->ao);
  792|  2.56k|    uninit_audio_out(mpctx);
  793|  2.56k|    reinit_audio_filters(mpctx); // mostly to issue refresh seek
  794|       |
  795|  2.56k|    struct ao_chain *ao_c = mpctx->ao_chain;
  796|       |
  797|  2.56k|    if (ao_c) {
  ------------------
  |  Branch (797:9): [True: 2.26k, False: 300]
  ------------------
  798|  2.26k|        reset_audio_state(mpctx);
  799|  2.26k|        mp_output_chain_reset_harder(ao_c->filter);
  800|  2.26k|    }
  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|  2.56k|    if (ao_c && ao_c->track) {
  ------------------
  |  Branch (805:9): [True: 2.26k, False: 300]
  |  Branch (805:17): [True: 2.26k, False: 0]
  ------------------
  806|  2.26k|        struct mp_decoder_wrapper *dec = ao_c->track->dec;
  807|  2.26k|        if (dec && ao_c->spdif_failed) {
  ------------------
  |  Branch (807:13): [True: 2.26k, False: 0]
  |  Branch (807:20): [True: 0, False: 2.26k]
  ------------------
  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|  2.26k|    }
  817|       |
  818|  2.56k|    mp_wakeup_core(mpctx);
  819|  2.56k|}
audio_start_ao:
  854|  1.98M|{
  855|  1.98M|    struct ao_chain *ao_c = mpctx->ao_chain;
  856|  1.98M|    if (!ao_c || !ao_c->ao || mpctx->audio_status != STATUS_READY)
  ------------------
  |  Branch (856:9): [True: 0, False: 1.98M]
  |  Branch (856:18): [True: 11.5k, False: 1.97M]
  |  Branch (856:31): [True: 1.05M, False: 927k]
  ------------------
  857|  1.06M|        return;
  858|   927k|    double pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   927k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  859|   927k|    if (!get_sync_pts(mpctx, &pts))
  ------------------
  |  Branch (859:9): [True: 80, False: 927k]
  ------------------
  860|     80|        return;
  861|   927k|    double apts = playing_audio_pts(mpctx);
  862|   927k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (862:9): [True: 29.1k, False: 898k]
  ------------------
  863|  29.1k|        double speed = mpctx->opts->playback_speed;
  864|  29.1k|        if (!ao_c->delaying_audio_start && pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  43.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (864:13): [True: 14.3k, False: 14.7k]
  |  Branch (864:44): [True: 14.3k, False: 0]
  ------------------
  865|  14.3k|            apts != MP_NOPTS_VALUE && pts < apts)
  ------------------
  |  |   39|  43.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (865:13): [True: 14.2k, False: 113]
  |  Branch (865:39): [True: 1.73k, False: 12.4k]
  ------------------
  866|  1.73k|        {
  867|  1.73k|            MP_VERBOSE(mpctx, "delaying audio start %f vs. %f, diff=%f\n",
  ------------------
  |  |   92|  1.73k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.73k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  868|  1.73k|                       apts, pts, (apts - pts) / speed);
  869|  1.73k|            ao_c->delaying_audio_start = true;
  870|  1.73k|            ao_c->delayed_start_gap = apts - pts;
  871|  1.73k|            mpctx->delay += apts - pts;
  872|  1.73k|            ao_c->delayed_start_speed = 0;
  873|  1.73k|        }
  874|  29.1k|        if (ao_c->delaying_audio_start) {
  ------------------
  |  Branch (874:13): [True: 16.5k, False: 12.5k]
  ------------------
  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|  16.5k|            int64_t now = mp_time_ns();
  880|  16.5k|            double passed = MP_TIME_NS_TO_S(now - ao_c->delayed_start_last);
  ------------------
  |  |   76|  16.5k|#define MP_TIME_NS_TO_S(ns) ((ns) / (double)1000000000)
  ------------------
  881|  16.5k|            ao_c->delayed_start_gap -= passed * ao_c->delayed_start_speed;
  882|  16.5k|            ao_c->delayed_start_last = now;
  883|  16.5k|            ao_c->delayed_start_speed = get_internal_paused(mpctx) ? 0 : speed;
  ------------------
  |  Branch (883:41): [True: 12.7k, False: 3.76k]
  ------------------
  884|  16.5k|            if (ao_c->delayed_start_gap > 0) {
  ------------------
  |  Branch (884:17): [True: 16.2k, False: 312]
  ------------------
  885|  16.2k|                if (ao_c->delayed_start_speed > 0)
  ------------------
  |  Branch (885:21): [True: 3.52k, False: 12.6k]
  ------------------
  886|  3.52k|                    mp_set_timeout(mpctx, ao_c->delayed_start_gap / speed);
  887|  16.2k|                return;
  888|  16.2k|            }
  889|  16.5k|        }
  890|  29.1k|    }
  891|       |
  892|   911k|    MP_VERBOSE(mpctx, "starting audio playback\n");
  ------------------
  |  |   92|   911k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   911k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  893|   911k|    ao_c->delaying_audio_start = false;
  894|   911k|    ao_start(ao_c->ao);
  895|   911k|    mpctx->audio_status = STATUS_PLAYING;
  896|   911k|    if (ao_c->out_eof) {
  ------------------
  |  Branch (896:9): [True: 896k, False: 14.5k]
  ------------------
  897|   896k|        mpctx->audio_status = STATUS_DRAINING;
  898|   896k|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|   896k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   896k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  899|   896k|    }
  900|       |    ao_c->underrun = false;
  901|   911k|    mp_wakeup_core(mpctx);
  902|   911k|}
fill_audio_out_buffers:
  905|  11.4M|{
  906|  11.4M|    struct MPOpts *opts = mpctx->opts;
  907|       |
  908|  11.4M|    if (mpctx->ao && ao_query_and_reset_events(mpctx->ao, AO_EVENT_RELOAD))
  ------------------
  |  Branch (908:9): [True: 4.95M, False: 6.46M]
  |  Branch (908:22): [True: 0, False: 4.95M]
  ------------------
  909|      0|        reload_audio_output(mpctx);
  910|       |
  911|  11.4M|    update_throttle(mpctx);
  912|       |
  913|  11.4M|    struct ao_chain *ao_c = mpctx->ao_chain;
  914|  11.4M|    if (!ao_c)
  ------------------
  |  Branch (914:9): [True: 753k, False: 10.6M]
  ------------------
  915|   753k|        return;
  916|       |
  917|  10.6M|    if (ao_c->filter->failed_output_conversion) {
  ------------------
  |  Branch (917:9): [True: 0, False: 10.6M]
  ------------------
  918|      0|        error_on_track(mpctx, ao_c->track);
  919|      0|        return;
  920|      0|    }
  921|       |
  922|  10.6M|    if (ao_c->filter->ao_needs_update) {
  ------------------
  |  Branch (922:9): [True: 15.4k, False: 10.6M]
  ------------------
  923|  15.4k|        if (reinit_audio_filters_and_output(mpctx) < 0)
  ------------------
  |  Branch (923:13): [True: 8, False: 15.4k]
  ------------------
  924|      8|            return;
  925|  15.4k|    }
  926|       |
  927|  10.6M|    if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
  ------------------
  |  Branch (927:9): [True: 9.69M, False: 958k]
  |  Branch (927:28): [True: 9.69M, False: 0]
  |  Branch (927:43): [True: 9.69M, False: 0]
  ------------------
  928|  9.69M|        mp_decoder_wrapper_get_pts_reset(ao_c->track->dec))
  ------------------
  |  Branch (928:9): [True: 0, False: 9.69M]
  ------------------
  929|      0|    {
  930|      0|        MP_WARN(mpctx, "Reset playback due to audio timestamp reset.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  931|      0|        reset_playback_state(mpctx);
  932|      0|        mp_wakeup_core(mpctx);
  933|      0|    }
  934|       |
  935|  10.6M|    if (mpctx->audio_status == STATUS_SYNCING) {
  ------------------
  |  Branch (935:9): [True: 8.18M, False: 2.47M]
  ------------------
  936|  8.18M|        double pts;
  937|  8.18M|        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|  8.18M|        if (mpctx->ao && ao_is_playing(mpctx->ao) &&
  ------------------
  |  Branch (944:13): [True: 3.90M, False: 4.27M]
  |  Branch (944:26): [True: 3.50M, False: 398k]
  ------------------
  945|  3.50M|            mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (945:13): [True: 1.68M, False: 1.82M]
  ------------------
  946|  1.68M|            MP_VERBOSE(mpctx, "blocked, waiting for old audio to play\n");
  ------------------
  |  |   92|  1.68M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.68M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  947|  1.68M|            ok = false;
  948|  1.68M|        }
  949|       |
  950|  8.18M|        if (ao_c->start_pts_known != ok || ao_c->start_pts != pts) {
  ------------------
  |  Branch (950:13): [True: 2.32M, False: 5.85M]
  |  Branch (950:44): [True: 364, False: 5.85M]
  ------------------
  951|  2.32M|            ao_c->start_pts_known = ok;
  952|  2.32M|            ao_c->start_pts = pts;
  953|  2.32M|            mp_filter_wakeup(ao_c->ao_filter);
  954|  2.32M|        }
  955|       |
  956|  8.18M|        if (ao_c->ao && mp_async_queue_is_full(ao_c->ao_queue)) {
  ------------------
  |  Branch (956:13): [True: 3.90M, False: 4.27M]
  |  Branch (956:25): [True: 16.9k, False: 3.89M]
  ------------------
  957|  16.9k|            mpctx->audio_status = STATUS_READY;
  958|  16.9k|            mp_wakeup_core(mpctx);
  959|  16.9k|            MP_VERBOSE(mpctx, "audio ready\n");
  ------------------
  |  |   92|  16.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  16.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  960|  8.16M|        } else if (ao_c->out_eof) {
  ------------------
  |  Branch (960:20): [True: 897k, False: 7.26M]
  ------------------
  961|       |            // Force playback start early.
  962|   897k|            mpctx->audio_status = STATUS_READY;
  963|   897k|            mp_wakeup_core(mpctx);
  964|   897k|            MP_VERBOSE(mpctx, "audio ready (and EOF)\n");
  ------------------
  |  |   92|   897k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   897k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  965|   897k|        }
  966|  8.18M|    }
  967|       |
  968|  10.6M|    if (ao_c->ao && !ao_is_playing(ao_c->ao) && !ao_c->underrun &&
  ------------------
  |  Branch (968:9): [True: 4.96M, False: 5.69M]
  |  Branch (968:21): [True: 419k, False: 4.54M]
  |  Branch (968:49): [True: 419k, False: 0]
  ------------------
  969|   419k|        (mpctx->audio_status == STATUS_PLAYING ||
  ------------------
  |  Branch (969:10): [True: 159, False: 419k]
  ------------------
  970|   419k|         mpctx->audio_status == STATUS_DRAINING))
  ------------------
  |  Branch (970:10): [True: 11.3k, False: 408k]
  ------------------
  971|  11.5k|    {
  972|       |        // Should be playing, but somehow isn't.
  973|       |
  974|  11.5k|        if (ao_c->out_eof && !mp_async_queue_get_frames(ao_c->ao_queue)) {
  ------------------
  |  Branch (974:13): [True: 11.5k, False: 0]
  |  Branch (974:30): [True: 11.5k, False: 0]
  ------------------
  975|  11.5k|            MP_VERBOSE(mpctx, "AO signaled EOF (while in state %s)\n",
  ------------------
  |  |   92|  11.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  976|  11.5k|                       mp_status_str(mpctx->audio_status));
  977|  11.5k|            mpctx->audio_status = STATUS_EOF;
  978|  11.5k|            mp_wakeup_core(mpctx);
  979|       |            // stops untimed AOs, stops pull AOs from streaming silence
  980|  11.5k|            ao_reset(ao_c->ao);
  981|  11.5k|        } 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|  11.5k|    }
  999|       |
 1000|  10.6M|    if (mpctx->audio_status == STATUS_PLAYING && ao_c->out_eof) {
  ------------------
  |  Branch (1000:9): [True: 147k, False: 10.5M]
  |  Branch (1000:50): [True: 337, False: 146k]
  ------------------
 1001|    337|        mpctx->audio_status = STATUS_DRAINING;
 1002|    337|        MP_VERBOSE(mpctx, "audio draining\n");
  ------------------
  |  |   92|    337|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    337|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1003|    337|        mp_wakeup_core(mpctx);
 1004|    337|    }
 1005|       |
 1006|  10.6M|    if (mpctx->audio_status == STATUS_DRAINING) {
  ------------------
  |  Branch (1006:9): [True: 2.29M, False: 8.36M]
  ------------------
 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|  2.29M|        if (!ao_c->ao || (!ao_is_playing(ao_c->ao) || opts->gapless_audio))
  ------------------
  |  Branch (1009:13): [True: 1.41M, False: 884k]
  |  Branch (1009:27): [True: 82, False: 884k]
  |  Branch (1009:55): [True: 884k, False: 0]
  ------------------
 1010|  2.29M|        {
 1011|  2.29M|            MP_VERBOSE(mpctx, "audio EOF reached\n");
  ------------------
  |  |   92|  2.29M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.29M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1012|  2.29M|            mpctx->audio_status = STATUS_EOF;
 1013|  2.29M|            mp_wakeup_core(mpctx);
 1014|  2.29M|        }
 1015|  2.29M|    }
 1016|       |
 1017|  10.6M|    if (mpctx->restart_complete)
  ------------------
  |  Branch (1017:9): [True: 1.07M, False: 9.58M]
  ------------------
 1018|  1.07M|        audio_start_ao(mpctx); // in case it got delayed
 1019|  10.6M|}
clear_audio_output_buffers:
 1023|  28.4k|{
 1024|  28.4k|    if (mpctx->ao)
  ------------------
  |  Branch (1024:9): [True: 18.1k, False: 10.2k]
  ------------------
 1025|  18.1k|        ao_reset(mpctx->ao);
 1026|  28.4k|}
audio.c:recreate_audio_filters:
   89|  31.0k|{
   90|  31.0k|    struct ao_chain *ao_c = mpctx->ao_chain;
   91|  31.0k|    mp_assert(ao_c);
  ------------------
  |  |   41|  31.0k|#define mp_assert assert
  ------------------
  |  Branch (91:5): [True: 31.0k, False: 0]
  ------------------
   92|       |
   93|  31.0k|    if (!mp_output_chain_update_filters(ao_c->filter, mpctx->opts->af_settings))
  ------------------
  |  Branch (93:9): [True: 80, False: 31.0k]
  ------------------
   94|     80|        goto fail;
   95|       |
   96|  31.0k|    update_speed_filters(mpctx);
   97|       |
   98|  31.0k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
   99|       |
  100|  31.0k|    return 0;
  101|       |
  102|     80|fail:
  103|     80|    MP_ERR(mpctx, "Audio filter initialized failed!\n");
  ------------------
  |  |   89|     80|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     80|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  104|     80|    return -1;
  105|  31.0k|}
audio.c:compute_replaygain:
  133|  35.5k|{
  134|  35.5k|    struct MPOpts *opts = mpctx->opts;
  135|       |
  136|  35.5k|    float rgain = 1.0;
  137|       |
  138|  35.5k|    struct replaygain_data *rg = NULL;
  139|  35.5k|    struct track *track = mpctx->current_track[0][STREAM_AUDIO];
  140|  35.5k|    if (track)
  ------------------
  |  Branch (140:9): [True: 35.5k, False: 0]
  ------------------
  141|  35.5k|        rg = track->stream->codec->replaygain_data;
  142|  35.5k|    if (opts->rgain_mode && rg) {
  ------------------
  |  Branch (142:9): [True: 0, False: 35.5k]
  |  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|  35.5k|    } else if (opts->rgain_fallback) {
  ------------------
  |  Branch (165:16): [True: 0, False: 35.5k]
  ------------------
  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|  35.5k|    return rgain;
  171|  35.5k|}
audio.c:db_gain:
  128|  35.5k|{
  129|  35.5k|    return pow(10.0, db/20.0);
  130|  35.5k|}
audio.c:update_speed_filters:
   52|  50.8k|{
   53|  50.8k|    struct ao_chain *ao_c = mpctx->ao_chain;
   54|  50.8k|    if (!ao_c)
  ------------------
  |  Branch (54:9): [True: 17.4k, False: 33.4k]
  ------------------
   55|  17.4k|        return;
   56|       |
   57|  33.4k|    double pitch = mpctx->opts->playback_pitch;
   58|  33.4k|    double speed = mpctx->opts->playback_speed;
   59|  33.4k|    double resample = mpctx->speed_factor_a;
   60|  33.4k|    double drop = 1.0;
   61|       |
   62|  33.4k|    if (!mpctx->opts->pitch_correction) {
  ------------------
  |  Branch (62:9): [True: 126, False: 33.2k]
  ------------------
   63|    126|        resample *= speed;
   64|    126|        speed = 1.0;
   65|    126|    }
   66|       |
   67|  33.4k|    int video_sync = mpctx->display_sync_active ?
  ------------------
  |  Branch (67:22): [True: 0, False: 33.4k]
  ------------------
   68|  33.4k|        mpctx->video_out->opts->video_sync : VS_NONE;
   69|  33.4k|    switch (video_sync) {
   70|      0|        case VS_DISP_ADROP:
  ------------------
  |  Branch (70:9): [True: 0, False: 33.4k]
  ------------------
   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: 33.4k]
  ------------------
   76|      0|            speed = mpctx->audio_speed / pitch;
   77|      0|            resample = pitch;
   78|      0|            break;
   79|  33.4k|        default:
  ------------------
  |  Branch (79:9): [True: 33.4k, False: 0]
  ------------------
   80|  33.4k|            resample *= pitch;
   81|  33.4k|            speed /= pitch;
   82|  33.4k|            break;
   83|  33.4k|    }
   84|       |
   85|  33.4k|    mp_output_chain_set_audio_speed(ao_c->filter, speed, resample, drop);
   86|  33.4k|}
audio.c:ao_chain_reset_state:
  220|  2.33M|{
  221|  2.33M|    ao_c->last_out_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.33M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  222|  2.33M|    ao_c->out_eof = false;
  223|  2.33M|    ao_c->start_pts_known = false;
  224|  2.33M|    ao_c->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.33M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  225|  2.33M|    ao_c->untimed_throttle = false;
  226|  2.33M|    ao_c->underrun = false;
  227|       |    ao_c->delaying_audio_start = false;
  228|  2.33M|}
audio.c:ao_chain_uninit:
  267|  16.7k|{
  268|  16.7k|    struct track *track = ao_c->track;
  269|  16.7k|    if (track) {
  ------------------
  |  Branch (269:9): [True: 16.7k, False: 0]
  ------------------
  270|  16.7k|        mp_assert(track->ao_c == ao_c);
  ------------------
  |  |   41|  16.7k|#define mp_assert assert
  ------------------
  |  Branch (270:9): [True: 16.7k, False: 0]
  ------------------
  271|  16.7k|        track->ao_c = NULL;
  272|  16.7k|        if (ao_c->dec_src)
  ------------------
  |  Branch (272:13): [True: 16.7k, False: 0]
  ------------------
  273|  16.7k|            mp_assert(track->dec->f->pins[0] == ao_c->dec_src);
  ------------------
  |  |   41|  16.7k|#define mp_assert assert
  ------------------
  |  Branch (273:13): [True: 16.7k, False: 0]
  ------------------
  274|  16.7k|        if (track->dec) {
  ------------------
  |  Branch (274:13): [True: 16.7k, False: 0]
  ------------------
  275|  16.7k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  276|  16.7k|            track->dec = NULL;
  277|  16.7k|        }
  278|  16.7k|    }
  279|       |
  280|  16.7k|    if (ao_c->filter_src)
  ------------------
  |  Branch (280:9): [True: 0, False: 16.7k]
  ------------------
  281|      0|        mp_pin_disconnect(ao_c->filter_src);
  282|       |
  283|  16.7k|    talloc_free(ao_c->filter->f);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  284|  16.7k|    talloc_free(ao_c->ao_filter);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  285|  16.7k|    talloc_free(ao_c);
  ------------------
  |  |   47|  16.7k|#define talloc_free                     ta_free
  ------------------
  286|  16.7k|}
audio.c:ao_chain_init_decoder:
  567|  16.7k|{
  568|  16.7k|    struct track *track = ao_c->track;
  569|  16.7k|    if (!init_audio_decoder(mpctx, track))
  ------------------
  |  Branch (569:9): [True: 0, False: 16.7k]
  ------------------
  570|      0|        return false;
  571|  16.7k|    ao_c->dec_src = track->dec->f->pins[0];
  572|  16.7k|    mp_pin_connect(ao_c->filter->f->pins[0], ao_c->dec_src);
  573|       |    return true;
  574|  16.7k|}
audio.c:ao_process:
  684|  7.19M|{
  685|  7.19M|    struct ao_chain *ao_c = f->priv;
  686|  7.19M|    struct MPContext *mpctx = ao_c->mpctx;
  687|       |
  688|       |    // Once the chain reached EOF nothing is read from it again.
  689|  7.19M|    if (ao_c->out_eof)
  ------------------
  |  Branch (689:9): [True: 909k, False: 6.28M]
  ------------------
  690|   909k|        return;
  691|       |
  692|  6.28M|    if (!ao_c->queue_filter) {
  ------------------
  |  Branch (692:9): [True: 2.84M, False: 3.43M]
  ------------------
  693|       |        // This will eventually lead to the creation of the AO + queue, due
  694|       |        // to how f_output_chain and AO management works.
  695|  2.84M|        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|  2.84M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  699|  2.84M|        if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (699:13): [True: 1.41M, False: 1.43M]
  ------------------
  700|  1.41M|            MP_VERBOSE(mpctx, "got EOF with no data before it\n");
  ------------------
  |  |   92|  1.41M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.41M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  701|  1.41M|            ao_c->out_eof = true;
  702|  1.41M|            mpctx->audio_status = STATUS_DRAINING;
  703|  1.41M|            mp_wakeup_core(mpctx);
  704|  1.43M|        } else if (frame.type) {
  ------------------
  |  Branch (704:20): [True: 37, False: 1.43M]
  ------------------
  705|     37|            mp_pin_out_unread(f->ppins[0], frame);
  706|     37|        }
  707|  2.84M|        return;
  708|  2.84M|    }
  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|  3.43M|    if (mpctx->audio_status != STATUS_PLAYING &&
  ------------------
  |  Branch (713:9): [True: 3.22M, False: 214k]
  ------------------
  714|  3.22M|        mp_async_queue_is_full(ao_c->ao_queue))
  ------------------
  |  Branch (714:9): [True: 14.4k, False: 3.20M]
  ------------------
  715|  14.4k|        mp_wakeup_core(mpctx);
  716|       |
  717|  3.43M|    if (mpctx->audio_status == STATUS_SYNCING && !ao_c->start_pts_known)
  ------------------
  |  Branch (717:9): [True: 3.21M, False: 215k]
  |  Branch (717:50): [True: 928k, False: 2.29M]
  ------------------
  718|   928k|        return;
  719|       |
  720|  2.50M|    if (ao_c->untimed_throttle)
  ------------------
  |  Branch (720:9): [True: 40.2k, False: 2.46M]
  ------------------
  721|  40.2k|        return;
  722|       |
  723|  2.46M|    if (!mp_pin_can_transfer_data(ao_c->queue_filter->pins[0], f->ppins[0]))
  ------------------
  |  Branch (723:9): [True: 1.23M, False: 1.23M]
  ------------------
  724|  1.23M|        return;
  725|       |
  726|  1.23M|    struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  727|  1.23M|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (727:9): [True: 334k, False: 897k]
  ------------------
  728|   334k|        struct mp_aframe *af = frame.data;
  729|       |
  730|   334k|        double endpts = get_play_end_pts(mpctx);
  731|   334k|        if (endpts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   334k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (731:13): [True: 1.93k, False: 332k]
  ------------------
  732|  1.93k|            endpts *= mpctx->play_dir;
  733|       |            // Avoid decoding and discarding the entire rest of the file.
  734|  1.93k|            if (mp_aframe_get_pts(af) >= endpts) {
  ------------------
  |  Branch (734:17): [True: 560, False: 1.37k]
  ------------------
  735|    560|                mp_pin_out_unread(f->ppins[0], frame);
  736|    560|                if (!ao_c->out_eof) {
  ------------------
  |  Branch (736:21): [True: 560, False: 0]
  ------------------
  737|    560|                    ao_c->out_eof = true;
  738|    560|                    mp_pin_in_write(ao_c->queue_filter->pins[0], MP_EOF_FRAME);
  ------------------
  |  |   59|    560|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|    560|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  739|    560|                }
  740|    560|                return;
  741|    560|            }
  742|  1.93k|        }
  743|   333k|        double startpts = mpctx->audio_status == STATUS_SYNCING ?
  ------------------
  |  Branch (743:27): [True: 247k, False: 86.2k]
  ------------------
  744|   247k|                                            ao_c->start_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  86.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  745|   333k|        mp_aframe_clip_timestamps(af, startpts, endpts);
  746|       |
  747|   333k|        int samples = mp_aframe_get_size(af);
  748|   333k|        if (!samples) {
  ------------------
  |  Branch (748:13): [True: 1.59k, False: 332k]
  ------------------
  749|  1.59k|            mp_filter_internal_mark_progress(f);
  750|  1.59k|            mp_frame_unref(&frame);
  751|  1.59k|            return;
  752|  1.59k|        }
  753|       |
  754|   332k|        mpctx->shown_aframes += samples;
  755|   332k|        double real_samplerate = mp_aframe_get_rate(af) / mpctx->audio_speed;
  756|   332k|        if (mpctx->video_status != STATUS_EOF)
  ------------------
  |  Branch (756:13): [True: 314k, False: 17.3k]
  ------------------
  757|   314k|            mpctx->delay += samples / real_samplerate;
  758|   332k|        ao_c->last_out_pts = mp_aframe_end_pts(af);
  759|   332k|        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|   332k|        if (mpctx->audio_status == STATUS_SYNCING && ao_is_playing(ao_c->ao)) {
  ------------------
  |  Branch (766:13): [True: 246k, False: 86.2k]
  |  Branch (766:54): [True: 5, False: 246k]
  ------------------
  767|      5|            mpctx->audio_status = STATUS_READY;
  768|      5|            mp_wakeup_core(mpctx);
  769|      5|            MP_VERBOSE(mpctx, "previous audio still playing; continuing\n");
  ------------------
  |  |   92|      5|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  770|      5|        }
  771|       |
  772|   332k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  773|   897k|    } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (773:16): [True: 897k, False: 0]
  ------------------
  774|   897k|        MP_VERBOSE(mpctx, "audio filter EOF\n");
  ------------------
  |  |   92|   897k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   897k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  775|       |
  776|   897k|        ao_c->out_eof = true;
  777|   897k|        mp_wakeup_core(mpctx);
  778|       |
  779|   897k|        mp_pin_in_write(ao_c->queue_filter->pins[0], frame);
  780|   897k|        mp_filter_internal_mark_progress(f);
  781|   897k|    } else {
  782|      0|        mp_frame_unref(&frame);
  783|      0|    }
  784|  1.23M|}
audio.c:get_sync_pts:
  824|  9.11M|{
  825|  9.11M|    struct MPOpts *opts = mpctx->opts;
  826|       |
  827|  9.11M|    *pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  9.11M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  828|       |
  829|  9.11M|    if (!opts->initial_audio_sync)
  ------------------
  |  Branch (829:9): [True: 0, False: 9.11M]
  ------------------
  830|      0|        return true;
  831|       |
  832|  9.11M|    bool sync_to_video = mpctx->vo_chain && mpctx->video_status != STATUS_EOF &&
  ------------------
  |  Branch (832:26): [True: 8.32M, False: 788k]
  |  Branch (832:45): [True: 4.33M, False: 3.98M]
  ------------------
  833|  4.33M|                         !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (833:26): [True: 4.33M, False: 0]
  ------------------
  834|       |
  835|  9.11M|    if (sync_to_video) {
  ------------------
  |  Branch (835:9): [True: 4.33M, False: 4.77M]
  ------------------
  836|  4.33M|        if (mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (836:13): [True: 4.26M, False: 67.2k]
  ------------------
  837|  4.26M|            return false; // wait until we know a video PTS
  838|  67.2k|        if (mpctx->video_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  67.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (838:13): [True: 67.2k, False: 0]
  ------------------
  839|  67.2k|            *pts = mpctx->video_pts - opts->audio_delay;
  840|  4.77M|    } else if (mpctx->hrseek_active) {
  ------------------
  |  Branch (840:16): [True: 4.72M, False: 49.3k]
  ------------------
  841|  4.72M|        *pts = mpctx->hrseek_pts;
  842|  4.72M|    } else {
  843|       |        // If audio-only is enabled mid-stream during playback, sync accordingly.
  844|  49.3k|        *pts = mpctx->playback_pts;
  845|  49.3k|    }
  846|       |
  847|  4.84M|    return true;
  848|  9.11M|}
audio.c:update_throttle:
  670|  11.7M|{
  671|  11.7M|    struct ao_chain *ao_c = mpctx->ao_chain;
  672|  11.7M|    bool new_throttle = mpctx->audio_status == STATUS_PLAYING &&
  ------------------
  |  Branch (672:25): [True: 233k, False: 11.5M]
  ------------------
  673|   233k|                        mpctx->delay > 0 && ao_c && ao_c->ao &&
  ------------------
  |  Branch (673:25): [True: 112k, False: 121k]
  |  Branch (673:45): [True: 112k, False: 0]
  |  Branch (673:53): [True: 112k, False: 0]
  ------------------
  674|   112k|                        ao_untimed(ao_c->ao) &&
  ------------------
  |  Branch (674:25): [True: 112k, False: 0]
  ------------------
  675|   112k|                        mpctx->video_status != STATUS_EOF;
  ------------------
  |  Branch (675:25): [True: 112k, False: 5]
  ------------------
  676|  11.7M|    if (ao_c && new_throttle != ao_c->untimed_throttle) {
  ------------------
  |  Branch (676:9): [True: 10.9M, False: 753k]
  |  Branch (676:17): [True: 30.3k, False: 10.9M]
  ------------------
  677|  30.3k|        ao_c->untimed_throttle = new_throttle;
  678|  30.3k|        mp_wakeup_core(mpctx);
  679|  30.3k|        mp_filter_wakeup(ao_c->ao_filter);
  680|  30.3k|    }
  681|  11.7M|}
audio.c:reinit_audio_filters_and_output:
  360|  15.4k|{
  361|  15.4k|    struct MPOpts *opts = mpctx->opts;
  362|  15.4k|    struct ao_chain *ao_c = mpctx->ao_chain;
  363|  15.4k|    mp_assert(ao_c);
  ------------------
  |  |   41|  15.4k|#define mp_assert assert
  ------------------
  |  Branch (363:5): [True: 15.4k, False: 0]
  ------------------
  364|  15.4k|    struct track *track = ao_c->track;
  365|       |
  366|  15.4k|    mp_assert(ao_c->filter->ao_needs_update);
  ------------------
  |  |   41|  15.4k|#define mp_assert assert
  ------------------
  |  Branch (366:5): [True: 15.4k, False: 0]
  ------------------
  367|       |
  368|       |    // The "ideal" filter output format
  369|  15.4k|    struct mp_aframe *out_fmt = mp_aframe_new_ref(ao_c->filter->output_aformat);
  370|  15.4k|    MP_HANDLE_OOM(out_fmt);
  ------------------
  |  |  206|  15.4k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|  15.4k|        void *oom_p_ = (x);     \
  |  |  208|  15.4k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 15.4k]
  |  |  ------------------
  |  |  209|  15.4k|            abort();            \
  |  |  210|  15.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 15.4k]
  |  |  ------------------
  ------------------
  371|       |
  372|  15.4k|    if (!mp_aframe_config_is_valid(out_fmt)) {
  ------------------
  |  Branch (372:9): [True: 0, False: 15.4k]
  ------------------
  373|      0|        talloc_free(out_fmt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  374|      0|        goto init_error;
  375|      0|    }
  376|       |
  377|  15.4k|    if (af_fmt_is_pcm(mp_aframe_get_format(out_fmt))) {
  ------------------
  |  Branch (377:9): [True: 15.4k, False: 0]
  ------------------
  378|  15.4k|        if (opts->force_srate)
  ------------------
  |  Branch (378:13): [True: 4, False: 15.4k]
  ------------------
  379|      4|            mp_aframe_set_rate(out_fmt, opts->force_srate);
  380|  15.4k|        if (opts->audio_output_format)
  ------------------
  |  Branch (380:13): [True: 0, False: 15.4k]
  ------------------
  381|      0|            mp_aframe_set_format(out_fmt, opts->audio_output_format);
  382|  15.4k|        if (opts->audio_output_channels.num_chmaps == 1)
  ------------------
  |  Branch (382:13): [True: 0, False: 15.4k]
  ------------------
  383|      0|            mp_aframe_set_chmap(out_fmt, &opts->audio_output_channels.chmaps[0]);
  384|  15.4k|    }
  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|  15.4k|    if ((mpctx->ao_filter_fmt && mpctx->ao && opts->gapless_audio < 0 &&
  ------------------
  |  Branch (389:10): [True: 533, False: 14.9k]
  |  Branch (389:34): [True: 533, False: 0]
  |  Branch (389:47): [True: 533, False: 0]
  ------------------
  390|    533|         keep_weak_gapless_format(mpctx->ao_filter_fmt, out_fmt)) ||
  ------------------
  |  Branch (390:10): [True: 297, False: 236]
  ------------------
  391|  15.1k|        (mpctx->ao && opts->gapless_audio > 0))
  ------------------
  |  Branch (391:10): [True: 236, False: 14.9k]
  |  Branch (391:23): [True: 0, False: 236]
  ------------------
  392|    297|    {
  393|    297|        ao_chain_set_ao(ao_c, mpctx->ao);
  394|    297|        talloc_free(out_fmt);
  ------------------
  |  |   47|    297|#define talloc_free                     ta_free
  ------------------
  395|    297|        return 0;
  396|    297|    }
  397|       |
  398|       |    // Format change during syncing. Force playback start early, then wait.
  399|  15.1k|    if (ao_c->ao_queue && mp_async_queue_get_frames(ao_c->ao_queue) &&
  ------------------
  |  Branch (399:9): [True: 235, False: 14.9k]
  |  Branch (399:27): [True: 119, False: 116]
  ------------------
  400|    119|        mpctx->audio_status == STATUS_SYNCING)
  ------------------
  |  Branch (400:9): [True: 11, False: 108]
  ------------------
  401|     11|    {
  402|     11|        mpctx->audio_status = STATUS_READY;
  403|     11|        mp_wakeup_core(mpctx);
  404|     11|        talloc_free(out_fmt);
  ------------------
  |  |   47|     11|#define talloc_free                     ta_free
  ------------------
  405|     11|        return 0;
  406|     11|    }
  407|  15.1k|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (407:9): [True: 95, False: 15.0k]
  ------------------
  408|     95|        talloc_free(out_fmt);
  ------------------
  |  |   47|     95|#define talloc_free                     ta_free
  ------------------
  409|     95|        return 0;
  410|     95|    }
  411|       |
  412|  15.0k|    uninit_audio_out(mpctx);
  413|       |
  414|  15.0k|    int out_rate = mp_aframe_get_rate(out_fmt);
  415|  15.0k|    int out_format = mp_aframe_get_format(out_fmt);
  416|  15.0k|    struct mp_chmap out_channels = {0};
  417|  15.0k|    mp_aframe_get_chmap(out_fmt, &out_channels);
  418|       |
  419|  15.0k|    int ao_flags = 0;
  420|  15.0k|    bool spdif_fallback = !af_fmt_is_pcm(out_format) &&
  ------------------
  |  Branch (420:27): [True: 0, False: 15.0k]
  ------------------
  421|      0|                          ao_c->spdif_passthrough;
  ------------------
  |  Branch (421:27): [True: 0, False: 0]
  ------------------
  422|       |
  423|  15.0k|    if (opts->ao_null_fallback && !spdif_fallback)
  ------------------
  |  Branch (423:9): [True: 0, False: 15.0k]
  |  Branch (423:35): [True: 0, False: 0]
  ------------------
  424|      0|        ao_flags |= AO_INIT_NULL_FALLBACK;
  425|       |
  426|  15.0k|    if (opts->audio_stream_silence)
  ------------------
  |  Branch (426:9): [True: 0, False: 15.0k]
  ------------------
  427|      0|        ao_flags |= AO_INIT_STREAM_SILENCE;
  428|       |
  429|  15.0k|    if (opts->audio_exclusive)
  ------------------
  |  Branch (429:9): [True: 0, False: 15.0k]
  ------------------
  430|      0|        ao_flags |= AO_INIT_EXCLUSIVE;
  431|       |
  432|  15.0k|    if (af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (432:9): [True: 15.0k, False: 0]
  ------------------
  433|  15.0k|        if (!opts->audio_output_channels.set ||
  ------------------
  |  Branch (433:13): [True: 0, False: 15.0k]
  ------------------
  434|  15.0k|            opts->audio_output_channels.auto_safe)
  ------------------
  |  Branch (434:13): [True: 15.0k, False: 0]
  ------------------
  435|  15.0k|            ao_flags |= AO_INIT_SAFE_MULTICHANNEL_ONLY;
  436|       |
  437|  15.0k|        mp_chmap_sel_list(&out_channels,
  438|  15.0k|                          opts->audio_output_channels.chmaps,
  439|  15.0k|                          opts->audio_output_channels.num_chmaps);
  440|  15.0k|    }
  441|       |
  442|  15.0k|    if (!has_video_track(mpctx))
  ------------------
  |  Branch (442:9): [True: 0, False: 15.0k]
  ------------------
  443|      0|        ao_flags |= AO_INIT_MEDIA_ROLE_MUSIC;
  444|       |
  445|  15.0k|    mpctx->ao_filter_fmt = out_fmt;
  446|       |
  447|  15.0k|    mpctx->ao = ao_init_best(mpctx->global, ao_flags, mp_wakeup_core_cb,
  448|  15.0k|                             mpctx, mpctx->encode_lavc_ctx, out_rate,
  449|  15.0k|                             out_format, out_channels);
  450|       |
  451|  15.0k|    int ao_rate = 0;
  452|  15.0k|    int ao_format = 0;
  453|  15.0k|    struct mp_chmap ao_channels = {0};
  454|  15.0k|    if (mpctx->ao)
  ------------------
  |  Branch (454:9): [True: 15.0k, False: 8]
  ------------------
  455|  15.0k|        ao_get_format(mpctx->ao, &ao_rate, &ao_format, &ao_channels);
  456|       |
  457|       |    // Verify passthrough format was not changed.
  458|  15.0k|    if (mpctx->ao && !af_fmt_is_pcm(out_format)) {
  ------------------
  |  Branch (458:9): [True: 15.0k, False: 8]
  |  Branch (458:22): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|    if (!mpctx->ao) {
  ------------------
  |  Branch (468:9): [True: 8, False: 15.0k]
  ------------------
  469|       |        // If spdif was used, try to fallback to PCM.
  470|      8|        if (spdif_fallback && ao_c->track && ao_c->track->dec) {
  ------------------
  |  Branch (470:13): [True: 0, False: 8]
  |  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|      8|        MP_ERR(mpctx, "Could not open/initialize audio device -> no sound.\n");
  ------------------
  |  |   89|      8|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      8|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|      8|        mpctx->error_playing = MPV_ERROR_AO_INIT_FAILED;
  485|      8|        goto init_error;
  486|      8|    }
  487|       |
  488|  15.0k|    char tmp[192];
  489|  15.0k|    MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(mpctx->ao),
  ------------------
  |  |   91|  15.0k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  15.0k|            audio_config_to_str_buf(tmp, sizeof(tmp), ao_rate, ao_format,
  491|  15.0k|                                    ao_channels));
  492|  15.0k|    MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(mpctx->ao));
  ------------------
  |  |   92|  15.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  493|  15.0k|    update_window_title(mpctx, true);
  494|       |
  495|  15.0k|    ao_c->ao_resume_time =
  496|  15.0k|        opts->audio_wait_open > 0 ? mp_time_sec() + opts->audio_wait_open : 0;
  ------------------
  |  Branch (496:9): [True: 0, False: 15.0k]
  ------------------
  497|       |
  498|  15.0k|    bool eof = mpctx->audio_status == STATUS_EOF;
  499|  15.0k|    ao_set_paused(mpctx->ao, get_internal_paused(mpctx), eof);
  500|       |
  501|  15.0k|    ao_chain_set_ao(ao_c, mpctx->ao);
  502|       |
  503|  15.0k|    audio_update_volume(mpctx);
  504|       |
  505|       |    // Almost nonsensical hack to deal with certain format change scenarios.
  506|  15.0k|    if (mpctx->audio_status == STATUS_PLAYING)
  ------------------
  |  Branch (506:9): [True: 126, False: 14.8k]
  ------------------
  507|    126|        ao_start(mpctx->ao);
  508|       |
  509|  15.0k|    mp_wakeup_core(mpctx);
  510|  15.0k|    mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  511|       |
  512|  15.0k|    return 0;
  513|       |
  514|      8|init_error:
  515|      8|    uninit_audio_chain(mpctx);
  516|      8|    uninit_audio_out(mpctx);
  517|      8|    error_on_track(mpctx, track);
  518|      8|    return -1;
  519|  15.0k|}
audio.c:keep_weak_gapless_format:
  315|    533|{
  316|    533|    bool res = false;
  317|    533|    struct mp_aframe *new_mod = mp_aframe_new_ref(new);
  318|    533|    MP_HANDLE_OOM(new_mod);
  ------------------
  |  |  206|    533|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|    533|        void *oom_p_ = (x);     \
  |  |  208|    533|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 533]
  |  |  ------------------
  |  |  209|    533|            abort();            \
  |  |  210|    533|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 533]
  |  |  ------------------
  ------------------
  319|       |
  320|       |    // If the sample formats are compatible (== libswresample generally can
  321|       |    // convert them), keep the AO. On other changes, recreate it.
  322|       |
  323|    533|    int old_fmt = mp_aframe_get_format(old);
  324|    533|    int new_fmt = mp_aframe_get_format(new);
  325|       |
  326|    533|    if (af_format_conversion_score(old_fmt, new_fmt) == INT_MIN)
  ------------------
  |  Branch (326:9): [True: 0, False: 533]
  ------------------
  327|      0|        goto done; // completely incompatible formats
  328|       |
  329|    533|    if (!mp_aframe_set_format(new_mod, old_fmt))
  ------------------
  |  Branch (329:9): [True: 0, False: 533]
  ------------------
  330|      0|        goto done;
  331|       |
  332|    533|    res = mp_aframe_config_equals(old, new_mod);
  333|       |
  334|    533|done:
  335|    533|    talloc_free(new_mod);
  ------------------
  |  |   47|    533|#define talloc_free                     ta_free
  ------------------
  336|    533|    return res;
  337|    533|}
audio.c:ao_chain_set_ao:
  340|  15.3k|{
  341|  15.3k|    if (ao_c->ao != ao) {
  ------------------
  |  Branch (341:9): [True: 15.0k, False: 233]
  ------------------
  342|  15.0k|        mp_assert(!ao_c->ao);
  ------------------
  |  |   41|  15.0k|#define mp_assert assert
  ------------------
  |  Branch (342:9): [True: 15.0k, False: 0]
  ------------------
  343|  15.0k|        ao_c->ao = ao;
  344|  15.0k|        ao_c->ao_queue = ao_get_queue(ao_c->ao);
  345|  15.0k|        ao_c->queue_filter = mp_async_queue_create_filter(ao_c->ao_filter,
  346|  15.0k|                                                          MP_PIN_IN, ao_c->ao_queue);
  347|  15.0k|        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|  15.0k|        mp_filter_set_high_priority(ao_c->queue_filter, true);
  350|  15.0k|        audio_update_volume(ao_c->mpctx);
  351|  15.0k|    }
  352|       |
  353|  15.3k|    if (ao_c->filter->ao_needs_update)
  ------------------
  |  Branch (353:9): [True: 15.3k, False: 0]
  ------------------
  354|  15.3k|        mp_output_chain_set_ao(ao_c->filter, ao_c->ao);
  355|       |
  356|  15.3k|    mp_filter_wakeup(ao_c->ao_filter);
  357|  15.3k|}
audio.c:has_video_track:
  206|  15.0k|{
  207|  15.0k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart)
  ------------------
  |  Branch (207:9): [True: 14.7k, False: 264]
  |  Branch (207:28): [True: 0, False: 14.7k]
  ------------------
  208|      0|        return false;
  209|       |
  210|  15.0k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (210:21): [True: 15.0k, False: 0]
  ------------------
  211|  15.0k|        struct track *track = mpctx->tracks[n];
  212|  15.0k|        if (track->type == STREAM_VIDEO && !track->attached_picture && !track->image)
  ------------------
  |  Branch (212:13): [True: 15.0k, False: 21]
  |  Branch (212:44): [True: 15.0k, False: 0]
  |  Branch (212:72): [True: 15.0k, False: 0]
  ------------------
  213|  15.0k|            return true;
  214|  15.0k|    }
  215|       |
  216|      0|    return false;
  217|  15.0k|}
audio.c:audio_config_to_str_buf:
  302|  15.0k|{
  303|  15.0k|    char ch[128];
  304|  15.0k|    mp_chmap_to_str_buf(ch, sizeof(ch), &channels);
  305|  15.0k|    char *hr_ch = mp_chmap_to_str_hr(&channels);
  ------------------
  |  |  153|  15.0k|#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4)
  |  |  ------------------
  |  |  |  |  152|  15.0k|#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m))
  |  |  ------------------
  ------------------
  306|  15.0k|    if (strcmp(hr_ch, ch) != 0)
  ------------------
  |  Branch (306:9): [True: 163, False: 14.8k]
  ------------------
  307|    163|        mp_snprintf_cat(ch, sizeof(ch), " (%s)", hr_ch);
  308|  15.0k|    snprintf(buf, buf_sz, "%dHz %s %dch %s", rate,
  309|  15.0k|             ch, channels.num, af_fmt_to_str(format));
  310|  15.0k|    return buf;
  311|  15.0k|}

mp_clients_init:
  180|  11.6k|{
  181|  11.6k|    mpctx->clients = talloc_ptrtype(NULL, mpctx->clients);
  ------------------
  |  |   34|  11.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  11.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|  11.6k|    *mpctx->clients = (struct mp_client_api) {
  183|  11.6k|        .mpctx = mpctx,
  184|  11.6k|    };
  185|  11.6k|    mpctx->global->client_api = mpctx->clients;
  186|  11.6k|    mp_mutex_init(&mpctx->clients->lock);
  187|  11.6k|}
mp_clients_destroy:
  190|  11.6k|{
  191|  11.6k|    if (!mpctx->clients)
  ------------------
  |  Branch (191:9): [True: 0, False: 11.6k]
  ------------------
  192|      0|        return;
  193|  11.6k|    mp_assert(mpctx->clients->num_clients == 0);
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (193:5): [True: 11.6k, 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|  11.6k|    if (mpctx->clients->render_context) {
  ------------------
  |  Branch (197:9): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    mp_mutex_destroy(&mpctx->clients->lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  203|  11.6k|    talloc_free(mpctx->clients);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  204|       |    mpctx->clients = NULL;
  205|  11.6k|}
mp_clients_all_initialized:
  210|  11.6k|{
  211|  11.6k|    bool all_ok = true;
  212|  11.6k|    mp_mutex_lock(&mpctx->clients->lock);
  ------------------
  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  213|  23.3k|    for (int n = 0; n < mpctx->clients->num_clients; n++) {
  ------------------
  |  Branch (213:21): [True: 11.6k, False: 11.6k]
  ------------------
  214|  11.6k|        struct mpv_handle *ctx = mpctx->clients->clients[n];
  215|  11.6k|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  216|  11.6k|        all_ok &= ctx->fuzzy_initialized;
  217|  11.6k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  218|  11.6k|    }
  219|  11.6k|    mp_mutex_unlock(&mpctx->clients->lock);
  ------------------
  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  220|  11.6k|    return all_ok;
  221|  11.6k|}
mp_new_weak_client:
  324|  11.6k|{
  325|       |    return new_client(clients, name, true);
  326|  11.6k|}
mp_client_get_log:
  339|   478k|{
  340|   478k|    return ctx->log;
  341|   478k|}
mpv_set_wakeup_callback:
  378|  23.3k|{
  379|  23.3k|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  380|  23.3k|    ctx->wakeup_cb = cb;
  381|  23.3k|    ctx->wakeup_cb_ctx = d;
  382|  23.3k|    if (ctx->wakeup_cb)
  ------------------
  |  Branch (382:9): [True: 23.3k, False: 0]
  ------------------
  383|  23.3k|        ctx->wakeup_cb(ctx->wakeup_cb_ctx);
  384|  23.3k|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  385|  23.3k|}
mpv_wait_async_requests:
  398|  35.0k|{
  399|  35.0k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  400|  35.0k|    while (ctx->reserved_events || ctx->async_counter)
  ------------------
  |  Branch (400:12): [True: 0, False: 35.0k]
  |  Branch (400:36): [True: 0, False: 35.0k]
  ------------------
  401|      0|        wait_wakeup(ctx, INT64_MAX);
  402|  35.0k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  403|  35.0k|}
mpv_destroy:
  537|  23.3k|{
  538|       |    mp_destroy_client(ctx, false);
  539|  23.3k|}
mpv_terminate_destroy:
  542|  11.6k|{
  543|       |    mp_destroy_client(ctx, true);
  544|  11.6k|}
mp_shutdown_clients:
  549|  23.3k|{
  550|  23.3k|    struct mp_client_api *clients = mpctx->clients;
  551|       |
  552|       |    // Forcefully abort async work after 2 seconds of waiting.
  553|  23.3k|    double abort_time = mp_time_sec() + 2;
  554|       |
  555|  23.3k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  556|       |
  557|       |    // Prevent that new clients can appear.
  558|  23.3k|    clients->shutting_down = true;
  559|       |
  560|       |    // Wait until we can terminate.
  561|  27.3k|    while (clients->num_clients || mpctx->outstanding_async ||
  ------------------
  |  Branch (561:12): [True: 3.83k, False: 23.5k]
  |  Branch (561:36): [True: 0, False: 23.5k]
  ------------------
  562|  23.5k|           !(mpctx->is_cli || clients->terminate_core_thread))
  ------------------
  |  Branch (562:14): [True: 0, False: 23.5k]
  |  Branch (562:31): [True: 23.3k, False: 196]
  ------------------
  563|  4.03k|    {
  564|  4.03k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  4.03k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  565|       |
  566|  4.03k|        double left = abort_time - mp_time_sec();
  567|  4.03k|        if (left >= 0) {
  ------------------
  |  Branch (567:13): [True: 4.03k, False: 0]
  ------------------
  568|  4.03k|            mp_set_timeout(mpctx, left);
  569|  4.03k|        } 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|  4.03k|        mp_client_broadcast_event(mpctx, MPV_EVENT_SHUTDOWN, NULL);
  577|  4.03k|        mp_wait_events(mpctx);
  578|       |
  579|  4.03k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  4.03k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  580|  4.03k|    }
  581|       |
  582|  23.3k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  583|  23.3k|}
mp_is_shutting_down:
  586|   152k|{
  587|   152k|    struct mp_client_api *clients = mpctx->clients;
  588|   152k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   152k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  589|   152k|    bool res = clients->shutting_down;
  590|   152k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   152k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  591|   152k|    return res;
  592|   152k|}
mpv_create:
  639|  11.6k|{
  640|       |    return create_core(false);
  641|  11.6k|}
mpv_create_client:
  654|  11.6k|{
  655|       |    return create_client(ctx, name, false);
  656|  11.6k|}
mpv_initialize_opts:
  669|  11.6k|{
  670|  11.6k|    lock_core(ctx);
  671|  11.6k|    int res = mp_initialize(ctx->mpctx, options) ? MPV_ERROR_INVALID_PARAMETER : 0;
  ------------------
  |  Branch (671:15): [True: 0, False: 11.6k]
  ------------------
  672|  11.6k|#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|  11.6k|    if (options)
  ------------------
  |  Branch (675:9): [True: 0, False: 11.6k]
  ------------------
  676|      0|        ctx->mpctx->stop_play = PT_QUIT;
  677|  11.6k|#endif
  678|  11.6k|    mp_wakeup_core(ctx->mpctx);
  679|  11.6k|    unlock_core(ctx);
  680|  11.6k|    return res;
  681|  11.6k|}
mpv_initialize:
  684|  11.6k|{
  685|       |    return mpv_initialize_opts(ctx, NULL);
  686|  11.6k|}
mp_client_broadcast_event:
  786|  9.03M|{
  787|  9.03M|    struct mp_client_api *clients = mpctx->clients;
  788|       |
  789|  9.03M|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  9.03M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  790|       |
  791|  26.9M|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (791:21): [True: 17.9M, False: 9.03M]
  ------------------
  792|  17.9M|        struct mpv_event event_data = {
  793|  17.9M|            .event_id = event,
  794|  17.9M|            .data = data,
  795|  17.9M|        };
  796|  17.9M|        send_event(clients->clients[n], &event_data, true);
  797|  17.9M|    }
  798|       |
  799|  9.03M|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  9.03M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  800|  9.03M|}
mp_client_broadcast_event_external:
  806|  3.67k|{
  807|  3.67k|    struct MPContext *mpctx = api->mpctx;
  808|       |
  809|  3.67k|    mp_client_broadcast_event(mpctx, event, data);
  810|  3.67k|    mp_wakeup_core(mpctx);
  811|  3.67k|}
mp_client_send_event:
  816|    559|{
  817|    559|    if (!client_name) {
  ------------------
  |  Branch (817:9): [True: 0, False: 559]
  ------------------
  818|      0|        mp_client_broadcast_event(mpctx, event, data);
  819|      0|        talloc_free(data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  820|      0|        return 0;
  821|      0|    }
  822|       |
  823|    559|    struct mp_client_api *clients = mpctx->clients;
  824|    559|    int r = 0;
  825|       |
  826|    559|    struct mpv_event event_data = {
  827|    559|        .event_id = event,
  828|    559|        .data = data,
  829|    559|        .reply_userdata = reply_userdata,
  830|    559|    };
  831|       |
  832|    559|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|    559|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  833|       |
  834|    559|    struct mpv_handle *ctx = find_client(clients, client_name);
  835|    559|    if (ctx) {
  ------------------
  |  Branch (835:9): [True: 0, False: 559]
  ------------------
  836|      0|        r = send_event(ctx, &event_data, false);
  837|    559|    } else {
  838|    559|        r = -1;
  839|    559|    }
  840|       |
  841|    559|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|    559|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|       |
  843|    559|    if (r < 0)
  ------------------
  |  Branch (843:9): [True: 559, False: 0]
  ------------------
  844|    559|        talloc_free(data);
  ------------------
  |  |   47|    559|#define talloc_free                     ta_free
  ------------------
  845|       |
  846|    559|    return r;
  847|    559|}
mp_client_send_event_dup:
  851|    319|{
  852|    319|    if (!client_name) {
  ------------------
  |  Branch (852:9): [True: 248, False: 71]
  ------------------
  853|    248|        mp_client_broadcast_event(mpctx, event, data);
  854|    248|        return 0;
  855|    248|    }
  856|       |
  857|     71|    struct mpv_event event_data = {
  858|     71|        .event_id = event,
  859|     71|        .data = data,
  860|     71|    };
  861|       |
  862|     71|    dup_event_data(&event_data);
  863|     71|    return mp_client_send_event(mpctx, client_name, 0, event, event_data.data);
  864|    319|}
mpv_request_event:
  872|  35.0k|{
  873|  35.0k|    if (!mpv_event_name(event) || enable < 0 || enable > 1)
  ------------------
  |  Branch (873:9): [True: 0, False: 35.0k]
  |  Branch (873:35): [True: 0, False: 35.0k]
  |  Branch (873:49): [True: 0, False: 35.0k]
  ------------------
  874|      0|        return MPV_ERROR_INVALID_PARAMETER;
  875|  35.0k|    if (event == MPV_EVENT_SHUTDOWN && !enable)
  ------------------
  |  Branch (875:9): [True: 0, False: 35.0k]
  |  Branch (875:40): [True: 0, False: 0]
  ------------------
  876|      0|        return MPV_ERROR_INVALID_PARAMETER;
  877|  35.0k|    mp_assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (877:5): [True: 35.0k, False: 0]
  ------------------
  878|  35.0k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  879|  35.0k|    uint64_t bit = 1ULL << event;
  880|  35.0k|    ctx->event_mask = enable ? ctx->event_mask | bit : ctx->event_mask & ~bit;
  ------------------
  |  Branch (880:23): [True: 0, False: 35.0k]
  ------------------
  881|  35.0k|    if (enable && event < MP_ARRAY_SIZE(deprecated_events) &&
  ------------------
  |  |   49|  35.0k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (881:9): [True: 0, False: 35.0k]
  |  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|  35.0k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  888|  35.0k|    return 0;
  889|  35.0k|}
mpv_wait_event:
  913|  11.5M|{
  914|  11.5M|    mpv_event *event = ctx->cur_event;
  915|       |
  916|  11.5M|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  11.5M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  917|       |
  918|  11.5M|    if (!ctx->fuzzy_initialized)
  ------------------
  |  Branch (918:9): [True: 11.6k, False: 11.5M]
  ------------------
  919|  11.6k|        mp_wakeup_core(ctx->clients->mpctx);
  920|  11.5M|    ctx->fuzzy_initialized = true;
  921|       |
  922|  11.5M|    if (timeout < 0)
  ------------------
  |  Branch (922:9): [True: 147k, False: 11.4M]
  ------------------
  923|   147k|        timeout = 1e20;
  924|       |
  925|  11.5M|    int64_t deadline = mp_time_ns_add(mp_time_ns(), timeout);
  926|       |
  927|  11.5M|    *event = (mpv_event){0};
  928|  11.5M|    talloc_free_children(event);
  ------------------
  |  |   46|  11.5M|#define talloc_free_children            ta_free_children
  ------------------
  929|       |
  930|  17.0M|    while (1) {
  ------------------
  |  Branch (930:12): [True: 17.0M, Folded]
  ------------------
  931|  17.0M|        if (ctx->queued_wakeup)
  ------------------
  |  Branch (931:13): [True: 0, False: 17.0M]
  ------------------
  932|      0|            deadline = 0;
  933|       |        // Recover from overflow.
  934|  17.0M|        if (ctx->choked && !ctx->num_events) {
  ------------------
  |  Branch (934:13): [True: 19.0k, False: 17.0M]
  |  Branch (934:28): [True: 19, False: 19.0k]
  ------------------
  935|     19|            ctx->choked = false;
  936|     19|            event->event_id = MPV_EVENT_QUEUE_OVERFLOW;
  937|     19|            break;
  938|     19|        }
  939|  17.0M|        struct mpv_event *ev =
  940|  17.0M|            ctx->num_events ? &ctx->events[ctx->first_event] : NULL;
  ------------------
  |  Branch (940:13): [True: 11.1M, False: 5.87M]
  ------------------
  941|  17.0M|        if (ev && ev->event_id == MPV_EVENT_HOOK) {
  ------------------
  |  Branch (941:13): [True: 11.1M, False: 5.87M]
  |  Branch (941:19): [True: 0, False: 11.1M]
  ------------------
  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|  17.0M|        if (ev) {
  ------------------
  |  Branch (955:13): [True: 11.1M, False: 5.87M]
  ------------------
  956|  11.1M|            *event = *ev;
  957|  11.1M|            ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  958|  11.1M|            ctx->num_events--;
  959|  11.1M|            talloc_steal(event, event->data);
  ------------------
  |  |   38|  11.1M|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  11.1M|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  960|  11.1M|            break;
  961|  11.1M|        }
  962|       |        // If there's a changed property, generate change event (never queued).
  963|  5.87M|        if (gen_property_change_event(ctx))
  ------------------
  |  Branch (963:13): [True: 21.5k, False: 5.84M]
  ------------------
  964|  21.5k|            break;
  965|       |        // Pop item from message queue, and return as event.
  966|  5.84M|        if (gen_log_message_event(ctx))
  ------------------
  |  Branch (966:13): [True: 0, False: 5.84M]
  ------------------
  967|      0|            break;
  968|  5.84M|        int r = wait_wakeup(ctx, deadline);
  969|  5.84M|        if (r == ETIMEDOUT)
  ------------------
  |  Branch (969:13): [True: 356k, False: 5.49M]
  ------------------
  970|   356k|            break;
  971|  5.84M|    }
  972|  11.5M|    ctx->queued_wakeup = false;
  973|       |
  974|  11.5M|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  11.5M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  975|       |
  976|  11.5M|    return event;
  977|  11.5M|}
mpv_free_node_contents:
 1038|   909k|{
 1039|   909k|    static const struct m_option type = { .type = CONF_TYPE_NODE };
  ------------------
  |  |  253|   909k|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 1040|   909k|    m_option_free(&type, node);
 1041|   909k|}
mpv_set_option:
 1045|  93.3k|{
 1046|  93.3k|    const struct m_option *type = get_mp_type(format);
 1047|  93.3k|    if (!type)
  ------------------
  |  Branch (1047:9): [True: 0, False: 93.3k]
  ------------------
 1048|      0|        return MPV_ERROR_OPTION_FORMAT;
 1049|  93.3k|    struct mpv_node tmp;
 1050|  93.3k|    if (format != MPV_FORMAT_NODE) {
  ------------------
  |  Branch (1050:9): [True: 93.3k, False: 0]
  ------------------
 1051|  93.3k|        tmp.format = format;
 1052|  93.3k|        memcpy(&tmp.u, data, type->type->size);
 1053|  93.3k|        data = &tmp;
 1054|  93.3k|    }
 1055|  93.3k|    lock_core(ctx);
 1056|  93.3k|    int err = m_config_set_option_node(ctx->mpctx->mconfig, bstr0(name), data, 0);
 1057|  93.3k|    unlock_core(ctx);
 1058|  93.3k|    switch (err) {
 1059|      0|    case M_OPT_MISSING_PARAM:
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (1059:5): [True: 0, False: 93.3k]
  ------------------
 1060|      0|    case M_OPT_INVALID:
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  |  Branch (1060:5): [True: 0, False: 93.3k]
  ------------------
 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: 93.3k]
  ------------------
 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: 93.3k]
  ------------------
 1065|      0|        return MPV_ERROR_OPTION_NOT_FOUND;
 1066|  93.3k|    default:
  ------------------
  |  Branch (1066:5): [True: 93.3k, False: 0]
  ------------------
 1067|  93.3k|        if (err >= 0)
  ------------------
  |  Branch (1067:13): [True: 93.3k, False: 0]
  ------------------
 1068|  93.3k|            return 0;
 1069|      0|        return MPV_ERROR_OPTION_ERROR;
 1070|  93.3k|    }
 1071|  93.3k|}
mpv_set_option_string:
 1074|  93.3k|{
 1075|  93.3k|    return mpv_set_option(ctx, name, MPV_FORMAT_STRING, &data);
 1076|  93.3k|}
mpv_command:
 1165|  35.0k|{
 1166|       |    return run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), NULL);
 1167|  35.0k|}
mpv_command_string:
 1188|  2.76M|{
 1189|  2.76M|    return run_client_command(ctx,
 1190|       |        mp_input_parse_cmd(ctx->mpctx->input, bstr0((char*)args), ctx->name), NULL);
 1191|  2.76M|}
mpv_get_property:
 1493|  24.9k|{
 1494|  24.9k|    if (!ctx->mpctx->initialized)
  ------------------
  |  Branch (1494:9): [True: 0, False: 24.9k]
  ------------------
 1495|      0|        return MPV_ERROR_UNINITIALIZED;
 1496|  24.9k|    if (!data)
  ------------------
  |  Branch (1496:9): [True: 0, False: 24.9k]
  ------------------
 1497|      0|        return MPV_ERROR_INVALID_PARAMETER;
 1498|  24.9k|    if (!get_mp_type_get(format))
  ------------------
  |  Branch (1498:9): [True: 0, False: 24.9k]
  ------------------
 1499|      0|        return MPV_ERROR_PROPERTY_FORMAT;
 1500|       |
 1501|  24.9k|    struct getproperty_request req = {
 1502|  24.9k|        .mpctx = ctx->mpctx,
 1503|  24.9k|        .name = name,
 1504|  24.9k|        .format = format,
 1505|  24.9k|        .data = data,
 1506|  24.9k|    };
 1507|  24.9k|    run_locked(ctx, getproperty_fn, &req);
 1508|  24.9k|    return req.status;
 1509|  24.9k|}
mpv_observe_property:
 1558|  23.3k|{
 1559|  23.3k|    const struct m_option *type = get_mp_type_get(format);
 1560|  23.3k|    if (format != MPV_FORMAT_NONE && !type)
  ------------------
  |  Branch (1560:9): [True: 0, False: 23.3k]
  |  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|  23.3k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1563:9): [True: 0, False: 23.3k]
  ------------------
 1564|      0|        return MPV_ERROR_PROPERTY_FORMAT;
 1565|       |
 1566|  23.3k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1567|  23.3k|    mp_assert(!ctx->destroying);
  ------------------
  |  |   41|  23.3k|#define mp_assert assert
  ------------------
  |  Branch (1567:5): [True: 23.3k, False: 0]
  ------------------
 1568|  23.3k|    struct observe_property *prop = talloc_ptrtype(ctx, prop);
  ------------------
  |  |   34|  23.3k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  23.3k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  23.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|  23.3k|    talloc_set_destructor(prop, property_free);
  ------------------
  |  |   41|  23.3k|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1570|  23.3k|    *prop = (struct observe_property){
 1571|  23.3k|        .owner = ctx,
 1572|  23.3k|        .name = talloc_strdup(prop, name),
  ------------------
  |  |   50|  23.3k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1573|  23.3k|        .id = mp_get_property_id(ctx->mpctx, name),
 1574|  23.3k|        .event_mask = mp_get_property_event_mask(name),
 1575|  23.3k|        .reply_id = userdata,
 1576|  23.3k|        .format = format,
 1577|  23.3k|        .type = type,
 1578|  23.3k|        .change_ts = 1, // force initial event
 1579|  23.3k|        .refcount = 1,
 1580|  23.3k|        .value = m_option_value_default,
 1581|  23.3k|        .value_ret = m_option_value_default,
 1582|  23.3k|    };
 1583|  23.3k|    ctx->properties_change_ts += 1;
 1584|  23.3k|    MP_TARRAY_APPEND(ctx, ctx->properties, ctx->num_properties, prop);
  ------------------
  |  |  105|  23.3k|    do {                                            \
  |  |  106|  23.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  23.3k|    do {                                            \
  |  |  |  |   97|  23.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  23.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  23.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  23.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 11.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  23.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  23.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 23.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  23.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  23.3k|        (idxvar)++;                                 \
  |  |  109|  23.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 23.3k]
  |  |  ------------------
  ------------------
 1585|  23.3k|    ctx->property_event_masks |= prop->event_mask;
 1586|  23.3k|    ctx->new_property_events = true;
 1587|  23.3k|    ctx->cur_property_index = 0;
 1588|  23.3k|    ctx->has_pending_properties = true;
 1589|  23.3k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1590|  23.3k|    mp_wakeup_core(ctx->mpctx);
 1591|  23.3k|    return 0;
 1592|  23.3k|}
mpv_unobserve_property:
 1595|  23.3k|{
 1596|  23.3k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1597|  23.3k|    int count = 0;
 1598|  46.6k|    for (int n = ctx->num_properties - 1; n >= 0; n--) {
  ------------------
  |  Branch (1598:43): [True: 23.3k, False: 23.3k]
  ------------------
 1599|  23.3k|        struct observe_property *prop = ctx->properties[n];
 1600|       |        // Perform actual removal of the property lazily to avoid creating
 1601|       |        // dangling pointers and such.
 1602|  23.3k|        if (prop->reply_id == userdata) {
  ------------------
  |  Branch (1602:13): [True: 23.3k, False: 0]
  ------------------
 1603|  23.3k|            prop_unref(prop);
 1604|  23.3k|            ctx->properties_change_ts += 1;
 1605|  23.3k|            MP_TARRAY_REMOVE_AT(ctx->properties, ctx->num_properties, n);
  ------------------
  |  |  143|  23.3k|    do {                                            \
  |  |  144|  23.3k|        size_t at_ = (at);                          \
  |  |  145|  23.3k|        assert(at_ < (idxvar));                     \
  |  |  146|  23.3k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  23.3k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  23.3k|        (idxvar)--;                                 \
  |  |  149|  23.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 23.3k]
  |  |  ------------------
  ------------------
  |  Branch (1605:13): [True: 23.3k, False: 0]
  ------------------
 1606|  23.3k|            ctx->cur_property_index = 0;
 1607|  23.3k|            count++;
 1608|  23.3k|        }
 1609|  23.3k|    }
 1610|  23.3k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1611|  23.3k|    return count;
 1612|  23.3k|}
mp_client_property_change:
 1640|   205k|{
 1641|   205k|    struct mp_client_api *clients = mpctx->clients;
 1642|   205k|    int id = mp_get_property_id(mpctx, name);
 1643|   205k|    bool any_pending = false;
 1644|       |
 1645|   205k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|   205k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1646|       |
 1647|   615k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1647:21): [True: 410k, False: 205k]
  ------------------
 1648|   410k|        struct mpv_handle *client = clients->clients[n];
 1649|   410k|        mp_mutex_lock(&client->lock);
  ------------------
  |  |  134|   410k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1650|   410k|        for (int i = 0; i < client->num_properties; i++) {
  ------------------
  |  Branch (1650:25): [True: 24, False: 410k]
  ------------------
 1651|     24|            if (client->properties[i]->id == id &&
  ------------------
  |  Branch (1651:17): [True: 0, False: 24]
  ------------------
 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|     24|        }
 1658|   410k|        mp_mutex_unlock(&client->lock);
  ------------------
  |  |  136|   410k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1659|   410k|    }
 1660|       |
 1661|   205k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|   205k|#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|   205k|    if (any_pending)
  ------------------
  |  Branch (1667:9): [True: 0, False: 205k]
  ------------------
 1668|      0|        mp_dispatch_adjust_timeout(mpctx->dispatch, 0);
 1669|   205k|}
mp_client_send_property_changes:
 1774|  11.6M|{
 1775|  11.6M|    struct mp_client_api *clients = mpctx->clients;
 1776|       |
 1777|  11.6M|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  11.6M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1778|  11.6M|    uint64_t cur_ts = clients->clients_list_change_ts;
 1779|       |
 1780|  34.9M|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (1780:21): [True: 23.2M, False: 11.6M]
  ------------------
 1781|  23.2M|        struct mpv_handle *ctx = clients->clients[n];
 1782|       |
 1783|  23.2M|        mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  23.2M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1784|  23.2M|        if (!ctx->has_pending_properties || ctx->destroying) {
  ------------------
  |  Branch (1784:13): [True: 23.2M, False: 23.3k]
  |  Branch (1784:45): [True: 0, False: 23.3k]
  ------------------
 1785|  23.2M|            mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  23.2M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1786|  23.2M|            continue;
 1787|  23.2M|        }
 1788|       |        // Keep ctx->lock locked (unlock order does not matter).
 1789|  23.3k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1790|  23.3k|        send_client_property_changes(ctx);
 1791|  23.3k|        mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  23.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1792|  23.3k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  23.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1793|  23.3k|        if (cur_ts != clients->clients_list_change_ts) {
  ------------------
  |  Branch (1793:13): [True: 54, False: 23.3k]
  ------------------
 1794|       |            // List changed; need to start over. Do it in the next iteration.
 1795|     54|            mp_wakeup_core(mpctx);
 1796|     54|            break;
 1797|     54|        }
 1798|  23.3k|    }
 1799|       |
 1800|  11.6M|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  11.6M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1801|  11.6M|}
mpv_event_to_node:
 1970|  5.57M|{
 1971|  5.57M|    *dst = (mpv_node){0};
 1972|       |
 1973|  5.57M|    node_init(dst, MPV_FORMAT_NODE_MAP, NULL);
 1974|  5.57M|    node_map_add_string(dst, "event", mpv_event_name(event->event_id));
 1975|       |
 1976|  5.57M|    if (event->error < 0)
  ------------------
  |  Branch (1976:9): [True: 0, False: 5.57M]
  ------------------
 1977|      0|        node_map_add_string(dst, "error", mpv_error_string(event->error));
 1978|       |
 1979|  5.57M|    if (event->reply_userdata)
  ------------------
  |  Branch (1979:9): [True: 0, False: 5.57M]
  ------------------
 1980|      0|        node_map_add_int64(dst, "id", event->reply_userdata);
 1981|       |
 1982|  5.57M|    switch (event->event_id) {
  ------------------
  |  Branch (1982:13): [True: 22.7k, False: 5.55M]
  ------------------
 1983|       |
 1984|  16.1k|    case MPV_EVENT_START_FILE: {
  ------------------
  |  Branch (1984:5): [True: 16.1k, False: 5.55M]
  ------------------
 1985|  16.1k|        mpv_event_start_file *esf = event->data;
 1986|       |
 1987|  16.1k|        node_map_add_int64(dst, "playlist_entry_id", esf->playlist_entry_id);
 1988|  16.1k|        break;
 1989|      0|    }
 1990|       |
 1991|  5.98k|    case MPV_EVENT_END_FILE: {
  ------------------
  |  Branch (1991:5): [True: 5.98k, False: 5.56M]
  ------------------
 1992|  5.98k|        mpv_event_end_file *eef = event->data;
 1993|       |
 1994|  5.98k|        const char *reason;
 1995|  5.98k|        switch (eef->reason) {
 1996|  3.71k|        case MPV_END_FILE_REASON_EOF: reason = "eof"; break;
  ------------------
  |  Branch (1996:9): [True: 3.71k, False: 2.27k]
  ------------------
 1997|  1.41k|        case MPV_END_FILE_REASON_STOP: reason = "stop"; break;
  ------------------
  |  Branch (1997:9): [True: 1.41k, False: 4.56k]
  ------------------
 1998|      7|        case MPV_END_FILE_REASON_QUIT: reason = "quit"; break;
  ------------------
  |  Branch (1998:9): [True: 7, False: 5.98k]
  ------------------
 1999|    846|        case MPV_END_FILE_REASON_ERROR: reason = "error"; break;
  ------------------
  |  Branch (1999:9): [True: 846, False: 5.14k]
  ------------------
 2000|      0|        case MPV_END_FILE_REASON_REDIRECT: reason = "redirect"; break;
  ------------------
  |  Branch (2000:9): [True: 0, False: 5.98k]
  ------------------
 2001|      0|        default:
  ------------------
  |  Branch (2001:9): [True: 0, False: 5.98k]
  ------------------
 2002|      0|            reason = "unknown";
 2003|  5.98k|        }
 2004|  5.98k|        node_map_add_string(dst, "reason", reason);
 2005|       |
 2006|  5.98k|        node_map_add_int64(dst, "playlist_entry_id", eef->playlist_entry_id);
 2007|       |
 2008|  5.98k|        if (eef->playlist_insert_id) {
  ------------------
  |  Branch (2008:13): [True: 0, False: 5.98k]
  ------------------
 2009|      0|            node_map_add_int64(dst, "playlist_insert_id", eef->playlist_insert_id);
 2010|      0|            node_map_add_int64(dst, "playlist_insert_num_entries",
 2011|      0|                               eef->playlist_insert_num_entries);
 2012|      0|        }
 2013|       |
 2014|  5.98k|        if (eef->reason == MPV_END_FILE_REASON_ERROR)
  ------------------
  |  Branch (2014:13): [True: 846, False: 5.14k]
  ------------------
 2015|    846|            node_map_add_string(dst, "file_error", mpv_error_string(eef->error));
 2016|  5.98k|        break;
 2017|  5.98k|    }
 2018|       |
 2019|      0|    case MPV_EVENT_LOG_MESSAGE: {
  ------------------
  |  Branch (2019:5): [True: 0, False: 5.57M]
  ------------------
 2020|      0|        mpv_event_log_message *msg = event->data;
 2021|       |
 2022|      0|        node_map_add_string(dst, "prefix", msg->prefix);
 2023|      0|        node_map_add_string(dst, "level",  msg->level);
 2024|      0|        node_map_add_string(dst, "text",   msg->text);
 2025|      0|        break;
 2026|  5.98k|    }
 2027|       |
 2028|    677|    case MPV_EVENT_CLIENT_MESSAGE: {
  ------------------
  |  Branch (2028:5): [True: 677, False: 5.57M]
  ------------------
 2029|    677|        mpv_event_client_message *msg = event->data;
 2030|       |
 2031|    677|        struct mpv_node *args = node_map_add(dst, "args", MPV_FORMAT_NODE_ARRAY);
 2032|  7.15k|        for (int n = 0; n < msg->num_args; n++) {
  ------------------
  |  Branch (2032:25): [True: 6.48k, False: 677]
  ------------------
 2033|  6.48k|            struct mpv_node *sn = node_array_add(args, MPV_FORMAT_NONE);
 2034|  6.48k|            sn->format = MPV_FORMAT_STRING;
 2035|  6.48k|            sn->u.string = (char *)msg->args[n];
 2036|  6.48k|        }
 2037|    677|        break;
 2038|  5.98k|    }
 2039|       |
 2040|      0|    case MPV_EVENT_PROPERTY_CHANGE: {
  ------------------
  |  Branch (2040:5): [True: 0, False: 5.57M]
  ------------------
 2041|      0|        mpv_event_property *prop = event->data;
 2042|       |
 2043|      0|        node_map_add_string(dst, "name", prop->name);
 2044|       |
 2045|      0|        switch (prop->format) {
 2046|      0|        case MPV_FORMAT_NODE:
  ------------------
  |  Branch (2046:9): [True: 0, False: 0]
  ------------------
 2047|      0|            *node_map_add(dst, "data", MPV_FORMAT_NONE) =
 2048|      0|                *(struct mpv_node *)prop->data;
 2049|      0|            break;
 2050|      0|        case MPV_FORMAT_DOUBLE:
  ------------------
  |  Branch (2050:9): [True: 0, False: 0]
  ------------------
 2051|      0|            node_map_add_double(dst, "data", *(double *)prop->data);
 2052|      0|            break;
 2053|      0|        case MPV_FORMAT_FLAG:
  ------------------
  |  Branch (2053:9): [True: 0, False: 0]
  ------------------
 2054|      0|            node_map_add_flag(dst, "data", *(int *)prop->data);
 2055|      0|            break;
 2056|      0|        case MPV_FORMAT_STRING:
  ------------------
  |  Branch (2056:9): [True: 0, False: 0]
  ------------------
 2057|      0|            node_map_add_string(dst, "data", *(char **)prop->data);
 2058|      0|            break;
 2059|      0|        default: ;
  ------------------
  |  Branch (2059:9): [True: 0, False: 0]
  ------------------
 2060|      0|        }
 2061|      0|        break;
 2062|      0|    }
 2063|       |
 2064|      0|    case MPV_EVENT_COMMAND_REPLY: {
  ------------------
  |  Branch (2064:5): [True: 0, False: 5.57M]
  ------------------
 2065|      0|        mpv_event_command *cmd = event->data;
 2066|       |
 2067|      0|        *node_map_add(dst, "result", MPV_FORMAT_NONE) = cmd->result;
 2068|      0|        break;
 2069|      0|    }
 2070|       |
 2071|      0|    case MPV_EVENT_HOOK: {
  ------------------
  |  Branch (2071:5): [True: 0, False: 5.57M]
  ------------------
 2072|      0|        mpv_event_hook *hook = event->data;
 2073|       |
 2074|      0|        node_map_add_int64(dst, "hook_id", hook->id);
 2075|      0|        break;
 2076|      0|    }
 2077|       |
 2078|  5.57M|    }
 2079|  5.57M|    return 0;
 2080|  5.57M|}
mpv_error_string:
 2107|   495k|{
 2108|   495k|    error = -error;
 2109|   495k|    if (error < 0)
  ------------------
  |  Branch (2109:9): [True: 0, False: 495k]
  ------------------
 2110|      0|        error = 0;
 2111|   495k|    const char *name = NULL;
 2112|   495k|    if (error < MP_ARRAY_SIZE(err_table))
  ------------------
  |  |   49|   495k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2112:9): [True: 495k, False: 0]
  ------------------
 2113|   495k|        name = err_table[error];
 2114|   495k|    return name ? name : "unknown error";
  ------------------
  |  Branch (2114:12): [True: 495k, False: 0]
  ------------------
 2115|   495k|}
mpv_event_name:
 2140|  5.60M|{
 2141|  5.60M|    if ((unsigned)event >= MP_ARRAY_SIZE(event_table))
  ------------------
  |  |   49|  5.60M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2141:9): [True: 0, False: 5.60M]
  ------------------
 2142|      0|        return NULL;
 2143|  5.60M|    return event_table[event];
 2144|  5.60M|}
mp_streamcb_lookup:
 2252|  30.1k|{
 2253|  30.1k|    struct mp_client_api *clients = g->client_api;
 2254|  30.1k|    bool found = false;
 2255|  30.1k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  30.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2256|  30.1k|    for (int n = 0; n < clients->num_custom_protocols; n++) {
  ------------------
  |  Branch (2256:21): [True: 0, False: 30.1k]
  ------------------
 2257|      0|        struct mp_custom_protocol *proto = &clients->custom_protocols[n];
 2258|      0|        if (strcmp(proto->protocol, protocol) == 0) {
  ------------------
  |  Branch (2258:13): [True: 0, False: 0]
  ------------------
 2259|      0|            *out_user_data = proto->user_data;
 2260|      0|            *out_fn = proto->open_fn;
 2261|      0|            found = true;
 2262|      0|            break;
 2263|      0|        }
 2264|      0|    }
 2265|  30.1k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  30.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2266|  30.1k|    return found;
 2267|  30.1k|}
client.c:find_client_id:
  224|      1|{
  225|      3|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (225:21): [True: 2, False: 1]
  ------------------
  226|      2|        if (clients->clients[n]->id == id)
  ------------------
  |  Branch (226:13): [True: 0, False: 2]
  ------------------
  227|      0|            return clients->clients[n];
  228|      2|    }
  229|      1|    return NULL;
  230|      1|}
client.c:new_client:
  262|  35.0k|{
  263|  35.0k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  264|       |
  265|  35.0k|    char nname[MAX_CLIENT_NAME];
  266|  35.0k|    for (int n = 1; n < 1000; n++) {
  ------------------
  |  Branch (266:21): [True: 35.0k, False: 0]
  ------------------
  267|  35.0k|        if (!name)
  ------------------
  |  Branch (267:13): [True: 0, False: 35.0k]
  ------------------
  268|      0|            name = "client";
  269|  35.0k|        snprintf(nname, sizeof(nname) - 3, "%s", name); // - space for number
  270|   151k|        for (int i = 0; nname[i]; i++)
  ------------------
  |  Branch (270:25): [True: 116k, False: 35.0k]
  ------------------
  271|   116k|            nname[i] = mp_isalnum(nname[i]) ? nname[i] : '_';
  ------------------
  |  Branch (271:24): [True: 116k, False: 0]
  ------------------
  272|  35.0k|        if (n > 1)
  ------------------
  |  Branch (272:13): [True: 0, False: 35.0k]
  ------------------
  273|      0|            mp_snprintf_cat(nname, sizeof(nname), "%d", n);
  274|  35.0k|        if (!find_client(clients, nname))
  ------------------
  |  Branch (274:13): [True: 35.0k, False: 0]
  ------------------
  275|  35.0k|            break;
  276|      0|        nname[0] = '\0';
  277|      0|    }
  278|       |
  279|  35.0k|    if (!nname[0] || clients->shutting_down) {
  ------------------
  |  Branch (279:9): [True: 0, False: 35.0k]
  |  Branch (279:22): [True: 0, False: 35.0k]
  ------------------
  280|      0|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  281|      0|        return NULL;
  282|      0|    }
  283|       |
  284|  35.0k|    int num_events = 1000;
  285|       |
  286|  35.0k|    struct mpv_handle *client = talloc_ptrtype(NULL, client);
  ------------------
  |  |   34|  35.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  35.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|  35.0k|    *client = (struct mpv_handle){
  288|  35.0k|        .log = mp_log_new(client, clients->mpctx->log, nname),
  289|  35.0k|        .mpctx = clients->mpctx,
  290|  35.0k|        .clients = clients,
  291|  35.0k|        .id = ++(clients->id_alloc),
  292|  35.0k|        .cur_event = talloc_zero(client, struct mpv_event),
  ------------------
  |  |   27|  35.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  35.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|  35.0k|        .events = talloc_array(client, mpv_event, num_events),
  ------------------
  |  |   29|  35.0k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  35.0k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|  35.0k|        .max_events = num_events,
  295|  35.0k|        .event_mask = (1ULL << INTERNAL_EVENT_BASE) - 1, // exclude internal events
  296|  35.0k|        .wakeup_pipe = {-1, -1},
  297|  35.0k|        .is_weak = weak,
  298|  35.0k|    };
  299|  35.0k|    mp_mutex_init(&client->lock);
  300|  35.0k|    mp_mutex_init(&client->wakeup_lock);
  301|  35.0k|    mp_cond_init(&client->wakeup);
  302|       |
  303|  35.0k|    snprintf(client->name, sizeof(client->name), "%s", nname);
  304|       |
  305|  35.0k|    clients->clients_list_change_ts += 1;
  306|  35.0k|    MP_TARRAY_APPEND(clients, clients->clients, clients->num_clients, client);
  ------------------
  |  |  105|  35.0k|    do {                                            \
  |  |  106|  35.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  35.0k|    do {                                            \
  |  |  |  |   97|  35.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  35.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  35.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  35.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 23.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  35.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  35.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 35.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  35.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  35.0k|        (idxvar)++;                                 \
  |  |  109|  35.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 35.0k]
  |  |  ------------------
  ------------------
  307|       |
  308|  35.0k|    if (clients->num_clients == 1 && !clients->mpctx->is_cli)
  ------------------
  |  Branch (308:9): [True: 11.6k, False: 23.3k]
  |  Branch (308:38): [True: 11.6k, False: 0]
  ------------------
  309|  11.6k|        client->fuzzy_initialized = true;
  310|       |
  311|  35.0k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  312|       |
  313|  35.0k|    mpv_request_event(client, MPV_EVENT_TICK, 0);
  314|       |
  315|  35.0k|    return client;
  316|  35.0k|}
client.c:wait_wakeup:
  364|  5.84M|{
  365|  5.84M|    int r = 0;
  366|  5.84M|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  5.84M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  367|  5.84M|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|  5.84M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  368|  5.84M|    if (!ctx->need_wakeup)
  ------------------
  |  Branch (368:9): [True: 5.46M, False: 387k]
  ------------------
  369|  5.46M|        r = mp_cond_timedwait_until(&ctx->wakeup, &ctx->wakeup_lock, end);
  370|  5.84M|    if (r == 0)
  ------------------
  |  Branch (370:9): [True: 5.49M, False: 356k]
  ------------------
  371|  5.49M|        ctx->need_wakeup = false;
  372|  5.84M|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|  5.84M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  373|  5.84M|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  5.84M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  374|  5.84M|    return r;
  375|  5.84M|}
client.c:mp_destroy_client:
  430|  35.0k|{
  431|  35.0k|    if (!ctx)
  ------------------
  |  Branch (431:9): [True: 0, False: 35.0k]
  ------------------
  432|      0|        return;
  433|       |
  434|  35.0k|    struct MPContext *mpctx = ctx->mpctx;
  435|  35.0k|    struct mp_client_api *clients = ctx->clients;
  436|       |
  437|  35.0k|    MP_DBG(ctx, "Destroying client handle...\n");
  ------------------
  |  |   93|  35.0k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  35.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|  35.0k|    if (terminate)
  ------------------
  |  Branch (439:9): [True: 11.6k, False: 23.3k]
  ------------------
  440|  11.6k|        mpv_command(ctx, (const char*[]){"quit", NULL});
  441|       |
  442|  35.0k|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  443|       |
  444|  35.0k|    ctx->destroying = true;
  445|       |
  446|  35.0k|    for (int n = 0; n < ctx->num_properties; n++)
  ------------------
  |  Branch (446:21): [True: 0, False: 35.0k]
  ------------------
  447|      0|        prop_unref(ctx->properties[n]);
  448|  35.0k|    ctx->num_properties = 0;
  449|  35.0k|    ctx->properties_change_ts += 1;
  450|       |
  451|  35.0k|    prop_unref(ctx->cur_property);
  452|  35.0k|    ctx->cur_property = NULL;
  453|       |
  454|  35.0k|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  455|       |
  456|  35.0k|    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|  35.0k|    mpv_wait_async_requests(ctx);
  462|       |
  463|  35.0k|    osd_set_external_remove_owner(mpctx->osd, ctx);
  464|  35.0k|    mp_input_remove_sections_by_owner(mpctx->input, ctx->name);
  465|       |
  466|  35.0k|    mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  467|       |
  468|  58.3k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (468:21): [True: 58.3k, False: 0]
  ------------------
  469|  58.3k|        if (clients->clients[n] == ctx) {
  ------------------
  |  Branch (469:13): [True: 35.0k, False: 23.3k]
  ------------------
  470|  35.0k|            clients->clients_list_change_ts += 1;
  471|  35.0k|            MP_TARRAY_REMOVE_AT(clients->clients, clients->num_clients, n);
  ------------------
  |  |  143|  35.0k|    do {                                            \
  |  |  144|  35.0k|        size_t at_ = (at);                          \
  |  |  145|  35.0k|        assert(at_ < (idxvar));                     \
  |  |  146|  35.0k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  35.0k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  35.0k|        (idxvar)--;                                 \
  |  |  149|  35.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 35.0k]
  |  |  ------------------
  ------------------
  |  Branch (471:13): [True: 35.0k, False: 0]
  ------------------
  472|  39.8k|            while (ctx->num_events) {
  ------------------
  |  Branch (472:20): [True: 4.85k, False: 35.0k]
  ------------------
  473|  4.85k|                talloc_free(ctx->events[ctx->first_event].data);
  ------------------
  |  |   47|  4.85k|#define talloc_free                     ta_free
  ------------------
  474|  4.85k|                ctx->first_event = (ctx->first_event + 1) % ctx->max_events;
  475|  4.85k|                ctx->num_events--;
  476|  4.85k|            }
  477|  35.0k|            mp_msg_log_buffer_destroy(ctx->messages);
  478|  35.0k|            mp_cond_destroy(&ctx->wakeup);
  479|  35.0k|            mp_mutex_destroy(&ctx->wakeup_lock);
  ------------------
  |  |  133|  35.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  480|  35.0k|            mp_mutex_destroy(&ctx->lock);
  ------------------
  |  |  133|  35.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  481|  35.0k|            if (ctx->wakeup_pipe[0] != -1) {
  ------------------
  |  Branch (481:17): [True: 0, False: 35.0k]
  ------------------
  482|      0|                close(ctx->wakeup_pipe[0]);
  483|      0|                close(ctx->wakeup_pipe[1]);
  484|      0|            }
  485|  35.0k|            talloc_free(ctx);
  ------------------
  |  |   47|  35.0k|#define talloc_free                     ta_free
  ------------------
  486|  35.0k|            ctx = NULL;
  487|  35.0k|            break;
  488|  35.0k|        }
  489|  58.3k|    }
  490|  35.0k|    mp_assert(!ctx);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (490:5): [True: 35.0k, False: 0]
  ------------------
  491|       |
  492|  35.0k|    if (mpctx->is_cli) {
  ------------------
  |  Branch (492:9): [True: 0, False: 35.0k]
  ------------------
  493|      0|        terminate = false;
  494|  35.0k|    } else {
  495|       |        // If the last strong mpv_handle got destroyed, destroy the core.
  496|  35.0k|        bool has_strong_ref = false;
  497|  58.3k|        for (int n = 0; n < clients->num_clients; n++)
  ------------------
  |  Branch (497:25): [True: 23.3k, False: 35.0k]
  ------------------
  498|  23.3k|            has_strong_ref |= !clients->clients[n]->is_weak;
  499|  35.0k|        if (!has_strong_ref)
  ------------------
  |  Branch (499:13): [True: 11.6k, False: 23.3k]
  ------------------
  500|  11.6k|            terminate = true;
  501|       |
  502|       |        // Reserve the right to destroy mpctx for us.
  503|  35.0k|        if (clients->have_terminator)
  ------------------
  |  Branch (503:13): [True: 0, False: 35.0k]
  ------------------
  504|      0|            terminate = false;
  505|  35.0k|        clients->have_terminator |= terminate;
  506|  35.0k|    }
  507|       |
  508|       |    // mp_shutdown_clients() sleeps to avoid wasting CPU.
  509|       |    // mp_hook_test_completion() also relies on this a bit.
  510|  35.0k|    mp_wakeup_core(mpctx);
  511|       |
  512|  35.0k|    mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  35.0k|#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|  35.0k|    if (terminate) {
  ------------------
  |  Branch (516:9): [True: 11.6k, False: 23.3k]
  ------------------
  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|  11.6k|        mp_dispatch_lock(mpctx->dispatch);
  520|  11.6k|        mpctx->stop_play = PT_QUIT;
  521|  11.6k|        mp_dispatch_unlock(mpctx->dispatch);
  522|       |
  523|       |        // Ask the core thread to stop.
  524|  11.6k|        mp_mutex_lock(&clients->lock);
  ------------------
  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  525|  11.6k|        clients->terminate_core_thread = true;
  526|  11.6k|        mp_mutex_unlock(&clients->lock);
  ------------------
  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  527|  11.6k|        mp_wakeup_core(mpctx);
  528|       |
  529|       |        // Blocking wait for all clients and core thread to terminate.
  530|  11.6k|        mp_thread_join(mpctx->core_thread);
  ------------------
  |  |  215|  11.6k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  531|       |
  532|  11.6k|        mp_destroy(mpctx);
  533|  11.6k|    }
  534|  35.0k|}
client.c:abort_async:
  410|  35.0k|{
  411|  35.0k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  412|       |
  413|       |    // Destroy all => ensure any newly appearing work is aborted immediately.
  414|  35.0k|    if (ctx == NULL)
  ------------------
  |  Branch (414:9): [True: 0, False: 35.0k]
  ------------------
  415|      0|        mpctx->abort_all = true;
  416|       |
  417|  35.0k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (417:21): [True: 0, False: 35.0k]
  ------------------
  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|  35.0k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  427|  35.0k|}
client.c:create_core:
  615|  11.6k|{
  616|  11.6k|    struct MPContext *mpctx = mp_create();
  617|  11.6k|    if (!mpctx)
  ------------------
  |  Branch (617:9): [True: 0, False: 11.6k]
  ------------------
  618|      0|        return NULL;
  619|       |
  620|  11.6k|    m_config_set_profile(mpctx->mconfig, "libmpv", 0);
  621|       |
  622|  11.6k|    mpv_handle *ctx = new_client(mpctx->clients, "main", weak);
  623|  11.6k|    if (!ctx) {
  ------------------
  |  Branch (623:9): [True: 0, False: 11.6k]
  ------------------
  624|      0|        mp_destroy(mpctx);
  625|      0|        return NULL;
  626|      0|    }
  627|       |
  628|  11.6k|    if (mp_thread_create(&mpctx->core_thread, core_thread, mpctx) != 0) {
  ------------------
  |  |  214|  11.6k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  ------------------
  |  Branch (628:9): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    return ctx;
  636|  11.6k|}
client.c:core_thread:
  595|  11.6k|{
  596|  11.6k|    struct MPContext *mpctx = p;
  597|       |
  598|  11.6k|    mp_thread_set_name("core");
  599|       |
  600|  25.2k|    while (!mpctx->initialized && mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (600:12): [True: 13.5k, False: 11.6k]
  |  Branch (600:35): [True: 13.5k, False: 0]
  ------------------
  601|  13.5k|        mp_idle(mpctx);
  602|       |
  603|  11.6k|    if (mpctx->initialized)
  ------------------
  |  Branch (603:9): [True: 11.6k, False: 0]
  ------------------
  604|  11.6k|        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|  11.6k|    mp_shutdown_clients(mpctx);
  610|       |
  611|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  11.6k|#define MP_THREAD_RETURN() return NULL
  ------------------
  612|  11.6k|}
client.c:create_client:
  644|  11.6k|{
  645|  11.6k|    if (!ctx)
  ------------------
  |  Branch (645:9): [True: 0, False: 11.6k]
  ------------------
  646|      0|        return create_core(weak);
  647|  11.6k|    mpv_handle *new = new_client(ctx->mpctx->clients, name, weak);
  648|  11.6k|    if (new)
  ------------------
  |  Branch (648:9): [True: 11.6k, False: 0]
  ------------------
  649|  11.6k|        mpv_wait_event(new, 0); // set fuzzy_initialized
  650|  11.6k|    return new;
  651|  11.6k|}
client.c:lock_core:
  388|   708k|{
  389|   708k|    mp_dispatch_lock(ctx->mpctx->dispatch);
  390|   708k|}
client.c:unlock_core:
  393|   708k|{
  394|   708k|    mp_dispatch_unlock(ctx->mpctx->dispatch);
  395|   708k|}
client.c:send_event:
  749|  17.9M|{
  750|  17.9M|    mp_mutex_lock(&ctx->lock);
  ------------------
  |  |  134|  17.9M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  751|  17.9M|    uint64_t mask = 1ULL << event->event_id;
  752|  17.9M|    if (ctx->property_event_masks & mask)
  ------------------
  |  Branch (752:9): [True: 41.8k, False: 17.8M]
  ------------------
  753|  41.8k|        notify_property_events(ctx, event->event_id);
  754|  17.9M|    int r;
  755|  17.9M|    if (!(ctx->event_mask & mask)) {
  ------------------
  |  Branch (755:9): [True: 6.74M, False: 11.1M]
  ------------------
  756|  6.74M|        r = 0;
  757|  11.1M|    } else if (ctx->choked) {
  ------------------
  |  Branch (757:16): [True: 3.76k, False: 11.1M]
  ------------------
  758|  3.76k|        r = -1;
  759|  11.1M|    } else {
  760|  11.1M|        r = append_event(ctx, *event, copy);
  761|  11.1M|        if (r < 0) {
  ------------------
  |  Branch (761:13): [True: 19, False: 11.1M]
  ------------------
  762|     19|            MP_ERR(ctx, "Too many events queued.\n");
  ------------------
  |  |   89|     19|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     19|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  763|     19|            ctx->choked = true;
  764|     19|        }
  765|  11.1M|    }
  766|  17.9M|    mp_mutex_unlock(&ctx->lock);
  ------------------
  |  |  136|  17.9M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  767|  17.9M|    return r;
  768|  17.9M|}
client.c:notify_property_events:
 1674|  41.8k|{
 1675|  41.8k|    uint64_t mask = 1ULL << event;
 1676|  41.9k|    for (int i = 0; i < ctx->num_properties; i++) {
  ------------------
  |  Branch (1676:21): [True: 111, False: 41.8k]
  ------------------
 1677|    111|        if (ctx->properties[i]->event_mask & mask) {
  ------------------
  |  Branch (1677:13): [True: 111, False: 0]
  ------------------
 1678|    111|            ctx->properties[i]->change_ts += 1;
 1679|    111|            ctx->has_pending_properties = true;
 1680|    111|        }
 1681|    111|    }
 1682|       |
 1683|       |    // Same as in mp_client_property_change().
 1684|  41.8k|    if (ctx->has_pending_properties)
  ------------------
  |  Branch (1684:9): [True: 111, False: 41.7k]
  ------------------
 1685|    111|        mp_dispatch_adjust_timeout(ctx->mpctx->dispatch, 0);
 1686|  41.8k|}
client.c:append_event:
  735|  11.1M|{
  736|  11.1M|    if (ctx->num_events + ctx->reserved_events >= ctx->max_events)
  ------------------
  |  Branch (736:9): [True: 19, False: 11.1M]
  ------------------
  737|     19|        return -1;
  738|  11.1M|    if (copy)
  ------------------
  |  Branch (738:9): [True: 11.1M, False: 0]
  ------------------
  739|  11.1M|        dup_event_data(&event);
  740|  11.1M|    ctx->events[(ctx->first_event + ctx->num_events) % ctx->max_events] = event;
  741|  11.1M|    ctx->num_events++;
  742|  11.1M|    wakeup_client(ctx);
  743|  11.1M|    if (event.event_id == MPV_EVENT_SHUTDOWN)
  ------------------
  |  Branch (743:9): [True: 2.05k, False: 11.1M]
  ------------------
  744|  2.05k|        ctx->event_mask &= ctx->event_mask & ~(1ULL << MPV_EVENT_SHUTDOWN);
  745|  11.1M|    return 0;
  746|  11.1M|}
client.c:find_client:
  234|  35.5k|{
  235|  35.5k|    if (name[0] == '@') {
  ------------------
  |  Branch (235:9): [True: 2, False: 35.5k]
  ------------------
  236|      2|        char *end;
  237|      2|        errno = 0;
  238|      2|        long long int id = strtoll(name + 1, &end, 10);
  239|      2|        if (errno || end[0])
  ------------------
  |  Branch (239:13): [True: 0, False: 2]
  |  Branch (239:22): [True: 1, False: 1]
  ------------------
  240|      1|            return NULL;
  241|      1|        return find_client_id(clients, id);
  242|      2|    }
  243|       |
  244|  60.0k|    for (int n = 0; n < clients->num_clients; n++) {
  ------------------
  |  Branch (244:21): [True: 24.4k, False: 35.5k]
  ------------------
  245|  24.4k|        if (strcmp(clients->clients[n]->name, name) == 0)
  ------------------
  |  Branch (245:13): [True: 0, False: 24.4k]
  ------------------
  246|      0|            return clients->clients[n];
  247|  24.4k|    }
  248|       |
  249|  35.5k|    return NULL;
  250|  35.5k|}
client.c:dup_event_data:
  691|  11.1M|{
  692|  11.1M|    switch (ev->event_id) {
  693|  1.42k|    case MPV_EVENT_CLIENT_MESSAGE: {
  ------------------
  |  Branch (693:5): [True: 1.42k, False: 11.1M]
  ------------------
  694|  1.42k|        struct mpv_event_client_message *src = ev->data;
  695|  1.42k|        struct mpv_event_client_message *msg =
  696|  1.42k|            talloc_zero(NULL, struct mpv_event_client_message);
  ------------------
  |  |   27|  1.42k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.42k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.42k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|  14.8k|        for (int n = 0; n < src->num_args; n++) {
  ------------------
  |  Branch (697:25): [True: 13.4k, False: 1.42k]
  ------------------
  698|  13.4k|            MP_TARRAY_APPEND(msg, msg->args, msg->num_args,
  ------------------
  |  |  105|  13.4k|    do {                                            \
  |  |  106|  13.4k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  13.4k|    do {                                            \
  |  |  |  |   97|  13.4k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  13.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  13.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  13.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3.21k, False: 10.2k]
  |  |  |  |  ------------------
  |  |  |  |   99|  13.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  3.21k|    do {                                                        \
  |  |  |  |  |  |   89|  3.21k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  3.21k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  3.21k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.21k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.21k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  3.21k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  3.21k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3.21k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  13.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 13.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  13.4k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  13.4k|        (idxvar)++;                                 \
  |  |  109|  13.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 13.4k]
  |  |  ------------------
  ------------------
  699|  13.4k|                             talloc_strdup(msg, src->args[n]));
  700|  13.4k|        }
  701|  1.42k|        ev->data = msg;
  702|  1.42k|        break;
  703|      0|    }
  704|  32.3k|    case MPV_EVENT_START_FILE:
  ------------------
  |  Branch (704:5): [True: 32.3k, False: 11.1M]
  ------------------
  705|  32.3k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_start_file));
  ------------------
  |  |   49|  32.3k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  32.3k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  32.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  32.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  32.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  706|  32.3k|        break;
  707|  12.6k|    case MPV_EVENT_END_FILE:
  ------------------
  |  Branch (707:5): [True: 12.6k, False: 11.1M]
  ------------------
  708|  12.6k|        ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_end_file));
  ------------------
  |  |   49|  12.6k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  12.6k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|  12.6k|        break;
  710|  11.1M|    default:
  ------------------
  |  Branch (710:5): [True: 11.1M, False: 46.4k]
  ------------------
  711|       |        // Doesn't use events with memory allocation.
  712|  11.1M|        if (ev->data)
  ------------------
  |  Branch (712:13): [True: 0, False: 11.1M]
  ------------------
  713|      0|            abort();
  714|  11.1M|    }
  715|  11.1M|}
client.c:wakeup_client:
  349|  11.2M|{
  350|  11.2M|    mp_mutex_lock(&ctx->wakeup_lock);
  ------------------
  |  |  134|  11.2M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  351|  11.2M|    if (!ctx->need_wakeup) {
  ------------------
  |  Branch (351:9): [True: 5.49M, False: 5.71M]
  ------------------
  352|  5.49M|        ctx->need_wakeup = true;
  353|  5.49M|        mp_cond_broadcast(&ctx->wakeup);
  354|  5.49M|        if (ctx->wakeup_cb)
  ------------------
  |  Branch (354:13): [True: 5.47M, False: 23.3k]
  ------------------
  355|  5.47M|            ctx->wakeup_cb(ctx->wakeup_cb_ctx);
  356|  5.49M|        if (ctx->wakeup_pipe[0] != -1)
  ------------------
  |  Branch (356:13): [True: 0, False: 5.49M]
  ------------------
  357|      0|            (void)write(ctx->wakeup_pipe[1], &(char){0}, 1);
  358|  5.49M|    }
  359|  11.2M|    mp_mutex_unlock(&ctx->wakeup_lock);
  ------------------
  |  |  136|  11.2M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  360|  11.2M|}
client.c:get_mp_type:
  997|   191k|{
  998|   191k|    if ((unsigned)format >= MP_ARRAY_SIZE(type_conv))
  ------------------
  |  |   49|   191k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (998:9): [True: 0, False: 191k]
  ------------------
  999|      0|        return NULL;
 1000|   191k|    if (!type_conv[format].type)
  ------------------
  |  Branch (1000:9): [True: 23.3k, False: 168k]
  ------------------
 1001|  23.3k|        return NULL;
 1002|   168k|    return &type_conv[format];
 1003|   191k|}
client.c:run_client_command:
 1126|  2.80M|{
 1127|  2.80M|    if (!cmd)
  ------------------
  |  Branch (1127:9): [True: 2.19M, False: 603k]
  ------------------
 1128|  2.19M|        return MPV_ERROR_INVALID_PARAMETER;
 1129|   603k|    if (!ctx->mpctx->initialized) {
  ------------------
  |  Branch (1129:9): [True: 0, False: 603k]
  ------------------
 1130|      0|        talloc_free(cmd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1131|      0|        return MPV_ERROR_UNINITIALIZED;
 1132|      0|    }
 1133|       |
 1134|   603k|    cmd->sender = ctx->name;
 1135|       |
 1136|   603k|    struct cmd_request req = {
 1137|   603k|        .mpctx = ctx->mpctx,
 1138|   603k|        .cmd = cmd,
 1139|   603k|        .res = res,
 1140|   603k|        .completion = MP_WAITER_INITIALIZER,
  ------------------
  |  |   19|   603k|#define MP_WAITER_INITIALIZER { \
  |  |   20|   603k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|   603k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|   603k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|   603k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|   603k|    }
  ------------------
 1141|   603k|    };
 1142|       |
 1143|   603k|    bool async = cmd->flags & MP_ASYNC_CMD;
 1144|       |
 1145|   603k|    lock_core(ctx);
 1146|   603k|    if (async) {
  ------------------
  |  Branch (1146:9): [True: 475, False: 603k]
  ------------------
 1147|    475|        run_command(ctx->mpctx, cmd, NULL, NULL, NULL);
 1148|   603k|    } else {
 1149|   603k|        struct mp_abort_entry *abort = NULL;
 1150|   603k|        if (cmd->def->can_abort) {
  ------------------
  |  Branch (1150:13): [True: 93.3k, False: 509k]
  ------------------
 1151|  93.3k|            abort = talloc_zero(NULL, struct mp_abort_entry);
  ------------------
  |  |   27|  93.3k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  93.3k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  93.3k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|  93.3k|            abort->client = ctx;
 1153|  93.3k|        }
 1154|   603k|        run_command(ctx->mpctx, cmd, abort, cmd_complete, &req);
 1155|   603k|    }
 1156|   603k|    unlock_core(ctx);
 1157|       |
 1158|   603k|    if (!async)
  ------------------
  |  Branch (1158:9): [True: 603k, False: 475]
  ------------------
 1159|   603k|        mp_waiter_wait(&req.completion);
 1160|       |
 1161|   603k|    return req.status;
 1162|   603k|}
client.c:cmd_complete:
 1112|   603k|{
 1113|   603k|    struct cmd_request *req = cmd->on_completion_priv;
 1114|       |
 1115|   603k|    req->status = cmd->success ? 0 : MPV_ERROR_COMMAND;
  ------------------
  |  Branch (1115:19): [True: 297k, False: 305k]
  ------------------
 1116|   603k|    if (req->res) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 603k]
  ------------------
 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|   603k|    mp_waiter_wakeup(&req->completion, 0);
 1123|   603k|}
client.c:run_locked:
 1080|  24.9k|{
 1081|  24.9k|    mp_dispatch_lock(ctx->mpctx->dispatch);
 1082|  24.9k|    fn(fn_data);
 1083|  24.9k|    mp_dispatch_unlock(ctx->mpctx->dispatch);
 1084|  24.9k|}
client.c:translate_property_error:
 1277|  24.9k|{
 1278|  24.9k|    switch (errc) {
 1279|  24.9k|    case M_PROPERTY_OK:                 return 0;
  ------------------
  |  Branch (1279:5): [True: 24.9k, False: 0]
  ------------------
 1280|      0|    case M_PROPERTY_ERROR:              return MPV_ERROR_PROPERTY_ERROR;
  ------------------
  |  Branch (1280:5): [True: 0, False: 24.9k]
  ------------------
 1281|      0|    case M_PROPERTY_UNAVAILABLE:        return MPV_ERROR_PROPERTY_UNAVAILABLE;
  ------------------
  |  Branch (1281:5): [True: 0, False: 24.9k]
  ------------------
 1282|      0|    case M_PROPERTY_NOT_IMPLEMENTED:    return MPV_ERROR_PROPERTY_ERROR;
  ------------------
  |  Branch (1282:5): [True: 0, False: 24.9k]
  ------------------
 1283|      0|    case M_PROPERTY_UNKNOWN:            return MPV_ERROR_PROPERTY_NOT_FOUND;
  ------------------
  |  Branch (1283:5): [True: 0, False: 24.9k]
  ------------------
 1284|      0|    case M_PROPERTY_INVALID_FORMAT:     return MPV_ERROR_PROPERTY_FORMAT;
  ------------------
  |  Branch (1284:5): [True: 0, False: 24.9k]
  ------------------
 1285|       |    // shouldn't happen
 1286|      0|    default:                            return MPV_ERROR_PROPERTY_ERROR;
  ------------------
  |  Branch (1286:5): [True: 0, False: 24.9k]
  ------------------
 1287|  24.9k|    }
 1288|  24.9k|}
client.c:get_mp_type_get:
 1007|  73.2k|{
 1008|  73.2k|    if (format == MPV_FORMAT_OSD_STRING)
  ------------------
  |  Branch (1008:9): [True: 0, False: 73.2k]
  ------------------
 1009|      0|        format = MPV_FORMAT_STRING; // it's string data, just other semantics
 1010|  73.2k|    return get_mp_type(format);
 1011|  73.2k|}
client.c:getproperty_fn:
 1418|  24.9k|{
 1419|  24.9k|    struct getproperty_request *req = arg;
 1420|  24.9k|    const struct m_option *type = get_mp_type_get(req->format);
 1421|       |
 1422|  24.9k|    union m_option_value xdata = m_option_value_default;
 1423|  24.9k|    void *data = req->data ? req->data : &xdata;
  ------------------
  |  Branch (1423:18): [True: 24.9k, False: 0]
  ------------------
 1424|       |
 1425|  24.9k|    int err = -1;
 1426|  24.9k|    switch (req->format) {
 1427|      0|    case MPV_FORMAT_OSD_STRING:
  ------------------
  |  Branch (1427:5): [True: 0, False: 24.9k]
  ------------------
 1428|      0|        err = mp_property_do(req->name, M_PROPERTY_PRINT, data, req->mpctx);
 1429|      0|        break;
 1430|      0|    case MPV_FORMAT_STRING: {
  ------------------
  |  Branch (1430:5): [True: 0, False: 24.9k]
  ------------------
 1431|      0|        char *s = NULL;
 1432|      0|        err = mp_property_do(req->name, M_PROPERTY_GET_STRING, &s, req->mpctx);
 1433|      0|        if (err == M_PROPERTY_OK)
  ------------------
  |  Branch (1433:13): [True: 0, False: 0]
  ------------------
 1434|      0|            *(char **)data = s;
 1435|      0|        break;
 1436|      0|    }
 1437|      0|    case MPV_FORMAT_NODE:
  ------------------
  |  Branch (1437:5): [True: 0, False: 24.9k]
  ------------------
 1438|  24.9k|    case MPV_FORMAT_FLAG:
  ------------------
  |  Branch (1438:5): [True: 24.9k, False: 0]
  ------------------
 1439|  24.9k|    case MPV_FORMAT_INT64:
  ------------------
  |  Branch (1439:5): [True: 0, False: 24.9k]
  ------------------
 1440|  24.9k|    case MPV_FORMAT_DOUBLE: {
  ------------------
  |  Branch (1440:5): [True: 0, False: 24.9k]
  ------------------
 1441|  24.9k|        struct mpv_node node = {{0}};
 1442|  24.9k|        err = mp_property_do(req->name, M_PROPERTY_GET_NODE, &node, req->mpctx);
 1443|  24.9k|        if (err == M_PROPERTY_NOT_IMPLEMENTED) {
  ------------------
  |  Branch (1443:13): [True: 0, False: 24.9k]
  ------------------
 1444|       |            // Go through explicit string conversion. Same reasoning as on the
 1445|       |            // GET code path.
 1446|      0|            char *s = NULL;
 1447|      0|            err = mp_property_do(req->name, M_PROPERTY_GET_STRING, &s,
 1448|      0|                                 req->mpctx);
 1449|      0|            if (err != M_PROPERTY_OK)
  ------------------
  |  Branch (1449:17): [True: 0, False: 0]
  ------------------
 1450|      0|                break;
 1451|      0|            node.format = MPV_FORMAT_STRING;
 1452|      0|            node.u.string = s;
 1453|  24.9k|        } else if (err <= 0)
  ------------------
  |  Branch (1453:20): [True: 0, False: 24.9k]
  ------------------
 1454|      0|            break;
 1455|  24.9k|        if (req->format == MPV_FORMAT_NODE) {
  ------------------
  |  Branch (1455:13): [True: 0, False: 24.9k]
  ------------------
 1456|      0|            *(struct mpv_node *)data = node;
 1457|  24.9k|        } else {
 1458|  24.9k|            if (!conv_node_to_format(data, req->format, &node)) {
  ------------------
  |  Branch (1458:17): [True: 0, False: 24.9k]
  ------------------
 1459|      0|                err = M_PROPERTY_INVALID_FORMAT;
 1460|      0|                mpv_free_node_contents(&node);
 1461|      0|            }
 1462|  24.9k|        }
 1463|  24.9k|        break;
 1464|  24.9k|    }
 1465|      0|    default:
  ------------------
  |  Branch (1465:5): [True: 0, False: 24.9k]
  ------------------
 1466|      0|        abort();
 1467|  24.9k|    }
 1468|       |
 1469|  24.9k|    req->status = translate_property_error(err);
 1470|       |
 1471|  24.9k|    if (req->reply_ctx) {
  ------------------
  |  Branch (1471:9): [True: 0, False: 24.9k]
  ------------------
 1472|      0|        struct mpv_event_property *prop = talloc_ptrtype(NULL, prop);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1473|      0|        *prop = (struct mpv_event_property){
 1474|      0|            .name = talloc_steal(prop, (char *)req->name),
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1475|      0|            .format = req->format,
 1476|      0|            .data = talloc_size(prop, type->type->size),
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1477|      0|        };
 1478|       |        // move data
 1479|      0|        memcpy(prop->data, &xdata, type->type->size);
 1480|      0|        talloc_set_destructor(prop, free_prop_data);
  ------------------
  |  |   41|      0|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1481|      0|        struct mpv_event reply = {
 1482|      0|            .event_id = MPV_EVENT_GET_PROPERTY_REPLY,
 1483|      0|            .data = prop,
 1484|      0|            .error = req->status,
 1485|      0|        };
 1486|      0|        send_reply(req->reply_ctx, req->userdata, &reply);
 1487|      0|        talloc_free(req);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1488|      0|    }
 1489|  24.9k|}
client.c:conv_node_to_format:
 1016|  24.9k|{
 1017|  24.9k|    if (dst_fmt == src->format) {
  ------------------
  |  Branch (1017:9): [True: 24.9k, False: 0]
  ------------------
 1018|  24.9k|        const struct m_option *type = get_mp_type(dst_fmt);
 1019|  24.9k|        memcpy(dst, &src->u, type->type->size);
 1020|  24.9k|        return true;
 1021|  24.9k|    }
 1022|      0|    if (dst_fmt == MPV_FORMAT_DOUBLE && src->format == MPV_FORMAT_INT64) {
  ------------------
  |  Branch (1022:9): [True: 0, False: 0]
  |  Branch (1022:41): [True: 0, False: 0]
  ------------------
 1023|      0|        *(double *)dst = src->u.int64;
 1024|      0|        return true;
 1025|      0|    }
 1026|      0|    if (dst_fmt == MPV_FORMAT_INT64 && src->format == MPV_FORMAT_DOUBLE) {
  ------------------
  |  Branch (1026:9): [True: 0, False: 0]
  |  Branch (1026:40): [True: 0, False: 0]
  ------------------
 1027|      0|        if (src->u.double_ > (double)INT64_MIN &&
  ------------------
  |  Branch (1027:13): [True: 0, False: 0]
  ------------------
 1028|      0|            src->u.double_ < (double)INT64_MAX)
  ------------------
  |  Branch (1028:13): [True: 0, False: 0]
  ------------------
 1029|      0|        {
 1030|      0|            *(int64_t *)dst = src->u.double_;
 1031|      0|            return true;
 1032|      0|        }
 1033|      0|    }
 1034|      0|    return false;
 1035|      0|}
client.c:property_free:
 1545|  23.3k|{
 1546|  23.3k|    struct observe_property *prop = p;
 1547|       |
 1548|  23.3k|    mp_assert(prop->refcount == 0);
  ------------------
  |  |   41|  23.3k|#define mp_assert assert
  ------------------
  |  Branch (1548:5): [True: 23.3k, False: 0]
  ------------------
 1549|       |
 1550|  23.3k|    if (prop->type) {
  ------------------
  |  Branch (1550:9): [True: 0, False: 23.3k]
  ------------------
 1551|      0|        m_option_free(prop->type, &prop->value);
 1552|      0|        m_option_free(prop->type, &prop->value_ret);
 1553|      0|    }
 1554|  23.3k|}
client.c:prop_unref:
  169|  79.9k|{
  170|  79.9k|    if (!prop)
  ------------------
  |  Branch (170:9): [True: 35.0k, False: 44.9k]
  ------------------
  171|  35.0k|        return;
  172|       |
  173|  44.9k|    mp_assert(prop->refcount > 0);
  ------------------
  |  |   41|  44.9k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 44.9k, False: 0]
  ------------------
  174|  44.9k|    prop->refcount -= 1;
  175|  44.9k|    if (!prop->refcount)
  ------------------
  |  Branch (175:9): [True: 23.3k, False: 21.5k]
  ------------------
  176|  23.3k|        talloc_free(prop);
  ------------------
  |  |   47|  23.3k|#define talloc_free                     ta_free
  ------------------
  177|  44.9k|}
client.c:send_client_property_changes:
 1690|  23.3k|{
 1691|  23.3k|    uint64_t cur_ts = ctx->properties_change_ts;
 1692|       |
 1693|  23.3k|    ctx->has_pending_properties = false;
 1694|       |
 1695|  46.6k|    for (int n = 0; n < ctx->num_properties; n++) {
  ------------------
  |  Branch (1695:21): [True: 23.3k, False: 23.3k]
  ------------------
 1696|  23.3k|        struct observe_property *prop = ctx->properties[n];
 1697|       |
 1698|  23.3k|        if (prop->value_ts == prop->change_ts)
  ------------------
  |  Branch (1698:13): [True: 0, False: 23.3k]
  ------------------
 1699|      0|            continue;
 1700|       |
 1701|  23.3k|        bool changed = false;
 1702|  23.3k|        if (prop->format) {
  ------------------
  |  Branch (1702:13): [True: 0, False: 23.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|  23.3k|        } else {
 1751|  23.3k|            changed = true;
 1752|  23.3k|        }
 1753|       |
 1754|  23.3k|        if (prop->waiting_for_hook)
  ------------------
  |  Branch (1754:13): [True: 0, False: 23.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|  23.3k|        if (!changed && prop->value_ret_ts == prop->value_ts) {
  ------------------
  |  Branch (1759:13): [True: 0, False: 23.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|  23.3k|        } else {
 1763|  23.3k|            ctx->new_property_events = true;
 1764|  23.3k|        }
 1765|       |
 1766|  23.3k|        prop->value_ts = prop->change_ts;
 1767|  23.3k|    }
 1768|       |
 1769|  23.3k|    if (ctx->destroying || ctx->new_property_events)
  ------------------
  |  Branch (1769:9): [True: 0, False: 23.3k]
  |  Branch (1769:28): [True: 23.3k, False: 11]
  ------------------
 1770|  23.3k|        wakeup_client(ctx);
 1771|  23.3k|}
client.c:gen_property_change_event:
 1806|  5.87M|{
 1807|  5.87M|    if (!ctx->mpctx->initialized)
  ------------------
  |  Branch (1807:9): [True: 0, False: 5.87M]
  ------------------
 1808|      0|        return false;
 1809|       |
 1810|  5.91M|    while (1) {
  ------------------
  |  Branch (1810:12): [True: 5.91M, Folded]
  ------------------
 1811|  5.91M|        if (ctx->cur_property_index >= ctx->num_properties) {
  ------------------
  |  Branch (1811:13): [True: 5.89M, False: 23.3k]
  ------------------
 1812|  5.89M|            ctx->new_property_events &= ctx->num_properties > 0;
 1813|  5.89M|            if (!ctx->new_property_events)
  ------------------
  |  Branch (1813:17): [True: 5.84M, False: 44.8k]
  ------------------
 1814|  5.84M|                break;
 1815|  44.8k|            ctx->new_property_events = false;
 1816|  44.8k|            ctx->cur_property_index = 0;
 1817|  44.8k|        }
 1818|       |
 1819|  68.1k|        struct observe_property *prop = ctx->properties[ctx->cur_property_index++];
 1820|       |
 1821|  68.1k|        if (prop->value_ts == prop->change_ts &&    // not a stale value?
  ------------------
  |  Branch (1821:13): [True: 21.5k, False: 46.5k]
  ------------------
 1822|  21.5k|            prop->value_ret_ts != prop->value_ts)   // other value than last time?
  ------------------
  |  Branch (1822:13): [True: 21.5k, False: 0]
  ------------------
 1823|  21.5k|        {
 1824|  21.5k|            prop->value_ret_ts = prop->value_ts;
 1825|  21.5k|            prop->waiting_for_hook = false;
 1826|  21.5k|            prop_unref(ctx->cur_property);
 1827|  21.5k|            ctx->cur_property = prop;
 1828|  21.5k|            prop->refcount += 1;
 1829|       |
 1830|  21.5k|            if (prop->value_valid)
  ------------------
  |  Branch (1830:17): [True: 0, False: 21.5k]
  ------------------
 1831|      0|                m_option_copy(prop->type, &prop->value_ret, &prop->value);
 1832|       |
 1833|  21.5k|            ctx->cur_property_event = (struct mpv_event_property){
 1834|  21.5k|                .name = prop->name,
 1835|  21.5k|                .format = prop->value_valid ? prop->format : 0,
  ------------------
  |  Branch (1835:27): [True: 0, False: 21.5k]
  ------------------
 1836|  21.5k|                .data = prop->value_valid ? &prop->value_ret : NULL,
  ------------------
  |  Branch (1836:25): [True: 0, False: 21.5k]
  ------------------
 1837|  21.5k|            };
 1838|  21.5k|            *ctx->cur_event = (struct mpv_event){
 1839|  21.5k|                .event_id = MPV_EVENT_PROPERTY_CHANGE,
 1840|  21.5k|                .reply_userdata = prop->reply_id,
 1841|  21.5k|                .data = &ctx->cur_property_event,
 1842|  21.5k|            };
 1843|  21.5k|            return true;
 1844|  21.5k|        }
 1845|  68.1k|    }
 1846|       |
 1847|  5.84M|    return false;
 1848|  5.87M|}
client.c:gen_log_message_event:
 1928|  5.84M|{
 1929|  5.84M|    if (ctx->messages) {
  ------------------
  |  Branch (1929:9): [True: 0, False: 5.84M]
  ------------------
 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|  5.84M|    return false;
 1950|  5.84M|}

clipboard-vo.c:init:
   29|  11.6k|{
   30|  11.6k|    struct clipboard_vo_priv *priv = talloc_ptrtype(cl, priv);
  ------------------
  |  |   34|  11.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  11.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   31|  11.6k|    priv->mpctx = params->mpctx;
   32|  11.6k|    priv->log = mp_log_new(priv, cl->log, "vo"),
   33|  11.6k|    cl->priv = priv;
   34|  11.6k|    return CLIPBOARD_SUCCESS;
   35|  11.6k|}
clipboard-vo.c:get_data:
   39|      2|{
   40|      2|    struct clipboard_vo_priv *priv = cl->priv;
   41|      2|    struct vo *vo = priv->mpctx->video_out;
   42|      2|    struct voctrl_clipboard vc = {
   43|      2|        .data = *out,
   44|      2|        .params = *params,
   45|      2|        .talloc_ctx = talloc_ctx,
   46|      2|    };
   47|       |
   48|      2|    if (!vo)
  ------------------
  |  Branch (48:9): [True: 0, False: 2]
  ------------------
   49|      0|        return CLIPBOARD_UNAVAILABLE;
   50|      2|    int ret = vo_control(vo, VOCTRL_GET_CLIPBOARD, &vc);
   51|      2|    switch (ret) {
   52|      0|    case VO_TRUE:
  ------------------
  |  |  146|      0|#define VO_TRUE         true
  ------------------
  |  Branch (52:5): [True: 0, False: 2]
  ------------------
   53|      0|        *out = vc.data;
   54|      0|        return CLIPBOARD_SUCCESS;
   55|      0|    case VO_NOTAVAIL:
  ------------------
  |  |  149|      0|#define VO_NOTAVAIL     -2
  ------------------
  |  Branch (55:5): [True: 0, False: 2]
  ------------------
   56|      2|    case VO_NOTIMPL:
  ------------------
  |  |  150|      2|#define VO_NOTIMPL      -3
  ------------------
  |  Branch (56:5): [True: 2, False: 0]
  ------------------
   57|      2|        MP_VERBOSE(priv, "VO does not support getting clipboard in the requested format.\n");
  ------------------
  |  |   92|      2|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   58|      2|        return CLIPBOARD_UNAVAILABLE;
   59|      0|    default:
  ------------------
  |  Branch (59:5): [True: 0, False: 2]
  ------------------
   60|      0|        MP_WARN(priv, "Failed getting VO clipboard.\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__)
  |  |  ------------------
  ------------------
   61|      0|        return CLIPBOARD_FAILED;
   62|      2|    }
   63|      2|}

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

mp_hook_test_completion:
  204|  93.7k|{
  205|  93.7k|    struct command_ctx *cmd = mpctx->command_ctx;
  206|  93.7k|    for (int n = 0; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (206:21): [True: 0, False: 93.7k]
  ------------------
  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|  93.7k|    return true;
  219|  93.7k|}
mp_hook_start:
  269|  93.7k|{
  270|  93.7k|    run_next_hook_handler(mpctx, type, 0);
  271|  93.7k|}
mark_seek:
  320|  2.68M|{
  321|  2.68M|    struct command_ctx *cmd = mpctx->command_ctx;
  322|  2.68M|    double now = mp_time_sec();
  323|  2.68M|    if (now > cmd->last_seek_time + 2.0 || cmd->last_seek_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (323:9): [True: 0, False: 2.68M]
  |  Branch (323:44): [True: 3.03k, False: 2.68M]
  ------------------
  324|  3.03k|        cmd->last_seek_pts = get_current_time(mpctx);
  325|  2.68M|    cmd->last_seek_time = now;
  326|  2.68M|}
mp_get_property_event_mask:
 5025|  23.3k|{
 5026|  23.3k|    uint64_t mask = 0;
 5027|  1.02M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_event_property_change); n++) {
  ------------------
  |  |   49|  1.02M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (5027:21): [True: 1.00M, False: 23.3k]
  ------------------
 5028|  1.00M|        const char *const *const list = mp_event_property_change[n];
 5029|  4.10M|        for (int i = 0; list && list[i]; i++) {
  ------------------
  |  Branch (5029:25): [True: 3.68M, False: 420k]
  |  Branch (5029:33): [True: 3.10M, False: 583k]
  ------------------
 5030|  3.10M|            if (match_property(list[i], name))
  ------------------
  |  Branch (5030:17): [True: 116k, False: 2.98M]
  ------------------
 5031|   116k|                mask |= 1ULL << n;
 5032|  3.10M|        }
 5033|  1.00M|    }
 5034|  23.3k|    return mask;
 5035|  23.3k|}
mp_get_property_id:
 5040|   228k|{
 5041|   228k|    struct command_ctx *ctx = mpctx->command_ctx;
 5042|   138M|    for (int n = 0; n < ctx->properties.num; n++) {
  ------------------
  |  Branch (5042:21): [True: 138M, False: 50]
  ------------------
 5043|   138M|        if (match_property(ctx->properties.props[n].name, name))
  ------------------
  |  Branch (5043:13): [True: 228k, False: 138M]
  ------------------
 5044|   228k|            return n;
 5045|   138M|    }
 5046|     50|    return -1;
 5047|   228k|}
mp_property_do:
 5069|   548k|{
 5070|   548k|    struct command_ctx *cmd = ctx->command_ctx;
 5071|   548k|    int r = m_property_do(ctx->log, &cmd->properties, name, action, val, ctx);
 5072|       |
 5073|   548k|    if (mp_msg_test(ctx->log, MSGL_V) && is_property_set(action, val)) {
  ------------------
  |  Branch (5073:9): [True: 548k, False: 0]
  |  Branch (5073:42): [True: 193k, False: 354k]
  ------------------
 5074|   193k|        struct m_property *property = m_property_list_find(&cmd->properties, name);
 5075|   193k|        if (property && property->is_noisy && !mp_msg_test(ctx->log, MSGL_TRACE))
  ------------------
  |  Branch (5075:13): [True: 128k, False: 65.6k]
  |  Branch (5075:25): [True: 50, False: 128k]
  |  Branch (5075:47): [True: 0, False: 50]
  ------------------
 5076|      0|            return r;
 5077|       |
 5078|   193k|        struct m_option option_type = {0};
 5079|   193k|        void *data = val;
 5080|   193k|        switch (action) {
  ------------------
  |  Branch (5080:17): [True: 1.25k, False: 192k]
  ------------------
 5081|     50|        case M_PROPERTY_SET_NODE:
  ------------------
  |  Branch (5081:9): [True: 50, False: 193k]
  ------------------
 5082|     50|            option_type.type = &m_option_type_node;
 5083|     50|            break;
 5084|  1.20k|        case M_PROPERTY_SET_STRING:
  ------------------
  |  Branch (5084:9): [True: 1.20k, False: 192k]
  ------------------
 5085|  1.20k|            option_type.type = &m_option_type_string;
 5086|  1.20k|            data = &val;
 5087|  1.20k|            break;
 5088|   193k|        }
 5089|   193k|        char *t = option_type.type ? m_option_print(&option_type, data) : NULL;
  ------------------
  |  Branch (5089:19): [True: 1.25k, False: 192k]
  ------------------
 5090|   193k|        MP_VERBOSE(ctx, "Set property: %s%s%s -> %d\n",
  ------------------
  |  |   92|   193k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   775k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 1.25k, False: 192k]
  |  |  |  |  |  Branch (86:57): [True: 1.25k, False: 192k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5091|   193k|                   name, t ? "=" : "", t ? t : "", r);
 5092|   193k|        talloc_free(t);
  ------------------
  |  |   47|   193k|#define talloc_free                     ta_free
  ------------------
 5093|   193k|    }
 5094|   548k|    return r;
 5095|   548k|}
mp_property_expand_string:
 5098|  3.32M|{
 5099|  3.32M|    struct command_ctx *ctx = mpctx->command_ctx;
 5100|  3.32M|    return m_properties_expand_string(&ctx->properties, str, mpctx,
 5101|  3.32M|                                      M_PROPERTY_PRINT);
 5102|  3.32M|}
mp_property_expand_escaped_string:
 5129|  21.0k|{
 5130|  21.0k|    return expand_escaped_string(mpctx, str, M_PROPERTY_PRINT);
 5131|  21.0k|}
mp_cmd_ctx_complete:
 5933|   603k|{
 5934|   603k|    cmd->completed = true;
 5935|   603k|    if (!cmd->success)
  ------------------
  |  Branch (5935:9): [True: 306k, False: 297k]
  ------------------
 5936|   306k|        mpv_free_node_contents(&cmd->result);
 5937|   603k|    if (cmd->on_completion)
  ------------------
  |  Branch (5937:9): [True: 603k, False: 478]
  ------------------
 5938|   603k|        cmd->on_completion(cmd);
 5939|   603k|    if (cmd->abort)
  ------------------
  |  Branch (5939:9): [True: 93.3k, False: 510k]
  ------------------
 5940|  93.3k|        mp_abort_remove(cmd->mpctx, cmd->abort);
 5941|   603k|    mpv_free_node_contents(&cmd->result);
 5942|   603k|    talloc_free(cmd);
  ------------------
  |  |   47|   603k|#define talloc_free                     ta_free
  ------------------
 5943|   603k|}
run_command:
 5980|   603k|{
 5981|   603k|    struct mp_cmd_ctx *ctx = talloc(NULL, struct mp_cmd_ctx);
  ------------------
  |  |   26|   603k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   603k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   603k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5982|   603k|    *ctx = (struct mp_cmd_ctx){
 5983|   603k|        .mpctx = mpctx,
 5984|   603k|        .cmd = talloc_steal(ctx, cmd),
  ------------------
  |  |   38|   603k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   603k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5985|   603k|        .args = cmd->args,
 5986|   603k|        .num_args = cmd->nargs,
 5987|   603k|        .priv = cmd->def->priv,
 5988|   603k|        .abort = talloc_steal(ctx, abort),
  ------------------
  |  |   38|   603k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   603k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5989|   603k|        .success = true,
 5990|   603k|        .completed = true,
 5991|   603k|        .on_completion = on_completion,
 5992|   603k|        .on_completion_priv = on_completion_priv,
 5993|   603k|    };
 5994|       |
 5995|   603k|    if (!ctx->abort && cmd->def->can_abort)
  ------------------
  |  Branch (5995:9): [True: 510k, False: 93.3k]
  |  Branch (5995:24): [True: 18, False: 510k]
  ------------------
 5996|     18|        ctx->abort = talloc_zero(ctx, struct mp_abort_entry);
  ------------------
  |  |   27|     18|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     18|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     18|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5997|       |
 5998|   603k|    mp_assert(cmd->def->can_abort == !!ctx->abort);
  ------------------
  |  |   41|   603k|#define mp_assert assert
  ------------------
  |  Branch (5998:5): [True: 603k, False: 0]
  ------------------
 5999|       |
 6000|   603k|    if (ctx->abort) {
  ------------------
  |  Branch (6000:9): [True: 93.3k, False: 510k]
  ------------------
 6001|  93.3k|        ctx->abort->coupled_to_playback |= cmd->def->abort_on_playback_end;
 6002|  93.3k|        mp_abort_add(mpctx, ctx->abort);
 6003|  93.3k|    }
 6004|       |
 6005|   603k|    struct MPOpts *opts = mpctx->opts;
 6006|   603k|    ctx->on_osd = cmd->flags & MP_ON_OSD_FLAGS;
 6007|   603k|    bool auto_osd = ctx->on_osd == MP_ON_OSD_AUTO;
 6008|   603k|    ctx->msg_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_MSG);
  ------------------
  |  Branch (6008:20): [True: 568k, False: 35.1k]
  |  Branch (6008:32): [True: 40, False: 35.1k]
  ------------------
 6009|   603k|    ctx->bar_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_BAR);
  ------------------
  |  Branch (6009:20): [True: 568k, False: 35.1k]
  |  Branch (6009:32): [True: 57, False: 35.0k]
  ------------------
 6010|   603k|    ctx->seek_msg_osd = auto_osd ? opts->osd_on_seek & 2 : ctx->msg_osd;
  ------------------
  |  Branch (6010:25): [True: 568k, False: 35.1k]
  ------------------
 6011|   603k|    ctx->seek_bar_osd = auto_osd ? opts->osd_on_seek & 1 : ctx->bar_osd;
  ------------------
  |  Branch (6011:25): [True: 568k, False: 35.1k]
  ------------------
 6012|       |
 6013|   603k|    bool noise = cmd->def->is_noisy || cmd->mouse_move;
  ------------------
  |  Branch (6013:18): [True: 9.66k, False: 593k]
  |  Branch (6013:40): [True: 0, False: 593k]
  ------------------
 6014|   603k|    mp_cmd_dump(mpctx->log, noise ? MSGL_TRACE : MSGL_DEBUG, "Run command:", cmd);
  ------------------
  |  Branch (6014:29): [True: 9.66k, False: 593k]
  ------------------
 6015|       |
 6016|   603k|    if (cmd->flags & MP_EXPAND_PROPERTIES) {
  ------------------
  |  Branch (6016:9): [True: 568k, False: 35.0k]
  ------------------
 6017|  1.66M|        for (int n = 0; n < cmd->nargs; n++) {
  ------------------
  |  Branch (6017:25): [True: 1.09M, False: 568k]
  ------------------
 6018|  1.09M|            const m_option_type_t *type = cmd->args[n].type->type;
 6019|  1.09M|            char **list = NULL;
 6020|  1.09M|            if (type == CONF_TYPE_STRING)
  ------------------
  |  |  244|  1.09M|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  |  Branch (6020:17): [True: 462k, False: 635k]
  ------------------
 6021|   462k|                list = &cmd->args[n].v.s;
 6022|   635k|            else if (type == CONF_TYPE_STRING_LIST || type == CONF_TYPE_KV_LIST)
  ------------------
  |  |  245|  1.27M|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
                          else if (type == CONF_TYPE_STRING_LIST || type == CONF_TYPE_KV_LIST)
  ------------------
  |  |  246|   633k|#define CONF_TYPE_KV_LIST       (&m_option_type_keyvalue_list)
  ------------------
  |  Branch (6022:22): [True: 1.79k, False: 633k]
  |  Branch (6022:55): [True: 1.79k, False: 631k]
  ------------------
 6023|  3.58k|                list = cmd->args[n].v.str_list;
 6024|  1.12M|            for (; list && *list; list++) {
  ------------------
  |  Branch (6024:20): [True: 491k, False: 634k]
  |  Branch (6024:28): [True: 424k, False: 66.3k]
  ------------------
 6025|   424k|                char *s = mp_property_expand_string(mpctx, *list);
 6026|   424k|                if (!s) {
  ------------------
  |  Branch (6026:21): [True: 0, False: 424k]
  ------------------
 6027|      0|                    ctx->success = false;
 6028|      0|                    mp_cmd_ctx_complete(ctx);
 6029|      0|                    return;
 6030|      0|                }
 6031|   424k|                talloc_free(*list);
  ------------------
  |  |   47|   424k|#define talloc_free                     ta_free
  ------------------
 6032|   424k|                *list = s;
 6033|   424k|                if (type == CONF_TYPE_STRING)
  ------------------
  |  |  244|   424k|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
  |  Branch (6033:21): [True: 397k, False: 27.4k]
  ------------------
 6034|   397k|                    break;
 6035|   424k|            }
 6036|  1.09M|        }
 6037|   568k|    }
 6038|       |
 6039|   603k|    if (cmd->def->spawn_thread) {
  ------------------
  |  Branch (6039:9): [True: 152k, False: 451k]
  ------------------
 6040|   152k|        mpctx->outstanding_async += 1; // prevent that core disappears
 6041|   152k|        if (!mp_thread_pool_queue(mpctx->thread_pool,
  ------------------
  |  Branch (6041:13): [True: 0, False: 152k]
  ------------------
 6042|   152k|                                  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|   451k|    } else {
 6049|   451k|        bool exec_async = cmd->def->exec_async;
 6050|   451k|        cmd->def->handler(ctx);
 6051|   451k|        if (!exec_async)
  ------------------
  |  Branch (6051:13): [True: 451k, False: 457]
  ------------------
 6052|   451k|            mp_cmd_ctx_complete(ctx);
 6053|   451k|    }
 6054|   603k|}
mp_cmd_msg:
 6059|  94.2k|{
 6060|  94.2k|    va_list ap;
 6061|  94.2k|    char *s;
 6062|       |
 6063|  94.2k|    va_start(ap, msg);
 6064|  94.2k|    s = talloc_vasprintf(NULL, msg, ap);
  ------------------
  |  |   53|  94.2k|#define talloc_vasprintf                ta_xvasprintf
  |  |  ------------------
  |  |  |  |  128|  94.2k|#define ta_xvasprintf(...)              ta_oom_s(ta_vasprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 6065|  94.2k|    va_end(ap);
 6066|       |
 6067|  94.2k|    MP_MSG(cmd->mpctx, status, "%s\n", s);
  ------------------
  |  |   86|  94.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
 6068|  94.2k|    if (cmd->msg_osd && status <= MSGL_INFO)
  ------------------
  |  Branch (6068:9): [True: 94.2k, False: 0]
  |  Branch (6068:25): [True: 59.7k, False: 34.4k]
  ------------------
 6069|  59.7k|        set_osd_msg(cmd->mpctx, 1, cmd->mpctx->opts->osd_duration, "%s", s);
 6070|       |
 6071|  94.2k|    talloc_free(s);
  ------------------
  |  |   47|  94.2k|#define talloc_free                     ta_free
  ------------------
 6072|  94.2k|}
mp_abort_cache_dumping:
 7482|  16.6k|{
 7483|  16.6k|    struct command_ctx *ctx = mpctx->command_ctx;
 7484|       |
 7485|  16.6k|    if (ctx->cache_dump_cmd)
  ------------------
  |  Branch (7485:9): [True: 0, False: 16.6k]
  ------------------
 7486|      0|        mp_cancel_trigger(ctx->cache_dump_cmd->abort->cancel);
 7487|  16.6k|    cache_dump_poll(mpctx);
 7488|       |    mp_assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked
  ------------------
  |  |   41|  16.6k|#define mp_assert assert
  ------------------
  |  Branch (7488:5): [True: 16.6k, False: 0]
  ------------------
 7489|  16.6k|}
command_uninit:
 8218|  11.6k|{
 8219|  11.6k|    struct command_ctx *ctx = mpctx->command_ctx;
 8220|       |
 8221|  11.6k|    mp_assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it
  ------------------
  |  |   41|  11.6k|#define mp_assert assert
  ------------------
  |  Branch (8221:5): [True: 11.6k, False: 0]
  ------------------
 8222|       |
 8223|  11.6k|    overlay_uninit(mpctx);
 8224|  11.6k|    ao_hotplug_destroy(ctx->hotplug);
 8225|       |
 8226|  11.6k|    m_option_free(&script_props_type, &ctx->script_props);
 8227|       |
 8228|  11.6k|    talloc_free(mpctx->command_ctx);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 8229|       |    mpctx->command_ctx = NULL;
 8230|  11.6k|}
command_init:
 8238|  11.6k|{
 8239|  11.6k|    struct command_ctx *ctx = talloc(NULL, struct command_ctx);
  ------------------
  |  |   26|  11.6k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  11.6k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8240|  11.6k|    *ctx = (struct command_ctx){
 8241|  11.6k|        .last_seek_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  11.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8242|  11.6k|    };
 8243|  11.6k|    mpctx->command_ctx = ctx;
 8244|       |
 8245|  11.6k|    int num_base = MP_ARRAY_SIZE(mp_properties_base);
  ------------------
  |  |   49|  11.6k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
 8246|  11.6k|    int num_opts = m_config_get_co_count(mpctx->mconfig);
 8247|  11.6k|    struct m_property *props =
 8248|  11.6k|        talloc_zero_array(ctx, struct m_property, num_base + num_opts);
  ------------------
  |  |   30|  11.6k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  11.6k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8249|  11.6k|    memcpy(props, mp_properties_base, sizeof(mp_properties_base));
 8250|       |
 8251|  11.6k|    const char **prop_names = talloc_array(NULL, const char *, num_base);
  ------------------
  |  |   29|  11.6k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  11.6k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8252|  2.28M|    for (int i = 0; i < num_base; ++i)
  ------------------
  |  Branch (8252:21): [True: 2.27M, False: 11.6k]
  ------------------
 8253|  2.27M|        prop_names[i] = mp_properties_base[i].name;
 8254|  11.6k|    qsort(prop_names, num_base, sizeof(const char *), str_compare);
 8255|       |
 8256|  11.6k|    int count = num_base;
 8257|  9.16M|    for (int n = 0; n < num_opts; n++) {
  ------------------
  |  Branch (8257:21): [True: 9.15M, False: 11.6k]
  ------------------
 8258|  9.15M|        struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n);
 8259|  9.15M|        mp_assert(co->name[0]);
  ------------------
  |  |   41|  9.15M|#define mp_assert assert
  ------------------
  |  Branch (8259:9): [True: 9.15M, False: 0]
  ------------------
 8260|  9.15M|        if (co->opt->flags & M_OPT_NOPROP)
  ------------------
  |  |  477|  9.15M|#define M_OPT_NOPROP            (UINT64_C(1) << 60)
  ------------------
  |  Branch (8260:13): [True: 326k, False: 8.82M]
  ------------------
 8261|   326k|            continue;
 8262|       |
 8263|  8.82M|        struct m_property prop = {
 8264|  8.82M|            .name = co->name,
 8265|  8.82M|            .call = mp_property_generic_option,
 8266|  8.82M|            .priv = co,
 8267|  8.82M|            .is_option = true,
 8268|  8.82M|        };
 8269|       |
 8270|  8.82M|        if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8270:13): [True: 268k, False: 8.55M]
  ------------------
 8271|   268k|            char buf[M_CONFIG_MAX_OPT_NAME_LEN];
 8272|   268k|            const char *alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co->opt_id,
 8273|   268k|                                                                   buf, sizeof(buf));
 8274|   268k|            prop.priv = talloc_strdup(ctx, alias);
  ------------------
  |  |   50|   268k|#define talloc_strdup                   ta_xstrdup
  ------------------
 8275|       |
 8276|   268k|            prop.call = co->opt->deprecation_message ?
  ------------------
  |  Branch (8276:25): [True: 81.7k, False: 186k]
  ------------------
 8277|   186k|                            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|   268k|            struct m_config_option *co2 = co;
 8284|   536k|            while (co2 && co2->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (8284:20): [True: 536k, False: 0]
  |  Branch (8284:27): [True: 268k, False: 268k]
  ------------------
 8285|   268k|                const char *co2_alias = m_config_shadow_get_alias_from_opt(mpctx->mconfig->shadow, co2->opt_id,
 8286|   268k|                                                                           buf, sizeof(buf));
 8287|   268k|                co2 = m_config_get_co_raw(mpctx->mconfig, bstr0(co2_alias));
 8288|   268k|            }
 8289|   268k|            if (!co2)
  ------------------
  |  Branch (8289:17): [True: 0, False: 268k]
  ------------------
 8290|      0|                continue;
 8291|   268k|        }
 8292|       |
 8293|       |        // The option might be covered by a manual property already.
 8294|  8.82M|        if (bsearch(&prop.name, prop_names, num_base, sizeof(const char *), str_compare))
  ------------------
  |  Branch (8294:13): [True: 280k, False: 8.54M]
  ------------------
 8295|   280k|            continue;
 8296|       |
 8297|  8.54M|        props[count++] = prop;
 8298|  8.54M|    }
 8299|       |
 8300|  11.6k|    ctx->properties = (struct m_property_list){props, count};
 8301|  11.6k|    m_property_list_sort(&ctx->properties);
 8302|       |
 8303|  11.6k|    node_init(&ctx->mdata, MPV_FORMAT_NODE_ARRAY, NULL);
 8304|  11.6k|    talloc_steal(ctx, ctx->mdata.u.list);
  ------------------
  |  |   38|  11.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  11.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8305|       |
 8306|  11.6k|    node_init(&ctx->udata, MPV_FORMAT_NODE_MAP, NULL);
 8307|  11.6k|    talloc_steal(ctx, ctx->udata.u.list);
  ------------------
  |  |   38|  11.6k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  11.6k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 8308|  11.6k|    talloc_free(prop_names);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
 8309|  11.6k|}
handle_command_updates:
 8357|  11.6M|{
 8358|  11.6M|    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|  11.6M|    if (ctx->hotplug && ao_hotplug_check_update(ctx->hotplug))
  ------------------
  |  Branch (8362:9): [True: 427, False: 11.6M]
  |  Branch (8362:25): [True: 0, False: 427]
  ------------------
 8363|      0|        mp_notify_property(mpctx, "audio-device-list");
 8364|       |
 8365|       |    // Depends on polling demuxer wakeup callback notifications.
 8366|  11.6M|    cache_dump_poll(mpctx);
 8367|  11.6M|}
run_command_opts:
 8370|  2.71M|{
 8371|  2.71M|    struct MPOpts *opts = mpctx->opts;
 8372|  2.71M|    struct command_ctx *ctx = mpctx->command_ctx;
 8373|       |
 8374|  2.71M|    if (!opts->input_commands || ctx->command_opts_processed)
  ------------------
  |  Branch (8374:9): [True: 2.71M, False: 0]
  |  Branch (8374:34): [True: 0, False: 0]
  ------------------
 8375|  2.71M|        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|  9.02M|{
 8391|       |    // The OSD can implicitly reference some properties.
 8392|  9.02M|    mpctx->osd_idle_update = true;
 8393|       |
 8394|  9.02M|    command_event(mpctx, event, arg);
 8395|       |
 8396|  9.02M|    mp_client_broadcast_event(mpctx, event, arg);
 8397|  9.02M|}
mp_option_change_callback:
 8429|   147k|{
 8430|   147k|    struct MPContext *mpctx = ctx;
 8431|   147k|    struct MPOpts *opts = mpctx->opts;
 8432|   147k|    void *opt_ptr = !co ? NULL : co->data; // NULL on start
  ------------------
  |  Branch (8432:21): [True: 11.6k, False: 135k]
  ------------------
 8433|       |
 8434|   147k|    if (co)
  ------------------
  |  Branch (8434:9): [True: 135k, False: 11.6k]
  ------------------
 8435|   135k|        mp_notify_property(mpctx, co->name);
 8436|   147k|    if (opt_ptr == &opts->media_title)
  ------------------
  |  Branch (8436:9): [True: 0, False: 147k]
  ------------------
 8437|      0|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
 8438|       |
 8439|   147k|    if (self_update)
  ------------------
  |  Branch (8439:9): [True: 67.2k, False: 80.3k]
  ------------------
 8440|  67.2k|        return;
 8441|       |
 8442|       |    // Run these immediately.
 8443|  80.3k|    if (co && !co->coalesce) {
  ------------------
  |  Branch (8443:9): [True: 68.6k, False: 11.6k]
  |  Branch (8443:15): [True: 68.6k, False: 0]
  ------------------
 8444|  68.6k|        struct mp_option_callback callback = {.co = co, .flags = flags};
 8445|  68.6k|        mp_option_run_callback(mpctx, &callback);
 8446|  68.6k|        return;
 8447|  68.6k|    }
 8448|       |
 8449|       |    // Coalesce redundant updates and only keep the newest one.
 8450|  80.3k|    bool drop = false;
 8451|  11.6k|    for (int i = 0; i < mpctx->num_option_callbacks; i++) {
  ------------------
  |  Branch (8451:21): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|    if (!drop) {
  ------------------
  |  Branch (8465:9): [True: 11.6k, False: 0]
  ------------------
 8466|  11.6k|        struct mp_option_callback callback = {.co = co, .flags = flags};
 8467|  11.6k|        MP_TARRAY_APPEND(mpctx, mpctx->option_callbacks, mpctx->num_option_callbacks, callback);
  ------------------
  |  |  105|  11.6k|    do {                                            \
  |  |  106|  11.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  11.6k|    do {                                            \
  |  |  |  |   97|  11.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  11.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  11.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  11.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 11.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  11.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  11.6k|    do {                                                        \
  |  |  |  |  |  |   89|  11.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  11.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  11.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  11.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  11.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  11.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  11.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 11.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  11.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 11.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  11.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  11.6k|        (idxvar)++;                                 \
  |  |  109|  11.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
 8468|  11.6k|    }
 8469|  11.6k|}
mp_option_run_callback:
 8472|  80.3k|{
 8473|  80.3k|    struct MPOpts *opts = mpctx->opts;
 8474|  80.3k|    struct m_config_option *co = callback->co;
 8475|  80.3k|    void *opt_ptr = co ? co->data : NULL;
  ------------------
  |  Branch (8475:21): [True: 68.6k, False: 11.6k]
  ------------------
 8476|  80.3k|    uint64_t flags = callback->flags;
 8477|       |
 8478|  80.3k|    if (flags & UPDATE_TERM)
  ------------------
  |  |  442|  80.3k|#define UPDATE_TERM             (UINT64_C(1) << 0)   // terminal options
  ------------------
  |  Branch (8478:9): [True: 12.4k, False: 67.9k]
  ------------------
 8479|  12.4k|        mp_update_logging(mpctx, false);
 8480|       |
 8481|  80.3k|    if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  444|  80.3k|#define UPDATE_OSD              (UINT64_C(1) << 2)   // related to OSD rendering
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  443|  80.3k|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
                  if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  455|  80.3k|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (8481:9): [True: 12.4k, False: 67.8k]
  ------------------
 8482|  37.4k|        for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (8482:25): [True: 24.9k, False: 12.4k]
  ------------------
 8483|  24.9k|            struct track *track = mpctx->current_track[n][STREAM_SUB];
 8484|  24.9k|            struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (8484:35): [True: 264, False: 24.7k]
  ------------------
 8485|  24.9k|            if (sub) {
  ------------------
  |  Branch (8485:17): [True: 264, False: 24.7k]
  ------------------
 8486|    264|                int ret = sub_control(sub, SD_CTRL_UPDATE_OPTS, &flags);
 8487|    264|                if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |   95|    528|#define CONTROL_OK 1
  ------------------
                              if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  443|    264|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
                              if (ret == CONTROL_OK && flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
  ------------------
  |  |  455|    264|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (8487:21): [True: 264, False: 0]
  |  Branch (8487:42): [True: 0, False: 264]
  ------------------
 8488|      0|                    sub_redecode_cached_packets(sub);
 8489|      0|                }
 8490|    264|            }
 8491|  24.9k|        }
 8492|       |        // For subs on a still image.
 8493|  12.4k|        redraw_subs(mpctx);
 8494|  12.4k|        osd_changed(mpctx->osd);
 8495|  12.4k|    }
 8496|       |
 8497|  80.3k|    if (flags & UPDATE_BUILTIN_SCRIPTS)
  ------------------
  |  |  445|  80.3k|#define UPDATE_BUILTIN_SCRIPTS  (UINT64_C(1) << 3)   // osc/ytdl/stats
  ------------------
  |  Branch (8497:9): [True: 11.6k, False: 68.6k]
  ------------------
 8498|  11.6k|        mp_load_builtin_scripts(mpctx);
 8499|       |
 8500|  80.3k|    if (flags & UPDATE_IMGPAR) {
  ------------------
  |  |  446|  80.3k|#define UPDATE_IMGPAR           (UINT64_C(1) << 4)   // video image params overrides
  ------------------
  |  Branch (8500:9): [True: 12.4k, False: 67.8k]
  ------------------
 8501|  12.4k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8502|  12.4k|        if (track && track->dec) {
  ------------------
  |  Branch (8502:13): [True: 380, False: 12.1k]
  |  Branch (8502:22): [True: 380, False: 0]
  ------------------
 8503|    380|            mp_decoder_wrapper_reset_params(track->dec);
 8504|    380|            mp_force_video_refresh(mpctx);
 8505|    380|        }
 8506|  12.4k|    }
 8507|       |
 8508|  80.3k|    if (flags & UPDATE_INPUT)
  ------------------
  |  |  447|  80.3k|#define UPDATE_INPUT            (UINT64_C(1) << 5)   // mostly --input-* options
  ------------------
  |  Branch (8508:9): [True: 11.6k, False: 68.6k]
  ------------------
 8509|  11.6k|        mp_input_update_opts(mpctx->input);
 8510|       |
 8511|  80.3k|    if (flags & UPDATE_CLIPBOARD)
  ------------------
  |  |  458|  80.3k|#define UPDATE_CLIPBOARD        (UINT64_C(1) << 17)  // reinit the clipboard
  ------------------
  |  Branch (8511:9): [True: 11.6k, False: 68.6k]
  ------------------
 8512|  11.6k|        reinit_clipboard(mpctx);
 8513|       |
 8514|  80.3k|    if (opt_ptr == &opts->ipc_path || opt_ptr == &opts->ipc_client) {
  ------------------
  |  Branch (8514:9): [True: 0, False: 80.3k]
  |  Branch (8514:39): [True: 0, False: 80.3k]
  ------------------
 8515|      0|        mp_uninit_ipc(mpctx->ipc_ctx);
 8516|      0|        mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
 8517|      0|    }
 8518|       |
 8519|  80.3k|    if (flags & UPDATE_VO && mpctx->video_out) {
  ------------------
  |  |  457|   160k|#define UPDATE_VO               (UINT64_C(1) << 16)  // reinit the VO
  ------------------
  |  Branch (8519:9): [True: 40.3k, False: 39.9k]
  |  Branch (8519:30): [True: 6.87k, False: 33.4k]
  ------------------
 8520|  6.87k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8521|  6.87k|        struct mp_pin *filter_src = mpctx->vo_chain ? mpctx->vo_chain->filter_src : NULL;
  ------------------
  |  Branch (8521:37): [True: 4.05k, False: 2.82k]
  ------------------
 8522|  6.87k|        uninit_video_out(mpctx);
 8523|  6.87k|        handle_force_window(mpctx, true);
 8524|       |
 8525|  6.87k|        if (filter_src) {
  ------------------
  |  Branch (8525:13): [True: 0, False: 6.87k]
  ------------------
 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|  6.87k|        } else {
 8532|  6.87k|            reinit_video_chain(mpctx);
 8533|  6.87k|        }
 8534|       |
 8535|  6.87k|        if (track || filter_src)
  ------------------
  |  Branch (8535:13): [True: 4.05k, False: 2.82k]
  |  Branch (8535:22): [True: 0, False: 2.82k]
  ------------------
 8536|  4.05k|            queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);
 8537|       |
 8538|  6.87k|        mp_wakeup_core(mpctx);
 8539|  6.87k|    }
 8540|       |
 8541|  80.3k|    if (flags & UPDATE_AUDIO)
  ------------------
  |  |  448|  80.3k|#define UPDATE_AUDIO            (UINT64_C(1) << 6)   // --audio-channels etc.
  ------------------
  |  Branch (8541:9): [True: 11.6k, False: 68.6k]
  ------------------
 8542|  11.6k|        reload_audio_output(mpctx);
 8543|       |
 8544|  80.3k|    if (flags & UPDATE_PRIORITY)
  ------------------
  |  |  449|  80.3k|#define UPDATE_PRIORITY         (UINT64_C(1) << 7)   // --priority (Windows-only)
  ------------------
  |  Branch (8544:9): [True: 11.6k, False: 68.6k]
  ------------------
 8545|  11.6k|        update_priority(mpctx);
 8546|       |
 8547|  80.3k|    if (flags & UPDATE_SCREENSAVER)
  ------------------
  |  |  450|  80.3k|#define UPDATE_SCREENSAVER      (UINT64_C(1) << 8)   // --stop-screensaver
  ------------------
  |  Branch (8547:9): [True: 11.7k, False: 68.6k]
  ------------------
 8548|  11.7k|        update_screensaver_state(mpctx);
 8549|       |
 8550|  80.3k|    if (flags & UPDATE_VOL)
  ------------------
  |  |  451|  80.3k|#define UPDATE_VOL              (UINT64_C(1) << 9)   // softvol related options
  ------------------
  |  Branch (8550:9): [True: 12.9k, False: 67.3k]
  ------------------
 8551|  12.9k|        audio_update_volume(mpctx);
 8552|       |
 8553|  80.3k|    if (flags & UPDATE_LAVFI_COMPLEX)
  ------------------
  |  |  452|  80.3k|#define UPDATE_LAVFI_COMPLEX    (UINT64_C(1) << 10)  // --lavfi-complex
  ------------------
  |  Branch (8553:9): [True: 11.6k, False: 68.6k]
  ------------------
 8554|  11.6k|        update_lavfi_complex(mpctx);
 8555|       |
 8556|  80.3k|    if (flags & UPDATE_VIDEO) {
  ------------------
  |  |  456|  80.3k|#define UPDATE_VIDEO            (UINT64_C(1) << 15)  // force redraw if needed
  ------------------
  |  Branch (8556:9): [True: 11.8k, False: 68.5k]
  ------------------
 8557|  11.8k|        if (mpctx->video_out) {
  ------------------
  |  Branch (8557:13): [True: 77, False: 11.7k]
  ------------------
 8558|     77|            vo_control(mpctx->video_out, VOCTRL_UPDATE_RENDER_OPTS, NULL);
 8559|     77|            mp_wakeup_core(mpctx);
 8560|     77|        }
 8561|  11.8k|    }
 8562|       |
 8563|  80.3k|    if (flags & UPDATE_HWDEC) {
  ------------------
  |  |  453|  80.3k|#define UPDATE_HWDEC            (UINT64_C(1) << 11)  // --hwdec
  ------------------
  |  Branch (8563:9): [True: 11.6k, False: 68.6k]
  ------------------
 8564|  11.6k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8565|  11.6k|        struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
  ------------------
  |  Branch (8565:42): [True: 11, False: 11.6k]
  ------------------
 8566|  11.6k|        if (dec) {
  ------------------
  |  Branch (8566:13): [True: 11, False: 11.6k]
  ------------------
 8567|     11|            mp_decoder_wrapper_control(dec, VDCTRL_REINIT, NULL);
 8568|       |            // filter chain might not change (which normally triggers this), but
 8569|       |            // hwdec will.
 8570|     11|            mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 8571|     11|            double last_pts = mpctx->video_pts;
 8572|     11|            if (last_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|     11|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (8572:17): [True: 10, False: 1]
  ------------------
 8573|     10|                queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0);
 8574|     11|        }
 8575|  11.6k|    }
 8576|       |
 8577|  80.3k|    if (flags & UPDATE_DVB_PROG) {
  ------------------
  |  |  454|  80.3k|#define UPDATE_DVB_PROG         (UINT64_C(1) << 12)  // some --dvbin-...
  ------------------
  |  Branch (8577:9): [True: 12.0k, False: 68.3k]
  ------------------
 8578|  12.0k|        if (!mpctx->stop_play)
  ------------------
  |  Branch (8578:13): [True: 275, False: 11.7k]
  ------------------
 8579|    275|            mpctx->stop_play = PT_CURRENT_ENTRY;
 8580|  12.0k|    }
 8581|       |
 8582|  80.3k|    if (flags & UPDATE_DEMUXER)
  ------------------
  |  |  459|  80.3k|#define UPDATE_DEMUXER          (UINT64_C(1) << 18)  // invalidate --prefetch-playlist's data
  ------------------
  |  Branch (8582:9): [True: 11.7k, False: 68.6k]
  ------------------
 8583|  11.7k|        mpctx->demuxer_changed = true;
 8584|       |
 8585|  80.3k|    if (flags & UPDATE_AD && mpctx->ao_chain) {
  ------------------
  |  |  460|   160k|#define UPDATE_AD               (UINT64_C(1) << 19)  // reinit audio chain and decoder
  ------------------
  |  Branch (8585:9): [True: 12.5k, False: 67.8k]
  |  Branch (8585:30): [True: 93, False: 12.4k]
  ------------------
 8586|     93|        uninit_audio_chain(mpctx);
 8587|     93|        reinit_audio_chain(mpctx);
 8588|     93|    }
 8589|       |
 8590|  80.3k|    if (flags & UPDATE_VD && mpctx->vo_chain) {
  ------------------
  |  |  461|   160k|#define UPDATE_VD               (UINT64_C(1) << 20)  // reinit video chain and decoder
  ------------------
  |  Branch (8590:9): [True: 11.6k, False: 68.6k]
  |  Branch (8590:30): [True: 17, False: 11.6k]
  ------------------
 8591|     17|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 8592|     17|        uninit_video_chain(mpctx);
 8593|     17|        reinit_video_chain(mpctx);
 8594|     17|        if (track)
  ------------------
  |  Branch (8594:13): [True: 17, False: 0]
  ------------------
 8595|     17|            queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);
 8596|     17|    }
 8597|       |
 8598|  80.3k|    if (opt_ptr == &opts->vo->android_surface_size || opt_ptr == &opts->vo->d3d11_composition_size) {
  ------------------
  |  Branch (8598:9): [True: 0, False: 80.3k]
  |  Branch (8598:55): [True: 0, False: 80.3k]
  ------------------
 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|  80.3k|    if (opt_ptr == &opts->input_commands) {
  ------------------
  |  Branch (8603:9): [True: 0, False: 80.3k]
  ------------------
 8604|      0|        mpctx->command_ctx->command_opts_processed = false;
 8605|      0|        run_command_opts(mpctx);
 8606|      0|    }
 8607|       |
 8608|  80.3k|    if (opt_ptr == &opts->playback_speed || opt_ptr == &opts->playback_pitch ||
  ------------------
  |  Branch (8608:9): [True: 3.96k, False: 76.3k]
  |  Branch (8608:45): [True: 1.66k, False: 74.7k]
  ------------------
 8609|  74.7k|        opt_ptr == &opts->pitch_correction) {
  ------------------
  |  Branch (8609:9): [True: 25, False: 74.6k]
  ------------------
 8610|  5.66k|        update_playback_speed(mpctx);
 8611|  5.66k|        mp_wakeup_core(mpctx);
 8612|  5.66k|    }
 8613|       |
 8614|  80.3k|    if (opt_ptr == &opts->play_dir) {
  ------------------
  |  Branch (8614:9): [True: 452, False: 79.8k]
  ------------------
 8615|    452|        if (mpctx->play_dir != opts->play_dir) {
  ------------------
  |  Branch (8615:13): [True: 413, False: 39]
  ------------------
 8616|       |            // The option must be set before we seek if we're at EOF.
 8617|    413|            if (mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (8617:17): [True: 45, False: 368]
  ------------------
 8618|     45|                mpctx->play_dir = opts->play_dir;
 8619|    413|            queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx),
 8620|    413|                       MPSEEK_EXACT, 0);
 8621|    413|        }
 8622|    452|    }
 8623|       |
 8624|  80.3k|    if (opt_ptr == &opts->edition_id) {
  ------------------
  |  Branch (8624:9): [True: 2, False: 80.3k]
  ------------------
 8625|      2|        struct demuxer *demuxer = mpctx->demuxer;
 8626|      2|        if (mpctx->playback_initialized && demuxer && demuxer->num_editions > 0) {
  ------------------
  |  Branch (8626:13): [True: 0, False: 2]
  |  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|      2|    }
 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|  80.3k|    if (opt_ptr == &opts->pause)
  ------------------
  |  Branch (8684:9): [True: 25, False: 80.3k]
  ------------------
 8685|     25|        set_pause_state(mpctx, opts->pause);
 8686|       |
 8687|  80.3k|    if (opt_ptr == &opts->audio_delay) {
  ------------------
  |  Branch (8687:9): [True: 23, False: 80.3k]
  ------------------
 8688|     23|        if (mpctx->ao_chain) {
  ------------------
  |  Branch (8688:13): [True: 10, False: 13]
  ------------------
 8689|     10|            double change = mpctx->opts->audio_delay - mpctx->ao_chain->delay;
 8690|     10|            mpctx->delay += change;
 8691|     10|            mpctx->ao_chain->delayed_start_gap += change;
 8692|     10|            mpctx->ao_chain->delay = mpctx->opts->audio_delay;
 8693|     10|        }
 8694|     23|        mp_wakeup_core(mpctx);
 8695|     23|    }
 8696|       |
 8697|  80.3k|    if (opt_ptr == &opts->vo->window_scale)
  ------------------
  |  Branch (8697:9): [True: 5, False: 80.3k]
  ------------------
 8698|      5|        update_window_scale(mpctx);
 8699|       |
 8700|  80.3k|    if (opt_ptr == &opts->vo->hidpi_window_scale)
  ------------------
  |  Branch (8700:9): [True: 7, False: 80.3k]
  ------------------
 8701|      7|        update_hidpi_window_scale(mpctx, opts->vo->hidpi_window_scale);
 8702|       |
 8703|  80.3k|    if (opt_ptr == &opts->cursor_autohide_delay)
  ------------------
  |  Branch (8703:9): [True: 3, False: 80.3k]
  ------------------
 8704|      3|        mpctx->mouse_timer = 0;
 8705|       |
 8706|  80.3k|    if (opt_ptr == &opts->loop_file) {
  ------------------
  |  Branch (8706:9): [True: 1.28k, False: 79.0k]
  ------------------
 8707|  1.28k|        mpctx->remaining_file_loops = opts->loop_file;
 8708|  1.28k|        mp_notify_property(mpctx, "remaining-file-loops");
 8709|  1.28k|    }
 8710|       |
 8711|  80.3k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1] ||
  ------------------
  |  Branch (8711:9): [True: 5.54k, False: 74.8k]
  |  Branch (8711:41): [True: 4.91k, False: 69.8k]
  ------------------
 8712|  69.8k|        opt_ptr == &opts->ab_loop_count) {
  ------------------
  |  Branch (8712:9): [True: 36, False: 69.8k]
  ------------------
 8713|  10.4k|        mpctx->remaining_ab_loops = opts->ab_loop_count;
 8714|  10.4k|        mp_notify_property(mpctx, "remaining-ab-loops");
 8715|  10.4k|    }
 8716|       |
 8717|  80.3k|    if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) {
  ------------------
  |  Branch (8717:9): [True: 5.54k, False: 74.8k]
  |  Branch (8717:41): [True: 4.91k, False: 69.8k]
  ------------------
 8718|  10.4k|        update_ab_loop_clip(mpctx);
 8719|       |        // Update if visible
 8720|  10.4k|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
 8721|  10.4k|        mp_wakeup_core(mpctx);
 8722|  10.4k|    }
 8723|       |
 8724|  80.3k|    if (opt_ptr == &opts->vf_settings)
  ------------------
  |  Branch (8724:9): [True: 0, False: 80.3k]
  ------------------
 8725|      0|        set_filters(mpctx, STREAM_VIDEO, opts->vf_settings);
 8726|       |
 8727|  80.3k|    if (opt_ptr == &opts->af_settings)
  ------------------
  |  Branch (8727:9): [True: 0, False: 80.3k]
  ------------------
 8728|      0|        set_filters(mpctx, STREAM_AUDIO, opts->af_settings);
 8729|       |
 8730|   321k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (8730:24): [True: 241k, False: 80.3k]
  ------------------
 8731|   562k|        for (int order = 0; order < num_ptracks[type]; order++) {
  ------------------
  |  Branch (8731:29): [True: 321k, False: 241k]
  ------------------
 8732|   321k|            if (opt_ptr == &opts->stream_id[order][type])
  ------------------
  |  Branch (8732:17): [True: 134, False: 321k]
  ------------------
 8733|    134|                update_track_switch(mpctx, order, type);
 8734|   321k|        }
 8735|   241k|    }
 8736|       |
 8737|  80.3k|    if (opt_ptr == &opts->vo->fullscreen && !opts->vo->fullscreen)
  ------------------
  |  Branch (8737:9): [True: 147, False: 80.2k]
  |  Branch (8737:45): [True: 60, False: 87]
  ------------------
 8738|     60|        mpctx->mouse_event_ts--; // Show mouse cursor
 8739|       |
 8740|  80.3k|    if (opt_ptr == &opts->vo->taskbar_progress)
  ------------------
  |  Branch (8740:9): [True: 3, False: 80.3k]
  ------------------
 8741|      3|        update_vo_playback_state(mpctx);
 8742|       |
 8743|  80.3k|    if (opt_ptr == &opts->force_vo)
  ------------------
  |  Branch (8743:9): [True: 82, False: 80.2k]
  ------------------
 8744|     82|        handle_force_window(mpctx, false);
 8745|       |
 8746|  80.3k|    if (opt_ptr == &opts->image_display_duration && mpctx->vo_chain
  ------------------
  |  Branch (8746:9): [True: 12, False: 80.3k]
  |  Branch (8746:53): [True: 11, False: 1]
  ------------------
 8747|     11|        && mpctx->vo_chain->is_sparse && !mpctx->ao_chain
  ------------------
  |  Branch (8747:12): [True: 0, False: 11]
  |  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|  80.3k|}
mp_notify_property:
 8753|   205k|{
 8754|   205k|    mp_client_property_change(mpctx, property);
 8755|   205k|}
command.c:run_next_hook_handler:
  246|  93.7k|{
  247|  93.7k|    struct command_ctx *cmd = mpctx->command_ctx;
  248|       |
  249|  93.7k|    for (int n = start; n < cmd->num_hooks; n++) {
  ------------------
  |  Branch (249:25): [True: 0, False: 93.7k]
  ------------------
  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|  93.7k|    mp_wakeup_core(mpctx); // finished hook
  263|  93.7k|    return 0;
  264|  93.7k|}
command.c:match_property:
 5009|   141M|{
 5010|   141M|    if (strcmp(a, "*") == 0)
  ------------------
  |  Branch (5010:9): [True: 116k, False: 141M]
  ------------------
 5011|   116k|        return true;
 5012|       |    // Give options and properties the same ID each, so change notifications
 5013|       |    // work both way.
 5014|   141M|    if (strncmp(a, "options/", 8) == 0)
  ------------------
  |  Branch (5014:9): [True: 0, False: 141M]
  ------------------
 5015|      0|        a += 8;
 5016|   141M|    if (strncmp(b, "options/", 8) == 0)
  ------------------
  |  Branch (5016:9): [True: 0, False: 141M]
  ------------------
 5017|      0|        b += 8;
 5018|   141M|    int len_a = prefix_len(a);
 5019|   141M|    int len_b = prefix_len(b);
 5020|   141M|    return strncmp(a, b, MPMIN(len_a, len_b)) == 0;
  ------------------
  |  |   45|   141M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 103M, False: 38.1M]
  |  |  ------------------
  ------------------
 5021|   141M|}
command.c:prefix_len:
 5003|   283M|{
 5004|   283M|    const char *end = strchr(p, '/');
 5005|   283M|    return end ? end - p : strlen(p) + 1;
  ------------------
  |  Branch (5005:12): [True: 21.8M, False: 261M]
  ------------------
 5006|   283M|}
command.c:is_property_set:
 5050|   548k|{
 5051|   548k|    switch (action) {
 5052|  21.7k|    case M_PROPERTY_SET:
  ------------------
  |  Branch (5052:5): [True: 21.7k, False: 526k]
  ------------------
 5053|   192k|    case M_PROPERTY_SWITCH:
  ------------------
  |  Branch (5053:5): [True: 170k, False: 377k]
  ------------------
 5054|   193k|    case M_PROPERTY_SET_STRING:
  ------------------
  |  Branch (5054:5): [True: 1.20k, False: 546k]
  ------------------
 5055|   193k|    case M_PROPERTY_SET_NODE:
  ------------------
  |  Branch (5055:5): [True: 50, False: 548k]
  ------------------
 5056|   193k|    case M_PROPERTY_MULTIPLY:
  ------------------
  |  Branch (5056:5): [True: 0, False: 548k]
  ------------------
 5057|   193k|        return true;
 5058|     29|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (5058:5): [True: 29, False: 548k]
  ------------------
 5059|     29|        struct m_property_action_arg *key = val;
 5060|     29|        return is_property_set(key->action, key->arg);
 5061|   193k|    }
 5062|   354k|    default:
  ------------------
  |  Branch (5062:5): [True: 354k, False: 194k]
  ------------------
 5063|       |        return false;
 5064|   548k|    }
 5065|   548k|}
command.c:expand_escaped_string:
 5107|  21.0k|{
 5108|  21.0k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  21.0k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  21.0k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 5109|  21.0k|    bstr strb = bstr0(str);
 5110|  21.0k|    bstr dst = {0};
 5111|  21.0k|    while (strb.len) {
  ------------------
  |  Branch (5111:12): [True: 0, False: 21.0k]
  ------------------
 5112|      0|        if (!mp_append_escaped_string(tmp, &dst, &strb)) {
  ------------------
  |  Branch (5112:13): [True: 0, False: 0]
  ------------------
 5113|      0|            talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 5114|      0|            return talloc_strdup(NULL, "(broken escape sequences)");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 5115|      0|        }
 5116|       |        // pass " through literally
 5117|      0|        if (!bstr_eatstart0(&strb, "\""))
  ------------------
  |  Branch (5117:13): [True: 0, False: 0]
  ------------------
 5118|      0|            break;
 5119|      0|        bstr_xappend(tmp, &dst, bstr0("\""));
 5120|      0|    }
 5121|  21.0k|    struct command_ctx *ctx = mpctx->command_ctx;
 5122|  21.0k|    char *r = m_properties_expand_string(&ctx->properties, dst.start, mpctx,
 5123|  21.0k|                                         print_action);
 5124|  21.0k|    talloc_free(tmp);
  ------------------
  |  |   47|  21.0k|#define talloc_free                     ta_free
  ------------------
 5125|  21.0k|    return r;
 5126|  21.0k|}
command.c:cmd_list:
 5912|     23|{
 5913|     23|    struct mp_cmd_ctx *cmd = p;
 5914|       |
 5915|     23|    cmd->completed = false;
 5916|       |
 5917|     23|    struct cmd_list_ctx *list = talloc_zero(NULL, struct cmd_list_ctx);
  ------------------
  |  |   27|     23|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     23|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     23|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5918|     23|    list->mpctx = cmd->mpctx;
 5919|     23|    list->parent = p;
 5920|       |
 5921|     23|    continue_cmd_list(list);
 5922|     23|}
command.c:continue_cmd_list:
 5875|     41|{
 5876|     70|    while (list->parent->args[0].v.p) {
  ------------------
  |  Branch (5876:12): [True: 47, False: 23]
  ------------------
 5877|     47|        struct mp_cmd *sub = list->parent->args[0].v.p;
 5878|     47|        list->parent->args[0].v.p = sub->queue_next;
 5879|       |
 5880|     47|        ta_set_parent(sub, NULL);
 5881|       |
 5882|     47|        if (sub->flags & MP_ASYNC_CMD) {
  ------------------
  |  Branch (5882:13): [True: 0, False: 47]
  ------------------
 5883|       |            // We run it "detached" (fire & forget)
 5884|      0|            run_command(list->mpctx, sub, NULL, NULL, NULL);
 5885|     47|        } else {
 5886|       |            // Run the next command once this one completes.
 5887|       |
 5888|     47|            list->completed_recursive = false;
 5889|     47|            list->current_valid = true;
 5890|     47|            list->current_tid = mp_thread_current_id();
  ------------------
  |  |  217|     47|#define mp_thread_current_id      pthread_self
  ------------------
 5891|       |
 5892|     47|            run_command(list->mpctx, sub, NULL, on_cmd_list_sub_completion, list);
 5893|       |
 5894|     47|            list->current_valid = false;
 5895|       |
 5896|       |            // run_command() either recursively calls the completion function,
 5897|       |            // or lets the command continue run in the background. If it was
 5898|       |            // completed recursively, we can just continue our loop. Otherwise
 5899|       |            // the completion handler will invoke this loop again elsewhere.
 5900|       |            // We could unconditionally call continue_cmd_list() in the handler
 5901|       |            // instead, but then stack depth would grow with list length.
 5902|     47|            if (!list->completed_recursive)
  ------------------
  |  Branch (5902:17): [True: 18, False: 29]
  ------------------
 5903|     18|                return;
 5904|     47|        }
 5905|     47|    }
 5906|       |
 5907|     23|    mp_cmd_ctx_complete(list->parent);
 5908|     23|    talloc_free(list);
  ------------------
  |  |   47|     23|#define talloc_free                     ta_free
  ------------------
 5909|     23|}
command.c:on_cmd_list_sub_completion:
 5864|     47|{
 5865|     47|    struct cmd_list_ctx *list = cmd->on_completion_priv;
 5866|       |
 5867|     47|    if (list->current_valid && mp_thread_id_equal(list->current_tid, mp_thread_current_id())) {
  ------------------
  |  |  218|     29|#define mp_thread_id_equal(a, b)  ((a) == (b))
  |  |  ------------------
  |  |  |  Branch (218:35): [True: 29, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (5867:9): [True: 29, False: 18]
  ------------------
 5868|     29|        list->completed_recursive = true;
 5869|     29|    } else {
 5870|     18|        continue_cmd_list(list);
 5871|     18|    }
 5872|     47|}
command.c:run_command_on_worker_thread:
 5946|   152k|{
 5947|   152k|    struct mp_cmd_ctx *ctx = p;
 5948|   152k|    struct MPContext *mpctx = ctx->mpctx;
 5949|       |
 5950|   152k|    mp_core_lock(mpctx);
 5951|       |
 5952|   152k|    bool exec_async = ctx->cmd->def->exec_async;
 5953|   152k|    ctx->cmd->def->handler(ctx);
 5954|   152k|    if (!exec_async)
  ------------------
  |  Branch (5954:9): [True: 152k, False: 0]
  ------------------
 5955|   152k|        mp_cmd_ctx_complete(ctx);
 5956|       |
 5957|   152k|    mpctx->outstanding_async -= 1;
 5958|   152k|    if (!mpctx->outstanding_async && mp_is_shutting_down(mpctx))
  ------------------
  |  Branch (5958:9): [True: 152k, False: 8]
  |  Branch (5958:38): [True: 4, False: 152k]
  ------------------
 5959|      4|        mp_wakeup_core(mpctx);
 5960|       |
 5961|   152k|    mp_core_unlock(mpctx);
 5962|   152k|}
command.c:cache_dump_poll:
 7450|  11.6M|{
 7451|  11.6M|    struct command_ctx *ctx = mpctx->command_ctx;
 7452|  11.6M|    struct mp_cmd_ctx *cmd = ctx->cache_dump_cmd;
 7453|       |
 7454|  11.6M|    if (!cmd)
  ------------------
  |  Branch (7454:9): [True: 11.6M, False: 44]
  ------------------
 7455|  11.6M|        return;
 7456|       |
 7457|       |    // Can't close demuxer without stopping dumping.
 7458|     44|    mp_assert(mpctx->demuxer);
  ------------------
  |  |   41|     44|#define mp_assert assert
  ------------------
  |  Branch (7458:5): [True: 44, False: 0]
  ------------------
 7459|       |
 7460|     44|    if (mp_cancel_test(cmd->abort->cancel)) {
  ------------------
  |  Branch (7460:9): [True: 0, False: 44]
  ------------------
 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|     44|    int status = demux_cache_dump_get_status(mpctx->demuxer);
 7468|     44|    if (status <= 0) {
  ------------------
  |  Branch (7468:9): [True: 44, False: 0]
  ------------------
 7469|     44|        if (status < 0) {
  ------------------
  |  Branch (7469:13): [True: 44, False: 0]
  ------------------
 7470|     44|            mp_cmd_msg(cmd, MSGL_ERR, "Cache dumping stopped due to error.");
 7471|     44|            cmd->success = false;
 7472|     44|        } 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|     44|        mp_cmd_ctx_complete(cmd);
 7478|     44|    }
 7479|     44|}
command.c:cmd_ignore:
 7287|     89|{
 7288|     89|}
command.c:cmd_seek:
 6075|  40.4k|{
 6076|  40.4k|    struct mp_cmd_ctx *cmd = p;
 6077|  40.4k|    struct MPContext *mpctx = cmd->mpctx;
 6078|       |
 6079|  40.4k|    double v = cmd->args[0].v.d * cmd->cmd->scale;
 6080|  40.4k|    int abs = cmd->args[1].v.i & 3;
 6081|  40.4k|    enum seek_precision precision = MPSEEK_DEFAULT;
 6082|  40.4k|    switch (((cmd->args[2].v.i | cmd->args[1].v.i) >> 3) & 3) {
  ------------------
  |  Branch (6082:13): [True: 0, False: 40.4k]
  ------------------
 6083|      0|    case 1: precision = MPSEEK_KEYFRAME; break;
  ------------------
  |  Branch (6083:5): [True: 0, False: 40.4k]
  ------------------
 6084|      0|    case 2: precision = MPSEEK_EXACT; break;
  ------------------
  |  Branch (6084:5): [True: 0, False: 40.4k]
  ------------------
 6085|  40.4k|    }
 6086|  40.4k|    if (!mpctx->playback_initialized) {
  ------------------
  |  Branch (6086:9): [True: 32.2k, False: 8.13k]
  ------------------
 6087|  32.2k|        cmd->success = false;
 6088|  32.2k|        return;
 6089|  32.2k|    }
 6090|       |
 6091|  8.13k|    mark_seek(mpctx);
 6092|  8.13k|    switch (abs) {
  ------------------
  |  Branch (6092:13): [True: 8.13k, False: 0]
  ------------------
 6093|  8.13k|    case 0: { // Relative seek
  ------------------
  |  Branch (6093:5): [True: 8.13k, False: 0]
  ------------------
 6094|  8.13k|        queue_seek(mpctx, MPSEEK_RELATIVE, v, precision, MPSEEK_FLAG_DELAY);
 6095|  8.13k|        set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
  ------------------
  |  Branch (6095:33): [True: 4.21k, False: 3.92k]
  ------------------
 6096|  8.13k|        break;
 6097|      0|    }
 6098|      0|    case 1: { // Absolute seek by percentage
  ------------------
  |  Branch (6098:5): [True: 0, False: 8.13k]
  ------------------
 6099|      0|        double ratio = v / 100.0;
 6100|      0|        double cur_pos = get_current_pos_ratio(mpctx, false);
 6101|      0|        queue_seek(mpctx, MPSEEK_FACTOR, ratio, precision, MPSEEK_FLAG_DELAY);
 6102|      0|        set_osd_function(mpctx, cur_pos < ratio ? OSD_FFW : OSD_REW);
  ------------------
  |  Branch (6102:33): [True: 0, False: 0]
  ------------------
 6103|      0|        break;
 6104|      0|    }
 6105|      0|    case 2: { // Absolute seek to a timestamp in seconds
  ------------------
  |  Branch (6105:5): [True: 0, False: 8.13k]
  ------------------
 6106|      0|        if (v < 0) {
  ------------------
  |  Branch (6106:13): [True: 0, False: 0]
  ------------------
 6107|       |            // Seek from end
 6108|      0|            double len = get_time_length(mpctx);
 6109|      0|            if (len < 0) {
  ------------------
  |  Branch (6109:17): [True: 0, False: 0]
  ------------------
 6110|      0|                cmd->success = false;
 6111|      0|                return;
 6112|      0|            }
 6113|      0|            v = MPMAX(0, len + v);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 6114|      0|        }
 6115|      0|        queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, MPSEEK_FLAG_DELAY);
 6116|      0|        set_osd_function(mpctx,
 6117|      0|                         v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
  ------------------
  |  Branch (6117:26): [True: 0, False: 0]
  ------------------
 6118|      0|        break;
 6119|      0|    }
 6120|      0|    case 3: { // Relative seek by percentage
  ------------------
  |  Branch (6120:5): [True: 0, False: 8.13k]
  ------------------
 6121|      0|        queue_seek(mpctx, MPSEEK_FACTOR,
 6122|      0|                   get_current_pos_ratio(mpctx, false) + v / 100.0,
 6123|      0|                   precision, MPSEEK_FLAG_DELAY);
 6124|      0|        set_osd_function(mpctx, v > 0 ? OSD_FFW : OSD_REW);
  ------------------
  |  Branch (6124:33): [True: 0, False: 0]
  ------------------
 6125|      0|        break;
 6126|      0|    }}
 6127|  8.13k|    if (cmd->seek_bar_osd)
  ------------------
  |  Branch (6127:9): [True: 8.13k, False: 0]
  ------------------
 6128|  8.13k|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
 6129|  8.13k|    if (cmd->seek_msg_osd)
  ------------------
  |  Branch (6129:9): [True: 0, False: 8.13k]
  ------------------
 6130|      0|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
 6131|  8.13k|}
command.c:cmd_revert_seek:
 6134|  6.75k|{
 6135|  6.75k|    struct mp_cmd_ctx *cmd = p;
 6136|  6.75k|    struct MPContext *mpctx = cmd->mpctx;
 6137|  6.75k|    struct command_ctx *cmdctx = mpctx->command_ctx;
 6138|       |
 6139|  6.75k|    if (!mpctx->playback_initialized) {
  ------------------
  |  Branch (6139:9): [True: 5.51k, False: 1.23k]
  ------------------
 6140|  5.51k|        cmd->success = false;
 6141|  5.51k|        return;
 6142|  5.51k|    }
 6143|       |
 6144|  1.23k|    double oldpts = cmdctx->last_seek_pts;
 6145|  1.23k|    if (cmdctx->marked_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.23k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (6145:9): [True: 0, False: 1.23k]
  ------------------
 6146|      0|        oldpts = cmdctx->marked_pts;
 6147|  1.23k|    if (cmd->args[0].v.i & 3) {
  ------------------
  |  Branch (6147:9): [True: 0, False: 1.23k]
  ------------------
 6148|      0|        cmdctx->marked_pts = get_current_time(mpctx);
 6149|      0|        cmdctx->marked_permanent = cmd->args[0].v.i & 1;
 6150|  1.23k|    } else if (oldpts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.23k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (6150:16): [True: 614, False: 620]
  ------------------
 6151|    614|        if (!cmdctx->marked_permanent) {
  ------------------
  |  Branch (6151:13): [True: 614, False: 0]
  ------------------
 6152|    614|            cmdctx->marked_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    614|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 6153|    614|            cmdctx->last_seek_pts = get_current_time(mpctx);
 6154|    614|        }
 6155|    614|        queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, MPSEEK_EXACT,
 6156|    614|                   MPSEEK_FLAG_DELAY);
 6157|    614|        set_osd_function(mpctx, OSD_REW);
 6158|    614|        if (cmd->seek_bar_osd)
  ------------------
  |  Branch (6158:13): [True: 610, False: 4]
  ------------------
 6159|    610|            mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
 6160|    614|        if (cmd->seek_msg_osd)
  ------------------
  |  Branch (6160:13): [True: 4, False: 610]
  ------------------
 6161|      4|            mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
 6162|    620|    } else {
 6163|       |        cmd->success = false;
 6164|    620|    }
 6165|  1.23k|}
command.c:cmd_quit:
 6327|  23.5k|{
 6328|  23.5k|    struct mp_cmd_ctx *cmd = p;
 6329|  23.5k|    struct MPContext *mpctx = cmd->mpctx;
 6330|  23.5k|    bool write_watch_later = *(bool *)cmd->priv;
 6331|  23.5k|    if (write_watch_later || mpctx->opts->position_save_on_quit)
  ------------------
  |  Branch (6331:9): [True: 44, False: 23.5k]
  |  Branch (6331:30): [True: 171, False: 23.3k]
  ------------------
 6332|    215|        mp_write_watch_later_conf(mpctx);
 6333|  23.5k|    mpctx->stop_play = PT_QUIT;
 6334|  23.5k|    mpctx->quit_custom_rc = cmd->args[0].v.i;
 6335|       |    mpctx->has_quit_custom_rc = true;
 6336|  23.5k|    mp_wakeup_core(mpctx);
 6337|  23.5k|}
command.c:cmd_stop:
 6733|    912|{
 6734|    912|    struct mp_cmd_ctx *cmd = p;
 6735|    912|    struct MPContext *mpctx = cmd->mpctx;
 6736|    912|    int flags = cmd->args[0].v.i;
 6737|       |
 6738|    912|    if (!(flags & 1))
  ------------------
  |  Branch (6738:9): [True: 912, False: 0]
  ------------------
 6739|    912|        playlist_clear(mpctx->playlist);
 6740|       |
 6741|    912|    if (mpctx->opts->player_idle_mode < 2 &&
  ------------------
  |  Branch (6741:9): [True: 0, False: 912]
  ------------------
 6742|      0|        mpctx->opts->position_save_on_quit)
  ------------------
  |  Branch (6742:9): [True: 0, False: 0]
  ------------------
 6743|      0|    {
 6744|      0|        mp_write_watch_later_conf(mpctx);
 6745|      0|    }
 6746|       |
 6747|    912|    if (mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (6747:9): [True: 901, False: 11]
  ------------------
 6748|    901|        mpctx->stop_play = PT_STOP;
 6749|    912|    mp_wakeup_core(mpctx);
 6750|    912|}
command.c:cmd_frame_step:
 6292|  33.3k|{
 6293|  33.3k|    struct mp_cmd_ctx *cmd = p;
 6294|  33.3k|    struct MPContext *mpctx = cmd->mpctx;
 6295|  33.3k|    bool backstep = *(bool *)cmd->priv;
 6296|  33.3k|    int frames = backstep ? -1 : cmd->args[0].v.i;
  ------------------
  |  Branch (6296:18): [True: 3.29k, False: 30.0k]
  ------------------
 6297|  33.3k|    int flags = backstep ? 1 : cmd->args[1].v.i;
  ------------------
  |  Branch (6297:17): [True: 3.29k, False: 30.0k]
  ------------------
 6298|       |
 6299|  33.3k|    if (!mpctx->playback_initialized || frames == 0) {
  ------------------
  |  Branch (6299:9): [True: 21.7k, False: 11.6k]
  |  Branch (6299:41): [True: 56, False: 11.5k]
  ------------------
 6300|  21.8k|        cmd->success = false;
 6301|  21.8k|        return;
 6302|  21.8k|    }
 6303|       |
 6304|  11.5k|    if (flags == 1) {
  ------------------
  |  Branch (6304:9): [True: 622, False: 10.9k]
  ------------------
 6305|       |        // frame-step command has on_updown set so it is called on both down
 6306|       |        // and up, but stepping should only be triggered when it matches the
 6307|       |        // emit_on_up flag or if the command is repeated.
 6308|    622|        if (cmd->cmd->repeated || cmd->cmd->is_up == cmd->cmd->emit_on_up)
  ------------------
  |  Branch (6308:13): [True: 0, False: 622]
  |  Branch (6308:35): [True: 622, False: 0]
  ------------------
 6309|    622|            add_step_frame(mpctx, frames, true);
 6310|  10.9k|    } else {
 6311|  10.9k|        if (cmd->cmd->is_up) {
  ------------------
  |  Branch (6311:13): [True: 0, False: 10.9k]
  ------------------
 6312|      0|            if (mpctx->step_frames < 1)
  ------------------
  |  Branch (6312:17): [True: 0, False: 0]
  ------------------
 6313|      0|                set_pause_state(mpctx, true);
 6314|  10.9k|        } else {
 6315|  10.9k|            if (flags == 2)
  ------------------
  |  Branch (6315:17): [True: 0, False: 10.9k]
  ------------------
 6316|      0|                step_frame_mute(mpctx, true);
 6317|  10.9k|            if (cmd->cmd->repeated) {
  ------------------
  |  Branch (6317:17): [True: 0, False: 10.9k]
  ------------------
 6318|      0|                set_pause_state(mpctx, false);
 6319|  10.9k|            } else {
 6320|       |                add_step_frame(mpctx, frames, false);
 6321|  10.9k|            }
 6322|  10.9k|        }
 6323|  10.9k|    }
 6324|  11.5k|}
command.c:cmd_playlist_next_prev:
 6340|  4.94k|{
 6341|  4.94k|    struct mp_cmd_ctx *cmd = p;
 6342|  4.94k|    struct MPContext *mpctx = cmd->mpctx;
 6343|  4.94k|    int dir = *(int *)cmd->priv;
 6344|  4.94k|    int force = cmd->args[0].v.i;
 6345|       |
 6346|  4.94k|    struct playlist_entry *e = mp_next_file(mpctx, dir, force, true);
 6347|  4.94k|    if (!e && !force) {
  ------------------
  |  Branch (6347:9): [True: 2.27k, False: 2.67k]
  |  Branch (6347:15): [True: 2.27k, False: 0]
  ------------------
 6348|  2.27k|        cmd->success = false;
 6349|  2.27k|        return;
 6350|  2.27k|    }
 6351|       |
 6352|  2.67k|    mp_set_playlist_entry(mpctx, e);
 6353|  2.67k|    if (cmd->on_osd & MP_ON_OSD_MSG)
  ------------------
  |  Branch (6353:9): [True: 0, False: 2.67k]
  ------------------
 6354|      0|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
 6355|  2.67k|}
command.c:cmd_playlist_next_prev_playlist:
 6358|     27|{
 6359|     27|    struct mp_cmd_ctx *cmd = p;
 6360|     27|    struct MPContext *mpctx = cmd->mpctx;
 6361|     27|    int direction = *(int *)cmd->priv;
 6362|       |
 6363|     27|    struct playlist_entry *entry =
 6364|     27|        playlist_get_first_in_next_playlist(mpctx->playlist, direction);
 6365|       |
 6366|     27|    if (!entry && mpctx->opts->loop_times != 1 && mpctx->playlist->current) {
  ------------------
  |  Branch (6366:9): [True: 27, False: 0]
  |  Branch (6366:19): [True: 0, False: 27]
  |  Branch (6366:51): [True: 0, False: 0]
  ------------------
 6367|      0|        entry = direction > 0 ? playlist_get_first(mpctx->playlist)
  ------------------
  |  Branch (6367:17): [True: 0, False: 0]
  ------------------
 6368|      0|                              : playlist_get_last(mpctx->playlist);
 6369|       |
 6370|      0|        if (entry && entry->playlist_path &&
  ------------------
  |  Branch (6370:13): [True: 0, False: 0]
  |  Branch (6370:22): [True: 0, False: 0]
  ------------------
 6371|      0|            mpctx->playlist->current->playlist_path &&
  ------------------
  |  Branch (6371:13): [True: 0, False: 0]
  ------------------
 6372|      0|            strcmp(entry->playlist_path,
  ------------------
  |  Branch (6372:13): [True: 0, False: 0]
  ------------------
 6373|      0|                   mpctx->playlist->current->playlist_path) == 0)
 6374|      0|            entry = NULL;
 6375|       |
 6376|      0|        if (direction > 0 && entry && mpctx->opts->loop_times > 1) {
  ------------------
  |  Branch (6376:13): [True: 0, False: 0]
  |  Branch (6376:30): [True: 0, False: 0]
  |  Branch (6376:39): [True: 0, False: 0]
  ------------------
 6377|      0|            mpctx->opts->loop_times--;
 6378|      0|            m_config_notify_change_opt_ptr(mpctx->mconfig,
 6379|      0|                                           &mpctx->opts->loop_times);
 6380|      0|        }
 6381|       |
 6382|      0|        if (direction < 0)
  ------------------
  |  Branch (6382:13): [True: 0, False: 0]
  ------------------
 6383|      0|            entry = playlist_get_first_in_same_playlist(
 6384|      0|                        entry, mpctx->playlist->current->playlist_path);
 6385|      0|    }
 6386|       |
 6387|     27|    if (!entry) {
  ------------------
  |  Branch (6387:9): [True: 27, False: 0]
  ------------------
 6388|     27|        cmd->success = false;
 6389|     27|        return;
 6390|     27|    }
 6391|       |
 6392|      0|    mp_set_playlist_entry(mpctx, entry);
 6393|      0|    if (cmd->on_osd & MP_ON_OSD_MSG)
  ------------------
  |  Branch (6393:9): [True: 0, False: 0]
  ------------------
 6394|      0|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
 6395|      0|}
command.c:cmd_playlist_play_index:
 6398|     29|{
 6399|     29|    struct mp_cmd_ctx *cmd = p;
 6400|     29|    struct MPContext *mpctx = cmd->mpctx;
 6401|     29|    struct playlist *pl = mpctx->playlist;
 6402|     29|    int pos = cmd->args[0].v.i;
 6403|     29|    bool preserve_options = cmd->num_args >= 2 && cmd->args[1].v.b;
  ------------------
  |  Branch (6403:29): [True: 29, False: 0]
  |  Branch (6403:51): [True: 0, False: 29]
  ------------------
 6404|       |
 6405|     29|    if (pos == -2)
  ------------------
  |  Branch (6405:9): [True: 0, False: 29]
  ------------------
 6406|      0|        pos = playlist_entry_to_index(pl, pl->current);
 6407|       |
 6408|     29|    if (preserve_options && pl->current && pos == pl->current->pl_index)
  ------------------
  |  Branch (6408:9): [True: 0, False: 29]
  |  Branch (6408:29): [True: 0, False: 0]
  |  Branch (6408:44): [True: 0, False: 0]
  ------------------
 6409|      0|        pl->current->reloading = true;
 6410|       |
 6411|     29|    mp_set_playlist_entry(mpctx, playlist_entry_from_index(pl, pos));
 6412|     29|    if (cmd->on_osd & MP_ON_OSD_MSG)
  ------------------
  |  Branch (6412:9): [True: 0, False: 29]
  ------------------
 6413|      0|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
 6414|     29|}
command.c:cmd_playlist_shuffle:
 6715|    151|{
 6716|    151|    struct mp_cmd_ctx *cmd = p;
 6717|    151|    struct MPContext *mpctx = cmd->mpctx;
 6718|       |
 6719|    151|    playlist_shuffle(mpctx->playlist);
 6720|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6721|    151|}
command.c:cmd_playlist_unshuffle:
 6724|    109|{
 6725|    109|    struct mp_cmd_ctx *cmd = p;
 6726|    109|    struct MPContext *mpctx = cmd->mpctx;
 6727|       |
 6728|    109|    playlist_unshuffle(mpctx->playlist);
 6729|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6730|    109|}
command.c:cmd_sub_step_seek:
 6417|    189|{
 6418|    189|    struct mp_cmd_ctx *cmd = p;
 6419|    189|    struct MPContext *mpctx = cmd->mpctx;
 6420|    189|    bool step = *(bool *)cmd->priv;
 6421|    189|    int track_ind = cmd->args[1].v.i;
 6422|       |
 6423|    189|    if (!mpctx->playback_initialized) {
  ------------------
  |  Branch (6423:9): [True: 146, False: 43]
  ------------------
 6424|    146|        cmd->success = false;
 6425|    146|        return;
 6426|    146|    }
 6427|       |
 6428|     43|    struct track *track = mpctx->current_track[track_ind][STREAM_SUB];
 6429|     43|    struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (6429:27): [True: 27, False: 16]
  ------------------
 6430|     43|    double refpts = get_current_time(mpctx);
 6431|     43|    if (sub && refpts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|     27|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (6431:9): [True: 27, False: 16]
  |  Branch (6431:16): [True: 27, False: 0]
  ------------------
 6432|     27|        double a[2];
 6433|     27|        a[0] = refpts;
 6434|     27|        a[1] = cmd->args[0].v.i;
 6435|     27|        if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) {
  ------------------
  |  Branch (6435:13): [True: 10, False: 17]
  ------------------
 6436|     10|            if (step) {
  ------------------
  |  Branch (6436:17): [True: 0, False: 10]
  ------------------
 6437|      0|                mpctx->opts->subs_shared->sub_delay[track_ind] -= a[0] - refpts;
 6438|      0|                m_config_notify_change_opt_ptr_notify(mpctx->mconfig,
 6439|      0|                                &mpctx->opts->subs_shared->sub_delay[track_ind]);
 6440|      0|                show_property_osd(
 6441|      0|                    mpctx,
 6442|      0|                    track_ind == 0 ? "sub-delay" : "secondary-sub-delay",
  ------------------
  |  Branch (6442:21): [True: 0, False: 0]
  ------------------
 6443|      0|                    cmd->on_osd);
 6444|     10|            } else {
 6445|       |                // We can easily seek/step to the wrong subtitle line (because
 6446|       |                // video frame PTS and sub PTS rarely match exactly).
 6447|       |                // sub/sd_ass.c adds SUB_SEEK_OFFSET as a workaround, and we
 6448|       |                // need an even bigger offset without a video.
 6449|     10|                if (!mpctx->current_track[0][STREAM_VIDEO] ||
  ------------------
  |  Branch (6449:21): [True: 1, False: 9]
  ------------------
 6450|      9|                    mpctx->current_track[0][STREAM_VIDEO]->image) {
  ------------------
  |  Branch (6450:21): [True: 0, False: 9]
  ------------------
 6451|      1|                    a[0] += SUB_SEEK_WITHOUT_VIDEO_OFFSET - SUB_SEEK_OFFSET;
  ------------------
  |  |   10|      1|#define SUB_SEEK_WITHOUT_VIDEO_OFFSET 0.1
  ------------------
                                  a[0] += SUB_SEEK_WITHOUT_VIDEO_OFFSET - SUB_SEEK_OFFSET;
  ------------------
  |  |    9|      1|#define SUB_SEEK_OFFSET 0.01
  ------------------
 6452|      1|                }
 6453|     10|                mark_seek(mpctx);
 6454|     10|                queue_seek(mpctx, MPSEEK_ABSOLUTE, a[0], MPSEEK_EXACT,
 6455|     10|                           MPSEEK_FLAG_DELAY);
 6456|     10|                set_osd_function(mpctx, (a[0] > refpts) ? OSD_FFW : OSD_REW);
  ------------------
  |  Branch (6456:41): [True: 10, False: 0]
  ------------------
 6457|     10|                if (cmd->seek_bar_osd)
  ------------------
  |  Branch (6457:21): [True: 10, False: 0]
  ------------------
 6458|     10|                    mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
 6459|     10|                if (cmd->seek_msg_osd)
  ------------------
  |  Branch (6459:21): [True: 0, False: 10]
  ------------------
 6460|      0|                    mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
 6461|     10|            }
 6462|     10|        }
 6463|     27|    }
 6464|     43|}
command.c:show_property_osd:
 5253|   141k|{
 5254|   141k|    struct MPOpts *opts = mpctx->opts;
 5255|   141k|    struct property_osd_display disp = {.name = name, .osd_name = name};
 5256|   141k|    struct command_ctx *cmd = mpctx->command_ctx;
 5257|       |
 5258|   141k|    if (!osd_mode)
  ------------------
  |  Branch (5258:9): [True: 45, False: 141k]
  ------------------
 5259|     45|        return;
 5260|       |
 5261|       |    // hwdec is a special case that must wait until video reconfig
 5262|   141k|    if (strcmp(name, "hwdec") == 0 && !cmd->hwdec_osd_mode) {
  ------------------
  |  Branch (5262:9): [True: 20, False: 141k]
  |  Branch (5262:39): [True: 10, False: 10]
  ------------------
 5263|     10|        cmd->hwdec_osd_mode = osd_mode;
 5264|     10|        return;
 5265|     10|    }
 5266|       |
 5267|       |    // look for the command
 5268|  7.31M|    for (const struct property_osd_display *p = property_osd_display; p->name; p++)
  ------------------
  |  Branch (5268:71): [True: 7.22M, False: 94.8k]
  ------------------
 5269|  7.22M|    {
 5270|  7.22M|        if (!strcmp(p->name, name)) {
  ------------------
  |  Branch (5270:13): [True: 46.7k, False: 7.17M]
  ------------------
 5271|  46.7k|            disp = *p;
 5272|  46.7k|            break;
 5273|  46.7k|        }
 5274|  7.22M|    }
 5275|       |
 5276|   141k|    if (osd_mode == MP_ON_OSD_AUTO) {
  ------------------
  |  Branch (5276:9): [True: 118k, False: 22.8k]
  ------------------
 5277|   118k|        osd_mode =
 5278|   118k|            ((disp.msg || disp.osd_name || disp.seek_msg) ? MP_ON_OSD_MSG : 0) |
  ------------------
  |  Branch (5278:15): [True: 7.12k, False: 111k]
  |  Branch (5278:27): [True: 111k, False: 44]
  |  Branch (5278:44): [True: 19, False: 25]
  ------------------
 5279|   118k|            ((disp.osd_progbar || disp.seek_bar) ? MP_ON_OSD_BAR : 0);
  ------------------
  |  Branch (5279:15): [True: 1.30k, False: 117k]
  |  Branch (5279:35): [True: 19, False: 117k]
  ------------------
 5280|   118k|    }
 5281|       |
 5282|   141k|    if (!disp.osd_progbar)
  ------------------
  |  Branch (5282:9): [True: 140k, False: 1.30k]
  ------------------
 5283|   140k|        disp.osd_progbar = ' ';
 5284|       |
 5285|   141k|    if (!disp.osd_name)
  ------------------
  |  Branch (5285:9): [True: 5.88k, False: 135k]
  ------------------
 5286|  5.88k|        disp.osd_name = name;
 5287|       |
 5288|   141k|    if (disp.seek_msg || disp.seek_bar) {
  ------------------
  |  Branch (5288:9): [True: 19, False: 141k]
  |  Branch (5288:26): [True: 0, False: 141k]
  ------------------
 5289|     19|        mpctx->add_osd_seek_info |=
 5290|     19|            (osd_mode & MP_ON_OSD_MSG ? disp.seek_msg : 0) |
  ------------------
  |  Branch (5290:14): [True: 19, False: 0]
  ------------------
 5291|     19|            (osd_mode & MP_ON_OSD_BAR ? disp.seek_bar : 0);
  ------------------
  |  Branch (5291:14): [True: 19, False: 0]
  ------------------
 5292|     19|        return;
 5293|     19|    }
 5294|       |
 5295|   141k|    struct m_option prop = {0};
 5296|   141k|    mp_property_do(name, M_PROPERTY_GET_CONSTRICTED_TYPE, &prop, mpctx);
 5297|   141k|    if ((osd_mode & MP_ON_OSD_BAR)) {
  ------------------
  |  Branch (5297:9): [True: 1.33k, False: 140k]
  ------------------
 5298|  1.33k|        if (prop.type == CONF_TYPE_INT && prop.min < prop.max) {
  ------------------
  |  |  240|  2.67k|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
  |  Branch (5298:13): [True: 0, False: 1.33k]
  |  Branch (5298:43): [True: 0, False: 0]
  ------------------
 5299|      0|            int n = prop.min;
 5300|      0|            if (disp.osd_progbar)
  ------------------
  |  Branch (5300:17): [True: 0, False: 0]
  ------------------
 5301|      0|                n = disp.marker;
 5302|      0|            int i;
 5303|      0|            if (mp_property_do(name, M_PROPERTY_GET, &i, mpctx) > 0)
  ------------------
  |  Branch (5303:17): [True: 0, False: 0]
  ------------------
 5304|      0|                set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, i);
 5305|  1.33k|        } else if (prop.type == CONF_TYPE_FLOAT && prop.min < prop.max) {
  ------------------
  |  |  242|  2.67k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  ------------------
  |  Branch (5305:20): [True: 1.30k, False: 30]
  |  Branch (5305:52): [True: 1.30k, False: 0]
  ------------------
 5306|  1.30k|            float n = prop.min;
 5307|  1.30k|            if (disp.osd_progbar)
  ------------------
  |  Branch (5307:17): [True: 1.30k, False: 0]
  ------------------
 5308|  1.30k|                n = disp.marker;
 5309|  1.30k|            float f;
 5310|  1.30k|            if (mp_property_do(name, M_PROPERTY_GET, &f, mpctx) > 0)
  ------------------
  |  Branch (5310:17): [True: 1.30k, False: 6]
  ------------------
 5311|  1.30k|                set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, f);
 5312|  1.30k|        }
 5313|  1.33k|    }
 5314|       |
 5315|   141k|    if (osd_mode & MP_ON_OSD_MSG) {
  ------------------
  |  Branch (5315:9): [True: 141k, False: 25]
  ------------------
 5316|   141k|        void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   141k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   141k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 5317|       |
 5318|   141k|        const char *msg = disp.msg;
 5319|   141k|        if (!msg)
  ------------------
  |  Branch (5319:13): [True: 111k, False: 29.9k]
  ------------------
 5320|   111k|            msg = talloc_asprintf(tmp, "%s: ${%s}", disp.osd_name, name);
  ------------------
  |  |   52|   111k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   111k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 5321|       |
 5322|   141k|        char *osd_msg = talloc_steal(tmp, mp_property_expand_string(mpctx, msg));
  ------------------
  |  |   38|   141k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   141k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5323|       |
 5324|   141k|        if (osd_msg && osd_msg[0])
  ------------------
  |  Branch (5324:13): [True: 141k, False: 0]
  |  Branch (5324:24): [True: 141k, False: 0]
  ------------------
 5325|   141k|            set_osd_msg(mpctx, 1, opts->osd_duration, "%s", osd_msg);
 5326|       |
 5327|   141k|        talloc_free(tmp);
  ------------------
  |  |   47|   141k|#define talloc_free                     ta_free
  ------------------
 5328|   141k|    }
 5329|   141k|}
command.c:cmd_print_text:
 6467|     74|{
 6468|     74|    struct mp_cmd_ctx *cmd = p;
 6469|     74|    struct MPContext *mpctx = cmd->mpctx;
 6470|       |
 6471|     74|    MP_INFO(mpctx, "%s\n", cmd->args[0].v.s);
  ------------------
  |  |   91|     74|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     74|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 6472|     74|}
command.c:cmd_show_text:
 6475|    910|{
 6476|    910|    struct mp_cmd_ctx *cmd = p;
 6477|    910|    struct MPContext *mpctx = cmd->mpctx;
 6478|    910|    int osd_duration = mpctx->opts->osd_duration;
 6479|       |
 6480|       |    // if no argument supplied use default osd_duration, else <arg> ms.
 6481|    910|    set_osd_msg(mpctx, cmd->args[2].v.i,
 6482|    910|                (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
  ------------------
  |  Branch (6482:18): [True: 800, False: 110]
  ------------------
 6483|    910|                "%s", cmd->args[0].v.s);
 6484|    910|}
command.c:cmd_expand_text:
 6487|     21|{
 6488|     21|    struct mp_cmd_ctx *cmd = p;
 6489|     21|    struct MPContext *mpctx = cmd->mpctx;
 6490|       |
 6491|     21|    cmd->result = (mpv_node){
 6492|     21|        .format = MPV_FORMAT_STRING,
 6493|     21|        .u.string = mp_property_expand_string(mpctx, cmd->args[0].v.s)
 6494|     21|    };
 6495|     21|}
command.c:cmd_expand_path:
 6498|     15|{
 6499|     15|    struct mp_cmd_ctx *cmd = p;
 6500|     15|    struct MPContext *mpctx = cmd->mpctx;
 6501|       |
 6502|     15|    cmd->result = (mpv_node){
 6503|     15|        .format = MPV_FORMAT_STRING,
 6504|       |        .u.string = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s)
 6505|     15|    };
 6506|     15|}
command.c:cmd_normalize_path:
 6509|    761|{
 6510|    761|    struct mp_cmd_ctx *cmd = p;
 6511|    761|    struct MPContext *mpctx = cmd->mpctx;
 6512|       |
 6513|    761|    char *path = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s);
 6514|    761|    cmd->result = (mpv_node){
 6515|    761|        .format = MPV_FORMAT_STRING,
 6516|    761|        .u.string = mp_normalize_path(NULL, path),
 6517|    761|    };
 6518|       |
 6519|    761|    talloc_free(path);
  ------------------
  |  |   47|    761|#define talloc_free                     ta_free
  ------------------
 6520|    761|}
command.c:cmd_escape_ass:
 6523|    160|{
 6524|    160|    struct mp_cmd_ctx *cmd = p;
 6525|    160|    bstr dst = {0};
 6526|       |
 6527|    160|    osd_mangle_ass(&dst, cmd->args[0].v.s, true);
 6528|       |
 6529|    160|    cmd->result = (mpv_node){
 6530|    160|        .format = MPV_FORMAT_STRING,
 6531|    160|        .u.string = dst.len ? (char *)dst.start : talloc_strdup(NULL, ""),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (6531:21): [True: 160, False: 0]
  ------------------
 6532|    160|    };
 6533|    160|}
command.c:cmd_show_progress:
 6753|  8.39k|{
 6754|  8.39k|    struct mp_cmd_ctx *cmd = p;
 6755|  8.39k|    struct MPContext *mpctx = cmd->mpctx;
 6756|       |
 6757|  8.39k|    mpctx->add_osd_seek_info |=
 6758|  8.39k|            (cmd->msg_osd ? OSD_SEEK_INFO_TEXT : 0) |
  ------------------
  |  Branch (6758:14): [True: 8.39k, False: 0]
  ------------------
 6759|  8.39k|            (cmd->bar_osd ? OSD_SEEK_INFO_BAR : 0);
  ------------------
  |  Branch (6759:14): [True: 8.39k, False: 0]
  ------------------
 6760|       |
 6761|       |    // If we got neither (i.e. no-osd) force both like osd-auto.
 6762|  8.39k|    if (!mpctx->add_osd_seek_info)
  ------------------
  |  Branch (6762:9): [True: 0, False: 8.39k]
  ------------------
 6763|      0|        mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT | OSD_SEEK_INFO_BAR;
 6764|       |    mpctx->osd_force_update = true;
 6765|  8.39k|    mp_wakeup_core(mpctx);
 6766|  8.39k|}
command.c:cmd_track_add:
 6769|  31.3k|{
 6770|  31.3k|    struct mp_cmd_ctx *cmd = p;
 6771|  31.3k|    struct MPContext *mpctx = cmd->mpctx;
 6772|  31.3k|    int type = *(int *)cmd->priv;
 6773|  31.3k|    int select = cmd->args[1].v.i & 3;
 6774|  31.3k|    enum track_flags flags = cmd->args[1].v.i & ~3;
 6775|  31.3k|    if (type == STREAM_VIDEO && cmd->args[4].v.b)
  ------------------
  |  Branch (6775:9): [True: 1.06k, False: 30.3k]
  |  Branch (6775:33): [True: 0, False: 1.06k]
  ------------------
 6776|      0|        flags |= TRACK_ATTACHED_PICTURE;
 6777|       |
 6778|  31.3k|    if (mpctx->stop_play) {
  ------------------
  |  Branch (6778:9): [True: 4.84k, False: 26.5k]
  ------------------
 6779|  4.84k|        cmd->success = false;
 6780|  4.84k|        return;
 6781|  4.84k|    }
 6782|       |
 6783|  26.5k|    if (select == 2) {
  ------------------
  |  Branch (6783:9): [True: 0, False: 26.5k]
  ------------------
 6784|      0|        struct track *t = find_track_with_url(mpctx, type, cmd->args[0].v.s);
 6785|      0|        if (t) {
  ------------------
  |  Branch (6785:13): [True: 0, False: 0]
  ------------------
 6786|      0|            if (mpctx->playback_initialized) {
  ------------------
  |  Branch (6786:17): [True: 0, False: 0]
  ------------------
 6787|      0|                mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
  ------------------
  |  |  559|      0|#define FLAG_MARK_SELECTION 1
  ------------------
 6788|      0|                print_track_list(mpctx, "Track switched:");
 6789|      0|            } else {
 6790|      0|                mark_track_selection(mpctx, 0, t->type, t->user_tid);
 6791|      0|            }
 6792|      0|            return;
 6793|      0|        }
 6794|      0|    }
 6795|  26.5k|    int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type,
 6796|  26.5k|                                     cmd->abort->cancel, flags);
 6797|  26.5k|    if (first < 0) {
  ------------------
  |  Branch (6797:9): [True: 22.6k, False: 3.92k]
  ------------------
 6798|  22.6k|        cmd->success = false;
 6799|  22.6k|        return;
 6800|  22.6k|    }
 6801|       |
 6802|  7.84k|    for (int n = first; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (6802:25): [True: 3.92k, False: 3.92k]
  ------------------
 6803|  3.92k|        struct track *t = mpctx->tracks[n];
 6804|  3.92k|        if (select == 1) {
  ------------------
  |  Branch (6804:13): [True: 0, False: 3.92k]
  ------------------
 6805|      0|            t->no_default = true;
 6806|  3.92k|        } else if (n == first) {
  ------------------
  |  Branch (6806:20): [True: 3.92k, False: 0]
  ------------------
 6807|  3.92k|            if (mpctx->playback_initialized) {
  ------------------
  |  Branch (6807:17): [True: 3.89k, False: 29]
  ------------------
 6808|  3.89k|                mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
  ------------------
  |  |  559|  3.89k|#define FLAG_MARK_SELECTION 1
  ------------------
 6809|  3.89k|            } else {
 6810|     29|                mark_track_selection(mpctx, 0, t->type, t->user_tid);
 6811|     29|            }
 6812|  3.92k|        }
 6813|       |
 6814|  3.92k|        flags = 0;
 6815|  3.92k|        bstr lang = mp_guess_lang_from_filename(bstr0(t->external_filename), NULL,
 6816|  3.92k|                    &flags);
 6817|  3.92k|        t->lang = bstrdup0(t, lang);
 6818|  3.92k|        t->hearing_impaired_track = flags & TRACK_HEARING_IMPAIRED;
 6819|  3.92k|        t->forced_track = flags & TRACK_FORCED;
 6820|  3.92k|        t->default_track = flags & TRACK_DEFAULT;
 6821|       |
 6822|  3.92k|        char *title = cmd->args[2].v.s;
 6823|  3.92k|        if (title && title[0])
  ------------------
  |  Branch (6823:13): [True: 22, False: 3.89k]
  |  Branch (6823:22): [True: 19, False: 3]
  ------------------
 6824|     19|            t->title = talloc_strdup(t, title);
  ------------------
  |  |   50|     19|#define talloc_strdup                   ta_xstrdup
  ------------------
 6825|  3.92k|        char *lang_arg = cmd->args[3].v.s;
 6826|  3.92k|        if (lang_arg && lang_arg[0])
  ------------------
  |  Branch (6826:13): [True: 3, False: 3.91k]
  |  Branch (6826:25): [True: 3, False: 0]
  ------------------
 6827|      3|            talloc_replace(t, t->lang, lang_arg);
  ------------------
  |  |   54|      3|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|      3|    do {                                                \
  |  |  |  |  107|      3|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      3|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|      3|        } 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|      3|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6828|  3.92k|    }
 6829|       |
 6830|  3.92k|    if (mpctx->playback_initialized)
  ------------------
  |  Branch (6830:9): [True: 3.89k, False: 29]
  ------------------
 6831|  3.89k|        print_track_list(mpctx, "Track added:");
 6832|  3.92k|}
command.c:cmd_track_remove:
 6835|    259|{
 6836|    259|    struct mp_cmd_ctx *cmd = p;
 6837|    259|    struct MPContext *mpctx = cmd->mpctx;
 6838|    259|    int type = *(int *)cmd->priv;
 6839|       |
 6840|    259|    struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
 6841|    259|    if (!t) {
  ------------------
  |  Branch (6841:9): [True: 213, False: 46]
  ------------------
 6842|    213|        cmd->success = false;
 6843|    213|        return;
 6844|    213|    }
 6845|       |
 6846|     46|    mp_remove_track(mpctx, t);
 6847|     46|    if (mpctx->playback_initialized)
  ------------------
  |  Branch (6847:9): [True: 46, False: 0]
  ------------------
 6848|     46|        print_track_list(mpctx, "Track removed:");
 6849|     46|}
command.c:cmd_track_reload:
 6852|  20.7k|{
 6853|  20.7k|    struct mp_cmd_ctx *cmd = p;
 6854|  20.7k|    struct MPContext *mpctx = cmd->mpctx;
 6855|  20.7k|    int type = *(int *)cmd->priv;
 6856|       |
 6857|  20.7k|    if (!mpctx->playback_initialized) {
  ------------------
  |  Branch (6857:9): [True: 9.72k, False: 11.0k]
  ------------------
 6858|  9.72k|        MP_ERR(mpctx, "Cannot reload while not initialized.\n");
  ------------------
  |  |   89|  9.72k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.72k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 6859|  9.72k|        cmd->success = false;
 6860|  9.72k|        return;
 6861|  9.72k|    }
 6862|       |
 6863|  11.0k|    struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
 6864|  11.0k|    int nt_num = -1;
 6865|  11.0k|    char *lang = NULL;
 6866|       |
 6867|  11.0k|    if (t && t->is_external && t->external_filename) {
  ------------------
  |  Branch (6867:9): [True: 10.6k, False: 418]
  |  Branch (6867:14): [True: 817, False: 9.81k]
  |  Branch (6867:32): [True: 817, False: 0]
  ------------------
 6868|    817|        char *filename = talloc_strdup(NULL, t->external_filename);
  ------------------
  |  |   50|    817|#define talloc_strdup                   ta_xstrdup
  ------------------
 6869|    817|        lang = talloc_steal(NULL, t->lang);
  ------------------
  |  |   38|    817|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    817|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 6870|    817|        enum track_flags flags = 0;
 6871|    817|        flags |= t->attached_picture ? TRACK_ATTACHED_PICTURE : 0;
  ------------------
  |  Branch (6871:18): [True: 0, False: 817]
  ------------------
 6872|    817|        flags |= t->hearing_impaired_track ? TRACK_HEARING_IMPAIRED : 0;
  ------------------
  |  Branch (6872:18): [True: 0, False: 817]
  ------------------
 6873|    817|        flags |= t->visual_impaired_track ? TRACK_VISUAL_IMPAIRED : 0;
  ------------------
  |  Branch (6873:18): [True: 0, False: 817]
  ------------------
 6874|    817|        flags |= t->forced_track ? TRACK_FORCED : 0;
  ------------------
  |  Branch (6874:18): [True: 0, False: 817]
  ------------------
 6875|    817|        flags |= t->default_track ? TRACK_DEFAULT : 0;
  ------------------
  |  Branch (6875:18): [True: 0, False: 817]
  ------------------
 6876|    817|        flags |= t->commentary_track ? TRACK_COMMENTARY : 0;
  ------------------
  |  Branch (6876:18): [True: 0, False: 817]
  ------------------
 6877|    817|        mp_remove_track(mpctx, t);
 6878|    817|        nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel,
 6879|    817|                                      flags);
 6880|    817|        talloc_free(filename);
  ------------------
  |  |   47|    817|#define talloc_free                     ta_free
  ------------------
 6881|    817|    }
 6882|       |
 6883|  11.0k|    if (nt_num < 0) {
  ------------------
  |  Branch (6883:9): [True: 10.2k, False: 812]
  ------------------
 6884|  10.2k|        cmd->success = false;
 6885|  10.2k|        talloc_free(lang);
  ------------------
  |  |   47|  10.2k|#define talloc_free                     ta_free
  ------------------
 6886|  10.2k|        return;
 6887|  10.2k|    }
 6888|       |
 6889|    812|    struct track *nt = mpctx->tracks[nt_num];
 6890|       |
 6891|    812|    if (nt->lang) {
  ------------------
  |  Branch (6891:9): [True: 0, False: 812]
  ------------------
 6892|      0|        talloc_free(lang);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 6893|    812|    } else {
 6894|    812|        nt->lang = talloc_steal(nt, lang);
  ------------------
  |  |   38|    812|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    812|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 6895|    812|    }
 6896|       |
 6897|    812|    mp_switch_track(mpctx, nt->type, nt, 0);
 6898|    812|    print_track_list(mpctx, "Reloaded:");
 6899|    812|}
command.c:cmd_rescan_external_files:
 6902|    309|{
 6903|    309|    struct mp_cmd_ctx *cmd = p;
 6904|    309|    struct MPContext *mpctx = cmd->mpctx;
 6905|       |
 6906|    309|    if (mpctx->stop_play) {
  ------------------
  |  Branch (6906:9): [True: 122, False: 187]
  ------------------
 6907|    122|        cmd->success = false;
 6908|    122|        return;
 6909|    122|    }
 6910|       |
 6911|    187|    autoload_external_files(mpctx, cmd->abort->cancel);
 6912|    187|    if (!cmd->args[0].v.i && mpctx->playback_initialized) {
  ------------------
  |  Branch (6912:9): [True: 187, False: 0]
  |  Branch (6912:30): [True: 180, False: 7]
  ------------------
 6913|       |        // somewhat fuzzy and not ideal
 6914|    180|        struct track *a = select_default_track(mpctx, 0, STREAM_AUDIO);
 6915|    180|        if (a && a->is_external)
  ------------------
  |  Branch (6915:13): [True: 161, False: 19]
  |  Branch (6915:18): [True: 0, False: 161]
  ------------------
 6916|      0|            mp_switch_track(mpctx, STREAM_AUDIO, a, 0);
 6917|    180|        struct track *s = select_default_track(mpctx, 0, STREAM_SUB);
 6918|    180|        if (s && s->is_external)
  ------------------
  |  Branch (6918:13): [True: 89, False: 91]
  |  Branch (6918:18): [True: 89, False: 0]
  ------------------
 6919|     89|            mp_switch_track(mpctx, STREAM_SUB, s, 0);
 6920|       |
 6921|    180|        print_track_list(mpctx, "Track list:");
 6922|    180|    }
 6923|    187|}
command.c:cmd_loadfile:
 6569|  13.4k|{
 6570|  13.4k|    struct mp_cmd_ctx *cmd = p;
 6571|  13.4k|    struct MPContext *mpctx = cmd->mpctx;
 6572|  13.4k|    char *filename = cmd->args[0].v.s;
 6573|  13.4k|    int action_flag = cmd->args[1].v.i;
 6574|  13.4k|    int insert_at_idx = cmd->args[2].v.i;
 6575|       |
 6576|  13.4k|    struct load_action action = get_load_action(mpctx, action_flag);
 6577|       |
 6578|  13.4k|    if (action.type == LOAD_TYPE_REPLACE)
  ------------------
  |  Branch (6578:9): [True: 13.4k, False: 0]
  ------------------
 6579|  13.4k|        playlist_clear(mpctx->playlist);
 6580|       |
 6581|  13.4k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 6582|  13.4k|    struct playlist_entry *entry = playlist_entry_new(path);
 6583|  13.4k|    talloc_free(path);
  ------------------
  |  |   47|  13.4k|#define talloc_free                     ta_free
  ------------------
 6584|  13.4k|    if (cmd->args[3].v.str_list) {
  ------------------
  |  Branch (6584:9): [True: 0, False: 13.4k]
  ------------------
 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|  13.4k|    struct playlist_entry *at = get_insert_entry(mpctx, &action, insert_at_idx);
 6591|  13.4k|    playlist_insert_at(mpctx->playlist, entry, at);
 6592|       |
 6593|  13.4k|    struct mpv_node *res = &cmd->result;
 6594|  13.4k|    node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 6595|  13.4k|    node_map_add_int64(res, "playlist_entry_id", entry->id);
 6596|       |
 6597|  13.4k|    if (action.type == LOAD_TYPE_REPLACE || (action.play && !mpctx->playlist->current)) {
  ------------------
  |  Branch (6597:9): [True: 13.4k, False: 0]
  |  Branch (6597:46): [True: 0, False: 0]
  |  Branch (6597:61): [True: 0, False: 0]
  ------------------
 6598|  13.4k|        if (mpctx->opts->position_save_on_quit) // requested in issue #1148
  ------------------
  |  Branch (6598:13): [True: 8, False: 13.4k]
  ------------------
 6599|      8|            mp_write_watch_later_conf(mpctx);
 6600|  13.4k|        mp_set_playlist_entry(mpctx, entry);
 6601|  13.4k|    }
 6602|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6603|  13.4k|    mp_wakeup_core(mpctx);
 6604|  13.4k|}
command.c:get_load_action:
 6536|  53.0k|{
 6537|  53.0k|    int type = action_flag & 3;
 6538|  53.0k|    bool play = (action_flag >> 3) & 1;
 6539|  53.0k|    switch (type) {
 6540|  53.0k|    case 0:
  ------------------
  |  Branch (6540:5): [True: 53.0k, False: 0]
  ------------------
 6541|  53.0k|        return (struct load_action){LOAD_TYPE_REPLACE, .play = play};
 6542|      0|    case 1:
  ------------------
  |  Branch (6542:5): [True: 0, False: 53.0k]
  ------------------
 6543|      0|        return (struct load_action){LOAD_TYPE_APPEND, .play = play};
 6544|      0|    case 2:
  ------------------
  |  Branch (6544:5): [True: 0, False: 53.0k]
  ------------------
 6545|      0|        return (struct load_action){LOAD_TYPE_INSERT_NEXT, .play = play};
 6546|      0|    case 3:
  ------------------
  |  Branch (6546:5): [True: 0, False: 53.0k]
  ------------------
 6547|      0|        return (struct load_action){LOAD_TYPE_INSERT_AT, .play = play};
 6548|      0|    default: // default: replace
  ------------------
  |  Branch (6548:5): [True: 0, False: 53.0k]
  ------------------
 6549|       |        return (struct load_action){LOAD_TYPE_REPLACE, .play = true};
 6550|  53.0k|    }
 6551|  53.0k|}
command.c:get_insert_entry:
 6555|  17.8k|{
 6556|  17.8k|    switch (action->type) {
 6557|      0|    case LOAD_TYPE_INSERT_NEXT:
  ------------------
  |  Branch (6557:5): [True: 0, False: 17.8k]
  ------------------
 6558|      0|        return playlist_get_next(mpctx->playlist, +1);
 6559|      0|    case LOAD_TYPE_INSERT_AT:
  ------------------
  |  Branch (6559:5): [True: 0, False: 17.8k]
  ------------------
 6560|      0|        return playlist_entry_from_index(mpctx->playlist, insert_at_idx);
 6561|  17.8k|    case LOAD_TYPE_REPLACE:
  ------------------
  |  Branch (6561:5): [True: 17.8k, False: 0]
  ------------------
 6562|  17.8k|    case LOAD_TYPE_APPEND:
  ------------------
  |  Branch (6562:5): [True: 0, False: 17.8k]
  ------------------
 6563|  17.8k|    default:
  ------------------
  |  Branch (6563:5): [True: 0, False: 17.8k]
  ------------------
 6564|       |        return NULL;
 6565|  17.8k|    }
 6566|  17.8k|}
command.c:cmd_loadlist:
 6607|  39.5k|{
 6608|  39.5k|    struct mp_cmd_ctx *cmd = p;
 6609|  39.5k|    struct MPContext *mpctx = cmd->mpctx;
 6610|  39.5k|    char *filename = cmd->args[0].v.s;
 6611|  39.5k|    int action_flag = cmd->args[1].v.i;
 6612|  39.5k|    int insert_at_idx = cmd->args[2].v.i;
 6613|       |
 6614|  39.5k|    struct load_action action = get_load_action(mpctx, action_flag);
 6615|       |
 6616|  39.5k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 6617|  39.5k|    struct playlist *pl = playlist_parse_file(path, cmd->abort->cancel,
 6618|  39.5k|                                              mpctx->global);
 6619|  39.5k|    talloc_free(path);
  ------------------
  |  |   47|  39.5k|#define talloc_free                     ta_free
  ------------------
 6620|       |
 6621|  39.5k|    if (pl) {
  ------------------
  |  Branch (6621:9): [True: 4.41k, False: 35.1k]
  ------------------
 6622|  4.41k|        prepare_playlist(mpctx, pl, true);
 6623|  4.41k|        struct playlist_entry *new = pl->current;
 6624|  4.41k|        if (action.type == LOAD_TYPE_REPLACE)
  ------------------
  |  Branch (6624:13): [True: 4.41k, False: 0]
  ------------------
 6625|  4.41k|            playlist_clear(mpctx->playlist);
 6626|  4.41k|        struct playlist_entry *first = playlist_entry_from_index(pl, 0);
 6627|  4.41k|        int num_entries = pl->num_entries;
 6628|       |
 6629|  4.41k|        struct playlist_entry *at = get_insert_entry(mpctx, &action, insert_at_idx);
 6630|  4.41k|        if (at == NULL) {
  ------------------
  |  Branch (6630:13): [True: 4.41k, False: 0]
  ------------------
 6631|  4.41k|            playlist_append_entries(mpctx->playlist, pl);
 6632|  4.41k|        } else {
 6633|      0|            int at_index = playlist_entry_to_index(mpctx->playlist, at);
 6634|      0|            playlist_transfer_entries_to(mpctx->playlist, at_index, pl);
 6635|      0|        }
 6636|  4.41k|        talloc_free(pl);
  ------------------
  |  |   47|  4.41k|#define talloc_free                     ta_free
  ------------------
 6637|       |
 6638|  4.41k|        if (!new)
  ------------------
  |  Branch (6638:13): [True: 4.31k, False: 98]
  ------------------
 6639|  4.31k|            new = playlist_get_first(mpctx->playlist);
 6640|       |
 6641|  4.41k|        if ((action.type == LOAD_TYPE_REPLACE ||
  ------------------
  |  Branch (6641:14): [True: 4.41k, False: 0]
  ------------------
 6642|  4.41k|            (action.play && !mpctx->playlist->current)) && new) {
  ------------------
  |  Branch (6642:14): [True: 0, False: 0]
  |  Branch (6642:29): [True: 0, False: 0]
  |  Branch (6642:60): [True: 98, False: 4.31k]
  ------------------
 6643|     98|            mp_set_playlist_entry(mpctx, new);
 6644|     98|        }
 6645|       |
 6646|  4.41k|        struct mpv_node *res = &cmd->result;
 6647|  4.41k|        node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 6648|  4.41k|        if (num_entries) {
  ------------------
  |  Branch (6648:13): [True: 98, False: 4.31k]
  ------------------
 6649|     98|            node_map_add_int64(res, "playlist_entry_id", first->id);
 6650|     98|            node_map_add_int64(res, "num_entries", num_entries);
 6651|     98|        }
 6652|       |
 6653|  4.41k|        mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6654|  4.41k|        mp_wakeup_core(mpctx);
 6655|  35.1k|    } else {
 6656|  35.1k|        MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
  ------------------
  |  |   89|  35.1k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  35.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 6657|       |        cmd->success = false;
 6658|  35.1k|    }
 6659|  39.5k|}
command.c:cmd_playlist_clear:
 6662|    332|{
 6663|    332|    struct mp_cmd_ctx *cmd = p;
 6664|    332|    struct MPContext *mpctx = cmd->mpctx;
 6665|       |
 6666|       |    // Supposed to clear the playlist, except the currently played item.
 6667|    332|    if (mpctx->playlist->current_was_replaced)
  ------------------
  |  Branch (6667:9): [True: 0, False: 332]
  ------------------
 6668|      0|        mpctx->playlist->current = NULL;
 6669|    332|    playlist_clear_except_current(mpctx->playlist);
 6670|       |    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 6671|    332|    mp_wakeup_core(mpctx);
 6672|    332|}
command.c:cmd_run:
 6926|  8.13k|{
 6927|  8.13k|    struct mp_cmd_ctx *cmd = p;
 6928|  8.13k|    struct MPContext *mpctx = cmd->mpctx;
 6929|  8.13k|    char **args = talloc_zero_array(NULL, char *, cmd->num_args + 1);
  ------------------
  |  |   30|  8.13k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  8.13k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  8.13k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6930|  22.7k|    for (int n = 0; n < cmd->num_args; n++)
  ------------------
  |  Branch (6930:21): [True: 14.6k, False: 8.13k]
  ------------------
 6931|  14.6k|        args[n] = cmd->args[n].v.s;
 6932|  8.13k|    mp_msg_flush_status_line(mpctx->log, true);
 6933|  8.13k|    struct mp_subprocess_opts opts = {
 6934|  8.13k|        .exe = args[0],
 6935|  8.13k|        .args = args,
 6936|  8.13k|        .fds = { {0, .src_fd = 0}, {1, .src_fd = 1}, {2, .src_fd = 2} },
 6937|  8.13k|        .num_fds = 3,
 6938|  8.13k|        .detach = true,
 6939|  8.13k|    };
 6940|  8.13k|    struct mp_subprocess_result res;
 6941|  8.13k|    mp_subprocess(mpctx->log, &opts, &res);
 6942|  8.13k|    talloc_free(args);
  ------------------
  |  |   47|  8.13k|#define talloc_free                     ta_free
  ------------------
 6943|  8.13k|}
command.c:cmd_subprocess:
 6971|    896|{
 6972|    896|    struct mp_cmd_ctx *cmd = p;
 6973|    896|    struct MPContext *mpctx = cmd->mpctx;
 6974|    896|    char **args = cmd->args[0].v.str_list;
 6975|    896|    bool playback_only = cmd->args[1].v.b;
 6976|    896|    bool detach = cmd->args[5].v.b;
 6977|    896|    char **env = cmd->args[6].v.str_list;
 6978|    896|    bstr stdin_data = bstr0(cmd->args[7].v.s);
 6979|    896|    bool passthrough_stdin = cmd->args[8].v.b;
 6980|       |
 6981|    896|    if (env && !env[0])
  ------------------
  |  Branch (6981:9): [True: 36, False: 860]
  |  Branch (6981:16): [True: 0, False: 36]
  ------------------
 6982|      0|        env = NULL; // do not actually set an empty environment
 6983|       |
 6984|    896|    if (!args || !args[0]) {
  ------------------
  |  Branch (6984:9): [True: 0, False: 896]
  |  Branch (6984:18): [True: 0, False: 896]
  ------------------
 6985|      0|        MP_ERR(mpctx, "program name missing\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__)
  |  |  ------------------
  ------------------
 6986|      0|        cmd->success = false;
 6987|      0|        return;
 6988|      0|    }
 6989|       |
 6990|    896|    if (stdin_data.len && passthrough_stdin) {
  ------------------
  |  Branch (6990:9): [True: 26, False: 870]
  |  Branch (6990:27): [True: 7, False: 19]
  ------------------
 6991|      7|        MP_ERR(mpctx, "both stdin_data and passthrough_stdin set\n");
  ------------------
  |  |   89|      7|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      7|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 6992|      7|        cmd->success = false;
 6993|      7|        return;
 6994|      7|    }
 6995|       |
 6996|    889|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|    889|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|    889|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 6997|       |
 6998|    889|    struct mp_log *fdlog = mp_log_new(tmp, mpctx->log, cmd->cmd->sender);
 6999|    889|    struct subprocess_fd_ctx fdctx[3];
 7000|  3.55k|    for (int fd = 0; fd < 3; fd++) {
  ------------------
  |  Branch (7000:22): [True: 2.66k, False: 889]
  ------------------
 7001|  2.66k|        fdctx[fd] = (struct subprocess_fd_ctx) {
 7002|  2.66k|            .log = fdlog,
 7003|  2.66k|            .talloc_ctx = tmp,
 7004|  2.66k|            .max_size = cmd->args[2].v.i,
 7005|  2.66k|            .msgl = fd == 2 ? MSGL_ERR : MSGL_INFO,
  ------------------
  |  Branch (7005:21): [True: 889, False: 1.77k]
  ------------------
 7006|  2.66k|        };
 7007|  2.66k|    }
 7008|    889|    fdctx[1].capture = cmd->args[3].v.b;
 7009|    889|    fdctx[2].capture = cmd->args[4].v.b;
 7010|       |
 7011|    889|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|    889|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 7012|    889|    cmd->abort->coupled_to_playback = playback_only;
 7013|    889|    mp_abort_recheck_locked(mpctx, cmd->abort);
 7014|    889|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|    889|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 7015|       |
 7016|    889|    mp_core_unlock(mpctx);
 7017|       |
 7018|    889|    struct mp_subprocess_opts opts = {
 7019|    889|        .exe = args[0],
 7020|    889|        .args = args,
 7021|    889|        .env = env,
 7022|    889|        .cancel = cmd->abort->cancel,
 7023|    889|        .detach = detach,
 7024|    889|        .fds = {
 7025|    889|            {
 7026|    889|                .fd = 0, // stdin
 7027|    889|                .src_fd = passthrough_stdin ? 0 : -1,
  ------------------
  |  Branch (7027:27): [True: 0, False: 889]
  ------------------
 7028|    889|            },
 7029|    889|        },
 7030|    889|        .num_fds = 1,
 7031|    889|    };
 7032|       |
 7033|       |    // stdout, stderr
 7034|  2.66k|    for (int fd = 1; fd < 3; fd++) {
  ------------------
  |  Branch (7034:22): [True: 1.77k, False: 889]
  ------------------
 7035|  1.77k|        bool capture = fdctx[fd].capture || !detach;
  ------------------
  |  Branch (7035:24): [True: 75, False: 1.70k]
  |  Branch (7035:45): [True: 1.70k, False: 0]
  ------------------
 7036|  1.77k|        opts.fds[opts.num_fds++] = (struct mp_subprocess_fd){
 7037|  1.77k|            .fd = fd,
 7038|  1.77k|            .src_fd = capture ? -1 : fd,
  ------------------
  |  Branch (7038:23): [True: 1.77k, False: 0]
  ------------------
 7039|  1.77k|            .on_read = capture ? subprocess_read : NULL,
  ------------------
  |  Branch (7039:24): [True: 1.77k, False: 0]
  ------------------
 7040|  1.77k|            .on_read_ctx = &fdctx[fd],
 7041|  1.77k|        };
 7042|  1.77k|    }
 7043|       |    // stdin
 7044|    889|    if (stdin_data.len) {
  ------------------
  |  Branch (7044:9): [True: 19, False: 870]
  ------------------
 7045|     19|        opts.fds[0] = (struct mp_subprocess_fd){
 7046|     19|            .fd = 0,
 7047|     19|            .src_fd = -1,
 7048|     19|            .on_write = subprocess_write,
 7049|     19|            .on_write_ctx = &fdctx[0],
 7050|     19|            .write_buf = &stdin_data,
 7051|     19|        };
 7052|     19|    }
 7053|       |
 7054|    889|    struct mp_subprocess_result sres;
 7055|    889|    mp_subprocess(fdlog, &opts, &sres);
 7056|    889|    int status = sres.exit_status;
 7057|    889|    char *error = NULL;
 7058|    889|    if (sres.error < 0) {
  ------------------
  |  Branch (7058:9): [True: 889, False: 0]
  ------------------
 7059|    889|        error = (char *)mp_subprocess_err_str(sres.error);
 7060|    889|        status = sres.error;
 7061|    889|    }
 7062|       |
 7063|    889|    mp_core_lock(mpctx);
 7064|       |
 7065|    889|    struct mpv_node *res = &cmd->result;
 7066|    889|    node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 7067|    889|    node_map_add_int64(res, "status", status);
 7068|    889|    node_map_add_flag(res, "killed_by_us", status == MP_SUBPROCESS_EKILLED_BY_US);
  ------------------
  |  |   75|    889|#define MP_SUBPROCESS_EKILLED_BY_US     -2  // mp_cancel was triggered
  ------------------
 7069|    889|    node_map_add_string(res, "error_string", error ? error : "");
  ------------------
  |  Branch (7069:46): [True: 889, False: 0]
  ------------------
 7070|    889|    const char *sname[] = {NULL, "stdout", "stderr"};
 7071|  2.66k|    for (int fd = 1; fd < 3; fd++) {
  ------------------
  |  Branch (7071:22): [True: 1.77k, False: 889]
  ------------------
 7072|  1.77k|        if (!fdctx[fd].capture)
  ------------------
  |  Branch (7072:13): [True: 1.70k, False: 75]
  ------------------
 7073|  1.70k|            continue;
 7074|     75|        struct mpv_byte_array *ba =
 7075|     75|            node_map_add(res, sname[fd], MPV_FORMAT_BYTE_ARRAY)->u.ba;
 7076|     75|        *ba = (struct mpv_byte_array){
 7077|     75|            .data = talloc_steal(ba, fdctx[fd].output.start),
  ------------------
  |  |   38|     75|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|     75|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 7078|     75|            .size = fdctx[fd].output.len,
 7079|     75|        };
 7080|     75|    }
 7081|       |
 7082|    889|    talloc_free(tmp);
  ------------------
  |  |   47|    889|#define talloc_free                     ta_free
  ------------------
 7083|    889|}
command.c:cmd_set:
 6168|     77|{
 6169|     77|    struct mp_cmd_ctx *cmd = p;
 6170|       |
 6171|     77|    change_property_cmd(cmd, cmd->args[0].v.s,
 6172|     77|                        M_PROPERTY_SET_STRING, cmd->args[1].v.s);
 6173|     77|}
command.c:change_property_cmd:
 5766|   170k|{
 5767|   170k|    struct m_property *prop = NULL;
 5768|   170k|    if (cmd->cmd->coalesce) {
  ------------------
  |  Branch (5768:9): [True: 0, False: 170k]
  ------------------
 5769|      0|        struct command_ctx *ctx = cmd->mpctx->command_ctx;
 5770|      0|        prop = m_property_list_find(&ctx->properties, name);
 5771|      0|        if (prop)
  ------------------
  |  Branch (5771:13): [True: 0, False: 0]
  ------------------
 5772|      0|            prop->coalesce = true;
 5773|      0|    }
 5774|   170k|    int r = mp_property_do(name, action, arg, cmd->mpctx);
 5775|   170k|    show_property_status(cmd, name, r);
 5776|   170k|    if (prop)
  ------------------
  |  Branch (5776:9): [True: 0, False: 170k]
  ------------------
 5777|      0|        prop->coalesce = false;
 5778|   170k|}
command.c:show_property_status:
 5744|   170k|{
 5745|   170k|    struct MPContext *mpctx = cmd->mpctx;
 5746|   170k|    struct MPOpts *opts = mpctx->opts;
 5747|   170k|    int osd_duration = opts->osd_duration;
 5748|   170k|    int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
  ------------------
  |  Branch (5748:16): [True: 170k, False: 57]
  ------------------
 5749|       |
 5750|   170k|    if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
  ------------------
  |  Branch (5750:9): [True: 101k, False: 69.2k]
  |  Branch (5750:31): [True: 1.82k, False: 67.4k]
  ------------------
 5751|   102k|        show_property_osd(mpctx, name, cmd->on_osd);
 5752|   102k|        if (r == M_PROPERTY_UNAVAILABLE)
  ------------------
  |  Branch (5752:13): [True: 1.82k, False: 101k]
  ------------------
 5753|  1.82k|            cmd->success = false;
 5754|   102k|    } else if (r == M_PROPERTY_UNKNOWN) {
  ------------------
  |  Branch (5754:16): [True: 63.7k, False: 3.73k]
  ------------------
 5755|  63.7k|        set_osd_msg(mpctx, osdl, osd_duration, "Unknown property: '%s'", name);
 5756|  63.7k|        cmd->success = false;
 5757|  63.7k|    } else if (r <= 0) {
  ------------------
  |  Branch (5757:16): [True: 3.73k, False: 0]
  ------------------
 5758|  3.73k|        set_osd_msg(mpctx, osdl, osd_duration, "Failed to set property '%s'",
 5759|  3.73k|                    name);
 5760|       |        cmd->success = false;
 5761|  3.73k|    }
 5762|   170k|}
command.c:cmd_del:
 6176|    877|{
 6177|    877|    struct mp_cmd_ctx *cmd = p;
 6178|    877|    struct MPContext *mpctx = cmd->mpctx;
 6179|    877|    const char *name = cmd->args[0].v.s;
 6180|    877|    int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
  ------------------
  |  Branch (6180:16): [True: 877, False: 0]
  ------------------
 6181|    877|    int osd_duration = mpctx->opts->osd_duration;
 6182|       |
 6183|    877|    int r = mp_property_do(name, M_PROPERTY_DELETE, NULL, mpctx);
 6184|       |
 6185|    877|    if (r == M_PROPERTY_OK) {
  ------------------
  |  Branch (6185:9): [True: 0, False: 877]
  ------------------
 6186|      0|        set_osd_msg(mpctx, osdl, osd_duration, "Deleted property: '%s'", name);
 6187|      0|        cmd->success = true;
 6188|    877|    } else if (r == M_PROPERTY_UNKNOWN) {
  ------------------
  |  Branch (6188:16): [True: 585, False: 292]
  ------------------
 6189|    585|        set_osd_msg(mpctx, osdl, osd_duration, "Unknown property: '%s'", name);
 6190|    585|        cmd->success = false;
 6191|    585|    } else if (r <= 0) {
  ------------------
  |  Branch (6191:16): [True: 292, False: 0]
  ------------------
 6192|    292|        set_osd_msg(mpctx, osdl, osd_duration, "Failed to set property '%s'",
 6193|    292|                    name);
 6194|       |        cmd->success = false;
 6195|    292|    }
 6196|    877|}
command.c:cmd_change_list:
 6199|     31|{
 6200|     31|    struct mp_cmd_ctx *cmd = p;
 6201|     31|    struct MPContext *mpctx = cmd->mpctx;
 6202|     31|    char *name = cmd->args[0].v.s;
 6203|     31|    char *op = cmd->args[1].v.s;
 6204|     31|    char *value = cmd->args[2].v.s;
 6205|     31|    int osd_duration = mpctx->opts->osd_duration;
 6206|     31|    int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
  ------------------
  |  Branch (6206:16): [True: 31, False: 0]
  ------------------
 6207|       |
 6208|     31|    struct m_option prop = {0};
 6209|     31|    if (mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0) {
  ------------------
  |  Branch (6209:9): [True: 20, False: 11]
  ------------------
 6210|     20|        set_osd_msg(mpctx, osdl, osd_duration, "Unknown option: '%s'", name);
 6211|     20|        cmd->success = false;
 6212|     20|        return;
 6213|     20|    }
 6214|       |
 6215|     11|    const struct m_option_type *type = prop.type;
 6216|     11|    bool found = false;
 6217|     99|    for (int i = 0; type->actions && type->actions[i].name; i++) {
  ------------------
  |  Branch (6217:21): [True: 99, False: 0]
  |  Branch (6217:38): [True: 88, False: 11]
  ------------------
 6218|     88|        const struct m_option_action *action = &type->actions[i];
 6219|     88|        if (strcmp(action->name, op) == 0)
  ------------------
  |  Branch (6219:13): [True: 0, False: 88]
  ------------------
 6220|      0|            found = true;
 6221|     88|    }
 6222|     11|    if (!found) {
  ------------------
  |  Branch (6222:9): [True: 11, False: 0]
  ------------------
 6223|     11|        set_osd_msg(mpctx, osdl, osd_duration, "Unknown action: '%s'", op);
 6224|     11|        cmd->success = false;
 6225|     11|        return;
 6226|     11|    }
 6227|       |
 6228|      0|    union m_option_value val = m_option_value_default;
 6229|      0|    if (mp_property_do(name, M_PROPERTY_GET, &val, mpctx) <= 0) {
  ------------------
  |  Branch (6229:9): [True: 0, False: 0]
  ------------------
 6230|      0|        set_osd_msg(mpctx, osdl, osd_duration, "Could not read: '%s'", name);
 6231|      0|        cmd->success = false;
 6232|      0|        return;
 6233|      0|    }
 6234|       |
 6235|      0|    char *optname = mp_tprintf(80, "%s-%s", name, op); // the dirty truth
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 6236|      0|    int r = m_option_parse(mpctx->log, &prop, bstr0(optname), bstr0(value), &val);
 6237|      0|    if (r >= 0 && mp_property_do(name, M_PROPERTY_SET, &val, mpctx) <= 0)
  ------------------
  |  Branch (6237:9): [True: 0, False: 0]
  |  Branch (6237:19): [True: 0, False: 0]
  ------------------
 6238|      0|        r = -1;
 6239|      0|    m_option_free(&prop, &val);
 6240|      0|    if (r < 0) {
  ------------------
  |  Branch (6240:9): [True: 0, False: 0]
  ------------------
 6241|      0|        set_osd_msg(mpctx, osdl, osd_duration,
 6242|      0|                    "Failed setting option: '%s'", name);
 6243|      0|        cmd->success = false;
 6244|      0|        return;
 6245|      0|    }
 6246|       |
 6247|      0|    show_property_osd(mpctx, name, cmd->on_osd);
 6248|      0|}
command.c:cmd_add_cycle:
 6251|   168k|{
 6252|   168k|    struct mp_cmd_ctx *cmd = p;
 6253|   168k|    struct MPContext *mpctx = cmd->mpctx;
 6254|   168k|    bool is_cycle = !!cmd->priv;
 6255|       |
 6256|   168k|    char *property = cmd->args[0].v.s;
 6257|   168k|    if (cmd->cmd->repeated && !check_property_autorepeat(property, mpctx) &&
  ------------------
  |  Branch (6257:9): [True: 0, False: 168k]
  |  Branch (6257:31): [True: 0, False: 0]
  ------------------
 6258|      0|        !(cmd->cmd->flags & MP_ALLOW_REPEAT)  /* "repeatable" prefix */ )
  ------------------
  |  Branch (6258:9): [True: 0, False: 0]
  ------------------
 6259|      0|    {
 6260|      0|        MP_VERBOSE(mpctx, "Dropping command '%s' from auto-repeated key.\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__)
  |  |  ------------------
  ------------------
 6261|      0|                   cmd->cmd->original);
 6262|      0|        return;
 6263|      0|    }
 6264|       |
 6265|   168k|    double scale = 1;
 6266|   168k|    int scale_units = cmd->cmd->scale_units;
 6267|   168k|    if (check_property_scalable(property, mpctx)) {
  ------------------
  |  Branch (6267:9): [True: 84.5k, False: 84.3k]
  ------------------
 6268|  84.5k|        scale = cmd->cmd->scale;
 6269|  84.5k|        scale_units = 1;
 6270|  84.5k|    }
 6271|       |
 6272|   269k|    for (int i = 0; i < scale_units; i++) {
  ------------------
  |  Branch (6272:21): [True: 168k, False: 100k]
  ------------------
 6273|   168k|        struct m_property_switch_arg s = {
 6274|   168k|            .inc = cmd->args[1].v.d * scale,
 6275|   168k|            .wrap = is_cycle,
 6276|   168k|        };
 6277|   168k|        change_property_cmd(cmd, property, M_PROPERTY_SWITCH, &s);
 6278|   168k|        if (!cmd->success)
  ------------------
  |  Branch (6278:13): [True: 68.3k, False: 100k]
  ------------------
 6279|  68.3k|            return;
 6280|   168k|    }
 6281|   168k|}
command.c:check_property_scalable:
 5731|   168k|{
 5732|   168k|    struct m_option prop = {0};
 5733|   168k|    if (mp_property_do(property, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
  ------------------
  |  Branch (5733:9): [True: 65.3k, False: 103k]
  ------------------
 5734|  65.3k|        return true;
 5735|       |
 5736|       |    // These properties are backed by a floating-point number
 5737|   103k|    return prop.type == &m_option_type_float ||
  ------------------
  |  Branch (5737:12): [True: 13.2k, False: 90.3k]
  ------------------
 5738|  90.3k|           prop.type == &m_option_type_double ||
  ------------------
  |  Branch (5738:12): [True: 5.81k, False: 84.4k]
  ------------------
 5739|  84.4k|           prop.type == &m_option_type_time ||
  ------------------
  |  Branch (5739:12): [True: 53, False: 84.4k]
  ------------------
 5740|  84.4k|           prop.type == &m_option_type_aspect;
  ------------------
  |  Branch (5740:12): [True: 112, False: 84.3k]
  ------------------
 5741|   168k|}
command.c:cmd_cycle_values:
 5781|  1.33k|{
 5782|  1.33k|    struct mp_cmd_ctx *cmd = p;
 5783|  1.33k|    struct MPContext *mpctx = cmd->mpctx;
 5784|  1.33k|    int first = 0, dir = 1;
 5785|       |
 5786|  1.33k|    if (strcmp(cmd->args[first].v.s, "!reverse") == 0) {
  ------------------
  |  Branch (5786:9): [True: 0, False: 1.33k]
  ------------------
 5787|      0|        first += 1;
 5788|      0|        dir = -1;
 5789|      0|    }
 5790|       |
 5791|  1.33k|    const char *name = cmd->args[first].v.s;
 5792|  1.33k|    first += 1;
 5793|       |
 5794|  1.33k|    if (first >= cmd->num_args) {
  ------------------
  |  Branch (5794:9): [True: 0, False: 1.33k]
  ------------------
 5795|      0|        MP_ERR(mpctx, "cycle-values command does not have any value arguments.\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__)
  |  |  ------------------
  ------------------
 5796|      0|        cmd->success = false;
 5797|      0|        return;
 5798|      0|    }
 5799|       |
 5800|  1.33k|    struct m_option prop = {0};
 5801|  1.33k|    int r = mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx);
 5802|  1.33k|    if (r <= 0) {
  ------------------
  |  Branch (5802:9): [True: 194, False: 1.13k]
  ------------------
 5803|    194|        show_property_status(cmd, name, r);
 5804|    194|        return;
 5805|    194|    }
 5806|       |
 5807|  1.13k|    union m_option_value curval = m_option_value_default;
 5808|  1.13k|    r = mp_property_do(name, M_PROPERTY_GET, &curval, mpctx);
 5809|  1.13k|    if (r <= 0) {
  ------------------
  |  Branch (5809:9): [True: 5, False: 1.13k]
  ------------------
 5810|      5|        show_property_status(cmd, name, r);
 5811|      5|        return;
 5812|      5|    }
 5813|       |
 5814|  1.13k|    int current = -1;
 5815|  5.03k|    for (int n = first; n < cmd->num_args; n++) {
  ------------------
  |  Branch (5815:25): [True: 4.02k, False: 1.01k]
  ------------------
 5816|  4.02k|        union m_option_value val = m_option_value_default;
 5817|  4.02k|        if (m_option_parse(mpctx->log, &prop, bstr0(name),
  ------------------
  |  Branch (5817:13): [True: 2.75k, False: 1.26k]
  ------------------
 5818|  4.02k|                           bstr0(cmd->args[n].v.s), &val) < 0)
 5819|  2.75k|            continue;
 5820|       |
 5821|  1.26k|        if (m_option_equal(&prop, &curval, &val))
  ------------------
  |  Branch (5821:13): [True: 119, False: 1.15k]
  ------------------
 5822|    119|            current = n;
 5823|       |
 5824|  1.26k|        m_option_free(&prop, &val);
 5825|       |
 5826|  1.26k|        if (current >= 0)
  ------------------
  |  Branch (5826:13): [True: 119, False: 1.15k]
  ------------------
 5827|    119|            break;
 5828|  1.26k|    }
 5829|       |
 5830|  1.13k|    m_option_free(&prop, &curval);
 5831|       |
 5832|  1.13k|    if (current >= 0) {
  ------------------
  |  Branch (5832:9): [True: 119, False: 1.01k]
  ------------------
 5833|    119|        current += dir;
 5834|    119|        if (current < first)
  ------------------
  |  Branch (5834:13): [True: 0, False: 119]
  ------------------
 5835|      0|            current = cmd->num_args - 1;
 5836|    119|        if (current >= cmd->num_args)
  ------------------
  |  Branch (5836:13): [True: 25, False: 94]
  ------------------
 5837|     25|            current = first;
 5838|  1.01k|    } else {
 5839|  1.01k|        MP_VERBOSE(mpctx, "Current value not found. Picking default.\n");
  ------------------
  |  |   92|  1.01k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.01k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 5840|  1.01k|        current = dir > 0 ? first : cmd->num_args - 1;
  ------------------
  |  Branch (5840:19): [True: 1.01k, False: 0]
  ------------------
 5841|  1.01k|    }
 5842|       |
 5843|  1.13k|    change_property_cmd(cmd, name, M_PROPERTY_SET_STRING, cmd->args[current].v.s);
 5844|  1.13k|}
command.c:cmd_enable_input_section:
 7086|  2.80k|{
 7087|  2.80k|    struct mp_cmd_ctx *cmd = p;
 7088|  2.80k|    struct MPContext *mpctx = cmd->mpctx;
 7089|  2.80k|    mp_input_enable_section(mpctx->input, cmd->args[0].v.s, cmd->args[1].v.i);
 7090|  2.80k|}
command.c:cmd_disable_input_section:
 7093|     56|{
 7094|     56|    struct mp_cmd_ctx *cmd = p;
 7095|     56|    struct MPContext *mpctx = cmd->mpctx;
 7096|     56|    mp_input_disable_section(mpctx->input, cmd->args[0].v.s);
 7097|     56|}
command.c:cmd_define_input_section:
 7100|    107|{
 7101|    107|    struct mp_cmd_ctx *cmd = p;
 7102|    107|    struct MPContext *mpctx = cmd->mpctx;
 7103|    107|    mp_input_define_section(mpctx->input, cmd->args[0].v.s, "<api>",
 7104|    107|                            cmd->args[1].v.s, !cmd->args[2].v.i,
 7105|    107|                            cmd->cmd->sender);
 7106|    107|}
command.c:cmd_ab_loop:
 7109|  17.6k|{
 7110|  17.6k|    struct mp_cmd_ctx *cmd = p;
 7111|  17.6k|    struct MPContext *mpctx = cmd->mpctx;
 7112|  17.6k|    int osd_duration = mpctx->opts->osd_duration;
 7113|  17.6k|    int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
  ------------------
  |  Branch (7113:16): [True: 17.6k, False: 0]
  ------------------
 7114|       |
 7115|  17.6k|    double now = get_current_time(mpctx);
 7116|  17.6k|    if (mpctx->opts->ab_loop[0] == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  17.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (7116:9): [True: 10.1k, False: 7.58k]
  ------------------
 7117|  10.1k|        mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
 7118|  10.1k|        show_property_osd(mpctx, "ab-loop-a", cmd->on_osd);
 7119|  10.1k|    } else if (mpctx->opts->ab_loop[1] == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  7.58k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (7119:16): [True: 5.36k, False: 2.21k]
  ------------------
 7120|  5.36k|        mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
 7121|  5.36k|        show_property_osd(mpctx, "ab-loop-b", cmd->on_osd);
 7122|  5.36k|    } else {
 7123|  2.21k|        now = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.21k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 7124|  2.21k|        mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
 7125|  2.21k|        mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
 7126|  2.21k|        set_osd_msg(mpctx, osdl, osd_duration, "Clear A-B loop");
 7127|  2.21k|    }
 7128|  17.6k|}
command.c:cmd_drop_buffers:
 7151|  19.2k|{
 7152|  19.2k|    struct mp_cmd_ctx *cmd = p;
 7153|  19.2k|    struct MPContext *mpctx = cmd->mpctx;
 7154|       |
 7155|  19.2k|    reset_playback_state(mpctx);
 7156|       |
 7157|  19.2k|    if (mpctx->demuxer)
  ------------------
  |  Branch (7157:9): [True: 6.58k, False: 12.7k]
  ------------------
 7158|  6.58k|        demux_flush(mpctx->demuxer);
 7159|  19.2k|}
command.c:cmd_filter:
 7169|  42.6k|{
 7170|  42.6k|    struct mp_cmd_ctx *cmd = p;
 7171|  42.6k|    struct MPContext *mpctx = cmd->mpctx;
 7172|  42.6k|    int type = *(int *)cmd->priv;
 7173|  42.6k|    cmd->success = edit_filters_osd(mpctx, type, cmd->args[0].v.s,
 7174|  42.6k|                                    cmd->args[1].v.s, cmd->msg_osd) >= 0;
 7175|  42.6k|}
command.c:edit_filters_osd:
 5400|  42.6k|{
 5401|  42.6k|    int r = edit_filters(mpctx, mpctx->log, mediatype, cmd, arg);
 5402|  42.6k|    if (on_osd) {
  ------------------
  |  Branch (5402:9): [True: 42.6k, False: 16]
  ------------------
 5403|  42.6k|        if (r >= 0) {
  ------------------
  |  Branch (5403:13): [True: 22.8k, False: 19.8k]
  ------------------
 5404|  22.8k|            const char *prop = filter_opt[mediatype];
 5405|  22.8k|            show_property_osd(mpctx, prop, MP_ON_OSD_MSG);
 5406|  22.8k|        } else {
 5407|  19.8k|            set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
 5408|  19.8k|                         "Changing filters failed!");
 5409|  19.8k|        }
 5410|  42.6k|    }
 5411|  42.6k|    return r;
 5412|  42.6k|}
command.c:edit_filters:
 5376|  42.6k|{
 5377|  42.6k|    bstr option = bstr0(filter_opt[mediatype]);
 5378|  42.6k|    struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
 5379|  42.6k|    if (!co)
  ------------------
  |  Branch (5379:9): [True: 0, False: 42.6k]
  ------------------
 5380|      0|        return -1;
 5381|       |
 5382|       |    // The option parser is used to modify the filter list itself.
 5383|  42.6k|    char optname[20];
 5384|  42.6k|    snprintf(optname, sizeof(optname), "%.*s-%s", BSTR_P(option), cmd);
  ------------------
  |  |  307|  42.6k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 42.6k, False: 0]
  |  |  ------------------
  ------------------
 5385|       |
 5386|  42.6k|    struct m_obj_settings *new_chain = NULL;
 5387|  42.6k|    m_option_copy(co->opt, &new_chain, co->data);
 5388|       |
 5389|  42.6k|    int r = m_option_parse(log, co->opt, bstr0(optname), bstr0(arg), &new_chain);
 5390|  42.6k|    if (r >= 0)
  ------------------
  |  Branch (5390:9): [True: 22.9k, False: 19.7k]
  ------------------
 5391|  22.9k|        r = set_filters(mpctx, mediatype, new_chain);
 5392|       |
 5393|  42.6k|    m_option_free(co->opt, &new_chain);
 5394|       |
 5395|  42.6k|    return r >= 0 ? 0 : -1;
  ------------------
  |  Branch (5395:12): [True: 22.8k, False: 19.8k]
  ------------------
 5396|  42.6k|}
command.c:cmd_filter_command:
 7178|      8|{
 7179|      8|    struct mp_cmd_ctx *cmd = p;
 7180|      8|    struct MPContext *mpctx = cmd->mpctx;
 7181|      8|    int type = *(int *)cmd->priv;
 7182|       |
 7183|      8|    struct mp_output_chain *chain = NULL;
 7184|      8|    if (type == STREAM_VIDEO)
  ------------------
  |  Branch (7184:9): [True: 3, False: 5]
  ------------------
 7185|      3|        chain = mpctx->vo_chain ? mpctx->vo_chain->filter : NULL;
  ------------------
  |  Branch (7185:17): [True: 3, False: 0]
  ------------------
 7186|      8|    if (type == STREAM_AUDIO)
  ------------------
  |  Branch (7186:9): [True: 5, False: 3]
  ------------------
 7187|      5|        chain = mpctx->ao_chain ? mpctx->ao_chain->filter : NULL;
  ------------------
  |  Branch (7187:17): [True: 4, False: 1]
  ------------------
 7188|      8|    if (!chain) {
  ------------------
  |  Branch (7188:9): [True: 1, False: 7]
  ------------------
 7189|      1|        cmd->success = false;
 7190|      1|        return;
 7191|      1|    }
 7192|      7|    struct mp_filter_command filter_cmd = {
 7193|      7|        .type = MP_FILTER_COMMAND_TEXT,
 7194|      7|        .target = cmd->args[3].v.s,
 7195|      7|        .cmd = cmd->args[1].v.s,
 7196|      7|        .arg = cmd->args[2].v.s,
 7197|      7|    };
 7198|      7|    cmd->success = mp_output_chain_command(chain, cmd->args[0].v.s, &filter_cmd);
 7199|      7|}
command.c:cmd_ao_reload:
 7162|  15.6k|{
 7163|  15.6k|    struct mp_cmd_ctx *cmd = p;
 7164|  15.6k|    struct MPContext *mpctx = cmd->mpctx;
 7165|  15.6k|    reload_audio_output(mpctx);
 7166|  15.6k|}
command.c:cmd_script_binding:
 7202|    319|{
 7203|    319|    struct mp_cmd_ctx *cmd = p;
 7204|    319|    struct mp_cmd *incmd = cmd->cmd;
 7205|    319|    struct MPContext *mpctx = cmd->mpctx;
 7206|       |
 7207|    319|    mpv_event_client_message event = {0};
 7208|    319|    char *name = cmd->args[0].v.s;
 7209|    319|    if (!name || !name[0]) {
  ------------------
  |  Branch (7209:9): [True: 0, False: 319]
  |  Branch (7209:18): [True: 0, False: 319]
  ------------------
 7210|      0|        cmd->success = false;
 7211|      0|        return;
 7212|      0|    }
 7213|       |
 7214|    319|    char *sep = strchr(name, '/');
 7215|    319|    char *target = NULL;
 7216|    319|    char space[MAX_CLIENT_NAME];
 7217|    319|    if (sep) {
  ------------------
  |  Branch (7217:9): [True: 71, False: 248]
  ------------------
 7218|     71|        snprintf(space, sizeof(space), "%.*s", (int)(sep - name), name);
 7219|     71|        target = space;
 7220|     71|        name = sep + 1;
 7221|     71|    }
 7222|    319|    char state[4] = {'p', incmd->is_mouse_button ? 'm' : '-',
  ------------------
  |  Branch (7222:27): [True: 0, False: 319]
  ------------------
 7223|    319|                          incmd->canceled ? 'c' : '-'};
  ------------------
  |  Branch (7223:27): [True: 0, False: 319]
  ------------------
 7224|    319|    if (incmd->is_up_down)
  ------------------
  |  Branch (7224:9): [True: 0, False: 319]
  ------------------
 7225|      0|        state[0] = incmd->repeated ? 'r' : (incmd->is_up ? 'u' : 'd');
  ------------------
  |  Branch (7225:20): [True: 0, False: 0]
  |  Branch (7225:45): [True: 0, False: 0]
  ------------------
 7226|       |
 7227|    319|    double scale = 1;
 7228|    319|    int scale_units = incmd->scale_units;
 7229|    319|    if (mp_input_is_scalable_cmd(incmd)) {
  ------------------
  |  Branch (7229:9): [True: 319, False: 0]
  ------------------
 7230|    319|        scale = incmd->scale;
 7231|    319|        scale_units = 1;
 7232|    319|    }
 7233|    319|    char *scale_s = mp_format_double(NULL, scale, 6, false, false, false);
 7234|       |
 7235|    567|    for (int i = 0; i < scale_units; i++) {
  ------------------
  |  Branch (7235:21): [True: 319, False: 248]
  ------------------
 7236|    319|        event.num_args = 7;
 7237|    319|        event.args = (const char*[7]){"key-binding", name, state,
 7238|    319|                                      incmd->key_name ? incmd->key_name : "",
  ------------------
  |  Branch (7238:39): [True: 0, False: 319]
  ------------------
 7239|    319|                                      incmd->key_text ? incmd->key_text : "",
  ------------------
  |  Branch (7239:39): [True: 0, False: 319]
  ------------------
 7240|    319|                                      scale_s, cmd->args[1].v.s};
 7241|    319|        if (mp_client_send_event_dup(mpctx, target,
  ------------------
  |  Branch (7241:13): [True: 71, False: 248]
  ------------------
 7242|    319|                                     MPV_EVENT_CLIENT_MESSAGE, &event) < 0)
 7243|     71|        {
 7244|     71|            MP_VERBOSE(mpctx, "Can't find script '%s' when handling input.\n",
  ------------------
  |  |   92|     71|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    142|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7245|     71|                        target ? target : "-");
 7246|     71|            cmd->success = false;
 7247|     71|            break;
 7248|     71|        }
 7249|    319|    }
 7250|    319|    talloc_free(scale_s);
  ------------------
  |  |   47|    319|#define talloc_free                     ta_free
  ------------------
 7251|    319|}
command.c:cmd_script_message:
 7274|    429|{
 7275|    429|    struct mp_cmd_ctx *cmd = p;
 7276|    429|    struct MPContext *mpctx = cmd->mpctx;
 7277|       |
 7278|    429|    const char **args = talloc_array(NULL, const char *, cmd->num_args);
  ------------------
  |  |   29|    429|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|    429|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    429|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7279|    429|    mpv_event_client_message event = {.args = args};
 7280|  5.17k|    for (int n = 0; n < cmd->num_args; n++)
  ------------------
  |  Branch (7280:21): [True: 4.74k, False: 429]
  ------------------
 7281|  4.74k|        event.args[event.num_args++] = cmd->args[n].v.s;
 7282|    429|    mp_client_broadcast_event(mpctx, MPV_EVENT_CLIENT_MESSAGE, &event);
 7283|    429|    talloc_free(args);
  ------------------
  |  |   47|    429|#define talloc_free                     ta_free
  ------------------
 7284|    429|}
command.c:cmd_script_message_to:
 7254|    488|{
 7255|    488|    struct mp_cmd_ctx *cmd = p;
 7256|    488|    struct MPContext *mpctx = cmd->mpctx;
 7257|       |
 7258|    488|    mpv_event_client_message *event = talloc_ptrtype(NULL, event);
  ------------------
  |  |   34|    488|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    488|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    488|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7259|    488|    *event = (mpv_event_client_message){0};
 7260|  1.78k|    for (int n = 1; n < cmd->num_args; n++) {
  ------------------
  |  Branch (7260:21): [True: 1.29k, False: 488]
  ------------------
 7261|  1.29k|        MP_TARRAY_APPEND(event, event->args, event->num_args,
  ------------------
  |  |  105|  1.29k|    do {                                            \
  |  |  106|  1.29k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  1.29k|    do {                                            \
  |  |  |  |   97|  1.29k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  1.29k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.29k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  1.29k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 639, False: 656]
  |  |  |  |  ------------------
  |  |  |  |   99|  1.29k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    639|    do {                                                        \
  |  |  |  |  |  |   89|    639|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    639|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    639|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    639|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    639|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    639|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    639|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 639]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  1.29k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  1.29k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  1.29k|        (idxvar)++;                                 \
  |  |  109|  1.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
 7262|  1.29k|                         talloc_strdup(event, cmd->args[n].v.s));
 7263|  1.29k|    }
 7264|    488|    if (mp_client_send_event(mpctx, cmd->args[0].v.s, 0,
  ------------------
  |  Branch (7264:9): [True: 488, False: 0]
  ------------------
 7265|    488|                                MPV_EVENT_CLIENT_MESSAGE, event) < 0)
 7266|    488|    {
 7267|    488|        MP_VERBOSE(mpctx, "Can't find script '%s' to send message to.\n",
  ------------------
  |  |   92|    488|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    488|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 7268|    488|                   cmd->args[0].v.s);
 7269|       |        cmd->success = false;
 7270|    488|    }
 7271|    488|}
command.c:cmd_overlay_remove:
 5642|      3|{
 5643|      3|    struct mp_cmd_ctx *cmd = p;
 5644|      3|    struct MPContext *mpctx = cmd->mpctx;
 5645|      3|    struct command_ctx *cmdctx = mpctx->command_ctx;
 5646|      3|    int id = cmd->args[0].v.i;
 5647|      3|    if (id >= 0 && id < cmdctx->num_overlays)
  ------------------
  |  Branch (5647:9): [True: 3, False: 0]
  |  Branch (5647:20): [True: 0, False: 3]
  ------------------
 5648|      0|        replace_overlay(mpctx, id, &(struct overlay){0});
 5649|      3|}
command.c:cmd_write_watch_later_config:
 7291|    299|{
 7292|    299|    struct mp_cmd_ctx *cmd = p;
 7293|    299|    struct MPContext *mpctx = cmd->mpctx;
 7294|       |
 7295|    299|    mp_write_watch_later_conf(mpctx);
 7296|    299|}
command.c:cmd_delete_watch_later_config:
 7299|  2.53k|{
 7300|  2.53k|    struct mp_cmd_ctx *cmd = p;
 7301|  2.53k|    struct MPContext *mpctx = cmd->mpctx;
 7302|       |
 7303|  2.53k|    char *filename = cmd->args[0].v.s;
 7304|  2.53k|    if (filename && !filename[0])
  ------------------
  |  Branch (7304:9): [True: 2.33k, False: 207]
  |  Branch (7304:21): [True: 0, False: 2.33k]
  ------------------
 7305|      0|        filename = NULL;
 7306|  2.53k|    mp_delete_watch_later_conf(mpctx, filename);
 7307|  2.53k|}
command.c:cmd_key_bind:
 7376|  1.59k|{
 7377|  1.59k|    struct mp_cmd_ctx *cmd = p;
 7378|  1.59k|    struct MPContext *mpctx = cmd->mpctx;
 7379|       |
 7380|  1.59k|    const char *key = cmd->args[0].v.s;
 7381|  1.59k|    const char *target_cmd = cmd->args[1].v.s;
 7382|  1.59k|    const char *comment = cmd->args[2].v.s;
 7383|  1.59k|    if (comment && !comment[0])
  ------------------
  |  Branch (7383:9): [True: 548, False: 1.05k]
  |  Branch (7383:20): [True: 0, False: 548]
  ------------------
 7384|      0|        comment = NULL;
 7385|  1.59k|    if (!mp_input_bind_key(mpctx->input, key, bstr0(target_cmd), comment)) {
  ------------------
  |  Branch (7385:9): [True: 347, False: 1.25k]
  ------------------
 7386|    347|        MP_ERR(mpctx, "'%s' is not a valid input name.\n", key);
  ------------------
  |  |   89|    347|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    347|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 7387|       |        cmd->success = false;
 7388|    347|    }
 7389|  1.59k|}
command.c:cmd_key:
 7355|  21.2k|{
 7356|  21.2k|    struct mp_cmd_ctx *cmd = p;
 7357|  21.2k|    struct MPContext *mpctx = cmd->mpctx;
 7358|  21.2k|    int action = *(int *)cmd->priv;
 7359|       |
 7360|  21.2k|    const char *key_name = cmd->args[0].v.s;
 7361|  21.2k|    if ((!key_name || key_name[0] == '\0') && action == MP_KEY_STATE_UP) {
  ------------------
  |  |  259|    590|#define MP_KEY_STATE_UP        (1u<<29)
  ------------------
  |  Branch (7361:10): [True: 580, False: 20.7k]
  |  Branch (7361:23): [True: 10, False: 20.6k]
  |  Branch (7361:47): [True: 580, False: 10]
  ------------------
 7362|    580|        mp_input_put_key_artificial(mpctx->input, MP_INPUT_RELEASE_ALL, 1);
  ------------------
  |  |  230|    580|#define MP_INPUT_RELEASE_ALL    (MP_KEY_INTERN+6)
  |  |  ------------------
  |  |  |  |  205|    580|#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    580|#define MP_KEY_BASE (1<<21)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7363|  20.7k|    } else {
 7364|  20.7k|        int code = mp_input_get_key_from_name(key_name);
 7365|  20.7k|        if (code < 0) {
  ------------------
  |  Branch (7365:13): [True: 1.08k, False: 19.6k]
  ------------------
 7366|  1.08k|            MP_ERR(mpctx, "'%s' is not a valid input name.\n", key_name);
  ------------------
  |  |   89|  1.08k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.08k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 7367|  1.08k|            cmd->success = false;
 7368|  1.08k|            return;
 7369|  1.08k|        }
 7370|  19.6k|        double scale = action == 0 ? cmd->args[1].v.d : 1;
  ------------------
  |  Branch (7370:24): [True: 476, False: 19.1k]
  ------------------
 7371|  19.6k|        mp_input_put_key_artificial(mpctx->input, code | action, scale);
 7372|  19.6k|    }
 7373|  21.2k|}
command.c:cmd_apply_profile:
 7392|     38|{
 7393|     38|    struct mp_cmd_ctx *cmd = p;
 7394|     38|    struct MPContext *mpctx = cmd->mpctx;
 7395|       |
 7396|     38|    char *profile = cmd->args[0].v.s;
 7397|     38|    int mode = cmd->args[1].v.i;
 7398|     38|    if (mode == 0) {
  ------------------
  |  Branch (7398:9): [True: 38, False: 0]
  ------------------
 7399|     38|        cmd->success = m_config_set_profile(mpctx->mconfig, profile, 0) >= 0;
 7400|     38|    } else {
 7401|      0|        cmd->success = m_config_restore_profile(mpctx->mconfig, profile) >= 0;
 7402|      0|    }
 7403|     38|}
command.c:cmd_load_config_file:
 7406|  8.00k|{
 7407|  8.00k|    struct mp_cmd_ctx *cmd = p;
 7408|  8.00k|    struct MPContext *mpctx = cmd->mpctx;
 7409|       |
 7410|  8.00k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|  8.00k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  8.00k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 7411|  8.00k|    char *config_file = mp_get_user_path(ctx, mpctx->global, cmd->args[0].v.s);
 7412|  8.00k|    int r = m_config_parse_config_file(mpctx->mconfig, mpctx->global,
 7413|  8.00k|                                       config_file, NULL, 0);
 7414|  8.00k|    talloc_free(ctx);
  ------------------
  |  |   47|  8.00k|#define talloc_free                     ta_free
  ------------------
 7415|       |
 7416|  8.00k|    if (r < 1) {
  ------------------
  |  Branch (7416:9): [True: 7.37k, False: 630]
  ------------------
 7417|  7.37k|        cmd->success = false;
 7418|  7.37k|        return;
 7419|  7.37k|    }
 7420|       |
 7421|    630|    mp_notify_property(mpctx, "profile-list");
 7422|    630|}
command.c:cmd_load_input_conf:
 7425|     23|{
 7426|     23|    struct mp_cmd_ctx *cmd = p;
 7427|     23|    struct MPContext *mpctx = cmd->mpctx;
 7428|       |
 7429|     23|    char *config_file = cmd->args[0].v.s;
 7430|     23|    cmd->success = mp_input_load_config_file(mpctx->input, config_file);
 7431|     23|}
command.c:cmd_load_script:
 7434|  1.11k|{
 7435|  1.11k|    struct mp_cmd_ctx *cmd = p;
 7436|  1.11k|    struct MPContext *mpctx = cmd->mpctx;
 7437|       |
 7438|  1.11k|    char *script = cmd->args[0].v.s;
 7439|  1.11k|    int64_t id = mp_load_user_script(mpctx, script);
 7440|  1.11k|    if (id > 0) {
  ------------------
  |  Branch (7440:9): [True: 0, False: 1.11k]
  ------------------
 7441|      0|        struct mpv_node *res = &cmd->result;
 7442|      0|        node_init(res, MPV_FORMAT_NODE_MAP, NULL);
 7443|      0|        node_map_add_int64(res, "client_id", id);
 7444|  1.11k|    } else {
 7445|       |        cmd->success = false;
 7446|  1.11k|    }
 7447|  1.11k|}
command.c:run_dump_cmd:
 7493|    434|{
 7494|    434|    struct MPContext *mpctx = cmd->mpctx;
 7495|    434|    struct command_ctx *ctx = mpctx->command_ctx;
 7496|       |
 7497|    434|    mp_abort_cache_dumping(mpctx);
 7498|       |
 7499|    434|    if (!mpctx->demuxer) {
  ------------------
  |  Branch (7499:9): [True: 316, False: 118]
  ------------------
 7500|    316|        mp_cmd_msg(cmd, MSGL_ERR, "No demuxer open.");
 7501|    316|        cmd->success = false;
 7502|    316|        mp_cmd_ctx_complete(cmd);
 7503|    316|        return;
 7504|    316|    }
 7505|       |
 7506|    118|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 7507|    118|    mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping started.");
 7508|       |
 7509|    118|    if (!demux_cache_dump_set(mpctx->demuxer, start, end, path)) {
  ------------------
  |  Branch (7509:9): [True: 74, False: 44]
  ------------------
 7510|     74|        mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping stopped.");
 7511|     74|        mp_cmd_ctx_complete(cmd);
 7512|     74|        talloc_free(path);
  ------------------
  |  |   47|     74|#define talloc_free                     ta_free
  ------------------
 7513|     74|        return;
 7514|     74|    }
 7515|       |
 7516|     44|    ctx->cache_dump_cmd = cmd;
 7517|     44|    cache_dump_poll(mpctx);
 7518|     44|    talloc_free(path);
  ------------------
  |  |   47|     44|#define talloc_free                     ta_free
  ------------------
 7519|     44|}
command.c:cmd_dump_cache_ab:
 7529|    434|{
 7530|    434|    struct mp_cmd_ctx *cmd = p;
 7531|    434|    struct MPContext *mpctx = cmd->mpctx;
 7532|       |
 7533|    434|    run_dump_cmd(cmd, mpctx->opts->ab_loop[0], mpctx->opts->ab_loop[1],
 7534|    434|                 cmd->args[0].v.s);
 7535|    434|}
command.c:cmd_align_cache_ab:
 7131|    835|{
 7132|    835|    struct mp_cmd_ctx *cmd = p;
 7133|    835|    struct MPContext *mpctx = cmd->mpctx;
 7134|       |
 7135|    835|    if (!mpctx->demuxer)
  ------------------
  |  Branch (7135:9): [True: 374, False: 461]
  ------------------
 7136|    374|        return;
 7137|       |
 7138|    461|    double a = demux_probe_cache_dump_target(mpctx->demuxer,
 7139|    461|                                             mpctx->opts->ab_loop[0], false);
 7140|    461|    double b = demux_probe_cache_dump_target(mpctx->demuxer,
 7141|    461|                                             mpctx->opts->ab_loop[1], true);
 7142|       |
 7143|    461|    mp_property_do("ab-loop-a", M_PROPERTY_SET, &a, mpctx);
 7144|    461|    mp_property_do("ab-loop-b", M_PROPERTY_SET, &b, mpctx);
 7145|       |
 7146|       |    // Happens to cover both properties.
 7147|    461|    show_property_osd(mpctx, "ab-loop-b", cmd->on_osd);
 7148|    461|}
command.c:cmd_begin_vo_dragging:
 7538|     50|{
 7539|     50|    struct mp_cmd_ctx *cmd = p;
 7540|     50|    struct MPContext *mpctx = cmd->mpctx;
 7541|     50|    struct vo *vo = mpctx->video_out;
 7542|       |
 7543|     50|    if (vo)
  ------------------
  |  Branch (7543:9): [True: 35, False: 15]
  ------------------
 7544|     35|        vo_control(vo, VOCTRL_BEGIN_DRAGGING, NULL);
 7545|     50|}
command.c:cmd_context_menu:
 7562|    123|{
 7563|    123|    struct mp_cmd_ctx *cmd = p;
 7564|    123|    struct MPContext *mpctx = cmd->mpctx;
 7565|    123|    struct vo *vo = mpctx->video_out;
 7566|       |
 7567|    123|    if (vo)
  ------------------
  |  Branch (7567:9): [True: 21, False: 102]
  ------------------
 7568|     21|        vo_control(vo, VOCTRL_SHOW_MENU, NULL);
 7569|    123|}
command.c:cmd_flush_status_line:
 7616|     10|{
 7617|     10|    struct mp_cmd_ctx *cmd = p;
 7618|     10|    struct MPContext *mpctx = cmd->mpctx;
 7619|       |
 7620|     10|    if (!mpctx->log)
  ------------------
  |  Branch (7620:9): [True: 0, False: 10]
  ------------------
 7621|      0|        return;
 7622|       |
 7623|     10|    mp_msg_flush_status_line(mpctx->log, cmd->args[0].v.b);
 7624|     10|}
command.c:cmd_notify_property:
 7627|     51|{
 7628|     51|    struct mp_cmd_ctx *cmd = p;
 7629|     51|    struct MPContext *mpctx = cmd->mpctx;
 7630|       |
 7631|     51|    mp_notify_property(mpctx, cmd->args[0].v.s);
 7632|     51|}
command.c:overlay_uninit:
 5652|  11.6k|{
 5653|  11.6k|    struct command_ctx *cmd = mpctx->command_ctx;
 5654|  11.6k|    if (!mpctx->osd)
  ------------------
  |  Branch (5654:9): [True: 0, False: 11.6k]
  ------------------
 5655|      0|        return;
 5656|  11.6k|    for (int id = 0; id < cmd->num_overlays; id++)
  ------------------
  |  Branch (5656:22): [True: 0, False: 11.6k]
  ------------------
 5657|      0|        replace_overlay(mpctx, id, &(struct overlay){0});
 5658|  11.6k|    osd_set_bitmaps(mpctx->osd, OSDTYPE_EXTERNAL2, NULL);
 5659|  35.0k|    for (int n = 0; n < 2; n++)
  ------------------
  |  Branch (5659:21): [True: 23.3k, False: 11.6k]
  ------------------
 5660|  23.3k|        mp_image_unrefp(&cmd->overlay_osd[n].packed);
 5661|  11.6k|}
command.c:mp_property_pid:
  517|    158|{
  518|       |    // 32 bit on linux/windows - which C99 `int' is not guaranteed to hold
  519|    158|    return m_property_int64_ro(action, arg, mp_getpid());
  ------------------
  |  |   28|    158|#define mp_getpid() getpid()
  ------------------
  520|    158|}
command.c:mp_property_playback_speed:
  464|  43.6k|{
  465|  43.6k|    MPContext *mpctx = ctx;
  466|  43.6k|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (466:9): [True: 3.96k, False: 39.6k]
  |  Branch (466:39): [True: 0, False: 39.6k]
  ------------------
  467|  3.96k|        *(char **)arg = mp_format_double(NULL, mpctx->opts->playback_speed, 2,
  468|  3.96k|                                         false, false, action != M_PROPERTY_FIXED_LEN_PRINT);
  469|  3.96k|        return M_PROPERTY_OK;
  470|  3.96k|    }
  471|  39.6k|    return mp_property_generic_option(mpctx, prop, action, arg);
  472|  43.6k|}
command.c:mp_property_playback_pitch:
  477|  18.3k|{
  478|  18.3k|    MPContext *mpctx = ctx;
  479|  18.3k|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (479:9): [True: 1.66k, False: 16.6k]
  |  Branch (479:39): [True: 0, False: 16.6k]
  ------------------
  480|  1.66k|        *(char **)arg = mp_format_double(NULL, mpctx->opts->playback_pitch, 2,
  481|  1.66k|                                         false, false, action != M_PROPERTY_FIXED_LEN_PRINT);
  482|  1.66k|        return M_PROPERTY_OK;
  483|  1.66k|    }
  484|  16.6k|    return mp_property_generic_option(mpctx, prop, action, arg);
  485|  18.3k|}
command.c:mp_property_av_speed_correction:
  489|     22|{
  490|     22|    MPContext *mpctx = ctx;
  491|     22|    char *type = prop->priv;
  492|     22|    double val = 0;
  493|     22|    switch (type[0]) {
  494|      0|    case 'a': val = mpctx->speed_factor_a; break;
  ------------------
  |  Branch (494:5): [True: 0, False: 22]
  ------------------
  495|     22|    case 'v': val = mpctx->speed_factor_v; break;
  ------------------
  |  Branch (495:5): [True: 22, False: 0]
  ------------------
  496|     22|    default: MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (496:5): [True: 0, False: 22]
  |  Branch (496:14): [Folded, False: 0]
  ------------------
  497|     22|    }
  498|       |
  499|     22|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (499:9): [True: 0, False: 22]
  |  Branch (499:39): [True: 0, False: 22]
  ------------------
  500|      0|        *(char **)arg = mp_format_double(NULL, (val - 1) * 100, 4, true,
  501|      0|                                         true, action != M_PROPERTY_FIXED_LEN_PRINT);
  502|      0|        return M_PROPERTY_OK;
  503|      0|    }
  504|       |
  505|     22|    return m_property_double_ro(action, arg, val);
  506|     22|}
command.c:mp_property_display_sync_active:
  510|      5|{
  511|      5|    MPContext *mpctx = ctx;
  512|      5|    return m_property_bool_ro(action, arg, mpctx->display_sync_active);
  513|      5|}
command.c:mp_property_filename:
  534|  27.5M|{
  535|  27.5M|    MPContext *mpctx = ctx;
  536|  27.5M|    if (!mpctx->filename)
  ------------------
  |  Branch (536:9): [True: 15.4k, False: 27.5M]
  ------------------
  537|  15.4k|        return M_PROPERTY_UNAVAILABLE;
  538|  27.5M|    const char *name = mpctx->demuxer ? mpctx->demuxer->server_filename : NULL;
  ------------------
  |  Branch (538:24): [True: 27.3M, False: 131k]
  ------------------
  539|  27.5M|    char *filename = talloc_strdup(NULL, name ? name : mpctx->filename);
  ------------------
  |  |   50|  27.5M|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (539:42): [True: 0, False: 27.5M]
  ------------------
  540|  27.5M|    char *f = filename;
  541|  27.5M|    if (!name) {
  ------------------
  |  Branch (541:9): [True: 27.5M, False: 0]
  ------------------
  542|  27.5M|        if (mp_is_url(bstr0(filename)))
  ------------------
  |  Branch (542:13): [True: 27.5M, False: 1.40k]
  ------------------
  543|  27.5M|            mp_url_unescape_inplace(filename);
  544|  27.5M|        f = (char *)mp_basename(filename);
  545|  27.5M|        if (!f[0])
  ------------------
  |  Branch (545:13): [True: 100, False: 27.5M]
  ------------------
  546|    100|            f = filename;
  547|  27.5M|    }
  548|  27.5M|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (548:9): [True: 0, False: 27.5M]
  ------------------
  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|  27.5M|    int r = m_property_strdup_ro(action, arg, f);
  557|  27.5M|    talloc_free(filename);
  ------------------
  |  |   47|  27.5M|#define talloc_free                     ta_free
  ------------------
  558|  27.5M|    return r;
  559|  27.5M|}
command.c:mp_property_env:
  563|     31|{
  564|     31|    switch (action) {
  ------------------
  |  Branch (564:13): [True: 17, False: 14]
  ------------------
  565|     14|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (565:5): [True: 14, False: 17]
  ------------------
  566|     14|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     14|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
  567|     14|        return M_PROPERTY_OK;
  568|      3|    case M_PROPERTY_GET:
  ------------------
  |  Branch (568:5): [True: 3, False: 28]
  ------------------
  569|      3|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (569:5): [True: 0, False: 31]
  ------------------
  570|      3|        struct mpv_node node;
  571|      3|        node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
  572|    105|        for (char **env = environ; env && *env; env++) {
  ------------------
  |  Branch (572:36): [True: 105, False: 0]
  |  Branch (572:43): [True: 102, False: 3]
  ------------------
  573|    102|            char *sep = strchr(*env, '=');
  574|    102|            if (!sep)
  ------------------
  |  Branch (574:17): [True: 0, False: 102]
  ------------------
  575|      0|                continue;
  576|    102|            bstr key = { .start = *env, .len = sep - *env };
  577|    102|            struct mpv_node *np = node_map_badd(&node, key, MPV_FORMAT_NONE);
  578|    102|            np->format = MPV_FORMAT_STRING;
  579|    102|            np->u.string = talloc_strdup(node.u.list, sep + 1);
  ------------------
  |  |   50|    102|#define talloc_strdup                   ta_xstrdup
  ------------------
  580|    102|        }
  581|      3|        *(struct mpv_node *)arg = node;
  582|      3|        return M_PROPERTY_OK;
  583|      3|    }
  584|      0|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (584:5): [True: 0, False: 31]
  ------------------
  585|      0|        struct m_property_action_arg *ka = arg;
  586|      0|        char *val = getenv(ka->key);
  587|      0|        return m_property_strdup_ro(ka->action, ka->arg, val);
  588|      3|    }
  589|     31|    }
  590|     14|    return M_PROPERTY_NOT_IMPLEMENTED;
  591|     31|}
command.c:mp_property_stream_open_filename:
  595|     43|{
  596|     43|    MPContext *mpctx = ctx;
  597|     43|    if (!mpctx->stream_open_filename || !mpctx->playing)
  ------------------
  |  Branch (597:9): [True: 6, False: 37]
  |  Branch (597:41): [True: 0, False: 37]
  ------------------
  598|      6|        return M_PROPERTY_UNAVAILABLE;
  599|     37|    switch (action) {
  ------------------
  |  Branch (599:13): [True: 23, False: 14]
  ------------------
  600|      5|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (600:5): [True: 5, False: 32]
  ------------------
  601|      5|        if (mpctx->demuxer)
  ------------------
  |  Branch (601:13): [True: 4, False: 1]
  ------------------
  602|      4|            return M_PROPERTY_ERROR;
  603|      1|        mpctx->stream_open_filename =
  604|      1|            talloc_strdup(mpctx->stream_open_filename, *(char **)arg);
  ------------------
  |  |   50|      1|#define talloc_strdup                   ta_xstrdup
  ------------------
  605|      1|        mp_notify_property(mpctx, prop->name);
  606|      1|        return M_PROPERTY_OK;
  607|      5|    }
  608|     12|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (608:5): [True: 12, False: 25]
  ------------------
  609|     18|    case M_PROPERTY_GET:
  ------------------
  |  Branch (609:5): [True: 6, False: 31]
  ------------------
  610|     18|        return m_property_strdup_ro(action, arg, mpctx->stream_open_filename);
  611|     37|    }
  612|     14|    return M_PROPERTY_NOT_IMPLEMENTED;
  613|     37|}
command.c:mp_property_file_size:
  617|     28|{
  618|     28|    MPContext *mpctx = ctx;
  619|     28|    if (!mpctx->demuxer)
  ------------------
  |  Branch (619:9): [True: 12, False: 16]
  ------------------
  620|     12|        return M_PROPERTY_UNAVAILABLE;
  621|       |
  622|     16|    int64_t size = mpctx->demuxer->filesize;
  623|     16|    if (size < 0)
  ------------------
  |  Branch (623:9): [True: 16, False: 0]
  ------------------
  624|     16|        return M_PROPERTY_UNAVAILABLE;
  625|       |
  626|      0|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (626:9): [True: 0, False: 0]
  ------------------
  627|      0|        *(char **)arg = format_file_size(size);
  628|      0|        return M_PROPERTY_OK;
  629|      0|    }
  630|      0|    return m_property_int64_ro(action, arg, size);
  631|      0|}
command.c:mp_property_media_title:
  635|  27.5M|{
  636|  27.5M|    MPContext *mpctx = ctx;
  637|  27.5M|    const char *name = mp_find_non_filename_media_title(mpctx);
  638|  27.5M|    if (name && name[0])
  ------------------
  |  Branch (638:9): [True: 0, False: 27.5M]
  |  Branch (638:17): [True: 0, False: 0]
  ------------------
  639|      0|        return m_property_strdup_ro(action, arg, name);
  640|  27.5M|    return mp_property_filename(ctx, prop, action, arg);
  641|  27.5M|}
command.c:mp_property_file_format:
  665|     44|{
  666|     44|    MPContext *mpctx = ctx;
  667|     44|    struct demuxer *demuxer = mpctx->demuxer;
  668|     44|    if (!demuxer)
  ------------------
  |  Branch (668:9): [True: 28, False: 16]
  ------------------
  669|     28|        return M_PROPERTY_UNAVAILABLE;
  670|     16|    const char *name = demuxer->filetype ? demuxer->filetype : demuxer->desc->name;
  ------------------
  |  Branch (670:24): [True: 16, False: 0]
  ------------------
  671|     16|    return m_property_strdup_ro(action, arg, name);
  672|     44|}
command.c:mp_property_stream_pos:
  676|    312|{
  677|    312|    MPContext *mpctx = ctx;
  678|    312|    struct demuxer *demuxer = mpctx->demuxer;
  679|    312|    if (!demuxer || demuxer->filepos < 0)
  ------------------
  |  Branch (679:9): [True: 140, False: 172]
  |  Branch (679:21): [True: 172, False: 0]
  ------------------
  680|    312|        return M_PROPERTY_UNAVAILABLE;
  681|      0|    return m_property_int64_ro(action, arg, demuxer->filepos);
  682|    312|}
command.c:mp_property_duration:
  730|     59|{
  731|     59|    MPContext *mpctx = ctx;
  732|     59|    double len = get_time_length(mpctx);
  733|       |
  734|     59|    if (len < 0)
  ------------------
  |  Branch (734:9): [True: 17, False: 42]
  ------------------
  735|     17|        return M_PROPERTY_UNAVAILABLE;
  736|       |
  737|     42|    return property_time(action, arg, len);
  738|     59|}
command.c:property_time:
  694|    401|{
  695|    401|    if (time == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    401|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (695:9): [True: 27, False: 374]
  ------------------
  696|     27|        return M_PROPERTY_UNAVAILABLE;
  697|       |
  698|    374|    const struct m_option time_type = {.type = CONF_TYPE_TIME};
  ------------------
  |  |  251|    374|#define CONF_TYPE_TIME          (&m_option_type_time)
  ------------------
  699|    374|    switch (action) {
  ------------------
  |  Branch (699:13): [True: 186, False: 188]
  ------------------
  700|     60|    case M_PROPERTY_GET:
  ------------------
  |  Branch (700:5): [True: 60, False: 314]
  ------------------
  701|     60|        *(double *)arg = time;
  702|     60|        return M_PROPERTY_OK;
  703|    124|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (703:5): [True: 124, False: 250]
  ------------------
  704|    124|        *(struct m_option *)arg = time_type;
  705|    124|        return M_PROPERTY_OK;
  706|      2|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (706:5): [True: 2, False: 372]
  ------------------
  707|      2|        struct m_property_action_arg *ka = arg;
  708|       |
  709|      2|        if (strcmp(ka->key, "full") != 0)
  ------------------
  |  Branch (709:13): [True: 2, False: 0]
  ------------------
  710|      2|            return M_PROPERTY_UNKNOWN;
  711|       |
  712|      0|        switch (ka->action) {
  ------------------
  |  Branch (712:17): [True: 0, False: 0]
  ------------------
  713|      0|        case M_PROPERTY_GET:
  ------------------
  |  Branch (713:9): [True: 0, False: 0]
  ------------------
  714|      0|            *(double *)ka->arg = time;
  715|      0|            return M_PROPERTY_OK;
  716|      0|        case M_PROPERTY_PRINT:
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  ------------------
  717|      0|            *(char **)ka->arg = mp_format_time(time, true);
  718|      0|            return M_PROPERTY_OK;
  719|      0|        case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (719:9): [True: 0, False: 0]
  ------------------
  720|      0|            *(struct m_option *)ka->arg = time_type;
  721|      0|            return M_PROPERTY_OK;
  722|      0|        }
  723|      0|    }
  724|    374|    }
  725|    188|    return M_PROPERTY_NOT_IMPLEMENTED;
  726|    374|}
command.c:mp_property_avsync:
  742|     35|{
  743|     35|    MPContext *mpctx = ctx;
  744|     35|    if (!mpctx->ao_chain || !mpctx->vo_chain)
  ------------------
  |  Branch (744:9): [True: 20, False: 15]
  |  Branch (744:29): [True: 0, False: 15]
  ------------------
  745|     20|        return M_PROPERTY_UNAVAILABLE;
  746|     15|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (746:9): [True: 0, False: 15]
  |  Branch (746:39): [True: 0, False: 15]
  ------------------
  747|      0|        *(char **)arg = mp_format_double(NULL, mpctx->last_av_difference, 5,
  748|      0|                                         true, false, action != M_PROPERTY_FIXED_LEN_PRINT);
  749|      0|        return M_PROPERTY_OK;
  750|      0|    }
  751|     15|    return m_property_double_ro(action, arg, mpctx->last_av_difference);
  752|     15|}
command.c:mp_property_total_avsync_change:
  756|      6|{
  757|      6|    MPContext *mpctx = ctx;
  758|      6|    if (!mpctx->ao_chain || !mpctx->vo_chain)
  ------------------
  |  Branch (758:9): [True: 0, False: 6]
  |  Branch (758:29): [True: 0, False: 6]
  ------------------
  759|      0|        return M_PROPERTY_UNAVAILABLE;
  760|      6|    if (mpctx->total_avsync_change == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      6|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (760:9): [True: 0, False: 6]
  ------------------
  761|      0|        return M_PROPERTY_UNAVAILABLE;
  762|      6|    return m_property_double_ro(action, arg, mpctx->total_avsync_change);
  763|      6|}
command.c:mp_property_mistimed_frame_count:
  780|     85|{
  781|     85|    MPContext *mpctx = ctx;
  782|     85|    if (!mpctx->vo_chain || !mpctx->display_sync_active)
  ------------------
  |  Branch (782:9): [True: 64, False: 21]
  |  Branch (782:29): [True: 21, False: 0]
  ------------------
  783|     85|        return M_PROPERTY_UNAVAILABLE;
  784|       |
  785|      0|    return m_property_int_ro(action, arg, mpctx->mistimed_frames_total);
  786|     85|}
command.c:mp_property_vsync_ratio:
  790|     31|{
  791|     31|    MPContext *mpctx = ctx;
  792|     31|    if (!mpctx->vo_chain || !mpctx->display_sync_active)
  ------------------
  |  Branch (792:9): [True: 20, False: 11]
  |  Branch (792:29): [True: 11, False: 0]
  ------------------
  793|     31|        return M_PROPERTY_UNAVAILABLE;
  794|       |
  795|      0|    int vsyncs = 0, frames = 0;
  796|      0|    for (int n = 0; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (796:21): [True: 0, False: 0]
  ------------------
  797|      0|        int vsync = mpctx->past_frames[n].num_vsyncs;
  798|      0|        if (vsync < 0)
  ------------------
  |  Branch (798:13): [True: 0, False: 0]
  ------------------
  799|      0|            break;
  800|      0|        vsyncs += vsync;
  801|      0|        frames += 1;
  802|      0|    }
  803|       |
  804|      0|    if (!frames)
  ------------------
  |  Branch (804:9): [True: 0, False: 0]
  ------------------
  805|      0|        return M_PROPERTY_UNAVAILABLE;
  806|       |
  807|      0|    return m_property_double_ro(action, arg, vsyncs / (double)frames);
  808|      0|}
command.c:mp_property_display_resolution:
 2937|     19|{
 2938|     19|    MPContext *mpctx = ctx;
 2939|     19|    struct vo *vo = mpctx->video_out;
 2940|     19|    if (!vo)
  ------------------
  |  Branch (2940:9): [True: 4, False: 15]
  ------------------
 2941|      4|        return M_PROPERTY_UNAVAILABLE;
 2942|     15|    int res[2];
 2943|     15|    if (vo_control(vo, VOCTRL_GET_DISPLAY_RES, &res) <= 0)
  ------------------
  |  Branch (2943:9): [True: 15, False: 0]
  ------------------
 2944|     15|        return M_PROPERTY_UNAVAILABLE;
 2945|      0|    if (strcmp(prop->name, "display-width") == 0) {
  ------------------
  |  Branch (2945:9): [True: 0, False: 0]
  ------------------
 2946|      0|        return m_property_int_ro(action, arg, res[0]);
 2947|      0|    } else {
 2948|      0|        return m_property_int_ro(action, arg, res[1]);
 2949|      0|    }
 2950|      0|}
command.c:mp_property_frame_drop_dec:
  767|     18|{
  768|     18|    MPContext *mpctx = ctx;
  769|     18|    struct mp_decoder_wrapper *dec = mpctx->vo_chain && mpctx->vo_chain->track
  ------------------
  |  Branch (769:38): [True: 6, False: 12]
  |  Branch (769:57): [True: 6, False: 0]
  ------------------
  770|     18|        ? mpctx->vo_chain->track->dec : NULL;
  771|     18|    if (!dec)
  ------------------
  |  Branch (771:9): [True: 12, False: 6]
  ------------------
  772|     12|        return M_PROPERTY_UNAVAILABLE;
  773|       |
  774|      6|    return m_property_int_ro(action, arg,
  775|      6|                             mp_decoder_wrapper_get_frames_dropped(dec));
  776|     18|}
command.c:mp_property_frame_drop_vo:
  812|     18|{
  813|     18|    MPContext *mpctx = ctx;
  814|     18|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (814:9): [True: 0, False: 18]
  ------------------
  815|      0|        return M_PROPERTY_UNAVAILABLE;
  816|       |
  817|     18|    return m_property_int_ro(action, arg, vo_get_drop_count(mpctx->video_out));
  818|     18|}
command.c:mp_property_vo_delayed_frame_count:
  822|     64|{
  823|     64|    MPContext *mpctx = ctx;
  824|     64|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (824:9): [True: 28, False: 36]
  ------------------
  825|     28|        return M_PROPERTY_UNAVAILABLE;
  826|       |
  827|     36|    return m_property_int_ro(action, arg, vo_get_delayed_count(mpctx->video_out));
  828|     64|}
command.c:mp_property_vo_presentation_delay:
  832|      7|{
  833|      7|    MPContext *mpctx = ctx;
  834|      7|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (834:9): [True: 4, False: 3]
  ------------------
  835|      4|        return M_PROPERTY_UNAVAILABLE;
  836|      3|    double delay = vo_get_presentation_delay(mpctx->video_out);
  837|      3|    if (isnan(delay))
  ------------------
  |  Branch (837:9): [True: 3, False: 0]
  ------------------
  838|      3|        return M_PROPERTY_UNAVAILABLE;
  839|      0|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (839:9): [True: 0, False: 0]
  |  Branch (839:39): [True: 0, False: 0]
  ------------------
  840|      0|        *(char **)arg = mp_format_double(NULL, delay, 5, true, false,
  841|      0|                                         action != M_PROPERTY_FIXED_LEN_PRINT);
  842|      0|        return M_PROPERTY_OK;
  843|      0|    }
  844|      0|    return m_property_double_ro(action, arg, delay);
  845|      0|}
command.c:mp_property_percent_pos:
  850|     87|{
  851|     87|    MPContext *mpctx = ctx;
  852|     87|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (852:9): [True: 7, False: 80]
  ------------------
  853|      7|        return M_PROPERTY_UNAVAILABLE;
  854|       |
  855|     80|    switch (action) {
  ------------------
  |  Branch (855:13): [True: 48, False: 32]
  ------------------
  856|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (856:5): [True: 0, False: 80]
  ------------------
  857|      0|        double pos = *(double *)arg;
  858|      0|        queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, MPSEEK_DEFAULT, 0);
  859|      0|        return M_PROPERTY_OK;
  860|      0|    }
  861|     16|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (861:5): [True: 16, False: 64]
  ------------------
  862|     16|        double pos = get_current_pos_ratio(mpctx, false) * 100.0;
  863|     16|        if (pos < 0)
  ------------------
  |  Branch (863:13): [True: 0, False: 16]
  ------------------
  864|      0|            return M_PROPERTY_UNAVAILABLE;
  865|     16|        *(double *)arg = pos;
  866|     16|        return M_PROPERTY_OK;
  867|     16|    }
  868|     32|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (868:5): [True: 32, False: 48]
  ------------------
  869|     32|        *(struct m_option *)arg = (struct m_option){
  870|     32|            .type = CONF_TYPE_DOUBLE,
  ------------------
  |  |  243|     32|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  ------------------
  871|     32|            .min = 0,
  872|     32|            .max = 100,
  873|     32|        };
  874|     32|        return M_PROPERTY_OK;
  875|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (875:5): [True: 0, False: 80]
  ------------------
  876|      0|        double pos = get_current_pos_ratio(mpctx, false);
  877|      0|        if (pos < 0)
  ------------------
  |  Branch (877:13): [True: 0, False: 0]
  ------------------
  878|      0|            return M_PROPERTY_UNAVAILABLE;
  879|      0|        *(char **)arg = talloc_asprintf(NULL, "%.f", pos * 100);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  880|      0|        return M_PROPERTY_OK;
  881|      0|    }
  882|     80|    }
  883|     32|    return M_PROPERTY_NOT_IMPLEMENTED;
  884|     80|}
command.c:mp_property_time_pos:
  889|    304|{
  890|    304|    MPContext *mpctx = ctx;
  891|    304|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (891:9): [True: 220, False: 84]
  ------------------
  892|    220|        return M_PROPERTY_UNAVAILABLE;
  893|       |
  894|     84|    if (action == M_PROPERTY_SET) {
  ------------------
  |  Branch (894:9): [True: 6, False: 78]
  ------------------
  895|      6|        queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, 0);
  896|      6|        return M_PROPERTY_OK;
  897|      6|    }
  898|     78|    return property_time(action, arg, get_playback_time(mpctx));
  899|     84|}
command.c:mp_property_remaining:
  928|    196|{
  929|    196|    double remaining;
  930|    196|    if (!time_remaining(ctx, &remaining))
  ------------------
  |  Branch (930:9): [True: 76, False: 120]
  ------------------
  931|     76|        return M_PROPERTY_UNAVAILABLE;
  932|       |
  933|    120|    return property_time(action, arg, remaining);
  934|    196|}
command.c:time_remaining:
  914|    248|{
  915|    248|    double len = get_time_length(mpctx);
  916|    248|    double playback = get_playback_time(mpctx);
  917|       |
  918|    248|    if (playback == MP_NOPTS_VALUE || len <= 0)
  ------------------
  |  |   39|    496|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (918:9): [True: 104, False: 144]
  |  Branch (918:39): [True: 0, False: 144]
  ------------------
  919|    104|        return false;
  920|       |
  921|    144|    *remaining = len - playback;
  922|       |
  923|    144|    return len >= 0;
  924|    248|}
command.c:mp_property_audio_pts:
  904|     74|{
  905|     74|    MPContext *mpctx = ctx;
  906|     74|    if (!mpctx->playback_initialized || mpctx->audio_status < STATUS_PLAYING ||
  ------------------
  |  Branch (906:9): [True: 56, False: 18]
  |  Branch (906:41): [True: 0, False: 18]
  ------------------
  907|     18|        mpctx->audio_status >= STATUS_EOF)
  ------------------
  |  Branch (907:9): [True: 0, False: 18]
  ------------------
  908|     56|        return M_PROPERTY_UNAVAILABLE;
  909|       |
  910|     18|    return property_time(action, arg, playing_audio_pts(mpctx));
  911|     74|}
command.c:mp_property_playtime_remaining:
  938|     52|{
  939|     52|    MPContext *mpctx = ctx;
  940|     52|    double remaining;
  941|     52|    if (!time_remaining(mpctx, &remaining))
  ------------------
  |  Branch (941:9): [True: 28, False: 24]
  ------------------
  942|     28|        return M_PROPERTY_UNAVAILABLE;
  943|       |
  944|     24|    double speed = mpctx->video_speed;
  945|     24|    return property_time(action, arg, remaining / speed);
  946|     52|}
command.c:mp_property_remaining_file_loops:
  950|     18|{
  951|     18|    MPContext *mpctx = ctx;
  952|     18|    return m_property_int_ro(action, arg, mpctx->remaining_file_loops);
  953|     18|}
command.c:mp_property_remaining_ab_loops:
  957|    144|{
  958|    144|    MPContext *mpctx = ctx;
  959|    144|    return m_property_int_ro(action, arg, mpctx->remaining_ab_loops);
  960|    144|}
command.c:mp_property_chapter:
  965|     33|{
  966|     33|    MPContext *mpctx = ctx;
  967|     33|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (967:9): [True: 6, False: 27]
  ------------------
  968|      6|        return M_PROPERTY_UNAVAILABLE;
  969|       |
  970|     27|    int chapter = get_current_chapter(mpctx);
  971|     27|    int num = get_chapter_count(mpctx);
  972|     27|    if (chapter < -1)
  ------------------
  |  Branch (972:9): [True: 27, False: 0]
  ------------------
  973|     27|        return M_PROPERTY_UNAVAILABLE;
  974|       |
  975|      0|    switch (action) {
  ------------------
  |  Branch (975:13): [True: 0, False: 0]
  ------------------
  976|      0|    case M_PROPERTY_GET:
  ------------------
  |  Branch (976:5): [True: 0, False: 0]
  ------------------
  977|      0|        *(int *) arg = chapter;
  978|      0|        return M_PROPERTY_OK;
  979|      0|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (979:5): [True: 0, False: 0]
  ------------------
  980|      0|        *(struct m_option *)arg = (struct m_option){
  981|      0|            .type = CONF_TYPE_INT,
  ------------------
  |  |  240|      0|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
  982|      0|            .min = -1,
  983|      0|            .max = num - 1,
  984|      0|        };
  985|      0|        return M_PROPERTY_OK;
  986|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (986:5): [True: 0, False: 0]
  ------------------
  987|      0|        *(char **) arg = chapter_display_name(mpctx, chapter);
  988|      0|        return M_PROPERTY_OK;
  989|      0|    }
  990|      0|    case M_PROPERTY_SWITCH:
  ------------------
  |  Branch (990:5): [True: 0, False: 0]
  ------------------
  991|      0|    case M_PROPERTY_SET: ;
  ------------------
  |  Branch (991:5): [True: 0, False: 0]
  ------------------
  992|      0|        mark_seek(mpctx);
  993|      0|        int step_all;
  994|      0|        if (action == M_PROPERTY_SWITCH) {
  ------------------
  |  Branch (994:13): [True: 0, False: 0]
  ------------------
  995|      0|            struct m_property_switch_arg *sarg = arg;
  996|      0|            step_all = lrint(sarg->inc);
  997|       |            // Check threshold for relative backward seeks
  998|      0|            if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
  ------------------
  |  Branch (998:17): [True: 0, False: 0]
  |  Branch (998:61): [True: 0, False: 0]
  ------------------
  999|      0|                double current_chapter_start =
 1000|      0|                    chapter_start_time(mpctx, chapter);
 1001|       |                // If we are far enough into a chapter, seek back to the
 1002|       |                // beginning of current chapter instead of previous one
 1003|      0|                if (current_chapter_start != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1003:21): [True: 0, False: 0]
  ------------------
 1004|      0|                    get_current_time(mpctx) - current_chapter_start >
  ------------------
  |  Branch (1004:21): [True: 0, False: 0]
  ------------------
 1005|      0|                    mpctx->opts->chapter_seek_threshold)
 1006|      0|                {
 1007|      0|                    step_all++;
 1008|      0|                }
 1009|      0|            }
 1010|      0|        } else // Absolute set
 1011|      0|            step_all = *(int *)arg - chapter;
 1012|      0|        chapter += step_all;
 1013|      0|        if (chapter < 0) // avoid using -1 if first chapter starts at 0
  ------------------
  |  Branch (1013:13): [True: 0, False: 0]
  ------------------
 1014|      0|            chapter = (chapter_start_time(mpctx, 0) <= 0) ? 0 : -1;
  ------------------
  |  Branch (1014:23): [True: 0, False: 0]
  ------------------
 1015|      0|        if (chapter >= num && step_all > 0) {
  ------------------
  |  Branch (1015:13): [True: 0, False: 0]
  |  Branch (1015:31): [True: 0, False: 0]
  ------------------
 1016|      0|            if (mpctx->opts->keep_open) {
  ------------------
  |  Branch (1016:17): [True: 0, False: 0]
  ------------------
 1017|      0|                seek_to_last_frame(mpctx);
 1018|      0|            } else {
 1019|       |                // semi-broken file; ignore for user convenience
 1020|      0|                if (action == M_PROPERTY_SWITCH && num < 2)
  ------------------
  |  Branch (1020:21): [True: 0, False: 0]
  |  Branch (1020:52): [True: 0, False: 0]
  ------------------
 1021|      0|                    return M_PROPERTY_UNAVAILABLE;
 1022|      0|                if (!mpctx->stop_play)
  ------------------
  |  Branch (1022:21): [True: 0, False: 0]
  ------------------
 1023|      0|                    mpctx->stop_play = PT_NEXT_ENTRY;
 1024|      0|                mp_wakeup_core(mpctx);
 1025|      0|            }
 1026|      0|        } else {
 1027|      0|            double pts = chapter_start_time(mpctx, chapter);
 1028|      0|            if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1028:17): [True: 0, False: 0]
  ------------------
 1029|      0|                queue_seek(mpctx, MPSEEK_CHAPTER, pts, MPSEEK_DEFAULT, 0);
 1030|      0|                mpctx->last_chapter_seek = chapter;
 1031|      0|                mpctx->last_chapter_flag = true;
 1032|      0|            }
 1033|      0|        }
 1034|      0|        return M_PROPERTY_OK;
 1035|      0|    }
 1036|      0|    return M_PROPERTY_NOT_IMPLEMENTED;
 1037|      0|}
command.c:mp_property_edition:
 1181|     36|{
 1182|     36|    MPContext *mpctx = ctx;
 1183|     36|    struct demuxer *demuxer = mpctx->demuxer;
 1184|     36|    char *name = NULL;
 1185|       |
 1186|     36|    if (!demuxer)
  ------------------
  |  Branch (1186:9): [True: 24, False: 12]
  ------------------
 1187|     24|        return mp_property_generic_option(mpctx, prop, action, arg);
 1188|       |
 1189|     12|    int ed = demuxer->edition;
 1190|       |
 1191|     12|    if (demuxer->num_editions <= 1)
  ------------------
  |  Branch (1191:9): [True: 12, False: 0]
  ------------------
 1192|     12|        return M_PROPERTY_UNAVAILABLE;
 1193|       |
 1194|      0|    switch (action) {
 1195|      0|    case M_PROPERTY_GET_CONSTRICTED_TYPE: {
  ------------------
  |  Branch (1195:5): [True: 0, False: 0]
  ------------------
 1196|      0|        *(struct m_option *)arg = (struct m_option){
 1197|      0|            .type = CONF_TYPE_INT,
  ------------------
  |  |  240|      0|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
 1198|      0|            .min = 0,
 1199|      0|            .max = demuxer->num_editions - 1,
 1200|      0|        };
 1201|      0|        return M_PROPERTY_OK;
 1202|      0|    }
 1203|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (1203:5): [True: 0, False: 0]
  ------------------
 1204|      0|        if (ed < 0)
  ------------------
  |  Branch (1204:13): [True: 0, False: 0]
  ------------------
 1205|      0|            return M_PROPERTY_UNAVAILABLE;
 1206|      0|        name = mp_tags_get_str(demuxer->editions[ed].metadata, "title");
 1207|      0|        if (name) {
  ------------------
  |  Branch (1207:13): [True: 0, False: 0]
  ------------------
 1208|      0|            *(char **) arg = talloc_strdup(NULL, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1209|      0|        } else {
 1210|      0|            *(char **) arg = talloc_asprintf(NULL, "%d", ed + 1);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1211|      0|        }
 1212|      0|        return M_PROPERTY_OK;
 1213|      0|    }
 1214|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (1214:5): [True: 0, False: 0]
  ------------------
 1215|       |        // For disc demuxers, jump the title directly, we sometimes need to
 1216|       |        // react even if the actual edition "value" doesn't change.
 1217|      0|        if (disc_nav_get_stream(mpctx)) {
  ------------------
  |  Branch (1217:13): [True: 0, False: 0]
  ------------------
 1218|      0|            int new_ed = *(int *)arg;
 1219|      0|            if (new_ed < 0 || new_ed >= demuxer->num_editions)
  ------------------
  |  Branch (1219:17): [True: 0, False: 0]
  |  Branch (1219:31): [True: 0, False: 0]
  ------------------
 1220|      0|                return M_PROPERTY_ERROR;
 1221|      0|            unsigned new_title = new_ed;
 1222|      0|            if (stream_control(demuxer->stream, STREAM_CTRL_SET_CURRENT_TITLE,
  ------------------
  |  Branch (1222:17): [True: 0, False: 0]
  ------------------
 1223|      0|                               &new_title) < 1)
 1224|      0|                return M_PROPERTY_ERROR;
 1225|      0|            mpctx->opts->edition_id = new_ed;
 1226|      0|            m_config_notify_change_opt_ptr(mpctx->mconfig,
 1227|      0|                                           &mpctx->opts->edition_id);
 1228|      0|            mp_notify_property(mpctx, "edition");
 1229|      0|            mp_wakeup_core(mpctx);
 1230|      0|            return M_PROPERTY_OK;
 1231|      0|        }
 1232|      0|        return mp_property_generic_option(mpctx, prop, action, arg);
 1233|      0|    }
 1234|      0|    default:
  ------------------
  |  Branch (1234:5): [True: 0, False: 0]
  ------------------
 1235|      0|        return mp_property_generic_option(mpctx, prop, action, arg);
 1236|      0|    }
 1237|      0|}
command.c:mp_property_current_edition:
 1158|    211|{
 1159|    211|    MPContext *mpctx = ctx;
 1160|    211|    struct demuxer *demuxer = mpctx->demuxer;
 1161|    211|    if (!demuxer || demuxer->num_editions <= 0)
  ------------------
  |  Branch (1161:9): [True: 80, False: 131]
  |  Branch (1161:21): [True: 131, False: 0]
  ------------------
 1162|    211|        return M_PROPERTY_UNAVAILABLE;
 1163|      0|    return m_property_int_ro(action, arg, demuxer->edition);
 1164|    211|}
command.c:mp_property_disc_menu_active:
 1168|     32|{
 1169|     32|    MPContext *mpctx = ctx;
 1170|     32|    struct stream *s = disc_nav_get_stream(mpctx);
 1171|     32|    if (!s)
  ------------------
  |  Branch (1171:9): [True: 32, False: 0]
  ------------------
 1172|     32|        return M_PROPERTY_UNAVAILABLE;
 1173|      0|    struct stream_nav_state st = {0};
 1174|      0|    if (stream_control(s, STREAM_CTRL_GET_NAV_STATE, &st) < 1)
  ------------------
  |  Branch (1174:9): [True: 0, False: 0]
  ------------------
 1175|      0|        return M_PROPERTY_UNAVAILABLE;
 1176|      0|    return m_property_bool_ro(action, arg, st.menu_active);
 1177|      0|}
command.c:mp_property_chapters:
 1311|     94|{
 1312|     94|    MPContext *mpctx = ctx;
 1313|     94|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (1313:9): [True: 48, False: 46]
  ------------------
 1314|     48|        return M_PROPERTY_UNAVAILABLE;
 1315|     46|    int count = get_chapter_count(mpctx);
 1316|     46|    return m_property_int_ro(action, arg, count);
 1317|     94|}
command.c:mp_property_editions:
 1321|     16|{
 1322|     16|    MPContext *mpctx = ctx;
 1323|     16|    struct demuxer *demuxer = mpctx->demuxer;
 1324|     16|    if (!demuxer)
  ------------------
  |  Branch (1324:9): [True: 0, False: 16]
  ------------------
 1325|      0|        return M_PROPERTY_UNAVAILABLE;
 1326|     16|    if (demuxer->num_editions <= 0)
  ------------------
  |  Branch (1326:9): [True: 16, False: 0]
  ------------------
 1327|     16|        return M_PROPERTY_UNAVAILABLE;
 1328|      0|    return m_property_int_ro(action, arg, demuxer->num_editions);
 1329|     16|}
command.c:mp_property_metadata:
 1429|    209|{
 1430|    209|    MPContext *mpctx = ctx;
 1431|    209|    struct demuxer *demuxer = mpctx->demuxer;
 1432|    209|    if (!demuxer)
  ------------------
  |  Branch (1432:9): [True: 133, False: 76]
  ------------------
 1433|    133|        return M_PROPERTY_UNAVAILABLE;
 1434|       |
 1435|     76|    return tag_property(action, arg, demuxer->metadata);
 1436|    209|}
command.c:tag_property:
 1347|    593|{
 1348|    593|    switch (action) {
  ------------------
  |  Branch (1348:13): [True: 279, False: 314]
  ------------------
 1349|      0|    case M_PROPERTY_GET_NODE: // same as GET, because type==mpv_node
  ------------------
  |  Branch (1349:5): [True: 0, False: 593]
  ------------------
 1350|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (1350:5): [True: 1, False: 592]
  ------------------
 1351|      1|        mpv_node_list *list = talloc_zero(NULL, mpv_node_list);
  ------------------
  |  |   27|      1|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      1|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1352|      1|        mpv_node node = {
 1353|      1|            .format = MPV_FORMAT_NODE_MAP,
 1354|      1|            .u.list = list,
 1355|      1|        };
 1356|      1|        list->num = tags->num_keys;
 1357|      1|        list->values = talloc_array(list, mpv_node, list->num);
  ------------------
  |  |   29|      1|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      1|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1358|      1|        list->keys = talloc_array(list, char*, list->num);
  ------------------
  |  |   29|      1|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      1|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1359|      1|        for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (1359:25): [True: 0, False: 1]
  ------------------
 1360|      0|            list->keys[n] = talloc_strdup(list, tags->keys[n]);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1361|      0|            list->values[n] = (struct mpv_node){
 1362|      0|                .format = MPV_FORMAT_STRING,
 1363|      0|                .u.string = talloc_strdup(list, tags->values[n]),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1364|      0|            };
 1365|      0|        }
 1366|      1|        *(mpv_node*)arg = node;
 1367|      1|        return M_PROPERTY_OK;
 1368|      0|    }
 1369|    278|    case M_PROPERTY_GET_TYPE: {
  ------------------
  |  Branch (1369:5): [True: 278, False: 315]
  ------------------
 1370|    278|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|    278|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 1371|    278|        return M_PROPERTY_OK;
 1372|      0|    }
 1373|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (1373:5): [True: 0, False: 593]
  ------------------
 1374|      0|        char *res = NULL;
 1375|      0|        for (int n = 0; n < tags->num_keys; n++) {
  ------------------
  |  Branch (1375:25): [True: 0, False: 0]
  ------------------
 1376|      0|            res = talloc_asprintf_append_buffer(res, "%s: %s\n",
  ------------------
  |  |   64|      0|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
 1377|      0|                                                tags->keys[n], tags->values[n]);
 1378|      0|        }
 1379|      0|        if (!res)
  ------------------
  |  Branch (1379:13): [True: 0, False: 0]
  ------------------
 1380|      0|            res = talloc_strdup(NULL, "(empty)");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1381|      0|        *(char **)arg = res;
 1382|      0|        return M_PROPERTY_OK;
 1383|      0|    }
 1384|      0|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (1384:5): [True: 0, False: 593]
  ------------------
 1385|      0|        struct m_property_action_arg *ka = arg;
 1386|      0|        bstr key;
 1387|      0|        const char *rem;
 1388|      0|        m_property_split_path(ka->key, &key, &rem);
 1389|      0|        if (bstr_equals0(key, "list")) {
  ------------------
  |  Branch (1389:13): [True: 0, False: 0]
  ------------------
 1390|      0|            struct m_property_action_arg nka = *ka;
 1391|      0|            nka.key = rem;
 1392|      0|            return m_property_read_list(action, &nka, tags->num_keys,
 1393|      0|                                        get_tag_entry, tags);
 1394|      0|        }
 1395|       |        // Direct access without this prefix is allowed for compatibility.
 1396|      0|        bstr k = bstr0(ka->key);
 1397|      0|        bstr_eatstart0(&k, "by-key/");
 1398|      0|        switch (ka->action) {
  ------------------
  |  Branch (1398:17): [True: 0, False: 0]
  ------------------
 1399|      0|        case M_PROPERTY_GET: {
  ------------------
  |  Branch (1399:9): [True: 0, False: 0]
  ------------------
 1400|      0|            char *meta = mp_tags_get_bstr(tags, k);
 1401|      0|            if (!meta)
  ------------------
  |  Branch (1401:17): [True: 0, False: 0]
  ------------------
 1402|      0|                return M_PROPERTY_UNKNOWN;
 1403|      0|            *(char **)ka->arg = talloc_strdup(NULL, meta);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1404|      0|            return M_PROPERTY_OK;
 1405|      0|        }
 1406|      0|        case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (1406:9): [True: 0, False: 0]
  ------------------
 1407|      0|            *(struct m_option *)ka->arg = (struct m_option){
 1408|      0|                .type = CONF_TYPE_STRING,
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 1409|      0|            };
 1410|      0|            return M_PROPERTY_OK;
 1411|      0|        case M_PROPERTY_SET: {
  ------------------
  |  Branch (1411:9): [True: 0, False: 0]
  ------------------
 1412|      0|            bstr v = bstr0(*(char **)ka->arg);
 1413|      0|            if (v.len == 0) {
  ------------------
  |  Branch (1413:17): [True: 0, False: 0]
  ------------------
 1414|      0|                mp_tags_remove_bstr(tags, k);
 1415|      0|            } else {
 1416|      0|                mp_tags_set_bstr(tags, k, v);
 1417|      0|            }
 1418|      0|            return M_PROPERTY_OK;
 1419|      0|        }
 1420|      0|        }
 1421|      0|    }
 1422|    593|    }
 1423|    314|    return M_PROPERTY_NOT_IMPLEMENTED;
 1424|    593|}
command.c:mp_property_filtered_metadata:
 1440|    993|{
 1441|    993|    MPContext *mpctx = ctx;
 1442|    993|    if (!mpctx->filtered_tags)
  ------------------
  |  Branch (1442:9): [True: 476, False: 517]
  ------------------
 1443|    476|        return M_PROPERTY_UNAVAILABLE;
 1444|       |
 1445|    517|    return tag_property(action, arg, mpctx->filtered_tags);
 1446|    993|}
command.c:mp_property_chapter_metadata:
 1450|     40|{
 1451|     40|    MPContext *mpctx = ctx;
 1452|     40|    int chapter = get_current_chapter(mpctx);
 1453|     40|    if (chapter < 0)
  ------------------
  |  Branch (1453:9): [True: 40, False: 0]
  ------------------
 1454|     40|        return M_PROPERTY_UNAVAILABLE;
 1455|      0|    return tag_property(action, arg, mpctx->chapters[chapter].metadata);
 1456|     40|}
command.c:mp_property_filter_metadata:
 1460|     12|{
 1461|     12|    MPContext *mpctx = ctx;
 1462|     12|    const char *type = prop->priv;
 1463|       |
 1464|     12|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (1464:9): [True: 0, False: 12]
  ------------------
 1465|      0|        struct m_property_action_arg *ka = arg;
 1466|      0|        bstr key;
 1467|      0|        const char *rem;
 1468|      0|        m_property_split_path(ka->key, &key, &rem);
 1469|      0|        struct mp_tags *metadata = NULL;
 1470|      0|        struct mp_output_chain *chain = NULL;
 1471|      0|        if (strcmp(type, "vf") == 0) {
  ------------------
  |  Branch (1471:13): [True: 0, False: 0]
  ------------------
 1472|      0|            chain = mpctx->vo_chain ? mpctx->vo_chain->filter : NULL;
  ------------------
  |  Branch (1472:21): [True: 0, False: 0]
  ------------------
 1473|      0|        } else if (strcmp(type, "af") == 0) {
  ------------------
  |  Branch (1473:20): [True: 0, False: 0]
  ------------------
 1474|      0|            chain = mpctx->ao_chain ? mpctx->ao_chain->filter : NULL;
  ------------------
  |  Branch (1474:21): [True: 0, False: 0]
  ------------------
 1475|      0|        }
 1476|      0|        if (!chain)
  ------------------
  |  Branch (1476:13): [True: 0, False: 0]
  ------------------
 1477|      0|            return M_PROPERTY_UNAVAILABLE;
 1478|       |
 1479|      0|        int remaining = strlen(rem);
 1480|      0|        if (remaining || ka->action != M_PROPERTY_GET_TYPE) {
  ------------------
  |  Branch (1480:13): [True: 0, False: 0]
  |  Branch (1480:26): [True: 0, False: 0]
  ------------------
 1481|      0|            struct mp_filter_command cmd = {
 1482|      0|                .type = MP_FILTER_COMMAND_GET_META,
 1483|      0|                .res = &metadata,
 1484|      0|            };
 1485|      0|            mp_output_chain_command(chain, mp_tprintf(80, "%.*s", BSTR_P(key)),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (195:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1486|      0|                                    &cmd);
 1487|       |
 1488|      0|            if (!metadata)
  ------------------
  |  Branch (1488:17): [True: 0, False: 0]
  ------------------
 1489|      0|                return M_PROPERTY_ERROR;
 1490|      0|        }
 1491|       |
 1492|      0|        int res;
 1493|      0|        if (remaining) {
  ------------------
  |  Branch (1493:13): [True: 0, False: 0]
  ------------------
 1494|      0|            struct m_property_action_arg next_ka = *ka;
 1495|      0|            next_ka.key = rem;
 1496|      0|            res = tag_property(M_PROPERTY_KEY_ACTION, &next_ka, metadata);
 1497|      0|        } else {
 1498|      0|            res = tag_property(ka->action, ka->arg, metadata);
 1499|      0|        }
 1500|      0|        talloc_free(metadata);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1501|      0|        return res;
 1502|      0|    }
 1503|     12|    return M_PROPERTY_NOT_IMPLEMENTED;
 1504|     12|}
command.c:mp_property_core_idle:
 1508|     48|{
 1509|     48|    MPContext *mpctx = ctx;
 1510|     48|    return m_property_bool_ro(action, arg, !mpctx->playback_active);
 1511|     48|}
command.c:mp_property_eof_reached:
 1545|      8|{
 1546|      8|    MPContext *mpctx = ctx;
 1547|      8|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (1547:9): [True: 8, False: 0]
  ------------------
 1548|      8|        return M_PROPERTY_UNAVAILABLE;
 1549|      8|    bool eof = mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1549:16): [True: 0, False: 0]
  ------------------
 1550|      0|               mpctx->audio_status == STATUS_EOF;
  ------------------
  |  Branch (1550:16): [True: 0, False: 0]
  ------------------
 1551|      0|    return m_property_bool_ro(action, arg, eof);
 1552|      8|}
command.c:mp_property_seeking:
 1556|     79|{
 1557|     79|    MPContext *mpctx = ctx;
 1558|     79|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (1558:9): [True: 59, False: 20]
  ------------------
 1559|     59|        return M_PROPERTY_UNAVAILABLE;
 1560|     20|    return m_property_bool_ro(action, arg, !mpctx->restart_complete);
 1561|     79|}
command.c:mp_property_playback_abort:
 1565|    192|{
 1566|    192|    MPContext *mpctx = ctx;
 1567|    192|    return m_property_bool_ro(action, arg, !mpctx->playing || mpctx->stop_play);
  ------------------
  |  Branch (1567:44): [True: 144, False: 48]
  |  Branch (1567:63): [True: 0, False: 48]
  ------------------
 1568|    192|}
command.c:mp_property_cache_speed:
 1572|     24|{
 1573|     24|    MPContext *mpctx = ctx;
 1574|     24|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1574:9): [True: 5, False: 19]
  ------------------
 1575|      5|        return M_PROPERTY_UNAVAILABLE;
 1576|       |
 1577|     19|    struct demux_reader_state s;
 1578|     19|    demux_get_reader_state(mpctx->demuxer, &s);
 1579|       |
 1580|     19|    uint64_t val = s.bytes_per_second;
 1581|       |
 1582|     19|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (1582:9): [True: 0, False: 19]
  ------------------
 1583|      0|        *(char **)arg = talloc_strdup_append(format_file_size(val), "/s");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 1584|      0|        return M_PROPERTY_OK;
 1585|      0|    }
 1586|     19|    return m_property_int64_ro(action, arg, val);
 1587|     19|}
command.c:mp_property_demuxer_cache_duration:
 1591|     70|{
 1592|     70|    MPContext *mpctx = ctx;
 1593|     70|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1593:9): [True: 16, False: 54]
  ------------------
 1594|     16|        return M_PROPERTY_UNAVAILABLE;
 1595|       |
 1596|     54|    struct demux_reader_state s;
 1597|     54|    demux_get_reader_state(mpctx->demuxer, &s);
 1598|       |
 1599|     54|    if (s.ts_info.duration < 0)
  ------------------
  |  Branch (1599:9): [True: 0, False: 54]
  ------------------
 1600|      0|        return M_PROPERTY_UNAVAILABLE;
 1601|       |
 1602|     54|    return m_property_double_ro(action, arg, s.ts_info.duration);
 1603|     54|}
command.c:mp_property_demuxer_cache_time:
 1607|      5|{
 1608|      5|    MPContext *mpctx = ctx;
 1609|      5|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1609:9): [True: 0, False: 5]
  ------------------
 1610|      0|        return M_PROPERTY_UNAVAILABLE;
 1611|       |
 1612|      5|    struct demux_reader_state s;
 1613|      5|    demux_get_reader_state(mpctx->demuxer, &s);
 1614|       |
 1615|      5|    if (s.ts_info.end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      5|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1615:9): [True: 0, False: 5]
  ------------------
 1616|      0|        return M_PROPERTY_UNAVAILABLE;
 1617|       |
 1618|      5|    return m_property_double_ro(action, arg, s.ts_info.end);
 1619|      5|}
command.c:mp_property_demuxer_cache_idle:
 1623|     27|{
 1624|     27|    MPContext *mpctx = ctx;
 1625|     27|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1625:9): [True: 13, False: 14]
  ------------------
 1626|     13|        return M_PROPERTY_UNAVAILABLE;
 1627|       |
 1628|     14|    struct demux_reader_state s;
 1629|     14|    demux_get_reader_state(mpctx->demuxer, &s);
 1630|       |
 1631|     14|    return m_property_bool_ro(action, arg, s.idle);
 1632|     27|}
command.c:mp_property_demuxer_start_time:
 1715|      6|{
 1716|      6|    MPContext *mpctx = ctx;
 1717|      6|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1717:9): [True: 0, False: 6]
  ------------------
 1718|      0|        return M_PROPERTY_UNAVAILABLE;
 1719|       |
 1720|      6|    return m_property_double_ro(action, arg, mpctx->demuxer->start_time);
 1721|      6|}
command.c:mp_property_demuxer_cache_state:
 1636|    237|{
 1637|    237|    MPContext *mpctx = ctx;
 1638|    237|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1638:9): [True: 16, False: 221]
  ------------------
 1639|     16|        return M_PROPERTY_UNAVAILABLE;
 1640|       |
 1641|    221|    if (action == M_PROPERTY_GET_TYPE) {
  ------------------
  |  Branch (1641:9): [True: 110, False: 111]
  ------------------
 1642|    110|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|    110|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 1643|    110|        return M_PROPERTY_OK;
 1644|    110|    }
 1645|    111|    if (action != M_PROPERTY_GET)
  ------------------
  |  Branch (1645:9): [True: 110, False: 1]
  ------------------
 1646|    110|        return M_PROPERTY_NOT_IMPLEMENTED;
 1647|       |
 1648|      1|    struct demux_reader_state s;
 1649|      1|    demux_get_reader_state(mpctx->demuxer, &s);
 1650|       |
 1651|      1|    struct mpv_node *r = (struct mpv_node *)arg;
 1652|      1|    node_init(r, MPV_FORMAT_NODE_MAP, NULL);
 1653|       |
 1654|      1|    if (s.ts_info.end != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1654:9): [True: 1, False: 0]
  ------------------
 1655|      1|        node_map_add_double(r, "cache-end", s.ts_info.end);
 1656|       |
 1657|      1|    if (s.ts_info.reader != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1657:9): [True: 1, False: 0]
  ------------------
 1658|      1|        node_map_add_double(r, "reader-pts", s.ts_info.reader);
 1659|       |
 1660|      1|    if (s.ts_info.duration >= 0)
  ------------------
  |  Branch (1660:9): [True: 1, False: 0]
  ------------------
 1661|      1|        node_map_add_double(r, "cache-duration", s.ts_info.duration);
 1662|       |
 1663|      1|    node_map_add_flag(r, "eof", s.eof);
 1664|      1|    node_map_add_flag(r, "underrun", s.underrun);
 1665|      1|    node_map_add_flag(r, "idle", s.idle);
 1666|      1|    node_map_add_int64(r, "total-bytes", s.total_bytes);
 1667|      1|    node_map_add_int64(r, "fw-bytes", s.fw_bytes);
 1668|      1|    if (s.file_cache_bytes >= 0)
  ------------------
  |  Branch (1668:9): [True: 0, False: 1]
  ------------------
 1669|      0|        node_map_add_int64(r, "file-cache-bytes", s.file_cache_bytes);
 1670|      1|    if (s.bytes_per_second > 0)
  ------------------
  |  Branch (1670:9): [True: 0, False: 1]
  ------------------
 1671|      0|        node_map_add_int64(r, "raw-input-rate", s.bytes_per_second);
 1672|      1|    if (s.seeking != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1672:9): [True: 0, False: 1]
  ------------------
 1673|      0|        node_map_add_double(r, "debug-seeking", s.seeking);
 1674|      1|    node_map_add_int64(r, "debug-low-level-seeks", s.low_level_seeks);
 1675|      1|    node_map_add_int64(r, "debug-byte-level-seeks", s.byte_level_seeks);
 1676|      1|    if (s.ts_last != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1676:9): [True: 1, False: 0]
  ------------------
 1677|      1|        node_map_add_double(r, "debug-ts-last", s.ts_last);
 1678|       |
 1679|      1|    struct mpv_node *stream_types =
 1680|      1|        node_map_add(r, "ts-per-stream", MPV_FORMAT_NODE_ARRAY);
 1681|      4|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (1681:21): [True: 3, False: 1]
  ------------------
 1682|      3|        struct demux_ctrl_ts_info ts = s.ts_per_stream[n];
 1683|      3|        if (ts.duration == -1)
  ------------------
  |  Branch (1683:13): [True: 1, False: 2]
  ------------------
 1684|      1|            continue;
 1685|       |
 1686|      2|        struct mpv_node *st = node_array_add(stream_types, MPV_FORMAT_NODE_MAP);
 1687|      2|        node_map_add_string(st, "type",
 1688|      2|            n == STREAM_VIDEO ? "video" :
  ------------------
  |  Branch (1688:13): [True: 1, False: 1]
  ------------------
 1689|      2|            n == STREAM_AUDIO ? "audio" :
  ------------------
  |  Branch (1689:13): [True: 1, False: 0]
  ------------------
 1690|      1|            n == STREAM_SUB ? "subtitle" : "unknown");
  ------------------
  |  Branch (1690:13): [True: 0, False: 0]
  ------------------
 1691|      2|        node_map_add_double(st, "cache-duration", ts.duration);
 1692|      2|        if (ts.reader != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      2|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1692:13): [True: 2, False: 0]
  ------------------
 1693|      2|            node_map_add_double(st, "reader-pts", ts.reader);
 1694|      2|        if (ts.end != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      2|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1694:13): [True: 2, False: 0]
  ------------------
 1695|      2|            node_map_add_double(st, "cache-end", ts.end);
 1696|      2|    }
 1697|       |
 1698|      1|    node_map_add_flag(r, "bof-cached", s.bof_cached);
 1699|      1|    node_map_add_flag(r, "eof-cached", s.eof_cached);
 1700|       |
 1701|      1|    struct mpv_node *ranges =
 1702|      1|        node_map_add(r, "seekable-ranges", MPV_FORMAT_NODE_ARRAY);
 1703|      1|    for (int n = s.num_seek_ranges - 1; n >= 0; n--) {
  ------------------
  |  Branch (1703:41): [True: 0, False: 1]
  ------------------
 1704|      0|        struct demux_seek_range *range = &s.seek_ranges[n];
 1705|      0|        struct mpv_node *sub = node_array_add(ranges, MPV_FORMAT_NODE_MAP);
 1706|      0|        node_map_add_double(sub, "start", range->start);
 1707|      0|        node_map_add_double(sub, "end", range->end);
 1708|      0|    }
 1709|       |
 1710|      1|    return M_PROPERTY_OK;
 1711|    111|}
command.c:mp_property_cache_buffering:
 1734|    512|{
 1735|    512|    MPContext *mpctx = ctx;
 1736|    512|    int state = get_cache_buffering_percentage(mpctx);
 1737|    512|    if (state < 0)
  ------------------
  |  Branch (1737:9): [True: 68, False: 444]
  ------------------
 1738|     68|        return M_PROPERTY_UNAVAILABLE;
 1739|    444|    return m_property_int_ro(action, arg, state);
 1740|    512|}
command.c:mp_property_paused_for_cache:
 1725|     58|{
 1726|     58|    MPContext *mpctx = ctx;
 1727|     58|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (1727:9): [True: 16, False: 42]
  ------------------
 1728|     16|        return M_PROPERTY_UNAVAILABLE;
 1729|     42|    return m_property_bool_ro(action, arg, mpctx->paused_for_cache);
 1730|     58|}
command.c:mp_property_demuxer_is_network:
 1744|      6|{
 1745|      6|    MPContext *mpctx = ctx;
 1746|      6|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1746:9): [True: 0, False: 6]
  ------------------
 1747|      0|        return M_PROPERTY_UNAVAILABLE;
 1748|       |
 1749|      6|    return m_property_bool_ro(action, arg, mpctx->demuxer->is_network);
 1750|      6|}
command.c:mp_property_clock:
 1755|      6|{
 1756|      6|    char outstr[6];
 1757|      6|    time_t t = time(NULL);
 1758|      6|    struct tm *tmp = localtime(&t);
 1759|       |
 1760|      6|    if ((tmp != NULL) && (strftime(outstr, sizeof(outstr), "%H:%M", tmp) == 5))
  ------------------
  |  Branch (1760:9): [True: 6, False: 0]
  |  Branch (1760:26): [True: 6, False: 0]
  ------------------
 1761|      6|        return m_property_strdup_ro(action, arg, outstr);
 1762|      0|    return M_PROPERTY_UNAVAILABLE;
 1763|      6|}
command.c:mp_property_seekable:
 1767|    144|{
 1768|    144|    MPContext *mpctx = ctx;
 1769|    144|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1769:9): [True: 120, False: 24]
  ------------------
 1770|    120|        return M_PROPERTY_UNAVAILABLE;
 1771|     24|    return m_property_bool_ro(action, arg, mpctx->demuxer->seekable);
 1772|    144|}
command.c:mp_property_partially_seekable:
 1776|     31|{
 1777|     31|    MPContext *mpctx = ctx;
 1778|     31|    if (!mpctx->demuxer)
  ------------------
  |  Branch (1778:9): [True: 25, False: 6]
  ------------------
 1779|     25|        return M_PROPERTY_UNAVAILABLE;
 1780|      6|    return m_property_bool_ro(action, arg, mpctx->demuxer->partially_seekable);
 1781|     31|}
command.c:mp_property_deinterlace:
 1515|     18|{
 1516|     18|    MPContext *mpctx = ctx;
 1517|     18|    struct vo_chain *vo_c = mpctx->vo_chain;
 1518|     18|    if (!vo_c)
  ------------------
  |  Branch (1518:9): [True: 3, False: 15]
  ------------------
 1519|      3|        return M_PROPERTY_UNAVAILABLE;
 1520|       |
 1521|     18|    bool deinterlace_active = mp_output_chain_deinterlace_active(vo_c->filter);
 1522|     15|    return m_property_bool_ro(action, arg, deinterlace_active);
 1523|     18|}
command.c:mp_property_idle:
 1527|  49.9k|{
 1528|  49.9k|    MPContext *mpctx = ctx;
 1529|  49.9k|    return m_property_bool_ro(action, arg, mpctx->stop_play == PT_STOP);
 1530|  49.9k|}
command.c:mp_property_window_id:
 1534|    128|{
 1535|    128|    MPContext *mpctx = ctx;
 1536|    128|    struct vo *vo = mpctx->video_out;
 1537|    128|    int64_t wid;
 1538|    128|    if (!vo || vo_control(vo, VOCTRL_GET_WINDOW_ID, &wid) <= 0)
  ------------------
  |  Branch (1538:9): [True: 88, False: 40]
  |  Branch (1538:16): [True: 40, False: 0]
  ------------------
 1539|    128|        return M_PROPERTY_UNAVAILABLE;
 1540|      0|    return m_property_int64_ro(action, arg, wid);
 1541|    128|}
command.c:mp_property_vo_display_swapchain:
 2681|    308|{
 2682|    308|    MPContext *mpctx = ctx;
 2683|    308|    struct vo *vo = mpctx->video_out;
 2684|    308|    if (!vo)
  ------------------
  |  Branch (2684:9): [True: 72, False: 236]
  ------------------
 2685|     72|        return M_PROPERTY_UNAVAILABLE;
 2686|       |
 2687|    236|    void *swapchain_ptr = vo_get_display_swapchain(vo);
 2688|    236|    if (swapchain_ptr == NULL)
  ------------------
  |  Branch (2688:9): [True: 236, False: 0]
  ------------------
 2689|    236|        return M_PROPERTY_UNAVAILABLE;
 2690|       |
 2691|      0|    int64_t swapchain = (intptr_t)swapchain_ptr;
 2692|       |
 2693|      0|    return m_property_int64_ro(action, arg, swapchain);
 2694|    236|}
command.c:mp_property_player_operation_mode:
 3247|     63|{
 3248|     63|    MPContext *mpctx = ctx;
 3249|     63|    const struct m_opt_choice_alternatives mode_names[] = {{"cplayer", 0}, {"pseudo-gui", 1}};
 3250|     63|    return m_property_strdup_ro(action, arg, m_opt_choice_str(mode_names, mpctx->opts->operation_mode));
 3251|     63|}
command.c:mp_property_list_tracks:
 2309|    241|{
 2310|    241|    MPContext *mpctx = ctx;
 2311|    241|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (2311:9): [True: 0, False: 241]
  ------------------
 2312|      0|        char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2313|       |
 2314|      0|        int spacing = 0;
 2315|      0|        for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (2315:28): [True: 0, False: 0]
  ------------------
 2316|      0|            for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2316:29): [True: 0, False: 0]
  ------------------
 2317|      0|                struct track *track = mpctx->tracks[n];
 2318|      0|                if (track->type != type)
  ------------------
  |  Branch (2318:21): [True: 0, False: 0]
  ------------------
 2319|      0|                    continue;
 2320|      0|                if (!track_is_visible(mpctx, track))
  ------------------
  |  Branch (2320:21): [True: 0, False: 0]
  ------------------
 2321|      0|                    continue;
 2322|      0|                res = talloc_asprintf_append(res, "%s%s: ",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 2323|      0|                    spacing == 2 ? "\n\n" : spacing == 1 ? "\n" : "",
  ------------------
  |  Branch (2323:21): [True: 0, False: 0]
  |  Branch (2323:45): [True: 0, False: 0]
  ------------------
 2324|      0|                    track_type_name(track));
 2325|      0|                res = append_track_info(res, track);
 2326|      0|                spacing = 1;
 2327|      0|            }
 2328|      0|            if (spacing)
  ------------------
  |  Branch (2328:17): [True: 0, False: 0]
  ------------------
 2329|      0|                spacing = 2;
 2330|      0|        }
 2331|       |
 2332|      0|        struct demuxer *demuxer = mpctx->demuxer;
 2333|      0|        if (demuxer && demuxer->num_editions > 1) {
  ------------------
  |  Branch (2333:13): [True: 0, False: 0]
  |  Branch (2333:24): [True: 0, False: 0]
  ------------------
 2334|      0|            res = talloc_asprintf_append(res, "%sEdition: %d of %d",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 2335|      0|                                         spacing == 2 ? "\n\n" : "",
  ------------------
  |  Branch (2335:42): [True: 0, False: 0]
  ------------------
 2336|      0|                                         demuxer->edition + 1,
 2337|      0|                                         demuxer->num_editions);
 2338|      0|        }
 2339|       |
 2340|      0|        *(char **)arg = res;
 2341|      0|        return M_PROPERTY_OK;
 2342|      0|    }
 2343|       |
 2344|    241|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (2344:9): [True: 212, False: 29]
  ------------------
 2345|    212|        struct m_property_action_arg *ka = arg;
 2346|       |
 2347|    212|        int type = -1;
 2348|    212|        if (!strcmp(ka->key, "video")) {
  ------------------
  |  Branch (2348:13): [True: 0, False: 212]
  ------------------
 2349|      0|            type = STREAM_VIDEO;
 2350|    212|        } else if (!strcmp(ka->key, "audio")) {
  ------------------
  |  Branch (2350:20): [True: 0, False: 212]
  ------------------
 2351|      0|            type = STREAM_AUDIO;
 2352|    212|        } else if (!strcmp(ka->key, "sub")) {
  ------------------
  |  Branch (2352:20): [True: 0, False: 212]
  ------------------
 2353|      0|            type = STREAM_SUB;
 2354|      0|        }
 2355|       |
 2356|    212|        if (type != -1) {
  ------------------
  |  Branch (2356:13): [True: 0, False: 212]
  ------------------
 2357|      0|            char *res;
 2358|       |
 2359|      0|            switch (ka->action) {
 2360|      0|                case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (2360:17): [True: 0, False: 0]
  ------------------
 2361|      0|                    *(struct m_option *)ka->arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 2362|      0|                    return M_PROPERTY_OK;
 2363|      0|                case M_PROPERTY_PRINT:
  ------------------
  |  Branch (2363:17): [True: 0, False: 0]
  ------------------
 2364|      0|                    res = talloc_asprintf(NULL, "Available %s tracks:",
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2365|      0|                              type == STREAM_SUB ? "subtitle" : stream_type_name(type));
 2366|       |
 2367|      0|                    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2367:37): [True: 0, False: 0]
  ------------------
 2368|      0|                        struct track *track = mpctx->tracks[n];
 2369|      0|                        if (track->type == type && track_is_visible(mpctx, track)) {
  ------------------
  |  Branch (2369:29): [True: 0, False: 0]
  |  Branch (2369:52): [True: 0, False: 0]
  ------------------
 2370|      0|                            res = talloc_strdup_append(res, "\n");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 2371|      0|                            res = append_track_info(res, track);
 2372|      0|                        }
 2373|      0|                    }
 2374|       |
 2375|      0|                    *(char **)ka->arg = res;
 2376|      0|                    return M_PROPERTY_OK;
 2377|      0|                default:
  ------------------
  |  Branch (2377:17): [True: 0, False: 0]
  ------------------
 2378|      0|                    return M_PROPERTY_NOT_IMPLEMENTED;
 2379|      0|            }
 2380|      0|        }
 2381|    212|    }
 2382|       |
 2383|    241|    int *map = talloc_array(NULL, int, mpctx->num_tracks);
  ------------------
  |  |   29|    241|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|    241|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    241|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2384|    241|    int count = 0;
 2385|    789|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2385:21): [True: 548, False: 241]
  ------------------
 2386|    548|        if (track_is_visible(mpctx, mpctx->tracks[n]))
  ------------------
  |  Branch (2386:13): [True: 548, False: 0]
  ------------------
 2387|    548|            map[count++] = n;
 2388|    548|    }
 2389|    241|    struct filtered_track_ctx ft = { .mpctx = mpctx, .map = map };
 2390|    241|    int r = m_property_read_list(action, arg, count, get_filtered_track_entry, &ft);
 2391|    241|    talloc_free(map);
  ------------------
  |  |   47|    241|#define talloc_free                     ta_free
  ------------------
 2392|    241|    return r;
 2393|    241|}
command.c:get_filtered_track_entry:
 2302|    212|{
 2303|    212|    struct filtered_track_ctx *ft = ctx;
 2304|    212|    return get_track_entry(ft->map[item], action, arg, ft->mpctx);
 2305|    212|}
command.c:get_track_entry:
 2129|    212|{
 2130|    212|    struct MPContext *mpctx = ctx;
 2131|    212|    struct track *track = mpctx->tracks[item];
 2132|       |
 2133|    212|    struct mp_codec_params p =
 2134|    212|        track->stream ? *track->stream->codec : (struct mp_codec_params){0};
  ------------------
  |  Branch (2134:9): [True: 212, False: 0]
  ------------------
 2135|       |
 2136|    212|    bool has_rg = track->stream && track->stream->codec->replaygain_data;
  ------------------
  |  Branch (2136:19): [True: 212, False: 0]
  |  Branch (2136:36): [True: 0, False: 212]
  ------------------
 2137|    212|    struct replaygain_data rg = has_rg ? *track->stream->codec->replaygain_data
  ------------------
  |  Branch (2137:33): [True: 0, False: 212]
  ------------------
 2138|    212|                                       : (struct replaygain_data){0};
 2139|       |
 2140|    212|    struct mp_tags *tags = track->stream ? track->stream->tags : &(struct mp_tags){0};
  ------------------
  |  Branch (2140:28): [True: 212, False: 0]
  ------------------
 2141|    212|    char **tag_list = talloc_zero_array(NULL, char *, tags->num_keys * 2 + 1);
  ------------------
  |  |   30|    212|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|    212|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    212|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2142|    212|    for (int i = 0; i < tags->num_keys; i++) {
  ------------------
  |  Branch (2142:21): [True: 0, False: 212]
  ------------------
 2143|      0|        tag_list[2 * i] = talloc_strdup(tag_list, tags->keys[i]);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2144|      0|        tag_list[2 * i + 1] = talloc_strdup(tag_list, tags->values[i]);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2145|      0|    }
 2146|       |
 2147|    212|    struct sh_stream *sh = track->stream;
 2148|       |
 2149|    212|    double par = 0.0;
 2150|    212|    if (p.dar_h && p.disp_w)
  ------------------
  |  Branch (2150:9): [True: 0, False: 212]
  |  Branch (2150:20): [True: 0, False: 0]
  ------------------
 2151|      0|        par = p.dar_w * (double) p.disp_h / (p.dar_h * (double) p.disp_w);
 2152|    212|    else if (p.par_h)
  ------------------
  |  Branch (2152:14): [True: 174, False: 38]
  ------------------
 2153|    174|        par = p.par_w / (double) p.par_h;
 2154|       |
 2155|    212|    int order = -1;
 2156|    212|    if (track->selected) {
  ------------------
  |  Branch (2156:9): [True: 212, False: 0]
  ------------------
 2157|    212|        for (int i = 0; i < num_ptracks[track->type]; i++) {
  ------------------
  |  Branch (2157:25): [True: 212, False: 0]
  ------------------
 2158|    212|            if (mpctx->current_track[i][track->type] == track) {
  ------------------
  |  Branch (2158:17): [True: 212, False: 0]
  ------------------
 2159|    212|                order = i;
 2160|    212|                break;
 2161|    212|            }
 2162|    212|        }
 2163|    212|    }
 2164|       |
 2165|    212|    bool has_crop = mp_rect_w(p.crop) > 0 && mp_rect_h(p.crop) > 0;
  ------------------
  |  |  157|    212|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                  bool has_crop = mp_rect_w(p.crop) > 0 && mp_rect_h(p.crop) > 0;
  ------------------
  |  |  158|      0|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (2165:21): [True: 0, False: 212]
  |  Branch (2165:46): [True: 0, False: 0]
  ------------------
 2166|    212|    struct m_sub_property props[] = {
 2167|    212|        {"id",          SUB_PROP_INT(track->user_tid)},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2168|    212|        {"type",        SUB_PROP_STR(stream_type_name(track->type)),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2169|    212|                        .unavailable = !stream_type_name(track->type)},
 2170|    212|        {"src-id",      SUB_PROP_INT(track->demuxer_id),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2171|    212|                        .unavailable = track->demuxer_id == -1},
 2172|    212|        {"title",       SUB_PROP_STR(track->title),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2173|    212|                        .unavailable = !track->title},
 2174|    212|        {"lang",        SUB_PROP_STR(track->lang),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2175|    212|                        .unavailable = !track->lang},
 2176|    212|        {"audio-channels", SUB_PROP_INT(track_channels(track)),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2177|    212|                        .unavailable = track_channels(track) <= 0},
 2178|    212|        {"image",       SUB_PROP_BOOL(track->image)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2179|    212|        {"albumart",    SUB_PROP_BOOL(track->attached_picture)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2180|    212|        {"default",     SUB_PROP_BOOL(track->default_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2181|    212|        {"forced",      SUB_PROP_BOOL(track->forced_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2182|    212|        {"dependent",   SUB_PROP_BOOL(track->dependent_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2183|    212|        {"visual-impaired",  SUB_PROP_BOOL(track->visual_impaired_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2184|    212|        {"hearing-impaired", SUB_PROP_BOOL(track->hearing_impaired_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2185|    212|        {"original",    SUB_PROP_BOOL(track->original_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2186|    212|        {"commentary",  SUB_PROP_BOOL(track->commentary_track)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2187|    212|        {"external",    SUB_PROP_BOOL(track->is_external)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2188|    212|        {"selected",    SUB_PROP_BOOL(track->selected)},
  ------------------
  |  |  243|    212|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|    212|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2189|    212|        {"main-selection", SUB_PROP_INT(order), .unavailable = order < 0},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2190|    212|        {"external-filename", SUB_PROP_STR(track->external_filename),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2191|    212|                        .unavailable = !track->external_filename},
 2192|    212|        {"ff-index",    SUB_PROP_INT(track->ff_index),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2193|    212|                        .unavailable = track->ff_index == -1},
 2194|    212|        {"hls-bitrate", SUB_PROP_INT(track->hls_bitrate),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2195|    212|                        .unavailable = !track->hls_bitrate},
 2196|    212|        {"program-id",  SUB_PROP_INT(sh && sh->num_program_ids ? sh->program_ids[0] : -1),
  ------------------
  |  |  233|    848|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  |  |  |  Branch (233:57): [True: 212, False: 0]
  |  |  |  Branch (233:57): [True: 0, False: 212]
  |  |  ------------------
  ------------------
 2197|    212|                        .unavailable = !sh || !sh->num_program_ids},
  ------------------
  |  Branch (2197:40): [True: 0, False: 212]
  |  Branch (2197:47): [True: 212, False: 0]
  ------------------
 2198|    212|        {"program-ids", SUB_PROP_INT_ARRAY(sh ? sh->program_ids : NULL,
  ------------------
  |  |  256|    212|#define SUB_PROP_INT_ARRAY(ptr, n)    SUB_PROP_TYPE_ARRAY(CONF_TYPE_INT, ptr, n)
  |  |  ------------------
  |  |  |  |  254|    212|    .type = {.type = &m_option_type_prop_array}, \
  |  |  |  |  255|    424|    .value = {.prop_arr = {.data = (ptr), .count = (n), .elem_type = (etype)}}
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (255:37): [True: 212, False: 0]
  |  |  |  |  |  Branch (255:53): [True: 212, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2199|    212|                                           sh ? sh->num_program_ids : 0),
 2200|    212|                        .unavailable = !sh || !sh->num_program_ids},
  ------------------
  |  Branch (2200:40): [True: 0, False: 212]
  |  Branch (2200:47): [True: 212, False: 0]
  ------------------
 2201|    212|        {"decoder",     SUB_PROP_STR(p.decoder),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2202|    212|                        .unavailable = !p.decoder},
 2203|    212|        {"decoder-desc", SUB_PROP_STR(p.decoder_desc),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2204|    212|                        .unavailable = !p.decoder_desc},
 2205|    212|        {"codec",       SUB_PROP_STR(p.codec),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2206|    212|                        .unavailable = !p.codec},
 2207|    212|        {"codec-desc",  SUB_PROP_STR(p.codec_desc),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2208|    212|                        .unavailable = !p.codec_desc},
 2209|    212|        {"codec-profile", SUB_PROP_STR(p.codec_profile),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2210|    212|                        .unavailable = !p.codec_profile},
 2211|    212|        {"demux-w",     SUB_PROP_INT(p.disp_w), .unavailable = !p.disp_w},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2212|    212|        {"demux-h",     SUB_PROP_INT(p.disp_h), .unavailable = !p.disp_h},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2213|    212|        {"demux-crop-x",SUB_PROP_INT(p.crop.x0), .unavailable = !has_crop},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2214|    212|        {"demux-crop-y",SUB_PROP_INT(p.crop.y0), .unavailable = !has_crop},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2215|    212|        {"demux-crop-w",SUB_PROP_INT(mp_rect_w(p.crop)), .unavailable = !has_crop},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2216|    212|        {"demux-crop-h",SUB_PROP_INT(mp_rect_h(p.crop)), .unavailable = !has_crop},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2217|    212|        {"demux-channel-count", SUB_PROP_INT(p.channels.num),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2218|    212|                        .unavailable = !p.channels.num},
 2219|    212|        {"demux-channels", SUB_PROP_STR(mp_chmap_to_str(&p.channels)),
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2220|    212|                        .unavailable = !p.channels.num},
 2221|    212|        {"demux-samplerate", SUB_PROP_INT(p.samplerate),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2222|    212|                        .unavailable = !p.samplerate},
 2223|    212|        {"demux-fps",   SUB_PROP_DOUBLE(p.fps), .unavailable = p.fps <= 0},
  ------------------
  |  |  241|    212|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|    212|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 2224|    212|        {"demux-bitrate",  SUB_PROP_INT(p.bitrate), .unavailable = p.bitrate <= 0},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2225|    212|        {"demux-rotation", SUB_PROP_INT(p.rotate),  .unavailable = p.rotate <= 0},
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2226|    212|        {"demux-par",      SUB_PROP_DOUBLE(par),    .unavailable = par <= 0},
  ------------------
  |  |  241|    212|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|    212|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 2227|    212|        {"demux-duration", SUB_PROP_PTS(p.duration), .unavailable = p.duration <= 0},
  ------------------
  |  |  245|    212|    .type = {.type = &m_option_type_time}, .value = {.double_ = (f)}
  ------------------
 2228|    212|        {"format-name", SUB_PROP_STR(p.format_name), .unavailable = !p.format_name},
  ------------------
  |  |  237|    212|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|    212|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2229|    212|        {"replaygain-track-peak", SUB_PROP_FLOAT(rg.track_peak),
  ------------------
  |  |  239|    212|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|    212|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2230|    212|                        .unavailable = !has_rg},
 2231|    212|        {"replaygain-track-gain", SUB_PROP_FLOAT(rg.track_gain),
  ------------------
  |  |  239|    212|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|    212|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2232|    212|                        .unavailable = !has_rg},
 2233|    212|        {"replaygain-album-peak", SUB_PROP_FLOAT(rg.album_peak),
  ------------------
  |  |  239|    212|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|    212|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2234|    212|                        .unavailable = !has_rg},
 2235|    212|        {"replaygain-album-gain", SUB_PROP_FLOAT(rg.album_gain),
  ------------------
  |  |  239|    212|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|    212|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2236|    212|                        .unavailable = !has_rg},
 2237|    212|        {"dolby-vision-profile", SUB_PROP_INT(p.dv_profile),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2238|    212|                        .unavailable = !p.dovi},
 2239|    212|        {"dolby-vision-level", SUB_PROP_INT(p.dv_level),
  ------------------
  |  |  233|    212|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    212|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2240|    212|                        .unavailable = !p.dovi},
 2241|    212|        {"metadata", SUB_PROP_KEYVALUE_LIST(tag_list),
  ------------------
  |  |  247|    212|    .type = {.type = &m_option_type_keyvalue_list}, .value = {.keyvalue_list = (l)}
  ------------------
 2242|    212|                        .unavailable = !tags->num_keys},
 2243|    212|        {0}
 2244|    212|    };
 2245|       |
 2246|    212|    int ret = 0;
 2247|    212|    switch (action) {
 2248|    212|    case M_PROPERTY_KEY_ACTION: ;
  ------------------
  |  Branch (2248:5): [True: 212, False: 0]
  ------------------
 2249|    212|        struct m_property_action_arg *ka = arg;
 2250|    212|        if (!strncmp(ka->key, "metadata/", 9)) {
  ------------------
  |  Branch (2250:13): [True: 0, False: 212]
  ------------------
 2251|      0|            bstr key = {0};
 2252|      0|            const char *rem = "";
 2253|      0|            m_property_split_path(ka->key, &key, &rem);
 2254|      0|            ka->key = rem;
 2255|      0|            if (!rem[0]) {
  ------------------
  |  Branch (2255:17): [True: 0, False: 0]
  ------------------
 2256|      0|                ret = M_PROPERTY_ERROR;
 2257|      0|            } else if (tags->num_keys == 0) {
  ------------------
  |  Branch (2257:24): [True: 0, False: 0]
  ------------------
 2258|      0|                ret = M_PROPERTY_UNAVAILABLE;
 2259|      0|            } else {
 2260|      0|                ret = tag_property(action, (void *)ka, tags);
 2261|      0|            }
 2262|      0|            goto done;
 2263|      0|        }
 2264|    212|        MP_FALLTHROUGH;
  ------------------
  |  |   17|    212|#define MP_FALLTHROUGH __attribute__((fallthrough))
  ------------------
 2265|    212|    default:
  ------------------
  |  Branch (2265:5): [True: 0, False: 212]
  ------------------
 2266|    212|        ret = m_property_read_sub(props, action, arg);
 2267|    212|    }
 2268|       |
 2269|    212|done:
 2270|    212|    talloc_free(tag_list);
  ------------------
  |  |   47|    212|#define talloc_free                     ta_free
  ------------------
 2271|    212|    return ret;
 2272|    212|}
command.c:track_channels:
 2124|    424|{
 2125|    424|    return track->stream ? track->stream->codec->channels.num : 0;
  ------------------
  |  Branch (2125:12): [True: 424, False: 0]
  ------------------
 2126|    424|}
command.c:mp_property_current_tracks:
 2397|    358|{
 2398|    358|    MPContext *mpctx = ctx;
 2399|       |
 2400|    358|    if (action != M_PROPERTY_KEY_ACTION)
  ------------------
  |  Branch (2400:9): [True: 12, False: 346]
  ------------------
 2401|     12|        return M_PROPERTY_UNAVAILABLE;
 2402|       |
 2403|    346|    int type = -1;
 2404|    346|    int order = 0;
 2405|       |
 2406|    346|    struct m_property_action_arg *ka = arg;
 2407|    346|    bstr key;
 2408|    346|    const char *rem;
 2409|    346|    m_property_split_path(ka->key, &key, &rem);
 2410|       |
 2411|    346|    if (bstr_equals0(key, "video")) {
  ------------------
  |  Branch (2411:9): [True: 297, False: 49]
  ------------------
 2412|    297|        type = STREAM_VIDEO;
 2413|    297|    } else if (bstr_equals0(key, "audio")) {
  ------------------
  |  Branch (2413:16): [True: 49, False: 0]
  ------------------
 2414|     49|        type = STREAM_AUDIO;
 2415|     49|    } else if (bstr_equals0(key, "sub")) {
  ------------------
  |  Branch (2415:16): [True: 0, False: 0]
  ------------------
 2416|      0|        type = STREAM_SUB;
 2417|      0|    } else if (bstr_equals0(key, "sub2")) {
  ------------------
  |  Branch (2417:16): [True: 0, False: 0]
  ------------------
 2418|      0|        type = STREAM_SUB;
 2419|      0|        order = 1;
 2420|      0|    }
 2421|       |
 2422|    346|    if (type < 0)
  ------------------
  |  Branch (2422:9): [True: 0, False: 346]
  ------------------
 2423|      0|        return M_PROPERTY_UNKNOWN;
 2424|       |
 2425|    346|    struct track *t = mpctx->current_track[order][type];
 2426|       |
 2427|    346|    if (!t && mpctx->lavfi) {
  ------------------
  |  Branch (2427:9): [True: 203, False: 143]
  |  Branch (2427:15): [True: 0, False: 203]
  ------------------
 2428|      0|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2428:25): [True: 0, False: 0]
  ------------------
 2429|      0|            if (mpctx->tracks[n]->type == type && mpctx->tracks[n]->selected) {
  ------------------
  |  Branch (2429:17): [True: 0, False: 0]
  |  Branch (2429:51): [True: 0, False: 0]
  ------------------
 2430|      0|                t = mpctx->tracks[n];
 2431|      0|                break;
 2432|      0|            }
 2433|      0|        }
 2434|      0|    }
 2435|       |
 2436|    346|    if (!t)
  ------------------
  |  Branch (2436:9): [True: 203, False: 143]
  ------------------
 2437|    203|        return M_PROPERTY_UNAVAILABLE;
 2438|       |
 2439|    143|    int index = -1;
 2440|    143|    int filtered_index = 0;
 2441|    181|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2441:21): [True: 181, False: 0]
  ------------------
 2442|    181|        if (!track_is_visible(mpctx, mpctx->tracks[n]))
  ------------------
  |  Branch (2442:13): [True: 0, False: 181]
  ------------------
 2443|      0|            continue;
 2444|    181|        if (mpctx->tracks[n] == t) {
  ------------------
  |  Branch (2444:13): [True: 143, False: 38]
  ------------------
 2445|    143|            index = filtered_index;
 2446|    143|            break;
 2447|    143|        }
 2448|     38|        filtered_index++;
 2449|     38|    }
 2450|    143|    if (index < 0)
  ------------------
  |  Branch (2450:9): [True: 0, False: 143]
  ------------------
 2451|      0|        return M_PROPERTY_UNAVAILABLE;
 2452|       |
 2453|    143|    char *name = mp_tprintf(80, "track-list/%d%s%s", index, *rem ? "/" : "", rem);
  ------------------
  |  |  195|    286|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (195:55): [True: 143, False: 0]
  |  |  ------------------
  ------------------
 2454|    143|    return mp_property_do(name, ka->action, ka->arg, ctx);
 2455|    143|}
command.c:mp_property_list_editions:
 1272|     16|{
 1273|     16|    MPContext *mpctx = ctx;
 1274|     16|    struct demuxer *demuxer = mpctx->demuxer;
 1275|     16|    if (!demuxer)
  ------------------
  |  Branch (1275:9): [True: 4, False: 12]
  ------------------
 1276|      4|        return M_PROPERTY_UNAVAILABLE;
 1277|       |
 1278|     12|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (1278:9): [True: 0, False: 12]
  ------------------
 1279|      0|        char *res = NULL;
 1280|       |
 1281|      0|        struct demux_edition *editions = demuxer->editions;
 1282|      0|        int num_editions = demuxer->num_editions;
 1283|      0|        int current = demuxer->edition;
 1284|       |
 1285|      0|        if (!num_editions)
  ------------------
  |  Branch (1285:13): [True: 0, False: 0]
  ------------------
 1286|      0|            res = talloc_asprintf_append(res, "No editions.");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 1287|       |
 1288|      0|        for (int n = 0; n < num_editions; n++) {
  ------------------
  |  Branch (1288:25): [True: 0, False: 0]
  ------------------
 1289|      0|            struct demux_edition *ed = &editions[n];
 1290|       |
 1291|      0|            if (n == current)
  ------------------
  |  Branch (1291:17): [True: 0, False: 0]
  ------------------
 1292|      0|                res = append_selected_style(mpctx, res);
 1293|      0|            res = talloc_asprintf_append(res, "%d: ", n);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 1294|      0|            char *title = mp_tags_get_str(ed->metadata, "title");
 1295|      0|            if (!title)
  ------------------
  |  Branch (1295:17): [True: 0, False: 0]
  ------------------
 1296|      0|                title = "unnamed";
 1297|      0|            res = talloc_asprintf_append(res, "'%s'%s\n", title,
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 1298|      0|                                         n == current ? get_style_reset(mpctx) : "");
  ------------------
  |  Branch (1298:42): [True: 0, False: 0]
  ------------------
 1299|      0|        }
 1300|       |
 1301|      0|        *(char **)arg = res;
 1302|      0|        return M_PROPERTY_OK;
 1303|      0|    }
 1304|     12|    return m_property_read_list(action, arg, demuxer->num_editions,
 1305|     12|                                get_edition_entry, mpctx);
 1306|     12|}
command.c:mp_property_playlist:
 3793|    444|{
 3794|    444|    MPContext *mpctx = ctx;
 3795|    444|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_PRINT_UNCUT) {
  ------------------
  |  Branch (3795:9): [True: 0, False: 444]
  |  Branch (3795:39): [True: 0, False: 444]
  ------------------
 3796|      0|        struct playlist *pl = mpctx->playlist;
 3797|      0|        char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3798|       |
 3799|      0|        for (int n = 0; n < pl->num_entries; n++) {
  ------------------
  |  Branch (3799:25): [True: 0, False: 0]
  ------------------
 3800|      0|            struct playlist_entry *e = pl->entries[n];
 3801|      0|            if (pl->current == e)
  ------------------
  |  Branch (3801:17): [True: 0, False: 0]
  ------------------
 3802|      0|                res = append_selected_style(mpctx, res);
 3803|      0|            const char *reset = pl->current == e ? get_style_reset(mpctx) : "";
  ------------------
  |  Branch (3803:33): [True: 0, False: 0]
  ------------------
 3804|      0|            const char *p = e->title;
 3805|      0|            if (!p || mpctx->opts->playlist_entry_name > 0) {
  ------------------
  |  Branch (3805:17): [True: 0, False: 0]
  |  Branch (3805:23): [True: 0, False: 0]
  ------------------
 3806|      0|                p = e->filename;
 3807|      0|                if (!mp_is_url(bstr0(p))) {
  ------------------
  |  Branch (3807:21): [True: 0, False: 0]
  ------------------
 3808|      0|                    const char *s = mp_basename(e->filename);
 3809|      0|                    if (s[0])
  ------------------
  |  Branch (3809:25): [True: 0, False: 0]
  ------------------
 3810|      0|                        p = s;
 3811|      0|                }
 3812|      0|            }
 3813|      0|            if (!e->title || p == e->title || mpctx->opts->playlist_entry_name == 1) {
  ------------------
  |  Branch (3813:17): [True: 0, False: 0]
  |  Branch (3813:30): [True: 0, False: 0]
  |  Branch (3813:47): [True: 0, False: 0]
  ------------------
 3814|      0|                res = talloc_asprintf_append(res, "%s%s\n", p, reset);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3815|      0|            } else {
 3816|      0|                res = talloc_asprintf_append(res, "%s (%s)%s\n", e->title, p, reset);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3817|      0|            }
 3818|      0|        }
 3819|       |
 3820|      0|        *(char **)arg = cut_osd_list(mpctx, action, "Playlist", res,
 3821|      0|                                     playlist_entry_to_index(pl, pl->current));
 3822|      0|        return M_PROPERTY_OK;
 3823|      0|    }
 3824|       |
 3825|    444|    return m_property_read_list(action, arg, playlist_entry_count(mpctx->playlist),
 3826|    444|                                do_playlist_entry, mpctx);
 3827|    444|}
command.c:do_playlist_entry:
 3732|     54|{
 3733|     54|    struct MPContext *mpctx = ctx;
 3734|       |
 3735|     54|    struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist, item);
 3736|     54|    if (!e)
  ------------------
  |  Branch (3736:9): [True: 0, False: 54]
  ------------------
 3737|      0|        return M_PROPERTY_ERROR;
 3738|       |
 3739|     54|    bool current = mpctx->playlist->current == e;
 3740|     54|    bool playing = mpctx->playing == e;
 3741|     54|    struct m_sub_property props[] = {
 3742|     54|        {"filename",      SUB_PROP_STR(e->filename)},
  ------------------
  |  |  237|     54|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|     54|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3743|     54|        {"current",       SUB_PROP_BOOL(1), .unavailable = !current},
  ------------------
  |  |  243|     54|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|     54|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 3744|     54|        {"playing",       SUB_PROP_BOOL(1), .unavailable = !playing},
  ------------------
  |  |  243|     54|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|     54|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 3745|     54|        {"title",         SUB_PROP_STR(e->title), .unavailable = !e->title},
  ------------------
  |  |  237|     54|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|     54|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3746|     54|        {"id",            SUB_PROP_INT64(e->id)},
  ------------------
  |  |  235|     54|    .type = {.type = CONF_TYPE_INT64}, .value = {.int64 = (i)}
  |  |  ------------------
  |  |  |  |  241|     54|#define CONF_TYPE_INT64         (&m_option_type_int64)
  |  |  ------------------
  ------------------
 3747|     54|        {"playlist-path", SUB_PROP_STR(e->playlist_path), .unavailable = !e->playlist_path},
  ------------------
  |  |  237|     54|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|     54|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3748|     54|        {0}
 3749|     54|    };
 3750|       |
 3751|     54|    if (action != M_PROPERTY_KEY_ACTION)
  ------------------
  |  Branch (3751:9): [True: 36, False: 18]
  ------------------
 3752|     36|        goto prop_get;
 3753|       |
 3754|     18|    struct m_property_action_arg *ka = arg;
 3755|     18|    if (strcmp(ka->key, "title") != 0)
  ------------------
  |  Branch (3755:9): [True: 18, False: 0]
  ------------------
 3756|     18|        goto prop_get;
 3757|       |
 3758|       |    // handle playlist/N/title writes
 3759|      0|    switch (ka->action) {
  ------------------
  |  Branch (3759:13): [True: 0, False: 0]
  ------------------
 3760|      0|    case M_PROPERTY_SET_NODE: {
  ------------------
  |  Branch (3760:5): [True: 0, False: 0]
  ------------------
 3761|      0|        return M_PROPERTY_NOT_IMPLEMENTED;
 3762|      0|    }
 3763|      0|    case M_PROPERTY_GET_TYPE: {
  ------------------
  |  Branch (3763:5): [True: 0, False: 0]
  ------------------
 3764|      0|        *(struct m_option *)ka->arg = (struct m_option){
 3765|      0|            .type = CONF_TYPE_STRING,
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 3766|      0|        };
 3767|      0|        return M_PROPERTY_OK;
 3768|      0|    }
 3769|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (3769:5): [True: 0, False: 0]
  ------------------
 3770|      0|        talloc_replace(e, e->title, *(char **)ka->arg);
  ------------------
  |  |   54|      0|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|      0|    do {                                                \
  |  |  |  |  107|      0|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|      0|        } else {                                        \
  |  |  |  |  110|      0|            *(str) = '\0';                              \
  |  |  |  |  111|      0|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|      0|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|      0|        }                                               \
  |  |  |  |  113|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3771|      0|        mp_notify_property(mpctx, "playlist");
 3772|      0|        return M_PROPERTY_OK;
 3773|      0|    }
 3774|      0|    }
 3775|       |
 3776|     54|prop_get:
 3777|     54|    return m_property_read_sub(props, action, arg);
 3778|      0|}
command.c:mp_property_playlist_path:
 3782|     28|{
 3783|     28|    MPContext *mpctx = ctx;
 3784|     28|    if (!mpctx->playlist->current)
  ------------------
  |  Branch (3784:9): [True: 8, False: 20]
  ------------------
 3785|      8|        return M_PROPERTY_UNAVAILABLE;
 3786|       |
 3787|     20|    struct playlist_entry *e = mpctx->playlist->current;
 3788|     20|    return m_property_strdup_ro(action, arg, e->playlist_path);
 3789|     28|}
command.c:mp_property_playlist_pos:
 3721|  1.33k|{
 3722|  1.33k|    return mp_property_playlist_pos_x(ctx, prop, action, arg, 0);
 3723|  1.33k|}
command.c:mp_property_playlist_pos_x:
 3686|  3.03k|{
 3687|  3.03k|    MPContext *mpctx = ctx;
 3688|  3.03k|    struct playlist *pl = mpctx->playlist;
 3689|       |
 3690|  3.03k|    switch (action) {
  ------------------
  |  Branch (3690:13): [True: 2.48k, False: 552]
  ------------------
 3691|    552|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3691:5): [True: 552, False: 2.48k]
  ------------------
 3692|    552|        int pos = playlist_entry_to_index(pl, pl->current);
 3693|    552|        *(int *)arg = pos < 0 ? -1 : pos + base;
  ------------------
  |  Branch (3693:23): [True: 371, False: 181]
  ------------------
 3694|    552|        return M_PROPERTY_OK;
 3695|      0|    }
 3696|    275|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (3696:5): [True: 275, False: 2.76k]
  ------------------
 3697|    275|        int pos = *(int *)arg - base;
 3698|    275|        if (pos >= 0 && playlist_entry_to_index(pl, pl->current) == pos)
  ------------------
  |  Branch (3698:13): [True: 179, False: 96]
  |  Branch (3698:25): [True: 0, False: 179]
  ------------------
 3699|      0|            return M_PROPERTY_OK;
 3700|    275|        mp_set_playlist_entry(mpctx, playlist_entry_from_index(pl, pos));
 3701|    275|        return M_PROPERTY_OK;
 3702|    275|    }
 3703|    829|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3703:5): [True: 829, False: 2.20k]
  ------------------
 3704|    829|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT};
  ------------------
  |  |  240|    829|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
 3705|    829|        return M_PROPERTY_OK;
 3706|    827|    case M_PROPERTY_GET_CONSTRICTED_TYPE: {
  ------------------
  |  Branch (3706:5): [True: 827, False: 2.20k]
  ------------------
 3707|    827|        struct m_option opt = {
 3708|    827|            .type = CONF_TYPE_INT,
  ------------------
  |  |  240|    827|#define CONF_TYPE_INT           (&m_option_type_int)
  ------------------
 3709|    827|            .min = base,
 3710|    827|            .max = playlist_entry_count(pl) - 1 + base,
 3711|    827|        };
 3712|    827|        *(struct m_option *)arg = opt;
 3713|    827|        return M_PROPERTY_OK;
 3714|    275|    }
 3715|  3.03k|    }
 3716|    552|    return M_PROPERTY_NOT_IMPLEMENTED;
 3717|  3.03k|}
command.c:mp_property_playlist_pos_1:
 3727|  1.69k|{
 3728|  1.69k|    return mp_property_playlist_pos_x(ctx, prop, action, arg, 1);
 3729|  1.69k|}
command.c:mp_property_playlist_playing_pos:
 3677|      6|{
 3678|      6|    MPContext *mpctx = ctx;
 3679|      6|    struct playlist *pl = mpctx->playlist;
 3680|      6|    return m_property_int_ro(action, arg,
 3681|      6|                             playlist_entry_to_index(pl, mpctx->playing));
 3682|      6|}
command.c:mp_property_mixer_active:
 1785|      9|{
 1786|      9|    MPContext *mpctx = ctx;
 1787|      9|    return m_property_bool_ro(action, arg, !!mpctx->ao);
 1788|      9|}
command.c:mp_property_volume:
 1793|  3.07k|{
 1794|  3.07k|    MPContext *mpctx = ctx;
 1795|  3.07k|    struct MPOpts *opts = mpctx->opts;
 1796|       |
 1797|  3.07k|    switch (action) {
  ------------------
  |  Branch (1797:13): [True: 1.08k, False: 1.99k]
  ------------------
 1798|    900|    case M_PROPERTY_GET_CONSTRICTED_TYPE:
  ------------------
  |  Branch (1798:5): [True: 900, False: 2.17k]
  ------------------
 1799|    900|        *(struct m_option *)arg = (struct m_option){
 1800|    900|            .type = CONF_TYPE_FLOAT,
  ------------------
  |  |  242|    900|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  ------------------
 1801|    900|            .min = 0,
 1802|    900|            .max = opts->softvol_max,
 1803|    900|        };
 1804|    900|        return M_PROPERTY_OK;
 1805|    180|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (1805:5): [True: 180, False: 2.89k]
  ------------------
 1806|    180|        *(char **)arg = talloc_asprintf(NULL, "%.f", opts->softvol_volume);
  ------------------
  |  |   52|    180|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|    180|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1807|    180|        return M_PROPERTY_OK;
 1808|  3.07k|    }
 1809|       |
 1810|  1.99k|    return mp_property_generic_option(mpctx, prop, action, arg);
 1811|  3.07k|}
command.c:mp_property_volume_gain:
 1815|  18.7k|{
 1816|  18.7k|    MPContext *mpctx = ctx;
 1817|  18.7k|    struct MPOpts *opts = mpctx->opts;
 1818|       |
 1819|  18.7k|    switch (action) {
  ------------------
  |  Branch (1819:13): [True: 6.60k, False: 12.1k]
  ------------------
 1820|  5.50k|    case M_PROPERTY_GET_CONSTRICTED_TYPE:
  ------------------
  |  Branch (1820:5): [True: 5.50k, False: 13.2k]
  ------------------
 1821|  5.50k|        *(struct m_option *)arg = (struct m_option){
 1822|  5.50k|            .type = CONF_TYPE_FLOAT,
  ------------------
  |  |  242|  5.50k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  ------------------
 1823|  5.50k|            .min = opts->softvol_gain_min,
 1824|  5.50k|            .max = opts->softvol_gain_max,
 1825|  5.50k|        };
 1826|  5.50k|        return M_PROPERTY_OK;
 1827|  1.10k|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (1827:5): [True: 1.10k, False: 17.6k]
  ------------------
 1828|  1.10k|        *(char **)arg = talloc_asprintf(NULL, "%.1f", opts->softvol_gain);
  ------------------
  |  |   52|  1.10k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  1.10k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1829|  1.10k|        return M_PROPERTY_OK;
 1830|  18.7k|    }
 1831|       |
 1832|  12.1k|    return mp_property_generic_option(mpctx, prop, action, arg);
 1833|  18.7k|}
command.c:mp_property_ao_volume:
 1837|    114|{
 1838|    114|    MPContext *mpctx = ctx;
 1839|    114|    struct ao *ao = mpctx->ao;
 1840|    114|    if (!ao)
  ------------------
  |  Branch (1840:9): [True: 6, False: 108]
  ------------------
 1841|      6|        return M_PROPERTY_NOT_IMPLEMENTED;
 1842|       |
 1843|    108|    switch (action) {
  ------------------
  |  Branch (1843:13): [True: 72, False: 36]
  ------------------
 1844|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (1844:5): [True: 0, False: 108]
  ------------------
 1845|      0|        float vol = *(float *)arg;
 1846|      0|        if (ao_control(ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (1846:13): [True: 0, False: 0]
  ------------------
 1847|      0|            return M_PROPERTY_UNAVAILABLE;
 1848|      0|        return M_PROPERTY_OK;
 1849|      0|    }
 1850|     30|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (1850:5): [True: 30, False: 78]
  ------------------
 1851|     30|        if (ao_control(ao, AOCONTROL_GET_VOLUME, arg) != CONTROL_OK)
  ------------------
  |  |   95|     30|#define CONTROL_OK 1
  ------------------
  |  Branch (1851:13): [True: 30, False: 0]
  ------------------
 1852|     30|            return M_PROPERTY_UNAVAILABLE;
 1853|      0|        return M_PROPERTY_OK;
 1854|     30|    }
 1855|     36|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (1855:5): [True: 36, False: 72]
  ------------------
 1856|     36|        *(struct m_option *)arg = (struct m_option){
 1857|     36|            .type = CONF_TYPE_FLOAT,
  ------------------
  |  |  242|     36|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  ------------------
 1858|     36|            .min = 0,
 1859|     36|            .max = 100,
 1860|     36|        };
 1861|     36|        return M_PROPERTY_OK;
 1862|      6|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (1862:5): [True: 6, False: 102]
  ------------------
 1863|      6|        float vol = 0;
 1864|      6|        if (ao_control(ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK)
  ------------------
  |  |   95|      6|#define CONTROL_OK 1
  ------------------
  |  Branch (1864:13): [True: 6, False: 0]
  ------------------
 1865|      6|            return M_PROPERTY_UNAVAILABLE;
 1866|      0|        *(char **)arg = talloc_asprintf(NULL, "%.f", vol);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1867|      0|        return M_PROPERTY_OK;
 1868|      6|    }
 1869|    108|    }
 1870|     36|    return M_PROPERTY_NOT_IMPLEMENTED;
 1871|    108|}
command.c:mp_property_ao_mute:
 1876|    450|{
 1877|    450|    MPContext *mpctx = ctx;
 1878|    450|    struct ao *ao = mpctx->ao;
 1879|    450|    if (!ao)
  ------------------
  |  Branch (1879:9): [True: 230, False: 220]
  ------------------
 1880|    230|        return M_PROPERTY_NOT_IMPLEMENTED;
 1881|       |
 1882|    220|    switch (action) {
  ------------------
  |  Branch (1882:13): [True: 120, False: 100]
  ------------------
 1883|      0|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (1883:5): [True: 0, False: 220]
  ------------------
 1884|      0|        bool value = *(int *)arg;
 1885|      0|        if (ao_control(ao, AOCONTROL_SET_MUTE, &value) != CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (1885:13): [True: 0, False: 0]
  ------------------
 1886|      0|            return M_PROPERTY_UNAVAILABLE;
 1887|      0|        return M_PROPERTY_OK;
 1888|      0|    }
 1889|     40|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (1889:5): [True: 40, False: 180]
  ------------------
 1890|     40|        bool value = false;
 1891|     40|        if (ao_control(ao, AOCONTROL_GET_MUTE, &value) != CONTROL_OK)
  ------------------
  |  |   95|     40|#define CONTROL_OK 1
  ------------------
  |  Branch (1891:13): [True: 40, False: 0]
  ------------------
 1892|     40|            return M_PROPERTY_UNAVAILABLE;
 1893|      0|        *(int *)arg = value;
 1894|      0|        return M_PROPERTY_OK;
 1895|     40|    }
 1896|     80|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (1896:5): [True: 80, False: 140]
  ------------------
 1897|     80|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_BOOL};
  ------------------
  |  |  238|     80|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  ------------------
 1898|     80|        return M_PROPERTY_OK;
 1899|    220|    }
 1900|    100|    return M_PROPERTY_NOT_IMPLEMENTED;
 1901|    220|}
command.c:mp_property_audio_delay:
 1979|    258|{
 1980|    258|    MPContext *mpctx = ctx;
 1981|    258|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (1981:9): [True: 23, False: 235]
  ------------------
 1982|     23|        *(char **)arg = format_delay(mpctx->opts->audio_delay);
 1983|     23|        return M_PROPERTY_OK;
 1984|     23|    }
 1985|    235|    return mp_property_generic_option(mpctx, prop, action, arg);
 1986|    258|}
command.c:format_delay:
  428|     28|{
  429|     28|    char *str = mp_format_double(NULL, time * 1000, 6, false, false, true);
  430|     28|    return talloc_strdup_append(str, " ms");
  ------------------
  |  |   57|     28|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  431|     28|}
command.c:mp_property_audio_params:
 2010|     15|{
 2011|     15|    MPContext *mpctx = ctx;
 2012|       |
 2013|     15|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2014|     15|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2014:9): [True: 12, False: 3]
  ------------------
 2015|     12|        return valid;
 2016|       |
 2017|      3|    return property_audiofmt(mpctx->ao_chain ?
  ------------------
  |  Branch (2017:30): [True: 3, False: 0]
  ------------------
 2018|      3|        mpctx->ao_chain->filter->input_aformat : NULL, action, arg);
 2019|     15|}
command.c:property_audiofmt:
 1989|      3|{
 1990|      3|    if (!fmt || !mp_aframe_config_is_valid(fmt))
  ------------------
  |  Branch (1990:9): [True: 0, False: 3]
  |  Branch (1990:17): [True: 0, False: 3]
  ------------------
 1991|      0|        return M_PROPERTY_UNAVAILABLE;
 1992|       |
 1993|      3|    struct mp_chmap chmap = {0};
 1994|      3|    mp_aframe_get_chmap(fmt, &chmap);
 1995|       |
 1996|      3|    struct m_sub_property props[] = {
 1997|      3|        {"samplerate",      SUB_PROP_INT(mp_aframe_get_rate(fmt))},
  ------------------
  |  |  233|      3|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|      3|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 1998|      3|        {"channel-count",   SUB_PROP_INT(chmap.num)},
  ------------------
  |  |  233|      3|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|      3|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 1999|      3|        {"channels",        SUB_PROP_STR(mp_chmap_to_str(&chmap))},
  ------------------
  |  |  237|      3|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      3|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2000|      3|        {"hr-channels",     SUB_PROP_STR(mp_chmap_to_str_hr(&chmap))},
  ------------------
  |  |  237|      3|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      3|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2001|      3|        {"format",          SUB_PROP_STR(af_fmt_to_str(mp_aframe_get_format(fmt)))},
  ------------------
  |  |  237|      3|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      3|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2002|      3|        {0}
 2003|      3|    };
 2004|       |
 2005|      3|    return m_property_read_sub(props, action, arg);
 2006|      3|}
command.c:mp_property_audio_out_params:
 2023|     24|{
 2024|     24|    MPContext *mpctx = ctx;
 2025|       |
 2026|     24|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2027|     24|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2027:9): [True: 24, False: 0]
  ------------------
 2028|     24|        return valid;
 2029|       |
 2030|      0|    struct mp_aframe *frame = NULL;
 2031|      0|    if (mpctx->ao) {
  ------------------
  |  Branch (2031:9): [True: 0, False: 0]
  ------------------
 2032|      0|        frame = mp_aframe_create();
 2033|      0|        int samplerate;
 2034|      0|        int format;
 2035|      0|        struct mp_chmap channels;
 2036|      0|        ao_get_format(mpctx->ao, &samplerate, &format, &channels);
 2037|      0|        mp_aframe_set_rate(frame, samplerate);
 2038|      0|        mp_aframe_set_format(frame, format);
 2039|      0|        mp_aframe_set_chmap(frame, &channels);
 2040|      0|    }
 2041|      0|    int r = property_audiofmt(frame, action, arg);
 2042|      0|    talloc_free(frame);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2043|      0|    return r;
 2044|     24|}
command.c:mp_property_switch_track:
 2072|   380k|{
 2073|   380k|    MPContext *mpctx = ctx;
 2074|   380k|    const int *def = prop->priv;
 2075|   380k|    int order = def[0];
 2076|   380k|    enum stream_type type = def[1];
 2077|       |
 2078|   380k|    struct track *track = mpctx->current_track[order][type];
 2079|       |
 2080|   380k|    switch (action) {
  ------------------
  |  Branch (2080:13): [True: 84.3k, False: 296k]
  ------------------
 2081|     43|    case M_PROPERTY_GET:
  ------------------
  |  Branch (2081:5): [True: 43, False: 380k]
  ------------------
 2082|     43|        if (mpctx->playback_initialized) {
  ------------------
  |  Branch (2082:13): [True: 18, False: 25]
  ------------------
 2083|     18|            *(int *)arg = track ? track->user_tid : -2;
  ------------------
  |  Branch (2083:27): [True: 4, False: 14]
  ------------------
 2084|     25|        } else {
 2085|     25|            *(int *)arg = mpctx->opts->stream_id[order][type];
 2086|     25|        }
 2087|     43|        return M_PROPERTY_OK;
 2088|  42.1k|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (2088:5): [True: 42.1k, False: 338k]
  ------------------
 2089|  42.1k|        if (track) {
  ------------------
  |  Branch (2089:13): [True: 14.5k, False: 27.6k]
  ------------------
 2090|  14.5k|            void *talloc_ctx = talloc_new(NULL);
  ------------------
  |  |   40|  14.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  14.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 2091|  14.5k|            *(char **)arg = talloc_asprintf(NULL, "(%d) %s", track->user_tid,
  ------------------
  |  |   52|  14.5k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  14.5k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 2092|  14.5k|                mp_format_track_metadata(talloc_ctx, track, true));
 2093|  14.5k|            talloc_free(talloc_ctx);
  ------------------
  |  |   47|  14.5k|#define talloc_free                     ta_free
  ------------------
 2094|  27.6k|        } else {
 2095|  27.6k|            const char *msg = "no";
 2096|  27.6k|            if (!mpctx->playback_initialized &&
  ------------------
  |  Branch (2096:17): [True: 12.2k, False: 15.3k]
  ------------------
 2097|  12.2k|                mpctx->opts->stream_id[order][type] == -1)
  ------------------
  |  Branch (2097:17): [True: 6.12k, False: 6.09k]
  ------------------
 2098|  6.12k|                msg = "auto";
 2099|  27.6k|            *(char **) arg = talloc_strdup(NULL, msg);
  ------------------
  |  |   50|  27.6k|#define talloc_strdup                   ta_xstrdup
  ------------------
 2100|  27.6k|        }
 2101|  42.1k|        return M_PROPERTY_OK;
 2102|       |
 2103|  42.1k|    case M_PROPERTY_SWITCH: {
  ------------------
  |  Branch (2103:5): [True: 42.1k, False: 338k]
  ------------------
 2104|  42.1k|        if (mpctx->playback_initialized) {
  ------------------
  |  Branch (2104:13): [True: 29.9k, False: 12.2k]
  ------------------
 2105|  29.9k|            struct m_property_switch_arg *sarg = arg;
 2106|  29.9k|            do {
 2107|  29.9k|                track = track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track);
  ------------------
  |  Branch (2107:49): [True: 29.9k, False: 2]
  ------------------
 2108|  29.9k|                mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
  ------------------
  |  |  559|  29.9k|#define FLAG_MARK_SELECTION 1
  ------------------
 2109|  29.9k|            } while (mpctx->current_track[order][type] != track);
  ------------------
  |  Branch (2109:22): [True: 0, False: 29.9k]
  ------------------
 2110|  29.9k|            print_track_list(mpctx, "Track switched:");
 2111|  29.9k|        } else {
 2112|       |            // Simply cycle between "no" and "auto". It's possible that this does
 2113|       |            // not always do what the user means, but keep the complexity low.
 2114|  12.2k|            mark_track_selection(mpctx, order, type,
 2115|  12.2k|                mpctx->opts->stream_id[order][type] == -1 ? -2 : -1);
  ------------------
  |  Branch (2115:17): [True: 6.09k, False: 6.12k]
  ------------------
 2116|  12.2k|        }
 2117|  42.1k|        return M_PROPERTY_OK;
 2118|      0|    }
 2119|   380k|    }
 2120|   296k|    return mp_property_generic_option(mpctx, prop, action, arg);
 2121|   380k|}
command.c:track_next:
 2048|  29.9k|{
 2049|  29.9k|    mp_assert(direction == -1 || direction == +1);
  ------------------
  |  |   41|  29.9k|#define mp_assert assert
  ------------------
  |  Branch (2049:5): [True: 2, False: 29.9k]
  |  Branch (2049:5): [True: 29.9k, False: 0]
  ------------------
 2050|  29.9k|    struct track *prev = NULL, *next = NULL;
 2051|  29.9k|    bool seen = track == NULL;
 2052|  96.0k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2052:21): [True: 66.1k, False: 29.9k]
  ------------------
 2053|  66.1k|        struct track *cur = mpctx->tracks[n];
 2054|  66.1k|        if (cur->type == type && track_is_visible(mpctx, cur)) {
  ------------------
  |  Branch (2054:13): [True: 29.9k, False: 36.1k]
  |  Branch (2054:34): [True: 29.9k, False: 0]
  ------------------
 2055|  29.9k|            if (cur == track) {
  ------------------
  |  Branch (2055:17): [True: 15.3k, False: 14.5k]
  ------------------
 2056|  15.3k|                seen = true;
 2057|  15.3k|            } else if (!cur->selected) {
  ------------------
  |  Branch (2057:24): [True: 14.5k, False: 0]
  ------------------
 2058|  14.5k|                if (seen && !next) {
  ------------------
  |  Branch (2058:21): [True: 14.5k, False: 4]
  |  Branch (2058:29): [True: 14.5k, False: 34]
  ------------------
 2059|  14.5k|                    next = cur;
 2060|  14.5k|                }
 2061|  14.5k|                if (!seen || !track) {
  ------------------
  |  Branch (2061:21): [True: 4, False: 14.5k]
  |  Branch (2061:30): [True: 14.5k, False: 46]
  ------------------
 2062|  14.5k|                    prev = cur;
 2063|  14.5k|                }
 2064|  14.5k|            }
 2065|  29.9k|        }
 2066|  66.1k|    }
 2067|  29.9k|    return direction > 0 ? next : prev;
  ------------------
  |  Branch (2067:12): [True: 29.9k, False: 2]
  ------------------
 2068|  29.9k|}
command.c:mp_property_audio_device:
 1929|    148|{
 1930|    148|    struct MPContext *mpctx = ctx;
 1931|    148|    struct command_ctx *cmd = mpctx->command_ctx;
 1932|    148|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (1932:9): [True: 12, False: 136]
  ------------------
 1933|     12|        create_hotplug(mpctx);
 1934|       |
 1935|     12|        char *name = NULL;
 1936|     12|        if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &name) < 1)
  ------------------
  |  Branch (1936:13): [True: 0, False: 12]
  ------------------
 1937|      0|            name = NULL;
 1938|       |
 1939|     12|        struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug, mpctx->ao);
 1940|     24|        for (int n = 0; n < list->num_devices; n++) {
  ------------------
  |  Branch (1940:25): [True: 12, False: 12]
  ------------------
 1941|     12|            struct ao_device_desc *dev = &list->devices[n];
 1942|     12|            if (dev->name && name && strcmp(dev->name, name) == 0) {
  ------------------
  |  Branch (1942:17): [True: 12, False: 0]
  |  Branch (1942:30): [True: 12, False: 0]
  |  Branch (1942:38): [True: 0, False: 12]
  ------------------
 1943|      0|                *(char **)arg = talloc_strdup(NULL, dev->desc ? dev->desc : "?");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (1943:53): [True: 0, False: 0]
  ------------------
 1944|      0|                talloc_free(name);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1945|      0|                return M_PROPERTY_OK;
 1946|      0|            }
 1947|     12|        }
 1948|       |
 1949|     12|        talloc_free(name);
  ------------------
  |  |   47|     12|#define talloc_free                     ta_free
  ------------------
 1950|     12|    }
 1951|    148|    return mp_property_generic_option(mpctx, prop, action, arg);
 1952|    148|}
command.c:create_hotplug:
 1918|    149|{
 1919|    149|    struct command_ctx *cmd = mpctx->command_ctx;
 1920|       |
 1921|    149|    if (!cmd->hotplug) {
  ------------------
  |  Branch (1921:9): [True: 12, False: 137]
  ------------------
 1922|     12|        cmd->hotplug = ao_hotplug_create(mpctx->global, mp_wakeup_core_cb,
 1923|     12|                                         mpctx);
 1924|     12|    }
 1925|    149|}
command.c:mp_property_audio_devices:
 1956|    137|{
 1957|    137|    struct MPContext *mpctx = ctx;
 1958|    137|    struct command_ctx *cmd = mpctx->command_ctx;
 1959|    137|    create_hotplug(mpctx);
 1960|       |
 1961|    137|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 1962|    137|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (1962:9): [True: 136, False: 1]
  ------------------
 1963|    136|        return valid;
 1964|       |
 1965|      1|    struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug, mpctx->ao);
 1966|      1|    return m_property_read_list(action, arg, list->num_devices,
 1967|      1|                                get_device_entry, list);
 1968|    137|}
command.c:get_device_entry:
 1904|      1|{
 1905|      1|    struct ao_device_list *list = ctx;
 1906|      1|    struct ao_device_desc *entry = &list->devices[item];
 1907|       |
 1908|      1|    struct m_sub_property props[] = {
 1909|      1|        {"name",        SUB_PROP_STR(entry->name)},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 1910|      1|        {"description", SUB_PROP_STR(entry->desc)},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 1911|      1|        {0}
 1912|      1|    };
 1913|       |
 1914|      1|    return m_property_read_sub(props, action, arg);
 1915|      1|}
command.c:mp_property_ao:
 1971|     64|{
 1972|     64|    MPContext *mpctx = ctx;
 1973|     64|    return m_property_strdup_ro(action, arg, mpctx->ao ? ao_get_name(mpctx->ao) : NULL);
  ------------------
  |  Branch (1973:46): [True: 12, False: 52]
  ------------------
 1974|     64|}
command.c:mp_property_tgt_imgparams:
 2714|     28|{
 2715|     28|    MPContext *mpctx = ctx;
 2716|     28|    struct vo *vo = mpctx->video_out;
 2717|     28|    if (!mpctx->video_out)
  ------------------
  |  Branch (2717:9): [True: 0, False: 28]
  ------------------
 2718|      0|        return M_PROPERTY_UNAVAILABLE;
 2719|       |
 2720|     28|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2721|     28|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2721:9): [True: 28, False: 0]
  ------------------
 2722|     28|        return valid;
 2723|       |
 2724|      0|    struct mp_image_params p = vo_get_target_params(vo);
 2725|      0|    return property_imgparams(&p, action, arg);
 2726|     28|}
command.c:property_imgparams:
 2567|  9.91k|{
 2568|  9.91k|    if (!p->imgfmt && !p->imgfmt_name)
  ------------------
  |  Branch (2568:9): [True: 200, False: 9.71k]
  |  Branch (2568:23): [True: 200, False: 0]
  ------------------
 2569|    200|        return M_PROPERTY_UNAVAILABLE;
 2570|       |
 2571|  9.71k|    int d_w, d_h;
 2572|  9.71k|    mp_image_params_get_dsize(p, &d_w, &d_h);
 2573|       |
 2574|  9.71k|    int bpp = 0;
 2575|  9.71k|    enum pl_alpha_mode alpha = p->repr.alpha;
 2576|  9.71k|    int fmt = p->hw_subfmt ? p->hw_subfmt : p->imgfmt;
  ------------------
  |  Branch (2576:15): [True: 0, False: 9.71k]
  ------------------
 2577|  9.71k|    if (fmt) {
  ------------------
  |  Branch (2577:9): [True: 9.71k, False: 0]
  ------------------
 2578|  9.71k|        struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
 2579|  38.1k|        for (int i = 0; i < desc.num_planes; i++)
  ------------------
  |  Branch (2579:25): [True: 28.4k, False: 9.71k]
  ------------------
 2580|  28.4k|            bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
 2581|       |
 2582|       |        // If PL_ALPHA_NONE is supported, use it directly, unless in auto mode.
 2583|  9.71k|        if ((desc.flags & MP_IMGFLAG_ALPHA) && alpha == PL_ALPHA_UNKNOWN)
  ------------------
  |  |   52|  9.71k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (2583:13): [True: 330, False: 9.38k]
  |  Branch (2583:48): [True: 330, False: 0]
  ------------------
 2584|    330|            alpha = PL_ALPHA_INDEPENDENT;
 2585|  9.71k|    }
 2586|       |
 2587|  9.71k|    const struct pl_hdr_metadata *hdr = &p->color.hdr;
 2588|  9.71k|    bool has_cie_y     = pl_hdr_metadata_contains(hdr, PL_HDR_METADATA_CIE_Y);
 2589|  9.71k|    bool has_hdr10     = pl_hdr_metadata_contains(hdr, PL_HDR_METADATA_HDR10);
 2590|  9.71k|    bool has_hdr10plus = pl_hdr_metadata_contains(hdr, PL_HDR_METADATA_HDR10PLUS);
 2591|  9.71k|    bool custom_prim   = pl_primaries_valid(&hdr->prim) &&
  ------------------
  |  Branch (2591:26): [True: 0, False: 9.71k]
  ------------------
 2592|      0|                         !pl_raw_primaries_similar(&hdr->prim, pl_raw_primaries_get(p->color.primaries));
  ------------------
  |  Branch (2592:26): [True: 0, False: 0]
  ------------------
 2593|       |
 2594|  9.71k|    bool has_crop = mp_rect_w(p->crop) > 0 && mp_rect_h(p->crop) > 0;
  ------------------
  |  |  157|  9.71k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
                  bool has_crop = mp_rect_w(p->crop) > 0 && mp_rect_h(p->crop) > 0;
  ------------------
  |  |  158|  9.38k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (2594:21): [True: 9.38k, False: 330]
  |  Branch (2594:47): [True: 9.38k, False: 0]
  ------------------
 2595|  9.71k|    const char *aspect_name = get_aspect_ratio_name(d_w / (double)d_h);
 2596|  9.71k|    const char *sar_name = get_aspect_ratio_name(p->w / (double)p->h);
 2597|  9.71k|    const char *pixelformat_name = p->imgfmt_name ? p->imgfmt_name :
  ------------------
  |  Branch (2597:36): [True: 0, False: 9.71k]
  ------------------
 2598|  9.71k|                                                   mp_imgfmt_to_name(p->imgfmt);
  ------------------
  |  |  333|  9.71k|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
 2599|  9.71k|    struct m_sub_property props[] = {
 2600|  9.71k|        {"pixelformat",     SUB_PROP_STR(pixelformat_name)},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2601|  9.71k|        {"hw-pixelformat",  SUB_PROP_STR(mp_imgfmt_to_name(p->hw_subfmt)),
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2602|  9.71k|                            .unavailable = !p->hw_subfmt},
 2603|  9.71k|        {"average-bpp",     SUB_PROP_INT(bpp),
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2604|  9.71k|                            .unavailable = !bpp},
 2605|  9.71k|        {"w",               SUB_PROP_INT(p->w)},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2606|  9.71k|        {"h",               SUB_PROP_INT(p->h)},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2607|  9.71k|        {"dw",              SUB_PROP_INT(d_w)},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2608|  9.71k|        {"dh",              SUB_PROP_INT(d_h)},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2609|  9.71k|        {"crop-x",          SUB_PROP_INT(p->crop.x0), .unavailable = !has_crop},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2610|  9.71k|        {"crop-y",          SUB_PROP_INT(p->crop.y0), .unavailable = !has_crop},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2611|  9.71k|        {"crop-w",          SUB_PROP_INT(mp_rect_w(p->crop)), .unavailable = !has_crop},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2612|  9.71k|        {"crop-h",          SUB_PROP_INT(mp_rect_h(p->crop)), .unavailable = !has_crop},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2613|  9.71k|        {"aspect",          SUB_PROP_DOUBLE(d_w / (double)d_h)},
  ------------------
  |  |  241|  9.71k|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|  9.71k|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 2614|  9.71k|        {"aspect-name",     SUB_PROP_STR(aspect_name), .unavailable = !aspect_name},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2615|  9.71k|        {"par",             SUB_PROP_DOUBLE(p->p_w / (double)p->p_h)},
  ------------------
  |  |  241|  9.71k|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|  9.71k|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 2616|  9.71k|        {"sar",             SUB_PROP_DOUBLE(p->w / (double)p->h)},
  ------------------
  |  |  241|  9.71k|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|  9.71k|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 2617|  9.71k|        {"sar-name",        SUB_PROP_STR(sar_name), .unavailable = !sar_name},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2618|  9.71k|        {"colormatrix",
 2619|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_csp_names, p->repr.sys))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2620|  9.71k|        {"colorlevels",
 2621|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_csp_levels_names, p->repr.levels))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2622|  9.71k|        {"primaries",
 2623|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_csp_prim_names, p->color.primaries))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2624|  9.71k|        {"gamma",
 2625|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_csp_trc_names, p->color.transfer))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2626|  9.71k|        {"sig-peak", SUB_PROP_FLOAT(p->color.hdr.max_luma / MP_REF_WHITE)},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2627|  9.71k|        {"light",
 2628|  9.71k|            SUB_PROP_STR(m_opt_choice_str(mp_csp_light_names, p->light))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2629|  9.71k|        {"chroma-location",
 2630|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_chroma_names, p->chroma_location))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2631|  9.71k|        {"stereo-in",
 2632|  9.71k|            SUB_PROP_STR(m_opt_choice_str(mp_stereo3d_names, p->stereo3d))},
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2633|  9.71k|        {"rotate",          SUB_PROP_INT(p->rotate)},
  ------------------
  |  |  233|  9.71k|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|  9.71k|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2634|  9.71k|        {"alpha",
 2635|  9.71k|            SUB_PROP_STR(m_opt_choice_str(pl_alpha_names, alpha)),
  ------------------
  |  |  237|  9.71k|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|  9.71k|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2636|       |            // avoid using "auto" for "no", so just make it unavailable
 2637|  9.71k|            .unavailable = alpha == PL_ALPHA_UNKNOWN},
 2638|  9.71k|        {"min-luma",    SUB_PROP_FLOAT(hdr->min_luma),     .unavailable = !has_hdr10},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2639|  9.71k|        {"max-luma",    SUB_PROP_FLOAT(hdr->max_luma),     .unavailable = !has_hdr10},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2640|  9.71k|        {"max-cll",     SUB_PROP_FLOAT(hdr->max_cll),      .unavailable = !has_hdr10},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2641|  9.71k|        {"max-fall",    SUB_PROP_FLOAT(hdr->max_fall),     .unavailable = !has_hdr10},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2642|  9.71k|        {"scene-max-r", SUB_PROP_FLOAT(hdr->scene_max[0]), .unavailable = !has_hdr10plus},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2643|  9.71k|        {"scene-max-g", SUB_PROP_FLOAT(hdr->scene_max[1]), .unavailable = !has_hdr10plus},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2644|  9.71k|        {"scene-max-b", SUB_PROP_FLOAT(hdr->scene_max[2]), .unavailable = !has_hdr10plus},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2645|  9.71k|        {"scene-avg",   SUB_PROP_FLOAT(hdr->scene_avg),    .unavailable = !has_hdr10plus},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2646|  9.71k|        {"max-pq-y",    SUB_PROP_FLOAT(hdr->max_pq_y),     .unavailable = !has_cie_y},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2647|  9.71k|        {"avg-pq-y",    SUB_PROP_FLOAT(hdr->avg_pq_y),     .unavailable = !has_cie_y},
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2648|  9.71k|        {"prim-red-x",   SUB_PROP_FLOAT(hdr->prim.red.x),  .unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2649|  9.71k|        {"prim-red-y",   SUB_PROP_FLOAT(hdr->prim.red.y),  .unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2650|  9.71k|        {"prim-green-x", SUB_PROP_FLOAT(hdr->prim.green.x),.unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2651|  9.71k|        {"prim-green-y", SUB_PROP_FLOAT(hdr->prim.green.y),.unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2652|  9.71k|        {"prim-blue-x",  SUB_PROP_FLOAT(hdr->prim.blue.x), .unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2653|  9.71k|        {"prim-blue-y",  SUB_PROP_FLOAT(hdr->prim.blue.y), .unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2654|  9.71k|        {"prim-white-x", SUB_PROP_FLOAT(hdr->prim.white.x),.unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2655|  9.71k|        {"prim-white-y", SUB_PROP_FLOAT(hdr->prim.white.y),.unavailable = !custom_prim },
  ------------------
  |  |  239|  9.71k|    .type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
  |  |  ------------------
  |  |  |  |  242|  9.71k|#define CONF_TYPE_FLOAT         (&m_option_type_float)
  |  |  ------------------
  ------------------
 2656|  9.71k|        {0}
 2657|  9.71k|    };
 2658|       |
 2659|  9.71k|    return m_property_read_sub(props, action, arg);
 2660|  9.91k|}
command.c:get_aspect_ratio_name:
 2525|  19.4k|{
 2526|       |    // Depending on cropping/mastering exact ratio may differ.
 2527|  19.4k|#define RATIO_THRESH 0.025
 2528|  19.4k|#define RATIO_CASE(ref, name)                     \
 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
 2530|  19.4k|        return name;                              \
 2531|  19.4k|
 2532|       |    // https://en.wikipedia.org/wiki/Aspect_ratio_(image)
 2533|  19.4k|    RATIO_CASE(9.0 / 16.0, "Vertical")
  ------------------
  |  | 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|  19.4k|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 19.4k]
  |  |  ------------------
  |  | 2530|  19.4k|        return name;                              \
  ------------------
 2534|  19.4k|    RATIO_CASE(1.0, "Square");
  ------------------
  |  | 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|  19.4k|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 19.4k]
  |  |  ------------------
  |  | 2530|  19.4k|        return name;                              \
  ------------------
 2535|  19.4k|    RATIO_CASE(19.0 / 16.0, "Movietone Ratio");
  ------------------
  |  | 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|  19.4k|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 19.4k]
  |  |  ------------------
  |  | 2530|  19.4k|        return name;                              \
  ------------------
 2536|  19.4k|    RATIO_CASE(5.0 / 4.0, "5:4");
  ------------------
  |  | 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|  19.4k|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 19.4k]
  |  |  ------------------
  |  | 2530|  19.4k|        return name;                              \
  ------------------
 2537|  19.4k|    RATIO_CASE(4.0 / 3.0, "4:3");
  ------------------
  |  | 2529|  19.4k|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|  19.4k|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 18.7k, False: 660]
  |  |  ------------------
  |  | 2530|  19.4k|        return name;                              \
  ------------------
 2538|    660|    RATIO_CASE(11.0 / 8.0, "Academy Ratio");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 660]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2539|    660|    RATIO_CASE(1.43, "IMAX Ratio");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 660]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2540|    660|    RATIO_CASE(3.0 / 2.0, "VistaVision Ratio");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 660]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2541|    660|    RATIO_CASE(16.0 / 10.0, "16:10");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 660]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2542|    660|    RATIO_CASE(5.0 / 3.0, "35mm Widescreen Ratio");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 660]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2543|    660|    RATIO_CASE(16.0 / 9.0, "16:9");
  ------------------
  |  | 2529|    660|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|    660|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 660, False: 0]
  |  |  ------------------
  |  | 2530|    660|        return name;                              \
  ------------------
 2544|      0|    RATIO_CASE(7.0 / 4.0, "Early 35mm Widescreen Ratio");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2545|      0|    RATIO_CASE(1.85, "Academy Flat");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2546|      0|    RATIO_CASE(256.0 / 135.0, "SMPTE/DCI Ratio");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2547|      0|    RATIO_CASE(2.0, "Univisium");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2548|      0|    RATIO_CASE(2.208, "70mm film");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2549|      0|    RATIO_CASE(2.35, "Scope");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2550|      0|    RATIO_CASE(2.39, "Panavision");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2551|      0|    RATIO_CASE(2.55, "Original CinemaScope");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2552|      0|    RATIO_CASE(2.59, "Full-frame Cinerama");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2553|      0|    RATIO_CASE(24.0 / 9.0, "Full-frame Super 16mm");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2554|      0|    RATIO_CASE(2.76, "Ultra Panavision 70");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2555|      0|    RATIO_CASE(32.0 / 9.0, "32:9");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2556|      0|    RATIO_CASE(3.6, "Ultra-WideScreen 3.6");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2557|      0|    RATIO_CASE(4.0, "Polyvision");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2558|      0|    RATIO_CASE(12.0, "Circle-Vision 360°");
  ------------------
  |  | 2529|      0|    if (fabs(ratio - (ref)) < RATIO_THRESH)       \
  |  |  ------------------
  |  |  |  | 2527|      0|#define RATIO_THRESH 0.025
  |  |  ------------------
  |  |  |  Branch (2529:9): [True: 0, False: 0]
  |  |  ------------------
  |  | 2530|      0|        return name;                              \
  ------------------
 2559|       |
 2560|      0|    return NULL;
 2561|       |
 2562|      0|#undef RATIO_THRESH
 2563|      0|#undef RATIO_CASE
 2564|      0|}
command.c:mp_property_vo_imgparams:
 2698|  11.4k|{
 2699|  11.4k|    MPContext *mpctx = ctx;
 2700|  11.4k|    struct vo *vo = mpctx->video_out;
 2701|  11.4k|    if (!vo)
  ------------------
  |  Branch (2701:9): [True: 1.55k, False: 9.84k]
  ------------------
 2702|  1.55k|        return M_PROPERTY_UNAVAILABLE;
 2703|       |
 2704|  9.84k|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2705|  9.84k|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2705:9): [True: 12, False: 9.83k]
  ------------------
 2706|     12|        return valid;
 2707|       |
 2708|  9.83k|    struct mp_image_params p = vo_get_current_params(vo);
 2709|  9.83k|    return property_imgparams(&p, action, arg);
 2710|  9.84k|}
command.c:mp_property_dec_imgparams:
 2730|     25|{
 2731|     25|    MPContext *mpctx = ctx;
 2732|     25|    struct mp_image_params p = {0};
 2733|     25|    struct vo_chain *vo_c = mpctx->vo_chain;
 2734|     25|    if (!vo_c || !vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (2734:9): [True: 12, False: 13]
  |  Branch (2734:18): [True: 0, False: 13]
  |  Branch (2734:34): [True: 0, False: 13]
  ------------------
 2735|     12|        return M_PROPERTY_UNAVAILABLE;
 2736|       |
 2737|     13|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2738|     13|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2738:9): [True: 12, False: 1]
  ------------------
 2739|     12|        return valid;
 2740|       |
 2741|      1|    mp_decoder_wrapper_get_video_dec_params(vo_c->track->dec, &p);
 2742|      1|    if (!p.imgfmt)
  ------------------
  |  Branch (2742:9): [True: 0, False: 1]
  ------------------
 2743|      0|        return M_PROPERTY_UNAVAILABLE;
 2744|      1|    return property_imgparams(&p, action, arg);
 2745|      1|}
command.c:mp_property_vd_imgparams:
 2749|    188|{
 2750|    188|    MPContext *mpctx = ctx;
 2751|    188|    struct vo_chain *vo_c = mpctx->vo_chain;
 2752|    188|    if (!vo_c)
  ------------------
  |  Branch (2752:9): [True: 55, False: 133]
  ------------------
 2753|     55|        return M_PROPERTY_UNAVAILABLE;
 2754|       |
 2755|    133|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2756|    133|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2756:9): [True: 16, False: 117]
  ------------------
 2757|     16|        return valid;
 2758|       |
 2759|    117|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 2760|    117|    struct mp_codec_params *c =
 2761|    117|        track && track->stream ? track->stream->codec : NULL;
  ------------------
  |  Branch (2761:9): [True: 117, False: 0]
  |  Branch (2761:18): [True: 117, False: 0]
  ------------------
 2762|    117|    if (vo_c->filter->input_params.imgfmt) {
  ------------------
  |  Branch (2762:9): [True: 75, False: 42]
  ------------------
 2763|     75|        return property_imgparams(&vo_c->filter->input_params, action, arg);
 2764|     75|    } else if (c && c->disp_w && c->disp_h) {
  ------------------
  |  Branch (2764:16): [True: 42, False: 0]
  |  Branch (2764:21): [True: 42, False: 0]
  |  Branch (2764:34): [True: 42, False: 0]
  ------------------
 2765|       |        // Simplistic fallback for stupid scripts querying "width"/"height"
 2766|       |        // before the first frame is decoded.
 2767|     42|        struct m_sub_property props[] = {
 2768|     42|            {"w", SUB_PROP_INT(c->disp_w)},
  ------------------
  |  |  233|     42|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|     42|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2769|     42|            {"h", SUB_PROP_INT(c->disp_h)},
  ------------------
  |  |  233|     42|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|     42|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 2770|     42|            {0}
 2771|     42|        };
 2772|     42|        return m_property_read_sub(props, action, arg);
 2773|     42|    }
 2774|      0|    return M_PROPERTY_UNAVAILABLE;
 2775|    117|}
command.c:mp_property_video_frame_info:
 2779|      5|{
 2780|      5|    MPContext *mpctx = ctx;
 2781|      5|    if (!mpctx->video_out)
  ------------------
  |  Branch (2781:9): [True: 0, False: 5]
  ------------------
 2782|      0|        return M_PROPERTY_UNAVAILABLE;
 2783|       |
 2784|      5|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 2785|      5|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (2785:9): [True: 4, False: 1]
  ------------------
 2786|      4|        return valid;
 2787|       |
 2788|      1|    struct mp_image *f = vo_get_current_frame(mpctx->video_out);
 2789|      1|    if (!f)
  ------------------
  |  Branch (2789:9): [True: 0, False: 1]
  ------------------
 2790|      0|        return M_PROPERTY_UNAVAILABLE;
 2791|       |
 2792|      1|    const char *pict_types[] = {0, "I", "P", "B"};
 2793|      1|    const char *pict_type = f->pict_type >= 1 && f->pict_type <= 3
  ------------------
  |  Branch (2793:29): [True: 1, False: 0]
  |  Branch (2793:50): [True: 1, False: 0]
  ------------------
 2794|      1|                          ? pict_types[f->pict_type] : NULL;
 2795|       |
 2796|      1|    char gop_tc[AV_TIMECODE_STR_SIZE] = {0};
 2797|      1|    char s12m_tc[AV_TIMECODE_STR_SIZE] = {0};
 2798|      1|    for (int n = 0; n < f->num_ff_side_data; n++) {
  ------------------
  |  Branch (2798:21): [True: 0, False: 1]
  ------------------
 2799|       |
 2800|      0|        struct mp_ff_side_data *mpsd = &f->ff_side_data[n];
 2801|      0|        if (mpsd->type == AV_FRAME_DATA_GOP_TIMECODE)
  ------------------
  |  Branch (2801:13): [True: 0, False: 0]
  ------------------
 2802|      0|            av_timecode_make_mpeg_tc_string(gop_tc, *(int64_t*)(mpsd->buf->data));
 2803|      0|        if (mpctx->vo_chain && mpsd->type == AV_FRAME_DATA_S12M_TIMECODE) {
  ------------------
  |  Branch (2803:13): [True: 0, False: 0]
  |  Branch (2803:32): [True: 0, False: 0]
  ------------------
 2804|      0|            av_timecode_make_smpte_tc_string2(s12m_tc,
 2805|      0|                                              av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX),
 2806|      0|                                              *(uint32_t*)(mpsd->buf->data), 0, 0);
 2807|      0|        }
 2808|      0|    }
 2809|       |
 2810|      1|    char approx_smpte[AV_TIMECODE_STR_SIZE] = {0};
 2811|      1|    if (s12m_tc[0] == '\0' && mpctx->vo_chain) {
  ------------------
  |  Branch (2811:9): [True: 1, False: 0]
  |  Branch (2811:31): [True: 1, False: 0]
  ------------------
 2812|      1|        unsigned container_fps = lrint(mpctx->vo_chain->filter->container_fps);
 2813|       |        // Avoid division-by-zero in av_timecode_make_string() if reported
 2814|       |        // container_fps is or rounds to 0.
 2815|      1|        if (container_fps) {
  ------------------
  |  Branch (2815:13): [True: 1, False: 0]
  ------------------
 2816|      1|            const AVTimecode tcr = {
 2817|      1|                .start = 0,
 2818|      1|                .flags = AV_TIMECODE_FLAG_DROPFRAME,
 2819|      1|                .rate = av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX),
 2820|      1|                .fps = container_fps,
 2821|      1|            };
 2822|      1|            int frame = lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx));
 2823|      1|            av_timecode_make_string(&tcr, approx_smpte, frame);
 2824|      1|        }
 2825|      1|    }
 2826|       |
 2827|      1|    struct m_sub_property props[] = {
 2828|      1|        {"picture-type",    SUB_PROP_STR(pict_type), .unavailable = !pict_type},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2829|      1|        {"interlaced",      SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_INTERLACED))},
  ------------------
  |  |  243|      1|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|      1|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2830|      1|        {"tff",             SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_TOP_FIRST))},
  ------------------
  |  |  243|      1|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|      1|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2831|      1|        {"repeat",          SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_REPEAT_FIRST))},
  ------------------
  |  |  243|      1|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|      1|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 2832|      1|        {"gop-timecode",    SUB_PROP_STR(gop_tc), .unavailable = gop_tc[0] == '\0'},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2833|      1|        {"smpte-timecode",  SUB_PROP_STR(s12m_tc), .unavailable = s12m_tc[0] == '\0'},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2834|      1|        {"estimated-smpte-timecode", SUB_PROP_STR(approx_smpte), .unavailable = approx_smpte[0] == '\0'},
  ------------------
  |  |  237|      1|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      1|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 2835|      1|        {0}
 2836|      1|    };
 2837|       |
 2838|      1|    talloc_free(f);
  ------------------
  |  |   47|      1|#define talloc_free                     ta_free
  ------------------
 2839|      1|    return m_property_read_sub(props, action, arg);
 2840|      1|}
command.c:get_frame_count:
 2487|    192|{
 2488|    192|    struct demuxer *demuxer = mpctx->demuxer;
 2489|    192|    if (!demuxer)
  ------------------
  |  Branch (2489:9): [True: 32, False: 160]
  ------------------
 2490|     32|        return -1;
 2491|    160|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2491:9): [True: 4, False: 156]
  ------------------
 2492|      4|        return -1;
 2493|    156|    double len = get_time_length(mpctx);
 2494|    156|    double fps = mpctx->vo_chain->filter->container_fps;
 2495|    156|    if (len < 0 || fps <= 0)
  ------------------
  |  Branch (2495:9): [True: 0, False: 156]
  |  Branch (2495:20): [True: 0, False: 156]
  ------------------
 2496|      0|        return 0;
 2497|       |
 2498|    156|    return len * fps;
 2499|    156|}
command.c:mp_property_current_window_scale:
 2844|     21|{
 2845|     21|    MPContext *mpctx = ctx;
 2846|     21|    struct vo *vo = mpctx->video_out;
 2847|     21|    if (!vo)
  ------------------
  |  Branch (2847:9): [True: 16, False: 5]
  ------------------
 2848|     16|        return M_PROPERTY_UNAVAILABLE;
 2849|       |
 2850|      5|    struct mp_image_params params = get_video_out_params(mpctx);
 2851|      5|    int vid_w, vid_h;
 2852|      5|    mp_image_params_get_dsize(&params, &vid_w, &vid_h);
 2853|      5|    if (vid_w < 1 || vid_h < 1)
  ------------------
  |  Branch (2853:9): [True: 0, False: 5]
  |  Branch (2853:22): [True: 0, False: 5]
  ------------------
 2854|      0|        return M_PROPERTY_UNAVAILABLE;
 2855|       |
 2856|      5|    if (params.rotate % 180 == 90 && (vo->driver->caps & VO_CAP_ROTATE90))
  ------------------
  |  Branch (2856:9): [True: 0, False: 5]
  |  Branch (2856:38): [True: 0, False: 0]
  ------------------
 2857|      0|        MPSWAP(int, vid_w, vid_h);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2858|       |
 2859|      5|    if (vo->monitor_par < 1) {
  ------------------
  |  Branch (2859:9): [True: 0, False: 5]
  ------------------
 2860|      0|        vid_h = MPCLAMP(vid_h / vo->monitor_par, 1, 16000);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2861|      5|    } else {
 2862|      5|        vid_w = MPCLAMP(vid_w * vo->monitor_par, 1, 16000);
  ------------------
  |  |   46|      5|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 5]
  |  |  |  Branch (46:56): [True: 0, False: 5]
  |  |  ------------------
  ------------------
 2863|      5|    }
 2864|       |
 2865|      5|    if (action == M_PROPERTY_SET) {
  ------------------
  |  Branch (2865:9): [True: 1, False: 4]
  ------------------
 2866|       |        // Also called by update_window_scale as a NULL property.
 2867|      1|        double scale = *(double *)arg;
 2868|      1|        int s[2] = {vid_w * scale, vid_h * scale};
 2869|      1|        if (s[0] <= 0 || s[1] <= 0)
  ------------------
  |  Branch (2869:13): [True: 0, False: 1]
  |  Branch (2869:26): [True: 0, False: 1]
  ------------------
 2870|      0|            return M_PROPERTY_INVALID_FORMAT;
 2871|      1|        vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
 2872|      1|        return M_PROPERTY_OK;
 2873|      1|    }
 2874|       |
 2875|      4|    int s[2];
 2876|      4|    if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
  ------------------
  |  Branch (2876:9): [True: 4, False: 0]
  ------------------
 2877|      0|        s[0] < 1 || s[1] < 1)
  ------------------
  |  Branch (2877:9): [True: 0, False: 0]
  |  Branch (2877:21): [True: 0, False: 0]
  ------------------
 2878|      4|        return M_PROPERTY_UNAVAILABLE;
 2879|       |
 2880|      0|    double xs = (double)s[0] / vid_w;
 2881|      0|    double ys = (double)s[1] / vid_h;
 2882|      0|    return m_property_double_ro(action, arg, (xs + ys) / 2);
 2883|      4|}
command.c:get_video_out_params:
 2663|      5|{
 2664|      5|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2664:9): [True: 0, False: 5]
  ------------------
 2665|      0|        return (struct mp_image_params){0};
 2666|       |
 2667|      5|    struct mp_image_params o_params = mpctx->vo_chain->filter->output_params;
 2668|      5|    if (mpctx->video_out) {
  ------------------
  |  Branch (2668:9): [True: 5, False: 0]
  ------------------
 2669|      5|        struct m_geometry *gm = &mpctx->video_out->opts->video_crop;
 2670|      5|        if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
  ------------------
  |  Branch (2670:13): [True: 0, False: 5]
  |  Branch (2670:30): [True: 0, False: 5]
  |  Branch (2670:47): [True: 0, False: 0]
  |  Branch (2670:60): [True: 0, False: 0]
  ------------------
 2671|      0|        {
 2672|      0|            m_rect_apply(&o_params.crop, o_params.w, o_params.h, gm);
 2673|      0|        }
 2674|      5|    }
 2675|       |
 2676|      5|    return o_params;
 2677|      5|}
command.c:mp_property_vo_configured:
 3052|     51|{
 3053|     51|    MPContext *mpctx = ctx;
 3054|     51|    return m_property_bool_ro(action, arg,
 3055|     51|                        mpctx->video_out && mpctx->video_out->config_ok);
  ------------------
  |  Branch (3055:25): [True: 15, False: 36]
  |  Branch (3055:45): [True: 15, False: 0]
  ------------------
 3056|     51|}
command.c:mp_property_vo_passes:
 3089|     36|{
 3090|     36|    MPContext *mpctx = ctx;
 3091|     36|    if (!mpctx->video_out)
  ------------------
  |  Branch (3091:9): [True: 36, False: 0]
  ------------------
 3092|     36|        return M_PROPERTY_UNAVAILABLE;
 3093|       |
 3094|       |    // Return early, to avoid having to go through a completely unnecessary VOCTRL
 3095|      0|    switch (action) {
 3096|      0|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (3096:5): [True: 0, False: 0]
  ------------------
 3097|      0|    case M_PROPERTY_GET:
  ------------------
  |  Branch (3097:5): [True: 0, False: 0]
  ------------------
 3098|      0|        break;
 3099|      0|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3099:5): [True: 0, False: 0]
  ------------------
 3100|      0|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|      0|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 3101|      0|        return M_PROPERTY_OK;
 3102|      0|    default:
  ------------------
  |  Branch (3102:5): [True: 0, False: 0]
  ------------------
 3103|      0|        return M_PROPERTY_NOT_IMPLEMENTED;
 3104|      0|    }
 3105|       |
 3106|      0|    struct voctrl_performance_data *data = talloc_ptrtype(NULL, data);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3107|      0|    if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, data) <= 0) {
  ------------------
  |  Branch (3107:9): [True: 0, False: 0]
  ------------------
 3108|      0|        talloc_free(data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3109|      0|        return M_PROPERTY_UNAVAILABLE;
 3110|      0|    }
 3111|       |
 3112|      0|    switch (action) {
  ------------------
  |  Branch (3112:13): [True: 0, False: 0]
  ------------------
 3113|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (3113:5): [True: 0, False: 0]
  ------------------
 3114|      0|        char *res = NULL;
 3115|      0|        res = talloc_asprintf_append(res, "fresh:\n");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3116|      0|        res = asprint_perf(res, &data->fresh);
 3117|      0|        res = talloc_asprintf_append(res, "\nredraw:\n");
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3118|      0|        res = asprint_perf(res, &data->redraw);
 3119|      0|        *(char **)arg = res;
 3120|      0|        break;
 3121|      0|    }
 3122|       |
 3123|      0|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3123:5): [True: 0, False: 0]
  ------------------
 3124|      0|        struct mpv_node node;
 3125|      0|        node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
 3126|      0|        struct mpv_node *fresh = node_map_add(&node, "fresh", MPV_FORMAT_NODE_ARRAY);
 3127|      0|        struct mpv_node *redraw = node_map_add(&node, "redraw", MPV_FORMAT_NODE_ARRAY);
 3128|      0|        get_frame_perf(fresh, &data->fresh);
 3129|      0|        get_frame_perf(redraw, &data->redraw);
 3130|      0|        *(struct mpv_node *)arg = node;
 3131|      0|        break;
 3132|      0|    }
 3133|      0|    }
 3134|       |
 3135|      0|    talloc_free(data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3136|      0|    return M_PROPERTY_OK;
 3137|      0|}
command.c:mp_property_perf_info:
 3141|     40|{
 3142|     40|    MPContext *mpctx = ctx;
 3143|       |
 3144|     40|    switch (action) {
  ------------------
  |  Branch (3144:13): [True: 24, False: 16]
  ------------------
 3145|     16|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3145:5): [True: 16, False: 24]
  ------------------
 3146|     16|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     16|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 3147|     16|        return M_PROPERTY_OK;
 3148|      8|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3148:5): [True: 8, False: 32]
  ------------------
 3149|      8|        stats_global_query(mpctx->global, (struct mpv_node *)arg);
 3150|      8|        return M_PROPERTY_OK;
 3151|      0|    }
 3152|     40|    }
 3153|     16|    return M_PROPERTY_NOT_IMPLEMENTED;
 3154|     40|}
command.c:mp_property_vo:
 3157|    156|{
 3158|    156|    MPContext *mpctx = ctx;
 3159|    156|    return m_property_strdup_ro(action, arg, mpctx->video_out ?
  ------------------
  |  Branch (3159:46): [True: 92, False: 64]
  ------------------
 3160|     92|                                mpctx->video_out->driver->name : NULL);
 3161|    156|}
command.c:mp_property_gpu_context:
 3164|     32|{
 3165|     32|    MPContext *mpctx = ctx;
 3166|     32|    return m_property_strdup_ro(action, arg, mpctx->video_out ?
  ------------------
  |  Branch (3166:46): [True: 12, False: 20]
  ------------------
 3167|     12|                                mpctx->video_out->context_name : NULL);
 3168|     32|}
command.c:mp_property_fps:
 3395|  6.01k|{
 3396|  6.01k|    MPContext *mpctx = ctx;
 3397|  6.01k|    float fps = mpctx->vo_chain ? mpctx->vo_chain->filter->container_fps : 0;
  ------------------
  |  Branch (3397:17): [True: 5.18k, False: 828]
  ------------------
 3398|  6.01k|    if (fps < 0.1 || !isfinite(fps))
  ------------------
  |  Branch (3398:9): [True: 828, False: 5.18k]
  |  Branch (3398:22): [True: 0, False: 5.18k]
  ------------------
 3399|    828|        return M_PROPERTY_UNAVAILABLE;
 3400|  5.18k|    return m_property_float_ro(action, arg, fps);
 3401|  6.01k|}
command.c:mp_property_vf_fps:
 3405|     38|{
 3406|     38|    MPContext *mpctx = ctx;
 3407|     38|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (3407:9): [True: 24, False: 14]
  ------------------
 3408|     24|        return M_PROPERTY_UNAVAILABLE;
 3409|     14|    double avg = calc_average_frame_duration(mpctx);
 3410|     14|    if (avg <= 0)
  ------------------
  |  Branch (3410:9): [True: 8, False: 6]
  ------------------
 3411|      8|        return M_PROPERTY_UNAVAILABLE;
 3412|      6|    return m_property_double_ro(action, arg, 1.0 / avg);
 3413|     14|}
command.c:mp_property_video_aspect_override:
 3419|  1.11k|{
 3420|  1.11k|    MPContext *mpctx = ctx;
 3421|  1.11k|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (3421:9): [True: 101, False: 1.01k]
  ------------------
 3422|    101|        double aspect_ratio;
 3423|    101|        mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &aspect_ratio);
 3424|       |
 3425|    101|        if (doubles_equal(aspect_ratio, 2.35 / 1.0))
  ------------------
  |  | 3415|    101|#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
  |  |  ------------------
  |  |  |  Branch (3415:29): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 3426|      0|            *(char **)arg = talloc_asprintf(NULL, "2.35:1");
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3427|    101|        else if (doubles_equal(aspect_ratio, 16.0 / 9.0))
  ------------------
  |  | 3415|    101|#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
  |  |  ------------------
  |  |  |  Branch (3415:29): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 3428|      0|            *(char **)arg = talloc_asprintf(NULL, "16:9");
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3429|    101|        else if (doubles_equal(aspect_ratio, 16.0 / 10.0))
  ------------------
  |  | 3415|    101|#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
  |  |  ------------------
  |  |  |  Branch (3415:29): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 3430|      0|            *(char **)arg = talloc_asprintf(NULL, "16:10");
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3431|    101|        else if (doubles_equal(aspect_ratio, 4.0 / 3.0))
  ------------------
  |  | 3415|    101|#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
  |  |  ------------------
  |  |  |  Branch (3415:29): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 3432|      0|            *(char **)arg = talloc_asprintf(NULL, "4:3");
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3433|    101|        else if (aspect_ratio < 0.0)
  ------------------
  |  Branch (3433:18): [True: 45, False: 56]
  ------------------
 3434|     45|            *(char **)arg = talloc_asprintf(NULL, "Original");
  ------------------
  |  |   52|     45|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     45|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3435|     56|        else
 3436|     56|            *(char **)arg = talloc_asprintf(NULL, "%.3f", aspect_ratio);
  ------------------
  |  |   52|     56|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     56|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3437|       |
 3438|    101|        return M_PROPERTY_OK;
 3439|    101|    }
 3440|  1.01k|    return mp_property_generic_option(mpctx, prop, action, arg);
 3441|  1.11k|}
command.c:mp_property_hwdec_current:
 2459|    234|{
 2460|    234|    MPContext *mpctx = ctx;
 2461|    234|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 2462|    234|    struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
  ------------------
  |  Branch (2462:38): [True: 126, False: 108]
  ------------------
 2463|    234|    char *current = NULL;
 2464|       |
 2465|    234|    if (!dec || !mp_decoder_wrapper_control(dec, VDCTRL_GET_HWDEC, &current))
  ------------------
  |  Branch (2465:9): [True: 117, False: 117]
  |  Branch (2465:17): [True: 105, False: 12]
  ------------------
 2466|    222|        return M_PROPERTY_UNAVAILABLE;
 2467|       |
 2468|     12|    if (!current || !current[0])
  ------------------
  |  Branch (2468:9): [True: 12, False: 0]
  |  Branch (2468:21): [True: 0, False: 0]
  ------------------
 2469|     12|        current = "no";
 2470|     12|    return m_property_strdup_ro(action, arg, current);
 2471|    234|}
command.c:mp_property_hwdec_interop:
 2475|    138|{
 2476|    138|    MPContext *mpctx = ctx;
 2477|    138|    if (!mpctx->video_out || !mpctx->video_out->hwdec_devs)
  ------------------
  |  Branch (2477:9): [True: 63, False: 75]
  |  Branch (2477:30): [True: 75, False: 0]
  ------------------
 2478|    138|        return M_PROPERTY_UNAVAILABLE;
 2479|       |
 2480|      0|    char *names = hwdec_devices_get_names(mpctx->video_out->hwdec_devs);
 2481|      0|    int res = m_property_strdup_ro(action, arg, names);
 2482|      0|    talloc_free(names);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2483|      0|    return res;
 2484|    138|}
command.c:mp_property_frame_count:
 2515|    186|{
 2516|    186|    MPContext *mpctx = ctx;
 2517|    186|    int frames = get_frame_count(mpctx);
 2518|    186|    if (frames < 0)
  ------------------
  |  Branch (2518:9): [True: 36, False: 150]
  ------------------
 2519|     36|        return M_PROPERTY_UNAVAILABLE;
 2520|       |
 2521|    150|    return m_property_int_ro(action, arg, frames);
 2522|    186|}
command.c:mp_property_frame_number:
 2503|      5|{
 2504|      5|    MPContext *mpctx = ctx;
 2505|      5|    int frames = get_frame_count(mpctx);
 2506|      5|    if (frames < 0)
  ------------------
  |  Branch (2506:9): [True: 0, False: 5]
  ------------------
 2507|      0|        return M_PROPERTY_UNAVAILABLE;
 2508|       |
 2509|      5|    return m_property_int_ro(action, arg,
 2510|       |        lrint(get_current_pos_ratio(mpctx, false) * frames));
 2511|      5|}
command.c:mp_property_osd_dim:
 3172|    207|{
 3173|    207|    MPContext *mpctx = ctx;
 3174|       |
 3175|    207|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 3176|    207|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (3176:9): [True: 0, False: 207]
  ------------------
 3177|      0|        return valid;
 3178|       |
 3179|    207|    struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd);
 3180|       |
 3181|    207|    if (!mpctx->video_out || !mpctx->video_out->config_ok)
  ------------------
  |  Branch (3181:9): [True: 48, False: 159]
  |  Branch (3181:30): [True: 39, False: 120]
  ------------------
 3182|     87|        vo_res = (struct mp_osd_res){0};
 3183|       |
 3184|    207|    double aspect = 1.0 * vo_res.w / MPMAX(vo_res.h, 1) /
  ------------------
  |  |   44|    207|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 207]
  |  |  ------------------
  ------------------
 3185|    207|                    (vo_res.display_par ? vo_res.display_par : 1);
  ------------------
  |  Branch (3185:22): [True: 0, False: 207]
  ------------------
 3186|       |
 3187|    207|    struct m_sub_property props[] = {
 3188|    207|        {"w",       SUB_PROP_INT(vo_res.w)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3189|    207|        {"h",       SUB_PROP_INT(vo_res.h)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3190|    207|        {"par",     SUB_PROP_DOUBLE(vo_res.display_par)},
  ------------------
  |  |  241|    207|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|    207|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 3191|    207|        {"aspect",  SUB_PROP_DOUBLE(aspect)},
  ------------------
  |  |  241|    207|    .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
  |  |  ------------------
  |  |  |  |  243|    207|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  |  |  ------------------
  ------------------
 3192|    207|        {"mt",      SUB_PROP_INT(vo_res.mt)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3193|    207|        {"mb",      SUB_PROP_INT(vo_res.mb)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3194|    207|        {"ml",      SUB_PROP_INT(vo_res.ml)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3195|    207|        {"mr",      SUB_PROP_INT(vo_res.mr)},
  ------------------
  |  |  233|    207|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|    207|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3196|    207|        {0}
 3197|    207|    };
 3198|       |
 3199|    207|    return m_property_read_sub(props, action, arg);
 3200|    207|}
command.c:mp_property_osd_ass:
 3213|     21|{
 3214|     21|    struct m_sub_property props[] = {
 3215|     21|        {"0",   SUB_PROP_STR(OSD_ASS_0)},
  ------------------
  |  |  237|     21|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|     21|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3216|     21|        {"1",   SUB_PROP_STR(OSD_ASS_1)},
  ------------------
  |  |  237|     21|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|     21|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3217|     21|        {0}
 3218|     21|    };
 3219|     21|    return m_property_read_sub(props, action, arg);
 3220|     21|}
command.c:mp_property_term_clip:
 3224|     68|{
 3225|     68|    return m_property_strdup_ro(action, arg, TERM_MSG_0);
  ------------------
  |  |   30|     68|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|     68|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
 3226|     68|}
command.c:mp_property_mouse_pos:
 3255|      8|{
 3256|      8|    MPContext *mpctx = ctx;
 3257|       |
 3258|      8|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 3259|      8|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (3259:9): [True: 8, False: 0]
  ------------------
 3260|      8|        return valid;
 3261|       |
 3262|      0|    int x, y, hover;
 3263|      0|    mp_input_get_mouse_pos(mpctx->input, &x, &y, &hover);
 3264|      0|    struct m_sub_property props[] = {
 3265|      0|        {"x",      SUB_PROP_INT64(x)},
  ------------------
  |  |  235|      0|    .type = {.type = CONF_TYPE_INT64}, .value = {.int64 = (i)}
  |  |  ------------------
  |  |  |  |  241|      0|#define CONF_TYPE_INT64         (&m_option_type_int64)
  |  |  ------------------
  ------------------
 3266|      0|        {"y",      SUB_PROP_INT64(y)},
  ------------------
  |  |  235|      0|    .type = {.type = CONF_TYPE_INT64}, .value = {.int64 = (i)}
  |  |  ------------------
  |  |  |  |  241|      0|#define CONF_TYPE_INT64         (&m_option_type_int64)
  |  |  ------------------
  ------------------
 3267|      0|        {"hover",  SUB_PROP_BOOL(!!hover)},
  ------------------
  |  |  243|      0|    .type = {.type = CONF_TYPE_BOOL}, .value = {.bool_ = (f)}
  |  |  ------------------
  |  |  |  |  238|      0|#define CONF_TYPE_BOOL          (&m_option_type_bool)
  |  |  ------------------
  ------------------
 3268|      0|        {0}
 3269|      0|    };
 3270|       |
 3271|      0|    return m_property_read_sub(props, action, arg);
 3272|      8|}
command.c:mp_property_touch_pos:
 3291|     64|{
 3292|     64|    MPContext *mpctx = ctx;
 3293|       |
 3294|     64|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 3295|     64|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (3295:9): [True: 64, False: 0]
  ------------------
 3296|     64|        return valid;
 3297|       |
 3298|      0|    int xs[MAX_TOUCH_POINTS], ys[MAX_TOUCH_POINTS], ids[MAX_TOUCH_POINTS];
 3299|      0|    int count = mp_input_get_touch_pos(mpctx->input, MAX_TOUCH_POINTS, xs, ys, ids);
  ------------------
  |  | 3288|      0|#define MAX_TOUCH_POINTS 10
  ------------------
 3300|      0|    const int *pos[3] = {xs, ys, ids};
 3301|      0|    return m_property_read_list(action, arg, MPMIN(MAX_TOUCH_POINTS, count),
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3302|      0|                                get_touch_pos, (void *)pos);
 3303|     64|}
command.c:mp_property_dropped_files:
 3356|     12|{
 3357|     12|    MPContext *mpctx = ctx;
 3358|       |
 3359|     12|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 3360|     12|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (3360:9): [True: 9, False: 3]
  ------------------
 3361|      9|        return valid;
 3362|       |
 3363|      3|    int64_t dnd_ts;
 3364|      3|    enum mp_dnd_action dnd_action;
 3365|      3|    char **dropped_files;
 3366|      3|    void *talloc_ctx = talloc_new(NULL);
  ------------------
  |  |   40|      3|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      3|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3367|      3|    mp_input_get_dropped_files(mpctx->input, talloc_ctx, &dnd_ts,
 3368|      3|                               &dnd_action, &dropped_files);
 3369|      3|    int r = M_PROPERTY_UNAVAILABLE;
 3370|      3|    if (dnd_action == DND_NONE)
  ------------------
  |  Branch (3370:9): [True: 3, False: 0]
  ------------------
 3371|      3|        goto done;
 3372|       |
 3373|      0|    char *actionstr = dnd_action == DND_REPLACE ? "replace" :
  ------------------
  |  Branch (3373:23): [True: 0, False: 0]
  ------------------
 3374|      0|                      dnd_action == DND_APPEND ? "append" :
  ------------------
  |  Branch (3374:23): [True: 0, False: 0]
  ------------------
 3375|      0|                      dnd_action == DND_INSERT_NEXT ? "insert-next" :
  ------------------
  |  Branch (3375:23): [True: 0, False: 0]
  ------------------
 3376|      0|                      "none";
 3377|       |
 3378|      0|    struct m_sub_property props[] = {
 3379|      0|        {"time",   SUB_PROP_INT64(dnd_ts)},
  ------------------
  |  |  235|      0|    .type = {.type = CONF_TYPE_INT64}, .value = {.int64 = (i)}
  |  |  ------------------
  |  |  |  |  241|      0|#define CONF_TYPE_INT64         (&m_option_type_int64)
  |  |  ------------------
  ------------------
 3380|      0|        {"action", SUB_PROP_STR(actionstr)},
  ------------------
  |  |  237|      0|    .type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
  |  |  ------------------
  |  |  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  |  |  ------------------
  ------------------
 3381|      0|        {"files",  SUB_PROP_STRING_LIST(dropped_files)},
  ------------------
  |  |  249|      0|    .type = {.type = CONF_TYPE_STRING_LIST}, .value = {.string_list = (l)}
  |  |  ------------------
  |  |  |  |  245|      0|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  |  |  ------------------
  ------------------
 3382|      0|        {0}
 3383|      0|    };
 3384|       |
 3385|      0|    r = m_property_read_sub(props, action, arg);
 3386|       |
 3387|      3|done:
 3388|      3|    talloc_free(talloc_ctx);
  ------------------
  |  |   47|      3|#define talloc_free                     ta_free
  ------------------
 3389|      3|    return r;
 3390|      0|}
command.c:mp_property_sub_delay:
 3446|     60|{
 3447|     60|    MPContext *mpctx = ctx;
 3448|     60|    struct MPOpts *opts = mpctx->opts;
 3449|     60|    int track_ind = *(int *)prop->priv;
 3450|     60|    switch (action) {
  ------------------
  |  Branch (3450:13): [True: 5, False: 55]
  ------------------
 3451|      5|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (3451:5): [True: 5, False: 55]
  ------------------
 3452|      5|        *(char **)arg = format_delay(opts->subs_shared->sub_delay[track_ind]);
 3453|      5|        return M_PROPERTY_OK;
 3454|     60|    }
 3455|     55|    return mp_property_generic_option(mpctx, prop, action, arg);
 3456|     60|}
command.c:mp_property_sub_speed:
 3461|    187|{
 3462|    187|    MPContext *mpctx = ctx;
 3463|    187|    struct MPOpts *opts = mpctx->opts;
 3464|    187|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (3464:9): [True: 17, False: 170]
  ------------------
 3465|     17|        *(char **)arg =
 3466|     17|            talloc_asprintf(NULL, "%4.1f%%", 100 * opts->subs_rend->sub_speed);
  ------------------
  |  |   52|     17|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|     17|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3467|     17|        return M_PROPERTY_OK;
 3468|     17|    }
 3469|    170|    return mp_property_generic_option(mpctx, prop, action, arg);
 3470|    187|}
command.c:mp_property_sub_pos:
 3474|     40|{
 3475|     40|    MPContext *mpctx = ctx;
 3476|     40|    struct MPOpts *opts = mpctx->opts;
 3477|     40|    int track_ind = *(int *)prop->priv;
 3478|     40|    if (action == M_PROPERTY_PRINT || action == M_PROPERTY_FIXED_LEN_PRINT) {
  ------------------
  |  Branch (3478:9): [True: 3, False: 37]
  |  Branch (3478:39): [True: 0, False: 37]
  ------------------
 3479|      3|        *(char **)arg = mp_format_double(NULL, opts->subs_shared->sub_pos[track_ind], 2,
 3480|      3|                                         false, true, action != M_PROPERTY_FIXED_LEN_PRINT);
 3481|      3|        return M_PROPERTY_OK;
 3482|      3|    }
 3483|     37|    return mp_property_generic_option(mpctx, prop, action, arg);
 3484|     40|}
command.c:mp_property_sub_ass_extradata:
 3488|     32|{
 3489|     32|    MPContext *mpctx = ctx;
 3490|     32|    struct track *track = mpctx->current_track[0][STREAM_SUB];
 3491|     32|    struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (3491:27): [True: 0, False: 32]
  ------------------
 3492|     32|    if (!sub)
  ------------------
  |  Branch (3492:9): [True: 32, False: 0]
  ------------------
 3493|     32|        return M_PROPERTY_UNAVAILABLE;
 3494|      0|    switch (action) {
  ------------------
  |  Branch (3494:13): [True: 0, False: 0]
  ------------------
 3495|      0|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3495:5): [True: 0, False: 0]
  ------------------
 3496|      0|        char *data = sub_ass_get_extradata(sub);
 3497|      0|        if (!data)
  ------------------
  |  Branch (3497:13): [True: 0, False: 0]
  ------------------
 3498|      0|            return M_PROPERTY_UNAVAILABLE;
 3499|      0|        *(char **)arg = data;
 3500|      0|        return M_PROPERTY_OK;
 3501|      0|    }
 3502|      0|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3502:5): [True: 0, False: 0]
  ------------------
 3503|      0|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 3504|      0|        return M_PROPERTY_OK;
 3505|      0|    }
 3506|      0|    return M_PROPERTY_NOT_IMPLEMENTED;
 3507|      0|}
command.c:mp_property_sub_text:
 3511|    126|{
 3512|    126|    MPContext *mpctx = ctx;
 3513|    126|    const int *def = prop->priv;
 3514|    126|    int sub_index = def[0];
 3515|    126|    int type = def[1];
 3516|       |
 3517|    126|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (3517:9): [True: 3, False: 123]
  ------------------
 3518|      3|        struct m_property_action_arg *ka = arg;
 3519|       |
 3520|      3|        if (!strcmp(ka->key, "ass"))
  ------------------
  |  Branch (3520:13): [True: 3, False: 0]
  ------------------
 3521|      3|            type = SD_TEXT_TYPE_ASS;
 3522|      0|        else if (!strcmp(ka->key, "ass-full"))
  ------------------
  |  Branch (3522:18): [True: 0, False: 0]
  ------------------
 3523|      0|            type = SD_TEXT_TYPE_ASS_FULL;
 3524|      0|        else
 3525|      0|            return M_PROPERTY_UNKNOWN;
 3526|       |
 3527|      3|        action = ka->action;
 3528|      3|        arg = ka->arg;
 3529|      3|    }
 3530|       |
 3531|    126|    struct track *track = mpctx->current_track[sub_index][STREAM_SUB];
 3532|    126|    struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (3532:27): [True: 84, False: 42]
  ------------------
 3533|    126|    double pts = mpctx->playback_pts;
 3534|    126|    if (!sub || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|     84|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3534:9): [True: 42, False: 84]
  |  Branch (3534:17): [True: 12, False: 72]
  ------------------
 3535|     54|        return M_PROPERTY_UNAVAILABLE;
 3536|       |
 3537|     72|    switch (action) {
  ------------------
  |  Branch (3537:13): [True: 36, False: 36]
  ------------------
 3538|      0|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3538:5): [True: 0, False: 72]
  ------------------
 3539|      0|        char *text = sub_get_text(sub, pts, type);
 3540|      0|        if (!text)
  ------------------
  |  Branch (3540:13): [True: 0, False: 0]
  ------------------
 3541|      0|            text = talloc_strdup(NULL, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3542|      0|        *(char **)arg = text;
 3543|      0|        return M_PROPERTY_OK;
 3544|      0|    }
 3545|     36|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3545:5): [True: 36, False: 36]
  ------------------
 3546|     36|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|     36|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 3547|     36|        return M_PROPERTY_OK;
 3548|     72|    }
 3549|     36|    return M_PROPERTY_NOT_IMPLEMENTED;
 3550|     72|}
command.c:mp_property_sub_start:
 3568|      9|{
 3569|      9|    double start = get_times(ctx, prop, action, arg).start;
 3570|      9|    if (start == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      9|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3570:9): [True: 9, False: 0]
  ------------------
 3571|      9|        return M_PROPERTY_UNAVAILABLE;
 3572|      0|    return property_time(action, arg, start);
 3573|      9|}
command.c:get_times:
 3554|    214|{
 3555|    214|    struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    214|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    214|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3556|    214|    MPContext *mpctx = ctx;
 3557|    214|    int track_ind = *(int *)prop->priv;
 3558|    214|    struct track *track = mpctx->current_track[track_ind][STREAM_SUB];
 3559|    214|    struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (3559:27): [True: 134, False: 80]
  ------------------
 3560|    214|    double pts = mpctx->playback_pts;
 3561|    214|    if (!sub || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    134|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3561:9): [True: 80, False: 134]
  |  Branch (3561:17): [True: 12, False: 122]
  ------------------
 3562|     92|        return res;
 3563|    122|    return sub_get_times(sub, pts);
 3564|    214|}
command.c:mp_property_sub_end:
 3578|    205|{
 3579|    205|    double end = get_times(ctx, prop, action, arg).end;
 3580|    205|    if (end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    205|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3580:9): [True: 115, False: 90]
  ------------------
 3581|    115|        return M_PROPERTY_UNAVAILABLE;
 3582|     90|    return property_time(action, arg, end);
 3583|    205|}
command.c:mp_property_sub_lines:
 3587|     47|{
 3588|     47|    MPContext *mpctx = ctx;
 3589|     47|    int sub_index = *(int *)prop->priv;
 3590|     47|    struct track *track = mpctx->current_track[sub_index][STREAM_SUB];
 3591|     47|    struct dec_sub *sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (3591:27): [True: 24, False: 23]
  ------------------
 3592|     47|    if (!sub)
  ------------------
  |  Branch (3592:9): [True: 23, False: 24]
  ------------------
 3593|     23|        return M_PROPERTY_UNAVAILABLE;
 3594|       |
 3595|     24|    switch (action) {
  ------------------
  |  Branch (3595:13): [True: 12, False: 12]
  ------------------
 3596|     12|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3596:5): [True: 12, False: 12]
  ------------------
 3597|     12|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     12|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 3598|     12|        return M_PROPERTY_OK;
 3599|      0|    case M_PROPERTY_GET:
  ------------------
  |  Branch (3599:5): [True: 0, False: 24]
  ------------------
 3600|      0|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (3600:5): [True: 0, False: 24]
  ------------------
 3601|      0|        struct sub_lines *lines = sub_get_lines(sub);
 3602|      0|        if (!lines)
  ------------------
  |  Branch (3602:13): [True: 0, False: 0]
  ------------------
 3603|      0|            return M_PROPERTY_UNAVAILABLE;
 3604|       |
 3605|      0|        struct mpv_node *node = arg;
 3606|      0|        node_init(node, MPV_FORMAT_NODE_ARRAY, NULL);
 3607|      0|        for (int i = 0; i < lines->num_entries; i++) {
  ------------------
  |  Branch (3607:25): [True: 0, False: 0]
  ------------------
 3608|      0|            struct sub_line *line = &lines->entries[i];
 3609|      0|            struct mpv_node *entry = node_array_add(node, MPV_FORMAT_NODE_MAP);
 3610|      0|            node_map_add_string(entry, "text", line->text);
 3611|      0|            node_map_add_double(entry, "start", line->start);
 3612|      0|            if (line->end != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3612:17): [True: 0, False: 0]
  ------------------
 3613|      0|                node_map_add_double(entry, "end", line->end);
 3614|      0|        }
 3615|      0|        talloc_free(lines);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3616|      0|        return M_PROPERTY_OK;
 3617|      0|    }
 3618|      0|    case M_PROPERTY_PRINT:
  ------------------
  |  Branch (3618:5): [True: 0, False: 24]
  ------------------
 3619|      0|    case M_PROPERTY_PRINT_UNCUT: {
  ------------------
  |  Branch (3619:5): [True: 0, False: 24]
  ------------------
 3620|      0|        struct sub_lines *lines = sub_get_lines(sub);
 3621|      0|        if (!lines)
  ------------------
  |  Branch (3621:13): [True: 0, False: 0]
  ------------------
 3622|      0|            return M_PROPERTY_UNAVAILABLE;
 3623|       |
 3624|      0|        char *res = talloc_strdup(NULL, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 3625|      0|        double time_pos = get_playback_time(mpctx);
 3626|      0|        int pos = 0;
 3627|       |
 3628|      0|        for (int i = 0; i < lines->num_entries; i++) {
  ------------------
  |  Branch (3628:25): [True: 0, False: 0]
  ------------------
 3629|      0|            struct sub_line *line = &lines->entries[i];
 3630|      0|            const char *reset = "";
 3631|       |
 3632|      0|            if (line->start <= time_pos && line->end > time_pos) {
  ------------------
  |  Branch (3632:17): [True: 0, False: 0]
  |  Branch (3632:44): [True: 0, False: 0]
  ------------------
 3633|      0|                res = append_selected_style(mpctx, res);
 3634|      0|                reset = get_style_reset(mpctx);
 3635|      0|            }
 3636|       |
 3637|      0|            res = talloc_asprintf_append(res, "%s%s\n", line->text, reset);
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3638|       |
 3639|      0|            if (line->start <= time_pos && i)
  ------------------
  |  Branch (3639:17): [True: 0, False: 0]
  |  Branch (3639:44): [True: 0, False: 0]
  ------------------
 3640|      0|                pos += count_lines(lines->entries[i - 1].text);
 3641|      0|        }
 3642|       |
 3643|      0|        *(char **)arg = cut_osd_list(mpctx, action, "Subtitle lines", res, pos);
 3644|      0|        talloc_free(lines);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3645|      0|        return M_PROPERTY_OK;
 3646|      0|    }
 3647|     24|    }
 3648|     12|    return M_PROPERTY_NOT_IMPLEMENTED;
 3649|     24|}
command.c:mp_property_vf:
 3863|  14.4k|{
 3864|  14.4k|    return property_filter(prop, action, arg, ctx, STREAM_VIDEO);
 3865|  14.4k|}
command.c:property_filter:
 3851|   114k|{
 3852|   114k|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (3852:9): [True: 22.8k, False: 91.4k]
  ------------------
 3853|  22.8k|        struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
 3854|  22.8k|                                                      bstr0(prop->name));
 3855|  22.8k|        *(char **)arg = print_obj_osd_list(*(struct m_obj_settings **)opt->data);
 3856|  22.8k|        return M_PROPERTY_OK;
 3857|  22.8k|    }
 3858|  91.4k|    return mp_property_generic_option(mpctx, prop, action, arg);
 3859|   114k|}
command.c:print_obj_osd_list:
 3830|  22.8k|{
 3831|  22.8k|    char *res = NULL;
 3832|  45.5k|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (3832:21): [True: 44.7k, False: 832]
  |  Branch (3832:29): [True: 22.7k, False: 22.0k]
  ------------------
 3833|  22.7k|        res = talloc_asprintf_append(res, "%s [", list[n].name);
  ------------------
  |  |   63|  22.7k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3834|  24.6k|        for (int i = 0; list[n].attribs && list[n].attribs[i]; i += 2) {
  ------------------
  |  Branch (3834:25): [True: 3.29k, False: 21.3k]
  |  Branch (3834:44): [True: 1.94k, False: 1.35k]
  ------------------
 3835|  1.94k|            res = talloc_asprintf_append(res, "%s%s=%s", i > 0 ? " " : "",
  ------------------
  |  |   63|  1.94k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (3835:58): [True: 581, False: 1.35k]
  ------------------
 3836|  1.94k|                                         list[n].attribs[i],
 3837|  1.94k|                                         list[n].attribs[i + 1]);
 3838|  1.94k|        }
 3839|  22.7k|        res = talloc_asprintf_append(res, "]");
  ------------------
  |  |   63|  22.7k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
 3840|  22.7k|        if (!list[n].enabled)
  ------------------
  |  Branch (3840:13): [True: 0, False: 22.7k]
  ------------------
 3841|      0|            res = talloc_strdup_append(res, " (disabled)");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3842|  22.7k|        res = talloc_strdup_append(res, "\n");
  ------------------
  |  |   57|  22.7k|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
 3843|  22.7k|    }
 3844|  22.8k|    if (!res)
  ------------------
  |  Branch (3844:9): [True: 2.88k, False: 19.9k]
  ------------------
 3845|  2.88k|        res = talloc_strdup(NULL, "(empty)");
  ------------------
  |  |   50|  2.88k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3846|  22.8k|    return res;
 3847|  22.8k|}
command.c:mp_property_af:
 3869|  99.7k|{
 3870|  99.7k|    return property_filter(prop, action, arg, ctx, STREAM_AUDIO);
 3871|  99.7k|}
command.c:mp_property_ab_loop:
 3875|   139k|{
 3876|   139k|    struct MPContext *mpctx = ctx;
 3877|   139k|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (3877:9): [True: 29, False: 139k]
  ------------------
 3878|     29|        double val;
 3879|     29|        if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &val) < 1)
  ------------------
  |  Branch (3879:13): [True: 0, False: 29]
  ------------------
 3880|      0|            return M_PROPERTY_ERROR;
 3881|       |
 3882|     29|        return property_time(action, arg, val);
 3883|     29|    }
 3884|   139k|    return mp_property_generic_option(mpctx, prop, action, arg);
 3885|   139k|}
command.c:mp_property_packet_bitrate:
 3889|     43|{
 3890|     43|    MPContext *mpctx = ctx;
 3891|     43|    int type = *(int *)prop->priv;
 3892|       |
 3893|     43|    struct demuxer *demuxer = NULL;
 3894|     43|    if (mpctx->current_track[0][type])
  ------------------
  |  Branch (3894:9): [True: 15, False: 28]
  ------------------
 3895|     15|        demuxer = mpctx->current_track[0][type]->demuxer;
 3896|     43|    if (!demuxer)
  ------------------
  |  Branch (3896:9): [True: 28, False: 15]
  ------------------
 3897|     28|        demuxer = mpctx->demuxer;
 3898|     43|    if (!demuxer)
  ------------------
  |  Branch (3898:9): [True: 8, False: 35]
  ------------------
 3899|      8|        return M_PROPERTY_UNAVAILABLE;
 3900|       |
 3901|     35|    double r[STREAM_TYPE_COUNT];
 3902|     35|    demux_get_bitrate_stats(demuxer, r);
 3903|     35|    if (r[type] < 0)
  ------------------
  |  Branch (3903:9): [True: 35, False: 0]
  ------------------
 3904|     35|        return M_PROPERTY_UNAVAILABLE;
 3905|       |
 3906|       |    // r[type] is in bytes/second -> bits
 3907|      0|    double rate = r[type] * 8;
 3908|       |
 3909|      0|    if (action == M_PROPERTY_PRINT) {
  ------------------
  |  Branch (3909:9): [True: 0, False: 0]
  ------------------
 3910|      0|        rate /= 1000;
 3911|      0|        if (rate < 1000) {
  ------------------
  |  Branch (3911:13): [True: 0, False: 0]
  ------------------
 3912|      0|            *(char **)arg = talloc_asprintf(NULL, "%.f kbps", rate);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3913|      0|        } else {
 3914|      0|            *(char **)arg = talloc_asprintf(NULL, "%.3f Mbps", rate / 1000.0);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 3915|      0|        }
 3916|      0|        return M_PROPERTY_OK;
 3917|      0|    }
 3918|      0|    return m_property_int64_ro(action, arg, llrint(rate));
 3919|      0|}
command.c:mp_property_focused:
 3013|     75|{
 3014|     75|    MPContext *mpctx = ctx;
 3015|     75|    struct vo *vo = mpctx->video_out;
 3016|     75|    if (!vo)
  ------------------
  |  Branch (3016:9): [True: 60, False: 15]
  ------------------
 3017|     60|        return M_PROPERTY_UNAVAILABLE;
 3018|       |
 3019|     75|    bool focused;
 3020|     15|    if (vo_control(vo, VOCTRL_GET_FOCUSED, &focused) < 1)
  ------------------
  |  Branch (3020:9): [True: 15, False: 0]
  ------------------
 3021|     15|        return M_PROPERTY_UNAVAILABLE;
 3022|       |
 3023|      0|    return m_property_bool_ro(action, arg, focused);
 3024|     15|}
command.c:mp_property_display_names:
 3028|     42|{
 3029|     42|    MPContext *mpctx = ctx;
 3030|     42|    struct vo *vo = mpctx->video_out;
 3031|     42|    if (!vo || vo->display_swapchain)
  ------------------
  |  Branch (3031:9): [True: 6, False: 36]
  |  Branch (3031:16): [True: 0, False: 36]
  ------------------
 3032|      6|        return M_PROPERTY_UNAVAILABLE;
 3033|       |
 3034|     36|    switch (action) {
  ------------------
  |  Branch (3034:13): [True: 22, False: 14]
  ------------------
 3035|     14|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3035:5): [True: 14, False: 22]
  ------------------
 3036|     14|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|     14|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 3037|     14|        return M_PROPERTY_OK;
 3038|      8|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3038:5): [True: 8, False: 28]
  ------------------
 3039|      8|        char** display_names;
 3040|      8|        if (vo_control(vo, VOCTRL_GET_DISPLAY_NAMES, &display_names) < 1)
  ------------------
  |  Branch (3040:13): [True: 8, False: 0]
  ------------------
 3041|      8|            return M_PROPERTY_UNAVAILABLE;
 3042|       |
 3043|      0|        *(char ***)arg = display_names;
 3044|      0|        return M_PROPERTY_OK;
 3045|      8|    }
 3046|     36|    }
 3047|     14|    return M_PROPERTY_NOT_IMPLEMENTED;
 3048|     36|}
command.c:mp_property_display_fps:
 2894|    418|{
 2895|    418|    MPContext *mpctx = ctx;
 2896|    418|    double fps = mpctx->video_out ? vo_get_display_fps(mpctx->video_out) : 0;
  ------------------
  |  Branch (2896:18): [True: 33, False: 385]
  ------------------
 2897|    418|    switch (action) {
  ------------------
  |  Branch (2897:13): [True: 228, False: 190]
  ------------------
 2898|     76|    case M_PROPERTY_GET:
  ------------------
  |  Branch (2898:5): [True: 76, False: 342]
  ------------------
 2899|     76|        if (fps <= 0)
  ------------------
  |  Branch (2899:13): [True: 76, False: 0]
  ------------------
 2900|     76|            return M_PROPERTY_UNAVAILABLE;
 2901|      0|        return m_property_double_ro(action, arg, fps);
 2902|    152|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (2902:5): [True: 152, False: 266]
  ------------------
 2903|    152|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_DOUBLE};
  ------------------
  |  |  243|    152|#define CONF_TYPE_DOUBLE        (&m_option_type_double)
  ------------------
 2904|    152|        return M_PROPERTY_OK;
 2905|    418|    }
 2906|    190|    return M_PROPERTY_NOT_IMPLEMENTED;
 2907|    418|}
command.c:mp_property_estimated_display_fps:
 2911|     16|{
 2912|     16|    MPContext *mpctx = ctx;
 2913|     16|    struct vo *vo = mpctx->video_out;
 2914|     16|    if (!vo)
  ------------------
  |  Branch (2914:9): [True: 4, False: 12]
  ------------------
 2915|      4|        return M_PROPERTY_UNAVAILABLE;
 2916|     12|    double interval = vo_get_estimated_vsync_interval(vo) / 1e9;
 2917|     12|    if (interval <= 0)
  ------------------
  |  Branch (2917:9): [True: 12, False: 0]
  ------------------
 2918|     12|        return M_PROPERTY_UNAVAILABLE;
 2919|      0|    return m_property_double_ro(action, arg, 1.0 / interval);
 2920|     12|}
command.c:mp_property_vsync_jitter:
 2924|     34|{
 2925|     34|    MPContext *mpctx = ctx;
 2926|     34|    struct vo *vo = mpctx->video_out;
 2927|     34|    if (!vo)
  ------------------
  |  Branch (2927:9): [True: 13, False: 21]
  ------------------
 2928|     13|        return M_PROPERTY_UNAVAILABLE;
 2929|     21|    double stddev = vo_get_estimated_vsync_jitter(vo);
 2930|     21|    if (stddev < 0)
  ------------------
  |  Branch (2930:9): [True: 21, False: 0]
  ------------------
 2931|     21|        return M_PROPERTY_UNAVAILABLE;
 2932|      0|    return m_property_double_ro(action, arg, stddev);
 2933|     21|}
command.c:mp_property_hidpi_scale:
 2954|    155|{
 2955|    155|    MPContext *mpctx = ctx;
 2956|    155|    struct command_ctx *cmd = mpctx->command_ctx;
 2957|    155|    struct vo *vo = mpctx->video_out;
 2958|    155|    if (!vo)
  ------------------
  |  Branch (2958:9): [True: 100, False: 55]
  ------------------
 2959|    100|        return M_PROPERTY_UNAVAILABLE;
 2960|     55|    if (!cmd->cached_window_scale) {
  ------------------
  |  Branch (2960:9): [True: 7, False: 48]
  ------------------
 2961|      7|        double scale = 0;
 2962|      7|        if (vo_control(vo, VOCTRL_GET_HIDPI_SCALE, &scale) < 1 || !scale)
  ------------------
  |  Branch (2962:13): [True: 7, False: 0]
  |  Branch (2962:67): [True: 0, False: 0]
  ------------------
 2963|      7|            scale = -1;
 2964|      7|        cmd->cached_window_scale = scale;
 2965|      7|    }
 2966|     55|    if (cmd->cached_window_scale < 0)
  ------------------
  |  Branch (2966:9): [True: 55, False: 0]
  ------------------
 2967|     55|        return M_PROPERTY_UNAVAILABLE;
 2968|      0|    return m_property_double_ro(action, arg, cmd->cached_window_scale);
 2969|     55|}
command.c:mp_property_ambient_light:
 2993|     83|{
 2994|     83|    MPContext *mpctx = ctx;
 2995|     83|    if (!mpctx->als_state) {
  ------------------
  |  Branch (2995:9): [True: 8, False: 75]
  ------------------
 2996|      8|        mpctx->als_state = mp_als_create(mpctx, mpctx);
 2997|      8|    }
 2998|       |
 2999|     83|    double lux;
 3000|     83|    switch (mp_als_get_lux(mpctx->als_state, &lux)) {
 3001|      0|    case MP_ALS_STATUS_OK:
  ------------------
  |  Branch (3001:5): [True: 0, False: 83]
  ------------------
 3002|      0|        return m_property_double_ro(action, arg, lux);
 3003|     83|    case MP_ALS_STATUS_NODEVICE:
  ------------------
  |  Branch (3003:5): [True: 83, False: 0]
  ------------------
 3004|     83|        return M_PROPERTY_UNAVAILABLE;
 3005|      0|    case MP_ALS_STATUS_READFAILED:
  ------------------
  |  Branch (3005:5): [True: 0, False: 83]
  ------------------
 3006|      0|    default:
  ------------------
  |  Branch (3006:5): [True: 0, False: 83]
  ------------------
 3007|      0|        return M_PROPERTY_ERROR;
 3008|     83|    }
 3009|     83|}
command.c:mp_property_cwd:
 3923|     22|{
 3924|     22|    switch (action) {
  ------------------
  |  Branch (3924:13): [True: 3, False: 19]
  ------------------
 3925|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (3925:5): [True: 1, False: 21]
  ------------------
 3926|      1|        char *cwd = mp_getcwd(NULL);
 3927|      1|        if (!cwd)
  ------------------
  |  Branch (3927:13): [True: 0, False: 1]
  ------------------
 3928|      0|            return M_PROPERTY_ERROR;
 3929|      1|        *(char **)arg = cwd;
 3930|      1|        return M_PROPERTY_OK;
 3931|      1|    }
 3932|      2|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3932:5): [True: 2, False: 20]
  ------------------
 3933|      2|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|      2|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 3934|      2|        return M_PROPERTY_OK;
 3935|     22|    }
 3936|     19|    return M_PROPERTY_NOT_IMPLEMENTED;
 3937|     22|}
command.c:mp_property_current_watch_later_dir:
 3941|      7|{
 3942|      7|    MPContext *mpctx = ctx;
 3943|      7|    char *dir = mp_get_playback_resume_dir(mpctx);
 3944|      7|    int r = m_property_strdup_ro(action, arg, dir);
 3945|      7|    talloc_free(dir);
  ------------------
  |  |   47|      7|#define talloc_free                     ta_free
  ------------------
 3946|      7|    return r;
 3947|      7|}
command.c:mp_property_protocols:
 3951|     46|{
 3952|     46|    switch (action) {
  ------------------
  |  Branch (3952:13): [True: 23, False: 23]
  ------------------
 3953|      3|    case M_PROPERTY_GET:
  ------------------
  |  Branch (3953:5): [True: 3, False: 43]
  ------------------
 3954|      3|        *(char ***)arg = stream_get_proto_list(false);
 3955|      3|        return M_PROPERTY_OK;
 3956|     20|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3956:5): [True: 20, False: 26]
  ------------------
 3957|     20|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|     20|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 3958|     20|        return M_PROPERTY_OK;
 3959|     46|    }
 3960|     23|    return M_PROPERTY_NOT_IMPLEMENTED;
 3961|     46|}
command.c:mp_property_decoders:
 3994|     12|{
 3995|     12|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 3996|     12|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (3996:9): [True: 12, False: 0]
  ------------------
 3997|     12|        return valid;
 3998|       |
 3999|      0|    struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4000|      0|    struct mp_decoder_list *v = talloc_steal(codecs, video_decoder_list());
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4001|      0|    struct mp_decoder_list *a = talloc_steal(codecs, audio_decoder_list());
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4002|      0|    mp_append_decoders(codecs, v);
 4003|      0|    mp_append_decoders(codecs, a);
 4004|      0|    int r = m_property_read_list(action, arg, codecs->num_entries,
 4005|      0|                                 get_decoder_entry, codecs);
 4006|      0|    talloc_free(codecs);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4007|      0|    return r;
 4008|     12|}
command.c:mp_property_encoders:
 4012|     12|{
 4013|     12|    int valid = m_property_read_sub_validate(ctx, prop, action, arg);
 4014|     12|    if (valid != M_PROPERTY_VALID)
  ------------------
  |  Branch (4014:9): [True: 12, False: 0]
  ------------------
 4015|     12|        return valid;
 4016|       |
 4017|      0|    struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4018|      0|    mp_add_lavc_encoders(codecs);
 4019|      0|    int r = m_property_read_list(action, arg, codecs->num_entries,
 4020|      0|                                 get_decoder_entry, codecs);
 4021|      0|    talloc_free(codecs);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4022|      0|    return r;
 4023|     12|}
command.c:mp_property_lavf_demuxers:
 4027|     18|{
 4028|     18|    switch (action) {
  ------------------
  |  Branch (4028:13): [True: 9, False: 9]
  ------------------
 4029|      1|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4029:5): [True: 1, False: 17]
  ------------------
 4030|      1|        *(char ***)arg = mp_get_lavf_demuxers();
 4031|      1|        return M_PROPERTY_OK;
 4032|      8|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4032:5): [True: 8, False: 10]
  ------------------
 4033|      8|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|      8|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 4034|      8|        return M_PROPERTY_OK;
 4035|     18|    }
 4036|      9|    return M_PROPERTY_NOT_IMPLEMENTED;
 4037|     18|}
command.c:mp_property_keylist:
 3965|     28|{
 3966|     28|    switch (action) {
  ------------------
  |  Branch (3966:13): [True: 14, False: 14]
  ------------------
 3967|      2|    case M_PROPERTY_GET:
  ------------------
  |  Branch (3967:5): [True: 2, False: 26]
  ------------------
 3968|      2|        *(char ***)arg = mp_get_key_list();
 3969|      2|        return M_PROPERTY_OK;
 3970|     12|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (3970:5): [True: 12, False: 16]
  ------------------
 3971|     12|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|     12|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 3972|     12|        return M_PROPERTY_OK;
 3973|     28|    }
 3974|     14|    return M_PROPERTY_NOT_IMPLEMENTED;
 3975|     28|}
command.c:mp_property_version:
 4041|    668|{
 4042|    668|    return m_property_strdup_ro(action, arg, mpv_version);
 4043|    668|}
command.c:mp_property_configuration:
 4047|     12|{
 4048|     12|    return m_property_strdup_ro(action, arg, CONFIGURATION);
  ------------------
  |  |    8|     12|#define CONFIGURATION "-Dbuildtype=plain -Dwrap_mode=nodownload -Dbackend_max_links=4 -Ddefault_library=static -Dprefer_static=true -Dfuzzers=true -Dlibmpv=true -Dcplayer=false -Dgpl=true -Duchardet=enabled -Dlcms2=enabled -Dtests=false -Dfreetype2:harfbuzz=disabled -Dfreetype2:zlib=disabled -Dfreetype2:png=disabled -Dharfbuzz:tests=disabled -Dharfbuzz:introspection=disabled -Dharfbuzz:docs=disabled -Dharfbuzz:utilities=disabled -Dfontconfig:doc=disabled -Dfontconfig:nls=disabled -Dfontconfig:xml-backend=expat -Dfontconfig:tests=disabled -Dfontconfig:tools=disabled -Dfontconfig:cache-build=disabled -Dfribidi:deprecated=false -Dfribidi:docs=false -Dfribidi:bin=false -Dfribidi:tests=false -Dlibplacebo:lcms=enabled -Dlibplacebo:xxhash=enabled -Dlibplacebo:demos=false -Dlcms2:jpeg=disabled -Dlcms2:tiff=disabled -Dlibass:fontconfig=enabled -Dlibass:asm=disabled '-Dc_args=-O1   -fno-omit-frame-pointer   -gline-tables-only   -Wno-error=incompatible-function-pointer-types   -Wno-error=int-conversion   -Wno-error=deprecated-declarations   -Wno-error=implicit-function-declaration   -Wno-error=implicit-int   -Wno-error=unknown-warning-option   -Wno-error=vla-cxx-extension   -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument -DMPV_FONTCONFIG_SYSROOT=./src_root/fc_sysroot' '-Dcpp_args=-O1   -fno-omit-frame-pointer   -gline-tables-only   -Wno-error=incompatible-function-pointer-types   -Wno-error=int-conversion   -Wno-error=deprecated-declarations   -Wno-error=implicit-function-declaration   -Wno-error=implicit-int   -Wno-error=unknown-warning-option   -Wno-error=vla-cxx-extension   -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument -stdlib=libc++ -DMPV_FONTCONFIG_SYSROOT=./src_root/fc_sysroot' '-Dc_link_args=-O1   -fno-omit-frame-pointer   -gline-tables-only   -Wno-error=incompatible-function-pointer-types   -Wno-error=int-conversion   -Wno-error=deprecated-declarations   -Wno-error=implicit-function-declaration   -Wno-error=implicit-int   -Wno-error=unknown-warning-option   -Wno-error=vla-cxx-extension   -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument' '-Dcpp_link_args=-O1   -fno-omit-frame-pointer   -gline-tables-only   -Wno-error=incompatible-function-pointer-types   -Wno-error=int-conversion   -Wno-error=deprecated-declarations   -Wno-error=implicit-function-declaration   -Wno-error=implicit-int   -Wno-error=unknown-warning-option   -Wno-error=vla-cxx-extension   -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument -stdlib=libc++' -Dlibdir=lib/x86_64-linux-gnu"
  ------------------
 4049|     12|}
command.c:mp_property_ffmpeg:
 4053|     12|{
 4054|     12|    return m_property_strdup_ro(action, arg, av_version_info());
 4055|     12|}
command.c:mp_property_libass_version:
 4059|      3|{
 4060|      3|    return m_property_int64_ro(action, arg, ass_library_version());
 4061|      3|}
command.c:mp_property_libplacebo_version:
 4065|      4|{
 4066|      4|    return m_property_strdup_ro(action, arg, PL_VERSION);
  ------------------
  |  |   32|      4|#define PL_VERSION (pl_version())
  ------------------
 4067|      4|}
command.c:mp_property_subrandr_version:
 4071|      7|{
 4072|       |#if HAVE_SUBRANDR
 4073|       |    uint32_t major, minor, patch;
 4074|       |    sbr_library_version(&major, &minor, &patch);
 4075|       |    const char *result = mp_tprintf(33, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, major, minor, patch);
 4076|       |    return m_property_strdup_ro(action, arg, result);
 4077|       |#else
 4078|      7|    return M_PROPERTY_UNAVAILABLE;
 4079|      7|#endif
 4080|      7|}
command.c:mp_property_platform:
 4084|      4|{
 4085|      4|    return m_property_strdup_ro(action, arg, PLATFORM);
  ------------------
  |  |  284|      4|#define PLATFORM "linux"
  ------------------
 4086|      4|}
command.c:mp_property_options:
 4161|  1.79k|{
 4162|  1.79k|    MPContext *mpctx = ctx;
 4163|       |    return access_option_list(action, arg, false, mpctx);
 4164|  1.79k|}
command.c:access_option_list:
 4144|  1.94k|{
 4145|  1.94k|    switch (action) {
  ------------------
  |  Branch (4145:13): [True: 1.84k, False: 93]
  ------------------
 4146|     92|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4146:5): [True: 92, False: 1.85k]
  ------------------
 4147|     92|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|     92|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 4148|     92|        return M_PROPERTY_OK;
 4149|      1|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4149:5): [True: 1, False: 1.94k]
  ------------------
 4150|      1|        *(char ***)arg = m_config_list_options(NULL, mpctx->mconfig);
 4151|      1|        return M_PROPERTY_OK;
 4152|  1.75k|    case M_PROPERTY_KEY_ACTION:
  ------------------
  |  Branch (4152:5): [True: 1.75k, False: 186]
  ------------------
 4153|  1.75k|        return access_options(arg, local, mpctx);
 4154|  1.94k|    }
 4155|     93|    return M_PROPERTY_NOT_IMPLEMENTED;
 4156|  1.94k|}
command.c:access_options:
 4116|  1.75k|{
 4117|  1.75k|    struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
 4118|  1.75k|                                                  bstr0(ka->key));
 4119|  1.75k|    if (!opt)
  ------------------
  |  Branch (4119:9): [True: 101, False: 1.65k]
  ------------------
 4120|    101|        return M_PROPERTY_UNKNOWN;
 4121|  1.65k|    if (!opt->data)
  ------------------
  |  Branch (4121:9): [True: 31, False: 1.62k]
  ------------------
 4122|     31|        return M_PROPERTY_UNAVAILABLE;
 4123|       |
 4124|  1.62k|    switch (ka->action) {
  ------------------
  |  Branch (4124:13): [True: 947, False: 677]
  ------------------
 4125|    270|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4125:5): [True: 270, False: 1.35k]
  ------------------
 4126|    270|        m_option_copy(opt->opt, ka->arg, opt->data);
 4127|    270|        return M_PROPERTY_OK;
 4128|    135|    case M_PROPERTY_SET: {
  ------------------
  |  Branch (4128:5): [True: 135, False: 1.48k]
  ------------------
 4129|    135|        if (local && !mpctx->playing)
  ------------------
  |  Branch (4129:13): [True: 0, False: 135]
  |  Branch (4129:22): [True: 0, False: 0]
  ------------------
 4130|      0|            return M_PROPERTY_ERROR;
 4131|    135|        int flags = local ? M_SETOPT_BACKUP : 0;
  ------------------
  |  Branch (4131:21): [True: 0, False: 135]
  ------------------
 4132|    135|        int r = m_config_set_option_raw(mpctx->mconfig, opt, ka->arg, flags);
 4133|    135|        mp_wakeup_core(mpctx);
 4134|    135|        return r < 0 ? M_PROPERTY_ERROR : M_PROPERTY_OK;
  ------------------
  |  Branch (4134:16): [True: 0, False: 135]
  ------------------
 4135|    135|    }
 4136|    542|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4136:5): [True: 542, False: 1.08k]
  ------------------
 4137|    542|        *(struct m_option *)ka->arg = *opt->opt;
 4138|    542|        return M_PROPERTY_OK;
 4139|  1.62k|    }
 4140|    677|    return M_PROPERTY_NOT_IMPLEMENTED;
 4141|  1.62k|}
command.c:mp_property_local_options:
 4168|    152|{
 4169|    152|    MPContext *mpctx = ctx;
 4170|       |    return access_option_list(action, arg, true, mpctx);
 4171|    152|}
command.c:mp_property_list:
 4251|     10|{
 4252|     10|    struct MPContext *mpctx = ctx;
 4253|     10|    struct command_ctx *cmd = mpctx->command_ctx;
 4254|       |
 4255|     10|    switch (action) {
  ------------------
  |  Branch (4255:13): [True: 5, False: 5]
  ------------------
 4256|      4|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4256:5): [True: 4, False: 6]
  ------------------
 4257|      4|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
  ------------------
  |  |  245|      4|#define CONF_TYPE_STRING_LIST   (&m_option_type_string_list)
  ------------------
 4258|      4|        return M_PROPERTY_OK;
 4259|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (4259:5): [True: 1, False: 9]
  ------------------
 4260|      1|        char **list = NULL;
 4261|      1|        int num = 0;
 4262|    928|        for (int n = 0; n < cmd->properties.num; n++) {
  ------------------
  |  Branch (4262:25): [True: 927, False: 1]
  ------------------
 4263|    927|            MP_TARRAY_APPEND(NULL, list, num,
  ------------------
  |  |  105|    927|    do {                                            \
  |  |  106|    927|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    927|    do {                                            \
  |  |  |  |   97|    927|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    927|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    927|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    927|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 9, False: 918]
  |  |  |  |  ------------------
  |  |  |  |   99|    927|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      9|    do {                                                        \
  |  |  |  |  |  |   89|      9|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      9|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      9|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      9|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      9|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      9|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      9|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 9]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    927|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 927]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    927|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    927|        (idxvar)++;                                 \
  |  |  109|    927|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 927]
  |  |  ------------------
  ------------------
 4264|    927|                             talloc_strdup(NULL, cmd->properties.props[n].name));
 4265|    927|        }
 4266|      1|        MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|      1|    do {                                            \
  |  |  106|      1|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      1|    do {                                            \
  |  |  |  |   97|      1|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      1|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      1|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      1|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |   99|      1|            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|      1|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      1|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      1|        (idxvar)++;                                 \
  |  |  109|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
 4267|      1|        *(char ***)arg = list;
 4268|      1|        return M_PROPERTY_OK;
 4269|      0|    }
 4270|     10|    }
 4271|      5|    return M_PROPERTY_NOT_IMPLEMENTED;
 4272|     10|}
command.c:mp_profile_list:
 4276|     37|{
 4277|     37|    MPContext *mpctx = ctx;
 4278|     37|    switch (action) {
  ------------------
  |  Branch (4278:13): [True: 19, False: 18]
  ------------------
 4279|     18|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4279:5): [True: 18, False: 19]
  ------------------
 4280|     18|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     18|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 4281|     18|        return M_PROPERTY_OK;
 4282|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (4282:5): [True: 1, False: 36]
  ------------------
 4283|      1|        *(struct mpv_node *)arg = m_config_get_profiles(mpctx->mconfig);
 4284|      1|        return M_PROPERTY_OK;
 4285|      0|    }
 4286|     37|    }
 4287|     18|    return M_PROPERTY_NOT_IMPLEMENTED;
 4288|     37|}
command.c:mp_property_commands:
 4292|     81|{
 4293|     81|    switch (action) {
  ------------------
  |  Branch (4293:13): [True: 41, False: 40]
  ------------------
 4294|     40|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4294:5): [True: 40, False: 41]
  ------------------
 4295|     40|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|     40|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 4296|     40|        return M_PROPERTY_OK;
 4297|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (4297:5): [True: 1, False: 80]
  ------------------
 4298|      1|        struct mpv_node *root = arg;
 4299|      1|        node_init(root, MPV_FORMAT_NODE_ARRAY, NULL);
 4300|       |
 4301|     88|        for (int n = 0; mp_cmds[n].name; n++) {
  ------------------
  |  Branch (4301:25): [True: 87, False: 1]
  ------------------
 4302|     87|            const struct mp_cmd_def *cmd = &mp_cmds[n];
 4303|     87|            struct mpv_node *entry = node_array_add(root, MPV_FORMAT_NODE_MAP);
 4304|       |
 4305|     87|            node_map_add_string(entry, "name", cmd->name);
 4306|       |
 4307|     87|            struct mpv_node *args =
 4308|     87|                node_map_add(entry, "args", MPV_FORMAT_NODE_ARRAY);
 4309|    249|            for (int i = 0; i < MP_CMD_DEF_MAX_ARGS; i++) {
  ------------------
  |  |   26|    249|#define MP_CMD_DEF_MAX_ARGS 15
  ------------------
  |  Branch (4309:29): [True: 248, False: 1]
  ------------------
 4310|    248|                const struct m_option *a = &cmd->args[i];
 4311|    248|                if (!a->type)
  ------------------
  |  Branch (4311:21): [True: 86, False: 162]
  ------------------
 4312|     86|                    break;
 4313|    162|                struct mpv_node *ae = node_array_add(args, MPV_FORMAT_NODE_MAP);
 4314|    162|                node_map_add_string(ae, "name", a->name);
 4315|    162|                node_map_add_string(ae, "type", a->type->name);
 4316|    162|                node_map_add_flag(ae, "optional", a->flags & MP_CMD_OPT_ARG);
  ------------------
  |  |   27|    162|#define MP_CMD_OPT_ARG M_OPT_OPTIONAL_PARAM
  |  |  ------------------
  |  |  |  |  497|    162|#define M_OPT_OPTIONAL_PARAM    (UINT64_C(1) << 54)
  |  |  ------------------
  ------------------
 4317|    162|                if (a->type == &m_option_type_choice ||
  ------------------
  |  Branch (4317:21): [True: 21, False: 141]
  ------------------
 4318|    141|                    a->type == &m_option_type_flags) {
  ------------------
  |  Branch (4318:21): [True: 10, False: 131]
  ------------------
 4319|     31|                    const struct m_opt_choice_alternatives *alt = a->priv;
 4320|     31|                    if (alt) {
  ------------------
  |  Branch (4320:25): [True: 31, False: 0]
  ------------------
 4321|     31|                        if (a->defval) {
  ------------------
  |  Branch (4321:29): [True: 9, False: 22]
  ------------------
 4322|      9|                            const int ival = *(const int *)a->defval;
 4323|      9|                            const char *val = m_opt_choice_str_def(alt, ival, NULL);
 4324|      9|                            if (val)
  ------------------
  |  Branch (4324:33): [True: 9, False: 0]
  ------------------
 4325|      9|                                node_map_add_string(ae, "default-value", val);
 4326|      9|                        }
 4327|     31|                        struct mpv_node *choices =
 4328|     31|                            node_map_add(ae, "choices", MPV_FORMAT_NODE_ARRAY);
 4329|    195|                        for (int j = 0; alt[j].name; j++) {
  ------------------
  |  Branch (4329:41): [True: 164, False: 31]
  ------------------
 4330|    164|                           struct mpv_node *ce = node_array_add(choices, MPV_FORMAT_NONE);
 4331|    164|                           ce->format = MPV_FORMAT_STRING;
 4332|    164|                           ce->u.string = talloc_strdup(choices->u.list, alt[j].name);
  ------------------
  |  |   50|    164|#define talloc_strdup                   ta_xstrdup
  ------------------
 4333|    164|                        }
 4334|     31|                    }
 4335|    131|                } else if (a->defval) {
  ------------------
  |  Branch (4335:28): [True: 31, False: 100]
  ------------------
 4336|     31|                    struct mpv_node *def =
 4337|     31|                        node_map_add(ae, "default-value", MPV_FORMAT_NONE);
 4338|     31|                    m_option_get_node(a, ae->u.list, def, (void *)a->defval);
 4339|     31|                }
 4340|    162|            }
 4341|       |
 4342|     87|            node_map_add_flag(entry, "vararg", cmd->vararg);
 4343|     87|        }
 4344|       |
 4345|      1|        return M_PROPERTY_OK;
 4346|      0|    }
 4347|     81|    }
 4348|     40|    return M_PROPERTY_NOT_IMPLEMENTED;
 4349|     81|}
command.c:mp_property_bindings:
 4353|     17|{
 4354|     17|    MPContext *mpctx = ctx;
 4355|     17|    switch (action) {
  ------------------
  |  Branch (4355:13): [True: 9, False: 8]
  ------------------
 4356|      8|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4356:5): [True: 8, False: 9]
  ------------------
 4357|      8|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|      8|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 4358|      8|        return M_PROPERTY_OK;
 4359|      1|    case M_PROPERTY_GET: {
  ------------------
  |  Branch (4359:5): [True: 1, False: 16]
  ------------------
 4360|      1|        *(struct mpv_node *)arg = mp_input_get_bindings(mpctx->input);
 4361|      1|        return M_PROPERTY_OK;
 4362|      0|    }
 4363|     17|    }
 4364|      8|    return M_PROPERTY_NOT_IMPLEMENTED;
 4365|     17|}
command.c:mp_property_mdata:
 4369|    200|{
 4370|    200|    MPContext *mpctx = ctx;
 4371|    200|    mpv_node *node = &mpctx->command_ctx->mdata;
 4372|       |
 4373|    200|    switch (action) {
  ------------------
  |  Branch (4373:13): [True: 100, False: 100]
  ------------------
 4374|    100|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4374:5): [True: 100, False: 100]
  ------------------
 4375|    100|        *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
  ------------------
  |  |  253|    100|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 4376|    100|        return M_PROPERTY_OK;
 4377|      0|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4377:5): [True: 0, False: 200]
  ------------------
 4378|      0|    case M_PROPERTY_GET_NODE:
  ------------------
  |  Branch (4378:5): [True: 0, False: 200]
  ------------------
 4379|      0|        m_option_copy(&mdata_type, arg, node);
 4380|      0|        return M_PROPERTY_OK;
 4381|      0|    case M_PROPERTY_SET:
  ------------------
  |  Branch (4381:5): [True: 0, False: 200]
  ------------------
 4382|      0|    case M_PROPERTY_SET_NODE: {
  ------------------
  |  Branch (4382:5): [True: 0, False: 200]
  ------------------
 4383|      0|        m_option_copy(&mdata_type, node, arg);
 4384|      0|        talloc_steal(mpctx->command_ctx, node_get_alloc(node));
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4385|      0|        mp_notify_property(mpctx, prop->name);
 4386|       |
 4387|      0|        struct vo *vo = mpctx->video_out;
 4388|      0|        if (vo)
  ------------------
  |  Branch (4388:13): [True: 0, False: 0]
  ------------------
 4389|      0|            vo_control(vo, VOCTRL_UPDATE_MENU, arg);
 4390|      0|        return M_PROPERTY_OK;
 4391|      0|    }
 4392|    200|    }
 4393|    100|    return M_PROPERTY_NOT_IMPLEMENTED;
 4394|    200|}
command.c:mp_property_default_menu:
 4398|     18|{
 4399|     18|    switch (action) {
  ------------------
  |  Branch (4399:13): [True: 9, False: 9]
  ------------------
 4400|      1|        case M_PROPERTY_GET:
  ------------------
  |  Branch (4400:9): [True: 1, False: 17]
  ------------------
 4401|      1|            *(char **)arg = talloc_strdup(NULL,
  ------------------
  |  |   50|      1|#define talloc_strdup                   ta_xstrdup
  ------------------
 4402|      1|#include "etc/menu.conf.inc"
  ------------------
  |  |    1|       |// Generated from etc/menu.conf
  |  |    2|       |
  |  |    3|      1|"Pla&y\tcycle pause\t\thidden=not pause and not idle_active\tdisabled=idle_active\n"
  |  |    4|      1|"Pa&use\tcycle pause\t\thidden=idle_active or pause\n"
  |  |    5|      1|"&Stop\tstop\t\t\thidden=idle ~= true\t\t\t\t\t\tdisabled=idle_active\n"
  |  |    6|      1|"\n"
  |  |    7|      1|"Ope&n\n"
  |  |    8|      1|"\t&Clipboard\t\tupdate-clipboard text; loadfile \044{clipboard/text}; show-text '+ \044{clipboard/text}'\n"
  |  |    9|      1|"\t&History\t\tscript-binding select/select-watch-history\n"
  |  |   10|      1|"\t&Watch later\tscript-binding select/select-watch-later\n"
  |  |   11|      1|"&Playlist\t\044playlist\n"
  |  |   12|      1|"\n"
  |  |   13|      1|"&Tracks\t\044tracks\n"
  |  |   14|      1|"P&layback\n"
  |  |   15|      1|"\t&Display duration\thidden=not p[\"current-tracks/video/image\"] or p[\"current-tracks/audio\"]\n"
  |  |   16|      1|"\t\t1 second\t\tset image-display-duration 1\t\tchecked=image_display_duration == 1\n"
  |  |   17|      1|"\t\t2 seconds\t\tset image-display-duration 2\t\tchecked=image_display_duration == 2\n"
  |  |   18|      1|"\t\t5 seconds\t\tset image-display-duration 5\t\tchecked=image_display_duration == 5\n"
  |  |   19|      1|"\t\t10 seconds\t\tset image-display-duration 10\t\tchecked=image_display_duration == 10\n"
  |  |   20|      1|"\t\tInfinite\t\tset image-display-duration inf\t\tchecked=image_display_duration == math.huge\n"
  |  |   21|      1|"\tSp&eed\n"
  |  |   22|      1|"\t\t25%\t\tset speed 0.25\t\tchecked=speed == 0.25\n"
  |  |   23|      1|"\t\t50%\t\tset speed 0.50\t\tchecked=speed == 0.50\n"
  |  |   24|      1|"\t\t75%\t\tset speed 0.75\t\tchecked=speed == 0.75\n"
  |  |   25|      1|"\t\t&100%\tset speed 1\t\t\tchecked=speed == 1\n"
  |  |   26|      1|"\t\t1&25%\tset speed 1.25\t\tchecked=speed == 1.25\n"
  |  |   27|      1|"\t\t1&50%\tset speed 1.50\t\tchecked=speed == 1.50\n"
  |  |   28|      1|"\t\t1&75%\tset speed 1.75\t\tchecked=speed == 1.75\n"
  |  |   29|      1|"\t\t&200%\tset speed 2\t\t\tchecked=speed == 2\n"
  |  |   30|      1|"\t\t&400%\tset speed 4\t\t\tchecked=speed == 4\n"
  |  |   31|      1|"\t\t&800%\tset speed 8\t\t\tchecked=speed == 8\n"
  |  |   32|      1|"\n"
  |  |   33|      1|"\tSet/clear &A-B loop points\tab-loop\n"
  |  |   34|      1|"\t&Loop file\t\tcycle-values loop-file inf no\t\tchecked=loop_file == \"inf\"\n"
  |  |   35|      1|"\tL&oop playlist\tcycle-values loop-playlist inf no\tchecked=loop_playlist == \"inf\"\n"
  |  |   36|      1|"\n"
  |  |   37|      1|"\tSeek &10 seconds forward\tseek  10\thidden=p[\"current-tracks/video/image\"] and not p[\"current-tracks/audio\"]\n"
  |  |   38|      1|"\tSeek 1&0 seconds backward\tseek -10\thidden=p[\"current-tracks/video/image\"] and not p[\"current-tracks/audio\"]\n"
  |  |   39|      1|"\tSeek 10 &minutes forward\tseek  600\thidden=p[\"current-tracks/video/image\"] and not p[\"current-tracks/audio\"]\n"
  |  |   40|      1|"\tSeek 10 m&inutes backward\tseek -600\thidden=p[\"current-tracks/video/image\"] and not p[\"current-tracks/audio\"]\n"
  |  |   41|      1|"\n"
  |  |   42|      1|"\t&Reload\t\tset file-local-options/start \044{=time-pos}; playlist-play-index current yes; show-text \"Reloading current file...\"\n"
  |  |   43|      1|"\n"
  |  |   44|      1|"\t&Next file\t\tplaylist-next\tdisabled=playlist_count < 2\n"
  |  |   45|      1|"\t&Previous file\tplaylist-prev\tdisabled=playlist_count < 2\n"
  |  |   46|      1|"\n"
  |  |   47|      1|"\tN&ext sub-playlist\t\tplaylist-next-playlist\tdisabled=playlist_count < 2\n"
  |  |   48|      1|"\tP&revious sub-playlist\tplaylist-prev-playlist\tdisabled=playlist_count < 2\n"
  |  |   49|      1|"\n"
  |  |   50|      1|"\t&Shuffle\tplaylist-shuffle\n"
  |  |   51|      1|"\t&Unshuffle\tplaylist-unshuffle\n"
  |  |   52|      1|"&Chapters\t\t\t\044chapters\n"
  |  |   53|      1|"&Editions/Titles\t\044editions\n"
  |  |   54|      1|"\n"
  |  |   55|      1|"&Video\n"
  |  |   56|      1|"\t&Track\t\044video-tracks\n"
  |  |   57|      1|"\n"
  |  |   58|      1|"\t&Fill\t\tno-osd cycle-values panscan 0 1; no-osd set video-unscaled no; no-osd set video-zoom 0\t\tchecked=panscan == 1\n"
  |  |   59|      1|"\t&Stretch\tno-osd cycle keepaspect\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tchecked=not keepaspect\n"
  |  |   60|      1|"\t&Unscaled\tno-osd cycle-values video-unscaled yes no; no-osd set video-zoom 0; no-osd set panscan 0\tchecked=video_unscaled\n"
  |  |   61|      1|"\t&Zoom\n"
  |  |   62|      1|"\t\t&50%\tset video-zoom -1\tchecked=video_zoom == -1\n"
  |  |   63|      1|"\t\t&100%\tset video-zoom  0\tchecked=video_zoom == 0\n"
  |  |   64|      1|"\t\t&200%\tset video-zoom  1\tchecked=video_zoom == 1\n"
  |  |   65|      1|"\t&Aspect ratio\n"
  |  |   66|      1|"\t\t&16:9\t\tset video-aspect-override 16:9\t\tchecked=math.abs(video_aspect_override - 16/9) < 1e-12\n"
  |  |   67|      1|"\t\t&4:3\t\tset video-aspect-override 4:3\t\tchecked=math.abs(video_aspect_override - 4/3) < 1e-12\n"
  |  |   68|      1|"\t\t&2.35:1\t\tset video-aspect-override 2.35:1\tchecked=video_aspect_override == 2.35\n"
  |  |   69|      1|"\t\t&Default\tset video-aspect-override no\t\tchecked=video_aspect_override == -2\n"
  |  |   70|      1|"\t&Center\t\tno-osd set video-pan-x 0; no-osd set video-pan-y 0; no-osd set video-align-x 0; no-osd set video-align-y 0\t\tdisabled=video_pan_x == 0 and video_pan_y == 0 and video_align_x == 0 and video_align_y == 0\n"
  |  |   71|      1|"\n"
  |  |   72|      1|"\tRotate &clockwise\t\t\tcycle-values video-rotate 90 180 270 0\n"
  |  |   73|      1|"\tRotate c&ounterclockwise\tcycle-values video-rotate 270 180 90 0\n"
  |  |   74|      1|"\n"
  |  |   75|      1|"\t&Deband\t\t\tcycle deband\t\tchecked=deband\n"
  |  |   76|      1|"\tD&einterlace\tcycle deinterlace\tchecked=deinterlace_active\n"
  |  |   77|      1|"\n"
  |  |   78|      1|"\t&Screenshot\t\t\t\t\t\tscreenshot\t\t\tdisabled=not p[\"current-tracks/video\"]\n"
  |  |   79|      1|"\tScreenshot &without subtitles\tscreenshot video\tdisabled=not p[\"current-tracks/video\"]\n"
  |  |   80|      1|"&Audio\n"
  |  |   81|      1|"\t&Track\t\t\044audio-tracks\n"
  |  |   82|      1|"\t&Devices\t\044audio-devices\n"
  |  |   83|      1|"\t&Channels\n"
  |  |   84|      1|"\t\t&Auto\t\tset audio-channels auto-safe\tchecked=audio_channels == \"auto-safe\"\n"
  |  |   85|      1|"\t\t&Stereo\t\tset audio-channels stereo\t\tchecked=audio_channels == \"stereo\"\n"
  |  |   86|      1|"\t\t&Mono\t\tset audio-channels mono\t\t\tchecked=audio_channels == \"mono\"\n"
  |  |   87|      1|"\n"
  |  |   88|      1|"\tIncrease &volume\tadd volume  2\n"
  |  |   89|      1|"\tDecrease v&olume\tadd volume -2\n"
  |  |   90|      1|"\t&Mute\t\t\t\tcycle mute\t\tchecked=mute\n"
  |  |   91|      1|"\n"
  |  |   92|      1|"\tIncrease d&elay\t\tadd audio-delay  0.1\n"
  |  |   93|      1|"\tDecrease de&lay\t\tadd audio-delay -0.1\n"
  |  |   94|      1|"&Subtitle\n"
  |  |   95|      1|"\t&Track\t\t\044sub-tracks\n"
  |  |   96|      1|"\t&Visible\tcycle sub-visibility\tchecked=sub_visibility\n"
  |  |   97|      1|"\n"
  |  |   98|      1|"\tIncrease &delay\t\tadd sub-delay  0.1\n"
  |  |   99|      1|"\tDecrease d&elay\t\tadd sub-delay -0.1\n"
  |  |  100|      1|"\n"
  |  |  101|      1|"\tScale &up\t\tadd sub-scale  0.1\n"
  |  |  102|      1|"\tScale d&own\t\tadd sub-scale -0.1\n"
  |  |  103|      1|"\n"
  |  |  104|      1|"\t&Lines\tscript-binding select/select-subtitle-line\tdisabled=not sid or p[\"current-tracks/sub/codec\"] == \"dvb_subtitle\" or p[\"current-tracks/sub/codec\"] == \"dvd_subtitle\" or p[\"current-tracks/sub/codec\"] == \"hdmv_pgs_subtitle\"\n"
  |  |  105|      1|"\t&Secondary subtitle\n"
  |  |  106|      1|"\t\t&Track\t\t\044secondary-sub-tracks\n"
  |  |  107|      1|"\t\t&Visible\tcycle secondary-sub-visibility\tchecked=secondary_sub_visibility\n"
  |  |  108|      1|"\n"
  |  |  109|      1|"\t\tIncrease &delay\t\tadd secondary-sub-delay  0.1\n"
  |  |  110|      1|"\t\tDecrease d&elay\t\tadd secondary-sub-delay -0.1\n"
  |  |  111|      1|"\n"
  |  |  112|      1|"\t\t&Lines\tscript-binding select/select-secondary-subtitle-line\tdisabled=not secondary_sid or p[\"current-tracks/sub2/codec\"] == \"dvb_subtitle\" or p[\"current-tracks/sub2/codec\"] == \"dvd_subtitle\" or p[\"current-tracks/sub2/codec\"] == \"hdmv_pgs_subtitle\"\n"
  |  |  113|      1|"\n"
  |  |  114|      1|"&Window\n"
  |  |  115|      1|"\t&Fullscreen\t\tcycle fullscreen\tchecked=fullscreen\n"
  |  |  116|      1|"\t&Border\t\t\tcycle border\t\tchecked=border\n"
  |  |  117|      1|"\t&Title bar\t\tcycle title-bar\t\tchecked=title_bar\n"
  |  |  118|      1|"\t&Always on top\tcycle ontop\t\t\tchecked=ontop\n"
  |  |  119|      1|"\t&Window scale\n"
  |  |  120|      1|"\t\t50%\t\tset window-scale 0.5\tchecked=math.abs(get(\"current-window-scale\", 0) - 0.5) < 0.1\n"
  |  |  121|      1|"\t\t100%\tset window-scale 1\t\tchecked=math.abs(get(\"current-window-scale\", 0) - 1) < 0.1\n"
  |  |  122|      1|"\t\t200%\tset window-scale 2\t\tchecked=math.abs(get(\"current-window-scale\", 0) - 2) < 0.1\n"
  |  |  123|      1|"\t\t300%\tset window-scale 3\t\tchecked=math.abs(get(\"current-window-scale\", 0) - 3) < 0.1\n"
  |  |  124|      1|"\t&Screenshot window\tscreenshot window\n"
  |  |  125|      1|"V&iew\n"
  |  |  126|      1|"\t&Playback statistics\tscript-binding stats/display-page-1-toggle\n"
  |  |  127|      1|"\t&File information\t\tscript-binding stats/display-page-5-toggle\n"
  |  |  128|      1|"\t&Key bindings\t\t\tscript-binding stats/display-page-4-toggle\n"
  |  |  129|      1|"\t&Time OSD\t\t\t\tno-osd cycle-values osd-level 3 1\tchecked=osd_level == 3\n"
  |  |  130|      1|"\t&Cycle OSC visibility\tscript-binding osc/visibility\n"
  |  |  131|      1|"\t&OSC layout\n"
  |  |  132|      1|"\t\t&Bottom bar\t\t\tno-osd change-list script-opts append osc-layout=bottombar\n"
  |  |  133|      1|"\t\t&Top bar\t\t\tno-osd change-list script-opts append osc-layout=topbar\n"
  |  |  134|      1|"\t\t&Floating\t\t\tno-osd change-list script-opts append osc-layout=floating\n"
  |  |  135|      1|"\t\tB&ox\t\t\t\tno-osd change-list script-opts append osc-layout=box\n"
  |  |  136|      1|"\t\t&Slimbox\t\t\tno-osd change-list script-opts append osc-layout=slimbox\n"
  |  |  137|      1|"\t\tS&lim bottom bar\tno-osd change-list script-opts append osc-layout=slimbottombar\thidden=not p[\"current-tracks/video/image\"] or p[\"current-tracks/audio\"]\n"
  |  |  138|      1|"\t\tSl&im top bar\t\tno-osd change-list script-opts append osc-layout=slimtopbar\t\thidden=not p[\"current-tracks/video/image\"] or p[\"current-tracks/audio\"]\n"
  |  |  139|      1|"P&rofiles\t\044profiles\n"
  |  |  140|      1|"T&ools\n"
  |  |  141|      1|"\tCopy &path\t\tset clipboard/text \044{path}\t\t\tdisabled=idle_active\n"
  |  |  142|      1|"\tCopy &subtitle\tset clipboard/text \044{sub-text}\t\tdisabled=not sid or p[\"current-tracks/sub/codec\"] == \"dvd_subtitle\" or p[\"current-tracks/sub/codec\"] == \"hdmv_pgs_subtitle\"\n"
  |  |  143|      1|"\tCopy &title\t\tset clipboard/text \044{media-title}\tdisabled=idle_active\n"
  |  |  144|      1|"\n"
  |  |  145|      1|"\t&Hardware decoding\tcycle-values hwdec no auto\tchecked=hwdec_current and hwdec_current ~= \"no\"\tdisabled=p[\"current-tracks/video/image\"] ~= false\n"
  |  |  146|      1|"\t&Key bindings\t\tscript-binding select/select-binding\n"
  |  |  147|      1|"\tP&roperties\t\t\tscript-binding select/show-properties\n"
  |  |  148|      1|"\t&Console\t\t\tscript-binding commands/open\n"
  |  |  149|      1|"\n"
  |  |  150|      1|"\t&Edit config file\t\tscript-binding select/edit-config-file\n"
  |  |  151|      1|"\tEdit key &bindings\t\tscript-binding select/edit-input-conf\n"
  |  |  152|      1|"\n"
  |  |  153|      1|"\t&Online documentation\tscript-binding select/open-docs\n"
  |  |  154|      1|"\tS&upport\t\t\t\tscript-binding select/open-chat\n"
  |  |  155|      1|"\n"
  |  |  156|      1|"&Quit\t\t\t\t\tquit\n"
  |  |  157|      1|"Quit an&d save position\tquit-watch-later\thidden=save_position_on_quit\n"
  ------------------
 4403|      1|                );
 4404|      1|            return M_PROPERTY_OK;
 4405|      8|        case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4405:9): [True: 8, False: 10]
  ------------------
 4406|      8|            *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
  ------------------
  |  |  244|      8|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 4407|      8|            return M_PROPERTY_OK;
 4408|     18|    }
 4409|      9|    return M_PROPERTY_NOT_IMPLEMENTED;
 4410|     18|}
command.c:mp_property_udata:
 4555|     33|{
 4556|       |    // The root of udata is a shared map; don't allow overwriting
 4557|       |    // or deleting the whole thing
 4558|     33|    if (action == M_PROPERTY_SET || action == M_PROPERTY_SET_NODE ||
  ------------------
  |  Branch (4558:9): [True: 0, False: 33]
  |  Branch (4558:37): [True: 1, False: 32]
  ------------------
 4559|     32|        action == M_PROPERTY_DELETE)
  ------------------
  |  Branch (4559:9): [True: 0, False: 32]
  ------------------
 4560|      1|        return M_PROPERTY_NOT_IMPLEMENTED;
 4561|       |
 4562|     32|    char *path = NULL;
 4563|     32|    if (action == M_PROPERTY_KEY_ACTION) {
  ------------------
  |  Branch (4563:9): [True: 0, False: 32]
  ------------------
 4564|      0|        struct m_property_action_arg *act = arg;
 4565|      0|        if (act->action == M_PROPERTY_SET || act->action == M_PROPERTY_SET_NODE)
  ------------------
  |  Branch (4565:13): [True: 0, False: 0]
  |  Branch (4565:46): [True: 0, False: 0]
  ------------------
 4566|      0|            path = talloc_asprintf(NULL, "%s/%s", prop->name, act->key);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 4567|      0|    }
 4568|       |
 4569|     32|    struct MPContext *mpctx = ctx;
 4570|     32|    struct udata_ctx nctx = {
 4571|     32|        .mpctx = mpctx,
 4572|     32|        .path = path,
 4573|     32|        .node = &mpctx->command_ctx->udata,
 4574|     32|        .ta_parent = mpctx->command_ctx,
 4575|     32|    };
 4576|       |
 4577|     32|    int ret = do_op_udata(&nctx, action, arg);
 4578|       |
 4579|     32|    talloc_free(path);
  ------------------
  |  |   47|     32|#define talloc_free                     ta_free
  ------------------
 4580|       |
 4581|     32|    return ret;
 4582|     33|}
command.c:do_op_udata:
 4423|     32|{
 4424|     32|    MPContext *mpctx = ctx->mpctx;
 4425|     32|    mpv_node *node = ctx->node;
 4426|       |
 4427|     32|    switch (action) {
  ------------------
  |  Branch (4427:13): [True: 17, False: 15]
  ------------------
 4428|     16|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4428:5): [True: 16, False: 16]
  ------------------
 4429|     16|        *(struct m_option *)arg = udata_type;
 4430|     16|        return M_PROPERTY_OK;
 4431|      1|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4431:5): [True: 1, False: 31]
  ------------------
 4432|      1|    case M_PROPERTY_GET_NODE: // same as GET, because type==mpv_node
  ------------------
  |  Branch (4432:5): [True: 0, False: 32]
  ------------------
 4433|      1|        mp_assert(node);
  ------------------
  |  |   41|      1|#define mp_assert assert
  ------------------
  |  Branch (4433:9): [True: 1, False: 0]
  ------------------
 4434|      1|        m_option_copy(&udata_type, arg, node);
 4435|      1|        return M_PROPERTY_OK;
 4436|      0|    case M_PROPERTY_FIXED_LEN_PRINT:
  ------------------
  |  Branch (4436:5): [True: 0, False: 32]
  ------------------
 4437|      0|    case M_PROPERTY_PRINT: {
  ------------------
  |  Branch (4437:5): [True: 0, False: 32]
  ------------------
 4438|      0|        char *str = m_option_pretty_print(&udata_type, node, action == M_PROPERTY_FIXED_LEN_PRINT);
 4439|      0|        *(char **)arg = str;
 4440|      0|        return str != NULL;
 4441|      0|    }
 4442|      0|    case M_PROPERTY_SET:
  ------------------
  |  Branch (4442:5): [True: 0, False: 32]
  ------------------
 4443|      0|    case M_PROPERTY_SET_NODE:
  ------------------
  |  Branch (4443:5): [True: 0, False: 32]
  ------------------
 4444|      0|        mp_assert(node);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (4444:9): [True: 0, False: 0]
  ------------------
 4445|      0|        m_option_copy(&udata_type, node, arg);
 4446|      0|        talloc_steal(ctx->ta_parent, node_get_alloc(node));
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4447|      0|        mp_notify_property(mpctx, ctx->path);
 4448|      0|        return M_PROPERTY_OK;
 4449|      0|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (4449:5): [True: 0, False: 32]
  ------------------
 4450|      0|        mp_assert(node);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (4450:9): [True: 0, False: 0]
  ------------------
 4451|       |
 4452|       |        // If we're operating on an array, sub-object access is handled by m_property_read_list
 4453|      0|        if (node->format == MPV_FORMAT_NODE_ARRAY)
  ------------------
  |  Branch (4453:13): [True: 0, False: 0]
  ------------------
 4454|      0|            return m_property_read_list(action, arg, node->u.list->num, &do_list_udata, ctx);
 4455|       |
 4456|       |        // Sub-objects only make sense for arrays and maps
 4457|      0|        if (node->format != MPV_FORMAT_NODE_MAP)
  ------------------
  |  Branch (4457:13): [True: 0, False: 0]
  ------------------
 4458|      0|            return M_PROPERTY_NOT_IMPLEMENTED;
 4459|       |
 4460|      0|        struct m_property_action_arg *act = arg;
 4461|       |
 4462|       |        // See if the next layer down will also be a sub-object access
 4463|      0|        bstr key;
 4464|      0|        const char *rem;
 4465|      0|        bool has_split = m_property_split_path(act->key, &key, &rem);
 4466|       |
 4467|      0|        if (!has_split && act->action == M_PROPERTY_DELETE) {
  ------------------
  |  Branch (4467:13): [True: 0, False: 0]
  |  Branch (4467:27): [True: 0, False: 0]
  ------------------
 4468|       |            // Find the object we're looking for
 4469|      0|            int i;
 4470|      0|            for (i = 0; i < node->u.list->num; i++) {
  ------------------
  |  Branch (4470:25): [True: 0, False: 0]
  ------------------
 4471|      0|                if (bstr_equals0(key, node->u.list->keys[i]))
  ------------------
  |  Branch (4471:21): [True: 0, False: 0]
  ------------------
 4472|      0|                    break;
 4473|      0|            }
 4474|       |
 4475|       |            // Return if it didn't exist
 4476|      0|            if (i == node->u.list->num)
  ------------------
  |  Branch (4476:17): [True: 0, False: 0]
  ------------------
 4477|      0|                return M_PROPERTY_UNKNOWN;
 4478|       |
 4479|       |            // Delete the item
 4480|      0|            m_option_free(&udata_type, &node->u.list->values[i]);
 4481|      0|            talloc_free(node->u.list->keys[i]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4482|       |
 4483|       |            // Shift the remaining items back
 4484|      0|            for (i++; i < node->u.list->num; i++) {
  ------------------
  |  Branch (4484:23): [True: 0, False: 0]
  ------------------
 4485|      0|                node->u.list->values[i - 1] = node->u.list->values[i];
 4486|      0|                node->u.list->keys[i - 1] = node->u.list->keys[i];
 4487|      0|            }
 4488|       |
 4489|       |            // And decrement the count
 4490|      0|            node->u.list->num--;
 4491|       |
 4492|      0|            return M_PROPERTY_OK;
 4493|      0|        }
 4494|       |
 4495|       |        // Look up the next level down
 4496|      0|        mpv_node *cnode = node_map_bget(node, key);
 4497|       |
 4498|      0|        if (!cnode) {
  ------------------
  |  Branch (4498:13): [True: 0, False: 0]
  ------------------
 4499|      0|            switch (act->action) {
 4500|      0|                case M_PROPERTY_SET:
  ------------------
  |  Branch (4500:17): [True: 0, False: 0]
  ------------------
 4501|      0|                case M_PROPERTY_SET_NODE: {
  ------------------
  |  Branch (4501:17): [True: 0, False: 0]
  ------------------
 4502|       |                    // If we're doing a set, and the key doesn't exist, create it.
 4503|       |                    // If we're recursing another layer down, make it an empty map;
 4504|       |                    // otherwise, make it NONE, since we'll be overwriting it at the next level.
 4505|      0|                    cnode = node_map_badd(node, key, has_split ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NONE);
  ------------------
  |  Branch (4505:54): [True: 0, False: 0]
  ------------------
 4506|      0|                    if (!cnode)
  ------------------
  |  Branch (4506:25): [True: 0, False: 0]
  ------------------
 4507|      0|                        return M_PROPERTY_ERROR;
 4508|      0|                    break;
 4509|      0|                case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4509:17): [True: 0, False: 0]
  ------------------
 4510|       |                    // Nonexistent keys have type NODE, so they can be overwritten
 4511|      0|                    *(struct m_option *)act->arg = udata_type;
 4512|      0|                    return M_PROPERTY_OK;
 4513|      0|                default:
  ------------------
  |  Branch (4513:17): [True: 0, False: 0]
  ------------------
 4514|       |                    // We can't perform any other options on nonexistent keys
 4515|      0|                    return M_PROPERTY_UNKNOWN;
 4516|      0|                }
 4517|      0|            }
 4518|      0|        }
 4519|       |
 4520|      0|        struct udata_ctx nctx = *ctx;
 4521|      0|        nctx.node = cnode;
 4522|      0|        nctx.ta_parent = node_get_alloc(node);
 4523|       |
 4524|       |        // If we're going down another level, set up a new key-action.
 4525|      0|        if (has_split) {
  ------------------
  |  Branch (4525:13): [True: 0, False: 0]
  ------------------
 4526|      0|            struct m_property_action_arg sub_act = {
 4527|      0|                .key = rem,
 4528|      0|                .action = act->action,
 4529|      0|                .arg = act->arg,
 4530|      0|            };
 4531|       |
 4532|      0|            if (nctx.depth++ > 100)
  ------------------
  |  Branch (4532:17): [True: 0, False: 0]
  ------------------
 4533|      0|                return M_PROPERTY_ERROR;
 4534|      0|            return do_op_udata(&nctx, M_PROPERTY_KEY_ACTION, &sub_act);
 4535|      0|        } else {
 4536|      0|            return do_op_udata(&nctx, act->action, act->arg);
 4537|      0|        }
 4538|      0|    }
 4539|     32|    }
 4540|     15|    return M_PROPERTY_NOT_IMPLEMENTED;
 4541|     32|}
command.c:mp_property_term_size:
 3230|     36|{
 3231|     36|    int w = -1, h = -1;
 3232|     36|    terminal_get_size(&w, &h);
 3233|     36|    if (w == -1 || h == -1)
  ------------------
  |  Branch (3233:9): [True: 36, False: 0]
  |  Branch (3233:20): [True: 0, False: 0]
  ------------------
 3234|     36|        return M_PROPERTY_UNAVAILABLE;
 3235|       |
 3236|      0|    struct m_sub_property props[] = {
 3237|      0|        {"w",      SUB_PROP_INT(w)},
  ------------------
  |  |  233|      0|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|      0|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3238|      0|        {"h",      SUB_PROP_INT(h)},
  ------------------
  |  |  233|      0|    .type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
  |  |  ------------------
  |  |  |  |  240|      0|#define CONF_TYPE_INT           (&m_option_type_int)
  |  |  ------------------
  ------------------
 3239|      0|        {0}
 3240|      0|    };
 3241|       |
 3242|      0|    return m_property_read_sub(props, action, arg);
 3243|     36|}
command.c:mp_property_clipboard:
 4636|      5|{
 4637|      5|    struct MPContext *mpctx = ctx;
 4638|      5|    struct clipboard_access_params params = {
 4639|      5|        .type = CLIPBOARD_DATA_TEXT,
 4640|      5|        .target = CLIPBOARD_TARGET_CLIPBOARD,
 4641|      5|    };
 4642|       |
 4643|      5|    switch (action) {
 4644|      2|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4644:5): [True: 2, False: 3]
  ------------------
 4645|      2|        *(struct m_option *)arg = (struct m_option){
 4646|      2|            .type = CONF_TYPE_NODE,
  ------------------
  |  |  253|      2|#define CONF_TYPE_NODE          (&m_option_type_node)
  ------------------
 4647|      2|        };
 4648|      2|        return M_PROPERTY_OK;
 4649|      1|    case M_PROPERTY_GET:
  ------------------
  |  Branch (4649:5): [True: 1, False: 4]
  ------------------
 4650|      1|    case M_PROPERTY_GET_NODE: {
  ------------------
  |  Branch (4650:5): [True: 0, False: 5]
  ------------------
 4651|      1|        struct mpv_node node;
 4652|      1|        node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
 4653|      1|        char *data = NULL;
 4654|      1|        if (get_clipboard(mpctx, &data, &params) == M_PROPERTY_OK) {
  ------------------
  |  Branch (4654:13): [True: 0, False: 1]
  ------------------
 4655|      0|            node_map_add_string(&node, "text", data);
 4656|      0|            talloc_free(data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4657|      0|        }
 4658|      1|        params.target = CLIPBOARD_TARGET_PRIMARY_SELECTION;
 4659|      1|        data = NULL;
 4660|      1|        if (get_clipboard(mpctx, &data, &params) == M_PROPERTY_OK) {
  ------------------
  |  Branch (4660:13): [True: 0, False: 1]
  ------------------
 4661|      0|            node_map_add_string(&node, "text-primary", data);
 4662|      0|            talloc_free(data);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4663|      0|        }
 4664|      1|        *(struct mpv_node *)arg = node;
 4665|      1|        return M_PROPERTY_OK;
 4666|      1|    }
 4667|      0|    case M_PROPERTY_KEY_ACTION: {
  ------------------
  |  Branch (4667:5): [True: 0, False: 5]
  ------------------
 4668|      0|        struct m_property_action_arg *act = arg;
 4669|      0|        const char *key = act->key;
 4670|       |
 4671|      0|        if (!strcmp(key, "text-primary"))
  ------------------
  |  Branch (4671:13): [True: 0, False: 0]
  ------------------
 4672|      0|            params.target = CLIPBOARD_TARGET_PRIMARY_SELECTION;
 4673|      0|        else if (strcmp(key, "text"))
  ------------------
  |  Branch (4673:18): [True: 0, False: 0]
  ------------------
 4674|      0|            return M_PROPERTY_UNKNOWN;
 4675|       |
 4676|      0|        switch (act->action) {
 4677|      0|        case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (4677:9): [True: 0, False: 0]
  ------------------
 4678|      0|            switch (params.type) {
 4679|      0|            case CLIPBOARD_DATA_TEXT:
  ------------------
  |  Branch (4679:13): [True: 0, False: 0]
  ------------------
 4680|      0|                *(struct m_option *)act->arg = (struct m_option){
 4681|      0|                    .type = CONF_TYPE_STRING,
  ------------------
  |  |  244|      0|#define CONF_TYPE_STRING        (&m_option_type_string)
  ------------------
 4682|      0|                };
 4683|      0|                return M_PROPERTY_OK;
 4684|      0|            default:
  ------------------
  |  Branch (4684:13): [True: 0, False: 0]
  ------------------
 4685|      0|                return M_PROPERTY_UNKNOWN;
 4686|      0|            }
 4687|      0|        case M_PROPERTY_GET:
  ------------------
  |  Branch (4687:9): [True: 0, False: 0]
  ------------------
 4688|      0|            return get_clipboard(mpctx, act->arg, &params);
 4689|      0|        case M_PROPERTY_SET:
  ------------------
  |  Branch (4689:9): [True: 0, False: 0]
  ------------------
 4690|      0|            return set_clipboard(mpctx, act->arg, &params);
 4691|      0|        default:
  ------------------
  |  Branch (4691:9): [True: 0, False: 0]
  ------------------
 4692|      0|            return M_PROPERTY_NOT_IMPLEMENTED;
 4693|      0|        }
 4694|      0|    }
 4695|      2|    default:
  ------------------
  |  Branch (4695:5): [True: 2, False: 3]
  ------------------
 4696|      2|        return M_PROPERTY_NOT_IMPLEMENTED;
 4697|      5|    }
 4698|      5|}
command.c:get_clipboard:
 4593|      2|{
 4594|      2|    struct clipboard_data data;
 4595|      2|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|      2|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      2|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 4596|       |
 4597|      2|    int ret = mp_clipboard_get_data(mpctx->clipboard, params, &data, tmp);
 4598|      2|    if (ret != CLIPBOARD_SUCCESS) {
  ------------------
  |  Branch (4598:9): [True: 2, False: 0]
  ------------------
 4599|      2|        talloc_free(tmp);
  ------------------
  |  |   47|      2|#define talloc_free                     ta_free
  ------------------
 4600|      2|        return ret == CLIPBOARD_UNAVAILABLE ? M_PROPERTY_UNAVAILABLE : M_PROPERTY_ERROR;
  ------------------
  |  Branch (4600:16): [True: 2, False: 0]
  ------------------
 4601|      2|    }
 4602|       |
 4603|      0|    switch (data.type) {
 4604|      0|    case CLIPBOARD_DATA_TEXT:
  ------------------
  |  Branch (4604:5): [True: 0, False: 0]
  ------------------
 4605|      0|        *(char **)arg = talloc_steal(NULL, data.u.text);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 4606|      0|        talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4607|      0|        return M_PROPERTY_OK;
 4608|      0|    default:
  ------------------
  |  Branch (4608:5): [True: 0, False: 0]
  ------------------
 4609|      0|        talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 4610|      0|        return M_PROPERTY_NOT_IMPLEMENTED;
 4611|      0|    }
 4612|      0|}
command.c:mp_property_current_clipboard_backend:
 4586|      4|{
 4587|      4|    MPContext *mpctx = ctx;
 4588|      4|    return m_property_strdup_ro(action, arg, mp_clipboard_get_backend_name(mpctx->clipboard));
 4589|      4|}
command.c:str_compare:
 8233|  81.7M|{
 8234|  81.7M|    return strcmp(*(const char **)a, *(const char **)b);
 8235|  81.7M|}
command.c:mp_property_generic_option:
  436|  1.29M|{
  437|  1.29M|    MPContext *mpctx = ctx;
  438|  1.29M|    struct m_config_option *opt = prop->is_option ? prop->priv :
  ------------------
  |  Branch (438:35): [True: 697k, False: 600k]
  ------------------
  439|  1.29M|                        m_config_get_co(mpctx->mconfig, bstr0(prop->name));
  440|  1.29M|    if (!opt)
  ------------------
  |  Branch (440:9): [True: 0, False: 1.29M]
  ------------------
  441|      0|        return M_PROPERTY_UNKNOWN;
  442|       |
  443|  1.29M|    switch (action) {
  ------------------
  |  Branch (443:13): [True: 747k, False: 549k]
  ------------------
  444|   512k|    case M_PROPERTY_GET_TYPE:
  ------------------
  |  Branch (444:5): [True: 512k, False: 784k]
  ------------------
  445|   512k|        *(struct m_option *)arg = *(opt->opt);
  446|   512k|        return M_PROPERTY_OK;
  447|   155k|    case M_PROPERTY_GET:
  ------------------
  |  Branch (447:5): [True: 155k, False: 1.14M]
  ------------------
  448|   155k|        if (!opt->data)
  ------------------
  |  Branch (448:13): [True: 0, False: 155k]
  ------------------
  449|      0|            return M_PROPERTY_NOT_IMPLEMENTED;
  450|   155k|        m_option_copy(opt->opt, arg, opt->data);
  451|   155k|        return M_PROPERTY_OK;
  452|  79.2k|    case M_PROPERTY_SET:
  ------------------
  |  Branch (452:5): [True: 79.2k, False: 1.21M]
  ------------------
  453|  79.2k|        opt->coalesce = prop->coalesce;
  454|  79.2k|        if (m_config_set_option_raw(mpctx->mconfig, opt, arg, 0) < 0)
  ------------------
  |  Branch (454:13): [True: 0, False: 79.2k]
  ------------------
  455|      0|            return M_PROPERTY_ERROR;
  456|  79.2k|        return M_PROPERTY_OK;
  457|  1.29M|    }
  458|   549k|    return M_PROPERTY_NOT_IMPLEMENTED;
  459|  1.29M|}
command.c:mp_property_deprecated_alias:
 4097|    503|{
 4098|    503|    MPContext *mpctx = ctx;
 4099|    503|    struct command_ctx *cmd = mpctx->command_ctx;
 4100|    503|    const char *real_property = prop->priv;
 4101|    511|    for (int n = 0; n < cmd->num_warned_deprecated; n++) {
  ------------------
  |  Branch (4101:21): [True: 460, False: 51]
  ------------------
 4102|    460|        if (strcmp(cmd->warned_deprecated[n], prop->name) == 0)
  ------------------
  |  Branch (4102:13): [True: 452, False: 8]
  ------------------
 4103|    452|            goto done;
 4104|    460|    }
 4105|     51|    MP_WARN(mpctx, "Warning: property '%s' was replaced with '%s' and "
  ------------------
  |  |   90|     51|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     51|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4106|     51|            "might be removed in the future.\n", prop->name, real_property);
 4107|     51|    MP_TARRAY_APPEND(cmd, cmd->warned_deprecated, cmd->num_warned_deprecated,
  ------------------
  |  |  105|     51|    do {                                            \
  |  |  106|     51|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     51|    do {                                            \
  |  |  |  |   97|     51|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     51|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     51|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     51|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 50, False: 1]
  |  |  |  |  ------------------
  |  |  |  |   99|     51|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     50|    do {                                                        \
  |  |  |  |  |  |   89|     50|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     50|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     50|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     50|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     50|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     50|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     50|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 50]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     51|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     51|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     51|        (idxvar)++;                                 \
  |  |  109|     51|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 51]
  |  |  ------------------
  ------------------
 4108|     51|                     (char *)prop->name);
 4109|       |
 4110|    503|done:
 4111|    503|    return mp_property_do(real_property, action, arg, ctx);
 4112|     51|}
command.c:mp_property_alias:
 4090|  16.5k|{
 4091|  16.5k|    const char *real_property = prop->priv;
 4092|  16.5k|    return mp_property_do(real_property, action, arg, ctx);
 4093|  16.5k|}
command.c:command_event:
 8312|  9.02M|{
 8313|  9.02M|    struct command_ctx *ctx = mpctx->command_ctx;
 8314|       |
 8315|  9.02M|    if (event == MPV_EVENT_START_FILE) {
  ------------------
  |  Branch (8315:9): [True: 16.1k, False: 9.00M]
  ------------------
 8316|  16.1k|        ctx->last_seek_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8317|  16.1k|        ctx->marked_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 8318|  16.1k|        ctx->marked_permanent = false;
 8319|  16.1k|    }
 8320|       |
 8321|  9.02M|    if (event == MPV_EVENT_PLAYBACK_RESTART) {
  ------------------
  |  Branch (8321:9): [True: 2.69M, False: 6.32M]
  ------------------
 8322|  2.69M|        ctx->last_seek_time = mp_time_sec();
 8323|  2.69M|        run_command_opts(mpctx);
 8324|  2.69M|    }
 8325|       |
 8326|  9.02M|    if (event == MPV_EVENT_VIDEO_RECONFIG && ctx->hwdec_osd_mode) {
  ------------------
  |  Branch (8326:9): [True: 95.3k, False: 8.92M]
  |  Branch (8326:46): [True: 10, False: 95.3k]
  ------------------
 8327|     10|        show_property_osd(mpctx, "hwdec", ctx->hwdec_osd_mode);
 8328|     10|        ctx->hwdec_osd_mode = 0;
 8329|     10|    }
 8330|       |
 8331|  9.02M|    if (event == MPV_EVENT_IDLE)
  ------------------
  |  Branch (8331:9): [True: 16.6k, False: 9.00M]
  ------------------
 8332|  16.6k|        run_command_opts(mpctx);
 8333|       |
 8334|  9.02M|    if (event == MPV_EVENT_END_FILE)
  ------------------
  |  Branch (8334:9): [True: 16.1k, False: 9.00M]
  ------------------
 8335|  16.1k|        mp_msg_flush_status_line(mpctx->log, false);
 8336|       |
 8337|  9.02M|    if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
  ------------------
  |  Branch (8337:9): [True: 16.1k, False: 9.00M]
  |  Branch (8337:40): [True: 14.1k, False: 8.99M]
  ------------------
 8338|       |        // Update chapters - does nothing if something else is visible.
 8339|  30.3k|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
 8340|  30.3k|    }
 8341|  9.02M|    if (event == MP_EVENT_WIN_STATE2)
  ------------------
  |  Branch (8341:9): [True: 0, False: 9.02M]
  ------------------
 8342|      0|        ctx->cached_window_scale = 0;
 8343|       |
 8344|  9.02M|    if (event == MP_EVENT_METADATA_UPDATE) {
  ------------------
  |  Branch (8344:9): [True: 373k, False: 8.64M]
  ------------------
 8345|   373k|        struct playlist_entry *const pe = mpctx->playing;
 8346|   373k|        if (pe && !pe->title) {
  ------------------
  |  Branch (8346:13): [True: 373k, False: 0]
  |  Branch (8346:19): [True: 373k, False: 0]
  ------------------
 8347|   373k|            const char *const name = mp_find_non_filename_media_title(mpctx);
 8348|   373k|            if (name && name[0]) {
  ------------------
  |  Branch (8348:17): [True: 0, False: 373k]
  |  Branch (8348:25): [True: 0, False: 0]
  ------------------
 8349|      0|                pe->title = talloc_strdup(pe, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 8350|      0|                mp_notify_property(mpctx, "playlist");
 8351|      0|            }
 8352|   373k|        }
 8353|   373k|    }
 8354|  9.02M|}
command.c:update_priority:
 8400|  11.6k|{
 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|  11.6k|}
command.c:update_window_scale:
 2886|      5|{
 2887|      5|    double scale = mpctx->opts->vo->window_scale;
 2888|       |    mp_property_current_window_scale(mpctx, (struct m_property *)NULL,
 2889|      5|                                     M_PROPERTY_SET, (void*)&scale);
 2890|      5|}
command.c:update_hidpi_window_scale:
 2972|      7|{
 2973|      7|    struct command_ctx *cmd = mpctx->command_ctx;
 2974|      7|    struct vo *vo = mpctx->video_out;
 2975|      7|    if (!vo || cmd->cached_window_scale <= 0)
  ------------------
  |  Branch (2975:9): [True: 3, False: 4]
  |  Branch (2975:16): [True: 4, False: 0]
  ------------------
 2976|      7|        return;
 2977|       |
 2978|      0|    double scale = hidpi_scale ? cmd->cached_window_scale : 1 / cmd->cached_window_scale;
  ------------------
  |  Branch (2978:20): [True: 0, False: 0]
  ------------------
 2979|       |
 2980|      0|    int s[2];
 2981|      0|    if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 || s[0] < 1 || s[1] < 1)
  ------------------
  |  Branch (2981:9): [True: 0, False: 0]
  |  Branch (2981:64): [True: 0, False: 0]
  |  Branch (2981:76): [True: 0, False: 0]
  ------------------
 2982|      0|        return;
 2983|       |
 2984|      0|    s[0] *= scale;
 2985|      0|    s[1] *= scale;
 2986|      0|    if (s[0] <= 0 || s[1] <= 0)
  ------------------
  |  Branch (2986:9): [True: 0, False: 0]
  |  Branch (2986:22): [True: 0, False: 0]
  ------------------
 2987|      0|        return;
 2988|      0|    vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
 2989|      0|}
command.c:set_filters:
 5349|  22.9k|{
 5350|  22.9k|    bstr option = bstr0(filter_opt[mediatype]);
 5351|  22.9k|    struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
 5352|  22.9k|    if (!co)
  ------------------
  |  Branch (5352:9): [True: 0, False: 22.9k]
  ------------------
 5353|      0|        return -1;
 5354|       |
 5355|  22.9k|    struct m_obj_settings **list = co->data;
 5356|  22.9k|    struct m_obj_settings *old_settings = *list;
 5357|  22.9k|    *list = NULL;
 5358|  22.9k|    m_option_copy(co->opt, list, &new_chain);
 5359|       |
 5360|  22.9k|    bool success = reinit_filters(mpctx, mediatype);
 5361|       |
 5362|  22.9k|    if (success) {
  ------------------
  |  Branch (5362:9): [True: 22.8k, False: 90]
  ------------------
 5363|  22.8k|        m_option_free(co->opt, &old_settings);
 5364|  22.8k|        m_config_notify_change_opt_ptr(mpctx->mconfig, list);
 5365|  22.8k|    } else {
 5366|     90|        m_option_free(co->opt, list);
 5367|     90|        *list = old_settings;
 5368|     90|    }
 5369|       |
 5370|  22.9k|    return success ? 0 : -1;
  ------------------
  |  Branch (5370:12): [True: 22.8k, False: 90]
  ------------------
 5371|  22.9k|}
command.c:reinit_filters:
 5332|  22.9k|{
 5333|  22.9k|    switch (mediatype) {
  ------------------
  |  Branch (5333:13): [True: 22.9k, False: 0]
  ------------------
 5334|  2.90k|    case STREAM_VIDEO:
  ------------------
  |  Branch (5334:5): [True: 2.90k, False: 20.0k]
  ------------------
 5335|  2.90k|        return reinit_video_filters(mpctx) >= 0;
 5336|  20.0k|    case STREAM_AUDIO:
  ------------------
  |  Branch (5336:5): [True: 20.0k, False: 2.90k]
  ------------------
 5337|  20.0k|        return reinit_audio_filters(mpctx) >= 0;
 5338|  22.9k|    }
 5339|      0|    return false;
 5340|  22.9k|}
command.c:update_track_switch:
 8409|    134|{
 8410|    134|    if (!mpctx->playback_initialized)
  ------------------
  |  Branch (8410:9): [True: 107, False: 27]
  ------------------
 8411|    107|        return;
 8412|       |
 8413|     27|    int tid = mpctx->opts->stream_id[order][type];
 8414|     27|    struct track *track;
 8415|     27|    if (tid == -1) {
  ------------------
  |  Branch (8415:9): [True: 10, False: 17]
  ------------------
 8416|       |        // If "auto" reset to default track selection
 8417|     10|        track = select_default_track(mpctx, order, type);
 8418|     10|        mark_track_selection(mpctx, order, type, -1);
 8419|     17|    } else {
 8420|     17|        track = mp_track_by_tid(mpctx, type, tid);
 8421|     17|    }
 8422|     27|    mp_switch_track_n(mpctx, order, type, track, (tid == -1) ? 0 : FLAG_MARK_SELECTION);
  ------------------
  |  |  559|     17|#define FLAG_MARK_SELECTION 1
  ------------------
  |  Branch (8422:50): [True: 10, False: 17]
  ------------------
 8423|     27|    print_track_list(mpctx, "Track switched:");
 8424|     27|    mp_wakeup_core(mpctx);
 8425|     27|}

mp_parse_cfgfiles:
   69|  11.6k|{
   70|  11.6k|    struct MPOpts *opts = mpctx->opts;
   71|       |
   72|  11.6k|    mp_mk_user_dir(mpctx->global, "home", "");
   73|       |
   74|  11.6k|    char *p1 = mp_get_user_path(NULL, mpctx->global, "~~home/");
   75|  11.6k|    char *p2 = mp_get_user_path(NULL, mpctx->global, "~~old_home/");
   76|  11.6k|    if (strcmp(p1, p2) != 0 && mp_path_exists(p2)) {
  ------------------
  |  Branch (76:9): [True: 0, False: 11.6k]
  |  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|  11.6k|    talloc_free(p1);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
   82|  11.6k|    talloc_free(p2);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
   83|       |
   84|  11.6k|    char *section = NULL;
   85|  11.6k|    bool encoding = opts->encode_opts->file && opts->encode_opts->file[0];
  ------------------
  |  Branch (85:21): [True: 0, False: 11.6k]
  |  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|  11.6k|    if (encoding)
  ------------------
  |  Branch (90:9): [True: 0, False: 11.6k]
  ------------------
   91|      0|        section = "playback-default";
   92|       |
   93|  11.6k|    load_all_cfgfiles(mpctx, NULL, "encoding-profiles.conf");
   94|       |
   95|  11.6k|    load_all_cfgfiles(mpctx, section, "mpv.conf|config");
   96|       |
   97|  11.6k|    if (encoding) {
  ------------------
  |  Branch (97:9): [True: 0, False: 11.6k]
  ------------------
   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|  11.6k|}
mp_load_auto_profiles:
  165|  16.1k|{
  166|  16.1k|    mp_auto_load_profile(mpctx, "protocol",
  167|  16.1k|                         mp_split_proto(bstr0(mpctx->filename), NULL));
  168|  16.1k|    mp_auto_load_profile(mpctx, "extension",
  169|  16.1k|                         mp_get_ext(bstr0(mpctx->filename)));
  170|       |
  171|  16.1k|    mp_load_per_file_config(mpctx);
  172|  16.1k|}
mp_get_playback_resume_dir:
  203|  19.1k|{
  204|  19.1k|    char *wl_dir = mpctx->opts->watch_later_dir;
  205|  19.1k|    if (wl_dir && wl_dir[0]) {
  ------------------
  |  Branch (205:9): [True: 0, False: 19.1k]
  |  Branch (205:19): [True: 0, False: 0]
  ------------------
  206|      0|        wl_dir = mp_get_user_path(NULL, mpctx->global, wl_dir);
  207|  19.1k|    } else {
  208|  19.1k|        wl_dir = mp_find_user_file(NULL, mpctx->global, "state", MP_WATCH_LATER_CONF);
  ------------------
  |  |  174|  19.1k|#define MP_WATCH_LATER_CONF "watch_later"
  ------------------
  209|  19.1k|    }
  210|  19.1k|    return wl_dir;
  211|  19.1k|}
mp_write_watch_later_conf:
  300|    522|{
  301|    522|    struct playlist_entry *cur = mpctx->playing;
  302|    522|    char *conffile = NULL;
  303|       |
  304|    522|    if (!cur)
  ------------------
  |  Branch (304:9): [True: 68, False: 454]
  ------------------
  305|     68|        goto exit;
  306|       |
  307|    454|    struct demuxer *demux = mpctx->demuxer;
  308|       |
  309|    454|    conffile = mp_get_playback_resume_config_filename(mpctx, cur->filename);
  310|    454|    if (!conffile)
  ------------------
  |  Branch (310:9): [True: 454, False: 0]
  ------------------
  311|    454|        goto exit;
  312|       |
  313|      0|    char *wl_dir = mp_get_playback_resume_dir(mpctx);
  314|      0|    mp_mkdirp(wl_dir);
  315|      0|    talloc_free(wl_dir);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  316|       |
  317|      0|    MP_INFO(mpctx, "Saving state.\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__)
  |  |  ------------------
  ------------------
  318|       |
  319|      0|    bstr data = {0};
  320|      0|    write_filename(mpctx, conffile, &data, cur->filename);
  321|       |
  322|      0|    bool write_start = true;
  323|      0|    double pos = get_playback_time(mpctx);
  324|       |
  325|      0|    if ((demux && (!demux->seekable || demux->partially_seekable)) ||
  ------------------
  |  Branch (325:10): [True: 0, False: 0]
  |  Branch (325:20): [True: 0, False: 0]
  |  Branch (325:40): [True: 0, False: 0]
  ------------------
  326|      0|        pos == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (326:9): [True: 0, False: 0]
  ------------------
  327|      0|    {
  328|      0|        write_start = false;
  329|      0|        MP_INFO(mpctx, "Not seekable, or time unknown - not saving position.\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__)
  |  |  ------------------
  ------------------
  330|      0|    }
  331|      0|    char **watch_later_options = mpctx->opts->watch_later_options;
  332|      0|    for (int i = 0; watch_later_options && watch_later_options[i]; i++) {
  ------------------
  |  Branch (332:21): [True: 0, False: 0]
  |  Branch (332:44): [True: 0, False: 0]
  ------------------
  333|      0|        char *pname = watch_later_options[i];
  334|       |        // Always save start if we have it in the array.
  335|      0|        if (write_start && strcmp(pname, "start") == 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 0]
  |  Branch (335:28): [True: 0, False: 0]
  ------------------
  336|      0|            bstr_xappend_asprintf(conffile, &data, "%s=%f\n", pname, pos);
  337|      0|            continue;
  338|      0|        }
  339|       |        // Only store it if it's different from the initial value.
  340|      0|        if (m_config_watch_later_backup_opt_changed(mpctx->mconfig, pname)) {
  ------------------
  |  Branch (340:13): [True: 0, False: 0]
  ------------------
  341|      0|            char *val = NULL;
  342|      0|            mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx);
  343|      0|            if (!val) {
  ------------------
  |  Branch (343:17): [True: 0, False: 0]
  ------------------
  344|      0|                MP_VERBOSE(mpctx, "Option %s unavailable while "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  345|      0|                    "writing watch-later file\n", pname);
  346|      0|            } else if (needs_config_quoting(val)) {
  ------------------
  |  Branch (346:24): [True: 0, False: 0]
  ------------------
  347|       |                // e.g. '%6%STRING'
  348|      0|                bstr_xappend_asprintf(conffile, &data, "%s=%%%d%%%s\n", pname, (int)strlen(val), val);
  349|      0|            } else {
  350|      0|                bstr_xappend_asprintf(conffile, &data, "%s=%s\n", pname, val);
  351|      0|            }
  352|      0|            talloc_free(val);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  353|      0|        }
  354|      0|    }
  355|      0|    bool ok = mp_save_to_file(conffile, data.start, data.len);
  356|      0|    if (!ok) {
  ------------------
  |  Branch (356:9): [True: 0, False: 0]
  ------------------
  357|      0|        MP_WARN(mpctx, "Can't save state to %s\n", conffile);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  358|      0|        goto exit;
  359|      0|    }
  360|       |
  361|      0|    if (mpctx->opts->position_check_mtime && !mp_is_url(bstr0(cur->filename)) &&
  ------------------
  |  Branch (361:9): [True: 0, False: 0]
  |  Branch (361:46): [True: 0, False: 0]
  ------------------
  362|      0|        !copy_mtime(cur->filename, conffile))
  ------------------
  |  Branch (362:9): [True: 0, False: 0]
  ------------------
  363|      0|    {
  364|      0|        MP_WARN(mpctx, "Can't copy mtime from %s to %s\n", cur->filename,
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  365|      0|                conffile);
  366|      0|    }
  367|       |
  368|      0|    write_redirects_for_parent_dirs(mpctx, cur->filename);
  369|       |
  370|       |    // Also write redirect entries for a playlist that mpv expanded if the
  371|       |    // current entry is a URL, this is mostly useful for playing multiple
  372|       |    // archives of images, e.g. with mpv 1.zip 2.zip and quit-watch-later
  373|       |    // on 2.zip, write redirect entries for 2.zip, not just for the archive://
  374|       |    // URL.
  375|      0|    if (cur->playlist_path && mp_is_url(bstr0(cur->filename))) {
  ------------------
  |  Branch (375:9): [True: 0, False: 0]
  |  Branch (375:31): [True: 0, False: 0]
  ------------------
  376|      0|        write_redirect(mpctx, cur->playlist_path);
  377|      0|        write_redirects_for_parent_dirs(mpctx, cur->playlist_path);
  378|      0|    }
  379|       |
  380|    522|exit:
  381|    522|    talloc_free(conffile);
  ------------------
  |  |   47|    522|#define talloc_free                     ta_free
  ------------------
  382|    522|}
mp_delete_watch_later_conf:
  385|  2.53k|{
  386|  2.53k|    char *path = file ? mp_normalize_path(NULL, file)
  ------------------
  |  Branch (386:18): [True: 2.33k, False: 207]
  ------------------
  387|  2.53k|                      : talloc_strdup(NULL, mpctx->filename);
  ------------------
  |  |   50|    207|#define talloc_strdup                   ta_xstrdup
  ------------------
  388|  2.53k|    if (!path)
  ------------------
  |  Branch (388:9): [True: 155, False: 2.38k]
  ------------------
  389|    155|        goto exit;
  390|       |
  391|  2.38k|    char *fname = mp_get_playback_resume_config_filename(mpctx, path);
  392|  2.38k|    if (!fname)
  ------------------
  |  Branch (392:9): [True: 2.38k, False: 0]
  ------------------
  393|  2.38k|        goto exit;
  394|       |
  395|      0|    unlink(fname);
  ------------------
  |  |  271|      0|#define unlink(...) mp_unlink(__VA_ARGS__)
  ------------------
  396|      0|    talloc_free(fname);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  397|       |
  398|      0|    if (mp_is_url(bstr0(path)) || mpctx->opts->ignore_path_in_watch_later_config)
  ------------------
  |  Branch (398:9): [True: 0, False: 0]
  |  Branch (398:35): [True: 0, False: 0]
  ------------------
  399|      0|        goto exit;
  400|       |
  401|      0|    bstr dir = mp_dirname(path);
  402|      0|    while (dir.len > 1 && dir.len < strlen(path)) {
  ------------------
  |  Branch (402:12): [True: 0, False: 0]
  |  Branch (402:27): [True: 0, False: 0]
  ------------------
  403|      0|        path[dir.len] = '\0';
  404|      0|        mp_path_strip_trailing_separator(path);
  405|      0|        fname = mp_get_playback_resume_config_filename(mpctx, path);
  406|      0|        if (!fname)
  ------------------
  |  Branch (406:13): [True: 0, False: 0]
  ------------------
  407|      0|            break;
  408|      0|        unlink(fname);
  ------------------
  |  |  271|      0|#define unlink(...) mp_unlink(__VA_ARGS__)
  ------------------
  409|      0|        talloc_free(fname);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  410|      0|        dir = mp_dirname(path);
  411|      0|    }
  412|       |
  413|  2.53k|exit:
  414|  2.53k|    talloc_free(path);
  ------------------
  |  |   47|  2.53k|#define talloc_free                     ta_free
  ------------------
  415|  2.53k|}
mp_load_playback_resume:
  418|  16.1k|{
  419|  16.1k|    bool resume = false;
  420|  16.1k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (420:9): [True: 0, False: 16.1k]
  ------------------
  421|      0|        return resume;
  422|  16.1k|    char *fname = mp_get_playback_resume_config_filename(mpctx, file);
  423|  16.1k|    if (fname && mp_path_exists(fname)) {
  ------------------
  |  Branch (423:9): [True: 0, False: 16.1k]
  |  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|  16.1k|    talloc_free(fname);
  ------------------
  |  |   47|  16.1k|#define talloc_free                     ta_free
  ------------------
  439|  16.1k|    return resume;
  440|  16.1k|}
mp_check_playlist_resume:
  449|  16.0k|{
  450|  16.0k|    if (!mpctx->opts->position_resume)
  ------------------
  |  Branch (450:9): [True: 0, False: 16.0k]
  ------------------
  451|      0|        return NULL;
  452|  16.1k|    for (int n = 0; n < playlist->num_entries; n++) {
  ------------------
  |  Branch (452:21): [True: 98, False: 16.0k]
  ------------------
  453|     98|        struct playlist_entry *e = playlist->entries[n];
  454|     98|        char *conf = mp_get_playback_resume_config_filename(mpctx, e->filename);
  455|     98|        bool exists = conf && mp_path_exists(conf);
  ------------------
  |  Branch (455:23): [True: 0, False: 98]
  |  Branch (455:31): [True: 0, False: 0]
  ------------------
  456|     98|        talloc_free(conf);
  ------------------
  |  |   47|     98|#define talloc_free                     ta_free
  ------------------
  457|     98|        if (exists)
  ------------------
  |  Branch (457:13): [True: 0, False: 98]
  ------------------
  458|      0|            return e;
  459|     98|    }
  460|  16.0k|    return NULL;
  461|  16.0k|}
configfiles.c:load_all_cfgfiles:
   58|  23.3k|{
   59|  23.3k|    char **cf = mp_find_all_config_files(NULL, mpctx->global, filename);
   60|  23.3k|    for (int i = 0; cf && cf[i]; i++)
  ------------------
  |  Branch (60:21): [True: 23.3k, False: 0]
  |  Branch (60:27): [True: 0, False: 23.3k]
  ------------------
   61|      0|        m_config_parse_config_file(mpctx->mconfig, mpctx->global, cf[i], section, 0);
   62|  23.3k|    talloc_free(cf);
  ------------------
  |  |   47|  23.3k|#define talloc_free                     ta_free
  ------------------
   63|  23.3k|}
configfiles.c:mp_auto_load_profile:
  151|  32.3k|{
  152|  32.3k|    if (!item.len)
  ------------------
  |  Branch (152:9): [True: 17.6k, False: 14.6k]
  ------------------
  153|  17.6k|        return;
  154|       |
  155|  14.6k|    char t[512];
  156|  14.6k|    snprintf(t, sizeof(t), "%s.%.*s", category, BSTR_P(item));
  ------------------
  |  |  307|  14.6k|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 14.6k, False: 0]
  |  |  ------------------
  ------------------
  157|  14.6k|    m_profile_t *p = m_config_get_profile0(mpctx->mconfig, t);
  158|  14.6k|    if (p) {
  ------------------
  |  Branch (158:9): [True: 0, False: 14.6k]
  ------------------
  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|  14.6k|}
configfiles.c:mp_load_per_file_config:
  118|  16.1k|{
  119|  16.1k|    struct MPOpts *opts = mpctx->opts;
  120|  16.1k|    char *confpath;
  121|  16.1k|    char cfg[512];
  122|  16.1k|    const char *file = mpctx->filename;
  123|       |
  124|  16.1k|    if (opts->use_filedir_conf) {
  ------------------
  |  Branch (124:9): [True: 0, False: 16.1k]
  ------------------
  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|  16.1k|}
configfiles.c:mp_get_playback_resume_config_filename:
  215|  19.1k|{
  216|  19.1k|    struct MPOpts *opts = mpctx->opts;
  217|  19.1k|    char *res = NULL;
  218|  19.1k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  19.1k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  19.1k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  219|  19.1k|    if (opts->ignore_path_in_watch_later_config && !mp_is_url(bstr0(path)))
  ------------------
  |  Branch (219:9): [True: 0, False: 19.1k]
  |  Branch (219:52): [True: 0, False: 0]
  ------------------
  220|      0|        path = mp_basename(path);
  221|       |
  222|  19.1k|    bstr hashstr = mp_hash_to_bstr(tmp, path, strlen(path), "MD5");
  223|  19.1k|    char *wl_dir = mp_get_playback_resume_dir(mpctx);
  224|  19.1k|    if (wl_dir && wl_dir[0])
  ------------------
  |  Branch (224:9): [True: 0, False: 19.1k]
  |  Branch (224:19): [True: 0, False: 0]
  ------------------
  225|      0|        res = mp_path_join_bstr(NULL, bstr0(wl_dir), hashstr);
  226|  19.1k|    talloc_free(wl_dir);
  ------------------
  |  |   47|  19.1k|#define talloc_free                     ta_free
  ------------------
  227|  19.1k|    talloc_free(tmp);
  ------------------
  |  |   47|  19.1k|#define talloc_free                     ta_free
  ------------------
  228|  19.1k|    return res;
  229|  19.1k|}

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

mp_abort_playback_async:
   73|  19.2k|{
   74|  19.2k|    mp_cancel_trigger(mpctx->playback_abort);
   75|       |
   76|  19.2k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  19.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   77|       |
   78|  19.6k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (78:21): [True: 412, False: 19.2k]
  ------------------
   79|    412|        struct mp_abort_entry *abort = mpctx->abort_list[n];
   80|    412|        if (abort->coupled_to_playback)
  ------------------
  |  Branch (80:13): [True: 312, False: 100]
  ------------------
   81|    312|            mp_abort_trigger_locked(mpctx, abort);
   82|    412|    }
   83|       |
   84|  19.2k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  19.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|  19.2k|}
mp_abort_add:
   89|  93.3k|{
   90|  93.3k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  93.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   91|  93.3k|    mp_assert(!abort->cancel);
  ------------------
  |  |   41|  93.3k|#define mp_assert assert
  ------------------
  |  Branch (91:5): [True: 93.3k, False: 0]
  ------------------
   92|  93.3k|    abort->cancel = mp_cancel_new(NULL);
   93|  93.3k|    MP_TARRAY_APPEND(NULL, mpctx->abort_list, mpctx->num_abort_list, abort);
  ------------------
  |  |  105|  93.3k|    do {                                            \
  |  |  106|  93.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  93.3k|    do {                                            \
  |  |  |  |   97|  93.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  93.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  93.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  93.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 5.40k, False: 87.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  93.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  5.40k|    do {                                                        \
  |  |  |  |  |  |   89|  5.40k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  5.40k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  5.40k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  5.40k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.40k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  5.40k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  5.40k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 5.40k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  93.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 93.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  93.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  93.3k|        (idxvar)++;                                 \
  |  |  109|  93.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 93.3k]
  |  |  ------------------
  ------------------
   94|  93.3k|    mp_abort_recheck_locked(mpctx, abort);
   95|  93.3k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  93.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   96|  93.3k|}
mp_abort_remove:
  101|  93.3k|{
  102|  93.3k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  93.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  103|  93.3k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (103:21): [True: 93.3k, False: 0]
  ------------------
  104|  93.3k|        if (mpctx->abort_list[n] == abort) {
  ------------------
  |  Branch (104:13): [True: 93.3k, False: 0]
  ------------------
  105|  93.3k|            MP_TARRAY_REMOVE_AT(mpctx->abort_list, mpctx->num_abort_list, n);
  ------------------
  |  |  143|  93.3k|    do {                                            \
  |  |  144|  93.3k|        size_t at_ = (at);                          \
  |  |  145|  93.3k|        assert(at_ < (idxvar));                     \
  |  |  146|  93.3k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  93.3k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  93.3k|        (idxvar)--;                                 \
  |  |  149|  93.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 93.3k]
  |  |  ------------------
  ------------------
  |  Branch (105:13): [True: 93.3k, False: 0]
  ------------------
  106|  93.3k|            TA_FREEP(&abort->cancel);
  ------------------
  |  |   81|  93.3k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  93.3k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 93.3k]
  |  |  ------------------
  ------------------
  107|  93.3k|            abort = NULL; // it's not free'd, just clear for the assert below
  108|  93.3k|            break;
  109|  93.3k|        }
  110|  93.3k|    }
  111|  93.3k|    mp_assert(!abort); // should have been in the list
  ------------------
  |  |   41|  93.3k|#define mp_assert assert
  ------------------
  |  Branch (111:5): [True: 93.3k, False: 0]
  ------------------
  112|  93.3k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  93.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  113|  93.3k|}
mp_abort_recheck_locked:
  119|  94.2k|{
  120|  94.2k|    if ((abort->coupled_to_playback && mp_cancel_test(mpctx->playback_abort)) ||
  ------------------
  |  Branch (120:10): [True: 53.3k, False: 40.8k]
  |  Branch (120:40): [True: 12.0k, False: 41.3k]
  ------------------
  121|  82.2k|        mpctx->abort_all)
  ------------------
  |  Branch (121:9): [True: 0, False: 82.2k]
  ------------------
  122|  12.0k|    {
  123|  12.0k|        mp_abort_trigger_locked(mpctx, abort);
  124|  12.0k|    }
  125|  94.2k|}
mp_abort_trigger_locked:
  129|  12.3k|{
  130|  12.3k|    mp_cancel_trigger(abort->cancel);
  131|  12.3k|}
track_is_visible:
  318|   223k|{
  319|   223k|    if (!track_in_current_edition(mpctx, track))
  ------------------
  |  Branch (319:9): [True: 0, False: 223k]
  ------------------
  320|      0|        return false;
  321|   223k|    if (track->dependent_track && !mpctx->opts->show_dependent_tracks)
  ------------------
  |  Branch (321:9): [True: 0, False: 223k]
  |  Branch (321:35): [True: 0, False: 0]
  ------------------
  322|      0|        return false;
  323|   223k|    return true;
  324|   223k|}
print_track_list:
  327|  49.0k|{
  328|  49.0k|    if (mpctx->opts->term_show_tracks == 2)
  ------------------
  |  Branch (328:9): [True: 0, False: 49.0k]
  ------------------
  329|      0|        return;
  330|  49.0k|    if (msg)
  ------------------
  |  Branch (330:9): [True: 34.8k, False: 14.2k]
  ------------------
  331|  49.0k|        MP_INFO(mpctx, "%s\n", msg);
  ------------------
  |  |   91|  34.8k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  34.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  332|   196k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (332:21): [True: 147k, False: 49.0k]
  ------------------
  333|   640k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (333:25): [True: 493k, False: 147k]
  ------------------
  334|   493k|            struct track *track = mpctx->tracks[n];
  335|   493k|            if (track->type != t || !track_is_visible(mpctx, track))
  ------------------
  |  Branch (335:17): [True: 329k, False: 164k]
  |  Branch (335:37): [True: 0, False: 164k]
  ------------------
  336|   329k|                continue;
  337|   164k|            if (mpctx->opts->term_show_tracks == 1 && !track->selected)
  ------------------
  |  Branch (337:17): [True: 0, False: 164k]
  |  Branch (337:55): [True: 0, False: 0]
  ------------------
  338|      0|                continue;
  339|       |            // Indent tracks after messages like "Tracks switched" and
  340|       |            // "Playing:".
  341|   164k|            print_stream(mpctx, track, msg ||
  ------------------
  |  Branch (341:40): [True: 136k, False: 28.4k]
  ------------------
  342|  28.4k|                         mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (342:26): [True: 0, False: 28.4k]
  ------------------
  343|  28.4k|                         mpctx->playing->playlist_path);
  ------------------
  |  Branch (343:26): [True: 0, False: 28.4k]
  ------------------
  344|   164k|        }
  345|   147k|    }
  346|  49.0k|}
update_demuxer_properties:
  349|  11.4M|{
  350|  11.4M|    struct demuxer *demuxer = mpctx->demuxer;
  351|  11.4M|    if (!demuxer)
  ------------------
  |  Branch (351:9): [True: 0, False: 11.4M]
  ------------------
  352|      0|        return;
  353|  11.4M|    demux_update(demuxer, get_current_time(mpctx));
  354|  11.4M|    int events = demuxer->events;
  355|  11.4M|    if ((events & DEMUX_EVENT_INIT) && demuxer->num_editions > 1 &&
  ------------------
  |  Branch (355:9): [True: 14.2k, False: 11.4M]
  |  Branch (355:40): [True: 0, False: 14.2k]
  ------------------
  356|      0|        mpctx->opts->term_show_editions != 2)
  ------------------
  |  Branch (356:9): [True: 0, False: 0]
  ------------------
  357|      0|    {
  358|      0|        for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (358:25): [True: 0, False: 0]
  ------------------
  359|      0|            if (mpctx->opts->term_show_editions == 1 && n != demuxer->edition)
  ------------------
  |  Branch (359:17): [True: 0, False: 0]
  |  Branch (359:57): [True: 0, False: 0]
  ------------------
  360|      0|                continue;
  361|      0|            struct demux_edition *edition = &demuxer->editions[n];
  362|      0|            char b[128] = {0};
  363|      0|            if (mpctx->playlist->num_entries > 1 || mpctx->playing->playlist_path)
  ------------------
  |  Branch (363:17): [True: 0, False: 0]
  |  Branch (363:53): [True: 0, False: 0]
  ------------------
  364|      0|                APPEND(b, " ");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  365|      0|            APPEND(b, "%s --edition=%d", n == demuxer->edition ?
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  366|      0|                   BLACK_CIRCLE : WHITE_CIRCLE, n);
  367|      0|            char *name = mp_tags_get_str(edition->metadata, "title");
  368|      0|            if (name)
  ------------------
  |  Branch (368:17): [True: 0, False: 0]
  ------------------
  369|      0|                APPEND(b, " '%s'", name);
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  370|      0|            if (edition->default_edition)
  ------------------
  |  Branch (370:17): [True: 0, False: 0]
  ------------------
  371|      0|                APPEND(b, " [default]");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  372|      0|            MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  373|      0|        }
  374|      0|    }
  375|  11.4M|    struct demuxer *tracks = mpctx->demuxer;
  376|  11.4M|    if (tracks->events & DEMUX_EVENT_STREAMS) {
  ------------------
  |  Branch (376:9): [True: 14.2k, False: 11.4M]
  ------------------
  377|  14.2k|        int num_old_tracks = mpctx->num_tracks;
  378|  14.2k|        add_demuxer_tracks(mpctx, tracks);
  379|  14.2k|        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|  14.2k|        if (mpctx->playback_initialized && mpctx->opts->stream_auto_sel) {
  ------------------
  |  Branch (386:13): [True: 0, False: 14.2k]
  |  Branch (386:44): [True: 0, False: 0]
  ------------------
  387|      0|            for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (387:29): [True: 0, False: 0]
  ------------------
  388|      0|                for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (388:33): [True: 0, False: 0]
  ------------------
  389|      0|                    if (mpctx->current_track[i][t])
  ------------------
  |  Branch (389:25): [True: 0, False: 0]
  ------------------
  390|      0|                        continue;
  391|       |                    // The output belongs to a complex filter.
  392|      0|                    if ((t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (392:26): [True: 0, False: 0]
  |  Branch (392:47): [True: 0, False: 0]
  ------------------
  393|      0|                        (t == STREAM_AUDIO && mpctx->ao_chain))
  ------------------
  |  Branch (393:26): [True: 0, False: 0]
  |  Branch (393:47): [True: 0, False: 0]
  ------------------
  394|      0|                        continue;
  395|      0|                    if (mpctx->opts->stream_id[i][t] == -2)
  ------------------
  |  Branch (395:25): [True: 0, False: 0]
  ------------------
  396|      0|                        continue;
  397|      0|                    struct track *sel = select_default_track(mpctx, i, t);
  398|      0|                    bool is_new = false;
  399|      0|                    for (int n = num_old_tracks; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (399:50): [True: 0, False: 0]
  ------------------
  400|      0|                        is_new |= mpctx->tracks[n] == sel;
  401|      0|                    if (is_new)
  ------------------
  |  Branch (401:25): [True: 0, False: 0]
  ------------------
  402|      0|                        mp_switch_track_n(mpctx, i, t, sel, 0);
  403|      0|                }
  404|      0|            }
  405|      0|        }
  406|  14.2k|        print_track_list(mpctx, NULL);
  407|  14.2k|    }
  408|  11.4M|    if (events & DEMUX_EVENT_METADATA) {
  ------------------
  |  Branch (408:9): [True: 373k, False: 11.0M]
  ------------------
  409|   373k|        struct mp_tags *info =
  410|   373k|            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|   373k|        struct mp_tags *prev = mpctx->filtered_tags;
  413|   373k|        int n_prev = 0;
  414|   373k|        bool had_output = false;
  415|   373k|        for (int n = 0; n < info->num_keys; n++) {
  ------------------
  |  Branch (415:25): [True: 0, False: 373k]
  ------------------
  416|      0|            if (prev && n_prev < prev->num_keys) {
  ------------------
  |  Branch (416:17): [True: 0, False: 0]
  |  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|      0|            struct mp_log *log = mp_log_new(NULL, mpctx->log, "!display-tags");
  424|      0|            if (!had_output)
  ------------------
  |  Branch (424:17): [True: 0, False: 0]
  ------------------
  425|      0|                mp_info(log, "File tags:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  426|      0|            mp_info(log, " %s: ", info->keys[n]);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  427|      0|            const char *p = info->values[n];
  428|      0|            while (*p) {
  ------------------
  |  Branch (428:20): [True: 0, False: 0]
  ------------------
  429|      0|                int len = strcspn(p, "\x8\xa\xb\xc\xd");
  430|      0|                mp_info(log, "%.*s", len, p);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  431|      0|                p += len;
  432|      0|                if (*p == '\r')
  ------------------
  |  Branch (432:21): [True: 0, False: 0]
  ------------------
  433|      0|                    mp_info(log, " ");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  434|       |                // Align continued lines with header
  435|      0|                if (*p == '\n')
  ------------------
  |  Branch (435:21): [True: 0, False: 0]
  ------------------
  436|      0|                    mp_info(log, "\n %-*s  ", (int)strlen(info->keys[n]), "");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  437|      0|                if (*p)
  ------------------
  |  Branch (437:21): [True: 0, False: 0]
  ------------------
  438|      0|                    p++;
  439|      0|            }
  440|      0|            mp_info(log, "\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  441|      0|            had_output = true;
  442|      0|            talloc_free(log);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  443|      0|        }
  444|   373k|        talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|   373k|#define talloc_free                     ta_free
  ------------------
  445|   373k|        mpctx->filtered_tags = info;
  446|   373k|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
  447|   373k|    }
  448|  11.4M|    if (events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (448:9): [True: 62.1k, False: 11.3M]
  ------------------
  449|  62.1k|        mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL);
  450|  11.4M|    if (events & DEMUX_EVENT_CODEC)
  ------------------
  |  Branch (450:9): [True: 0, False: 11.4M]
  ------------------
  451|      0|        mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  452|  11.4M|    if (events & DEMUX_EVENT_LISTS) {
  ------------------
  |  Branch (452:9): [True: 0, False: 11.4M]
  ------------------
  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|  11.4M|    demuxer->events = 0;
  476|  11.4M|}
reselect_demux_stream:
  483|  66.9k|{
  484|  66.9k|    if (!track->stream)
  ------------------
  |  Branch (484:9): [True: 0, False: 66.9k]
  ------------------
  485|      0|        return;
  486|  66.9k|    double pts = get_current_time(mpctx);
  487|  66.9k|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  66.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (487:9): [True: 66.9k, False: 0]
  ------------------
  488|  66.9k|        pts += get_track_seek_offset(mpctx, track);
  489|  66.9k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (489:13): [True: 8.52k, False: 58.3k]
  ------------------
  490|  8.52k|            pts -= 10.0;
  491|  66.9k|    }
  492|  66.9k|    if (refresh_only)
  ------------------
  |  Branch (492:9): [True: 0, False: 66.9k]
  ------------------
  493|      0|        demuxer_refresh_track(track->demuxer, track->stream, pts);
  494|  66.9k|    else
  495|  66.9k|        demuxer_select_track(track->demuxer, track->stream, pts, track->selected);
  496|  66.9k|}
add_demuxer_tracks:
  556|  28.4k|{
  557|  85.3k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++)
  ------------------
  |  Branch (557:21): [True: 56.9k, False: 28.4k]
  ------------------
  558|  56.9k|        add_stream_track(mpctx, demuxer, demux_get_stream(demuxer, n));
  559|  28.4k|}
select_default_track:
  677|  57.2k|{
  678|  57.2k|    struct MPOpts *opts = mpctx->opts;
  679|  57.2k|    int tid = opts->stream_id[order][type];
  680|  57.2k|    const struct demuxer *demuxer = mpctx->demuxer;
  681|  57.2k|    if (tid == -2)
  ------------------
  |  Branch (681:9): [True: 14.8k, False: 42.4k]
  ------------------
  682|  14.8k|        return NULL;
  683|  42.4k|    char **langs = process_langs(opts->stream_lang[type]);
  684|  42.4k|    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|  42.4k|    if (type == STREAM_SUB && (!langs || !strcmp(langs[0], "")) && opts->subs_match_os_language) {
  ------------------
  |  Branch (686:9): [True: 14.3k, False: 28.0k]
  |  Branch (686:32): [True: 14.3k, False: 0]
  |  Branch (686:42): [True: 0, False: 0]
  |  Branch (686:68): [True: 14.3k, False: 0]
  ------------------
  687|  14.3k|        talloc_free(langs);
  ------------------
  |  |   47|  14.3k|#define talloc_free                     ta_free
  ------------------
  688|  14.3k|        langs = add_os_langs();
  689|  14.3k|        os_langs = true;
  690|  14.3k|    }
  691|  42.4k|    const char *audio_lang = mpctx->current_track[0][STREAM_AUDIO] ?
  ------------------
  |  Branch (691:30): [True: 14.3k, False: 28.1k]
  ------------------
  692|  14.3k|                             mpctx->current_track[0][STREAM_AUDIO]->lang :
  693|  42.4k|                             NULL;
  694|  42.4k|    bool sub = type == STREAM_SUB;
  695|  42.4k|    int *preferred_programs = NULL;
  696|  42.4k|    int num_preferred_programs = 0;
  697|  42.4k|    struct track *cvt = mpctx->current_track[0][STREAM_VIDEO];
  698|  42.4k|    bool video_has_programs = cvt && cvt->stream && cvt->stream->num_program_ids;
  ------------------
  |  Branch (698:31): [True: 27.9k, False: 14.5k]
  |  Branch (698:38): [True: 27.9k, False: 0]
  |  Branch (698:53): [True: 0, False: 27.9k]
  ------------------
  699|  42.4k|    bool no_edition_mapping = !demuxer || !demuxer->edition_is_track_mapping ||
  ------------------
  |  Branch (699:31): [True: 0, False: 42.4k]
  |  Branch (699:43): [True: 42.4k, False: 0]
  ------------------
  700|      0|                              demuxer->num_editions <= 1;
  ------------------
  |  Branch (700:31): [True: 0, False: 0]
  ------------------
  701|  42.4k|    if (type != STREAM_VIDEO && video_has_programs && no_edition_mapping) {
  ------------------
  |  Branch (701:9): [True: 28.5k, False: 13.8k]
  |  Branch (701:33): [True: 0, False: 28.5k]
  |  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|  42.4k|    struct track *pick = NULL;
  706|   127k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (706:21): [True: 85.2k, False: 42.2k]
  ------------------
  707|  85.2k|        struct track *track = mpctx->tracks[n];
  708|  85.2k|        if (track->type != type)
  ------------------
  |  Branch (708:13): [True: 56.9k, False: 28.2k]
  ------------------
  709|  56.9k|            continue;
  710|  28.2k|        if (!track_is_visible(mpctx, track))
  ------------------
  |  Branch (710:13): [True: 0, False: 28.2k]
  ------------------
  711|      0|            continue;
  712|  28.2k|        if (track->user_tid == tid) {
  ------------------
  |  Branch (712:13): [True: 148, False: 28.1k]
  ------------------
  713|    148|            pick = track;
  714|    148|            goto cleanup;
  715|    148|        }
  716|  28.1k|        if (track->no_auto_select || track->dec_failed)
  ------------------
  |  Branch (716:13): [True: 0, False: 28.1k]
  |  Branch (716:38): [True: 0, False: 28.1k]
  ------------------
  717|      0|            continue;
  718|  28.1k|        if (!opts->autoload_files && track->is_external)
  ------------------
  |  Branch (718:13): [True: 0, False: 28.1k]
  |  Branch (718:38): [True: 0, False: 0]
  ------------------
  719|      0|            continue;
  720|       |        // Prefer tracks from the same programs as the selected video.
  721|  28.1k|        bool in_program = !num_preferred_programs || track->is_external ||
  ------------------
  |  Branch (721:27): [True: 28.1k, 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|  28.1k|        for (int i = 0; i < num_preferred_programs && !in_program; i++)
  ------------------
  |  Branch (723:25): [True: 0, False: 28.1k]
  |  Branch (723:55): [True: 0, False: 0]
  ------------------
  724|      0|            in_program = track_has_program(track, preferred_programs[i]);
  725|  28.1k|        if (!in_program)
  ------------------
  |  Branch (725:13): [True: 0, False: 28.1k]
  ------------------
  726|      0|            continue;
  727|  28.1k|        if (duplicate_track(mpctx, order, type, track))
  ------------------
  |  Branch (727:13): [True: 0, False: 28.1k]
  ------------------
  728|      0|            continue;
  729|  28.1k|        if (sub) {
  ------------------
  |  Branch (729:13): [True: 196, False: 27.9k]
  ------------------
  730|       |            // Subtitle specific auto-selecting crap.
  731|    196|            bool audio_matches = mp_match_lang((char *[]){ (char *)audio_lang, NULL }, track->lang) > 0;
  732|    196|            bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
  ------------------
  |  Branch (732:27): [True: 0, False: 196]
  |  Branch (732:51): [True: 0, False: 0]
  ------------------
  733|      0|                          (audio_matches && opts->subs_fallback_forced == 1));
  ------------------
  |  Branch (733:28): [True: 0, False: 0]
  |  Branch (733:45): [True: 0, False: 0]
  ------------------
  734|    196|            bool lang_match = !os_langs && mp_match_lang(langs, track->lang) > 0;
  ------------------
  |  Branch (734:31): [True: 0, False: 196]
  |  Branch (734:44): [True: 0, False: 0]
  ------------------
  735|    196|            bool subs_fallback = (track->is_external && !track->no_default) || opts->subs_fallback == 2 ||
  ------------------
  |  Branch (735:35): [True: 196, False: 0]
  |  Branch (735:57): [True: 196, False: 0]
  |  Branch (735:80): [True: 0, False: 0]
  ------------------
  736|      0|                                 (opts->subs_fallback == 1 && track->default_track);
  ------------------
  |  Branch (736:35): [True: 0, False: 0]
  |  Branch (736:63): [True: 0, False: 0]
  ------------------
  737|    196|            bool subs_matching_audio = (!mp_match_lang(langs, audio_lang) || opts->subs_with_matching_audio == 2 ||
  ------------------
  |  Branch (737:41): [True: 196, 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|    196|            if (!subs_matching_audio)
  ------------------
  |  Branch (739:17): [True: 0, False: 196]
  ------------------
  740|      0|                continue;
  741|    196|            if (!forced && !lang_match && !subs_fallback)
  ------------------
  |  Branch (741:17): [True: 196, False: 0]
  |  Branch (741:28): [True: 196, False: 0]
  |  Branch (741:43): [True: 0, False: 196]
  ------------------
  742|      0|                continue;
  743|    196|            track->forced_select = forced;
  744|    196|        }
  745|  28.1k|        if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts)) {
  ------------------
  |  Branch (745:13): [True: 28.0k, False: 106]
  |  Branch (745:22): [True: 0, False: 106]
  ------------------
  746|  28.0k|            pick = track;
  747|  28.0k|        }
  748|  28.1k|    }
  749|       |
  750|  42.2k|    if (pick && pick->attached_picture && !mpctx->opts->audio_display)
  ------------------
  |  Branch (750:9): [True: 27.9k, False: 14.2k]
  |  Branch (750:17): [True: 0, False: 27.9k]
  |  Branch (750:43): [True: 0, False: 0]
  ------------------
  751|      0|        pick = NULL;
  752|  42.4k|cleanup:
  753|  42.4k|    talloc_free(langs);
  ------------------
  |  |   47|  42.4k|#define talloc_free                     ta_free
  ------------------
  754|  42.4k|    return pick;
  755|  42.2k|}
mark_track_selection:
  801|  46.9k|{
  802|  46.9k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  46.9k|#define mp_assert assert
  ------------------
  |  Branch (802:5): [True: 46.9k, False: 0]
  |  Branch (802:5): [True: 46.9k, False: 0]
  ------------------
  803|  46.9k|    mpctx->opts->stream_id[order][type] = value;
  804|  46.9k|    m_config_notify_change_opt_ptr(mpctx->mconfig,
  805|  46.9k|                                   &mpctx->opts->stream_id[order][type]);
  806|  46.9k|}
mp_switch_track_n:
  810|  35.5k|{
  811|  35.5k|    mp_assert(!track || track->type == type);
  ------------------
  |  |   41|  35.5k|#define mp_assert assert
  ------------------
  |  Branch (811:5): [True: 16.2k, False: 19.3k]
  |  Branch (811:5): [True: 19.3k, False: 0]
  ------------------
  812|  35.5k|    mp_assert(type >= 0 && type < STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  35.5k|#define mp_assert assert
  ------------------
  |  Branch (812:5): [True: 35.5k, False: 0]
  |  Branch (812:5): [True: 35.5k, False: 0]
  ------------------
  813|  35.5k|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|  35.5k|#define mp_assert assert
  ------------------
  |  Branch (813:5): [True: 35.5k, False: 0]
  |  Branch (813:5): [True: 35.5k, 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|  35.5k|    if (flags & FLAG_MARK_SELECTION)
  ------------------
  |  |  559|  35.5k|#define FLAG_MARK_SELECTION 1
  ------------------
  |  Branch (817:9): [True: 33.8k, False: 1.74k]
  ------------------
  818|  33.8k|        mark_track_selection(mpctx, order, type, track ? track->user_tid : -2);
  ------------------
  |  Branch (818:50): [True: 18.4k, False: 15.4k]
  ------------------
  819|       |
  820|       |    // No decoder should be initialized yet.
  821|  35.5k|    if (!mpctx->demuxer)
  ------------------
  |  Branch (821:9): [True: 0, False: 35.5k]
  ------------------
  822|      0|        return;
  823|       |
  824|  35.5k|    struct track *current = mpctx->current_track[order][type];
  825|  35.5k|    if (track == current)
  ------------------
  |  Branch (825:9): [True: 68, False: 35.5k]
  ------------------
  826|     68|        return;
  827|       |
  828|  35.5k|    if (current && current->sink) {
  ------------------
  |  Branch (828:9): [True: 19.1k, False: 16.3k]
  |  Branch (828:20): [True: 0, False: 19.1k]
  ------------------
  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|  35.5k|    if ((type == STREAM_VIDEO && mpctx->vo_chain && !mpctx->vo_chain->track) ||
  ------------------
  |  Branch (832:10): [True: 24.4k, False: 11.0k]
  |  Branch (832:34): [True: 12.5k, False: 11.8k]
  |  Branch (832:53): [True: 0, False: 12.5k]
  ------------------
  833|  35.5k|        (type == STREAM_AUDIO && mpctx->ao_chain && !mpctx->ao_chain->track))
  ------------------
  |  Branch (833:10): [True: 5.50k, False: 30.0k]
  |  Branch (833:34): [True: 2.84k, False: 2.65k]
  |  Branch (833:53): [True: 0, False: 2.84k]
  ------------------
  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|  35.5k|    if (track && track->selected) {
  ------------------
  |  Branch (839:9): [True: 19.2k, False: 16.2k]
  |  Branch (839:18): [True: 0, False: 19.2k]
  ------------------
  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|  35.5k|    if (order == 0) {
  ------------------
  |  Branch (845:9): [True: 35.5k, False: 0]
  ------------------
  846|  35.5k|        if (type == STREAM_VIDEO) {
  ------------------
  |  Branch (846:13): [True: 24.4k, False: 11.0k]
  ------------------
  847|  24.4k|            uninit_video_chain(mpctx);
  848|  24.4k|            if (!track)
  ------------------
  |  Branch (848:17): [True: 12.5k, False: 11.8k]
  ------------------
  849|  12.5k|                handle_force_window(mpctx, true);
  850|  24.4k|        } else if (type == STREAM_AUDIO) {
  ------------------
  |  Branch (850:20): [True: 5.50k, False: 5.56k]
  ------------------
  851|  5.50k|            clear_audio_output_buffers(mpctx);
  852|  5.50k|            uninit_audio_chain(mpctx);
  853|  5.50k|            if (!track)
  ------------------
  |  Branch (853:17): [True: 2.85k, False: 2.64k]
  ------------------
  854|  2.85k|                uninit_audio_out(mpctx);
  855|  5.50k|        }
  856|  35.5k|    }
  857|  35.5k|    if (type == STREAM_SUB)
  ------------------
  |  Branch (857:9): [True: 5.56k, False: 29.9k]
  ------------------
  858|  5.56k|        uninit_sub(mpctx, current);
  859|       |
  860|  35.5k|    if (current) {
  ------------------
  |  Branch (860:9): [True: 19.1k, False: 16.3k]
  ------------------
  861|  19.1k|        current->selected = false;
  862|  19.1k|        reselect_demux_stream(mpctx, current, false);
  863|  19.1k|    }
  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|  35.5k|    if (type == STREAM_VIDEO && order == 0 && !current && track->image) {
  ------------------
  |  Branch (867:9): [True: 24.4k, False: 11.0k]
  |  Branch (867:33): [True: 24.4k, False: 0]
  |  Branch (867:47): [True: 11.8k, False: 12.5k]
  |  Branch (867:59): [True: 0, False: 11.8k]
  ------------------
  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|  35.5k|    mpctx->current_track[order][type] = track;
  880|       |
  881|  35.5k|    if (track) {
  ------------------
  |  Branch (881:9): [True: 19.2k, False: 16.2k]
  ------------------
  882|  19.2k|        track->selected = true;
  883|  19.2k|        reselect_demux_stream(mpctx, track, false);
  884|  19.2k|    }
  885|       |
  886|  35.5k|    if (type == STREAM_VIDEO && order == 0) {
  ------------------
  |  Branch (886:9): [True: 24.4k, False: 11.0k]
  |  Branch (886:33): [True: 24.4k, False: 0]
  ------------------
  887|  24.4k|        reinit_video_chain(mpctx);
  888|  24.4k|    } else if (type == STREAM_AUDIO && order == 0) {
  ------------------
  |  Branch (888:16): [True: 5.50k, False: 5.56k]
  |  Branch (888:40): [True: 5.50k, False: 0]
  ------------------
  889|  5.50k|        reinit_audio_chain(mpctx);
  890|  5.56k|    } else if (type == STREAM_SUB && order >= 0 && order <= 2) {
  ------------------
  |  Branch (890:16): [True: 5.56k, False: 0]
  |  Branch (890:38): [True: 5.56k, False: 0]
  |  Branch (890:52): [True: 5.56k, False: 0]
  ------------------
  891|  5.56k|        reinit_sub(mpctx, track);
  892|  5.56k|    }
  893|       |
  894|  35.5k|    mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL);
  895|  35.5k|    mp_wakeup_core(mpctx);
  896|       |
  897|  35.5k|    talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|  35.5k|#define talloc_free                     ta_free
  ------------------
  898|  35.5k|    mpctx->track_layout_hash = talloc_steal(mpctx, track_layout_hash(mpctx));
  ------------------
  |  |   38|  35.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  35.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  899|       |
  900|  35.5k|    return;
  901|      0|error:
  902|      0|    mark_track_selection(mpctx, order, type, -1);
  903|      0|}
mp_switch_track:
  907|  4.79k|{
  908|  4.79k|    mp_switch_track_n(mpctx, 0, type, track, flags);
  909|  4.79k|}
mp_deselect_track:
  912|    832|{
  913|    832|    if (track && track->selected) {
  ------------------
  |  Branch (913:9): [True: 832, False: 0]
  |  Branch (913:18): [True: 832, False: 0]
  ------------------
  914|  2.48k|        for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (914:25): [True: 1.64k, False: 832]
  ------------------
  915|  1.64k|            if (mpctx->current_track[t][track->type] != track)
  ------------------
  |  Branch (915:17): [True: 817, False: 832]
  ------------------
  916|    817|                continue;
  917|    832|            mp_switch_track_n(mpctx, t, track->type, NULL, 0);
  918|    832|            mark_track_selection(mpctx, t, track->type, -1); // default
  919|    832|        }
  920|    832|    }
  921|    832|}
mp_track_by_tid:
  925|  11.3k|{
  926|  11.3k|    if (tid == -1)
  ------------------
  |  Branch (926:9): [True: 11.0k, False: 236]
  ------------------
  927|  11.0k|        return mpctx->current_track[0][type];
  928|    352|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (928:21): [True: 126, False: 226]
  ------------------
  929|    126|        struct track *track = mpctx->tracks[n];
  930|    126|        if (track->type == type && track->user_tid == tid)
  ------------------
  |  Branch (930:13): [True: 66, False: 60]
  |  Branch (930:36): [True: 10, False: 56]
  ------------------
  931|     10|            return track;
  932|    126|    }
  933|    226|    return NULL;
  934|    236|}
mp_remove_track:
  937|    863|{
  938|    863|    if (!track->is_external)
  ------------------
  |  Branch (938:9): [True: 46, False: 817]
  ------------------
  939|     46|        return false;
  940|       |
  941|    817|    mp_deselect_track(mpctx, track);
  942|    817|    if (track->selected)
  ------------------
  |  Branch (942:9): [True: 0, False: 817]
  ------------------
  943|      0|        return false;
  944|       |
  945|    817|    struct demuxer *d = track->demuxer;
  946|       |
  947|    817|    int index = 0;
  948|  9.05k|    while (index < mpctx->num_tracks && mpctx->tracks[index] != track)
  ------------------
  |  Branch (948:12): [True: 9.05k, False: 0]
  |  Branch (948:41): [True: 8.23k, False: 817]
  ------------------
  949|  8.23k|        index++;
  950|    817|    MP_TARRAY_REMOVE_AT(mpctx->tracks, mpctx->num_tracks, index);
  ------------------
  |  |  143|    817|    do {                                            \
  |  |  144|    817|        size_t at_ = (at);                          \
  |  |  145|    817|        assert(at_ < (idxvar));                     \
  |  |  146|    817|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|    817|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|    817|        (idxvar)--;                                 \
  |  |  149|    817|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 817]
  |  |  ------------------
  ------------------
  |  Branch (950:5): [True: 817, False: 0]
  ------------------
  951|    817|    talloc_free(track);
  ------------------
  |  |   47|    817|#define talloc_free                     ta_free
  ------------------
  952|       |
  953|       |    // Close the demuxer, unless there is still a track using it. These are
  954|       |    // all external tracks.
  955|    817|    bool in_use = false;
  956|  9.05k|    for (int n = mpctx->num_tracks - 1; n >= 0 && !in_use; n--)
  ------------------
  |  Branch (956:41): [True: 8.24k, False: 817]
  |  Branch (956:51): [True: 8.24k, False: 0]
  ------------------
  957|  8.24k|        in_use |= mpctx->tracks[n]->demuxer == d;
  958|       |
  959|    817|    if (!in_use)
  ------------------
  |  Branch (959:9): [True: 817, False: 0]
  ------------------
  960|    817|        demux_cancel_and_free(d);
  961|       |
  962|    817|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  963|       |
  964|       |    return true;
  965|    817|}
mp_add_external_file:
  975|  27.3k|{
  976|  27.3k|    struct MPOpts *opts = mpctx->opts;
  977|  27.3k|    if (!filename || mp_cancel_test(cancel))
  ------------------
  |  Branch (977:9): [True: 0, False: 27.3k]
  |  Branch (977:22): [True: 1, False: 27.3k]
  ------------------
  978|      1|        return -1;
  979|       |
  980|  27.3k|    void *unescaped_url = NULL;
  981|  27.3k|    char *disp_filename = filename;
  982|  27.3k|    if (strncmp(disp_filename, "memory://", 9) == 0) {
  ------------------
  |  Branch (982:9): [True: 16.5k, False: 10.8k]
  ------------------
  983|  16.5k|        disp_filename = "memory://"; // avoid noise
  984|  16.5k|    } else if (mp_is_url(bstr0(disp_filename))) {
  ------------------
  |  Branch (984:16): [True: 3.46k, False: 7.37k]
  ------------------
  985|  3.46k|        disp_filename = unescaped_url = mp_url_unescape(NULL, disp_filename);
  986|  3.46k|    }
  987|       |
  988|  27.3k|    struct demuxer_params params = {
  989|  27.3k|        .is_top_level = true,
  990|  27.3k|        .stream_flags = STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   47|  27.3k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  991|  27.3k|        .allow_playlist_create = false,
  992|  27.3k|    };
  993|       |
  994|  27.3k|    switch (filter) {
  ------------------
  |  Branch (994:13): [True: 26.3k, False: 995]
  ------------------
  995|  26.3k|    case STREAM_SUB:
  ------------------
  |  Branch (995:5): [True: 26.3k, False: 1.04k]
  ------------------
  996|  26.3k|        params.force_format = opts->sub_demuxer_name;
  997|  26.3k|        break;
  998|     50|    case STREAM_AUDIO:
  ------------------
  |  Branch (998:5): [True: 50, False: 27.3k]
  ------------------
  999|     50|        params.force_format = opts->audio_demuxer_name;
 1000|     50|        break;
 1001|  27.3k|    }
 1002|       |
 1003|  27.3k|    mp_core_unlock(mpctx);
 1004|       |
 1005|  27.3k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 1006|  27.3k|    struct demuxer *demuxer =
 1007|  27.3k|        demux_open_url(path, &params, cancel, mpctx->global);
 1008|  27.3k|    talloc_free(path);
  ------------------
  |  |   47|  27.3k|#define talloc_free                     ta_free
  ------------------
 1009|       |
 1010|  27.3k|    if (demuxer)
  ------------------
  |  Branch (1010:9): [True: 6.34k, False: 21.0k]
  ------------------
 1011|  6.34k|        enable_demux_thread(mpctx, demuxer);
 1012|       |
 1013|  27.3k|    mp_core_lock(mpctx);
 1014|       |
 1015|       |    // The command could have overlapped with playback exiting. (We don't care
 1016|       |    // if playback has started again meanwhile - weird, but not a problem.)
 1017|  27.3k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1017:9): [True: 295, False: 27.0k]
  ------------------
 1018|    295|        goto err_out;
 1019|       |
 1020|  27.0k|    if (!demuxer)
  ------------------
  |  Branch (1020:9): [True: 20.7k, False: 6.32k]
  ------------------
 1021|  20.7k|        goto err_out;
 1022|       |
 1023|  6.32k|    if (filter != STREAM_SUB && opts->rebase_start_time)
  ------------------
  |  Branch (1023:9): [True: 288, False: 6.03k]
  |  Branch (1023:33): [True: 288, False: 0]
  ------------------
 1024|    288|        demux_set_ts_offset(demuxer, -demuxer->start_time);
 1025|       |
 1026|  6.32k|    bool has_any = false;
 1027|  6.80k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
  ------------------
  |  Branch (1027:21): [True: 5.21k, False: 1.59k]
  ------------------
 1028|  5.21k|        struct sh_stream *sh = demux_get_stream(demuxer, n);
 1029|  5.21k|        if (sh->type == filter || filter == STREAM_TYPE_COUNT) {
  ------------------
  |  Branch (1029:13): [True: 4.73k, False: 482]
  |  Branch (1029:35): [True: 0, False: 482]
  ------------------
 1030|  4.73k|            has_any = true;
 1031|  4.73k|            break;
 1032|  4.73k|        }
 1033|  5.21k|    }
 1034|       |
 1035|  6.32k|    if (!has_any) {
  ------------------
  |  Branch (1035:9): [True: 1.59k, False: 4.73k]
  ------------------
 1036|  1.59k|        char *tname = mp_tprintf(20, "%s ", stream_type_name(filter));
  ------------------
  |  |  195|  1.59k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1037|  1.59k|        if (filter == STREAM_TYPE_COUNT)
  ------------------
  |  Branch (1037:13): [True: 0, False: 1.59k]
  ------------------
 1038|      0|            tname = "";
 1039|  1.59k|        MP_ERR(mpctx, "No %sstreams in file %s.\n", tname, disp_filename);
  ------------------
  |  |   89|  1.59k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.59k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1040|  1.59k|        goto err_out;
 1041|  1.59k|    }
 1042|       |
 1043|  4.73k|    int first_num = -1;
 1044|  9.46k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
  ------------------
  |  Branch (1044:21): [True: 4.73k, False: 4.73k]
  ------------------
 1045|  4.73k|        struct sh_stream *sh = demux_get_stream(demuxer, n);
 1046|  4.73k|        struct track *t = add_stream_track(mpctx, demuxer, sh);
 1047|  4.73k|        t->is_external = true;
 1048|  4.73k|        if (sh->title && sh->title[0]) {
  ------------------
  |  Branch (1048:13): [True: 0, False: 4.73k]
  |  Branch (1048:26): [True: 0, False: 0]
  ------------------
 1049|      0|            t->title = talloc_strdup(t, sh->title);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1050|  4.73k|        } else {
 1051|  4.73k|            bstr parent = {0};
 1052|  4.73k|            if (mpctx->filename)
  ------------------
  |  Branch (1052:17): [True: 4.73k, False: 0]
  ------------------
 1053|  4.73k|                parent = mp_strip_ext(bstr0(mp_basename(mpctx->filename)));
 1054|  4.73k|            bstr title = bstr0(mp_basename(disp_filename));
 1055|  4.73k|            bstr_eatstart(&title, parent);
 1056|  4.73k|            bstr_eatstart(&title, bstr0("."));
 1057|  4.73k|            if (title.len)
  ------------------
  |  Branch (1057:17): [True: 0, False: 4.73k]
  ------------------
 1058|      0|                t->title = bstrdup0(t, title);
 1059|  4.73k|        }
 1060|  4.73k|        t->external_filename = mp_normalize_user_path(t, mpctx->global, filename);
 1061|  4.73k|        t->no_default = sh->type != filter;
 1062|  4.73k|        t->no_auto_select = t->no_default;
 1063|  4.73k|        t->hearing_impaired_track = flags & TRACK_HEARING_IMPAIRED;
 1064|  4.73k|        t->visual_impaired_track = flags & TRACK_VISUAL_IMPAIRED;
 1065|  4.73k|        t->forced_track = flags & TRACK_FORCED;
 1066|  4.73k|        t->default_track = flags & TRACK_DEFAULT;
 1067|  4.73k|        t->commentary_track = flags & TRACK_COMMENTARY;
 1068|       |        // if we found video, and we are loading cover art, flag as such.
 1069|  4.73k|        t->attached_picture = t->type == STREAM_VIDEO && (flags & TRACK_ATTACHED_PICTURE);
  ------------------
  |  Branch (1069:31): [True: 0, False: 4.73k]
  |  Branch (1069:58): [True: 0, False: 0]
  ------------------
 1070|  4.73k|        if (first_num < 0 && (filter == STREAM_TYPE_COUNT || sh->type == filter))
  ------------------
  |  Branch (1070:13): [True: 4.73k, False: 0]
  |  Branch (1070:31): [True: 0, False: 4.73k]
  |  Branch (1070:62): [True: 4.73k, False: 0]
  ------------------
 1071|  4.73k|            first_num = mpctx->num_tracks - 1;
 1072|  4.73k|    }
 1073|       |
 1074|  4.73k|    mp_cancel_set_parent(demuxer->cancel, mpctx->playback_abort);
 1075|       |
 1076|  4.73k|    talloc_free(unescaped_url);
  ------------------
  |  |   47|  4.73k|#define talloc_free                     ta_free
  ------------------
 1077|  4.73k|    return first_num;
 1078|       |
 1079|  22.6k|err_out:
 1080|  22.6k|    demux_cancel_and_free(demuxer);
 1081|  22.6k|    if (!mp_cancel_test(cancel))
  ------------------
  |  Branch (1081:9): [True: 22.4k, False: 222]
  ------------------
 1082|  22.6k|        MP_ERR(mpctx, "Can not open external file %s.\n", disp_filename);
  ------------------
  |  |   89|  22.4k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  22.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1083|  22.6k|    talloc_free(unescaped_url);
  ------------------
  |  |   47|  22.6k|#define talloc_free                     ta_free
  ------------------
 1084|  22.6k|    return -1;
 1085|  6.32k|}
autoload_external_files:
 1105|  14.4k|{
 1106|  14.4k|    struct MPOpts *opts = mpctx->opts;
 1107|       |
 1108|  14.4k|    if (opts->sub_auto < 0 && opts->audiofile_auto < 0 && opts->coverart_auto < 0)
  ------------------
  |  Branch (1108:9): [True: 0, False: 14.4k]
  |  Branch (1108:31): [True: 0, False: 0]
  |  Branch (1108:59): [True: 0, False: 0]
  ------------------
 1109|      0|        return;
 1110|  14.4k|    if (!opts->autoload_files || strcmp(mpctx->filename, "-") == 0)
  ------------------
  |  Branch (1110:9): [True: 0, False: 14.4k]
  |  Branch (1110:34): [True: 0, False: 14.4k]
  ------------------
 1111|      0|        return;
 1112|       |
 1113|  14.4k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  14.4k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  14.4k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1114|  14.4k|    struct subfn *list = find_external_files(mpctx->global, mpctx->filename, opts);
 1115|  14.4k|    talloc_steal(tmp, list);
  ------------------
  |  |   38|  14.4k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  14.4k|#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|  14.4k|    int sc[STREAM_TYPE_COUNT + 1] = {0};
 1120|  43.5k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1120:21): [True: 29.1k, False: 14.4k]
  ------------------
 1121|  29.1k|        mp_assert(mpctx->tracks[n]->type >= 0);
  ------------------
  |  |   41|  29.1k|#define mp_assert assert
  ------------------
  |  Branch (1121:9): [True: 29.1k, False: 0]
  ------------------
 1122|  29.1k|        mp_assert(mpctx->tracks[n]->type <= STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  29.1k|#define mp_assert assert
  ------------------
  |  Branch (1122:9): [True: 29.1k, False: 0]
  ------------------
 1123|  29.1k|        if (!mpctx->tracks[n]->attached_picture)
  ------------------
  |  Branch (1123:13): [True: 29.1k, False: 0]
  ------------------
 1124|  29.1k|            sc[mpctx->tracks[n]->type]++;
 1125|  29.1k|    }
 1126|       |
 1127|  14.4k|    for (int i = 0; list && list[i].fname; i++) {
  ------------------
  |  Branch (1127:21): [True: 14.4k, False: 0]
  |  Branch (1127:29): [True: 0, False: 14.4k]
  ------------------
 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|  14.4k|    talloc_free(tmp);
  ------------------
  |  |   47|  14.4k|#define talloc_free                     ta_free
  ------------------
 1159|  14.4k|}
prepare_playlist:
 1164|  16.0k|{
 1165|  16.0k|    struct MPOpts *opts = mpctx->opts;
 1166|  16.0k|    struct playlist_entry *entry = NULL;
 1167|       |
 1168|  16.0k|    if (overwrite_current)
  ------------------
  |  Branch (1168:9): [True: 4.41k, False: 11.6k]
  ------------------
 1169|  4.41k|        pl->current = NULL;
 1170|       |
 1171|  16.0k|    pl->playlist_completed = false;
 1172|  16.0k|    pl->playlist_started = false;
 1173|       |
 1174|  16.0k|    if (opts->playlist_pos >= 0) {
  ------------------
  |  Branch (1174:9): [True: 0, False: 16.0k]
  ------------------
 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|  16.0k|    if (pl->playlist_dir)
  ------------------
  |  Branch (1179:9): [True: 0, False: 16.0k]
  ------------------
 1180|      0|        playlist_set_current(pl);
 1181|       |
 1182|  16.0k|    if (opts->shuffle)
  ------------------
  |  Branch (1182:9): [True: 0, False: 16.0k]
  ------------------
 1183|      0|        playlist_shuffle(pl);
 1184|       |
 1185|  16.0k|    if (opts->merge_files)
  ------------------
  |  Branch (1185:9): [True: 0, False: 16.0k]
  ------------------
 1186|      0|        merge_playlist_files(pl);
 1187|       |
 1188|  16.0k|    if (!pl->current || (!overwrite_current && !entry)) {
  ------------------
  |  Branch (1188:9): [True: 16.0k, False: 0]
  |  Branch (1188:26): [True: 0, False: 0]
  |  Branch (1188:48): [True: 0, False: 0]
  ------------------
 1189|  16.0k|        entry = mp_check_playlist_resume(mpctx, pl);
 1190|  16.0k|        pl->current = overwrite_current || entry ? entry : pl->current;
  ------------------
  |  Branch (1190:23): [True: 4.41k, False: 11.6k]
  |  Branch (1190:44): [True: 0, False: 11.6k]
  ------------------
 1191|  16.0k|    }
 1192|       |
 1193|  16.0k|    if (!pl->current)
  ------------------
  |  Branch (1193:9): [True: 16.0k, False: 0]
  ------------------
 1194|  16.0k|        pl->current = playlist_get_first(pl);
 1195|  16.0k|}
prefetch_next:
 1440|  11.6M|{
 1441|  11.6M|    if (!mpctx->opts->prefetch_open || mpctx->open_active)
  ------------------
  |  Branch (1441:9): [True: 11.6M, False: 0]
  |  Branch (1441:40): [True: 0, False: 0]
  ------------------
 1442|  11.6M|        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|  11.4M|{
 1673|  11.4M|    if (!mpctx->vo_chain || !mpctx->vo_chain->filter)
  ------------------
  |  Branch (1673:9): [True: 961k, False: 10.4M]
  |  Branch (1673:29): [True: 0, False: 10.4M]
  ------------------
 1674|   961k|        return;
 1675|  10.4M|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1676|  10.4M|    mp_output_chain_set_el_stream(mpctx->vo_chain->filter,
 1677|  10.4M|        track ? sh_stream_dependent_sibling(track->stream) : NULL);
  ------------------
  |  Branch (1677:9): [True: 10.4M, False: 0]
  ------------------
 1678|  10.4M|}
update_lavfi_complex:
 1681|  11.6k|{
 1682|  11.6k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1682:9): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|}
mp_next_file:
 2250|  9.76k|{
 2251|  9.76k|    struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
 2252|  9.76k|    if (next && direction < 0 && !force)
  ------------------
  |  Branch (2252:9): [True: 2.67k, False: 7.09k]
  |  Branch (2252:17): [True: 2.64k, False: 24]
  |  Branch (2252:34): [True: 2.64k, False: 0]
  ------------------
 2253|  2.64k|        next->playlist_prev_attempt = true;
 2254|  9.76k|    if (!next && mpctx->opts->loop_times != 1) {
  ------------------
  |  Branch (2254:9): [True: 7.09k, False: 2.67k]
  |  Branch (2254:18): [True: 0, False: 7.09k]
  ------------------
 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|  9.76k|    return next;
 2284|  9.76k|}
mp_play_files:
 2289|  11.6k|{
 2290|  11.6k|    stats_register_thread_cputime(mpctx->stats, "thread");
 2291|       |
 2292|       |    // Wait for all scripts to load before possibly starting playback.
 2293|  11.6k|    if (!mp_clients_all_initialized(mpctx)) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|    mp_msg_set_early_logging(mpctx->global, false);
 2302|       |
 2303|  11.6k|    prepare_playlist(mpctx, mpctx->playlist, false);
 2304|       |
 2305|  17.8k|    for (;;) {
 2306|  17.8k|        idle_loop(mpctx);
 2307|       |
 2308|  17.8k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2308:13): [True: 1.66k, False: 16.1k]
  ------------------
 2309|  1.66k|            break;
 2310|       |
 2311|  16.1k|        if (mpctx->playlist->current)
  ------------------
  |  Branch (2311:13): [True: 16.1k, False: 2]
  ------------------
 2312|  16.1k|            play_current_file(mpctx);
 2313|       |
 2314|  16.1k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2314:13): [True: 10.0k, False: 6.17k]
  ------------------
 2315|  10.0k|            break;
 2316|       |
 2317|  6.17k|        struct playlist_entry *new_entry = NULL;
 2318|  6.17k|        if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR ||
  ------------------
  |  Branch (2318:13): [True: 0, False: 6.17k]
  |  Branch (2318:50): [True: 690, False: 5.48k]
  ------------------
 2319|  5.48k|            mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (2319:13): [True: 4.04k, False: 1.43k]
  ------------------
 2320|  4.73k|        {
 2321|  4.73k|            new_entry = mp_next_file(mpctx, +1, false, true);
 2322|  4.73k|        } else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
  ------------------
  |  Branch (2322:20): [True: 1.29k, False: 144]
  ------------------
 2323|  1.29k|            new_entry = mpctx->playlist->current;
 2324|  1.29k|        }
 2325|       |
 2326|  6.17k|        if (!new_entry)
  ------------------
  |  Branch (2326:13): [True: 4.96k, False: 1.21k]
  ------------------
 2327|  4.96k|            mpctx->playlist->playlist_completed = true;
 2328|       |
 2329|  6.17k|        mpctx->playlist->current = new_entry;
 2330|  6.17k|        mpctx->playlist->current_was_replaced = false;
 2331|  6.17k|        mpctx->stop_play = new_entry ? PT_NEXT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2331:28): [True: 1.21k, False: 4.96k]
  ------------------
 2332|       |
 2333|  6.17k|        if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2)
  ------------------
  |  Branch (2333:13): [True: 4.96k, False: 1.21k]
  |  Branch (2333:42): [True: 0, False: 4.96k]
  ------------------
 2334|      0|            break;
 2335|  6.17k|    }
 2336|       |
 2337|  11.6k|    cancel_open(mpctx);
 2338|       |
 2339|  11.6k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2339:9): [True: 0, False: 11.6k]
  ------------------
 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|  11.6k|}
mp_set_playlist_entry:
 2354|  16.5k|{
 2355|  16.5k|    mp_assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
  ------------------
  |  |   41|  16.5k|#define mp_assert assert
  ------------------
  |  Branch (2355:5): [True: 239, False: 16.3k]
  |  Branch (2355:5): [True: 16.3k, False: 0]
  ------------------
 2356|  16.5k|    mpctx->playlist->current = e;
 2357|  16.5k|    mpctx->playlist->current_was_replaced = false;
 2358|  16.5k|    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 2359|       |    // Make it pick up the new entry.
 2360|  16.5k|    if (mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (2360:9): [True: 16.5k, False: 1]
  ------------------
 2361|  16.5k|        mpctx->stop_play = e ? PT_CURRENT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2361:28): [True: 16.3k, False: 239]
  ------------------
 2362|  16.5k|    mp_wakeup_core(mpctx);
 2363|  16.5k|}
loadfile.c:track_in_current_edition:
  301|   223k|{
  302|   223k|    struct demuxer *demuxer = mpctx->demuxer;
  303|   223k|    if (!demuxer || !demuxer->edition_is_track_mapping || demuxer->num_editions <= 1)
  ------------------
  |  Branch (303:9): [True: 0, False: 223k]
  |  Branch (303:21): [True: 223k, False: 0]
  |  Branch (303:59): [True: 0, False: 0]
  ------------------
  304|   223k|        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|   164k|{
  245|   164k|    const char *tname = "?";
  246|   164k|    const char *selopt = "?";
  247|   164k|    const char *langopt = "?";
  248|   164k|    switch (t->type) {
  ------------------
  |  Branch (248:13): [True: 164k, False: 0]
  ------------------
  249|  49.0k|    case STREAM_VIDEO:
  ------------------
  |  Branch (249:5): [True: 49.0k, False: 115k]
  ------------------
  250|  49.0k|        tname = t->image ? "Image" : "Video"; selopt = "vid"; langopt = "vlang";
  ------------------
  |  Branch (250:17): [True: 0, False: 49.0k]
  ------------------
  251|  49.0k|        break;
  252|  49.0k|    case STREAM_AUDIO:
  ------------------
  |  Branch (252:5): [True: 49.0k, False: 115k]
  ------------------
  253|  49.0k|        tname = "Audio"; selopt = "aid"; langopt = "alang";
  254|  49.0k|        break;
  255|  66.3k|    case STREAM_SUB:
  ------------------
  |  Branch (255:5): [True: 66.3k, False: 98.1k]
  ------------------
  256|  66.3k|        tname = "Subs"; selopt = "sid"; langopt = "slang";
  257|  66.3k|        break;
  258|   164k|    }
  259|   164k|    char b[2048] = {0};
  260|       |
  261|   164k|    int max_lang_length = 0;
  262|  2.55M|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (262:21): [True: 2.38M, False: 164k]
  ------------------
  263|  2.38M|        if (mpctx->tracks[n]->lang)
  ------------------
  |  Branch (263:13): [True: 6.05k, False: 2.38M]
  ------------------
  264|  6.05k|            max_lang_length = MPMAX(strlen(mpctx->tracks[n]->lang), max_lang_length);
  ------------------
  |  |   44|  6.05k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 3.64k, False: 2.41k]
  |  |  ------------------
  ------------------
  265|  2.38M|    }
  266|       |
  267|   164k|    if (indent)
  ------------------
  |  Branch (267:9): [True: 136k, False: 28.4k]
  ------------------
  268|   136k|        APPEND(b, " ");
  ------------------
  |  |  240|   136k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  269|   164k|    APPEND(b, "%s %-5s  --%s=%-2d", t->selected ? BLACK_CIRCLE : WHITE_CIRCLE,
  ------------------
  |  |  240|   329k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 89.0k, False: 75.4k]
  |  |  ------------------
  ------------------
  270|   164k|           tname, selopt, t->user_tid);
  271|   164k|    if (t->lang) {
  ------------------
  |  Branch (271:9): [True: 957, False: 163k]
  ------------------
  272|    957|        APPEND(b, " --%s=%-*s ", langopt, max_lang_length, t->lang);
  ------------------
  |  |  240|    957|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  273|   163k|    } else if (max_lang_length) {
  ------------------
  |  Branch (273:16): [True: 2.68k, False: 160k]
  ------------------
  274|  2.68k|        FILL(b, (int) strlen(" --alang= ") + max_lang_length);
  ------------------
  |  |  241|  2.68k|#define FILL(s, n) mp_snprintf_cat(s, sizeof(s), "%*s", n, "")
  ------------------
  275|  2.68k|    }
  276|       |
  277|   164k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|   164k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   164k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  278|   164k|    APPEND(b, " %s", mp_format_track_metadata(ctx, t, false));
  ------------------
  |  |  240|   164k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  279|   164k|    talloc_free(ctx);
  ------------------
  |  |   47|   164k|#define talloc_free                     ta_free
  ------------------
  280|       |
  281|   164k|    MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|   164k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   164k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  282|   164k|}
loadfile.c:add_stream_track:
  520|  61.6k|{
  521|   154k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (521:21): [True: 121k, False: 33.2k]
  ------------------
  522|   121k|        struct track *track = mpctx->tracks[i];
  523|   121k|        if (track->stream == stream)
  ------------------
  |  Branch (523:13): [True: 28.4k, False: 93.1k]
  ------------------
  524|  28.4k|            return track;
  525|   121k|    }
  526|       |
  527|  33.2k|    struct track *track = talloc_ptrtype(NULL, track);
  ------------------
  |  |   34|  33.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  33.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  33.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|  33.2k|    *track = (struct track) {
  529|  33.2k|        .type = stream->type,
  530|  33.2k|        .user_tid = find_new_tid(mpctx, stream->type),
  531|  33.2k|        .demuxer_id = stream->demuxer_id,
  532|  33.2k|        .ff_index = stream->ff_index,
  533|  33.2k|        .hls_bitrate = stream->hls_bitrate,
  534|  33.2k|        .title = stream->title,
  535|  33.2k|        .default_track = stream->default_track,
  536|  33.2k|        .forced_track = stream->forced_track,
  537|  33.2k|        .dependent_track = stream->dependent_track,
  538|  33.2k|        .visual_impaired_track = stream->visual_impaired_track,
  539|  33.2k|        .hearing_impaired_track = stream->hearing_impaired_track,
  540|  33.2k|        .original_track = stream->original_track,
  541|  33.2k|        .commentary_track = stream->commentary_track,
  542|  33.2k|        .image = stream->image,
  543|  33.2k|        .attached_picture = stream->attached_picture != NULL,
  544|  33.2k|        .lang = stream->lang,
  545|  33.2k|        .demuxer = demuxer,
  546|  33.2k|        .stream = stream,
  547|  33.2k|    };
  548|  33.2k|    MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
  ------------------
  |  |  105|  33.2k|    do {                                            \
  |  |  106|  33.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  33.2k|    do {                                            \
  |  |  |  |   97|  33.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  33.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  33.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  33.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 12.9k, False: 20.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  33.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  12.9k|    do {                                                        \
  |  |  |  |  |  |   89|  12.9k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  12.9k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  12.9k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  12.9k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  12.9k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  12.9k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  12.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 12.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  33.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 33.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  33.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  33.2k|        (idxvar)++;                                 \
  |  |  109|  33.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 33.2k]
  |  |  ------------------
  ------------------
  549|       |
  550|  33.2k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  551|       |
  552|  33.2k|    return track;
  553|  61.6k|}
loadfile.c:find_new_tid:
  507|  33.2k|{
  508|  33.2k|    int new_id = 0;
  509|   112k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (509:21): [True: 78.8k, False: 33.2k]
  ------------------
  510|  78.8k|        struct track *track = mpctx->tracks[i];
  511|  78.8k|        if (track->type == t)
  ------------------
  |  Branch (511:13): [True: 55.1k, False: 23.7k]
  ------------------
  512|  55.1k|            new_id = MPMAX(new_id, track->user_tid);
  ------------------
  |  |   44|  55.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 55.1k]
  |  |  ------------------
  ------------------
  513|  78.8k|    }
  514|  33.2k|    return new_id + 1;
  515|  33.2k|}
loadfile.c:process_langs:
  665|  42.4k|{
  666|  42.4k|    size_t nb = 0;
  667|  42.4k|    char **out = NULL;
  668|  42.4k|    for (int i = 0; in && in[i]; i++) {
  ------------------
  |  Branch (668:21): [True: 0, False: 42.4k]
  |  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|  42.4k|    return out;
  673|  42.4k|}
loadfile.c:add_os_langs:
  650|  14.3k|{
  651|  14.3k|    size_t nb = 0;
  652|  14.3k|    char **out = NULL;
  653|  14.3k|    char **autos = mp_get_user_langs();
  654|  14.3k|    for (int i = 0; autos && autos[i]; i++) {
  ------------------
  |  Branch (654:21): [True: 14.3k, False: 0]
  |  Branch (654:30): [True: 0, False: 14.3k]
  ------------------
  655|      0|        if (!append_lang(&nb, &out, autos[i]))
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            goto cleanup;
  657|      0|    }
  658|       |
  659|  14.3k|cleanup:
  660|  14.3k|    talloc_free(autos);
  ------------------
  |  |   47|  14.3k|#define talloc_free                     ta_free
  ------------------
  661|  14.3k|    return out;
  662|  14.3k|}
loadfile.c:duplicate_track:
  630|  28.1k|{
  631|  28.1k|    for (int i = 0; i < order; i++) {
  ------------------
  |  Branch (631:21): [True: 0, False: 28.1k]
  ------------------
  632|      0|        if (mpctx->current_track[i][type] == track)
  ------------------
  |  Branch (632:13): [True: 0, False: 0]
  ------------------
  633|      0|            return true;
  634|      0|    }
  635|  28.1k|    return false;
  636|  28.1k|}
loadfile.c:compare_track:
  585|    106|{
  586|    106|    bool sub = t2->type == STREAM_SUB;
  587|    106|    bool ext1 = t1->is_external && !t1->no_default;
  ------------------
  |  Branch (587:17): [True: 106, False: 0]
  |  Branch (587:36): [True: 106, False: 0]
  ------------------
  588|    106|    bool ext2 = t2->is_external && !t2->no_default;
  ------------------
  |  Branch (588:17): [True: 106, False: 0]
  |  Branch (588:36): [True: 106, False: 0]
  ------------------
  589|    106|    if (ext1 != ext2 && t1->image == t2->image) {
  ------------------
  |  Branch (589:9): [True: 0, False: 106]
  |  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|    106|    if (t1->auto_loaded != t2->auto_loaded)
  ------------------
  |  Branch (595:9): [True: 0, False: 106]
  ------------------
  596|      0|        return !t1->auto_loaded;
  597|    106|    int l1 = mp_match_lang(langs, t1->lang), l2 = mp_match_lang(langs, t2->lang);
  598|    106|    if (!os_langs && l1 != l2)
  ------------------
  |  Branch (598:9): [True: 0, False: 106]
  |  Branch (598:22): [True: 0, False: 0]
  ------------------
  599|      0|        return l1 > l2;
  600|    106|    if (t1->forced_select != t2->forced_select)
  ------------------
  |  Branch (600:9): [True: 0, False: 106]
  ------------------
  601|      0|        return t1->forced_select;
  602|    106|    if (t1->default_track != t2->default_track)
  ------------------
  |  Branch (602:9): [True: 0, False: 106]
  ------------------
  603|      0|        return t1->default_track;
  604|    106|    if (sub && t1->forced_track != t2->forced_track)
  ------------------
  |  Branch (604:9): [True: 106, False: 0]
  |  Branch (604:16): [True: 0, False: 106]
  ------------------
  605|      0|        return !t1->forced_track;
  606|    106|    if (os_langs && l1 != l2)
  ------------------
  |  Branch (606:9): [True: 106, False: 0]
  |  Branch (606:21): [True: 0, False: 106]
  ------------------
  607|      0|        return l1 > l2;
  608|    106|    if (t1->attached_picture != t2->attached_picture)
  ------------------
  |  Branch (608:9): [True: 0, False: 106]
  ------------------
  609|      0|        return !t1->attached_picture;
  610|    106|    if (t1->image != t2->image)
  ------------------
  |  Branch (610:9): [True: 0, False: 106]
  ------------------
  611|      0|        return !t1->image;
  612|    106|    if (t1->dependent_track != t2->dependent_track)
  ------------------
  |  Branch (612:9): [True: 0, False: 106]
  ------------------
  613|      0|        return !t1->dependent_track;
  614|    106|    if (t1->stream && t2->stream && opts->hls_bitrate >= 0 &&
  ------------------
  |  Branch (614:9): [True: 106, False: 0]
  |  Branch (614:23): [True: 106, False: 0]
  |  Branch (614:37): [True: 106, False: 0]
  ------------------
  615|    106|        t1->stream->hls_bitrate != t2->stream->hls_bitrate)
  ------------------
  |  Branch (615:9): [True: 0, False: 106]
  ------------------
  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|    106|    return t1->user_tid <= t2->user_tid;
  626|    106|}
loadfile.c:track_layout_hash:
  758|  35.9k|{
  759|  35.9k|    char *h = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  35.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
  760|   143k|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (760:24): [True: 107k, False: 35.9k]
  ------------------
  761|   544k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (761:25): [True: 436k, False: 107k]
  ------------------
  762|   436k|            struct track *track = mpctx->tracks[n];
  763|   436k|            if (track->type != type)
  ------------------
  |  Branch (763:17): [True: 291k, False: 145k]
  ------------------
  764|   291k|                continue;
  765|   145k|            h = talloc_asprintf_append_buffer(h, "%d-%d-%d-%d-%s\n", type,
  ------------------
  |  |   64|   145k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  766|   145k|                    track->user_tid, track->default_track, track->is_external,
  767|   145k|                    track->lang ? track->lang : "");
  ------------------
  |  Branch (767:21): [True: 902, False: 144k]
  ------------------
  768|   145k|        }
  769|   107k|    }
  770|  35.9k|    return h;
  771|  35.9k|}
loadfile.c:enable_demux_thread:
  499|  20.5k|{
  500|  20.5k|    if (mpctx->opts->demuxer_thread && !demux->fully_read) {
  ------------------
  |  Branch (500:9): [True: 20.5k, False: 0]
  |  Branch (500:40): [True: 14.7k, False: 5.82k]
  ------------------
  501|  14.7k|        demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
  502|  14.7k|        demux_start_thread(demux);
  503|  14.7k|    }
  504|  20.5k|}
loadfile.c:wakeup_demux:
   66|  7.01M|{
   67|  7.01M|    struct MPContext *mpctx = pctx;
   68|  7.01M|    mp_wakeup_core(mpctx);
   69|  7.01M|}
loadfile.c:start_open:
 1356|  16.1k|{
 1357|  16.1k|    cancel_open(mpctx);
 1358|       |
 1359|  16.1k|    mp_assert(!mpctx->open_active);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1359:5): [True: 16.1k, False: 0]
  ------------------
 1360|  16.1k|    mp_assert(!mpctx->open_cancel);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1360:5): [True: 16.1k, False: 0]
  ------------------
 1361|  16.1k|    mp_assert(!mpctx->open_res_demuxer);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1361:5): [True: 16.1k, False: 0]
  ------------------
 1362|  16.1k|    mp_assert(!atomic_load(&mpctx->open_done));
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1362:5): [True: 16.1k, False: 0]
  ------------------
 1363|       |
 1364|  16.1k|    mpctx->open_cancel = mp_cancel_new(NULL);
 1365|  16.1k|    mpctx->open_url = talloc_strdup(NULL, url);
  ------------------
  |  |   50|  16.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1366|  16.1k|    mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name);
  ------------------
  |  |   50|  16.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1367|  16.1k|    mpctx->open_url_flags = url_flags;
 1368|  16.1k|    mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
  ------------------
  |  Branch (1368:32): [True: 0, False: 16.1k]
  |  Branch (1368:48): [True: 0, False: 0]
  ------------------
 1369|  16.1k|    mpctx->demuxer_changed = false;
 1370|       |
 1371|  16.1k|    if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
  ------------------
  |  |  214|  16.1k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 16.1k]
  |  |  ------------------
  ------------------
 1372|      0|        cancel_open(mpctx);
 1373|      0|        return;
 1374|      0|    }
 1375|       |
 1376|  16.1k|    mpctx->open_active = true;
 1377|  16.1k|}
loadfile.c:open_demux_thread:
 1287|  16.1k|{
 1288|  16.1k|    struct MPContext *mpctx = ctx;
 1289|       |
 1290|  16.1k|    mp_thread_set_name("opener");
 1291|       |
 1292|  16.1k|    struct demuxer_params p = {
 1293|  16.1k|        .force_format = mpctx->open_format,
 1294|  16.1k|        .stream_flags = mpctx->open_url_flags,
 1295|  16.1k|        .stream_record = true,
 1296|  16.1k|        .is_top_level = true,
 1297|  16.1k|        .allow_playlist_create = mpctx->playlist->num_entries <= 1 &&
  ------------------
  |  Branch (1297:34): [True: 16.1k, False: 0]
  ------------------
 1298|  16.1k|                                 !mpctx->playlist->playlist_dir,
  ------------------
  |  Branch (1298:34): [True: 16.1k, False: 0]
  ------------------
 1299|  16.1k|    };
 1300|  16.1k|    struct demuxer *demux =
 1301|  16.1k|        demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);
 1302|  16.1k|    mpctx->open_res_demuxer = demux;
 1303|       |
 1304|  16.1k|    if (demux) {
  ------------------
  |  Branch (1304:9): [True: 14.6k, False: 1.56k]
  ------------------
 1305|  14.6k|        MP_VERBOSE(mpctx, "Opening done: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  14.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1306|       |
 1307|  14.6k|        if (mpctx->open_for_prefetch && !demux->fully_read) {
  ------------------
  |  Branch (1307:13): [True: 0, False: 14.6k]
  |  Branch (1307:41): [True: 0, False: 0]
  ------------------
 1308|      0|            int num_streams = demux_get_num_stream(demux);
 1309|      0|            for (int n = 0; n < num_streams; n++) {
  ------------------
  |  Branch (1309:29): [True: 0, False: 0]
  ------------------
 1310|      0|                struct sh_stream *sh = demux_get_stream(demux, n);
 1311|      0|                demuxer_select_track(demux, sh, MP_NOPTS_VALUE, true);
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1312|      0|            }
 1313|       |
 1314|      0|            demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
 1315|      0|            demux_start_thread(demux);
 1316|      0|            demux_start_prefetch(demux);
 1317|      0|        }
 1318|  14.6k|    } else {
 1319|  1.56k|        MP_VERBOSE(mpctx, "Opening failed or was aborted: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  1.56k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.56k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1320|       |
 1321|  1.56k|        if (p.demuxer_failed) {
  ------------------
  |  Branch (1321:13): [True: 75, False: 1.49k]
  ------------------
 1322|     75|            mpctx->open_res_error = MPV_ERROR_UNKNOWN_FORMAT;
 1323|  1.49k|        } else {
 1324|  1.49k|            mpctx->open_res_error = MPV_ERROR_LOADING_FAILED;
 1325|  1.49k|        }
 1326|  1.56k|    }
 1327|       |
 1328|  16.1k|    atomic_store(&mpctx->open_done, true);
 1329|  16.1k|    mp_wakeup_core(mpctx);
 1330|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  16.1k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1331|  16.1k|}
loadfile.c:reinit_complex_filters:
 1533|  30.3k|{
 1534|  30.3k|    char *graph = mpctx->opts->lavfi_complex;
 1535|  30.3k|    bool have_graph = graph && graph[0] && !force_uninit;
  ------------------
  |  Branch (1535:23): [True: 0, False: 30.3k]
  |  Branch (1535:32): [True: 0, False: 0]
  |  Branch (1535:44): [True: 0, False: 0]
  ------------------
 1536|  30.3k|    if (have_graph && mpctx->lavfi &&
  ------------------
  |  Branch (1536:9): [True: 0, False: 30.3k]
  |  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|  30.3k|    if (!mpctx->lavfi && !have_graph)
  ------------------
  |  Branch (1540:9): [True: 30.3k, False: 0]
  |  Branch (1540:26): [True: 30.3k, False: 0]
  ------------------
 1541|  30.3k|        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|  16.1k|{
 1821|  16.1k|    struct MPOpts *opts = mpctx->opts;
 1822|       |
 1823|  16.1k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1823:5): [True: 16.1k, False: 0]
  ------------------
 1824|  16.1k|    mpctx->stop_play = 0;
 1825|       |
 1826|  16.1k|    process_hooks(mpctx, "on_before_start_file");
 1827|  16.1k|    if (mpctx->stop_play || !mpctx->playlist->current)
  ------------------
  |  Branch (1827:9): [True: 0, False: 16.1k]
  |  Branch (1827:29): [True: 0, False: 16.1k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  16.1k|    mpv_event_start_file start_event = {
 1831|  16.1k|        .playlist_entry_id = mpctx->playlist->current->id,
 1832|  16.1k|    };
 1833|  16.1k|    mpv_event_end_file end_event = {
 1834|  16.1k|        .playlist_entry_id = start_event.playlist_entry_id,
 1835|  16.1k|    };
 1836|       |
 1837|  16.1k|    mp_notify(mpctx, MPV_EVENT_START_FILE, &start_event);
 1838|       |
 1839|  16.1k|    mp_cancel_reset(mpctx->playback_abort);
 1840|       |
 1841|  16.1k|    mpctx->error_playing = MPV_ERROR_LOADING_FAILED;
 1842|  16.1k|    mpctx->filename = NULL;
 1843|  16.1k|    mpctx->shown_aframes = 0;
 1844|  16.1k|    mpctx->shown_vframes = 0;
 1845|  16.1k|    mpctx->last_chapter_seek = -2;
 1846|  16.1k|    mpctx->last_chapter_flag = false;
 1847|  16.1k|    mpctx->last_chapter = -2;
 1848|  16.1k|    mpctx->paused = false;
 1849|  16.1k|    mpctx->playing_msg_shown = false;
 1850|  16.1k|    mpctx->max_frames = -1;
 1851|  16.1k|    mpctx->video_speed = mpctx->audio_speed = opts->playback_speed;
 1852|  16.1k|    mpctx->speed_factor_a = mpctx->speed_factor_v = 1.0;
 1853|  16.1k|    mpctx->display_sync_error = 0.0;
 1854|  16.1k|    mpctx->display_sync_active = false;
 1855|       |    // let get_current_time() show 0 as start time (before playback_pts is set)
 1856|  16.1k|    mpctx->last_seek_pts = 0.0;
 1857|  16.1k|    mpctx->seek = (struct seek_params){ 0 };
 1858|  16.1k|    disc_nav_reset(mpctx);
 1859|  16.1k|    mpctx->filter_root = mp_filter_create_root(mpctx->global);
 1860|  16.1k|    mp_filter_graph_set_wakeup_cb(mpctx->filter_root, mp_wakeup_core_cb, mpctx);
 1861|  16.1k|    mp_filter_graph_set_max_run_time(mpctx->filter_root, 0.1);
 1862|       |
 1863|  16.1k|    reset_playback_state(mpctx);
 1864|       |
 1865|  16.1k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1866|  16.1k|    if (mpctx->playlist->num_entries > 3)
  ------------------
  |  Branch (1866:9): [True: 0, False: 16.1k]
  ------------------
 1867|      0|        goto terminate_playback;
 1868|  16.1k|#endif
 1869|       |
 1870|  16.1k|    mpctx->playing = mpctx->playlist->current;
 1871|  16.1k|    mp_assert(mpctx->playing);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1871:5): [True: 16.1k, False: 0]
  ------------------
 1872|  16.1k|    mp_assert(mpctx->playing->filename);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1872:5): [True: 16.1k, False: 0]
  ------------------
 1873|  16.1k|    mpctx->playing->reserved += 1;
 1874|       |
 1875|  16.1k|    mpctx->filename = talloc_strdup(NULL, mpctx->playing->filename);
  ------------------
  |  |   50|  16.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1876|  16.1k|    mpctx->stream_open_filename = mpctx->filename;
 1877|       |
 1878|  16.1k|    mpctx->add_osd_seek_info &= OSD_SEEK_INFO_CURRENT_FILE;
 1879|       |
 1880|  16.1k|    if (opts->reset_options) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 16.1k]
  ------------------
 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|  16.1k|    mp_load_auto_profiles(mpctx);
 1894|       |
 1895|  16.1k|    bool watch_later = mp_load_playback_resume(mpctx, mpctx->filename);
 1896|       |
 1897|  16.1k|    load_per_file_options(mpctx->mconfig, mpctx->playing->params,
 1898|  16.1k|                          mpctx->playing->num_params);
 1899|       |
 1900|  16.1k|    mpctx->remaining_file_loops = mpctx->opts->loop_file;
 1901|  16.1k|    mp_notify_property(mpctx, "remaining-file-loops");
 1902|  16.1k|    mpctx->remaining_ab_loops = mpctx->opts->ab_loop_count;
 1903|  16.1k|    mp_notify_property(mpctx, "remaining-ab-loops");
 1904|       |
 1905|  16.1k|    mpctx->max_frames = opts->play_frames;
 1906|       |
 1907|  16.1k|    handle_force_window(mpctx, false);
 1908|       |
 1909|  16.1k|    if (mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (1909:9): [True: 0, False: 16.1k]
  ------------------
 1910|  16.1k|        mpctx->playing->playlist_path)
  ------------------
  |  Branch (1910:9): [True: 82, False: 16.0k]
  ------------------
 1911|  16.1k|        MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
  ------------------
  |  |   91|     82|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     82|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1912|       |
 1913|  16.1k|    mp_assert(mpctx->demuxer == NULL);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (1913:5): [True: 16.1k, False: 0]
  ------------------
 1914|       |
 1915|  16.1k|    process_hooks(mpctx, "on_load");
 1916|  16.1k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1916:9): [True: 0, False: 16.1k]
  ------------------
 1917|      0|        goto terminate_playback;
 1918|       |
 1919|  16.1k|    if (opts->stream_dump && opts->stream_dump[0]) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 16.1k]
  |  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|  16.1k|    open_demux_reentrant(mpctx);
 1926|  16.1k|    if (!mpctx->stop_play && !mpctx->demuxer) {
  ------------------
  |  Branch (1926:9): [True: 14.8k, False: 1.30k]
  |  Branch (1926:30): [True: 628, False: 14.2k]
  ------------------
 1927|    628|        process_hooks(mpctx, "on_load_fail");
 1928|    628|        if (strcmp(mpctx->stream_open_filename, mpctx->filename) != 0 &&
  ------------------
  |  Branch (1928:13): [True: 0, False: 628]
  ------------------
 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|    628|    }
 1935|  16.1k|    if (!mpctx->demuxer || mpctx->stop_play)
  ------------------
  |  Branch (1935:9): [True: 1.56k, False: 14.6k]
  |  Branch (1935:28): [True: 365, False: 14.2k]
  ------------------
 1936|  1.93k|        goto terminate_playback;
 1937|       |
 1938|  14.2k|    struct playlist *pl = mpctx->demuxer->playlist;
 1939|  14.2k|    if (pl) {
  ------------------
  |  Branch (1939:9): [True: 0, False: 14.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|  14.2k|    if (mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (1957:9): [True: 14.2k, False: 0]
  ------------------
 1958|  14.2k|        demux_set_ts_offset(mpctx->demuxer, -mpctx->demuxer->start_time);
 1959|  14.2k|    enable_demux_thread(mpctx, mpctx->demuxer);
 1960|       |
 1961|  14.2k|    add_demuxer_tracks(mpctx, mpctx->demuxer);
 1962|       |
 1963|  14.2k|    load_external_opts(mpctx);
 1964|  14.2k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1964:9): [True: 31, False: 14.2k]
  ------------------
 1965|     31|        goto terminate_playback;
 1966|       |
 1967|  14.2k|    check_previous_track_selection(mpctx);
 1968|       |
 1969|  14.2k|    process_hooks(mpctx, "on_preloaded");
 1970|  14.2k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1970:9): [True: 0, False: 14.2k]
  ------------------
 1971|      0|        goto terminate_playback;
 1972|       |
 1973|  14.2k|    if (reinit_complex_filters(mpctx, false) < 0)
  ------------------
  |  Branch (1973:9): [True: 0, False: 14.2k]
  ------------------
 1974|      0|        goto terminate_playback;
 1975|       |
 1976|  56.8k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1976:21): [True: 42.6k, False: 14.2k]
  ------------------
 1977|  99.5k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1977:25): [True: 56.8k, False: 42.6k]
  ------------------
 1978|  56.8k|            struct track *sel = NULL;
 1979|  56.8k|            bool taken = (t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (1979:27): [True: 14.2k, False: 42.6k]
  |  Branch (1979:48): [True: 0, False: 14.2k]
  ------------------
 1980|  56.8k|                         (t == STREAM_AUDIO && mpctx->ao_chain);
  ------------------
  |  Branch (1980:27): [True: 14.2k, False: 42.6k]
  |  Branch (1980:48): [True: 0, False: 14.2k]
  ------------------
 1981|  56.8k|            if (!taken && opts->stream_auto_sel)
  ------------------
  |  Branch (1981:17): [True: 56.8k, False: 0]
  |  Branch (1981:27): [True: 56.8k, False: 0]
  ------------------
 1982|  56.8k|                sel = select_default_track(mpctx, i, t);
 1983|  56.8k|            mpctx->current_track[i][t] = sel;
 1984|  56.8k|        }
 1985|  42.6k|    }
 1986|  56.8k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1986:21): [True: 42.6k, False: 14.2k]
  ------------------
 1987|  99.5k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1987:25): [True: 56.8k, False: 42.6k]
  ------------------
 1988|       |            // One track can strictly feed at most 1 decoder
 1989|  56.8k|            struct track *track = mpctx->current_track[i][t];
 1990|  56.8k|            if (track) {
  ------------------
  |  Branch (1990:17): [True: 27.8k, False: 28.9k]
  ------------------
 1991|  27.8k|                if (track->type != STREAM_SUB &&
  ------------------
  |  Branch (1991:21): [True: 27.8k, False: 23]
  ------------------
 1992|  27.8k|                    mpctx->encode_lavc_ctx &&
  ------------------
  |  Branch (1992:21): [True: 0, False: 27.8k]
  ------------------
 1993|      0|                    !encode_lavc_stream_type_ok(mpctx->encode_lavc_ctx,
  ------------------
  |  Branch (1993:21): [True: 0, False: 0]
  ------------------
 1994|      0|                                                track->type))
 1995|      0|                {
 1996|      0|                    MP_WARN(mpctx, "Disabling %s (not supported by target "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1997|      0|                            "format).\n", stream_type_name(track->type));
 1998|      0|                    mpctx->current_track[i][t] = NULL;
 1999|      0|                    mark_track_selection(mpctx, i, t, -2); // disable
 2000|  27.8k|                } else if (track->selected) {
  ------------------
  |  Branch (2000:28): [True: 0, False: 27.8k]
  ------------------
 2001|      0|                    MP_ERR(mpctx, "Track %d can't be selected twice.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2002|      0|                           track->user_tid);
 2003|      0|                    mpctx->current_track[i][t] = NULL;
 2004|      0|                    mark_track_selection(mpctx, i, t, -2); // disable
 2005|  27.8k|                } else {
 2006|  27.8k|                    track->selected = true;
 2007|  27.8k|                }
 2008|  27.8k|            }
 2009|       |
 2010|       |            // Revert selection of unselected tracks to default. This is needed
 2011|       |            // because track properties have inconsistent behavior.
 2012|  56.8k|            if (!track && opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (2012:17): [True: 28.9k, False: 27.8k]
  |  Branch (2012:27): [True: 9, False: 28.9k]
  ------------------
 2013|      9|                mark_track_selection(mpctx, i, t, -1); // default
 2014|  56.8k|        }
 2015|  42.6k|    }
 2016|       |
 2017|  14.2k|    process_hooks(mpctx, "on_loaded");
 2018|  56.8k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (2018:21): [True: 42.6k, False: 14.2k]
  ------------------
 2019|   128k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2019:25): [True: 85.3k, False: 42.6k]
  ------------------
 2020|  85.3k|            struct track *track = mpctx->tracks[n];
 2021|  85.3k|            if (track->type != t)
  ------------------
  |  Branch (2021:17): [True: 56.9k, False: 28.4k]
  ------------------
 2022|  56.9k|                continue;
 2023|       |            // Only reselect dependent tracks when explicitly selected by user
 2024|  28.4k|            if (track->stream && track->stream->dependent_track &&
  ------------------
  |  Branch (2024:17): [True: 28.4k, False: 0]
  |  Branch (2024:34): [True: 0, False: 28.4k]
  ------------------
 2025|      0|                !track->selected)
  ------------------
  |  Branch (2025:17): [True: 0, False: 0]
  ------------------
 2026|      0|                continue;
 2027|  28.4k|            reselect_demux_stream(mpctx, track, false);
 2028|  28.4k|        }
 2029|  42.6k|    }
 2030|       |
 2031|  14.2k|    update_demuxer_properties(mpctx);
 2032|       |
 2033|  14.2k|    update_playback_speed(mpctx);
 2034|       |
 2035|  14.2k|    reinit_video_chain(mpctx);
 2036|  14.2k|    reinit_audio_chain(mpctx);
 2037|  14.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|  14.2k|    update_vo_chain_el_pair(mpctx);
 2041|       |
 2042|  14.2k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2042:9): [True: 0, False: 14.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|  14.2k|    if (!mpctx->vo_chain && !mpctx->ao_chain && opts->stream_auto_sel) {
  ------------------
  |  Branch (2051:9): [True: 348, False: 13.8k]
  |  Branch (2051:29): [True: 65, False: 283]
  |  Branch (2051:49): [True: 65, False: 0]
  ------------------
 2052|     65|        MP_FATAL(mpctx, "No video or audio streams selected.\n");
  ------------------
  |  |   88|     65|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     65|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2053|     65|        mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2054|     65|        goto terminate_playback;
 2055|     65|    }
 2056|       |
 2057|  14.1k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart) {
  ------------------
  |  Branch (2057:9): [True: 13.8k, False: 283]
  |  Branch (2057:28): [True: 0, False: 13.8k]
  ------------------
 2058|      0|        MP_INFO(mpctx,
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2059|      0|            "Displaying cover art. Use --no-audio-display to prevent this.\n");
 2060|      0|    }
 2061|       |
 2062|  14.1k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2062:9): [True: 283, False: 13.8k]
  ------------------
 2063|    283|        handle_force_window(mpctx, true);
 2064|       |
 2065|  14.1k|    MP_VERBOSE(mpctx, "Starting playback...\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__)
  |  |  ------------------
  ------------------
 2066|       |
 2067|  14.1k|    mpctx->playback_initialized = true;
 2068|  14.1k|    mpctx->playing->playlist_prev_attempt = false;
 2069|  14.1k|    mpctx->playlist->playlist_completed = false;
 2070|  14.1k|    mpctx->playlist->playlist_started = true;
 2071|  14.1k|    mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
 2072|  14.1k|    update_screensaver_state(mpctx);
 2073|  14.1k|    clear_playlist_paths(mpctx);
 2074|       |
 2075|       |    // Clear out subs from the previous file if the video track is a still image.
 2076|  14.1k|    redraw_subs(mpctx);
 2077|       |
 2078|  14.1k|    if (watch_later)
  ------------------
  |  Branch (2078:9): [True: 0, False: 14.1k]
  ------------------
 2079|      0|        mp_delete_watch_later_conf(mpctx, mpctx->filename);
 2080|       |
 2081|  14.1k|    append_to_watch_history(mpctx);
 2082|       |
 2083|  14.1k|    if (mpctx->max_frames == 0) {
  ------------------
  |  Branch (2083:9): [True: 0, False: 14.1k]
  ------------------
 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|  14.1k|    if (opts->demuxer_cache_wait) {
  ------------------
  |  Branch (2090:9): [True: 0, False: 14.1k]
  ------------------
 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|  14.1k|    double play_start_pts = rel_time_to_abs(mpctx, opts->play_start);
 2105|       |
 2106|       |    // Backward playback -> start from end by default.
 2107|  14.1k|    if (play_start_pts == MP_NOPTS_VALUE && opts->play_dir < 0)
  ------------------
  |  |   39|  28.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2107:9): [True: 14.1k, False: 0]
  |  Branch (2107:45): [True: 216, False: 13.9k]
  ------------------
 2108|    216|        play_start_pts = get_start_time(mpctx, -1);
 2109|       |
 2110|  14.1k|    if (play_start_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  14.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2110:9): [True: 216, False: 13.9k]
  ------------------
 2111|    216|        queue_seek(mpctx, MPSEEK_ABSOLUTE, play_start_pts, MPSEEK_DEFAULT, 0);
 2112|    216|        execute_queued_seek(mpctx);
 2113|    216|    }
 2114|       |
 2115|  14.1k|    update_internal_pause_state(mpctx);
 2116|       |
 2117|  14.1k|    mpctx->error_playing = 0;
 2118|  14.1k|    mpctx->in_playloop = true;
 2119|  11.4M|    while (!mpctx->stop_play)
  ------------------
  |  Branch (2119:12): [True: 11.4M, False: 14.1k]
  ------------------
 2120|  11.4M|        run_playloop(mpctx);
 2121|  14.1k|    mpctx->in_playloop = false;
 2122|       |
 2123|  14.1k|    MP_VERBOSE(mpctx, "EOF code: %d\n", mpctx->stop_play);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 2124|       |
 2125|  16.1k|terminate_playback:
 2126|       |
 2127|  16.1k|    if (!mpctx->stop_play)
  ------------------
  |  Branch (2127:9): [True: 693, False: 15.4k]
  ------------------
 2128|    693|        mpctx->stop_play = PT_ERROR;
 2129|       |
 2130|  16.1k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (2130:9): [True: 11.6k, False: 4.51k]
  ------------------
 2131|  11.6k|        clear_audio_output_buffers(mpctx);
 2132|       |
 2133|  16.1k|    update_core_idle_state(mpctx);
 2134|       |
 2135|  16.1k|    if (mpctx->step_frames) {
  ------------------
  |  Branch (2135:9): [True: 237, False: 15.9k]
  ------------------
 2136|    237|        opts->pause = true;
 2137|    237|        m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
 2138|    237|    }
 2139|       |
 2140|  16.1k|    process_hooks(mpctx, "on_unload");
 2141|       |
 2142|       |    // time to uninit all, except global stuff:
 2143|  16.1k|    reinit_complex_filters(mpctx, true);
 2144|  16.1k|    uninit_audio_chain(mpctx);
 2145|  16.1k|    uninit_video_chain(mpctx);
 2146|  16.1k|    uninit_sub_all(mpctx);
 2147|  16.1k|    if (!opts->gapless_audio && !mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (2147:9): [True: 1, False: 16.1k]
  |  Branch (2147:33): [True: 1, False: 0]
  ------------------
 2148|      1|        uninit_audio_out(mpctx);
 2149|       |
 2150|  16.1k|    mpctx->playback_initialized = false;
 2151|       |
 2152|  16.1k|    uninit_demuxer(mpctx);
 2153|       |
 2154|       |    // Possibly stop ongoing async commands.
 2155|  16.1k|    mp_abort_playback_async(mpctx);
 2156|       |
 2157|  16.1k|    struct playlist_entry *current = mpctx->playlist->current;
 2158|  16.1k|    bool reloading = mpctx->stop_play == PT_CURRENT_ENTRY &&
  ------------------
  |  Branch (2158:22): [True: 1.29k, False: 14.8k]
  ------------------
 2159|  1.29k|                     current && current->reloading;
  ------------------
  |  Branch (2159:22): [True: 1.21k, False: 82]
  |  Branch (2159:33): [True: 0, False: 1.21k]
  ------------------
 2160|  16.1k|    if (current)
  ------------------
  |  Branch (2160:9): [True: 15.6k, False: 479]
  ------------------
 2161|  15.6k|        current->reloading = false;
 2162|  16.1k|    if (!reloading)
  ------------------
  |  Branch (2162:9): [True: 16.1k, False: 0]
  ------------------
 2163|  16.1k|        m_config_restore_backups(mpctx->mconfig);
 2164|       |
 2165|  16.1k|    TA_FREEP(&mpctx->filter_root);
  ------------------
  |  |   81|  16.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  16.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 16.1k]
  |  |  ------------------
  ------------------
 2166|  16.1k|    talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  16.1k|#define talloc_free                     ta_free
  ------------------
 2167|  16.1k|    mpctx->filtered_tags = NULL;
 2168|       |
 2169|  16.1k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 2170|       |
 2171|  16.1k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx))
  ------------------
  |  Branch (2171:9): [True: 0, False: 16.1k]
  ------------------
 2172|      0|        mpctx->stop_play = PT_ERROR;
 2173|       |
 2174|  16.1k|    if (mpctx->stop_play == PT_ERROR && !mpctx->error_playing)
  ------------------
  |  Branch (2174:9): [True: 690, False: 15.4k]
  |  Branch (2174:41): [True: 0, False: 690]
  ------------------
 2175|      0|        mpctx->error_playing = MPV_ERROR_GENERIC;
 2176|       |
 2177|  16.1k|    bool nothing_played = !mpctx->shown_aframes && !mpctx->shown_vframes &&
  ------------------
  |  Branch (2177:27): [True: 2.61k, False: 13.5k]
  |  Branch (2177:52): [True: 2.24k, False: 367]
  ------------------
 2178|  2.24k|                          mpctx->error_playing <= 0;
  ------------------
  |  Branch (2178:27): [True: 2.24k, False: 0]
  ------------------
 2179|  16.1k|    bool playlist_prev_continue = false;
 2180|  16.1k|    switch (mpctx->stop_play) {
  ------------------
  |  Branch (2180:13): [True: 16.1k, False: 0]
  ------------------
 2181|    690|    case PT_ERROR:
  ------------------
  |  Branch (2181:5): [True: 690, False: 15.4k]
  ------------------
 2182|  4.73k|    case AT_END_OF_FILE:
  ------------------
  |  Branch (2182:5): [True: 4.04k, False: 12.1k]
  ------------------
 2183|  4.73k|    {
 2184|  4.73k|        if (mpctx->error_playing == 0 && nothing_played)
  ------------------
  |  Branch (2184:13): [True: 4.04k, False: 692]
  |  Branch (2184:42): [True: 171, False: 3.87k]
  ------------------
 2185|    171|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2186|  4.73k|        if (mpctx->error_playing < 0) {
  ------------------
  |  Branch (2186:13): [True: 863, False: 3.87k]
  ------------------
 2187|    863|            end_event.error = mpctx->error_playing;
 2188|    863|            end_event.reason = MPV_END_FILE_REASON_ERROR;
 2189|  3.87k|        } else if (mpctx->error_playing == 2) {
  ------------------
  |  Branch (2189:20): [True: 0, False: 3.87k]
  ------------------
 2190|      0|            end_event.reason = MPV_END_FILE_REASON_REDIRECT;
 2191|  3.87k|        } else {
 2192|  3.87k|            end_event.reason = MPV_END_FILE_REASON_EOF;
 2193|  3.87k|        }
 2194|  4.73k|        if (mpctx->playing) {
  ------------------
  |  Branch (2194:13): [True: 4.73k, False: 0]
  ------------------
 2195|  4.73k|            mpctx->playing->init_failed = nothing_played;
 2196|  4.73k|            playlist_prev_continue = mpctx->playing->playlist_prev_attempt &&
  ------------------
  |  Branch (2196:38): [True: 92, False: 4.64k]
  ------------------
 2197|     92|                                     nothing_played;
  ------------------
  |  Branch (2197:38): [True: 92, False: 0]
  ------------------
 2198|  4.73k|            mpctx->playing->playlist_prev_attempt = false;
 2199|  4.73k|        }
 2200|  4.73k|        break;
 2201|    690|    }
 2202|       |    // Note that error_playing is meaningless in these cases.
 2203|      0|    case PT_NEXT_ENTRY:
  ------------------
  |  Branch (2203:5): [True: 0, False: 16.1k]
  ------------------
 2204|  1.29k|    case PT_CURRENT_ENTRY:
  ------------------
  |  Branch (2204:5): [True: 1.29k, False: 14.8k]
  ------------------
 2205|  1.43k|    case PT_STOP:           end_event.reason = MPV_END_FILE_REASON_STOP; break;
  ------------------
  |  Branch (2205:5): [True: 144, False: 16.0k]
  ------------------
 2206|  10.0k|    case PT_QUIT:           end_event.reason = MPV_END_FILE_REASON_QUIT; break;
  ------------------
  |  Branch (2206:5): [True: 10.0k, False: 6.17k]
  ------------------
 2207|  16.1k|    };
 2208|  16.1k|    mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event);
 2209|       |
 2210|  16.1k|    MP_VERBOSE(mpctx, "finished playback, %s (reason %d)\n",
  ------------------
  |  |   92|  16.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  16.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2211|  16.1k|               mpv_error_string(end_event.error), end_event.reason);
 2212|  16.1k|    if (end_event.error == MPV_ERROR_UNKNOWN_FORMAT)
  ------------------
  |  Branch (2212:9): [True: 24, False: 16.1k]
  ------------------
 2213|  16.1k|        MP_ERR(mpctx, "Failed to recognize file format.\n");
  ------------------
  |  |   89|     24|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     24|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2214|       |
 2215|  16.1k|    if (mpctx->playing)
  ------------------
  |  Branch (2215:9): [True: 16.1k, False: 0]
  ------------------
 2216|  16.1k|        playlist_entry_unref(mpctx->playing);
 2217|  16.1k|    mpctx->playing = NULL;
 2218|  16.1k|    talloc_free(mpctx->filename);
  ------------------
  |  |   47|  16.1k|#define talloc_free                     ta_free
  ------------------
 2219|  16.1k|    mpctx->filename = NULL;
 2220|  16.1k|    mpctx->stream_open_filename = NULL;
 2221|       |
 2222|  16.1k|    if (end_event.error < 0 && nothing_played) {
  ------------------
  |  Branch (2222:9): [True: 863, False: 15.3k]
  |  Branch (2222:32): [True: 860, False: 3]
  ------------------
 2223|    860|        mpctx->files_broken++;
 2224|  15.3k|    } else if (end_event.error < 0) {
  ------------------
  |  Branch (2224:16): [True: 3, False: 15.3k]
  ------------------
 2225|      3|        mpctx->files_errored++;
 2226|  15.3k|    } else {
 2227|  15.3k|        mpctx->files_played++;
 2228|  15.3k|    }
 2229|       |
 2230|  16.1k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  16.1k|#define mp_assert assert
  ------------------
  |  Branch (2230:5): [True: 16.1k, False: 0]
  ------------------
 2231|       |
 2232|  16.1k|    process_hooks(mpctx, "on_after_end_file");
 2233|       |
 2234|  16.1k|    if (playlist_prev_continue) {
  ------------------
  |  Branch (2234:9): [True: 92, False: 16.0k]
  ------------------
 2235|     92|        struct playlist_entry *e = mp_next_file(mpctx, -1, false, true);
 2236|     92|        if (e) {
  ------------------
  |  Branch (2236:13): [True: 0, False: 92]
  ------------------
 2237|      0|            mp_set_playlist_entry(mpctx, e);
 2238|      0|            play_current_file(mpctx);
 2239|      0|        }
 2240|     92|    }
 2241|  16.1k|}
loadfile.c:process_hooks:
 1225|  93.7k|{
 1226|  93.7k|    mp_hook_start(mpctx, name);
 1227|       |
 1228|  93.7k|    while (!mp_hook_test_completion(mpctx, name)) {
  ------------------
  |  Branch (1228:12): [True: 0, False: 93.7k]
  ------------------
 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|  93.7k|}
loadfile.c:load_per_file_options:
 1279|  16.1k|{
 1280|  16.1k|    for (int n = 0; n < params_count; n++) {
  ------------------
  |  Branch (1280:21): [True: 0, False: 16.1k]
  ------------------
 1281|      0|        m_config_set_option_cli(conf, params[n].name, params[n].value,
 1282|      0|                                M_SETOPT_BACKUP);
 1283|      0|    }
 1284|  16.1k|}
loadfile.c:open_demux_reentrant:
 1380|  16.1k|{
 1381|  16.1k|    char *url = mpctx->stream_open_filename;
 1382|       |
 1383|  16.1k|    if (mpctx->open_active) {
  ------------------
  |  Branch (1383:9): [True: 0, False: 16.1k]
  ------------------
 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|  16.1k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1410:9): [True: 16.1k, False: 0]
  ------------------
 1411|  16.1k|        start_open(mpctx, url, mpctx->playing->stream_flags, false);
 1412|       |
 1413|       |    // If thread failed to start, cancel the playback
 1414|  16.1k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1414:9): [True: 0, False: 16.1k]
  ------------------
 1415|      0|        goto cancel;
 1416|       |
 1417|       |    // User abort should cancel the opener now.
 1418|  16.1k|    mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort);
 1419|       |
 1420|  84.4k|    while (!atomic_load(&mpctx->open_done)) {
  ------------------
  |  Branch (1420:12): [True: 68.2k, False: 16.1k]
  ------------------
 1421|  68.2k|        mp_idle(mpctx);
 1422|       |
 1423|  68.2k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1423:13): [True: 3.04k, False: 65.2k]
  ------------------
 1424|  3.04k|            mp_abort_playback_async(mpctx);
 1425|  68.2k|    }
 1426|       |
 1427|  16.1k|    if (mpctx->open_res_demuxer) {
  ------------------
  |  Branch (1427:9): [True: 14.6k, False: 1.56k]
  ------------------
 1428|  14.6k|        mpctx->demuxer = mpctx->open_res_demuxer;
 1429|  14.6k|        mpctx->open_res_demuxer = NULL;
 1430|  14.6k|        mp_cancel_set_parent(mpctx->demuxer->cancel, mpctx->playback_abort);
 1431|  14.6k|    } else {
 1432|  1.56k|        mpctx->error_playing = mpctx->open_res_error;
 1433|  1.56k|    }
 1434|       |
 1435|  16.1k|cancel:
 1436|  16.1k|    cancel_open(mpctx); // cleanup
 1437|  16.1k|}
loadfile.c:load_external_opts:
 1715|  14.2k|{
 1716|  14.2k|    struct mp_waiter wait = MP_WAITER_INITIALIZER;
  ------------------
  |  |   19|  14.2k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  14.2k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  14.2k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  14.2k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  14.2k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  14.2k|    }
  ------------------
 1717|       |
 1718|  14.2k|    void *a[] = {mpctx, &wait};
 1719|  14.2k|    if (!mp_thread_pool_queue(mpctx->thread_pool, load_external_opts_thread, a)) {
  ------------------
  |  Branch (1719:9): [True: 0, False: 14.2k]
  ------------------
 1720|      0|        mpctx->stop_play = PT_ERROR;
 1721|      0|        return;
 1722|      0|    }
 1723|       |
 1724|  28.6k|    while (!mp_waiter_poll(&wait)) {
  ------------------
  |  Branch (1724:12): [True: 14.4k, False: 14.2k]
  ------------------
 1725|  14.4k|        mp_idle(mpctx);
 1726|       |
 1727|  14.4k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1727:13): [True: 35, False: 14.3k]
  ------------------
 1728|     35|            mp_abort_playback_async(mpctx);
 1729|  14.4k|    }
 1730|       |
 1731|  14.2k|    mp_waiter_wait(&wait);
 1732|  14.2k|}
loadfile.c:load_external_opts_thread:
 1695|  14.2k|{
 1696|  14.2k|    void **a = p;
 1697|  14.2k|    struct MPContext *mpctx = a[0];
 1698|  14.2k|    struct mp_waiter *waiter = a[1];
 1699|       |
 1700|  14.2k|    mp_core_lock(mpctx);
 1701|       |
 1702|  14.2k|    load_chapters(mpctx);
 1703|  14.2k|    open_external_files(mpctx, mpctx->opts->audio_files, STREAM_AUDIO);
 1704|  14.2k|    open_external_files(mpctx, mpctx->opts->sub_name, STREAM_SUB);
 1705|  14.2k|    open_external_files(mpctx, mpctx->opts->coverart_files, STREAM_VIDEO);
 1706|  14.2k|    open_external_files(mpctx, mpctx->opts->external_files, STREAM_TYPE_COUNT);
 1707|  14.2k|    autoload_external_files(mpctx, mpctx->playback_abort);
 1708|       |
 1709|  14.2k|    mp_waiter_wakeup(waiter, 0);
 1710|  14.2k|    mp_wakeup_core(mpctx);
 1711|  14.2k|    mp_core_unlock(mpctx);
 1712|  14.2k|}
loadfile.c:load_chapters:
 1240|  14.2k|{
 1241|  14.2k|    struct demuxer *src = mpctx->demuxer;
 1242|  14.2k|    bool free_src = false;
 1243|  14.2k|    char *chapter_file = mpctx->opts->chapter_file;
 1244|  14.2k|    if (chapter_file && chapter_file[0]) {
  ------------------
  |  Branch (1244:9): [True: 0, False: 14.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|  14.2k|    if (src && !mpctx->chapters) {
  ------------------
  |  Branch (1263:9): [True: 14.2k, False: 0]
  |  Branch (1263:16): [True: 14.2k, False: 0]
  ------------------
 1264|  14.2k|        talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  14.2k|#define talloc_free                     ta_free
  ------------------
 1265|  14.2k|        mpctx->num_chapters = src->num_chapters;
 1266|  14.2k|        mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters);
 1267|  14.2k|        if (mpctx->opts->rebase_start_time) {
  ------------------
  |  Branch (1267:13): [True: 14.2k, False: 0]
  ------------------
 1268|  14.2k|            for (int n = 0; n < mpctx->num_chapters; n++)
  ------------------
  |  Branch (1268:29): [True: 0, False: 14.2k]
  ------------------
 1269|      0|                mpctx->chapters[n].pts -= src->start_time;
 1270|  14.2k|        }
 1271|  14.2k|    }
 1272|  14.2k|    if (free_src)
  ------------------
  |  Branch (1272:9): [True: 0, False: 14.2k]
  ------------------
 1273|      0|        demux_cancel_and_free(src);
 1274|  14.2k|}
loadfile.c:open_external_files:
 1090|  56.9k|{
 1091|       |    // Need a copy, because the option value could be mutated during iteration.
 1092|  56.9k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  56.9k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  56.9k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1093|  56.9k|    files = mp_dup_str_array(tmp, files);
 1094|       |
 1095|  56.9k|    for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1095:21): [True: 4, False: 56.9k]
  |  Branch (1095:30): [True: 2, False: 2]
  ------------------
 1096|       |        // when given filter is set to video, we are loading up cover art
 1097|      2|        mp_add_external_file(mpctx, files[n], filter, mpctx->playback_abort,
 1098|      2|                             filter == STREAM_VIDEO ? TRACK_ATTACHED_PICTURE : 0);
  ------------------
  |  Branch (1098:30): [True: 2, False: 0]
  ------------------
 1099|       |
 1100|  56.9k|    talloc_free(tmp);
  ------------------
  |  |   47|  56.9k|#define talloc_free                     ta_free
  ------------------
 1101|  56.9k|}
loadfile.c:check_previous_track_selection:
  776|  14.2k|{
  777|  14.2k|    struct MPOpts *opts = mpctx->opts;
  778|       |
  779|  14.2k|    if (!mpctx->track_layout_hash)
  ------------------
  |  Branch (779:9): [True: 13.7k, False: 461]
  ------------------
  780|  13.7k|        return;
  781|       |
  782|    461|    char *h = track_layout_hash(mpctx);
  783|    461|    if (strcmp(h, mpctx->track_layout_hash) != 0) {
  ------------------
  |  Branch (783:9): [True: 48, False: 413]
  ------------------
  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|    192|        for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (786:25): [True: 144, False: 48]
  ------------------
  787|    336|            for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (787:29): [True: 192, False: 144]
  ------------------
  788|    192|                if (opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (788:21): [True: 48, False: 144]
  ------------------
  789|     48|                    mark_track_selection(mpctx, i, t, i == 0 ? -1 : -2);
  ------------------
  |  Branch (789:55): [True: 48, False: 0]
  ------------------
  790|    192|            }
  791|    144|        }
  792|     48|        talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|     48|#define talloc_free                     ta_free
  ------------------
  793|     48|        mpctx->track_layout_hash = NULL;
  794|     48|    }
  795|    461|    talloc_free(h);
  ------------------
  |  |   47|    461|#define talloc_free                     ta_free
  ------------------
  796|    461|}
loadfile.c:clear_playlist_paths:
 1452|  14.1k|{
 1453|       |    TA_FREEP(&mpctx->playlist_paths);
  ------------------
  |  |   81|  14.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  14.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 14.1k]
  |  |  ------------------
  ------------------
 1454|  14.1k|    mpctx->playlist_paths_len = 0;
 1455|  14.1k|}
loadfile.c:append_to_watch_history:
 1735|  14.1k|{
 1736|  14.1k|    if (!mpctx->opts->save_watch_history)
  ------------------
  |  Branch (1736:9): [True: 14.1k, False: 2]
  ------------------
 1737|  14.1k|        return;
 1738|       |
 1739|      2|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|      2|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      2|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1740|      2|    char *history_path = mp_get_user_path(ctx, mpctx->global,
 1741|      2|                                          mpctx->opts->watch_history_path);
 1742|      2|    char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
 1743|      2|    mp_mkdirp(history_path_dir);
 1744|       |
 1745|      2|    FILE *history_file = fopen(history_path, "ab");
  ------------------
  |  |   84|      2|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
 1746|      2|    if (!history_file) {
  ------------------
  |  Branch (1746:9): [True: 0, False: 2]
  ------------------
 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|      2|    char *title = (char *)mp_find_non_filename_media_title(mpctx);
 1753|       |
 1754|      2|    mpv_node_list *list = talloc_zero(ctx, mpv_node_list);
  ------------------
  |  |   27|      2|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      2|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      2|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|      2|    mpv_node node = {
 1756|      2|        .format = MPV_FORMAT_NODE_MAP,
 1757|      2|        .u.list = list,
 1758|      2|    };
 1759|      2|    list->num = title ? 3 : 2;
  ------------------
  |  Branch (1759:17): [True: 0, False: 2]
  ------------------
 1760|      2|    list->keys = talloc_array(ctx, char*, list->num);
  ------------------
  |  |   29|      2|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      2|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      2|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|      2|    list->values = talloc_array(ctx, mpv_node, list->num);
  ------------------
  |  |   29|      2|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      2|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      2|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1762|      2|    list->keys[0] = "time";
 1763|      2|    list->values[0] = (struct mpv_node) {
 1764|      2|        .format = MPV_FORMAT_INT64,
 1765|      2|        .u.int64 = time(NULL),
 1766|      2|    };
 1767|      2|    list->keys[1] = "path";
 1768|      2|    list->values[1] = (struct mpv_node) {
 1769|      2|        .format = MPV_FORMAT_STRING,
 1770|      2|        .u.string = mpctx->filename,
 1771|      2|    };
 1772|      2|    if (title) {
  ------------------
  |  Branch (1772:9): [True: 0, False: 2]
  ------------------
 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|      2|    bstr dst = {0};
 1781|      2|    json_append(&dst, &node, -1);
 1782|      2|    talloc_steal(ctx, dst.start);
  ------------------
  |  |   38|      2|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      2|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1783|      2|    if (!dst.len) {
  ------------------
  |  Branch (1783:9): [True: 0, False: 2]
  ------------------
 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|      2|    bstr_xappend0(ctx, &dst, "\n");
 1788|       |
 1789|      2|    int seek = fseek(history_file, 0, SEEK_END);
 1790|      2|    off_t history_size = ftell(history_file);
 1791|      2|    if (seek != 0 || history_size == -1) {
  ------------------
  |  Branch (1791:9): [True: 0, False: 2]
  |  Branch (1791:22): [True: 0, False: 2]
  ------------------
 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|      2|    bool failed = fwrite(dst.start, dst.len, 1, history_file) != 1 ||
  ------------------
  |  Branch (1797:19): [True: 0, False: 2]
  ------------------
 1798|      2|                  fflush(history_file) != 0;
  ------------------
  |  Branch (1798:19): [True: 0, False: 2]
  ------------------
 1799|       |
 1800|      2|    if (failed) {
  ------------------
  |  Branch (1800:9): [True: 0, False: 2]
  ------------------
 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|      2|done:
 1811|      2|    if (history_file != NULL && fclose(history_file) != 0)
  ------------------
  |  Branch (1811:9): [True: 2, False: 0]
  |  Branch (1811:33): [True: 0, False: 2]
  ------------------
 1812|      2|        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|      2|    talloc_free(ctx);
  ------------------
  |  |   47|      2|#define talloc_free                     ta_free
  ------------------
 1815|      2|}
loadfile.c:uninit_demuxer:
  193|  16.1k|{
  194|  64.7k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (194:21): [True: 48.5k, False: 16.1k]
  ------------------
  195|   113k|        for (int r = 0; r < num_ptracks[t]; r++)
  ------------------
  |  Branch (195:25): [True: 64.7k, False: 48.5k]
  ------------------
  196|  64.7k|            mpctx->current_track[r][t] = NULL;
  197|  48.5k|    }
  198|       |
  199|  16.1k|    talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  16.1k|#define talloc_free                     ta_free
  ------------------
  200|  16.1k|    mpctx->chapters = NULL;
  201|  16.1k|    mpctx->num_chapters = 0;
  202|       |
  203|  16.1k|    mp_abort_cache_dumping(mpctx);
  204|       |
  205|  16.1k|    struct demuxer **demuxers = NULL;
  206|  16.1k|    int num_demuxers = 0;
  207|       |
  208|  16.1k|    if (mpctx->demuxer)
  ------------------
  |  Branch (208:9): [True: 14.6k, False: 1.56k]
  ------------------
  209|  14.6k|        MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, mpctx->demuxer);
  ------------------
  |  |  105|  14.6k|    do {                                            \
  |  |  106|  14.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  14.6k|    do {                                            \
  |  |  |  |   97|  14.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  14.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  14.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  14.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  14.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  14.6k|    do {                                                        \
  |  |  |  |  |  |   89|  14.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  14.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  14.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  14.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  14.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  14.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  14.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  14.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 14.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  14.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  14.6k|        (idxvar)++;                                 \
  |  |  109|  14.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 14.6k]
  |  |  ------------------
  ------------------
  210|  16.1k|    mpctx->demuxer = NULL;
  211|       |
  212|  48.5k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (212:21): [True: 32.4k, False: 16.1k]
  ------------------
  213|  32.4k|        struct track *track = mpctx->tracks[i];
  214|       |
  215|  32.4k|        mp_assert(!track->dec && !track->d_sub);
  ------------------
  |  |   41|  32.4k|#define mp_assert assert
  ------------------
  |  Branch (215:9): [True: 32.4k, False: 0]
  |  Branch (215:9): [True: 32.4k, False: 0]
  ------------------
  216|  32.4k|        mp_assert(!track->vo_c && !track->ao_c);
  ------------------
  |  |   41|  32.4k|#define mp_assert assert
  ------------------
  |  Branch (216:9): [True: 32.4k, False: 0]
  |  Branch (216:9): [True: 32.4k, False: 0]
  ------------------
  217|  32.4k|        mp_assert(!track->sink);
  ------------------
  |  |   41|  32.4k|#define mp_assert assert
  ------------------
  |  Branch (217:9): [True: 32.4k, 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|  84.8k|        for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (221:25): [True: 80.9k, False: 3.91k]
  ------------------
  222|  80.9k|            if (demuxers[n] == track->demuxer) {
  ------------------
  |  Branch (222:17): [True: 28.4k, False: 52.4k]
  ------------------
  223|  28.4k|                track->demuxer = NULL;
  224|  28.4k|                break;
  225|  28.4k|            }
  226|  80.9k|        }
  227|  32.4k|        if (track->demuxer)
  ------------------
  |  Branch (227:13): [True: 3.91k, False: 28.4k]
  ------------------
  228|  3.91k|            MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, track->demuxer);
  ------------------
  |  |  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: 564, False: 3.35k]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.91k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    564|    do {                                                        \
  |  |  |  |  |  |   89|    564|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    564|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    564|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    564|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    564|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    564|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    564|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 564]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  ------------------
  ------------------
  229|       |
  230|  32.4k|        talloc_free(track);
  ------------------
  |  |   47|  32.4k|#define talloc_free                     ta_free
  ------------------
  231|  32.4k|    }
  232|  16.1k|    mpctx->num_tracks = 0;
  233|       |
  234|  16.1k|    kill_demuxers_reentrant(mpctx, demuxers, num_demuxers);
  235|  16.1k|    talloc_free(demuxers);
  ------------------
  |  |   47|  16.1k|#define talloc_free                     ta_free
  ------------------
  236|       |
  237|  16.1k|    disc_nav_reset(mpctx);
  238|  16.1k|}
loadfile.c:kill_demuxers_reentrant:
  135|  16.1k|{
  136|  16.1k|    struct demux_free_async_state **items = NULL;
  137|  16.1k|    int num_items = 0;
  138|       |
  139|  34.7k|    for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (139:21): [True: 18.5k, False: 16.1k]
  ------------------
  140|  18.5k|        struct demuxer *d = demuxers[n];
  141|       |
  142|  18.5k|        if (!demux_cancel_test(d)) {
  ------------------
  |  Branch (142:13): [True: 18.1k, False: 399]
  ------------------
  143|       |            // Make sure it is set if it wasn't yet.
  144|  18.1k|            demux_set_wakeup_cb(d, wakeup_demux, mpctx);
  145|       |
  146|  18.1k|            struct demux_free_async_state *item = demux_free_async(d);
  147|  18.1k|            if (item) {
  ------------------
  |  Branch (147:17): [True: 14.2k, False: 3.91k]
  ------------------
  148|  14.2k|                MP_TARRAY_APPEND(NULL, items, num_items, item);
  ------------------
  |  |  105|  14.2k|    do {                                            \
  |  |  106|  14.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  14.2k|    do {                                            \
  |  |  |  |   97|  14.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  14.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  14.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  14.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  14.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  14.2k|    do {                                                        \
  |  |  |  |  |  |   89|  14.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  14.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  14.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  14.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  14.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  14.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  14.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  14.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 14.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  14.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  14.2k|        (idxvar)++;                                 \
  |  |  109|  14.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 14.2k]
  |  |  ------------------
  ------------------
  149|  14.2k|                d = NULL;
  150|  14.2k|            }
  151|  18.1k|        }
  152|       |
  153|  18.5k|        demux_cancel_and_free(d);
  154|  18.5k|    }
  155|       |
  156|  16.1k|    if (!num_items)
  ------------------
  |  Branch (156:9): [True: 1.96k, False: 14.2k]
  ------------------
  157|  1.96k|        return;
  158|       |
  159|  14.2k|    MP_DBG(mpctx, "Terminating demuxers...\n");
  ------------------
  |  |   93|  14.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|       |
  161|  14.2k|    double end = mp_time_sec() + mpctx->opts->demux_termination_timeout;
  162|  14.2k|    bool force = false;
  163|  73.0k|    while (num_items) {
  ------------------
  |  Branch (163:12): [True: 58.7k, False: 14.2k]
  ------------------
  164|  58.7k|        double wait = end - mp_time_sec();
  165|       |
  166|   103k|        for (int n = 0; n < num_items; n++) {
  ------------------
  |  Branch (166:25): [True: 58.7k, False: 44.5k]
  ------------------
  167|  58.7k|            struct demux_free_async_state *item = items[n];
  168|  58.7k|            if (demux_free_async_finish(item)) {
  ------------------
  |  Branch (168:17): [True: 14.2k, False: 44.5k]
  ------------------
  169|  14.2k|                items[n] = items[num_items - 1];
  170|  14.2k|                num_items -= 1;
  171|  14.2k|                n--;
  172|  14.2k|                goto repeat;
  173|  44.5k|            } else if (wait < 0) {
  ------------------
  |  Branch (173:24): [True: 0, False: 44.5k]
  ------------------
  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|  58.7k|        }
  180|       |
  181|  44.5k|        if (wait >= 0)
  ------------------
  |  Branch (181:13): [True: 44.5k, False: 0]
  ------------------
  182|  44.5k|            mp_set_timeout(mpctx, wait);
  183|  44.5k|        mp_idle(mpctx);
  184|  58.7k|    repeat:;
  185|  58.7k|    }
  186|       |
  187|  14.2k|    talloc_free(items);
  ------------------
  |  |   47|  14.2k|#define talloc_free                     ta_free
  ------------------
  188|       |
  189|  14.2k|    MP_DBG(mpctx, "Done terminating demuxers.\n");
  ------------------
  |  |   93|  14.2k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  14.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  190|  14.2k|}
loadfile.c:cancel_open:
 1334|  44.0k|{
 1335|  44.0k|    if (mpctx->open_cancel)
  ------------------
  |  Branch (1335:9): [True: 16.1k, False: 27.8k]
  ------------------
 1336|  16.1k|        mp_cancel_trigger(mpctx->open_cancel);
 1337|       |
 1338|  44.0k|    if (mpctx->open_active)
  ------------------
  |  Branch (1338:9): [True: 16.1k, False: 27.8k]
  ------------------
 1339|  16.1k|        mp_thread_join(mpctx->open_thread);
  ------------------
  |  |  215|  16.1k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1340|  44.0k|    mpctx->open_active = false;
 1341|       |
 1342|  44.0k|    if (mpctx->open_res_demuxer)
  ------------------
  |  Branch (1342:9): [True: 0, False: 44.0k]
  ------------------
 1343|      0|        demux_cancel_and_free(mpctx->open_res_demuxer);
 1344|  44.0k|    mpctx->open_res_demuxer = NULL;
 1345|       |
 1346|  44.0k|    TA_FREEP(&mpctx->open_cancel);
  ------------------
  |  |   81|  44.0k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  44.0k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 44.0k]
  |  |  ------------------
  ------------------
 1347|  44.0k|    TA_FREEP(&mpctx->open_url);
  ------------------
  |  |   81|  44.0k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  44.0k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 44.0k]
  |  |  ------------------
  ------------------
 1348|  44.0k|    TA_FREEP(&mpctx->open_format);
  ------------------
  |  |   81|  44.0k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  44.0k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 44.0k]
  |  |  ------------------
  ------------------
 1349|       |
 1350|       |    atomic_store(&mpctx->open_done, false);
 1351|  44.0k|}

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

rel_time_to_abs:
   55|   791k|{
   56|   791k|    double length = get_time_length(mpctx);
   57|       |    // Relative times are an offset to the start of the file.
   58|   791k|    double start = 0;
   59|   791k|    if (mpctx->demuxer && !mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (59:9): [True: 791k, False: 0]
  |  Branch (59:27): [True: 0, False: 791k]
  ------------------
   60|      0|        start = mpctx->demuxer->start_time;
   61|       |
   62|   791k|    switch (t.type) {
  ------------------
  |  Branch (62:13): [True: 0, False: 791k]
  ------------------
   63|      0|    case REL_TIME_ABSOLUTE:
  ------------------
  |  Branch (63:5): [True: 0, False: 791k]
  ------------------
   64|      0|        return t.pos;
   65|      0|    case REL_TIME_RELATIVE:
  ------------------
  |  Branch (65:5): [True: 0, False: 791k]
  ------------------
   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: 791k]
  ------------------
   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: 791k]
  ------------------
   78|      0|        return chapter_start_time(mpctx, t.pos); // already absolute time
   79|   791k|    }
   80|       |
   81|   791k|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|   791k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   82|   791k|}
get_play_end_pts:
  100|   383k|{
  101|   383k|    double end = get_play_end_pts_setting(mpctx);
  102|   383k|    double ab[2];
  103|   383k|    if (mpctx->ab_loop_clip && get_ab_loop_times(mpctx, ab)) {
  ------------------
  |  Branch (103:9): [True: 193k, False: 189k]
  |  Branch (103:32): [True: 6.60k, False: 187k]
  ------------------
  104|  6.60k|        if (end == MP_NOPTS_VALUE || end > ab[1])
  ------------------
  |  |   39|  13.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (104:13): [True: 6.60k, False: 0]
  |  Branch (104:38): [True: 0, False: 0]
  ------------------
  105|  6.60k|            end = ab[1];
  106|  6.60k|    }
  107|   383k|    return end;
  108|   383k|}
get_play_start_pts:
  113|  10.9k|{
  114|  10.9k|    struct MPOpts *opts = mpctx->opts;
  115|  10.9k|    double res = rel_time_to_abs(mpctx, opts->play_start);
  116|  10.9k|    if (res == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  10.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (116:9): [True: 10.9k, False: 0]
  ------------------
  117|  10.9k|        res = get_start_time(mpctx, mpctx->play_dir);
  118|  10.9k|    return res;
  119|  10.9k|}
get_ab_loop_times:
  125|  8.28M|{
  126|  8.28M|    struct MPOpts *opts = mpctx->opts;
  127|  8.28M|    int dir = mpctx->play_dir;
  128|       |
  129|  8.28M|    t[0] = opts->ab_loop[0];
  130|  8.28M|    t[1] = opts->ab_loop[1];
  131|       |
  132|  8.28M|    if (!mpctx->remaining_ab_loops)
  ------------------
  |  Branch (132:9): [True: 931, False: 8.27M]
  ------------------
  133|    931|        return false;
  134|       |
  135|  8.27M|    if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|  16.5M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|  15.4M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (135:9): [True: 1.10M, False: 7.17M]
  |  Branch (135:35): [True: 1.02M, False: 6.15M]
  |  Branch (135:61): [True: 791k, False: 5.36M]
  ------------------
  136|  2.91M|        return false;
  137|       |
  138|  5.36M|    if (t[0] * dir > t[1] * dir)
  ------------------
  |  Branch (138:9): [True: 1.16M, False: 4.20M]
  ------------------
  139|  1.16M|        MPSWAP(double, t[0], t[1]);
  ------------------
  |  |   48|  1.16M|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 1.16M]
  |  |  ------------------
  ------------------
  140|       |
  141|       |    return true;
  142|  8.27M|}
get_track_seek_offset:
  145|  5.59M|{
  146|  5.59M|    struct MPOpts *opts = mpctx->opts;
  147|  5.59M|    if (track->selected) {
  ------------------
  |  Branch (147:9): [True: 5.00M, False: 591k]
  ------------------
  148|  5.00M|        if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (148:13): [True: 2.32M, False: 2.67M]
  ------------------
  149|  2.32M|            return -opts->audio_delay;
  150|  2.67M|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (150:13): [True: 166k, False: 2.50M]
  ------------------
  151|   166k|        {
  152|   166k|            for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (152:29): [True: 166k, False: 0]
  ------------------
  153|   166k|                if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (153:21): [True: 166k, False: 0]
  ------------------
  154|   166k|                    return -opts->subs_shared->sub_delay[n];
  155|   166k|            }
  156|   166k|        }
  157|  2.67M|    }
  158|  3.10M|    return 0;
  159|  5.59M|}
issue_refresh_seek:
  162|    551|{
  163|       |    // let queued seeks execute at a slightly later point
  164|    551|    if (mpctx->seek.type) {
  ------------------
  |  Branch (164:9): [True: 13, False: 538]
  ------------------
  165|     13|        mp_wakeup_core(mpctx);
  166|     13|        return;
  167|     13|    }
  168|       |    // repeat currently ongoing seeks
  169|    538|    if (mpctx->current_seek.type) {
  ------------------
  |  Branch (169:9): [True: 219, False: 319]
  ------------------
  170|    219|        mpctx->seek = mpctx->current_seek;
  171|    219|        mp_wakeup_core(mpctx);
  172|    219|        return;
  173|    219|    }
  174|    319|    queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx), min_prec, 0);
  175|    319|}
update_content_type:
  178|  32.8k|{
  179|  32.8k|    enum mp_content_type content_type;
  180|  32.8k|    if (!track || !track->vo_c) {
  ------------------
  |  Branch (180:9): [True: 2.55k, False: 30.2k]
  |  Branch (180:19): [True: 473, False: 29.8k]
  ------------------
  181|  3.02k|        content_type = MP_CONTENT_NONE;
  182|  29.8k|    } else if (track->image) {
  ------------------
  |  Branch (182:16): [True: 0, False: 29.8k]
  ------------------
  183|      0|        content_type = MP_CONTENT_IMAGE;
  184|  29.8k|    } else {
  185|  29.8k|        content_type = MP_CONTENT_VIDEO;
  186|  29.8k|    }
  187|  32.8k|    if (mpctx->video_out)
  ------------------
  |  Branch (187:9): [True: 32.8k, False: 0]
  ------------------
  188|  32.8k|        vo_control(mpctx->video_out, VOCTRL_CONTENT_TYPE, &content_type);
  189|  32.8k|}
update_vo_playback_state:
  192|  2.98M|{
  193|  2.98M|    if (mpctx->video_out && mpctx->video_out->config_ok) {
  ------------------
  |  Branch (193:9): [True: 2.64M, False: 336k]
  |  Branch (193:29): [True: 1.53M, False: 1.11M]
  ------------------
  194|  1.53M|        struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
  195|  1.53M|        double pos = get_current_pos_ratio(mpctx, false);
  196|  1.53M|        struct voctrl_playback_state newstate = {
  197|  1.53M|            .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
  ------------------
  |  Branch (197:33): [True: 1.53M, False: 9]
  |  Branch (197:70): [True: 1.50M, False: 26.7k]
  ------------------
  198|  1.53M|            .playing = mpctx->playing,
  199|  1.53M|            .paused = mpctx->paused,
  200|  1.53M|            .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
  ------------------
  |  Branch (200:25): [True: 375k, False: 1.15M]
  ------------------
  201|  1.53M|        };
  202|       |
  203|  1.53M|        bool state_changed = oldstate.taskbar_progress != newstate.taskbar_progress ||
  ------------------
  |  Branch (203:30): [True: 10.9k, False: 1.52M]
  ------------------
  204|  1.52M|                             oldstate.playing != newstate.playing ||
  ------------------
  |  Branch (204:30): [True: 11.5k, False: 1.51M]
  ------------------
  205|  1.51M|                             oldstate.paused != newstate.paused;
  ------------------
  |  Branch (205:30): [True: 12.9k, False: 1.49M]
  ------------------
  206|  1.53M|        if (state_changed || oldstate.position != newstate.position) {
  ------------------
  |  Branch (206:13): [True: 35.4k, False: 1.49M]
  |  Branch (206:30): [True: 183k, False: 1.31M]
  ------------------
  207|       |            // Don't update progress bar if it was and still is hidden
  208|   218k|            if ((oldstate.playing && oldstate.taskbar_progress) ||
  ------------------
  |  Branch (208:18): [True: 204k, False: 14.1k]
  |  Branch (208:38): [True: 198k, False: 6.27k]
  ------------------
  209|  20.4k|                (newstate.playing && newstate.taskbar_progress))
  ------------------
  |  Branch (209:18): [True: 20.1k, False: 220]
  |  Branch (209:38): [True: 8.82k, False: 11.3k]
  ------------------
  210|   207k|            {
  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|   207k|                int64_t now = mp_time_ns();
  218|   207k|                int64_t elapsed = now - mpctx->vo_playback_state_time;
  219|   207k|                if (!state_changed && elapsed < MP_TIME_MS_TO_NS(1000))
  ------------------
  |  |   72|   183k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  |  Branch (219:21): [True: 183k, False: 23.8k]
  |  Branch (219:39): [True: 183k, False: 4]
  ------------------
  220|   183k|                    return;
  221|  23.8k|                mpctx->vo_playback_state_time = now;
  222|  23.8k|                vo_control_async(mpctx->video_out,
  223|  23.8k|                                 VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
  224|  23.8k|            }
  225|  35.4k|            mpctx->vo_playback_state = newstate;
  226|  35.4k|        }
  227|  1.53M|    } else {
  228|  1.44M|        mpctx->vo_playback_state = (struct voctrl_playback_state){ 0 };
  229|  1.44M|    }
  230|  2.98M|}
update_window_title:
  233|  3.02M|{
  234|  3.02M|    if (!mpctx->video_out && !mpctx->ao) {
  ------------------
  |  Branch (234:9): [True: 336k, False: 2.69M]
  |  Branch (234:30): [True: 270k, False: 65.9k]
  ------------------
  235|   270k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|   270k|#define talloc_free                     ta_free
  ------------------
  236|   270k|        mpctx->last_window_title = NULL;
  237|   270k|        return;
  238|   270k|    }
  239|  2.75M|    char *title = mp_property_expand_string(mpctx, mpctx->opts->wintitle);
  240|  2.75M|    if (!mpctx->last_window_title || force ||
  ------------------
  |  Branch (240:9): [True: 14.1k, False: 2.74M]
  |  Branch (240:38): [True: 33.6k, False: 2.71M]
  ------------------
  241|  2.71M|        strcmp(title, mpctx->last_window_title) != 0)
  ------------------
  |  Branch (241:9): [True: 271, False: 2.71M]
  ------------------
  242|  48.1k|    {
  243|  48.1k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  48.1k|#define talloc_free                     ta_free
  ------------------
  244|  48.1k|        mpctx->last_window_title = talloc_steal(mpctx, title);
  ------------------
  |  |   38|  48.1k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  48.1k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  245|       |
  246|  48.1k|        if (mpctx->video_out)
  ------------------
  |  Branch (246:13): [True: 47.8k, False: 242]
  ------------------
  247|  47.8k|            vo_control(mpctx->video_out, VOCTRL_UPDATE_WINDOW_TITLE, title);
  248|       |
  249|  48.1k|        if (mpctx->ao) {
  ------------------
  |  Branch (249:13): [True: 29.9k, False: 18.1k]
  ------------------
  250|  29.9k|            ao_control(mpctx->ao, AOCONTROL_UPDATE_STREAM_TITLE, title);
  251|  29.9k|        }
  252|  2.71M|    } else {
  253|  2.71M|        talloc_free(title);
  ------------------
  |  |   47|  2.71M|#define talloc_free                     ta_free
  ------------------
  254|  2.71M|    }
  255|  2.75M|}
error_on_track:
  258|  18.8k|{
  259|  18.8k|    if (!track || !track->selected)
  ------------------
  |  Branch (259:9): [True: 18.8k, False: 15]
  |  Branch (259:19): [True: 0, False: 15]
  ------------------
  260|  18.8k|        return;
  261|     15|    int order = -1;
  262|     15|    for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (262:21): [True: 15, False: 0]
  ------------------
  263|     15|        if (mpctx->current_track[t][track->type] == track) {
  ------------------
  |  Branch (263:13): [True: 15, False: 0]
  ------------------
  264|     15|            order = t;
  265|     15|            break;
  266|     15|        }
  267|     15|    }
  268|       |    // Select the next best track, if the current one failed to initialize.
  269|     15|    if (order >= 0 && track->dec_failed && mpctx->opts->stream_auto_sel &&
  ------------------
  |  Branch (269:9): [True: 15, False: 0]
  |  Branch (269:23): [True: 0, False: 15]
  |  Branch (269:44): [True: 0, False: 0]
  ------------------
  270|      0|        mpctx->opts->stream_id[order][track->type] == -1)
  ------------------
  |  Branch (270:9): [True: 0, False: 0]
  ------------------
  271|      0|    {
  272|      0|        struct track *next = select_default_track(mpctx, order, track->type);
  273|      0|        if (next) {
  ------------------
  |  Branch (273:13): [True: 0, False: 0]
  ------------------
  274|      0|            MP_WARN(mpctx, "Falling back to %s track %d.\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__)
  |  |  ------------------
  ------------------
  275|      0|                    stream_type_name(track->type), next->user_tid);
  276|      0|            mp_switch_track_n(mpctx, order, track->type, next, 0);
  277|      0|            if (mpctx->current_track[order][track->type] != track)
  ------------------
  |  Branch (277:17): [True: 0, False: 0]
  ------------------
  278|      0|                return;
  279|      0|        }
  280|      0|    }
  281|     15|    mp_deselect_track(mpctx, track);
  282|     15|    if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (282:9): [True: 10, False: 5]
  ------------------
  283|     15|        MP_INFO(mpctx, "Audio: no audio\n");
  ------------------
  |  |   91|     10|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     10|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  284|     15|    if (track->type == STREAM_VIDEO)
  ------------------
  |  Branch (284:9): [True: 5, False: 10]
  ------------------
  285|     15|        MP_INFO(mpctx, "Video: no video\n");
  ------------------
  |  |   91|      5|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|     15|    if (mpctx->opts->stop_playback_on_init_failure ||
  ------------------
  |  Branch (286:9): [True: 0, False: 15]
  ------------------
  287|     15|        (!mpctx->current_track[0][STREAM_AUDIO] &&
  ------------------
  |  Branch (287:10): [True: 10, False: 5]
  ------------------
  288|     10|         !mpctx->current_track[0][STREAM_VIDEO]))
  ------------------
  |  Branch (288:10): [True: 1, False: 9]
  ------------------
  289|      1|    {
  290|      1|        if (!mpctx->stop_play)
  ------------------
  |  Branch (290:13): [True: 1, False: 0]
  ------------------
  291|      1|            mpctx->stop_play = PT_ERROR;
  292|      1|        if (mpctx->error_playing >= 0)
  ------------------
  |  Branch (292:13): [True: 0, False: 1]
  ------------------
  293|      0|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
  294|      1|    }
  295|     15|    mp_wakeup_core(mpctx);
  296|     15|}
mp_status_str:
  375|  10.7M|{
  376|  10.7M|    switch (st) {
  377|  5.02M|    case STATUS_SYNCING:    return "syncing";
  ------------------
  |  Branch (377:5): [True: 5.02M, False: 5.76M]
  ------------------
  378|    954|    case STATUS_READY:      return "ready";
  ------------------
  |  Branch (378:5): [True: 954, False: 10.7M]
  ------------------
  379|  49.3k|    case STATUS_PLAYING:    return "playing";
  ------------------
  |  Branch (379:5): [True: 49.3k, False: 10.7M]
  ------------------
  380|   907k|    case STATUS_DRAINING:   return "draining";
  ------------------
  |  Branch (380:5): [True: 907k, False: 9.88M]
  ------------------
  381|  4.80M|    case STATUS_EOF:        return "eof";
  ------------------
  |  Branch (381:5): [True: 4.80M, False: 5.98M]
  ------------------
  382|      0|    default:                return "bug";
  ------------------
  |  Branch (382:5): [True: 0, False: 10.7M]
  ------------------
  383|  10.7M|    }
  384|  10.7M|}
mp_format_track_metadata:
  392|   179k|{
  393|   179k|    struct sh_stream *s = t->stream;
  394|   179k|    bstr dst = {0};
  395|       |
  396|   179k|    if (t->title)
  ------------------
  |  Branch (396:9): [True: 35, False: 179k]
  ------------------
  397|     35|        bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title);
  398|       |
  399|   179k|    bstr_xappend0(ctx, &dst, "(");
  400|       |
  401|   179k|    if (add_lang && t->lang)
  ------------------
  |  Branch (401:9): [True: 14.5k, False: 164k]
  |  Branch (401:21): [True: 8, False: 14.5k]
  ------------------
  402|      8|        bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang);
  403|       |
  404|   179k|    if (s) {
  ------------------
  |  Branch (404:9): [True: 179k, False: 0]
  ------------------
  405|   179k|        demux_append_codec_desc(ctx, &dst, s, NULL);
  406|   179k|    } else {
  407|      0|        bstr_xappend0(ctx, &dst, "<unknown>");
  408|      0|    }
  409|   179k|    bstr_xappend0(ctx, &dst, ")");
  410|       |
  411|   179k|    bool first = true;
  412|   179k|    if (t->default_track)
  ------------------
  |  Branch (412:9): [True: 0, False: 179k]
  ------------------
  413|      0|        ADD_FLAG(ctx, dst, "default", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  414|   179k|    if (t->forced_track)
  ------------------
  |  Branch (414:9): [True: 0, False: 179k]
  ------------------
  415|      0|        ADD_FLAG(ctx, dst, "forced", first);
  ------------------
  |  |  386|      0|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|      0|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    first = false;                                                     \
  |  |  389|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  416|   179k|    if (t->dependent_track)
  ------------------
  |  Branch (416:9): [True: 0, False: 179k]
  ------------------
  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|   179k|    if (t->visual_impaired_track)
  ------------------
  |  Branch (418:9): [True: 0, False: 179k]
  ------------------
  419|      0|        ADD_FLAG(ctx, dst, "visual-impaired", 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]
  |  |  ------------------
  ------------------
  420|   179k|    if (t->hearing_impaired_track)
  ------------------
  |  Branch (420:9): [True: 0, False: 179k]
  ------------------
  421|      0|        ADD_FLAG(ctx, dst, "hearing-impaired", 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]
  |  |  ------------------
  ------------------
  422|   179k|    if (t->original_track)
  ------------------
  |  Branch (422:9): [True: 0, False: 179k]
  ------------------
  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|   179k|    if (t->commentary_track)
  ------------------
  |  Branch (424:9): [True: 0, False: 179k]
  ------------------
  425|      0|        ADD_FLAG(ctx, dst, "commentary", 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]
  |  |  ------------------
  ------------------
  426|   179k|    if (t->is_external)
  ------------------
  |  Branch (426:9): [True: 66.3k, False: 112k]
  ------------------
  427|  66.3k|        ADD_FLAG(ctx, dst, "external", first);
  ------------------
  |  |  386|  66.3k|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|  66.3k|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 66.3k, False: 0]
  |  |  ------------------
  |  |  388|  66.3k|    first = false;                                                     \
  |  |  389|  66.3k|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 66.3k]
  |  |  ------------------
  ------------------
  428|   179k|    if (!first)
  ------------------
  |  Branch (428:9): [True: 66.3k, False: 112k]
  ------------------
  429|  66.3k|        bstr_xappend0(ctx, &dst, "]");
  430|       |
  431|   179k|    return bstrto0(ctx, dst);
  432|   179k|}
mp_find_non_filename_media_title:
  435|  27.8M|{
  436|  27.8M|    const char *name = mpctx->opts->media_title;
  437|  27.8M|    if (name && name[0])
  ------------------
  |  Branch (437:9): [True: 0, False: 27.8M]
  |  Branch (437:17): [True: 0, False: 0]
  ------------------
  438|      0|        return name;
  439|  27.8M|    if (mpctx->demuxer) {
  ------------------
  |  Branch (439:9): [True: 27.7M, False: 147k]
  ------------------
  440|  27.7M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
  441|  27.7M|        if (name && name[0])
  ------------------
  |  Branch (441:13): [True: 0, False: 27.7M]
  |  Branch (441:21): [True: 0, False: 0]
  ------------------
  442|      0|            return name;
  443|  27.7M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
  444|  27.7M|        if (name && name[0])
  ------------------
  |  Branch (444:13): [True: 0, False: 27.7M]
  |  Branch (444:21): [True: 0, False: 0]
  ------------------
  445|      0|            return name;
  446|  27.7M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
  447|  27.7M|        if (name && name[0])
  ------------------
  |  Branch (447:13): [True: 0, False: 27.7M]
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|      0|            return name;
  449|  27.7M|    }
  450|  27.8M|    if (mpctx->playing && mpctx->playing->title)
  ------------------
  |  Branch (450:9): [True: 27.8M, False: 15.4k]
  |  Branch (450:27): [True: 0, False: 27.8M]
  ------------------
  451|      0|        return mpctx->playing->title;
  452|  27.8M|    if (mpctx->demuxer && mpctx->demuxer->server_filename)
  ------------------
  |  Branch (452:9): [True: 27.7M, False: 147k]
  |  Branch (452:27): [True: 0, False: 27.7M]
  ------------------
  453|      0|        return mpctx->demuxer->server_filename;
  454|  27.8M|    return NULL;
  455|  27.8M|}
misc.c:get_play_end_pts_setting:
   85|   383k|{
   86|   383k|    struct MPOpts *opts = mpctx->opts;
   87|   383k|    double end = rel_time_to_abs(mpctx, opts->play_end);
   88|   383k|    double length = rel_time_to_abs(mpctx, opts->play_length);
   89|   383k|    if (length != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   383k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (89:9): [True: 0, False: 383k]
  ------------------
   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|   383k|    return end;
   95|   383k|}

term_osd_clear_subs:
  123|  2.75M|{
  124|  2.75M|    term_osd_set_subs(mpctx, NULL, 0);
  125|       |    term_osd_set_subs(mpctx, NULL, 1);
  126|  2.75M|}
term_osd_set_subs:
  129|  5.53M|{
  130|  5.53M|    if (mpctx->video_out || !text || !mpctx->opts->subs_shared->sub_visibility[order])
  ------------------
  |  Branch (130:9): [True: 5.05M, False: 478k]
  |  Branch (130:29): [True: 453k, False: 25.4k]
  |  Branch (130:38): [True: 0, False: 25.4k]
  ------------------
  131|  5.50M|        text = ""; // disable
  132|  5.53M|    if (strcmp(mpctx->term_osd_subs[order] ? mpctx->term_osd_subs[order] : "", text) == 0)
  ------------------
  |  Branch (132:9): [True: 5.53M, False: 860]
  |  Branch (132:16): [True: 1.53k, False: 5.53M]
  ------------------
  133|  5.53M|        return;
  134|    860|    talloc_replace(mpctx, mpctx->term_osd_subs[order], text);
  ------------------
  |  |   54|    860|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|    860|    do {                                                \
  |  |  |  |  107|    860|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 55, False: 805]
  |  |  |  |  ------------------
  |  |  |  |  108|     55|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|    805|        } else {                                        \
  |  |  |  |  110|    805|            *(str) = '\0';                              \
  |  |  |  |  111|    805|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|    805|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|    805|        }                                               \
  |  |  |  |  113|    860|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 860]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|    860|    term_osd_update(mpctx);
  136|    860|}
set_osd_msg:
  331|   295k|{
  332|   295k|    va_list ap;
  333|   295k|    va_start(ap, fmt);
  334|   295k|    bool r = set_osd_msg_va(mpctx, level, time, fmt, ap);
  335|       |    va_end(ap);
  336|   295k|    return r;
  337|   295k|}
set_osd_bar:
  342|  17.3k|{
  343|  17.3k|    struct MPOpts *opts = mpctx->opts;
  344|  17.3k|    bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (344:22): [True: 10.2k, False: 7.04k]
  |  Branch (344:42): [True: 10.2k, False: 0]
  ------------------
  345|  17.3k|    if (opts->osd_level < 1 || !opts->osd_bar_visible || !video_osd)
  ------------------
  |  Branch (345:9): [True: 0, False: 17.3k]
  |  Branch (345:32): [True: 16, False: 17.2k]
  |  Branch (345:58): [True: 7.03k, False: 10.2k]
  ------------------
  346|  7.05k|        return;
  347|       |
  348|  10.2k|    mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0;
  349|  10.2k|    mpctx->osd_progbar.type = type;
  350|  10.2k|    mpctx->osd_progbar.value = (val - min) / (max - min);
  351|  10.2k|    mpctx->osd_progbar.num_stops = 0;
  352|  10.2k|    if (neutral > min && neutral < max) {
  ------------------
  |  Branch (352:9): [True: 750, False: 9.50k]
  |  Branch (352:26): [True: 750, False: 0]
  ------------------
  353|    750|        float pos = (neutral - min) / (max - min);
  354|    750|        MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
  ------------------
  |  |  105|    750|    do {                                            \
  |  |  106|    750|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    750|    do {                                            \
  |  |  |  |   97|    750|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    750|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    750|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    750|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 110, False: 640]
  |  |  |  |  ------------------
  |  |  |  |   99|    750|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    110|    do {                                                        \
  |  |  |  |  |  |   89|    110|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    110|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    110|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    110|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    110|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    110|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    110|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 110]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    750|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 750]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    750|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    750|        (idxvar)++;                                 \
  |  |  109|    750|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 750]
  |  |  ------------------
  ------------------
  355|    750|                         mpctx->osd_progbar.num_stops, pos);
  356|    750|    }
  357|  10.2k|    osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  358|  10.2k|    mp_wakeup_core(mpctx);
  359|  10.2k|}
set_osd_bar_chapters:
  377|  56.7k|{
  378|  56.7k|    if (mpctx->osd_progbar.type != type)
  ------------------
  |  Branch (378:9): [True: 32.7k, False: 24.0k]
  ------------------
  379|  32.7k|        return;
  380|       |
  381|  24.0k|    mpctx->osd_progbar.num_stops = 0;
  382|  24.0k|    double len = get_time_length(mpctx);
  383|  24.0k|    if (len > 0) {
  ------------------
  |  Branch (383:9): [True: 12.1k, False: 11.9k]
  ------------------
  384|       |        // Always render the loop points, even if they're incomplete.
  385|  12.1k|        double ab[2];
  386|  12.1k|        bool valid = get_ab_loop_times(mpctx, ab);
  387|  36.5k|        for (int n = 0; n < 2; n++) {
  ------------------
  |  Branch (387:25): [True: 24.3k, False: 12.1k]
  ------------------
  388|  24.3k|            if (ab[n] != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  24.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (388:17): [True: 9.64k, False: 14.7k]
  ------------------
  389|  9.64k|                MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
  ------------------
  |  |  105|  9.64k|    do {                                            \
  |  |  106|  9.64k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  9.64k|    do {                                            \
  |  |  |  |   97|  9.64k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  9.64k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  9.64k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  9.64k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 464, False: 9.18k]
  |  |  |  |  ------------------
  |  |  |  |   99|  9.64k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    464|    do {                                                        \
  |  |  |  |  |  |   89|    464|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    464|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    464|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    464|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    464|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    464|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    464|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 464]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  9.64k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 9.64k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  9.64k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  9.64k|        (idxvar)++;                                 \
  |  |  109|  9.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.64k]
  |  |  ------------------
  ------------------
  390|  9.64k|                                 mpctx->osd_progbar.num_stops, ab[n] / len);
  391|  9.64k|            }
  392|  24.3k|        }
  393|  12.1k|        if (!valid) {
  ------------------
  |  Branch (393:13): [True: 10.3k, False: 1.84k]
  ------------------
  394|  10.3k|            int num = get_chapter_count(mpctx);
  395|  10.3k|            for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (395:29): [True: 0, False: 10.3k]
  ------------------
  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|  10.3k|        }
  404|  12.1k|    }
  405|  24.0k|    osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  406|  24.0k|    mp_wakeup_core(mpctx);
  407|  24.0k|}
set_osd_function:
  411|  2.68M|{
  412|  2.68M|    struct MPOpts *opts = mpctx->opts;
  413|       |
  414|  2.68M|    mpctx->osd_function = osd_function;
  415|  2.68M|    mpctx->osd_function_visible = mp_time_sec() + opts->osd_duration / 1000.0;
  416|       |    mpctx->osd_force_update = true;
  417|  2.68M|    mp_wakeup_core(mpctx);
  418|  2.68M|}
get_current_osd_sym:
  421|  44.4k|{
  422|  44.4k|    int sym = mpctx->osd_function;
  423|  44.4k|    if (!sym) {
  ------------------
  |  Branch (423:9): [True: 3.28k, False: 41.1k]
  ------------------
  424|  3.28k|        if (is_busy(mpctx) || (mpctx->paused_for_cache && !mpctx->opts->pause)) {
  ------------------
  |  Branch (424:13): [True: 68, False: 3.21k]
  |  Branch (424:32): [True: 0, False: 3.21k]
  |  Branch (424:59): [True: 0, False: 0]
  ------------------
  425|     68|            sym = OSD_CLOCK;
  426|  3.21k|        } else if (mpctx->paused || mpctx->step_frames) {
  ------------------
  |  Branch (426:20): [True: 2.52k, False: 695]
  |  Branch (426:37): [True: 524, False: 171]
  ------------------
  427|  3.04k|            sym = OSD_PAUSE;
  428|  3.04k|        } else if (mpctx->play_dir < 0 ) {
  ------------------
  |  Branch (428:20): [True: 113, False: 58]
  ------------------
  429|    113|            sym = OSD_REV;
  430|    113|        } else {
  431|     58|            sym = OSD_PLAY;
  432|     58|        }
  433|  3.28k|    }
  434|  44.4k|    osd_get_function_sym(buf, buf_size, sym);
  435|  44.4k|}
update_osd_msg:
  503|  11.7M|{
  504|  11.7M|    struct MPOpts *opts = mpctx->opts;
  505|  11.7M|    struct osd_state *osd = mpctx->osd;
  506|       |
  507|  11.7M|    double now = mp_time_sec();
  508|       |
  509|  11.7M|    if (!mpctx->osd_force_update) {
  ------------------
  |  Branch (509:9): [True: 8.74M, False: 2.96M]
  ------------------
  510|       |        // Assume nothing is going on at all.
  511|  8.74M|        if (!mpctx->osd_idle_update)
  ------------------
  |  Branch (511:13): [True: 21.3k, False: 8.72M]
  ------------------
  512|  21.3k|            return;
  513|       |
  514|  8.72M|        double delay = 0.050; // update the OSD at most this often
  515|  8.72M|        double diff = now - mpctx->osd_last_update;
  516|  8.72M|        if (diff < delay) {
  ------------------
  |  Branch (516:13): [True: 8.71M, False: 13.4k]
  ------------------
  517|  8.71M|            mp_set_timeout(mpctx, delay - diff);
  518|  8.71M|            return;
  519|  8.71M|        }
  520|  8.72M|    }
  521|  2.98M|    mpctx->osd_force_update = false;
  522|  2.98M|    mpctx->osd_idle_update = false;
  523|  2.98M|    mpctx->osd_last_update = now;
  524|       |
  525|  2.98M|    if (mpctx->osd_visible) {
  ------------------
  |  Branch (525:9): [True: 1.75M, False: 1.22M]
  ------------------
  526|  1.75M|        double sleep = mpctx->osd_visible - now;
  527|  1.75M|        if (sleep > 0) {
  ------------------
  |  Branch (527:13): [True: 1.75M, False: 53]
  ------------------
  528|  1.75M|            mp_set_timeout(mpctx, sleep);
  529|  1.75M|            mpctx->osd_idle_update = true;
  530|  1.75M|        } else {
  531|     53|            mpctx->osd_visible = 0;
  532|     53|            mpctx->osd_progbar.type = -1; // disable
  533|     53|            osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  534|     53|        }
  535|  1.75M|    }
  536|       |
  537|  2.98M|    if (mpctx->osd_function_visible) {
  ------------------
  |  Branch (537:9): [True: 2.77M, False: 204k]
  ------------------
  538|  2.77M|        double sleep = mpctx->osd_function_visible - now;
  539|  2.77M|        if (sleep > 0) {
  ------------------
  |  Branch (539:13): [True: 2.77M, False: 27]
  ------------------
  540|  2.77M|            mp_set_timeout(mpctx, sleep);
  541|  2.77M|            mpctx->osd_idle_update = true;
  542|  2.77M|        } else {
  543|     27|            mpctx->osd_function_visible = 0;
  544|     27|            mpctx->osd_function = 0;
  545|     27|        }
  546|  2.77M|    }
  547|       |
  548|  2.98M|    if (mpctx->osd_msg_next_duration > 0) {
  ------------------
  |  Branch (548:9): [True: 228k, False: 2.75M]
  ------------------
  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|   228k|        mpctx->osd_msg_visible = now + mpctx->osd_msg_next_duration;
  552|   228k|        mpctx->osd_msg_next_duration = 0;
  553|   228k|    }
  554|       |
  555|  2.98M|    if (mpctx->osd_msg_visible) {
  ------------------
  |  Branch (555:9): [True: 2.86M, False: 112k]
  ------------------
  556|  2.86M|        double sleep = mpctx->osd_msg_visible - now;
  557|  2.86M|        if (sleep > 0) {
  ------------------
  |  Branch (557:13): [True: 2.86M, False: 205]
  ------------------
  558|  2.86M|            mp_set_timeout(mpctx, sleep);
  559|  2.86M|            mpctx->osd_idle_update = true;
  560|  2.86M|        } else {
  561|    205|            talloc_free(mpctx->osd_msg_text);
  ------------------
  |  |   47|    205|#define talloc_free                     ta_free
  ------------------
  562|    205|            mpctx->osd_msg_text = NULL;
  563|    205|            mpctx->osd_msg_visible = 0;
  564|    205|            mpctx->osd_show_pos = false;
  565|    205|        }
  566|  2.86M|    }
  567|       |
  568|  2.98M|    add_seek_osd_messages(mpctx);
  569|       |
  570|  2.98M|    if (mpctx->osd_progbar.type == OSD_BAR_SEEK) {
  ------------------
  |  Branch (570:9): [True: 1.73M, False: 1.24M]
  ------------------
  571|  1.73M|        double pos = get_current_pos_ratio(mpctx, false);
  572|  1.73M|        update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, MPCLAMP(pos, 0, 1));
  ------------------
  |  |   46|  1.73M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 68.8k, False: 1.67M]
  |  |  |  Branch (46:56): [True: 0, False: 1.67M]
  |  |  ------------------
  ------------------
  573|  1.73M|    }
  574|       |
  575|  2.98M|    term_osd_set_text_lazy(mpctx, mpctx->osd_msg_text);
  576|  2.98M|    term_osd_print_status_lazy(mpctx);
  577|  2.98M|    term_osd_update(mpctx);
  578|       |
  579|  2.98M|    if (!opts->video_osd)
  ------------------
  |  Branch (579:9): [True: 0, False: 2.98M]
  ------------------
  580|      0|        return;
  581|       |
  582|  2.98M|    int osd_level = opts->osd_level;
  583|  2.98M|    if (mpctx->osd_show_pos)
  ------------------
  |  Branch (583:9): [True: 44.4k, False: 2.93M]
  ------------------
  584|  44.4k|        osd_level = 3;
  585|       |
  586|  2.98M|    char *text = NULL;
  587|  2.98M|    sadd_osd_status(&text, mpctx, osd_level);
  588|  2.98M|    if (mpctx->osd_msg_text && mpctx->osd_msg_text[0]) {
  ------------------
  |  Branch (588:9): [True: 2.86M, False: 112k]
  |  Branch (588:32): [True: 2.82M, False: 44.4k]
  ------------------
  589|  2.82M|        text = talloc_asprintf_append(text, "%s%s", text ? "\n" : "",
  ------------------
  |  |   63|  2.82M|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (589:53): [True: 32, False: 2.82M]
  ------------------
  590|  2.82M|                                      mpctx->osd_msg_text);
  591|  2.82M|    }
  592|  2.98M|    osd_set_text(osd, text);
  593|  2.98M|    talloc_free(text);
  ------------------
  |  |   47|  2.98M|#define talloc_free                     ta_free
  ------------------
  594|  2.98M|}
osd.c:term_osd_update:
   76|  2.98M|{
   77|  2.98M|    int num_parts = 0;
   78|  2.98M|    char *parts[4] = {0};
   79|       |
   80|  2.98M|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (80:9): [True: 2.96M, False: 21.2k]
  ------------------
   81|  2.96M|        return;
   82|       |
   83|  21.2k|    if (!term_osd_empty(mpctx->term_osd_subs[0]))
  ------------------
  |  Branch (83:9): [True: 151, False: 21.0k]
  ------------------
   84|    151|        parts[num_parts++] = mpctx->term_osd_subs[0];
   85|  21.2k|    if (!term_osd_empty(mpctx->term_osd_subs[1]))
  ------------------
  |  Branch (85:9): [True: 0, False: 21.2k]
  ------------------
   86|      0|        parts[num_parts++] = mpctx->term_osd_subs[1];
   87|  21.2k|    if (!term_osd_empty(mpctx->term_osd_text))
  ------------------
  |  Branch (87:9): [True: 10.7k, False: 10.5k]
  ------------------
   88|  10.7k|        parts[num_parts++] = mpctx->term_osd_text;
   89|  21.2k|    if (!term_osd_empty(mpctx->term_osd_status))
  ------------------
  |  Branch (89:9): [True: 11.7k, False: 9.45k]
  ------------------
   90|  11.7k|        parts[num_parts++] = mpctx->term_osd_status;
   91|       |
   92|  21.2k|    char *s = join_lines(mpctx, parts, num_parts);
   93|       |
   94|  21.2k|    if (strcmp(mpctx->term_osd_contents, s) == 0 &&
  ------------------
  |  Branch (94:9): [True: 11.3k, False: 9.86k]
  ------------------
   95|  11.3k|        mp_msg_has_status_line(mpctx->global))
  ------------------
  |  Branch (95:9): [True: 10.5k, False: 824]
  ------------------
   96|  10.5k|    {
   97|  10.5k|        talloc_free(s);
  ------------------
  |  |   47|  10.5k|#define talloc_free                     ta_free
  ------------------
   98|  10.6k|    } else {
   99|  10.6k|        talloc_free(mpctx->term_osd_contents);
  ------------------
  |  |   47|  10.6k|#define talloc_free                     ta_free
  ------------------
  100|  10.6k|        mpctx->term_osd_contents = s;
  101|  10.6k|        mp_msg(mpctx->statusline, MSGL_STATUS, "%s", s);
  102|  10.6k|    }
  103|  21.2k|}
osd.c:term_osd_empty:
   71|  84.9k|{
   72|  84.9k|    return !text || !text[0] || !strcmp(text, TERM_MSG_0);
  ------------------
  |  |   30|  22.6k|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  22.6k|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  |  Branch (72:12): [True: 42.5k, False: 42.4k]
  |  Branch (72:21): [True: 19.7k, False: 22.6k]
  |  Branch (72:33): [True: 0, False: 22.6k]
  ------------------
   73|  84.9k|}
osd.c:join_lines:
   63|  21.2k|{
   64|  21.2k|    char *res = talloc_strdup(ta_ctx, "");
  ------------------
  |  |   50|  21.2k|#define talloc_strdup                   ta_xstrdup
  ------------------
   65|  43.9k|    for (int n = 0; n < num_parts; n++)
  ------------------
  |  Branch (65:21): [True: 22.6k, False: 21.2k]
  ------------------
   66|  22.6k|        res = talloc_asprintf_append(res, "%s%s", n ? "\n" : "", parts[n]);
  ------------------
  |  |   63|  22.6k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  |  Branch (66:51): [True: 2.33k, False: 20.3k]
  ------------------
   67|  21.2k|    return res;
   68|  21.2k|}
osd.c:set_osd_msg_va:
  314|   295k|{
  315|   295k|    if (level > mpctx->opts->osd_level)
  ------------------
  |  Branch (315:9): [True: 12, False: 295k]
  ------------------
  316|     12|        return false;
  317|       |
  318|   295k|    talloc_free(mpctx->osd_msg_text);
  ------------------
  |  |   47|   295k|#define talloc_free                     ta_free
  ------------------
  319|   295k|    mpctx->osd_msg_text = talloc_vasprintf(mpctx, fmt, ap);
  ------------------
  |  |   53|   295k|#define talloc_vasprintf                ta_xvasprintf
  |  |  ------------------
  |  |  |  |  128|   295k|#define ta_xvasprintf(...)              ta_oom_s(ta_vasprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  320|   295k|    mpctx->osd_show_pos = false;
  321|   295k|    mpctx->osd_msg_next_duration = time / 1000.0;
  322|   295k|    mpctx->osd_force_update = true;
  323|   295k|    mp_wakeup_core(mpctx);
  324|   295k|    if (mpctx->osd_msg_next_duration <= 0)
  ------------------
  |  Branch (324:9): [True: 0, False: 295k]
  ------------------
  325|      0|        mpctx->osd_msg_visible = mp_time_sec();
  326|       |    return true;
  327|   295k|}
osd.c:is_busy:
  176|  14.2k|{
  177|  14.2k|    return !mpctx->restart_complete && mp_time_sec() - mpctx->start_timestamp > 0.3;
  ------------------
  |  Branch (177:12): [True: 5.72k, False: 8.52k]
  |  Branch (177:40): [True: 93, False: 5.63k]
  ------------------
  178|  14.2k|}
osd.c:add_seek_osd_messages:
  472|  2.98M|{
  473|  2.98M|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
  ------------------
  |  Branch (473:9): [True: 16.0k, False: 2.96M]
  ------------------
  474|  16.0k|        double pos = get_current_pos_ratio(mpctx, false);
  475|  16.0k|        set_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, 0, MPCLAMP(pos, 0, 1));
  ------------------
  |  |   46|  16.0k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 6.50k, False: 9.49k]
  |  |  |  Branch (46:56): [True: 0, False: 9.49k]
  |  |  ------------------
  ------------------
  476|  16.0k|        set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
  477|  16.0k|    }
  478|  2.98M|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
  ------------------
  |  Branch (478:9): [True: 8.16k, False: 2.97M]
  ------------------
  479|       |        // Never in term-osd mode
  480|  8.16k|        bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (480:26): [True: 2.43k, False: 5.73k]
  |  Branch (480:46): [True: 2.43k, False: 0]
  ------------------
  481|  8.16k|        if (video_osd && mpctx->opts->term_osd != 1) {
  ------------------
  |  Branch (481:13): [True: 2.43k, False: 5.73k]
  |  Branch (481:26): [True: 2.43k, False: 0]
  ------------------
  482|  2.43k|            if (set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, ""))
  ------------------
  |  Branch (482:17): [True: 2.43k, False: 0]
  ------------------
  483|  2.43k|                mpctx->osd_show_pos = true;
  484|  2.43k|        }
  485|  8.16k|    }
  486|  2.98M|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) {
  ------------------
  |  Branch (486:9): [True: 8, False: 2.98M]
  ------------------
  487|      8|        char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx));
  488|      8|        set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
  489|      8|                     "Chapter: %s", chapter);
  490|      8|        talloc_free(chapter);
  ------------------
  |  |   47|      8|#define talloc_free                     ta_free
  ------------------
  491|      8|    }
  492|  2.98M|    if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CURRENT_FILE) {
  ------------------
  |  Branch (492:9): [True: 0, False: 2.98M]
  ------------------
  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|  2.98M|    mpctx->add_osd_seek_info = 0;
  499|  2.98M|}
osd.c:update_osd_bar:
  365|  1.73M|{
  366|  1.73M|    if (mpctx->osd_progbar.type != type)
  ------------------
  |  Branch (366:9): [True: 0, False: 1.73M]
  ------------------
  367|      0|        return;
  368|       |
  369|  1.73M|    float new_value = (val - min) / (max - min);
  370|  1.73M|    if (new_value != mpctx->osd_progbar.value) {
  ------------------
  |  Branch (370:9): [True: 9.04k, False: 1.73M]
  ------------------
  371|  9.04k|        mpctx->osd_progbar.value = new_value;
  372|  9.04k|        osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
  373|  9.04k|    }
  374|  1.73M|}
osd.c:term_osd_set_text_lazy:
  139|  2.98M|{
  140|  2.98M|    bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
  ------------------
  |  Branch (140:22): [True: 2.64M, False: 336k]
  |  Branch (140:42): [True: 2.64M, False: 0]
  ------------------
  141|  2.98M|    if ((video_osd && mpctx->opts->term_osd != 1) || !text)
  ------------------
  |  Branch (141:10): [True: 2.64M, False: 336k]
  |  Branch (141:23): [True: 2.64M, False: 0]
  |  Branch (141:54): [True: 23.7k, False: 312k]
  ------------------
  142|  2.66M|        text = ""; // disable
  143|  2.98M|    talloc_replace(mpctx, mpctx->term_osd_text, text);
  ------------------
  |  |   54|  2.98M|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  2.98M|    do {                                                \
  |  |  |  |  107|  2.98M|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 11.6k, False: 2.96M]
  |  |  |  |  ------------------
  |  |  |  |  108|  11.6k|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  2.96M|        } else {                                        \
  |  |  |  |  110|  2.96M|            *(str) = '\0';                              \
  |  |  |  |  111|  2.96M|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|  2.96M|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|  2.96M|        }                                               \
  |  |  |  |  113|  2.98M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 2.98M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|  2.98M|}
osd.c:term_osd_print_status_lazy:
  281|  2.98M|{
  282|  2.98M|    struct MPOpts *opts = mpctx->opts;
  283|       |
  284|  2.98M|    term_osd_update_title(mpctx);
  285|  2.98M|    update_window_title(mpctx, false);
  286|  2.98M|    update_vo_playback_state(mpctx);
  287|       |
  288|  2.98M|    if (!opts->use_terminal)
  ------------------
  |  Branch (288:9): [True: 2.95M, False: 21.0k]
  ------------------
  289|  2.95M|        return;
  290|       |
  291|  21.0k|    if (opts->quiet || !mpctx->playback_initialized || !mpctx->playing_msg_shown)
  ------------------
  |  Branch (291:9): [True: 0, False: 21.0k]
  |  Branch (291:24): [True: 9.18k, False: 11.8k]
  |  Branch (291:56): [True: 932, False: 10.9k]
  ------------------
  292|  10.1k|    {
  293|  10.1k|        if (!mpctx->playing)
  ------------------
  |  Branch (293:13): [True: 5.20k, False: 4.91k]
  ------------------
  294|  5.20k|            term_osd_set_status_lazy(mpctx, "");
  295|  10.1k|        return;
  296|  10.1k|    }
  297|       |
  298|  10.9k|    char *line = get_term_status_msg(mpctx);
  299|       |
  300|  10.9k|    if (opts->term_osd_bar) {
  ------------------
  |  Branch (300:9): [True: 0, False: 10.9k]
  ------------------
  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|  10.9k|    term_osd_set_status_lazy(mpctx, line);
  308|  10.9k|    talloc_free(line);
  ------------------
  |  |   47|  10.9k|#define talloc_free                     ta_free
  ------------------
  309|  10.9k|}
osd.c:term_osd_update_title:
  106|  2.98M|{
  107|  2.98M|    if (!mpctx->opts->use_terminal)
  ------------------
  |  Branch (107:9): [True: 2.95M, False: 21.0k]
  ------------------
  108|  2.95M|        return;
  109|       |
  110|  21.0k|    char *s = mp_property_expand_escaped_string(mpctx, mpctx->opts->term_title);
  111|  21.0k|    bstr title = bstr0(s);
  112|  21.0k|    mp_msg_sanitize(&title, false);
  113|  21.0k|    if (bstr_equals(title, bstr0(mpctx->term_osd_title))) {
  ------------------
  |  Branch (113:9): [True: 21.0k, False: 0]
  ------------------
  114|  21.0k|        talloc_free(s);
  ------------------
  |  |   47|  21.0k|#define talloc_free                     ta_free
  ------------------
  115|  21.0k|        return;
  116|  21.0k|    }
  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:term_osd_set_status_lazy:
  147|  16.1k|{
  148|  16.1k|    talloc_replace(mpctx, mpctx->term_osd_status, text);
  ------------------
  |  |   54|  16.1k|#define talloc_replace                  ta_replace
  |  |  ------------------
  |  |  |  |  106|  16.1k|    do {                                                \
  |  |  |  |  107|  16.1k|        if (!(str)) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:13): [True: 412, False: 15.7k]
  |  |  |  |  ------------------
  |  |  |  |  108|    412|            (str) = ta_xstrdup((ta_parent), (replace)); \
  |  |  |  |  109|  15.7k|        } else {                                        \
  |  |  |  |  110|  15.7k|            *(str) = '\0';                              \
  |  |  |  |  111|  15.7k|            ta_xstrdup_append(&(str), (replace));       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|  15.7k|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  112|  15.7k|        }                                               \
  |  |  |  |  113|  16.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (113:14): [Folded, False: 16.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|  16.1k|}
osd.c:get_term_status_msg:
  181|  10.9k|{
  182|  10.9k|    struct MPOpts *opts = mpctx->opts;
  183|       |
  184|  10.9k|    if (opts->status_msg)
  ------------------
  |  Branch (184:9): [True: 0, False: 10.9k]
  ------------------
  185|      0|        return mp_expand_term_status_msg(mpctx);
  186|       |
  187|  10.9k|    char *line = NULL;
  188|       |
  189|       |    // Playback status
  190|  10.9k|    if (is_busy(mpctx)) {
  ------------------
  |  Branch (190:9): [True: 25, False: 10.9k]
  ------------------
  191|     25|        saddf(&line, "(...) ");
  ------------------
  |  |   47|     25|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|     25|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  192|  10.9k|    } else if (mpctx->paused_for_cache && !opts->pause) {
  ------------------
  |  Branch (192:16): [True: 0, False: 10.9k]
  |  Branch (192:43): [True: 0, False: 0]
  ------------------
  193|      0|        saddf(&line, "(Buffering) ");
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  194|  10.9k|    } else if (mpctx->paused) {
  ------------------
  |  Branch (194:16): [True: 8.10k, False: 2.82k]
  ------------------
  195|  8.10k|        saddf(&line, "(Paused) ");
  ------------------
  |  |   47|  8.10k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  8.10k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  196|  8.10k|    }
  197|       |
  198|  10.9k|    if (mpctx->ao_chain)
  ------------------
  |  Branch (198:9): [True: 10.3k, False: 621]
  ------------------
  199|  10.3k|        saddf(&line, "A");
  ------------------
  |  |   47|  10.3k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  10.3k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  200|  10.9k|    if (mpctx->vo_chain)
  ------------------
  |  Branch (200:9): [True: 9.26k, False: 1.69k]
  ------------------
  201|  9.26k|        saddf(&line, "V");
  ------------------
  |  |   47|  9.26k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  9.26k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  202|  10.9k|    saddf(&line, ": ");
  ------------------
  |  |   47|  10.9k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  10.9k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  203|       |
  204|       |    // Playback position
  205|  10.9k|    sadd_hhmmssff(&line, get_playback_time(mpctx), opts->osd_fractions);
  206|  10.9k|    saddf(&line, " / ");
  ------------------
  |  |   47|  10.9k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  10.9k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  207|  10.9k|    sadd_hhmmssff(&line, get_time_length(mpctx), opts->osd_fractions);
  208|       |
  209|  10.9k|    sadd_percentage(&line, get_current_pos_ratio(mpctx, false));
  210|       |
  211|       |    // other
  212|  10.9k|    if (opts->playback_speed != 1)
  ------------------
  |  Branch (212:9): [True: 2.06k, False: 8.89k]
  ------------------
  213|  2.06k|        saddf(&line, " x%4.2f", opts->playback_speed);
  ------------------
  |  |   47|  2.06k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  2.06k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  214|       |
  215|       |    // A-V sync
  216|  10.9k|    if (mpctx->ao_chain && mpctx->vo_chain && !mpctx->vo_chain->is_sparse) {
  ------------------
  |  Branch (216:9): [True: 10.3k, False: 621]
  |  Branch (216:28): [True: 8.75k, False: 1.58k]
  |  Branch (216:47): [True: 8.75k, False: 0]
  ------------------
  217|  8.75k|        saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
  ------------------
  |  |   47|  8.75k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  8.75k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  218|  8.75k|        if (fabs(mpctx->total_avsync_change) > 0.05)
  ------------------
  |  Branch (218:13): [True: 0, False: 8.75k]
  ------------------
  219|      0|            saddf(&line, " ct:%7.3f", mpctx->total_avsync_change);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  220|  8.75k|    }
  221|       |
  222|  10.9k|    double position = get_current_pos_ratio(mpctx, true);
  223|  10.9k|    char lavcbuf[80];
  224|  10.9k|    if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf),
  ------------------
  |  Branch (224:9): [True: 0, False: 10.9k]
  ------------------
  225|  10.9k|            position) >= 0)
  226|      0|    {
  227|       |        // encoding stats
  228|      0|        saddf(&line, " %s", lavcbuf);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  229|  10.9k|    } else {
  230|       |        // VO stats
  231|  10.9k|        if (mpctx->vo_chain) {
  ------------------
  |  Branch (231:13): [True: 9.26k, False: 1.69k]
  ------------------
  232|  9.26k|            if (mpctx->display_sync_active) {
  ------------------
  |  Branch (232:17): [True: 0, False: 9.26k]
  ------------------
  233|      0|                char *r = mp_property_expand_string(mpctx,
  234|      0|                                            "${?vsync-ratio:${>vsync-ratio}}");
  235|      0|                if (r[0]) {
  ------------------
  |  Branch (235:21): [True: 0, False: 0]
  ------------------
  236|      0|                    saddf(&line, " DS: %s/%"PRId64, r,
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  237|      0|                          vo_get_delayed_count(mpctx->video_out));
  238|      0|                }
  239|      0|                talloc_free(r);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  240|      0|            }
  241|  9.26k|            int64_t c = vo_get_drop_count(mpctx->video_out);
  242|  9.26k|            struct mp_decoder_wrapper *dec = mpctx->vo_chain->track
  ------------------
  |  Branch (242:46): [True: 9.26k, False: 0]
  ------------------
  243|  9.26k|                                        ? mpctx->vo_chain->track->dec : NULL;
  244|  9.26k|            int dropped_frames =
  245|  9.26k|                dec ? mp_decoder_wrapper_get_frames_dropped(dec) : 0;
  ------------------
  |  Branch (245:17): [True: 9.26k, False: 0]
  ------------------
  246|  9.26k|            if (c > 0 || dropped_frames > 0) {
  ------------------
  |  Branch (246:17): [True: 0, False: 9.26k]
  |  Branch (246:26): [True: 0, False: 9.26k]
  ------------------
  247|      0|                saddf(&line, " Dropped: %"PRId64, c);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  248|      0|                if (dropped_frames)
  ------------------
  |  Branch (248:21): [True: 0, False: 0]
  ------------------
  249|      0|                    saddf(&line, "/%d", dropped_frames);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  250|      0|            }
  251|  9.26k|        }
  252|  10.9k|    }
  253|       |
  254|  10.9k|    if (mpctx->demuxer && demux_is_network_cached(mpctx->demuxer)) {
  ------------------
  |  Branch (254:9): [True: 10.9k, False: 0]
  |  Branch (254:27): [True: 0, False: 10.9k]
  ------------------
  255|      0|        saddf(&line, " Cache: ");
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  256|       |
  257|      0|        struct demux_reader_state s;
  258|      0|        demux_get_reader_state(mpctx->demuxer, &s);
  259|       |
  260|      0|        if (s.ts_info.duration < 0) {
  ------------------
  |  Branch (260:13): [True: 0, False: 0]
  ------------------
  261|      0|            saddf(&line, "???");
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  262|      0|        } else if (s.ts_info.duration < 10) {
  ------------------
  |  Branch (262:20): [True: 0, False: 0]
  ------------------
  263|      0|            saddf(&line, "%2.1fs", s.ts_info.duration);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  264|      0|        } else {
  265|      0|            saddf(&line, "%2ds", (int)s.ts_info.duration);
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  266|      0|        }
  267|      0|        int64_t cache_size = s.fw_bytes;
  268|      0|        if (cache_size > 0) {
  ------------------
  |  Branch (268:13): [True: 0, False: 0]
  ------------------
  269|      0|            if (cache_size >= 1024 * 1024) {
  ------------------
  |  Branch (269:17): [True: 0, False: 0]
  ------------------
  270|      0|                saddf(&line, "/%lldMB", (long long)(cache_size / 1024 / 1024));
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  271|      0|            } else {
  272|      0|                saddf(&line, "/%lldKB", (long long)(cache_size / 1024));
  ------------------
  |  |   47|      0|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  273|      0|            }
  274|      0|        }
  275|      0|    }
  276|       |
  277|  10.9k|    return line;
  278|  10.9k|}
osd.c:sadd_hhmmssff:
   51|   110k|{
   52|   110k|    char *s = mp_format_time(time, fractions);
   53|   110k|    *buf = talloc_strdup_append(*buf, s);
  ------------------
  |  |   57|   110k|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
   54|   110k|    talloc_free(s);
  ------------------
  |  |   47|   110k|#define talloc_free                     ta_free
  ------------------
   55|   110k|}
osd.c:sadd_percentage:
   57|  55.3k|static void sadd_percentage(char **buf, double ratio) {
   58|  55.3k|    if (ratio >= 0)
  ------------------
  |  Branch (58:9): [True: 53.8k, False: 1.52k]
  ------------------
   59|  53.8k|        *buf = talloc_asprintf_append(*buf, " (%.f%%)", ratio * 100);
  ------------------
  |  |   63|  53.8k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
   60|  55.3k|}
osd.c:sadd_osd_status:
  438|  2.98M|{
  439|  2.98M|    mp_assert(level >= 0 && level <= 3);
  ------------------
  |  |   41|  2.98M|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 2.98M, False: 0]
  |  Branch (439:5): [True: 2.98M, False: 0]
  ------------------
  440|  2.98M|    if (level == 0)
  ------------------
  |  Branch (440:9): [True: 0, False: 2.98M]
  ------------------
  441|      0|        return;
  442|  2.98M|    char *msg = mpctx->opts->osd_msg[level - 1];
  443|       |
  444|  2.98M|    if (msg && msg[0]) {
  ------------------
  |  Branch (444:9): [True: 0, False: 2.98M]
  |  Branch (444:16): [True: 0, False: 0]
  ------------------
  445|      0|        char *text = mp_property_expand_escaped_string(mpctx, msg);
  446|      0|        *buffer = talloc_strdup_append(*buffer, text);
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  447|      0|        talloc_free(text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  448|  2.98M|    } else if (level >= 2) {
  ------------------
  |  Branch (448:16): [True: 44.4k, False: 2.93M]
  ------------------
  449|  44.4k|        bool fractions = mpctx->opts->osd_fractions;
  450|  44.4k|        char sym[10];
  451|  44.4k|        get_current_osd_sym(mpctx, sym, sizeof(sym));
  452|  44.4k|        saddf(buffer, "%s ", sym);
  ------------------
  |  |   47|  44.4k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  44.4k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  453|  44.4k|        char *custom_msg = mpctx->opts->osd_status_msg;
  454|  44.4k|        if (custom_msg && level == 3) {
  ------------------
  |  Branch (454:13): [True: 0, False: 44.4k]
  |  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|  44.4k|        } else {
  459|  44.4k|            sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions);
  460|  44.4k|            if (level == 3) {
  ------------------
  |  Branch (460:17): [True: 44.4k, False: 32]
  ------------------
  461|  44.4k|                saddf(buffer, " / ");
  ------------------
  |  |   47|  44.4k|#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
  |  |  ------------------
  |  |  |  |   63|  44.4k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  |  |  ------------------
  ------------------
  462|  44.4k|                sadd_hhmmssff(buffer, get_time_length(mpctx), fractions);
  463|       |                sadd_percentage(buffer, get_current_pos_ratio(mpctx, false));
  464|  44.4k|            }
  465|  44.4k|        }
  466|  44.4k|    }
  467|  2.98M|}

mp_wait_events:
   55|  11.6M|{
   56|  11.6M|    mp_client_send_property_changes(mpctx);
   57|       |
   58|  11.6M|    stats_event(mpctx->stats, "iterations");
   59|       |
   60|  11.6M|    bool sleeping = mpctx->sleeptime > 0;
   61|  11.6M|    if (sleeping)
  ------------------
  |  Branch (61:9): [True: 9.17M, False: 2.50M]
  ------------------
   62|  11.6M|        MP_STATS(mpctx, "start sleep");
  ------------------
  |  |   99|  9.17M|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.17M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   63|       |
   64|  11.6M|    mp_dispatch_queue_process(mpctx->dispatch, mpctx->sleeptime);
   65|       |
   66|  11.6M|    mpctx->sleeptime = INFINITY;
   67|       |
   68|  11.6M|    if (sleeping)
  ------------------
  |  Branch (68:9): [True: 9.17M, False: 2.50M]
  ------------------
   69|  11.6M|        MP_STATS(mpctx, "end sleep");
  ------------------
  |  |   99|  9.17M|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  9.17M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   70|  11.6M|}
mp_set_timeout:
   76|  54.3M|{
   77|  54.3M|    if (mpctx->sleeptime > sleeptime) {
  ------------------
  |  Branch (77:9): [True: 23.5M, False: 30.7M]
  ------------------
   78|  23.5M|        mpctx->sleeptime = sleeptime;
   79|  23.5M|        int64_t abstime = mp_time_ns_add(mp_time_ns(), sleeptime);
   80|  23.5M|        mp_dispatch_adjust_timeout(mpctx->dispatch, abstime);
   81|  23.5M|    }
   82|  54.3M|}
mp_wakeup_core:
   88|  35.7M|{
   89|  35.7M|    mp_dispatch_interrupt(mpctx->dispatch);
   90|  35.7M|}
mp_wakeup_core_cb:
   94|  8.42M|{
   95|  8.42M|    struct MPContext *mpctx = ctx;
   96|  8.42M|    mp_wakeup_core(mpctx);
   97|  8.42M|}
mp_core_lock:
  100|   229k|{
  101|   229k|    mp_dispatch_lock(mpctx->dispatch);
  102|   229k|}
mp_core_unlock:
  105|   229k|{
  106|   229k|    mp_dispatch_unlock(mpctx->dispatch);
  107|   229k|}
handle_option_callbacks:
  128|  11.6M|{
  129|  11.6M|    for (int i = 0; i < mpctx->num_option_callbacks; i++)
  ------------------
  |  Branch (129:21): [True: 11.6k, False: 11.6M]
  ------------------
  130|  11.6k|        mp_option_run_callback(mpctx, &mpctx->option_callbacks[i]);
  131|  11.6M|    mpctx->num_option_callbacks = 0;
  132|  11.6M|}
get_relative_time:
  135|  5.06M|{
  136|  5.06M|    int64_t new_time = mp_time_ns();
  137|  5.06M|    int64_t delta = new_time - mpctx->last_time;
  138|  5.06M|    mpctx->last_time = new_time;
  139|  5.06M|    return delta * 1e-9;
  140|  5.06M|}
update_core_idle_state:
  143|  19.6M|{
  144|  19.6M|    bool eof = mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (144:16): [True: 11.8M, False: 7.74M]
  ------------------
  145|  11.8M|               mpctx->audio_status == STATUS_EOF;
  ------------------
  |  Branch (145:16): [True: 4.53M, False: 7.32M]
  ------------------
  146|  19.6M|    bool active = !mpctx->paused && mpctx->restart_complete &&
  ------------------
  |  Branch (146:19): [True: 991k, False: 18.6M]
  |  Branch (146:37): [True: 230k, False: 761k]
  ------------------
  147|   230k|                  !mpctx->stop_play && mpctx->in_playloop && !eof;
  ------------------
  |  Branch (147:19): [True: 228k, False: 1.89k]
  |  Branch (147:40): [True: 228k, False: 0]
  |  Branch (147:62): [True: 56.7k, False: 171k]
  ------------------
  148|       |
  149|  19.6M|    if (mpctx->playback_active != active) {
  ------------------
  |  Branch (149:9): [True: 45.9k, False: 19.5M]
  ------------------
  150|  45.9k|        mpctx->playback_active = active;
  151|       |
  152|  45.9k|        update_screensaver_state(mpctx);
  153|  45.9k|        mp_set_idle_power_mode(!active);
  154|       |
  155|       |        mp_notify(mpctx, MP_EVENT_CORE_IDLE, NULL);
  156|  45.9k|    }
  157|  19.6M|}
get_internal_paused:
  160|  5.51M|{
  161|  5.51M|    return mpctx->opts->pause || mpctx->paused_for_cache;
  ------------------
  |  Branch (161:12): [True: 5.30M, False: 209k]
  |  Branch (161:34): [True: 0, False: 209k]
  ------------------
  162|  5.51M|}
set_pause_state:
  166|  2.75M|{
  167|  2.75M|    struct MPOpts *opts = mpctx->opts;
  168|       |
  169|  2.75M|    opts->pause = user_pause;
  170|       |
  171|  2.75M|    bool internal_paused = get_internal_paused(mpctx);
  172|  2.75M|    if (internal_paused != mpctx->paused) {
  ------------------
  |  Branch (172:9): [True: 31.1k, False: 2.72M]
  ------------------
  173|  31.1k|        mpctx->paused = internal_paused;
  174|       |
  175|  31.1k|        if (mpctx->ao) {
  ------------------
  |  Branch (175:13): [True: 13.0k, False: 18.0k]
  ------------------
  176|  13.0k|            bool eof = mpctx->audio_status == STATUS_EOF;
  177|  13.0k|            ao_set_paused(mpctx->ao, internal_paused, eof);
  178|  13.0k|        }
  179|       |
  180|  31.1k|        if (mpctx->video_out)
  ------------------
  |  Branch (180:13): [True: 15.6k, False: 15.4k]
  ------------------
  181|  15.6k|            vo_set_paused(mpctx->video_out, internal_paused);
  182|       |
  183|  31.1k|        mpctx->osd_function = 0;
  184|  31.1k|        mpctx->osd_force_update = true;
  185|       |
  186|  31.1k|        mp_wakeup_core(mpctx);
  187|       |
  188|  31.1k|        if (internal_paused) {
  ------------------
  |  Branch (188:13): [True: 23.2k, False: 7.94k]
  ------------------
  189|  23.2k|            mpctx->step_frames = 0;
  190|  23.2k|            mpctx->time_frame -= get_relative_time(mpctx);
  191|  23.2k|        } else {
  192|  7.94k|            (void)get_relative_time(mpctx); // ignore time that passed during pause
  193|  7.94k|        }
  194|  31.1k|    }
  195|       |
  196|  2.75M|    update_core_idle_state(mpctx);
  197|       |
  198|  2.75M|    m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
  199|  2.75M|}
update_internal_pause_state:
  202|  2.73M|{
  203|  2.73M|    set_pause_state(mpctx, mpctx->opts->pause);
  204|  2.73M|}
update_screensaver_state:
  207|   104k|{
  208|   104k|    if (!mpctx->video_out)
  ------------------
  |  Branch (208:9): [True: 30.5k, False: 74.1k]
  ------------------
  209|  30.5k|        return;
  210|       |
  211|   104k|    bool saver_state = (!mpctx->playback_active || !mpctx->opts->stop_screensaver) &&
  ------------------
  |  Branch (211:25): [True: 60.3k, False: 13.7k]
  |  Branch (211:52): [True: 27, False: 13.7k]
  ------------------
  212|  60.4k|                       mpctx->opts->stop_screensaver != 2;
  ------------------
  |  Branch (212:24): [True: 60.3k, False: 23]
  ------------------
  213|  74.1k|    vo_control_async(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
  ------------------
  |  Branch (213:40): [True: 60.3k, False: 13.7k]
  ------------------
  214|  74.1k|                                                   : VOCTRL_KILL_SCREENSAVER, NULL);
  215|  74.1k|}
add_step_frame:
  218|  11.5k|{
  219|  11.5k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (219:9): [True: 944, False: 10.6k]
  ------------------
  220|    944|        return;
  221|  10.6k|    if (dir > 0 && !use_seek) {
  ------------------
  |  Branch (221:9): [True: 10.0k, False: 574]
  |  Branch (221:20): [True: 10.0k, False: 0]
  ------------------
  222|  10.0k|        mpctx->step_frames += dir;
  223|  10.0k|        set_pause_state(mpctx, false);
  224|  10.0k|    } else {
  225|    574|        if (!mpctx->hrseek_active) {
  ------------------
  |  Branch (225:13): [True: 273, False: 301]
  ------------------
  226|    273|            queue_seek(mpctx, MPSEEK_FRAMESTEP, dir, MPSEEK_VERY_EXACT, 0);
  227|       |            set_pause_state(mpctx, true);
  228|    273|        }
  229|    574|    }
  230|  10.6k|}
step_frame_mute:
  233|  5.26k|{
  234|  5.26k|    if (!mpctx->ao_chain || !mpctx->ao_chain->ao)
  ------------------
  |  Branch (234:9): [True: 121, False: 5.14k]
  |  Branch (234:29): [True: 308, False: 4.83k]
  ------------------
  235|    429|        return;
  236|       |
  237|  4.83k|    float gain = mute ? 0 : audio_get_gain(mpctx);
  ------------------
  |  Branch (237:18): [True: 0, False: 4.83k]
  ------------------
  238|  4.83k|    ao_set_gain(mpctx->ao_chain->ao, gain);
  239|  4.83k|}
reset_playback_state:
  243|  2.72M|{
  244|  2.72M|    mp_filter_reset(mpctx->filter_root);
  245|       |
  246|  2.72M|    reset_video_state(mpctx);
  247|  2.72M|    reset_audio_state(mpctx);
  248|  2.72M|    reset_subtitle_state(mpctx);
  249|       |
  250|  2.72M|    if (mpctx->demuxer)
  ------------------
  |  Branch (250:9): [True: 2.69M, False: 28.8k]
  ------------------
  251|  2.69M|        demux_nav_refresh(mpctx->demuxer);
  252|       |
  253|  8.32M|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (253:21): [True: 5.60M, False: 2.72M]
  ------------------
  254|  5.60M|        struct track *t = mpctx->tracks[n];
  255|       |        // (Often, but not always, this is redundant and also done elsewhere.)
  256|  5.60M|        if (t->dec)
  ------------------
  |  Branch (256:13): [True: 4.81M, False: 793k]
  ------------------
  257|  4.81M|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  258|  5.60M|        if (t->d_sub)
  ------------------
  |  Branch (258:13): [True: 161k, False: 5.44M]
  ------------------
  259|   161k|            sub_set_play_dir(t->d_sub, mpctx->play_dir);
  260|  5.60M|    }
  261|       |
  262|       |    // May need unpause first
  263|  2.72M|    if (mpctx->paused_for_cache)
  ------------------
  |  Branch (263:9): [True: 0, False: 2.72M]
  ------------------
  264|      0|        update_internal_pause_state(mpctx);
  265|       |
  266|  2.72M|    mpctx->hrseek_active = false;
  267|  2.72M|    mpctx->hrseek_lastframe = false;
  268|  2.72M|    mpctx->hrseek_backstep = false;
  269|  2.72M|    mpctx->current_seek = (struct seek_params){0};
  270|  2.72M|    mpctx->playback_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.72M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  271|  2.72M|    mpctx->step_frames = 0;
  272|  2.72M|    mpctx->ab_loop_clip = true;
  273|  2.72M|    mpctx->restart_complete = false;
  274|  2.72M|    mpctx->paused_for_cache = false;
  275|  2.72M|    mpctx->cache_buffer = 100;
  276|  2.72M|    mpctx->cache_update_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.72M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  277|       |
  278|  2.72M|    encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
  279|       |
  280|  2.72M|    update_internal_pause_state(mpctx);
  281|  2.72M|    update_core_idle_state(mpctx);
  282|  2.72M|}
queue_seek:
  460|  2.68M|{
  461|  2.68M|    struct seek_params *seek = &mpctx->seek;
  462|       |
  463|  2.68M|    mp_wakeup_core(mpctx);
  464|       |
  465|  2.68M|    if (type != MPSEEK_CHAPTER) {
  ------------------
  |  Branch (465:9): [True: 2.68M, False: 0]
  ------------------
  466|  2.68M|        mpctx->last_chapter_flag = false;
  467|  2.68M|        mpctx->last_chapter_seek = -2;
  468|  2.68M|    }
  469|       |
  470|  2.68M|    switch (type) {
  ------------------
  |  Branch (470:13): [True: 2.68M, False: 0]
  ------------------
  471|  12.3k|    case MPSEEK_RELATIVE:
  ------------------
  |  Branch (471:5): [True: 12.3k, False: 2.67M]
  ------------------
  472|  12.3k|        seek->flags |= flags;
  473|  12.3k|        if (seek->type == MPSEEK_FACTOR)
  ------------------
  |  Branch (473:13): [True: 0, False: 12.3k]
  ------------------
  474|      0|            return;  // Well... not common enough to bother doing better
  475|  12.3k|        seek->amount += amount;
  476|  12.3k|        seek->exact = MPMAX(seek->exact, exact);
  ------------------
  |  |   44|  12.3k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 206, False: 12.1k]
  |  |  ------------------
  ------------------
  477|  12.3k|        if (seek->type == MPSEEK_NONE)
  ------------------
  |  Branch (477:13): [True: 10.5k, False: 1.81k]
  ------------------
  478|  10.5k|            seek->exact = exact;
  479|  12.3k|        if (seek->type == MPSEEK_ABSOLUTE)
  ------------------
  |  Branch (479:13): [True: 241, False: 12.0k]
  ------------------
  480|    241|            return;
  481|  12.0k|        seek->type = MPSEEK_RELATIVE;
  482|  12.0k|        return;
  483|  2.67M|    case MPSEEK_ABSOLUTE:
  ------------------
  |  Branch (483:5): [True: 2.67M, False: 12.5k]
  ------------------
  484|  2.67M|    case MPSEEK_FACTOR:
  ------------------
  |  Branch (484:5): [True: 0, False: 2.68M]
  ------------------
  485|  2.67M|    case MPSEEK_FRAMESTEP:
  ------------------
  |  Branch (485:5): [True: 273, False: 2.68M]
  ------------------
  486|  2.67M|    case MPSEEK_CHAPTER:
  ------------------
  |  Branch (486:5): [True: 0, False: 2.68M]
  ------------------
  487|  2.67M|        *seek = (struct seek_params) {
  488|  2.67M|            .type = type,
  489|  2.67M|            .amount = amount,
  490|  2.67M|            .exact = exact,
  491|  2.67M|            .flags = flags,
  492|  2.67M|        };
  493|  2.67M|        return;
  494|      0|    case MPSEEK_NONE:
  ------------------
  |  Branch (494:5): [True: 0, False: 2.68M]
  ------------------
  495|      0|        *seek = (struct seek_params){ 0 };
  496|      0|        return;
  497|  2.68M|    }
  498|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (498:5): [Folded, False: 0]
  ------------------
  499|      0|}
execute_queued_seek:
  502|  11.4M|{
  503|  11.4M|    if (mpctx->seek.type) {
  ------------------
  |  Branch (503:9): [True: 2.70M, False: 8.70M]
  ------------------
  504|  2.70M|        bool queued_hr_seek = mpctx->seek.exact != MPSEEK_KEYFRAME;
  505|       |        // Let explicitly imprecise seeks cancel precise seeks:
  506|  2.70M|        if (mpctx->hrseek_active && !queued_hr_seek)
  ------------------
  |  Branch (506:13): [True: 17.8k, False: 2.68M]
  |  Branch (506:37): [True: 0, False: 17.8k]
  ------------------
  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|  2.70M|        if ((mpctx->seek.flags & MPSEEK_FLAG_DELAY) &&
  ------------------
  |  Branch (511:13): [True: 22.8k, False: 2.68M]
  ------------------
  512|  22.8k|            mp_time_sec() - mpctx->start_timestamp < 0.3)
  ------------------
  |  Branch (512:13): [True: 21.3k, False: 1.52k]
  ------------------
  513|  21.3k|        {
  514|       |            // Wait until a video frame is available and has been shown.
  515|  21.3k|            if (mpctx->video_status < STATUS_PLAYING)
  ------------------
  |  Branch (515:17): [True: 4.57k, False: 16.7k]
  ------------------
  516|  4.57k|                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|  16.7k|            if (mpctx->hrseek_active && queued_hr_seek && mpctx->vo_chain &&
  ------------------
  |  Branch (520:17): [True: 13.3k, False: 3.46k]
  |  Branch (520:41): [True: 13.3k, False: 0]
  |  Branch (520:59): [True: 13.1k, False: 166]
  ------------------
  521|  13.1k|                mpctx->ao_chain && !mpctx->restart_complete)
  ------------------
  |  Branch (521:17): [True: 13.1k, False: 0]
  |  Branch (521:36): [True: 13.1k, False: 0]
  ------------------
  522|  13.1k|                return;
  523|  16.7k|        }
  524|  2.68M|        mp_seek(mpctx, mpctx->seek);
  525|  2.68M|        mpctx->seek = (struct seek_params){0};
  526|  2.68M|    }
  527|  11.4M|}
get_time_length:
  531|  9.56M|{
  532|  9.56M|    struct demuxer *demuxer = mpctx->demuxer;
  533|  9.56M|    return demuxer && demuxer->duration >= 0 ? demuxer->duration : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  29.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (533:12): [True: 9.55M, False: 10.8k]
  |  Branch (533:23): [True: 9.53M, False: 19.0k]
  ------------------
  534|  9.56M|}
get_start_time:
  539|   902k|{
  540|   902k|    double res = 0;
  541|   902k|    if (mpctx->demuxer) {
  ------------------
  |  Branch (541:9): [True: 902k, False: 0]
  ------------------
  542|   902k|        if (!mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (542:13): [True: 0, False: 902k]
  ------------------
  543|      0|            res += mpctx->demuxer->start_time;
  544|   902k|        if (dir < 0)
  ------------------
  |  Branch (544:13): [True: 321, False: 902k]
  ------------------
  545|    321|            res += MPMAX(mpctx->demuxer->duration, 0);
  ------------------
  |  |   44|    321|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 105, False: 216]
  |  |  ------------------
  ------------------
  546|   902k|    }
  547|   902k|    return res;
  548|   902k|}
get_current_time:
  551|  22.9M|{
  552|  22.9M|    if (!mpctx->demuxer)
  ------------------
  |  Branch (552:9): [True: 11.8k, False: 22.9M]
  ------------------
  553|  11.8k|        return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  11.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  554|  22.9M|    if (mpctx->playback_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  22.9M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (554:9): [True: 385k, False: 22.5M]
  ------------------
  555|   385k|        return mpctx->playback_pts * mpctx->play_dir;
  556|  22.5M|    return mpctx->last_seek_pts;
  557|  22.9M|}
get_playback_time:
  560|  2.74M|{
  561|  2.74M|    double cur = get_current_time(mpctx);
  562|       |    // During seeking, the time corresponds to the last seek time - apply some
  563|       |    // cosmetics to it.
  564|  2.74M|    if (cur != MP_NOPTS_VALUE && mpctx->playback_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  5.48M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (cur != MP_NOPTS_VALUE && mpctx->playback_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  2.74M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (564:9): [True: 2.74M, False: 1.53k]
  |  Branch (564:34): [True: 2.72M, False: 13.3k]
  ------------------
  565|  2.72M|        double length = get_time_length(mpctx);
  566|  2.72M|        if (length >= 0)
  ------------------
  |  Branch (566:13): [True: 2.72M, False: 262]
  ------------------
  567|  2.72M|            cur = MPCLAMP(cur, 0, length);
  ------------------
  |  |   46|  2.72M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 965, False: 2.72M]
  |  |  |  Branch (46:56): [True: 1.41k, False: 2.72M]
  |  |  ------------------
  ------------------
  568|  2.72M|    }
  569|       |    // Force to 0 if this is not MP_NOPTS_VALUE.
  570|  2.74M|    if (cur != MP_NOPTS_VALUE && cur < 0)
  ------------------
  |  |   39|  5.48M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (570:9): [True: 2.74M, False: 1.53k]
  |  Branch (570:34): [True: 67, False: 2.74M]
  ------------------
  571|     67|        cur = 0.0;
  572|  2.74M|    return cur;
  573|  2.74M|}
get_current_pos_ratio:
  577|  3.35M|{
  578|  3.35M|    struct demuxer *demuxer = mpctx->demuxer;
  579|  3.35M|    if (!demuxer)
  ------------------
  |  Branch (579:9): [True: 89.8k, False: 3.26M]
  ------------------
  580|  89.8k|        return -1;
  581|  3.26M|    double ret = -1;
  582|  3.26M|    double start = 0;
  583|  3.26M|    double len = get_time_length(mpctx);
  584|  3.26M|    if (use_range) {
  ------------------
  |  Branch (584:9): [True: 10.9k, False: 3.25M]
  ------------------
  585|  10.9k|        double startpos = get_play_start_pts(mpctx);
  586|  10.9k|        double endpos = get_play_end_pts(mpctx);
  587|  10.9k|        if (endpos > MPMAX(0, len))
  ------------------
  |  |   44|  10.9k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 10.9k]
  |  |  ------------------
  ------------------
  |  Branch (587:13): [True: 3.04k, False: 7.91k]
  ------------------
  588|  3.04k|            endpos = MPMAX(0, len);
  ------------------
  |  |   44|  3.04k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 3.04k]
  |  |  ------------------
  ------------------
  589|  10.9k|        if (endpos < startpos)
  ------------------
  |  Branch (589:13): [True: 6.94k, False: 4.01k]
  ------------------
  590|  6.94k|            endpos = startpos;
  591|  10.9k|        start = startpos;
  592|  10.9k|        len = endpos - startpos;
  593|  10.9k|    }
  594|  3.26M|    double pos = get_current_time(mpctx);
  595|  3.26M|    if (len > 0)
  ------------------
  |  Branch (595:9): [True: 3.24M, False: 20.7k]
  ------------------
  596|  3.24M|        ret = MPCLAMP((pos - start) / len, 0, 1);
  ------------------
  |  |   46|  3.24M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 144k, False: 3.10M]
  |  |  |  Branch (46:56): [True: 5.76k, False: 3.09M]
  |  |  ------------------
  ------------------
  597|  3.26M|    if (ret < 0) {
  ------------------
  |  Branch (597:9): [True: 20.7k, False: 3.24M]
  ------------------
  598|  20.7k|        int64_t size = demuxer->filesize;
  599|  20.7k|        if (size > 0 && demuxer->filepos >= 0)
  ------------------
  |  Branch (599:13): [True: 0, False: 20.7k]
  |  Branch (599:25): [True: 0, False: 0]
  ------------------
  600|      0|            ret = MPCLAMP(demuxer->filepos / (double)size, 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]
  |  |  ------------------
  ------------------
  601|  20.7k|    }
  602|  3.26M|    if (use_range) {
  ------------------
  |  Branch (602:9): [True: 10.9k, False: 3.25M]
  ------------------
  603|  10.9k|        if (mpctx->opts->play_frames > 0)
  ------------------
  |  Branch (603:13): [True: 0, False: 10.9k]
  ------------------
  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|  10.9k|                    mpctx->max_frames / (double) mpctx->opts->play_frames);
  606|  10.9k|    }
  607|  3.26M|    return ret;
  608|  3.35M|}
get_current_chapter:
  612|  11.4M|{
  613|  11.4M|    if (!mpctx->num_chapters)
  ------------------
  |  Branch (613:9): [True: 11.4M, False: 0]
  ------------------
  614|  11.4M|        return -2;
  615|      0|    double current_pts = get_current_time(mpctx);
  616|      0|    int i;
  617|      0|    for (i = 0; i < mpctx->num_chapters; i++)
  ------------------
  |  Branch (617:17): [True: 0, False: 0]
  ------------------
  618|      0|        if (current_pts < mpctx->chapters[i].pts)
  ------------------
  |  Branch (618:13): [True: 0, False: 0]
  ------------------
  619|      0|            break;
  620|      0|    return mpctx->last_chapter_flag ?
  ------------------
  |  Branch (620:12): [True: 0, False: 0]
  ------------------
  621|      0|        mpctx->last_chapter_seek : MPMAX(mpctx->last_chapter_seek, i - 1);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  622|  11.4M|}
chapter_display_name:
  625|      8|{
  626|      8|    char *name = chapter_name(mpctx, chapter);
  627|      8|    char *dname = NULL;
  628|      8|    if (name) {
  ------------------
  |  Branch (628:9): [True: 0, False: 8]
  ------------------
  629|      0|        dname = talloc_asprintf(NULL, "(%d) %s", chapter + 1, name);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  630|      8|    } else if (chapter < -1) {
  ------------------
  |  Branch (630:16): [True: 8, False: 0]
  ------------------
  631|      8|        dname = talloc_strdup(NULL, "(unavailable)");
  ------------------
  |  |   50|      8|#define talloc_strdup                   ta_xstrdup
  ------------------
  632|      8|    } else {
  633|      0|        int chapter_count = get_chapter_count(mpctx);
  634|      0|        if (chapter_count <= 0)
  ------------------
  |  Branch (634:13): [True: 0, False: 0]
  ------------------
  635|      0|            dname = talloc_asprintf(NULL, "(%d)", chapter + 1);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  636|      0|        else
  637|      0|            dname = talloc_asprintf(NULL, "(%d) of %d", chapter + 1,
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  638|      0|                                    chapter_count);
  639|      0|    }
  640|      8|    return dname;
  641|      8|}
chapter_name:
  645|      8|{
  646|      8|    if (chapter < 0 || chapter >= mpctx->num_chapters)
  ------------------
  |  Branch (646:9): [True: 8, False: 0]
  |  Branch (646:24): [True: 0, False: 0]
  ------------------
  647|      8|        return NULL;
  648|      0|    return mp_tags_get_str(mpctx->chapters[chapter].metadata, "title");
  649|      8|}
get_chapter_count:
  662|  10.4k|{
  663|  10.4k|    return mpctx->num_chapters;
  664|  10.4k|}
update_ab_loop_clip:
  670|  5.39M|{
  671|  5.39M|    double pts = get_current_time(mpctx);
  672|  5.39M|    double ab[2];
  673|  5.39M|    mpctx->ab_loop_clip = pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  10.7M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (673:27): [True: 5.39M, False: 292]
  ------------------
  674|  5.39M|                          get_ab_loop_times(mpctx, ab) &&
  ------------------
  |  Branch (674:27): [True: 3.57M, False: 1.82M]
  ------------------
  675|  3.57M|                          pts * mpctx->play_dir <= ab[1] * mpctx->play_dir;
  ------------------
  |  Branch (675:27): [True: 3.57M, False: 282]
  ------------------
  676|  5.39M|}
get_cache_buffering_percentage:
  829|    512|{
  830|    512|    return mpctx->demuxer ? mpctx->cache_buffer : -1;
  ------------------
  |  Branch (830:12): [True: 444, False: 68]
  ------------------
  831|    512|}
seek_to_last_frame:
  965|    146|{
  966|    146|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (966:9): [True: 0, False: 146]
  ------------------
  967|      0|        return;
  968|    146|    if (mpctx->hrseek_lastframe) // exit if we already tried this
  ------------------
  |  Branch (968:9): [True: 122, False: 24]
  ------------------
  969|    122|        return;
  970|     24|    MP_VERBOSE(mpctx, "seeking to last frame...\n");
  ------------------
  |  |   92|     24|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     24|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  971|       |    // Approximately seek close to the end of the file.
  972|       |    // Usually, it will seek some seconds before end.
  973|     24|    double end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|     24|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  974|     24|    if (mpctx->play_dir > 0) {
  ------------------
  |  Branch (974:9): [True: 24, False: 0]
  ------------------
  975|     24|        end = get_play_end_pts(mpctx);
  976|     24|        if (end == MP_NOPTS_VALUE)
  ------------------
  |  |   39|     24|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (976:13): [True: 24, False: 0]
  ------------------
  977|     24|            end = get_time_length(mpctx);
  978|     24|    } else {
  979|      0|        end = get_start_time(mpctx, 1);
  980|      0|    }
  981|     24|    mp_seek(mpctx, (struct seek_params){
  982|     24|                   .type = MPSEEK_ABSOLUTE,
  983|     24|                   .amount = end,
  984|     24|                   .exact = MPSEEK_VERY_EXACT,
  985|     24|                   });
  986|       |    // Make it exact: stop seek only if last frame was reached.
  987|     24|    if (mpctx->hrseek_active) {
  ------------------
  |  Branch (987:9): [True: 24, False: 0]
  ------------------
  988|     24|        mpctx->hrseek_pts = INFINITY * mpctx->play_dir;
  989|       |        mpctx->hrseek_lastframe = true;
  990|     24|    }
  991|     24|}
handle_force_window:
 1032|  11.4M|{
 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|  11.4M|    bool act = mpctx->stop_play || mpctx->playback_initialized || force;
  ------------------
  |  Branch (1035:16): [True: 28.6k, False: 11.4M]
  |  Branch (1035:36): [True: 11.4M, False: 16.7k]
  |  Branch (1035:67): [True: 537, False: 16.1k]
  ------------------
 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|  11.4M|    bool stalled_video = mpctx->playback_initialized && mpctx->restart_complete &&
  ------------------
  |  Branch (1039:26): [True: 11.4M, False: 35.6k]
  |  Branch (1039:57): [True: 1.09M, False: 10.3M]
  ------------------
 1040|  1.09M|                         mpctx->video_status == STATUS_EOF && mpctx->vo_chain &&
  ------------------
  |  Branch (1040:26): [True: 945k, False: 153k]
  |  Branch (1040:63): [True: 866k, False: 79.2k]
  ------------------
 1041|   866k|                         !mpctx->video_out->config_ok;
  ------------------
  |  Branch (1041:26): [True: 134k, False: 732k]
  ------------------
 1042|       |
 1043|       |    // Don't interfere with real video playback
 1044|  11.4M|    if (mpctx->vo_chain && !stalled_video)
  ------------------
  |  Branch (1044:9): [True: 10.4M, False: 1.01M]
  |  Branch (1044:28): [True: 10.3M, False: 134k]
  ------------------
 1045|  10.3M|        return 0;
 1046|       |
 1047|  1.14M|    if (!mpctx->opts->force_vo) {
  ------------------
  |  Branch (1047:9): [True: 1.14M, False: 4.83k]
  ------------------
 1048|  1.14M|        if (act && !mpctx->vo_chain)
  ------------------
  |  Branch (1048:13): [True: 1.12M, False: 15.9k]
  |  Branch (1048:20): [True: 993k, False: 134k]
  ------------------
 1049|   993k|            uninit_video_out(mpctx);
 1050|  1.14M|        return 0;
 1051|  1.14M|    }
 1052|       |
 1053|  4.83k|    if (mpctx->opts->force_vo != 2 && !act)
  ------------------
  |  Branch (1053:9): [True: 4.73k, False: 94]
  |  Branch (1053:39): [True: 196, False: 4.54k]
  ------------------
 1054|    196|        return 0;
 1055|       |
 1056|  4.63k|    if (!mpctx->video_out) {
  ------------------
  |  Branch (1056:9): [True: 2.68k, False: 1.94k]
  ------------------
 1057|  2.68k|        struct vo_extra ex = {
 1058|  2.68k|            .input_ctx = mpctx->input,
 1059|  2.68k|            .osd = mpctx->osd,
 1060|  2.68k|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
 1061|  2.68k|            .wakeup_cb = mp_wakeup_core_cb,
 1062|  2.68k|            .wakeup_ctx = mpctx,
 1063|  2.68k|        };
 1064|  2.68k|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
 1065|  2.68k|        if (!mpctx->video_out)
  ------------------
  |  Branch (1065:13): [True: 0, False: 2.68k]
  ------------------
 1066|      0|            goto err;
 1067|  2.68k|        mpctx->mouse_cursor_visible = true;
 1068|  2.68k|    }
 1069|       |
 1070|  4.63k|    if (!mpctx->video_out->config_ok || force) {
  ------------------
  |  Branch (1070:9): [True: 2.68k, False: 1.94k]
  |  Branch (1070:41): [True: 334, False: 1.61k]
  ------------------
 1071|  3.02k|        struct vo *vo = mpctx->video_out;
 1072|       |        // Pick whatever works
 1073|  3.02k|        int config_format = 0;
 1074|  3.02k|        uint8_t fmts[IMGFMT_END - IMGFMT_START] = {0};
 1075|  3.02k|        vo_query_formats(vo, fmts);
 1076|  3.02k|        if (fmts[IMGFMT_RGBA - IMGFMT_START])
  ------------------
  |  Branch (1076:13): [True: 3.02k, False: 0]
  ------------------
 1077|  3.02k|            config_format = IMGFMT_RGBA;
 1078|  3.02k|        for (int fmt = IMGFMT_START; fmt < IMGFMT_END && !config_format; fmt++) {
  ------------------
  |  Branch (1078:38): [True: 3.02k, False: 0]
  |  Branch (1078:58): [True: 0, False: 3.02k]
  ------------------
 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|  3.02k|        int w = 960;
 1089|  3.02k|        int h = 540;
 1090|  3.02k|        struct mp_image_params p = {
 1091|  3.02k|            .imgfmt = config_format,
 1092|  3.02k|            .w = w,   .h = h,
 1093|  3.02k|            .p_w = 1, .p_h = 1,
 1094|  3.02k|            .force_window = true,
 1095|  3.02k|            .color = pl_color_space_srgb,
 1096|  3.02k|        };
 1097|  3.02k|        mp_image_params_guess_csp(&p);
 1098|  3.02k|        if (vo_reconfig(vo, &p) < 0)
  ------------------
  |  Branch (1098:13): [True: 0, False: 3.02k]
  ------------------
 1099|      0|            goto err;
 1100|  3.02k|        struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1101|  3.02k|        update_window_title(mpctx, true);
 1102|  3.02k|        update_content_type(mpctx, track);
 1103|  3.02k|        update_screensaver_state(mpctx);
 1104|  3.02k|        vo_set_paused(vo, true);
 1105|  3.02k|        vo_redraw(vo);
 1106|  3.02k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1107|  3.02k|    }
 1108|       |
 1109|  4.63k|    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|  4.63k|}
run_playloop:
 1329|  11.4M|{
 1330|  11.4M|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) {
  ------------------
  |  Branch (1330:9): [True: 0, False: 11.4M]
  ------------------
 1331|      0|        mpctx->stop_play = PT_ERROR;
 1332|      0|        return;
 1333|      0|    }
 1334|       |
 1335|  11.4M|    update_demuxer_properties(mpctx);
 1336|       |
 1337|  11.4M|    update_vo_chain_el_pair(mpctx);
 1338|       |
 1339|  11.4M|    handle_cursor_autohide(mpctx);
 1340|  11.4M|    handle_vo_events(mpctx);
 1341|  11.4M|    handle_command_updates(mpctx);
 1342|       |
 1343|  11.4M|    if (mpctx->lavfi && mp_filter_has_failed(mpctx->lavfi))
  ------------------
  |  Branch (1343:9): [True: 0, False: 11.4M]
  |  Branch (1343:25): [True: 0, False: 0]
  ------------------
 1344|      0|        mpctx->stop_play = AT_END_OF_FILE;
 1345|       |
 1346|  11.4M|    fill_audio_out_buffers(mpctx);
 1347|  11.4M|    write_video(mpctx);
 1348|       |
 1349|  11.4M|    handle_lazy_streams(mpctx);
 1350|       |
 1351|  11.4M|    handle_playback_restart(mpctx);
 1352|       |
 1353|  11.4M|    handle_playback_time(mpctx);
 1354|       |
 1355|  11.4M|    handle_dummy_ticks(mpctx);
 1356|       |
 1357|  11.4M|    handle_clipboard_updates(mpctx);
 1358|       |
 1359|  11.4M|    update_osd_msg(mpctx);
 1360|       |
 1361|  11.4M|    handle_update_subtitles(mpctx);
 1362|       |
 1363|  11.4M|    disc_nav_update(mpctx);
 1364|       |
 1365|  11.4M|    handle_each_frame_screenshot(mpctx);
 1366|       |
 1367|  11.4M|    handle_eof(mpctx);
 1368|       |
 1369|  11.4M|    handle_loop_file(mpctx);
 1370|       |
 1371|  11.4M|    handle_keep_open(mpctx);
 1372|       |
 1373|  11.4M|    handle_sstep(mpctx);
 1374|       |
 1375|  11.4M|    update_core_idle_state(mpctx);
 1376|       |
 1377|  11.4M|    execute_queued_seek(mpctx);
 1378|       |
 1379|  11.4M|    if (mpctx->stop_play)
  ------------------
  |  Branch (1379:9): [True: 4.51k, False: 11.4M]
  ------------------
 1380|  4.51k|        return;
 1381|       |
 1382|  11.4M|    handle_osd_redraw(mpctx);
 1383|       |
 1384|  11.4M|    if (mp_filter_graph_run(mpctx->filter_root))
  ------------------
  |  Branch (1384:9): [True: 2.28M, False: 9.12M]
  ------------------
 1385|  2.28M|        mp_wakeup_core(mpctx);
 1386|       |
 1387|  11.4M|    mp_wait_events(mpctx);
 1388|       |
 1389|  11.4M|    handle_update_cache(mpctx);
 1390|       |
 1391|  11.4M|    mp_process_input(mpctx);
 1392|       |
 1393|  11.4M|    handle_option_callbacks(mpctx);
 1394|       |
 1395|  11.4M|    handle_chapter_change(mpctx);
 1396|       |
 1397|       |    handle_force_window(mpctx, false);
 1398|  11.4M|}
mp_idle:
 1401|   264k|{
 1402|   264k|    handle_dummy_ticks(mpctx);
 1403|   264k|    handle_clipboard_updates(mpctx);
 1404|   264k|    mp_wait_events(mpctx);
 1405|   264k|    mp_process_input(mpctx);
 1406|   264k|    handle_option_callbacks(mpctx);
 1407|   264k|    handle_command_updates(mpctx);
 1408|   264k|    handle_update_cache(mpctx);
 1409|   264k|    handle_cursor_autohide(mpctx);
 1410|   264k|    handle_vo_events(mpctx);
 1411|   264k|    update_osd_msg(mpctx);
 1412|   264k|    handle_osd_redraw(mpctx);
 1413|   264k|}
idle_loop:
 1417|  17.8k|{
 1418|       |    // ================= idle loop (STOP state) =========================
 1419|  17.8k|    bool need_reinit = true;
 1420|   142k|    while (mpctx->opts->player_idle_mode && mpctx->stop_play == PT_STOP) {
  ------------------
  |  Branch (1420:12): [True: 142k, False: 0]
  |  Branch (1420:45): [True: 124k, False: 17.8k]
  ------------------
 1421|   124k|        if (need_reinit) {
  ------------------
  |  Branch (1421:13): [True: 16.6k, False: 107k]
  ------------------
 1422|  16.6k|            uninit_audio_out(mpctx);
 1423|  16.6k|            handle_force_window(mpctx, true);
 1424|  16.6k|            mp_wakeup_core(mpctx);
 1425|  16.6k|            mp_notify(mpctx, MPV_EVENT_IDLE, NULL);
 1426|  16.6k|            demux_packet_pool_clear(demux_packet_pool_get(mpctx->global));
 1427|       |            need_reinit = false;
 1428|  16.6k|        }
 1429|   124k|        mp_idle(mpctx);
 1430|   124k|    }
 1431|  17.8k|}
playloop.c:mp_seek:
  295|  2.68M|{
  296|  2.68M|    struct MPOpts *opts = mpctx->opts;
  297|       |
  298|  2.68M|    if (!mpctx->demuxer || !seek.type || seek.amount == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (298:9): [True: 0, False: 2.68M]
  |  Branch (298:28): [True: 0, False: 2.68M]
  |  Branch (298:42): [True: 58, False: 2.68M]
  ------------------
  299|     58|        return;
  300|       |
  301|  2.68M|    if (seek.type == MPSEEK_CHAPTER) {
  ------------------
  |  Branch (301:9): [True: 0, False: 2.68M]
  ------------------
  302|      0|        mpctx->last_chapter_flag = false;
  303|      0|        seek.type = MPSEEK_ABSOLUTE;
  304|      0|    }
  305|       |
  306|  2.68M|    bool hr_seek_very_exact = seek.exact == MPSEEK_VERY_EXACT;
  307|  2.68M|    double current_time = get_playback_time(mpctx);
  308|  2.68M|    if (current_time == MP_NOPTS_VALUE && seek.type == MPSEEK_RELATIVE)
  ------------------
  |  |   39|  5.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (308:9): [True: 0, False: 2.68M]
  |  Branch (308:43): [True: 0, False: 0]
  ------------------
  309|      0|        return;
  310|  2.68M|    if (current_time == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (310:9): [True: 0, False: 2.68M]
  ------------------
  311|      0|        current_time = 0;
  312|  2.68M|    double seek_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  313|  2.68M|    int demux_flags = 0;
  314|       |
  315|  2.68M|    switch (seek.type) {
  316|  2.67M|    case MPSEEK_ABSOLUTE:
  ------------------
  |  Branch (316:5): [True: 2.67M, False: 9.91k]
  ------------------
  317|  2.67M|        seek_pts = seek.amount;
  318|  2.67M|        break;
  319|    240|    case MPSEEK_FRAMESTEP:
  ------------------
  |  Branch (319:5): [True: 240, False: 2.68M]
  ------------------
  320|    240|        seek_pts = calculate_framestep_pts(mpctx, current_time,
  321|    240|                                           (int)seek.amount);
  322|    240|        hr_seek_very_exact = true;
  323|    240|        break;
  324|  9.67k|    case MPSEEK_RELATIVE:
  ------------------
  |  Branch (324:5): [True: 9.67k, False: 2.67M]
  ------------------
  325|  9.67k|        demux_flags = seek.amount > 0 ? SEEK_FORWARD : 0;
  ------------------
  |  |   95|  2.83k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (325:23): [True: 2.83k, False: 6.83k]
  ------------------
  326|  9.67k|        seek_pts = current_time + seek.amount;
  327|  9.67k|        break;
  328|      0|    case MPSEEK_FACTOR: ;
  ------------------
  |  Branch (328:5): [True: 0, False: 2.68M]
  ------------------
  329|      0|        double len = get_time_length(mpctx);
  330|      0|        if (len >= 0)
  ------------------
  |  Branch (330:13): [True: 0, False: 0]
  ------------------
  331|      0|            seek_pts = seek.amount * len;
  332|      0|        break;
  333|  2.68M|    default: MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (333:5): [True: 0, False: 2.68M]
  |  Branch (333:14): [Folded, False: 0]
  ------------------
  334|  2.68M|    }
  335|       |
  336|  2.68M|    double demux_pts = seek_pts;
  337|       |
  338|  2.68M|    bool hr_seek = seek.exact != MPSEEK_KEYFRAME && seek_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  5.37M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (338:20): [True: 2.68M, False: 0]
  |  Branch (338:53): [True: 2.68M, False: 0]
  ------------------
  339|  2.68M|        (seek.exact >= MPSEEK_EXACT || opts->hr_seek == 1 ||
  ------------------
  |  Branch (339:10): [True: 1.78M, False: 897k]
  |  Branch (339:40): [True: 0, False: 897k]
  ------------------
  340|   897k|         (opts->hr_seek >= 0 && seek.type == MPSEEK_ABSOLUTE) ||
  ------------------
  |  Branch (340:11): [True: 897k, False: 0]
  |  Branch (340:33): [True: 891k, False: 5.75k]
  ------------------
  341|  5.75k|         (opts->hr_seek == 2 && (!mpctx->vo_chain || mpctx->vo_chain->is_sparse)));
  ------------------
  |  Branch (341:11): [True: 5.75k, False: 0]
  |  Branch (341:34): [True: 690, False: 5.06k]
  |  Branch (341:54): [True: 0, False: 5.06k]
  ------------------
  342|       |
  343|       |    // Under certain circumstances, prefer SEEK_FACTOR.
  344|  2.68M|    if (seek.type == MPSEEK_FACTOR && !hr_seek &&
  ------------------
  |  Branch (344:9): [True: 0, False: 2.68M]
  |  Branch (344:39): [True: 0, False: 0]
  ------------------
  345|      0|        (mpctx->demuxer->ts_resets_possible || seek_pts == MP_NOPTS_VALUE))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (345:10): [True: 0, False: 0]
  |  Branch (345:48): [True: 0, False: 0]
  ------------------
  346|      0|    {
  347|      0|        demux_pts = seek.amount;
  348|      0|        demux_flags |= SEEK_FACTOR;
  ------------------
  |  |   94|      0|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  349|      0|    }
  350|       |
  351|  2.68M|    int play_dir = opts->play_dir;
  352|  2.68M|    if (play_dir < 0)
  ------------------
  |  Branch (352:9): [True: 9.26k, False: 2.67M]
  ------------------
  353|  9.26k|        demux_flags |= SEEK_SATAN;
  ------------------
  |  |   98|  9.26k|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
  354|       |
  355|  2.68M|    if (hr_seek) {
  ------------------
  |  Branch (355:9): [True: 2.68M, False: 5.06k]
  ------------------
  356|  2.68M|        double hr_seek_offset = opts->hr_seek_demuxer_offset;
  357|       |        // Always try to compensate for possibly bad demuxers in "special"
  358|       |        // situations where we need more robustness from the hr-seek code, even
  359|       |        // if the user doesn't use --hr-seek-demuxer-offset.
  360|       |        // The value is arbitrary, but should be "good enough" in most situations.
  361|  2.68M|        if (hr_seek_very_exact)
  ------------------
  |  Branch (361:13): [True: 642, False: 2.68M]
  ------------------
  362|    642|            hr_seek_offset = MPMAX(hr_seek_offset, 0.5); // arbitrary
  ------------------
  |  |   44|    642|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 642]
  |  |  ------------------
  ------------------
  363|  8.26M|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (363:25): [True: 5.58M, False: 2.68M]
  ------------------
  364|  5.58M|            double offset = 0;
  365|  5.58M|            if (!mpctx->tracks[n]->is_external)
  ------------------
  |  Branch (365:17): [True: 5.36M, False: 220k]
  ------------------
  366|  5.36M|                offset += get_track_seek_offset(mpctx, mpctx->tracks[n]);
  367|  5.58M|            hr_seek_offset = MPMAX(hr_seek_offset, -offset);
  ------------------
  |  |   44|  5.58M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.34k, False: 5.58M]
  |  |  ------------------
  ------------------
  368|  5.58M|        }
  369|  2.68M|        demux_pts -= hr_seek_offset * play_dir;
  370|  2.68M|        demux_flags = (demux_flags | SEEK_HR) & ~SEEK_FORWARD;
  ------------------
  |  |   99|  2.68M|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
                      demux_flags = (demux_flags | SEEK_HR) & ~SEEK_FORWARD;
  ------------------
  |  |   95|  2.68M|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  371|       |        // For HR seeks in backward playback mode, the correct seek rounding
  372|       |        // direction is forward instead of backward.
  373|  2.68M|        if (play_dir < 0)
  ------------------
  |  Branch (373:13): [True: 9.23k, False: 2.67M]
  ------------------
  374|  9.23k|            demux_flags |= SEEK_FORWARD;
  ------------------
  |  |   95|  9.23k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  375|  2.68M|    }
  376|       |
  377|  2.68M|    if (!mpctx->demuxer->seekable)
  ------------------
  |  Branch (377:9): [True: 0, False: 2.68M]
  ------------------
  378|      0|        demux_flags |= SEEK_CACHED;
  ------------------
  |  |   97|      0|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
  379|       |
  380|  2.68M|    demux_flags |= SEEK_BLOCK;
  ------------------
  |  |  100|  2.68M|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
  381|       |
  382|  2.68M|    if (!demux_seek(mpctx->demuxer, demux_pts, demux_flags)) {
  ------------------
  |  Branch (382:9): [True: 0, False: 2.68M]
  ------------------
  383|      0|        if (!mpctx->demuxer->seekable) {
  ------------------
  |  Branch (383:13): [True: 0, False: 0]
  ------------------
  384|      0|            MP_ERR(mpctx, "Cannot seek 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__)
  |  |  ------------------
  ------------------
  385|      0|            MP_ERR(mpctx, "You can force it with '--force-seekable=yes'.\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__)
  |  |  ------------------
  ------------------
  386|      0|        }
  387|      0|        return;
  388|      0|    }
  389|       |
  390|  2.68M|    mpctx->play_dir = play_dir;
  391|       |
  392|       |    // Seek external, extra files too:
  393|  8.28M|    for (int t = 0; t < mpctx->num_tracks; t++) {
  ------------------
  |  Branch (393:21): [True: 5.59M, False: 2.68M]
  ------------------
  394|  5.59M|        struct track *track = mpctx->tracks[t];
  395|  5.59M|        if (track->selected && track->is_external && track->demuxer) {
  ------------------
  |  Branch (395:13): [True: 4.96M, False: 630k]
  |  Branch (395:32): [True: 161k, False: 4.80M]
  |  Branch (395:54): [True: 161k, False: 0]
  ------------------
  396|   161k|            double main_new_pos = demux_pts;
  397|   161k|            if (!hr_seek || track->is_external)
  ------------------
  |  Branch (397:17): [True: 149, False: 161k]
  |  Branch (397:29): [True: 161k, False: 0]
  ------------------
  398|   161k|                main_new_pos += get_track_seek_offset(mpctx, track);
  399|   161k|            if (demux_flags & SEEK_FACTOR)
  ------------------
  |  |   94|   161k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (399:17): [True: 0, False: 161k]
  ------------------
  400|      0|                main_new_pos = seek_pts;
  401|   161k|            demux_seek(track->demuxer, main_new_pos,
  402|   161k|                       demux_flags & (SEEK_SATAN | SEEK_BLOCK));
  ------------------
  |  |   98|   161k|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
                                     demux_flags & (SEEK_SATAN | SEEK_BLOCK));
  ------------------
  |  |  100|   161k|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
  403|   161k|        }
  404|  5.59M|    }
  405|       |
  406|  2.68M|    if (!(seek.flags & MPSEEK_FLAG_NOFLUSH))
  ------------------
  |  Branch (406:9): [True: 11.3k, False: 2.67M]
  ------------------
  407|  11.3k|        clear_audio_output_buffers(mpctx);
  408|       |
  409|  2.68M|    reset_playback_state(mpctx);
  410|       |
  411|  2.68M|    demux_block_reading(mpctx->demuxer, false);
  412|  8.28M|    for (int t = 0; t < mpctx->num_tracks; t++) {
  ------------------
  |  Branch (412:21): [True: 5.59M, False: 2.68M]
  ------------------
  413|  5.59M|        struct track *track = mpctx->tracks[t];
  414|  5.59M|        if (track->selected && track->demuxer)
  ------------------
  |  Branch (414:13): [True: 4.96M, False: 630k]
  |  Branch (414:32): [True: 4.96M, False: 0]
  ------------------
  415|  4.96M|            demux_block_reading(track->demuxer, false);
  416|  5.59M|    }
  417|       |
  418|       |    /* Use the target time as "current position" for further relative
  419|       |     * seeks etc until a new video frame has been decoded */
  420|  2.68M|    mpctx->last_seek_pts = seek_pts;
  421|       |
  422|  2.68M|    if (hr_seek) {
  ------------------
  |  Branch (422:9): [True: 2.68M, False: 5.06k]
  ------------------
  423|  2.68M|        mpctx->hrseek_active = true;
  424|  2.68M|        mpctx->hrseek_backstep = seek.type == MPSEEK_FRAMESTEP && seek.amount == -1;
  ------------------
  |  Branch (424:34): [True: 240, False: 2.68M]
  |  Branch (424:67): [True: 214, False: 26]
  ------------------
  425|  2.68M|        mpctx->hrseek_pts = seek_pts * mpctx->play_dir;
  426|       |
  427|       |        // allow decoder to drop frames before hrseek_pts
  428|  2.68M|        bool hrseek_framedrop = !hr_seek_very_exact && opts->hr_seek_framedrop;
  ------------------
  |  Branch (428:33): [True: 2.68M, False: 642]
  |  Branch (428:56): [True: 2.68M, False: 0]
  ------------------
  429|       |
  430|  2.68M|        MP_VERBOSE(mpctx, "hr-seek, skipping to %f%s%s\n", mpctx->hrseek_pts,
  ------------------
  |  |   92|  2.68M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  10.7M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 2.68M, False: 642]
  |  |  |  |  |  Branch (86:57): [True: 214, False: 2.68M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|  2.68M|                   hrseek_framedrop ? "" : " (no framedrop)",
  432|  2.68M|                   mpctx->hrseek_backstep ? " (backstep)" : "");
  433|       |
  434|  8.26M|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (434:25): [True: 5.58M, False: 2.68M]
  ------------------
  435|  5.58M|            struct track *track = mpctx->tracks[n];
  436|  5.58M|            struct mp_decoder_wrapper *dec = track->dec;
  437|  5.58M|            if (dec && hrseek_framedrop)
  ------------------
  |  Branch (437:17): [True: 4.79M, False: 791k]
  |  Branch (437:24): [True: 4.79M, False: 1.21k]
  ------------------
  438|  4.79M|                mp_decoder_wrapper_set_start_pts(dec, mpctx->hrseek_pts);
  439|  5.58M|        }
  440|  2.68M|    }
  441|       |
  442|  2.68M|    if (mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (442:9): [True: 0, False: 2.68M]
  ------------------
  443|      0|        mpctx->stop_play = KEEP_PLAYING;
  444|       |
  445|  2.68M|    mpctx->start_timestamp = mp_time_sec();
  446|  2.68M|    mp_wakeup_core(mpctx);
  447|       |
  448|  2.68M|    mp_notify(mpctx, MPV_EVENT_SEEK, NULL);
  449|  2.68M|    mp_notify(mpctx, MPV_EVENT_TICK, NULL);
  450|       |
  451|  2.68M|    update_ab_loop_clip(mpctx);
  452|       |
  453|  2.68M|    mpctx->current_seek = seek;
  454|  2.68M|    redraw_subs(mpctx);
  455|  2.68M|}
playloop.c:calculate_framestep_pts:
  286|    240|{
  287|       |    // Crude guess at the pts. Use current_time if step_frames is -1.
  288|    240|    int previous_frame = mpctx->num_past_frames - 1;
  289|    240|    int offset = step_frames == -1 ? 0 : step_frames;
  ------------------
  |  Branch (289:18): [True: 214, False: 26]
  ------------------
  290|    240|    double pts = mpctx->past_frames[previous_frame].approx_duration * offset;
  291|    240|    return current_time + pts;
  292|    240|}
playloop.c:handle_cursor_autohide:
  850|  11.6M|{
  851|  11.6M|    struct MPOpts *opts = mpctx->opts;
  852|  11.6M|    struct vo *vo = mpctx->video_out;
  853|       |
  854|  11.6M|    if (!vo)
  ------------------
  |  Branch (854:9): [True: 1.17M, False: 10.5M]
  ------------------
  855|  1.17M|        return;
  856|       |
  857|  11.6M|    bool mouse_cursor_visible = mpctx->mouse_cursor_visible;
  858|  10.5M|    double now = mp_time_sec();
  859|       |
  860|  10.5M|    unsigned mouse_event_ts = mp_input_get_mouse_event_counter(mpctx->input);
  861|  10.5M|    if (mpctx->mouse_event_ts != mouse_event_ts) {
  ------------------
  |  Branch (861:9): [True: 2.80M, False: 7.69M]
  ------------------
  862|  2.80M|        mpctx->mouse_event_ts = mouse_event_ts;
  863|  2.80M|        mpctx->mouse_timer = now + opts->cursor_autohide_delay / 1000.0;
  864|  2.80M|        mouse_cursor_visible = true;
  865|  2.80M|    }
  866|       |
  867|  10.5M|    if (mpctx->mouse_timer > now) {
  ------------------
  |  Branch (867:9): [True: 2.91M, False: 7.59M]
  ------------------
  868|  2.91M|        mp_set_timeout(mpctx, mpctx->mouse_timer - now);
  869|  7.59M|    } else {
  870|  7.59M|        mouse_cursor_visible = false;
  871|  7.59M|    }
  872|       |
  873|  10.5M|    if (opts->cursor_autohide_delay == -1)
  ------------------
  |  Branch (873:9): [True: 0, False: 10.5M]
  ------------------
  874|      0|        mouse_cursor_visible = true;
  875|       |
  876|  10.5M|    if (opts->cursor_autohide_delay == -2)
  ------------------
  |  Branch (876:9): [True: 0, False: 10.5M]
  ------------------
  877|      0|        mouse_cursor_visible = false;
  878|       |
  879|  10.5M|    if (opts->cursor_autohide_fs && !opts->vo->fullscreen)
  ------------------
  |  Branch (879:9): [True: 304, False: 10.5M]
  |  Branch (879:37): [True: 304, False: 0]
  ------------------
  880|    304|        mouse_cursor_visible = true;
  881|       |
  882|  10.5M|    if (mouse_cursor_visible != mpctx->mouse_cursor_visible)
  ------------------
  |  Branch (882:9): [True: 22.6k, False: 10.4M]
  ------------------
  883|  22.6k|        vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &mouse_cursor_visible);
  884|  10.5M|    mpctx->mouse_cursor_visible = mouse_cursor_visible;
  885|  10.5M|}
playloop.c:handle_vo_events:
  888|  11.6M|{
  889|  11.6M|    struct vo *vo = mpctx->video_out;
  890|  11.6M|    int events = vo ? vo_query_and_reset_events(vo, VO_EVENTS_USER) : 0;
  ------------------
  |  Branch (890:18): [True: 10.5M, False: 1.17M]
  ------------------
  891|  11.6M|    if (events & VO_EVENT_RESIZE)
  ------------------
  |  Branch (891:9): [True: 0, False: 11.6M]
  ------------------
  892|      0|        mp_notify(mpctx, MP_EVENT_WIN_RESIZE, NULL);
  893|  11.6M|    if (events & VO_EVENT_WIN_STATE)
  ------------------
  |  Branch (893:9): [True: 25.1k, False: 11.6M]
  ------------------
  894|  25.1k|        mp_notify(mpctx, MP_EVENT_WIN_STATE, NULL);
  895|  11.6M|    if (events & VO_EVENT_DPI)
  ------------------
  |  Branch (895:9): [True: 0, False: 11.6M]
  ------------------
  896|      0|        mp_notify(mpctx, MP_EVENT_WIN_STATE2, NULL);
  897|  11.6M|    if (events & VO_EVENT_FOCUS)
  ------------------
  |  Branch (897:9): [True: 0, False: 11.6M]
  ------------------
  898|      0|        mp_notify(mpctx, MP_EVENT_FOCUS, NULL);
  899|  11.6M|    if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED)
  ------------------
  |  Branch (899:9): [True: 0, False: 11.6M]
  ------------------
  900|      0|        mp_notify(mpctx, MP_EVENT_AMBIENT_LIGHTING_CHANGED, NULL);
  901|  11.6M|    if (events & VO_EVENT_PRESENTATION_DELAY)
  ------------------
  |  Branch (901:9): [True: 0, False: 11.6M]
  ------------------
  902|      0|        mp_notify(mpctx, MP_EVENT_PRESENTATION_DELAY, NULL);
  903|  11.6M|}
playloop.c:handle_lazy_streams:
 1242|  11.4M|{
 1243|  11.4M|    struct track *track = mpctx->vo_chain ? mpctx->vo_chain->track : NULL;
  ------------------
  |  Branch (1243:27): [True: 10.4M, False: 961k]
  ------------------
 1244|  11.4M|    if (track) {
  ------------------
  |  Branch (1244:9): [True: 10.4M, False: 961k]
  ------------------
 1245|  10.4M|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1246|  10.4M|        if (!track->dec) {
  ------------------
  |  Branch (1246:13): [True: 0, False: 10.4M]
  ------------------
 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|  10.4M|        } else if (mpctx->video_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1257:20): [True: 7.74M, False: 2.70M]
  |  Branch (1257:57): [True: 0, False: 7.74M]
  ------------------
 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|  10.4M|    }
 1262|       |
 1263|  11.4M|    track = mpctx->ao_chain ? mpctx->ao_chain->track : NULL;
  ------------------
  |  Branch (1263:13): [True: 10.6M, False: 753k]
  ------------------
 1264|  11.4M|    if (track) {
  ------------------
  |  Branch (1264:9): [True: 10.6M, False: 753k]
  ------------------
 1265|  10.6M|        bool lazy = demux_stream_eof_is_lazy(track->stream);
 1266|  10.6M|        if (!track->dec) {
  ------------------
  |  Branch (1266:13): [True: 0, False: 10.6M]
  ------------------
 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|  10.6M|        } else if (mpctx->audio_status == STATUS_EOF && lazy) {
  ------------------
  |  Branch (1274:20): [True: 2.31M, False: 8.34M]
  |  Branch (1274:57): [True: 0, False: 2.31M]
  ------------------
 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|  10.6M|    }
 1279|  11.4M|}
playloop.c:handle_playback_restart:
 1160|  11.4M|{
 1161|  11.4M|    struct MPOpts *opts = mpctx->opts;
 1162|       |
 1163|  11.4M|    if (mpctx->audio_status < STATUS_READY ||
  ------------------
  |  Branch (1163:9): [True: 7.26M, False: 4.14M]
  ------------------
 1164|  4.14M|        mpctx->video_status < STATUS_READY)
  ------------------
  |  Branch (1164:9): [True: 383k, False: 3.76M]
  ------------------
 1165|  7.65M|        return;
 1166|       |
 1167|  3.76M|    handle_update_cache(mpctx);
 1168|       |
 1169|  3.76M|    if (mpctx->video_status == STATUS_READY) {
  ------------------
  |  Branch (1169:9): [True: 15.3k, False: 3.74M]
  ------------------
 1170|  15.3k|        mpctx->video_status = STATUS_PLAYING;
 1171|  15.3k|        get_relative_time(mpctx);
 1172|  15.3k|        mp_wakeup_core(mpctx);
 1173|  15.3k|        MP_DBG(mpctx, "starting video playback\n");
  ------------------
  |  |   93|  15.3k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1174|  15.3k|    }
 1175|       |
 1176|  3.76M|    if (mpctx->audio_status == STATUS_READY) {
  ------------------
  |  Branch (1176:9): [True: 920k, False: 2.84M]
  ------------------
 1177|       |        // If a new seek is queued while the current one finishes, don't
 1178|       |        // actually play the audio, but resume seeking immediately.
 1179|   920k|        if (mpctx->seek.type && mpctx->video_status == STATUS_PLAYING) {
  ------------------
  |  Branch (1179:13): [True: 2.25k, False: 918k]
  |  Branch (1179:33): [True: 1.41k, False: 834]
  ------------------
 1180|  1.41k|            handle_playback_time(mpctx);
 1181|  1.41k|            mpctx->seek.flags &= ~MPSEEK_FLAG_DELAY; // immediately
 1182|  1.41k|            execute_queued_seek(mpctx);
 1183|  1.41k|            return;
 1184|  1.41k|        }
 1185|       |
 1186|   919k|        audio_start_ao(mpctx);
 1187|   919k|    }
 1188|       |
 1189|  3.75M|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (1189:9): [True: 2.69M, False: 1.06M]
  ------------------
 1190|  2.69M|        mpctx->hrseek_active = false;
 1191|  2.69M|        mpctx->restart_complete = true;
 1192|  2.69M|        mpctx->current_seek = (struct seek_params){0};
 1193|  2.69M|        handle_playback_time(mpctx);
 1194|  2.69M|        mp_notify(mpctx, MPV_EVENT_PLAYBACK_RESTART, NULL);
 1195|  2.69M|        update_core_idle_state(mpctx);
 1196|  2.69M|        if (!mpctx->playing_msg_shown) {
  ------------------
  |  Branch (1196:13): [True: 14.0k, False: 2.68M]
  ------------------
 1197|  14.0k|            if (opts->playing_msg && opts->playing_msg[0]) {
  ------------------
  |  Branch (1197:17): [True: 0, False: 14.0k]
  |  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|  14.0k|            if (opts->osd_playing_msg && opts->osd_playing_msg[0]) {
  ------------------
  |  Branch (1205:17): [True: 0, False: 14.0k]
  |  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|  14.0k|        }
 1214|  2.69M|        mpctx->playing_msg_shown = true;
 1215|  2.69M|        mp_wakeup_core(mpctx);
 1216|  2.69M|        update_ab_loop_clip(mpctx);
 1217|  2.69M|        MP_VERBOSE(mpctx, "playback restart complete @ %f, audio=%s, video=%s%s\n",
  ------------------
  |  |   92|  2.69M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.39M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 2.60M, False: 95.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|  2.69M|                   mpctx->playback_pts, mp_status_str(mpctx->audio_status),
 1219|  2.69M|                   mp_status_str(mpctx->video_status),
 1220|  2.69M|                   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|  2.69M|        double length = get_time_length(mpctx);
 1225|  2.69M|        if (mpctx->last_seek_pts != MP_NOPTS_VALUE && length >= 0)
  ------------------
  |  |   39|  5.39M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1225:13): [True: 2.69M, False: 0]
  |  Branch (1225:55): [True: 2.69M, False: 0]
  ------------------
 1226|  2.69M|            mpctx->last_seek_pts = MPCLAMP(mpctx->last_seek_pts, 0, length);
  ------------------
  |  |   46|  2.69M|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 125k, False: 2.57M]
  |  |  |  Branch (46:56): [True: 2.06k, False: 2.56M]
  |  |  ------------------
  ------------------
 1227|       |
 1228|       |        // Continuous seeks past EOF => treat as EOF instead of repeating seek.
 1229|  2.69M|        if (mpctx->seek.type == MPSEEK_RELATIVE && mpctx->seek.amount > 0 &&
  ------------------
  |  Branch (1229:13): [True: 2.20k, False: 2.69M]
  |  Branch (1229:52): [True: 833, False: 1.37k]
  ------------------
 1230|    833|            mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1230:13): [True: 815, False: 18]
  ------------------
 1231|    815|            mpctx->audio_status == STATUS_EOF)
  ------------------
  |  Branch (1231:13): [True: 571, False: 244]
  ------------------
 1232|    571|            mpctx->seek = (struct seek_params){0};
 1233|  2.69M|    }
 1234|  3.75M|}
playloop.c:handle_playback_time:
 1135|  14.1M|{
 1136|  14.1M|    if (mpctx->vo_chain &&
  ------------------
  |  Branch (1136:9): [True: 12.9M, False: 1.16M]
  ------------------
 1137|  12.9M|        !mpctx->vo_chain->is_sparse &&
  ------------------
  |  Branch (1137:9): [True: 12.9M, False: 0]
  ------------------
 1138|  12.9M|        mpctx->video_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1138:9): [True: 10.3M, False: 2.55M]
  ------------------
 1139|  10.3M|        mpctx->video_status < STATUS_EOF)
  ------------------
  |  Branch (1139:9): [True: 166k, False: 10.2M]
  ------------------
 1140|   166k|    {
 1141|   166k|        mpctx->playback_pts = mpctx->video_pts;
 1142|  13.9M|    } else if (mpctx->audio_status >= STATUS_PLAYING &&
  ------------------
  |  Branch (1142:16): [True: 6.67M, False: 7.26M]
  ------------------
 1143|  6.67M|               mpctx->audio_status < STATUS_EOF)
  ------------------
  |  Branch (1143:16): [True: 1.83M, False: 4.84M]
  ------------------
 1144|  1.83M|    {
 1145|  1.83M|        mpctx->playback_pts = playing_audio_pts(mpctx);
 1146|  12.1M|    } else if (mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1146:16): [True: 9.56M, False: 2.54M]
  ------------------
 1147|  9.56M|               mpctx->audio_status == STATUS_EOF)
  ------------------
  |  Branch (1147:16): [True: 4.47M, False: 5.09M]
  ------------------
 1148|  4.47M|    {
 1149|  4.47M|        double apts = playing_audio_pts(mpctx);
 1150|  4.47M|        double vpts = mpctx->video_pts;
 1151|  4.47M|        double mpts = MP_PTS_MAX(apts, vpts);
  ------------------
  |  |   65|  4.47M|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  8.94M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 3.00k, False: 4.46M]
  |  |  |  |  |  Branch (44:23): [True: 4.46M, False: 4.40k]
  |  |  |  |  |  Branch (44:29): [True: 4.46M, False: 4.48k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 3.00k]
  |  |  |  |  |  Branch (44:41): [True: 4.46M, False: 1.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|  4.47M|        if (mpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  4.47M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1152:13): [True: 4.64k, False: 4.46M]
  ------------------
 1153|  4.64k|            mpctx->playback_pts = mpts;
 1154|  4.47M|    }
 1155|  14.1M|}
playloop.c:handle_dummy_ticks:
 1121|  11.6M|{
 1122|  11.6M|    if ((mpctx->video_status != STATUS_PLAYING &&
  ------------------
  |  Branch (1122:10): [True: 11.5M, False: 151k]
  ------------------
 1123|  11.5M|         mpctx->video_status != STATUS_DRAINING) ||
  ------------------
  |  Branch (1123:10): [True: 11.5M, False: 8]
  ------------------
 1124|   151k|         mpctx->paused)
  ------------------
  |  Branch (1124:10): [True: 135k, False: 16.1k]
  ------------------
 1125|  11.6M|    {
 1126|  11.6M|        if (mp_time_sec() - mpctx->last_idle_tick > 0.050) {
  ------------------
  |  Branch (1126:13): [True: 20.4k, False: 11.6M]
  ------------------
 1127|  20.4k|            mpctx->last_idle_tick = mp_time_sec();
 1128|       |            mp_notify(mpctx, MPV_EVENT_TICK, NULL);
 1129|  20.4k|        }
 1130|  11.6M|    }
 1131|  11.6M|}
playloop.c:handle_clipboard_updates:
 1323|  11.6M|{
 1324|  11.6M|    if (mp_clipboard_data_changed(mpctx->clipboard))
  ------------------
  |  Branch (1324:9): [True: 0, False: 11.6M]
  ------------------
 1325|      0|        mp_notify_property(mpctx, "clipboard");
 1326|  11.6M|}
playloop.c:handle_update_subtitles:
  834|  11.4M|{
  835|  11.4M|    if (mpctx->video_status == STATUS_EOF) {
  ------------------
  |  Branch (835:9): [True: 8.70M, False: 2.70M]
  ------------------
  836|  8.70M|        update_subtitles(mpctx, mpctx->playback_pts);
  837|  8.70M|        return;
  838|  8.70M|    }
  839|       |
  840|  8.44M|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (840:21): [True: 5.73M, False: 2.70M]
  ------------------
  841|  5.73M|        struct track *track = mpctx->tracks[n];
  842|  5.73M|        if (track->type == STREAM_SUB && !track->demuxer_ready) {
  ------------------
  |  Branch (842:13): [True: 327k, False: 5.40M]
  |  Branch (842:42): [True: 446, False: 327k]
  ------------------
  843|    446|            update_subtitles(mpctx, mpctx->playback_pts);
  844|    446|            break;
  845|    446|        }
  846|  5.73M|    }
  847|  2.70M|}
playloop.c:handle_eof:
 1282|  11.4M|{
 1283|  11.4M|    if (mpctx->seek.type)
  ------------------
  |  Branch (1283:9): [True: 27.4k, False: 11.3M]
  ------------------
 1284|  27.4k|        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|  11.4M|    bool prevent_eof =
 1290|  11.3M|        mpctx->paused && mpctx->video_out && vo_has_frame(mpctx->video_out) &&
  ------------------
  |  Branch (1290:9): [True: 10.7M, False: 678k]
  |  Branch (1290:26): [True: 9.91M, False: 787k]
  |  Branch (1290:46): [True: 165k, False: 9.75M]
  ------------------
 1291|   165k|        !mpctx->vo_chain->is_coverart;
  ------------------
  |  Branch (1291:9): [True: 165k, 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|  11.3M|    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|  11.3M|    if ((mpctx->ao_chain || mpctx->vo_chain) && !prevent_eof &&
  ------------------
  |  Branch (1300:10): [True: 10.6M, False: 752k]
  |  Branch (1300:29): [True: 750k, False: 1.92k]
  |  Branch (1300:49): [True: 11.2M, False: 165k]
  ------------------
 1301|  11.2M|        mpctx->audio_status == STATUS_EOF &&
  ------------------
  |  Branch (1301:9): [True: 3.05M, False: 8.16M]
  ------------------
 1302|  3.05M|        mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (1302:9): [True: 2.68M, False: 375k]
  ------------------
 1303|  2.68M|        !mpctx->stop_play)
  ------------------
  |  Branch (1303:9): [True: 2.68M, False: 0]
  ------------------
 1304|  2.68M|    {
 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|  2.68M|        bool waiting = (mpctx->vo_chain && mpctx->vo_chain->track &&
  ------------------
  |  Branch (1308:25): [True: 2.48M, False: 198k]
  |  Branch (1308:44): [True: 2.48M, False: 0]
  ------------------
 1309|  2.48M|                        !mpctx->vo_chain->track->dec) ||
  ------------------
  |  Branch (1309:25): [True: 0, False: 2.48M]
  ------------------
 1310|  2.68M|                       (mpctx->ao_chain && mpctx->ao_chain->track &&
  ------------------
  |  Branch (1310:25): [True: 2.30M, False: 372k]
  |  Branch (1310:44): [True: 2.30M, False: 0]
  ------------------
 1311|  2.30M|                        !mpctx->ao_chain->track->dec);
  ------------------
  |  Branch (1311:25): [True: 0, False: 2.30M]
  ------------------
 1312|  2.68M|        if (waiting) {
  ------------------
  |  Branch (1312:13): [True: 0, False: 2.68M]
  ------------------
 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|  2.68M|        mpctx->stop_play = AT_END_OF_FILE;
 1319|  2.68M|    }
 1320|  11.3M|}
playloop.c:handle_loop_file:
  925|  11.4M|{
  926|  11.4M|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (926:9): [True: 8.73M, False: 2.68M]
  ------------------
  927|  8.73M|        return;
  928|       |
  929|  2.68M|    double target = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  930|  2.68M|    enum seek_precision prec = MPSEEK_DEFAULT;
  931|       |
  932|  2.68M|    double ab[2];
  933|  2.68M|    if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) {
  ------------------
  |  Branch (933:9): [True: 1.78M, False: 895k]
  |  Branch (933:41): [True: 1.78M, False: 98]
  ------------------
  934|  1.78M|        if (mpctx->remaining_ab_loops > 0) {
  ------------------
  |  Branch (934:13): [True: 2, False: 1.78M]
  ------------------
  935|      2|            mpctx->remaining_ab_loops--;
  936|      2|            mp_notify_property(mpctx, "remaining-ab-loops");
  937|      2|        }
  938|  1.78M|        target = ab[0];
  939|  1.78M|        prec = MPSEEK_EXACT;
  940|  1.78M|    } else if (mpctx->remaining_file_loops) {
  ------------------
  |  Branch (940:16): [True: 891k, False: 4.65k]
  ------------------
  941|   891k|        if (mpctx->remaining_file_loops > 0) {
  ------------------
  |  Branch (941:13): [True: 24.4k, False: 866k]
  ------------------
  942|  24.4k|            mpctx->remaining_file_loops--;
  943|  24.4k|            mp_notify_property(mpctx, "remaining-file-loops");
  944|  24.4k|        }
  945|   891k|        target = get_start_time(mpctx, mpctx->play_dir);
  946|   891k|    }
  947|       |
  948|  2.68M|    if (target != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  2.68M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (948:9): [True: 2.67M, False: 4.65k]
  ------------------
  949|  2.67M|        if (!mpctx->shown_aframes && !mpctx->shown_vframes) {
  ------------------
  |  Branch (949:13): [True: 246k, False: 2.42M]
  |  Branch (949:38): [True: 43, False: 246k]
  ------------------
  950|     43|            MP_WARN(mpctx, "No media data to loop.\n");
  ------------------
  |  |   90|     43|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     43|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  951|     43|            return;
  952|     43|        }
  953|       |
  954|  2.67M|        mpctx->stop_play = KEEP_PLAYING;
  955|  2.67M|        set_osd_function(mpctx, OSD_FFW);
  956|  2.67M|        mark_seek(mpctx);
  957|       |
  958|       |        // Assumes execute_queued_seek() happens before next audio/video is
  959|       |        // attempted to be decoded or filtered.
  960|  2.67M|        queue_seek(mpctx, MPSEEK_ABSOLUTE, target, prec, MPSEEK_FLAG_NOFLUSH);
  961|  2.67M|    }
  962|  2.68M|}
playloop.c:handle_keep_open:
  994|  11.4M|{
  995|  11.4M|    struct MPOpts *opts = mpctx->opts;
  996|  11.4M|    if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE &&
  ------------------
  |  Branch (996:9): [True: 585, False: 11.4M]
  |  Branch (996:28): [True: 184, False: 401]
  ------------------
  997|    184|        (opts->keep_open == 2 ||
  ------------------
  |  Branch (997:10): [True: 30, False: 154]
  ------------------
  998|    154|        (!playlist_get_next(mpctx->playlist, 1) && opts->loop_times == 1)))
  ------------------
  |  Branch (998:10): [True: 154, False: 0]
  |  Branch (998:52): [True: 154, False: 0]
  ------------------
  999|    184|    {
 1000|    184|        mpctx->stop_play = KEEP_PLAYING;
 1001|    184|        if (mpctx->vo_chain) {
  ------------------
  |  Branch (1001:13): [True: 146, False: 38]
  ------------------
 1002|    146|            if (!vo_has_frame(mpctx->video_out)) { // EOF not reached normally
  ------------------
  |  Branch (1002:17): [True: 146, False: 0]
  ------------------
 1003|    146|                seek_to_last_frame(mpctx);
 1004|    146|                mpctx->audio_status = STATUS_EOF;
 1005|    146|                mpctx->video_status = STATUS_EOF;
 1006|    146|            }
 1007|    146|        }
 1008|    184|        if (opts->keep_open_pause) {
  ------------------
  |  Branch (1008:13): [True: 184, False: 0]
  ------------------
 1009|    184|            if (mpctx->ao && ao_is_playing(mpctx->ao))
  ------------------
  |  Branch (1009:17): [True: 157, False: 27]
  |  Branch (1009:30): [True: 14, False: 143]
  ------------------
 1010|     14|                return;
 1011|    170|            set_pause_state(mpctx, true);
 1012|    170|        }
 1013|    184|    }
 1014|  11.4M|}
playloop.c:handle_sstep:
  906|  11.4M|{
  907|  11.4M|    struct MPOpts *opts = mpctx->opts;
  908|  11.4M|    if (mpctx->stop_play || !mpctx->restart_complete)
  ------------------
  |  Branch (908:9): [True: 4.51k, False: 11.4M]
  |  Branch (908:29): [True: 7.63M, False: 3.76M]
  ------------------
  909|  7.64M|        return;
  910|       |
  911|  3.76M|    if (opts->step_sec > 0 && !mpctx->paused) {
  ------------------
  |  Branch (911:9): [True: 988, False: 3.76M]
  |  Branch (911:31): [True: 115, False: 873]
  ------------------
  912|    115|        set_osd_function(mpctx, OSD_FFW);
  913|    115|        queue_seek(mpctx, MPSEEK_RELATIVE, opts->step_sec, MPSEEK_DEFAULT, 0);
  914|    115|    }
  915|       |
  916|  3.76M|    if (mpctx->video_status >= STATUS_EOF) {
  ------------------
  |  Branch (916:9): [True: 3.61M, False: 155k]
  ------------------
  917|  3.61M|        if (mpctx->max_frames >= 0 && !mpctx->stop_play)
  ------------------
  |  Branch (917:13): [True: 0, False: 3.61M]
  |  Branch (917:39): [True: 0, False: 0]
  ------------------
  918|      0|            mpctx->stop_play = AT_END_OF_FILE; // force EOF even if audio left
  919|  3.61M|        if (mpctx->step_frames > 0 && !mpctx->paused)
  ------------------
  |  Branch (919:13): [True: 2.16k, False: 3.61M]
  |  Branch (919:39): [True: 2.16k, False: 0]
  ------------------
  920|  2.16k|            set_pause_state(mpctx, true);
  921|  3.61M|    }
  922|  3.76M|}
playloop.c:handle_osd_redraw:
  679|  11.6M|{
  680|  11.6M|    if (!mpctx->video_out || !mpctx->video_out->config_ok || (mpctx->playing && mpctx->stop_play))
  ------------------
  |  Branch (680:9): [True: 1.17M, False: 10.5M]
  |  Branch (680:30): [True: 4.36M, False: 6.13M]
  |  Branch (680:63): [True: 6.12M, False: 6.15k]
  |  Branch (680:81): [True: 38.6k, False: 6.08M]
  ------------------
  681|  5.57M|        return;
  682|       |    // If we're playing normally, let OSD be redrawn naturally as part of
  683|       |    // video display.
  684|  6.09M|    if (!mpctx->paused) {
  ------------------
  |  Branch (684:9): [True: 197k, False: 5.89M]
  ------------------
  685|   197k|        if (mpctx->sleeptime < 0.1 && mpctx->video_status == STATUS_PLAYING)
  ------------------
  |  Branch (685:13): [True: 166k, False: 30.7k]
  |  Branch (685:39): [True: 15.5k, False: 151k]
  ------------------
  686|  15.5k|            return;
  687|   197k|    }
  688|       |    // Don't redraw immediately during a seek (makes it significantly slower).
  689|  6.09M|    bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (689:22): [True: 6.06M, False: 12.4k]
  |  Branch (689:41): [True: 6.06M, False: 0]
  ------------------
  690|  6.07M|    if (use_video && mp_time_sec() - mpctx->start_timestamp < 0.1) {
  ------------------
  |  Branch (690:9): [True: 6.06M, False: 12.4k]
  |  Branch (690:22): [True: 5.89M, False: 166k]
  ------------------
  691|  5.89M|        mp_set_timeout(mpctx, 0.1);
  692|  5.89M|        return;
  693|  5.89M|    }
  694|  6.07M|    bool want_redraw = osd_query_and_reset_want_redraw(mpctx->osd) ||
  ------------------
  |  Branch (694:24): [True: 57.0k, False: 121k]
  ------------------
  695|   121k|                       vo_want_redraw(mpctx->video_out);
  ------------------
  |  Branch (695:24): [True: 0, False: 121k]
  ------------------
  696|   178k|    if (!want_redraw)
  ------------------
  |  Branch (696:9): [True: 121k, False: 57.0k]
  ------------------
  697|   121k|        return;
  698|  57.0k|    vo_redraw(mpctx->video_out);
  699|  57.0k|}
playloop.c:handle_update_cache:
  715|  15.4M|{
  716|  15.4M|    bool force_update = false;
  717|  15.4M|    struct MPOpts *opts = mpctx->opts;
  718|       |
  719|  15.4M|    if (!mpctx->demuxer || mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (719:9): [True: 250k, False: 15.1M]
  |  Branch (719:28): [True: 0, False: 15.1M]
  ------------------
  720|   250k|        clear_underruns(mpctx);
  721|   250k|        return;
  722|   250k|    }
  723|       |
  724|  15.1M|    double now = mp_time_sec();
  725|       |
  726|  15.1M|    struct demux_reader_state s;
  727|  15.1M|    demux_get_reader_state(mpctx->demuxer, &s);
  728|       |
  729|  15.1M|    mpctx->demux_underrun |= s.underrun;
  730|       |
  731|  15.1M|    int cache_buffer = 100;
  732|  15.1M|    bool use_pause_on_low_cache = opts->cache_pause && mpctx->play_dir > 0;
  ------------------
  |  Branch (732:35): [True: 15.1M, False: 0]
  |  Branch (732:56): [True: 14.8M, False: 347k]
  ------------------
  733|       |
  734|  15.1M|    if (!mpctx->restart_complete) {
  ------------------
  |  Branch (734:9): [True: 13.0M, False: 2.14M]
  ------------------
  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|  13.0M|        use_pause_on_low_cache &= opts->cache_pause_initial &&
  ------------------
  |  Branch (738:35): [True: 0, False: 13.0M]
  ------------------
  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|  13.0M|    }
  742|       |
  743|  15.1M|    bool is_low = use_pause_on_low_cache && !s.idle &&
  ------------------
  |  Branch (743:19): [True: 2.13M, False: 13.0M]
  |  Branch (743:45): [True: 33.5k, False: 2.09M]
  ------------------
  744|  33.5k|                  s.ts_info.duration < opts->cache_pause_wait;
  ------------------
  |  Branch (744:19): [True: 33.5k, False: 0]
  ------------------
  745|       |
  746|       |    // Enter buffering state only if there actually was an underrun (or if
  747|       |    // initial caching before playback restart is used).
  748|  15.1M|    bool need_wait = is_low;
  749|  15.1M|    if (is_low && !mpctx->paused_for_cache && mpctx->restart_complete) {
  ------------------
  |  Branch (749:9): [True: 33.5k, False: 15.1M]
  |  Branch (749:19): [True: 33.5k, False: 0]
  |  Branch (749:47): [True: 33.5k, False: 0]
  ------------------
  750|       |        // Wait only if an output underrun was registered. (Or if there is no
  751|       |        // underrun detection.)
  752|  33.5k|        bool output_underrun = false;
  753|       |
  754|  33.5k|        if (mpctx->ao_chain)
  ------------------
  |  Branch (754:13): [True: 33.3k, False: 181]
  ------------------
  755|  33.3k|            output_underrun |= mpctx->ao_chain->underrun;
  756|  33.5k|        if (mpctx->vo_chain)
  ------------------
  |  Branch (756:13): [True: 16.7k, False: 16.8k]
  ------------------
  757|  16.7k|            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|  33.5k|        need_wait = mpctx->demux_underrun && output_underrun;
  ------------------
  |  Branch (763:21): [True: 24.0k, False: 9.52k]
  |  Branch (763:46): [True: 0, False: 24.0k]
  ------------------
  764|  33.5k|    }
  765|       |
  766|       |    // Let the underrun flag "stick" around until the cache has fully recovered.
  767|       |    // See logic where demux_underrun is used.
  768|  15.1M|    if (!is_low)
  ------------------
  |  Branch (768:9): [True: 15.1M, False: 33.5k]
  ------------------
  769|  15.1M|        mpctx->demux_underrun = false;
  770|       |
  771|  15.1M|    if (mpctx->paused_for_cache != need_wait) {
  ------------------
  |  Branch (771:9): [True: 0, False: 15.1M]
  ------------------
  772|      0|        mpctx->paused_for_cache = need_wait;
  773|      0|        update_internal_pause_state(mpctx);
  774|      0|        force_update = true;
  775|      0|        if (mpctx->paused_for_cache)
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            mpctx->cache_stop_time = now;
  777|      0|    }
  778|       |
  779|  15.1M|    if (!mpctx->paused_for_cache)
  ------------------
  |  Branch (779:9): [True: 15.1M, False: 0]
  ------------------
  780|  15.1M|        clear_underruns(mpctx);
  781|       |
  782|  15.1M|    if (mpctx->paused_for_cache) {
  ------------------
  |  Branch (782:9): [True: 0, False: 15.1M]
  ------------------
  783|      0|        cache_buffer =
  784|      0|            100 * MPCLAMP(s.ts_info.duration / opts->cache_pause_wait, 0, 0.99);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  785|      0|        mp_set_timeout(mpctx, 0.2);
  786|      0|    }
  787|       |
  788|       |    // Also update cache properties.
  789|  15.1M|    bool busy = !s.idle;
  790|  15.1M|    if (fabs(mpctx->cache_update_pts - mpctx->playback_pts) >= 1.0)
  ------------------
  |  Branch (790:9): [True: 320k, False: 14.8M]
  ------------------
  791|   320k|        busy = true;
  792|  15.1M|    if (busy || mpctx->next_cache_update > 0) {
  ------------------
  |  Branch (792:9): [True: 3.52M, False: 11.6M]
  |  Branch (792:17): [True: 11.6M, False: 18.8k]
  ------------------
  793|  15.1M|        if (mpctx->next_cache_update <= now) {
  ------------------
  |  Branch (793:13): [True: 13.6k, False: 15.1M]
  ------------------
  794|  13.6k|            mpctx->next_cache_update = busy ? now + 0.25 : 0;
  ------------------
  |  Branch (794:40): [True: 12.8k, False: 780]
  ------------------
  795|  13.6k|            force_update = true;
  796|  13.6k|        }
  797|  15.1M|        if (mpctx->next_cache_update > 0)
  ------------------
  |  Branch (797:13): [True: 15.1M, False: 780]
  ------------------
  798|  15.1M|            mp_set_timeout(mpctx, mpctx->next_cache_update - now);
  799|  15.1M|    }
  800|       |
  801|  15.1M|    if (mpctx->cache_buffer != cache_buffer) {
  ------------------
  |  Branch (801:9): [True: 0, False: 15.1M]
  ------------------
  802|      0|        if ((mpctx->cache_buffer == 100) != (cache_buffer == 100)) {
  ------------------
  |  Branch (802:13): [True: 0, False: 0]
  ------------------
  803|      0|            if (cache_buffer < 100) {
  ------------------
  |  Branch (803:17): [True: 0, False: 0]
  ------------------
  804|      0|                MP_VERBOSE(mpctx, "Enter buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  805|      0|                           mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  806|      0|            } else {
  807|      0|                double t = now - mpctx->cache_stop_time;
  808|      0|                MP_VERBOSE(mpctx, "End buffering (waited %f secs) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  809|      0|                           t, s.ts_info.duration);
  810|      0|            }
  811|      0|        } else {
  812|      0|            MP_VERBOSE(mpctx, "Still buffering (buffer went from %d%% -> %d%%) [%fs].\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  813|      0|                       mpctx->cache_buffer, cache_buffer, s.ts_info.duration);
  814|      0|        }
  815|      0|        mpctx->cache_buffer = cache_buffer;
  816|      0|        force_update = true;
  817|      0|    }
  818|       |
  819|  15.1M|    if (s.eof && !busy)
  ------------------
  |  Branch (819:9): [True: 11.9M, False: 3.26M]
  |  Branch (819:18): [True: 11.6M, False: 289k]
  ------------------
  820|  11.6M|        prefetch_next(mpctx);
  821|       |
  822|  15.1M|    if (force_update) {
  ------------------
  |  Branch (822:9): [True: 13.6k, False: 15.1M]
  ------------------
  823|  13.6k|        mpctx->cache_update_pts = mpctx->playback_pts;
  824|       |        mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
  825|  13.6k|    }
  826|  15.1M|}
playloop.c:clear_underruns:
  702|  15.4M|{
  703|  15.4M|    if (mpctx->ao_chain && mpctx->ao_chain->underrun) {
  ------------------
  |  Branch (703:9): [True: 14.0M, False: 1.39M]
  |  Branch (703:28): [True: 0, False: 14.0M]
  ------------------
  704|      0|        mpctx->ao_chain->underrun = false;
  705|      0|        mp_wakeup_core(mpctx);
  706|      0|    }
  707|       |
  708|  15.4M|    if (mpctx->vo_chain && mpctx->vo_chain->underrun) {
  ------------------
  |  Branch (708:9): [True: 13.9M, False: 1.49M]
  |  Branch (708:28): [True: 8, False: 13.9M]
  ------------------
  709|       |        mpctx->vo_chain->underrun = false;
  710|      8|        mp_wakeup_core(mpctx);
  711|      8|    }
  712|  15.4M|}
playloop.c:mp_process_input:
  111|  11.6M|{
  112|  11.6M|    bool notify = false;
  113|  11.6M|    for (;;) {
  114|  11.6M|        mp_cmd_t *cmd = mp_input_read_cmd(mpctx->input);
  115|  11.6M|        if (!cmd)
  ------------------
  |  Branch (115:13): [True: 11.6M, False: 3]
  ------------------
  116|  11.6M|            break;
  117|      3|        if (cmd->notify_event)
  ------------------
  |  Branch (117:13): [True: 3, False: 0]
  ------------------
  118|      3|            notify = true;
  119|      3|        run_command(mpctx, cmd, NULL, NULL, NULL);
  120|      3|    }
  121|  11.6M|    mp_set_timeout(mpctx, mp_input_get_delay(mpctx->input));
  122|  11.6M|    if (notify)
  ------------------
  |  Branch (122:9): [True: 3, False: 11.6M]
  ------------------
  123|      3|        mp_notify(mpctx, MP_EVENT_INPUT_PROCESSED, NULL);
  124|  11.6M|}
playloop.c:handle_chapter_change:
 1017|  11.4M|{
 1018|  11.4M|    int chapter = get_current_chapter(mpctx);
 1019|  11.4M|    if (chapter != mpctx->last_chapter) {
  ------------------
  |  Branch (1019:9): [True: 0, False: 11.4M]
  ------------------
 1020|      0|        mpctx->last_chapter = chapter;
 1021|       |        mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
 1022|      0|    }
 1023|  11.4M|}

screenshot_init:
   64|  11.6k|{
   65|  11.6k|    mpctx->screenshot_ctx = talloc(mpctx, screenshot_ctx);
  ------------------
  |  |   26|  11.6k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  11.6k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|  11.6k|    *mpctx->screenshot_ctx = (screenshot_ctx) {
   67|  11.6k|        .mpctx = mpctx,
   68|  11.6k|        .frameno = 1,
   69|  11.6k|        .log = mp_log_new(mpctx, mpctx->log, "screenshot")
   70|  11.6k|    };
   71|  11.6k|}
convert_image:
  434|    770|{
  435|    770|    int d_w, d_h;
  436|    770|    mp_image_params_get_dsize(&image->params, &d_w, &d_h);
  437|       |
  438|    770|    struct mp_image_params p = {
  439|    770|        .imgfmt = destfmt,
  440|    770|        .w = d_w,
  441|    770|        .h = d_h,
  442|    770|        .p_w = 1,
  443|    770|        .p_h = 1,
  444|    770|    };
  445|    770|    mp_image_params_guess_csp(&p);
  446|       |
  447|    770|    if (mp_image_params_equal(&p, &image->params))
  ------------------
  |  Branch (447:9): [True: 0, False: 770]
  ------------------
  448|      0|        return mp_image_new_ref(image);
  449|       |
  450|    770|    struct mp_image *dst = mp_image_alloc(p.imgfmt, p.w, p.h);
  451|    770|    if (!dst) {
  ------------------
  |  Branch (451:9): [True: 5, False: 765]
  ------------------
  452|      5|        mp_err(log, "Out of memory.\n");
  ------------------
  |  |   76|      5|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  453|      5|        return NULL;
  454|      5|    }
  455|    765|    mp_image_copy_attributes(dst, image);
  456|       |
  457|    765|    dst->params = p;
  458|       |
  459|    765|    struct mp_sws_context *sws = mp_sws_alloc(NULL);
  460|    765|    sws->log = log;
  461|    765|    if (global)
  ------------------
  |  Branch (461:9): [True: 765, False: 0]
  ------------------
  462|    765|        mp_sws_enable_cmdline_opts(sws, global);
  463|    765|    bool ok = mp_sws_scale(sws, dst, image) >= 0;
  464|    765|    talloc_free(sws);
  ------------------
  |  |   47|    765|#define talloc_free                     ta_free
  ------------------
  465|       |
  466|    765|    if (!ok) {
  ------------------
  |  Branch (466:9): [True: 0, False: 765]
  ------------------
  467|      0|        mp_err(log, "Error when converting image.\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  468|      0|        talloc_free(dst);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  469|      0|        return NULL;
  470|      0|    }
  471|       |
  472|    765|    return dst;
  473|    765|}
cmd_screenshot_to_file:
  489|     34|{
  490|     34|    struct mp_cmd_ctx *cmd = p;
  491|     34|    struct MPContext *mpctx = cmd->mpctx;
  492|     34|    const char *filename = cmd->args[0].v.s;
  493|     34|    int mode = cmd->args[1].v.i;
  494|     34|    struct image_writer_opts opts = *mpctx->opts->screenshot_image_opts;
  495|       |
  496|     34|    int format = image_writer_format_from_ext(mp_get_ext(bstr0(filename)));
  497|     34|    if (format)
  ------------------
  |  Branch (497:9): [True: 0, False: 34]
  ------------------
  498|      0|        opts.format = format;
  499|     34|    bool high_depth = image_writer_high_depth(&opts);
  500|     34|    struct mp_image *image = screenshot_get(mpctx, mode, high_depth);
  501|     34|    if (!image) {
  ------------------
  |  Branch (501:9): [True: 19, False: 15]
  ------------------
  502|     19|        mp_cmd_msg(cmd, MSGL_ERR, "Taking screenshot failed.");
  503|     19|        cmd->success = false;
  504|     19|        return;
  505|     19|    }
  506|     15|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
  507|     15|    cmd->success = write_screenshot(cmd, image, path, &opts, true);
  508|     15|    talloc_free(image);
  ------------------
  |  |   47|     15|#define talloc_free                     ta_free
  ------------------
  509|     15|    talloc_free(path);
  ------------------
  |  |   47|     15|#define talloc_free                     ta_free
  ------------------
  510|     15|}
cmd_screenshot:
  513|  59.1k|{
  514|  59.1k|    struct mp_cmd_ctx *cmd = p;
  515|  59.1k|    struct MPContext *mpctx = cmd->mpctx;
  516|  59.1k|    struct mpv_node *res = &cmd->result;
  517|  59.1k|    int mode = cmd->args[0].v.i & 7;
  518|  59.1k|    bool each_frame_toggle = (cmd->args[0].v.i | cmd->args[1].v.i) & 8;
  519|  59.1k|    bool each_frame_mode = cmd->args[0].v.i & 16;
  520|       |
  521|  59.1k|    screenshot_ctx *ctx = mpctx->screenshot_ctx;
  522|       |
  523|  59.1k|    if ((mode & MODE_SUBTITLES) && osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  |   49|  59.1k|#define MODE_SUBTITLES 2
  ------------------
  |  Branch (523:9): [True: 59.1k, False: 13]
  |  Branch (523:36): [True: 0, False: 59.1k]
  ------------------
  524|      0|        mode &= ~MODE_SUBTITLES;
  ------------------
  |  |   49|      0|#define MODE_SUBTITLES 2
  ------------------
  525|       |
  526|  59.1k|    if (!each_frame_mode) {
  ------------------
  |  Branch (526:9): [True: 59.1k, False: 0]
  ------------------
  527|  59.1k|        if (each_frame_toggle) {
  ------------------
  |  Branch (527:13): [True: 0, False: 59.1k]
  ------------------
  528|      0|            if (ctx->each_frame) {
  ------------------
  |  Branch (528:17): [True: 0, False: 0]
  ------------------
  529|      0|                TA_FREEP(&ctx->each_frame);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  530|      0|                return;
  531|      0|            }
  532|      0|            ctx->each_frame = talloc_steal(ctx, mp_cmd_clone(cmd->cmd));
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  533|      0|            ctx->each_frame->args[0].v.i |= 16;
  534|  59.1k|        } else {
  535|  59.1k|            TA_FREEP(&ctx->each_frame);
  ------------------
  |  |   81|  59.1k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  59.1k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 59.1k]
  |  |  ------------------
  ------------------
  536|  59.1k|        }
  537|  59.1k|    }
  538|       |
  539|  59.1k|    cmd->success = false;
  540|       |
  541|  59.1k|    struct image_writer_opts *opts = mpctx->opts->screenshot_image_opts;
  542|  59.1k|    bool high_depth = image_writer_high_depth(opts);
  543|       |
  544|  59.1k|    struct mp_image *image = screenshot_get(mpctx, mode, high_depth);
  545|       |
  546|  59.1k|    if (image) {
  ------------------
  |  Branch (546:9): [True: 34.4k, False: 24.7k]
  ------------------
  547|  34.4k|        char *filename = gen_fname(cmd, image_writer_file_ext(opts));
  548|  34.4k|        if (filename) {
  ------------------
  |  Branch (548:13): [True: 34.4k, False: 0]
  ------------------
  549|  34.4k|            cmd->success = write_screenshot(cmd, image, filename, NULL, false);
  550|  34.4k|            if (cmd->success) {
  ------------------
  |  Branch (550:17): [True: 0, False: 34.4k]
  ------------------
  551|      0|                node_init(res, MPV_FORMAT_NODE_MAP, NULL);
  552|      0|                node_map_add_string(res, "filename", filename);
  553|      0|            }
  554|  34.4k|        }
  555|  34.4k|        talloc_free(filename);
  ------------------
  |  |   47|  34.4k|#define talloc_free                     ta_free
  ------------------
  556|  34.4k|    } else {
  557|  24.7k|        mp_cmd_msg(cmd, MSGL_ERR, "Taking screenshot failed.");
  558|  24.7k|    }
  559|       |
  560|  59.1k|    talloc_free(image);
  ------------------
  |  |   47|  59.1k|#define talloc_free                     ta_free
  ------------------
  561|  59.1k|}
cmd_screenshot_raw:
  564|  1.30k|{
  565|  1.30k|    struct mp_cmd_ctx *cmd = p;
  566|  1.30k|    struct MPContext *mpctx = cmd->mpctx;
  567|  1.30k|    struct mpv_node *res = &cmd->result;
  568|       |
  569|  1.30k|    const enum mp_imgfmt formats[] = {IMGFMT_BGR0, IMGFMT_BGRA, IMGFMT_RGBA, IMGFMT_RGBA64};
  570|  1.30k|    const char *format_names[] = {"bgr0", "bgra", "rgba", "rgba64"};
  571|  1.30k|    int idx = cmd->args[1].v.i;
  572|  1.30k|    mp_assert(idx >= 0 && idx <= 3);
  ------------------
  |  |   41|  1.30k|#define mp_assert assert
  ------------------
  |  Branch (572:5): [True: 1.30k, False: 0]
  |  Branch (572:5): [True: 1.30k, False: 0]
  ------------------
  573|       |
  574|  1.30k|    bool high_depth = formats[idx] == IMGFMT_RGBA64;
  575|  1.30k|    struct mp_image *img = screenshot_get_rgb(mpctx, cmd->args[0].v.i,
  576|  1.30k|                                              high_depth, formats[idx]);
  577|  1.30k|    if (!img) {
  ------------------
  |  Branch (577:9): [True: 539, False: 765]
  ------------------
  578|    539|        cmd->success = false;
  579|    539|        return;
  580|    539|    }
  581|       |
  582|    765|    node_init(res, MPV_FORMAT_NODE_MAP, NULL);
  583|    765|    node_map_add_int64(res, "w", img->w);
  584|    765|    node_map_add_int64(res, "h", img->h);
  585|    765|    node_map_add_int64(res, "stride", img->stride[0]);
  586|    765|    node_map_add_string(res, "format", format_names[idx]);
  587|    765|    struct mpv_byte_array *ba =
  588|    765|        node_map_add(res, "data", MPV_FORMAT_BYTE_ARRAY)->u.ba;
  589|    765|    *ba = (struct mpv_byte_array){
  590|    765|        .data = img->planes[0],
  591|    765|        .size = img->stride[0] * img->h,
  592|    765|    };
  593|    765|    talloc_steal(ba, img);
  ------------------
  |  |   38|    765|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    765|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  594|    765|}
handle_each_frame_screenshot:
  607|  11.4M|{
  608|  11.4M|    screenshot_ctx *ctx = mpctx->screenshot_ctx;
  609|       |
  610|  11.4M|    if (!ctx->each_frame)
  ------------------
  |  Branch (610:9): [True: 11.4M, False: 0]
  ------------------
  611|  11.4M|        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|}
screenshot.c:screenshot_get:
  347|  60.5k|{
  348|  60.5k|    struct mp_image *image = NULL;
  349|  60.5k|    const struct image_writer_opts *imgopts = mpctx->opts->screenshot_image_opts;
  350|  60.5k|    if ((mode & MODE_SUBTITLES) && osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  |   49|  60.5k|#define MODE_SUBTITLES 2
  ------------------
  |  Branch (350:9): [True: 60.5k, False: 13]
  |  Branch (350:36): [True: 0, False: 60.5k]
  ------------------
  351|      0|        mode &= ~MODE_SUBTITLES;
  ------------------
  |  |   49|      0|#define MODE_SUBTITLES 2
  ------------------
  352|       |
  353|  60.5k|    if (!mpctx->video_out || !mpctx->video_out->config_ok)
  ------------------
  |  Branch (353:9): [True: 19.9k, False: 40.5k]
  |  Branch (353:30): [True: 3.94k, False: 36.6k]
  ------------------
  354|  23.9k|        return NULL;
  355|       |
  356|  36.6k|    vo_wait_frame(mpctx->video_out); // important for each-frame mode
  357|       |
  358|  36.6k|    bool use_sw = mpctx->opts->screenshot_sw;
  359|  36.6k|    bool scaled = mode & MODE_SCALED;
  ------------------
  |  |   48|  36.6k|#define MODE_SCALED 1
  ------------------
  360|  36.6k|    bool subs = mode & MODE_SUBTITLES;
  ------------------
  |  |   49|  36.6k|#define MODE_SUBTITLES 2
  ------------------
  361|  36.6k|    bool osd = mode & MODE_OSD;
  ------------------
  |  |   50|  36.6k|#define MODE_OSD 4
  ------------------
  362|  36.6k|    struct voctrl_screenshot ctrl = {
  363|  36.6k|        .scaled = scaled,
  364|  36.6k|        .subs = subs,
  365|  36.6k|        .osd = osd,
  366|  36.6k|        .high_bit_depth = high_depth && imgopts->high_bit_depth,
  ------------------
  |  Branch (366:27): [True: 943, False: 35.6k]
  |  Branch (366:41): [True: 943, False: 0]
  ------------------
  367|  36.6k|        .native_csp = image_writer_flexible_csp(imgopts),
  368|  36.6k|    };
  369|  36.6k|    if (!use_sw)
  ------------------
  |  Branch (369:9): [True: 36.6k, False: 0]
  ------------------
  370|  36.6k|        vo_control(mpctx->video_out, VOCTRL_SCREENSHOT, &ctrl);
  371|  36.6k|    image = ctrl.res;
  372|       |
  373|       |    // VOCTRL_SCREENSHOT_WIN gets the complete rendered image so it's only
  374|       |    // usable for scaled+sub+osd screenshots.
  375|  36.6k|    if (!use_sw && !image && scaled && subs && osd)
  ------------------
  |  Branch (375:9): [True: 36.6k, False: 0]
  |  Branch (375:20): [True: 36.6k, False: 0]
  |  Branch (375:30): [True: 0, False: 36.6k]
  |  Branch (375:40): [True: 0, False: 0]
  |  Branch (375:48): [True: 0, False: 0]
  ------------------
  376|      0|        vo_control(mpctx->video_out, VOCTRL_SCREENSHOT_WIN, &image);
  377|       |
  378|  36.6k|    if (!image) {
  ------------------
  |  Branch (378:9): [True: 36.6k, False: 0]
  ------------------
  379|  36.6k|        use_sw = true;
  380|  36.6k|        MP_VERBOSE(mpctx->screenshot_ctx, "Falling back to software screenshot.\n");
  ------------------
  |  |   92|  36.6k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  36.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  381|  36.6k|        image = vo_get_current_frame(mpctx->video_out);
  382|  36.6k|    }
  383|       |
  384|       |    // vo_get_current_frame() can return a hardware frame, which we have to download first.
  385|  36.6k|    if (image && IMGFMT_IS_HWACCEL(image->imgfmt)) {
  ------------------
  |  |  329|  35.2k|#define IMGFMT_IS_HWACCEL(fmt) (!!(mp_imgfmt_get_desc(fmt).flags & MP_IMGFLAG_HWACCEL))
  |  |  ------------------
  |  |  |  |   70|  35.2k|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  |  |  ------------------
  |  |  |  |  |  |   65|  35.2k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 0, False: 35.2k]
  |  |  ------------------
  ------------------
  |  Branch (385:9): [True: 35.2k, False: 1.38k]
  |  Branch (385:9): [True: 0, False: 36.6k]
  ------------------
  386|      0|        struct mp_image *nimage = mp_image_hw_download(image, NULL);
  387|      0|        talloc_free(image);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  388|      0|        if (!nimage)
  ------------------
  |  Branch (388:13): [True: 0, False: 0]
  ------------------
  389|      0|            return NULL;
  390|      0|        image = nimage;
  391|      0|    }
  392|       |
  393|  36.6k|    if (use_sw && image && scaled) {
  ------------------
  |  Branch (393:9): [True: 36.6k, False: 0]
  |  Branch (393:19): [True: 35.2k, False: 1.38k]
  |  Branch (393:28): [True: 0, False: 35.2k]
  ------------------
  394|      0|        if (mp_image_crop_valid(&image->params) &&
  ------------------
  |  Branch (394:13): [True: 0, False: 0]
  ------------------
  395|      0|            (mp_rect_w(image->params.crop) != image->w ||
  ------------------
  |  |  157|      0|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  |  Branch (395:14): [True: 0, False: 0]
  ------------------
  396|      0|             mp_rect_h(image->params.crop) != image->h))
  ------------------
  |  |  158|      0|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (396:14): [True: 0, False: 0]
  ------------------
  397|      0|        {
  398|      0|            struct mp_image *nimage = mp_image_new_ref(image);
  399|      0|            if (!nimage) {
  ------------------
  |  Branch (399:17): [True: 0, False: 0]
  ------------------
  400|      0|                MP_ERR(mpctx->screenshot_ctx, "mp_image_new_ref 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__)
  |  |  ------------------
  ------------------
  401|      0|                return NULL;
  402|      0|            }
  403|      0|            mp_image_crop_rc(nimage, image->params.crop);
  404|      0|            talloc_free(image);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  405|      0|            image = nimage;
  406|      0|        }
  407|      0|        struct mp_osd_res res = osd_get_vo_res(mpctx->video_out->osd);
  408|      0|        struct mp_osd_res image_res = osd_res_from_image_params(&image->params);
  409|      0|        if (!osd_res_equals(res, image_res)) {
  ------------------
  |  Branch (409:13): [True: 0, False: 0]
  ------------------
  410|      0|            struct mp_image *nimage = mp_image_alloc(image->imgfmt, res.w, res.h);
  411|      0|            if (!nimage) {
  ------------------
  |  Branch (411:17): [True: 0, False: 0]
  ------------------
  412|      0|                talloc_free(image);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  413|      0|                return NULL;
  414|      0|            }
  415|      0|            struct mp_sws_context *sws = mp_sws_alloc(NULL);
  416|      0|            mp_sws_scale(sws, nimage, image);
  417|      0|            talloc_free(image);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  418|      0|            talloc_free(sws);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  419|      0|            image = nimage;
  420|      0|        }
  421|      0|    }
  422|       |
  423|  36.6k|    if (!image)
  ------------------
  |  Branch (423:9): [True: 1.38k, False: 35.2k]
  ------------------
  424|  1.38k|        return NULL;
  425|       |
  426|  35.2k|    if (use_sw && mode != 0)
  ------------------
  |  Branch (426:9): [True: 35.2k, False: 0]
  |  Branch (426:19): [True: 35.2k, False: 12]
  ------------------
  427|  35.2k|        add_osd(mpctx, image, mode);
  428|  35.2k|    mp_image_params_guess_csp(&image->params);
  429|  35.2k|    return image;
  430|  36.6k|}
screenshot.c:add_osd:
  332|  35.2k|{
  333|  35.2k|    struct mp_osd_res res = (mode & MODE_SCALED) ? osd_get_vo_res(mpctx->video_out->osd) :
  ------------------
  |  |   48|  35.2k|#define MODE_SCALED 1
  ------------------
  |  Branch (333:29): [True: 0, False: 35.2k]
  ------------------
  334|  35.2k|                            osd_res_from_image_params(&image->params);
  335|  35.2k|    if (mode & MODE_SUBTITLES) {
  ------------------
  |  |   49|  35.2k|#define MODE_SUBTITLES 2
  ------------------
  |  Branch (335:9): [True: 35.2k, False: 0]
  ------------------
  336|  35.2k|        osd_draw_on_image(mpctx->osd, res, mpctx->video_pts,
  337|  35.2k|                          OSD_DRAW_SUB_ONLY, image);
  338|  35.2k|    }
  339|  35.2k|    if (mode & MODE_OSD) {
  ------------------
  |  |   50|  35.2k|#define MODE_OSD 4
  ------------------
  |  Branch (339:9): [True: 0, False: 35.2k]
  ------------------
  340|      0|        osd_draw_on_image(mpctx->osd, res, mpctx->video_pts,
  341|      0|                          OSD_DRAW_OSD_ONLY, image);
  342|      0|    }
  343|  35.2k|}
screenshot.c:write_screenshot:
   76|  34.4k|{
   77|  34.4k|    struct MPContext *mpctx = cmd->mpctx;
   78|  34.4k|    struct image_writer_opts *gopts = mpctx->opts->screenshot_image_opts;
   79|  34.4k|    struct image_writer_opts opts_copy = opts ? *opts : *gopts;
  ------------------
  |  Branch (79:42): [True: 15, False: 34.4k]
  ------------------
   80|       |
   81|  34.4k|    mp_cmd_msg(cmd, MSGL_V, "Starting screenshot: '%s'", filename);
   82|       |
   83|  34.4k|    mp_core_unlock(mpctx);
   84|       |
   85|  34.4k|    bool ok = img && write_image(img, &opts_copy, filename, mpctx->global,
  ------------------
  |  Branch (85:15): [True: 34.4k, False: 0]
  |  Branch (85:22): [True: 0, False: 34.4k]
  ------------------
   86|  34.4k|                                 mpctx->screenshot_ctx->log, overwrite);
   87|       |
   88|  34.4k|    mp_core_lock(mpctx);
   89|       |
   90|  34.4k|    if (ok) {
  ------------------
  |  Branch (90:9): [True: 0, False: 34.4k]
  ------------------
   91|      0|        mp_cmd_msg(cmd, MSGL_INFO, "Screenshot: '%s'", filename);
   92|  34.4k|    } else {
   93|  34.4k|        mp_cmd_msg(cmd, MSGL_ERR, "Error writing screenshot!");
   94|  34.4k|    }
   95|  34.4k|    return ok;
   96|  34.4k|}
screenshot.c:gen_fname:
  286|  34.4k|{
  287|  34.4k|    struct MPContext *mpctx = cmd->mpctx;
  288|  34.4k|    screenshot_ctx *ctx = mpctx->screenshot_ctx;
  289|       |
  290|  34.4k|    int sequence = 0;
  291|  34.4k|    for (;;) {
  292|  34.4k|        int prev_sequence = sequence;
  293|  34.4k|        char *fname = create_fname(ctx->mpctx,
  294|  34.4k|                                   ctx->mpctx->opts->screenshot_template,
  295|  34.4k|                                   file_ext,
  296|  34.4k|                                   &sequence,
  297|  34.4k|                                   &ctx->frameno);
  298|       |
  299|  34.4k|        if (!fname) {
  ------------------
  |  Branch (299:13): [True: 0, False: 34.4k]
  ------------------
  300|      0|            mp_cmd_msg(cmd, MSGL_ERR, "Invalid screenshot filename "
  301|      0|                       "template! Fix or remove the --screenshot-template "
  302|      0|                       "option.");
  303|      0|            return NULL;
  304|      0|        }
  305|       |
  306|  34.4k|        char *dir = ctx->mpctx->opts->screenshot_dir;
  307|  34.4k|        if (dir && dir[0]) {
  ------------------
  |  Branch (307:13): [True: 0, False: 34.4k]
  |  Branch (307:20): [True: 0, False: 0]
  ------------------
  308|      0|            void *t = fname;
  309|      0|            dir = mp_get_user_path(t, ctx->mpctx->global, dir);
  310|      0|            fname = mp_path_join(NULL, dir, fname);
  311|      0|            talloc_free(t);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  312|      0|        }
  313|       |
  314|  34.4k|        char *full_dir = bstrto0(fname, mp_dirname(fname));
  315|  34.4k|        mp_mkdirp(full_dir);
  316|       |
  317|  34.4k|        if (!mp_path_exists(fname))
  ------------------
  |  Branch (317:13): [True: 34.4k, False: 0]
  ------------------
  318|  34.4k|            return fname;
  319|       |
  320|      0|        if (sequence == prev_sequence) {
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  ------------------
  321|      0|            mp_cmd_msg(cmd, MSGL_ERR, "Can't save screenshot, file '%s' "
  322|      0|                       "already exists!", fname);
  323|      0|            talloc_free(fname);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  324|      0|            return NULL;
  325|      0|        }
  326|       |
  327|      0|        talloc_free(fname);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  328|      0|    }
  329|  34.4k|}
screenshot.c:create_fname:
  127|  34.4k|{
  128|  34.4k|    char *res = talloc_strdup(NULL, ""); //empty string, non-NULL context
  ------------------
  |  |   50|  34.4k|#define talloc_strdup                   ta_xstrdup
  ------------------
  129|       |
  130|  34.4k|    time_t raw_time = time(NULL);
  131|  34.4k|    struct tm *local_time = localtime(&raw_time);
  132|       |
  133|  34.4k|    if (!template || *template == '\0')
  ------------------
  |  Branch (133:9): [True: 0, False: 34.4k]
  |  Branch (133:22): [True: 0, False: 34.4k]
  ------------------
  134|      0|        return NULL;
  135|       |
  136|  68.9k|    for (;;) {
  137|  68.9k|        char *next = strchr(template, '%');
  138|  68.9k|        if (!next)
  ------------------
  |  Branch (138:13): [True: 34.4k, False: 34.4k]
  ------------------
  139|  34.4k|            break;
  140|  34.4k|        res = talloc_strndup_append(res, template, next - template);
  ------------------
  |  |   59|  34.4k|#define talloc_strndup_append           ta_talloc_strndup_append
  ------------------
  141|  34.4k|        template = next + 1;
  142|  34.4k|        char fmt = *template++;
  143|  34.4k|        switch (fmt) {
  144|      0|        case '#':
  ------------------
  |  Branch (144:9): [True: 0, False: 34.4k]
  ------------------
  145|      0|        case '0':
  ------------------
  |  Branch (145:9): [True: 0, False: 34.4k]
  ------------------
  146|  34.4k|        case 'n': {
  ------------------
  |  Branch (146:9): [True: 34.4k, False: 0]
  ------------------
  147|  34.4k|            int digits = '4';
  148|  34.4k|            if (fmt == '#') {
  ------------------
  |  Branch (148:17): [True: 0, False: 34.4k]
  ------------------
  149|      0|                if (!*sequence) {
  ------------------
  |  Branch (149:21): [True: 0, False: 0]
  ------------------
  150|      0|                    *frameno = 1;
  151|      0|                }
  152|      0|                fmt = *template++;
  153|      0|            }
  154|  34.4k|            if (fmt == '0') {
  ------------------
  |  Branch (154:17): [True: 0, False: 34.4k]
  ------------------
  155|      0|                digits = *template++;
  156|      0|                if (digits < '0' || digits > '9')
  ------------------
  |  Branch (156:21): [True: 0, False: 0]
  |  Branch (156:37): [True: 0, False: 0]
  ------------------
  157|      0|                    goto error_exit;
  158|      0|                fmt = *template++;
  159|      0|            }
  160|  34.4k|            if (fmt != 'n')
  ------------------
  |  Branch (160:17): [True: 0, False: 34.4k]
  ------------------
  161|      0|                goto error_exit;
  162|  34.4k|            char fmtstr[] = {'%', '0', digits, 'd', '\0'};
  163|  34.4k|            res = talloc_asprintf_append(res, fmtstr, *frameno);
  ------------------
  |  |   63|  34.4k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  164|  34.4k|            if (*frameno < INT_MAX - 1) {
  ------------------
  |  Branch (164:17): [True: 34.4k, False: 0]
  ------------------
  165|  34.4k|                (*frameno) += 1;
  166|  34.4k|                (*sequence) += 1;
  167|  34.4k|            }
  168|  34.4k|            break;
  169|  34.4k|        }
  170|      0|        case 'f':
  ------------------
  |  Branch (170:9): [True: 0, False: 34.4k]
  ------------------
  171|      0|        case 'F': {
  ------------------
  |  Branch (171:9): [True: 0, False: 34.4k]
  ------------------
  172|      0|            const char *name;
  173|      0|            if (!mpctx->filename) {
  ------------------
  |  Branch (173:17): [True: 0, False: 0]
  ------------------
  174|      0|                name = "NO_FILE";
  175|      0|            } else if (mpctx->demuxer && mpctx->demuxer->server_filename) {
  ------------------
  |  Branch (175:24): [True: 0, False: 0]
  |  Branch (175:42): [True: 0, False: 0]
  ------------------
  176|      0|                name = mpctx->demuxer->server_filename;
  177|      0|            } else {
  178|      0|                if (bstr_endswith0(bstr0(mpctx->filename), "/")) {
  ------------------
  |  Branch (178:21): [True: 0, False: 0]
  ------------------
  179|      0|                    name = mpctx->filename;
  180|      0|                } else {
  181|      0|                    name = mp_basename(mpctx->filename);
  182|      0|                }
  183|      0|                if (mp_is_url(bstr0(mpctx->filename)))
  ------------------
  |  Branch (183:21): [True: 0, False: 0]
  ------------------
  184|      0|                    name = mp_url_unescape(res, name);
  185|      0|            }
  186|       |
  187|      0|            if (fmt == 'F')
  ------------------
  |  Branch (187:17): [True: 0, False: 0]
  ------------------
  188|      0|                name = bstrto0(res, mp_strip_ext(bstr0(name)));
  189|      0|            append_filename(&res, name);
  190|      0|            break;
  191|      0|        }
  192|      0|        case 'x':
  ------------------
  |  Branch (192:9): [True: 0, False: 34.4k]
  ------------------
  193|      0|        case 'X': {
  ------------------
  |  Branch (193:9): [True: 0, False: 34.4k]
  ------------------
  194|      0|            char *fallback = "";
  195|      0|            if (fmt == 'X') {
  ------------------
  |  Branch (195:17): [True: 0, False: 0]
  ------------------
  196|      0|                if (template[0] != '{')
  ------------------
  |  Branch (196:21): [True: 0, False: 0]
  ------------------
  197|      0|                    goto error_exit;
  198|      0|                char *end = strchr(template, '}');
  199|      0|                if (!end)
  ------------------
  |  Branch (199:21): [True: 0, False: 0]
  ------------------
  200|      0|                    goto error_exit;
  201|      0|                fallback = talloc_strndup(res, template + 1, end - template - 1);
  ------------------
  |  |   51|      0|#define talloc_strndup                  ta_xstrndup
  ------------------
  202|      0|                template = end + 1;
  203|      0|            }
  204|      0|            if (!mpctx->filename || mp_is_url(bstr0(mpctx->filename))) {
  ------------------
  |  Branch (204:17): [True: 0, False: 0]
  |  Branch (204:37): [True: 0, False: 0]
  ------------------
  205|      0|                res = talloc_strdup_append(res, fallback);
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  206|      0|            } else {
  207|      0|                bstr dir = mp_dirname(mpctx->filename);
  208|      0|                if (!bstr_equals0(dir, "."))
  ------------------
  |  Branch (208:21): [True: 0, False: 0]
  ------------------
  209|      0|                    res = talloc_asprintf_append(res, "%.*s", BSTR_P(dir));
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
                                  res = talloc_asprintf_append(res, "%.*s", BSTR_P(dir));
  ------------------
  |  |  307|      0|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  210|      0|            }
  211|      0|            break;
  212|      0|        }
  213|      0|        case 'p':
  ------------------
  |  Branch (213:9): [True: 0, False: 34.4k]
  ------------------
  214|      0|        case 'P': {
  ------------------
  |  Branch (214:9): [True: 0, False: 34.4k]
  ------------------
  215|      0|            char *t = mp_format_time(get_playback_time(mpctx), fmt == 'P');
  216|      0|            append_filename(&res, t);
  217|      0|            talloc_free(t);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  218|      0|            break;
  219|      0|        }
  220|      0|        case 'w': {
  ------------------
  |  Branch (220:9): [True: 0, False: 34.4k]
  ------------------
  221|      0|            char tfmt = *template;
  222|      0|            if (!tfmt)
  ------------------
  |  Branch (222:17): [True: 0, False: 0]
  ------------------
  223|      0|                goto error_exit;
  224|      0|            template++;
  225|      0|            char fmtstr[] = {'%', tfmt, '\0'};
  226|      0|            char *s = mp_format_time_fmt(fmtstr, get_playback_time(mpctx));
  227|      0|            if (!s)
  ------------------
  |  Branch (227:17): [True: 0, False: 0]
  ------------------
  228|      0|                goto error_exit;
  229|      0|            append_filename(&res, s);
  230|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  231|      0|            break;
  232|      0|        }
  233|      0|        case 't': {
  ------------------
  |  Branch (233:9): [True: 0, False: 34.4k]
  ------------------
  234|      0|            char tfmt = *template;
  235|       |            // Translate common extensions to the closest alternative.
  236|      0|            size_t i = strcspn("sklPaAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", (char[]){tfmt, '\0'});
  237|      0|            tfmt =             "sHIpaAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%"[i];
  238|      0|            if (!tfmt || !local_time)
  ------------------
  |  Branch (238:17): [True: 0, False: 0]
  |  Branch (238:26): [True: 0, False: 0]
  ------------------
  239|      0|                goto error_exit;
  240|      0|            template++;
  241|      0|            char buffer[80];
  242|      0|            if (tfmt == 's') {
  ------------------
  |  Branch (242:17): [True: 0, False: 0]
  ------------------
  243|      0|                snprintf(buffer, sizeof(buffer), "%"PRId64, (int64_t)raw_time);
  244|      0|            } else {
  245|      0|                char fmtstr[] = {'%', tfmt, '\0'};
  246|      0|                if (strftime(buffer, sizeof(buffer), fmtstr, local_time) == 0)
  ------------------
  |  Branch (246:21): [True: 0, False: 0]
  ------------------
  247|      0|                    buffer[0] = '\0';
  248|      0|            }
  249|      0|            append_filename(&res, buffer);
  250|      0|            break;
  251|      0|        }
  252|      0|        case '{': {
  ------------------
  |  Branch (252:9): [True: 0, False: 34.4k]
  ------------------
  253|      0|            char *end = strchr(template, '}');
  254|      0|            if (!end)
  ------------------
  |  Branch (254:17): [True: 0, False: 0]
  ------------------
  255|      0|                goto error_exit;
  256|      0|            struct bstr prop = bstr_splice(bstr0(template), 0, end - template);
  257|      0|            char *tmp = talloc_asprintf(NULL, "${%.*s}", BSTR_P(prop));
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      0|            char *s = mp_property_expand_string(mpctx, tmp);
  259|      0|            talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  260|      0|            if (s)
  ------------------
  |  Branch (260:17): [True: 0, False: 0]
  ------------------
  261|      0|                append_filename(&res, s);
  262|      0|            talloc_free(s);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  263|      0|            template = end + 1;
  264|      0|            break;
  265|      0|        }
  266|      0|        case '%':
  ------------------
  |  Branch (266:9): [True: 0, False: 34.4k]
  ------------------
  267|      0|            res = talloc_strdup_append(res, "%");
  ------------------
  |  |   57|      0|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  268|      0|            break;
  269|      0|        default:
  ------------------
  |  Branch (269:9): [True: 0, False: 34.4k]
  ------------------
  270|      0|            goto error_exit;
  271|  34.4k|        }
  272|  34.4k|    }
  273|       |
  274|  34.4k|    res = talloc_strdup_append(res, template);
  ------------------
  |  |   57|  34.4k|#define talloc_strdup_append            ta_talloc_strdup_append
  ------------------
  275|  34.4k|    res = talloc_asprintf_append(res, ".%s", file_ext);
  ------------------
  |  |   63|  34.4k|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  276|  34.4k|    char *fname = mp_get_user_path(NULL, mpctx->global, res);
  277|  34.4k|    talloc_free(res);
  ------------------
  |  |   47|  34.4k|#define talloc_free                     ta_free
  ------------------
  278|  34.4k|    return fname;
  279|       |
  280|      0|error_exit:
  281|      0|    talloc_free(res);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  282|       |    return NULL;
  283|  34.4k|}
screenshot.c:screenshot_get_rgb:
  478|  1.30k|{
  479|  1.30k|    struct mp_image *mpi = screenshot_get(mpctx, mode, high_depth);
  480|  1.30k|    if (!mpi)
  ------------------
  |  Branch (480:9): [True: 534, False: 770]
  ------------------
  481|    534|        return NULL;
  482|    770|    struct mp_image *res = convert_image(mpi, format, mpctx->global,
  483|    770|                                         mpctx->log);
  484|    770|    talloc_free(mpi);
  ------------------
  |  |   47|    770|#define talloc_free                     ta_free
  ------------------
  485|    770|    return res;
  486|  1.30k|}

mp_load_user_script:
  203|  1.11k|{
  204|  1.11k|    char *path = mp_get_user_path(NULL, mpctx->global, fname);
  205|  1.11k|    int64_t ret = mp_load_script(mpctx, path);
  206|  1.11k|    talloc_free(path);
  ------------------
  |  |   47|  1.11k|#define talloc_free                     ta_free
  ------------------
  207|  1.11k|    return ret;
  208|  1.11k|}
mp_load_builtin_scripts:
  262|  11.6k|{
  263|  11.6k|    load_builtin_script(mpctx, 0, mpctx->opts->lua_load_osc, "@osc.lua");
  264|  11.6k|    load_builtin_script(mpctx, 1, mpctx->opts->lua_load_ytdl, "@ytdl_hook.lua");
  265|  11.6k|    load_builtin_script(mpctx, 2, mpctx->opts->lua_load_stats, "@stats.lua");
  266|  11.6k|    load_builtin_script(mpctx, 3, mpctx->opts->lua_load_console, "@console.lua");
  267|  11.6k|    load_builtin_script(mpctx, 4, mpctx->opts->lua_load_auto_profiles,
  268|  11.6k|                        "@auto_profiles.lua");
  269|  11.6k|    load_builtin_script(mpctx, 5, mpctx->opts->lua_load_select, "@select.lua");
  270|  11.6k|    load_builtin_script(mpctx, 6, mpctx->opts->lua_load_positioning, "@positioning.lua");
  271|  11.6k|    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|  11.6k|    struct m_config_option *co = m_config_get_co(mpctx->mconfig, bstr0("d3d11-exclusive-fs"));
  275|  11.6k|    bool context_menu = mpctx->opts->lua_load_context_menu || (co && *(bool *)co->data);
  ------------------
  |  Branch (275:25): [True: 0, False: 11.6k]
  |  Branch (275:64): [True: 0, False: 11.6k]
  |  Branch (275:70): [True: 0, False: 0]
  ------------------
  276|  11.6k|    load_builtin_script(mpctx, 8, context_menu, "@context_menu.lua");
  277|  11.6k|}
mp_load_scripts:
  280|  11.6k|{
  281|  11.6k|    bool ok = true;
  282|       |
  283|       |    // Load scripts from options
  284|  11.6k|    char **files = mpctx->opts->script_files;
  285|  11.6k|    for (int n = 0; files && files[n]; n++) {
  ------------------
  |  Branch (285:21): [True: 0, False: 11.6k]
  |  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|  11.6k|    if (!mpctx->opts->auto_load_scripts)
  ------------------
  |  Branch (289:9): [True: 0, False: 11.6k]
  ------------------
  290|      0|        return ok;
  291|       |
  292|       |    // Load all scripts
  293|  11.6k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  11.6k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  11.6k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  294|  11.6k|    char **scriptsdir = mp_find_all_config_files(tmp, mpctx->global, "scripts");
  295|  11.6k|    for (int i = 0; scriptsdir && scriptsdir[i]; i++) {
  ------------------
  |  Branch (295:21): [True: 11.6k, False: 0]
  |  Branch (295:35): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    talloc_free(tmp);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  301|       |
  302|  11.6k|    return ok;
  303|  11.6k|}
scripting.c:mp_load_script:
  106|  1.11k|{
  107|  1.11k|    bstr ext = mp_get_ext(bstr0(fname));
  108|  1.11k|    if (bstrcasecmp0(ext, "disable") == 0)
  ------------------
  |  Branch (108:9): [True: 0, False: 1.11k]
  ------------------
  109|      0|        return 0;
  110|       |
  111|  1.11k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  1.11k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  1.11k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  112|       |
  113|  1.11k|    const char *path = NULL;
  114|  1.11k|    const char *script_name = NULL;
  115|  1.11k|    const struct mp_scripting *backend = NULL;
  116|       |
  117|  1.11k|    struct stat s;
  118|  1.11k|    if (!stat(fname, &s) && S_ISDIR(s.st_mode)) {
  ------------------
  |  Branch (118:9): [True: 10, False: 1.10k]
  |  Branch (118:29): [True: 10, False: 0]
  ------------------
  119|     10|        path = fname;
  120|     10|        fname = NULL;
  121|       |
  122|     30|        for (int n = 0; scripting_backends[n]; n++) {
  ------------------
  |  Branch (122:25): [True: 20, False: 10]
  ------------------
  123|     20|            const struct mp_scripting *b = scripting_backends[n];
  124|     20|            char *filename = mp_tprintf(80, "main.%s", b->file_ext);
  ------------------
  |  |  195|     20|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  125|     20|            fname = mp_path_join(tmp, path, filename);
  126|     20|            if (!stat(fname, &s) && S_ISREG(s.st_mode)) {
  ------------------
  |  Branch (126:17): [True: 0, False: 20]
  |  Branch (126:37): [True: 0, False: 0]
  ------------------
  127|      0|                backend = b;
  128|      0|                break;
  129|      0|            }
  130|     20|            talloc_free((void *)fname);
  ------------------
  |  |   47|     20|#define talloc_free                     ta_free
  ------------------
  131|     20|            fname = NULL;
  132|     20|        }
  133|       |
  134|     10|        if (!fname) {
  ------------------
  |  Branch (134:13): [True: 10, False: 0]
  ------------------
  135|     10|            MP_ERR(mpctx, "Cannot find main.* for any supported scripting "
  ------------------
  |  |   89|     10|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     10|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  136|     10|                   "backend in: %s\n", path);
  137|     10|            talloc_free(tmp);
  ------------------
  |  |   47|     10|#define talloc_free                     ta_free
  ------------------
  138|     10|            return -1;
  139|     10|        }
  140|       |
  141|      0|        char *path_dup = talloc_strdup(tmp, path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  142|      0|        mp_path_strip_trailing_separator(path_dup);
  143|      0|        script_name = mp_basename(path_dup);
  144|  1.10k|    } else {
  145|  3.30k|        for (int n = 0; scripting_backends[n]; n++) {
  ------------------
  |  Branch (145:25): [True: 2.20k, False: 1.10k]
  ------------------
  146|  2.20k|            const struct mp_scripting *b = scripting_backends[n];
  147|  2.20k|            if (bstrcasecmp0(ext, b->file_ext) == 0) {
  ------------------
  |  Branch (147:17): [True: 0, False: 2.20k]
  ------------------
  148|      0|                backend = b;
  149|      0|                break;
  150|      0|            }
  151|  2.20k|        }
  152|  1.10k|        script_name = script_name_from_filename(tmp, fname);
  153|  1.10k|    }
  154|       |
  155|  1.10k|    if (!backend) {
  ------------------
  |  Branch (155:9): [True: 1.10k, False: 0]
  ------------------
  156|  1.10k|        MP_ERR(mpctx, "Can't load unknown script: %s\n", fname);
  ------------------
  |  |   89|  1.10k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.10k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  157|  1.10k|        talloc_free(tmp);
  ------------------
  |  |   47|  1.10k|#define talloc_free                     ta_free
  ------------------
  158|  1.10k|        return -1;
  159|  1.10k|    }
  160|       |
  161|      0|    struct mp_script_args *arg = talloc_ptrtype(NULL, arg);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|      0|    *arg = (struct mp_script_args){
  163|      0|        .mpctx = mpctx,
  164|      0|        .filename = talloc_strdup(arg, fname),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  165|      0|        .path = talloc_strdup(arg, path),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  166|      0|        .backend = backend,
  167|       |        // Create the client before creating the thread; otherwise a race
  168|       |        // condition could happen, where MPContext is destroyed while the
  169|       |        // thread tries to create the client.
  170|      0|        .client = mp_new_weak_client(mpctx->clients, script_name),
  171|      0|    };
  172|       |
  173|      0|    talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  174|      0|    fname = NULL; // might have been freed so don't touch anymore
  175|       |
  176|      0|    if (!arg->client) {
  ------------------
  |  Branch (176:9): [True: 0, False: 0]
  ------------------
  177|      0|        MP_ERR(mpctx, "Failed to create client for script: %s\n", arg->filename);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  178|      0|        talloc_free(arg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  179|      0|        return -1;
  180|      0|    }
  181|       |
  182|      0|    arg->log = mp_client_get_log(arg->client);
  183|      0|    int64_t id = mpv_client_id(arg->client);
  184|       |
  185|      0|    MP_DBG(arg, "Loading %s script %s...\n", backend->name, arg->filename);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  186|       |
  187|      0|    if (backend->no_thread) {
  ------------------
  |  Branch (187:9): [True: 0, False: 0]
  ------------------
  188|      0|        run_script(arg);
  189|      0|    } else {
  190|      0|        mp_thread thread;
  191|      0|        if (mp_thread_create(&thread, script_thread, arg)) {
  ------------------
  |  |  214|      0|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  192|      0|            mpv_destroy(arg->client);
  193|      0|            talloc_free(arg);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  194|      0|            return -1;
  195|      0|        }
  196|      0|        mp_thread_detach(thread);
  ------------------
  |  |  216|      0|#define mp_thread_detach          pthread_detach
  ------------------
  197|      0|    }
  198|       |
  199|      0|    return id;
  200|      0|}
scripting.c:script_name_from_filename:
   62|  1.10k|{
   63|  1.10k|    fname = mp_basename(fname);
   64|  1.10k|    if (fname[0] == '@')
  ------------------
  |  Branch (64:9): [True: 11, False: 1.09k]
  ------------------
   65|     11|        fname += 1;
   66|  1.10k|    char *name = talloc_strdup(talloc_ctx, fname);
  ------------------
  |  |   50|  1.10k|#define talloc_strdup                   ta_xstrdup
  ------------------
   67|       |    // Drop file extension
   68|  1.10k|    char *dot = strrchr(name, '.');
   69|  1.10k|    if (dot)
  ------------------
  |  Branch (69:9): [True: 201, False: 900]
  ------------------
   70|    201|        *dot = '\0';
   71|       |    // Turn it into a safe identifier - this is used with e.g. dispatching
   72|       |    // input via: "send scriptname ..."
   73|  39.9k|    for (int n = 0; name[n]; n++) {
  ------------------
  |  Branch (73:21): [True: 38.8k, False: 1.10k]
  ------------------
   74|  38.8k|        char c = name[n];
   75|  38.8k|        if (!(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') &&
  ------------------
  |  Branch (75:15): [True: 24.2k, False: 14.6k]
  |  Branch (75:27): [True: 2.59k, False: 21.6k]
  |  Branch (75:42): [True: 21.2k, False: 15.0k]
  |  Branch (75:54): [True: 18.9k, False: 2.30k]
  ------------------
   76|  17.3k|            !(c >= '0' && c <= '9'))
  ------------------
  |  Branch (76:15): [True: 5.37k, False: 11.9k]
  |  Branch (76:27): [True: 2.52k, False: 2.84k]
  ------------------
   77|  14.7k|            name[n] = '_';
   78|  38.8k|    }
   79|  1.10k|    return talloc_asprintf(talloc_ctx, "%s", name);
  ------------------
  |  |   52|  1.10k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|  1.10k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
   80|  1.10k|}
scripting.c:load_builtin_script:
  242|   105k|{
  243|   105k|    mp_assert(slot < MP_ARRAY_SIZE(mpctx->builtin_script_ids));
  ------------------
  |  |   41|   105k|#define mp_assert assert
  ------------------
  |  Branch (243:5): [True: 105k, False: 0]
  ------------------
  244|   105k|    int64_t *pid = &mpctx->builtin_script_ids[slot];
  245|   105k|    if (*pid > 0 && !mp_client_id_exists(mpctx, *pid)) {
  ------------------
  |  Branch (245:9): [True: 0, False: 105k]
  |  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|   105k|    if ((*pid > 0) != enable) {
  ------------------
  |  Branch (249:9): [True: 0, False: 105k]
  ------------------
  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|   105k|}

redraw_subs:
   57|  2.71M|{
   58|  8.14M|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (58:21): [True: 5.42M, False: 2.71M]
  ------------------
   59|  5.42M|        if (mpctx->current_track[n][STREAM_SUB] &&
  ------------------
  |  Branch (59:13): [True: 161k, False: 5.26M]
  ------------------
   60|   161k|            mpctx->current_track[n][STREAM_SUB]->d_sub)
  ------------------
  |  Branch (60:13): [True: 161k, False: 0]
  ------------------
   61|   161k|        {
   62|       |            mpctx->current_track[n][STREAM_SUB]->redraw_subs = true;
   63|   161k|        }
   64|  5.42M|    }
   65|  2.71M|}
reset_subtitle_state:
   68|  2.72M|{
   69|  8.32M|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (69:21): [True: 5.60M, False: 2.72M]
  ------------------
   70|  5.60M|        reset_subtitles(mpctx, mpctx->tracks[n]);
   71|  2.72M|    term_osd_clear_subs(mpctx);
   72|  2.72M|}
uninit_sub:
   75|  37.9k|{
   76|  37.9k|    if (track && track->d_sub) {
  ------------------
  |  Branch (76:9): [True: 36.1k, False: 1.80k]
  |  Branch (76:18): [True: 4.76k, False: 31.4k]
  ------------------
   77|  4.76k|        int order = get_order(mpctx, track);
   78|  4.76k|        reset_subtitles(mpctx, track);
   79|  4.76k|        sub_select(track->d_sub, false);
   80|  4.76k|        if (order >= 0) {
  ------------------
  |  Branch (80:13): [True: 4.76k, False: 0]
  ------------------
   81|  4.76k|            term_osd_set_subs(mpctx, NULL, order);
   82|  4.76k|            osd_set_sub(mpctx->osd, order, NULL);
   83|  4.76k|        }
   84|  4.76k|        sub_destroy(track->d_sub);
   85|       |        track->d_sub = NULL;
   86|  4.76k|    }
   87|  37.9k|}
uninit_sub_all:
   90|  16.1k|{
   91|  48.5k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (91:21): [True: 32.4k, False: 16.1k]
  ------------------
   92|  32.4k|        uninit_sub(mpctx, mpctx->tracks[n]);
   93|  16.1k|}
update_subtitles:
  166|  8.75M|{
  167|  8.75M|    bool ok = true;
  168|  26.2M|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (168:21): [True: 17.5M, False: 8.75M]
  ------------------
  169|  17.5M|        ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
  170|  8.75M|    return ok;
  171|  8.75M|}
reinit_sub:
  219|  33.9k|{
  220|  33.9k|    if (!track || !track->stream || track->stream->type != STREAM_SUB)
  ------------------
  |  Branch (220:9): [True: 29.2k, False: 4.76k]
  |  Branch (220:19): [True: 0, False: 4.76k]
  |  Branch (220:37): [True: 0, False: 4.76k]
  ------------------
  221|  29.2k|        return;
  222|       |
  223|  4.76k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  4.76k|#define mp_assert assert
  ------------------
  |  Branch (223:5): [True: 4.76k, False: 0]
  ------------------
  224|       |
  225|  4.76k|    if (!init_subdec(mpctx, track)) {
  ------------------
  |  Branch (225:9): [True: 0, False: 4.76k]
  ------------------
  226|      0|        track->dec_failed = true;
  227|      0|        error_on_track(mpctx, track);
  228|      0|        return;
  229|      0|    }
  230|       |
  231|  4.76k|    sub_select(track->d_sub, true);
  232|  4.76k|    int order = get_order(mpctx, track);
  233|  4.76k|    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|  4.76k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (238:9): [True: 4.74k, False: 23]
  ------------------
  239|  4.74k|        track->demuxer_ready = false;
  240|  4.74k|        int64_t end = mp_time_ns() + MP_TIME_MS_TO_NS(50);
  ------------------
  |  |   72|  4.74k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  241|  9.48k|        while (!track->demuxer_ready && mp_time_ns() < end)
  ------------------
  |  Branch (241:16): [True: 4.74k, False: 4.74k]
  |  Branch (241:41): [True: 4.74k, False: 0]
  ------------------
  242|  4.74k|            track->demuxer_ready = update_subtitles(mpctx, mpctx->playback_pts) ||
  ------------------
  |  Branch (242:36): [True: 4.74k, False: 0]
  ------------------
  243|      0|                                  !mpctx->paused;
  ------------------
  |  Branch (243:35): [True: 0, False: 0]
  ------------------
  244|  4.74k|        if (!track->demuxer_ready)
  ------------------
  |  Branch (244:13): [True: 0, False: 4.74k]
  ------------------
  245|      0|            mp_wakeup_core(mpctx);
  246|       |
  247|  4.74k|    }
  248|  4.76k|}
reinit_sub_all:
  251|  14.2k|{
  252|  42.6k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (252:21): [True: 28.4k, False: 14.2k]
  ------------------
  253|  28.4k|        reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
  254|  14.2k|}
sub.c:reset_subtitles:
   48|  5.61M|{
   49|  5.61M|    if (track->d_sub) {
  ------------------
  |  Branch (49:9): [True: 166k, False: 5.44M]
  ------------------
   50|   166k|        sub_reset(track->d_sub);
   51|   166k|        sub_set_play_dir(track->d_sub, mpctx->play_dir);
   52|   166k|    }
   53|  5.61M|}
sub.c:get_order:
   39|  39.7k|{
   40|  39.7k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (40:21): [True: 39.7k, False: 0]
  ------------------
   41|  39.7k|        if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (41:13): [True: 39.7k, False: 0]
  ------------------
   42|  39.7k|            return n;
   43|  39.7k|    }
   44|      0|    return -1;
   45|  39.7k|}
sub.c:update_subtitle:
   97|  17.5M|{
   98|  17.5M|    struct dec_sub *dec_sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (98:31): [True: 669k, False: 16.8M]
  ------------------
   99|       |
  100|  17.5M|    if (!dec_sub)
  ------------------
  |  Branch (100:9): [True: 16.8M, False: 669k]
  ------------------
  101|  16.8M|        return true;
  102|       |
  103|   669k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (103:9): [True: 643k, False: 25.4k]
  ------------------
  104|   643k|        struct mp_image_params params = mpctx->vo_chain->filter->input_params;
  105|   643k|        if (params.imgfmt)
  ------------------
  |  Branch (105:13): [True: 626k, False: 17.2k]
  ------------------
  106|   626k|            sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
  107|   643k|    }
  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|   669k|    bool still_image = mpctx->video_out && ((mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (112:24): [True: 643k, False: 25.4k]
  |  Branch (112:46): [True: 637k, False: 6.66k]
  ------------------
  113|   637k|                       mpctx->opts->subs_rend->sub_past_video_end) ||
  ------------------
  |  Branch (113:24): [True: 0, False: 637k]
  ------------------
  114|   643k|                       !mpctx->current_track[0][STREAM_VIDEO] ||
  ------------------
  |  Branch (114:24): [True: 28, False: 643k]
  ------------------
  115|   643k|                       mpctx->current_track[0][STREAM_VIDEO]->image);
  ------------------
  |  Branch (115:24): [True: 0, False: 643k]
  ------------------
  116|   669k|    sub_control(dec_sub, SD_CTRL_SET_ANIMATED_CHECK, &still_image);
  117|       |
  118|   669k|    if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
  ------------------
  |  Branch (118:9): [True: 669k, False: 0]
  |  Branch (118:39): [True: 4.76k, False: 664k]
  ------------------
  119|       |        // Assume fully_read implies no interleaved audio/video streams.
  120|       |        // (Reading packets will change the demuxer position.)
  121|  4.76k|        demux_seek(track->demuxer, 0, 0);
  122|  4.76k|        sub_preload(dec_sub);
  123|  4.76k|    }
  124|       |
  125|   669k|    bool packets_read = false;
  126|   669k|    bool sub_updated = false;
  127|   669k|    sub_read_packets(dec_sub, video_pts, mpctx->paused, &packets_read, &sub_updated);
  128|       |
  129|   669k|    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|   669k|    if (sub_updated || track->redraw_subs || osd_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   507k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (133:9): [True: 203, False: 669k]
  |  Branch (133:24): [True: 161k, False: 507k]
  |  Branch (133:46): [True: 507k, False: 18]
  ------------------
  134|       |        // Always force a redecode of all packets if we seek on a still image.
  135|   669k|        if (track->redraw_subs && still_image)
  ------------------
  |  Branch (135:13): [True: 161k, False: 508k]
  |  Branch (135:35): [True: 2, False: 161k]
  ------------------
  136|      2|            sub_redecode_cached_packets(dec_sub);
  137|       |
  138|       |        // Handle displaying subtitles on terminal.
  139|   669k|        if (track->selected && track->type == STREAM_SUB && !mpctx->video_out) {
  ------------------
  |  Branch (139:13): [True: 669k, False: 0]
  |  Branch (139:32): [True: 669k, False: 0]
  |  Branch (139:61): [True: 25.4k, False: 643k]
  ------------------
  140|  25.4k|            char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
  141|  25.4k|            int order = get_order(mpctx, track);
  142|  25.4k|            if (order >= 0)
  ------------------
  |  Branch (142:17): [True: 25.4k, False: 0]
  ------------------
  143|  25.4k|                term_osd_set_subs(mpctx, text, order);
  144|  25.4k|            talloc_free(text);
  ------------------
  |  |   47|  25.4k|#define talloc_free                     ta_free
  ------------------
  145|  25.4k|        }
  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|   669k|        if (still_image) {
  ------------------
  |  Branch (150:13): [True: 10, False: 669k]
  ------------------
  151|     10|            if (osd_pts != video_pts) {
  ------------------
  |  Branch (151:17): [True: 2, False: 8]
  ------------------
  152|      2|                osd_set_force_video_pts(mpctx->osd, video_pts);
  153|      2|                osd_query_and_reset_want_redraw(mpctx->osd);
  154|      2|                vo_redraw(mpctx->video_out);
  155|      2|            }
  156|     10|        }
  157|   669k|    }
  158|       |
  159|       |    track->redraw_subs = false;
  160|   669k|    return packets_read;
  161|  17.5M|}
sub.c:init_subdec:
  197|  4.76k|{
  198|  4.76k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  4.76k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 4.76k, False: 0]
  ------------------
  199|       |
  200|  4.76k|    if (!track->demuxer || !track->stream)
  ------------------
  |  Branch (200:9): [True: 0, False: 4.76k]
  |  Branch (200:28): [True: 0, False: 4.76k]
  ------------------
  201|      0|        return false;
  202|       |
  203|  4.76k|    track->d_sub = sub_create(mpctx->global, track,
  204|  4.76k|                              get_all_attachments(mpctx),
  205|  4.76k|                              get_order(mpctx, track));
  206|  4.76k|    if (!track->d_sub)
  ------------------
  |  Branch (206:9): [True: 0, False: 4.76k]
  ------------------
  207|      0|        return false;
  208|       |
  209|  4.76k|    struct track *vtrack = mpctx->current_track[0][STREAM_VIDEO];
  210|  4.76k|    struct mp_codec_params *v_c =
  211|  4.76k|        vtrack && vtrack->stream ? vtrack->stream->codec : NULL;
  ------------------
  |  Branch (211:9): [True: 4.63k, False: 128]
  |  Branch (211:19): [True: 4.63k, False: 0]
  ------------------
  212|  4.76k|    double fps = v_c ? v_c->fps : 25;
  ------------------
  |  Branch (212:18): [True: 4.63k, False: 128]
  ------------------
  213|  4.76k|    sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps);
  214|       |
  215|       |    return true;
  216|  4.76k|}
sub.c:get_all_attachments:
  174|  4.76k|{
  175|  4.76k|    struct attachment_list *list = talloc_zero(NULL, struct attachment_list);
  ------------------
  |  |   27|  4.76k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.76k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|  4.76k|    struct demuxer *prev_demuxer = NULL;
  177|  74.3k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (177:21): [True: 69.5k, False: 4.76k]
  ------------------
  178|  69.5k|        struct track *t = mpctx->tracks[n];
  179|  69.5k|        if (!t->demuxer || prev_demuxer == t->demuxer)
  ------------------
  |  Branch (179:13): [True: 0, False: 69.5k]
  |  Branch (179:28): [True: 4.76k, False: 64.8k]
  ------------------
  180|  4.76k|            continue;
  181|  64.8k|        prev_demuxer = t->demuxer;
  182|  64.8k|        for (int i = 0; i < t->demuxer->num_attachments; i++) {
  ------------------
  |  Branch (182:25): [True: 0, False: 64.8k]
  ------------------
  183|      0|            struct demux_attachment *att = &t->demuxer->attachments[i];
  184|      0|            struct demux_attachment copy = {
  185|      0|                .name = talloc_strdup(list, att->name),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  186|      0|                .type = talloc_strdup(list, att->type),
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  187|      0|                .data = talloc_memdup(list, att->data, att->data_size),
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|      0|                .data_size = att->data_size,
  189|      0|            };
  190|      0|            MP_TARRAY_APPEND(list, list->entries, list->num_entries, copy);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  191|      0|        }
  192|  64.8k|    }
  193|  4.76k|    return list;
  194|  4.76k|}

reinit_video_filters:
   76|  2.90k|{
   77|  2.90k|    struct vo_chain *vo_c = mpctx->vo_chain;
   78|       |
   79|  2.90k|    if (!vo_c)
  ------------------
  |  Branch (79:9): [True: 2.57k, False: 329]
  ------------------
   80|  2.57k|        return 0;
   81|       |
   82|    329|    if (!recreate_video_filters(mpctx))
  ------------------
  |  Branch (82:9): [True: 12, False: 317]
  ------------------
   83|     12|        return -1;
   84|       |
   85|    317|    mp_force_video_refresh(mpctx);
   86|       |
   87|    317|    mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
   88|       |
   89|    317|    return 0;
   90|    329|}
reset_video_state:
  100|  2.78M|{
  101|  2.78M|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (101:9): [True: 2.55M, False: 228k]
  ------------------
  102|  2.55M|        vo_chain_reset_state(mpctx->vo_chain);
  103|  2.55M|        struct track *t = mpctx->vo_chain->track;
  104|  2.55M|        if (t && t->dec)
  ------------------
  |  Branch (104:13): [True: 2.55M, False: 0]
  |  Branch (104:18): [True: 2.55M, False: 0]
  ------------------
  105|  2.55M|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  106|  2.55M|    }
  107|       |
  108|  2.78M|    for (int n = 0; n < mpctx->num_next_frames; n++)
  ------------------
  |  Branch (108:21): [True: 70, False: 2.78M]
  ------------------
  109|     70|        mp_image_unrefp(&mpctx->next_frames[n]);
  110|  2.78M|    mpctx->num_next_frames = 0;
  111|  2.78M|    mp_image_unrefp(&mpctx->saved_frame);
  112|       |
  113|  2.78M|    mpctx->delay = 0;
  114|  2.78M|    mpctx->time_frame = 0;
  115|  2.78M|    mpctx->video_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.78M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  116|  2.78M|    mpctx->last_frame_duration = 0;
  117|  2.78M|    mpctx->num_past_frames = 0;
  118|  2.78M|    mpctx->total_avsync_change = 0;
  119|  2.78M|    mpctx->last_av_difference = 0;
  120|  2.78M|    mpctx->mistimed_frames_total = 0;
  121|  2.78M|    mpctx->drop_message_shown = 0;
  122|  2.78M|    mpctx->audio_drift_compensation = 0;
  123|  2.78M|    mpctx->avd_filtered = 0;
  124|  2.78M|    mpctx->display_sync_error = 0;
  125|  2.78M|    mpctx->display_sync_active = 0;
  126|       |
  127|  2.78M|    mpctx->video_status = mpctx->vo_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (127:27): [True: 2.55M, False: 228k]
  ------------------
  128|  2.78M|}
uninit_video_out:
  131|  1.01M|{
  132|  1.01M|    uninit_video_chain(mpctx);
  133|  1.01M|    if (mpctx->video_out) {
  ------------------
  |  Branch (133:9): [True: 31.9k, False: 979k]
  ------------------
  134|  31.9k|        vo_destroy(mpctx->video_out);
  135|  31.9k|        mpctx->video_out = NULL;
  136|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  137|  31.9k|    }
  138|  1.01M|}
uninit_video_chain:
  164|  1.05M|{
  165|  1.05M|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (165:9): [True: 29.8k, False: 1.02M]
  ------------------
  166|  29.8k|        reset_video_state(mpctx);
  167|  29.8k|        vo_chain_uninit(mpctx->vo_chain);
  168|  29.8k|        mpctx->vo_chain = NULL;
  169|       |
  170|  29.8k|        mpctx->video_status = STATUS_EOF;
  171|       |
  172|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  173|  29.8k|    }
  174|  1.05M|}
init_video_decoder:
  177|  29.8k|{
  178|  29.8k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 29.8k, False: 0]
  ------------------
  179|  29.8k|    if (!track->stream)
  ------------------
  |  Branch (179:9): [True: 0, False: 29.8k]
  ------------------
  180|      0|        goto err_out;
  181|       |
  182|  29.8k|    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|  29.8k|    if (track->vo_c)
  ------------------
  |  Branch (189:9): [True: 29.8k, False: 0]
  ------------------
  190|  29.8k|        parent = track->vo_c->filter->f;
  191|       |
  192|  29.8k|    track->dec = mp_decoder_wrapper_create(parent, track->stream);
  193|  29.8k|    if (!track->dec)
  ------------------
  |  Branch (193:9): [True: 0, False: 29.8k]
  ------------------
  194|      0|        goto err_out;
  195|       |
  196|  29.8k|    if (sh_stream_dependent_sibling(track->stream))
  ------------------
  |  Branch (196:9): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (199:9): [True: 0, False: 29.8k]
  ------------------
  200|      0|        goto err_out;
  201|       |
  202|  29.8k|    return 1;
  203|       |
  204|      0|err_out:
  205|      0|    if (track->sink)
  ------------------
  |  Branch (205:9): [True: 0, False: 0]
  ------------------
  206|      0|        mp_pin_disconnect(track->sink);
  207|      0|    track->sink = NULL;
  208|       |    track->dec_failed = true;
  209|      0|    return 0;
  210|  29.8k|}
reinit_video_chain:
  213|  45.5k|{
  214|  45.5k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
  215|  45.5k|    if (!track || !track->stream) {
  ------------------
  |  Branch (215:9): [True: 15.7k, False: 29.8k]
  |  Branch (215:19): [True: 0, False: 29.8k]
  ------------------
  216|  15.7k|        error_on_track(mpctx, track);
  217|  15.7k|        return;
  218|  15.7k|    }
  219|  29.8k|    reinit_video_chain_src(mpctx, track);
  220|  29.8k|}
reinit_video_chain_src:
  272|  29.8k|{
  273|  29.8k|    mp_assert(!mpctx->vo_chain);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (273:5): [True: 29.8k, False: 0]
  ------------------
  274|       |
  275|  29.8k|    if (!mpctx->video_out) {
  ------------------
  |  Branch (275:9): [True: 29.2k, False: 567]
  ------------------
  276|  29.2k|        struct vo_extra ex = {
  277|  29.2k|            .input_ctx = mpctx->input,
  278|  29.2k|            .osd = mpctx->osd,
  279|  29.2k|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
  280|  29.2k|            .wakeup_cb = mp_wakeup_core_cb,
  281|  29.2k|            .wakeup_ctx = mpctx,
  282|  29.2k|        };
  283|  29.2k|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
  284|  29.2k|        if (!mpctx->video_out) {
  ------------------
  |  Branch (284:13): [True: 5, False: 29.2k]
  ------------------
  285|      5|            MP_FATAL(mpctx, "Error opening/initializing "
  ------------------
  |  |   88|      5|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|      5|                    "the selected video_out (--vo) device.\n");
  287|      5|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
  288|      5|            goto err_out;
  289|      5|        }
  290|  29.2k|        mpctx->mouse_cursor_visible = true;
  291|  29.2k|    }
  292|       |
  293|  29.8k|    update_window_title(mpctx, true);
  294|       |
  295|  29.8k|    struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain);
  ------------------
  |  |   27|  29.8k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  29.8k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  29.8k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|  29.8k|    mpctx->vo_chain = vo_c;
  297|  29.8k|    vo_c->log = mpctx->log;
  298|  29.8k|    vo_c->vo = mpctx->video_out;
  299|  29.8k|    vo_c->filter =
  300|  29.8k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_VIDEO);
  301|  29.8k|    mp_output_chain_set_vo(vo_c->filter, vo_c->vo);
  302|  29.8k|    vo_c->filter->update_subtitles = filter_update_subtitles;
  303|  29.8k|    vo_c->filter->update_subtitles_ctx = mpctx;
  304|       |
  305|  29.8k|    if (track) {
  ------------------
  |  Branch (305:9): [True: 29.8k, False: 0]
  ------------------
  306|  29.8k|        vo_c->track = track;
  307|  29.8k|        track->vo_c = vo_c;
  308|  29.8k|        vo_c->is_coverart = !!track->attached_picture;
  309|  29.8k|        vo_c->is_sparse = track->stream->still_image || vo_c->is_coverart;
  ------------------
  |  Branch (309:27): [True: 0, False: 29.8k]
  |  Branch (309:57): [True: 0, False: 29.8k]
  ------------------
  310|  29.8k|        if (!vo_chain_init_decoder(mpctx, vo_c))
  ------------------
  |  Branch (310:13): [True: 0, False: 29.8k]
  ------------------
  311|      0|            goto err_out;
  312|  29.8k|    }
  313|       |
  314|  29.8k|    update_vo_chain_el_pair(mpctx);
  315|       |
  316|  29.8k|    if (!recreate_video_filters(mpctx))
  ------------------
  |  Branch (316:9): [True: 0, False: 29.8k]
  ------------------
  317|      0|        goto err_out;
  318|       |
  319|  29.8k|    update_content_type(mpctx, track);
  320|  29.8k|    update_screensaver_state(mpctx);
  321|       |
  322|  29.8k|    vo_set_paused(vo_c->vo, get_internal_paused(mpctx));
  323|       |
  324|  29.8k|    reset_video_state(mpctx);
  325|  29.8k|    term_osd_clear_subs(mpctx);
  326|       |
  327|  29.8k|    return;
  328|       |
  329|      5|err_out:
  330|      5|    uninit_video_chain(mpctx);
  331|      5|    error_on_track(mpctx, track);
  332|       |    handle_force_window(mpctx, true);
  333|      5|}
mp_force_video_refresh:
  338|    697|{
  339|    697|    struct MPOpts *opts = mpctx->opts;
  340|    697|    struct vo_chain *vo_c = mpctx->vo_chain;
  341|       |
  342|    697|    if (!vo_c)
  ------------------
  |  Branch (342:9): [True: 0, False: 697]
  ------------------
  343|      0|        return;
  344|       |
  345|       |    // If not paused, the next frame should come soon enough.
  346|    697|    if (opts->pause || mpctx->time_frame >= 0.5 ||
  ------------------
  |  Branch (346:9): [True: 527, False: 170]
  |  Branch (346:24): [True: 0, False: 170]
  ------------------
  347|    170|        (vo_c->track && vo_c->track->image) ||
  ------------------
  |  Branch (347:10): [True: 170, False: 0]
  |  Branch (347:25): [True: 0, False: 170]
  ------------------
  348|    170|        mpctx->video_status == STATUS_EOF)
  ------------------
  |  Branch (348:9): [True: 24, False: 146]
  ------------------
  349|    551|    {
  350|    551|        issue_refresh_seek(mpctx, MPSEEK_VERY_EXACT);
  351|    551|    }
  352|    697|}
calc_average_frame_duration:
  732|     14|{
  733|     14|    double total = 0;
  734|     14|    int num = 0;
  735|     20|    for (int n = 0; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (735:21): [True: 6, False: 14]
  ------------------
  736|      6|        double dur = mpctx->past_frames[n].approx_duration;
  737|      6|        if (dur <= 0)
  ------------------
  |  Branch (737:13): [True: 0, False: 6]
  ------------------
  738|      0|            continue;
  739|      6|        total += dur;
  740|      6|        num += 1;
  741|      6|    }
  742|     14|    return num > 0 ? total / num : 0;
  ------------------
  |  Branch (742:12): [True: 6, False: 8]
  ------------------
  743|     14|}
write_video:
 1109|  11.4M|{
 1110|  11.4M|    struct MPOpts *opts = mpctx->opts;
 1111|       |
 1112|  11.4M|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (1112:9): [True: 961k, False: 10.4M]
  ------------------
 1113|   961k|        return;
 1114|  10.4M|    struct track *track = mpctx->vo_chain->track;
 1115|  10.4M|    struct vo_chain *vo_c = mpctx->vo_chain;
 1116|  10.4M|    struct vo *vo = vo_c->vo;
 1117|       |
 1118|  10.4M|    if (vo_c->filter->reconfig_happened) {
  ------------------
  |  Branch (1118:9): [True: 14.6k, False: 10.4M]
  ------------------
 1119|  14.6k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1120|  14.6k|        vo_c->filter->reconfig_happened = false;
 1121|  14.6k|    }
 1122|       |
 1123|       |    // Actual playback starts when both audio and video are ready.
 1124|  10.4M|    if (mpctx->video_status == STATUS_READY)
  ------------------
  |  Branch (1124:9): [True: 29.3k, False: 10.4M]
  ------------------
 1125|  29.3k|        return;
 1126|       |
 1127|  10.4M|    if (mpctx->paused && mpctx->video_status >= STATUS_READY)
  ------------------
  |  Branch (1127:9): [True: 9.89M, False: 523k]
  |  Branch (1127:26): [True: 5.03M, False: 4.86M]
  ------------------
 1128|  5.03M|        return;
 1129|       |
 1130|       |    // Once the chain reached EOF nothing is read from it again.
 1131|  10.4M|    bool logical_eof = false;
 1132|  5.38M|    int r = VD_EOF;
 1133|  5.38M|    if (mpctx->video_status < STATUS_DRAINING)
  ------------------
  |  Branch (1133:9): [True: 5.04M, False: 335k]
  ------------------
 1134|  5.04M|        r = video_output_image(mpctx, &logical_eof);
 1135|  5.38M|    MP_TRACE(mpctx, "video_output_image: r=%d/eof=%d/st=%s\n", r, logical_eof,
  ------------------
  |  |   94|  5.38M|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.38M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|  5.38M|             mp_status_str(mpctx->video_status));
 1137|       |
 1138|  5.38M|    if (r < 0)
  ------------------
  |  Branch (1138:9): [True: 0, False: 5.38M]
  ------------------
 1139|      0|        goto error;
 1140|       |
 1141|  5.38M|    if (r == VD_WAIT) {
  ------------------
  |  Branch (1141:9): [True: 2.52M, False: 2.86M]
  ------------------
 1142|       |        // Heuristic to detect underruns.
 1143|  2.52M|        if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo) &&
  ------------------
  |  Branch (1143:13): [True: 9, False: 2.52M]
  |  Branch (1143:54): [True: 9, False: 0]
  ------------------
 1144|      9|            !vo_c->underrun_signaled)
  ------------------
  |  Branch (1144:13): [True: 9, False: 0]
  ------------------
 1145|      9|        {
 1146|      9|            vo_c->underrun = true;
 1147|      9|            vo_c->underrun_signaled = true;
 1148|      9|        }
 1149|       |        // Demuxer will wake us up for more packets to decode.
 1150|  2.52M|        return;
 1151|  2.52M|    }
 1152|       |
 1153|  2.86M|    if (r == VD_EOF) {
  ------------------
  |  Branch (1153:9): [True: 2.82M, False: 38.6k]
  ------------------
 1154|  2.82M|        if (check_for_hwdec_fallback(mpctx))
  ------------------
  |  Branch (1154:13): [True: 0, False: 2.82M]
  ------------------
 1155|      0|            return;
 1156|  2.82M|        if (check_for_forced_eof(mpctx)) {
  ------------------
  |  Branch (1156:13): [True: 0, False: 2.82M]
  ------------------
 1157|      0|            uninit_video_chain(mpctx);
 1158|      0|            handle_force_window(mpctx, true);
 1159|      0|            return;
 1160|      0|        }
 1161|  2.82M|        if (vo_c->filter->failed_output_conversion)
  ------------------
  |  Branch (1161:13): [True: 0, False: 2.82M]
  ------------------
 1162|      0|            goto error;
 1163|       |
 1164|  2.82M|        mpctx->delay = 0;
 1165|  2.82M|        mpctx->last_av_difference = 0;
 1166|       |
 1167|  2.82M|        if (mpctx->video_status <= STATUS_PLAYING) {
  ------------------
  |  Branch (1167:13): [True: 2.48M, False: 335k]
  ------------------
 1168|  2.48M|            mpctx->video_status = STATUS_DRAINING;
 1169|  2.48M|            get_relative_time(mpctx);
 1170|  2.48M|            if (vo_c->is_sparse && !mpctx->ao_chain) {
  ------------------
  |  Branch (1170:17): [True: 0, False: 2.48M]
  |  Branch (1170:36): [True: 0, False: 0]
  ------------------
 1171|      0|                MP_VERBOSE(mpctx, "assuming this is an image\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1172|      0|                mpctx->time_frame += opts->image_display_duration / opts->playback_speed;
 1173|  2.48M|            } else if (mpctx->last_frame_duration > 0 && !opts->untimed &&
  ------------------
  |  Branch (1173:24): [True: 583, False: 2.48M]
  |  Branch (1173:58): [True: 1, False: 582]
  ------------------
 1174|      1|                       !(vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1174:24): [True: 1, False: 0]
  ------------------
 1175|      1|            {
 1176|      1|                MP_VERBOSE(mpctx, "using demuxer frame duration for last frame\n");
  ------------------
  |  |   92|      1|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1177|      1|                mpctx->time_frame += mpctx->last_frame_duration;
 1178|  2.48M|            } else {
 1179|  2.48M|                mpctx->time_frame = 0;
 1180|  2.48M|            }
 1181|       |            // Encode mode can't honor this; it'll only delay finishing.
 1182|  2.48M|            if (mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (1182:17): [True: 0, False: 2.48M]
  ------------------
 1183|      0|                mpctx->time_frame = 0;
 1184|  2.48M|        }
 1185|       |
 1186|       |        // Wait for the VO to signal actual EOF, then exit if the frame timer
 1187|       |        // has expired.
 1188|  2.82M|        bool has_frame = vo_has_frame(vo); // maybe not configured
 1189|  2.82M|        if (mpctx->video_status == STATUS_DRAINING &&
  ------------------
  |  Branch (1189:13): [True: 2.48M, False: 335k]
  ------------------
 1190|  2.48M|            (vo_is_ready_for_frame(vo, -1) || !has_frame))
  ------------------
  |  Branch (1190:14): [True: 1.38M, False: 1.09M]
  |  Branch (1190:47): [True: 1.09M, False: 7]
  ------------------
 1191|  2.48M|        {
 1192|  2.48M|            mpctx->time_frame -= get_relative_time(mpctx);
 1193|  2.48M|            mp_set_timeout(mpctx, mpctx->time_frame);
 1194|  2.48M|            if (mpctx->time_frame <= 0 || !has_frame) {
  ------------------
  |  Branch (1194:17): [True: 2.48M, False: 1]
  |  Branch (1194:43): [True: 0, False: 1]
  ------------------
 1195|  2.48M|                MP_VERBOSE(mpctx, "video EOF reached\n");
  ------------------
  |  |   92|  2.48M|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.48M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1196|  2.48M|                mpctx->video_status = STATUS_EOF;
 1197|  2.48M|            }
 1198|  2.48M|        }
 1199|       |
 1200|       |        // Avoid pointlessly spamming the logs every frame.
 1201|  2.82M|        if (!vo_c->is_sparse || !vo_c->sparse_eof_signalled) {
  ------------------
  |  Branch (1201:13): [True: 2.82M, False: 0]
  |  Branch (1201:33): [True: 0, False: 0]
  ------------------
 1202|  2.82M|            MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status);
  ------------------
  |  |   93|  2.82M|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.82M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1203|  2.82M|            vo_c->sparse_eof_signalled = vo_c->is_sparse;
 1204|  2.82M|        }
 1205|  2.82M|        return;
 1206|  2.82M|    }
 1207|       |
 1208|  38.6k|    if (r != VD_NEW_FRAME) {
  ------------------
  |  Branch (1208:9): [True: 902, False: 37.7k]
  ------------------
 1209|    902|        mp_wakeup_core(mpctx); // Decode more in next iteration.
 1210|    902|        return;
 1211|    902|    }
 1212|       |
 1213|       |    // A sparse still-image stream may have no frame at the seek target.
 1214|       |    // Complete the restart without showing it.
 1215|  37.7k|    if (vo_c->is_sparse && mpctx->video_status < STATUS_READY) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 37.7k]
  |  Branch (1215:28): [True: 0, False: 0]
  ------------------
 1216|      0|        double ref = mpctx->playback_pts != MP_NOPTS_VALUE
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1216:22): [True: 0, False: 0]
  ------------------
 1217|      0|                        ? mpctx->playback_pts : mpctx->last_seek_pts;
 1218|      0|        if (ref != MP_NOPTS_VALUE && mpctx->next_frames[0]->pts > ref + 1.0) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1218:13): [True: 0, False: 0]
  |  Branch (1218:38): [True: 0, False: 0]
  ------------------
 1219|      0|            MP_VERBOSE(mpctx, "sparse video: frame %f is ahead of %f, not "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1220|      0|                       "showing it for the restart\n",
 1221|      0|                       mpctx->next_frames[0]->pts, ref);
 1222|      0|            mpctx->video_status = STATUS_READY;
 1223|      0|            return;
 1224|      0|        }
 1225|      0|    }
 1226|       |
 1227|  37.7k|    if (logical_eof && !mpctx->num_past_frames && mpctx->num_next_frames == 1 &&
  ------------------
  |  Branch (1227:9): [True: 336, False: 37.4k]
  |  Branch (1227:24): [True: 320, False: 16]
  |  Branch (1227:51): [True: 320, False: 0]
  ------------------
 1228|    320|        use_video_lookahead(mpctx) && !vo_c->is_sparse)
  ------------------
  |  Branch (1228:9): [True: 0, False: 320]
  |  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|  37.7k|    apply_video_crop(mpctx, vo);
 1243|       |
 1244|       |    // Filter output is different from VO input?
 1245|  37.7k|    struct mp_image_params *p = &mpctx->next_frames[0]->params;
 1246|  37.7k|    if (!vo->params || !mp_image_params_static_equal(p, vo->params)) {
  ------------------
  |  Branch (1246:9): [True: 15.3k, False: 22.3k]
  |  Branch (1246:24): [True: 211, False: 22.1k]
  ------------------
 1247|       |        // Changing config deletes the current frame; wait until it's finished.
 1248|  15.5k|        if (vo_still_displaying(vo)) {
  ------------------
  |  Branch (1248:13): [True: 0, False: 15.5k]
  ------------------
 1249|      0|            vo_request_wakeup_on_done(vo);
 1250|      0|            return;
 1251|      0|        }
 1252|       |
 1253|  15.5k|        const struct vo_driver *info = mpctx->video_out->driver;
 1254|  15.5k|        char extra[20] = {0};
 1255|  15.5k|        if (p->p_w != p->p_h) {
  ------------------
  |  Branch (1255:13): [True: 27, False: 15.5k]
  ------------------
 1256|     27|            int d_w, d_h;
 1257|     27|            mp_image_params_get_dsize(p, &d_w, &d_h);
 1258|     27|            snprintf(extra, sizeof(extra), " => %dx%d", d_w, d_h);
 1259|     27|        }
 1260|  15.5k|        char sfmt[20] = {0};
 1261|  15.5k|        if (p->hw_subfmt)
  ------------------
  |  Branch (1261:13): [True: 0, False: 15.5k]
  ------------------
 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|  15.5k|        MP_INFO(mpctx, "VO: [%s] %dx%d%s %s%s\n",
  ------------------
  |  |   91|  15.5k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1264|  15.5k|                info->name, p->w, p->h, extra, mp_imgfmt_to_name(p->imgfmt), sfmt);
 1265|  15.5k|        MP_VERBOSE(mpctx, "VO: Description: %s\n", info->description);
  ------------------
  |  |   92|  15.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1266|       |
 1267|  15.5k|        int vo_r = vo_reconfig2(vo, mpctx->next_frames[0]);
 1268|  15.5k|        if (vo_r < 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 15.5k]
  ------------------
 1269|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
 1270|      0|            goto error;
 1271|      0|        }
 1272|  15.5k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1273|  22.1k|    } else {
 1274|       |        // Update parameters that don't require reconfiguring the VO.
 1275|  22.1k|        mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|  22.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1276|  22.1k|        mp_image_params_update_dynamic(vo->params, p, vo->has_peak_detect_values);
 1277|  22.1k|        mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|  22.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1278|  22.1k|    }
 1279|       |
 1280|  37.7k|    mpctx->time_frame -= get_relative_time(mpctx);
 1281|  37.7k|    update_avsync_before_frame(mpctx);
 1282|       |
 1283|       |    // Enforce timing subtitles to video frames.
 1284|  37.7k|    osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  37.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1285|       |
 1286|  37.7k|    if (!update_subtitles(mpctx, mpctx->next_frames[0]->pts)) {
  ------------------
  |  Branch (1286:9): [True: 0, False: 37.7k]
  ------------------
 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|  37.7k|    double time_frame = MPMAX(mpctx->time_frame, -1);
  ------------------
  |  |   44|  37.7k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 37.7k, False: 0]
  |  |  ------------------
  ------------------
 1292|  37.7k|    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|  37.7k|    if (!vo_is_ready_for_frame(vo, mpctx->display_sync_active ? -1 : pts))
  ------------------
  |  Branch (1297:9): [True: 945, False: 36.8k]
  |  Branch (1297:36): [True: 0, False: 37.7k]
  ------------------
 1298|    945|        return;
 1299|       |
 1300|       |    // In encoding mode, wait for the ao to finish initializing.
 1301|  36.8k|    if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_AUDIO] && !mpctx->ao)
  ------------------
  |  Branch (1301:9): [True: 0, False: 36.8k]
  |  Branch (1301:35): [True: 0, False: 0]
  |  Branch (1301:76): [True: 0, False: 0]
  ------------------
 1302|      0|        return;
 1303|       |
 1304|  36.8k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (1304:5): [True: 36.8k, False: 0]
  ------------------
 1305|       |
 1306|  36.8k|    if (mpctx->num_past_frames >= MAX_NUM_VO_PTS)
  ------------------
  |  Branch (1306:9): [True: 0, False: 36.8k]
  ------------------
 1307|      0|        mpctx->num_past_frames--;
 1308|  36.8k|    MP_TARRAY_INSERT_AT(mpctx, mpctx->past_frames, mpctx->num_past_frames, 0,
  ------------------
  |  |  115|  36.8k|    do {                                            \
  |  |  116|  36.8k|        size_t at_ = (at);                          \
  |  |  117|  36.8k|        assert(at_ <= (idxvar));                    \
  |  |  118|  36.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  36.8k|    do {                                            \
  |  |  |  |   97|  36.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  36.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  36.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  36.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 14.3k, False: 22.4k]
  |  |  |  |  ------------------
  |  |  |  |   99|  36.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  14.3k|    do {                                                        \
  |  |  |  |  |  |   89|  14.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  14.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  14.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  14.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  14.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  14.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  14.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 14.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  36.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 36.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  36.8k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  36.8k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  36.8k|        (idxvar)++;                                 \
  |  |  122|  36.8k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  36.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 36.8k]
  |  |  ------------------
  ------------------
  |  Branch (1308:5): [True: 36.8k, False: 0]
  ------------------
 1309|  36.8k|                        (struct frame_info){0});
 1310|  36.8k|    mpctx->past_frames[0] = (struct frame_info){
 1311|  36.8k|        .pts = mpctx->next_frames[0]->pts,
 1312|  36.8k|        .num_vsyncs = -1,
 1313|  36.8k|    };
 1314|  36.8k|    calculate_frame_duration(mpctx);
 1315|       |
 1316|  36.8k|    int req = vo_get_num_req_frames(mpctx->video_out);
 1317|  36.8k|    mp_assert(req >= 1 && req <= VO_MAX_REQ_FRAMES);
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 36.8k, False: 0]
  |  Branch (1317:5): [True: 36.8k, False: 0]
  ------------------
 1318|  36.8k|    struct vo_frame dummy = {
 1319|  36.8k|        .pts = pts,
 1320|  36.8k|        .duration = -1,
 1321|  36.8k|        .still = mpctx->step_frames > 0,
 1322|  36.8k|        .can_drop = opts->frame_dropping & 1,
 1323|  36.8k|        .num_frames = MPMIN(mpctx->num_next_frames, req),
  ------------------
  |  |   45|  36.8k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 214, False: 36.6k]
  |  |  ------------------
  ------------------
 1324|  36.8k|        .num_vsyncs = 1,
 1325|  36.8k|    };
 1326|  73.6k|    for (int n = 0; n < dummy.num_frames; n++)
  ------------------
  |  Branch (1326:21): [True: 36.8k, False: 36.8k]
  ------------------
 1327|  36.8k|        dummy.frames[n] = mpctx->next_frames[n];
 1328|  36.8k|    struct vo_frame *frame = vo_frame_ref(&dummy);
 1329|       |
 1330|  36.8k|    double diff = mpctx->past_frames[0].approx_duration;
 1331|  36.8k|    if (opts->untimed || (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1331:9): [True: 36.6k, False: 217]
  |  Branch (1331:26): [True: 0, False: 217]
  ------------------
 1332|  36.6k|        diff = -1; // disable frame dropping and aspects of frame timing
 1333|  36.8k|    if (diff >= 0) {
  ------------------
  |  Branch (1333:9): [True: 217, False: 36.6k]
  ------------------
 1334|    217|        diff /= mpctx->video_speed;
 1335|    217|        frame->duration = MP_TIME_S_TO_NS(MPCLAMP(diff, 0, 10));
  ------------------
  |  |   71|    868|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 0, False: 217]
  |  |  |  Branch (71:30): [True: 0, False: 217]
  |  |  ------------------
  ------------------
 1336|    217|    }
 1337|       |
 1338|  36.8k|    mpctx->video_pts = mpctx->next_frames[0]->pts;
 1339|  36.8k|    mpctx->video_pts_unrounded = mpctx->next_pts_unrounded;
 1340|  36.8k|    mpctx->last_frame_duration =
 1341|  36.8k|        mpctx->next_frames[0]->pkt_duration / mpctx->video_speed;
 1342|       |
 1343|  36.8k|    shift_frames(mpctx);
 1344|       |
 1345|  36.8k|    schedule_frame(mpctx, frame);
 1346|       |
 1347|  36.8k|    mpctx->osd_force_update = true;
 1348|  36.8k|    update_osd_msg(mpctx);
 1349|       |
 1350|  36.8k|    vo_queue_frame(vo, frame);
 1351|       |
 1352|  36.8k|    check_framedrop(mpctx, vo_c);
 1353|       |
 1354|       |    // The frames were shifted down; "initialize" the new first entry.
 1355|  36.8k|    if (mpctx->num_next_frames >= 1)
  ------------------
  |  Branch (1355:9): [True: 214, False: 36.6k]
  ------------------
 1356|    214|        handle_new_frame(mpctx);
 1357|       |
 1358|  36.8k|    mpctx->shown_vframes++;
 1359|  36.8k|    if (mpctx->video_status < STATUS_PLAYING) {
  ------------------
  |  Branch (1359:9): [True: 17.2k, False: 19.6k]
  ------------------
 1360|  17.2k|        mpctx->video_status = STATUS_READY;
 1361|       |        // After a seek, make sure to wait until the first frame is visible.
 1362|  17.2k|        if (!opts->video_latency_hacks) {
  ------------------
  |  Branch (1362:13): [True: 17.2k, False: 0]
  ------------------
 1363|  17.2k|            vo_wait_frame(vo);
 1364|  17.2k|            MP_VERBOSE(mpctx, "first video frame after restart shown\n");
  ------------------
  |  |   92|  17.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  17.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1365|  17.2k|        }
 1366|  17.2k|    }
 1367|       |
 1368|  36.8k|    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|  36.8k|    if (logical_eof && !mpctx->num_next_frames && mpctx->ao_chain)
  ------------------
  |  Branch (1373:9): [True: 324, False: 36.4k]
  |  Branch (1373:24): [True: 324, False: 0]
  |  Branch (1373:51): [True: 293, False: 31]
  ------------------
 1374|    293|        mpctx->video_status = STATUS_EOF;
 1375|       |
 1376|  36.8k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (1376:9): [True: 36.5k, False: 293]
  ------------------
 1377|  36.5k|        if (mpctx->step_frames > 0) {
  ------------------
  |  Branch (1377:13): [True: 14.2k, False: 22.2k]
  ------------------
 1378|  14.2k|            mpctx->step_frames--;
 1379|  14.2k|            if (!mpctx->step_frames) {
  ------------------
  |  Branch (1379:17): [True: 5.26k, False: 8.99k]
  ------------------
 1380|  5.26k|                set_pause_state(mpctx, true);
 1381|  5.26k|                step_frame_mute(mpctx, false);
 1382|  5.26k|            }
 1383|  14.2k|        }
 1384|  36.5k|        if (mpctx->max_frames == 0 && !mpctx->stop_play)
  ------------------
  |  Branch (1384:13): [True: 0, False: 36.5k]
  |  Branch (1384:39): [True: 0, False: 0]
  ------------------
 1385|      0|            mpctx->stop_play = AT_END_OF_FILE;
 1386|  36.5k|        if (mpctx->max_frames > 0)
  ------------------
  |  Branch (1386:13): [True: 0, False: 36.5k]
  ------------------
 1387|      0|            mpctx->max_frames--;
 1388|  36.5k|    }
 1389|       |
 1390|  36.8k|    vo_c->underrun_signaled = false;
 1391|       |
 1392|  36.8k|    if (mpctx->video_status == STATUS_EOF || mpctx->stop_play)
  ------------------
  |  Branch (1392:9): [True: 293, False: 36.5k]
  |  Branch (1392:46): [True: 0, False: 36.5k]
  ------------------
 1393|    293|        mp_wakeup_core(mpctx);
 1394|  36.8k|    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|  30.1k|{
   68|  30.1k|    struct MPOpts *opts = mpctx->opts;
   69|  30.1k|    struct vo_chain *vo_c = mpctx->vo_chain;
   70|  30.1k|    mp_assert(vo_c);
  ------------------
  |  |   41|  30.1k|#define mp_assert assert
  ------------------
  |  Branch (70:5): [True: 30.1k, False: 0]
  ------------------
   71|       |
   72|  30.1k|    return mp_output_chain_update_filters(vo_c->filter, opts->vf_settings);
   73|  30.1k|}
video.c:vo_chain_reset_state:
   93|  2.55M|{
   94|  2.55M|    vo_seek_reset(vo_c->vo);
   95|  2.55M|    vo_c->underrun = false;
   96|       |    vo_c->underrun_signaled = false;
   97|  2.55M|}
video.c:vo_chain_uninit:
  141|  29.8k|{
  142|  29.8k|    struct track *track = vo_c->track;
  143|  29.8k|    if (track) {
  ------------------
  |  Branch (143:9): [True: 29.8k, False: 0]
  ------------------
  144|  29.8k|        mp_assert(track->vo_c == vo_c);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (144:9): [True: 29.8k, False: 0]
  ------------------
  145|  29.8k|        track->vo_c = NULL;
  146|  29.8k|        if (vo_c->dec_src)
  ------------------
  |  Branch (146:13): [True: 29.8k, False: 0]
  ------------------
  147|  29.8k|            mp_assert(track->dec->f->pins[0] == vo_c->dec_src);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (147:13): [True: 29.8k, False: 0]
  ------------------
  148|       |        // This is NULL if a sh_stream_group's filter fails.
  149|  29.8k|        if (track->dec) {
  ------------------
  |  Branch (149:13): [True: 29.8k, False: 0]
  ------------------
  150|  29.8k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  29.8k|#define talloc_free                     ta_free
  ------------------
  151|  29.8k|            track->dec = NULL;
  152|  29.8k|        }
  153|  29.8k|    }
  154|       |
  155|  29.8k|    if (vo_c->filter_src)
  ------------------
  |  Branch (155:9): [True: 0, False: 29.8k]
  ------------------
  156|      0|        mp_pin_disconnect(vo_c->filter_src);
  157|       |
  158|  29.8k|    talloc_free(vo_c->filter->f);
  ------------------
  |  |   47|  29.8k|#define talloc_free                     ta_free
  ------------------
  159|  29.8k|    talloc_free(vo_c);
  ------------------
  |  |   47|  29.8k|#define talloc_free                     ta_free
  ------------------
  160|       |    // this does not free the VO
  161|  29.8k|}
video.c:vo_chain_init_decoder:
  232|  29.8k|{
  233|  29.8k|    struct track *track = vo_c->track;
  234|  29.8k|    if (!init_video_decoder(mpctx, track))
  ------------------
  |  Branch (234:9): [True: 0, False: 29.8k]
  ------------------
  235|      0|        return false;
  236|  29.8k|    vo_c->dec_src = track->dec->f->pins[0];
  237|  29.8k|    vo_c->filter->container_fps =
  238|  29.8k|        mp_decoder_wrapper_get_container_fps(track->dec);
  239|  29.8k|    if (vo_c->is_coverart)
  ------------------
  |  Branch (239:9): [True: 0, False: 29.8k]
  ------------------
  240|      0|        mp_decoder_wrapper_set_coverart_flag(track->dec, true);
  241|  29.8k|    mp_pin_connect(vo_c->filter->f->pins[0], vo_c->dec_src);
  242|       |    return true;
  243|  29.8k|}
video.c:filter_update_subtitles:
  223|  37.9k|{
  224|  37.9k|    struct MPContext *mpctx = ctx;
  225|       |
  226|  37.9k|    if (osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  Branch (226:9): [True: 0, False: 37.9k]
  ------------------
  227|      0|        update_subtitles(mpctx, pts);
  228|  37.9k|}
video.c:video_output_image:
  520|  5.04M|{
  521|  5.04M|    struct vo_chain *vo_c = mpctx->vo_chain;
  522|  5.04M|    bool hrseek = false;
  523|  5.04M|    double hrseek_pts = mpctx->hrseek_pts;
  524|  5.04M|    double tolerance = mpctx->hrseek_backstep ? 0 : .005;
  ------------------
  |  Branch (524:24): [True: 311, False: 5.04M]
  ------------------
  525|  5.04M|    if (mpctx->video_status == STATUS_SYNCING) {
  ------------------
  |  Branch (525:9): [True: 5.02M, False: 21.1k]
  ------------------
  526|  5.02M|        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|  5.02M|        if (!hrseek && mpctx->playback_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  61.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (530:13): [True: 61.2k, False: 4.96M]
  |  Branch (530:24): [True: 7.08k, False: 54.1k]
  ------------------
  531|  7.08k|            hrseek = true;
  532|  7.08k|            hrseek_pts = mpctx->playback_pts;
  533|  7.08k|        }
  534|  5.02M|    }
  535|       |
  536|  5.04M|    if (vo_c->is_coverart) {
  ------------------
  |  Branch (536:9): [True: 0, False: 5.04M]
  ------------------
  537|      0|        *logical_eof = true;
  538|      0|        if (vo_has_frame(mpctx->video_out))
  ------------------
  |  Branch (538:13): [True: 0, False: 0]
  ------------------
  539|      0|            return VD_EOF;
  540|      0|    }
  541|       |
  542|       |    // Sparse streams usually have no frame at the seek target, or rather we
  543|       |    // don't want to jump to next keyframe, when there is a lot of other stream
  544|       |    // data in between.
  545|  5.04M|    if (vo_c->is_sparse)
  ------------------
  |  Branch (545:9): [True: 0, False: 5.04M]
  ------------------
  546|      0|        hrseek = false;
  547|       |
  548|  5.04M|    if (have_new_frame(mpctx, false))
  ------------------
  |  Branch (548:9): [True: 918, False: 5.04M]
  ------------------
  549|    918|        return VD_NEW_FRAME;
  550|       |
  551|       |    // Get a new frame if we need one.
  552|  5.04M|    int r = VD_PROGRESS;
  553|  5.04M|    if (needs_new_frame(mpctx)) {
  ------------------
  |  Branch (553:9): [True: 5.04M, False: 0]
  ------------------
  554|       |        // Filter a new frame.
  555|  5.04M|        struct mp_image *img = NULL;
  556|  5.04M|        struct mp_frame frame = mp_pin_out_read(vo_c->filter->f->pins[1]);
  557|  5.04M|        if (frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (557:13): [True: 2.52M, False: 2.52M]
  ------------------
  558|  2.52M|            r = vo_c->filter->got_output_eof ? VD_EOF : VD_WAIT;
  ------------------
  |  Branch (558:17): [True: 23, False: 2.52M]
  ------------------
  559|  2.52M|        } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (559:20): [True: 2.48M, False: 37.9k]
  ------------------
  560|  2.48M|            r = VD_EOF;
  561|  2.48M|        } else if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (561:20): [True: 37.9k, False: 0]
  ------------------
  562|  37.9k|            img = frame.data;
  563|  37.9k|        } 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|  5.04M|        if (img) {
  ------------------
  |  Branch (569:13): [True: 37.9k, False: 5.00M]
  ------------------
  570|  37.9k|            double endpts = get_play_end_pts(mpctx);
  571|  37.9k|            if (endpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  37.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (571:17): [True: 660, False: 37.2k]
  ------------------
  572|    660|                endpts *= mpctx->play_dir;
  573|  37.9k|            if ((endpts != MP_NOPTS_VALUE && img->pts >= endpts) ||
  ------------------
  |  |   39|  75.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (573:18): [True: 660, False: 37.2k]
  |  Branch (573:46): [True: 492, False: 168]
  ------------------
  574|  37.4k|                mpctx->max_frames == 0)
  ------------------
  |  Branch (574:17): [True: 0, False: 37.4k]
  ------------------
  575|    492|            {
  576|    492|                mp_pin_out_unread(vo_c->filter->f->pins[1], frame);
  577|    492|                img = NULL;
  578|    492|                r = VD_EOF;
  579|  37.4k|            } else if (hrseek && (img->pts < hrseek_pts - tolerance ||
  ------------------
  |  Branch (579:24): [True: 3.13k, False: 34.2k]
  |  Branch (579:35): [True: 844, False: 2.28k]
  ------------------
  580|  2.28k|                                  mpctx->hrseek_lastframe))
  ------------------
  |  Branch (580:35): [True: 0, False: 2.28k]
  ------------------
  581|    844|            {
  582|       |                /* just skip - but save in case it was the last frame */
  583|    844|                mp_image_setrefp(&mpctx->saved_frame, img);
  584|  36.5k|            } else {
  585|  36.5k|                if (hrseek && mpctx->hrseek_backstep) {
  ------------------
  |  Branch (585:21): [True: 2.28k, False: 34.2k]
  |  Branch (585:31): [True: 42, False: 2.24k]
  ------------------
  586|     42|                    if (mpctx->saved_frame) {
  ------------------
  |  Branch (586:25): [True: 1, False: 41]
  ------------------
  587|      1|                        add_new_frame(mpctx, mpctx->saved_frame);
  588|      1|                        mpctx->saved_frame = NULL;
  589|     41|                    } else {
  590|     41|                        MP_WARN(mpctx, "Backstep failed.\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__)
  |  |  ------------------
  ------------------
  591|     41|                    }
  592|     42|                    mpctx->hrseek_backstep = false;
  593|     42|                }
  594|  36.5k|                mp_image_unrefp(&mpctx->saved_frame);
  595|  36.5k|                add_new_frame(mpctx, img);
  596|  36.5k|                img = NULL;
  597|  36.5k|            }
  598|  37.9k|            talloc_free(img);
  ------------------
  |  |   47|  37.9k|#define talloc_free                     ta_free
  ------------------
  599|  37.9k|        }
  600|  5.04M|    }
  601|       |
  602|  5.04M|    if (!hrseek)
  ------------------
  |  Branch (602:9): [True: 74.4k, False: 4.97M]
  ------------------
  603|  74.4k|        mp_image_unrefp(&mpctx->saved_frame);
  604|       |
  605|  5.04M|    if (r == VD_EOF) {
  ------------------
  |  Branch (605:9): [True: 2.48M, False: 2.55M]
  ------------------
  606|       |        // If hr-seek went past EOF, use the last frame.
  607|  2.48M|        if (mpctx->saved_frame)
  ------------------
  |  Branch (607:13): [True: 320, False: 2.48M]
  ------------------
  608|    320|            add_new_frame(mpctx, mpctx->saved_frame);
  609|  2.48M|        mpctx->saved_frame = NULL;
  610|  2.48M|        *logical_eof = true;
  611|  2.48M|    }
  612|       |
  613|  5.04M|    return have_new_frame(mpctx, r <= 0) ? VD_NEW_FRAME : r;
  ------------------
  |  Branch (613:12): [True: 36.8k, False: 5.01M]
  ------------------
  614|  5.04M|}
video.c:have_new_frame:
  512|  10.0M|{
  513|  10.0M|    return mpctx->num_next_frames >= get_req_frames(mpctx, eof);
  514|  10.0M|}
video.c:get_req_frames:
  471|  15.1M|{
  472|       |    // On EOF, drain all frames.
  473|  15.1M|    if (eof)
  ------------------
  |  Branch (473:9): [True: 2.48M, False: 12.6M]
  ------------------
  474|  2.48M|        return 1;
  475|       |
  476|  12.6M|    if (!use_video_lookahead(mpctx))
  ------------------
  |  Branch (476:9): [True: 12.6M, False: 1.87k]
  ------------------
  477|  12.6M|        return 1;
  478|       |
  479|  1.87k|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (479:9): [True: 1.87k, False: 0]
  |  Branch (479:28): [True: 0, False: 1.87k]
  ------------------
  480|      0|        return 1;
  481|       |
  482|       |    // Normally require at least 2 frames, so we can compute a frame duration.
  483|  1.87k|    int min = 2;
  484|       |
  485|       |    // On the first frame, output a new frame as quickly as possible.
  486|  1.87k|    if (mpctx->video_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  1.87k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (486:9): [True: 828, False: 1.04k]
  ------------------
  487|    828|        return min;
  488|       |
  489|  1.04k|    int req = vo_get_num_req_frames(mpctx->video_out);
  490|  1.04k|    return MPCLAMP(req, min, MP_ARRAY_SIZE(mpctx->next_frames) - 1);
  ------------------
  |  |   46|  1.04k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 1.04k, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  491|  1.87k|}
video.c:needs_new_frame:
  495|  5.04M|{
  496|       |    return mpctx->num_next_frames < get_req_frames(mpctx, false);
  497|  5.04M|}
video.c:add_new_frame:
  501|  36.8k|{
  502|  36.8k|    mp_assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames));
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (502:5): [True: 36.8k, False: 0]
  ------------------
  503|  36.8k|    mp_assert(frame);
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (503:5): [True: 36.8k, False: 0]
  ------------------
  504|  36.8k|    mpctx->next_frames[mpctx->num_next_frames++] = frame;
  505|  36.8k|    if (mpctx->num_next_frames == 1)
  ------------------
  |  Branch (505:9): [True: 36.6k, False: 225]
  ------------------
  506|  36.6k|        handle_new_frame(mpctx);
  507|  36.8k|}
video.c:check_for_hwdec_fallback:
  617|  2.82M|{
  618|  2.82M|    struct vo_chain *vo_c = mpctx->vo_chain;
  619|       |
  620|  2.82M|    if (!vo_c->filter->failed_output_conversion || !vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (620:9): [True: 2.82M, False: 0]
  |  Branch (620:52): [True: 0, False: 0]
  |  Branch (620:68): [True: 0, False: 0]
  ------------------
  621|  2.82M|        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|  2.82M|{
  633|  2.82M|    struct vo_chain *vo_c = mpctx->vo_chain;
  634|       |
  635|  2.82M|    if (!vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (635:9): [True: 0, False: 2.82M]
  |  Branch (635:25): [True: 0, False: 2.82M]
  ------------------
  636|      0|        return false;
  637|       |
  638|  2.82M|    struct mp_decoder_wrapper *dec = vo_c->track->dec;
  639|  2.82M|    bool forced_eof = false;
  640|       |
  641|  2.82M|    mp_decoder_wrapper_control(dec, VDCTRL_CHECK_FORCED_EOF, &forced_eof);
  642|  2.82M|    return forced_eof;
  643|  2.82M|}
video.c:use_video_lookahead:
  463|  12.6M|{
  464|  12.6M|    return mpctx->video_out &&
  ------------------
  |  Branch (464:12): [True: 12.6M, False: 0]
  ------------------
  465|  12.6M|           !(mpctx->video_out->driver->caps & VO_CAP_NORETAIN) &&
  ------------------
  |  Branch (465:12): [True: 12.6M, False: 0]
  ------------------
  466|  12.6M|           !(mpctx->opts->untimed || (mpctx->video_out->driver->caps & VO_CAP_UNTIMED)) &&
  ------------------
  |  Branch (466:14): [True: 12.6M, False: 1.87k]
  |  Branch (466:38): [True: 0, False: 1.87k]
  ------------------
  467|  1.87k|           !mpctx->opts->video_latency_hacks;
  ------------------
  |  Branch (467:12): [True: 1.87k, False: 0]
  ------------------
  468|  12.6M|}
video.c:apply_video_crop:
 1083|  37.7k|{
 1084|  76.1k|    for (int n = 0; n < mpctx->num_next_frames; n++) {
  ------------------
  |  Branch (1084:21): [True: 38.4k, False: 37.7k]
  ------------------
 1085|  38.4k|        struct m_geometry *gm = &vo->opts->video_crop;
 1086|  38.4k|        struct mp_image_params p = mpctx->next_frames[n]->params;
 1087|  38.4k|        if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
  ------------------
  |  Branch (1087:13): [True: 0, False: 38.4k]
  |  Branch (1087:30): [True: 0, False: 38.4k]
  |  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|  38.4k|        if (p.crop.x1 == 0 && p.crop.y1 == 0)
  ------------------
  |  Branch (1092:13): [True: 0, False: 38.4k]
  |  Branch (1092:31): [True: 0, False: 0]
  ------------------
 1093|      0|            return;
 1094|       |
 1095|  38.4k|        if (!mp_image_crop_valid(&p)) {
  ------------------
  |  Branch (1095:13): [True: 0, False: 38.4k]
  ------------------
 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|  38.4k|        mpctx->next_frames[n]->params.crop = p.crop;
 1105|  38.4k|    }
 1106|  37.7k|}
video.c:update_avsync_before_frame:
  649|  37.7k|{
  650|  37.7k|    struct MPOpts *opts = mpctx->opts;
  651|  37.7k|    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|  37.7k|    bool first_frame = mpctx->video_pts == MP_NOPTS_VALUE;
  ------------------
  |  |   39|  37.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  660|  37.7k|    if (first_frame && mpctx->audio_status == STATUS_PLAYING) {
  ------------------
  |  Branch (660:9): [True: 17.2k, False: 20.5k]
  |  Branch (660:24): [True: 338, False: 16.8k]
  ------------------
  661|    338|        double apts = written_audio_pts(mpctx);
  662|    338|        double pts = mpctx->next_frames[0]->pts;
  663|    338|        if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|    676|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|    338|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (663:13): [True: 338, False: 0]
  |  Branch (663:39): [True: 338, False: 0]
  ------------------
  664|    338|            mpctx->delay = apts + opts->audio_delay - pts;
  665|    338|    }
  666|       |
  667|  37.7k|    if (mpctx->video_status < STATUS_READY && mpctx->audio_status != STATUS_PLAYING) {
  ------------------
  |  Branch (667:9): [True: 17.2k, False: 20.5k]
  |  Branch (667:47): [True: 16.8k, False: 338]
  ------------------
  668|  16.8k|        mpctx->time_frame = 0;
  669|  20.9k|    } else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
  ------------------
  |  Branch (669:16): [True: 0, False: 20.9k]
  |  Branch (669:46): [True: 0, False: 20.9k]
  ------------------
  670|       |        // don't touch the timing
  671|  20.9k|    } else if (mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao)) {
  ------------------
  |  Branch (671:16): [True: 16.5k, False: 4.33k]
  |  Branch (671:57): [True: 0, False: 16.5k]
  ------------------
  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|  20.9k|    } 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|  20.9k|        if (mpctx->time_frame < -0.2 || opts->untimed ||
  ------------------
  |  Branch (699:13): [True: 0, False: 20.9k]
  |  Branch (699:41): [True: 20.2k, False: 616]
  ------------------
  700|    616|            (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (700:13): [True: 0, False: 616]
  ------------------
  701|  20.2k|            mpctx->time_frame = 0;
  702|  20.9k|    }
  703|  37.7k|}
video.c:calculate_frame_duration:
 1032|  36.8k|{
 1033|  36.8k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1034|  36.8k|    mp_assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (1034:5): [True: 36.8k, False: 0]
  |  Branch (1034:5): [True: 36.8k, False: 0]
  ------------------
 1035|       |
 1036|  36.8k|    double demux_duration = vo_c->filter->container_fps > 0
  ------------------
  |  Branch (1036:29): [True: 36.8k, False: 0]
  ------------------
 1037|  36.8k|                            ? 1.0 / vo_c->filter->container_fps : -1;
 1038|  36.8k|    double duration = demux_duration;
 1039|       |
 1040|  36.8k|    if (mpctx->num_next_frames >= 2) {
  ------------------
  |  Branch (1040:9): [True: 214, False: 36.6k]
  ------------------
 1041|    214|        double pts0 = mpctx->next_frames[0]->pts;
 1042|    214|        double pts1 = mpctx->next_frames[1]->pts;
 1043|    214|        if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|    428|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|    428|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1043:13): [True: 214, False: 0]
  |  Branch (1043:39): [True: 214, False: 0]
  |  Branch (1043:65): [True: 214, False: 0]
  ------------------
 1044|    214|            duration = pts1 - pts0;
 1045|    214|    }
 1046|       |
 1047|       |    // The following code tries to compensate for rounded Matroska timestamps
 1048|       |    // by "unrounding" frame durations, or if not possible, approximating them.
 1049|  36.8k|    double tolerance = MP_PTS_ROUNDING_TOLERANCE;
  ------------------
  |  |   72|  36.8k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
 1050|       |
 1051|  36.8k|    double total = 0;
 1052|  36.8k|    int num_dur = 0;
 1053|   214k|    for (int n = 1; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (1053:21): [True: 177k, False: 36.8k]
  ------------------
 1054|       |        // Eliminate likely outliers using a really dumb heuristic.
 1055|   177k|        double dur = mpctx->past_frames[n].duration;
 1056|   177k|        if (dur <= 0 || fabs(dur - duration) >= tolerance)
  ------------------
  |  Branch (1056:13): [True: 0, False: 177k]
  |  Branch (1056:25): [True: 0, False: 177k]
  ------------------
 1057|      0|            break;
 1058|   177k|        total += dur;
 1059|   177k|        num_dur += 1;
 1060|   177k|    }
 1061|  36.8k|    double approx_duration = num_dur > 0 ? total / num_dur : duration;
  ------------------
  |  Branch (1061:30): [True: 19.6k, False: 17.2k]
  ------------------
 1062|       |
 1063|       |    // Try if the demuxer frame rate fits - if so, just take it.
 1064|  36.8k|    if (demux_duration > 0) {
  ------------------
  |  Branch (1064:9): [True: 36.8k, False: 0]
  ------------------
 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|  36.8k|        if (fabs(duration - demux_duration) < tolerance &&
  ------------------
  |  Branch (1067:13): [True: 36.8k, False: 0]
  ------------------
 1068|  36.8k|            fabs(total - demux_duration * num_dur) < tolerance &&
  ------------------
  |  Branch (1068:13): [True: 36.8k, False: 0]
  ------------------
 1069|  36.8k|            (num_dur >= 16 || num_dur >= mpctx->num_past_frames - 4))
  ------------------
  |  Branch (1069:14): [True: 4.15k, False: 32.6k]
  |  Branch (1069:31): [True: 32.6k, False: 0]
  ------------------
 1070|  36.8k|        {
 1071|  36.8k|            approx_duration = demux_duration;
 1072|  36.8k|        }
 1073|  36.8k|    }
 1074|       |
 1075|  36.8k|    mpctx->past_frames[0].duration = duration;
 1076|  36.8k|    mpctx->past_frames[0].approx_duration = approx_duration;
 1077|       |
 1078|  36.8k|    MP_STATS(mpctx, "value %f frame-duration", MPMAX(0, duration));
  ------------------
  |  |   99|  36.8k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  73.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 36.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1079|  36.8k|    MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
  ------------------
  |  |   99|  36.8k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  73.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 36.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|  36.8k|}
video.c:shift_frames:
  453|  36.8k|{
  454|  36.8k|    if (mpctx->num_next_frames < 1)
  ------------------
  |  Branch (454:9): [True: 0, False: 36.8k]
  ------------------
  455|      0|        return;
  456|  36.8k|    talloc_free(mpctx->next_frames[0]);
  ------------------
  |  |   47|  36.8k|#define talloc_free                     ta_free
  ------------------
  457|  37.0k|    for (int n = 0; n < mpctx->num_next_frames - 1; n++)
  ------------------
  |  Branch (457:21): [True: 214, False: 36.8k]
  ------------------
  458|    214|        mpctx->next_frames[n] = mpctx->next_frames[n + 1];
  459|  36.8k|    mpctx->num_next_frames -= 1;
  460|  36.8k|}
video.c:schedule_frame:
 1008|  36.8k|{
 1009|  36.8k|    handle_display_sync_frame(mpctx, frame);
 1010|       |
 1011|  36.8k|    if (mpctx->num_past_frames > 1 &&
  ------------------
  |  Branch (1011:9): [True: 19.6k, False: 17.2k]
  ------------------
 1012|  19.6k|        ((mpctx->past_frames[1].num_vsyncs >= 0) != mpctx->display_sync_active))
  ------------------
  |  Branch (1012:9): [True: 0, False: 19.6k]
  ------------------
 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|  36.8k|    if (!mpctx->display_sync_active) {
  ------------------
  |  Branch (1018:9): [True: 36.8k, False: 0]
  ------------------
 1019|  36.8k|        if (mpctx->num_past_frames > 1 && mpctx->past_frames[1].num_vsyncs >= 0) {
  ------------------
  |  Branch (1019:13): [True: 19.6k, False: 17.2k]
  |  Branch (1019:43): [True: 0, False: 19.6k]
  ------------------
 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|  36.8k|        update_av_diff(mpctx, mpctx->time_frame > 0 ?
  ------------------
  |  Branch (1025:31): [True: 176, False: 36.6k]
  ------------------
 1026|  36.6k|            mpctx->time_frame * mpctx->video_speed : 0);
 1027|  36.8k|    }
 1028|  36.8k|}
video.c:handle_display_sync_frame:
  861|  36.8k|{
  862|  36.8k|    struct MPOpts *opts = mpctx->opts;
  863|  36.8k|    struct vo *vo = mpctx->video_out;
  864|  36.8k|    int mode = vo->opts->video_sync;
  865|       |
  866|  36.8k|    bool sync_start = !mpctx->display_sync_active;
  867|  36.8k|    if (sync_start) {
  ------------------
  |  Branch (867:9): [True: 36.8k, False: 0]
  ------------------
  868|  36.8k|        mpctx->display_sync_error = 0.0;
  869|  36.8k|        mpctx->audio_drift_compensation = 0.0;
  870|  36.8k|        mpctx->avd_filtered = 0;
  871|  36.8k|    }
  872|       |
  873|  36.8k|    mpctx->display_sync_active = false;
  874|       |
  875|  36.8k|    if (!VS_IS_DISP(mode) || !vo_is_visible(vo) || mpctx->vo_chain->is_sparse ||
  ------------------
  |  |  131|  73.6k|#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE ||       \
  |  |  ------------------
  |  |  |  Branch (131:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  132|  36.8k|                       (x) == VS_DISP_RESAMPLE_VDROP || \
  |  |  ------------------
  |  |  |  Branch (132:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  133|  36.8k|                       (x) == VS_DISP_RESAMPLE_NONE ||  \
  |  |  ------------------
  |  |  |  Branch (133:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  134|  36.8k|                       (x) == VS_DISP_TEMPO ||          \
  |  |  ------------------
  |  |  |  Branch (134:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  135|  36.8k|                       (x) == VS_DISP_ADROP ||          \
  |  |  ------------------
  |  |  |  Branch (135:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  136|  36.8k|                       (x) == VS_DISP_VDROP ||          \
  |  |  ------------------
  |  |  |  Branch (136:24): [True: 0, False: 36.8k]
  |  |  ------------------
  |  |  137|  73.6k|                       (x) == VS_DISP_NONE)
  |  |  ------------------
  |  |  |  Branch (137:24): [True: 0, False: 36.8k]
  |  |  ------------------
  ------------------
  |  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|  36.8k|        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|  36.8k|{
  708|  36.8k|    struct MPOpts *opts = mpctx->opts;
  709|       |
  710|  36.8k|    mpctx->last_av_difference = 0;
  711|       |
  712|  36.8k|    if (mpctx->audio_status != STATUS_PLAYING ||
  ------------------
  |  Branch (712:9): [True: 21.1k, False: 15.7k]
  ------------------
  713|  15.7k|        mpctx->video_status != STATUS_PLAYING)
  ------------------
  |  Branch (713:9): [True: 338, False: 15.3k]
  ------------------
  714|  21.4k|        return;
  715|       |
  716|  15.3k|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (716:9): [True: 15.3k, False: 0]
  |  Branch (716:28): [True: 0, False: 15.3k]
  ------------------
  717|      0|        return;
  718|       |
  719|  15.3k|    double a_pos = playing_audio_pts(mpctx);
  720|  15.3k|    if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  30.7k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  15.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (720:9): [True: 15.3k, False: 0]
  |  Branch (720:36): [True: 15.3k, False: 0]
  ------------------
  721|  15.3k|        mpctx->last_av_difference = a_pos - mpctx->video_pts_unrounded
  722|  15.3k|                                  + opts->audio_delay + offset;
  723|  15.3k|    }
  724|       |
  725|  15.3k|    if (fabs(mpctx->last_av_difference) > 0.5 && !mpctx->drop_message_shown) {
  ------------------
  |  Branch (725:9): [True: 210, False: 15.1k]
  |  Branch (725:50): [True: 84, False: 126]
  ------------------
  726|     84|        MP_WARN(mpctx, "%s", av_desync_help_text);
  ------------------
  |  |   90|     84|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     84|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  727|       |        mpctx->drop_message_shown = true;
  728|     84|    }
  729|  15.3k|}
video.c:check_framedrop:
  355|  36.8k|{
  356|  36.8k|    struct MPOpts *opts = mpctx->opts;
  357|       |    // check for frame-drop:
  358|  36.8k|    if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
  ------------------
  |  Branch (358:9): [True: 19.6k, False: 17.2k]
  |  Branch (358:50): [True: 19.6k, False: 0]
  ------------------
  359|  19.6k|        mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao) &&
  ------------------
  |  Branch (359:9): [True: 15.3k, False: 4.24k]
  |  Branch (359:50): [True: 0, False: 15.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|  36.8k|}
video.c:handle_new_frame:
  411|  36.8k|{
  412|  36.8k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|  36.8k|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 36.8k, False: 0]
  ------------------
  413|       |
  414|  36.8k|    double frame_time = 0;
  415|  36.8k|    double pts = mpctx->next_frames[0]->pts;
  416|  36.8k|    bool is_sparse = mpctx->vo_chain && mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (416:22): [True: 36.8k, False: 0]
  |  Branch (416:41): [True: 0, False: 36.8k]
  ------------------
  417|       |
  418|  36.8k|    mpctx->next_pts_unrounded = pts;
  419|  36.8k|    if (mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  36.8k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (419:9): [True: 19.6k, False: 17.2k]
  ------------------
  420|  19.6k|        frame_time = pts - mpctx->video_pts;
  421|  19.6k|        double tolerance = mpctx->demuxer->ts_resets_possible &&
  ------------------
  |  Branch (421:28): [True: 0, False: 19.6k]
  ------------------
  422|  19.6k|                           !is_sparse ? 5 : 1e4;
  ------------------
  |  Branch (422:28): [True: 0, False: 0]
  ------------------
  423|  19.6k|        if (frame_time <= 0 || frame_time >= tolerance) {
  ------------------
  |  Branch (423:13): [True: 0, False: 19.6k]
  |  Branch (423:32): [True: 0, False: 19.6k]
  ------------------
  424|       |            // Assume a discontinuity.
  425|      0|            MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n",
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  426|      0|                    mpctx->video_pts, pts);
  427|      0|            frame_time = 0;
  428|  19.6k|        } 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|  19.6k|            double duration = mpctx->past_frames[0].approx_duration;
  437|  19.6k|            double unrounded = mpctx->video_pts_unrounded + duration;
  438|  19.6k|            if (duration > 0 && fabs(pts - unrounded) < MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|  19.6k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (438:17): [True: 19.6k, False: 0]
  |  Branch (438:33): [True: 19.6k, False: 0]
  ------------------
  439|  19.6k|                mpctx->next_pts_unrounded = unrounded + (pts - unrounded) / 64;
  440|  19.6k|            frame_time = mpctx->next_pts_unrounded - mpctx->video_pts_unrounded;
  441|  19.6k|        }
  442|  19.6k|    }
  443|  36.8k|    mpctx->time_frame += frame_time / mpctx->video_speed;
  444|  36.8k|    if (mpctx->ao_chain)
  ------------------
  |  Branch (444:9): [True: 35.4k, False: 1.44k]
  ------------------
  445|  35.4k|        mpctx->delay -= frame_time;
  446|  36.8k|    if (mpctx->video_status >= STATUS_PLAYING)
  ------------------
  |  Branch (446:9): [True: 19.6k, False: 17.2k]
  ------------------
  447|  19.6k|        adjust_sync(mpctx, mpctx->next_pts_unrounded, frame_time);
  448|  36.8k|    MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
  ------------------
  |  |   94|  36.8k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  36.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  449|  36.8k|}
video.c:adjust_sync:
  383|  19.6k|{
  384|  19.6k|    struct MPOpts *opts = mpctx->opts;
  385|       |
  386|  19.6k|    if (mpctx->audio_status != STATUS_PLAYING)
  ------------------
  |  Branch (386:9): [True: 4.24k, False: 15.3k]
  ------------------
  387|  4.24k|        return;
  388|       |
  389|  15.3k|    double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay;
  390|  15.3k|    double av_delay = a_pts - v_pts;
  391|       |
  392|  15.3k|    double change = av_delay * 0.1;
  393|  15.3k|    double factor = fabs(av_delay) < 0.3 ? 0.1 : 0.4;
  ------------------
  |  Branch (393:21): [True: 15.3k, False: 0]
  ------------------
  394|  15.3k|    double max_change = opts->default_max_pts_correction >= 0 ?
  ------------------
  |  Branch (394:25): [True: 0, False: 15.3k]
  ------------------
  395|  15.3k|                        opts->default_max_pts_correction : frame_time * factor;
  396|  15.3k|    if (change < -max_change)
  ------------------
  |  Branch (396:9): [True: 0, False: 15.3k]
  ------------------
  397|      0|        change = -max_change;
  398|  15.3k|    else if (change > max_change)
  ------------------
  |  Branch (398:14): [True: 47, False: 15.3k]
  ------------------
  399|     47|        change = max_change;
  400|  15.3k|    mpctx->delay += change;
  401|  15.3k|    mpctx->total_avsync_change += change;
  402|       |
  403|  15.3k|    if (mpctx->display_sync_active)
  ------------------
  |  Branch (403:9): [True: 0, False: 15.3k]
  ------------------
  404|      0|        mpctx->total_avsync_change = 0;
  405|  15.3k|}

mp_url_unescape_inplace:
  152|  27.5M|{
  153|  1.32G|    for (int len = strlen(url), i = 0, o = 0; i <= len;) {
  ------------------
  |  Branch (153:47): [True: 1.29G, False: 27.5M]
  ------------------
  154|  1.29G|        if ((url[i] != '%') || (i > len - 3)) {  // %NN can't start after len-3
  ------------------
  |  Branch (154:13): [True: 1.29G, False: 873]
  |  Branch (154:32): [True: 62, False: 811]
  ------------------
  155|  1.29G|            url[o++] = url[i++];
  156|  1.29G|            continue;
  157|  1.29G|        }
  158|       |
  159|    811|        int msd = hex2dec(url[i + 1]),
  160|    811|            lsd = hex2dec(url[i + 2]);
  161|       |
  162|    811|        if (msd >= 0 && lsd >= 0) {
  ------------------
  |  Branch (162:13): [True: 102, False: 709]
  |  Branch (162:25): [True: 53, False: 49]
  ------------------
  163|     53|            url[o++] = 16 * msd + lsd;
  164|     53|            i += 3;
  165|    758|        } else {
  166|    758|            url[o++] = url[i++];
  167|    758|            url[o++] = url[i++];
  168|    758|            url[o++] = url[i++];
  169|    758|        }
  170|    811|    }
  171|  27.5M|}
mp_url_unescape:
  174|  3.46k|{
  175|  3.46k|    char *unescaped = talloc_strdup(talloc_ctx, url);
  ------------------
  |  |   50|  3.46k|#define talloc_strdup                   ta_xstrdup
  ------------------
  176|  3.46k|    mp_url_unescape_inplace(unescaped);
  177|  3.46k|    return unescaped;
  178|  3.46k|}
stream_create_with_args:
  444|   155k|{
  445|   155k|    mp_assert(args->url);
  ------------------
  |  |   41|   155k|#define mp_assert assert
  ------------------
  |  Branch (445:5): [True: 155k, False: 0]
  ------------------
  446|       |
  447|   155k|    int r = STREAM_NO_MATCH;
  ------------------
  |  |   65|   155k|#define STREAM_NO_MATCH -2
  ------------------
  448|   155k|    *ret = NULL;
  449|       |
  450|       |    // Open stream proper
  451|   155k|    if (args->sinfo) {
  ------------------
  |  Branch (451:9): [True: 64.1k, False: 91.4k]
  ------------------
  452|  64.1k|        r = stream_create_instance(args->sinfo, args, ret);
  453|  91.4k|    } else {
  454|   748k|        for (int i = 0; i < MP_ARRAY_SIZE(stream_list); i++) {
  ------------------
  |  |   49|   748k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (454:25): [True: 747k, False: 889]
  ------------------
  455|   747k|            r = stream_create_instance(stream_list[i], args, ret);
  456|   747k|            if (r == STREAM_OK)
  ------------------
  |  |   68|   747k|#define STREAM_OK    1
  ------------------
  |  Branch (456:17): [True: 38.7k, False: 708k]
  ------------------
  457|  38.7k|                break;
  458|   708k|            if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   65|  1.41M|#define STREAM_NO_MATCH -2
  ------------------
                          if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
  ------------------
  |  |   66|  81.9k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (458:17): [True: 626k, False: 81.9k]
  |  Branch (458:41): [True: 30.1k, False: 51.8k]
  ------------------
  459|   656k|                continue;
  460|  51.8k|            if (r == STREAM_UNSAFE)
  ------------------
  |  |   64|  51.8k|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (460:17): [True: 14, False: 51.7k]
  ------------------
  461|     14|                continue;
  462|  51.7k|            break;
  463|  51.8k|        }
  464|  91.4k|    }
  465|       |
  466|   155k|    if (!*ret && !(args->flags & STREAM_SILENT) && !mp_cancel_test(args->cancel))
  ------------------
  |  |   44|  52.6k|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (466:9): [True: 52.6k, False: 102k]
  |  Branch (466:18): [True: 52.6k, False: 0]
  |  Branch (466:52): [True: 51.9k, False: 685]
  ------------------
  467|  51.9k|    {
  468|  51.9k|        struct mp_log *log = mp_log_new(NULL, args->global->log, "!stream");
  469|       |
  470|  51.9k|        if (r == STREAM_UNSAFE) {
  ------------------
  |  |   64|  51.9k|#define STREAM_UNSAFE -3
  ------------------
  |  Branch (470:13): [True: 0, False: 51.9k]
  ------------------
  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|  51.9k|        } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   65|   103k|#define STREAM_NO_MATCH -2
  ------------------
                      } else if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED) {
  ------------------
  |  |   66|  51.1k|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (473:20): [True: 885, False: 51.1k]
  |  Branch (473:44): [True: 0, False: 51.1k]
  ------------------
  474|    885|            mp_err(log, "No protocol handler found to open URL %s\n", args->url);
  ------------------
  |  |   76|    885|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  475|    885|            mp_err(log, "The protocol is either unsupported, or was disabled "
  ------------------
  |  |   76|    885|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  476|    885|                        "at compile-time.\n");
  477|  51.1k|        } else {
  478|  51.1k|            mp_err(log, "Failed to open %s.\n", args->url);
  ------------------
  |  |   76|  51.1k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  479|  51.1k|        }
  480|       |
  481|  51.9k|        talloc_free(log);
  ------------------
  |  |   47|  51.9k|#define talloc_free                     ta_free
  ------------------
  482|  51.9k|    }
  483|       |
  484|   155k|    return r;
  485|   155k|}
stream_create:
  489|  91.4k|{
  490|  91.4k|    struct stream_open_args args = {
  491|  91.4k|        .global = global,
  492|  91.4k|        .cancel = c,
  493|  91.4k|        .flags = flags,
  494|  91.4k|        .url = url,
  495|  91.4k|    };
  496|  91.4k|    struct stream *s;
  497|  91.4k|    stream_create_with_args(&args, &s);
  498|  91.4k|    return s;
  499|  91.4k|}
stream_read_partial:
  616|  30.5k|{
  617|  30.5k|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|  30.5k|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 30.5k, False: 0]
  ------------------
  618|  30.5k|    mp_assert(buf_size >= 0);
  ------------------
  |  |   41|  30.5k|#define mp_assert assert
  ------------------
  |  Branch (618:5): [True: 30.5k, False: 0]
  ------------------
  619|  30.5k|    if (s->buf_cur == s->buf_end && buf_size > 0) {
  ------------------
  |  Branch (619:9): [True: 25.4k, False: 5.07k]
  |  Branch (619:37): [True: 25.4k, False: 0]
  ------------------
  620|  25.4k|        if (buf_size > (s->buffer_mask + 1) / 2) {
  ------------------
  |  Branch (620:13): [True: 24, False: 25.4k]
  ------------------
  621|       |            // Direct read if the buffer is too small anyway.
  622|     24|            stream_drop_buffers(s);
  623|     24|            return stream_read_unbuffered(s, buf, buf_size);
  624|     24|        }
  625|  25.4k|        stream_read_more(s, 1);
  626|  25.4k|    }
  627|  30.4k|    int res = ring_copy(s, buf, buf_size, s->buf_cur);
  628|  30.4k|    s->buf_cur += res;
  629|  30.4k|    return res;
  630|  30.5k|}
stream_read_char_fallback:
  634|  5.30k|{
  635|  5.30k|    uint8_t c;
  636|  5.30k|    return stream_read_partial(s, &c, 1) ? c : STREAM_EOF;
  ------------------
  |  |   71|  5.30k|#define STREAM_EOF (-256)
  ------------------
  |  Branch (636:12): [True: 0, False: 5.30k]
  ------------------
  637|  5.30k|}
stream_read:
  640|  5.38k|{
  641|  5.38k|    int len = total;
  642|  10.1k|    while (len > 0) {
  ------------------
  |  Branch (642:12): [True: 10.1k, False: 0]
  ------------------
  643|  10.1k|        int read = stream_read_partial(s, mem, len);
  644|  10.1k|        if (read <= 0)
  ------------------
  |  Branch (644:13): [True: 5.38k, False: 4.75k]
  ------------------
  645|  5.38k|            break; // EOF
  646|  4.75k|        mem = (char *)mem + read;
  647|  4.75k|        len -= read;
  648|  4.75k|    }
  649|  5.38k|    total -= len;
  650|  5.38k|    return total;
  651|  5.38k|}
stream_peek:
  656|   677k|{
  657|   742k|    while (stream_read_more(s, forward_size)) {}
  ------------------
  |  Branch (657:12): [True: 65.0k, False: 677k]
  ------------------
  658|   677k|    return s->buf_end - s->buf_cur;
  659|   677k|}
stream_read_peek:
  664|   677k|{
  665|   677k|    stream_peek(s, buf_size);
  666|   677k|    return ring_copy(s, buf, buf_size, s->buf_cur);
  667|   677k|}
stream_drop_buffers:
  708|     66|{
  709|     66|    s->pos = stream_tell(s);
  710|     66|    s->buf_start = s->buf_cur = s->buf_end = 0;
  711|     66|    s->eof = 0;
  712|     66|    stream_resize_buffer(s, 0, 0);
  713|     66|}
stream_seek:
  754|   679k|{
  755|   679k|    MP_TRACE(s, "seek request from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   94|   679k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   679k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  756|   679k|             stream_tell(s), pos);
  757|       |
  758|   679k|    s->eof = 0; // eof should be set only on read; seeking always clears it
  759|       |
  760|   679k|    if (pos < 0) {
  ------------------
  |  Branch (760:9): [True: 0, False: 679k]
  ------------------
  761|      0|        MP_ERR(s, "Invalid seek to negative position %lld!\n", (long long)pos);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  762|      0|        pos = 0;
  763|      0|    }
  764|       |
  765|   679k|    if (pos <= s->pos) {
  ------------------
  |  Branch (765:9): [True: 679k, False: 21]
  ------------------
  766|   679k|        int64_t x = pos - (s->pos - (int)s->buf_end);
  767|   679k|        if (x >= (int)s->buf_start) {
  ------------------
  |  Branch (767:13): [True: 679k, False: 21]
  ------------------
  768|   679k|            s->buf_cur = x;
  769|   679k|            mp_assert(s->buf_cur >= s->buf_start);
  ------------------
  |  |   41|   679k|#define mp_assert assert
  ------------------
  |  Branch (769:13): [True: 679k, False: 0]
  ------------------
  770|   679k|            mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   679k|#define mp_assert assert
  ------------------
  |  Branch (770:13): [True: 679k, False: 0]
  ------------------
  771|   679k|            return true;
  772|   679k|        }
  773|   679k|    }
  774|       |
  775|     42|    if (s->mode == STREAM_WRITE)
  ------------------
  |  |   42|     42|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (775:9): [True: 0, False: 42]
  ------------------
  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|     42|    if (pos >= s->pos &&
  ------------------
  |  Branch (779:9): [True: 21, False: 21]
  ------------------
  780|     21|        ((!s->seekable && s->fast_skip) ||
  ------------------
  |  Branch (780:11): [True: 0, False: 21]
  |  Branch (780:27): [True: 0, False: 0]
  ------------------
  781|     21|         pos - s->pos <= s->requested_buffer_size))
  ------------------
  |  Branch (781:10): [True: 0, False: 21]
  ------------------
  782|      0|    {
  783|      0|        return stream_skip_read(s, pos - stream_tell(s));
  784|      0|    }
  785|       |
  786|     42|    return stream_seek_unbuffered(s, pos);
  787|     42|}
stream_seek_skip:
  792|   249k|{
  793|   249k|    uint64_t cur_pos = stream_tell(s);
  794|       |
  795|   249k|    if (cur_pos == pos)
  ------------------
  |  Branch (795:9): [True: 136k, False: 113k]
  ------------------
  796|   136k|        return true;
  797|       |
  798|   113k|    return !s->seekable && pos > cur_pos
  ------------------
  |  Branch (798:12): [True: 0, False: 113k]
  |  Branch (798:28): [True: 0, False: 0]
  ------------------
  799|   113k|        ? stream_skip_read(s, pos - cur_pos)
  800|   113k|        : stream_seek(s, pos);
  801|   249k|}
stream_control:
  804|  5.50M|{
  805|  5.50M|    return s->control ? s->control(s, cmd, arg) : STREAM_UNSUPPORTED;
  ------------------
  |  |   66|  5.50M|#define STREAM_UNSUPPORTED -1
  ------------------
  |  Branch (805:12): [True: 0, False: 5.50M]
  ------------------
  806|  5.50M|}
stream_get_size:
  810|  32.5k|{
  811|  32.5k|    return s->get_size ? s->get_size(s) : -1;
  ------------------
  |  Branch (811:12): [True: 16.0k, False: 16.5k]
  ------------------
  812|  32.5k|}
free_stream:
  815|   454k|{
  816|   454k|    if (!s)
  ------------------
  |  Branch (816:9): [True: 351k, False: 102k]
  ------------------
  817|   351k|        return;
  818|       |
  819|   102k|    if (s->close)
  ------------------
  |  Branch (819:9): [True: 4.43k, False: 98.4k]
  ------------------
  820|  4.43k|        s->close(s);
  821|   102k|    talloc_free(s);
  ------------------
  |  |   47|   102k|#define talloc_free                     ta_free
  ------------------
  822|   102k|}
stream_skip_bom:
  828|  63.8k|{
  829|  63.8k|    char buf[4];
  830|  63.8k|    int len = stream_read_peek(s, buf, sizeof(buf));
  831|  63.8k|    bstr data = {buf, len};
  832|   254k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (832:21): [True: 191k, False: 62.9k]
  ------------------
  833|   191k|        if (bstr_startswith0(data, bom[n])) {
  ------------------
  |  Branch (833:13): [True: 894, False: 190k]
  ------------------
  834|    894|            stream_seek_skip(s, stream_tell(s) + strlen(bom[n]));
  835|    894|            return n;
  836|    894|        }
  837|   191k|    }
  838|  62.9k|    return -1; // default to 8 bit codepages
  839|  63.8k|}
stream_read_complete:
  854|  5.38k|{
  855|  5.38k|    if (max_size < 0 || max_size > STREAM_MAX_READ_SIZE)
  ------------------
  |  |   36|  5.38k|#define STREAM_MAX_READ_SIZE (INT_MAX - 1)
  ------------------
  |  Branch (855:9): [True: 0, False: 5.38k]
  |  Branch (855:25): [True: 0, False: 5.38k]
  ------------------
  856|      0|        abort();
  857|  5.38k|    if (s->is_directory)
  ------------------
  |  Branch (857:9): [True: 0, False: 5.38k]
  ------------------
  858|      0|        return (struct bstr){NULL, 0};
  859|       |
  860|  5.38k|    int bufsize;
  861|  5.38k|    int total_read = 0;
  862|  5.38k|    int padding = 1;
  863|  5.38k|    char *buf = NULL;
  864|  5.38k|    int64_t size = stream_get_size(s) - stream_tell(s);
  865|  5.38k|    if (size > max_size && !s->allow_partial_read)
  ------------------
  |  Branch (865:9): [True: 0, False: 5.38k]
  |  Branch (865:28): [True: 0, False: 0]
  ------------------
  866|      0|        return (struct bstr){NULL, 0};
  867|  5.38k|    if (size > 0)
  ------------------
  |  Branch (867:9): [True: 4.75k, False: 631]
  ------------------
  868|  4.75k|        bufsize = size + padding;
  869|    631|    else
  870|    631|        bufsize = 1000;
  871|  5.38k|    if (s->allow_partial_read)
  ------------------
  |  Branch (871:9): [True: 0, False: 5.38k]
  ------------------
  872|      0|        bufsize = MPMIN(bufsize, max_size + padding);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  873|  5.38k|    while (1) {
  ------------------
  |  Branch (873:12): [True: 5.38k, Folded]
  ------------------
  874|  5.38k|        buf = talloc_realloc_size(talloc_ctx, buf, bufsize);
  ------------------
  |  |   39|  5.38k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  5.38k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  5.38k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  5.38k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  5.38k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  875|  5.38k|        int readsize = stream_read(s, buf + total_read, bufsize - total_read);
  876|  5.38k|        total_read += readsize;
  877|  5.38k|        if (total_read >= max_size && s->allow_partial_read) {
  ------------------
  |  Branch (877:13): [True: 0, False: 5.38k]
  |  Branch (877:39): [True: 0, False: 0]
  ------------------
  878|      0|            total_read = max_size;
  879|      0|            break;
  880|      0|        }
  881|  5.38k|        if (total_read < bufsize)
  ------------------
  |  Branch (881:13): [True: 5.38k, False: 0]
  ------------------
  882|  5.38k|            break;
  883|      0|        if (bufsize > max_size) {
  ------------------
  |  Branch (883:13): [True: 0, False: 0]
  ------------------
  884|      0|            talloc_free(buf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  885|      0|            return (struct bstr){NULL, 0};
  886|      0|        }
  887|      0|        bufsize = MPMIN(bufsize + (bufsize >> 1), max_size + padding);
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  888|      0|    }
  889|  5.38k|    buf = talloc_realloc_size(talloc_ctx, buf, total_read + padding);
  ------------------
  |  |   39|  5.38k|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  5.38k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  5.38k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  5.38k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  5.38k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  890|  5.38k|    memset(&buf[total_read], 0, padding);
  891|  5.38k|    return (struct bstr){buf, total_read};
  892|  5.38k|}
stream_read_file2:
  903|  8.03k|{
  904|  8.03k|    struct bstr res = {0};
  905|  8.03k|    stream_t *s = stream_create(filename, flags, NULL, global);
  906|  8.03k|    if (s) {
  ------------------
  |  Branch (906:9): [True: 644, False: 7.38k]
  ------------------
  907|    644|        if (s->is_directory)
  ------------------
  |  Branch (907:13): [True: 0, False: 644]
  ------------------
  908|      0|            mp_err(s->log, "Failed to open %s (not a file).\n", filename);
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  909|    644|        else
  910|    644|            res = stream_read_complete(s, talloc_ctx, max_size);
  911|    644|    }
  912|  8.03k|    free_stream(s);
  913|  8.03k|    return res;
  914|  8.03k|}
stream_get_proto_list:
  917|      3|{
  918|      3|    char **list = NULL;
  919|      3|    int num = 0;
  920|     48|    for (int i = 0; i < MP_ARRAY_SIZE(stream_list); i++) {
  ------------------
  |  |   49|     48|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (920:21): [True: 45, False: 3]
  ------------------
  921|     45|        const stream_info_t *stream_info = stream_list[i];
  922|     45|        if (safe_only && (stream_info->stream_origin & STREAM_ORIGIN_UNSAFE))
  ------------------
  |  |   50|      0|#define STREAM_ORIGIN_UNSAFE      (4 << 2) // from a grotesque source
  ------------------
  |  Branch (922:13): [True: 0, False: 45]
  |  Branch (922:26): [True: 0, False: 0]
  ------------------
  923|      0|            continue;
  924|       |
  925|     45|        char **get_protocols = stream_info->get_protocols ? stream_info->get_protocols() : NULL;
  ------------------
  |  Branch (925:32): [True: 6, False: 39]
  ------------------
  926|     45|        char **protocols = get_protocols ? get_protocols : (char **)stream_info->protocols;
  ------------------
  |  Branch (926:28): [True: 6, False: 39]
  ------------------
  927|       |
  928|    135|        for (int j = 0; protocols && protocols[j]; j++) {
  ------------------
  |  Branch (928:25): [True: 132, False: 3]
  |  Branch (928:38): [True: 90, False: 42]
  ------------------
  929|     90|            if (*protocols[j] == '\0')
  ------------------
  |  Branch (929:17): [True: 3, False: 87]
  ------------------
  930|      3|                continue;
  931|       |
  932|     87|            MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(list, protocols[j]));
  ------------------
  |  |  105|     87|    do {                                            \
  |  |  106|     87|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|     87|    do {                                            \
  |  |  |  |   97|     87|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|     87|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|     87|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|     87|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 12, False: 75]
  |  |  |  |  ------------------
  |  |  |  |   99|     87|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|     12|    do {                                                        \
  |  |  |  |  |  |   89|     12|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|     12|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|     12|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|     12|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|     12|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|     12|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|     12|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 12]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|     87|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|     87|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|     87|        (idxvar)++;                                 \
  |  |  109|     87|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 87]
  |  |  ------------------
  ------------------
  933|     87|        }
  934|       |
  935|     45|        talloc_free(get_protocols);
  ------------------
  |  |   47|     45|#define talloc_free                     ta_free
  ------------------
  936|     45|    }
  937|      3|    MP_TARRAY_APPEND(NULL, list, num, NULL);
  ------------------
  |  |  105|      3|    do {                                            \
  |  |  106|      3|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      3|    do {                                            \
  |  |  |  |   97|      3|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      3|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      3|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      3|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |   99|      3|            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|      3|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      3|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      3|        (idxvar)++;                                 \
  |  |  109|      3|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3]
  |  |  ------------------
  ------------------
  938|      3|    return list;
  939|      3|}
stream.c:hex2dec:
  140|  1.62k|{
  141|  1.62k|    if (c >= '0' && c <= '9')
  ------------------
  |  Branch (141:9): [True: 256, False: 1.36k]
  |  Branch (141:21): [True: 115, False: 141]
  ------------------
  142|    115|        return c - '0';
  143|  1.50k|    if (c >= 'A' && c <= 'F')
  ------------------
  |  Branch (143:9): [True: 141, False: 1.36k]
  |  Branch (143:21): [True: 68, False: 73]
  ------------------
  144|     68|        return 10 + c - 'A';
  145|  1.43k|    if (c >= 'a' && c <= 'f')
  ------------------
  |  Branch (145:9): [True: 73, False: 1.36k]
  |  Branch (145:21): [True: 41, False: 32]
  ------------------
  146|     41|        return 10 + c - 'a';
  147|  1.39k|    return -1;
  148|  1.43k|}
stream.c:stream_create_instance:
  337|   811k|{
  338|   811k|    const char *url = args->url;
  339|   811k|    int flags = args->flags;
  340|       |
  341|   811k|    *ret = NULL;
  342|       |
  343|   811k|    const char *path = url;
  344|       |
  345|   811k|    if (flags & STREAM_LOCAL_FS_ONLY) {
  ------------------
  |  |   54|   811k|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  ------------------
  |  Branch (345:9): [True: 0, False: 811k]
  ------------------
  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|   811k|    } else {
  349|   811k|        char **get_protocols = sinfo->get_protocols ? sinfo->get_protocols() : NULL;
  ------------------
  |  Branch (349:32): [True: 60.3k, False: 751k]
  ------------------
  350|   811k|        char **protocols = get_protocols ? get_protocols : (char **)sinfo->protocols;
  ------------------
  |  Branch (350:28): [True: 60.3k, False: 751k]
  ------------------
  351|       |
  352|  1.91M|        for (int n = 0; protocols && protocols[n]; n++) {
  ------------------
  |  Branch (352:25): [True: 1.88M, False: 30.1k]
  |  Branch (352:38): [True: 1.26M, False: 626k]
  ------------------
  353|  1.26M|            path = match_proto(url, protocols[n]);
  354|  1.26M|            if (path)
  ------------------
  |  Branch (354:17): [True: 154k, False: 1.10M]
  ------------------
  355|   154k|                break;
  356|  1.26M|        }
  357|       |
  358|   811k|        talloc_free(get_protocols);
  ------------------
  |  |   47|   811k|#define talloc_free                     ta_free
  ------------------
  359|       |
  360|   811k|        if (!path)
  ------------------
  |  Branch (360:13): [True: 626k, False: 184k]
  ------------------
  361|   626k|            return STREAM_NO_MATCH;
  ------------------
  |  |   65|   626k|#define STREAM_NO_MATCH -2
  ------------------
  362|   811k|    }
  363|       |
  364|   184k|    stream_t *s = talloc_zero(NULL, stream_t);
  ------------------
  |  |   27|   184k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   184k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   184k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|   184k|    s->global = args->global;
  366|   184k|    struct stream_opts *opts = mp_get_config_group(s, s->global, &stream_conf);
  367|   184k|    if (flags & STREAM_SILENT) {
  ------------------
  |  |   44|   184k|#define STREAM_SILENT             (1 << 1)
  ------------------
  |  Branch (367:9): [True: 64.1k, False: 120k]
  ------------------
  368|  64.1k|        s->log = mp_null_log;
  369|   120k|    } else {
  370|   120k|        s->log = mp_log_new(s, s->global->log, sinfo->name);
  371|   120k|    }
  372|   184k|    s->info = sinfo;
  373|   184k|    s->autoprobed = !args->sinfo;
  374|   184k|    s->cancel = args->cancel;
  375|   184k|    s->url = talloc_strdup(s, url);
  ------------------
  |  |   50|   184k|#define talloc_strdup                   ta_xstrdup
  ------------------
  376|   184k|    s->path = talloc_strdup(s, path);
  ------------------
  |  |   50|   184k|#define talloc_strdup                   ta_xstrdup
  ------------------
  377|   184k|    s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   41|   184k|#define STREAM_READ               0
  ------------------
                  s->mode = flags & (STREAM_READ | STREAM_WRITE);
  ------------------
  |  |   42|   184k|#define STREAM_WRITE              (1 << 0)
  ------------------
  378|   184k|    s->requested_buffer_size = opts->buffer_size;
  379|   184k|    s->allow_partial_read = flags & STREAM_ALLOW_PARTIAL_READ;
  ------------------
  |  |   56|   184k|#define STREAM_ALLOW_PARTIAL_READ (1 << 7) // allows partial read with stream_read_file()
  ------------------
  380|       |
  381|   184k|    if (flags & STREAM_LESS_NOISE)
  ------------------
  |  |   55|   184k|#define STREAM_LESS_NOISE         (1 << 6) // try to log errors only
  ------------------
  |  Branch (381:9): [True: 0, False: 184k]
  ------------------
  382|      0|        mp_msg_set_max_level(s->log, MSGL_WARN);
  383|       |
  384|   184k|    struct demux_opts *demux_opts = mp_get_config_group(s, s->global, &demux_conf);
  385|   184k|    s->access_references = demux_opts->access_references;
  386|   184k|    talloc_free(demux_opts);
  ------------------
  |  |   47|   184k|#define talloc_free                     ta_free
  ------------------
  387|       |
  388|   184k|    MP_VERBOSE(s, "Opening %s\n", url);
  ------------------
  |  |   92|   184k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   184k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  389|       |
  390|   184k|    if (strlen(url) > INT_MAX / 8) {
  ------------------
  |  Branch (390:9): [True: 0, False: 184k]
  ------------------
  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|   184k|    if ((s->mode & STREAM_WRITE) && !sinfo->can_write) {
  ------------------
  |  |   42|   184k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (396:9): [True: 0, False: 184k]
  |  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|   184k|    s->stream_origin = flags & STREAM_ORIGIN_MASK; // pass through by default
  ------------------
  |  |   52|   184k|#define STREAM_ORIGIN_MASK        (7 << 2) // for extracting origin value from flags
  ------------------
  403|   184k|    if (opts->load_unsafe_playlists) {
  ------------------
  |  Branch (403:9): [True: 89, False: 184k]
  ------------------
  404|     89|        s->stream_origin = STREAM_ORIGIN_DIRECT;
  ------------------
  |  |   47|     89|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  405|   184k|    } else if (sinfo->stream_origin) {
  ------------------
  |  Branch (405:16): [True: 102k, False: 82.5k]
  ------------------
  406|   102k|        s->stream_origin = check_origin(s->stream_origin, sinfo->stream_origin);
  407|   102k|    }
  408|       |
  409|   184k|    if (!s->stream_origin) {
  ------------------
  |  Branch (409:9): [True: 14, False: 184k]
  ------------------
  410|     14|        talloc_free(s);
  ------------------
  |  |   47|     14|#define talloc_free                     ta_free
  ------------------
  411|     14|        return STREAM_UNSAFE;
  ------------------
  |  |   64|     14|#define STREAM_UNSAFE -3
  ------------------
  412|     14|    }
  413|       |
  414|   184k|    int r = STREAM_UNSUPPORTED;
  ------------------
  |  |   66|   184k|#define STREAM_UNSUPPORTED -1
  ------------------
  415|   184k|    if (sinfo->open2) {
  ------------------
  |  Branch (415:9): [True: 108k, False: 76.0k]
  ------------------
  416|   108k|        r = sinfo->open2(s, args);
  417|   108k|    } else if (!args->special_arg) {
  ------------------
  |  Branch (417:16): [True: 76.0k, False: 18.4E]
  ------------------
  418|  76.0k|        r = (sinfo->open)(s);
  419|  76.0k|    }
  420|   184k|    if (r != STREAM_OK) {
  ------------------
  |  |   68|   184k|#define STREAM_OK    1
  ------------------
  |  Branch (420:9): [True: 81.9k, False: 102k]
  ------------------
  421|  81.9k|        talloc_free(s);
  ------------------
  |  |   47|  81.9k|#define talloc_free                     ta_free
  ------------------
  422|  81.9k|        return r;
  423|  81.9k|    }
  424|       |
  425|   102k|    if (!stream_resize_buffer(s, 0, 0)) {
  ------------------
  |  Branch (425:9): [True: 0, False: 102k]
  ------------------
  426|      0|        free_stream(s);
  427|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  428|      0|    }
  429|       |
  430|   102k|    mp_assert(s->seekable == !!s->seek);
  ------------------
  |  |   41|   102k|#define mp_assert assert
  ------------------
  |  Branch (430:5): [True: 102k, False: 18.4E]
  ------------------
  431|       |
  432|   102k|    if (s->mime_type)
  ------------------
  |  Branch (432:9): [True: 0, False: 102k]
  ------------------
  433|   102k|        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|   102k|    if (s->server_filename)
  ------------------
  |  Branch (434:9): [True: 0, False: 102k]
  ------------------
  435|   102k|        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|   102k|    MP_DBG(s, "Stream opened successfully.\n");
  ------------------
  |  |   93|   102k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   102k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  438|       |
  439|   102k|    *ret = s;
  440|   102k|    return STREAM_OK;
  ------------------
  |  |   68|   102k|#define STREAM_OK    1
  ------------------
  441|   102k|}
stream.c:match_proto:
  219|  1.26M|{
  220|  1.26M|    int l = strlen(proto);
  221|  1.26M|    if (l > 0) {
  ------------------
  |  Branch (221:9): [True: 1.20M, False: 56.4k]
  ------------------
  222|  1.20M|        if (strncasecmp(url, proto, l) == 0 && strncmp("://", url + l, 3) == 0)
  ------------------
  |  Branch (222:13): [True: 136k, False: 1.06M]
  |  Branch (222:48): [True: 128k, False: 7.54k]
  ------------------
  223|   128k|            return url + l + 3;
  224|  1.20M|    } else if (!mp_is_url(bstr0(url))) {
  ------------------
  |  Branch (224:16): [True: 26.0k, False: 30.3k]
  ------------------
  225|  26.0k|        return url; // pure filenames
  226|  26.0k|    }
  227|  1.10M|    return NULL;
  228|  1.26M|}
stream.c:check_origin:
  234|   102k|{
  235|   102k|    switch (src) {
  ------------------
  |  Branch (235:13): [True: 102k, False: 0]
  ------------------
  236|   101k|    case STREAM_ORIGIN_DIRECT:
  ------------------
  |  |   47|   101k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  |  Branch (236:5): [True: 101k, False: 303]
  ------------------
  237|   101k|    case STREAM_ORIGIN_UNSAFE:
  ------------------
  |  |   50|   101k|#define STREAM_ORIGIN_UNSAFE      (4 << 2) // from a grotesque source
  ------------------
  |  Branch (237:5): [True: 0, False: 102k]
  ------------------
  238|       |        // Allow anything, but constrain it to the new origin.
  239|   101k|        return new;
  240|    303|    case STREAM_ORIGIN_FS:
  ------------------
  |  |   48|    303|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
  |  Branch (240:5): [True: 303, False: 101k]
  ------------------
  241|       |        // From unix FS, allow all but unsafe.
  242|    303|        if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   48|    606|#define STREAM_ORIGIN_FS          (2 << 2) // referenced from playlist on unix FS
  ------------------
                      if (new == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|     14|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (242:13): [True: 289, False: 14]
  |  Branch (242:40): [True: 0, False: 14]
  ------------------
  243|    289|            return new;
  244|     14|        break;
  245|     14|    case STREAM_ORIGIN_NET:
  ------------------
  |  |   49|      0|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (245:5): [True: 0, False: 102k]
  ------------------
  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|   102k|    }
  251|     14|    return 0;
  252|   102k|}
stream.c:stream_read_unbuffered:
  517|   664k|{
  518|   664k|    mp_assert(len >= 0);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (518:5): [True: 664k, False: 0]
  ------------------
  519|   664k|    if (len <= 0)
  ------------------
  |  Branch (519:9): [True: 0, False: 664k]
  ------------------
  520|      0|        return 0;
  521|       |
  522|   664k|    int res = 0;
  523|       |    // we will retry even if we already reached EOF previously.
  524|   664k|    if (s->fill_buffer && !mp_cancel_test(s->cancel))
  ------------------
  |  Branch (524:9): [True: 663k, False: 784]
  |  Branch (524:27): [True: 663k, False: 117]
  ------------------
  525|   663k|        res = s->fill_buffer(s, buf, len);
  526|   664k|    if (res <= 0) {
  ------------------
  |  Branch (526:9): [True: 594k, False: 69.7k]
  ------------------
  527|   594k|        s->eof = 1;
  528|   594k|        return 0;
  529|   594k|    }
  530|  69.7k|    mp_assert(res <= len);
  ------------------
  |  |   41|  69.7k|#define mp_assert assert
  ------------------
  |  Branch (530:5): [True: 69.7k, False: 0]
  ------------------
  531|       |    // When reading succeeded we are obviously not at eof.
  532|  69.7k|    s->eof = 0;
  533|  69.7k|    s->pos += res;
  534|  69.7k|    s->total_unbuffered_read_bytes += res;
  535|  69.7k|    return res;
  536|  69.7k|}
stream.c:stream_read_more:
  543|   768k|{
  544|   768k|    mp_assert(forward >= 0);
  ------------------
  |  |   41|   768k|#define mp_assert assert
  ------------------
  |  Branch (544:5): [True: 768k, False: 0]
  ------------------
  545|       |
  546|   768k|    int forward_avail = s->buf_end - s->buf_cur;
  547|   768k|    if (forward_avail >= forward)
  ------------------
  |  Branch (547:9): [True: 103k, False: 664k]
  ------------------
  548|   103k|        return false;
  549|       |
  550|       |    // Avoid that many small reads will lead to many low-level read calls.
  551|   664k|    forward = MPMAX(forward, s->requested_buffer_size / 2);
  ------------------
  |  |   44|   664k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 14, False: 664k]
  |  |  ------------------
  ------------------
  552|   664k|    mp_assert(forward_avail < forward);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (552:5): [True: 664k, False: 0]
  ------------------
  553|       |
  554|       |    // Keep guaranteed seek-back.
  555|   664k|    int buf_old = MPMIN(s->buf_cur - s->buf_start, s->requested_buffer_size / 2);
  ------------------
  |  |   45|   664k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 664k]
  |  |  ------------------
  ------------------
  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|   664k|    int new_size = MPMAX(buf_old + forward, s->buffer_mask + 1);
  ------------------
  |  |   44|   664k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1, False: 664k]
  |  |  ------------------
  ------------------
  561|       |
  562|   664k|    if (!stream_resize_buffer(s, buf_old + forward_avail, new_size))
  ------------------
  |  Branch (562:9): [True: 0, False: 664k]
  ------------------
  563|      0|        return false;
  564|       |
  565|   664k|    int buf_alloc = s->buffer_mask + 1;
  566|       |
  567|   664k|    mp_assert(s->buf_start <= s->buf_cur);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (567:5): [True: 664k, False: 0]
  ------------------
  568|   664k|    mp_assert(s->buf_cur <= s->buf_end);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (568:5): [True: 664k, False: 0]
  ------------------
  569|   664k|    mp_assert(s->buf_cur < buf_alloc * 2);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (569:5): [True: 664k, False: 0]
  ------------------
  570|   664k|    mp_assert(s->buf_end < buf_alloc * 2);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (570:5): [True: 664k, False: 0]
  ------------------
  571|   664k|    mp_assert(s->buf_start < buf_alloc);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (571:5): [True: 664k, 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|   664k|    int read = buf_alloc - (buf_old + forward_avail); // free buffer past end
  577|       |
  578|   664k|    int pos = s->buf_end & s->buffer_mask;
  579|   664k|    read = MPMIN(read, buf_alloc - pos);
  ------------------
  |  |   45|   664k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 664k]
  |  |  ------------------
  ------------------
  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|   664k|    read = stream_read_unbuffered(s, &s->buffer[pos], read);
  585|       |
  586|   664k|    s->buf_end += read;
  587|       |
  588|       |    // May have overwritten old data.
  589|   664k|    if (s->buf_end - s->buf_start >= buf_alloc) {
  ------------------
  |  Branch (589:9): [True: 0, False: 664k]
  ------------------
  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|   664k|    mp_assert(s->buf_cur - s->buf_start >= buf_old);
  ------------------
  |  |   41|   664k|#define mp_assert assert
  ------------------
  |  Branch (605:5): [True: 664k, False: 0]
  ------------------
  606|       |
  607|   664k|    if (s->buf_cur < s->buf_end)
  ------------------
  |  Branch (607:9): [True: 328k, False: 336k]
  ------------------
  608|   328k|        s->eof = 0;
  609|       |
  610|   664k|    return !!read;
  611|   664k|}
stream.c:ring_copy:
  260|   708k|{
  261|   708k|    mp_assert(len >= 0);
  ------------------
  |  |   41|   708k|#define mp_assert assert
  ------------------
  |  Branch (261:5): [True: 708k, False: 0]
  ------------------
  262|       |
  263|   708k|    if (pos < s->buf_start || pos > s->buf_end)
  ------------------
  |  Branch (263:9): [True: 0, False: 708k]
  |  Branch (263:31): [True: 0, False: 708k]
  ------------------
  264|      0|        return 0;
  265|       |
  266|   708k|    int copied = 0;
  267|   708k|    len = MPMIN(len, s->buf_end - pos);
  ------------------
  |  |   45|   708k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 604k, False: 103k]
  |  |  ------------------
  ------------------
  268|       |
  269|   708k|    if (len && pos <= s->buffer_mask) {
  ------------------
  |  Branch (269:9): [True: 371k, False: 336k]
  |  Branch (269:16): [True: 371k, False: 0]
  ------------------
  270|   371k|        int copy = MPMIN(len, s->buffer_mask + 1 - pos);
  ------------------
  |  |   45|   371k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 371k]
  |  |  ------------------
  ------------------
  271|   371k|        memcpy(dst, &s->buffer[pos], copy);
  272|   371k|        copied += copy;
  273|   371k|        len -= copy;
  274|   371k|        pos += copy;
  275|   371k|    }
  276|       |
  277|   708k|    if (len) {
  ------------------
  |  Branch (277:9): [True: 0, False: 708k]
  ------------------
  278|      0|        memcpy((char *)dst + copied, &s->buffer[pos & s->buffer_mask], len);
  279|      0|        copied += len;
  280|      0|    }
  281|       |
  282|   708k|    return copied;
  283|   708k|}
stream.c:stream_resize_buffer:
  293|   767k|{
  294|   767k|    mp_assert(keep >= s->buf_end - s->buf_cur);
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (294:5): [True: 767k, False: 0]
  ------------------
  295|   767k|    mp_assert(keep <= new);
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (295:5): [True: 767k, False: 0]
  ------------------
  296|       |
  297|   767k|    new = MPMAX(new, s->requested_buffer_size);
  ------------------
  |  |   44|   767k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 3, False: 767k]
  |  |  ------------------
  ------------------
  298|   767k|    new = MPMIN(new, STREAM_MAX_BUFFER_SIZE);
  ------------------
  |  |   45|   767k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 767k]
  |  |  ------------------
  ------------------
  299|   767k|    new = mp_round_next_power_of_2(new);
  300|       |
  301|   767k|    mp_assert(keep <= new); // can't fail (if old buffer size was valid)
  ------------------
  |  |   41|   767k|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 767k, False: 0]
  ------------------
  302|       |
  303|   767k|    if (new == s->buffer_mask + 1)
  ------------------
  |  Branch (303:9): [True: 664k, False: 102k]
  ------------------
  304|   664k|        return true;
  305|       |
  306|   102k|    int old_pos = s->buf_cur - s->buf_start;
  307|   102k|    int old_used_len = s->buf_end - s->buf_start;
  308|   102k|    int skip = old_used_len > new ? old_used_len - new : 0;
  ------------------
  |  Branch (308:16): [True: 0, False: 102k]
  ------------------
  309|       |
  310|   102k|    MP_DBG(s, "resize stream to %d bytes, drop %d bytes\n", new, skip);
  ------------------
  |  |   93|   102k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   102k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  311|       |
  312|   102k|    void *nbuf = ta_alloc_size(s, new);
  ------------------
  |  |  153|   102k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  ------------------
  |  |  |  |   43|   102k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|   102k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   37|   102k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|   102k|    if (!nbuf)
  ------------------
  |  Branch (313:9): [True: 0, False: 102k]
  ------------------
  314|      0|        return false; // oom; tolerate it, caller needs to check if required
  315|       |
  316|   102k|    int new_len = 0;
  317|   102k|    if (s->buffer)
  ------------------
  |  Branch (317:9): [True: 1, False: 102k]
  ------------------
  318|      1|        new_len = ring_copy(s, nbuf, new, s->buf_start + skip);
  319|   102k|    mp_assert(new_len == old_used_len - skip);
  ------------------
  |  |   41|   102k|#define mp_assert assert
  ------------------
  |  Branch (319:5): [True: 102k, False: 0]
  ------------------
  320|   102k|    mp_assert(old_pos >= skip); // "keep" too low
  ------------------
  |  |   41|   102k|#define mp_assert assert
  ------------------
  |  Branch (320:5): [True: 102k, False: 0]
  ------------------
  321|   102k|    mp_assert(old_pos - skip <= new_len);
  ------------------
  |  |   41|   102k|#define mp_assert assert
  ------------------
  |  Branch (321:5): [True: 102k, False: 0]
  ------------------
  322|   102k|    s->buf_start = 0;
  323|   102k|    s->buf_cur = old_pos - skip;
  324|   102k|    s->buf_end = new_len;
  325|       |
  326|   102k|    ta_free(s->buffer);
  327|       |
  328|   102k|    s->buffer = nbuf;
  329|   102k|    s->buffer_mask = new - 1;
  330|       |
  331|       |    return true;
  332|   102k|}
stream.c:stream_seek_unbuffered:
  726|     42|{
  727|     42|    if (newpos != s->pos) {
  ------------------
  |  Branch (727:9): [True: 42, False: 0]
  ------------------
  728|     42|        MP_VERBOSE(s, "stream level seek from %" PRId64 " to %" PRId64 "\n",
  ------------------
  |  |   92|     42|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     42|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  729|     42|                   s->pos, newpos);
  730|       |
  731|     42|        s->total_stream_seeks++;
  732|       |
  733|     42|        if (newpos > s->pos && !s->seekable) {
  ------------------
  |  Branch (733:13): [True: 21, False: 21]
  |  Branch (733:32): [True: 0, False: 21]
  ------------------
  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|     42|        if (newpos < s->pos && !s->seekable) {
  ------------------
  |  Branch (737:13): [True: 21, False: 21]
  |  Branch (737:32): [True: 0, False: 21]
  ------------------
  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|     42|        if (s->seek(s, newpos) <= 0) {
  ------------------
  |  Branch (741:13): [True: 0, False: 42]
  ------------------
  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|     42|        stream_drop_buffers(s);
  748|     42|        s->pos = newpos;
  749|     42|    }
  750|     42|    return true;
  751|     42|}

demux_lavf.c:stream_tell:
  389|  34.7k|{
  390|  34.7k|    return s->pos + s->buf_cur - s->buf_end;
  391|  34.7k|}
demux_playlist.c:stream_read_char:
  380|  37.7k|{
  381|  37.7k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 32.4k, False: 5.30k]
  ------------------
  382|  37.7k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  37.7k|        : stream_read_char_fallback(s);
  384|  37.7k|}
demux_playlist.c:stream_tell:
  389|   308k|{
  390|   308k|    return s->pos + s->buf_cur - s->buf_end;
  391|   308k|}
ebml.c:stream_read_char:
  380|  53.6k|{
  381|  53.6k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 53.6k, False: 0]
  ------------------
  382|  53.6k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  53.6k|        : stream_read_char_fallback(s);
  384|  53.6k|}
stream.c:stream_tell:
  389|   935k|{
  390|   935k|    return s->pos + s->buf_cur - s->buf_end;
  391|   935k|}

stream_aes_ctr.c:open2:
  142|     16|{
  143|     16|    struct priv *p = talloc_zero(stream, struct priv);
  ------------------
  |  |   27|     16|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     16|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     16|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|     16|    talloc_set_destructor(p, priv_destructor);
  ------------------
  |  |   41|     16|#define talloc_set_destructor           ta_set_destructor
  ------------------
  145|     16|    stream->priv = p;
  146|       |
  147|     16|    stream->fill_buffer = fill_buffer;
  148|     16|    stream->get_size = get_size;
  149|     16|    stream->close = s_close;
  150|       |
  151|     16|    int parse_ret = parse_url(stream);
  152|     16|    if (parse_ret != STREAM_OK)
  ------------------
  |  |   68|     16|#define STREAM_OK    1
  ------------------
  |  Branch (152:9): [True: 16, False: 0]
  ------------------
  153|     16|        return parse_ret;
  154|       |
  155|      0|    struct stream_open_args args2 = *args;
  156|      0|    args2.url = stream->path;
  157|      0|    int inner_ret = stream_create_with_args(&args2, &p->inner);
  158|      0|    if (inner_ret != STREAM_OK)
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  |  Branch (158:9): [True: 0, False: 0]
  ------------------
  159|      0|        return inner_ret;
  160|       |
  161|      0|    if (p->inner->is_directory) {
  ------------------
  |  Branch (161:9): [True: 0, False: 0]
  ------------------
  162|      0|        MP_FATAL(stream, "Inner stream '%s' is a directory\n", p->inner->url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  163|      0|        free_stream(p->inner);
  164|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  165|      0|    }
  166|       |
  167|      0|    if (p->inner->seekable) {
  ------------------
  |  Branch (167:9): [True: 0, False: 0]
  ------------------
  168|      0|        stream->seek = seek;
  169|      0|        stream->seekable = true;
  170|      0|    }
  171|      0|    stream->fast_skip = p->inner->fast_skip;
  172|      0|    stream->streaming = p->inner->streaming;
  173|      0|    stream->is_network = p->inner->is_network;
  174|      0|    stream->stream_origin = p->inner->stream_origin;
  175|       |
  176|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  177|      0|}
stream_aes_ctr.c:priv_destructor:
   40|     16|{
   41|     16|    struct priv *p = ptr;
   42|     16|    av_free(p->aes);
   43|     16|}
stream_aes_ctr.c:parse_url:
  106|     16|{
  107|     16|    struct priv *p = stream->priv;
  108|       |
  109|     16|    struct bstr params, inner_url;
  110|     16|    if (!bstr_split_tok(bstr0(stream->path), "@", &params, &inner_url) ||
  ------------------
  |  Branch (110:9): [True: 10, False: 6]
  ------------------
  111|      6|        !inner_url.len)
  ------------------
  |  Branch (111:9): [True: 1, False: 5]
  ------------------
  112|     11|    {
  113|     11|        MP_ERR(stream, "Expected aes-ctr://key:iv@URL: '%s'\n", stream->url);
  ------------------
  |  |   89|     11|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     11|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  114|     11|        return STREAM_ERROR;
  ------------------
  |  |   67|     11|#define STREAM_ERROR 0
  ------------------
  115|     11|    }
  116|       |
  117|      5|    struct bstr key, iv;
  118|      5|    bstr_split_tok(params, ":", &key, &iv);
  119|      5|    if ((key.len != 32 && key.len != 48 && key.len != 64) ||
  ------------------
  |  Branch (119:10): [True: 4, False: 1]
  |  Branch (119:27): [True: 3, False: 1]
  |  Branch (119:44): [True: 3, False: 0]
  ------------------
  120|      2|        !bstr_decode_hex(stream, key, &key))
  ------------------
  |  Branch (120:9): [True: 2, False: 0]
  ------------------
  121|      5|    {
  122|      5|        MP_ERR(stream, "The key must have 32, 48 or 64 hex digits: '%s'\n",
  ------------------
  |  |   89|      5|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  123|      5|               stream->url);
  124|      5|        return STREAM_ERROR;
  ------------------
  |  |   67|      5|#define STREAM_ERROR 0
  ------------------
  125|      5|    }
  126|      0|    if (iv.len != 2 * BLOCKSIZE || !bstr_decode_hex(stream, iv, &iv)) {
  ------------------
  |  |   29|      0|#define BLOCKSIZE 16
  ------------------
  |  Branch (126:9): [True: 0, False: 0]
  |  Branch (126:36): [True: 0, False: 0]
  ------------------
  127|      0|        MP_ERR(stream, "The IV must have 32 hex digits: '%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__)
  |  |  ------------------
  ------------------
  128|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  129|      0|    }
  130|       |
  131|      0|    p->aes = av_aes_alloc();
  132|      0|    if (!p->aes || av_aes_init(p->aes, key.start, key.len * 8, 0) < 0)
  ------------------
  |  Branch (132:9): [True: 0, False: 0]
  |  Branch (132:20): [True: 0, False: 0]
  ------------------
  133|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  134|      0|    memcpy(p->iv, iv.start, BLOCKSIZE);
  ------------------
  |  |   29|      0|#define BLOCKSIZE 16
  ------------------
  135|       |
  136|      0|    stream->path = bstrto0(stream, inner_url);
  137|       |
  138|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  139|      0|}

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

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

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

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

stream_edl.c:s_open:
    7|  1.08k|{
    8|  1.08k|    stream->demuxer = "edl";
    9|       |
   10|  1.08k|    return STREAM_OK;
  ------------------
  |  |   68|  1.08k|#define STREAM_OK    1
  ------------------
   11|  1.08k|}

stream_env.c:open2:
   24|     10|{
   25|     10|    bstr data = bstr0(stream->url);
   26|     10|    bstr_eatstart0(&data, "env://");
   27|       |
   28|     10|    char *name = bstrdup0(stream, data);
   29|     10|    char *val = getenv(name);
   30|     10|    talloc_free(name);
  ------------------
  |  |   47|     10|#define talloc_free                     ta_free
  ------------------
   31|       |
   32|     10|    if (!val) {
  ------------------
  |  Branch (32:9): [True: 10, False: 0]
  ------------------
   33|     10|        MP_FATAL(stream, "Could not read from environment variable '%.*s'\n",
  ------------------
  |  |   88|     10|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     20|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   34|     10|                 BSTR_P(data));
   35|     10|        return STREAM_ERROR;
  ------------------
  |  |   67|     10|#define STREAM_ERROR 0
  ------------------
   36|     10|    }
   37|       |
   38|      0|    data = bstrdup(stream, bstr0(val));
   39|      0|    return stream_bstr_open2(stream, args, data);
   40|     10|}

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

mp_setup_av_network_options:
  158|  43.8k|{
  159|  43.8k|    void *temp = talloc_new(NULL);
  ------------------
  |  |   40|  43.8k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  43.8k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  160|  43.8k|    struct mp_network_opts *opts =
  161|  43.8k|        mp_get_config_group(temp, global, &mp_network_conf);
  162|       |
  163|       |    // HTTP specific options (other protocols ignore them)
  164|  43.8k|    if (opts->useragent)
  ------------------
  |  Branch (164:9): [True: 43.8k, False: 0]
  ------------------
  165|  43.8k|        av_dict_set(dict, "user_agent", opts->useragent, 0);
  166|  43.8k|    if (opts->cookies_enabled) {
  ------------------
  |  Branch (166:9): [True: 0, False: 43.8k]
  ------------------
  167|      0|        char *file = opts->cookies_file;
  168|      0|        if (file && file[0])
  ------------------
  |  Branch (168:13): [True: 0, False: 0]
  |  Branch (168:21): [True: 0, False: 0]
  ------------------
  169|      0|            file = mp_get_user_path(temp, global, file);
  170|      0|        char *cookies = cookies_lavf(temp, global, log, file);
  171|      0|        if (cookies && cookies[0])
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  |  Branch (171:24): [True: 0, False: 0]
  ------------------
  172|      0|            av_dict_set(dict, "cookies", cookies, 0);
  173|      0|    }
  174|  43.8k|    av_dict_set(dict, "tls_verify", opts->tls_verify ? "1" : "0", 0);
  ------------------
  |  Branch (174:37): [True: 43.8k, False: 0]
  ------------------
  175|  43.8k|    if (opts->tls_ca_file) {
  ------------------
  |  Branch (175:9): [True: 0, False: 43.8k]
  ------------------
  176|      0|        char *file = mp_get_user_path(temp, global, opts->tls_ca_file);
  177|      0|        av_dict_set(dict, "ca_file", file, 0);
  178|      0|    }
  179|  43.8k|    if (opts->tls_cert_file) {
  ------------------
  |  Branch (179:9): [True: 0, False: 43.8k]
  ------------------
  180|      0|        char *file = mp_get_user_path(temp, global, opts->tls_cert_file);
  181|      0|        av_dict_set(dict, "cert_file", file, 0);
  182|      0|    }
  183|  43.8k|    if (opts->tls_key_file) {
  ------------------
  |  Branch (183:9): [True: 0, False: 43.8k]
  ------------------
  184|      0|        char *file = mp_get_user_path(temp, global, opts->tls_key_file);
  185|      0|        av_dict_set(dict, "key_file", file, 0);
  186|      0|    }
  187|  43.8k|    char *cust_headers = talloc_strdup(temp, "");
  ------------------
  |  |   50|  43.8k|#define talloc_strdup                   ta_xstrdup
  ------------------
  188|  43.8k|    if (opts->referrer) {
  ------------------
  |  Branch (188:9): [True: 0, False: 43.8k]
  ------------------
  189|      0|        cust_headers = talloc_asprintf_append(cust_headers, "Referer: %s\r\n",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  190|      0|                                              opts->referrer);
  191|      0|    }
  192|  43.8k|    if (opts->http_header_fields) {
  ------------------
  |  Branch (192:9): [True: 0, False: 43.8k]
  ------------------
  193|      0|        for (int n = 0; opts->http_header_fields[n]; n++) {
  ------------------
  |  Branch (193:25): [True: 0, False: 0]
  ------------------
  194|      0|            cust_headers = talloc_asprintf_append(cust_headers, "%s\r\n",
  ------------------
  |  |   63|      0|#define talloc_asprintf_append          ta_talloc_asprintf_append
  ------------------
  195|      0|                                                  opts->http_header_fields[n]);
  196|      0|        }
  197|      0|    }
  198|  43.8k|    if (strlen(cust_headers))
  ------------------
  |  Branch (198:9): [True: 0, False: 43.8k]
  ------------------
  199|      0|        av_dict_set(dict, "headers", cust_headers, 0);
  200|  43.8k|    av_dict_set(dict, "icy", "1", 0);
  201|       |    // So far, every known protocol uses microseconds for this
  202|       |    // Except rtsp.
  203|  43.8k|    if (opts->timeout > 0) {
  ------------------
  |  Branch (203:9): [True: 43.8k, False: 0]
  ------------------
  204|  43.8k|        if (target_fmt && strcmp(target_fmt, "rtsp") == 0) {
  ------------------
  |  Branch (204:13): [True: 14.6k, False: 29.2k]
  |  Branch (204:27): [True: 0, False: 14.6k]
  ------------------
  205|      0|            mp_verbose(log, "Broken FFmpeg RTSP API => not setting timeout.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  206|  43.8k|        } else {
  207|  43.8k|            char buf[80];
  208|  43.8k|            snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
  209|  43.8k|            av_dict_set(dict, "timeout", buf, 0);
  210|  43.8k|        }
  211|  43.8k|    }
  212|  43.8k|    if (opts->http_proxy && opts->http_proxy[0])
  ------------------
  |  Branch (212:9): [True: 0, False: 43.8k]
  |  Branch (212:29): [True: 0, False: 0]
  ------------------
  213|      0|        av_dict_set(dict, "http_proxy", opts->http_proxy, 0);
  214|       |
  215|  43.8k|    struct stream_lavf_opts *lavf_opts =
  216|  43.8k|        mp_get_config_group(temp, global, &stream_lavf_conf);
  217|  43.8k|    mp_set_avdict(dict, lavf_opts->avopts);
  218|       |
  219|  43.8k|    talloc_free(temp);
  ------------------
  |  |   47|  43.8k|#define talloc_free                     ta_free
  ------------------
  220|  43.8k|}
stream_lavf.c:open_f:
  332|  29.2k|{
  333|  29.2k|    AVIOContext *avio = NULL;
  334|  29.2k|    int res = STREAM_ERROR;
  ------------------
  |  |   67|  29.2k|#define STREAM_ERROR 0
  ------------------
  335|  29.2k|    AVDictionary *dict = NULL;
  336|  29.2k|    void *temp = talloc_new(NULL);
  ------------------
  |  |   40|  29.2k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  29.2k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  337|       |
  338|  29.2k|    stream->seek = NULL;
  339|  29.2k|    stream->seekable = false;
  340|       |
  341|  29.2k|    int flags = stream->mode == STREAM_WRITE ? AVIO_FLAG_WRITE : AVIO_FLAG_READ;
  ------------------
  |  |   42|  29.2k|#define STREAM_WRITE              (1 << 0)
  ------------------
  |  Branch (341:17): [True: 0, False: 29.2k]
  ------------------
  342|  29.2k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  343|  29.2k|    if (flags & AVIO_FLAG_WRITE)
  ------------------
  |  Branch (343:9): [True: 0, False: 29.2k]
  ------------------
  344|      0|        goto out;
  345|  29.2k|#endif
  346|       |
  347|  29.2k|    const char *filename = stream->url;
  348|  29.2k|    if (!filename) {
  ------------------
  |  Branch (348:9): [True: 0, False: 29.2k]
  ------------------
  349|      0|        MP_ERR(stream, "No URL\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  350|      0|        goto out;
  351|      0|    }
  352|  87.8k|    for (int i = 0; i < MP_ARRAY_SIZE(prefix); i++)
  ------------------
  |  |   49|  87.8k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (352:21): [True: 58.5k, False: 29.2k]
  ------------------
  353|  58.5k|        if (!strncmp(filename, prefix[i], strlen(prefix[i])))
  ------------------
  |  Branch (353:13): [True: 27, False: 58.5k]
  ------------------
  354|     27|            filename += strlen(prefix[i]);
  355|       |    // URLs that libavformat handles in a demuxer rather than in a protocol.
  356|       |    // The demuxer opens the URL itself, so there is no stream layer and
  357|       |    // demux_lavf does all the real work.
  358|  29.2k|    char *lavf_demuxer = NULL;
  359|  29.2k|    if (!strncmp(filename, "rtsp:", 5) || !strncmp(filename, "rtsps:", 6)) {
  ------------------
  |  Branch (359:9): [True: 0, False: 29.2k]
  |  Branch (359:43): [True: 0, False: 29.2k]
  ------------------
  360|      0|        lavf_demuxer = "rtsp";
  361|  29.2k|    } else if (!strncmp(filename, "rtp:", 4)) {
  ------------------
  |  Branch (361:16): [True: 0, False: 29.2k]
  ------------------
  362|      0|        lavf_demuxer = "rtp";
  363|      0|    }
  364|  29.2k|    if (lavf_demuxer) {
  ------------------
  |  Branch (364:9): [True: 0, False: 29.2k]
  ------------------
  365|      0|        stream->demuxer = "lavf";
  366|      0|        stream->lavf_type = lavf_demuxer;
  367|      0|        stream->streaming = true;
  368|      0|        if (stream->info->stream_origin == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|      0|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (368:13): [True: 0, False: 0]
  ------------------
  369|      0|            stream->is_network = true;
  370|      0|        talloc_free(temp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  371|      0|        return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  372|      0|    }
  373|       |
  374|       |    // Replace "mms://" with "mmsh://", so that most mms:// URLs just work.
  375|       |    // Replace "dav://" or "webdav://" with "http://" and "davs://" or "webdavs://" with "https://"
  376|  29.2k|    bstr b_filename = bstr0(filename);
  377|  29.2k|    if (bstr_eatstart0(&b_filename, "mms://") ||
  ------------------
  |  Branch (377:9): [True: 0, False: 29.2k]
  ------------------
  378|  29.2k|        bstr_eatstart0(&b_filename, "mmshttp://"))
  ------------------
  |  Branch (378:9): [True: 0, False: 29.2k]
  ------------------
  379|      0|    {
  380|      0|        filename = talloc_asprintf(temp, "mmsh://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|  29.2k|    } else if (bstr_eatstart0(&b_filename, "dav://") || bstr_eatstart0(&b_filename, "webdav://"))
  ------------------
  |  Branch (381:16): [True: 0, False: 29.2k]
  |  Branch (381:57): [True: 0, False: 29.2k]
  ------------------
  382|      0|    {
  383|      0|        filename = talloc_asprintf(temp, "http://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|  29.2k|    } else if (bstr_eatstart0(&b_filename, "davs://") || bstr_eatstart0(&b_filename, "webdavs://"))
  ------------------
  |  Branch (384:16): [True: 0, False: 29.2k]
  |  Branch (384:58): [True: 0, False: 29.2k]
  ------------------
  385|      0|    {
  386|      0|        filename = talloc_asprintf(temp, "https://%.*s", BSTR_P(b_filename));
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  387|      0|    }
  388|       |
  389|  29.2k|    av_dict_set(&dict, "reconnect", "1", 0);
  390|  29.2k|    av_dict_set(&dict, "reconnect_delay_max", "7", 0);
  391|       |
  392|  29.2k|    mp_setup_av_network_options(&dict, NULL, stream->global, stream->log);
  393|       |
  394|  29.2k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  395|  29.2k|    av_dict_set(&dict, "protocol_blacklist", "fd,pipe", 0);
  396|  29.2k|#endif
  397|       |
  398|  29.2k|    AVIOInterruptCB cb = {
  399|  29.2k|        .callback = interrupt_cb,
  400|  29.2k|        .opaque = stream,
  401|  29.2k|    };
  402|       |
  403|  29.2k|    filename = normalize_url(stream, filename);
  404|       |
  405|  29.2k|    if (strncmp(filename, "rtmp", 4) == 0) {
  ------------------
  |  Branch (405:9): [True: 0, False: 29.2k]
  ------------------
  406|      0|        stream->demuxer = "lavf";
  407|      0|        stream->lavf_type = "flv";
  408|       |        // Setting timeout enables listen mode - force it to disabled.
  409|      0|        av_dict_set(&dict, "timeout", "0", 0);
  410|      0|    }
  411|       |
  412|  29.2k|    int err = avio_open2(&avio, filename, flags, &cb, &dict);
  413|  29.2k|    if (err < 0) {
  ------------------
  |  Branch (413:9): [True: 24.8k, False: 4.43k]
  ------------------
  414|  24.8k|        if (err == AVERROR_PROTOCOL_NOT_FOUND)
  ------------------
  |  Branch (414:13): [True: 845, False: 23.9k]
  ------------------
  415|  24.8k|            MP_ERR(stream, "Protocol not found. Make sure"
  ------------------
  |  |   89|    845|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    845|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  416|  24.8k|                   " FFmpeg is compiled with networking support.\n");
  417|  24.8k|        goto out;
  418|  24.8k|    }
  419|       |
  420|  4.43k|    mp_avdict_print_unset(stream->log, MSGL_V, dict);
  421|       |
  422|  4.43k|    if (avio->av_class) {
  ------------------
  |  Branch (422:9): [True: 4.43k, False: 0]
  ------------------
  423|  4.43k|        uint8_t *mt = NULL;
  424|  4.43k|        if (av_opt_get(avio, "mime_type", AV_OPT_SEARCH_CHILDREN, &mt) >= 0) {
  ------------------
  |  Branch (424:13): [True: 0, False: 4.43k]
  ------------------
  425|      0|            stream->mime_type = talloc_strdup(stream, mt);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  426|      0|            av_free(mt);
  427|      0|        }
  428|  4.43k|        uint8_t *location = NULL;
  429|  4.43k|        if (av_opt_get(avio, "location", AV_OPT_SEARCH_CHILDREN, &location) >= 0) {
  ------------------
  |  Branch (429:13): [True: 0, False: 4.43k]
  ------------------
  430|      0|            if (*location)
  ------------------
  |  Branch (430:17): [True: 0, False: 0]
  ------------------
  431|      0|                stream->effective_url = talloc_strdup(stream, location);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  432|      0|            av_free(location);
  433|      0|        }
  434|  4.43k|    }
  435|       |
  436|  4.43k|    stream->priv = avio;
  437|  4.43k|    stream->seekable = avio->seekable & AVIO_SEEKABLE_NORMAL;
  438|  4.43k|    stream->seek = stream->seekable ? seek : NULL;
  ------------------
  |  Branch (438:20): [True: 4.43k, False: 0]
  ------------------
  439|  4.43k|    stream->fill_buffer = fill_buffer;
  440|  4.43k|    stream->write_buffer = write_buffer;
  441|  4.43k|    stream->get_size = get_size;
  442|  4.43k|    stream->control = control;
  443|  4.43k|    stream->close = close_f;
  444|       |    // enable cache (should be avoided for files, but no way to detect this)
  445|  4.43k|    stream->streaming = true;
  446|  4.43k|    if (stream->info->stream_origin == STREAM_ORIGIN_NET)
  ------------------
  |  |   49|  4.43k|#define STREAM_ORIGIN_NET         (3 << 2) // referenced from playlist on network
  ------------------
  |  Branch (446:9): [True: 31, False: 4.40k]
  ------------------
  447|     31|        stream->is_network = true;
  448|  4.43k|    res = STREAM_OK;
  ------------------
  |  |   68|  4.43k|#define STREAM_OK    1
  ------------------
  449|       |
  450|  29.2k|out:
  451|  29.2k|    av_dict_free(&dict);
  452|  29.2k|    talloc_free(temp);
  ------------------
  |  |   47|  29.2k|#define talloc_free                     ta_free
  ------------------
  453|  29.2k|    return res;
  454|  4.43k|}
stream_lavf.c:interrupt_cb:
  149|  9.32k|{
  150|  9.32k|    struct stream *stream = ctx;
  151|  9.32k|    return mp_cancel_test(stream->cancel);
  152|  9.32k|}
stream_lavf.c:normalize_url:
  320|  29.2k|{
  321|  29.2k|    bstr proto = mp_split_proto(bstr0(filename), NULL);
  322|   175k|    for (int n = 0; http_like[n]; n++) {
  ------------------
  |  Branch (322:21): [True: 146k, False: 29.2k]
  ------------------
  323|   146k|        if (bstr_equals0(proto, http_like[n]))
  ------------------
  |  Branch (323:13): [True: 0, False: 146k]
  ------------------
  324|       |            // Escape everything but reserved characters.
  325|       |            // Also don't double-scape, so include '%'.
  326|      0|            return mp_url_escape(ta_parent, filename, ":/?#[]@!$&'()*+,;=%");
  327|   146k|    }
  328|  29.2k|    return (char *)filename;
  329|  29.2k|}
stream_lavf.c:fill_buffer:
   58|  9.91k|{
   59|  9.91k|    AVIOContext *avio = s->priv;
   60|  9.91k|    int r = avio_read_partial(avio, buffer, max_len);
   61|  9.91k|    return (r <= 0) ? -1 : r;
  ------------------
  |  Branch (61:12): [True: 9.88k, False: 31]
  ------------------
   62|  9.91k|}
stream_lavf.c:close_f:
   90|  4.43k|{
   91|  4.43k|    AVIOContext *avio = stream->priv;
   92|       |    /* NOTE: As of 2011 write streams must be manually flushed before close.
   93|       |     * Currently write_buffer() always flushes them after writing.
   94|       |     * avio_close() could return an error, but we have no way to return that
   95|       |     * with the current stream API.
   96|       |     */
   97|  4.43k|    if (avio)
  ------------------
  |  Branch (97:9): [True: 4.43k, False: 0]
  ------------------
   98|  4.43k|        avio_close(avio);
   99|  4.43k|}
stream_lavf.c:get_safe_protocols:
  250|  60.3k|{
  251|  60.3k|    int num = 0;
  252|  60.3k|    char **protocols = NULL;
  253|  60.3k|    char **ffmpeg_demuxers = mp_get_lavf_demuxers();
  254|  60.3k|    char **ffmpeg_protos = mp_get_lavf_protocols();
  255|       |
  256|   723k|    for (int i = 0; ffmpeg_protos[i]; i++) {
  ------------------
  |  Branch (256:21): [True: 663k, False: 60.3k]
  ------------------
  257|  12.7M|        for (int j = 0; safe_protos[j]; j++) {
  ------------------
  |  Branch (257:25): [True: 12.1M, False: 603k]
  ------------------
  258|  12.1M|            if (strcmp(ffmpeg_protos[i], safe_protos[j][0]) != 0)
  ------------------
  |  Branch (258:17): [True: 12.0M, False: 60.3k]
  ------------------
  259|  12.0M|                continue;
  260|   120k|            for (int k = 0; safe_protos[j][k]; k++)
  ------------------
  |  Branch (260:29): [True: 60.3k, False: 60.3k]
  ------------------
  261|  60.3k|                MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, safe_protos[j][k]));
  ------------------
  |  |  105|   120k|    do {                                            \
  |  |  106|  60.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.3k|    do {                                            \
  |  |  |  |   97|  60.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 60.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  60.3k|    do {                                                        \
  |  |  |  |  |  |   89|  60.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  60.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  60.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  60.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  60.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  60.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  60.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 60.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.3k|        (idxvar)++;                                 \
  |  |  109|  60.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.3k]
  |  |  ------------------
  ------------------
  262|  60.3k|            break;
  263|  12.1M|        }
  264|   663k|    }
  265|       |
  266|       |    // rtsp is a demuxer not protocol in ffmpeg so it is handled separately
  267|  22.0M|    for (int i = 0; ffmpeg_demuxers[i]; i++) {
  ------------------
  |  Branch (267:21): [True: 22.0M, False: 60.3k]
  ------------------
  268|  22.0M|        if (strcmp("rtsp", ffmpeg_demuxers[i]) == 0) {
  ------------------
  |  Branch (268:13): [True: 0, False: 22.0M]
  ------------------
  269|      0|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "rtsp"));
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  270|      0|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "rtsps"));
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  271|      0|            break;
  272|      0|        }
  273|  22.0M|    }
  274|       |
  275|  60.3k|    MP_TARRAY_APPEND(NULL, protocols, num, NULL);
  ------------------
  |  |  105|  60.3k|    do {                                            \
  |  |  106|  60.3k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  60.3k|    do {                                            \
  |  |  |  |   97|  60.3k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  60.3k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  60.3k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  60.3k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 60.3k]
  |  |  |  |  ------------------
  |  |  |  |   99|  60.3k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  60.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 60.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  60.3k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  60.3k|        (idxvar)++;                                 \
  |  |  109|  60.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 60.3k]
  |  |  ------------------
  ------------------
  276|       |
  277|  60.3k|    talloc_free(ffmpeg_demuxers);
  ------------------
  |  |   47|  60.3k|#define talloc_free                     ta_free
  ------------------
  278|  60.3k|    talloc_free(ffmpeg_protos);
  ------------------
  |  |   47|  60.3k|#define talloc_free                     ta_free
  ------------------
  279|       |
  280|  60.3k|    return protocols;
  281|  60.3k|}
stream_lavf.c:get_unsafe_protocols:
  284|  30.1k|{
  285|  30.1k|    int num = 0;
  286|  30.1k|    char **protocols = NULL;
  287|  30.1k|    char **safe_protocols = get_safe_protocols();
  288|  30.1k|    char **ffmpeg_protos = mp_get_lavf_protocols();
  289|       |
  290|   361k|    for (int i = 0; ffmpeg_protos[i]; i++) {
  ------------------
  |  Branch (290:21): [True: 331k, False: 30.1k]
  ------------------
  291|   331k|        bool safe_protocol = false;
  292|   632k|        for (int j = 0; safe_protocols[j]; j++) {
  ------------------
  |  Branch (292:25): [True: 331k, False: 301k]
  ------------------
  293|   331k|            if (strcmp(ffmpeg_protos[i], safe_protocols[j]) == 0) {
  ------------------
  |  Branch (293:17): [True: 30.1k, False: 301k]
  ------------------
  294|  30.1k|                safe_protocol = true;
  295|  30.1k|                break;
  296|  30.1k|            }
  297|   331k|        }
  298|       |        // Skip to avoid name conflict with builtin mpv protocol.
  299|   331k|        if (strcmp(ffmpeg_protos[i], "bluray") == 0 || strcmp(ffmpeg_protos[i], "dvd") == 0)
  ------------------
  |  Branch (299:13): [True: 0, False: 331k]
  |  Branch (299:56): [True: 0, False: 331k]
  ------------------
  300|      0|            continue;
  301|       |
  302|   331k|        if (!safe_protocol)
  ------------------
  |  Branch (302:13): [True: 301k, False: 30.1k]
  ------------------
  303|   301k|            MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, ffmpeg_protos[i]));
  ------------------
  |  |  105|   301k|    do {                                            \
  |  |  106|   301k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   301k|    do {                                            \
  |  |  |  |   97|   301k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   301k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   301k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   301k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 90.3k, False: 210k]
  |  |  |  |  ------------------
  |  |  |  |   99|   301k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  90.3k|    do {                                                        \
  |  |  |  |  |  |   89|  90.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  90.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  90.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  90.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  90.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  90.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  90.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 90.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   301k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 301k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   301k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   301k|        (idxvar)++;                                 \
  |  |  109|   301k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 301k]
  |  |  ------------------
  ------------------
  304|   331k|    }
  305|       |
  306|  30.1k|    MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "ffmpeg"));
  ------------------
  |  |  105|  30.1k|    do {                                            \
  |  |  106|  30.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  30.1k|    do {                                            \
  |  |  |  |   97|  30.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  30.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  30.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  30.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 30.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  30.1k|            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|  30.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 30.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  30.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  30.1k|        (idxvar)++;                                 \
  |  |  109|  30.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 30.1k]
  |  |  ------------------
  ------------------
  307|  30.1k|    MP_TARRAY_APPEND(NULL, protocols, num, talloc_strdup(protocols, "lavf"));
  ------------------
  |  |  105|  30.1k|    do {                                            \
  |  |  106|  30.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  30.1k|    do {                                            \
  |  |  |  |   97|  30.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  30.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  30.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  30.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 30.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  30.1k|            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|  30.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 30.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  30.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  30.1k|        (idxvar)++;                                 \
  |  |  109|  30.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 30.1k]
  |  |  ------------------
  ------------------
  308|       |
  309|  30.1k|    MP_TARRAY_APPEND(NULL, protocols, num, NULL);
  ------------------
  |  |  105|  30.1k|    do {                                            \
  |  |  106|  30.1k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  30.1k|    do {                                            \
  |  |  |  |   97|  30.1k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  30.1k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  30.1k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  30.1k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 30.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  30.1k|            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|  30.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 30.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  30.1k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  30.1k|        (idxvar)++;                                 \
  |  |  109|  30.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 30.1k]
  |  |  ------------------
  ------------------
  310|       |
  311|  30.1k|    talloc_free(ffmpeg_protos);
  ------------------
  |  |   47|  30.1k|#define talloc_free                     ta_free
  ------------------
  312|  30.1k|    talloc_free(safe_protocols);
  ------------------
  |  |   47|  30.1k|#define talloc_free                     ta_free
  ------------------
  313|  30.1k|    return protocols;
  314|  30.1k|}

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

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

stream_mpv.c:open_mpv:
   24|     23|{
   25|     23|    st->demuxer = "mpv";
   26|     23|    return STREAM_OK;
  ------------------
  |  |   68|     23|#define STREAM_OK    1
  ------------------
   27|     23|}

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

stream_slice.c:open2:
  146|     87|{
  147|     87|    struct priv *p = talloc_zero(stream, struct priv);
  ------------------
  |  |   27|     87|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     87|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     87|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|     87|    stream->priv = p;
  149|       |
  150|     87|    stream->fill_buffer = fill_buffer;
  151|     87|    stream->seek = seek;
  152|     87|    stream->get_size = get_size;
  153|     87|    stream->close = s_close;
  154|       |
  155|     87|    int parse_ret = parse_slice_range(stream);
  156|     87|    if (parse_ret != STREAM_OK) {
  ------------------
  |  |   68|     87|#define STREAM_OK    1
  ------------------
  |  Branch (156:9): [True: 87, False: 0]
  ------------------
  157|     87|        return parse_ret;
  158|     87|    }
  159|       |
  160|      0|    struct stream_open_args args2 = *args;
  161|      0|    args2.url = stream->path;
  162|      0|    int inner_ret = stream_create_with_args(&args2, &p->inner);
  163|      0|    if (inner_ret != STREAM_OK) {
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  |  Branch (163:9): [True: 0, False: 0]
  ------------------
  164|      0|        return inner_ret;
  165|      0|    }
  166|       |
  167|      0|    if (p->inner->is_directory) {
  ------------------
  |  Branch (167:9): [True: 0, False: 0]
  ------------------
  168|      0|        MP_FATAL(stream, "Inner stream '%s' is a directory\n", p->inner->url);
  ------------------
  |  |   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|        free_stream(p->inner);
  170|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  171|      0|    } else if (!p->inner->seekable) {
  ------------------
  |  Branch (171:16): [True: 0, False: 0]
  ------------------
  172|      0|        MP_FATAL(stream, "Non-seekable stream '%s' can't be used with 'slice://'\n", p->inner->url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  173|      0|        free_stream(p->inner);
  174|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  175|      0|    }
  176|       |
  177|      0|    stream->seekable = 1;
  178|      0|    stream->stream_origin = p->inner->stream_origin;
  179|       |
  180|      0|    if (p->slice_start)
  ------------------
  |  Branch (180:9): [True: 0, False: 0]
  ------------------
  181|      0|        seek(stream, 0);
  182|       |
  183|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  184|      0|}
stream_slice.c:parse_slice_range:
   78|     87|{
   79|     87|    struct priv *p = stream->priv;
   80|       |
   81|     87|    struct bstr b_url = bstr0(stream->url);
   82|     87|    struct bstr proto_with_range, inner_url;
   83|       |
   84|     87|    bool has_at = bstr_split_tok(b_url, "@", &proto_with_range, &inner_url);
   85|       |
   86|     87|    if (!has_at) {
  ------------------
  |  Branch (86:9): [True: 26, False: 61]
  ------------------
   87|     26|        MP_ERR(stream, "Expected slice://start[-end]@URL: '%s'\n", stream->url);
  ------------------
  |  |   89|     26|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     26|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
   88|     26|        return STREAM_ERROR;
  ------------------
  |  |   67|     26|#define STREAM_ERROR 0
  ------------------
   89|     26|    }
   90|       |
   91|     61|    if (!inner_url.len) {
  ------------------
  |  Branch (91:9): [True: 1, False: 60]
  ------------------
   92|      1|        MP_ERR(stream, "URL expected to follow 'slice://start[-end]@': '%s'.\n", stream->url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
   93|      1|        return STREAM_ERROR;
  ------------------
  |  |   67|      1|#define STREAM_ERROR 0
  ------------------
   94|      1|    }
   95|     60|    stream->path = bstrto0(stream, inner_url);
   96|       |
   97|     60|    mp_split_proto(proto_with_range, &proto_with_range);
   98|     60|    struct bstr range = proto_with_range;
   99|       |
  100|     60|    struct bstr start, end;
  101|     60|    bool has_end = bstr_split_tok(range, "-", &start, &end);
  102|       |
  103|     60|    if (!start.len) {
  ------------------
  |  Branch (103:9): [True: 17, False: 43]
  ------------------
  104|     17|        MP_ERR(stream, "The byte range must have a start, and it can't be negative: '%s'\n", stream->url);
  ------------------
  |  |   89|     17|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     17|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  105|     17|        return STREAM_ERROR;
  ------------------
  |  |   67|     17|#define STREAM_ERROR 0
  ------------------
  106|     17|    }
  107|       |
  108|     43|    if (has_end && !end.len) {
  ------------------
  |  Branch (108:9): [True: 20, False: 23]
  |  Branch (108:20): [True: 12, False: 8]
  ------------------
  109|     12|        MP_ERR(stream, "The byte range end can be omitted, but it can't be empty: '%s'\n", stream->url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  110|     12|        return STREAM_ERROR;
  ------------------
  |  |   67|     12|#define STREAM_ERROR 0
  ------------------
  111|     12|    }
  112|       |
  113|     31|    const struct m_option opt = {
  114|     31|        .type = &m_option_type_byte_size,
  115|     31|    };
  116|       |
  117|     31|    if (m_option_parse(stream->log, &opt, bstr0("slice_start"), start, &p->slice_start) < 0)
  ------------------
  |  Branch (117:9): [True: 31, False: 0]
  ------------------
  118|     31|        return STREAM_ERROR;
  ------------------
  |  |   67|     31|#define STREAM_ERROR 0
  ------------------
  119|       |
  120|     31|    bool max_end_is_offset = bstr_startswith0(end, "+");
  121|      0|    if (has_end) {
  ------------------
  |  Branch (121:9): [True: 0, False: 0]
  ------------------
  122|      0|        if (m_option_parse(stream->log, &opt, bstr0("slice_max_end"), end, &p->slice_max_end) < 0)
  ------------------
  |  Branch (122:13): [True: 0, False: 0]
  ------------------
  123|      0|            return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  124|      0|    }
  125|       |
  126|      0|    if (max_end_is_offset) {
  ------------------
  |  Branch (126:9): [True: 0, False: 0]
  ------------------
  127|      0|        if (p->slice_max_end > INT64_MAX - p->slice_start) {
  ------------------
  |  Branch (127:13): [True: 0, False: 0]
  ------------------
  128|      0|            MP_ERR(stream, "The byte range end overflows: '%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__)
  |  |  ------------------
  ------------------
  129|      0|            return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  130|      0|        }
  131|      0|        p->slice_max_end += p->slice_start;
  132|      0|    }
  133|       |
  134|      0|    if (p->slice_max_end && p->slice_max_end < p->slice_start) {
  ------------------
  |  Branch (134:9): [True: 0, False: 0]
  |  Branch (134:29): [True: 0, False: 0]
  ------------------
  135|      0|        MP_ERR(stream, "The byte range end (%"PRId64") can't be smaller than the start (%"PRId64"): '%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__)
  |  |  ------------------
  ------------------
  136|      0|                p->slice_max_end,
  137|      0|                p->slice_start,
  138|      0|                stream->url);
  139|      0|        return STREAM_ERROR;
  ------------------
  |  |   67|      0|#define STREAM_ERROR 0
  ------------------
  140|      0|    }
  141|       |
  142|      0|    return STREAM_OK;
  ------------------
  |  |   68|      0|#define STREAM_OK    1
  ------------------
  143|      0|}

mp_ass_set_style:
   41|    752|{
   42|    752|    if (!style)
  ------------------
  |  Branch (42:9): [True: 0, False: 752]
  ------------------
   43|      0|        return;
   44|       |
   45|    752|    if (opts->font) {
  ------------------
  |  Branch (45:9): [True: 752, False: 0]
  ------------------
   46|    752|        if (!style->FontName || strcmp(style->FontName, opts->font) != 0) {
  ------------------
  |  Branch (46:13): [True: 376, False: 376]
  |  Branch (46:33): [True: 349, False: 27]
  ------------------
   47|    725|            free(style->FontName);
   48|    725|            style->FontName = strdup(opts->font);
   49|    725|        }
   50|    752|    }
   51|       |
   52|       |    // libass_font_size = FontSize * (window_height / res_y)
   53|       |    // scale translates parameters from PlayResY=720 to res_y
   54|    752|    double scale = res_y / 720.0;
   55|       |
   56|    752|    style->FontSize = opts->font_size * scale;
   57|    752|    style->PrimaryColour = MP_ASS_COLOR(opts->color);
  ------------------
  |  |   38|    752|#define MP_ASS_COLOR(c) MP_ASS_RGBA((c).r, (c).g, (c).b, (c).a)
  |  |  ------------------
  |  |  |  |   35|    752|    (((unsigned)(r) << 24) | ((g) << 16) | ((b) << 8) | (0xFF - (a)))
  |  |  ------------------
  ------------------
   58|    752|    style->SecondaryColour = style->PrimaryColour;
   59|    752|    style->OutlineColour = MP_ASS_COLOR(opts->outline_color);
  ------------------
  |  |   38|    752|#define MP_ASS_COLOR(c) MP_ASS_RGBA((c).r, (c).g, (c).b, (c).a)
  |  |  ------------------
  |  |  |  |   35|    752|    (((unsigned)(r) << 24) | ((g) << 16) | ((b) << 8) | (0xFF - (a)))
  |  |  ------------------
  ------------------
   60|    752|    style->BackColour = MP_ASS_COLOR(opts->back_color);
  ------------------
  |  |   38|    752|#define MP_ASS_COLOR(c) MP_ASS_RGBA((c).r, (c).g, (c).b, (c).a)
  |  |  ------------------
  |  |  |  |   35|    752|    (((unsigned)(r) << 24) | ((g) << 16) | ((b) << 8) | (0xFF - (a)))
  |  |  ------------------
  ------------------
   61|    752|    style->BorderStyle = opts->border_style;
   62|    752|    style->Outline = opts->outline_size * scale;
   63|    752|    style->Shadow = opts->shadow_offset * scale;
   64|    752|    style->Spacing = opts->spacing * scale;
   65|    752|    style->MarginL = opts->margin_x * scale;
   66|    752|    style->MarginR = style->MarginL;
   67|    752|    style->MarginV = (opts->margin_y + opts->margin_y_offset) * scale;
   68|    752|    style->ScaleX = 1.;
   69|    752|    style->ScaleY = 1.;
   70|    752|    style->Alignment = 1 + (opts->align_x + 1) + (opts->align_y + 2) % 3 * 4;
   71|    752|#ifdef ASS_JUSTIFY_LEFT
   72|    752|    style->Justify = opts->justify;
   73|    752|#endif
   74|    752|    style->Blur = opts->blur;
   75|    752|    style->Bold = opts->bold;
   76|    752|    style->Italic = opts->italic;
   77|    752|}
mp_ass_configure_fonts:
   81|  4.76k|{
   82|  4.76k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  4.76k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  4.76k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
   83|  4.76k|    char *default_font = mp_find_config_file(tmp, global, "subfont.ttf");
   84|  4.76k|    char *config       = mp_find_config_file(tmp, global, "fonts.conf");
   85|       |
   86|  4.76k|    if (default_font && !mp_path_exists(default_font))
  ------------------
  |  Branch (86:9): [True: 0, False: 4.76k]
  |  Branch (86:25): [True: 0, False: 0]
  ------------------
   87|      0|        default_font = NULL;
   88|       |
   89|  4.76k|    int font_provider = ASS_FONTPROVIDER_AUTODETECT;
   90|  4.76k|    if (opts->font_provider == 1)
  ------------------
  |  Branch (90:9): [True: 0, False: 4.76k]
  ------------------
   91|      0|        font_provider = ASS_FONTPROVIDER_NONE;
   92|  4.76k|    if (opts->font_provider == 2)
  ------------------
  |  Branch (92:9): [True: 0, False: 4.76k]
  ------------------
   93|      0|        font_provider = ASS_FONTPROVIDER_FONTCONFIG;
   94|       |
   95|  4.76k|    mp_verbose(log, "Setting up fonts...\n");
  ------------------
  |  |   79|  4.76k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   96|  4.76k|    ass_set_fonts(priv, default_font, opts->font, font_provider, config, 1);
   97|  4.76k|    mp_verbose(log, "Done.\n");
  ------------------
  |  |   79|  4.76k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
   98|       |
   99|  4.76k|    talloc_free(tmp);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  100|  4.76k|}
mp_ass_init:
  127|  4.76k|{
  128|  4.76k|    char *path = opts->fonts_dir && opts->fonts_dir[0] ?
  ------------------
  |  Branch (128:18): [True: 0, False: 4.76k]
  |  Branch (128:37): [True: 0, False: 0]
  ------------------
  129|      0|                 mp_get_user_path(NULL, global, opts->fonts_dir) :
  130|  4.76k|                 mp_find_config_file(NULL, global, "fonts");
  131|  4.76k|    mp_dbg(log, "ASS library version: 0x%x (runtime 0x%x)\n",
  ------------------
  |  |   80|  4.76k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
  132|  4.76k|           (unsigned)LIBASS_VERSION, ass_library_version());
  133|  4.76k|    ASS_Library *priv = ass_library_init();
  134|  4.76k|    if (!priv)
  ------------------
  |  Branch (134:9): [True: 0, False: 4.76k]
  ------------------
  135|      0|        abort();
  136|  4.76k|    ass_set_message_cb(priv, message_callback, log);
  137|  4.76k|    if (path)
  ------------------
  |  Branch (137:9): [True: 0, False: 4.76k]
  ------------------
  138|      0|        ass_set_fonts_dir(priv, path);
  139|  4.76k|    talloc_free(path);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  140|  4.76k|    return priv;
  141|  4.76k|}
ass_mp.c:message_callback:
  115|  51.6k|{
  116|  51.6k|    struct mp_log *log = ctx;
  117|  51.6k|    if (!log)
  ------------------
  |  Branch (117:9): [True: 0, False: 51.6k]
  ------------------
  118|      0|        return;
  119|  51.6k|    level = map_ass_level[level];
  120|  51.6k|    mp_msg_va(log, level, format, va);
  121|       |    // libass messages lack trailing \n
  122|  51.6k|    mp_msg(log, level, "\n");
  123|  51.6k|}

sub_destroy:
  148|  4.76k|{
  149|  4.76k|    if (!sub)
  ------------------
  |  Branch (149:9): [True: 0, False: 4.76k]
  ------------------
  150|      0|        return;
  151|  4.76k|    demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
  152|  4.76k|    if (sub->sd) {
  ------------------
  |  Branch (152:9): [True: 4.76k, False: 0]
  ------------------
  153|  4.76k|        sub_reset(sub);
  154|  4.76k|        sub->sd->driver->uninit(sub->sd);
  155|  4.76k|    }
  156|  4.76k|    talloc_free(sub->sd);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  157|  4.76k|    mp_mutex_destroy(&sub->lock);
  ------------------
  |  |  133|  4.76k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  158|  4.76k|    talloc_free(sub);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  159|  4.76k|}
sub_create:
  197|  4.76k|{
  198|  4.76k|    mp_assert(track->stream && track->stream->type == STREAM_SUB);
  ------------------
  |  |   41|  4.76k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 4.76k, False: 0]
  |  Branch (198:5): [True: 4.76k, False: 0]
  ------------------
  199|       |
  200|  4.76k|    struct dec_sub *sub = talloc(NULL, struct dec_sub);
  ------------------
  |  |   26|  4.76k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  4.76k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|  4.76k|    *sub = (struct dec_sub){
  202|  4.76k|        .log = mp_log_new(sub, global->log, "sub"),
  203|  4.76k|        .global = global,
  204|  4.76k|        .packet_pool = demux_packet_pool_get(global),
  205|  4.76k|        .opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_sub_opts),
  206|  4.76k|        .shared_opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_shared_sub_opts),
  207|  4.76k|        .sh = track->stream,
  208|  4.76k|        .codec = track->stream->codec,
  209|  4.76k|        .lang = track->lang,
  210|  4.76k|        .attachments = talloc_steal(sub, attachments),
  ------------------
  |  |   38|  4.76k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  4.76k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  211|  4.76k|        .play_dir = 1,
  212|  4.76k|        .order = order,
  213|  4.76k|        .last_pkt_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.76k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  214|  4.76k|        .last_vo_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.76k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  215|  4.76k|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.76k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  216|  4.76k|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  4.76k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  217|  4.76k|    };
  218|  4.76k|    sub->opts = sub->opts_cache->opts;
  219|  4.76k|    sub->shared_opts = sub->shared_opts_cache->opts;
  220|  4.76k|    mp_mutex_init(&sub->lock);
  221|       |
  222|  4.76k|    sub->sd = init_decoder(sub);
  223|  4.76k|    if (sub->sd) {
  ------------------
  |  Branch (223:9): [True: 4.76k, False: 0]
  ------------------
  224|  4.76k|        update_subtitle_speed(sub);
  225|  4.76k|        return sub;
  226|  4.76k|    }
  227|       |
  228|      0|    sub_destroy(sub);
  229|       |    return NULL;
  230|  4.76k|}
sub_can_preload:
  262|   669k|{
  263|   669k|    bool r;
  264|   669k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   669k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  265|   669k|    r = sub->sd->driver->accept_packets_in_advance && !sub->preload_attempted;
  ------------------
  |  Branch (265:9): [True: 669k, False: 0]
  |  Branch (265:55): [True: 4.76k, False: 664k]
  ------------------
  266|   669k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   669k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  267|   669k|    return r;
  268|   669k|}
sub_preload:
  271|  4.76k|{
  272|  4.76k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  4.76k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  273|       |
  274|  4.76k|    struct mp_dispatch_queue *demux_waiter = mp_dispatch_create(NULL);
  275|  4.76k|    demux_set_stream_wakeup_cb(sub->sh, wakeup_demux, demux_waiter);
  276|       |
  277|  4.76k|    sub->preload_attempted = true;
  278|       |
  279|  8.59k|    for (;;) {
  280|  8.59k|        struct demux_packet *pkt = NULL;
  281|  8.59k|        int r = demux_read_packet_async(sub->sh, &pkt);
  282|  8.59k|        if (r == 0) {
  ------------------
  |  Branch (282:13): [True: 0, False: 8.59k]
  ------------------
  283|      0|            mp_dispatch_queue_process(demux_waiter, INFINITY);
  284|      0|            continue;
  285|      0|        }
  286|  8.59k|        if (!pkt)
  ------------------
  |  Branch (286:13): [True: 4.76k, False: 3.83k]
  ------------------
  287|  4.76k|            break;
  288|  3.83k|        sub->sd->driver->decode(sub->sd, pkt);
  289|  3.83k|        MP_TARRAY_APPEND(sub, sub->cached_pkts, sub->num_cached_pkts, pkt);
  ------------------
  |  |  105|  3.83k|    do {                                            \
  |  |  106|  3.83k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  3.83k|    do {                                            \
  |  |  |  |   97|  3.83k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  3.83k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.83k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  3.83k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.83k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  3.83k|    do {                                                        \
  |  |  |  |  |  |   89|  3.83k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  3.83k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  3.83k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.83k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.83k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  3.83k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  3.83k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3.83k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  3.83k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  3.83k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  3.83k|        (idxvar)++;                                 \
  |  |  109|  3.83k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.83k]
  |  |  ------------------
  ------------------
  290|  3.83k|    }
  291|       |
  292|  4.76k|    demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
  293|  4.76k|    talloc_free(demux_waiter);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  294|       |
  295|  4.76k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  4.76k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  296|  4.76k|}
sub_read_packets:
  347|   669k|{
  348|   669k|    *packets_read = true;
  349|   669k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   669k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  350|   669k|    video_pts = pts_to_subtitle(sub, video_pts);
  351|   781k|    while (1) {
  ------------------
  |  Branch (351:12): [True: 781k, Folded]
  ------------------
  352|   781k|        bool read_more = true;
  353|   781k|        if (sub->sd->driver->accepts_packet)
  ------------------
  |  Branch (353:13): [True: 0, False: 781k]
  ------------------
  354|      0|            read_more = sub->sd->driver->accepts_packet(sub->sd, video_pts);
  355|       |
  356|   781k|        if (!read_more)
  ------------------
  |  Branch (356:13): [True: 0, False: 781k]
  ------------------
  357|      0|            break;
  358|       |
  359|   781k|        if (sub->new_segment && sub->new_segment->start < video_pts) {
  ------------------
  |  Branch (359:13): [True: 0, False: 781k]
  |  Branch (359:33): [True: 0, False: 0]
  ------------------
  360|      0|            sub->last_vo_pts = video_pts;
  361|      0|            update_segment(sub);
  362|      0|        }
  363|       |
  364|   781k|        if (sub->new_segment)
  ------------------
  |  Branch (364:13): [True: 0, False: 781k]
  ------------------
  365|      0|            break;
  366|       |
  367|       |        // (Use this mechanism only if sub_delay matters to avoid corner cases.)
  368|   781k|        double delay = sub->order < 0 ? 0.0 : sub->shared_opts->sub_delay[sub->order];
  ------------------
  |  Branch (368:24): [True: 0, False: 781k]
  ------------------
  369|   781k|        double min_pts = delay < 0 || force ? video_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  23.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (369:26): [True: 0, False: 781k]
  |  Branch (369:39): [True: 757k, False: 23.1k]
  ------------------
  370|       |
  371|   781k|        struct demux_packet *pkt;
  372|   781k|        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|   781k|        if (st <= 0) {
  ------------------
  |  Branch (378:13): [True: 669k, False: 111k]
  ------------------
  379|   669k|            *packets_read = st < 0 || (sub->last_pkt_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (379:29): [True: 669k, False: 0]
  |  Branch (379:40): [True: 0, False: 0]
  ------------------
  380|      0|                                       sub->last_pkt_pts > video_pts);
  ------------------
  |  Branch (380:40): [True: 0, False: 0]
  ------------------
  381|   669k|            break;
  382|   669k|        }
  383|       |
  384|   111k|        if (sub->recorder_sink)
  ------------------
  |  Branch (384:13): [True: 0, False: 111k]
  ------------------
  385|      0|            mp_recorder_feed_packet(sub->recorder_sink, pkt);
  386|       |
  387|   111k|        sub->last_pkt_pts = pkt->pts;
  388|   111k|        MP_TARRAY_APPEND(sub, sub->cached_pkts, sub->num_cached_pkts, pkt);
  ------------------
  |  |  105|   111k|    do {                                            \
  |  |  106|   111k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   111k|    do {                                            \
  |  |  |  |   97|   111k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   111k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   111k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   111k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 111k]
  |  |  |  |  ------------------
  |  |  |  |   99|   111k|            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|   111k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 111k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   111k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   111k|        (idxvar)++;                                 \
  |  |  109|   111k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 111k]
  |  |  ------------------
  ------------------
  389|       |
  390|   111k|        if (is_new_segment(sub, pkt)) {
  ------------------
  |  Branch (390:13): [True: 0, False: 111k]
  ------------------
  391|      0|            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|      0|            update_segment(sub);
  394|      0|            break;
  395|      0|        }
  396|       |
  397|   111k|        if (!(sub->preload_attempted && sub->sd->preload_ok))
  ------------------
  |  Branch (397:15): [True: 111k, False: 0]
  |  Branch (397:41): [True: 111k, False: 0]
  ------------------
  398|      0|            sub->sd->driver->decode(sub->sd, pkt);
  399|   111k|    }
  400|   669k|    if (sub->cached_pkts && sub->num_cached_pkts) {
  ------------------
  |  Branch (400:9): [True: 468k, False: 200k]
  |  Branch (400:29): [True: 468k, False: 906]
  ------------------
  401|   468k|        bool visible = is_packet_visible(sub->cached_pkts[sub->cached_pkt_pos], video_pts);
  402|   468k|        *sub_updated = update_pkt_cache(sub, video_pts) || sub->sub_visible != visible;
  ------------------
  |  Branch (402:24): [True: 0, False: 468k]
  |  Branch (402:60): [True: 203, False: 467k]
  ------------------
  403|   468k|        sub->sub_visible = visible;
  404|   468k|    }
  405|   669k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   669k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  406|   669k|}
sub_redecode_cached_packets:
  411|      2|{
  412|      2|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|      2|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  413|      2|    int index = sub->cached_pkt_pos;
  414|      4|    while (index < sub->num_cached_pkts) {
  ------------------
  |  Branch (414:12): [True: 2, False: 2]
  ------------------
  415|      2|        sub->sd->driver->decode(sub->sd, sub->cached_pkts[index]);
  416|      2|        ++index;
  417|      2|    }
  418|      2|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|      2|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  419|      2|}
sub_get_bitmaps:
  424|  5.48k|{
  425|  5.48k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  5.48k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  426|       |
  427|  5.48k|    pts = pts_to_subtitle(sub, pts);
  428|       |
  429|  5.48k|    sub->last_vo_pts = pts;
  430|  5.48k|    update_segment(sub);
  431|       |
  432|  5.48k|    struct sub_bitmaps *res = NULL;
  433|       |
  434|  5.48k|    if (!(sub->end != MP_NOPTS_VALUE && pts >= sub->end) &&
  ------------------
  |  |   39|  10.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (434:11): [True: 0, False: 5.48k]
  |  Branch (434:41): [True: 0, False: 0]
  ------------------
  435|  5.48k|        sub->sd->driver->get_bitmaps)
  ------------------
  |  Branch (435:9): [True: 5.48k, False: 0]
  ------------------
  436|  5.48k|        res = sub->sd->driver->get_bitmaps(sub->sd, dim, format, pts);
  437|       |
  438|  5.48k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  5.48k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  439|  5.48k|    return res;
  440|  5.48k|}
sub_get_text:
  444|  25.4k|{
  445|  25.4k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  25.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  446|  25.4k|    char *text = NULL;
  447|       |
  448|  25.4k|    pts = pts_to_subtitle(sub, pts);
  449|       |
  450|  25.4k|    sub->last_vo_pts = pts;
  451|  25.4k|    update_segment(sub);
  452|       |
  453|  25.4k|    if (sub->sd->driver->get_text)
  ------------------
  |  Branch (453:9): [True: 25.4k, False: 0]
  ------------------
  454|  25.4k|        text = sub->sd->driver->get_text(sub->sd, pts, type);
  455|  25.4k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  25.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  456|  25.4k|    return text;
  457|  25.4k|}
sub_get_times:
  474|    122|{
  475|    122|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|    122|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  476|    122|    struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    122|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    122|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  477|       |
  478|    122|    pts = pts_to_subtitle(sub, pts);
  479|       |
  480|    122|    sub->last_vo_pts = pts;
  481|    122|    update_segment(sub);
  482|       |
  483|    122|    if (sub->sd->driver->get_times)
  ------------------
  |  Branch (483:9): [True: 122, False: 0]
  ------------------
  484|    122|        res = sub->sd->driver->get_times(sub->sd, pts);
  485|       |
  486|    122|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|    122|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  487|    122|    return res;
  488|    122|}
sub_reset:
  491|   171k|{
  492|   171k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   171k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  493|   171k|    if (sub->sd->driver->reset)
  ------------------
  |  Branch (493:9): [True: 171k, False: 0]
  ------------------
  494|   171k|        sub->sd->driver->reset(sub->sd);
  495|   171k|    sub->last_pkt_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   171k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  496|   171k|    sub->last_vo_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   171k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  497|   171k|    destroy_cached_pkts(sub);
  498|   171k|    demux_packet_pool_push(sub->packet_pool, sub->new_segment);
  499|   171k|    sub->new_segment = NULL;
  500|   171k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   171k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  501|   171k|}
sub_select:
  504|  9.53k|{
  505|  9.53k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  9.53k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  506|  9.53k|    if (sub->sd->driver->select)
  ------------------
  |  Branch (506:9): [True: 9.53k, False: 0]
  ------------------
  507|  9.53k|        sub->sd->driver->select(sub->sd, selected);
  508|  9.53k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  9.53k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  509|  9.53k|}
sub_control:
  512|  1.30M|{
  513|  1.30M|    int r = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  1.30M|#define CONTROL_UNKNOWN -1
  ------------------
  514|  1.30M|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  1.30M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  515|  1.30M|    bool propagate = false;
  516|  1.30M|    switch (cmd) {
  517|  4.76k|    case SD_CTRL_SET_VIDEO_DEF_FPS:
  ------------------
  |  Branch (517:5): [True: 4.76k, False: 1.29M]
  ------------------
  518|  4.76k|        sub->video_fps = *(double *)arg;
  519|  4.76k|        update_subtitle_speed(sub);
  520|  4.76k|        break;
  521|     27|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (521:5): [True: 27, False: 1.30M]
  ------------------
  522|     27|        double *a = arg;
  523|     27|        double arg2[2] = {a[0], a[1]};
  524|     27|        arg2[0] = pts_to_subtitle(sub, arg2[0]);
  525|     27|        if (sub->sd->driver->control)
  ------------------
  |  Branch (525:13): [True: 27, False: 0]
  ------------------
  526|     27|            r = sub->sd->driver->control(sub->sd, cmd, arg2);
  527|     27|        if (r == CONTROL_OK)
  ------------------
  |  |   95|     27|#define CONTROL_OK 1
  ------------------
  |  Branch (527:13): [True: 10, False: 17]
  ------------------
  528|     10|            a[0] = pts_from_subtitle(sub, arg2[0]);
  529|     27|        break;
  530|      0|    }
  531|    264|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (531:5): [True: 264, False: 1.30M]
  ------------------
  532|    264|        uint64_t flags = *(uint64_t *)arg;
  533|    264|        if (m_config_cache_update(sub->opts_cache))
  ------------------
  |  Branch (533:13): [True: 30, False: 234]
  ------------------
  534|     30|            update_subtitle_speed(sub);
  535|    264|        m_config_cache_update(sub->shared_opts_cache);
  536|    264|        propagate = true;
  537|    264|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|    264|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (537:13): [True: 0, False: 264]
  ------------------
  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|    264|        break;
  544|      0|    }
  545|  1.29M|    default:
  ------------------
  |  Branch (545:5): [True: 1.29M, False: 5.05k]
  ------------------
  546|  1.29M|        propagate = true;
  547|  1.30M|    }
  548|  1.30M|    if (propagate && sub->sd->driver->control)
  ------------------
  |  Branch (548:9): [True: 1.29M, False: 4.79k]
  |  Branch (548:22): [True: 1.29M, False: 0]
  ------------------
  549|  1.29M|        r = sub->sd->driver->control(sub->sd, cmd, arg);
  550|  1.30M|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  1.30M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  551|  1.30M|    return r;
  552|  1.30M|}
sub_set_play_dir:
  562|   328k|{
  563|   328k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   328k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  564|   328k|    sub->play_dir = dir;
  565|   328k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   328k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  566|   328k|}
sub_is_primary_visible:
  569|  5.48k|{
  570|  5.48k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  5.48k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  571|  5.48k|    bool ret = sub->shared_opts->sub_visibility[0];
  572|  5.48k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  5.48k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  573|  5.48k|    return ret;
  574|  5.48k|}
dec_sub.c:init_decoder:
  162|  4.76k|{
  163|  9.53k|    for (int n = 0; sd_list[n]; n++) {
  ------------------
  |  Branch (163:21): [True: 9.53k, False: 0]
  ------------------
  164|  9.53k|        const struct sd_functions *driver = sd_list[n];
  165|  9.53k|        struct sd *sd = talloc(NULL, struct sd);
  ------------------
  |  |   26|  9.53k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  9.53k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  9.53k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|  9.53k|        *sd = (struct sd){
  167|  9.53k|            .global = sub->global,
  168|  9.53k|            .log = mp_log_new(sd, sub->log, driver->name),
  169|  9.53k|            .opts = sub->opts,
  170|  9.53k|            .shared_opts = sub->shared_opts,
  171|  9.53k|            .driver = driver,
  172|  9.53k|            .order = sub->order,
  173|  9.53k|            .attachments = sub->attachments,
  174|  9.53k|            .codec = sub->codec,
  175|  9.53k|            .lang = sub->lang,
  176|  9.53k|            .preload_ok = true,
  177|  9.53k|        };
  178|       |
  179|  9.53k|        if (sd->driver->init(sd) >= 0)
  ------------------
  |  Branch (179:13): [True: 4.76k, False: 4.76k]
  ------------------
  180|  4.76k|            return sd;
  181|       |
  182|  4.76k|        talloc_free(sd);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
  183|  4.76k|    }
  184|       |
  185|      0|    MP_ERR(sub, "Could not find subtitle decoder 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__)
  |  |  ------------------
  ------------------
  186|      0|           sub->codec->codec);
  187|       |    return NULL;
  188|  4.76k|}
dec_sub.c:update_subtitle_speed:
   90|  9.56k|{
   91|  9.56k|    struct mp_subtitle_opts *opts = sub->opts;
   92|  9.56k|    sub->sub_speed = 1.0;
   93|       |
   94|  9.56k|    if (sub->video_fps > 0 && sub->codec->frame_based > 0) {
  ------------------
  |  Branch (94:9): [True: 4.79k, False: 4.76k]
  |  Branch (94:31): [True: 0, False: 4.79k]
  ------------------
   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|  9.56k|    if (opts->sub_fps && sub->video_fps)
  ------------------
  |  Branch (100:9): [True: 0, False: 9.56k]
  |  Branch (100:26): [True: 0, False: 0]
  ------------------
  101|      0|        sub->sub_speed *= opts->sub_fps / sub->video_fps;
  102|       |
  103|  9.56k|    sub->sub_speed *= opts->sub_speed;
  104|  9.56k|}
dec_sub.c:wakeup_demux:
  130|  8.59k|{
  131|  8.59k|    struct mp_dispatch_queue *q = ctx;
  132|  8.59k|    mp_dispatch_interrupt(q);
  133|  8.59k|}
dec_sub.c:pts_to_subtitle:
  108|   700k|{
  109|   700k|    struct mp_subtitle_shared_opts *opts = sub->shared_opts;
  110|   700k|    double delay = sub->order < 0 ? 0.0 : opts->sub_delay[sub->order];
  ------------------
  |  Branch (110:20): [True: 0, False: 700k]
  ------------------
  111|       |
  112|   700k|    if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   700k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (112:9): [True: 17.1k, False: 683k]
  ------------------
  113|  17.1k|        pts = (pts * sub->play_dir - delay) / sub->sub_speed;
  114|       |
  115|   700k|    return pts;
  116|   700k|}
dec_sub.c:update_segment:
  234|  31.0k|{
  235|  31.0k|    if (sub->new_segment && sub->last_vo_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  31.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (235:9): [True: 0, False: 31.0k]
  |  Branch (235:29): [True: 0, False: 0]
  ------------------
  236|      0|        sub->last_vo_pts >= sub->new_segment->start)
  ------------------
  |  Branch (236:9): [True: 0, False: 0]
  ------------------
  237|      0|    {
  238|      0|        MP_VERBOSE(sub, "Switch segment: %f at %f\n", sub->new_segment->start,
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  239|      0|                   sub->last_vo_pts);
  240|       |
  241|      0|        sub->codec = sub->new_segment->codec;
  242|      0|        sub->start = sub->new_segment->start;
  243|      0|        sub->end = sub->new_segment->end;
  244|      0|        struct sd *new = init_decoder(sub);
  245|      0|        if (new) {
  ------------------
  |  Branch (245:13): [True: 0, False: 0]
  ------------------
  246|      0|            sub->sd->driver->uninit(sub->sd);
  247|      0|            talloc_free(sub->sd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  248|      0|            sub->sd = new;
  249|      0|            update_subtitle_speed(sub);
  250|      0|        } 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|      0|        sub->sd->driver->decode(sub->sd, sub->new_segment);
  256|      0|        talloc_free(sub->new_segment);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  257|       |        sub->new_segment = NULL;
  258|      0|    }
  259|  31.0k|}
dec_sub.c:is_new_segment:
  299|   111k|{
  300|   111k|    return p->segmented &&
  ------------------
  |  Branch (300:12): [True: 0, False: 111k]
  ------------------
  301|      0|        (p->start != sub->start || p->end != sub->end || p->codec != sub->codec);
  ------------------
  |  Branch (301:10): [True: 0, False: 0]
  |  Branch (301:36): [True: 0, False: 0]
  |  Branch (301:58): [True: 0, False: 0]
  ------------------
  302|   111k|}
dec_sub.c:is_packet_visible:
  305|   468k|{
  306|   468k|    return p && p->pts <= video_pts && (video_pts <= p->pts + p->sub_duration ||
  ------------------
  |  Branch (306:12): [True: 468k, False: 0]
  |  Branch (306:17): [True: 2.15k, False: 465k]
  |  Branch (306:41): [True: 0, False: 2.15k]
  ------------------
  307|  2.15k|           p->sub_duration < 0);
  ------------------
  |  Branch (307:12): [True: 2.04k, False: 104]
  ------------------
  308|   468k|}
dec_sub.c:update_pkt_cache:
  311|   468k|{
  312|   468k|    if (!sub->cached_pkts[sub->cached_pkt_pos])
  ------------------
  |  Branch (312:9): [True: 0, False: 468k]
  ------------------
  313|      0|        return false;
  314|       |
  315|   468k|    struct demux_packet *pkt = sub->cached_pkts[sub->cached_pkt_pos];
  316|   468k|    struct demux_packet *next_pkt = sub->cached_pkt_pos + 1 < sub->num_cached_pkts ?
  ------------------
  |  Branch (316:37): [True: 0, False: 468k]
  ------------------
  317|   468k|                                    sub->cached_pkts[sub->cached_pkt_pos + 1] : NULL;
  318|   468k|    if (!pkt)
  ------------------
  |  Branch (318:9): [True: 0, False: 468k]
  ------------------
  319|      0|        return false;
  320|       |
  321|   468k|    double pts = video_pts + sub->shared_opts->sub_delay[sub->order];
  322|   468k|    double next_pts = next_pkt ? next_pkt->pts : INT_MAX;
  ------------------
  |  Branch (322:23): [True: 0, False: 468k]
  ------------------
  323|   468k|    double end_pts = pkt->sub_duration >= 0 ? pkt->pts + pkt->sub_duration : INT_MAX;
  ------------------
  |  Branch (323:22): [True: 441k, False: 26.9k]
  ------------------
  324|       |
  325|   468k|    if (next_pts < pts || end_pts < pts) {
  ------------------
  |  Branch (325:9): [True: 0, False: 468k]
  |  Branch (325:27): [True: 104, False: 467k]
  ------------------
  326|    104|        if (sub->cached_pkt_pos + 1 < sub->num_cached_pkts) {
  ------------------
  |  Branch (326:13): [True: 0, False: 104]
  ------------------
  327|      0|            TA_FREEP(&sub->cached_pkts[sub->cached_pkt_pos]);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  328|      0|            pkt = NULL;
  329|      0|            sub->cached_pkt_pos++;
  330|      0|        }
  331|    104|        if (next_pts < pts)
  ------------------
  |  Branch (331:13): [True: 0, False: 104]
  ------------------
  332|      0|            return true;
  333|    104|    }
  334|       |
  335|   468k|    if (pkt && pkt->animated == 1)
  ------------------
  |  Branch (335:9): [True: 468k, False: 0]
  |  Branch (335:16): [True: 0, False: 468k]
  ------------------
  336|      0|        return true;
  337|       |
  338|   468k|    return false;
  339|   468k|}
dec_sub.c:destroy_cached_pkts:
  136|   171k|{
  137|   171k|    int index = 0;
  138|   286k|    while (index < sub->num_cached_pkts) {
  ------------------
  |  Branch (138:12): [True: 115k, False: 171k]
  ------------------
  139|   115k|        demux_packet_pool_push(sub->packet_pool, sub->cached_pkts[index]);
  140|       |        sub->cached_pkts[index] = NULL;
  141|   115k|        ++index;
  142|   115k|    }
  143|   171k|    sub->cached_pkt_pos = 0;
  144|   171k|    sub->num_cached_pkts = 0;
  145|   171k|}
dec_sub.c:pts_from_subtitle:
  119|     10|{
  120|     10|    struct mp_subtitle_shared_opts *opts = sub->shared_opts;
  121|     10|    double delay = sub->order < 0 ? 0.0 : opts->sub_delay[sub->order];
  ------------------
  |  Branch (121:20): [True: 0, False: 10]
  ------------------
  122|       |
  123|     10|    if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|     10|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (123:9): [True: 10, False: 0]
  ------------------
  124|     10|        pts = (pts * sub->sub_speed + delay) * sub->play_dir;
  125|       |
  126|     10|    return pts;
  127|     10|}

filter_regex.c:rf_init:
   17|  4.76k|{
   18|  4.76k|    if (strcmp(ft->codec, "ass") != 0)
  ------------------
  |  Branch (18:9): [True: 0, False: 4.76k]
  ------------------
   19|      0|        return false;
   20|       |
   21|  4.76k|    if (!ft->opts->rf_enable)
  ------------------
  |  Branch (21:9): [True: 1, False: 4.76k]
  ------------------
   22|      1|        return false;
   23|       |
   24|  4.76k|    struct priv *p = talloc_zero(ft, struct priv);
  ------------------
  |  |   27|  4.76k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.76k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   25|  4.76k|    ft->priv = p;
   26|       |
   27|  4.76k|    for (int n = 0; ft->opts->rf_items && ft->opts->rf_items[n]; n++) {
  ------------------
  |  Branch (27:21): [True: 0, False: 4.76k]
  |  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|  4.76k|    if (!p->num_regexes)
  ------------------
  |  Branch (44:9): [True: 4.76k, False: 0]
  ------------------
   45|  4.76k|        return false;
   46|       |
   47|      0|    p->offset = sd_ass_fmt_offset(ft->event_format);
   48|       |    return true;
   49|  4.76k|}

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

osd_res_equals:
  152|  74.2k|{
  153|  74.2k|    return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt
  ------------------
  |  Branch (153:12): [True: 70.5k, False: 3.67k]
  |  Branch (153:26): [True: 70.5k, False: 0]
  |  Branch (153:40): [True: 70.5k, False: 0]
  |  Branch (153:56): [True: 70.5k, False: 0]
  ------------------
  154|  70.5k|        && a.mr == b.mr && a.mb == b.mb
  ------------------
  |  Branch (154:12): [True: 70.5k, False: 0]
  |  Branch (154:28): [True: 70.5k, False: 0]
  ------------------
  155|  70.5k|        && a.display_par == b.display_par;
  ------------------
  |  Branch (155:12): [True: 70.5k, False: 0]
  ------------------
  156|  74.2k|}
osd_create:
  159|  11.6k|{
  160|  11.6k|    static_assert(MAX_OSD_PARTS >= OSDTYPE_COUNT, "");
  161|       |
  162|  11.6k|    struct osd_state *osd = talloc_zero(NULL, struct osd_state);
  ------------------
  |  |   27|  11.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  11.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  11.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|  11.6k|    *osd = (struct osd_state) {
  164|  11.6k|        .opts_cache = m_config_cache_alloc(osd, global, &mp_osd_render_sub_opts),
  165|  11.6k|        .global = global,
  166|  11.6k|        .log = mp_log_new(osd, global->log, "osd"),
  167|  11.6k|        .force_video_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  11.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  11.6k|        .stats = stats_ctx_create(osd, global, "osd"),
  169|  11.6k|    };
  170|  11.6k|    mp_mutex_init(&osd->lock);
  171|  11.6k|    osd->opts = osd->opts_cache->opts;
  172|       |
  173|  81.7k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|  81.7k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (173:21): [True: 70.0k, False: 11.6k]
  ------------------
  174|  70.0k|        struct osd_object *obj = talloc(osd, struct osd_object);
  ------------------
  |  |   26|  70.0k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  70.0k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  70.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|  70.0k|        *obj = (struct osd_object) {
  176|  70.0k|            .type = n,
  177|  70.0k|            .text = talloc_strdup(obj, ""),
  ------------------
  |  |   50|  70.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  178|  70.0k|            .progbar_state = {.type = -1},
  179|  70.0k|            .vo_change_id = 1,
  180|  70.0k|        };
  181|  70.0k|        osd->objs[n] = obj;
  182|  70.0k|    }
  183|       |
  184|  11.6k|    osd->objs[OSDTYPE_SUB]->is_sub = true;
  185|  11.6k|    osd->objs[OSDTYPE_SUB2]->is_sub = true;
  186|       |
  187|  11.6k|    return osd;
  188|  11.6k|}
osd_free:
  191|  11.6k|{
  192|  11.6k|    if (!osd)
  ------------------
  |  Branch (192:9): [True: 0, False: 11.6k]
  ------------------
  193|      0|        return;
  194|  11.6k|    osd_destroy_backend(osd);
  195|  11.6k|    talloc_free(osd->objs[OSDTYPE_EXTERNAL2]->image_overlay);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  196|  11.6k|    talloc_free(osd->objs[OSDTYPE_DISC_MENU]->image_overlay);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  197|  11.6k|    mp_mutex_destroy(&osd->lock);
  ------------------
  |  |  133|  11.6k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  198|  11.6k|    talloc_free(osd);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  199|  11.6k|}
osd_set_text:
  202|  2.98M|{
  203|  2.98M|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  2.98M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  204|  2.98M|    struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
  205|  2.98M|    if (!text)
  ------------------
  |  Branch (205:9): [True: 112k, False: 2.86M]
  ------------------
  206|   112k|        text = "";
  207|  2.98M|    if (strcmp(osd_obj->text, text) != 0) {
  ------------------
  |  Branch (207:9): [True: 133k, False: 2.84M]
  ------------------
  208|   133k|        talloc_free(osd_obj->text);
  ------------------
  |  |   47|   133k|#define talloc_free                     ta_free
  ------------------
  209|   133k|        osd_obj->text = talloc_strdup(osd_obj, text);
  ------------------
  |  |   50|   133k|#define talloc_strdup                   ta_xstrdup
  ------------------
  210|   133k|        osd_obj->osd_changed = true;
  211|   133k|        osd->want_redraw_notification = true;
  212|   133k|    }
  213|  2.98M|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  2.98M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  214|  2.98M|}
osd_set_sub:
  217|  9.53k|{
  218|  9.53k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  9.53k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  219|  9.53k|    if (index >= 0 && index < 2) {
  ------------------
  |  Branch (219:9): [True: 9.53k, False: 0]
  |  Branch (219:23): [True: 9.53k, False: 0]
  ------------------
  220|  9.53k|        struct osd_object *obj = osd->objs[OSDTYPE_SUB + index];
  221|  9.53k|        obj->sub = dec_sub;
  222|  9.53k|        obj->vo_change_id += 1;
  223|  9.53k|    }
  224|  9.53k|    osd->want_redraw_notification = true;
  225|  9.53k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  9.53k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  226|  9.53k|}
osd_get_render_subs_in_filter:
  229|   157k|{
  230|   157k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   157k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|   157k|    bool r = osd->render_subs_in_filter;
  232|   157k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   157k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|   157k|    return r;
  234|   157k|}
osd_set_force_video_pts:
  252|  37.7k|{
  253|       |    atomic_store(&osd->force_video_pts, video_pts);
  254|  37.7k|}
osd_get_force_video_pts:
  257|   669k|{
  258|       |    return atomic_load(&osd->force_video_pts);
  259|   669k|}
osd_set_progbar:
  262|  43.4k|{
  263|  43.4k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  43.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  264|  43.4k|    struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
  265|  43.4k|    osd_obj->progbar_state.type = s->type;
  266|  43.4k|    osd_obj->progbar_state.value = s->value;
  267|  43.4k|    osd_obj->progbar_state.num_stops = s->num_stops;
  268|  43.4k|    MP_TARRAY_GROW(osd_obj, osd_obj->progbar_state.stops, s->num_stops);
  ------------------
  |  |   96|  43.4k|    do {                                            \
  |  |   97|  43.4k|        size_t nextidx_ = (nextidx);                \
  |  |   98|  43.4k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  43.4k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  43.4k|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 2.25k, False: 41.1k]
  |  |  ------------------
  |  |   99|  43.4k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|  2.25k|    do {                                                        \
  |  |  |  |   89|  2.25k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  2.25k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  2.25k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  2.25k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.25k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|  2.25k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|  2.25k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 2.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  43.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 43.4k]
  |  |  ------------------
  ------------------
  269|  43.4k|    if (s->num_stops) {
  ------------------
  |  Branch (269:9): [True: 8.62k, False: 34.8k]
  ------------------
  270|  8.62k|        memcpy(osd_obj->progbar_state.stops, s->stops,
  271|  8.62k|               sizeof(osd_obj->progbar_state.stops[0]) * s->num_stops);
  272|  8.62k|    }
  273|  43.4k|    osd_obj->osd_changed = true;
  274|  43.4k|    osd->want_redraw_notification = true;
  275|  43.4k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  43.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  276|  43.4k|}
osd_set_bitmaps:
  279|  11.6k|{
  280|  11.6k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  11.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  281|  11.6k|    struct osd_object *obj = osd->objs[type];
  282|  11.6k|    talloc_free(obj->image_overlay);
  ------------------
  |  |   47|  11.6k|#define talloc_free                     ta_free
  ------------------
  283|  11.6k|    obj->image_overlay = sub_bitmaps_copy(NULL, imgs);
  284|  11.6k|    obj->vo_change_id += 1;
  285|  11.6k|    osd->want_redraw_notification = true;
  286|  11.6k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  11.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  287|  11.6k|}
osd_render:
  368|  35.2k|{
  369|  35.2k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  35.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  370|       |
  371|  35.2k|    int64_t start_time = mp_time_ns();
  372|       |
  373|  35.2k|    struct sub_bitmap_list *list = talloc_zero(NULL, struct sub_bitmap_list);
  ------------------
  |  |   27|  35.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  35.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|  35.2k|    list->change_id = 1;
  375|  35.2k|    list->w = res.w;
  376|  35.2k|    list->h = res.h;
  377|       |
  378|  35.2k|    double force_video_pts = atomic_load(&osd->force_video_pts);
  379|  35.2k|    if (force_video_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  35.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (379:9): [True: 0, False: 35.2k]
  ------------------
  380|      0|        video_pts = force_video_pts;
  381|       |
  382|  35.2k|    if (draw_flags & OSD_DRAW_SUB_FILTER)
  ------------------
  |  Branch (382:9): [True: 0, False: 35.2k]
  ------------------
  383|      0|        draw_flags |= OSD_DRAW_SUB_ONLY;
  384|       |
  385|   246k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   246k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (385:21): [True: 211k, False: 35.2k]
  ------------------
  386|   211k|        struct osd_object *obj = osd->objs[n];
  387|       |
  388|       |        // Object is drawn into the video frame itself; don't draw twice
  389|   211k|        if (osd->render_subs_in_filter && obj->is_sub &&
  ------------------
  |  Branch (389:13): [True: 0, False: 211k]
  |  Branch (389:43): [True: 0, False: 0]
  ------------------
  390|      0|            !(draw_flags & OSD_DRAW_SUB_FILTER))
  ------------------
  |  Branch (390:13): [True: 0, False: 0]
  ------------------
  391|      0|            continue;
  392|   211k|        if ((draw_flags & OSD_DRAW_SUB_ONLY) && !obj->is_sub)
  ------------------
  |  Branch (392:13): [True: 211k, False: 0]
  |  Branch (392:49): [True: 140k, False: 70.4k]
  ------------------
  393|   140k|            continue;
  394|  70.4k|        if ((draw_flags & OSD_DRAW_OSD_ONLY) && obj->is_sub)
  ------------------
  |  Branch (394:13): [True: 0, False: 70.4k]
  |  Branch (394:49): [True: 0, False: 0]
  ------------------
  395|      0|            continue;
  396|       |
  397|  70.4k|        char *stat_type_render = obj->is_sub ? "sub-render" : "osd-render";
  ------------------
  |  Branch (397:34): [True: 70.4k, False: 0]
  ------------------
  398|  70.4k|        stats_time_start(osd->stats, stat_type_render);
  399|       |
  400|  70.4k|        struct sub_bitmaps *imgs =
  401|  70.4k|            render_object(osd, obj, res, video_pts, formats);
  402|       |
  403|  70.4k|        stats_time_end(osd->stats, stat_type_render);
  404|       |
  405|  70.4k|        if (imgs && imgs->num_parts > 0) {
  ------------------
  |  Branch (405:13): [True: 0, False: 70.4k]
  |  Branch (405:21): [True: 0, False: 0]
  ------------------
  406|      0|            if (formats[imgs->format]) {
  ------------------
  |  Branch (406:17): [True: 0, False: 0]
  ------------------
  407|      0|                talloc_steal(list, imgs);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  408|      0|                MP_TARRAY_APPEND(list, list->items, list->num_items, imgs);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  409|      0|                imgs = NULL;
  410|      0|            } else {
  411|      0|                MP_ERR(osd, "Can't render OSD part %d (format %d).\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__)
  |  |  ------------------
  ------------------
  412|      0|                       obj->type, imgs->format);
  413|      0|            }
  414|      0|        }
  415|       |
  416|  70.4k|        list->change_id += obj->vo_change_id;
  417|       |
  418|  70.4k|        talloc_free(imgs);
  ------------------
  |  |   47|  70.4k|#define talloc_free                     ta_free
  ------------------
  419|  70.4k|    }
  420|       |
  421|  35.2k|    double elapsed = MP_TIME_NS_TO_MS(mp_time_ns() - start_time);
  ------------------
  |  |   77|  35.2k|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  422|  35.2k|    bool slow = elapsed > 5;
  423|  35.2k|    mp_msg(osd->log, slow ? MSGL_DEBUG : MSGL_TRACE, "Spent %.3f ms in %s%s\n",
  ------------------
  |  Branch (423:22): [True: 8, False: 35.2k]
  ------------------
  424|  35.2k|           elapsed, __func__, slow ? " (slow!)" : "");
  ------------------
  |  Branch (424:31): [True: 8, False: 35.2k]
  ------------------
  425|       |
  426|  35.2k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  35.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  427|  35.2k|    return list;
  428|  35.2k|}
osd_draw_on_image:
  453|  35.2k|{
  454|       |    osd_draw_on_image_p(osd, res, video_pts, draw_flags, NULL, dest);
  455|  35.2k|}
osd_draw_on_image_p:
  463|  35.2k|{
  464|  35.2k|    struct sub_bitmap_list *list =
  465|  35.2k|        osd_render(osd, res, video_pts, draw_flags, mp_draw_sub_formats);
  466|       |
  467|  35.2k|    if (!list->num_items) {
  ------------------
  |  Branch (467:9): [True: 35.2k, False: 0]
  ------------------
  468|  35.2k|        talloc_free(list);
  ------------------
  |  |   47|  35.2k|#define talloc_free                     ta_free
  ------------------
  469|  35.2k|        return;
  470|  35.2k|    }
  471|       |
  472|      0|    if (!mp_image_pool_make_writeable(pool, dest))
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|        return; // on OOM, skip
  474|       |
  475|       |    // Need to lock for the dumb osd->draw_cache thing.
  476|      0|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  477|       |
  478|      0|    if (!osd->draw_cache)
  ------------------
  |  Branch (478:9): [True: 0, False: 0]
  ------------------
  479|      0|        osd->draw_cache = mp_draw_sub_alloc(osd, osd->global);
  480|       |
  481|      0|    stats_time_start(osd->stats, "draw-bmp");
  482|       |
  483|      0|    if (!mp_draw_sub_bitmaps(osd->draw_cache, dest, list))
  ------------------
  |  Branch (483:9): [True: 0, False: 0]
  ------------------
  484|      0|        MP_WARN(osd, "Failed rendering OSD.\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__)
  |  |  ------------------
  ------------------
  485|      0|    talloc_steal(osd, osd->draw_cache);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  486|       |
  487|      0|    stats_time_end(osd->stats, "draw-bmp");
  488|       |
  489|      0|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  490|       |
  491|      0|    talloc_free(list);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  492|      0|}
osd_res_from_image_params:
  498|  35.2k|{
  499|  35.2k|    return (struct mp_osd_res) {
  500|  35.2k|        .w = p->w,
  501|  35.2k|        .h = p->h,
  502|  35.2k|        .display_par = p->p_h / (double)p->p_w,
  503|  35.2k|    };
  504|  35.2k|}
osd_changed:
  508|  12.4k|{
  509|  12.4k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  12.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  510|  12.4k|    osd->objs[OSDTYPE_OSD]->osd_changed = true;
  511|  12.4k|    osd->want_redraw_notification = true;
  512|       |    // Done here for a lack of a better place.
  513|  12.4k|    m_config_cache_update(osd->opts_cache);
  514|  12.4k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  12.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  515|  12.4k|}
osd_query_and_reset_want_redraw:
  518|   178k|{
  519|   178k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   178k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  520|   178k|    bool r = osd->want_redraw_notification;
  521|   178k|    osd->want_redraw_notification = false;
  522|   178k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   178k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  523|   178k|    return r;
  524|   178k|}
osd_get_vo_res:
  527|    207|{
  528|    207|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|    207|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  529|       |    // Any OSDTYPE is fine; but it mustn't be a subtitle one (can have lower res.)
  530|    207|    struct mp_osd_res res = osd->objs[OSDTYPE_OSD]->vo_res;
  531|    207|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|    207|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  532|    207|    return res;
  533|    207|}
sub_bitmaps_copy:
  585|  17.1k|{
  586|  17.1k|    if (!in || !in->num_parts)
  ------------------
  |  Branch (586:9): [True: 11.6k, False: 5.48k]
  |  Branch (586:16): [True: 5.48k, False: 0]
  ------------------
  587|  17.1k|        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.c:check_obj_resize:
  291|  70.4k|{
  292|  70.4k|    if (!osd_res_equals(res, obj->vo_res)) {
  ------------------
  |  Branch (292:9): [True: 3.67k, False: 66.7k]
  ------------------
  293|  3.67k|        obj->vo_res = res;
  294|  3.67k|        obj->osd_changed = true;
  295|  3.67k|        mp_client_broadcast_event_external(osd->global->client_api,
  296|       |                                           MP_EVENT_WIN_RESIZE, NULL);
  297|  3.67k|    }
  298|  70.4k|}
osd.c:render_object:
  321|  70.4k|{
  322|  70.4k|    int format = SUBBITMAP_LIBASS;
  323|  70.4k|    if (!sub_formats[format] || osd->opts->force_rgba_osd)
  ------------------
  |  Branch (323:9): [True: 0, False: 70.4k]
  |  Branch (323:33): [True: 0, False: 70.4k]
  ------------------
  324|      0|        format = SUBBITMAP_BGRA;
  325|       |
  326|  70.4k|    struct sub_bitmaps *res = NULL;
  327|       |
  328|  70.4k|    check_obj_resize(osd, osdres, obj);
  329|       |
  330|  70.4k|    if (obj->type == OSDTYPE_SUB) {
  ------------------
  |  Branch (330:9): [True: 35.2k, False: 35.2k]
  ------------------
  331|  35.2k|        if (obj->sub && sub_is_primary_visible(obj->sub))
  ------------------
  |  Branch (331:13): [True: 5.48k, False: 29.7k]
  |  Branch (331:25): [True: 5.48k, False: 0]
  ------------------
  332|  5.48k|            res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts);
  333|  35.2k|    } else if (obj->type == OSDTYPE_SUB2) {
  ------------------
  |  Branch (333:16): [True: 35.2k, False: 0]
  ------------------
  334|  35.2k|        if (obj->sub && sub_is_secondary_visible(obj->sub))
  ------------------
  |  Branch (334:13): [True: 0, False: 35.2k]
  |  Branch (334:25): [True: 0, False: 0]
  ------------------
  335|      0|            res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts);
  336|  35.2k|    } else if (obj->type == OSDTYPE_EXTERNAL2 ||
  ------------------
  |  Branch (336:16): [True: 0, False: 0]
  ------------------
  337|      0|               obj->type == OSDTYPE_DISC_MENU) {
  ------------------
  |  Branch (337:16): [True: 0, False: 0]
  ------------------
  338|      0|        if (obj->image_overlay && obj->image_overlay->format) {
  ------------------
  |  Branch (338:13): [True: 0, False: 0]
  |  Branch (338:35): [True: 0, False: 0]
  ------------------
  339|      0|            res = sub_bitmaps_copy(NULL, obj->image_overlay); // need to be owner
  340|      0|            obj->image_overlay->change_id = 0;
  341|      0|        }
  342|      0|    } else {
  343|      0|        res = osd_object_get_bitmaps(osd, obj, format);
  344|      0|    }
  345|       |
  346|  70.4k|    if (obj->vo_had_output != !!res) {
  ------------------
  |  Branch (346:9): [True: 0, False: 70.4k]
  ------------------
  347|      0|        obj->vo_had_output = !!res;
  348|      0|        obj->vo_change_id += 1;
  349|      0|    }
  350|       |
  351|  70.4k|    if (res) {
  ------------------
  |  Branch (351:9): [True: 0, False: 70.4k]
  ------------------
  352|      0|        obj->vo_change_id += res->change_id;
  353|       |
  354|      0|        res->render_index = obj->type;
  355|      0|        res->change_id = obj->vo_change_id;
  356|      0|    }
  357|       |
  358|  70.4k|    return res;
  359|  70.4k|}

osd_destroy_backend:
   86|  11.6k|{
   87|  81.7k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|  81.7k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (87:21): [True: 70.0k, False: 11.6k]
  ------------------
   88|  70.0k|        struct osd_object *obj = osd->objs[n];
   89|  70.0k|        destroy_ass_renderer(&obj->ass);
   90|  70.0k|        for (int i = 0; i < obj->num_externals; i++)
  ------------------
  |  Branch (90:25): [True: 0, False: 70.0k]
  ------------------
   91|      0|            destroy_external(obj->externals[i]);
   92|  70.0k|        obj->num_externals = 0;
   93|  70.0k|    }
   94|  11.6k|}
osd_get_function_sym:
  197|  44.4k|{
  198|  44.4k|    snprintf(buffer, buffer_size, OSD_CODEPOINTS_ESCAPE "%c", osd_function);
  ------------------
  |  |  132|  44.4k|#define OSD_CODEPOINTS_ESCAPE "\xC2\x91"
  ------------------
  199|  44.4k|}
osd_mangle_ass:
  202|    160|{
  203|    160|    const char *start = in;
  204|    160|    bool escape_ass = true;
  205|  3.15k|    while (*in) {
  ------------------
  |  Branch (205:12): [True: 2.99k, False: 160]
  ------------------
  206|       |        // As used by osd_get_function_sym().
  207|  2.99k|        size_t len = strlen(OSD_CODEPOINTS_ESCAPE);
  ------------------
  |  |  132|  2.99k|#define OSD_CODEPOINTS_ESCAPE "\xC2\x91"
  ------------------
  208|  2.99k|        if (!strncmp(in, OSD_CODEPOINTS_ESCAPE, len) && in[len]) {
  ------------------
  |  |  132|  2.99k|#define OSD_CODEPOINTS_ESCAPE "\xC2\x91"
  ------------------
  |  Branch (208:13): [True: 0, False: 2.99k]
  |  Branch (208:57): [True: 0, False: 0]
  ------------------
  209|      0|            bstr_xappend(NULL, dst, bstr0(ASS_USE_OSD_FONT));
  ------------------
  |  |   40|      0|#define ASS_USE_OSD_FONT "{\\fnmpv-osd-symbols}"
  ------------------
  210|      0|            mp_append_utf8_bstr(NULL, dst, OSD_CODEPOINTS + in[len]);
  ------------------
  |  |  130|      0|#define OSD_CODEPOINTS 0xE000
  ------------------
  211|      0|            bstr_xappend(NULL, dst, bstr0("{\\r}"));
  212|      0|            in += len + 1;
  213|      0|            continue;
  214|      0|        }
  215|  2.99k|        len = strlen(OSD_ASS_0);
  ------------------
  |  |  154|  2.99k|#define OSD_ASS_0 OSD_ASS_ESCAPE "0"
  |  |  ------------------
  |  |  |  |  152|  2.99k|#define OSD_ASS_ESCAPE "\xC2\x92" "a"
  |  |  ------------------
  ------------------
  216|  2.99k|        if (!strncmp(in, OSD_ASS_0, len)) {
  ------------------
  |  |  154|  2.99k|#define OSD_ASS_0 OSD_ASS_ESCAPE "0"
  |  |  ------------------
  |  |  |  |  152|  2.99k|#define OSD_ASS_ESCAPE "\xC2\x92" "a"
  |  |  ------------------
  ------------------
  |  Branch (216:13): [True: 0, False: 2.99k]
  ------------------
  217|      0|            escape_ass = false;
  218|      0|            in += len;
  219|      0|            continue;
  220|      0|        }
  221|  2.99k|        len = strlen(OSD_ASS_1);
  ------------------
  |  |  155|  2.99k|#define OSD_ASS_1 OSD_ASS_ESCAPE "1"
  |  |  ------------------
  |  |  |  |  152|  2.99k|#define OSD_ASS_ESCAPE "\xC2\x92" "a"
  |  |  ------------------
  ------------------
  222|  2.99k|        if (!strncmp(in, OSD_ASS_1, len)) {
  ------------------
  |  |  155|  2.99k|#define OSD_ASS_1 OSD_ASS_ESCAPE "1"
  |  |  ------------------
  |  |  |  |  152|  2.99k|#define OSD_ASS_ESCAPE "\xC2\x92" "a"
  |  |  ------------------
  ------------------
  |  Branch (222:13): [True: 0, False: 2.99k]
  ------------------
  223|      0|            escape_ass = true;
  224|      0|            in += len;
  225|      0|            continue;
  226|      0|        }
  227|  2.99k|        len = strlen(TERM_MSG_0);
  ------------------
  |  |   30|  2.99k|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  2.99k|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  228|  2.99k|        if (!strncmp(in, TERM_MSG_0, len)) {
  ------------------
  |  |   30|  2.99k|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  2.99k|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  |  Branch (228:13): [True: 18, False: 2.97k]
  ------------------
  229|     18|            in += len;
  230|     18|            continue;
  231|     18|        }
  232|  2.97k|        if (escape_ass && *in == '{')
  ------------------
  |  Branch (232:13): [True: 2.97k, False: 0]
  |  Branch (232:27): [True: 82, False: 2.89k]
  ------------------
  233|     82|            bstr_xappend(NULL, dst, bstr0("\\"));
  234|       |        // Replace newlines with \N for escape-ass. This is necessary to apply
  235|       |        // ASS tags past newlines and to preserve consecutive newlines with
  236|       |        // osd-overlay because update_external() adds a ASS event per line.
  237|  2.97k|        if (replace_newlines && *in == '\n') {
  ------------------
  |  Branch (237:13): [True: 2.97k, False: 0]
  |  Branch (237:33): [True: 0, False: 2.97k]
  ------------------
  238|      0|            bstr_xappend(NULL, dst, bstr0("\\N"));
  239|      0|            in += 1;
  240|      0|            continue;
  241|      0|        }
  242|       |        // Libass will strip leading whitespace
  243|  2.97k|        if (in[0] == ' ' && (in == start || in[-1] == '\n')) {
  ------------------
  |  Branch (243:13): [True: 0, False: 2.97k]
  |  Branch (243:30): [True: 0, False: 0]
  |  Branch (243:45): [True: 0, False: 0]
  ------------------
  244|      0|            bstr_xappend(NULL, dst, bstr0("\\h"));
  245|      0|            in += 1;
  246|      0|            continue;
  247|      0|        }
  248|  2.97k|        bstr_xappend(NULL, dst, (bstr){(char *)in, 1});
  249|       |        // Break ASS escapes with U+2060 WORD JOINER
  250|  2.97k|        if (escape_ass && *in == '\\')
  ------------------
  |  Branch (250:13): [True: 2.97k, False: 0]
  |  Branch (250:27): [True: 169, False: 2.80k]
  ------------------
  251|    169|            mp_append_utf8_bstr(NULL, dst, 0x2060);
  252|  2.97k|        in++;
  253|  2.97k|    }
  254|    160|}
osd_set_external_remove_owner:
  648|  35.0k|{
  649|  35.0k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  35.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  650|  35.0k|    struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
  651|  35.0k|    for (int n = obj->num_externals - 1; n >= 0; n--) {
  ------------------
  |  Branch (651:42): [True: 0, False: 35.0k]
  ------------------
  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|  35.0k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  35.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  661|  35.0k|}
osd_libass.c:destroy_ass_renderer:
   65|  70.0k|{
   66|  70.0k|    if (ass->track)
  ------------------
  |  Branch (66:9): [True: 0, False: 70.0k]
  ------------------
   67|      0|        ass_free_track(ass->track);
   68|  70.0k|    ass->track = NULL;
   69|  70.0k|    if (ass->render)
  ------------------
  |  Branch (69:9): [True: 0, False: 70.0k]
  ------------------
   70|      0|        ass_renderer_done(ass->render);
   71|  70.0k|    ass->render = NULL;
   72|  70.0k|    if (ass->library)
  ------------------
  |  Branch (72:9): [True: 0, False: 70.0k]
  ------------------
   73|      0|        ass_library_done(ass->library);
   74|  70.0k|    ass->library = NULL;
   75|  70.0k|    talloc_free(ass->log);
  ------------------
  |  |   47|  70.0k|#define talloc_free                     ta_free
  ------------------
   76|       |    ass->log = NULL;
   77|  70.0k|}

mp_sub_packer_alloc:
   52|  4.76k|{
   53|  4.76k|    struct mp_sub_packer *p = talloc_zero(ta_parent, struct mp_sub_packer);
  ------------------
  |  |   27|  4.76k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.76k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|  4.76k|    p->packer = talloc_zero(p, struct bitmap_packer);
  ------------------
  |  |   27|  4.76k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.76k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  4.76k|    p->packer->padding = 1; // assume bilinear sampling
   56|  4.76k|    return p;
   57|  4.76k|}
mp_sub_packer_pack_ass:
  275|  4.16k|{
  276|  4.16k|    int format = preferred_osd_format == SUBBITMAP_BGRA ? SUBBITMAP_BGRA
  ------------------
  |  Branch (276:18): [True: 0, False: 4.16k]
  ------------------
  277|  4.16k|                                                        : SUBBITMAP_LIBASS;
  278|       |
  279|  4.16k|    if (p->cached_subs_valid && !image_lists_changed &&
  ------------------
  |  Branch (279:9): [True: 0, False: 4.16k]
  |  Branch (279:33): [True: 0, False: 0]
  ------------------
  280|      0|        p->cached_subs.format == format)
  ------------------
  |  Branch (280:9): [True: 0, False: 0]
  ------------------
  281|      0|    {
  282|      0|        *out = p->cached_subs;
  283|      0|        return;
  284|      0|    }
  285|       |
  286|  4.16k|    *out = (struct sub_bitmaps){.change_id = 1};
  287|  4.16k|    p->cached_subs_valid = false;
  288|       |
  289|  4.16k|    struct sub_bitmaps res = {
  290|  4.16k|        .change_id = image_lists_changed,
  291|  4.16k|        .format = SUBBITMAP_LIBASS,
  292|  4.16k|        .parts = p->cached_parts,
  293|  4.16k|        .video_color_space = video_color_space,
  294|  4.16k|    };
  295|       |
  296|  8.32k|    for (int n = 0; n < num_image_lists; n++) {
  ------------------
  |  Branch (296:21): [True: 4.16k, False: 4.16k]
  ------------------
  297|  4.16k|        for (struct ass_image *img = image_lists[n]; img; img = img->next) {
  ------------------
  |  Branch (297:54): [True: 0, False: 4.16k]
  ------------------
  298|      0|            if (img->w == 0 || img->h == 0)
  ------------------
  |  Branch (298:17): [True: 0, False: 0]
  |  Branch (298:32): [True: 0, False: 0]
  ------------------
  299|      0|                continue;
  300|      0|            MP_TARRAY_GROW(p, p->cached_parts, res.num_parts);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  301|      0|            res.parts = p->cached_parts;
  302|      0|            struct sub_bitmap *b = &res.parts[res.num_parts];
  303|      0|            b->bitmap = img->bitmap;
  304|      0|            b->stride = img->stride;
  305|      0|            b->libass.color = img->color;
  306|      0|            b->dw = b->w = img->w;
  307|      0|            b->dh = b->h = img->h;
  308|      0|            b->x = img->dst_x;
  309|      0|            b->y = img->dst_y;
  310|      0|            res.num_parts++;
  311|      0|        }
  312|  4.16k|    }
  313|       |
  314|  4.16k|    bool r = false;
  315|  4.16k|    if (format == SUBBITMAP_BGRA) {
  ------------------
  |  Branch (315:9): [True: 0, False: 4.16k]
  ------------------
  316|      0|        r = pack_rgba(p, &res);
  317|  4.16k|    } else {
  318|  4.16k|        r = pack_libass(p, &res);
  319|  4.16k|    }
  320|       |
  321|  4.16k|    if (!r)
  ------------------
  |  Branch (321:9): [True: 4.16k, False: 0]
  ------------------
  322|  4.16k|        return;
  323|       |
  324|      0|    *out = res;
  325|      0|    p->cached_subs = res;
  326|      0|    p->cached_subs.change_id = 0;
  327|       |    p->cached_subs_valid = true;
  328|      0|}
packer.c:pack:
   60|  4.16k|{
   61|  4.16k|    packer_set_size(p->packer, res->num_parts);
   62|       |
   63|  4.16k|    for (int n = 0; n < res->num_parts; n++)
  ------------------
  |  Branch (63:21): [True: 0, False: 4.16k]
  ------------------
   64|      0|        p->packer->in[n] = (struct pos){res->parts[n].w, res->parts[n].h};
   65|       |
   66|  4.16k|    if (p->packer->count == 0 || packer_pack(p->packer) < 0)
  ------------------
  |  Branch (66:9): [True: 4.16k, False: 0]
  |  Branch (66:34): [True: 0, False: 0]
  ------------------
   67|  4.16k|        return false;
   68|       |
   69|      0|    struct pos bb[2];
   70|      0|    packer_get_bb(p->packer, bb);
   71|       |
   72|      0|    res->packed_w = bb[1].x;
   73|      0|    res->packed_h = bb[1].y;
   74|       |
   75|      0|    if (!p->cached_img || p->cached_img->w < res->packed_w ||
  ------------------
  |  Branch (75:9): [True: 0, False: 0]
  |  Branch (75:27): [True: 0, False: 0]
  ------------------
   76|      0|                          p->cached_img->h < res->packed_h ||
  ------------------
  |  Branch (76:27): [True: 0, False: 0]
  ------------------
   77|      0|                          p->cached_img->imgfmt != imgfmt)
  ------------------
  |  Branch (77:27): [True: 0, False: 0]
  ------------------
   78|      0|    {
   79|      0|        talloc_free(p->cached_img);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
   80|      0|        p->cached_img = mp_image_alloc(imgfmt, p->packer->w, p->packer->h);
   81|      0|        if (!p->cached_img) {
  ------------------
  |  Branch (81:13): [True: 0, False: 0]
  ------------------
   82|      0|            packer_reset(p->packer);
   83|      0|            return false;
   84|      0|        }
   85|      0|        talloc_steal(p, p->cached_img);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
   86|      0|    }
   87|       |
   88|      0|    if (!mp_image_make_writeable(p->cached_img)) {
  ------------------
  |  Branch (88:9): [True: 0, False: 0]
  ------------------
   89|      0|        packer_reset(p->packer);
   90|      0|        return false;
   91|      0|    }
   92|       |
   93|      0|    res->packed = p->cached_img;
   94|       |
   95|      0|    for (int n = 0; n < res->num_parts; n++) {
  ------------------
  |  Branch (95:21): [True: 0, False: 0]
  ------------------
   96|      0|        struct sub_bitmap *b = &res->parts[n];
   97|      0|        struct pos pos = p->packer->result[n];
   98|       |
   99|      0|        b->src_x = pos.x;
  100|      0|        b->src_y = pos.y;
  101|      0|    }
  102|       |
  103|       |    return true;
  104|      0|}
packer.c:pack_libass:
  188|  4.16k|{
  189|  4.16k|    if (!pack(p, res, IMGFMT_Y8))
  ------------------
  |  Branch (189:9): [True: 4.16k, False: 0]
  ------------------
  190|  4.16k|        return false;
  191|       |
  192|      0|    int padding = p->packer->padding;
  193|      0|    uint8_t *base = res->packed->planes[0];
  194|      0|    int stride = res->packed->stride[0];
  195|       |
  196|      0|    for (int n = 0; n < res->num_parts; n++) {
  ------------------
  |  Branch (196:21): [True: 0, False: 0]
  ------------------
  197|      0|        struct sub_bitmap *b = &res->parts[n];
  198|      0|        void *pdata = base + b->src_y * stride + b->src_x;
  199|      0|        memcpy_pic(pdata, b->bitmap, b->w, b->h, stride, b->stride);
  200|      0|        fill_padding_1(pdata, b->w, b->h, stride, padding);
  201|       |
  202|      0|        b->bitmap = pdata;
  203|      0|        b->stride = stride;
  204|      0|    }
  205|       |
  206|       |    return true;
  207|  4.16k|}

sd_ass.c:init:
  304|  4.76k|{
  305|  4.76k|    struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
  ------------------
  |  |   27|  4.76k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  4.76k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  4.76k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  4.76k|    sd->priv = ctx;
  307|       |
  308|       |    // Note: accept "null" as alias for "ass", so EDL delay_open subtitle
  309|       |    //       streams work.
  310|  4.76k|    if (strcmp(sd->codec->codec, "ass") != 0 &&
  ------------------
  |  Branch (310:9): [True: 4.76k, False: 0]
  ------------------
  311|  4.76k|        strcmp(sd->codec->codec, "null") != 0)
  ------------------
  |  Branch (311:9): [True: 4.76k, False: 0]
  ------------------
  312|  4.76k|    {
  313|  4.76k|        ctx->is_converted = true;
  314|  4.76k|        ctx->converter = lavc_conv_create(sd);
  315|  4.76k|        if (!ctx->converter)
  ------------------
  |  Branch (315:13): [True: 0, False: 4.76k]
  ------------------
  316|      0|            return -1;
  317|  4.76k|    }
  318|       |
  319|  4.76k|    assobjects_init(sd);
  320|  4.76k|    filters_init(sd);
  321|       |
  322|  4.76k|    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|  4.76k|    const char *_Atomic *desc = ctx->converter ? &sd->codec->codec_profile : &sd->codec->codec_desc;
  ------------------
  |  Branch (325:33): [True: 4.76k, False: 0]
  ------------------
  326|  4.76k|    switch (ctx->ass_track->track_type) {
  ------------------
  |  Branch (326:13): [True: 4.76k, False: 0]
  ------------------
  327|  4.76k|    case TRACK_TYPE_ASS:
  ------------------
  |  Branch (327:5): [True: 4.76k, False: 0]
  ------------------
  328|  4.76k|        *desc = "Advanced Sub Station Alpha";
  329|  4.76k|        break;
  330|      0|    case TRACK_TYPE_SSA:
  ------------------
  |  Branch (330:5): [True: 0, False: 4.76k]
  ------------------
  331|      0|        *desc = "Sub Station Alpha";
  332|      0|        break;
  333|  4.76k|    }
  334|       |
  335|  4.76k|    return 0;
  336|  4.76k|}
sd_ass.c:assobjects_init:
  249|  4.76k|{
  250|  4.76k|    struct sd_ass_priv *ctx = sd->priv;
  251|  4.76k|    struct mp_subtitle_opts *opts = sd->opts;
  252|  4.76k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  253|       |
  254|  4.76k|    ctx->ass_library = mp_ass_init(sd->global, sd->opts->sub_style, sd->log);
  255|  4.76k|    ass_set_extract_fonts(ctx->ass_library, opts->use_embedded_fonts);
  256|       |
  257|  4.76k|    add_subtitle_fonts(sd);
  258|       |
  259|  4.76k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (259:9): [True: 4.76k, False: 0]
  ------------------
  260|  4.76k|        ass_set_style_overrides(ctx->ass_library, opts->ass_style_override_list);
  261|       |
  262|  4.76k|    ctx->ass_track = ass_new_track(ctx->ass_library);
  263|  4.76k|    ctx->ass_track->track_type = TRACK_TYPE_ASS;
  264|       |
  265|  4.76k|    ctx->shadow_track = ass_new_track(ctx->ass_library);
  266|  4.76k|    ctx->shadow_track->PlayResX = MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|  4.76k|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  267|  4.76k|    ctx->shadow_track->PlayResY = MP_ASS_FONT_PLAYRESY;
  ------------------
  |  |   32|  4.76k|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  268|  4.76k|    mp_ass_add_default_styles(sd, ctx->shadow_track, opts, shared_opts);
  269|       |
  270|  4.76k|    char *extradata = sd->codec->extradata;
  271|  4.76k|    int extradata_size = sd->codec->extradata_size;
  272|  4.76k|    if (ctx->converter) {
  ------------------
  |  Branch (272:9): [True: 4.76k, False: 0]
  ------------------
  273|  4.76k|        extradata = lavc_conv_get_extradata(ctx->converter);
  274|  4.76k|        extradata_size = extradata ? strlen(extradata) : 0;
  ------------------
  |  Branch (274:26): [True: 4.76k, False: 0]
  ------------------
  275|  4.76k|    }
  276|  4.76k|    if (extradata)
  ------------------
  |  Branch (276:9): [True: 4.76k, False: 0]
  ------------------
  277|  4.76k|        ass_process_codec_private(ctx->ass_track, extradata, extradata_size);
  278|       |
  279|  4.76k|    mp_ass_add_default_styles(sd, ctx->ass_track, opts, shared_opts);
  280|       |
  281|  4.76k|#if LIBASS_VERSION >= 0x01302000
  282|  4.76k|    ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
  ------------------
  |  Branch (282:45): [True: 0, False: 4.76k]
  ------------------
  283|  4.76k|#endif
  284|       |
  285|  4.76k|#if LIBASS_VERSION >= 0x01703010
  286|  4.76k|    ass_configure_prune(ctx->ass_track, sd->opts->ass_prune_delay * 1000.0);
  287|  4.76k|#endif
  288|       |
  289|       |    enable_output(sd, true);
  290|  4.76k|    ass_set_cache_limits(ctx->ass_renderer, sd->opts->sub_glyph_limit, sd->opts->sub_bitmap_max_size);
  291|  4.76k|}
sd_ass.c:add_subtitle_fonts:
  182|  4.76k|{
  183|  4.76k|    struct sd_ass_priv *ctx = sd->priv;
  184|  4.76k|    struct mp_subtitle_opts *opts = sd->opts;
  185|  4.76k|    if (!opts->ass_enabled || !opts->use_embedded_fonts || !sd->attachments)
  ------------------
  |  Branch (185:9): [True: 0, False: 4.76k]
  |  Branch (185:31): [True: 0, False: 4.76k]
  |  Branch (185:60): [True: 0, False: 4.76k]
  ------------------
  186|      0|        return;
  187|  4.76k|    for (int i = 0; i < sd->attachments->num_entries; i++) {
  ------------------
  |  Branch (187:21): [True: 0, False: 4.76k]
  ------------------
  188|      0|        struct demux_attachment *f = &sd->attachments->entries[i];
  189|      0|        if (attachment_is_font(sd->log, f))
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            ass_add_font(ctx->ass_library, f->name, f->data, f->data_size);
  191|      0|    }
  192|  4.76k|}
sd_ass.c:mp_ass_add_default_styles:
  119|  9.53k|{
  120|  9.53k|    if (opts->ass_styles_file && shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (120:9): [True: 0, False: 9.53k]
  |  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|  9.53k|    if (track->n_styles == 0) {
  ------------------
  |  Branch (126:9): [True: 0, False: 9.53k]
  ------------------
  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|  9.53k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (139:9): [True: 9.53k, False: 0]
  ------------------
  140|  9.53k|        ass_process_force_style(track);
  141|  9.53k|}
sd_ass.c:filters_init:
  208|  4.76k|{
  209|  4.76k|    struct sd_ass_priv *ctx = sd->priv;
  210|       |
  211|  4.76k|    filters_destroy(sd);
  212|       |
  213|  14.2k|    for (int n = 0; filters[n]; n++) {
  ------------------
  |  Branch (213:21): [True: 9.53k, False: 4.76k]
  ------------------
  214|  9.53k|        struct sd_filter *ft = talloc_ptrtype(ctx, ft);
  ------------------
  |  |   34|  9.53k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  9.53k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  9.53k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|  9.53k|        *ft = (struct sd_filter){
  216|  9.53k|            .global = sd->global,
  217|  9.53k|            .log = sd->log,
  218|  9.53k|            .packet_pool = demux_packet_pool_get(sd->global),
  219|  9.53k|            .opts = mp_get_config_group(ft, sd->global, &mp_sub_filter_opts),
  220|  9.53k|            .driver = filters[n],
  221|  9.53k|            .codec = "ass",
  222|  9.53k|            .event_format = talloc_strdup(ft, ctx->ass_track->event_format),
  ------------------
  |  |   50|  9.53k|#define talloc_strdup                   ta_xstrdup
  ------------------
  223|  9.53k|        };
  224|  9.53k|        if (ft->driver->init(ft)) {
  ------------------
  |  Branch (224:13): [True: 0, False: 9.53k]
  ------------------
  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|  9.53k|        } else {
  227|  9.53k|            talloc_free(ft);
  ------------------
  |  |   47|  9.53k|#define talloc_free                     ta_free
  ------------------
  228|  9.53k|        }
  229|  9.53k|    }
  230|  4.76k|}
sd_ass.c:filters_destroy:
  195|  9.53k|{
  196|  9.53k|    struct sd_ass_priv *ctx = sd->priv;
  197|       |
  198|  9.53k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (198:21): [True: 0, False: 9.53k]
  ------------------
  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|  9.53k|    ctx->num_filters = 0;
  205|  9.53k|}
sd_ass.c:decode:
  468|  3.83k|{
  469|  3.83k|    struct sd_ass_priv *ctx = sd->priv;
  470|  3.83k|    ASS_Track *track = ctx->ass_track;
  471|       |
  472|  3.83k|    packet->sub_duration = packet->duration;
  473|       |
  474|  3.83k|    if (ctx->converter) {
  ------------------
  |  Branch (474:9): [True: 3.83k, False: 0]
  ------------------
  475|  3.83k|        if (!sd->opts->sub_clear_on_seek && check_packet_seen(sd, packet))
  ------------------
  |  Branch (475:13): [True: 3.83k, False: 0]
  |  Branch (475:45): [True: 2, False: 3.83k]
  ------------------
  476|      2|            return;
  477|       |
  478|  3.83k|        double sub_pts = 0;
  479|  3.83k|        double sub_duration = 0;
  480|  3.83k|        char **r = lavc_conv_decode(ctx->converter, packet, &sub_pts,
  481|  3.83k|                                    &sub_duration);
  482|  3.83k|        if (sd->opts->sub_stretch_durations ||
  ------------------
  |  Branch (482:13): [True: 0, False: 3.83k]
  ------------------
  483|  3.83k|            packet->duration < 0 || sub_duration == UINT32_MAX) {
  ------------------
  |  Branch (483:13): [True: 3.83k, False: 0]
  |  Branch (483:37): [True: 0, False: 0]
  ------------------
  484|  3.83k|            MP_VERBOSE(sd, "Subtitle with unknown duration.\n");
  ------------------
  |  |   92|  3.83k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  3.83k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  485|  3.83k|            sub_duration = UNKNOWN_DURATION;
  ------------------
  |  |  465|  3.83k|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  486|  3.83k|        }
  487|       |
  488|  7.66k|        for (int n = 0; r && r[n]; n++) {
  ------------------
  |  Branch (488:25): [True: 7.66k, False: 0]
  |  Branch (488:30): [True: 3.83k, False: 3.83k]
  ------------------
  489|  3.83k|            struct demux_packet pkt2 = {
  490|  3.83k|                .pts = sub_pts,
  491|  3.83k|                .duration = sub_duration,
  492|  3.83k|                .buffer = r[n],
  493|  3.83k|                .len = strlen(r[n]),
  494|  3.83k|            };
  495|  3.83k|            filter_and_add(sd, &pkt2);
  496|  3.83k|        }
  497|  7.66k|        for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (497:43): [True: 3.83k, False: 3.83k]
  ------------------
  498|  3.83k|            if (track->events[track->n_events - 1].Start == track->events[n].Start)
  ------------------
  |  Branch (498:17): [True: 3.83k, False: 0]
  ------------------
  499|  3.83k|                continue;
  500|      0|            if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
  ------------------
  |  |  465|      0|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  |  Branch (500:17): [True: 0, False: 0]
  ------------------
  501|      0|                if (track->events[n].Start < track->events[n + 1].Start) {
  ------------------
  |  Branch (501:21): [True: 0, False: 0]
  ------------------
  502|      0|                    track->events[n].Duration = track->events[n + 1].Start -
  503|      0|                                                track->events[n].Start;
  504|      0|                } else if (track->events[n].Start == track->events[n + 1].Start) {
  ------------------
  |  Branch (504:28): [True: 0, False: 0]
  ------------------
  505|      0|                    track->events[n].Duration = track->events[n + 1].Duration;
  506|      0|                }
  507|      0|            }
  508|      0|            if (n > 0 && track->events[n].Start != track->events[n - 1].Start)
  ------------------
  |  Branch (508:17): [True: 0, False: 0]
  |  Branch (508:26): [True: 0, False: 0]
  ------------------
  509|      0|                break;
  510|      0|        }
  511|  3.83k|    } 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|      0|        packet->seen = check_packet_seen(sd, packet);
  516|      0|        filter_and_add(sd, packet);
  517|      0|    }
  518|  3.83k|}
sd_ass.c:check_packet_seen:
  439|  3.83k|{
  440|  3.83k|    struct sd_ass_priv *priv = sd->priv;
  441|  3.83k|    int64_t sig = packet->pos >= 0 ? packet->pos
  ------------------
  |  Branch (441:19): [True: 3.83k, False: 0]
  ------------------
  442|  3.83k|                                   : hash_data(packet->buffer, packet->len);
  443|  3.83k|    int a = 0;
  444|  3.83k|    int b = priv->num_seen_packets;
  445|  3.83k|    while (a < b) {
  ------------------
  |  Branch (445:12): [True: 2, False: 3.83k]
  ------------------
  446|      2|        int mid = a + (b - a) / 2;
  447|      2|        struct seen_packet *seen_packet = &priv->seen_packets[mid];
  448|      2|        if (sig == seen_packet->sig && packet->pts == seen_packet->pts) {
  ------------------
  |  Branch (448:13): [True: 2, False: 0]
  |  Branch (448:40): [True: 2, False: 0]
  ------------------
  449|      2|            packet->seen_pos = mid;
  450|      2|            return true;
  451|      2|        }
  452|      0|        if (sig > seen_packet->sig ||
  ------------------
  |  Branch (452:13): [True: 0, False: 0]
  ------------------
  453|      0|            (sig == seen_packet->sig && packet->pts > seen_packet->pts)) {
  ------------------
  |  Branch (453:14): [True: 0, False: 0]
  |  Branch (453:41): [True: 0, False: 0]
  ------------------
  454|      0|            a = mid + 1;
  455|      0|        } else {
  456|      0|            b = mid;
  457|      0|        }
  458|      0|    }
  459|  3.83k|    packet->seen_pos = a;
  460|  3.83k|    MP_TARRAY_INSERT_AT(priv, priv->seen_packets, priv->num_seen_packets, a,
  ------------------
  |  |  115|  3.83k|    do {                                            \
  |  |  116|  3.83k|        size_t at_ = (at);                          \
  |  |  117|  3.83k|        assert(at_ <= (idxvar));                    \
  |  |  118|  3.83k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  3.83k|    do {                                            \
  |  |  |  |   97|  3.83k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  3.83k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.83k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  3.83k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 3.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  3.83k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  3.83k|    do {                                                        \
  |  |  |  |  |  |   89|  3.83k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  3.83k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  3.83k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.83k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.83k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  3.83k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  3.83k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 3.83k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  3.83k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 3.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  3.83k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  3.83k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  3.83k|        (idxvar)++;                                 \
  |  |  122|  3.83k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  3.83k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 3.83k]
  |  |  ------------------
  ------------------
  |  Branch (460:5): [True: 3.83k, False: 0]
  ------------------
  461|  3.83k|                        (struct seen_packet){sig, packet->pts, -1});
  462|  3.83k|    return false;
  463|  3.83k|}
sd_ass.c:filter_and_add:
  371|  3.83k|{
  372|  3.83k|    struct sd_ass_priv *ctx = sd->priv;
  373|  3.83k|    struct demux_packet *orig_pkt = pkt;
  374|  3.83k|    ASS_Track *track = ctx->ass_track;
  375|  3.83k|    int old_n_events = track->n_events;
  376|       |
  377|  3.83k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (377:21): [True: 0, False: 3.83k]
  ------------------
  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|  3.83k|    ass_process_chunk(ctx->ass_track, pkt->buffer, pkt->len,
  388|  3.83k|                      floor(pkt->pts * 1000 + 1e-6),
  389|  3.83k|                      floor(pkt->duration * 1000 + 1e-6));
  390|  3.83k|    if (pkt != orig_pkt)
  ------------------
  |  Branch (390:9): [True: 0, False: 3.83k]
  ------------------
  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|  3.83k|    pkt = orig_pkt;
  394|       |
  395|       |    // This bookkeeping only has any practical use for ASS subs
  396|       |    // over a VO with no video.
  397|  3.83k|    if (!ctx->is_converted) {
  ------------------
  |  Branch (397:9): [True: 0, False: 3.83k]
  ------------------
  398|      0|        if (!pkt->seen) {
  ------------------
  |  Branch (398:13): [True: 0, False: 0]
  ------------------
  399|      0|            for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (399:47): [True: 0, False: 0]
  ------------------
  400|      0|                if (n + 1 == old_n_events || pkt->animated == 1)
  ------------------
  |  Branch (400:21): [True: 0, False: 0]
  |  Branch (400:46): [True: 0, False: 0]
  ------------------
  401|      0|                    break;
  402|      0|                ASS_Event *event = &track->events[n];
  403|       |                // Might as well mark pkt->animated here with effects if we can.
  404|      0|                pkt->animated = (event->Effect && event->Effect[0]) ? 1 : -1;
  ------------------
  |  Branch (404:34): [True: 0, False: 0]
  |  Branch (404:51): [True: 0, False: 0]
  ------------------
  405|      0|                if (ctx->check_animated && pkt->animated != 1)
  ------------------
  |  Branch (405:21): [True: 0, False: 0]
  |  Branch (405:44): [True: 0, False: 0]
  ------------------
  406|      0|                    pkt->animated = is_animated(event->Text);
  407|      0|            }
  408|      0|            ctx->seen_packets[pkt->seen_pos].animated = pkt->animated;
  409|      0|        } else {
  410|      0|            if (ctx->check_animated && ctx->seen_packets[pkt->seen_pos].animated == -1) {
  ------------------
  |  Branch (410:17): [True: 0, False: 0]
  |  Branch (410:40): [True: 0, False: 0]
  ------------------
  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|      0|            } else {
  419|      0|                pkt->animated = ctx->seen_packets[pkt->seen_pos].animated;
  420|      0|            }
  421|      0|        }
  422|      0|    }
  423|  3.83k|}
sd_ass.c:reset:
 1008|   171k|{
 1009|   171k|    struct sd_ass_priv *ctx = sd->priv;
 1010|   171k|    if (sd->opts->sub_clear_on_seek || ctx->clear_once) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 171k]
  |  Branch (1010:40): [True: 0, False: 171k]
  ------------------
 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|   171k|    if (ctx->converter)
  ------------------
  |  Branch (1016:9): [True: 171k, False: 0]
  ------------------
 1017|   171k|        lavc_conv_reset(ctx->converter);
 1018|   171k|}
sd_ass.c:enable_output:
  233|  19.0k|{
  234|  19.0k|    struct sd_ass_priv *ctx = sd->priv;
  235|  19.0k|    if (enable == !!ctx->ass_renderer)
  ------------------
  |  Branch (235:9): [True: 9.53k, False: 9.53k]
  ------------------
  236|  9.53k|        return;
  237|  9.53k|    if (ctx->ass_renderer) {
  ------------------
  |  Branch (237:9): [True: 4.76k, False: 4.76k]
  ------------------
  238|  4.76k|        ass_renderer_done(ctx->ass_renderer);
  239|  4.76k|        ctx->ass_renderer = NULL;
  240|  4.76k|    } else {
  241|  4.76k|        ctx->ass_renderer = ass_renderer_init(ctx->ass_library);
  242|       |
  243|  4.76k|        mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_style,
  244|  4.76k|                               sd->global, sd->log);
  245|  4.76k|    }
  246|  9.53k|}
sd_ass.c:uninit:
 1021|  4.76k|{
 1022|  4.76k|    struct sd_ass_priv *ctx = sd->priv;
 1023|       |
 1024|  4.76k|    filters_destroy(sd);
 1025|  4.76k|    if (ctx->converter)
  ------------------
  |  Branch (1025:9): [True: 4.76k, False: 0]
  ------------------
 1026|  4.76k|        lavc_conv_uninit(ctx->converter);
 1027|  4.76k|    assobjects_destroy(sd);
 1028|  4.76k|    talloc_free(ctx->copy_cache);
  ------------------
  |  |   47|  4.76k|#define talloc_free                     ta_free
  ------------------
 1029|  4.76k|}
sd_ass.c:assobjects_destroy:
  294|  4.76k|{
  295|  4.76k|    struct sd_ass_priv *ctx = sd->priv;
  296|       |
  297|  4.76k|    ass_free_track(ctx->ass_track);
  298|  4.76k|    ass_free_track(ctx->shadow_track);
  299|       |    enable_output(sd, false);
  300|  4.76k|    ass_library_done(ctx->ass_library);
  301|  4.76k|}
sd_ass.c:control:
 1070|  1.29M|{
 1071|  1.29M|    struct sd_ass_priv *ctx = sd->priv;
 1072|  1.29M|    switch (cmd) {
 1073|     27|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (1073:5): [True: 27, False: 1.29M]
  ------------------
 1074|     27|        double *a = arg;
 1075|     27|        long long ts = floor(a[0] * 1000.0 + 1e-6);
 1076|     27|        long long res = ass_step_sub(ctx->ass_track, ts, a[1]);
 1077|     27|        if (!res)
  ------------------
  |  Branch (1077:13): [True: 17, False: 10]
  ------------------
 1078|     17|            return false;
 1079|       |        // Try to account for overlapping durations
 1080|     10|        a[0] += res / 1000.0 + SUB_SEEK_OFFSET;
  ------------------
  |  |    9|     10|#define SUB_SEEK_OFFSET 0.01
  ------------------
 1081|     10|        return true;
 1082|     27|    }
 1083|   669k|    case SD_CTRL_SET_ANIMATED_CHECK:
  ------------------
  |  Branch (1083:5): [True: 669k, False: 626k]
  ------------------
 1084|   669k|        ctx->check_animated = *(bool *)arg;
 1085|   669k|        return CONTROL_OK;
  ------------------
  |  |   95|   669k|#define CONTROL_OK 1
  ------------------
 1086|      0|    case SD_CTRL_RESET_SOFT:
  ------------------
  |  Branch (1086:5): [True: 0, False: 1.29M]
  ------------------
 1087|      0|        ctx->clear_once = true;
 1088|      0|        reset(sd);
 1089|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
 1090|   626k|    case SD_CTRL_SET_VIDEO_PARAMS:
  ------------------
  |  Branch (1090:5): [True: 626k, False: 669k]
  ------------------
 1091|   626k|        ctx->video_params = *(struct mp_image_params *)arg;
 1092|   626k|        return CONTROL_OK;
  ------------------
  |  |   95|   626k|#define CONTROL_OK 1
  ------------------
 1093|    264|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (1093:5): [True: 264, False: 1.29M]
  ------------------
 1094|    264|        uint64_t flags = *(uint64_t *)arg;
 1095|    264|        if (flags & UPDATE_SUB_FILT) {
  ------------------
  |  |  443|    264|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
  |  Branch (1095:13): [True: 0, False: 264]
  ------------------
 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|    264|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|    264|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (1101:13): [True: 0, False: 264]
  ------------------
 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|    264|        ctx->ass_configured = false; // ass always needs to be reconfigured
 1109|    264|        return CONTROL_OK;
  ------------------
  |  |   95|    264|#define CONTROL_OK 1
  ------------------
 1110|     27|    }
 1111|      0|    default:
  ------------------
  |  Branch (1111:5): [True: 0, False: 1.29M]
  ------------------
 1112|      0|        return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1113|  1.29M|    }
 1114|  1.29M|}
sd_ass.c:get_bitmaps:
  740|  5.48k|{
  741|  5.48k|    struct sd_ass_priv *ctx = sd->priv;
  742|  5.48k|    struct mp_subtitle_opts *opts = sd->opts;
  743|  5.48k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  744|  5.48k|    bool no_ass = !opts->ass_enabled ||
  ------------------
  |  Branch (744:19): [True: 0, False: 5.48k]
  ------------------
  745|  5.48k|        shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_STRIP;
  ------------------
  |  Branch (745:9): [True: 0, False: 5.48k]
  ------------------
  746|  5.48k|    bool converted = (ctx->is_converted && !lavc_conv_is_styled(ctx->converter)) || no_ass;
  ------------------
  |  Branch (746:23): [True: 5.48k, False: 0]
  |  Branch (746:44): [True: 5.48k, False: 0]
  |  Branch (746:85): [True: 0, False: 0]
  ------------------
  747|  5.48k|    ASS_Track *track = no_ass ? ctx->shadow_track : ctx->ass_track;
  ------------------
  |  Branch (747:24): [True: 0, False: 5.48k]
  ------------------
  748|  5.48k|    ASS_Renderer *renderer = ctx->ass_renderer;
  749|  5.48k|    struct sub_bitmaps *res = &(struct sub_bitmaps){0};
  750|       |
  751|       |    // Always update the osd_res
  752|  5.48k|    struct mp_osd_res old_osd = ctx->osd;
  753|  5.48k|    ctx->osd = dim;
  754|       |
  755|  5.48k|    if (pts == MP_NOPTS_VALUE || !renderer)
  ------------------
  |  |   39|  10.9k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (755:9): [True: 1.21k, False: 4.26k]
  |  Branch (755:34): [True: 0, False: 4.26k]
  ------------------
  756|  1.21k|        goto done;
  757|       |
  758|       |    // Currently no supported text sub formats support a distinction between forced
  759|       |    // and unforced lines, so we just assume everything's unforced and discard everything.
  760|       |    // If we ever see a format that makes this distinction, we can add support here.
  761|  4.26k|    if (opts->sub_forced_events_only)
  ------------------
  |  Branch (761:9): [True: 104, False: 4.16k]
  ------------------
  762|    104|        goto done;
  763|       |
  764|  4.16k|    double scale = dim.display_par;
  765|  4.16k|    if (!converted && (!shared_opts->ass_style_override[sd->order] ||
  ------------------
  |  Branch (765:9): [True: 0, False: 4.16k]
  |  Branch (765:24): [True: 0, False: 0]
  ------------------
  766|      0|                       opts->ass_use_video_data >= 1))
  ------------------
  |  Branch (766:24): [True: 0, False: 0]
  ------------------
  767|      0|    {
  768|       |        // Let's factor in video PAR for vsfilter compatibility:
  769|      0|        double par = opts->ass_video_aspect > 0 ?
  ------------------
  |  Branch (769:22): [True: 0, False: 0]
  ------------------
  770|      0|                opts->ass_video_aspect :
  771|      0|                ctx->video_params.p_w / (double)ctx->video_params.p_h;
  772|      0|        if (isnormal(par))
  ------------------
  |  Branch (772:13): [True: 0, False: 0]
  ------------------
  773|      0|            scale *= par;
  774|      0|    }
  775|  4.16k|    if (!ctx->ass_configured || !osd_res_equals(old_osd, ctx->osd)) {
  ------------------
  |  Branch (775:9): [True: 376, False: 3.78k]
  |  Branch (775:33): [True: 0, False: 3.78k]
  ------------------
  776|    376|        configure_ass(sd, &dim, converted, track);
  777|    376|        ctx->ass_configured = true;
  778|    376|    }
  779|  4.16k|    ass_set_pixel_aspect(renderer, scale);
  780|  4.16k|    if (!converted && (!shared_opts->ass_style_override[sd->order] ||
  ------------------
  |  Branch (780:9): [True: 0, False: 4.16k]
  |  Branch (780:24): [True: 0, False: 0]
  ------------------
  781|      0|                       opts->ass_use_video_data >= 2))
  ------------------
  |  Branch (781:24): [True: 0, False: 0]
  ------------------
  782|      0|    {
  783|      0|        ass_set_storage_size(renderer, ctx->video_params.w, ctx->video_params.h);
  784|  4.16k|    } else {
  785|  4.16k|        ass_set_storage_size(renderer, 0, 0);
  786|  4.16k|    }
  787|  4.16k|    long long ts = find_timestamp(sd, pts);
  788|       |
  789|  4.16k|    if (no_ass)
  ------------------
  |  Branch (789:9): [True: 0, False: 4.16k]
  ------------------
  790|      0|        fill_plaintext(sd, pts);
  791|       |
  792|  4.16k|    int changed;
  793|  4.16k|    ASS_Image *imgs = ass_render_frame(renderer, track, ts, &changed);
  794|  4.16k|    mp_sub_packer_pack_ass(ctx->packer, &imgs, 1, changed, !converted, format, res);
  795|       |
  796|  5.48k|done:
  797|       |    // mangle_colors() modifies the color field, so copy the thing _before_.
  798|  5.48k|    res = sub_bitmaps_copy(&ctx->copy_cache, res);
  799|       |
  800|  5.48k|    if (!converted && res)
  ------------------
  |  Branch (800:9): [True: 0, False: 5.48k]
  |  Branch (800:23): [True: 0, False: 0]
  ------------------
  801|      0|        mangle_colors(sd, res);
  802|       |
  803|  5.48k|    return res;
  804|  4.16k|}
sd_ass.c:configure_ass:
  537|    376|{
  538|    376|    struct mp_subtitle_opts *opts = sd->opts;
  539|    376|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  540|    376|    struct sd_ass_priv *ctx = sd->priv;
  541|    376|    ASS_Renderer *priv = ctx->ass_renderer;
  542|       |
  543|    376|    ass_set_frame_size(priv, dim->w, dim->h);
  544|    376|    ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr);
  545|       |
  546|    376|    bool set_use_margins = false;
  547|    376|    float set_sub_pos = 0.0f;
  548|    376|    float set_line_spacing = 0;
  549|    376|    float set_font_scale = 1;
  550|    376|    int set_hinting = 0;
  551|    376|    bool set_scale_with_window = false;
  552|    376|    bool set_scale_by_window = true;
  553|    376|    bool total_override = false;
  554|       |
  555|       |    // With forced overrides, apply the --sub-* specific options
  556|    376|    if (converted || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_FORCE) {
  ------------------
  |  Branch (556:9): [True: 376, False: 0]
  |  Branch (556:22): [True: 0, False: 0]
  ------------------
  557|    376|        set_scale_with_window = opts->sub_scale_with_window;
  558|    376|        set_use_margins = opts->sub_use_margins;
  559|    376|        set_scale_by_window = opts->sub_scale_by_window;
  560|    376|        total_override = true;
  561|    376|    } else {
  562|      0|        set_scale_with_window = opts->ass_scale_with_window;
  563|      0|        set_use_margins = opts->ass_use_margins;
  564|      0|    }
  565|    376|    if (converted || shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (565:9): [True: 376, False: 0]
  |  Branch (565:22): [True: 0, False: 0]
  ------------------
  566|    376|        set_sub_pos = 100.0f - shared_opts->sub_pos[sd->order];
  567|    376|        set_line_spacing = opts->sub_line_spacing;
  568|    376|        set_hinting = opts->sub_hinting;
  569|    376|    }
  570|    376|    if (total_override || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE) {
  ------------------
  |  Branch (570:9): [True: 376, False: 0]
  |  Branch (570:27): [True: 0, False: 0]
  ------------------
  571|    376|        set_font_scale = shared_opts->sub_scale[sd->order];
  572|    376|    }
  573|    376|    if (set_scale_with_window) {
  ------------------
  |  Branch (573:9): [True: 376, False: 0]
  ------------------
  574|    376|        set_font_scale *= dim->h / MPMAX(get_libass_scale_height(dim, set_use_margins), 1);
  ------------------
  |  |   44|    376|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 376, False: 0]
  |  |  ------------------
  ------------------
  575|    376|    }
  576|    376|    if (!set_scale_by_window) {
  ------------------
  |  Branch (576:9): [True: 0, False: 376]
  ------------------
  577|      0|        double factor = dim->h / 720.0;
  578|      0|        if (factor != 0.0)
  ------------------
  |  Branch (578:13): [True: 0, False: 0]
  ------------------
  579|      0|            set_font_scale /= factor;
  580|      0|    }
  581|    376|    ass_set_use_margins(priv, set_use_margins);
  582|    376|    ass_set_line_position(priv, set_sub_pos);
  583|    376|    ass_set_shaper(priv, opts->sub_shaper);
  584|    376|    int set_force_flags = 0;
  585|    376|    if (total_override) {
  ------------------
  |  Branch (585:9): [True: 376, False: 0]
  ------------------
  586|    376|        set_force_flags |= ASS_OVERRIDE_BIT_FONT_NAME
  587|    376|                            | ASS_OVERRIDE_BIT_FONT_SIZE_FIELDS
  588|    376|                            | ASS_OVERRIDE_BIT_COLORS
  589|    376|                            | ASS_OVERRIDE_BIT_BORDER;
  590|    376|        if (!opts->sub_scale_signs)
  ------------------
  |  Branch (590:13): [True: 376, False: 0]
  ------------------
  591|    376|            set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
  592|    376|#if LIBASS_VERSION >= 0x01703020
  593|    376|        set_force_flags |= ASS_OVERRIDE_BIT_BLUR;
  594|    376|#endif
  595|    376|    }
  596|    376|    if (shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE &&
  ------------------
  |  Branch (596:9): [True: 376, False: 0]
  ------------------
  597|    376|        !opts->sub_scale_signs)
  ------------------
  |  Branch (597:9): [True: 376, False: 0]
  ------------------
  598|    376|        set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
  599|    376|    if (converted)
  ------------------
  |  Branch (599:9): [True: 376, False: 0]
  ------------------
  600|    376|        set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT;
  601|    376|#if LIBASS_VERSION >= 0x01306000
  602|    376|    if ((converted || shared_opts->ass_style_override[sd->order]) && opts->ass_justify)
  ------------------
  |  Branch (602:10): [True: 376, False: 0]
  |  Branch (602:23): [True: 0, False: 0]
  |  Branch (602:70): [True: 0, False: 376]
  ------------------
  603|      0|        set_force_flags |= ASS_OVERRIDE_BIT_JUSTIFY;
  604|    376|#endif
  605|    376|    ass_set_selective_style_override_enabled(priv, set_force_flags);
  606|    376|    ASS_Style style = {0};
  607|    376|    mp_ass_set_style(&style, MP_ASS_FONT_PLAYRESY, opts->sub_style);
  ------------------
  |  |   32|    376|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  608|    376|    ass_set_selective_style_override(priv, &style);
  609|    376|    free(style.FontName);
  610|    376|    if (converted && track->default_style < track->n_styles) {
  ------------------
  |  Branch (610:9): [True: 376, False: 0]
  |  Branch (610:22): [True: 376, False: 0]
  ------------------
  611|    376|        mp_ass_set_style(track->styles + track->default_style,
  612|    376|                         track->PlayResY, opts->sub_style);
  613|    376|    }
  614|    376|    ass_set_font_scale(priv, set_font_scale);
  615|    376|    ass_set_hinting(priv, set_hinting);
  616|    376|    ass_set_line_spacing(priv, set_line_spacing);
  617|    376|#if LIBASS_VERSION >= 0x01600010
  618|    376|    if (converted) {
  ------------------
  |  Branch (618:9): [True: 376, False: 0]
  ------------------
  619|    376|        ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
  620|    376|        if (!opts->sub_vsfilter_bidi_compat) {
  ------------------
  |  Branch (620:13): [True: 376, False: 0]
  ------------------
  621|  1.12k|            for (int n = 0; n < track->n_styles; n++) {
  ------------------
  |  Branch (621:29): [True: 752, False: 376]
  ------------------
  622|    752|                track->styles[n].Encoding = -1;
  623|    752|            }
  624|    376|            ass_track_set_feature(track, ASS_FEATURE_BIDI_BRACKETS, 1);
  625|    376|            ass_track_set_feature(track, ASS_FEATURE_WHOLE_TEXT_LAYOUT, 1);
  626|    376|        }
  627|    376|    }
  628|    376|#endif
  629|    376|    if (converted) {
  ------------------
  |  Branch (629:9): [True: 376, False: 0]
  ------------------
  630|    376|        bool override_playres = true;
  631|    376|        char **ass_style_override_list = opts->ass_style_override_list;
  632|    376|        for (int i = 0; ass_style_override_list && ass_style_override_list[i]; i++) {
  ------------------
  |  Branch (632:25): [True: 0, False: 376]
  |  Branch (632:52): [True: 0, False: 0]
  ------------------
  633|      0|            if (bstr_find0(bstr0(ass_style_override_list[i]), "PlayResX") >= 0)
  ------------------
  |  Branch (633:17): [True: 0, False: 0]
  ------------------
  634|      0|                override_playres = false;
  635|      0|        }
  636|       |
  637|       |        // srt to ass conversion from ffmpeg has fixed PlayResX of 384 with an
  638|       |        // aspect of 4:3. Starting with libass f08f8ea5 (pre 0.17) PlayResX
  639|       |        // affects shadow and border widths, among others, so to render borders
  640|       |        // and shadows correctly, we adjust PlayResX according to the DAR.
  641|       |        // But PlayResX also affects margins, so we adjust those too.
  642|       |        // This should ensure basic srt-to-ass ffmpeg conversion has correct
  643|       |        // borders, but there could be other issues with some srt extensions
  644|       |        // and/or different source formats which would be exposed over time.
  645|       |        // Make these adjustments only if the user didn't set PlayResX.
  646|    376|        if (override_playres) {
  ------------------
  |  Branch (646:13): [True: 376, False: 0]
  ------------------
  647|    376|            int vidw = dim->w - (dim->ml + dim->mr);
  648|    376|            int vidh = dim->h - (dim->mt + dim->mb);
  649|    376|            track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
  ------------------
  |  |   44|    376|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 376, False: 0]
  |  |  ------------------
  ------------------
  650|       |            // ffmpeg and mpv use a default PlayResX of 384 when it is not known,
  651|       |            // this comes from VSFilter.
  652|    376|            double fix_margins = track->PlayResX / (double)MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|    376|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  653|  1.12k|            for (int n = 0; n < track->n_styles; n++) {
  ------------------
  |  Branch (653:29): [True: 752, False: 376]
  ------------------
  654|    752|                track->styles[n].MarginL = lrint(track->styles[n].MarginL * fix_margins);
  655|    752|                track->styles[n].MarginR = lrint(track->styles[n].MarginR * fix_margins);
  656|    752|                track->styles[n].MarginV = lrint(track->styles[n].MarginV * set_font_scale);
  657|    752|            }
  658|    376|        }
  659|    376|    }
  660|    376|}
sd_ass.c:get_libass_scale_height:
  526|    752|{
  527|    752|    float vidw = dim->w - (dim->ml + dim->mr);
  528|    752|    float vidh = dim->h - (dim->mt + dim->mb);
  529|    752|    if (!use_margins || vidw < 1.0)
  ------------------
  |  Branch (529:9): [True: 0, False: 752]
  |  Branch (529:25): [True: 0, False: 752]
  ------------------
  530|      0|        return vidh;
  531|    752|    else
  532|    752|        return MPMIN(dim->h, dim->w / vidw * vidh);
  ------------------
  |  |   45|    752|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 752]
  |  |  ------------------
  ------------------
  533|    752|}
sd_ass.c:find_timestamp:
  673|  6.50k|{
  674|  6.50k|    struct sd_ass_priv *priv = sd->priv;
  675|  6.50k|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  6.50k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (675:9): [True: 0, False: 6.50k]
  ------------------
  676|      0|        return 0;
  677|       |
  678|  6.50k|    long long ts = floor(pts * 1000 + 1e-6);
  679|       |
  680|  6.50k|    if (!sd->opts->sub_fix_timing ||
  ------------------
  |  Branch (680:9): [True: 6.50k, False: 0]
  ------------------
  681|      0|        sd->shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_NONE)
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  ------------------
  682|  6.50k|        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|  25.4k|{
  871|  25.4k|    struct sd_ass_priv *ctx = sd->priv;
  872|  25.4k|    ASS_Track *track = ctx->ass_track;
  873|       |
  874|  25.4k|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  25.4k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (874:9): [True: 23.2k, False: 2.22k]
  ------------------
  875|  23.2k|        return (bstr){0};
  876|  2.22k|    long long ipts = find_timestamp(sd, pts);
  877|       |
  878|  2.22k|    bstr *b = &ctx->last_text;
  879|       |
  880|  2.22k|    if (!b->start)
  ------------------
  |  Branch (880:9): [True: 267, False: 1.95k]
  ------------------
  881|    267|        b->start = talloc_size(ctx, 4096);
  ------------------
  |  |   43|    267|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|    267|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    267|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    267|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    267|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    267|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  882|       |
  883|  2.22k|    b->len = 0;
  884|       |
  885|  4.01k|    for (int i = 0; i < track->n_events; ++i) {
  ------------------
  |  Branch (885:21): [True: 1.78k, False: 2.22k]
  ------------------
  886|  1.78k|        ASS_Event *event = track->events + i;
  887|  1.78k|        if (ipts >= event->Start && ipts < event->Start + event->Duration) {
  ------------------
  |  Branch (887:13): [True: 880, False: 909]
  |  Branch (887:37): [True: 880, False: 0]
  ------------------
  888|    880|            if (event->Text) {
  ------------------
  |  Branch (888:17): [True: 880, False: 0]
  ------------------
  889|    880|                int start = b->len;
  890|    880|                if (type == SD_TEXT_TYPE_PLAIN) {
  ------------------
  |  Branch (890:21): [True: 880, False: 0]
  ------------------
  891|    880|                    ass_to_plaintext(b, event->Text);
  892|    880|                } 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|    880|                if (is_whitespace_only(bstr_cut(*b, start))) {
  ------------------
  |  Branch (917:21): [True: 0, False: 880]
  ------------------
  918|      0|                    b->len = start;
  919|    880|                } else {
  920|    880|                    append(b, '\n');
  921|    880|                }
  922|    880|            }
  923|    880|        }
  924|  1.78k|    }
  925|       |
  926|  2.22k|    bstr_eatend(b, (bstr)bstr0_lit("\n"));
  ------------------
  |  |   59|  2.22k|#define bstr0_lit(s) {(unsigned char *)(s), sizeof("" s) - 1}
  ------------------
  927|       |
  928|  2.22k|    return *b;
  929|  25.4k|}
sd_ass.c:is_whitespace_only:
  861|    880|{
  862|    880|    for (int n = 0; n < b.len; n++) {
  ------------------
  |  Branch (862:21): [True: 880, False: 0]
  ------------------
  863|    880|        if (b.start[n] != ' ' && b.start[n] != '\t')
  ------------------
  |  Branch (863:13): [True: 880, False: 0]
  |  Branch (863:34): [True: 880, False: 0]
  ------------------
  864|    880|            return false;
  865|    880|    }
  866|      0|    return true;
  867|    880|}
sd_ass.c:append:
  810|  18.1k|{
  811|       |    bstr_xappend(NULL, b, (bstr){&c, 1});
  812|  18.1k|}
sd_ass.c:get_text:
  932|  25.4k|{
  933|       |    return bstrto0(NULL, get_text_buf(sd, pts, type));
  934|  25.4k|}
sd_ass.c:get_times:
  937|    122|{
  938|    122|    struct sd_ass_priv *ctx = sd->priv;
  939|    122|    ASS_Track *track = ctx->ass_track;
  940|    122|    struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    122|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
  ------------------
  |  |   39|    122|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  941|       |
  942|    122|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|    122|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (942:9): [True: 0, False: 122]
  ------------------
  943|      0|        return res;
  944|       |
  945|    122|    long long ipts = find_timestamp(sd, pts);
  946|       |
  947|    224|    for (int i = 0; i < track->n_events; ++i) {
  ------------------
  |  Branch (947:21): [True: 102, False: 122]
  ------------------
  948|    102|        ASS_Event *event = track->events + i;
  949|    102|        if (ipts >= event->Start && ipts < event->Start + event->Duration) {
  ------------------
  |  Branch (949:13): [True: 90, False: 12]
  |  Branch (949:37): [True: 90, False: 0]
  ------------------
  950|     90|            double start = event->Start / 1000.0;
  951|     90|            double end = event->Duration == UNKNOWN_DURATION ?
  ------------------
  |  |  465|     90|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  |  Branch (951:26): [True: 0, False: 90]
  ------------------
  952|     90|                MP_NOPTS_VALUE : (event->Start + event->Duration) / 1000.0;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  953|       |
  954|     90|            if (res.start == MP_NOPTS_VALUE || res.start > start)
  ------------------
  |  |   39|    180|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (954:17): [True: 90, False: 0]
  |  Branch (954:48): [True: 0, False: 0]
  ------------------
  955|     90|                res.start = start;
  956|       |
  957|     90|            if (res.end == MP_NOPTS_VALUE || res.end < end)
  ------------------
  |  |   39|    180|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (957:17): [True: 90, False: 0]
  |  Branch (957:46): [True: 0, False: 0]
  ------------------
  958|     90|                res.end = end;
  959|     90|        }
  960|    102|    }
  961|       |
  962|    122|    return res;
  963|    122|}
sd_ass.c:ass_to_plaintext:
  815|    880|{
  816|    880|    const char *open_tag_pos = NULL;
  817|    880|    bool in_drawing = false;
  818|  19.1k|    while (*in) {
  ------------------
  |  Branch (818:12): [True: 18.2k, False: 880]
  ------------------
  819|  18.2k|        if (open_tag_pos) {
  ------------------
  |  Branch (819:13): [True: 648, False: 17.6k]
  ------------------
  820|    648|            if (in[0] == '}') {
  ------------------
  |  Branch (820:17): [True: 324, False: 324]
  ------------------
  821|    324|                in += 1;
  822|    324|                open_tag_pos = NULL;
  823|    324|            } else if (in[0] == '\\' && in[1] == 'p' && in[2] != 'o') {
  ------------------
  |  Branch (823:24): [True: 0, False: 324]
  |  Branch (823:41): [True: 0, False: 0]
  |  Branch (823:57): [True: 0, False: 0]
  ------------------
  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|    324|            } else {
  834|    324|                in += 1;
  835|    324|            }
  836|  17.6k|        } else {
  837|  17.6k|            if (in[0] == '\\' && (in[1] == 'N' || in[1] == 'n')) {
  ------------------
  |  Branch (837:17): [True: 364, False: 17.2k]
  |  Branch (837:35): [True: 38, False: 326]
  |  Branch (837:51): [True: 0, False: 326]
  ------------------
  838|     38|                in += 2;
  839|     38|                append(b, '\n');
  840|  17.5k|            } else if (in[0] == '\\' && in[1] == 'h') {
  ------------------
  |  Branch (840:24): [True: 326, False: 17.2k]
  |  Branch (840:41): [True: 0, False: 326]
  ------------------
  841|      0|                in += 2;
  842|      0|                append(b, ' ');
  843|  17.5k|            } else if (in[0] == '{') {
  ------------------
  |  Branch (843:24): [True: 324, False: 17.2k]
  ------------------
  844|    324|                open_tag_pos = in;
  845|    324|                in += 1;
  846|  17.2k|            } else {
  847|  17.2k|                if (!in_drawing)
  ------------------
  |  Branch (847:21): [True: 17.2k, False: 0]
  ------------------
  848|  17.2k|                    append(b, in[0]);
  849|  17.2k|                in += 1;
  850|  17.2k|            }
  851|  17.6k|        }
  852|  18.2k|    }
  853|       |    // A '{' without a closing '}' is always visible.
  854|    880|    if (open_tag_pos) {
  ------------------
  |  Branch (854:9): [True: 0, False: 880]
  ------------------
  855|       |        bstr_xappend(NULL, b, bstr0(open_tag_pos));
  856|      0|    }
  857|    880|}

sd_lavc.c:init:
   82|  4.76k|{
   83|  4.76k|    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|  4.76k|    switch (cid) {
   87|      0|    case AV_CODEC_ID_DVB_SUBTITLE:
  ------------------
  |  Branch (87:5): [True: 0, False: 4.76k]
  ------------------
   88|      0|    case AV_CODEC_ID_DVB_TELETEXT:
  ------------------
  |  Branch (88:5): [True: 0, False: 4.76k]
  ------------------
   89|      0|    case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
  ------------------
  |  Branch (89:5): [True: 0, False: 4.76k]
  ------------------
   90|      0|    case AV_CODEC_ID_XSUB:
  ------------------
  |  Branch (90:5): [True: 0, False: 4.76k]
  ------------------
   91|      0|    case AV_CODEC_ID_DVD_SUBTITLE:
  ------------------
  |  Branch (91:5): [True: 0, False: 4.76k]
  ------------------
   92|      0|    case AV_CODEC_ID_ARIB_CAPTION:
  ------------------
  |  Branch (92:5): [True: 0, False: 4.76k]
  ------------------
   93|      0|        break;
   94|  4.76k|    default:
  ------------------
  |  Branch (94:5): [True: 4.76k, False: 0]
  ------------------
   95|  4.76k|        return -1;
   96|  4.76k|    }
   97|       |
   98|      0|    struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|      0|    AVCodecContext *ctx = NULL;
  100|      0|    const AVCodec *sub_codec = avcodec_find_decoder(cid);
  101|      0|    if (!sub_codec)
  ------------------
  |  Branch (101:9): [True: 0, False: 0]
  ------------------
  102|      0|        goto error_probe;
  103|      0|    ctx = avcodec_alloc_context3(sub_codec);
  104|      0|    if (!ctx)
  ------------------
  |  Branch (104:9): [True: 0, False: 0]
  ------------------
  105|      0|        goto error_probe;
  106|       |
  107|      0|    mp_set_avopts(sd->log, ctx, sd->opts->sub_avopts);
  108|       |
  109|      0|    switch (cid) {
  ------------------
  |  Branch (109:13): [True: 0, False: 0]
  ------------------
  110|      0|    case AV_CODEC_ID_DVB_TELETEXT: {
  ------------------
  |  Branch (110:5): [True: 0, False: 0]
  ------------------
  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: 0]
  ------------------
  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|      0|    }
  128|       |
  129|      0|    MP_VERBOSE(sd, "Using subtitle decoder %s\n", sub_codec->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__)
  |  |  ------------------
  ------------------
  130|       |
  131|      0|    priv->avpkt = av_packet_alloc();
  132|      0|    priv->codec = sd->codec;
  133|      0|    if (!priv->avpkt)
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  ------------------
  134|      0|        goto error;
  135|      0|    if (mp_set_avctx_codec_headers(ctx, sd->codec) < 0)
  ------------------
  |  Branch (135:9): [True: 0, False: 0]
  ------------------
  136|      0|        goto error;
  137|      0|    priv->pkt_timebase = mp_get_codec_timebase(sd->codec);
  138|      0|    ctx->pkt_timebase = priv->pkt_timebase;
  139|      0|    if (avcodec_open2(ctx, sub_codec, NULL) < 0)
  ------------------
  |  Branch (139:9): [True: 0, False: 0]
  ------------------
  140|      0|        goto error;
  141|      0|    priv->avctx = ctx;
  142|      0|    sd->priv = priv;
  143|      0|    priv->displayed_id = -1;
  144|      0|    priv->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  145|      0|    priv->packer = talloc_zero(priv, struct bitmap_packer);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|      0|    return 0;
  147|       |
  148|      0|error:
  149|      0|    MP_FATAL(sd, "Could not open libavcodec subtitle decoder\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__)
  |  |  ------------------
  ------------------
  150|      0|error_probe:
  151|      0|    avcodec_free_context(&ctx);
  152|      0|    mp_free_av_packet(&priv->avpkt);
  153|      0|    talloc_free(priv);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  154|      0|    return -1;
  155|      0|}

ta_set_parent:
   88|   827M|{
   89|   827M|    struct ta_header *ch = get_header(ptr);
   90|   827M|    if (!ch)
  ------------------
  |  Branch (90:9): [True: 17.2M, False: 810M]
  ------------------
   91|  17.2M|        return;
   92|   810M|    struct ta_header *new_parent = get_header(ta_parent);
   93|       |    // Unlink from previous parent
   94|   810M|    if (ch->prev)
  ------------------
  |  Branch (94:9): [True: 797k, False: 809M]
  ------------------
   95|   797k|        ch->prev->next = ch->next;
   96|   810M|    if (ch->next)
  ------------------
  |  Branch (96:9): [True: 115M, False: 694M]
  ------------------
   97|   115M|        ch->next->prev = ch->prev;
   98|       |    // If ch was the first child, change child link of old parent
   99|   810M|    if (ch->parent) {
  ------------------
  |  Branch (99:9): [True: 155M, False: 654M]
  ------------------
  100|   155M|        assert(ch->parent->child == ch);
  ------------------
  |  Branch (100:9): [True: 155M, False: 18.4E]
  ------------------
  101|   155M|        ch->parent->child = ch->next;
  102|   155M|        if (ch->parent->child) {
  ------------------
  |  Branch (102:13): [True: 114M, False: 41.4M]
  ------------------
  103|   114M|            assert(!ch->parent->child->parent);
  ------------------
  |  Branch (103:13): [True: 114M, False: 18.4E]
  ------------------
  104|   114M|            ch->parent->child->parent = ch->parent;
  105|   114M|        }
  106|   155M|    }
  107|   810M|    ch->next = ch->prev = ch->parent = NULL;
  108|       |    // Link to new parent - insert at start of list (LIFO destructor order)
  109|   810M|    if (new_parent) {
  ------------------
  |  Branch (109:9): [True: 156M, False: 653M]
  ------------------
  110|   156M|        ch->next = new_parent->child;
  111|   156M|        if (ch->next) {
  ------------------
  |  Branch (111:13): [True: 115M, False: 41.4M]
  ------------------
  112|   115M|            ch->next->prev = ch;
  113|       |            ch->next->parent = NULL;
  114|   115M|        }
  115|   156M|        new_parent->child = ch;
  116|   156M|        ch->parent = new_parent;
  117|   156M|    }
  118|   810M|}
ta_alloc_size:
  136|   269M|{
  137|   269M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   269M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (137:9): [True: 0, False: 269M]
  ------------------
  138|      0|        return NULL;
  139|   269M|    struct ta_header *h = malloc(sizeof(union aligned_header) + size);
  140|   269M|    if (!h)
  ------------------
  |  Branch (140:9): [True: 0, False: 269M]
  ------------------
  141|      0|        return NULL;
  142|   269M|    *h = (struct ta_header) {.size = size};
  143|   269M|    ta_dbg_add(h);
  144|   269M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|   269M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  145|   269M|    ta_set_parent(ptr, ta_parent);
  146|   269M|    return ptr;
  147|   269M|}
ta_zalloc_size:
  153|  33.4M|{
  154|  33.4M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|  33.4M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (154:9): [True: 0, False: 33.4M]
  ------------------
  155|      0|        return NULL;
  156|  33.4M|    struct ta_header *h = calloc(1, sizeof(union aligned_header) + size);
  157|  33.4M|    if (!h)
  ------------------
  |  Branch (157:9): [True: 0, False: 33.4M]
  ------------------
  158|      0|        return NULL;
  159|  33.4M|    *h = (struct ta_header) {.size = size};
  160|  33.4M|    ta_dbg_add(h);
  161|  33.4M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  33.4M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  162|  33.4M|    ta_set_parent(ptr, ta_parent);
  163|  33.4M|    return ptr;
  164|  33.4M|}
ta_realloc_size:
  179|   245M|{
  180|   245M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   245M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (180:9): [True: 0, False: 245M]
  ------------------
  181|      0|        return NULL;
  182|   245M|    if (!size) {
  ------------------
  |  Branch (182:9): [True: 121k, False: 245M]
  ------------------
  183|   121k|        ta_free(ptr);
  184|   121k|        return NULL;
  185|   121k|    }
  186|   245M|    if (!ptr)
  ------------------
  |  Branch (186:9): [True: 215M, False: 29.5M]
  ------------------
  187|   215M|        return ta_alloc_size(ta_parent, size);
  188|  29.5M|    struct ta_header *h = get_header(ptr);
  189|  29.5M|    struct ta_header *old_h = h;
  190|  29.5M|    if (h->size == size)
  ------------------
  |  Branch (190:9): [True: 9.89k, False: 29.5M]
  ------------------
  191|  9.89k|        return ptr;
  192|  29.5M|    ta_dbg_remove(h);
  193|  29.5M|    h = realloc(h, sizeof(union aligned_header) + size);
  194|  18.4E|    ta_dbg_add(h ? h : old_h);
  ------------------
  |  Branch (194:16): [True: 29.5M, False: 18.4E]
  ------------------
  195|  29.5M|    if (!h)
  ------------------
  |  Branch (195:9): [True: 0, False: 29.5M]
  ------------------
  196|      0|        return NULL;
  197|  29.5M|    h->size = size;
  198|  29.5M|    if (h != old_h) {
  ------------------
  |  Branch (198:9): [True: 14.4M, False: 15.0M]
  ------------------
  199|       |        // Relink parent
  200|  14.4M|        if (h->parent)
  ------------------
  |  Branch (200:13): [True: 2.26M, False: 12.2M]
  ------------------
  201|  2.26M|            h->parent->child = h;
  202|       |        // Relink siblings
  203|  14.4M|        if (h->next)
  ------------------
  |  Branch (203:13): [True: 2.49M, False: 11.9M]
  ------------------
  204|  2.49M|            h->next->prev = h;
  205|  14.4M|        if (h->prev)
  ------------------
  |  Branch (205:13): [True: 1.70M, False: 12.7M]
  ------------------
  206|  1.70M|            h->prev->next = h;
  207|       |        // Relink children
  208|  14.4M|        if (h->child)
  ------------------
  |  Branch (208:13): [True: 383k, False: 14.0M]
  ------------------
  209|   383k|            h->child->parent = h;
  210|  14.4M|    }
  211|  29.5M|    return PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  29.5M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  212|  29.5M|}
ta_get_size:
  219|  1.00G|{
  220|  1.00G|    struct ta_header *h = get_header(ptr);
  221|  1.00G|    return h ? h->size : 0;
  ------------------
  |  Branch (221:12): [True: 602M, False: 407M]
  ------------------
  222|  1.00G|}
ta_free_children:
  228|   316M|{
  229|   316M|    struct ta_header *h = get_header(ptr);
  230|   470M|    while (h && h->child)
  ------------------
  |  Branch (230:12): [True: 470M, False: 24.1k]
  |  Branch (230:17): [True: 153M, False: 316M]
  ------------------
  231|   153M|        ta_free(PTR_FROM_HEADER(h->child));
  ------------------
  |  |   64|   153M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  232|   316M|}
ta_free:
  237|   365M|{
  238|   365M|    struct ta_header *h = get_header(ptr);
  239|   365M|    if (!h)
  ------------------
  |  Branch (239:9): [True: 62.8M, False: 302M]
  ------------------
  240|  62.8M|        return;
  241|   302M|    if (h->destructor)
  ------------------
  |  Branch (241:9): [True: 21.9M, False: 280M]
  ------------------
  242|  21.9M|        h->destructor(ptr);
  243|   302M|    ta_free_children(ptr);
  244|       |    ta_set_parent(ptr, NULL);
  245|   302M|    ta_dbg_remove(h);
  246|   302M|    free(h);
  247|   302M|}
ta_set_destructor:
  260|  21.9M|{
  261|  21.9M|    struct ta_header *h = get_header(ptr);
  262|  21.9M|    if (h)
  ------------------
  |  Branch (262:9): [True: 21.9M, False: 18.4E]
  ------------------
  263|  21.9M|        h->destructor = destructor;
  264|  21.9M|}
ta_dbg_set_loc:
  379|   326M|{
  380|   326M|    struct ta_header *h = get_header(ptr);
  381|   326M|    if (h)
  ------------------
  |  Branch (381:9): [True: 325M, False: 623k]
  ------------------
  382|   325M|        h->name = loc;
  383|   326M|    return ptr;
  384|   326M|}
ta_dbg_mark_as_string:
  389|   203M|{
  390|       |    // Specially handled by leak report code.
  391|   203M|    return ta_dbg_set_loc(ptr, &allocation_is_string);
  392|   203M|}
ta.c:get_header:
   73|  3.69G|{
   74|  3.69G|    struct ta_header *h = ptr ? PTR_TO_HEADER(ptr) : NULL;
  ------------------
  |  |   63|  2.56G|#define PTR_TO_HEADER(ptr) (&((union aligned_header *)(ptr) - 1)->ta)
  ------------------
  |  Branch (74:27): [True: 2.56G, False: 1.13G]
  ------------------
   75|  3.69G|    ta_dbg_check_header(h);
   76|  3.69G|    return h;
   77|  3.69G|}
ta.c:ta_dbg_check_header:
  289|  4.02G|{
  290|  4.02G|    if (h) {
  ------------------
  |  Branch (290:9): [True: 2.89G, False: 1.13G]
  ------------------
  291|  2.89G|        assert(h->canary == CANARY);
  ------------------
  |  Branch (291:9): [True: 2.89G, False: 18.4E]
  ------------------
  292|  2.89G|        if (h->parent) {
  ------------------
  |  Branch (292:13): [True: 843M, False: 2.04G]
  ------------------
  293|   843M|            assert(!h->prev);
  ------------------
  |  Branch (293:13): [True: 843M, False: 18.4E]
  ------------------
  294|   843M|            assert(h->parent->child == h);
  ------------------
  |  Branch (294:13): [True: 843M, False: 18.4E]
  ------------------
  295|   843M|        }
  296|  2.89G|    }
  297|  4.02G|}
ta.c:ta_dbg_add:
  276|   331M|{
  277|   331M|    h->canary = CANARY;
  ------------------
  |  |   50|   331M|#define CANARY 0xD3ADB3EF
  ------------------
  278|   331M|    if (enable_leak_check) {
  ------------------
  |  Branch (278:9): [True: 0, False: 331M]
  ------------------
  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|   331M|}
ta.c:ta_dbg_remove:
  300|   331M|{
  301|   331M|    ta_dbg_check_header(h);
  302|   331M|    if (h->leak_next) { // assume checking for !=NULL invariant ok without lock
  ------------------
  |  Branch (302:9): [True: 0, False: 331M]
  ------------------
  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|   331M|    h->canary = 0;
  310|   331M|}

aframe.c:ta_oom_p:
  162|  2.41M|{
  163|  2.41M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.41M]
  ------------------
  164|      0|        abort();
  165|  2.41M|    return p;
  166|  2.41M|}
ad_dsd.c:ta_oom_p:
  162|  16.7k|{
  163|  16.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.7k]
  ------------------
  164|      0|        abort();
  165|  16.7k|    return p;
  166|  16.7k|}
ad_spdif.c:ta_oom_p:
  162|  16.7k|{
  163|  16.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.7k]
  ------------------
  164|      0|        abort();
  165|  16.7k|    return p;
  166|  16.7k|}
af_scaletempo2.c:ta_oom_p:
  162|  2.19k|{
  163|  2.19k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.19k]
  ------------------
  164|      0|        abort();
  165|  2.19k|    return p;
  166|  2.19k|}
af_scaletempo2_internals.c:ta_oom_p:
  162|  55.1k|{
  163|  55.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 55.1k]
  ------------------
  164|      0|        abort();
  165|  55.1k|    return p;
  166|  55.1k|}
ao.c:ta_oom_p:
  162|  30.0k|{
  163|  30.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 30.0k]
  ------------------
  164|      0|        abort();
  165|  30.0k|    return p;
  166|  30.0k|}
buffer.c:ta_oom_p:
  162|  15.0k|{
  163|  15.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 15.0k]
  ------------------
  164|      0|        abort();
  165|  15.0k|    return p;
  166|  15.0k|}
codecs.c:ta_oom_p:
  162|  46.5k|{
  163|  46.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 46.5k]
  ------------------
  164|      0|        abort();
  165|  46.5k|    return p;
  166|  46.5k|}
msg.c:ta_oom_p:
  162|  2.45M|{
  163|  2.45M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.45M]
  ------------------
  164|      0|        abort();
  165|  2.45M|    return p;
  166|  2.45M|}
msg.c:ta_oom_s:
  175|   206k|{
  176|   206k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 206k]
  ------------------
  177|      0|        abort();
  178|   206k|    return s;
  179|   206k|}
playlist.c:ta_oom_p:
  162|  18.0k|{
  163|  18.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 18.0k]
  ------------------
  164|      0|        abort();
  165|  18.0k|    return p;
  166|  18.0k|}
stats.c:ta_oom_p:
  162|   453k|{
  163|   453k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 453k]
  ------------------
  164|      0|        abort();
  165|   453k|    return p;
  166|   453k|}
stats.c:ta_oom_s:
  175|  26.4k|{
  176|  26.4k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 26.4k]
  ------------------
  177|      0|        abort();
  178|  26.4k|    return s;
  179|  26.4k|}
tags.c:ta_oom_p:
  162|   398k|{
  163|   398k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 398k]
  ------------------
  164|      0|        abort();
  165|   398k|    return p;
  166|   398k|}
demux.c:ta_oom_p:
  162|  2.77M|{
  163|  2.77M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.77M]
  ------------------
  164|      0|        abort();
  165|  2.77M|    return p;
  166|  2.77M|}
demux_disc.c:ta_oom_p:
  162|  30.0k|{
  163|  30.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 30.0k]
  ------------------
  164|      0|        abort();
  165|  30.0k|    return p;
  166|  30.0k|}
demux_edl.c:ta_oom_p:
  162|  35.0k|{
  163|  35.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 35.0k]
  ------------------
  164|      0|        abort();
  165|  35.0k|    return p;
  166|  35.0k|}
demux_lavf.c:ta_oom_p:
  162|   133k|{
  163|   133k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 133k]
  ------------------
  164|      0|        abort();
  165|   133k|    return p;
  166|   133k|}
demux_mf.c:ta_oom_p:
  162|  25.3k|{
  163|  25.3k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 25.3k]
  ------------------
  164|      0|        abort();
  165|  25.3k|    return p;
  166|  25.3k|}
demux_mkv.c:ta_oom_p:
  162|  30.0k|{
  163|  30.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 30.0k]
  ------------------
  164|      0|        abort();
  165|  30.0k|    return p;
  166|  30.0k|}
demux_mpv.c:ta_oom_p:
  162|     23|{
  163|     23|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 23]
  ------------------
  164|      0|        abort();
  165|     23|    return p;
  166|     23|}
demux_playlist.c:ta_oom_p:
  162|   118k|{
  163|   118k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 118k]
  ------------------
  164|      0|        abort();
  165|   118k|    return p;
  166|   118k|}
demux_timeline.c:ta_oom_p:
  162|     33|{
  163|     33|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 33]
  ------------------
  164|      0|        abort();
  165|     33|    return p;
  166|     33|}
demux_timeline.c:ta_oom_s:
  175|     11|{
  176|     11|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 11]
  ------------------
  177|      0|        abort();
  178|     11|    return s;
  179|     11|}
packet.c:ta_oom_p:
  162|   944k|{
  163|   944k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 944k]
  ------------------
  164|      0|        abort();
  165|   944k|    return p;
  166|   944k|}
packet_pool.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
timeline.c:ta_oom_p:
  162|  1.08k|{
  163|  1.08k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.08k]
  ------------------
  164|      0|        abort();
  165|  1.08k|    return p;
  166|  1.08k|}
f_async_queue.c:ta_oom_p:
  162|  30.0k|{
  163|  30.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 30.0k]
  ------------------
  164|      0|        abort();
  165|  30.0k|    return p;
  166|  30.0k|}
f_decoder_wrapper.c:ta_oom_p:
  162|  46.5k|{
  163|  46.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 46.5k]
  ------------------
  164|      0|        abort();
  165|  46.5k|    return p;
  166|  46.5k|}
f_output_chain.c:ta_oom_p:
  162|  61.2k|{
  163|  61.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 61.2k]
  ------------------
  164|      0|        abort();
  165|  61.2k|    return p;
  166|  61.2k|}
f_swresample.c:ta_oom_p:
  162|  7.45k|{
  163|  7.45k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 7.45k]
  ------------------
  164|      0|        abort();
  165|  7.45k|    return p;
  166|  7.45k|}
filter.c:ta_oom_p:
  162|  5.16M|{
  163|  5.16M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 5.16M]
  ------------------
  164|      0|        abort();
  165|  5.16M|    return p;
  166|  5.16M|}
cmd.c:ta_oom_p:
  162|  5.60M|{
  163|  5.60M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 5.60M]
  ------------------
  164|      0|        abort();
  165|  5.60M|    return p;
  166|  5.60M|}
input.c:ta_oom_s:
  175|     99|{
  176|     99|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 99]
  ------------------
  177|      0|        abort();
  178|     99|    return s;
  179|     99|}
input.c:ta_oom_p:
  162|  58.9k|{
  163|  58.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 58.9k]
  ------------------
  164|      0|        abort();
  165|  58.9k|    return p;
  166|  58.9k|}
ipc.c:ta_oom_p:
  162|  12.0M|{
  163|  12.0M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.0M]
  ------------------
  164|      0|        abort();
  165|  12.0M|    return p;
  166|  12.0M|}
bstr.c:ta_oom_p:
  162|  1.59k|{
  163|  1.59k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.59k]
  ------------------
  164|      0|        abort();
  165|  1.59k|    return p;
  166|  1.59k|}
charset_conv.c:ta_oom_p:
  162|  67.8k|{
  163|  67.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 67.8k]
  ------------------
  164|      0|        abort();
  165|  67.8k|    return p;
  166|  67.8k|}
dispatch.c:ta_oom_p:
  162|   288k|{
  163|   288k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 288k]
  ------------------
  164|      0|        abort();
  165|   288k|    return p;
  166|   288k|}
json.c:ta_oom_p:
  162|   483k|{
  163|   483k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 483k]
  ------------------
  164|      0|        abort();
  165|   483k|    return p;
  166|   483k|}
language.c:ta_oom_p:
  162|     93|{
  163|     93|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 93]
  ------------------
  164|      0|        abort();
  165|     93|    return p;
  166|     93|}
node.c:ta_oom_p:
  162|  5.61M|{
  163|  5.61M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 5.61M]
  ------------------
  164|      0|        abort();
  165|  5.61M|    return p;
  166|  5.61M|}
path_utils.c:ta_oom_s:
  175|  4.67k|{
  176|  4.67k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 4.67k]
  ------------------
  177|      0|        abort();
  178|  4.67k|    return s;
  179|  4.67k|}
path_utils.c:ta_oom_p:
  162|  4.86k|{
  163|  4.86k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.86k]
  ------------------
  164|      0|        abort();
  165|  4.86k|    return p;
  166|  4.86k|}
thread_pool.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
thread_tools.c:ta_oom_p:
  162|   204k|{
  163|   204k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 204k]
  ------------------
  164|      0|        abort();
  165|   204k|    return p;
  166|   204k|}
m_config_core.c:ta_oom_p:
  162|  10.5M|{
  163|  10.5M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 10.5M]
  ------------------
  164|      0|        abort();
  165|  10.5M|    return p;
  166|  10.5M|}
m_config_frontend.c:ta_oom_p:
  162|  17.3M|{
  163|  17.3M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 17.3M]
  ------------------
  164|      0|        abort();
  165|  17.3M|    return p;
  166|  17.3M|}
m_option.c:ta_oom_s:
  175|   375k|{
  176|   375k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 375k]
  ------------------
  177|      0|        abort();
  178|   375k|    return s;
  179|   375k|}
m_option.c:ta_oom_p:
  162|  3.29M|{
  163|  3.29M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 3.29M]
  ------------------
  164|      0|        abort();
  165|  3.29M|    return p;
  166|  3.29M|}
m_option.c:ta_oom_b:
  169|    276|{
  170|    276|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 276]
  ------------------
  171|      0|        abort();
  172|    276|}
m_property.c:ta_oom_p:
  162|     87|{
  163|     87|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 87]
  ------------------
  164|      0|        abort();
  165|     87|    return p;
  166|     87|}
parse_configfile.c:ta_oom_p:
  162|  12.3k|{
  163|  12.3k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.3k]
  ------------------
  164|      0|        abort();
  165|  12.3k|    return p;
  166|  12.3k|}
path.c:ta_oom_p:
  162|   129k|{
  163|   129k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 129k]
  ------------------
  164|      0|        abort();
  165|   129k|    return p;
  166|   129k|}
audio.c:ta_oom_p:
  162|  16.7k|{
  163|  16.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16.7k]
  ------------------
  164|      0|        abort();
  165|  16.7k|    return p;
  166|  16.7k|}
client.c:ta_oom_p:
  162|   234k|{
  163|   234k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 234k]
  ------------------
  164|      0|        abort();
  165|   234k|    return p;
  166|   234k|}
command.c:ta_oom_p:
  162|   834k|{
  163|   834k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 834k]
  ------------------
  164|      0|        abort();
  165|   834k|    return p;
  166|   834k|}
command.c:ta_oom_s:
  175|   221k|{
  176|   221k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 221k]
  ------------------
  177|      0|        abort();
  178|   221k|    return s;
  179|   221k|}
configfiles.c:ta_oom_p:
  162|  19.1k|{
  163|  19.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.1k]
  ------------------
  164|      0|        abort();
  165|  19.1k|    return p;
  166|  19.1k|}
external_files.c:ta_oom_p:
  162|  28.8k|{
  163|  28.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 28.8k]
  ------------------
  164|      0|        abort();
  165|  28.8k|    return p;
  166|  28.8k|}
loadfile.c:ta_oom_p:
  162|   269k|{
  163|   269k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 269k]
  ------------------
  164|      0|        abort();
  165|   269k|    return p;
  166|   269k|}
main.c:ta_oom_p:
  162|  35.0k|{
  163|  35.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 35.0k]
  ------------------
  164|      0|        abort();
  165|  35.0k|    return p;
  166|  35.0k|}
osd.c:ta_oom_b:
  169|  2.98M|{
  170|  2.98M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 2.98M]
  ------------------
  171|      0|        abort();
  172|  2.98M|}
osd.c:ta_oom_s:
  175|   295k|{
  176|   295k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 295k]
  ------------------
  177|      0|        abort();
  178|   295k|    return s;
  179|   295k|}
osd.c:ta_oom_p:
  162|   116k|{
  163|   116k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 116k]
  ------------------
  164|      0|        abort();
  165|   116k|    return p;
  166|   116k|}
screenshot.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
scripting.c:ta_oom_s:
  175|  1.10k|{
  176|  1.10k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 1.10k]
  ------------------
  177|      0|        abort();
  178|  1.10k|    return s;
  179|  1.10k|}
scripting.c:ta_oom_p:
  162|  12.7k|{
  163|  12.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.7k]
  ------------------
  164|      0|        abort();
  165|  12.7k|    return p;
  166|  12.7k|}
sub.c:ta_oom_p:
  162|  4.76k|{
  163|  4.76k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.76k]
  ------------------
  164|      0|        abort();
  165|  4.76k|    return p;
  166|  4.76k|}
video.c:ta_oom_p:
  162|  29.8k|{
  163|  29.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 29.8k]
  ------------------
  164|      0|        abort();
  165|  29.8k|    return p;
  166|  29.8k|}
clipboard.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
clipboard-vo.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
stream.c:ta_oom_p:
  162|   184k|{
  163|   184k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 184k]
  ------------------
  164|      0|        abort();
  165|   184k|    return p;
  166|   184k|}
stream_aes_ctr.c:ta_oom_p:
  162|     16|{
  163|     16|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 16]
  ------------------
  164|      0|        abort();
  165|     16|    return p;
  166|     16|}
stream_cb.c:ta_oom_p:
  162|  30.1k|{
  163|  30.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 30.1k]
  ------------------
  164|      0|        abort();
  165|  30.1k|    return p;
  166|  30.1k|}
stream_file.c:ta_oom_p:
  162|  26.2k|{
  163|  26.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 26.2k]
  ------------------
  164|      0|        abort();
  165|  26.2k|    return p;
  166|  26.2k|}
stream_lavf.c:ta_oom_p:
  162|  73.1k|{
  163|  73.1k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 73.1k]
  ------------------
  164|      0|        abort();
  165|  73.1k|    return p;
  166|  73.1k|}
stream_slice.c:ta_oom_p:
  162|     87|{
  163|     87|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 87]
  ------------------
  164|      0|        abort();
  165|     87|    return p;
  166|     87|}
stream_bstr.c:ta_oom_p:
  162|  81.8k|{
  163|  81.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 81.8k]
  ------------------
  164|      0|        abort();
  165|  81.8k|    return p;
  166|  81.8k|}
ass_mp.c:ta_oom_p:
  162|  4.76k|{
  163|  4.76k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.76k]
  ------------------
  164|      0|        abort();
  165|  4.76k|    return p;
  166|  4.76k|}
dec_sub.c:ta_oom_p:
  162|  14.2k|{
  163|  14.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 14.2k]
  ------------------
  164|      0|        abort();
  165|  14.2k|    return p;
  166|  14.2k|}
lavc_conv.c:ta_oom_p:
  162|  9.53k|{
  163|  9.53k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 9.53k]
  ------------------
  164|      0|        abort();
  165|  9.53k|    return p;
  166|  9.53k|}
packer.c:ta_oom_p:
  162|  9.53k|{
  163|  9.53k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 9.53k]
  ------------------
  164|      0|        abort();
  165|  9.53k|    return p;
  166|  9.53k|}
sd_ass.c:ta_oom_p:
  162|  14.5k|{
  163|  14.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 14.5k]
  ------------------
  164|      0|        abort();
  165|  14.5k|    return p;
  166|  14.5k|}
mp_image.c:ta_oom_p:
  162|   267k|{
  163|   267k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 267k]
  ------------------
  164|      0|        abort();
  165|   267k|    return p;
  166|   267k|}
mp_image_pool.c:ta_oom_p:
  162|  59.6k|{
  163|  59.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 59.6k]
  ------------------
  164|      0|        abort();
  165|  59.6k|    return p;
  166|  59.6k|}
vo.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|}
sws_utils.c:ta_oom_p:
  162|  70.4k|{
  163|  70.4k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 70.4k]
  ------------------
  164|      0|        abort();
  165|  70.4k|    return p;
  166|  70.4k|}
ta_talloc.c:ta_oom_b:
  169|  10.3M|{
  170|  10.3M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 10.3M]
  ------------------
  171|      0|        abort();
  172|  10.3M|}
ta_utils.c:ta_oom_b:
  169|   266M|{
  170|   266M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 266M]
  ------------------
  171|      0|        abort();
  172|   266M|}
ipc-unix.c:ta_oom_p:
  162|  11.6k|{
  163|  11.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.6k]
  ------------------
  164|      0|        abort();
  165|  11.6k|    return p;
  166|  11.6k|}
filter_regex.c:ta_oom_p:
  162|  4.76k|{
  163|  4.76k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.76k]
  ------------------
  164|      0|        abort();
  165|  4.76k|    return p;
  166|  4.76k|}
als-linux.c:ta_oom_p:
  162|      8|{
  163|      8|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 8]
  ------------------
  164|      0|        abort();
  165|      8|    return p;
  166|      8|}
stream_dvb.c:ta_oom_p:
  162|      8|{
  163|      8|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 8]
  ------------------
  164|      0|        abort();
  165|      8|    return p;
  166|      8|}

ta_talloc_strdup_append:
   24|  6.21M|{
   25|  6.21M|    ta_xstrdup_append(&s, a);
  ------------------
  |  |  123|  6.21M|#define ta_xstrdup_append(...)          ta_oom_b(ta_strdup_append(__VA_ARGS__))
  ------------------
   26|  6.21M|    return s;
   27|  6.21M|}
ta_talloc_strdup_append_buffer:
   30|  46.5k|{
   31|  46.5k|    ta_xstrdup_append_buffer(&s, a);
  ------------------
  |  |  124|  46.5k|#define ta_xstrdup_append_buffer(...)   ta_oom_b(ta_strdup_append_buffer(__VA_ARGS__))
  ------------------
   32|  46.5k|    return s;
   33|  46.5k|}
ta_talloc_strndup_append:
   36|  34.4k|{
   37|  34.4k|    ta_xstrndup_append(&s, a, n);
  ------------------
  |  |  125|  34.4k|#define ta_xstrndup_append(...)         ta_oom_b(ta_strndup_append(__VA_ARGS__))
  ------------------
   38|  34.4k|    return s;
   39|  34.4k|}
ta_talloc_strndup_append_buffer:
   42|  45.4k|{
   43|  45.4k|    ta_xstrndup_append_buffer(&s, a, n);
  ------------------
  |  |  126|  45.4k|#define ta_xstrndup_append_buffer(...)  ta_oom_b(ta_strndup_append_buffer(__VA_ARGS__))
  ------------------
   44|  45.4k|    return s;
   45|  45.4k|}
ta_talloc_vasprintf_append:
   48|  3.16M|{
   49|  3.16M|    ta_xvasprintf_append(&s, fmt, ap);
  ------------------
  |  |  130|  3.16M|#define ta_xvasprintf_append(...)       ta_oom_b(ta_vasprintf_append(__VA_ARGS__))
  ------------------
   50|  3.16M|    return s;
   51|  3.16M|}
ta_talloc_vasprintf_append_buffer:
   54|   841k|{
   55|   841k|    ta_xvasprintf_append_buffer(&s, fmt, ap);
  ------------------
  |  |  132|   841k|#define ta_xvasprintf_append_buffer(...) ta_oom_b(ta_vasprintf_append_buffer(__VA_ARGS__))
  ------------------
   56|   841k|    return s;
   57|   841k|}
ta_talloc_asprintf_append:
   60|  3.16M|{
   61|  3.16M|    char *res;
   62|  3.16M|    va_list ap;
   63|  3.16M|    va_start(ap, fmt);
   64|  3.16M|    res = talloc_vasprintf_append(s, fmt, ap);
  ------------------
  |  |   61|  3.16M|#define talloc_vasprintf_append         ta_talloc_vasprintf_append
  ------------------
   65|       |    va_end(ap);
   66|  3.16M|    return res;
   67|  3.16M|}
ta_talloc_asprintf_append_buffer:
   70|   841k|{
   71|   841k|    char *res;
   72|   841k|    va_list ap;
   73|   841k|    va_start(ap, fmt);
   74|   841k|    res = talloc_vasprintf_append_buffer(s, fmt, ap);
  ------------------
  |  |   62|   841k|#define talloc_vasprintf_append_buffer  ta_talloc_vasprintf_append_buffer
  ------------------
   75|       |    va_end(ap);
   76|   841k|    return res;
   77|   841k|}

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

mp_csp_guess_colorspace:
  191|  18.0k|{
  192|  18.0k|    return width >= 1280 || height > 576 ? PL_COLOR_SYSTEM_BT_709 : PL_COLOR_SYSTEM_BT_601;
  ------------------
  |  Branch (192:12): [True: 0, False: 18.0k]
  |  Branch (192:29): [True: 0, False: 18.0k]
  ------------------
  193|  18.0k|}
mp_csp_guess_primaries:
  196|  18.0k|{
  197|       |    // HD content
  198|  18.0k|    if (width >= 1280 || height > 576)
  ------------------
  |  Branch (198:9): [True: 0, False: 18.0k]
  |  Branch (198:26): [True: 0, False: 18.0k]
  ------------------
  199|      0|        return PL_COLOR_PRIM_BT_709;
  200|       |
  201|  18.0k|    switch (height) {
  202|      0|    case 576: // Typical PAL content, including anamorphic/squared
  ------------------
  |  Branch (202:5): [True: 0, False: 18.0k]
  ------------------
  203|      0|        return PL_COLOR_PRIM_BT_601_625;
  204|       |
  205|      0|    case 480: // Typical NTSC content, including squared
  ------------------
  |  Branch (205:5): [True: 0, False: 18.0k]
  ------------------
  206|      0|    case 486: // NTSC Pro or anamorphic NTSC
  ------------------
  |  Branch (206:5): [True: 0, False: 18.0k]
  ------------------
  207|      0|        return PL_COLOR_PRIM_BT_601_525;
  208|       |
  209|  18.0k|    default: // No good metric, just pick BT.709 to minimize damage
  ------------------
  |  Branch (209:5): [True: 18.0k, False: 0]
  ------------------
  210|  18.0k|        return PL_COLOR_PRIM_BT_709;
  211|  18.0k|    }
  212|  18.0k|}
mp_parse_raw_primaries:
  566|     39|{
  567|     39|    if (!str)
  ------------------
  |  Branch (567:9): [True: 0, False: 39]
  ------------------
  568|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  569|       |
  570|     39|    if (!*str)
  ------------------
  |  Branch (570:9): [True: 0, False: 39]
  ------------------
  571|      0|        return M_OPT_MISSING_PARAM;
  ------------------
  |  |  532|      0|#define M_OPT_MISSING_PARAM     -2
  ------------------
  572|       |
  573|       |    // Comma-separated CIE xy values: Rx,Ry,Gx,Gy,Bx,By,Wx,Wy
  574|     39|    struct pl_raw_primaries prim;
  575|     39|    if (sscanf(str, "%f,%f,%f,%f,%f,%f,%f,%f",
  ------------------
  |  Branch (575:9): [True: 0, False: 39]
  ------------------
  576|     39|            &prim.red.x, &prim.red.y, &prim.green.x, &prim.green.y,
  577|     39|            &prim.blue.x, &prim.blue.y, &prim.white.x, &prim.white.y) == 8)
  578|      0|    {
  579|      0|        if (!pl_primaries_valid(&prim))
  ------------------
  |  Branch (579:13): [True: 0, False: 0]
  ------------------
  580|      0|            return M_OPT_OUT_OF_RANGE;
  ------------------
  |  |  539|      0|#define M_OPT_OUT_OF_RANGE      -4
  ------------------
  581|      0|        *out = prim;
  582|      0|        return 1;
  583|      0|    }
  584|       |
  585|     39|    const m_option_t choice_opt = {
  586|     39|        .priv = (void *)pl_csp_prim_names,
  587|     39|    };
  588|       |
  589|     39|    int prim_choice;
  590|     39|    int ret = m_option_type_choice.parse(log, &choice_opt, bstr0("target-gamut"),
  591|     39|                                         bstr0(str), &prim_choice);
  592|     39|    if (ret >= 0) {
  ------------------
  |  Branch (592:9): [True: 0, False: 39]
  ------------------
  593|      0|        if (!prim_choice)
  ------------------
  |  Branch (593:13): [True: 0, False: 0]
  ------------------
  594|      0|            return 0;
  595|      0|        *out = *pl_raw_primaries_get(prim_choice);
  596|     39|    } else if (ret != M_OPT_MISSING_PARAM) {
  ------------------
  |  |  532|     39|#define M_OPT_MISSING_PARAM     -2
  ------------------
  |  Branch (596:16): [True: 39, False: 0]
  ------------------
  597|     39|        mp_info(log, "    Rx,Ry,Gx,Gy,Bx,By,Wx,Wy (custom CIE xy primaries)\n");
  ------------------
  |  |   78|     39|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  598|     39|    }
  599|       |
  600|     39|    return ret;
  601|     39|}

vd_lavc.c:add_all_hwdec_methods:
  346|  29.8k|{
  347|  29.8k|    const AVCodec *codec = NULL;
  348|  29.8k|    void *iter = NULL;
  349|  14.9M|    while (1) {
  ------------------
  |  Branch (349:12): [True: 14.9M, Folded]
  ------------------
  350|  14.9M|        codec = av_codec_iterate(&iter);
  351|  14.9M|        if (!codec)
  ------------------
  |  Branch (351:13): [True: 29.8k, False: 14.9M]
  ------------------
  352|  29.8k|            break;
  353|  14.9M|        if (codec->type != AVMEDIA_TYPE_VIDEO || !av_codec_is_decoder(codec))
  ------------------
  |  Branch (353:13): [True: 7.30M, False: 7.63M]
  |  Branch (353:50): [True: 0, False: 7.63M]
  ------------------
  354|  7.30M|            continue;
  355|       |
  356|  7.63M|        struct hwdec_info info_template = {
  357|  7.63M|            .pix_fmt = AV_PIX_FMT_NONE,
  358|  7.63M|            .codec = codec,
  359|  7.63M|        };
  360|       |
  361|  7.63M|        const char *wrapper = NULL;
  362|  7.63M|        if (codec->capabilities & (AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_HYBRID))
  ------------------
  |  Branch (362:13): [True: 268k, False: 7.36M]
  ------------------
  363|   268k|            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|  7.63M|        bool found_any = false;
  369|  7.63M|        for (int n = 0; ; n++) {
  370|  7.63M|            const AVCodecHWConfig *cfg = avcodec_get_hw_config(codec, n);
  371|  7.63M|            if (!cfg)
  ------------------
  |  Branch (371:17): [True: 7.63M, False: 0]
  ------------------
  372|  7.63M|                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|  7.63M|        if (!found_any && wrapper) {
  ------------------
  |  Branch (435:13): [True: 7.63M, False: 0]
  |  Branch (435:27): [True: 268k, False: 7.36M]
  ------------------
  436|       |            // We _know_ there's something supported here, usually outputting
  437|       |            // sw surfaces. E.g. mediacodec (before hw_device_ctx support).
  438|       |
  439|   268k|            struct hwdec_info info = info_template;
  440|   268k|            info.copying = true; // probably
  441|       |
  442|   268k|            snprintf(info.method_name, sizeof(info.method_name), "%s", wrapper);
  443|   268k|            add_hwdec_item(infos, num_infos, info);
  444|   268k|        }
  445|  7.63M|    }
  446|       |
  447|  29.8k|    qsort(*infos, *num_infos, sizeof(struct hwdec_info), hwdec_compare);
  448|  29.8k|}
vd_lavc.c:add_hwdec_item:
  321|   268k|{
  322|   268k|    if (info.copying)
  ------------------
  |  Branch (322:9): [True: 268k, False: 0]
  ------------------
  323|   268k|        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|   268k|    snprintf(info.name, sizeof(info.name), "%s-%s",
  328|   268k|             info.codec->name, info.method_name);
  329|       |
  330|   268k|    info.rank = *num_infos;
  331|   268k|    info.auto_pos = INT_MAX;
  332|       |
  333|  5.10M|    for (int x = 0; hwdec_autoprobe_info[x].method_name; x++) {
  ------------------
  |  Branch (333:21): [True: 4.83M, False: 268k]
  ------------------
  334|  4.83M|        const struct autoprobe_info *entry = &hwdec_autoprobe_info[x];
  335|  4.83M|        if (strcmp(entry->method_name, info.method_name) == 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 4.83M]
  ------------------
  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|  4.83M|    }
  341|       |
  342|   268k|    MP_TARRAY_APPEND(NULL, *infos, *num_infos, info);
  ------------------
  |  |  105|   268k|    do {                                            \
  |  |  106|   268k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   268k|    do {                                            \
  |  |  |  |   97|   268k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   268k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   268k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   268k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 89.4k, False: 178k]
  |  |  |  |  ------------------
  |  |  |  |   99|   268k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  89.4k|    do {                                                        \
  |  |  |  |  |  |   89|  89.4k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  89.4k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  89.4k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  89.4k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  89.4k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  89.4k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  89.4k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 89.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   268k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 268k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   268k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   268k|        (idxvar)++;                                 \
  |  |  109|   268k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 268k]
  |  |  ------------------
  ------------------
  343|   268k|}
vd_lavc.c:hwdec_compare:
  295|   387k|{
  296|   387k|    struct hwdec_info *h1 = (void *)p1;
  297|   387k|    struct hwdec_info *h2 = (void *)p2;
  298|       |
  299|   387k|    if (h1 == h2)
  ------------------
  |  Branch (299:9): [True: 0, False: 387k]
  ------------------
  300|      0|        return 0;
  301|       |
  302|       |    // Strictly put non-preferred hwdecs to the end of the list.
  303|   387k|    if ((h1->auto_pos == INT_MAX) != (h2->auto_pos == INT_MAX))
  ------------------
  |  Branch (303:9): [True: 0, False: 387k]
  ------------------
  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|   387k|    if (h1->copying != h2->copying)
  ------------------
  |  Branch (306:9): [True: 0, False: 387k]
  ------------------
  307|      0|        return h1->copying ? 1 : -1;
  ------------------
  |  Branch (307:16): [True: 0, False: 0]
  ------------------
  308|       |    // Order by autoprobe preference order.
  309|   387k|    if (h1->auto_pos != h2->auto_pos)
  ------------------
  |  Branch (309:9): [True: 0, False: 387k]
  ------------------
  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|   387k|    if ((!!h1->lavc_device) != (!!h2->lavc_device))
  ------------------
  |  Branch (312:9): [True: 0, False: 387k]
  ------------------
  313|      0|        return h1->lavc_device ? -1 : 1;
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|       |    // Fallback sort order to make sorting stable.
  315|   387k|    return h1->rank > h2->rank ? 1 :-1;
  ------------------
  |  Branch (315:12): [True: 0, False: 387k]
  ------------------
  316|   387k|}
vd_lavc.c:create:
 1503|  29.8k|{
 1504|  29.8k|    struct mp_filter *vd = mp_filter_create(parent, &vd_lavc_filter);
 1505|  29.8k|    if (!vd)
  ------------------
  |  Branch (1505:9): [True: 0, False: 29.8k]
  ------------------
 1506|      0|        return NULL;
 1507|       |
 1508|  29.8k|    mp_filter_add_pin(vd, MP_PIN_IN, "in");
 1509|  29.8k|    mp_filter_add_pin(vd, MP_PIN_OUT, "out");
 1510|       |
 1511|  29.8k|    vd->log = mp_log_new(vd, parent->log, NULL);
 1512|       |
 1513|  29.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1514|  29.8k|    ctx->log = vd->log;
 1515|  29.8k|    ctx->opts_cache = m_config_cache_alloc(ctx, vd->global, &vd_lavc_conf);
 1516|  29.8k|    ctx->opts = ctx->opts_cache->opts;
 1517|  29.8k|    ctx->hwdec_opts_cache = m_config_cache_alloc(ctx, vd->global, &hwdec_conf);
 1518|  29.8k|    ctx->hwdec_opts = ctx->hwdec_opts_cache->opts;
 1519|  29.8k|    ctx->codec = codec;
 1520|  29.8k|    ctx->decoder = talloc_strdup(ctx, decoder);
  ------------------
  |  |   50|  29.8k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1521|  29.8k|    ctx->hwdec_swpool = mp_image_pool_new(ctx);
 1522|  29.8k|    ctx->dr_pool = mp_image_pool_new(ctx);
 1523|       |
 1524|  29.8k|    ctx->public.f = vd;
 1525|  29.8k|    ctx->public.control = control;
 1526|       |
 1527|  29.8k|    mp_mutex_init(&ctx->dr_lock);
 1528|       |
 1529|       |    // hwdec/DR
 1530|  29.8k|    struct mp_stream_info *info = mp_filter_find_stream_info(vd);
 1531|  29.8k|    if (info) {
  ------------------
  |  Branch (1531:9): [True: 29.8k, False: 0]
  ------------------
 1532|  29.8k|        ctx->hwdec_devs = info->hwdec_devs;
 1533|  29.8k|        ctx->vo = info->dr_vo;
 1534|  29.8k|        ctx->force_swdec = info->force_swdec;
 1535|  29.8k|    }
 1536|       |
 1537|  29.8k|    reinit(vd);
 1538|       |
 1539|  29.8k|    if (!ctx->avctx) {
  ------------------
  |  Branch (1539:9): [True: 0, False: 29.8k]
  ------------------
 1540|      0|        talloc_free(vd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1541|      0|        return NULL;
 1542|      0|    }
 1543|       |
 1544|  29.8k|    codec->codec_desc = ctx->avctx->codec_descriptor->long_name;
 1545|       |
 1546|  29.8k|    return &ctx->public;
 1547|  29.8k|}
vd_lavc.c:vd_lavc_destroy:
 1484|  29.8k|{
 1485|  29.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1486|       |
 1487|  29.8k|    uninit_avctx(vd);
 1488|       |
 1489|  29.8k|    mp_mutex_destroy(&ctx->dr_lock);
  ------------------
  |  |  133|  29.8k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1490|  29.8k|}
vd_lavc.c:uninit_avctx:
  937|  59.6k|{
  938|  59.6k|    vd_ffmpeg_ctx *ctx = vd->priv;
  939|       |
  940|  59.6k|    flush_all(vd);
  941|  59.6k|    av_frame_free(&ctx->pic);
  942|  59.6k|    mp_free_av_packet(&ctx->avpkt);
  943|  59.6k|    av_buffer_unref(&ctx->cached_hw_frames_ctx);
  944|       |
  945|  59.6k|    avcodec_free_context(&ctx->avctx);
  946|       |
  947|  59.6k|    av_buffer_unref(&ctx->hwdec_dev);
  948|       |
  949|  59.6k|    ctx->hwdec_failed = false;
  950|  59.6k|    ctx->hwdec_fail_count = 0;
  951|  59.6k|    ctx->max_delay_queue = 0;
  952|  59.6k|    ctx->hw_probing = false;
  953|  59.6k|    ctx->hwdec = (struct hwdec_info){0};
  954|       |    ctx->use_hwdec = false;
  955|  59.6k|}
vd_lavc.c:flush_all:
  918|  5.04M|{
  919|  5.04M|    vd_ffmpeg_ctx *ctx = vd->priv;
  920|       |
  921|  5.04M|    for (int n = 0; n < ctx->num_delay_queue; n++)
  ------------------
  |  Branch (921:21): [True: 0, False: 5.04M]
  ------------------
  922|      0|        talloc_free(ctx->delay_queue[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  923|  5.04M|    ctx->num_delay_queue = 0;
  924|       |
  925|  5.04M|    for (int n = 0; n < ctx->num_sent_packets; n++)
  ------------------
  |  Branch (925:21): [True: 0, False: 5.04M]
  ------------------
  926|      0|        talloc_free(ctx->sent_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  927|  5.04M|    ctx->num_sent_packets = 0;
  928|       |
  929|  5.04M|    for (int n = 0; n < ctx->num_requeue_packets; n++)
  ------------------
  |  Branch (929:21): [True: 0, False: 5.04M]
  ------------------
  930|      0|        talloc_free(ctx->requeue_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  931|  5.04M|    ctx->num_requeue_packets = 0;
  932|       |
  933|  5.04M|    reset_avctx(vd);
  934|  5.04M|}
vd_lavc.c:reset_avctx:
  905|  5.04M|{
  906|  5.04M|    vd_ffmpeg_ctx *ctx = vd->priv;
  907|       |
  908|  5.04M|    if (ctx->avctx && avcodec_is_open(ctx->avctx))
  ------------------
  |  Branch (908:9): [True: 5.01M, False: 29.8k]
  |  Branch (908:23): [True: 5.01M, False: 0]
  ------------------
  909|  5.01M|        avcodec_flush_buffers(ctx->avctx);
  910|  5.04M|    ctx->flushing = false;
  911|  5.04M|    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|  5.04M|    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: 5.04M]
  ------------------
  915|  5.04M|}
vd_lavc.c:vd_lavc_process:
 1467|  5.12M|{
 1468|  5.12M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1469|       |
 1470|  5.12M|    lavc_process(vd, &ctx->state, send_packet, receive_frame);
 1471|  5.12M|}
vd_lavc.c:send_packet:
 1224|  39.3k|{
 1225|  39.3k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1226|  39.3k|    AVCodecContext *avctx = ctx->avctx;
 1227|       |
 1228|  39.3k|    if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt)
  ------------------
  |  Branch (1228:9): [True: 0, False: 39.3k]
  |  Branch (1228:37): [True: 0, False: 0]
  ------------------
 1229|      0|        return AVERROR(EAGAIN); // cannot consume the packet
 1230|       |
 1231|  39.3k|    if (ctx->hwdec_failed)
  ------------------
  |  Branch (1231:9): [True: 0, False: 39.3k]
  ------------------
 1232|      0|        return AVERROR(EAGAIN);
 1233|       |
 1234|  39.3k|    if (!ctx->avctx)
  ------------------
  |  Branch (1234:9): [True: 0, False: 39.3k]
  ------------------
 1235|      0|        return AVERROR_EOF;
 1236|       |
 1237|  39.3k|    prepare_decoding(vd);
 1238|       |
 1239|  39.3k|    if (ctx->wait_for_keyframe > 0 && pkt) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 39.3k]
  |  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|  39.3k|    if (avctx->skip_frame == AVDISCARD_ALL)
  ------------------
  |  Branch (1248:9): [True: 0, False: 39.3k]
  ------------------
 1249|      0|        return 0;
 1250|       |
 1251|  39.3k|    mp_set_av_packet(ctx->avpkt, pkt, &ctx->codec_timebase);
 1252|       |
 1253|  39.3k|    int ret = avcodec_send_packet(avctx, pkt ? ctx->avpkt : NULL);
  ------------------
  |  Branch (1253:42): [True: 38.5k, False: 757]
  ------------------
 1254|  39.3k|    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
  ------------------
  |  Branch (1254:9): [True: 0, False: 39.3k]
  |  Branch (1254:35): [True: 0, False: 39.3k]
  ------------------
 1255|      0|        return ret;
 1256|       |
 1257|  39.3k|    if (ctx->hw_probing && ctx->num_sent_packets < 32 &&
  ------------------
  |  Branch (1257:9): [True: 0, False: 39.3k]
  |  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|  39.3k|    if (ret < 0)
  ------------------
  |  Branch (1264:9): [True: 0, False: 39.3k]
  ------------------
 1265|      0|        handle_err(vd);
 1266|  39.3k|    return ret;
 1267|  39.3k|}
vd_lavc.c:prepare_decoding:
 1184|  5.14M|{
 1185|  5.14M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1186|  5.14M|    AVCodecContext *avctx = ctx->avctx;
 1187|  5.14M|    struct vd_lavc_params *opts = ctx->opts;
 1188|       |
 1189|  5.14M|    if (!avctx)
  ------------------
  |  Branch (1189:9): [True: 0, False: 5.14M]
  ------------------
 1190|      0|        return;
 1191|       |
 1192|  5.14M|    int drop = ctx->framedrop_flags;
 1193|  5.14M|    if (drop == 1) {
  ------------------
  |  Branch (1193:9): [True: 0, False: 5.14M]
  ------------------
 1194|      0|        avctx->skip_frame = opts->framedrop;    // normal framedrop
 1195|  5.14M|    } else if (drop == 2) {
  ------------------
  |  Branch (1195:16): [True: 0, False: 5.14M]
  ------------------
 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|  5.14M|    } else {
 1201|  5.14M|        avctx->skip_frame = ctx->skip_frame;    // normal playback
 1202|  5.14M|    }
 1203|       |
 1204|  5.14M|    if (ctx->hwdec_request_reinit)
  ------------------
  |  Branch (1204:9): [True: 0, False: 5.14M]
  ------------------
 1205|      0|        reset_avctx(vd);
 1206|  5.14M|}
vd_lavc.c:receive_frame:
 1345|  5.10M|{
 1346|  5.10M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1347|       |
 1348|  5.10M|    int ret = decode_frame(vd);
 1349|       |
 1350|  5.10M|    if (ctx->hwdec_failed) {
  ------------------
  |  Branch (1350:9): [True: 0, False: 5.10M]
  ------------------
 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|  5.10M|    if (ret == AVERROR(EAGAIN) && ctx->num_requeue_packets)
  ------------------
  |  Branch (1377:9): [True: 5.06M, False: 39.3k]
  |  Branch (1377:35): [True: 0, False: 5.06M]
  ------------------
 1378|      0|        return 0; // force retry, so send_queued_packet() gets called
 1379|       |
 1380|  5.10M|    if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF)
  ------------------
  |  Branch (1380:9): [True: 5.06M, False: 38.5k]
  |  Branch (1380:57): [True: 5.06M, False: 757]
  ------------------
 1381|  5.06M|        return ret;
 1382|       |
 1383|  39.3k|    if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1383:9): [True: 757, False: 38.5k]
  ------------------
 1384|    757|        return ret;
 1385|       |
 1386|  38.5k|    struct mp_image *res = ctx->delay_queue[0];
 1387|  38.5k|    MP_TARRAY_REMOVE_AT(ctx->delay_queue, ctx->num_delay_queue, 0);
  ------------------
  |  |  143|  38.5k|    do {                                            \
  |  |  144|  38.5k|        size_t at_ = (at);                          \
  |  |  145|  38.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  38.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  38.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  38.5k|        (idxvar)--;                                 \
  |  |  149|  38.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 38.5k]
  |  |  ------------------
  ------------------
  |  Branch (1387:5): [True: 38.5k, False: 0]
  ------------------
 1388|       |
 1389|  38.5k|    res = res ? mp_img_swap_to_native(res) : NULL;
  ------------------
  |  Branch (1389:11): [True: 38.5k, False: 0]
  ------------------
 1390|  38.5k|    if (!res)
  ------------------
  |  Branch (1390:9): [True: 0, False: 38.5k]
  ------------------
 1391|      0|        return AVERROR_UNKNOWN;
 1392|       |
 1393|  38.5k|    if (ctx->use_hwdec && ctx->hwdec.copying && res->hwctx) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 38.5k]
  |  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|  38.5k|    if (!ctx->hwdec_notified) {
  ------------------
  |  Branch (1405:9): [True: 15.8k, False: 22.7k]
  ------------------
 1406|  15.8k|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1406:13): [True: 0, False: 15.8k]
  ------------------
 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|  15.8k|        } else {
 1410|  15.8k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  15.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  15.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1411|  15.8k|        }
 1412|  15.8k|        ctx->hwdec_notified = true;
 1413|  15.8k|    }
 1414|       |
 1415|  38.5k|    if (ctx->hw_probing) {
  ------------------
  |  Branch (1415:9): [True: 0, False: 38.5k]
  ------------------
 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|  38.5k|    *out_frame = MAKE_FRAME(MP_FRAME_VIDEO, res);
  ------------------
  |  |   57|  38.5k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1423|  38.5k|    return 0;
 1424|  38.5k|}
vd_lavc.c:decode_frame:
 1283|  5.10M|{
 1284|  5.10M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1285|  5.10M|    AVCodecContext *avctx = ctx->avctx;
 1286|       |
 1287|  5.10M|    if (!avctx || ctx->force_eof)
  ------------------
  |  Branch (1287:9): [True: 0, False: 5.10M]
  |  Branch (1287:19): [True: 0, False: 5.10M]
  ------------------
 1288|      0|        return AVERROR_EOF;
 1289|       |
 1290|  5.10M|    prepare_decoding(vd);
 1291|       |
 1292|       |    // Re-send old packets (typically after a hwdec fallback during init).
 1293|  5.10M|    if (ctx->num_requeue_packets)
  ------------------
  |  Branch (1293:9): [True: 0, False: 5.10M]
  ------------------
 1294|      0|        send_queued_packet(vd);
 1295|       |
 1296|  5.10M|    int ret = avcodec_receive_frame(avctx, ctx->pic);
 1297|  5.10M|    if (ret < 0) {
  ------------------
  |  Branch (1297:9): [True: 5.06M, False: 38.5k]
  ------------------
 1298|  5.06M|        if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (1298:13): [True: 757, False: 5.06M]
  ------------------
 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|    757|            if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1303:17): [True: 757, False: 0]
  ------------------
 1304|    757|                reset_avctx(vd);
 1305|  5.06M|        } else if (ret == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1305:20): [True: 5.06M, False: 0]
  ------------------
 1306|       |            // just retry after caller writes a packet
 1307|  5.06M|        } else {
 1308|      0|            handle_err(vd);
 1309|      0|        }
 1310|  5.06M|        return ret;
 1311|  5.06M|    }
 1312|       |
 1313|  38.5k|    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|  38.5k|    mp_assert(ctx->pic->buf[0]);
  ------------------
  |  |   41|  38.5k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 38.5k, False: 0]
  ------------------
 1318|       |
 1319|  38.5k|    struct mp_image *mpi = mp_image_from_av_frame(ctx->pic);
 1320|  38.5k|    if (!mpi) {
  ------------------
  |  Branch (1320:9): [True: 0, False: 38.5k]
  ------------------
 1321|      0|        av_frame_unref(ctx->pic);
 1322|      0|        return ret;
 1323|      0|    }
 1324|       |
 1325|  38.5k|    if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 38.5k]
  |  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|  38.5k|    ctx->hwdec_fail_count = 0;
 1333|       |
 1334|  38.5k|    mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
 1335|  38.5k|    mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
 1336|  38.5k|    mpi->pkt_duration = mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
 1337|       |
 1338|  38.5k|    av_frame_unref(ctx->pic);
 1339|       |
 1340|  38.5k|    MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi);
  ------------------
  |  |  105|  38.5k|    do {                                            \
  |  |  106|  38.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  38.5k|    do {                                            \
  |  |  |  |   97|  38.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  38.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  38.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  38.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 15.8k, False: 22.7k]
  |  |  |  |  ------------------
  |  |  |  |   99|  38.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  15.8k|    do {                                                        \
  |  |  |  |  |  |   89|  15.8k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  15.8k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  15.8k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  15.8k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  15.8k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  15.8k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  15.8k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 15.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  38.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 38.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  38.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  38.5k|        (idxvar)++;                                 \
  |  |  109|  38.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 38.5k]
  |  |  ------------------
  ------------------
 1341|  38.5k|    return ret;
 1342|  38.5k|}
vd_lavc.c:select_and_set_hwdec:
  504|  29.8k|{
  505|  29.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
  506|  29.8k|    const char *codec = ctx->codec->codec;
  507|       |
  508|  29.8k|    m_config_cache_update(ctx->hwdec_opts_cache);
  509|       |
  510|  29.8k|    struct hwdec_info *hwdecs = NULL;
  511|  29.8k|    int num_hwdecs = 0;
  512|  29.8k|    add_all_hwdec_methods(&hwdecs, &num_hwdecs);
  513|       |
  514|  29.8k|    char **hwdec_api = ctx->hwdec_opts->hwdec_api;
  515|  29.8k|    for (int i = 0; hwdec_api && hwdec_api[i]; i++) {
  ------------------
  |  Branch (515:21): [True: 29.8k, False: 0]
  |  Branch (515:34): [True: 29.8k, False: 0]
  ------------------
  516|  29.8k|        bstr opt = bstr0(hwdec_api[i]);
  517|       |
  518|  29.8k|        bool hwdec_requested = !bstr_equals0(opt, "no");
  519|  29.8k|        bool hwdec_auto_safe = bstr_equals0(opt, "auto") ||
  ------------------
  |  Branch (519:32): [True: 0, False: 29.8k]
  ------------------
  520|  29.8k|                            bstr_equals0(opt, "auto-safe") ||
  ------------------
  |  Branch (520:29): [True: 0, False: 29.8k]
  ------------------
  521|  29.8k|                            bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (521:29): [True: 0, False: 29.8k]
  ------------------
  522|  29.8k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (522:29): [True: 0, False: 29.8k]
  ------------------
  523|  29.8k|                            bstr_equals0(opt, "yes") ||
  ------------------
  |  Branch (523:29): [True: 0, False: 29.8k]
  ------------------
  524|  29.8k|                            bstr_equals0(opt, "");
  ------------------
  |  Branch (524:29): [True: 1, False: 29.8k]
  ------------------
  525|  29.8k|        bool hwdec_auto_unsafe = bstr_equals0(opt, "auto-unsafe");
  526|  29.8k|        bool hwdec_auto_copy = bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (526:32): [True: 0, False: 29.8k]
  ------------------
  527|  29.8k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (527:29): [True: 0, False: 29.8k]
  ------------------
  528|  29.8k|                            bstr_equals0(opt, "auto-copy-unsafe");
  ------------------
  |  Branch (528:29): [True: 0, False: 29.8k]
  ------------------
  529|  29.8k|        bool hwdec_auto = hwdec_auto_unsafe || hwdec_auto_copy || hwdec_auto_safe;
  ------------------
  |  Branch (529:27): [True: 0, False: 29.8k]
  |  Branch (529:48): [True: 0, False: 29.8k]
  |  Branch (529:67): [True: 1, False: 29.8k]
  ------------------
  530|       |
  531|  29.8k|        if (!hwdec_requested) {
  ------------------
  |  Branch (531:13): [True: 29.8k, False: 10]
  ------------------
  532|  29.8k|            MP_VERBOSE(vd, "No hardware decoding requested.\n");
  ------------------
  |  |   92|  29.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  29.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  533|  29.8k|            break;
  534|  29.8k|        } else if (!hwdec_codec_allowed(vd, codec)) {
  ------------------
  |  Branch (534:20): [True: 10, False: 0]
  ------------------
  535|     10|            MP_VERBOSE(vd, "Not trying to use hardware decoding: codec %s is not "
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  536|     10|                    "on whitelist.\n", codec);
  537|     10|            break;
  538|     10|        } 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|  29.8k|    }
  635|  29.8k|    talloc_free(hwdecs);
  ------------------
  |  |   47|  29.8k|#define talloc_free                     ta_free
  ------------------
  636|       |
  637|       |
  638|  29.8k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (638:9): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|    } 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|  29.8k|        if (ctx->hwdec_opts->software_fallback == INT_MAX) {
  ------------------
  |  Branch (646:13): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|        } else {
  650|  29.8k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  29.8k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  29.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  651|  29.8k|        }
  652|  29.8k|    }
  653|  29.8k|}
vd_lavc.c:hwdec_codec_allowed:
  451|     10|{
  452|     10|    vd_ffmpeg_ctx *ctx = vd->priv;
  453|     10|    bstr s = bstr0(ctx->hwdec_opts->hwdec_codecs);
  454|    120|    while (s.len) {
  ------------------
  |  Branch (454:12): [True: 110, False: 10]
  ------------------
  455|    110|        bstr item;
  456|    110|        bstr_split_tok(s, ",", &item, &s);
  457|    110|        if (bstr_equals0(item, "all") || bstr_equals0(item, codec))
  ------------------
  |  Branch (457:13): [True: 0, False: 110]
  |  Branch (457:42): [True: 0, False: 110]
  ------------------
  458|      0|            return true;
  459|    110|    }
  460|     10|    return false;
  461|     10|}
vd_lavc.c:init_avctx:
  728|  29.8k|{
  729|  29.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
  730|  29.8k|    struct vd_lavc_params *lavc_param = ctx->opts;
  731|  29.8k|    struct mp_codec_params *c = ctx->codec;
  732|       |
  733|  29.8k|    m_config_cache_update(ctx->opts_cache);
  734|       |
  735|  29.8k|    mp_assert(!ctx->avctx);
  ------------------
  |  |   41|  29.8k|#define mp_assert assert
  ------------------
  |  Branch (735:5): [True: 29.8k, False: 0]
  ------------------
  736|       |
  737|  29.8k|    const AVCodec *lavc_codec = NULL;
  738|       |
  739|  29.8k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (739:9): [True: 0, False: 29.8k]
  ------------------
  740|      0|        lavc_codec = ctx->hwdec.codec;
  741|  29.8k|    } else {
  742|  29.8k|        lavc_codec = avcodec_find_decoder_by_name(ctx->decoder);
  743|  29.8k|    }
  744|  29.8k|    if (!lavc_codec)
  ------------------
  |  Branch (744:9): [True: 0, False: 29.8k]
  ------------------
  745|      0|        return;
  746|       |
  747|  29.8k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id);
  748|  29.8k|    ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY);
  ------------------
  |  Branch (748:23): [True: 29.8k, False: 0]
  |  Branch (748:31): [True: 0, False: 29.8k]
  ------------------
  749|       |
  750|  29.8k|    ctx->codec_timebase = mp_get_codec_timebase(ctx->codec);
  751|       |
  752|  29.8k|    ctx->hwdec_failed = false;
  753|  29.8k|    ctx->hwdec_request_reinit = false;
  754|  29.8k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  755|  29.8k|    AVCodecContext *avctx = ctx->avctx;
  756|  29.8k|    if (!ctx->avctx)
  ------------------
  |  Branch (756:9): [True: 0, False: 29.8k]
  ------------------
  757|      0|        goto error;
  758|  29.8k|    avctx->codec_type = AVMEDIA_TYPE_VIDEO;
  759|  29.8k|    avctx->codec_id = lavc_codec->id;
  760|  29.8k|    avctx->pkt_timebase = ctx->codec_timebase;
  761|       |
  762|  29.8k|    ctx->pic = av_frame_alloc();
  763|  29.8k|    if (!ctx->pic)
  ------------------
  |  Branch (763:9): [True: 0, False: 29.8k]
  ------------------
  764|      0|        goto error;
  765|       |
  766|  29.8k|    ctx->avpkt = av_packet_alloc();
  767|  29.8k|    if (!ctx->avpkt)
  ------------------
  |  Branch (767:9): [True: 0, False: 29.8k]
  ------------------
  768|      0|        goto error;
  769|       |
  770|  29.8k|    int threads = lavc_param->threads;
  771|  29.8k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (771:9): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|    mp_set_avcodec_threads(vd->log, avctx, threads);
  820|       |
  821|  29.8k|    if (!ctx->use_hwdec && ctx->vo && lavc_param->dr) {
  ------------------
  |  Branch (821:9): [True: 29.8k, False: 0]
  |  Branch (821:28): [True: 29.8k, False: 0]
  |  Branch (821:39): [True: 29.8k, False: 1]
  ------------------
  822|  29.8k|        avctx->opaque = vd;
  823|  29.8k|        avctx->get_buffer2 = get_buffer2_direct;
  824|  29.8k|    }
  825|       |
  826|  29.8k|    avctx->flags |= lavc_param->bitexact ? AV_CODEC_FLAG_BITEXACT : 0;
  ------------------
  |  Branch (826:21): [True: 0, False: 29.8k]
  ------------------
  827|  29.8k|    avctx->flags2 |= lavc_param->fast ? AV_CODEC_FLAG2_FAST : 0;
  ------------------
  |  Branch (827:22): [True: 0, False: 29.8k]
  ------------------
  828|       |
  829|  29.8k|    if (lavc_param->show_all)
  ------------------
  |  Branch (829:9): [True: 13, False: 29.8k]
  ------------------
  830|     13|        avctx->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT;
  831|       |
  832|  29.8k|    avctx->skip_loop_filter = lavc_param->skip_loop_filter;
  833|  29.8k|    avctx->skip_idct = lavc_param->skip_idct;
  834|  29.8k|    avctx->skip_frame = lavc_param->skip_frame;
  835|  29.8k|    avctx->apply_cropping = lavc_param->apply_cropping;
  836|       |
  837|  29.8k|    if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
  ------------------
  |  Branch (837:9): [True: 0, False: 29.8k]
  |  Branch (837:47): [True: 0, False: 0]
  ------------------
  838|      0|        av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
  839|       |
  840|  29.8k|    switch(ctx->opts->film_grain) {
  841|      2|    case 0: /*CPU*/
  ------------------
  |  Branch (841:5): [True: 2, False: 29.8k]
  ------------------
  842|       |        // default lavc flags handle film grain within the decoder.
  843|      2|        break;
  844|      1|    case 1: /*GPU*/
  ------------------
  |  Branch (844:5): [True: 1, False: 29.8k]
  ------------------
  845|      1|        if (!ctx->vo ||
  ------------------
  |  Branch (845:13): [True: 0, False: 1]
  ------------------
  846|      1|            (ctx->vo && !(ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))) {
  ------------------
  |  Branch (846:14): [True: 1, False: 0]
  |  Branch (846:25): [True: 1, False: 0]
  ------------------
  847|      1|            MP_MSG(vd, ctx->vo ? MSGL_WARN : MSGL_V,
  ------------------
  |  |   86|      2|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (86:52): [True: 1, False: 0]
  |  |  |  Branch (86:57): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  848|      1|                   "GPU film grain requested, but VO %s, expect wrong output.\n",
  849|      1|                   ctx->vo ?
  850|      1|                   "does not support applying film grain" :
  851|      1|                   "is not available at decoder initialization to verify support");
  852|      1|        }
  853|       |
  854|      1|        avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  855|      1|        break;
  856|  29.8k|    default:
  ------------------
  |  Branch (856:5): [True: 29.8k, False: 3]
  ------------------
  857|  29.8k|        if (ctx->vo && (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))
  ------------------
  |  Branch (857:13): [True: 29.8k, False: 0]
  |  Branch (857:24): [True: 0, False: 29.8k]
  ------------------
  858|      0|            avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  859|       |
  860|  29.8k|        break;
  861|  29.8k|    }
  862|       |
  863|  29.8k|    mp_set_avopts(vd->log, avctx, lavc_param->avopts);
  864|       |
  865|       |    // Do this after the above avopt handling in case it changes values
  866|  29.8k|    ctx->skip_frame = avctx->skip_frame;
  867|       |
  868|  29.8k|    if (mp_set_avctx_codec_headers(avctx, c) < 0) {
  ------------------
  |  Branch (868:9): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  874|  29.8k|    if (avctx->width > 8192 || avctx->height > 8192) {
  ------------------
  |  Branch (874:9): [True: 0, False: 29.8k]
  |  Branch (874:32): [True: 0, False: 29.8k]
  ------------------
  875|      0|        MP_ERR(vd, "Frame size too big %" PRIu32 "x%" PRIu32 ".\n", avctx->width, avctx->height);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  876|      0|        goto error;
  877|      0|    }
  878|  29.8k|    avctx->max_pixels = 2048 * 2048;
  879|  29.8k|#endif
  880|       |
  881|       |    /* open it */
  882|  29.8k|    if (avcodec_open2(avctx, lavc_codec, NULL) < 0)
  ------------------
  |  Branch (882:9): [True: 0, False: 29.8k]
  ------------------
  883|      0|        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|  29.8k|    if (lavc_codec->id == AV_CODEC_ID_H264 && c->first_packet) {
  ------------------
  |  Branch (889:9): [True: 0, False: 29.8k]
  |  Branch (889:47): [True: 0, False: 0]
  ------------------
  890|      0|        mp_set_av_packet(ctx->avpkt, c->first_packet, &ctx->codec_timebase);
  891|      0|        avcodec_send_packet(avctx, ctx->avpkt);
  892|      0|        avcodec_receive_frame(avctx, ctx->pic);
  893|      0|        av_frame_unref(ctx->pic);
  894|      0|        avcodec_flush_buffers(ctx->avctx);
  895|      0|    }
  896|       |
  897|  29.8k|    return;
  898|       |
  899|      0|error:
  900|      0|    MP_ERR(vd, "Could not open 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__)
  |  |  ------------------
  ------------------
  901|      0|    uninit_avctx(vd);
  902|      0|}
vd_lavc.c:vd_lavc_reset:
 1474|  4.98M|{
 1475|  4.98M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1476|       |
 1477|  4.98M|    flush_all(vd);
 1478|       |
 1479|  4.98M|    ctx->state = (struct lavc_state){0};
 1480|  4.98M|    ctx->framedrop_flags = 0;
 1481|  4.98M|}
vd_lavc.c:control:
 1427|  8.20M|{
 1428|  8.20M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1429|  8.20M|    switch (cmd) {
  ------------------
  |  Branch (1429:13): [True: 8.20M, False: 0]
  ------------------
 1430|  2.52M|    case VDCTRL_SET_FRAMEDROP:
  ------------------
  |  Branch (1430:5): [True: 2.52M, False: 5.67M]
  ------------------
 1431|  2.52M|        ctx->framedrop_flags = *(int *)arg;
 1432|  2.52M|        return CONTROL_TRUE;
  ------------------
  |  |   96|  2.52M|#define CONTROL_TRUE 1
  ------------------
 1433|      0|    case VDCTRL_SET_EXTRA_HW_FRAMES:
  ------------------
  |  Branch (1433:5): [True: 0, False: 8.20M]
  ------------------
 1434|      0|        ctx->extra_hw_frames_hint = *(int *)arg;
 1435|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1436|  2.82M|    case VDCTRL_CHECK_FORCED_EOF: {
  ------------------
  |  Branch (1436:5): [True: 2.82M, False: 5.38M]
  ------------------
 1437|  2.82M|        *(bool *)arg = ctx->force_eof;
 1438|  2.82M|        return CONTROL_TRUE;
  ------------------
  |  |   96|  2.82M|#define CONTROL_TRUE 1
  ------------------
 1439|      0|    }
 1440|      0|    case VDCTRL_GET_BFRAMES: {
  ------------------
  |  Branch (1440:5): [True: 0, False: 8.20M]
  ------------------
 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|  2.85M|    case VDCTRL_GET_HWDEC: {
  ------------------
  |  Branch (1447:5): [True: 2.85M, False: 5.35M]
  ------------------
 1448|  2.85M|        if (!ctx->hwdec_notified)
  ------------------
  |  Branch (1448:13): [True: 1.38M, False: 1.47M]
  ------------------
 1449|  1.38M|            return CONTROL_FALSE;
  ------------------
  |  |   97|  1.38M|#define CONTROL_FALSE 0
  ------------------
 1450|  1.47M|        *(char **)arg = ctx->use_hwdec ? ctx->hwdec.method_name : NULL;
  ------------------
  |  Branch (1450:25): [True: 0, False: 1.47M]
  ------------------
 1451|  1.47M|        return CONTROL_TRUE;
  ------------------
  |  |   96|  1.47M|#define CONTROL_TRUE 1
  ------------------
 1452|  2.85M|    }
 1453|      0|    case VDCTRL_FORCE_HWDEC_FALLBACK:
  ------------------
  |  Branch (1453:5): [True: 0, False: 8.20M]
  ------------------
 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|     11|    case VDCTRL_REINIT:
  ------------------
  |  Branch (1459:5): [True: 11, False: 8.20M]
  ------------------
 1460|     11|        reinit(vd);
 1461|     11|        return CONTROL_TRUE;
  ------------------
  |  |   96|     11|#define CONTROL_TRUE 1
  ------------------
 1462|  8.20M|    }
 1463|      0|    return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1464|  8.20M|}
vd_lavc.c:reinit:
  696|  29.8k|{
  697|  29.8k|    vd_ffmpeg_ctx *ctx = vd->priv;
  698|       |
  699|  29.8k|    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|  29.8k|    TA_FREEP(&ctx->attempted_hwdecs);
  ------------------
  |  |   81|  29.8k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  29.8k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 29.8k]
  |  |  ------------------
  ------------------
  708|  29.8k|    ctx->num_attempted_hwdecs = 0;
  709|  29.8k|    ctx->hwdec_notified = false;
  710|       |
  711|  29.8k|    select_and_set_hwdec(vd);
  712|       |
  713|  29.8k|    bool use_hwdec = ctx->use_hwdec;
  714|  29.8k|    init_avctx(vd);
  715|  29.8k|    if (!ctx->avctx && use_hwdec) {
  ------------------
  |  Branch (715:9): [True: 0, False: 29.8k]
  |  Branch (715:24): [True: 0, False: 0]
  ------------------
  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|  29.8k|    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: 29.8k]
  ------------------
  725|  29.8k|}
vd_lavc.c:add_decoders:
 1550|  29.8k|{
 1551|  29.8k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_VIDEO);
 1552|  29.8k|}

vf_format.c:vf_format_create:
  239|    909|{
  240|    909|    struct mp_filter *f = mp_filter_create(parent, &vf_format_filter);
  241|    909|    if (!f) {
  ------------------
  |  Branch (241:9): [True: 0, False: 909]
  ------------------
  242|      0|        talloc_free(options);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  243|      0|        return NULL;
  244|      0|    }
  245|       |
  246|    909|    struct priv *priv = f->priv;
  247|    909|    priv->opts = talloc_steal(priv, options);
  ------------------
  |  |   38|    909|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|    909|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  248|       |
  249|    909|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  250|    909|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  251|       |
  252|    909|    priv->conv = mp_autoconvert_create(f);
  253|    909|    if (!priv->conv) {
  ------------------
  |  Branch (253:9): [True: 0, False: 909]
  ------------------
  254|      0|        talloc_free(f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  255|      0|        return NULL;
  256|      0|    }
  257|       |
  258|    909|    priv->conv->force_scaler = priv->opts->force_scaler;
  259|       |
  260|    909|    if (priv->opts->fmt)
  ------------------
  |  Branch (260:9): [True: 0, False: 909]
  ------------------
  261|      0|        mp_autoconvert_add_imgfmt(priv->conv, priv->opts->fmt, 0);
  262|       |
  263|    909|    return f;
  264|    909|}
vf_format.c:vf_format_process:
  136|   260k|{
  137|   260k|    struct priv *priv = f->priv;
  138|       |
  139|   260k|    if (mp_pin_can_transfer_data(priv->conv->f->pins[0], f->ppins[0])) {
  ------------------
  |  Branch (139:9): [True: 64.8k, False: 195k]
  ------------------
  140|  64.8k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  141|       |
  142|  64.8k|        if (priv->opts->convert && frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (142:13): [True: 0, False: 64.8k]
  |  Branch (142:36): [True: 0, False: 0]
  ------------------
  143|      0|            struct mp_image *img = frame.data;
  144|      0|            struct mp_image_params par = img->params;
  145|      0|            int outfmt = priv->opts->fmt;
  146|       |
  147|       |            // If we convert from RGB to YUV, default to limited range.
  148|      0|            if (mp_imgfmt_get_forced_csp(img->imgfmt) == PL_COLOR_SYSTEM_RGB &&
  ------------------
  |  Branch (148:17): [True: 0, False: 0]
  ------------------
  149|      0|                outfmt && mp_imgfmt_get_forced_csp(outfmt) == PL_COLOR_SYSTEM_UNKNOWN)
  ------------------
  |  Branch (149:17): [True: 0, False: 0]
  |  Branch (149:27): [True: 0, False: 0]
  ------------------
  150|      0|            {
  151|      0|                par.repr.levels = PL_COLOR_LEVELS_LIMITED;
  152|      0|            }
  153|       |
  154|      0|            set_params(priv->opts, &par, true);
  155|       |
  156|      0|            if (outfmt && par.imgfmt != outfmt) {
  ------------------
  |  Branch (156:17): [True: 0, False: 0]
  |  Branch (156:27): [True: 0, False: 0]
  ------------------
  157|      0|                par.imgfmt = outfmt;
  158|      0|                par.hw_subfmt = 0;
  159|      0|            }
  160|      0|            mp_image_params_guess_csp(&par);
  161|       |
  162|      0|            mp_autoconvert_set_target_image_params(priv->conv, &par);
  163|      0|        }
  164|       |
  165|  64.8k|        mp_pin_in_write(priv->conv->f->pins[0], frame);
  166|  64.8k|    }
  167|       |
  168|   260k|    if (mp_pin_can_transfer_data(f->ppins[1], priv->conv->f->pins[1])) {
  ------------------
  |  Branch (168:9): [True: 64.8k, False: 195k]
  ------------------
  169|  64.8k|        struct mp_frame frame = mp_pin_out_read(priv->conv->f->pins[1]);
  170|  64.8k|        struct mp_image *img = frame.data;
  171|       |
  172|  64.8k|        if (frame.type != MP_FRAME_VIDEO)
  ------------------
  |  Branch (172:13): [True: 64.1k, False: 703]
  ------------------
  173|  64.1k|            goto write_out;
  174|       |
  175|    703|        if (!priv->opts->convert) {
  ------------------
  |  Branch (175:13): [True: 703, False: 0]
  ------------------
  176|    703|            set_params(priv->opts, &img->params, false);
  177|    703|            mp_image_params_guess_csp(&img->params);
  178|    703|        }
  179|       |
  180|    703|        if (!priv->opts->dovi) {
  ------------------
  |  Branch (180:13): [True: 0, False: 703]
  ------------------
  181|      0|            mp_image_params_restore_dovi_mapping(&img->params);
  182|       |            // Map again to strip any DV metadata set to common fields.
  183|      0|            img->params.color.hdr = (struct pl_hdr_metadata){0};
  184|      0|            pl_map_hdr_metadata(&img->params.color.hdr, &(struct pl_av_hdr_metadata) {
  185|      0|                .mdm = get_side_data(img, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA),
  186|      0|                .clm = get_side_data(img, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL),
  187|      0|                .dhp = get_side_data(img, AV_FRAME_DATA_DYNAMIC_HDR_PLUS),
  188|      0|            });
  189|       |            // Tell the f_enhancement_pair filter to not inherit DV metadata
  190|       |            // from the EL.
  191|      0|            img->params.no_dovi = true;
  192|      0|        }
  193|       |
  194|    703|        if (!priv->opts->enhancement_layer) {
  ------------------
  |  Branch (194:13): [True: 0, False: 703]
  ------------------
  195|       |            // This is no-op, but just in case. f_enhancement_pair runs at the
  196|       |            // end of chain.
  197|      0|            mp_image_unrefp(&img->enhancement_layer);
  198|      0|            img->params.no_enhancement_layer = true;
  199|      0|        }
  200|       |
  201|    703|        if (!priv->opts->hdr10plus) {
  ------------------
  |  Branch (201:13): [True: 0, False: 703]
  ------------------
  202|      0|            memset(img->params.color.hdr.scene_max, 0,
  203|      0|                   sizeof(img->params.color.hdr.scene_max));
  204|      0|            img->params.color.hdr.scene_avg = 0;
  205|      0|            img->params.color.hdr.ootf = (struct pl_hdr_bezier){0};
  206|      0|            if (img->params.repr.sys != PL_COLOR_SYSTEM_DOLBYVISION) {
  ------------------
  |  Branch (206:17): [True: 0, False: 0]
  ------------------
  207|      0|                img->params.color.hdr.max_pq_y = 0;
  208|      0|                img->params.color.hdr.avg_pq_y = 0;
  209|      0|            }
  210|      0|        }
  211|       |
  212|    703|        if (priv->opts->min_luma)
  ------------------
  |  Branch (212:13): [True: 0, False: 703]
  ------------------
  213|      0|            img->params.color.hdr.min_luma = priv->opts->min_luma;
  214|       |
  215|    703|        if (priv->opts->max_luma)
  ------------------
  |  Branch (215:13): [True: 0, False: 703]
  ------------------
  216|      0|            img->params.color.hdr.max_luma = priv->opts->max_luma;
  217|       |
  218|    703|        if (priv->opts->max_cll)
  ------------------
  |  Branch (218:13): [True: 0, False: 703]
  ------------------
  219|      0|            img->params.color.hdr.max_cll = priv->opts->max_cll;
  220|       |
  221|    703|        if (priv->opts->max_fall)
  ------------------
  |  Branch (221:13): [True: 0, False: 703]
  ------------------
  222|      0|            img->params.color.hdr.max_fall = priv->opts->max_fall;
  223|       |
  224|    703|        if (!priv->opts->film_grain)
  ------------------
  |  Branch (224:13): [True: 0, False: 703]
  ------------------
  225|      0|            av_buffer_unref(&img->film_grain);
  226|       |
  227|  64.8k|write_out:
  228|  64.8k|        mp_pin_in_write(f->ppins[1], frame);
  229|  64.8k|    }
  230|   260k|}
vf_format.c:set_params:
   74|    703|{
   75|    703|    if (p->colormatrix)
  ------------------
  |  Branch (75:9): [True: 0, False: 703]
  ------------------
   76|      0|        out->repr.sys = p->colormatrix;
   77|    703|    if (p->colorlevels)
  ------------------
  |  Branch (77:9): [True: 0, False: 703]
  ------------------
   78|      0|        out->repr.levels = p->colorlevels;
   79|    703|    if (p->primaries)
  ------------------
  |  Branch (79:9): [True: 0, False: 703]
  ------------------
   80|      0|        out->color.primaries = p->primaries;
   81|    703|    if (p->gamma) {
  ------------------
  |  Branch (81:9): [True: 0, False: 703]
  ------------------
   82|      0|        enum pl_color_transfer in_gamma = p->gamma;
   83|      0|        if (in_gamma != out->color.transfer) {
  ------------------
  |  Branch (83:13): [True: 0, False: 0]
  ------------------
   84|       |            // When changing the gamma function explicitly, also reset stuff
   85|       |            // related to the gamma function since that information will almost
   86|       |            // surely be false now and have to be re-inferred
   87|      0|            out->color.hdr = (struct pl_hdr_metadata){0};
   88|      0|            out->light = MP_CSP_LIGHT_AUTO;
   89|      0|        }
   90|      0|        out->color.transfer = p->gamma;
   91|      0|    }
   92|    703|    if (out->repr.sys != PL_COLOR_SYSTEM_DOLBYVISION) {
  ------------------
  |  Branch (92:9): [True: 703, False: 0]
  ------------------
   93|    703|        out->primaries_orig = out->color.primaries;
   94|    703|        out->transfer_orig = out->color.transfer;
   95|    703|        out->sys_orig = out->repr.sys;
   96|    703|    }
   97|    703|    if (p->sig_peak)
  ------------------
  |  Branch (97:9): [True: 0, False: 703]
  ------------------
   98|      0|        out->color.hdr = (struct pl_hdr_metadata){ .max_luma = p->sig_peak * MP_REF_WHITE };
  ------------------
  |  |   85|      0|#define MP_REF_WHITE 203.0
  ------------------
   99|    703|    if (p->light)
  ------------------
  |  Branch (99:9): [True: 0, False: 703]
  ------------------
  100|      0|        out->light = p->light;
  101|    703|    if (p->chroma_location)
  ------------------
  |  Branch (101:9): [True: 0, False: 703]
  ------------------
  102|      0|        out->chroma_location = p->chroma_location;
  103|    703|    if (p->stereo_in >= 0)
  ------------------
  |  Branch (103:9): [True: 0, False: 703]
  ------------------
  104|      0|        out->stereo3d = p->stereo_in;
  105|    703|    if (p->rotate >= 0)
  ------------------
  |  Branch (105:9): [True: 0, False: 703]
  ------------------
  106|      0|        out->rotate = p->rotate;
  107|    703|    if (p->alpha)
  ------------------
  |  Branch (107:9): [True: 0, False: 703]
  ------------------
  108|      0|        out->repr.alpha = p->alpha;
  109|       |
  110|    703|    if (p->w > 0 && set_size)
  ------------------
  |  Branch (110:9): [True: 0, False: 703]
  |  Branch (110:21): [True: 0, False: 0]
  ------------------
  111|      0|        out->w = p->w;
  112|    703|    if (p->h > 0 && set_size)
  ------------------
  |  Branch (112:9): [True: 0, False: 703]
  |  Branch (112:21): [True: 0, False: 0]
  ------------------
  113|      0|        out->h = p->h;
  114|    703|    AVRational dsize;
  115|    703|    mp_image_params_get_dsize(out, &dsize.num, &dsize.den);
  116|    703|    if (p->dw > 0)
  ------------------
  |  Branch (116:9): [True: 217, False: 486]
  ------------------
  117|    217|        dsize.num = p->dw;
  118|    703|    if (p->dh > 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 703]
  ------------------
  119|      0|        dsize.den = p->dh;
  120|    703|    if (p->dar > 0)
  ------------------
  |  Branch (120:9): [True: 0, False: 703]
  ------------------
  121|      0|        dsize = av_d2q(p->dar, INT_MAX);
  122|    703|    mp_image_params_set_dsize(out, dsize.num, dsize.den);
  123|    703|}

imgfmt2pixfmt:
   76|  2.02M|{
   77|  2.02M|    if (fmt == IMGFMT_NONE)
  ------------------
  |  Branch (77:9): [True: 9.71k, False: 2.01M]
  ------------------
   78|  9.71k|        return AV_PIX_FMT_NONE;
   79|       |
   80|  2.01M|    if (fmt >= IMGFMT_AVPIXFMT_START && fmt < IMGFMT_AVPIXFMT_END) {
  ------------------
  |  Branch (80:9): [True: 645k, False: 1.36M]
  |  Branch (80:41): [True: 644k, False: 1.28k]
  ------------------
   81|   644k|        enum AVPixelFormat pixfmt = fmt - IMGFMT_AVPIXFMT_START;
   82|       |        // Avoid duplicate format - each format must be unique.
   83|   644k|        int mpfmt = pixfmt2imgfmt(pixfmt);
   84|   644k|        if (mpfmt == fmt && av_pix_fmt_desc_get(pixfmt))
  ------------------
  |  Branch (84:13): [True: 302k, False: 341k]
  |  Branch (84:29): [True: 302k, False: 0]
  ------------------
   85|   302k|            return pixfmt;
   86|   341k|        return AV_PIX_FMT_NONE;
   87|   644k|    }
   88|       |
   89|  21.6M|    for (int i = 0; conversion_map[i].fmt; i++) {
  ------------------
  |  Branch (89:21): [True: 21.6M, False: 3.86k]
  ------------------
   90|  21.6M|        if (conversion_map[i].fmt == fmt)
  ------------------
  |  Branch (90:13): [True: 1.36M, False: 20.2M]
  ------------------
   91|  1.36M|            return conversion_map[i].pix_fmt;
   92|  21.6M|    }
   93|  3.86k|    return AV_PIX_FMT_NONE;
   94|  1.37M|}
pixfmt2imgfmt:
   97|   685k|{
   98|   685k|    if (pix_fmt == AV_PIX_FMT_NONE)
  ------------------
  |  Branch (98:9): [True: 3.27k, False: 682k]
  ------------------
   99|  3.27k|        return IMGFMT_NONE;
  100|       |
  101|  22.9M|    for (int i = 0; conversion_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
  ------------------
  |  Branch (101:21): [True: 22.3M, False: 598k]
  ------------------
  102|  22.3M|        if (conversion_map[i].pix_fmt == pix_fmt)
  ------------------
  |  Branch (102:13): [True: 83.6k, False: 22.2M]
  ------------------
  103|  83.6k|            return conversion_map[i].fmt;
  104|  22.3M|    }
  105|       |
  106|   598k|    int generic = IMGFMT_AVPIXFMT_START + pix_fmt;
  107|   598k|    if (generic < IMGFMT_AVPIXFMT_END && av_pix_fmt_desc_get(pix_fmt))
  ------------------
  |  Branch (107:9): [True: 598k, False: 0]
  |  Branch (107:42): [True: 302k, False: 296k]
  ------------------
  108|   302k|        return generic;
  109|       |
  110|   296k|    return 0;
  111|   598k|}

image_writer_file_ext:
  562|  34.4k|{
  563|  34.4k|    struct image_writer_opts defs = image_writer_opts_defaults;
  564|       |
  565|  34.4k|    if (!opts)
  ------------------
  |  Branch (565:9): [True: 0, False: 34.4k]
  ------------------
  566|      0|        opts = &defs;
  567|       |
  568|  34.4k|    return m_opt_choice_str(mp_image_writer_formats, opts->format);
  569|  34.4k|}
image_writer_high_depth:
  572|  59.2k|{
  573|  59.2k|    return opts->format == AV_CODEC_ID_PNG
  ------------------
  |  Branch (573:12): [True: 508, False: 58.7k]
  ------------------
  574|  58.7k|           || opts->format == AV_CODEC_ID_JPEGXL
  ------------------
  |  Branch (574:15): [True: 388, False: 58.3k]
  ------------------
  575|  58.3k|           || opts->format == AV_CODEC_ID_AV1;
  ------------------
  |  Branch (575:15): [True: 134, False: 58.1k]
  ------------------
  576|  59.2k|}
image_writer_flexible_csp:
  579|  71.0k|{
  580|  71.0k|    if (!opts->tag_csp)
  ------------------
  |  Branch (580:9): [True: 0, False: 71.0k]
  ------------------
  581|      0|        return false;
  582|  71.0k|    return opts->format == AV_CODEC_ID_JPEGXL
  ------------------
  |  Branch (582:12): [True: 666, False: 70.4k]
  ------------------
  583|  70.4k|        || opts->format == AV_CODEC_ID_AV1
  ------------------
  |  Branch (583:12): [True: 264, False: 70.1k]
  ------------------
  584|  70.1k|        || opts->format == AV_CODEC_ID_PNG;
  ------------------
  |  Branch (584:12): [True: 958, False: 69.2k]
  ------------------
  585|  71.0k|}
image_writer_format_from_ext:
  588|     34|{
  589|    238|    for (int n = 0; mp_image_writer_formats[n].name; n++) {
  ------------------
  |  Branch (589:21): [True: 204, False: 34]
  ------------------
  590|    204|        if (bstrcmp0(ext, mp_image_writer_formats[n].name) == 0)
  ------------------
  |  Branch (590:13): [True: 0, False: 204]
  ------------------
  591|      0|            return mp_image_writer_formats[n].value;
  592|    204|    }
  593|     34|    return 0;
  594|     34|}
write_image:
  681|  34.4k|{
  682|  34.4k|    struct image_writer_opts defs = image_writer_opts_defaults;
  683|  34.4k|    if (!opts)
  ------------------
  |  Branch (683:9): [True: 0, False: 34.4k]
  ------------------
  684|      0|        opts = &defs;
  685|       |
  686|  34.4k|    mp_verbose(log, "input: %s\n", mp_image_params_to_str(&image->params));
  ------------------
  |  |   79|  34.4k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  687|       |
  688|  34.4k|    struct image_writer_ctx ctx = { log, opts, image->fmt };
  689|  34.4k|    bool (*write)(struct image_writer_ctx *, mp_image_t *, FILE *) = write_lavc;
  690|  34.4k|    int destfmt = 0;
  691|       |
  692|       |#if HAVE_JPEG
  693|       |    if (opts->format == AV_CODEC_ID_MJPEG) {
  694|       |        write = write_jpeg;
  695|       |        destfmt = IMGFMT_RGB24;
  696|       |    }
  697|       |#endif
  698|  34.4k|    if (opts->format == AV_CODEC_ID_AV1) {
  ------------------
  |  Branch (698:9): [True: 132, False: 34.3k]
  ------------------
  699|    132|        write = write_avif;
  700|    132|        if (opts->avif_pixfmt && opts->avif_pixfmt[0])
  ------------------
  |  Branch (700:13): [True: 0, False: 132]
  |  Branch (700:34): [True: 0, False: 0]
  ------------------
  701|      0|            destfmt = mp_imgfmt_from_name(bstr0(opts->avif_pixfmt));
  702|  34.3k|    } else if (opts->format == AV_CODEC_ID_WEBP && !opts->webp_lossless) {
  ------------------
  |  Branch (702:16): [True: 1.40k, False: 32.9k]
  |  Branch (702:52): [True: 1.40k, False: 0]
  ------------------
  703|       |        // For lossy images, libwebp has its own RGB->YUV conversion.
  704|       |        // We don't want that, so force YUV/YUVA here.
  705|  1.40k|        int alpha = image->fmt.flags & MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|  1.40k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  706|  1.40k|        destfmt = alpha ? pixfmt2imgfmt(AV_PIX_FMT_YUVA420P) : IMGFMT_420P;
  ------------------
  |  Branch (706:19): [True: 0, False: 1.40k]
  ------------------
  707|  1.40k|    }
  708|       |
  709|  34.4k|    if (!destfmt)
  ------------------
  |  Branch (709:9): [True: 33.0k, False: 1.40k]
  ------------------
  710|  33.0k|        destfmt = get_target_format(&ctx);
  711|       |
  712|  34.4k|    enum pl_color_levels levels; // Ignored if destfmt is a RGB format
  713|  34.4k|    if (opts->format == AV_CODEC_ID_WEBP) {
  ------------------
  |  Branch (713:9): [True: 1.40k, False: 33.0k]
  ------------------
  714|  1.40k|        levels = PL_COLOR_LEVELS_LIMITED;
  715|  33.0k|    } else {
  716|  33.0k|        levels = PL_COLOR_LEVELS_FULL;
  717|  33.0k|    }
  718|       |
  719|  34.4k|    struct mp_image *dst = convert_image(image, destfmt, levels, opts, global, log);
  720|  34.4k|    if (!dst)
  ------------------
  |  Branch (720:9): [True: 225, False: 34.2k]
  ------------------
  721|    225|        return false;
  722|       |
  723|  34.4k|    bool success = false;
  724|  34.2k|    FILE *fp = fopen(filename, overwrite ? "wb" : "wbx");
  ------------------
  |  |   84|  68.4k|#define fopen(...) mp_fopen(__VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (84:29): [True: 15, False: 34.2k]
  |  |  ------------------
  ------------------
  725|  34.2k|    if (!fp) {
  ------------------
  |  Branch (725:9): [True: 0, False: 34.2k]
  ------------------
  726|      0|        mp_err(log, "Error creating '%s' for writing: %s!\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  727|      0|               filename, mp_strerror(errno));
  728|      0|        goto done;
  729|      0|    }
  730|       |
  731|  34.2k|    success = write(&ctx, dst, fp);
  732|  34.2k|    if (fclose(fp) || !success) {
  ------------------
  |  Branch (732:9): [True: 0, False: 34.2k]
  |  Branch (732:23): [True: 34.2k, False: 0]
  ------------------
  733|  34.2k|        mp_err(log, "Error writing file '%s'!\n", filename);
  ------------------
  |  |   76|  34.2k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  734|  34.2k|        unlink(filename);
  ------------------
  |  |  271|  34.2k|#define unlink(...) mp_unlink(__VA_ARGS__)
  ------------------
  735|  34.2k|    }
  736|       |
  737|  34.2k|done:
  738|  34.2k|    talloc_free(dst);
  ------------------
  |  |   47|  34.2k|#define talloc_free                     ta_free
  ------------------
  739|  34.2k|    return success;
  740|  34.2k|}
image_writer.c:write_lavc:
  159|  34.1k|{
  160|  34.1k|    bool success = false;
  161|  34.1k|    AVFrame *pic = NULL;
  162|  34.1k|    AVPacket *pkt = NULL;
  163|       |
  164|  34.1k|    const AVCodec *codec;
  165|  34.1k|    if (ctx->opts->format == AV_CODEC_ID_WEBP) {
  ------------------
  |  Branch (165:9): [True: 1.40k, False: 32.7k]
  ------------------
  166|  1.40k|        codec = avcodec_find_encoder_by_name("libwebp"); // non-animated encoder
  167|  32.7k|    } else {
  168|  32.7k|        codec = avcodec_find_encoder(ctx->opts->format);
  169|  32.7k|    }
  170|       |
  171|  34.1k|    AVCodecContext *avctx = NULL;
  172|  34.1k|    if (!codec)
  ------------------
  |  Branch (172:9): [True: 34.1k, False: 0]
  ------------------
  173|  34.1k|        goto print_open_fail;
  174|      0|    avctx = avcodec_alloc_context3(codec);
  175|      0|    if (!avctx)
  ------------------
  |  Branch (175:9): [True: 0, False: 0]
  ------------------
  176|      0|        goto print_open_fail;
  177|       |
  178|      0|    MP_VERBOSE(ctx, "Using encoder %s\n", codec->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__)
  |  |  ------------------
  ------------------
  179|       |
  180|      0|    avctx->time_base = AV_TIME_BASE_Q;
  181|      0|    avctx->width = image->w;
  182|      0|    avctx->height = image->h;
  183|      0|    avctx->pix_fmt = imgfmt2pixfmt(image->imgfmt);
  184|       |
  185|       |    /*
  186|       |     * tagging avctx->bits_per_raw_sample indicates the number of significant
  187|       |     * bits. For example, if the original video was 10-bit, and the GPU buffer is
  188|       |     * 16-bit, this tells lavc that only 10 bits are significant. lavc encoders may
  189|       |     * ignore this value, but some codecs can make use of it (for example, PNG's
  190|       |     * sBIT chunk or JXL's bit depth header)
  191|       |     *
  192|       |     * This only works when screenshot-sw=yes is set. With hardware screenshots,
  193|       |     * the "original" is whatever is in the GPU buffer, which is likely to be at
  194|       |     * full bit depth already.
  195|       |     */
  196|      0|    if (image->params.repr.bits.color_depth != image->params.repr.bits.sample_depth) {
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|        MP_DBG(ctx, "tagging bits_per_raw_sample=%d\n", image->params.repr.bits.color_depth);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  198|      0|        avctx->bits_per_raw_sample = image->params.repr.bits.color_depth;
  199|      0|    }
  200|       |
  201|      0|    if (codec->id == AV_CODEC_ID_MJPEG) {
  ------------------
  |  Branch (201:9): [True: 0, False: 0]
  ------------------
  202|       |        // Annoying deprecated garbage for the jpg encoder.
  203|      0|        if (image->params.repr.levels == PL_COLOR_LEVELS_FULL)
  ------------------
  |  Branch (203:13): [True: 0, False: 0]
  ------------------
  204|      0|            avctx->pix_fmt = replace_j_format(avctx->pix_fmt);
  205|      0|    }
  206|      0|    if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
  ------------------
  |  Branch (206:9): [True: 0, False: 0]
  ------------------
  207|      0|        MP_ERR(ctx, "Image format %s not supported by lavc.\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__)
  |  |  ------------------
  ------------------
  208|      0|               mp_imgfmt_to_name(image->imgfmt));
  209|      0|        goto error_exit;
  210|      0|    }
  211|       |
  212|      0|    if (codec->id == AV_CODEC_ID_MJPEG) {
  ------------------
  |  Branch (212:9): [True: 0, False: 0]
  ------------------
  213|      0|        avctx->flags |= AV_CODEC_FLAG_QSCALE;
  214|       |        // jpeg_quality is set below
  215|      0|    } else if (codec->id == AV_CODEC_ID_PNG) {
  ------------------
  |  Branch (215:16): [True: 0, False: 0]
  ------------------
  216|      0|        avctx->compression_level = ctx->opts->png_compression;
  217|      0|        av_opt_set_int(avctx, "pred", ctx->opts->png_filter,
  218|      0|                       AV_OPT_SEARCH_CHILDREN);
  219|      0|    } else if (codec->id == AV_CODEC_ID_WEBP) {
  ------------------
  |  Branch (219:16): [True: 0, False: 0]
  ------------------
  220|      0|        avctx->compression_level = ctx->opts->webp_compression;
  221|      0|        av_opt_set_int(avctx, "lossless", ctx->opts->webp_lossless,
  222|      0|                       AV_OPT_SEARCH_CHILDREN);
  223|      0|        av_opt_set_int(avctx, "quality", ctx->opts->webp_quality,
  224|      0|                       AV_OPT_SEARCH_CHILDREN);
  225|      0|    } else if (codec->id == AV_CODEC_ID_JPEGXL) {
  ------------------
  |  Branch (225:16): [True: 0, False: 0]
  ------------------
  226|      0|        av_opt_set_double(avctx, "distance", ctx->opts->jxl_distance,
  227|      0|                          AV_OPT_SEARCH_CHILDREN);
  228|      0|        av_opt_set_int(avctx, "effort", ctx->opts->jxl_effort,
  229|      0|                       AV_OPT_SEARCH_CHILDREN);
  230|      0|    }
  231|       |
  232|      0|    if (avcodec_open2(avctx, codec, NULL) < 0) {
  ------------------
  |  Branch (232:9): [True: 0, False: 0]
  ------------------
  233|  34.1k|    print_open_fail:
  234|  34.1k|        MP_ERR(ctx, "Could not open libavcodec encoder for saving images\n");
  ------------------
  |  |   89|  34.1k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  34.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  235|  34.1k|        goto error_exit;
  236|      0|    }
  237|       |
  238|      0|    pic = av_frame_alloc();
  239|      0|    if (!pic)
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        goto error_exit;
  241|      0|    prepare_avframe(pic, avctx, image, ctx->opts->tag_csp, ctx->log);
  242|      0|    if (codec->id == AV_CODEC_ID_MJPEG) {
  ------------------
  |  Branch (242:9): [True: 0, False: 0]
  ------------------
  243|      0|        int qscale = 1 + (100 - ctx->opts->jpeg_quality) * 30 / 100;
  244|      0|        pic->quality = qscale * FF_QP2LAMBDA;
  245|      0|    }
  246|       |
  247|      0|    int ret = avcodec_send_frame(avctx, pic);
  248|      0|    if (ret < 0)
  ------------------
  |  Branch (248:9): [True: 0, False: 0]
  ------------------
  249|      0|        goto error_exit;
  250|      0|    ret = avcodec_send_frame(avctx, NULL); // send EOF
  251|      0|    if (ret < 0)
  ------------------
  |  Branch (251:9): [True: 0, False: 0]
  ------------------
  252|      0|        goto error_exit;
  253|      0|    pkt = av_packet_alloc();
  254|      0|    if (!pkt)
  ------------------
  |  Branch (254:9): [True: 0, False: 0]
  ------------------
  255|      0|        goto error_exit;
  256|      0|    ret = avcodec_receive_packet(avctx, pkt);
  257|      0|    if (ret < 0)
  ------------------
  |  Branch (257:9): [True: 0, False: 0]
  ------------------
  258|      0|        goto error_exit;
  259|       |
  260|      0|    success = fwrite(pkt->data, pkt->size, 1, fp) == 1;
  261|       |
  262|  34.1k|error_exit:
  263|  34.1k|    avcodec_free_context(&avctx);
  264|  34.1k|    av_frame_free(&pic);
  265|  34.1k|    av_packet_free(&pkt);
  266|  34.1k|    return success;
  267|      0|}
image_writer.c:write_avif:
  351|    132|{
  352|    132|    const AVCodec *codec = NULL;
  353|    132|    const AVOutputFormat *ofmt = NULL;
  354|    132|    AVCodecContext *avctx = NULL;
  355|    132|    AVIOContext *avioctx = NULL;
  356|    132|    AVFormatContext *fmtctx = NULL;
  357|    132|    AVStream *stream = NULL;
  358|    132|    AVFrame *pic = NULL;
  359|    132|    AVPacket *pkt = NULL;
  360|    132|    int ret;
  361|    132|    bool success = false;
  362|       |
  363|    132|    codec = avcodec_find_encoder_by_name(ctx->opts->avif_encoder);
  364|    132|    if (!codec) {
  ------------------
  |  Branch (364:9): [True: 132, False: 0]
  ------------------
  365|    132|        MP_ERR(ctx, "Could not find encoder '%s', for saving images\n",
  ------------------
  |  |   89|    132|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    132|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  366|    132|               ctx->opts->avif_encoder);
  367|    132|        goto free_data;
  368|    132|    }
  369|       |
  370|      0|    ofmt = av_guess_format("avif", NULL, NULL);
  371|      0|    if (!ofmt) {
  ------------------
  |  Branch (371:9): [True: 0, False: 0]
  ------------------
  372|      0|        MP_ERR(ctx, "Could not guess output format 'avif'\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__)
  |  |  ------------------
  ------------------
  373|      0|        goto free_data;
  374|      0|    }
  375|       |
  376|      0|    avctx = avcodec_alloc_context3(codec);
  377|      0|    if (!avctx) {
  ------------------
  |  Branch (377:9): [True: 0, False: 0]
  ------------------
  378|      0|        MP_ERR(ctx, "Failed to allocate AVContext.\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__)
  |  |  ------------------
  ------------------
  379|      0|        goto free_data;
  380|      0|    }
  381|       |
  382|      0|    avctx->width = image->w;
  383|      0|    avctx->height = image->h;
  384|      0|    avctx->time_base = (AVRational){1, 30};
  385|      0|    avctx->pkt_timebase = (AVRational){1, 30};
  386|      0|    avctx->codec_type = AVMEDIA_TYPE_VIDEO;
  387|      0|    avctx->pix_fmt = imgfmt2pixfmt(image->imgfmt);
  388|      0|    if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
  ------------------
  |  Branch (388:9): [True: 0, False: 0]
  ------------------
  389|      0|        MP_ERR(ctx, "Image format %s not supported by lavc.\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__)
  |  |  ------------------
  ------------------
  390|      0|               mp_imgfmt_to_name(image->imgfmt));
  391|      0|        goto free_data;
  392|      0|    }
  393|       |
  394|      0|    av_opt_set_int(avctx, "still-picture", 1, AV_OPT_SEARCH_CHILDREN);
  395|       |
  396|      0|    AVDictionary *avd = NULL;
  397|      0|    mp_set_avdict(&avd, ctx->opts->avif_opts);
  398|      0|    av_opt_set_dict2(avctx, &avd, AV_OPT_SEARCH_CHILDREN);
  399|      0|    av_dict_free(&avd);
  400|       |
  401|      0|    pic = av_frame_alloc();
  402|      0|    if (!pic) {
  ------------------
  |  Branch (402:9): [True: 0, False: 0]
  ------------------
  403|      0|        MP_ERR(ctx, "Could not allocate AVFrame\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|        goto free_data;
  405|      0|    }
  406|       |
  407|      0|    prepare_avframe(pic, avctx, image, ctx->opts->tag_csp, ctx->log);
  408|       |    // Not setting this flag caused ffmpeg to output avif that was not passing
  409|       |    // standard checks but ffmpeg would still read and not complain...
  410|      0|    avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  411|       |
  412|      0|    ret = avcodec_open2(avctx, codec, NULL);
  413|      0|    if (ret < 0) {
  ------------------
  |  Branch (413:9): [True: 0, False: 0]
  ------------------
  414|      0|        MP_ERR(ctx, "Could not open libavcodec encoder for saving images\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__)
  |  |  ------------------
  ------------------
  415|      0|        goto free_data;
  416|      0|    }
  417|       |
  418|      0|    avio_open_dyn_buf(&avioctx);
  419|      0|    MP_HANDLE_OOM(avioctx);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  420|       |
  421|      0|    fmtctx = avformat_alloc_context();
  422|      0|    if (!fmtctx) {
  ------------------
  |  Branch (422:9): [True: 0, False: 0]
  ------------------
  423|      0|        MP_ERR(ctx, "Could not allocate format context\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__)
  |  |  ------------------
  ------------------
  424|      0|        goto free_data;
  425|      0|    }
  426|      0|    fmtctx->pb = avioctx;
  427|      0|    fmtctx->oformat = ofmt;
  428|       |
  429|      0|    stream = avformat_new_stream(fmtctx, codec);
  430|      0|    if (!stream) {
  ------------------
  |  Branch (430:9): [True: 0, False: 0]
  ------------------
  431|      0|        MP_ERR(ctx, "Could not allocate 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__)
  |  |  ------------------
  ------------------
  432|      0|        goto free_data;
  433|      0|    }
  434|       |
  435|      0|    ret = avcodec_parameters_from_context(stream->codecpar, avctx);
  436|      0|    if (ret < 0) {
  ------------------
  |  Branch (436:9): [True: 0, False: 0]
  ------------------
  437|      0|        MP_ERR(ctx, "Could not copy parameters from context\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__)
  |  |  ------------------
  ------------------
  438|      0|        goto free_data;
  439|      0|    }
  440|       |
  441|      0|    ret = avformat_init_output(fmtctx, NULL);
  442|      0|    if (ret < 0) {
  ------------------
  |  Branch (442:9): [True: 0, False: 0]
  ------------------
  443|      0|        MP_ERR(ctx, "Could not initialize 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__)
  |  |  ------------------
  ------------------
  444|      0|        goto free_data;
  445|      0|    }
  446|       |
  447|      0|    ret = avformat_write_header(fmtctx, NULL);
  448|      0|    if (ret < 0) {
  ------------------
  |  Branch (448:9): [True: 0, False: 0]
  ------------------
  449|      0|        MP_ERR(ctx, "Could not write format header\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__)
  |  |  ------------------
  ------------------
  450|      0|        goto free_data;
  451|      0|    }
  452|       |
  453|      0|    pkt = av_packet_alloc();
  454|      0|    if (!pkt) {
  ------------------
  |  Branch (454:9): [True: 0, False: 0]
  ------------------
  455|      0|        MP_ERR(ctx, "Could not allocate packet\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  456|      0|        goto free_data;
  457|      0|    }
  458|       |
  459|      0|    ret = avcodec_send_frame(avctx, pic);
  460|      0|    if (ret < 0) {
  ------------------
  |  Branch (460:9): [True: 0, False: 0]
  ------------------
  461|      0|        MP_ERR(ctx, "Error sending 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__)
  |  |  ------------------
  ------------------
  462|      0|        goto free_data;
  463|      0|    }
  464|      0|    ret = avcodec_send_frame(avctx, NULL); // send EOF
  465|      0|    if (ret < 0)
  ------------------
  |  Branch (465:9): [True: 0, False: 0]
  ------------------
  466|      0|        goto free_data;
  467|       |
  468|      0|    int pts = 0;
  469|      0|    log_side_data(ctx, avctx->coded_side_data, avctx->nb_coded_side_data);
  470|      0|    while (ret >= 0) {
  ------------------
  |  Branch (470:12): [True: 0, False: 0]
  ------------------
  471|      0|        ret = avcodec_receive_packet(avctx, pkt);
  472|      0|        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
  ------------------
  |  Branch (472:13): [True: 0, False: 0]
  |  Branch (472:39): [True: 0, False: 0]
  ------------------
  473|      0|            break;
  474|      0|        if (ret < 0) {
  ------------------
  |  Branch (474:13): [True: 0, False: 0]
  ------------------
  475|      0|            MP_ERR(ctx, "Error receiving packet\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__)
  |  |  ------------------
  ------------------
  476|      0|            goto free_data;
  477|      0|        }
  478|      0|        pkt->dts = pkt->pts = ++pts;
  479|      0|        pkt->stream_index = stream->index;
  480|      0|        log_side_data(ctx, pkt->side_data, pkt->side_data_elems);
  481|       |
  482|      0|        ret = av_write_frame(fmtctx, pkt);
  483|      0|        if (ret < 0) {
  ------------------
  |  Branch (483:13): [True: 0, False: 0]
  ------------------
  484|      0|            MP_ERR(ctx, "Error writing 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__)
  |  |  ------------------
  ------------------
  485|      0|            goto free_data;
  486|      0|        }
  487|      0|        av_packet_unref(pkt);
  488|      0|    }
  489|       |
  490|      0|    ret = av_write_trailer(fmtctx);
  491|      0|    if (ret < 0) {
  ------------------
  |  Branch (491:9): [True: 0, False: 0]
  ------------------
  492|      0|        MP_ERR(ctx, "Could not write 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__)
  |  |  ------------------
  ------------------
  493|      0|        goto free_data;
  494|      0|    }
  495|      0|    MP_DBG(ctx, "write_avif(): avio_size() = %"PRIi64"\n", avio_size(avioctx));
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  496|       |
  497|      0|    uint8_t *buf = NULL;
  498|      0|    int written_size = avio_close_dyn_buf(avioctx, &buf);
  499|      0|    success = fwrite(buf, written_size, 1, fp) == 1;
  500|      0|    av_freep(&buf);
  501|       |
  502|    132|free_data:
  503|    132|    avformat_free_context(fmtctx);
  504|    132|    avcodec_free_context(&avctx);
  505|    132|    av_packet_free(&pkt);
  506|    132|    av_frame_free(&pic);
  507|       |
  508|    132|    return success;
  509|      0|}
image_writer.c:get_target_format:
  539|  33.0k|{
  540|  33.0k|    const AVCodec *codec = avcodec_find_encoder(ctx->opts->format);
  541|  33.0k|    if (!codec)
  ------------------
  |  Branch (541:9): [True: 33.0k, False: 0]
  ------------------
  542|  33.0k|        goto unknown;
  543|       |
  544|      0|    int srcfmt = ctx->original_format.id;
  545|       |
  546|      0|    int target = get_encoder_format(codec, srcfmt, ctx->opts->high_bit_depth);
  547|      0|    if (!target) {
  ------------------
  |  Branch (547:9): [True: 0, False: 0]
  ------------------
  548|      0|        mp_dbg(ctx->log, "Falling back to high-depth format.\n");
  ------------------
  |  |   80|      0|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
  549|      0|        target = get_encoder_format(codec, srcfmt, true);
  550|      0|    }
  551|       |
  552|      0|    if (!target)
  ------------------
  |  Branch (552:9): [True: 0, False: 0]
  ------------------
  553|      0|        goto unknown;
  554|       |
  555|      0|    return target;
  556|       |
  557|  33.0k|unknown:
  558|  33.0k|    return IMGFMT_RGB0;
  559|      0|}
image_writer.c:convert_image:
  601|  34.4k|{
  602|  34.4k|    int d_w, d_h;
  603|  34.4k|    mp_image_params_get_dsize(&image->params, &d_w, &d_h);
  604|       |
  605|  34.4k|    struct mp_image_params p = {
  606|  34.4k|        .imgfmt = destfmt,
  607|  34.4k|        .w = d_w,
  608|  34.4k|        .h = d_h,
  609|  34.4k|        .p_w = 1,
  610|  34.4k|        .p_h = 1,
  611|  34.4k|        .color = image->params.color,
  612|  34.4k|        .repr = image->params.repr,
  613|  34.4k|        .chroma_location = image->params.chroma_location,
  614|  34.4k|        .crop = {0, 0, d_w, d_h},
  615|  34.4k|    };
  616|  34.4k|    mp_image_params_guess_csp(&p);
  617|       |
  618|  34.4k|    if (!image_writer_flexible_csp(opts)) {
  ------------------
  |  Branch (618:9): [True: 33.5k, False: 943]
  ------------------
  619|       |        // If our format can't tag csps, set something sane
  620|  33.5k|        p.color.primaries = PL_COLOR_PRIM_BT_709;
  621|  33.5k|        p.color.transfer = PL_COLOR_TRC_UNKNOWN;
  622|  33.5k|        p.light = MP_CSP_LIGHT_DISPLAY;
  623|  33.5k|        p.color.hdr = (struct pl_hdr_metadata){0};
  624|  33.5k|        if (p.repr.sys != PL_COLOR_SYSTEM_RGB) {
  ------------------
  |  Branch (624:13): [True: 1.40k, False: 32.1k]
  ------------------
  625|  1.40k|            p.repr.levels = yuv_levels;
  626|  1.40k|            p.repr.sys = PL_COLOR_SYSTEM_BT_601;
  627|  1.40k|            p.chroma_location = PL_CHROMA_CENTER;
  628|  1.40k|        }
  629|  33.5k|        mp_image_params_guess_csp(&p);
  630|  33.5k|    }
  631|       |
  632|  34.4k|    if (mp_image_params_equal(&p, &image->params))
  ------------------
  |  Branch (632:9): [True: 0, False: 34.4k]
  ------------------
  633|      0|        return mp_image_new_ref(image);
  634|       |
  635|  34.4k|    mp_verbose(log, "converted: %s\n", mp_image_params_to_str(&p));
  ------------------
  |  |   79|  34.4k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  636|       |
  637|  34.4k|    struct mp_image *src = image;
  638|  34.4k|    if (mp_image_crop_valid(&src->params) &&
  ------------------
  |  Branch (638:9): [True: 34.4k, False: 0]
  ------------------
  639|  34.4k|        (mp_rect_w(src->params.crop) != src->w ||
  ------------------
  |  |  157|  34.4k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  |  Branch (639:10): [True: 0, False: 34.4k]
  ------------------
  640|  34.4k|         mp_rect_h(src->params.crop) != src->h))
  ------------------
  |  |  158|  34.4k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (640:10): [True: 0, False: 34.4k]
  ------------------
  641|      0|    {
  642|      0|        src = mp_image_new_ref(src);
  643|      0|        if (!src) {
  ------------------
  |  Branch (643:13): [True: 0, False: 0]
  ------------------
  644|      0|            mp_err(log, "mp_image_new_ref failed!\n");
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  645|      0|            return NULL;
  646|      0|        }
  647|      0|        mp_image_crop_rc(src, src->params.crop);
  648|      0|    }
  649|       |
  650|  34.4k|    struct mp_image *dst = mp_image_alloc(p.imgfmt, p.w, p.h);
  651|  34.4k|    if (!dst) {
  ------------------
  |  Branch (651:9): [True: 6, False: 34.4k]
  ------------------
  652|      6|        mp_err(log, "Out of memory.\n");
  ------------------
  |  |   76|      6|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  653|      6|        return NULL;
  654|      6|    }
  655|  34.4k|    mp_image_copy_attributes(dst, src);
  656|       |
  657|  34.4k|    dst->params = p;
  658|       |
  659|  34.4k|    struct mp_sws_context *sws = mp_sws_alloc(NULL);
  660|  34.4k|    sws->log = log;
  661|  34.4k|    if (global)
  ------------------
  |  Branch (661:9): [True: 34.4k, False: 0]
  ------------------
  662|  34.4k|        mp_sws_enable_cmdline_opts(sws, global);
  663|  34.4k|    bool ok = mp_sws_scale(sws, dst, src) >= 0;
  664|  34.4k|    talloc_free(sws);
  ------------------
  |  |   47|  34.4k|#define talloc_free                     ta_free
  ------------------
  665|       |
  666|  34.4k|    if (src != image)
  ------------------
  |  Branch (666:9): [True: 0, False: 34.4k]
  ------------------
  667|      0|        talloc_free(src);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  668|       |
  669|  34.4k|    if (!ok) {
  ------------------
  |  Branch (669:9): [True: 219, False: 34.2k]
  ------------------
  670|    219|        mp_err(log, "Error when converting image.\n");
  ------------------
  |  |   76|    219|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  671|    219|        talloc_free(dst);
  ------------------
  |  |   47|    219|#define talloc_free                     ta_free
  ------------------
  672|    219|        return NULL;
  673|    219|    }
  674|       |
  675|  34.2k|    return dst;
  676|  34.4k|}

mp_imgfmt_from_name:
  148|  3.27k|{
  149|  3.27k|    if (bstr_equals0(name, "none"))
  ------------------
  |  Branch (149:9): [True: 0, False: 3.27k]
  ------------------
  150|      0|        return 0;
  151|  3.27k|    static const struct { bstr old, new; } deprecated_fmt_names[] = {
  152|  3.27k|        {bstr0_lit("rgb30"), bstr0_lit("x2rgb10")},
  ------------------
  |  |   59|  3.27k|#define bstr0_lit(s) {(unsigned char *)(s), sizeof("" s) - 1}
  ------------------
                      {bstr0_lit("rgb30"), bstr0_lit("x2rgb10")},
  ------------------
  |  |   59|  3.27k|#define bstr0_lit(s) {(unsigned char *)(s), sizeof("" s) - 1}
  ------------------
  153|  3.27k|    };
  154|  6.54k|    for (int n = 0; n < MP_ARRAY_SIZE(deprecated_fmt_names); n++) {
  ------------------
  |  |   49|  6.54k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (154:21): [True: 3.27k, False: 3.27k]
  ------------------
  155|  3.27k|        if (bstr_equals(name, deprecated_fmt_names[n].old)) {
  ------------------
  |  Branch (155:13): [True: 0, False: 3.27k]
  ------------------
  156|      0|            name = deprecated_fmt_names[n].new;
  157|      0|            break;
  158|      0|        }
  159|  3.27k|    }
  160|  88.3k|    for (int n = 0; n < MP_ARRAY_SIZE(mp_imgfmt_list); n++) {
  ------------------
  |  |   49|  88.3k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (160:21): [True: 85.1k, False: 3.27k]
  ------------------
  161|  85.1k|        const struct mp_imgfmt_entry *p = &mp_imgfmt_list[n];
  162|  85.1k|        if (p->name && bstr_equals0(name, p->name))
  ------------------
  |  Branch (162:13): [True: 81.8k, False: 3.27k]
  |  Branch (162:24): [True: 0, False: 81.8k]
  ------------------
  163|      0|            return IMGFMT_CUST_BASE + n;
  164|  85.1k|    }
  165|  3.27k|    return pixfmt2imgfmt(av_get_pix_fmt(mp_tprintf(80, "%.*s", BSTR_P(name))));
  ------------------
  |  |  195|  6.54k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (195:55): [True: 3.27k, False: 0]
  |  |  ------------------
  ------------------
  166|  3.27k|}
mp_imgfmt_to_name_buf:
  169|   235k|{
  170|   235k|    const struct mp_imgfmt_entry *p = get_mp_desc(fmt);
  171|   235k|    const char *name = p ? p->name : NULL;
  ------------------
  |  Branch (171:24): [True: 0, False: 235k]
  ------------------
  172|   235k|    if (!name) {
  ------------------
  |  Branch (172:9): [True: 235k, False: 0]
  ------------------
  173|   235k|        const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(imgfmt2pixfmt(fmt));
  174|   235k|        if (pixdesc)
  ------------------
  |  Branch (174:13): [True: 226k, False: 9.71k]
  ------------------
  175|   226k|            name = pixdesc->name;
  176|   235k|    }
  177|   235k|    if (!name)
  ------------------
  |  Branch (177:9): [True: 9.71k, False: 226k]
  ------------------
  178|  9.71k|        name = "unknown";
  179|   235k|    snprintf(buf, buf_size, "%s", name);
  180|   235k|    int len = strlen(buf);
  181|   235k|    if (len > 2 && buf[len - 2] == MP_SELECT_LE_BE('l', 'b') && buf[len - 1] == 'e')
  ------------------
  |  |   38|   471k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  |  Branch (181:9): [True: 235k, False: 0]
  |  Branch (181:20): [True: 0, False: 235k]
  |  Branch (181:65): [True: 0, False: 0]
  ------------------
  182|      0|        buf[len - 2] = '\0';
  183|   235k|    return buf;
  184|   235k|}
mp_imgfmt_desc_get_num_comps:
  557|  1.31M|{
  558|  1.31M|    int flags = desc->flags;
  559|  1.31M|    if (!(flags & MP_IMGFLAG_COLOR_MASK))
  ------------------
  |  |   55|  1.31M|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (559:9): [True: 0, False: 1.31M]
  ------------------
  560|      0|        return 0;
  561|  1.31M|    return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   75|  1.31M|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
                  return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
  ------------------
  |  |   52|  1.31M|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (561:17): [True: 24.4k, False: 1.28M]
  ------------------
  562|  1.31M|}
mp_imgfmt_get_desc:
  565|  1.69M|{
  566|  1.69M|    struct mp_imgfmt_desc desc;
  567|       |
  568|  1.69M|    if (!get_native_desc(mpfmt, &desc) &&
  ------------------
  |  Branch (568:9): [True: 1.66M, False: 29.6k]
  ------------------
  569|  1.66M|        !mp_imgfmt_get_desc_from_pixdesc(mpfmt, &desc))
  ------------------
  |  Branch (569:9): [True: 345k, False: 1.31M]
  ------------------
  570|   345k|        return (struct mp_imgfmt_desc){0};
  571|       |
  572|  4.20M|    for (int p = 0; p < desc.num_planes; p++) {
  ------------------
  |  Branch (572:21): [True: 2.85M, False: 1.34M]
  ------------------
  573|  2.85M|        desc.xs[p] = (p == 1 || p == 2) ? desc.chroma_xs : 0;
  ------------------
  |  Branch (573:23): [True: 757k, False: 2.10M]
  |  Branch (573:33): [True: 721k, False: 1.38M]
  ------------------
  574|  2.85M|        desc.ys[p] = (p == 1 || p == 2) ? desc.chroma_ys : 0;
  ------------------
  |  Branch (574:23): [True: 757k, False: 2.10M]
  |  Branch (574:33): [True: 721k, False: 1.38M]
  ------------------
  575|  2.85M|    }
  576|       |
  577|  1.34M|    bool is_ba = desc.num_planes > 0;
  578|  4.20M|    for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (578:21): [True: 2.85M, False: 1.34M]
  ------------------
  579|  2.85M|        is_ba = !(desc.bpp[p] % 8u);
  580|       |
  581|  1.34M|    if (is_ba)
  ------------------
  |  Branch (581:9): [True: 1.31M, False: 29.6k]
  ------------------
  582|  1.31M|        desc.flags |= MP_IMGFLAG_BYTE_ALIGNED;
  ------------------
  |  |   40|  1.31M|#define MP_IMGFLAG_BYTE_ALIGNED (1 << 2)
  ------------------
  583|       |
  584|  1.34M|    if (desc.flags & MP_IMGFLAG_HAS_COMPS) {
  ------------------
  |  |   34|  1.34M|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (584:9): [True: 1.27M, False: 65.6k]
  ------------------
  585|  1.27M|        if (desc.comps[3].size)
  ------------------
  |  Branch (585:13): [True: 100k, False: 1.17M]
  ------------------
  586|   100k|            desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|   100k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  587|       |
  588|       |        // Assuming all colors are (CCC+[A]) or (C+[A]), the latter being gray.
  589|  1.27M|        if (!desc.comps[1].size)
  ------------------
  |  Branch (589:13): [True: 38.6k, False: 1.24M]
  ------------------
  590|  38.6k|            desc.flags |= MP_IMGFLAG_GRAY;
  ------------------
  |  |   75|  38.6k|#define MP_IMGFLAG_GRAY         (1 << 14)
  ------------------
  591|       |
  592|  1.27M|        bool bb = true;
  593|  6.39M|        for (int n = 0; n < MP_NUM_COMPONENTS; n++) {
  ------------------
  |  |   29|  6.39M|#define MP_NUM_COMPONENTS 4
  ------------------
  |  Branch (593:25): [True: 5.11M, False: 1.27M]
  ------------------
  594|  5.11M|            if (desc.comps[n].offset % 8u || desc.comps[n].size % 8u)
  ------------------
  |  Branch (594:17): [True: 57.9k, False: 5.06M]
  |  Branch (594:46): [True: 37.3k, False: 5.02M]
  ------------------
  595|  95.3k|                bb = false;
  596|  5.11M|        }
  597|  1.27M|        if (bb)
  ------------------
  |  Branch (597:13): [True: 1.24M, False: 33.4k]
  ------------------
  598|  1.24M|            desc.flags |= MP_IMGFLAG_BYTES;
  ------------------
  |  |   37|  1.24M|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  599|  1.27M|    }
  600|       |
  601|  1.34M|    if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   67|  1.34M|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|  1.34M|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
                  if ((desc.flags & (MP_IMGFLAG_YUV | MP_IMGFLAG_RGB))
  ------------------
  |  |   68|  1.34M|#define MP_IMGFLAG_RGB          MP_IMGFLAG_COLOR_RGB
  |  |  ------------------
  |  |  |  |   57|  1.34M|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  |  |  ------------------
  ------------------
  |  Branch (601:9): [True: 1.31M, False: 27.0k]
  ------------------
  602|  1.31M|        && (desc.flags & MP_IMGFLAG_HAS_COMPS)
  ------------------
  |  |   34|  1.31M|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  |  Branch (602:12): [True: 1.27M, False: 43.7k]
  ------------------
  603|  1.27M|        && (desc.flags & MP_IMGFLAG_BYTES)
  ------------------
  |  |   37|  1.27M|#define MP_IMGFLAG_BYTES        (1 << 1)
  ------------------
  |  Branch (603:12): [True: 1.24M, False: 33.4k]
  ------------------
  604|  1.24M|        && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   61|  1.24M|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
                      && ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
  ------------------
  |  |   62|  1.24M|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  |  Branch (604:12): [True: 1.19M, False: 42.5k]
  ------------------
  605|  1.19M|    {
  606|  1.19M|        int cnt = mp_imgfmt_desc_get_num_comps(&desc);
  607|  1.19M|        bool same_depth = true;
  608|  3.86M|        for (int p = 0; p < desc.num_planes; p++)
  ------------------
  |  Branch (608:25): [True: 2.66M, False: 1.19M]
  ------------------
  609|  2.66M|            same_depth &= desc.bpp[p] == desc.bpp[0];
  610|  1.19M|        if (same_depth && cnt == desc.num_planes) {
  ------------------
  |  Branch (610:13): [True: 1.16M, False: 32.2k]
  |  Branch (610:27): [True: 713k, False: 453k]
  ------------------
  611|   713k|            if (desc.flags & MP_IMGFLAG_YUV) {
  ------------------
  |  |   67|   713k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|   713k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
  |  Branch (611:17): [True: 670k, False: 42.5k]
  ------------------
  612|   670k|                desc.flags |= MP_IMGFLAG_YUV_P;
  ------------------
  |  |   94|   670k|#define MP_IMGFLAG_YUV_P        (1 << 16)
  ------------------
  613|   670k|            } else {
  614|  42.5k|                desc.flags |= MP_IMGFLAG_RGB_P;
  ------------------
  |  |   98|  42.5k|#define MP_IMGFLAG_RGB_P        (1 << 17)
  ------------------
  615|  42.5k|            }
  616|   713k|        }
  617|  1.19M|        if (cnt == 3 && desc.num_planes == 2 &&
  ------------------
  |  Branch (617:13): [True: 1.10M, False: 96.9k]
  |  Branch (617:25): [True: 32.2k, False: 1.06M]
  ------------------
  618|  32.2k|            desc.bpp[1] == desc.bpp[0] * 2 &&
  ------------------
  |  Branch (618:13): [True: 32.2k, False: 0]
  ------------------
  619|  32.2k|            (desc.flags & MP_IMGFLAG_YUV))
  ------------------
  |  |   67|  32.2k|#define MP_IMGFLAG_YUV          MP_IMGFLAG_COLOR_YUV
  |  |  ------------------
  |  |  |  |   56|  32.2k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  |  |  ------------------
  ------------------
  |  Branch (619:13): [True: 32.2k, False: 0]
  ------------------
  620|  32.2k|        {
  621|       |
  622|  32.2k|            desc.flags |= MP_IMGFLAG_YUV_NV;
  ------------------
  |  |  101|  32.2k|#define MP_IMGFLAG_YUV_NV       (1 << 18)
  ------------------
  623|  32.2k|        }
  624|  1.19M|    }
  625|       |
  626|  1.34M|    return desc;
  627|  1.69M|}
mp_imgfmt_get_forced_csp:
  682|   336k|{
  683|   336k|    return get_forced_csp_from_flags(mp_imgfmt_get_desc(imgfmt).flags);
  684|   336k|}
mp_imgfmt_is_subsampled:
  830|   196k|{
  831|   196k|    struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
  832|   196k|    return desc.chroma_xs || desc.chroma_ys;
  ------------------
  |  Branch (832:12): [True: 4.22k, False: 192k]
  |  Branch (832:30): [True: 0, False: 192k]
  ------------------
  833|   196k|}
img_format.c:get_mp_desc:
  124|  1.92M|{
  125|  1.92M|    if (imgfmt < IMGFMT_CUST_BASE)
  ------------------
  |  Branch (125:9): [True: 1.24M, False: 681k]
  ------------------
  126|  1.24M|        return NULL;
  127|   681k|    int index = imgfmt - IMGFMT_CUST_BASE;
  128|   681k|    if (index >= MP_ARRAY_SIZE(mp_imgfmt_list))
  ------------------
  |  |   49|   681k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (128:9): [True: 647k, False: 33.4k]
  ------------------
  129|   647k|        return NULL;
  130|  33.4k|    const struct mp_imgfmt_entry *e = &mp_imgfmt_list[index];
  131|  33.4k|    return e->name ? e : NULL;
  ------------------
  |  Branch (131:12): [True: 32.2k, False: 1.28k]
  ------------------
  132|   681k|}
img_format.c:get_native_desc:
  523|  1.69M|{
  524|  1.69M|    const struct mp_imgfmt_entry *p = get_mp_desc(mpfmt);
  525|  1.69M|    if (!p || !p->desc.flags)
  ------------------
  |  Branch (525:9): [True: 1.65M, False: 32.2k]
  |  Branch (525:15): [True: 2.57k, False: 29.6k]
  ------------------
  526|  1.66M|        return false;
  527|       |
  528|  29.6k|    *desc = p->desc;
  529|       |
  530|       |    // Fill in some fields mp_imgfmt_entry.desc is not required to set.
  531|       |
  532|  29.6k|    desc->id = mpfmt;
  533|       |
  534|   148k|    for (int n = 0; n < MP_NUM_COMPONENTS; n++) {
  ------------------
  |  |   29|   148k|#define MP_NUM_COMPONENTS 4
  ------------------
  |  Branch (534:21): [True: 118k, False: 29.6k]
  ------------------
  535|   118k|        struct mp_imgfmt_comp_desc *cd = &desc->comps[n];
  536|   118k|        if (cd->size)
  ------------------
  |  Branch (536:13): [True: 86.2k, False: 32.2k]
  ------------------
  537|  86.2k|            desc->num_planes = MPMAX(desc->num_planes, cd->plane + 1);
  ------------------
  |  |   44|  86.2k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 15.4k, False: 70.8k]
  |  |  ------------------
  ------------------
  538|   118k|        desc->bpp[cd->plane] =
  539|   118k|            MPMAX(desc->bpp[cd->plane], MP_ALIGN_UP(cd->offset + cd->size, 8));
  ------------------
  |  |   44|   118k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 27.0k, False: 91.4k]
  |  |  ------------------
  ------------------
  540|   118k|    }
  541|       |
  542|  29.6k|    if (!desc->align_x && !desc->align_y) {
  ------------------
  |  Branch (542:9): [True: 29.6k, False: 0]
  |  Branch (542:27): [True: 29.6k, False: 0]
  ------------------
  543|  29.6k|        desc->align_x = 1 << desc->chroma_xs;
  544|  29.6k|        desc->align_y = 1 << desc->chroma_ys;
  545|  29.6k|    }
  546|       |
  547|  29.6k|    if (desc->num_planes)
  ------------------
  |  Branch (547:9): [True: 28.3k, False: 1.28k]
  ------------------
  548|  28.3k|        desc->flags |= MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_NE;
  ------------------
  |  |   34|  28.3k|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
                      desc->flags |= MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_NE;
  ------------------
  |  |   49|  28.3k|#define MP_IMGFLAG_NE           MP_SELECT_LE_BE(MP_IMGFLAG_LE, MP_IMGFLAG_BE)
  |  |  ------------------
  |  |  |  |   38|  28.3k|#define MP_SELECT_LE_BE(LE, BE) LE
  |  |  ------------------
  ------------------
  549|       |
  550|  29.6k|    if (!(desc->flags & MP_IMGFLAG_TYPE_MASK))
  ------------------
  |  |   61|  29.6k|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
  |  Branch (550:9): [True: 11.5k, False: 18.0k]
  ------------------
  551|  11.5k|        desc->flags |= MP_IMGFLAG_TYPE_UINT;
  ------------------
  |  |   62|  11.5k|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  552|       |
  553|       |    return true;
  554|  1.69M|}
img_format.c:mp_imgfmt_get_desc_from_pixdesc:
  413|  1.66M|{
  414|  1.66M|    enum AVPixelFormat fmt = imgfmt2pixfmt(mpfmt);
  415|  1.66M|    const AVPixFmtDescriptor *pd = av_pix_fmt_desc_get(fmt);
  416|  1.66M|    if (!pd || pd->nb_components > 4)
  ------------------
  |  Branch (416:9): [True: 345k, False: 1.31M]
  |  Branch (416:16): [True: 0, False: 1.31M]
  ------------------
  417|   345k|        return false;
  418|       |
  419|  1.31M|    struct mp_imgfmt_desc desc = {
  420|  1.31M|        .id = mpfmt,
  421|  1.31M|        .chroma_xs = pd->log2_chroma_w,
  422|  1.31M|        .chroma_ys = pd->log2_chroma_h,
  423|  1.31M|    };
  424|       |
  425|  1.31M|    if (pd->flags & AV_PIX_FMT_FLAG_ALPHA)
  ------------------
  |  Branch (425:9): [True: 95.6k, False: 1.22M]
  ------------------
  426|  95.6k|        desc.flags |= MP_IMGFLAG_ALPHA;
  ------------------
  |  |   52|  95.6k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  427|       |
  428|  1.31M|    if (pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (428:9): [True: 21.8k, False: 1.29M]
  ------------------
  429|  21.8k|        desc.flags |= MP_IMGFLAG_TYPE_HW;
  ------------------
  |  |   65|  21.8k|#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|  1.31M|    if (strncmp(pd->name, "xyz", 3) == 0) {
  ------------------
  |  Branch (432:9): [True: 5.15k, False: 1.31M]
  ------------------
  433|  5.15k|        desc.flags |= MP_IMGFLAG_COLOR_XYZ;
  ------------------
  |  |   58|  5.15k|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  434|  1.31M|    } else if (pd->flags & AV_PIX_FMT_FLAG_RGB) {
  ------------------
  |  Branch (434:16): [True: 538k, False: 772k]
  ------------------
  435|   538k|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|   538k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  436|   772k|    } else if (fmt == AV_PIX_FMT_MONOBLACK || fmt == AV_PIX_FMT_MONOWHITE) {
  ------------------
  |  Branch (436:16): [True: 1.28k, False: 771k]
  |  Branch (436:47): [True: 1.28k, False: 770k]
  ------------------
  437|  2.57k|        desc.flags |= MP_IMGFLAG_COLOR_RGB;
  ------------------
  |  |   57|  2.57k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  438|   770k|    } else if (fmt == AV_PIX_FMT_PAL8) {
  ------------------
  |  Branch (438:16): [True: 1.28k, False: 768k]
  ------------------
  439|  1.28k|        desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   57|  1.28k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
                      desc.flags |= MP_IMGFLAG_COLOR_RGB | MP_IMGFLAG_TYPE_PAL8;
  ------------------
  |  |   64|  1.28k|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  ------------------
  440|  1.28k|    }
  441|       |
  442|  1.31M|    if (pd->flags & AV_PIX_FMT_FLAG_FLOAT)
  ------------------
  |  Branch (442:9): [True: 30.9k, False: 1.28M]
  ------------------
  443|  30.9k|        desc.flags |= MP_IMGFLAG_TYPE_FLOAT;
  ------------------
  |  |   63|  30.9k|#define MP_IMGFLAG_TYPE_FLOAT   (2 << 10)
  ------------------
  444|       |
  445|       |    // Educated guess.
  446|  1.31M|    if (!(desc.flags & MP_IMGFLAG_COLOR_MASK) &&
  ------------------
  |  |   55|  1.31M|#define MP_IMGFLAG_COLOR_MASK   (15 << 6)
  ------------------
  |  Branch (446:9): [True: 768k, False: 547k]
  ------------------
  447|   768k|        !(desc.flags & MP_IMGFLAG_TYPE_HW))
  ------------------
  |  |   65|   768k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  ------------------
  |  Branch (447:9): [True: 746k, False: 21.8k]
  ------------------
  448|   746k|        desc.flags |= MP_IMGFLAG_COLOR_YUV;
  ------------------
  |  |   56|   746k|#define MP_IMGFLAG_COLOR_YUV    (1 << 6)
  ------------------
  449|       |
  450|  1.31M|    desc.align_x = 1 << desc.chroma_xs;
  451|  1.31M|    desc.align_y = 1 << desc.chroma_ys;
  452|       |
  453|  1.31M|    fill_pixdesc_layout(&desc, fmt, pd);
  454|       |
  455|  1.31M|    if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   34|  1.31M|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
                  if (desc.flags & (MP_IMGFLAG_HAS_COMPS | MP_IMGFLAG_PACKED_SS_YUV)) {
  ------------------
  |  |   86|  1.31M|#define MP_IMGFLAG_PACKED_SS_YUV (1 << 15)
  ------------------
  |  Branch (455:9): [True: 1.26M, False: 51.5k]
  ------------------
  456|  1.26M|        if (!(desc.flags & MP_IMGFLAG_TYPE_MASK))
  ------------------
  |  |   61|  1.26M|#define MP_IMGFLAG_TYPE_MASK    (15 << 10)
  ------------------
  |  Branch (456:13): [True: 1.23M, False: 25.7k]
  ------------------
  457|  1.23M|            desc.flags |= MP_IMGFLAG_TYPE_UINT;
  ------------------
  |  |   62|  1.23M|#define MP_IMGFLAG_TYPE_UINT    (1 << 10)
  ------------------
  458|  1.26M|    }
  459|       |
  460|  1.31M|    if (desc.bpp[0] % 8u && (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM))
  ------------------
  |  Branch (460:9): [True: 6.44k, False: 1.30M]
  |  Branch (460:29): [True: 5.15k, False: 1.28k]
  ------------------
  461|  5.15k|        desc.align_x = 8 / desc.bpp[0]; // expect power of 2
  462|       |
  463|       |    // Very heuristical.
  464|  1.31M|    bool is_ne = !desc.endian_shift;
  465|  1.31M|    bool need_endian = (desc.comps[0].size % 8u && desc.bpp[0] > 8) ||
  ------------------
  |  Branch (465:25): [True: 33.4k, False: 1.28M]
  |  Branch (465:52): [True: 23.1k, False: 10.3k]
  ------------------
  466|  1.29M|                       desc.comps[0].size > 8;
  ------------------
  |  Branch (466:24): [True: 208k, False: 1.08M]
  ------------------
  467|       |
  468|  1.31M|    if (need_endian) {
  ------------------
  |  Branch (468:9): [True: 231k, False: 1.08M]
  ------------------
  469|   231k|        bool is_le = MP_SELECT_LE_BE(is_ne, !is_ne);
  ------------------
  |  |   38|   231k|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  470|   231k|        desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   43|   117k|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= is_le ? MP_IMGFLAG_LE : MP_IMGFLAG_BE;
  ------------------
  |  |   46|   346k|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  |  Branch (470:23): [True: 117k, False: 114k]
  ------------------
  471|  1.08M|    } else {
  472|  1.08M|        desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   43|  1.08M|#define MP_IMGFLAG_LE           (1 << 3)
  ------------------
                      desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
  ------------------
  |  |   46|  1.08M|#define MP_IMGFLAG_BE           (1 << 4)
  ------------------
  473|  1.08M|    }
  474|       |
  475|  1.31M|    *out = desc;
  476|       |    return true;
  477|  1.66M|}
img_format.c:fill_pixdesc_layout:
  189|  1.31M|{
  190|  1.31M|    if (pd->flags & AV_PIX_FMT_FLAG_PAL ||
  ------------------
  |  Branch (190:9): [True: 1.28k, False: 1.31M]
  ------------------
  191|  1.31M|        pd->flags & AV_PIX_FMT_FLAG_HWACCEL)
  ------------------
  |  Branch (191:9): [True: 21.8k, False: 1.29M]
  ------------------
  192|  23.1k|        goto fail;
  193|       |
  194|  1.31M|    bool has_alpha = pd->flags & AV_PIX_FMT_FLAG_ALPHA;
  195|  1.29M|    if (pd->nb_components != 1 + has_alpha &&
  ------------------
  |  Branch (195:9): [True: 1.25M, False: 33.4k]
  ------------------
  196|  1.25M|        pd->nb_components != 3 + has_alpha)
  ------------------
  |  Branch (196:9): [True: 0, False: 1.25M]
  ------------------
  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|  1.29M|    bool is_be = pd->flags & AV_PIX_FMT_FLAG_BE;
  203|  1.29M|    bool is_ne = MP_SELECT_LE_BE(false, true) == is_be;
  ------------------
  |  |   38|  1.29M|#define MP_SELECT_LE_BE(LE, BE) LE
  ------------------
  204|       |
  205|       |    // Packed sub-sampled YUV is very... special.
  206|  1.29M|    bool is_packed_ss_yuv = pd->log2_chroma_w && !pd->log2_chroma_h &&
  ------------------
  |  Branch (206:29): [True: 105k, False: 1.18M]
  |  Branch (206:50): [True: 54.0k, False: 51.6k]
  ------------------
  207|  54.0k|        pd->comp[1].plane == 0 && pd->comp[2].plane == 0 &&
  ------------------
  |  Branch (207:9): [True: 12.8k, False: 41.2k]
  |  Branch (207:35): [True: 12.8k, False: 0]
  ------------------
  208|  12.8k|        pd->nb_components == 3;
  ------------------
  |  Branch (208:9): [True: 12.8k, False: 0]
  ------------------
  209|       |
  210|  1.29M|    if (is_packed_ss_yuv)
  ------------------
  |  Branch (210:9): [True: 12.8k, False: 1.27M]
  ------------------
  211|  12.8k|        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|  1.29M|    bool any_shared_bytes = !!(pd->flags & AV_PIX_FMT_FLAG_BITSTREAM);
  217|  5.19M|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (217:21): [True: 3.90M, False: 1.29M]
  ------------------
  218|  7.94M|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (218:25): [True: 4.04M, False: 3.90M]
  ------------------
  219|  4.04M|            const AVComponentDescriptor *d1 = &pd->comp[c];
  220|  4.04M|            const AVComponentDescriptor *d2 = &pd->comp[i];
  221|  4.04M|            if (d1->plane == d2->plane) {
  ------------------
  |  Branch (221:17): [True: 1.73M, False: 2.31M]
  ------------------
  222|  1.73M|                if (d1->offset + (d1->depth + 7) / 8u > d2->offset &&
  ------------------
  |  Branch (222:21): [True: 1.59M, False: 132k]
  ------------------
  223|  1.59M|                    d2->offset + (d2->depth + 7) / 8u > d1->offset)
  ------------------
  |  Branch (223:21): [True: 92.7k, False: 1.50M]
  ------------------
  224|  92.7k|                    any_shared_bytes = true;
  225|  1.73M|            }
  226|  4.04M|        }
  227|  3.90M|    }
  228|       |
  229|  1.29M|    int el_bits = (pd->flags & AV_PIX_FMT_FLAG_BITSTREAM) ? 1 : 8;
  ------------------
  |  Branch (229:19): [True: 7.72k, False: 1.28M]
  ------------------
  230|  5.17M|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (230:21): [True: 3.89M, False: 1.27M]
  ------------------
  231|  3.89M|        const AVComponentDescriptor *d = &pd->comp[c];
  232|  3.89M|        if (d->plane >= MP_MAX_PLANES)
  ------------------
  |  |   28|  3.89M|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (232:13): [True: 0, False: 3.89M]
  ------------------
  233|      0|            goto fail;
  234|       |
  235|  3.89M|        desc->num_planes = MPMAX(desc->num_planes, d->plane + 1);
  ------------------
  |  |   44|  3.89M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 87.5k, False: 3.80M]
  |  |  ------------------
  ------------------
  236|       |
  237|  3.89M|        int plane_bits = desc->bpp[d->plane];
  238|  3.89M|        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|  3.89M|        if (plane_bits) {
  ------------------
  |  Branch (242:13): [True: 1.13M, False: 2.75M]
  ------------------
  243|  1.13M|            if (c_bits > plane_bits)
  ------------------
  |  Branch (243:17): [True: 5.15k, False: 1.13M]
  ------------------
  244|  5.15k|                goto fail; // inconsistent
  245|  2.75M|        } else {
  246|  2.75M|            desc->bpp[d->plane] = plane_bits = c_bits;
  247|  2.75M|        }
  248|       |
  249|  3.89M|        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|  3.89M|        if (fmt == AV_PIX_FMT_MONOBLACK)
  ------------------
  |  Branch (253:13): [True: 1.28k, False: 3.88M]
  ------------------
  254|  1.28k|            shift = 0;
  255|       |
  256|  3.89M|        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|  3.89M|        int word = mp_round_next_power_of_2(MPMAX(d->depth + shift, 8));
  ------------------
  |  |   44|  3.89M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 695k, False: 3.19M]
  |  |  ------------------
  ------------------
  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|  3.89M|        if (is_be && el_bits == 8 && word == 8)
  ------------------
  |  Branch (272:13): [True: 381k, False: 3.50M]
  |  Branch (272:22): [True: 373k, False: 7.72k]
  |  Branch (272:38): [True: 33.4k, False: 340k]
  ------------------
  273|  33.4k|            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|  3.89M|        int access_size = 8;
  288|  3.89M|        if (plane_bits > 8) {
  ------------------
  |  Branch (288:13): [True: 2.10M, False: 1.78M]
  ------------------
  289|  2.10M|            if (any_shared_bytes) {
  ------------------
  |  Branch (289:17): [True: 108k, False: 1.99M]
  ------------------
  290|   108k|                access_size = plane_bits;
  291|   108k|                if (is_be && word != access_size) {
  ------------------
  |  Branch (291:21): [True: 54.0k, False: 54.0k]
  |  Branch (291:30): [True: 48.9k, False: 5.15k]
  ------------------
  292|       |                    // Before: offset = 8*byte_offset (with word bits of data)
  293|       |                    // After: offset = bit_offset into swapped endian_size word
  294|  48.9k|                    offset = access_size - word - offset;
  295|  48.9k|                }
  296|  1.99M|            } else {
  297|  1.99M|                access_size = word;
  298|  1.99M|            }
  299|  2.10M|        }
  300|  3.89M|        int endian_size = (access_size && !is_ne) ? access_size : 8;
  ------------------
  |  Branch (300:28): [True: 3.89M, False: 18.4E]
  |  Branch (300:43): [True: 381k, False: 3.50M]
  ------------------
  301|  3.89M|        int endian_shift = mp_log2(endian_size) - 3;
  302|  3.89M|        if (!MP_IS_POWER_OF_2(endian_size) || endian_shift < 0 || endian_shift > 3)
  ------------------
  |  |   56|  7.78M|#define MP_IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1)))
  |  |  ------------------
  |  |  |  Branch (56:30): [True: 3.89M, False: 18.4E]
  |  |  |  Branch (56:41): [True: 3.89M, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (302:47): [True: 0, False: 3.89M]
  |  Branch (302:67): [True: 2, False: 3.89M]
  ------------------
  303|      0|            goto fail;
  304|  3.89M|        if (desc->endian_shift && desc->endian_shift != endian_shift)
  ------------------
  |  Branch (304:13): [True: 253k, False: 3.63M]
  |  Branch (304:35): [True: 0, False: 253k]
  ------------------
  305|      0|            goto fail;
  306|  3.89M|        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|  3.89M|        offset += shift;
  311|  3.89M|        if (offset < 0 || offset >= (1 << 6))
  ------------------
  |  Branch (311:13): [True: 2.57k, False: 3.88M]
  |  Branch (311:27): [True: 5.15k, False: 3.88M]
  ------------------
  312|  7.72k|            goto fail;
  313|  3.88M|        if (offset + d->depth > plane_bits)
  ------------------
  |  Branch (313:13): [True: 0, False: 3.88M]
  ------------------
  314|      0|            goto fail;
  315|  3.88M|        if (d->depth < 0 || d->depth >= (1 << 6))
  ------------------
  |  Branch (315:13): [True: 18.4E, False: 3.88M]
  |  Branch (315:29): [True: 18.4E, False: 3.88M]
  ------------------
  316|      0|            goto fail;
  317|  3.88M|        desc->comps[c] = (struct mp_imgfmt_comp_desc){
  318|  3.88M|            .plane = d->plane,
  319|  3.88M|            .offset = offset,
  320|  3.88M|            .size = d->depth,
  321|  3.88M|        };
  322|  3.88M|    }
  323|       |
  324|  4.03M|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (324:21): [True: 2.75M, False: 1.27M]
  ------------------
  325|  2.75M|        if (!desc->bpp[p])
  ------------------
  |  Branch (325:13): [True: 0, False: 2.75M]
  ------------------
  326|      0|            goto fail; // plane doesn't exist
  327|  2.75M|    }
  328|       |
  329|       |    // What the fuck: this is probably a pixdesc bug, so fix it.
  330|  1.27M|    if (fmt == AV_PIX_FMT_RGB8) {
  ------------------
  |  Branch (330:9): [True: 1.28k, False: 1.27M]
  ------------------
  331|  1.28k|        desc->comps[2] = (struct mp_imgfmt_comp_desc){0, 0, 2};
  332|  1.28k|        desc->comps[1] = (struct mp_imgfmt_comp_desc){0, 2, 3};
  333|  1.28k|        desc->comps[0] = (struct mp_imgfmt_comp_desc){0, 5, 3};
  334|  1.28k|    }
  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|  1.27M|    bool any_shared_bits = false;
  340|  5.14M|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (340:21): [True: 3.86M, False: 1.27M]
  ------------------
  341|  7.85M|        for (int i = 0; i < c; i++) {
  ------------------
  |  Branch (341:25): [True: 3.98M, False: 3.86M]
  ------------------
  342|  3.98M|            struct mp_imgfmt_comp_desc *c1 = &desc->comps[c];
  343|  3.98M|            struct mp_imgfmt_comp_desc *c2 = &desc->comps[i];
  344|  3.98M|            if (c1->plane == c2->plane) {
  ------------------
  |  Branch (344:17): [True: 1.67M, False: 2.31M]
  ------------------
  345|  1.67M|                if (c1->offset + c1->size > c2->offset &&
  ------------------
  |  Branch (345:21): [True: 1.53M, False: 145k]
  ------------------
  346|  1.53M|                    c2->offset + c2->size > c1->offset)
  ------------------
  |  Branch (346:21): [True: 46.3k, False: 1.48M]
  ------------------
  347|  46.3k|                    any_shared_bits = true;
  348|  1.67M|            }
  349|  3.98M|        }
  350|  3.86M|    }
  351|       |
  352|  1.27M|    if (any_shared_bits) {
  ------------------
  |  Branch (352:9): [True: 15.4k, False: 1.26M]
  ------------------
  353|  61.8k|        for (int c = 0; c < pd->nb_components; c++)
  ------------------
  |  Branch (353:25): [True: 46.3k, False: 15.4k]
  ------------------
  354|  46.3k|            desc->comps[c] = (struct mp_imgfmt_comp_desc){0};
  355|  15.4k|    }
  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|  5.14M|    for (int c = 0; c < pd->nb_components; c++) {
  ------------------
  |  Branch (365:21): [True: 3.86M, False: 1.27M]
  ------------------
  366|  3.86M|        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|  3.86M|        int fsize = MP_ALIGN_UP(cd->size, 8);
  ------------------
  |  |   53|  3.86M|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  370|  3.86M|        if (!any_shared_bytes && el_bits == 8 && fsize != cd->size &&
  ------------------
  |  Branch (370:13): [True: 3.72M, False: 141k]
  |  Branch (370:34): [True: 3.72M, False: 0]
  |  Branch (370:50): [True: 386k, False: 3.33M]
  ------------------
  371|   386k|            fsize - cd->size <= (1 << 3))
  ------------------
  |  Branch (371:13): [True: 386k, False: 0]
  ------------------
  372|   386k|        {
  373|   386k|            if (!(cd->offset % 8u)) {
  ------------------
  |  Branch (373:17): [True: 270k, False: 115k]
  ------------------
  374|   270k|                cd->pad = -(fsize - cd->size);
  375|   270k|                cd->size = fsize;
  376|   270k|            } else if (!((cd->offset + cd->size) % 8u)) {
  ------------------
  |  Branch (376:24): [True: 115k, False: 0]
  ------------------
  377|   115k|                cd->pad = fsize - cd->size;
  378|   115k|                cd->size = fsize;
  379|   115k|                cd->offset = MP_ALIGN_DOWN(cd->offset, 8);
  ------------------
  |  |   54|   115k|#define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
  ------------------
  380|   115k|            }
  381|   386k|        }
  382|  3.86M|    }
  383|       |
  384|       |    // The alpha component always has ID 4 (index 3) in our representation, so
  385|       |    // move the alpha component to there.
  386|  1.27M|    if (has_alpha && pd->nb_components < 4) {
  ------------------
  |  Branch (386:9): [True: 89.2k, False: 1.19M]
  |  Branch (386:22): [True: 9.01k, False: 80.2k]
  ------------------
  387|  9.01k|        desc->comps[3] = desc->comps[pd->nb_components - 1];
  388|  9.01k|        desc->comps[pd->nb_components - 1] = (struct mp_imgfmt_comp_desc){0};
  389|  9.01k|    }
  390|       |
  391|  1.27M|    if (is_packed_ss_yuv) {
  ------------------
  |  Branch (391:9): [True: 12.8k, False: 1.26M]
  ------------------
  392|  12.8k|        desc->flags |= MP_IMGFLAG_PACKED_SS_YUV;
  ------------------
  |  |   86|  12.8k|#define MP_IMGFLAG_PACKED_SS_YUV (1 << 15)
  ------------------
  393|  12.8k|        desc->bpp[0] /= 1 << pd->log2_chroma_w;
  394|  1.26M|    } else if (!any_shared_bits) {
  ------------------
  |  Branch (394:16): [True: 1.25M, False: 15.4k]
  ------------------
  395|  1.25M|        desc->flags |= MP_IMGFLAG_HAS_COMPS;
  ------------------
  |  |   34|  1.25M|#define MP_IMGFLAG_HAS_COMPS    (1 << 0)
  ------------------
  396|  1.25M|    }
  397|       |
  398|  1.27M|    return;
  399|       |
  400|  36.0k|fail:
  401|   180k|    for (int n = 0; n < 4; n++)
  ------------------
  |  Branch (401:21): [True: 144k, False: 36.0k]
  ------------------
  402|   144k|        desc->comps[n] = (struct mp_imgfmt_comp_desc){0};
  403|       |    // Average bit size fallback.
  404|  36.0k|    int num_planes = av_pix_fmt_count_planes(fmt);
  405|  36.0k|    desc->num_planes = MPCLAMP(num_planes, 0, MP_MAX_PLANES);
  ------------------
  |  |   46|  36.0k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 36.0k]
  |  |  |  Branch (46:56): [True: 0, False: 36.0k]
  |  |  ------------------
  ------------------
  406|  50.2k|    for (int p = 0; p < desc->num_planes; p++) {
  ------------------
  |  Branch (406:21): [True: 14.1k, False: 36.0k]
  ------------------
  407|  14.1k|        int ls = av_image_get_linesize(fmt, 256, p);
  408|  14.1k|        desc->bpp[p] = ls > 0 ? ls * 8 / 256 : 0;
  ------------------
  |  Branch (408:24): [True: 14.1k, False: 0]
  ------------------
  409|  14.1k|    }
  410|  36.0k|}
img_format.c:get_forced_csp_from_flags:
  671|   336k|{
  672|   336k|    if (flags & MP_IMGFLAG_COLOR_XYZ)
  ------------------
  |  |   58|   336k|#define MP_IMGFLAG_COLOR_XYZ    (4 << 6)
  ------------------
  |  Branch (672:9): [True: 0, False: 336k]
  ------------------
  673|      0|        return PL_COLOR_SYSTEM_XYZ;
  674|       |
  675|   336k|    if (flags & MP_IMGFLAG_COLOR_RGB)
  ------------------
  |  |   57|   336k|#define MP_IMGFLAG_COLOR_RGB    (2 << 6)
  ------------------
  |  Branch (675:9): [True: 136k, False: 200k]
  ------------------
  676|   136k|        return PL_COLOR_SYSTEM_RGB;
  677|       |
  678|   200k|    return PL_COLOR_SYSTEM_UNKNOWN;
  679|   336k|}

mp_image_get_alloc_size:
   99|  70.2k|{
  100|  70.2k|    int stride[MP_MAX_PLANES];
  101|  70.2k|    int plane_offset[MP_MAX_PLANES];
  102|  70.2k|    int plane_size[MP_MAX_PLANES];
  103|  70.2k|    return mp_image_layout(imgfmt, w, h, stride_align, stride, plane_offset,
  104|  70.2k|                           plane_size);
  105|  70.2k|}
mp_image_sethwfmt:
  199|   111k|{
  200|   111k|    struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(sw_fmt ? sw_fmt : hw_fmt);
  ------------------
  |  Branch (200:52): [True: 0, False: 111k]
  ------------------
  201|   111k|    mpi->params.imgfmt = hw_fmt;
  202|   111k|    mpi->params.hw_subfmt = sw_fmt;
  203|   111k|    mpi->fmt = fmt;
  204|   111k|    mpi->imgfmt = hw_fmt;
  205|   111k|    mpi->num_planes = fmt.num_planes;
  206|   111k|    mpi->params.repr.alpha = (fmt.flags & MP_IMGFLAG_ALPHA) ? PL_ALPHA_INDEPENDENT
  ------------------
  |  |   52|   111k|#define MP_IMGFLAG_ALPHA        (1 << 5)
  ------------------
  |  Branch (206:30): [True: 3.02k, False: 108k]
  ------------------
  207|   111k|                                                            : PL_ALPHA_NONE;
  208|       |    // Calculate bit encoding from all components (excluding alpha)
  209|   111k|    struct pl_bit_encoding bits = {0};
  210|   111k|    const int num_comps = mp_imgfmt_desc_get_num_comps(&fmt);
  211|   447k|    for (int c = 0; c < MPMIN(num_comps, 3); c++) {
  ------------------
  |  |   45|   447k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 12.0k, False: 435k]
  |  |  ------------------
  ------------------
  |  Branch (211:21): [True: 335k, False: 111k]
  ------------------
  212|   335k|        struct pl_bit_encoding cbits = {
  213|   335k|            .sample_depth = fmt.comps[c].size,
  214|   335k|            .color_depth  = fmt.comps[c].size - abs(fmt.comps[c].pad),
  215|   335k|            .bit_shift    = MPMAX(fmt.comps[c].pad, 0),
  ------------------
  |  |   44|   335k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 335k]
  |  |  ------------------
  ------------------
  216|   335k|        };
  217|       |
  218|   335k|        if (bits.sample_depth && !pl_bit_encoding_equal(&bits, &cbits)) {
  ------------------
  |  Branch (218:13): [True: 223k, False: 111k]
  |  Branch (218:34): [True: 0, False: 223k]
  ------------------
  219|       |            // Bit encoding differs between components, cannot handle this
  220|      0|            bits = (struct pl_bit_encoding) {0};
  221|      0|            break;
  222|      0|        }
  223|       |
  224|   335k|        bits = cbits;
  225|   335k|    }
  226|   111k|    mpi->params.repr.bits = bits;
  227|   111k|}
mp_image_setfmt:
  230|  73.2k|{
  231|  73.2k|    mp_image_sethwfmt(mpi, fmt, IMGFMT_NONE);
  232|  73.2k|}
mp_chroma_div_up:
  251|   771k|{
  252|   771k|    return (size + (1 << shift) - 1) >> shift;
  253|   771k|}
mp_image_plane_w:
  257|   105k|{
  258|   105k|    return mp_chroma_div_up(mpi->w, mpi->fmt.xs[plane]);
  259|   105k|}
mp_image_plane_h:
  263|   105k|{
  264|   105k|    return mp_chroma_div_up(mpi->h, mpi->fmt.ys[plane]);
  265|   105k|}
mp_image_set_size:
  269|   111k|{
  270|   111k|    mp_assert(w >= 0 && h >= 0);
  ------------------
  |  |   41|   111k|#define mp_assert assert
  ------------------
  |  Branch (270:5): [True: 111k, False: 0]
  |  Branch (270:5): [True: 111k, False: 0]
  ------------------
  271|   111k|    mpi->w = mpi->params.w = w;
  272|   111k|    mpi->h = mpi->params.h = h;
  273|   111k|}
mp_image_set_params:
  277|  3.02k|{
  278|       |    // possibly initialize other stuff
  279|  3.02k|    mp_image_setfmt(image, params->imgfmt);
  280|  3.02k|    mp_image_set_size(image, params->w, params->h);
  281|  3.02k|    image->params = *params;
  282|  3.02k|}
mp_image_alloc:
  285|  70.2k|{
  286|  70.2k|    struct mp_image *mpi = talloc_zero(NULL, struct mp_image);
  ------------------
  |  |   27|  70.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  70.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  70.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|  70.2k|    talloc_set_destructor(mpi, mp_image_destructor);
  ------------------
  |  |   41|  70.2k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  288|       |
  289|  70.2k|    mp_image_set_size(mpi, w, h);
  290|  70.2k|    mp_image_setfmt(mpi, imgfmt);
  291|  70.2k|    if (!mp_image_alloc_planes(mpi)) {
  ------------------
  |  Branch (291:9): [True: 11, False: 70.2k]
  ------------------
  292|     11|        talloc_free(mpi);
  ------------------
  |  |   47|     11|#define talloc_free                     ta_free
  ------------------
  293|     11|        return NULL;
  294|     11|    }
  295|  70.2k|    return mpi;
  296|  70.2k|}
mp_image_approx_byte_size:
  299|    938|{
  300|    938|    int total = sizeof(*img);
  301|       |
  302|  4.69k|    for (int n = 0; n < MP_MAX_PLANES; n++) {
  ------------------
  |  |   28|  4.69k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (302:21): [True: 3.75k, False: 938]
  ------------------
  303|  3.75k|        struct AVBufferRef *buf = img->bufs[n];
  304|  3.75k|        if (buf)
  ------------------
  |  Branch (304:13): [True: 2.81k, False: 938]
  ------------------
  305|  2.81k|            total += buf->size;
  306|  3.75k|    }
  307|       |
  308|    938|    return total;
  309|    938|}
mp_image_new_ref:
  360|   197k|{
  361|   197k|    if (!img)
  ------------------
  |  Branch (361:9): [True: 0, False: 197k]
  ------------------
  362|      0|        return NULL;
  363|       |
  364|   197k|    if (!img->bufs[0])
  ------------------
  |  Branch (364:9): [True: 0, False: 197k]
  ------------------
  365|      0|        return mp_image_new_copy(img);
  366|       |
  367|   197k|    struct mp_image *new = talloc_ptrtype(NULL, new);
  ------------------
  |  |   34|   197k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   197k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   197k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|   197k|    talloc_set_destructor(new, mp_image_destructor);
  ------------------
  |  |   41|   197k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  369|   197k|    *new = *img;
  370|       |
  371|   987k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   987k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (371:21): [True: 790k, False: 197k]
  ------------------
  372|   790k|        ref_buffer(&new->bufs[p]);
  373|       |
  374|   197k|    ref_buffer(&new->hwctx);
  375|   197k|    ref_buffer(&new->icc_profile);
  376|   197k|    ref_buffer(&new->a53_cc);
  377|   197k|    ref_buffer(&new->dovi);
  378|   197k|    ref_buffer(&new->film_grain);
  379|       |
  380|   197k|    new->ff_side_data = talloc_memdup(NULL, new->ff_side_data,
  ------------------
  |  |   49|   197k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|   197k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|   197k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|   197k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|   197k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|   197k|                        new->num_ff_side_data * sizeof(new->ff_side_data[0]));
  382|   197k|    for (int n = 0; n < new->num_ff_side_data; n++)
  ------------------
  |  Branch (382:21): [True: 0, False: 197k]
  ------------------
  383|      0|        ref_buffer(&new->ff_side_data[n].buf);
  384|       |
  385|   197k|    new->enhancement_layer = img->enhancement_layer
  ------------------
  |  Branch (385:30): [True: 0, False: 197k]
  ------------------
  386|   197k|        ? mp_image_new_ref(img->enhancement_layer) : NULL;
  387|       |
  388|   197k|    return new;
  389|   197k|}
mp_image_is_writeable:
  447|  35.0k|{
  448|  35.0k|    if (!img->bufs[0])
  ------------------
  |  Branch (448:9): [True: 0, False: 35.0k]
  ------------------
  449|      0|        return true; // not ref-counted => always considered writeable
  450|  70.0k|    for (int p = 0; p < MP_MAX_PLANES; p++) {
  ------------------
  |  |   28|  70.0k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (450:21): [True: 70.0k, False: 0]
  ------------------
  451|  70.0k|        if (!img->bufs[p])
  ------------------
  |  Branch (451:13): [True: 35.0k, False: 35.0k]
  ------------------
  452|  35.0k|            break;
  453|  35.0k|        if (!av_buffer_is_writable(img->bufs[p]))
  ------------------
  |  Branch (453:13): [True: 0, False: 35.0k]
  ------------------
  454|      0|            return false;
  455|  35.0k|    }
  456|  35.0k|    return true;
  457|  35.0k|}
mp_image_setrefp:
  479|  71.0k|{
  480|  71.0k|    if (*p_img != new_value) {
  ------------------
  |  Branch (480:9): [True: 844, False: 70.2k]
  ------------------
  481|    844|        talloc_free(*p_img);
  ------------------
  |  |   47|    844|#define talloc_free                     ta_free
  ------------------
  482|    844|        *p_img = new_value ? mp_image_new_ref(new_value) : NULL;
  ------------------
  |  Branch (482:18): [True: 844, False: 0]
  ------------------
  483|    844|    }
  484|  71.0k|}
mp_image_unrefp:
  488|  3.18M|{
  489|  3.18M|    talloc_free(*p_img);
  ------------------
  |  |   47|  3.18M|#define talloc_free                     ta_free
  ------------------
  490|       |    *p_img = NULL;
  491|  3.18M|}
memcpy_pic:
  495|   105k|{
  496|   105k|    if (bytesPerLine == dstStride && dstStride == srcStride && height) {
  ------------------
  |  Branch (496:9): [True: 105k, False: 0]
  |  Branch (496:38): [True: 105k, False: 0]
  |  Branch (496:64): [True: 105k, False: 0]
  ------------------
  497|   105k|        if (srcStride < 0) {
  ------------------
  |  Branch (497:13): [True: 0, False: 105k]
  ------------------
  498|      0|            src = (uint8_t*)src + (height - 1) * srcStride;
  499|      0|            dst = (uint8_t*)dst + (height - 1) * dstStride;
  500|      0|            srcStride = -srcStride;
  501|      0|        }
  502|       |
  503|   105k|        memcpy(dst, src, srcStride * (height - 1) + bytesPerLine);
  504|   105k|    } else {
  505|      0|        for (int i = 0; i < height; i++) {
  ------------------
  |  Branch (505:25): [True: 0, False: 0]
  ------------------
  506|      0|            memcpy(dst, src, bytesPerLine);
  507|      0|            src = (uint8_t*)src + srcStride;
  508|      0|            dst = (uint8_t*)dst + dstStride;
  509|      0|        }
  510|      0|    }
  511|   105k|}
mp_image_copy:
  514|  35.0k|{
  515|  35.0k|    mp_assert(dst->imgfmt == src->imgfmt);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (515:5): [True: 35.0k, False: 0]
  ------------------
  516|  35.0k|    mp_assert(dst->w == src->w && dst->h == src->h);
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (516:5): [True: 35.0k, False: 0]
  |  Branch (516:5): [True: 35.0k, False: 0]
  ------------------
  517|  35.0k|    mp_assert(mp_image_is_writeable(dst));
  ------------------
  |  |   41|  35.0k|#define mp_assert assert
  ------------------
  |  Branch (517:5): [True: 35.0k, False: 0]
  ------------------
  518|   140k|    for (int n = 0; n < dst->num_planes; n++) {
  ------------------
  |  Branch (518:21): [True: 105k, False: 35.0k]
  ------------------
  519|   105k|        int line_bytes = (mp_image_plane_w(dst, n) * dst->fmt.bpp[n] + 7) / 8;
  520|   105k|        int plane_h = mp_image_plane_h(dst, n);
  521|   105k|        memcpy_pic(dst->planes[n], src->planes[n], line_bytes, plane_h,
  522|   105k|                   dst->stride[n], src->stride[n]);
  523|   105k|    }
  524|  35.0k|    if (dst->fmt.flags & MP_IMGFLAG_PAL)
  ------------------
  |  |   69|  35.0k|#define MP_IMGFLAG_PAL          MP_IMGFLAG_TYPE_PAL8
  |  |  ------------------
  |  |  |  |   64|  35.0k|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  |  |  ------------------
  ------------------
  |  Branch (524:9): [True: 0, False: 35.0k]
  ------------------
  525|      0|        memcpy(dst->planes[1], src->planes[1], AVPALETTE_SIZE);
  526|  35.0k|}
mp_image_copy_attributes:
  549|  70.2k|{
  550|  70.2k|    mp_assert(dst != src);
  ------------------
  |  |   41|  70.2k|#define mp_assert assert
  ------------------
  |  Branch (550:5): [True: 70.2k, False: 0]
  ------------------
  551|       |
  552|  70.2k|    dst->pict_type = src->pict_type;
  553|  70.2k|    dst->fields = src->fields;
  554|  70.2k|    dst->pts = src->pts;
  555|  70.2k|    dst->dts = src->dts;
  556|  70.2k|    dst->pkt_duration = src->pkt_duration;
  557|  70.2k|    dst->params.vflip = src->params.vflip;
  558|  70.2k|    dst->params.rotate = src->params.rotate;
  559|  70.2k|    dst->params.stereo3d = src->params.stereo3d;
  560|  70.2k|    dst->params.p_w = src->params.p_w;
  561|  70.2k|    dst->params.p_h = src->params.p_h;
  562|  70.2k|    dst->params.color = src->params.color;
  563|  70.2k|    dst->params.repr = src->params.repr;
  564|  70.2k|    dst->params.light = src->params.light;
  565|  70.2k|    dst->params.chroma_location = src->params.chroma_location;
  566|  70.2k|    dst->params.crop = src->params.crop;
  567|  70.2k|    dst->nominal_fps = src->nominal_fps;
  568|  70.2k|    dst->params.primaries_orig = src->params.primaries_orig;
  569|  70.2k|    dst->params.transfer_orig = src->params.transfer_orig;
  570|  70.2k|    dst->params.sys_orig = src->params.sys_orig;
  571|  70.2k|    dst->params.no_dovi = src->params.no_dovi;
  572|  70.2k|    dst->params.no_enhancement_layer = src->params.no_enhancement_layer;
  573|       |
  574|       |    // ensure colorspace consistency
  575|  70.2k|    enum pl_color_system dst_forced_csp = mp_image_params_get_forced_csp(&dst->params);
  576|  70.2k|    if (mp_image_params_get_forced_csp(&src->params) != dst_forced_csp) {
  ------------------
  |  Branch (576:9): [True: 33.8k, False: 36.4k]
  ------------------
  577|  33.8k|        dst->params.repr.sys = dst_forced_csp != PL_COLOR_SYSTEM_UNKNOWN ?
  ------------------
  |  Branch (577:32): [True: 33.8k, False: 0]
  ------------------
  578|  33.8k|                                    dst_forced_csp :
  579|  33.8k|                                    mp_csp_guess_colorspace(src->w, src->h);
  580|  33.8k|    }
  581|       |
  582|  70.2k|    if ((dst->fmt.flags & MP_IMGFLAG_PAL) && (src->fmt.flags & MP_IMGFLAG_PAL)) {
  ------------------
  |  |   69|  70.2k|#define MP_IMGFLAG_PAL          MP_IMGFLAG_TYPE_PAL8
  |  |  ------------------
  |  |  |  |   64|  70.2k|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  |  |  ------------------
  ------------------
                  if ((dst->fmt.flags & MP_IMGFLAG_PAL) && (src->fmt.flags & MP_IMGFLAG_PAL)) {
  ------------------
  |  |   69|      0|#define MP_IMGFLAG_PAL          MP_IMGFLAG_TYPE_PAL8
  |  |  ------------------
  |  |  |  |   64|      0|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  |  |  ------------------
  ------------------
  |  Branch (582:9): [True: 0, False: 70.2k]
  |  Branch (582:46): [True: 0, False: 0]
  ------------------
  583|      0|        if (dst->planes[1] && src->planes[1]) {
  ------------------
  |  Branch (583:13): [True: 0, False: 0]
  |  Branch (583:31): [True: 0, False: 0]
  ------------------
  584|      0|            if (mp_image_make_writeable(dst))
  ------------------
  |  Branch (584:17): [True: 0, False: 0]
  ------------------
  585|      0|                memcpy(dst->planes[1], src->planes[1], AVPALETTE_SIZE);
  586|      0|        }
  587|      0|    }
  588|  70.2k|    assign_bufref(&dst->icc_profile, src->icc_profile);
  589|  70.2k|    assign_bufref(&dst->dovi, src->dovi);
  590|  70.2k|    assign_bufref(&dst->film_grain, src->film_grain);
  591|  70.2k|    assign_bufref(&dst->a53_cc, src->a53_cc);
  592|       |
  593|  70.2k|    for (int n = 0; n < dst->num_ff_side_data; n++)
  ------------------
  |  Branch (593:21): [True: 0, False: 70.2k]
  ------------------
  594|      0|        av_buffer_unref(&dst->ff_side_data[n].buf);
  595|       |
  596|  70.2k|    MP_RESIZE_ARRAY(NULL, dst->ff_side_data, src->num_ff_side_data);
  ------------------
  |  |   88|  70.2k|    do {                                                        \
  |  |   89|  70.2k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  ------------------
  |  |  |  |  158|  70.2k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  70.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  70.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  70.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   90|  70.2k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |   91|  70.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded, False: 70.2k]
  |  |  ------------------
  ------------------
  597|  70.2k|    dst->num_ff_side_data = src->num_ff_side_data;
  598|       |
  599|  70.2k|    for (int n = 0; n < dst->num_ff_side_data; n++) {
  ------------------
  |  Branch (599:21): [True: 0, False: 70.2k]
  ------------------
  600|      0|        dst->ff_side_data[n].type = src->ff_side_data[n].type;
  601|      0|        dst->ff_side_data[n].buf = av_buffer_ref(src->ff_side_data[n].buf);
  602|      0|        MP_HANDLE_OOM(dst->ff_side_data[n].buf);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  603|      0|    }
  604|       |
  605|  70.2k|    mp_image_setrefp(&dst->enhancement_layer, src->enhancement_layer);
  606|  70.2k|}
mp_image_crop_valid:
  778|   338k|{
  779|   338k|    return p->crop.x1 > p->crop.x0 && p->crop.y1 > p->crop.y0 &&
  ------------------
  |  Branch (779:12): [True: 331k, False: 6.37k]
  |  Branch (779:39): [True: 331k, False: 0]
  ------------------
  780|   331k|           p->crop.x0 >= 0 && p->crop.y0 >= 0 &&
  ------------------
  |  Branch (780:12): [True: 331k, False: 0]
  |  Branch (780:31): [True: 331k, False: 0]
  ------------------
  781|   331k|           p->crop.x1 <= p->w && p->crop.y1 <= p->h;
  ------------------
  |  Branch (781:12): [True: 331k, False: 0]
  |  Branch (781:34): [True: 331k, False: 0]
  ------------------
  782|   338k|}
mp_image_params_get_dsize:
  787|  64.3k|{
  788|  64.3k|    if (mp_image_crop_valid(p))
  ------------------
  |  Branch (788:9): [True: 60.9k, False: 3.35k]
  ------------------
  789|  60.9k|    {
  790|  60.9k|        *d_w = mp_rect_w(p->crop);
  ------------------
  |  |  157|  60.9k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  791|  60.9k|        *d_h = mp_rect_h(p->crop);
  ------------------
  |  |  158|  60.9k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  792|  60.9k|    } else {
  793|  3.35k|        *d_w = p->w;
  794|  3.35k|        *d_h = p->h;
  795|  3.35k|    }
  796|       |
  797|  64.3k|    if (p->p_w > p->p_h && p->p_h >= 1)
  ------------------
  |  Branch (797:9): [True: 10, False: 64.2k]
  |  Branch (797:28): [True: 10, False: 0]
  ------------------
  798|     10|        *d_w = MPCLAMP(*d_w * (int64_t)p->p_w / p->p_h, 1, INT_MAX);
  ------------------
  |  |   46|     10|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 10]
  |  |  |  Branch (46:56): [True: 0, False: 10]
  |  |  ------------------
  ------------------
  799|  64.3k|    if (p->p_h > p->p_w && p->p_w >= 1)
  ------------------
  |  Branch (799:9): [True: 55, False: 64.2k]
  |  Branch (799:28): [True: 55, False: 0]
  ------------------
  800|     55|        *d_h = MPCLAMP(*d_h * (int64_t)p->p_h / p->p_w, 1, INT_MAX);
  ------------------
  |  |   46|     55|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 55]
  |  |  |  Branch (46:56): [True: 0, False: 55]
  |  |  ------------------
  ------------------
  801|  64.3k|}
mp_image_params_set_dsize:
  804|    714|{
  805|    714|    AVRational ds = av_div_q((AVRational){d_w, d_h}, (AVRational){p->w, p->h});
  806|    714|    p->p_w = ds.num;
  807|    714|    p->p_h = ds.den;
  808|    714|}
mp_image_params_to_str_buf:
  812|   200k|{
  813|   200k|    if (p && p->imgfmt) {
  ------------------
  |  Branch (813:9): [True: 200k, False: 0]
  |  Branch (813:14): [True: 200k, False: 0]
  ------------------
  814|   200k|        snprintf(b, bs, "%dx%d", p->w, p->h);
  815|   200k|        if (p->p_w != p->p_h || !p->p_w)
  ------------------
  |  Branch (815:13): [True: 163, False: 200k]
  |  Branch (815:33): [True: 0, False: 200k]
  ------------------
  816|    163|            mp_snprintf_cat(b, bs, " [%d:%d]", p->p_w, p->p_h);
  817|   200k|        mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
  ------------------
  |  |  333|   200k|#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt))
  ------------------
  818|   200k|        if (p->hw_subfmt)
  ------------------
  |  Branch (818:13): [True: 0, False: 200k]
  ------------------
  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|   200k|        mp_snprintf_cat(b, bs, " %s/%s/%s/%s/%s",
  821|   200k|                        m_opt_choice_str(pl_csp_names, p->repr.sys),
  822|   200k|                        m_opt_choice_str(pl_csp_prim_names, p->color.primaries),
  823|   200k|                        m_opt_choice_str(pl_csp_trc_names, p->color.transfer),
  824|   200k|                        m_opt_choice_str(pl_csp_levels_names, p->repr.levels),
  825|   200k|                        m_opt_choice_str(mp_csp_light_names, p->light));
  826|   200k|        mp_snprintf_cat(b, bs, " CL=%s",
  827|   200k|                        m_opt_choice_str(pl_chroma_names, p->chroma_location));
  828|   200k|        if (mp_image_crop_valid(p)) {
  ------------------
  |  Branch (828:13): [True: 197k, False: 3.02k]
  ------------------
  829|   197k|            mp_snprintf_cat(b, bs, " crop=%dx%d+%d+%d", mp_rect_w(p->crop),
  ------------------
  |  |  157|   197k|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  830|   197k|                            mp_rect_h(p->crop), p->crop.x0, p->crop.y0);
  ------------------
  |  |  158|   197k|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  831|   197k|        }
  832|   200k|        if (p->rotate)
  ------------------
  |  Branch (832:13): [True: 0, False: 200k]
  ------------------
  833|      0|            mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
  834|   200k|        if (p->stereo3d > 0) {
  ------------------
  |  Branch (834:13): [True: 0, False: 200k]
  ------------------
  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|   200k|        if (p->repr.alpha) {
  ------------------
  |  Branch (838:13): [True: 197k, False: 3.02k]
  ------------------
  839|   197k|            mp_snprintf_cat(b, bs, " A=%s",
  840|   197k|                            m_opt_choice_str(pl_alpha_names, p->repr.alpha));
  841|   197k|        }
  842|   200k|    } else {
  843|      0|        snprintf(b, bs, "???");
  844|      0|    }
  845|   200k|    return b;
  846|   200k|}
mp_image_params_valid:
  851|   140k|{
  852|       |    // av_image_check_size has similar checks and triggers around 16000*16000
  853|       |    // It's mostly needed to deal with the fact that offsets are sometimes
  854|       |    // ints. We also should (for now) do the same as FFmpeg, to be sure large
  855|       |    // images don't crash with libswscale or when wrapping with AVFrame and
  856|       |    // passing the result to filters.
  857|   140k|    if (p->w <= 0 || p->h <= 0 || (p->w + 128LL) * (p->h + 128LL) >= INT_MAX / 8)
  ------------------
  |  Branch (857:9): [True: 0, False: 140k]
  |  Branch (857:22): [True: 0, False: 140k]
  |  Branch (857:35): [True: 0, False: 140k]
  ------------------
  858|      0|        return false;
  859|       |
  860|   140k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  861|   140k|    if (p->w > 16384 || p->h > 16384 || p->w * p->h > 2048 * 2048)
  ------------------
  |  Branch (861:9): [True: 0, False: 140k]
  |  Branch (861:25): [True: 11, False: 140k]
  |  Branch (861:41): [True: 0, False: 140k]
  ------------------
  862|     11|        return false;
  863|   140k|#endif
  864|       |
  865|   140k|    if (p->p_w < 0 || p->p_h < 0)
  ------------------
  |  Branch (865:9): [True: 0, False: 140k]
  |  Branch (865:23): [True: 0, False: 140k]
  ------------------
  866|      0|        return false;
  867|       |
  868|   140k|    if (p->rotate < 0 || p->rotate >= 360)
  ------------------
  |  Branch (868:9): [True: 0, False: 140k]
  |  Branch (868:26): [True: 0, False: 140k]
  ------------------
  869|      0|        return false;
  870|       |
  871|   140k|    struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p->imgfmt);
  872|   140k|    if (!desc.id)
  ------------------
  |  Branch (872:9): [True: 0, False: 140k]
  ------------------
  873|      0|        return false;
  874|       |
  875|   140k|    if (p->hw_subfmt && !(desc.flags & MP_IMGFLAG_HWACCEL))
  ------------------
  |  |   70|      0|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  ------------------
  |  |  |  |   65|      0|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  ------------------
  ------------------
  |  Branch (875:9): [True: 0, False: 140k]
  |  Branch (875:25): [True: 0, False: 0]
  ------------------
  876|      0|        return false;
  877|       |
  878|   140k|    return true;
  879|   140k|}
mp_image_params_equal:
  883|   437k|{
  884|   437k|    return p1->imgfmt == p2->imgfmt &&
  ------------------
  |  Branch (884:12): [True: 175k, False: 262k]
  ------------------
  885|   175k|           p1->hw_subfmt == p2->hw_subfmt &&
  ------------------
  |  Branch (885:12): [True: 175k, False: 0]
  ------------------
  886|   175k|           p1->w == p2->w && p1->h == p2->h &&
  ------------------
  |  Branch (886:12): [True: 175k, False: 0]
  |  Branch (886:30): [True: 175k, False: 0]
  ------------------
  887|   175k|           p1->p_w == p2->p_w && p1->p_h == p2->p_h &&
  ------------------
  |  Branch (887:12): [True: 175k, False: 0]
  |  Branch (887:34): [True: 175k, False: 0]
  ------------------
  888|   175k|           p1->force_window == p2->force_window &&
  ------------------
  |  Branch (888:12): [True: 175k, False: 0]
  ------------------
  889|   175k|           pl_color_space_equal(&p1->color, &p2->color) &&
  ------------------
  |  Branch (889:12): [True: 175k, False: 0]
  ------------------
  890|   175k|           pl_color_repr_equal(&p1->repr, &p2->repr) &&
  ------------------
  |  Branch (890:12): [True: 175k, False: 0]
  ------------------
  891|   175k|           p1->light == p2->light &&
  ------------------
  |  Branch (891:12): [True: 175k, False: 0]
  ------------------
  892|   175k|           p1->chroma_location == p2->chroma_location &&
  ------------------
  |  Branch (892:12): [True: 175k, False: 0]
  ------------------
  893|   175k|           p1->vflip == p2->vflip &&
  ------------------
  |  Branch (893:12): [True: 175k, False: 0]
  ------------------
  894|   175k|           p1->rotate == p2->rotate &&
  ------------------
  |  Branch (894:12): [True: 175k, False: 0]
  ------------------
  895|   175k|           p1->stereo3d == p2->stereo3d &&
  ------------------
  |  Branch (895:12): [True: 175k, False: 0]
  ------------------
  896|   175k|           mp_rect_equals(&p1->crop, &p2->crop);
  ------------------
  |  Branch (896:12): [True: 175k, False: 0]
  ------------------
  897|   437k|}
mp_image_params_static_equal:
  901|   135k|{
  902|       |    // Compare only static video parameters, excluding dynamic metadata.
  903|   135k|    struct mp_image_params a = *p1;
  904|   135k|    struct mp_image_params b = *p2;
  905|       |    a.repr.dovi = b.repr.dovi = NULL;
  906|   135k|    a.color.hdr = b.color.hdr = (struct pl_hdr_metadata){0};
  907|   135k|    return mp_image_params_equal(&a, &b);
  908|   135k|}
mp_image_params_update_dynamic:
  913|  22.1k|{
  914|  22.1k|    dst->repr.dovi = src->repr.dovi;
  915|       |    // Don't overwrite peak-detected HDR metadata if available.
  916|  22.1k|    struct pl_hdr_metadata *hdr = &dst->color.hdr;
  917|  22.1k|    const struct pl_hdr_metadata prev = *hdr;
  918|  22.1k|    *hdr = src->color.hdr;
  919|  22.1k|    if (has_peak_detect_values) {
  ------------------
  |  Branch (919:9): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|}
mp_image_params_guess_csp:
  990|   196k|{
  991|   196k|    enum pl_color_system forced_csp = mp_image_params_get_forced_csp(params);
  992|   196k|    if (forced_csp == PL_COLOR_SYSTEM_UNKNOWN) { // YUV/other
  ------------------
  |  Branch (992:9): [True: 93.4k, False: 102k]
  ------------------
  993|  93.4k|        if (params->repr.sys != PL_COLOR_SYSTEM_BT_601 &&
  ------------------
  |  Branch (993:13): [True: 18.0k, False: 75.3k]
  ------------------
  994|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_BT_709 &&
  ------------------
  |  Branch (994:13): [True: 18.0k, False: 0]
  ------------------
  995|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_NC &&
  ------------------
  |  Branch (995:13): [True: 18.0k, False: 0]
  ------------------
  996|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2020_C &&
  ------------------
  |  Branch (996:13): [True: 18.0k, False: 0]
  ------------------
  997|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_PQ &&
  ------------------
  |  Branch (997:13): [True: 18.0k, False: 0]
  ------------------
  998|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_BT_2100_HLG &&
  ------------------
  |  Branch (998:13): [True: 18.0k, False: 0]
  ------------------
  999|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_DOLBYVISION &&
  ------------------
  |  Branch (999:13): [True: 18.0k, False: 0]
  ------------------
 1000|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_SMPTE_240M &&
  ------------------
  |  Branch (1000:13): [True: 18.0k, False: 0]
  ------------------
 1001|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO &&
  ------------------
  |  Branch (1001:13): [True: 18.0k, False: 0]
  ------------------
 1002|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RE &&
  ------------------
  |  Branch (1002:13): [True: 18.0k, False: 0]
  ------------------
 1003|  18.0k|            params->repr.sys != PL_COLOR_SYSTEM_YCGCO_RO
  ------------------
  |  Branch (1003:13): [True: 18.0k, False: 0]
  ------------------
 1004|  93.4k|        ) {
 1005|       |            // Makes no sense, so guess instead
 1006|       |            // YCGCO should be separate, but libavcodec disagrees
 1007|  18.0k|            params->repr.sys = PL_COLOR_SYSTEM_UNKNOWN;
 1008|  18.0k|        }
 1009|  93.4k|        if (params->repr.sys == PL_COLOR_SYSTEM_UNKNOWN)
  ------------------
  |  Branch (1009:13): [True: 18.0k, False: 75.3k]
  ------------------
 1010|  18.0k|            params->repr.sys = mp_csp_guess_colorspace(params->w, params->h);
 1011|  93.4k|        if (params->repr.levels == PL_COLOR_LEVELS_UNKNOWN) {
  ------------------
  |  Branch (1011:13): [True: 18.0k, False: 75.3k]
  ------------------
 1012|  18.0k|            if (params->color.transfer == PL_COLOR_TRC_V_LOG) {
  ------------------
  |  Branch (1012:17): [True: 0, False: 18.0k]
  ------------------
 1013|      0|                params->repr.levels = PL_COLOR_LEVELS_FULL;
 1014|  18.0k|            } else {
 1015|  18.0k|                params->repr.levels = infer_levels(params->imgfmt);
 1016|  18.0k|            }
 1017|  18.0k|        }
 1018|  93.4k|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN) {
  ------------------
  |  Branch (1018:13): [True: 18.0k, False: 75.3k]
  ------------------
 1019|       |            // Guess based on the colormatrix as a first priority
 1020|  18.0k|            if (params->repr.sys == PL_COLOR_SYSTEM_BT_2020_NC ||
  ------------------
  |  Branch (1020:17): [True: 0, False: 18.0k]
  ------------------
 1021|  18.0k|                params->repr.sys == PL_COLOR_SYSTEM_BT_2020_C) {
  ------------------
  |  Branch (1021:17): [True: 0, False: 18.0k]
  ------------------
 1022|      0|                params->color.primaries = PL_COLOR_PRIM_BT_2020;
 1023|  18.0k|            } else if (params->repr.sys == PL_COLOR_SYSTEM_BT_709) {
  ------------------
  |  Branch (1023:24): [True: 0, False: 18.0k]
  ------------------
 1024|      0|                params->color.primaries = PL_COLOR_PRIM_BT_709;
 1025|  18.0k|            } else {
 1026|       |                // Ambiguous colormatrix for BT.601, guess based on res
 1027|  18.0k|                params->color.primaries = mp_csp_guess_primaries(params->w, params->h);
 1028|  18.0k|            }
 1029|  18.0k|        }
 1030|  93.4k|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1030:13): [True: 19.4k, False: 73.9k]
  ------------------
 1031|  19.4k|            params->color.transfer = params->repr.levels == PL_COLOR_LEVELS_LIMITED ?
  ------------------
  |  Branch (1031:38): [True: 19.4k, False: 0]
  ------------------
 1032|  19.4k|                                        PL_COLOR_TRC_BT_1886 : PL_COLOR_TRC_SRGB;
 1033|   102k|    } else if (forced_csp == PL_COLOR_SYSTEM_RGB) {
  ------------------
  |  Branch (1033:16): [True: 102k, False: 0]
  ------------------
 1034|   102k|        params->repr.sys = PL_COLOR_SYSTEM_RGB;
 1035|   102k|        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|   102k|        if (params->color.primaries == PL_COLOR_PRIM_UNKNOWN)
  ------------------
  |  Branch (1042:13): [True: 770, False: 102k]
  ------------------
 1043|    770|            params->color.primaries = PL_COLOR_PRIM_BT_709;
 1044|   102k|        if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
  ------------------
  |  Branch (1044:13): [True: 32.8k, False: 69.9k]
  ------------------
 1045|  32.8k|            params->color.transfer = PL_COLOR_TRC_SRGB;
 1046|   102k|    } 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|   196k|    pl_color_space_infer(&params->color);
 1071|       |
 1072|   196k|    if (!pl_color_space_is_hdr(&params->color)) {
  ------------------
  |  Branch (1072:9): [True: 196k, False: 0]
  ------------------
 1073|       |        // Some clips have leftover HDR metadata after conversion to SDR, so to
 1074|       |        // avoid blowing up the tone mapping code, strip/sanitize it
 1075|   196k|        params->color.hdr = pl_hdr_metadata_empty;
 1076|   196k|    }
 1077|       |
 1078|   196k|    if (mp_imgfmt_is_subsampled(params->hw_subfmt ? params->hw_subfmt : params->imgfmt)) {
  ------------------
  |  Branch (1078:9): [True: 4.22k, False: 192k]
  |  Branch (1078:33): [True: 0, False: 196k]
  ------------------
 1079|  4.22k|        if (params->chroma_location == PL_CHROMA_UNKNOWN) {
  ------------------
  |  Branch (1079:13): [True: 0, False: 4.22k]
  ------------------
 1080|      0|            if (params->repr.levels == PL_COLOR_LEVELS_LIMITED)
  ------------------
  |  Branch (1080:17): [True: 0, False: 0]
  ------------------
 1081|      0|                params->chroma_location = PL_CHROMA_LEFT;
 1082|      0|            if (params->repr.levels == PL_COLOR_LEVELS_FULL)
  ------------------
  |  Branch (1082:17): [True: 0, False: 0]
  ------------------
 1083|      0|                params->chroma_location = PL_CHROMA_CENTER;
 1084|      0|        }
 1085|   192k|    } else {
 1086|       |        // Set to center for non-subsampled formats.
 1087|   192k|        params->chroma_location = PL_CHROMA_CENTER;
 1088|   192k|    }
 1089|       |
 1090|   196k|    if (params->light == MP_CSP_LIGHT_AUTO) {
  ------------------
  |  Branch (1090:9): [True: 56.3k, False: 139k]
  ------------------
 1091|       |        // HLG is always scene-referred (using its own OOTF), everything else
 1092|       |        // we assume is display-referred by default.
 1093|  56.3k|        if (params->color.transfer == PL_COLOR_TRC_HLG) {
  ------------------
  |  Branch (1093:13): [True: 0, False: 56.3k]
  ------------------
 1094|      0|            params->light = MP_CSP_LIGHT_SCENE_HLG;
 1095|  56.3k|        } else {
 1096|  56.3k|            params->light = MP_CSP_LIGHT_DISPLAY;
 1097|  56.3k|        }
 1098|  56.3k|    }
 1099|   196k|}
mp_image_from_av_frame:
 1103|  38.5k|{
 1104|  38.5k|    struct mp_image *dst = &(struct mp_image){0};
 1105|  38.5k|    AVFrameSideData *sd;
 1106|       |
 1107|   192k|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|   192k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (1107:21): [True: 154k, False: 38.5k]
  ------------------
 1108|   154k|        dst->bufs[p] = src->buf[p];
 1109|       |
 1110|  38.5k|    dst->hwctx = src->hw_frames_ctx;
 1111|       |
 1112|  38.5k|    if (dst->hwctx) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 38.5k]
  ------------------
 1113|      0|        AVHWFramesContext *fctx = (void *)dst->hwctx->data;
 1114|      0|        dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format);
 1115|      0|    }
 1116|       |
 1117|  38.5k|    mp_image_sethwfmt(dst, pixfmt2imgfmt(src->format), dst->params.hw_subfmt);
 1118|  38.5k|    mp_image_set_size(dst, src->width, src->height);
 1119|       |
 1120|  38.5k|    dst->params.p_w = src->sample_aspect_ratio.num;
 1121|  38.5k|    dst->params.p_h = src->sample_aspect_ratio.den;
 1122|       |
 1123|   192k|    for (int i = 0; i < 4; i++) {
  ------------------
  |  Branch (1123:21): [True: 154k, False: 38.5k]
  ------------------
 1124|   154k|        dst->planes[i] = src->data[i];
 1125|   154k|        dst->stride[i] = src->linesize[i];
 1126|   154k|    }
 1127|       |
 1128|  38.5k|    dst->pict_type = src->pict_type;
 1129|       |
 1130|  38.5k|    dst->params.crop.x0 = src->crop_left;
 1131|  38.5k|    dst->params.crop.y0 = src->crop_top;
 1132|  38.5k|    dst->params.crop.x1 = src->width - src->crop_right;
 1133|  38.5k|    dst->params.crop.y1 = src->height - src->crop_bottom;
 1134|       |
 1135|  38.5k|    dst->fields = 0;
 1136|  38.5k|    if (src->flags & AV_FRAME_FLAG_INTERLACED)
  ------------------
  |  Branch (1136:9): [True: 0, False: 38.5k]
  ------------------
 1137|      0|        dst->fields |= MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|      0|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
 1138|  38.5k|    if (src->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
  ------------------
  |  Branch (1138:9): [True: 0, False: 38.5k]
  ------------------
 1139|      0|        dst->fields |= MP_IMGFIELD_TOP_FIRST;
  ------------------
  |  |   37|      0|#define MP_IMGFIELD_TOP_FIRST 0x02
  ------------------
 1140|  38.5k|    if (src->repeat_pict == 1)
  ------------------
  |  Branch (1140:9): [True: 0, False: 38.5k]
  ------------------
 1141|      0|        dst->fields |= MP_IMGFIELD_REPEAT_FIRST;
  ------------------
  |  |   38|      0|#define MP_IMGFIELD_REPEAT_FIRST 0x04
  ------------------
 1142|       |
 1143|  38.5k|    dst->params.repr.sys = pl_system_from_av(src->colorspace);
 1144|  38.5k|    dst->params.repr.levels = pl_levels_from_av(src->color_range);
 1145|       |
 1146|  38.5k|    dst->params.color = (struct pl_color_space){
 1147|  38.5k|        .primaries = pl_primaries_from_av(src->color_primaries),
 1148|  38.5k|        .transfer = pl_transfer_from_av(src->color_trc),
 1149|  38.5k|    };
 1150|       |
 1151|  38.5k|    dst->params.chroma_location = pl_chroma_from_av(src->chroma_location);
 1152|       |
 1153|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_STEREO3D);
 1154|  38.5k|    if (sd)
  ------------------
  |  Branch (1154:9): [True: 0, False: 38.5k]
  ------------------
 1155|      0|        dst->params.stereo3d = mp_stereo3d_from_av((const AVStereo3D *)sd->data);
 1156|       |
 1157|  38.5k|    if (src->opaque_ref) {
  ------------------
  |  Branch (1157:9): [True: 0, False: 38.5k]
  ------------------
 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|  38.5k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(60, 11, 100)
 1170|       |    // mp_image_setfmt sets to PL_ALPHA_INDEPENDENT, if format has alpha.
 1171|  38.5k|    if (dst->params.repr.alpha == PL_ALPHA_INDEPENDENT)
  ------------------
  |  Branch (1171:9): [True: 0, False: 38.5k]
  ------------------
 1172|      0|        dst->params.repr.alpha = pl_alpha_from_av(src->alpha_mode);
 1173|  38.5k|#endif
 1174|       |
 1175|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DISPLAYMATRIX);
 1176|  38.5k|    if (sd) {
  ------------------
  |  Branch (1176:9): [True: 0, False: 38.5k]
  ------------------
 1177|      0|        int32_t *matrix = (int32_t *) sd->data;
 1178|       |        // determinant
 1179|      0|        int vflip = ((int64_t)matrix[0] * (int64_t)matrix[4]
 1180|      0|                    - (int64_t)matrix[1] * (int64_t)matrix[3]) < 0;
 1181|      0|        double r = av_display_rotation_get(matrix);
 1182|      0|        if (!isnan(r)) {
  ------------------
  |  Branch (1182:13): [True: 0, False: 0]
  ------------------
 1183|      0|            dst->params.rotate = (((int)(-r) % 360) + 360) % 360;
 1184|      0|            dst->params.vflip = vflip;
 1185|      0|        }
 1186|      0|    }
 1187|       |
 1188|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE);
 1189|  38.5k|    if (sd)
  ------------------
  |  Branch (1189:9): [True: 0, False: 38.5k]
  ------------------
 1190|      0|        dst->icc_profile = sd->buf;
 1191|       |
 1192|  38.5k|    AVFrameSideData *mdm = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
 1193|  38.5k|    AVFrameSideData *clm = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
 1194|  38.5k|    AVFrameSideData *dhp = av_frame_get_side_data(src, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
 1195|  38.5k|    pl_map_hdr_metadata(&dst->params.color.hdr, &(struct pl_av_hdr_metadata) {
 1196|  38.5k|        .mdm = (void *)(mdm ? mdm->data : NULL),
  ------------------
  |  Branch (1196:25): [True: 0, False: 38.5k]
  ------------------
 1197|  38.5k|        .clm = (void *)(clm ? clm->data : NULL),
  ------------------
  |  Branch (1197:25): [True: 0, False: 38.5k]
  ------------------
 1198|  38.5k|        .dhp = (void *)(dhp ? dhp->data : NULL),
  ------------------
  |  Branch (1198:25): [True: 0, False: 38.5k]
  ------------------
 1199|  38.5k|    });
 1200|       |
 1201|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_A53_CC);
 1202|  38.5k|    if (sd)
  ------------------
  |  Branch (1202:9): [True: 0, False: 38.5k]
  ------------------
 1203|      0|        dst->a53_cc = sd->buf;
 1204|       |
 1205|  38.5k|    dst->params.primaries_orig = dst->params.color.primaries;
 1206|  38.5k|    dst->params.transfer_orig = dst->params.color.transfer;
 1207|  38.5k|    dst->params.sys_orig = dst->params.repr.sys;
 1208|  38.5k|    AVBufferRef *dovi = NULL;
 1209|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_METADATA);
 1210|  38.5k|    if (sd) {
  ------------------
  |  Branch (1210:9): [True: 0, False: 38.5k]
  ------------------
 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|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_RPU_BUFFER);
 1221|  38.5k|    if (sd) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 38.5k]
  ------------------
 1222|      0|        pl_hdr_metadata_from_dovi_rpu(&dst->params.color.hdr, sd->buf->data,
 1223|      0|                                      sd->buf->size);
 1224|      0|    }
 1225|       |
 1226|  38.5k|    sd = av_frame_get_side_data(src, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
 1227|  38.5k|    if (sd)
  ------------------
  |  Branch (1227:9): [True: 0, False: 38.5k]
  ------------------
 1228|      0|        dst->film_grain = sd->buf;
 1229|       |
 1230|  38.5k|    for (int n = 0; n < src->nb_side_data; n++) {
  ------------------
  |  Branch (1230:21): [True: 0, False: 38.5k]
  ------------------
 1231|      0|        sd = src->side_data[n];
 1232|      0|        struct mp_ff_side_data mpsd = {
 1233|      0|            .type = sd->type,
 1234|      0|            .buf = sd->buf,
 1235|      0|        };
 1236|      0|        MP_TARRAY_APPEND(NULL, dst->ff_side_data, dst->num_ff_side_data, mpsd);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1237|      0|    }
 1238|       |
 1239|  38.5k|    struct mp_image *res = mp_image_new_ref(dst);
 1240|       |
 1241|       |    // Allocated, but non-refcounted data.
 1242|  38.5k|    talloc_free(dst->ff_side_data);
  ------------------
  |  |   47|  38.5k|#define talloc_free                     ta_free
  ------------------
 1243|  38.5k|    av_buffer_unref(&dovi);
 1244|       |
 1245|  38.5k|    return res;
 1246|  38.5k|}
mp_image.c:mp_image_layout:
   53|   140k|{
   54|   140k|    struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(imgfmt);
   55|       |
   56|   140k|    struct mp_image_params params = {.imgfmt = imgfmt, .w = w, .h = h};
   57|       |
   58|   140k|    if (!mp_image_params_valid(&params) || desc.flags & MP_IMGFLAG_HWACCEL)
  ------------------
  |  |   70|   140k|#define MP_IMGFLAG_HWACCEL      MP_IMGFLAG_TYPE_HW
  |  |  ------------------
  |  |  |  |   65|   140k|#define MP_IMGFLAG_TYPE_HW      (8 << 10)
  |  |  ------------------
  ------------------
  |  Branch (58:9): [True: 11, False: 140k]
  |  Branch (58:44): [True: 0, False: 140k]
  ------------------
   59|     11|        return -1;
   60|       |
   61|   140k|    w = MP_ALIGN_UP(w, desc.align_x);
  ------------------
  |  |   53|   140k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
   62|   140k|    h = MP_ALIGN_UP(h, desc.align_y);
  ------------------
  |  |   53|   140k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
   63|       |
   64|       |    // Note: for non-mod-2 4:2:0 YUV frames, we have to allocate an additional
   65|       |    //       top/right border. This is needed for correct handling of such
   66|       |    //       images in filter and VO code (e.g. vo_vdpau or vo_gpu).
   67|       |
   68|   702k|    for (int n = 0; n < MP_MAX_PLANES; n++) {
  ------------------
  |  |   28|   702k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (68:21): [True: 561k, False: 140k]
  ------------------
   69|   561k|        int alloc_w = mp_chroma_div_up(w, desc.xs[n]);
   70|   561k|        int alloc_h = MP_ALIGN_UP(h, 32) >> desc.ys[n];
  ------------------
  |  |   53|   561k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
   71|   561k|        int line_bytes = (alloc_w * desc.bpp[n] + 7) / 8;
   72|   561k|        int align = mp_lcm(stride_align, (desc.bpp[n] && desc.bpp[n] % 8 == 0) ? desc.bpp[n] / 8 : 1);
  ------------------
  |  Branch (72:43): [True: 286k, False: 275k]
  |  Branch (72:58): [True: 286k, False: 0]
  ------------------
   73|   561k|        out_stride[n] = MP_ALIGN_NPOT(line_bytes, align);
  ------------------
  |  |   59|   561k|#define MP_ALIGN_NPOT(x, align) ((align) ? MP_DIV_UP(x, align) * (align) : (x))
  |  |  ------------------
  |  |  |  |   50|   561k|#define MP_DIV_UP(x, y) (((x) + (y) - 1) / (y))
  |  |  ------------------
  |  |  |  Branch (59:34): [True: 561k, False: 0]
  |  |  ------------------
  ------------------
   74|   561k|        int64_t plane_size = (int64_t)out_stride[n] * alloc_h;
   75|   561k|        if (plane_size < 0 || plane_size > INT_MAX)
  ------------------
  |  Branch (75:13): [True: 0, False: 561k]
  |  Branch (75:31): [True: 0, False: 561k]
  ------------------
   76|      0|            return -1;
   77|   561k|        out_plane_size[n] = plane_size;
   78|   561k|    }
   79|   140k|    if (desc.flags & MP_IMGFLAG_PAL)
  ------------------
  |  |   69|   140k|#define MP_IMGFLAG_PAL          MP_IMGFLAG_TYPE_PAL8
  |  |  ------------------
  |  |  |  |   64|   140k|#define MP_IMGFLAG_TYPE_PAL8    (4 << 10)
  |  |  ------------------
  ------------------
  |  Branch (79:9): [True: 0, False: 140k]
  ------------------
   80|      0|        out_plane_size[1] = AVPALETTE_SIZE;
   81|       |
   82|       |    // Leave room for the stride_align bytes the callers add to the size.
   83|   140k|    int sum = 0;
   84|   702k|    for (int n = 0; n < MP_MAX_PLANES; n++) {
  ------------------
  |  |   28|   702k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (84:21): [True: 561k, False: 140k]
  ------------------
   85|   561k|        if (out_plane_size[n] > INT_MAX - stride_align - sum)
  ------------------
  |  Branch (85:13): [True: 0, False: 561k]
  ------------------
   86|      0|            return -1;
   87|   561k|        out_plane_offset[n] = out_plane_size[n] ? sum : -1;
  ------------------
  |  Branch (87:31): [True: 286k, False: 275k]
  ------------------
   88|   561k|        sum += out_plane_size[n];
   89|   561k|    }
   90|       |
   91|   140k|    return sum;
   92|   140k|}
mp_image.c:mp_image_fill_alloc:
  115|  70.2k|{
  116|  70.2k|    int stride[MP_MAX_PLANES];
  117|  70.2k|    int plane_offset[MP_MAX_PLANES];
  118|  70.2k|    int plane_size[MP_MAX_PLANES];
  119|  70.2k|    int size = mp_image_layout(mpi->imgfmt, mpi->w, mpi->h, stride_align,
  120|  70.2k|                               stride, plane_offset, plane_size);
  121|  70.2k|    if (size < 0 || size > buffer_size)
  ------------------
  |  Branch (121:9): [True: 0, False: 70.2k]
  |  Branch (121:21): [True: 0, False: 70.2k]
  ------------------
  122|      0|        return false;
  123|       |
  124|  70.2k|    int align = MP_ALIGN_UP((uintptr_t)buffer, stride_align) - (uintptr_t)buffer;
  ------------------
  |  |   53|  70.2k|#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
  ------------------
  125|  70.2k|    if (buffer_size - size < align)
  ------------------
  |  Branch (125:9): [True: 0, False: 70.2k]
  ------------------
  126|      0|        return false;
  127|  70.2k|    uint8_t *s = buffer;
  128|  70.2k|    s += align;
  129|       |
  130|   351k|    for (int n = 0; n < MP_MAX_PLANES; n++) {
  ------------------
  |  |   28|   351k|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (130:21): [True: 280k, False: 70.2k]
  ------------------
  131|   280k|        mpi->planes[n] = plane_offset[n] >= 0 ? s + plane_offset[n] : NULL;
  ------------------
  |  Branch (131:26): [True: 143k, False: 137k]
  ------------------
  132|   280k|        mpi->stride[n] = stride[n];
  133|   280k|    }
  134|       |
  135|       |    return true;
  136|  70.2k|}
mp_image.c:mp_image_destructor:
  235|   267k|{
  236|   267k|    mp_image_t *mpi = ptr;
  237|  1.33M|    for (int p = 0; p < MP_MAX_PLANES; p++)
  ------------------
  |  |   28|  1.33M|#define MP_MAX_PLANES 4
  ------------------
  |  Branch (237:21): [True: 1.07M, False: 267k]
  ------------------
  238|  1.07M|        av_buffer_unref(&mpi->bufs[p]);
  239|   267k|    av_buffer_unref(&mpi->hwctx);
  240|   267k|    av_buffer_unref(&mpi->icc_profile);
  241|   267k|    av_buffer_unref(&mpi->a53_cc);
  242|   267k|    av_buffer_unref(&mpi->dovi);
  243|   267k|    av_buffer_unref(&mpi->film_grain);
  244|   267k|    for (int n = 0; n < mpi->num_ff_side_data; n++)
  ------------------
  |  Branch (244:21): [True: 0, False: 267k]
  ------------------
  245|      0|        av_buffer_unref(&mpi->ff_side_data[n].buf);
  246|   267k|    talloc_free(mpi->ff_side_data);
  ------------------
  |  |   47|   267k|#define talloc_free                     ta_free
  ------------------
  247|   267k|    mp_image_unrefp(&mpi->enhancement_layer);
  248|   267k|}
mp_image.c:mp_image_alloc_planes:
  175|  70.2k|{
  176|  70.2k|    mp_assert(!mpi->planes[0]);
  ------------------
  |  |   41|  70.2k|#define mp_assert assert
  ------------------
  |  Branch (176:5): [True: 70.2k, False: 0]
  ------------------
  177|  70.2k|    mp_assert(!mpi->bufs[0]);
  ------------------
  |  |   41|  70.2k|#define mp_assert assert
  ------------------
  |  Branch (177:5): [True: 70.2k, False: 0]
  ------------------
  178|       |
  179|  70.2k|    int align = MP_IMAGE_BYTE_ALIGN;
  ------------------
  |  |   35|  70.2k|#define MP_IMAGE_BYTE_ALIGN 64
  ------------------
  180|       |
  181|  70.2k|    int size = mp_image_get_alloc_size(mpi->imgfmt, mpi->w, mpi->h, align);
  182|  70.2k|    if (size < 0)
  ------------------
  |  Branch (182:9): [True: 11, False: 70.2k]
  ------------------
  183|     11|        return false;
  184|       |
  185|       |    // Note: mp_image_pool assumes this creates only 1 AVBufferRef.
  186|  70.2k|    mpi->bufs[0] = av_buffer_alloc(size + align);
  187|  70.2k|    if (!mpi->bufs[0])
  ------------------
  |  Branch (187:9): [True: 0, False: 70.2k]
  ------------------
  188|      0|        return false;
  189|       |
  190|  70.2k|    if (!mp_image_fill_alloc(mpi, align, mpi->bufs[0]->data, mpi->bufs[0]->size)) {
  ------------------
  |  Branch (190:9): [True: 0, False: 70.2k]
  ------------------
  191|      0|        av_buffer_unref(&mpi->bufs[0]);
  192|      0|        return false;
  193|      0|    }
  194|       |
  195|  70.2k|    return true;
  196|  70.2k|}
mp_image.c:ref_buffer:
  350|  1.77M|{
  351|  1.77M|    if (*dst) {
  ------------------
  |  Branch (351:9): [True: 592k, False: 1.18M]
  ------------------
  352|   592k|        *dst = av_buffer_ref(*dst);
  353|   592k|        MP_HANDLE_OOM(*dst);
  ------------------
  |  |  206|   592k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   592k|        void *oom_p_ = (x);     \
  |  |  208|   592k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 592k]
  |  |  ------------------
  |  |  209|   592k|            abort();            \
  |  |  210|   592k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 592k]
  |  |  ------------------
  ------------------
  354|   592k|    }
  355|  1.77M|}
mp_image.c:mp_image_params_get_forced_csp:
  529|   336k|{
  530|   336k|    int imgfmt = params->hw_subfmt ? params->hw_subfmt : params->imgfmt;
  ------------------
  |  Branch (530:18): [True: 0, False: 336k]
  ------------------
  531|   336k|    enum pl_color_system csp = mp_imgfmt_get_forced_csp(imgfmt);
  532|       |
  533|   336k|    if (csp == PL_COLOR_SYSTEM_RGB && params->repr.sys == PL_COLOR_SYSTEM_XYZ)
  ------------------
  |  Branch (533:9): [True: 136k, False: 200k]
  |  Branch (533:39): [True: 0, False: 136k]
  ------------------
  534|      0|        csp = PL_COLOR_SYSTEM_XYZ;
  535|       |
  536|   336k|    return csp;
  537|   336k|}
mp_image.c:assign_bufref:
  540|   280k|{
  541|   280k|    av_buffer_unref(dst);
  542|   280k|    if (new) {
  ------------------
  |  Branch (542:9): [True: 0, False: 280k]
  ------------------
  543|      0|        *dst = av_buffer_ref(new);
  544|      0|        MP_HANDLE_OOM(*dst);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  545|      0|    }
  546|   280k|}
mp_image.c:infer_levels:
  959|  18.0k|{
  960|  18.0k|    switch (imgfmt2pixfmt(imgfmt)) {
  961|      0|    case AV_PIX_FMT_YUVJ420P:
  ------------------
  |  Branch (961:5): [True: 0, False: 18.0k]
  ------------------
  962|      0|    case AV_PIX_FMT_YUVJ411P:
  ------------------
  |  Branch (962:5): [True: 0, False: 18.0k]
  ------------------
  963|      0|    case AV_PIX_FMT_YUVJ422P:
  ------------------
  |  Branch (963:5): [True: 0, False: 18.0k]
  ------------------
  964|      0|    case AV_PIX_FMT_YUVJ444P:
  ------------------
  |  Branch (964:5): [True: 0, False: 18.0k]
  ------------------
  965|      0|    case AV_PIX_FMT_YUVJ440P:
  ------------------
  |  Branch (965:5): [True: 0, False: 18.0k]
  ------------------
  966|      0|    case AV_PIX_FMT_GRAY8:
  ------------------
  |  Branch (966:5): [True: 0, False: 18.0k]
  ------------------
  967|      0|    case AV_PIX_FMT_YA8:
  ------------------
  |  Branch (967:5): [True: 0, False: 18.0k]
  ------------------
  968|      0|    case AV_PIX_FMT_GRAY9LE:
  ------------------
  |  Branch (968:5): [True: 0, False: 18.0k]
  ------------------
  969|      0|    case AV_PIX_FMT_GRAY9BE:
  ------------------
  |  Branch (969:5): [True: 0, False: 18.0k]
  ------------------
  970|      0|    case AV_PIX_FMT_GRAY10LE:
  ------------------
  |  Branch (970:5): [True: 0, False: 18.0k]
  ------------------
  971|      0|    case AV_PIX_FMT_GRAY10BE:
  ------------------
  |  Branch (971:5): [True: 0, False: 18.0k]
  ------------------
  972|      0|    case AV_PIX_FMT_GRAY12LE:
  ------------------
  |  Branch (972:5): [True: 0, False: 18.0k]
  ------------------
  973|      0|    case AV_PIX_FMT_GRAY12BE:
  ------------------
  |  Branch (973:5): [True: 0, False: 18.0k]
  ------------------
  974|      0|    case AV_PIX_FMT_GRAY14LE:
  ------------------
  |  Branch (974:5): [True: 0, False: 18.0k]
  ------------------
  975|      0|    case AV_PIX_FMT_GRAY14BE:
  ------------------
  |  Branch (975:5): [True: 0, False: 18.0k]
  ------------------
  976|      0|    case AV_PIX_FMT_GRAY16LE:
  ------------------
  |  Branch (976:5): [True: 0, False: 18.0k]
  ------------------
  977|      0|    case AV_PIX_FMT_GRAY16BE:
  ------------------
  |  Branch (977:5): [True: 0, False: 18.0k]
  ------------------
  978|      0|    case AV_PIX_FMT_YA16BE:
  ------------------
  |  Branch (978:5): [True: 0, False: 18.0k]
  ------------------
  979|      0|    case AV_PIX_FMT_YA16LE:
  ------------------
  |  Branch (979:5): [True: 0, False: 18.0k]
  ------------------
  980|      0|        return PL_COLOR_LEVELS_FULL;
  981|  18.0k|    default:
  ------------------
  |  Branch (981:5): [True: 18.0k, False: 0]
  ------------------
  982|  18.0k|        return PL_COLOR_LEVELS_LIMITED;
  983|  18.0k|    }
  984|  18.0k|}

mp_image_pool_new:
   82|  59.6k|{
   83|  59.6k|    struct mp_image_pool *pool = talloc_ptrtype(tparent, pool);
  ------------------
  |  |   34|  59.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  59.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  59.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  59.6k|    talloc_set_destructor(pool, image_pool_destructor);
  ------------------
  |  |   41|  59.6k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   85|  59.6k|    *pool = (struct mp_image_pool) {0};
   86|  59.6k|    return pool;
   87|  59.6k|}
mp_image_pool_clear:
   90|  59.6k|{
   91|  59.6k|    for (int n = 0; n < pool->num_images; n++) {
  ------------------
  |  Branch (91:21): [True: 0, False: 59.6k]
  ------------------
   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|  59.6k|    pool->num_images = 0;
  104|  59.6k|}
mp_image_pool.c:image_pool_destructor:
   75|  59.6k|{
   76|  59.6k|    struct mp_image_pool *pool = ptr;
   77|  59.6k|    mp_image_pool_clear(pool);
   78|  59.6k|}

packer_set_size:
  183|  4.16k|{
  184|  4.16k|    packer->count = size;
  185|  4.16k|    if (size <= packer->asize)
  ------------------
  |  Branch (185:9): [True: 4.16k, False: 0]
  ------------------
  186|  4.16k|        return;
  187|      0|    packer->asize = MPMAX(packer->asize * 2, size);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  188|      0|    talloc_free(packer->result);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  189|      0|    talloc_free(packer->scratch);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  190|      0|    packer->in = talloc_realloc(packer, packer->in, struct pos, packer->asize);
  ------------------
  |  |   33|      0|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|      0|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  191|      0|    packer->result = talloc_array_ptrtype(packer, packer->result,
  ------------------
  |  |   36|      0|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|      0|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|      0|                                          packer->asize);
  193|      0|    packer->scratch = talloc_array_ptrtype(packer, packer->scratch,
  ------------------
  |  |   36|      0|#define talloc_array_ptrtype            ta_xnew_array_ptrtype
  |  |  ------------------
  |  |  |  |  140|      0|#define ta_xnew_array_ptrtype(...)      ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|      0|                                           packer->asize + 16);
  195|      0|}

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

ra_hwdec_validate_drivers_only_opt:
  235|     16|{
  236|       |    return ra_hwdec_validate_opt_full(log, false, opt, name, value);
  237|     16|}
hwdec.c:ra_hwdec_validate_opt_full:
  195|     16|{
  196|     16|    struct bstr param = bstr0(*value);
  197|     16|    bool help = bstr_equals0(param, "help");
  198|     16|    if (help)
  ------------------
  |  Branch (198:9): [True: 0, False: 16]
  ------------------
  199|      0|        mp_info(log, "Available hwdecs:\n");
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  200|     16|    for (int n = 0; ra_hwdec_drivers[n]; n++) {
  ------------------
  |  Branch (200:21): [True: 0, False: 16]
  ------------------
  201|      0|        const struct ra_hwdec_driver *drv = ra_hwdec_drivers[n];
  202|      0|        if (help) {
  ------------------
  |  Branch (202:13): [True: 0, False: 0]
  ------------------
  203|      0|            mp_info(log, "    %s\n", drv->name);
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  204|      0|        } else if (bstr_equals0(param, drv->name)) {
  ------------------
  |  Branch (204:20): [True: 0, False: 0]
  ------------------
  205|      0|            return 1;
  206|      0|        }
  207|      0|    }
  208|     16|    if (help) {
  ------------------
  |  Branch (208:9): [True: 0, False: 16]
  ------------------
  209|      0|        if (include_modes) {
  ------------------
  |  Branch (209:13): [True: 0, False: 0]
  ------------------
  210|      0|            mp_info(log, "    auto (behavior depends on context)\n"
  ------------------
  |  |   78|      0|#define mp_info(log, ...)       mp_msg(log, MSGL_INFO, __VA_ARGS__)
  ------------------
  211|      0|                        "    all (load all hwdecs)\n"
  212|      0|                        "    no (do not load any and block loading on demand)\n");
  213|      0|        }
  214|      0|        return M_OPT_EXIT;
  ------------------
  |  |  545|      0|#define M_OPT_EXIT              -6
  ------------------
  215|      0|    }
  216|     16|    if (!param.len)
  ------------------
  |  Branch (216:9): [True: 0, False: 16]
  ------------------
  217|      0|        return 1; // "" is treated specially
  218|     16|    if (include_modes &&
  ------------------
  |  Branch (218:9): [True: 0, False: 16]
  ------------------
  219|      0|       (bstr_equals0(param, "all") || bstr_equals0(param, "auto") ||
  ------------------
  |  Branch (219:9): [True: 0, False: 0]
  |  Branch (219:39): [True: 0, False: 0]
  ------------------
  220|      0|        bstr_equals0(param, "no")))
  ------------------
  |  Branch (220:9): [True: 0, False: 0]
  ------------------
  221|      0|        return 1;
  222|     16|    mp_fatal(log, "No hwdec backend named '%.*s' found!\n", BSTR_P(param));
  ------------------
  |  |   75|     32|#define mp_fatal(log, ...)      mp_msg(log, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (75:57): [True: 16, False: 0]
  |  |  ------------------
  ------------------
  223|     16|    return M_OPT_INVALID;
  ------------------
  |  |  535|     16|#define M_OPT_INVALID           -3
  ------------------
  224|     16|}

video.c:validate_target_gamut:
 4437|     39|{
 4438|     39|    struct pl_raw_primaries tmp;
 4439|     39|    return mp_parse_raw_primaries(log, *value, &tmp);
 4440|     39|}

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

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

mp_sws_alloc:
  191|  35.2k|{
  192|  35.2k|    struct mp_sws_context *ctx = talloc_ptrtype(talloc_ctx, ctx);
  ------------------
  |  |   34|  35.2k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  35.2k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|  35.2k|    *ctx = (struct mp_sws_context) {
  194|  35.2k|        .log = mp_null_log,
  195|  35.2k|        .flags = SWS_BILINEAR,
  196|  35.2k|        .force_reload = true,
  197|  35.2k|        .params = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT},
  198|  35.2k|        .cached = talloc_zero(ctx, struct mp_sws_context),
  ------------------
  |  |   27|  35.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  35.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  35.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|  35.2k|    };
  200|  35.2k|    talloc_set_destructor(ctx, free_mp_sws);
  ------------------
  |  |   41|  35.2k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  201|       |
  202|       |#if HAVE_ZIMG
  203|       |    ctx->zimg = mp_zimg_alloc();
  204|       |    talloc_steal(ctx, ctx->zimg);
  205|       |#endif
  206|       |
  207|  35.2k|    return ctx;
  208|  35.2k|}
mp_sws_enable_cmdline_opts:
  214|  35.2k|{
  215|       |    // Should only ever be NULL for tests.
  216|  35.2k|    if (!g)
  ------------------
  |  Branch (216:9): [True: 0, False: 35.2k]
  ------------------
  217|      0|        return;
  218|  35.2k|    if (ctx->opts_cache)
  ------------------
  |  Branch (218:9): [True: 0, False: 35.2k]
  ------------------
  219|      0|        return;
  220|       |
  221|  35.2k|    ctx->opts_cache = m_config_cache_alloc(ctx, g, &sws_conf);
  222|  35.2k|    ctx->force_reload = true;
  223|  35.2k|    mp_sws_update_from_cmdline(ctx);
  224|       |
  225|       |#if HAVE_ZIMG
  226|       |    mp_zimg_enable_cmdline_opts(ctx->zimg, g);
  227|       |#endif
  228|  35.2k|}
mp_sws_reinit:
  233|  35.2k|{
  234|  35.2k|    struct mp_image_params src = ctx->src;
  235|  35.2k|    struct mp_image_params dst = ctx->dst;
  236|       |
  237|  35.2k|    if (cache_valid(ctx))
  ------------------
  |  Branch (237:9): [True: 0, False: 35.2k]
  ------------------
  238|      0|        return 0;
  239|       |
  240|  35.2k|    if (ctx->opts_cache)
  ------------------
  |  Branch (240:9): [True: 35.2k, False: 0]
  ------------------
  241|  35.2k|        mp_sws_update_from_cmdline(ctx);
  242|       |
  243|  35.2k|    sws_freeContext(ctx->sws);
  244|  35.2k|    ctx->sws = NULL;
  245|  35.2k|    ctx->zimg_ok = false;
  246|  35.2k|    TA_FREEP(&ctx->aligned_src);
  ------------------
  |  |   81|  35.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  35.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 35.2k]
  |  |  ------------------
  ------------------
  247|  35.2k|    TA_FREEP(&ctx->aligned_dst);
  ------------------
  |  |   81|  35.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  35.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 35.2k]
  |  |  ------------------
  ------------------
  248|       |
  249|       |#if HAVE_ZIMG
  250|       |    if (allow_zimg(ctx)) {
  251|       |        ctx->zimg->log = ctx->log;
  252|       |        ctx->zimg->src = src;
  253|       |        ctx->zimg->dst = dst;
  254|       |        if (ctx->zimg_opts)
  255|       |            ctx->zimg->opts = *ctx->zimg_opts;
  256|       |        if (mp_zimg_config(ctx->zimg)) {
  257|       |            ctx->zimg_ok = true;
  258|       |            MP_VERBOSE(ctx, "Using zimg.\n");
  259|       |            goto success;
  260|       |        }
  261|       |        MP_WARN(ctx, "Not using zimg, falling back to swscale.\n");
  262|       |    }
  263|       |#endif
  264|       |
  265|  35.2k|    if (!allow_sws(ctx)) {
  ------------------
  |  Branch (265:9): [True: 0, False: 35.2k]
  ------------------
  266|      0|        MP_ERR(ctx, "No scaler.\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__)
  |  |  ------------------
  ------------------
  267|      0|        return -1;
  268|      0|    }
  269|       |
  270|  35.2k|    ctx->sws = sws_alloc_context();
  271|  35.2k|    if (!ctx->sws)
  ------------------
  |  Branch (271:9): [True: 0, False: 35.2k]
  ------------------
  272|      0|        return -1;
  273|       |
  274|  35.2k|    mp_image_params_guess_csp(&src); // sanitize colorspace/colorlevels
  275|  35.2k|    mp_image_params_guess_csp(&dst);
  276|       |
  277|  35.2k|    enum AVPixelFormat s_fmt = imgfmt2pixfmt(src.imgfmt);
  278|  35.2k|    if (s_fmt == AV_PIX_FMT_NONE || sws_isSupportedInput(s_fmt) < 1) {
  ------------------
  |  Branch (278:9): [True: 0, False: 35.2k]
  |  Branch (278:37): [True: 0, False: 35.2k]
  ------------------
  279|      0|        MP_ERR(ctx, "Input image format %s not supported by libswscale.\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__)
  |  |  ------------------
  ------------------
  280|      0|               mp_imgfmt_to_name(src.imgfmt));
  281|      0|        return -1;
  282|      0|    }
  283|       |
  284|  35.2k|    enum AVPixelFormat d_fmt = imgfmt2pixfmt(dst.imgfmt);
  285|  35.2k|    if (d_fmt == AV_PIX_FMT_NONE || sws_isSupportedOutput(d_fmt) < 1) {
  ------------------
  |  Branch (285:9): [True: 0, False: 35.2k]
  |  Branch (285:37): [True: 0, False: 35.2k]
  ------------------
  286|      0|        MP_ERR(ctx, "Output image format %s not supported by libswscale.\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__)
  |  |  ------------------
  ------------------
  287|      0|               mp_imgfmt_to_name(dst.imgfmt));
  288|      0|        return -1;
  289|      0|    }
  290|       |
  291|  35.2k|    int s_csp = pl_csp_to_sws_colorspace(src.repr.sys);
  292|  35.2k|    int s_range = src.repr.levels == PL_COLOR_LEVELS_FULL;
  293|       |
  294|  35.2k|    int d_csp = pl_csp_to_sws_colorspace(src.repr.sys);
  295|  35.2k|    int d_range = dst.repr.levels == PL_COLOR_LEVELS_FULL;
  296|       |
  297|  35.2k|    av_opt_set_int(ctx->sws, "sws_flags", ctx->flags, 0);
  298|       |
  299|  35.2k|    av_opt_set_int(ctx->sws, "srcw", src.w, 0);
  300|  35.2k|    av_opt_set_int(ctx->sws, "srch", src.h, 0);
  301|  35.2k|    av_opt_set_int(ctx->sws, "src_format", s_fmt, 0);
  302|       |
  303|  35.2k|    av_opt_set_int(ctx->sws, "dstw", dst.w, 0);
  304|  35.2k|    av_opt_set_int(ctx->sws, "dsth", dst.h, 0);
  305|  35.2k|    av_opt_set_int(ctx->sws, "dst_format", d_fmt, 0);
  306|       |
  307|  35.2k|    av_opt_set_double(ctx->sws, "param0", ctx->params[0], 0);
  308|  35.2k|    av_opt_set_double(ctx->sws, "param1", ctx->params[1], 0);
  309|       |
  310|  35.2k|    int cr_src = pl_chroma_to_av(src.chroma_location);
  311|  35.2k|    int cr_dst = pl_chroma_to_av(dst.chroma_location);
  312|  35.2k|    int cr_xpos, cr_ypos;
  313|  35.2k|    if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
  ------------------
  |  Branch (313:9): [True: 35.2k, False: 0]
  ------------------
  314|  35.2k|        av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
  315|  35.2k|        av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
  316|  35.2k|    }
  317|  35.2k|    if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_dst) >= 0) {
  ------------------
  |  Branch (317:9): [True: 35.2k, False: 0]
  ------------------
  318|  35.2k|        av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0);
  319|  35.2k|        av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0);
  320|  35.2k|    }
  321|       |
  322|       |    // This can fail even with normal operation, e.g. if a conversion path
  323|       |    // simply does not support these settings.
  324|  35.2k|    int r =
  325|  35.2k|        sws_setColorspaceDetails(ctx->sws, sws_getCoefficients(s_csp), s_range,
  326|  35.2k|                                 sws_getCoefficients(d_csp), d_range,
  327|  35.2k|                                 0, 1 << 16, 1 << 16);
  328|  35.2k|    ctx->supports_csp = r >= 0;
  329|       |
  330|  35.2k|    if (sws_init_context(ctx->sws, ctx->src_filter, ctx->dst_filter) < 0)
  ------------------
  |  Branch (330:9): [True: 219, False: 35.0k]
  ------------------
  331|    219|        return -1;
  332|       |
  333|       |#if HAVE_ZIMG
  334|       |success:
  335|       |#endif
  336|       |
  337|  35.0k|    ctx->force_reload = false;
  338|  35.0k|    *ctx->cached = *ctx;
  339|  35.0k|    return 1;
  340|  35.2k|}
mp_sws_scale:
  383|  35.2k|{
  384|  35.2k|    ctx->src = src->params;
  385|  35.2k|    ctx->dst = dst->params;
  386|       |
  387|  35.2k|    int r = mp_sws_reinit(ctx);
  388|  35.2k|    if (r < 0) {
  ------------------
  |  Branch (388:9): [True: 219, False: 35.0k]
  ------------------
  389|    219|        MP_ERR(ctx, "libswscale initialization failed.\n");
  ------------------
  |  |   89|    219|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    219|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  390|    219|        return r;
  391|    219|    }
  392|       |
  393|       |#if HAVE_ZIMG
  394|       |    if (ctx->zimg_ok)
  395|       |        return mp_zimg_convert(ctx->zimg, dst, src) ? 0 : -1;
  396|       |#endif
  397|       |
  398|  35.0k|    if (src->params.repr.sys == PL_COLOR_SYSTEM_XYZ && dst->params.repr.sys != PL_COLOR_SYSTEM_XYZ) {
  ------------------
  |  Branch (398:9): [True: 0, False: 35.0k]
  |  Branch (398:56): [True: 0, False: 0]
  ------------------
  399|       |        // swsscale has hardcoded gamma 2.2 internally and 2.6 for XYZ
  400|      0|        dst->params.color.transfer = PL_COLOR_TRC_GAMMA22;
  401|       |        // and sRGB primaries...
  402|      0|        dst->params.color.primaries = PL_COLOR_PRIM_BT_709;
  403|       |        // it doesn't adjust white point though, but it is not worth to support
  404|       |        // this case. It would require custom prim with equal energy white point
  405|       |        // and sRGB primaries.
  406|      0|    }
  407|       |
  408|  35.0k|    struct mp_image *a_src = check_alignment(ctx->log, &ctx->aligned_src, src);
  409|  35.0k|    struct mp_image *a_dst = check_alignment(ctx->log, &ctx->aligned_dst, dst);
  410|  35.0k|    if (!a_src || !a_dst) {
  ------------------
  |  Branch (410:9): [True: 0, False: 35.0k]
  |  Branch (410:19): [True: 0, False: 35.0k]
  ------------------
  411|      0|        MP_ERR(ctx, "image allocation 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__)
  |  |  ------------------
  ------------------
  412|      0|        return -1;
  413|      0|    }
  414|       |
  415|  35.0k|    if (a_src != src)
  ------------------
  |  Branch (415:9): [True: 35.0k, False: 4]
  ------------------
  416|  35.0k|        mp_image_copy(a_src, src);
  417|       |
  418|  35.0k|    sws_scale(ctx->sws, (const uint8_t *const *) a_src->planes, a_src->stride,
  419|  35.0k|              0, a_src->h, a_dst->planes, a_dst->stride);
  420|       |
  421|  35.0k|    if (a_dst != dst)
  ------------------
  |  Branch (421:9): [True: 0, False: 35.0k]
  ------------------
  422|      0|        mp_image_copy(dst, a_dst);
  423|       |
  424|  35.0k|    return 0;
  425|  35.0k|}
mp_img_swap_to_native:
  455|  38.5k|{
  456|  38.5k|    int avfmt = imgfmt2pixfmt(img->imgfmt);
  457|  38.5k|    int to = AV_PIX_FMT_NONE;
  458|   192k|    for (int n = 0; endian_swaps[n][0] != AV_PIX_FMT_NONE; n++) {
  ------------------
  |  Branch (458:21): [True: 154k, False: 38.5k]
  ------------------
  459|   154k|        if (endian_swaps[n][0] == avfmt)
  ------------------
  |  Branch (459:13): [True: 0, False: 154k]
  ------------------
  460|      0|            to = endian_swaps[n][1];
  461|   154k|    }
  462|  38.5k|    if (to == AV_PIX_FMT_NONE || !mp_image_make_writeable(img))
  ------------------
  |  Branch (462:9): [True: 38.5k, False: 0]
  |  Branch (462:34): [True: 0, False: 0]
  ------------------
  463|  38.5k|        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|  38.5k|}
sws_utils.c:allow_sws:
  138|  35.2k|{
  139|  35.2k|    return ctx->force_scaler == MP_SWS_SWS || ctx->force_scaler == MP_SWS_AUTO;
  ------------------
  |  Branch (139:12): [True: 0, False: 35.2k]
  |  Branch (139:47): [True: 35.2k, False: 0]
  ------------------
  140|  35.2k|}
sws_utils.c:free_mp_sws:
  179|  35.2k|{
  180|  35.2k|    struct mp_sws_context *ctx = p;
  181|  35.2k|    sws_freeContext(ctx->sws);
  182|  35.2k|    sws_freeFilter(ctx->src_filter);
  183|  35.2k|    sws_freeFilter(ctx->dst_filter);
  184|  35.2k|    TA_FREEP(&ctx->aligned_src);
  ------------------
  |  |   81|  35.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  35.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 35.2k]
  |  |  ------------------
  ------------------
  185|       |    TA_FREEP(&ctx->aligned_dst);
  ------------------
  |  |   81|  35.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  35.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 35.2k]
  |  |  ------------------
  ------------------
  186|  35.2k|}
sws_utils.c:mp_sws_update_from_cmdline:
  101|  70.4k|{
  102|  70.4k|    m_config_cache_update(ctx->opts_cache);
  103|  70.4k|    struct sws_opts *opts = ctx->opts_cache->opts;
  104|       |
  105|  70.4k|    sws_freeFilter(ctx->src_filter);
  106|  70.4k|    ctx->src_filter = sws_getDefaultFilter(opts->lum_gblur, opts->chr_gblur,
  107|  70.4k|                                           opts->lum_sharpen, opts->chr_sharpen,
  108|  70.4k|                                           opts->chr_hshift, opts->chr_vshift, 0);
  109|  70.4k|    ctx->force_reload = true;
  110|       |
  111|  70.4k|    ctx->flags = SWS_PRINT_INFO;
  112|  70.4k|    ctx->flags |= opts->scaler;
  113|  70.4k|    if (!opts->fast)
  ------------------
  |  Branch (113:9): [True: 70.4k, False: 0]
  ------------------
  114|  70.4k|        ctx->flags |= mp_sws_hq_flags;
  115|  70.4k|    if (opts->bitexact)
  ------------------
  |  Branch (115:9): [True: 202, False: 70.2k]
  ------------------
  116|    202|        ctx->flags |= SWS_BITEXACT;
  117|       |
  118|  70.4k|    ctx->allow_zimg = opts->zimg;
  119|  70.4k|}
sws_utils.c:cache_valid:
  166|  35.2k|{
  167|  35.2k|    struct mp_sws_context *old = ctx->cached;
  168|  35.2k|    if (ctx->force_reload)
  ------------------
  |  Branch (168:9): [True: 35.2k, False: 0]
  ------------------
  169|  35.2k|        return false;
  170|      0|    return mp_image_params_static_equal(&ctx->src, &old->src) &&
  ------------------
  |  Branch (170:12): [True: 0, False: 0]
  ------------------
  171|      0|           mp_image_params_static_equal(&ctx->dst, &old->dst) &&
  ------------------
  |  Branch (171:12): [True: 0, False: 0]
  ------------------
  172|      0|           ctx->flags == old->flags &&
  ------------------
  |  Branch (172:12): [True: 0, False: 0]
  ------------------
  173|      0|           ctx->allow_zimg == old->allow_zimg &&
  ------------------
  |  Branch (173:12): [True: 0, False: 0]
  ------------------
  174|      0|           ctx->force_scaler == old->force_scaler &&
  ------------------
  |  Branch (174:12): [True: 0, False: 0]
  ------------------
  175|      0|           (!ctx->opts_cache || !m_config_cache_update(ctx->opts_cache));
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  |  Branch (175:33): [True: 0, False: 0]
  ------------------
  176|  35.2k|}
sws_utils.c:pl_csp_to_sws_colorspace:
  159|  70.4k|{
  160|       |    // The SWS_CS_* macros are just convenience redefinitions of the
  161|       |    // AVCOL_SPC_* macros, inside swscale.h.
  162|  70.4k|    return pl_system_to_av(csp);
  163|  70.4k|}
sws_utils.c:check_alignment:
  345|  70.0k|{
  346|       |    // It's completely unclear which alignment libswscale wants (for performance)
  347|       |    // or requires (for avoiding crashes and memory corruption).
  348|       |    // Is it av_cpu_max_align()? Is it the hardcoded AVFrame "default" of 32
  349|       |    // in get_video_buffer()? Is it whatever avcodec_align_dimensions2()
  350|       |    // determines? It's like you can't win if you try to prevent libswscale from
  351|       |    // corrupting memory...
  352|       |    // So use 32, a value that has been experimentally determined to be safe,
  353|       |    // and which in most cases is not larger than decoder output. It is smaller
  354|       |    // or equal to what most image allocators in mpv/ffmpeg use.
  355|  70.0k|    size_t align = 32;
  356|  70.0k|    mp_assert(align <= MP_IMAGE_BYTE_ALIGN); // or mp_image_alloc will not cut it
  ------------------
  |  |   41|  70.0k|#define mp_assert assert
  ------------------
  |  Branch (356:5): [True: 70.0k, False: 0]
  ------------------
  357|       |
  358|  70.0k|    bool is_aligned = true;
  359|   212k|    for (int p = 0; p < img->num_planes; p++) {
  ------------------
  |  Branch (359:21): [True: 142k, False: 70.0k]
  ------------------
  360|   142k|        is_aligned &= MP_IS_ALIGNED((uintptr_t)img->planes[p], align);
  ------------------
  |  |   55|   142k|#define MP_IS_ALIGNED(x, align) (!((x) & ((align) - 1)))
  ------------------
  361|   142k|        is_aligned &= MP_IS_ALIGNED(labs(img->stride[p]), align);
  ------------------
  |  |   55|   142k|#define MP_IS_ALIGNED(x, align) (!((x) & ((align) - 1)))
  ------------------
  362|   142k|    }
  363|       |
  364|  70.0k|    if (is_aligned)
  ------------------
  |  Branch (364:9): [True: 35.0k, False: 35.0k]
  ------------------
  365|  35.0k|        return img;
  366|       |
  367|  35.0k|    if (!*alloc) {
  ------------------
  |  Branch (367:9): [True: 35.0k, False: 0]
  ------------------
  368|  35.0k|        mp_verbose(log, "unaligned libswscale parameter; using slow copy.\n");
  ------------------
  |  |   79|  35.0k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  369|  35.0k|        *alloc = mp_image_alloc(img->imgfmt, img->w, img->h);
  370|  35.0k|        if (!*alloc)
  ------------------
  |  Branch (370:13): [True: 0, False: 35.0k]
  ------------------
  371|      0|            return NULL;
  372|  35.0k|    }
  373|       |
  374|  35.0k|    mp_image_copy_attributes(*alloc, img);
  375|  35.0k|    return *alloc;
  376|  35.0k|}

